diff options
| author | Adam <adammegarules1@gmail.com> | 2026-08-04 09:14:03 +0200 |
|---|---|---|
| committer | Adam <adammegarules1@gmail.com> | 2026-08-04 09:14:03 +0200 |
| commit | 2e67665665d8edd9f0471899d2b1cb0017c5c3c3 (patch) | |
| tree | e07b60af6ae554f75a8112444010ec6cd56fa1ff /src | |
| parent | 0f9a523370075ec64b3c0acd040926fdb0de7938 (diff) | |
improving code readiblity and maybe perfomance
Diffstat (limited to 'src')
| -rw-r--r-- | src/moves.cpp | 34 |
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)}); + } } } } |
