[position] Fix a bug in the pawn pushes move generator
This commit is contained in:
parent
1f78d4811a
commit
c558800385
1 changed files with 14 additions and 2 deletions
|
@ -3,7 +3,7 @@
|
|||
use super::{move_generator_declaration, MoveGeneratorInternal, MoveSet};
|
||||
use crate::{MoveBuilder, Position};
|
||||
use chessfriend_bitboard::BitBoard;
|
||||
use chessfriend_core::{Color, Piece, PlacedPiece, Square};
|
||||
use chessfriend_core::{Color, Piece, PlacedPiece, Rank, Square};
|
||||
|
||||
#[derive(Debug)]
|
||||
struct MoveIterator(usize, usize);
|
||||
|
@ -39,8 +39,20 @@ impl MoveGeneratorInternal for PawnMoveGenerator {
|
|||
|
||||
impl PawnMoveGenerator {
|
||||
fn pushes(position: &Position, piece: PlacedPiece) -> BitBoard {
|
||||
let square = piece.square();
|
||||
let bitboard: BitBoard = square.into();
|
||||
|
||||
let empty_squares = position.empty_squares();
|
||||
BitBoard::pawn_pushes(piece.square(), piece.color()) & empty_squares
|
||||
|
||||
let mut moves = bitboard.shift_north_one() & empty_squares;
|
||||
if !(bitboard
|
||||
& BitBoard::rank(Rank::PAWN_STARTING_RANKS[piece.color() as usize].as_index()))
|
||||
.is_empty()
|
||||
{
|
||||
moves |= moves.shift_north_one() & empty_squares;
|
||||
}
|
||||
|
||||
moves
|
||||
}
|
||||
|
||||
fn attacks(position: &Position, piece: PlacedPiece) -> BitBoard {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue