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 | |
parent | 98611e2e9d5a9a4a98d755f76f9e182a0226de3e (diff) | |
download | c-chess-851cb160f0d2838c75af43dcc7b6fad9969d925c.tar.gz |
feat: add castle to generate moves
-rw-r--r-- | src/config.h | 4 | ||||
-rw-r--r-- | src/main.c | 21 |
2 files changed, 22 insertions, 3 deletions
diff --git a/src/config.h b/src/config.h index f994cee..0b54698 100644 --- a/src/config.h +++ b/src/config.h @@ -5,6 +5,6 @@ #define INFINITY 2000 #define MAX_ZOBRIST_SEEDS 1500 #define TRANSPOSITION_TABLE_SIZE 1000000 -#define PLAYER 3 +#define PLAYER WHITE #define FILENAME "record.txt" -#define MOVE_TIME 15 +#define MOVE_TIME 10 @@ -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() { |