diff options
Diffstat (limited to 'src/moves.cpp')
| -rw-r--r-- | src/moves.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/moves.cpp b/src/moves.cpp index 803538b..17d6814 100644 --- a/src/moves.cpp +++ b/src/moves.cpp @@ -28,13 +28,14 @@ void GenerateKnightMoves(Game *b, int from, std::vector<Move> &moves, if (fileDelta != 1 && fileDelta != 2) { continue; }; - if (b->pieces[next].type != NONEPIECE) { - if (b->pieces[next].color == b->turn) { - continue; - }; + bool hasFriendlyPiece = b->turn + ? (b->WhitePieceBitboard & (1ULL << (next))) + : (b->BlackPieceBitboard & (1ULL << (next))); + bool isCaptuare = b->PieceBitboard & (1ULL << next); + if (hasFriendlyPiece) { + continue; } - - if (!GenerateQuietMoves && b->pieces[next].type == NONEPIECE) { + if (!GenerateQuietMoves && isCaptuare) { continue; } moves.push_back({IndexToPosition(from), IndexToPosition(next)}); @@ -92,7 +93,7 @@ void GeneratePawnMoves(Game *b, int from, std::vector<Move> &moves, int target = targetRank * 8 + targetFile; if (IndexToPosition(target) == b->enPassant && b->canEnpassant) { - moves.push_back({position, IndexToPosition(target)}); + moves.push_back({positiopn, IndexToPosition(target)}); } if (b->pieces[target].type != NONEPIECE && |
