-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ml
34 lines (32 loc) · 1.03 KB
/
main.ml
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
let start_game () =
let rec loop () =
print_endline "Start a new game? Y or N";
let resp = read_line () in
if resp = "Y" || resp = "y" then true
else if resp = "N" || resp = "n" then false
else loop ()
in
loop ()
let main () =
let rec start () =
if start_game () then
let game = Game.create () in
let player = Game.get_player game Game.Player1 in
begin
let rec loop b p =
match b with
| [] -> start ()
| _ -> begin
Board.display b;
Game.display p;
let coord = Parse.parse b in
loop (Board.resolve (Board.resolve_grid (Board.place b p coord) coord p) p) (Game.next game p)
end
in
loop (Board.create ()) player
end
else print_endline "Goodbye!"
in
start ()
(* Application entry point *)
let () = main ()