diff options
Diffstat (limited to 'morpion_rec/AmaneSuzuha')
-rw-r--r-- | morpion_rec/AmaneSuzuha/amane.ml | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/morpion_rec/AmaneSuzuha/amane.ml b/morpion_rec/AmaneSuzuha/amane.ml index f96859b..7ac321f 100644 --- a/morpion_rec/AmaneSuzuha/amane.ml +++ b/morpion_rec/AmaneSuzuha/amane.ml @@ -20,17 +20,20 @@ module Amane : Player.IA = struct | [], other -> let o' = List.filter (fun act -> - let g' = G.play g act in - let adv_win = - G.possibilities g' - |> List.map (G.play g') - |> List.exists won_game - in not adv_win) + try + let g' = G.play g act in + let adv_win = + G.possibilities g' + |> List.map (G.play g') + |> List.exists won_game + in not adv_win + with _ -> true) other - in match o', other with - | x::_, _ -> x - | _, a::_ -> a - | _ -> assert false + in + if List.length o' > 0 then + take_random o' + else + take_random other end |