aboutsummaryrefslogtreecommitdiff
path: root/judge/dummy_game.ml
blob: 869513a9cea156d02327a2c410dacb5c6b865f74 (plain) (blame)
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
open Core
open Main

module Dummy : GAME = struct

  type game = player * int

  let new_game = (P1, 10), TurnOf P1

  let turn (p0, g) p _ =
    if p <> p0 || g <= 0 then
      (p0, g), Eliminated p
    else
      let op = other_player p in
      (op, g-1), (
        if g - 1 = 0 then
          if Random.int 100 = 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 id = "dummy_game"
  let name = "Dumm game for testing purposes"

end

module C = Core(Dummy)
module Main = Juge(C)

let () =
  Random.self_init ();
  Main.run ()