From 00458d7b95022e1daa604a59d236678ac33b3154 Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Fri, 9 Dec 2022 00:08:46 -0800 Subject: added: castling moves rook. found workaround using make_move function. introduced castling related bug, unknown cause --- chess.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'chess.c') diff --git a/chess.c b/chess.c index 1e2fe5f..0671430 100644 --- a/chess.c +++ b/chess.c @@ -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); } } } -- cgit v1.3.1