aboutsummaryrefslogtreecommitdiff
path: root/morpion_rec/AmaneSuzuha/amane.ml
diff options
context:
space:
mode:
authorAlex AUVOLAT <alex.auvolat@ens.fr>2014-11-10 12:24:46 +0100
committerAlex AUVOLAT <alex.auvolat@ens.fr>2014-11-10 12:24:46 +0100
commitbcb124d26b40bd70fc22af49e4b7c994b37ee184 (patch)
treea730e69f37e79128d5795ca59d33595dc8811565 /morpion_rec/AmaneSuzuha/amane.ml
parent053f2090ebccd14f875b806c578e0f5467d68f5a (diff)
downloadCompetIA-bcb124d26b40bd70fc22af49e4b7c994b37ee184.tar.gz
CompetIA-bcb124d26b40bd70fc22af49e4b7c994b37ee184.zip
Improved handling of the dead ; correct bug in Amane.
Diffstat (limited to 'morpion_rec/AmaneSuzuha/amane.ml')
-rw-r--r--morpion_rec/AmaneSuzuha/amane.ml23
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