diff options
| author | Adam <adammegarules1@gmail.com> | 2026-07-28 12:50:36 +0200 |
|---|---|---|
| committer | Adam <adammegarules1@gmail.com> | 2026-07-28 12:50:36 +0200 |
| commit | 50be320c33bd942b238e8f82aa34230539878bab (patch) | |
| tree | d4b98a6a90e49cd29cfdbb8fbf0512e64d907217 /src/moves.cpp | |
| parent | 3109a2516e75072835f1998a9b702003781612d5 (diff) | |
changes
Diffstat (limited to 'src/moves.cpp')
| -rw-r--r-- | src/moves.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
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<Move> &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<Move> &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 |
