1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
open Core
open Main
module Dummy : GAME = struct
type game = int * (player * string) list * game_status
let new_game = (10, [], TurnOf P1)
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
(g-1, l@[p, xx],
if g - 1 = 0 then
if Random.int 10 = 0 then Eliminated p
else if Random.int 2 = 0 then Won p
else if Random.int 2 = 0 then Won op
else Tie
else
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"
end
module C = Core(Dummy)
module Main = Juge(C)
let () =
Random.self_init ();
Main.run ()
|