mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Introduce assert for stats update
Make sure updates to the stats are done in a stable way. No functional change Closes #1038 Closes #1037
This commit is contained in:
parent
3b7c1a17e4
commit
c5de4080db
2 changed files with 14 additions and 2 deletions
|
@ -42,7 +42,11 @@ struct HistoryStats {
|
||||||
Square from = from_sq(m);
|
Square from = from_sq(m);
|
||||||
Square to = to_sq(m);
|
Square to = to_sq(m);
|
||||||
|
|
||||||
table[c][from][to] -= table[c][from][to] * abs(int(v)) / 324;
|
const int denom = 324;
|
||||||
|
|
||||||
|
assert(abs(int(v)) <= denom); // Needed for stability.
|
||||||
|
|
||||||
|
table[c][from][to] -= table[c][from][to] * abs(int(v)) / denom;
|
||||||
table[c][from][to] += int(v) * 32;
|
table[c][from][to] += int(v) * 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +69,11 @@ struct Stats {
|
||||||
void update(Piece pc, Square to, Move m) { table[pc][to] = m; }
|
void update(Piece pc, Square to, Move m) { table[pc][to] = m; }
|
||||||
void update(Piece pc, Square to, Value v) {
|
void update(Piece pc, Square to, Value v) {
|
||||||
|
|
||||||
table[pc][to] -= table[pc][to] * abs(int(v)) / 936;
|
const int denom = 936;
|
||||||
|
|
||||||
|
assert(abs(int(v)) <= denom); // Needed for stability.
|
||||||
|
|
||||||
|
table[pc][to] -= table[pc][to] * abs(int(v)) / denom;
|
||||||
table[pc][to] += int(v) * 32;
|
table[pc][to] += int(v) * 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,10 @@ cat << EOF > game.exp
|
||||||
send "go nodes 1000\n"
|
send "go nodes 1000\n"
|
||||||
expect "bestmove"
|
expect "bestmove"
|
||||||
|
|
||||||
|
send "position fen 5rk1/1K4p1/8/8/3B4/8/8/8 b - - 0 1\n"
|
||||||
|
send "go depth 30\n"
|
||||||
|
expect "bestmove"
|
||||||
|
|
||||||
send "quit\n"
|
send "quit\n"
|
||||||
expect eof
|
expect eof
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue