diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-11-10 10:46:37 +0100 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-11-10 10:46:37 +0100 |
commit | 80e625a9c8d33c71fe69a375c211868fcc1938a5 (patch) | |
tree | f516d701cc8cb50e9a1d003afe6e7d1f05b457ca /judge/dummy_player.ml | |
parent | d343fcb803e955504b0d6b5c9c852620886c2994 (diff) | |
download | CompetIA-80e625a9c8d33c71fe69a375c211868fcc1938a5.tar.gz CompetIA-80e625a9c8d33c71fe69a375c211868fcc1938a5.zip |
Start work on players!
Diffstat (limited to 'judge/dummy_player.ml')
-rw-r--r-- | judge/dummy_player.ml | 49 |
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() |