mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 01:03:09 +00:00
Remove lowPly history
Seems that after pull request #3731 (Capping stat bonus at 2000) this heuristic is no longer useful. STC: https://tests.stockfishchess.org/tests/view/61b8d0e2dffbe89a35815444 LLR: 2.94 (-2.94,2.94) <-2.25,0.25> Total: 30672 W: 7974 L: 7812 D: 14886 Ptnml(0-2): 106, 3436, 8072, 3634, 88 LTC: https://tests.stockfishchess.org/tests/view/61b8e90cdffbe89a35815a67 LLR: 2.94 (-2.94,2.94) <-2.25,0.25> Total: 42448 W: 10884 L: 10751 D: 20813 Ptnml(0-2): 23, 4394, 12267, 4507, 33 closes https://github.com/official-stockfish/Stockfish/pull/3853 bench: 4474950
This commit is contained in:
parent
0889210262
commit
dc5d9bdfee
5 changed files with 27 additions and 52 deletions
|
@ -56,11 +56,14 @@ namespace {
|
||||||
/// ordering is at the current node.
|
/// ordering is at the current node.
|
||||||
|
|
||||||
/// MovePicker constructor for the main search
|
/// MovePicker constructor for the main search
|
||||||
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHistory* mh, const LowPlyHistory* lp,
|
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHistory* mh,
|
||||||
const CapturePieceToHistory* cph, const PieceToHistory** ch, Move cm, const Move* killers, int pl)
|
const CapturePieceToHistory* cph,
|
||||||
: pos(p), mainHistory(mh), lowPlyHistory(lp), captureHistory(cph), continuationHistory(ch),
|
const PieceToHistory** ch,
|
||||||
ttMove(ttm), refutations{{killers[0], 0}, {killers[1], 0}, {cm, 0}}, depth(d), ply(pl) {
|
Move cm,
|
||||||
|
const Move* killers)
|
||||||
|
: pos(p), mainHistory(mh), captureHistory(cph), continuationHistory(ch),
|
||||||
|
ttMove(ttm), refutations{{killers[0], 0}, {killers[1], 0}, {cm, 0}}, depth(d)
|
||||||
|
{
|
||||||
assert(d > 0);
|
assert(d > 0);
|
||||||
|
|
||||||
stage = (pos.checkers() ? EVASION_TT : MAIN_TT) +
|
stage = (pos.checkers() ? EVASION_TT : MAIN_TT) +
|
||||||
|
@ -69,9 +72,11 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHist
|
||||||
|
|
||||||
/// MovePicker constructor for quiescence search
|
/// MovePicker constructor for quiescence search
|
||||||
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHistory* mh,
|
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHistory* mh,
|
||||||
const CapturePieceToHistory* cph, const PieceToHistory** ch, Square rs)
|
const CapturePieceToHistory* cph,
|
||||||
: pos(p), mainHistory(mh), captureHistory(cph), continuationHistory(ch), ttMove(ttm), recaptureSquare(rs), depth(d) {
|
const PieceToHistory** ch,
|
||||||
|
Square rs)
|
||||||
|
: pos(p), mainHistory(mh), captureHistory(cph), continuationHistory(ch), ttMove(ttm), recaptureSquare(rs), depth(d)
|
||||||
|
{
|
||||||
assert(d <= 0);
|
assert(d <= 0);
|
||||||
|
|
||||||
stage = (pos.checkers() ? EVASION_TT : QSEARCH_TT) +
|
stage = (pos.checkers() ? EVASION_TT : QSEARCH_TT) +
|
||||||
|
@ -83,8 +88,8 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHist
|
||||||
/// MovePicker constructor for ProbCut: we generate captures with SEE greater
|
/// MovePicker constructor for ProbCut: we generate captures with SEE greater
|
||||||
/// than or equal to the given threshold.
|
/// than or equal to the given threshold.
|
||||||
MovePicker::MovePicker(const Position& p, Move ttm, Value th, const CapturePieceToHistory* cph)
|
MovePicker::MovePicker(const Position& p, Move ttm, Value th, const CapturePieceToHistory* cph)
|
||||||
: pos(p), captureHistory(cph), ttMove(ttm), threshold(th) {
|
: pos(p), captureHistory(cph), ttMove(ttm), threshold(th)
|
||||||
|
{
|
||||||
assert(!pos.checkers());
|
assert(!pos.checkers());
|
||||||
|
|
||||||
stage = PROBCUT_TT + !(ttm && pos.capture(ttm)
|
stage = PROBCUT_TT + !(ttm && pos.capture(ttm)
|
||||||
|
@ -110,8 +115,7 @@ void MovePicker::score() {
|
||||||
+ 2 * (*continuationHistory[0])[pos.moved_piece(m)][to_sq(m)]
|
+ 2 * (*continuationHistory[0])[pos.moved_piece(m)][to_sq(m)]
|
||||||
+ (*continuationHistory[1])[pos.moved_piece(m)][to_sq(m)]
|
+ (*continuationHistory[1])[pos.moved_piece(m)][to_sq(m)]
|
||||||
+ (*continuationHistory[3])[pos.moved_piece(m)][to_sq(m)]
|
+ (*continuationHistory[3])[pos.moved_piece(m)][to_sq(m)]
|
||||||
+ (*continuationHistory[5])[pos.moved_piece(m)][to_sq(m)]
|
+ (*continuationHistory[5])[pos.moved_piece(m)][to_sq(m)];
|
||||||
+ (ply < MAX_LPH ? 6 * (*lowPlyHistory)[ply][from_to(m)] : 0);
|
|
||||||
|
|
||||||
else // Type == EVASIONS
|
else // Type == EVASIONS
|
||||||
{
|
{
|
||||||
|
|
|
@ -88,12 +88,6 @@ enum StatsType { NoCaptures, Captures };
|
||||||
/// the move's from and to squares, see www.chessprogramming.org/Butterfly_Boards
|
/// the move's from and to squares, see www.chessprogramming.org/Butterfly_Boards
|
||||||
typedef Stats<int16_t, 14365, COLOR_NB, int(SQUARE_NB) * int(SQUARE_NB)> ButterflyHistory;
|
typedef Stats<int16_t, 14365, COLOR_NB, int(SQUARE_NB) * int(SQUARE_NB)> ButterflyHistory;
|
||||||
|
|
||||||
/// At higher depths LowPlyHistory records successful quiet moves near the root
|
|
||||||
/// and quiet moves which are/were in the PV (ttPv). LowPlyHistory is populated during
|
|
||||||
/// iterative deepening and at each new search the data is shifted down by 2 plies
|
|
||||||
constexpr int MAX_LPH = 4;
|
|
||||||
typedef Stats<int16_t, 10692, MAX_LPH, int(SQUARE_NB) * int(SQUARE_NB)> LowPlyHistory;
|
|
||||||
|
|
||||||
/// CounterMoveHistory stores counter moves indexed by [piece][to] of the previous
|
/// CounterMoveHistory stores counter moves indexed by [piece][to] of the previous
|
||||||
/// move, see www.chessprogramming.org/Countermove_Heuristic
|
/// move, see www.chessprogramming.org/Countermove_Heuristic
|
||||||
typedef Stats<Move, NOT_USED, PIECE_NB, SQUARE_NB> CounterMoveHistory;
|
typedef Stats<Move, NOT_USED, PIECE_NB, SQUARE_NB> CounterMoveHistory;
|
||||||
|
@ -123,18 +117,16 @@ class MovePicker {
|
||||||
public:
|
public:
|
||||||
MovePicker(const MovePicker&) = delete;
|
MovePicker(const MovePicker&) = delete;
|
||||||
MovePicker& operator=(const MovePicker&) = delete;
|
MovePicker& operator=(const MovePicker&) = delete;
|
||||||
MovePicker(const Position&, Move, Value, const CapturePieceToHistory*);
|
MovePicker(const Position&, Move, Depth, const ButterflyHistory*,
|
||||||
|
const CapturePieceToHistory*,
|
||||||
|
const PieceToHistory**,
|
||||||
|
Move,
|
||||||
|
const Move*);
|
||||||
MovePicker(const Position&, Move, Depth, const ButterflyHistory*,
|
MovePicker(const Position&, Move, Depth, const ButterflyHistory*,
|
||||||
const CapturePieceToHistory*,
|
const CapturePieceToHistory*,
|
||||||
const PieceToHistory**,
|
const PieceToHistory**,
|
||||||
Square);
|
Square);
|
||||||
MovePicker(const Position&, Move, Depth, const ButterflyHistory*,
|
MovePicker(const Position&, Move, Value, const CapturePieceToHistory*);
|
||||||
const LowPlyHistory*,
|
|
||||||
const CapturePieceToHistory*,
|
|
||||||
const PieceToHistory**,
|
|
||||||
Move,
|
|
||||||
const Move*,
|
|
||||||
int);
|
|
||||||
Move next_move(bool skipQuiets = false);
|
Move next_move(bool skipQuiets = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -145,7 +137,6 @@ private:
|
||||||
|
|
||||||
const Position& pos;
|
const Position& pos;
|
||||||
const ButterflyHistory* mainHistory;
|
const ButterflyHistory* mainHistory;
|
||||||
const LowPlyHistory* lowPlyHistory;
|
|
||||||
const CapturePieceToHistory* captureHistory;
|
const CapturePieceToHistory* captureHistory;
|
||||||
const PieceToHistory** continuationHistory;
|
const PieceToHistory** continuationHistory;
|
||||||
Move ttMove;
|
Move ttMove;
|
||||||
|
@ -154,7 +145,6 @@ private:
|
||||||
Square recaptureSquare;
|
Square recaptureSquare;
|
||||||
Value threshold;
|
Value threshold;
|
||||||
Depth depth;
|
Depth depth;
|
||||||
int ply;
|
|
||||||
ExtMove moves[MAX_MOVES];
|
ExtMove moves[MAX_MOVES];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ namespace {
|
||||||
Value value_from_tt(Value v, int ply, int r50c);
|
Value value_from_tt(Value v, int ply, int r50c);
|
||||||
void update_pv(Move* pv, Move move, Move* childPv);
|
void update_pv(Move* pv, Move move, Move* childPv);
|
||||||
void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus);
|
void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus);
|
||||||
void update_quiet_stats(const Position& pos, Stack* ss, Move move, int bonus, int depth);
|
void update_quiet_stats(const Position& pos, Stack* ss, Move move, int bonus);
|
||||||
void update_all_stats(const Position& pos, Stack* ss, Move bestMove, Value bestValue, Value beta, Square prevSq,
|
void update_all_stats(const Position& pos, Stack* ss, Move bestMove, Value bestValue, Value beta, Square prevSq,
|
||||||
Move* quietsSearched, int quietCount, Move* capturesSearched, int captureCount, Depth depth);
|
Move* quietsSearched, int quietCount, Move* capturesSearched, int captureCount, Depth depth);
|
||||||
|
|
||||||
|
@ -317,9 +317,6 @@ void Thread::search() {
|
||||||
mainThread->iterValue[i] = mainThread->bestPreviousScore;
|
mainThread->iterValue[i] = mainThread->bestPreviousScore;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::copy(&lowPlyHistory[2][0], &lowPlyHistory.back().back() + 1, &lowPlyHistory[0][0]);
|
|
||||||
std::fill(&lowPlyHistory[MAX_LPH - 2][0], &lowPlyHistory.back().back() + 1, 0);
|
|
||||||
|
|
||||||
size_t multiPV = size_t(Options["MultiPV"]);
|
size_t multiPV = size_t(Options["MultiPV"]);
|
||||||
Skill skill(Options["Skill Level"], Options["UCI_LimitStrength"] ? int(Options["UCI_Elo"]) : 0);
|
Skill skill(Options["Skill Level"], Options["UCI_LimitStrength"] ? int(Options["UCI_Elo"]) : 0);
|
||||||
|
|
||||||
|
@ -666,14 +663,6 @@ namespace {
|
||||||
if (!excludedMove)
|
if (!excludedMove)
|
||||||
ss->ttPv = PvNode || (ss->ttHit && tte->is_pv());
|
ss->ttPv = PvNode || (ss->ttHit && tte->is_pv());
|
||||||
|
|
||||||
// Update low ply history for previous move if we are near root and position is or has been in PV
|
|
||||||
if ( ss->ttPv
|
|
||||||
&& depth > 12
|
|
||||||
&& ss->ply - 1 < MAX_LPH
|
|
||||||
&& !priorCapture
|
|
||||||
&& is_ok((ss-1)->currentMove))
|
|
||||||
thisThread->lowPlyHistory[ss->ply - 1][from_to((ss-1)->currentMove)] << stat_bonus(depth - 5);
|
|
||||||
|
|
||||||
// At non-PV nodes we check for an early TT cutoff
|
// At non-PV nodes we check for an early TT cutoff
|
||||||
if ( !PvNode
|
if ( !PvNode
|
||||||
&& ss->ttHit
|
&& ss->ttHit
|
||||||
|
@ -689,7 +678,7 @@ namespace {
|
||||||
{
|
{
|
||||||
// Bonus for a quiet ttMove that fails high
|
// Bonus for a quiet ttMove that fails high
|
||||||
if (!ttCapture)
|
if (!ttCapture)
|
||||||
update_quiet_stats(pos, ss, ttMove, stat_bonus(depth), depth);
|
update_quiet_stats(pos, ss, ttMove, stat_bonus(depth));
|
||||||
|
|
||||||
// Extra penalty for early quiet moves of the previous ply
|
// Extra penalty for early quiet moves of the previous ply
|
||||||
if ((ss-1)->moveCount <= 2 && !priorCapture)
|
if ((ss-1)->moveCount <= 2 && !priorCapture)
|
||||||
|
@ -973,12 +962,10 @@ moves_loop: // When in check, search starts here
|
||||||
Move countermove = thisThread->counterMoves[pos.piece_on(prevSq)][prevSq];
|
Move countermove = thisThread->counterMoves[pos.piece_on(prevSq)][prevSq];
|
||||||
|
|
||||||
MovePicker mp(pos, ttMove, depth, &thisThread->mainHistory,
|
MovePicker mp(pos, ttMove, depth, &thisThread->mainHistory,
|
||||||
&thisThread->lowPlyHistory,
|
|
||||||
&captureHistory,
|
&captureHistory,
|
||||||
contHist,
|
contHist,
|
||||||
countermove,
|
countermove,
|
||||||
ss->killers,
|
ss->killers);
|
||||||
ss->ply);
|
|
||||||
|
|
||||||
value = bestValue;
|
value = bestValue;
|
||||||
moveCountPruning = false;
|
moveCountPruning = false;
|
||||||
|
@ -1708,7 +1695,7 @@ moves_loop: // When in check, search starts here
|
||||||
if (!pos.capture_or_promotion(bestMove))
|
if (!pos.capture_or_promotion(bestMove))
|
||||||
{
|
{
|
||||||
// Increase stats for the best move in case it was a quiet move
|
// Increase stats for the best move in case it was a quiet move
|
||||||
update_quiet_stats(pos, ss, bestMove, bonus2, depth);
|
update_quiet_stats(pos, ss, bestMove, bonus2);
|
||||||
|
|
||||||
// Decrease stats for all non-best quiet moves
|
// Decrease stats for all non-best quiet moves
|
||||||
for (int i = 0; i < quietCount; ++i)
|
for (int i = 0; i < quietCount; ++i)
|
||||||
|
@ -1755,7 +1742,7 @@ moves_loop: // When in check, search starts here
|
||||||
|
|
||||||
// update_quiet_stats() updates move sorting heuristics
|
// update_quiet_stats() updates move sorting heuristics
|
||||||
|
|
||||||
void update_quiet_stats(const Position& pos, Stack* ss, Move move, int bonus, int depth) {
|
void update_quiet_stats(const Position& pos, Stack* ss, Move move, int bonus) {
|
||||||
|
|
||||||
// Update killers
|
// Update killers
|
||||||
if (ss->killers[0] != move)
|
if (ss->killers[0] != move)
|
||||||
|
@ -1775,10 +1762,6 @@ moves_loop: // When in check, search starts here
|
||||||
Square prevSq = to_sq((ss-1)->currentMove);
|
Square prevSq = to_sq((ss-1)->currentMove);
|
||||||
thisThread->counterMoves[pos.piece_on(prevSq)][prevSq] = move;
|
thisThread->counterMoves[pos.piece_on(prevSq)][prevSq] = move;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update low ply history
|
|
||||||
if (depth > 11 && ss->ply < MAX_LPH)
|
|
||||||
thisThread->lowPlyHistory[ss->ply][from_to(move)] << stat_bonus(depth - 7);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// When playing with strength handicap, choose best move among a set of RootMoves
|
// When playing with strength handicap, choose best move among a set of RootMoves
|
||||||
|
|
|
@ -59,7 +59,6 @@ void Thread::clear() {
|
||||||
|
|
||||||
counterMoves.fill(MOVE_NONE);
|
counterMoves.fill(MOVE_NONE);
|
||||||
mainHistory.fill(0);
|
mainHistory.fill(0);
|
||||||
lowPlyHistory.fill(0);
|
|
||||||
captureHistory.fill(0);
|
captureHistory.fill(0);
|
||||||
|
|
||||||
for (bool inCheck : { false, true })
|
for (bool inCheck : { false, true })
|
||||||
|
|
|
@ -77,7 +77,6 @@ public:
|
||||||
Value rootDelta;
|
Value rootDelta;
|
||||||
CounterMoveHistory counterMoves;
|
CounterMoveHistory counterMoves;
|
||||||
ButterflyHistory mainHistory;
|
ButterflyHistory mainHistory;
|
||||||
LowPlyHistory lowPlyHistory;
|
|
||||||
CapturePieceToHistory captureHistory;
|
CapturePieceToHistory captureHistory;
|
||||||
ContinuationHistory continuationHistory[2][2];
|
ContinuationHistory continuationHistory[2][2];
|
||||||
Score trend;
|
Score trend;
|
||||||
|
|
Loading…
Add table
Reference in a new issue