aboutsummaryrefslogtreecommitdiff
path: root/src/moves.cpp
diff options
context:
space:
mode:
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;