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 /chess.c | |
| parent | 972363ca92691f289d32ac5cc787aa1b354da234 (diff) | |
added: castling moves rook. found workaround using make_move function. introduced castling related bug, unknown cause
Diffstat (limited to 'chess.c')
| -rw-r--r-- | chess.c | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -378,20 +378,17 @@ vectorp_t get_king_moves(board_t board, vector_t position, int color) { //check that the squares are free vector_t s1 = init_vector(3, color == 0 ? 7 : 0); vector_t s2 = init_vector(2, color == 0 ? 7 : 0); - vector_t s3 = init_vector(1, color == 0 ? 7 : 0); - if(is_empty(board, s1) && is_empty(board, s2) && is_empty(board, s3)) { + if(is_empty(board, s1) && is_empty(board, s2)) { //check that the squares are not threatened board_t tempBoard1 = make_move(clone_board(board), position, s1); board_t tempBoard2 = make_move(clone_board(board), position, s2); - board_t tempBoard3 = make_move(clone_board(board), position, s3); - if(!is_in_check(tempBoard1, color) && !is_in_check(tempBoard2, color) && !is_in_check(tempBoard3, color)) { + if(!is_in_check(tempBoard1, color) && !is_in_check(tempBoard2, color)) { //add the move - moves[moveCount] = s3; + moves[moveCount] = s2; moveCount++; } free(tempBoard1.pieces); free(tempBoard2.pieces); - free(tempBoard3.pieces); } } } |
