/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
- Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
+ Copyright (C) 2004-2023 The Stockfish developers (see AUTHORS file)
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/// start position to the position just before the search starts). Needed by
/// 'draw by repetition' detection. Use a std::deque because pointers to
/// elements are not invalidated upon list resizing.
-typedef std::unique_ptr<std::deque<StateInfo>> StateListPtr;
+using StateListPtr = std::unique_ptr<std::deque<StateInfo>>;
/// Position class stores information regarding the board representation as
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;
void move_piece(Square from, Square to);
template<bool Do>
void do_castling(Color us, Square from, Square& to, Square& rfrom, Square& rto);
+ template<bool AfterMove>
+ Key adjust_key50(Key k) const;
// Data members
Piece board[SQUARE_NB];
bool chess960;
};
-extern std::ostream& operator<<(std::ostream& os, const Position& pos);
+std::ostream& operator<<(std::ostream& os, const Position& pos);
inline Color Position::side_to_move() const {
return sideToMove;
}
inline Key Position::key() const {
- return st->rule50 < 14 ? st->key
- : st->key ^ make_key((st->rule50 - 14) / 8);
+ return adjust_key50<false>(st->key);
+}
+
+template<bool AfterMove>
+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 {
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];
}