aboutsummaryrefslogblamecommitdiff
path: root/judge/dummy_game.ml
blob: 869513a9cea156d02327a2c410dacb5c6b865f74 (plain) (tree)


































                                                 
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 ()