From 08c0a181d6e5beb6848fe278dfb421fbcb4e3aba Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 2 Aug 2026 15:15:45 +0200 Subject: adding colored piece bitboards --- src/moves.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/moves.cpp') 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 &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 &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 && -- cgit v1.2.3