summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 13013f8..4327b2e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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() {