[board, core, bitboard] Clean up casts between Rank, File and BitBoard
Let BitBoard::rank and BitBoard::file take a Rank and File directly, instead of a u8 by reference. And then make the Rank/File::as_index const and return a value rather than a reference. All this allows you to convert between Rank, File, and BitBoard at compile tile (i.e. as a const method) rather than needing to do runtime stuff.
This commit is contained in:
parent
588f049290
commit
3684e9b425
3 changed files with 24 additions and 25 deletions
|
@ -63,10 +63,10 @@ fn pawn_pushes(pawn: BitBoard, color: Color, occupancy: BitBoard) -> BitBoard {
|
|||
|
||||
match color {
|
||||
Color::White => {
|
||||
let second_rank = BitBoard::rank(&Rank::TWO.into());
|
||||
const SECOND_RANK: BitBoard = BitBoard::rank(Rank::TWO);
|
||||
|
||||
let mut pushes = pawn.shift_north_one() & vacancy;
|
||||
if !(pawn & second_rank).is_empty() {
|
||||
if !(pawn & SECOND_RANK).is_empty() {
|
||||
// Double push
|
||||
pushes = pushes | (pushes.shift_north_one() & vacancy);
|
||||
}
|
||||
|
@ -74,10 +74,10 @@ fn pawn_pushes(pawn: BitBoard, color: Color, occupancy: BitBoard) -> BitBoard {
|
|||
pushes
|
||||
}
|
||||
Color::Black => {
|
||||
let seventh_rank = BitBoard::rank(&Rank::SEVEN.into());
|
||||
const SEVENTH_RANK: BitBoard = BitBoard::rank(Rank::SEVEN);
|
||||
|
||||
let mut pushes = pawn.shift_south_one() & vacancy;
|
||||
if !(pawn & seventh_rank).is_empty() {
|
||||
if !(pawn & SEVENTH_RANK).is_empty() {
|
||||
// Double push
|
||||
pushes = pushes | (pushes.shift_south_one() & vacancy);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue