-
Notifications
You must be signed in to change notification settings - Fork 0
/
chessmodel.mli
93 lines (65 loc) · 2.79 KB
/
chessmodel.mli
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
open Chesstypes
(*
chessmodel.mli
chessmodel provides the primitive operations for
upating, modifying the current state of a game board.
Initializing pieces, making moves, etc. It has no
built-in knowledge of game rules. It tries to roughly
model a true, physical board.
*)
(*
returns a board with pieces arranged in standard
starting chess positions.
*)
val make_init_board: unit -> board
(*
returns a board where every square is empty analogous to a
physical chess board with no pieces on it.
*)
val make_empty_board: unit -> board
(*
executes a move and returns a board option.
the returned board will represent the updated state
of the board after the move was executed. moves correspond to
physical moves, not moves that are checked against chess rules.
if move is invalid, returns None.
*)
val execute_move: move -> board -> board option
(* returns the ((src_x,src_y),(dest_x,dest_y)) of a move *)
val coords_of_move: move -> (int*int)*(int*int)
val get_int_of_letter: string -> int
val get_nth_letter: int -> string
val get_square_on_board: boardpos -> board -> square ref
(* will throw exception if piece not at position *)
val get_piece: board -> boardpos -> piece
(* returns the boardpos for the given piece; if piece not found, return None *)
val find_piece_pos: piece -> board -> boardpos option
(* returns all pieces, of any team, currently on given board *)
val all_board_pieces: board -> piece list
(* given a team and a board, return a list of all pieces belonging to that team currently present on board *)
val all_team_pieces: board -> team -> piece list
(* converts a boardpos into integer x,y board coordinates *)
val boardpos_to_coords: boardpos -> (int*int)
(* converts integer x,y coordinates into boardpos format*)
val coords_to_boardpos: (int*int) -> boardpos
(* creates a new piece from given attributes *)
val create_piece: string -> team -> string -> piecekind -> piece
(* creates a new piece from given attributes and places it on board at given position *)
val add_piece_to_board: board -> boardpos -> string -> team -> string -> piecekind -> unit
(*
takes a board position and inverts each of its coordinates, so as to view
the coordinate from the opponent's viewpoint e.g. invert_board_pos ("2","b") = ("7","g")
*)
val invert_boardpos: boardpos -> boardpos
(*
takes a board and reflects its coordinate labels horizontally and vertically
physically, this would correspond to spinning the board around and viewing it from
your opponent's perspective
*)
val reflect_board_coords: board -> board
val get_all_pieces: team-> board-> piece list
val get_piece: board -> boardpos -> piece
(* returns a board with same data but fresh references to each square *)
val copy_board: board -> board
val put_piece_at_boardpos: piece option -> boardpos -> board -> unit
val display: board-> unit