aboutsummaryrefslogtreecommitdiff
path: root/src/moves.cpp
diff options
context:
space:
mode:
authorAdam <adammegarules1@gmail.com>2026-08-02 15:15:45 +0200
committerAdam <adammegarules1@gmail.com>2026-08-02 15:15:45 +0200
commit08c0a181d6e5beb6848fe278dfb421fbcb4e3aba (patch)
tree00c32b9ae97b189cf8d64e6f01ba93c4ae1c8860 /src/moves.cpp
parent26f5b9cc34633c5dd8c7f61c6751c43c63f30bc4 (diff)
adding colored piece bitboards
Diffstat (limited to 'src/moves.cpp')
-rw-r--r--src/moves.cpp15
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 &&