From bcb124d26b40bd70fc22af49e4b7c994b37ee184 Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Mon, 10 Nov 2014 12:24:46 +0100 Subject: Improved handling of the dead ; correct bug in Amane. --- morpion_rec/AmaneSuzuha/amane.ml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'morpion_rec') 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 -- cgit v1.2.3