diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-09-08 17:48:03 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-09-08 17:48:03 +0300 |
commit | 851cb160f0d2838c75af43dcc7b6fad9969d925c (patch) | |
tree | b0095283f9d5d61ece57002453accbbc3db02559 /src/main.c | |
parent | 98611e2e9d5a9a4a98d755f76f9e182a0226de3e (diff) | |
download | c-chess-851cb160f0d2838c75af43dcc7b6fad9969d925c.tar.gz |
feat: add castle to generate moves
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -546,6 +546,25 @@ int generate_pseudolegal_moves(Move* moves, int* board, int color) { moves_count++; } } + + // Castling + if (piece == (KING | WHITE) && origin == 4) { + if (board[1] == EMPTY && board[2] == EMPTY && board[3] == EMPTY && board[0] == (ROOK | WHITE)) { + if (moves) moves[moves_count] = (Move){ origin, origin - 2, 0 }; + moves_count++; + } if (board[5] == EMPTY && board[6] == EMPTY && board[7] == (ROOK | WHITE)) { + if (moves) moves[moves_count] = (Move){ origin, origin + 2, 0 }; + moves_count++; + } + } else if (piece == (KING | BLACK) && origin == 116) { + if (board[113] == EMPTY && board[114] == EMPTY && board[115] == EMPTY && board[112] == (ROOK | BLACK)) { + if (moves) moves[moves_count] = (Move){ origin, origin - 2, 0 }; + moves_count++; + } if (board[117] == EMPTY && board[118] == EMPTY && board[119] == (ROOK | BLACK)) { + if (moves) moves[moves_count] = (Move){ origin, origin + 2, 0 }; + moves_count++; + } + } } } } @@ -747,7 +766,7 @@ Move iterative_deepening(int* board, int color, long hash, Transposition* transp } printf("Max depth (%i) reached in %.2f seconds\n", MAX_DEPTH, (double)(clock() - start) / CLOCKS_PER_SEC); - return best_move; + return move; } int main() { |