From 4b900a9624cef9c28d556f2852f27720602a7c99 Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Sun, 9 Nov 2014 22:59:41 +0100 Subject: Add display functions... --- judge/core.ml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'judge/core.ml') diff --git a/judge/core.ml b/judge/core.ml index 8b437d3..0f665c2 100644 --- a/judge/core.ml +++ b/judge/core.ml @@ -24,11 +24,14 @@ module type GAME = sig type game (* immutable structure *) val name : string (* ex: Morpion récursif *) - val id : string (* ex: morpion_rec *) + val id : string (* ex: morpion_rec *) - val new_game : game * game_status + val new_game : game - val turn : game -> player -> string -> (game * game_status) + val turn : game -> player -> string -> game + val s : game -> game_status + + val display_game : game -> (string * string) -> unit end module type CORE = sig @@ -237,8 +240,8 @@ module Core (G: GAME) : CORE = struct in let p1 = open_c (Hashtbl.find players p1) in let p2 = open_c (Hashtbl.find players p2) in - let g, s = G.new_game in - let g = { p1; p2; hist = [g]; s } in + let g = G.new_game in + let g = { p1; p2; hist = [g]; s = G.s g } in r_games := g::(!r_games) in let can_launch, cannot_launch = List.partition @@ -284,7 +287,8 @@ module Core (G: GAME) : CORE = struct p.s <- StandBy !game_time; | Play act, Thinking (time, beg_r) -> let end_r = Unix.gettimeofday () in - let new_g, new_s = G.turn (List.hd g.hist) pi act in + let new_g = G.turn (List.hd g.hist) pi act in + let new_s = G.s new_g in send_m p OK; send_m op (Play act); g.s <- new_s; -- cgit v1.2.3