From 37398d945624773287bfa5e56fff9f6adadaec83 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Mon, 9 Nov 2009 20:49:01 +0100 Subject: [PATCH] Introduce CheckInfo struct Keeps info used to speed-up move_is_check() No functional change. Signed-off-by: Marco Costalba --- src/position.cpp | 19 ++++++++++++++++--- src/position.h | 12 ++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) 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 { -- 2.39.2