mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 11:39:15 +00:00
Use update_checkers<>() also for PAWN
No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
1d2247aea3
commit
a188a047ab
2 changed files with 25 additions and 22 deletions
|
@ -317,6 +317,25 @@ void Position::copy(const Position &pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Position::update_checkers() updates checkers info, used in do_move()
|
||||||
|
template<PieceType Piece>
|
||||||
|
inline void Position::update_checkers(Bitboard* pCheckersBB, Square ksq, Square from,
|
||||||
|
Square to, Bitboard dcCandidates) {
|
||||||
|
|
||||||
|
if (Piece != KING && bit_is_set(piece_attacks<Piece>(ksq), to))
|
||||||
|
set_bit(pCheckersBB, to);
|
||||||
|
|
||||||
|
if (Piece != QUEEN && bit_is_set(dcCandidates, from))
|
||||||
|
{
|
||||||
|
if (Piece != ROOK)
|
||||||
|
(*pCheckersBB) |= (piece_attacks<ROOK>(ksq) & rooks_and_queens(side_to_move()));
|
||||||
|
|
||||||
|
if (Piece != BISHOP)
|
||||||
|
(*pCheckersBB) |= (piece_attacks<BISHOP>(ksq) & bishops_and_queens(side_to_move()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Position:pinned_pieces() returns a bitboard of all pinned (against the
|
/// Position:pinned_pieces() returns a bitboard of all pinned (against the
|
||||||
/// king) pieces for the given color.
|
/// king) pieces for the given color.
|
||||||
Bitboard Position::pinned_pieces(Color c) const {
|
Bitboard Position::pinned_pieces(Color c) const {
|
||||||
|
@ -710,22 +729,6 @@ void Position::restore(const UndoInfo& u) {
|
||||||
// u.capture is restored in undo_move()
|
// u.capture is restored in undo_move()
|
||||||
}
|
}
|
||||||
|
|
||||||
template<PieceType Piece>
|
|
||||||
inline void Position::update_checkers(Bitboard* pCheckersBB, Square ksq, Square from, Square to, Bitboard dcCandidates) {
|
|
||||||
|
|
||||||
if (Piece != KING && bit_is_set(piece_attacks<Piece>(ksq), to))
|
|
||||||
set_bit(pCheckersBB, to);
|
|
||||||
|
|
||||||
if (Piece != QUEEN && bit_is_set(dcCandidates, from))
|
|
||||||
{
|
|
||||||
if (Piece != ROOK)
|
|
||||||
(*pCheckersBB) |= (piece_attacks<ROOK>(ksq) & rooks_and_queens(side_to_move()));
|
|
||||||
|
|
||||||
if (Piece != BISHOP)
|
|
||||||
(*pCheckersBB) |= (piece_attacks<BISHOP>(ksq) & bishops_and_queens(side_to_move()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Position::do_move() makes a move, and backs up all information necessary
|
/// Position::do_move() makes a move, and backs up all information necessary
|
||||||
/// to undo the move to an UndoInfo object. The move is assumed to be legal.
|
/// to undo the move to an UndoInfo object. The move is assumed to be legal.
|
||||||
/// Pseudo-legal moves should be filtered out before this function is called.
|
/// Pseudo-legal moves should be filtered out before this function is called.
|
||||||
|
@ -849,12 +852,7 @@ void Position::do_move(Move m, UndoInfo& u, Bitboard dcCandidates) {
|
||||||
switch (piece)
|
switch (piece)
|
||||||
{
|
{
|
||||||
case PAWN:
|
case PAWN:
|
||||||
if (bit_is_set(pawn_attacks(them, ksq), to))
|
update_checkers<PAWN>(&checkersBB, ksq, from, to, dcCandidates);
|
||||||
set_bit(&checkersBB, to);
|
|
||||||
|
|
||||||
if (bit_is_set(dcCandidates, from))
|
|
||||||
checkersBB |= ( (piece_attacks<ROOK>(ksq) & rooks_and_queens(us))
|
|
||||||
|(piece_attacks<BISHOP>(ksq) & bishops_and_queens(us)));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KNIGHT:
|
case KNIGHT:
|
||||||
|
|
|
@ -532,6 +532,11 @@ inline Bitboard Position::pawn_attacks(Color c, Square s) const {
|
||||||
return StepAttackBB[pawn_of_color(c)][s];
|
return StepAttackBB[pawn_of_color(c)][s];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline Bitboard Position::piece_attacks<PAWN>(Square s) const {
|
||||||
|
return StepAttackBB[pawn_of_color(opposite_color(sideToMove))][s];
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline Bitboard Position::piece_attacks<KNIGHT>(Square s) const {
|
inline Bitboard Position::piece_attacks<KNIGHT>(Square s) const {
|
||||||
return StepAttackBB[KNIGHT][s];
|
return StepAttackBB[KNIGHT][s];
|
||||||
|
|
Loading…
Add table
Reference in a new issue