new quad-bitboard representation
This commit is contained in:
parent
57b78880f2
commit
4c137d3c95
3 changed files with 43 additions and 39 deletions
|
|
@ -90,7 +90,7 @@ impl Position {
|
|||
Bitboard(0x2CFF00000000FF2C),
|
||||
Bitboard(0x7600000000000076),
|
||||
Bitboard(0x9900000000000099),
|
||||
Bitboard(0x000000000000FFFF),
|
||||
Bitboard(0xFFFF000000000000),
|
||||
],
|
||||
turn: Color::White,
|
||||
castling_rights: CastlingRights::full(),
|
||||
|
|
@ -230,7 +230,7 @@ impl Position {
|
|||
/// play and discards the en passant square.
|
||||
pub fn pass(&self) -> Option<Self> {
|
||||
let Setup {
|
||||
bitboards: [p_b_q, n_b_k, r_q_k, w],
|
||||
bitboards: [p_b_q, n_b_k, r_q_k, black],
|
||||
turn,
|
||||
en_passant: _,
|
||||
castling_rights: _,
|
||||
|
|
@ -243,8 +243,8 @@ impl Position {
|
|||
let r = r_q_k ^ q ^ k;
|
||||
let p = p_b_q ^ b ^ q;
|
||||
let (us, them) = match turn {
|
||||
Color::White => (w, blockers ^ w),
|
||||
Color::Black => (blockers ^ w, w),
|
||||
Color::White => (blockers ^ black, black),
|
||||
Color::Black => (black, blockers ^ black),
|
||||
};
|
||||
let king_square = (us & k).next().unwrap();
|
||||
let checkers = them
|
||||
|
|
@ -580,7 +580,7 @@ impl Position {
|
|||
let global_mask_to = moves.to();
|
||||
|
||||
let Setup {
|
||||
bitboards: [p_b_q, n_b_k, r_q_k, w],
|
||||
bitboards: [p_b_q, n_b_k, r_q_k, black],
|
||||
turn,
|
||||
en_passant,
|
||||
castling_rights,
|
||||
|
|
@ -588,8 +588,8 @@ impl Position {
|
|||
|
||||
let blockers = p_b_q | n_b_k | r_q_k;
|
||||
let (us, them) = match turn {
|
||||
Color::White => (w, blockers ^ w),
|
||||
Color::Black => (blockers ^ w, w),
|
||||
Color::White => (blockers ^ black, black),
|
||||
Color::Black => (black, blockers ^ black),
|
||||
};
|
||||
|
||||
let k = n_b_k & r_q_k;
|
||||
|
|
@ -938,9 +938,9 @@ impl Position {
|
|||
MoveType::EnPassant => {
|
||||
let direction = !setup.turn.forward();
|
||||
let x = (unsafe { to.trans_unchecked(direction) }).bitboard();
|
||||
let [p_b_q, _, _, w] = &mut setup.bitboards;
|
||||
let [p_b_q, _, _, black] = &mut setup.bitboards;
|
||||
*p_b_q ^= x;
|
||||
*w &= !x;
|
||||
*black &= !x;
|
||||
aux_play_pawn_advance(setup, Role::Pawn, from, to);
|
||||
}
|
||||
}
|
||||
|
|
@ -952,7 +952,7 @@ impl Position {
|
|||
#[inline]
|
||||
fn aux_play_normal(
|
||||
Setup {
|
||||
bitboards: [p_b_q, n_b_k, r_q_k, w],
|
||||
bitboards: [p_b_q, n_b_k, r_q_k, black],
|
||||
turn,
|
||||
en_passant: _,
|
||||
castling_rights,
|
||||
|
|
@ -967,7 +967,7 @@ fn aux_play_normal(
|
|||
*p_b_q &= mask;
|
||||
*n_b_k &= mask;
|
||||
*r_q_k &= mask;
|
||||
*w &= mask;
|
||||
*black &= mask;
|
||||
if target == Square::from_coords(File::H, turn.promotion_rank()) {
|
||||
castling_rights.unset(!*turn, CastlingSide::Short);
|
||||
}
|
||||
|
|
@ -1005,15 +1005,15 @@ fn aux_play_normal(
|
|||
*p_b_q |= to;
|
||||
}
|
||||
}
|
||||
if let Color::White = *turn {
|
||||
*w |= to;
|
||||
if let Color::Black = *turn {
|
||||
*black |= to;
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn aux_play_pawn_advance(
|
||||
Setup {
|
||||
bitboards: [p_b_q, n_b_k, r_q_k, w],
|
||||
bitboards: [p_b_q, n_b_k, r_q_k, black],
|
||||
turn,
|
||||
en_passant: _,
|
||||
castling_rights: _,
|
||||
|
|
@ -1044,15 +1044,15 @@ fn aux_play_pawn_advance(
|
|||
}
|
||||
Role::Pawn => *p_b_q ^= from | to,
|
||||
}
|
||||
if let Color::White = *turn {
|
||||
*w ^= from | to;
|
||||
if let Color::Black = *turn {
|
||||
*black ^= from | to;
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn aux_play_castle(
|
||||
Setup {
|
||||
bitboards: [_, n_b_k, r_q_k, w],
|
||||
bitboards: [_, n_b_k, r_q_k, black],
|
||||
turn,
|
||||
en_passant: _,
|
||||
castling_rights,
|
||||
|
|
@ -1075,8 +1075,8 @@ fn aux_play_castle(
|
|||
),
|
||||
};
|
||||
|
||||
if let Color::White = *turn {
|
||||
*w ^= king_flip | rook_flip;
|
||||
if let Color::Black = *turn {
|
||||
*black ^= king_flip | rook_flip;
|
||||
}
|
||||
*n_b_k ^= king_flip;
|
||||
*r_q_k ^= king_flip | rook_flip;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue