diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2022-12-09 00:08:46 -0800 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2022-12-09 00:08:46 -0800 |
| commit | 00458d7b95022e1daa604a59d236678ac33b3154 (patch) | |
| tree | 3eba12a695c5fd33f6f6852107ecdc06185f5b35 /chesshelpers.c | |
| parent | 972363ca92691f289d32ac5cc787aa1b354da234 (diff) | |
added: castling moves rook. found workaround using make_move function. introduced castling related bug, unknown cause
Diffstat (limited to 'chesshelpers.c')
| -rw-r--r-- | chesshelpers.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/chesshelpers.c b/chesshelpers.c index d0464fb..2e046c9 100644 --- a/chesshelpers.c +++ b/chesshelpers.c @@ -23,6 +23,13 @@ board_t make_move(board_t board, vector_t origin, vector_t end) { if(piece == king) { board.whiteCanCastleQueenside = 0; board.whiteCanCastleKingside = 0; + //if the king moved farther than it normally could, move must have been castling. move the rook as well + if(origin.mx == 4 && end.mx == 6) { + board = make_move(board, init_vector(7, 7), init_vector(5, 7)); + } + else if(origin.mx == 4 && end.mx == 2) { + board = make_move(board, init_vector(0, 7), init_vector(3, 7)); + } } //white kingside rook moved else if(origin.mx == 7 && origin.my == 7) { @@ -36,6 +43,13 @@ board_t make_move(board_t board, vector_t origin, vector_t end) { else if(piece == king + 6) { board.blackCanCastleQueenside = 0; board.blackCanCastleKingside = 0; + //if the king moved farther than it normally could, move must have been castling. move the rook as well + if(origin.mx == 4 && end.mx == 6) { + board = make_move(board, init_vector(7, 0), init_vector(5, 0)); + } + else if(origin.mx == 4 && end.mx == 2) { + board = make_move(board, init_vector(0, 0), init_vector(3, 0)); + } } //black kingside rook moved else if(origin.mx == 7 && origin.my == 0) { |
