aboutsummaryrefslogtreecommitdiff
path: root/src/moves.cpp
diff options
context:
space:
mode:
authorAdam <adammegarules1@gmail.com>2026-07-31 19:07:24 +0200
committerAdam <adammegarules1@gmail.com>2026-07-31 19:07:24 +0200
commitc437220aab7b908995a87cf958d9a67e54d478cb (patch)
treeb87f0ce44bc91d6cef834b4e94e01548a7306826 /src/moves.cpp
parenta90ba2e3ef8010692d9b94f51ba03d19e7bcb457 (diff)
keeping track of were all the pieces are
Diffstat (limited to 'src/moves.cpp')
-rw-r--r--src/moves.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/moves.cpp b/src/moves.cpp
index fc2b8c7..84c5ba4 100644
--- a/src/moves.cpp
+++ b/src/moves.cpp
@@ -147,10 +147,13 @@ std::vector<Move> GetPseudoLegalMoves(Game *b, bool GenerateQuietMoves) {
constexpr std::array<int, 4> rook_Moves{-1, 1, 8, -8};
constexpr std::array<int, 4> bishop_Moves{-9, 9, -7, 7};
- for (uint i = 0; i < sizeof(b->pieces) / sizeof(b->pieces[0]); i++) {
+ uint64_t piece_bitboard = b->PieceBitboard;
+ while (piece_bitboard != 0) {
+ int i = __builtin_ctzll(piece_bitboard);
+ piece_bitboard &= piece_bitboard - 1;
Piece piece = b->pieces[i];
if (piece.type == NONEPIECE) {
- continue;
+ assert(false && "got none piece in piece bitboard");
}
if (piece.color != b->turn) {
continue;