X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.h;h=1d6a99bab0f9bfa13314c7a77c7ca6bae4192144;hp=e2365a68f306266bb1ec4ba84c09fab8762c15c2;hb=77eec9f9cb50e742151273da6e4cd2847fe9ec1f;hpb=dda7e4639aa19b91f2bafd2e8fb5b55c57eda97a diff --git a/src/position.h b/src/position.h index e2365a68..1d6a99ba 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 dcCandidates; + Bitboard checkSq[8]; +}; + /// Castle rights, encoded as bit fields enum CastleRights { @@ -87,12 +99,13 @@ enum Phase { /// must be passed as a parameter. struct StateInfo { - Key key, pawnKey, materialKey; + Key pawnKey, materialKey; int castleRights, rule50, pliesFromNull; Square epSquare; Score value; Value npMaterial[2]; + Key key; PieceType capture; Bitboard checkersBB; StateInfo* previous; @@ -205,7 +218,7 @@ public: bool pl_move_is_legal(Move m, Bitboard pinned) const; bool pl_move_is_evasion(Move m, Bitboard pinned) const; bool move_is_check(Move m) const; - bool move_is_check(Move m, Bitboard dcCandidates) const; + bool move_is_check(Move m, const CheckInfo& ci) const; bool move_is_capture(Move m) const; bool move_is_capture_or_promotion(Move m) const; bool move_is_passed_pawn_push(Move m) const; @@ -223,7 +236,7 @@ public: // Doing and undoing moves void saveState(); void do_move(Move m, StateInfo& st); - void do_move(Move m, StateInfo& st, Bitboard dcCandidates); + void do_move(Move m, StateInfo& st, const CheckInfo& ci, bool moveIsCheck); void undo_move(Move m); void do_null_move(StateInfo& st); void undo_null_move(); @@ -242,7 +255,6 @@ public: // Incremental evaluation Score value() const; Value non_pawn_material(Color c) const; - Phase game_phase() const; Score pst_delta(Piece piece, Square from, Square to) const; // Game termination checks @@ -269,6 +281,9 @@ public: static void init_zobrist(); static void init_piece_square_tables(); + // Public zobs + static Key zobExclusion; + private: // Initialization helper functions (used while setting up a position) @@ -283,9 +298,6 @@ private: void undo_castle_move(Move m); void find_checkers(); - template - void update_checkers(Bitboard* pCheckersBB, Square ksq, Square from, Square to, Bitboard dcCandidates); - template Bitboard hidden_checkers(Color c) const; @@ -516,22 +528,6 @@ inline Value Position::non_pawn_material(Color c) const { return st->npMaterial[c]; } -inline Phase Position::game_phase() const { - - // Values modified by Joona Kiiski - static const Value MidgameLimit = Value(15581); - static const Value EndgameLimit = Value(3998); - - Value npm = non_pawn_material(WHITE) + non_pawn_material(BLACK); - - if (npm >= MidgameLimit) - return PHASE_MIDGAME; - else if(npm <= EndgameLimit) - return PHASE_ENDGAME; - else - return Phase(((npm - EndgameLimit) * 128) / (MidgameLimit - EndgameLimit)); -} - inline bool Position::move_is_passed_pawn_push(Move m) const { Color c = side_to_move();