aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/moves.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/moves.cpp b/src/moves.cpp
index 2f60e13..6321c77 100644
--- a/src/moves.cpp
+++ b/src/moves.cpp
@@ -431,26 +431,32 @@ void GenerateCastlingMoves(int from, Game *g, std::vector<Move> &moves) {
};
if (g->turn) {
// white
- if (!oneToRight && !twoToRight && g->whiteCastleKing && pathIsSafe(1)) {
- moves.push_back(
- {.From = IndexToPosition(from), .To = IndexToPosition(from + 2)});
+ if (!oneToRight && !twoToRight && g->whiteCastleKing) {
+ if (pathIsSafe(1)) {
+ moves.push_back(
+ {.From = IndexToPosition(from), .To = IndexToPosition(from + 2)});
+ }
}
- if (!oneToLeft && !twoToLeft && !threeToLeft && g->whiteCastleQueen &&
- pathIsSafe(-1)) {
- moves.push_back(
- {.From = IndexToPosition(from), .To = IndexToPosition(from - 2)});
+ if (!oneToLeft && !twoToLeft && !threeToLeft && g->whiteCastleQueen) {
+ if (pathIsSafe(-1)) {
+ moves.push_back(
+ {.From = IndexToPosition(from), .To = IndexToPosition(from - 2)});
+ }
}
}
if (!g->turn) {
// black
- if (!oneToRight && !twoToRight && g->blackCastleKing && pathIsSafe(1)) {
- moves.push_back(
- {.From = IndexToPosition(from), .To = IndexToPosition(from + 2)});
+ if (!oneToRight && !twoToRight && g->blackCastleKing) {
+ if (pathIsSafe(1)) {
+ moves.push_back(
+ {.From = IndexToPosition(from), .To = IndexToPosition(from + 2)});
+ }
}
- if (!oneToLeft && !twoToLeft && !threeToLeft && g->blackCastleQueen &&
- pathIsSafe(-1)) {
- moves.push_back(
- {.From = IndexToPosition(from), .To = IndexToPosition(from - 2)});
+ if (!oneToLeft && !twoToLeft && !threeToLeft && g->blackCastleQueen) {
+ if (pathIsSafe(-1)) {
+ moves.push_back(
+ {.From = IndexToPosition(from), .To = IndexToPosition(from - 2)});
+ }
}
}
}