Skip to content

Commit 82958c9

Browse files
committed
Basis implementation of using main and capture history for scoring the different possible moves (no functional changes but slower). Bench: 4881443
1 parent 221893b commit 82958c9

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/evaluate.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,11 @@ namespace {
257257
constexpr Bitboard OutpostRanks = (Us == WHITE ? Rank4BB | Rank5BB | Rank6BB
258258
: Rank5BB | Rank4BB | Rank3BB);
259259
const Square* pl = pos.squares<Pt>(Us);
260+
constexpr Piece movedPiece = make_piece(Us, Pt);
260261

261262
Bitboard b, bb;
262263
Score score = SCORE_ZERO;
264+
Thread *thisThread = pos.this_thread();
263265

264266
attackedBy[Us][Pt] = 0;
265267

@@ -284,10 +286,26 @@ namespace {
284286
kingAttacksCount[Us] += popcount(b & attackedBy[Them][KING]);
285287
}
286288

287-
int mob = popcount(b & mobilityArea[Us]);
289+
bb = b & mobilityArea[Us];
290+
int mob = popcount(bb);
288291

289292
mobility[Us] += MobilityBonus[Pt - 2][mob];
290293

294+
volatile int hist = -std::max(thisThread->mainHistory.divisor, thisThread->captureHistory.divisor);
295+
while (bb)
296+
{
297+
Square to = pop_lsb(&bb);
298+
Piece captured = pos.piece_on(to);
299+
volatile int h;
300+
301+
if (captured)
302+
h = thisThread->captureHistory[movedPiece][to][type_of(captured)];
303+
else
304+
h = thisThread->mainHistory[movedPiece][to];
305+
hist = std::max(h, hist);
306+
}
307+
score += make_score(hist / 100000, hist / 100000);
308+
291309
if (Pt == BISHOP || Pt == KNIGHT)
292310
{
293311
// Bonus if piece is on an outpost square or can reach one

src/movepick.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ struct Stats : public std::array<Stats<T, D, Sizes...>, Size>
6464
{
6565
typedef Stats<T, D, Size, Sizes...> stats;
6666

67+
static constexpr int divisor = D;
68+
6769
void fill(const T& v) {
6870

6971
// For standard-layout 'this' points to first struct member

0 commit comments

Comments
 (0)