GenPawnMoves function
This commit is contained in:
1 parent
b58c6bea77
commit
2aebd781fb
6 files changed
+53
-16
No files matched your search
@@ -271,4 +271,32 @@ Bitboard getQueenAttack(int square, U64 occupancy) {
|
||||
rookOccupancy >>= (64 - rookRelevantBits[square]);
|
||||
|
||||
return rookAttacks[square][rookOccupancy] | bishopAttacks[square][bishopOccupancy];
|
||||
}
|
||||
|
||||
void GenPawnMoves(Board &board, bool color) {
|
||||
Bitboard pawns = board.colors[color] & board.pieces[Pawn];
|
||||
|
||||
while (pawns.GetBoard()) {
|
||||
int square = pawns.getLS1BIndex();
|
||||
int direction = color ? south : north;
|
||||
|
||||
Bitboard attacks = pawnAttacks[color][square] & board.colors[!color];
|
||||
attacks |= (Bitboard::GetSquare(square + direction)
|
||||
| Bitboard::GetSquare(square + 2 * direction)) & ~(board.occupied);
|
||||
|
||||
while (attacks.GetBoard()) {
|
||||
int targetSquare = attacks.getLS1BIndex();
|
||||
|
||||
board.AddMove(Move(SQUARE(square), SQUARE(targetSquare)));
|
||||
|
||||
attacks.PopBit(targetSquare);
|
||||
}
|
||||
|
||||
pawns.PopBit(square);
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateMoves(Board &board) {
|
||||
GenPawnMoves(board, White);
|
||||
GenPawnMoves(board, Black);
|
||||
}
|
||||
Reference in new issue
Block a user