-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTODO
More file actions
140 lines (93 loc) · 6.88 KB
/
Copy pathTODO
File metadata and controls
140 lines (93 loc) · 6.88 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
In Progress:
MOVING TO TRELLO: https://trello.com/b/e66aa8LL/work
Update MovePiece() logic to allow [source_square][destination_square] format for all pieces (string size 4).
UCI Protocol:
Examples
e2e4
e7e5
e1g1 (white short castling): note that e1g1 doesn't have to be castles. Only call CastleKingside() if white King is on e1.
e7e8q (for promotion): can deal with later
Add in PGN file reading now for easier testing
Create a LoadPosition() function that takes an int move with the move number and goes back to it. All private variables in Board() are loaded back to the state at that position. DONE
Update LoadPosition() with a bool (in Board class) that tracks if position is not on latest move. If so, LoadCurrentPosition() before making a move. DONE
Add a counter for the 50-move rule for all non-pawn moves. DONE
Add a three-move repetition checker. DONE
Create a TakeBack() and a TakeBack(int move) function that takes back either one move, or the specified number of moves. DONE
To do after updating PGN reading to include 'x' and multiple possible pieces to same square:
Simplify MovePawn() to have both black and white to remove redundancies. Use int promotion_rank (0 or 7), starting_rank (1 or 6),
color_multiplier (1 if white, -1 if black for moving forward/backward).
color_multiplier*8 for pawn moving forward 1 square
color_multiplier*16 for pawn moving forward 2 squares
color_multiplier*7 and color_multiplier * 9 for pawn captures
Add pawn promotions DONE
Add storage of all previous board states using vector DONE
Add en passant: need to store the previous move, with true/false if pawn moved two squares. If square where pawn captures is blank, but
an "x" is given in the PGN notation, check if en passant is available. DONE
Add checkmate and stalemate rules
Add function that sets up board according to an FEN string, which is an optional part of a PGN file.
Testing:
Make sure all rules for castling are properly implemented
Bugs:
BUG: if final character of string is not int, example: "be7\", will abort. check for this before std::stoi. First add function to make sure all characters of user input are valid characters.
BUG: KingNotInCheckAfterMove() for en passant? maybe overload the function
Fixed bugs:
BUG: e4 f5 ef5 g6 fg6 h5 g7 nh6 "Another knight found"FIXED: wrap-around for rows not accounted for (ex: 15+10 wraps around from h-file to b-file)
BUG: After e4 e5 nf3 nf6 bc4 bc5 rg1, the a-rook moves to g1 instead of the h-rook. FIXED
BUG: check that all str.substr() are working. Note that second argument is string LENGTH, not the upper index
Cleaning up code:
List vs vector for storing Positions
Store Position as a class? So can have operator= for 3-move repetition checking
In IsThreeMoveRepetition(), only need to check board_ and white_move instead of every bool if fifty_move_counter_ is being properly updated
Turn the 6 bools for castling into 4: white_can_kingside_castle, white_can_queenside_castle, black_can_kingside_castle, black_can_queenside_castle
Turn color_multiplier if/else into one line using ternary operator
Remove redundancies: could move similar code from individual MovePiece() functions back into move? for example, col_specified, row_specified, and square_specified code is the same
IsCapturable() is addressed in IsLegalSquare(). Call it in there, and edit other code as necessary. May not have to check if capturable because IsLegalSquare() has already been called, so delete redundancies.
Call AddPiece() in constructor. Overload it to take an argument bool white_move.
Complete:
Add pawn captures DONE
BUG: e4 f5 exf5 g6 fxg6 hxg6 the white h-pawn is missing, and black doesn't capture. FIXED: forgot color_multiplier for piece_map[pawn]
Added last_moved_pawn for en passant. ALWAYS set this to nullptr after every move unless the move was a pawn moving 2 squares.
Add castling, making sure that king is never in check
->add booleans tracking if kings and rooks have moved already
Update white_in_check_ or and black_in_check_ booleans before each move DONE
Update InCheck() diagonals so it stops at edge of board. Example:
12->19->26->33->40 reaches the a-file, but keeps going currently because less than 63. DONE
Create new function KingNotInCheckAfterMove that updates piece positions in a copy DONE
board and makes sure the king is not in check afterwards DONE
Make sure king is not in check after piece moves DONE
Make sure that if king is currently in check, the move stops the check DONE
Handle multiple pieces moving, using standard PGN notation.
Allow 'x' to be inputted. Note: For easier user input, capturing can be done without typing an 'x', and INPUT will not be case-sensitive. However, there will be an error if 'x' is inputted but no capture is done. (Look at destination square to see if capturable piece is there)
Note: PGN notation uses capital O instead of 0 for castling. DONE
Moving:
e8=Q+
e8=Q#
dxe8=Q
Minimum size for pawn promotion: 4.
If ends with check/checkmate, ignore and get substring of the rest. TODO after: Similar to KingNotInCheckAfterMove(), add a function that makes sure resulting position matches with check/checkmate as specified in the input.
Then check if castles.
Then, if ends with a piece char 'Q', 'R', 'B', 'N', check if the one before is an '='. If so, call a separate PawnPromote() function. Note: captures are possible with pawn promotion.
Otherwise, possible combinations:
Note: for easier input, if "Nge2" is inputted but just inputting "Ne2" is possible, play it anyways.
N e2
N g e2
N 1 e2
N g1 e2
N g x e2
N 1 x e2
N g1 x e2
So first check legal square.
If an 'x' is before the square, make sure a capturable piece is on there, otherwise return false. Remove the 'x' from the string. DONE
Then, go to specific piece move() function. Check if pawn: first character must be from 'a' through 'h'. Handle captures in the pawnmove() function, e.g. "ed4".
MovePawn(): first, size must be 2 or 3. If size == 2, use existing code. If size == 3, calculate the possible squares for a pawn to be. If the destination square is empty, check for en passant (pawn is next to other pawn, previous move was pawn moving there). Otherwise, check the square where pawn would be to capture.
For pieces:
ADD: for size 2 or 3, make sure only one possible valid move (taking into account illegal moves that walk into check).
If string size is 2, move like normal.
Two helper functions to confirm that a piece is on specified row/file:
If string size is 3, 2 cases: rank (row) or file (col) specified.
NOTE: user input will be between 1 to 8, but many functions will take 0 to 7 as arguments.
If string size is 4, square specified.
>If rank specified, iterate through pieces and only process if square/8 == rank.
>If file specified, iterate through pieces and only process if square%8 == rank.
If string size is 4: 2 squares specified. Iterate through pieces and only process if piece's square == the first square specified.
>Note: not possible for Rook to have 2 squares specified.