aboutsummaryrefslogtreecommitdiff
path: root/judge/dummy_game.ml
diff options
context:
space:
mode:
Diffstat (limited to 'judge/dummy_game.ml')
-rw-r--r--judge/dummy_game.ml32
1 files changed, 26 insertions, 6 deletions
diff --git a/judge/dummy_game.ml b/judge/dummy_game.ml
index 0fac26b..c5be248 100644
--- a/judge/dummy_game.ml
+++ b/judge/dummy_game.ml
@@ -3,16 +3,16 @@ open Main
module Dummy : GAME = struct
- type game = player * int
+ type game = int * (player * string) list * game_status
- let new_game = (P1, 10), TurnOf P1
+ let new_game = (10, [], TurnOf P1)
- let turn (p0, g) p _ =
- if p <> p0 || g <= 0 then
- (p0, g), Eliminated p
+ let turn (g, l, s0) p xx =
+ if s0 <> TurnOf p || g <= 0 then
+ (g, l, Eliminated p)
else
let op = other_player p in
- (op, g-1), (
+ (g-1, l@[p, xx],
if g - 1 = 0 then
if Random.int 100 = 0 then Eliminated p
else if Random.int 2 = 0 then Won p
@@ -22,6 +22,26 @@ module Dummy : GAME = struct
TurnOf op
)
+ let s (_, _, s) = s
+
+ let display_game (cr, cs, t) (p1n, p2n) =
+ let open Graphics in
+ let open G_util in
+ let pt = function P1 -> p1n | P2 -> p2n in
+ List.iteri
+ (fun i (p, x) ->
+ text2 (i+4) black (string_of_int i);
+ text3 (i+4) (pc p) x)
+ cs;
+ text2 (List.length cs + 4) black ("... " ^ string_of_int cr);
+ let c, t = match t with
+ | TurnOf x -> pc x, "... " ^ pt x
+ | Won x -> pc x, pt x ^ " WON"
+ | Tie -> black, "TIE"
+ | Eliminated x -> pc x, pt x ^ " ELIM"
+ in
+ text3 (List.length cs + 4) c t
+
let id = "dummy_game"
let name = "Dummy game for testing purposes"