diff options
Diffstat (limited to 'src/moves.cpp')
| -rw-r--r-- | src/moves.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/moves.cpp b/src/moves.cpp index d7df595..00cd437 100644 --- a/src/moves.cpp +++ b/src/moves.cpp @@ -1,6 +1,7 @@ #include <array> #include <cassert> #include <cstdint> +#include <iostream> #include <sys/types.h> #include <vector> @@ -61,20 +62,22 @@ void GeneratePawnMoves(Game *b, int from, std::vector<Move> &moves) { moves.push_back({position, IndexToPosition(twoSteps)}); } } - - // check for (int fileOffset : {-1, 1}) { int targetFile = position.file + fileOffset; - if (targetFile < 0 || targetFile >= 8) { + int targetRank = position.rank + (pawn.color ? -1 : 1); + + if (targetFile < 0 || targetFile >= 8) continue; - } - int target = (position.rank + (pawn.color ? -1 : 1)) * 8 + targetFile; + if (targetRank < 0 || targetRank >= 8) + continue; + + int target = targetRank * 8 + targetFile; if (IndexToPosition(target) == b->enPassant && b->canEnpassant) { - // enpasstant!!!!!!! moves.push_back({position, IndexToPosition(target)}); } + if (b->pieces[target].type != NONE && b->pieces[target].color != pawn.color) { moves.push_back({position, IndexToPosition(target)}); |
