diff options
| author | Adam <adammegarules1@gmail.com> | 2026-07-31 19:07:24 +0200 |
|---|---|---|
| committer | Adam <adammegarules1@gmail.com> | 2026-07-31 19:07:24 +0200 |
| commit | c437220aab7b908995a87cf958d9a67e54d478cb (patch) | |
| tree | b87f0ce44bc91d6cef834b4e94e01548a7306826 /src/moves.cpp | |
| parent | a90ba2e3ef8010692d9b94f51ba03d19e7bcb457 (diff) | |
keeping track of were all the pieces are
Diffstat (limited to 'src/moves.cpp')
| -rw-r--r-- | src/moves.cpp | 7 |
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; |
