Remove the move lists from bishop, knight, queen, and rook move set construction
These are the easy ones.
This commit is contained in:
parent
cd3cb82192
commit
5e3ef9d21e
4 changed files with 18 additions and 40 deletions
|
@ -17,22 +17,12 @@ impl MoveGeneratorInternal for KnightMoveGenerator {
|
|||
let empty_squares = position.empty_squares();
|
||||
let knight_moves = BitBoard::knight_moves(placed_piece.square());
|
||||
|
||||
let quiet_moves_bb = knight_moves & empty_squares;
|
||||
let capture_moves_bb = knight_moves & opposing_pieces;
|
||||
|
||||
let quiet_moves = quiet_moves_bb.occupied_squares().map(|to_sq| {
|
||||
MoveBuilder::new(*placed_piece.piece(), placed_piece.square(), to_sq).build()
|
||||
});
|
||||
let capture_moves = capture_moves_bb.occupied_squares().map(|to_sq| {
|
||||
let captured_piece = position.piece_on_square(to_sq).unwrap();
|
||||
MoveBuilder::new(*placed_piece.piece(), placed_piece.square(), to_sq)
|
||||
.capturing(captured_piece)
|
||||
.build()
|
||||
});
|
||||
let quiet_moves = knight_moves & empty_squares;
|
||||
let capture_moves = knight_moves & opposing_pieces;
|
||||
|
||||
MoveSet::new(placed_piece)
|
||||
.quiet_moves(quiet_moves_bb, quiet_moves)
|
||||
.capture_moves(capture_moves_bb, capture_moves)
|
||||
.quiet_moves(quiet_moves)
|
||||
.capture_moves(capture_moves)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +62,7 @@ mod tests {
|
|||
MoveBuilder::new(piece!(White Knight), Square::E4, Square::F6).build(),
|
||||
];
|
||||
|
||||
let mut generated_moves: HashSet<Move> = generator.iter().cloned().collect();
|
||||
let mut generated_moves: HashSet<Move> = generator.iter().collect();
|
||||
|
||||
for ex_move in expected_moves {
|
||||
assert!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue