From 2e67665665d8edd9f0471899d2b1cb0017c5c3c3 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 4 Aug 2026 09:14:03 +0200 Subject: improving code readiblity and maybe perfomance --- src/moves.cpp | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'src/moves.cpp') 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 &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)}); + } } } } -- cgit v1.2.3