aboutsummaryrefslogtreecommitdiff
path: root/judge/dummy_player.ml
diff options
context:
space:
mode:
Diffstat (limited to 'judge/dummy_player.ml')
-rw-r--r--judge/dummy_player.ml49
1 files changed, 11 insertions, 38 deletions
diff --git a/judge/dummy_player.ml b/judge/dummy_player.ml
index 44a24ce..1897442 100644
--- a/judge/dummy_player.ml
+++ b/judge/dummy_player.ml
@@ -1,7 +1,6 @@
-
let words = [|
- "banane"; "hippopotame"; "povrion";
+ "banane"; "hippopotame"; "poivron";
"pourquoi???"; "un ange passe"; "television";
"ceci n'est pas..."; "environ 12"; "septante";
"Philipp Glass"; "nyaaa"; "tu crois ?"; "hallo";
@@ -19,44 +18,18 @@ let words = [|
"j'ai une grosse courgette"; "bouilloire"; "morning coffee";
|]
-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 Dummy_IA : Player.IA = struct
+
+ module G = Dummy_game.G
+
+ let play _ =
+ if Random.int 2 = 0 then Unix.sleep 1;
+ words.(Random.int (Array.length words))
-let finished _ =
- print_string "Fair enough\n"
+end
-let rec turn _ =
- expect [
- "Your turn",
- (fun _ ->
- if Random.int 2 = 0 then Unix.sleep 1;
- Format.printf "Play %s@."
- words.(Random.int (Array.length words));
- expect [ "OK", turn ]);
- "Play ", turn;
- "Tie", finished;
- "You win", finished;
- "You lose", finished;
- "Eliminated", finished
- ]
+module Dummy = Player.P(Dummy_IA)
let () =
Random.self_init ();
- expect [
- "Hello dummy_game",
- (fun _ -> print_string "Hello dummy_game\n";
- turn "")
- ];
+ Dummy.run()