X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fposition.h;h=078ff5b79f23e9e2d85b943734f2c4713bbbb3bd;hb=02ef1f4496965b5ad8c26ac6bc18245eaffae2ea;hp=e558581850f41a57a664af73a3f233b589d29665;hpb=9f6bcb38c032a18c8b1aec318d5c7255827f9c7b;p=stockfish diff --git a/src/position.h b/src/position.h index e5585818..078ff5b7 100644 --- a/src/position.h +++ b/src/position.h @@ -161,6 +161,7 @@ public: bool has_repeated() const; int rule50_count() const; Score psq_score() const; + Value psq_eg_stm() const; Value non_pawn_material(Color c) const; Value non_pawn_material() const; @@ -184,6 +185,8 @@ private: void move_piece(Square from, Square to); template void do_castling(Color us, Square from, Square& to, Square& rfrom, Square& rto); + template + Key adjust_key50(Key k) const; // Data members Piece board[SQUARE_NB]; @@ -326,8 +329,14 @@ inline int Position::pawns_on_same_color_squares(Color c, Square s) const { } inline Key Position::key() const { - return st->rule50 < 14 ? st->key - : st->key ^ make_key((st->rule50 - 14) / 8); + return adjust_key50(st->key); +} + +template +inline Key Position::adjust_key50(Key k) const +{ + return st->rule50 < 14 - AfterMove + ? k : k ^ make_key((st->rule50 - (14 - AfterMove)) / 8); } inline Key Position::pawn_key() const { @@ -342,6 +351,10 @@ inline Score Position::psq_score() const { return psq; } +inline Value Position::psq_eg_stm() const { + return (sideToMove == WHITE ? 1 : -1) * eg_value(psq); +} + inline Value Position::non_pawn_material(Color c) const { return st->nonPawnMaterial[c]; }