From: Marco Costalba Date: Mon, 9 Nov 2009 19:49:01 +0000 (+0100) Subject: Introduce CheckInfo struct X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=37398d945624773287bfa5e56fff9f6adadaec83;ds=sidebyside Introduce CheckInfo struct Keeps info used to speed-up move_is_check() No functional change. Signed-off-by: Marco Costalba --- diff --git a/src/position.cpp b/src/position.cpp index 77a6d604..8ab712b4 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -56,12 +56,25 @@ Score Position::PieceSquareTable[16][64]; static bool RequestPending = false; -//// -//// Functions -//// /// 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(ksq, them); + checkSq[KNIGHT] = pos.attacks_from(ksq); + checkSq[BISHOP] = pos.attacks_from(ksq); + checkSq[ROOK] = pos.attacks_from(ksq); + checkSq[QUEEN] = checkSq[BISHOP] | checkSq[ROOK]; + checkSq[KING] = EmptyBoardBB; +} + Position::Position(const Position& pos) { copy(pos); } diff --git a/src/position.h b/src/position.h index 09c63006..9e476722 100644 --- a/src/position.h +++ b/src/position.h @@ -63,6 +63,18 @@ const int MaxGameLength = 220; //// 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 enum CastleRights {