aboutsummaryrefslogtreecommitdiff
path: root/judge
diff options
context:
space:
mode:
authorAlex AUVOLAT <alex.auvolat@ens.fr>2014-11-10 19:58:46 +0100
committerAlex AUVOLAT <alex.auvolat@ens.fr>2014-11-10 19:58:46 +0100
commit78383da1e33ce2ee7e330cc6ffbcaa20d91c3600 (patch)
tree88860e6692a51b434b9522903f9331cea927f1c1 /judge
parente40508aa7f25247443b2ff8ebb6637b36608b8dc (diff)
downloadCompetIA-78383da1e33ce2ee7e330cc6ffbcaa20d91c3600.tar.gz
CompetIA-78383da1e33ce2ee7e330cc6ffbcaa20d91c3600.zip
Refactor pgo calculation.
Diffstat (limited to 'judge')
-rw-r--r--judge/morpion_rec.ml9
1 files changed, 3 insertions, 6 deletions
diff --git a/judge/morpion_rec.ml b/judge/morpion_rec.ml
index c7ca480..cb23821 100644
--- a/judge/morpion_rec.ml
+++ b/judge/morpion_rec.ml
@@ -111,11 +111,10 @@ module G = struct
let full_pm m =
List.for_all (fun p -> getp1 m p <> Empty) all_p1
-
let possibilities (s, m, lg) =
let pg_poss = match lg with
| None -> all_p1
- | Some x -> if full_pm (getp1 m x) then all_p1 else [x]
+ | Some x -> [x]
in
List.flatten
(List.map (fun pg ->
@@ -132,9 +131,7 @@ module G = struct
| TurnOf player when
(match pgo with
| None -> true
- | Some x when full_pm (getp1 m x) -> true
- | Some x when pg = x -> true
- | _ -> false)
+ | Some x -> pg = x)
&& getp m (pg, pp) = Empty
->
let op = other_player player in
@@ -145,7 +142,7 @@ module G = struct
| O -> Won P2
| T -> Tie
in
- (new_s, new_m, Some pp)
+ (new_s, new_m, if full_pm (getp1 new_m pp) then None else Some pp)
| TurnOf x -> (Eliminated x, m, pgo)
| _ -> raise (Eliminated_ex "not someone's turn!")