Remove classical psqt

Based on vondele's deletepsqt branch:
https://github.com/vondele/Stockfish/commit/369f5b051

This huge simplification uses a weighted material differences instead of
the positional piece square tables (psqt) in the semi-classical complexity
calculation. Tuned weights using spsa at 45+0.45 with:

int pawnMult = 100;
int knightMult = 325;
int bishopMult = 350;
int rookMult = 500;
int queenMult = 900;
TUNE(SetRange(0, 200), pawnMult);
TUNE(SetRange(0, 650), knightMult);
TUNE(SetRange(0, 700), bishopMult);
TUNE(SetRange(200, 800), rookMult);
TUNE(SetRange(600, 1200), queenMult);

The values obtained via this tuning session were for a model where
the psqt replacement formula was always from the point of view of White,
even if the side to move was Black. We re-used the same values for an
implementation with a psqt replacement from the point of view of the side
to move, testing the result both on our standard book on positions with
a strong White bias, and an alternate book with positions with a strong
Black bias.

We note that with the patch the last use of the venerable "Score" type
disappears in Stockfish codebase (the Score type was used in classical
evaluation to get a tampered eval interpolating values smoothly from the
early midgame stage to the endgame stage). We leave it to another commit
to clean all occurrences of Score in the code and the comments.

-------

Passed non-regression LTC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 142542 W: 36264 L: 36168 D: 70110
Ptnml(0-2): 76, 15578, 39856, 15696, 65
https://tests.stockfishchess.org/tests/view/64c8cb495b17f7c21c0cf9f8

Passed non-regression LTC (with a book with Black bias):
https://tests.stockfishchess.org/tests/view/64c8f9295b17f7c21c0cfdaf
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 494814 W: 125565 L: 125827 D: 243422
Ptnml(0-2): 244, 53926, 139346, 53630, 261

------

closes https://github.com/official-stockfish/Stockfish/pull/4713

Bench: 1655985
This commit is contained in:
Linmiao Xu
2023-07-24 01:22:21 -04:00
committed by Stéphane Nicolet
parent a6d9a302b8
commit 0ad9b51dea
6 changed files with 8 additions and 184 deletions

View File

@@ -26,7 +26,6 @@
#include "bitboard.h"
#include "evaluate.h"
#include "psqt.h"
#include "types.h"
#include "nnue/nnue_accumulator.h"
@@ -153,7 +152,6 @@ public:
bool has_game_cycle(int ply) const;
bool has_repeated() const;
int rule50_count() const;
Value psq_eg_stm() const;
Value non_pawn_material(Color c) const;
Value non_pawn_material() const;
@@ -192,7 +190,6 @@ private:
StateInfo* st;
int gamePly;
Color sideToMove;
Score psq;
bool chess960;
};
@@ -321,10 +318,6 @@ inline Key Position::material_key() const {
return st->materialKey;
}
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];
}
@@ -374,7 +367,6 @@ inline void Position::put_piece(Piece pc, Square s) {
byColorBB[color_of(pc)] |= s;
pieceCount[pc]++;
pieceCount[make_piece(color_of(pc), ALL_PIECES)]++;
psq += PSQT::psq[pc][s];
}
inline void Position::remove_piece(Square s) {
@@ -386,7 +378,6 @@ inline void Position::remove_piece(Square s) {
board[s] = NO_PIECE;
pieceCount[pc]--;
pieceCount[make_piece(color_of(pc), ALL_PIECES)]--;
psq -= PSQT::psq[pc][s];
}
inline void Position::move_piece(Square from, Square to) {
@@ -398,7 +389,6 @@ inline void Position::move_piece(Square from, Square to) {
byColorBB[color_of(pc)] ^= fromTo;
board[from] = NO_PIECE;
board[to] = pc;
psq += PSQT::psq[pc][to] - PSQT::psq[pc][from];
}
inline void Position::do_move(Move m, StateInfo& newSt) {