1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 16:53:09 +00:00

Better check evasion move sorting

Use in addition the counter move history table for sorting quiet
check evasion moves in main and quiecence search. Also rename
"contHistory" to "continuationHistory" while there.

STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 73284 W: 16433 L: 15938 D: 40913
http://tests.stockfishchess.org/tests/view/5b4f526e0ebc5902bdb7a401

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 12135 W: 2171 L: 1997 D: 7967
http://tests.stockfishchess.org/tests/view/5b4fc0ef0ebc5902bdb7ae0e

Closes https://github.com/official-stockfish/Stockfish/pull/1685

Bench 4817583
This commit is contained in:
Stefan Geschwentner 2018-07-19 18:26:05 +02:00 committed by Stéphane Nicolet
parent 3913726d1c
commit 12e79be910
6 changed files with 30 additions and 21 deletions

View file

@ -61,7 +61,7 @@ namespace {
/// MovePicker constructor for the main search
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHistory* mh,
const CapturePieceToHistory* cph, const PieceToHistory** ch, Move cm, Move* killers)
: pos(p), mainHistory(mh), captureHistory(cph), contHistory(ch),
: pos(p), mainHistory(mh), captureHistory(cph), continuationHistory(ch),
refutations{{killers[0], 0}, {killers[1], 0}, {cm, 0}}, depth(d) {
assert(d > DEPTH_ZERO);
@ -73,8 +73,8 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHist
/// MovePicker constructor for quiescence search
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHistory* mh,
const CapturePieceToHistory* cph, Square rs)
: pos(p), mainHistory(mh), captureHistory(cph), recaptureSquare(rs), depth(d) {
const CapturePieceToHistory* cph, const PieceToHistory** ch, Square rs)
: pos(p), mainHistory(mh), captureHistory(cph), continuationHistory(ch), recaptureSquare(rs), depth(d) {
assert(d <= DEPTH_ZERO);
@ -115,9 +115,9 @@ void MovePicker::score() {
else if (Type == QUIETS)
m.value = (*mainHistory)[pos.side_to_move()][from_to(m)]
+ (*contHistory[0])[pos.moved_piece(m)][to_sq(m)]
+ (*contHistory[1])[pos.moved_piece(m)][to_sq(m)]
+ (*contHistory[3])[pos.moved_piece(m)][to_sq(m)];
+ (*continuationHistory[0])[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)];
else // Type == EVASIONS
{
@ -125,7 +125,9 @@ void MovePicker::score() {
m.value = PieceValue[MG][pos.piece_on(to_sq(m))]
- Value(type_of(pos.moved_piece(m)));
else
m.value = (*mainHistory)[pos.side_to_move()][from_to(m)] - (1 << 28);
m.value = (*mainHistory)[pos.side_to_move()][from_to(m)]
+ (*continuationHistory[0])[pos.moved_piece(m)][to_sq(m)]
- (1 << 28);
}
}

View file

@ -119,6 +119,7 @@ public:
MovePicker(const Position&, Move, Value, const CapturePieceToHistory*);
MovePicker(const Position&, Move, Depth, const ButterflyHistory*,
const CapturePieceToHistory*,
const PieceToHistory**,
Square);
MovePicker(const Position&, Move, Depth, const ButterflyHistory*,
const CapturePieceToHistory*,
@ -136,7 +137,7 @@ private:
const Position& pos;
const ButterflyHistory* mainHistory;
const CapturePieceToHistory* captureHistory;
const PieceToHistory** contHistory;
const PieceToHistory** continuationHistory;
Move ttMove;
ExtMove refutations[3], *cur, *endMoves, *endBadCaptures;
int stage;

View file

@ -290,7 +290,7 @@ void Thread::search() {
std::memset(ss-4, 0, 7 * sizeof(Stack));
for (int i = 4; i > 0; i--)
(ss-i)->contHistory = this->contHistory[NO_PIECE][0].get(); // Use as sentinel
(ss-i)->continuationHistory = this->continuationHistory[NO_PIECE][0].get(); // Use as sentinel
bestValue = delta = alpha = -VALUE_INFINITE;
beta = VALUE_INFINITE;
@ -587,7 +587,7 @@ namespace {
(ss+1)->ply = ss->ply + 1;
ss->currentMove = (ss+1)->excludedMove = bestMove = MOVE_NONE;
ss->contHistory = thisThread->contHistory[NO_PIECE][0].get();
ss->continuationHistory = thisThread->continuationHistory[NO_PIECE][0].get();
(ss+2)->killers[0] = (ss+2)->killers[1] = MOVE_NONE;
Square prevSq = to_sq((ss-1)->currentMove);
@ -751,7 +751,7 @@ namespace {
Depth R = ((823 + 67 * depth / ONE_PLY) / 256 + std::min((eval - beta) / PawnValueMg, 3)) * ONE_PLY;
ss->currentMove = MOVE_NULL;
ss->contHistory = thisThread->contHistory[NO_PIECE][0].get();
ss->continuationHistory = thisThread->continuationHistory[NO_PIECE][0].get();
pos.do_null_move(st);
@ -802,7 +802,7 @@ namespace {
probCutCount++;
ss->currentMove = move;
ss->contHistory = thisThread->contHistory[pos.moved_piece(move)][to_sq(move)].get();
ss->continuationHistory = thisThread->continuationHistory[pos.moved_piece(move)][to_sq(move)].get();
assert(depth >= 5 * ONE_PLY);
@ -835,7 +835,7 @@ namespace {
moves_loop: // When in check, search starts from here
const PieceToHistory* contHist[] = { (ss-1)->contHistory, (ss-2)->contHistory, nullptr, (ss-4)->contHistory };
const PieceToHistory* contHist[] = { (ss-1)->continuationHistory, (ss-2)->continuationHistory, nullptr, (ss-4)->continuationHistory };
Move countermove = thisThread->counterMoves[pos.piece_on(prevSq)][prevSq];
MovePicker mp(pos, ttMove, depth, &thisThread->mainHistory,
@ -970,7 +970,7 @@ moves_loop: // When in check, search starts from here
// Update the current move (this must be done after singular extension search)
ss->currentMove = move;
ss->contHistory = thisThread->contHistory[movedPiece][to_sq(move)].get();
ss->continuationHistory = thisThread->continuationHistory[movedPiece][to_sq(move)].get();
// Step 15. Make the move
pos.do_move(move, st, givesCheck);
@ -1212,8 +1212,10 @@ moves_loop: // When in check, search starts from here
ss->pv[0] = MOVE_NONE;
}
Thread* thisThread = pos.this_thread();
(ss+1)->ply = ss->ply + 1;
ss->currentMove = bestMove = MOVE_NONE;
ss->continuationHistory = thisThread->continuationHistory[NO_PIECE][0].get();
inCheck = pos.checkers();
moveCount = 0;
@ -1283,12 +1285,15 @@ moves_loop: // When in check, search starts from here
futilityBase = bestValue + 128;
}
const PieceToHistory* contHist[] = { (ss-1)->continuationHistory, (ss-2)->continuationHistory, nullptr, (ss-4)->continuationHistory };
// Initialize a MovePicker object for the current position, and prepare
// to search the moves. Because the depth is <= 0 here, only captures,
// queen promotions and checks (only if depth >= DEPTH_QS_CHECKS) will
// be generated.
MovePicker mp(pos, ttMove, depth, &pos.this_thread()->mainHistory,
&pos.this_thread()->captureHistory,
MovePicker mp(pos, ttMove, depth, &thisThread->mainHistory,
&thisThread->captureHistory,
contHist,
to_sq((ss-1)->currentMove));
// Loop through the moves until no moves remain or a beta cutoff occurs
@ -1345,6 +1350,7 @@ moves_loop: // When in check, search starts from here
}
ss->currentMove = move;
ss->continuationHistory = thisThread->continuationHistory[pos.moved_piece(move)][to_sq(move)].get();
// Make and search the move
pos.do_move(move, st, givesCheck);
@ -1436,7 +1442,7 @@ moves_loop: // When in check, search starts from here
for (int i : {1, 2, 4})
if (is_ok((ss-i)->currentMove))
(*(ss-i)->contHistory)[pc][to] << bonus;
(*(ss-i)->continuationHistory)[pc][to] << bonus;
}

View file

@ -41,7 +41,7 @@ constexpr int CounterMovePruneThreshold = 0;
struct Stack {
Move* pv;
PieceToHistory* contHistory;
PieceToHistory* continuationHistory;
int ply;
Move currentMove;
Move excludedMove;

View file

@ -61,11 +61,11 @@ void Thread::clear() {
mainHistory.fill(0);
captureHistory.fill(0);
for (auto& to : contHistory)
for (auto& to : continuationHistory)
for (auto& h : to)
h.get()->fill(0);
contHistory[NO_PIECE][0].get()->fill(Search::CounterMovePruneThreshold - 1);
continuationHistory[NO_PIECE][0].get()->fill(Search::CounterMovePruneThreshold - 1);
}
/// Thread::start_searching() wakes up the thread that will start the search

View file

@ -71,7 +71,7 @@ public:
CounterMoveHistory counterMoves;
ButterflyHistory mainHistory;
CapturePieceToHistory captureHistory;
ContinuationHistory contHistory;
ContinuationHistory continuationHistory;
Score contempt;
};