From 50be320c33bd942b238e8f82aa34230539878bab Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 28 Jul 2026 12:50:36 +0200 Subject: changes --- src/moves.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/moves.cpp') diff --git a/src/moves.cpp b/src/moves.cpp index 3463fe8..bba85e7 100644 --- a/src/moves.cpp +++ b/src/moves.cpp @@ -52,9 +52,16 @@ void GeneratePawnMoves(Game *b, int from, std::vector &moves) { // if piece it want to move to is none and it as legal move if (b->pieces[next].type == NONE) { - moves.push_back({position, IndexToPosition(next)}); // adding legal move + if (position.rank + (pawn.color ? -1 : 1) == 0 || + position.rank + (pawn.color ? -1 : 1) == 7) { + moves.push_back({position, IndexToPosition(next), QUEEN}); + moves.push_back({position, IndexToPosition(next), ROOK}); + moves.push_back({position, IndexToPosition(next), BISHOP}); + moves.push_back({position, IndexToPosition(next), KNIGHT}); + } else { + moves.push_back({position, IndexToPosition(next)}); + } - // todo find why this code is here and what it does int startingRank = pawn.color ? 6 : 1; int twoSteps = from + step * 2; if (position.rank == startingRank && b->pieces[twoSteps].type == NONE) { @@ -79,7 +86,14 @@ void GeneratePawnMoves(Game *b, int from, std::vector &moves) { if (b->pieces[target].type != NONE && b->pieces[target].color != pawn.color) { - moves.push_back({position, IndexToPosition(target)}); + if (targetRank == 0 || targetRank == 7) { + moves.push_back({position, IndexToPosition(target), QUEEN}); + moves.push_back({position, IndexToPosition(target), ROOK}); + moves.push_back({position, IndexToPosition(target), BISHOP}); + moves.push_back({position, IndexToPosition(target), KNIGHT}); + } else { + moves.push_back({position, IndexToPosition(target)}); + } } } // the end -- cgit v1.2.3