aboutsummaryrefslogtreecommitdiffstats
path: root/ltg.ml
blob: d3b7473464a8253e3aa706e81f3fec53546e2695 (plain)
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
open Game

let _ = if Array.length Sys.argv < 2 then begin
    Printf.printf "You must specify the player number\n";
    exit 1
end

let me = int_of_string Sys.argv.(1)

let opponent = match me with
    | 0 -> 1
    | 1 -> 0
    | _ -> failwith "Wrong player_number"

let read_move () = Scanf.scanf "%d\n" (fun d -> match d with
    | 1 -> Scanf.scanf "%s\n%d\n" (fun s d ->
        Game.left_apply opponent (card_of_string s) d)
    | 2 -> Scanf.scanf "%d\n%s\n" (fun d s ->
        Game.right_apply opponent (card_of_string s) d)
    | _ -> failwith "Wrong move number"
)

let play_move () = ()

let do_round =
    if me = 0
    then fun () -> play_move (); read_move ()
    else fun () -> read_move (); play_move ()
              
                
let _ =
    let round = ref 1 in
    while !round <= 100000 do
        Printf.printf "Round %d\n========" !round;
        print_newline ();
        do_round ();
        incr round
    done