Skip to content

Commit 5084812

Browse files
committed
Separate stats
1 parent 46ad4aa commit 5084812

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/search.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ int risk_tolerance(const Position& pos, Value v) {
8989
return -345600 * x / (x * x + 3 * y * y);
9090
};
9191

92-
int material = 10 * pos.count<ROOK>() + 5 * pos.count<KNIGHT>() + 5 * pos.count<CANNON>()
93-
+ 3 * pos.count<BISHOP>() + 2 * pos.count<ADVISOR>() + pos.count<PAWN>();
92+
int material =
93+
(640 * pos.count<ROOK>() + 320 * pos.count<KNIGHT>() + 320 * pos.count<CANNON>()
94+
+ 192 * pos.count<BISHOP>() + 128 * pos.count<ADVISOR>() + 64 * pos.count<PAWN>())
95+
/ 64;
9496

9597
int m = std::clamp(material, 17, 110);
9698

@@ -137,11 +139,11 @@ void update_correction_history(const Position& pos,
137139
<< bonus * 128 / 128;
138140
}
139141

140-
// History and stats update bonus, based on depth
141-
int stat_bonus(Depth d) { return std::min(158 * d - 87, 2168); }
142+
// // History and stats update bonus, based on depth
143+
// int stat_bonus(Depth d) { return std::min(158 * d - 87, 2168); }
142144

143-
// History and stats update malus, based on depth
144-
int stat_malus(Depth d) { return std::min(977 * d - 282, 1524); }
145+
// // History and stats update malus, based on depth
146+
// int stat_malus(Depth d) { return std::min(977 * d - 282, 1524); }
145147

146148
// Add a small random component to draw evaluations to avoid 3-fold blindness
147149
Value value_draw(size_t nodes) { return VALUE_DRAW - 1 + Value(nodes & 0x2); }
@@ -668,12 +670,13 @@ Value Search::Worker::search(
668670
{
669671
// Bonus for a quiet ttMove that fails high
670672
if (!ttCapture)
671-
update_quiet_histories(pos, ss, *this, ttData.move, stat_bonus(depth) * 747 / 1024);
673+
update_quiet_histories(pos, ss, *this, ttData.move,
674+
std::min(115 * depth - 63, 1582));
672675

673676
// Extra penalty for early quiet moves of the previous ply
674677
if (prevSq != SQ_NONE && (ss - 1)->moveCount <= 2 && !priorCapture)
675678
update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq,
676-
-stat_malus(depth + 1) * 1091 / 1024);
679+
-std::min(1041 * (depth + 1) - 300, 1624));
677680
}
678681

679682
// Partial workaround for the graph history interaction problem
@@ -1347,7 +1350,7 @@ Value Search::Worker::search(
13471350

13481351
bonusScale = std::max(bonusScale, 0);
13491352

1350-
const int scaledBonus = stat_bonus(depth) * bonusScale;
1353+
const int scaledBonus = std::min(158 * depth - 87, 2168) * bonusScale;
13511354

13521355
update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq,
13531356
scaledBonus * 416 / 32768);
@@ -1366,7 +1369,7 @@ Value Search::Worker::search(
13661369
Piece capturedPiece = pos.captured_piece();
13671370
assert(capturedPiece != NO_PIECE);
13681371
thisThread->captureHistory[pos.piece_on(prevSq)][prevSq][type_of(capturedPiece)]
1369-
<< stat_bonus(depth) * 2;
1372+
<< std::min(316 * depth - 174, 4336);
13701373
}
13711374

13721375
if (PvNode)
@@ -1740,8 +1743,8 @@ void update_all_stats(const Position& pos,
17401743
Piece moved_piece = pos.moved_piece(bestMove);
17411744
PieceType captured;
17421745

1743-
int bonus = stat_bonus(depth) + 300 * isTTMove;
1744-
int malus = stat_malus(depth) - 34 * (moveCount - 1);
1746+
int bonus = std::min(158 * depth - 87, 2168) + 300 * isTTMove;
1747+
int malus = std::min(977 * depth - 282, 1524) - 34 * (moveCount - 1);
17451748

17461749
if (!pos.capture(bestMove))
17471750
{

0 commit comments

Comments
 (0)