mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-22 18:17:02 +08:00
Remove EvalList
This patch removes the EvalList structure from the Position object and generally simplifies the interface between do_move() and the NNUE code. The NNUE evaluation function first calculates the "accumulator". The accumulator consists of two halves: one for white's perspective, one for black's perspective. If the "friendly king" has moved or the accumulator for the parent position is not available, the accumulator for this half has to be calculated from scratch. To do this, the NNUE node needs to know the positions and types of all non-king pieces and the position of the friendly king. This information can easily be obtained from the Position object. If the "friendly king" has not moved, its half of the accumulator can be calculated by incrementally updating the accumulator for the previous position. For this, the NNUE code needs to know which pieces have been added to which squares and which pieces have been removed from which squares. In principle this information can be derived from the Position object and StateInfo struct (in the same way as undo_move() does this). However, it is probably a bit faster to prepare this information in do_move(), so I have kept the DirtyPiece struct. Since the DirtyPiece struct now stores the squares rather than "PieceSquare" indices, there are now at most three "dirty pieces" (previously two). A promotion move that captures a piece removes the capturing pawn and the captured piece from the board (to SQ_NONE) and moves the promoted piece to the promotion square (from SQ_NONE). An STC test has confirmed a small speedup: https://tests.stockfishchess.org/tests/view/5f43f06b5089a564a10d850a LLR: 2.94 (-2.94,2.94) {-0.25,1.25} Total: 87704 W: 9763 L: 9500 D: 68441 Ptnml(0-2): 426, 6950, 28845, 7197, 434 closes https://github.com/official-stockfish/Stockfish/pull/3068 No functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
b0b4ca17db
commit
9b4967071e
@@ -171,7 +171,6 @@ public:
|
||||
|
||||
// Used by NNUE
|
||||
StateInfo* state() const;
|
||||
const EvalList* eval_list() const;
|
||||
|
||||
private:
|
||||
// Initialization helpers (used while setting up a position)
|
||||
@@ -186,9 +185,6 @@ private:
|
||||
template<bool Do>
|
||||
void do_castling(Color us, Square from, Square& to, Square& rfrom, Square& rto);
|
||||
|
||||
// ID of a piece on a given square
|
||||
PieceId piece_id_on(Square sq) const;
|
||||
|
||||
// Data members
|
||||
Piece board[SQUARE_NB];
|
||||
Bitboard byTypeBB[PIECE_TYPE_NB];
|
||||
@@ -205,9 +201,6 @@ private:
|
||||
Thread* thisThread;
|
||||
StateInfo* st;
|
||||
bool chess960;
|
||||
|
||||
// List of pieces used in NNUE evaluation function
|
||||
EvalList evalList;
|
||||
};
|
||||
|
||||
namespace PSQT {
|
||||
@@ -451,20 +444,4 @@ inline StateInfo* Position::state() const {
|
||||
return st;
|
||||
}
|
||||
|
||||
inline const EvalList* Position::eval_list() const {
|
||||
|
||||
return &evalList;
|
||||
}
|
||||
|
||||
inline PieceId Position::piece_id_on(Square sq) const
|
||||
{
|
||||
|
||||
assert(piece_on(sq) != NO_PIECE);
|
||||
|
||||
PieceId pid = evalList.piece_id_list[sq];
|
||||
assert(is_ok(pid));
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
||||
#endif // #ifndef POSITION_H_INCLUDED
|
||||
|
||||
Reference in New Issue
Block a user