1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

Introduce CheckInfo struct

Keeps info used to speed-up move_is_check()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2009-11-09 20:49:01 +01:00
parent e05039156c
commit 37398d9456
2 changed files with 28 additions and 3 deletions

View file

@ -56,12 +56,25 @@ Score Position::PieceSquareTable[16][64];
static bool RequestPending = false; static bool RequestPending = false;
////
//// Functions
////
/// Constructors /// Constructors
CheckInfo::CheckInfo(const Position& pos) {
Color us = pos.side_to_move();
Color them = opposite_color(us);
ksq = pos.king_square(them);
dc = pos.discovered_check_candidates(us);
checkSq[PAWN] = pos.attacks_from<PAWN>(ksq, them);
checkSq[KNIGHT] = pos.attacks_from<KNIGHT>(ksq);
checkSq[BISHOP] = pos.attacks_from<BISHOP>(ksq);
checkSq[ROOK] = pos.attacks_from<ROOK>(ksq);
checkSq[QUEEN] = checkSq[BISHOP] | checkSq[ROOK];
checkSq[KING] = EmptyBoardBB;
}
Position::Position(const Position& pos) { Position::Position(const Position& pos) {
copy(pos); copy(pos);
} }

View file

@ -63,6 +63,18 @@ const int MaxGameLength = 220;
//// Types //// Types
//// ////
/// struct checkInfo is initialized at c'tor time and keeps
/// info used to detect if a move gives check.
struct CheckInfo {
CheckInfo(const Position&);
Square ksq;
Bitboard dc;
Bitboard checkSq[8];
};
/// Castle rights, encoded as bit fields /// Castle rights, encoded as bit fields
enum CastleRights { enum CastleRights {