aboutsummaryrefslogtreecommitdiff
path: root/src/moves.cpp
diff options
context:
space:
mode:
authorAdam <adammegarules1@gmail.com>2026-08-01 13:44:57 +0200
committerAdam <adammegarules1@gmail.com>2026-08-01 13:44:57 +0200
commitf56178ec9afdd89b85fc0284bddefa5b3f9515d1 (patch)
tree3cb637768272e89bbc4d0dec31e5eb818c2ce868 /src/moves.cpp
parent980ac2bc1ccbe1b8bde626a964464bb018baa466 (diff)
none
Diffstat (limited to 'src/moves.cpp')
-rw-r--r--src/moves.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/moves.cpp b/src/moves.cpp
index 163bb8c..803538b 100644
--- a/src/moves.cpp
+++ b/src/moves.cpp
@@ -417,6 +417,13 @@ void GenerateCastlingMoves(int from, Game *g, std::vector<Move> &moves) {
bool oneToLeft = g->PieceBitboard & (1ULL << (from - 1));
bool twoToLeft = g->PieceBitboard & (1ULL << (from - 2));
bool threeToLeft = g->PieceBitboard & (1ULL << (from - 3));
+
+ Position kingPosition = FindKing(g, g->turn);
+
+ bool check = IsSquareAttacked(g, kingPosition, !g->turn);
+ if (check) {
+ return;
+ }
if (g->turn) {
// white
if (!oneToRight && !twoToRight && g->whiteCastleKing) {