aboutsummaryrefslogtreecommitdiff
path: root/judge
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2014-11-15 22:36:31 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2014-11-15 22:36:31 +0100
commit0e83991e3f8739ec00d744f038fdfaea2b60c98e (patch)
tree5f2dab2a4ef5afd77fbc9372f57b7c7b063b4497 /judge
parent6881ee7acb98c902c312301d7990331e4a1ed854 (diff)
downloadCompetIA-0e83991e3f8739ec00d744f038fdfaea2b60c98e.tar.gz
CompetIA-0e83991e3f8739ec00d744f038fdfaea2b60c98e.zip
Nothing big...
Diffstat (limited to 'judge')
-rw-r--r--judge/morpion_rec.ml4
-rw-r--r--judge/player.ml38
2 files changed, 22 insertions, 20 deletions
diff --git a/judge/morpion_rec.ml b/judge/morpion_rec.ml
index cb23821..a46b7f9 100644
--- a/judge/morpion_rec.ml
+++ b/judge/morpion_rec.ml
@@ -90,9 +90,11 @@ module G = struct
alors même si l'adversaire aligne trois cases dedans APRES,
le petit morpion reste attribué à la même personne. *)
+ let setp1p (m, r) (px, py) v =
+ setp1 (m, r) (px, py) v (fun x -> x)
(* setp : 'a morpion morpion -> loc2 -> 'a -> 'a morpion morpion *)
let setp m (pg, pp) v =
- let im = setp1 (getp1 m pg) pp v (fun x -> x) in
+ let im = setp1p (getp1 m pg) pp v in
let om = setp1 m pg im reduct in
om
diff --git a/judge/player.ml b/judge/player.ml
index 8f74fe7..1d89fe8 100644
--- a/judge/player.ml
+++ b/judge/player.ml
@@ -4,10 +4,26 @@ module type IA = sig
module G : GAME
- val play : G.game -> string
+ val play : G.game -> float -> string
end
+let expect mgs =
+ let l = read_line () in
+ begin try
+ let (s, f) = List.find
+ (fun (s, _) ->
+ String.length l >= String.length s
+ && String.sub l 0 (String.length s) = s)
+ mgs
+ in f (String.sub l (String.length s)
+ (String.length l - String.length s))
+ with
+ Not_found ->
+ Format.eprintf "Unexpected '%s'.@." l;
+ exit 1
+ end
+
module P (W : IA) : sig
val run : unit -> unit
@@ -16,30 +32,14 @@ end = struct
module G = W.G
- let expect mgs =
- let l = read_line () in
- begin try
- let (s, f) = List.find
- (fun (s, _) ->
- String.length l >= String.length s
- && String.sub l 0 (String.length s) = s)
- mgs
- in f (String.sub l (String.length s)
- (String.length l - String.length s))
- with
- Not_found ->
- Format.eprintf "Unexpected '%s'.@." l;
- exit 1
- end
-
let finished _ =
print_string "Fair enough\n"
let rec turn g _ =
expect [
"Your turn",
- (fun _ ->
- let act = W.play g in
+ (fun time ->
+ let act = W.play g (float_of_string time) in
Format.printf "Play %s@." act;
let g' = G.play g act in
expect [ "OK", turn g' ]);