diff options
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); } } } |
