mirror of
https://github.com/sockspls/badfish
synced 2025-05-02 01:29:36 +00:00
Remove HistoryStats
STC: LLR: 3.44 (-2.94,2.94) [-3.00,1.00] Total: 120831 W: 21572 L: 21594 D: 77665 LTC: LLR: 2.96 (-2.94,2.94) [-3.00,1.00] Total: 26565 W: 3519 L: 3406 D: 19640 bench 5920493
This commit is contained in:
parent
d9dd520896
commit
e0504ab876
4 changed files with 15 additions and 26 deletions
|
@ -140,7 +140,6 @@ void MovePicker::score<CAPTURES>() {
|
||||||
template<>
|
template<>
|
||||||
void MovePicker::score<QUIETS>() {
|
void MovePicker::score<QUIETS>() {
|
||||||
|
|
||||||
const HistoryStats& history = pos.this_thread()->history;
|
|
||||||
const FromToStats& fromTo = pos.this_thread()->fromTo;
|
const FromToStats& fromTo = pos.this_thread()->fromTo;
|
||||||
|
|
||||||
const CounterMoveStats* cmh = (ss-1)->counterMoves;
|
const CounterMoveStats* cmh = (ss-1)->counterMoves;
|
||||||
|
@ -150,8 +149,7 @@ void MovePicker::score<QUIETS>() {
|
||||||
Color c = pos.side_to_move();
|
Color c = pos.side_to_move();
|
||||||
|
|
||||||
for (auto& m : *this)
|
for (auto& m : *this)
|
||||||
m.value = history[pos.moved_piece(m)][to_sq(m)]
|
m.value = (cmh ? (*cmh)[pos.moved_piece(m)][to_sq(m)] : VALUE_ZERO)
|
||||||
+ (cmh ? (*cmh)[pos.moved_piece(m)][to_sq(m)] : VALUE_ZERO)
|
|
||||||
+ (fmh ? (*fmh)[pos.moved_piece(m)][to_sq(m)] : VALUE_ZERO)
|
+ (fmh ? (*fmh)[pos.moved_piece(m)][to_sq(m)] : VALUE_ZERO)
|
||||||
+ (fmh2 ? (*fmh2)[pos.moved_piece(m)][to_sq(m)] : VALUE_ZERO)
|
+ (fmh2 ? (*fmh2)[pos.moved_piece(m)][to_sq(m)] : VALUE_ZERO)
|
||||||
+ fromTo.get(c, m);
|
+ fromTo.get(c, m);
|
||||||
|
@ -159,17 +157,16 @@ void MovePicker::score<QUIETS>() {
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void MovePicker::score<EVASIONS>() {
|
void MovePicker::score<EVASIONS>() {
|
||||||
// Try captures ordered by MVV/LVA, then non-captures ordered by history value
|
// Try captures ordered by MVV/LVA, then non-captures ordered by stats heuristics
|
||||||
const HistoryStats& history = pos.this_thread()->history;
|
|
||||||
const FromToStats& fromTo = pos.this_thread()->fromTo;
|
const FromToStats& fromTo = pos.this_thread()->fromTo;
|
||||||
Color c = pos.side_to_move();
|
Color c = pos.side_to_move();
|
||||||
|
|
||||||
for (auto& m : *this)
|
for (auto& m : *this)
|
||||||
if (pos.capture(m))
|
if (pos.capture(m))
|
||||||
m.value = PieceValue[MG][pos.piece_on(to_sq(m))]
|
m.value = PieceValue[MG][pos.piece_on(to_sq(m))]
|
||||||
- Value(type_of(pos.moved_piece(m))) + HistoryStats::Max;
|
- Value(type_of(pos.moved_piece(m))) + FromToStats::Max;
|
||||||
else
|
else
|
||||||
m.value = history[pos.moved_piece(m)][to_sq(m)] + fromTo.get(c, m);
|
m.value = fromTo.get(c, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,9 +38,6 @@
|
||||||
/// different origin but same destination and piece will be considered identical.
|
/// different origin but same destination and piece will be considered identical.
|
||||||
template<typename T, bool CM = false>
|
template<typename T, bool CM = false>
|
||||||
struct Stats {
|
struct Stats {
|
||||||
|
|
||||||
static const Value Max = Value(1 << 28);
|
|
||||||
|
|
||||||
const T* operator[](Piece pc) const { return table[pc]; }
|
const T* operator[](Piece pc) const { return table[pc]; }
|
||||||
T* operator[](Piece pc) { return table[pc]; }
|
T* operator[](Piece pc) { return table[pc]; }
|
||||||
void clear() { std::memset(table, 0, sizeof(table)); }
|
void clear() { std::memset(table, 0, sizeof(table)); }
|
||||||
|
@ -59,12 +56,13 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Stats<Move> MoveStats;
|
typedef Stats<Move> MoveStats;
|
||||||
typedef Stats<Value, false> HistoryStats;
|
typedef Stats<Value, true> CounterMoveStats;
|
||||||
typedef Stats<Value, true> CounterMoveStats;
|
|
||||||
typedef Stats<CounterMoveStats> CounterMoveHistoryStats;
|
typedef Stats<CounterMoveStats> CounterMoveHistoryStats;
|
||||||
|
|
||||||
struct FromToStats {
|
struct FromToStats {
|
||||||
|
|
||||||
|
static const Value Max = Value(1 << 28);
|
||||||
|
|
||||||
Value get(Color c, Move m) const { return table[c][from_sq(m)][to_sq(m)]; }
|
Value get(Color c, Move m) const { return table[c][from_sq(m)][to_sq(m)]; }
|
||||||
void clear() { std::memset(table, 0, sizeof(table)); }
|
void clear() { std::memset(table, 0, sizeof(table)); }
|
||||||
void update(Color c, Move m, Value v) {
|
void update(Color c, Move m, Value v) {
|
||||||
|
|
|
@ -211,7 +211,6 @@ void Search::clear() {
|
||||||
|
|
||||||
for (Thread* th : Threads)
|
for (Thread* th : Threads)
|
||||||
{
|
{
|
||||||
th->history.clear();
|
|
||||||
th->counterMoves.clear();
|
th->counterMoves.clear();
|
||||||
th->fromTo.clear();
|
th->fromTo.clear();
|
||||||
th->counterMoveHistory.clear();
|
th->counterMoveHistory.clear();
|
||||||
|
@ -642,7 +641,7 @@ namespace {
|
||||||
&& (ttValue >= beta ? (tte->bound() & BOUND_LOWER)
|
&& (ttValue >= beta ? (tte->bound() & BOUND_LOWER)
|
||||||
: (tte->bound() & BOUND_UPPER)))
|
: (tte->bound() & BOUND_UPPER)))
|
||||||
{
|
{
|
||||||
// If ttMove is quiet, update killers, history, counter move on TT hit
|
// If ttMove is quiet, update move sorting heuristics on TT hit
|
||||||
if (ttValue >= beta && ttMove)
|
if (ttValue >= beta && ttMove)
|
||||||
{
|
{
|
||||||
if (!pos.capture_or_promotion(ttMove))
|
if (!pos.capture_or_promotion(ttMove))
|
||||||
|
@ -983,12 +982,11 @@ moves_loop: // When in check search starts from here
|
||||||
&& !pos.see_ge(make_move(to_sq(move), from_sq(move)), VALUE_ZERO))
|
&& !pos.see_ge(make_move(to_sq(move), from_sq(move)), VALUE_ZERO))
|
||||||
r -= 2 * ONE_PLY;
|
r -= 2 * ONE_PLY;
|
||||||
|
|
||||||
ss->history = thisThread->history[moved_piece][to_sq(move)]
|
ss->history = (cmh ? (*cmh )[moved_piece][to_sq(move)] : VALUE_ZERO)
|
||||||
+ (cmh ? (*cmh )[moved_piece][to_sq(move)] : VALUE_ZERO)
|
+ (fmh ? (*fmh )[moved_piece][to_sq(move)] : VALUE_ZERO)
|
||||||
+ (fmh ? (*fmh )[moved_piece][to_sq(move)] : VALUE_ZERO)
|
+ (fmh2 ? (*fmh2)[moved_piece][to_sq(move)] : VALUE_ZERO)
|
||||||
+ (fmh2 ? (*fmh2)[moved_piece][to_sq(move)] : VALUE_ZERO)
|
+ thisThread->fromTo.get(~pos.side_to_move(), move)
|
||||||
+ thisThread->fromTo.get(~pos.side_to_move(), move)
|
- 8000; // Correction factor
|
||||||
- 8000; // Correction factor
|
|
||||||
|
|
||||||
// Decrease/increase reduction by comparing opponent's stat score
|
// Decrease/increase reduction by comparing opponent's stat score
|
||||||
if (ss->history > VALUE_ZERO && (ss-1)->history < VALUE_ZERO)
|
if (ss->history > VALUE_ZERO && (ss-1)->history < VALUE_ZERO)
|
||||||
|
@ -1118,7 +1116,7 @@ moves_loop: // When in check search starts from here
|
||||||
else if (bestMove)
|
else if (bestMove)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Quiet best move: update killers, history and countermoves
|
// Quiet best move: update move sorting heuristics
|
||||||
if (!pos.capture_or_promotion(bestMove))
|
if (!pos.capture_or_promotion(bestMove))
|
||||||
update_stats(pos, ss, bestMove, quietsSearched, quietCount, bonus(depth));
|
update_stats(pos, ss, bestMove, quietsSearched, quietCount, bonus(depth));
|
||||||
|
|
||||||
|
@ -1404,8 +1402,7 @@ moves_loop: // When in check search starts from here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// update_stats() updates killers, history, countermove and countermove plus
|
// update_stats() updates move sorting heuristics when a new quiet best move is found
|
||||||
// follow-up move history when a new quiet best move is found.
|
|
||||||
|
|
||||||
void update_stats(const Position& pos, Stack* ss, Move move,
|
void update_stats(const Position& pos, Stack* ss, Move move,
|
||||||
Move* quiets, int quietsCnt, Value bonus) {
|
Move* quiets, int quietsCnt, Value bonus) {
|
||||||
|
@ -1419,7 +1416,6 @@ moves_loop: // When in check search starts from here
|
||||||
Color c = pos.side_to_move();
|
Color c = pos.side_to_move();
|
||||||
Thread* thisThread = pos.this_thread();
|
Thread* thisThread = pos.this_thread();
|
||||||
thisThread->fromTo.update(c, move, bonus);
|
thisThread->fromTo.update(c, move, bonus);
|
||||||
thisThread->history.update(pos.moved_piece(move), to_sq(move), bonus);
|
|
||||||
update_cm_stats(ss, pos.moved_piece(move), to_sq(move), bonus);
|
update_cm_stats(ss, pos.moved_piece(move), to_sq(move), bonus);
|
||||||
|
|
||||||
if ((ss-1)->counterMoves)
|
if ((ss-1)->counterMoves)
|
||||||
|
@ -1432,7 +1428,6 @@ moves_loop: // When in check search starts from here
|
||||||
for (int i = 0; i < quietsCnt; ++i)
|
for (int i = 0; i < quietsCnt; ++i)
|
||||||
{
|
{
|
||||||
thisThread->fromTo.update(c, quiets[i], -bonus);
|
thisThread->fromTo.update(c, quiets[i], -bonus);
|
||||||
thisThread->history.update(pos.moved_piece(quiets[i]), to_sq(quiets[i]), -bonus);
|
|
||||||
update_cm_stats(ss, pos.moved_piece(quiets[i]), to_sq(quiets[i]), -bonus);
|
update_cm_stats(ss, pos.moved_piece(quiets[i]), to_sq(quiets[i]), -bonus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,6 @@ public:
|
||||||
Depth rootDepth;
|
Depth rootDepth;
|
||||||
Depth completedDepth;
|
Depth completedDepth;
|
||||||
std::atomic_bool resetCalls;
|
std::atomic_bool resetCalls;
|
||||||
HistoryStats history;
|
|
||||||
MoveStats counterMoves;
|
MoveStats counterMoves;
|
||||||
FromToStats fromTo;
|
FromToStats fromTo;
|
||||||
CounterMoveHistoryStats counterMoveHistory;
|
CounterMoveHistoryStats counterMoveHistory;
|
||||||
|
|
Loading…
Add table
Reference in a new issue