From 82958c97214b6d418e5bc95e3bf1961060cd6113 Mon Sep 17 00:00:00 2001 From: Stefan Geschwentner Date: Mon, 20 Apr 2020 11:36:33 +0200 Subject: [PATCH] Basis implementation of using main and capture history for scoring the different possible moves (no functional changes but slower). Bench: 4881443 --- src/evaluate.cpp | 20 +++++++++++++++++++- src/movepick.h | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index cbcebd045f6..72a66981935 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -257,9 +257,11 @@ namespace { constexpr Bitboard OutpostRanks = (Us == WHITE ? Rank4BB | Rank5BB | Rank6BB : Rank5BB | Rank4BB | Rank3BB); const Square* pl = pos.squares(Us); + constexpr Piece movedPiece = make_piece(Us, Pt); Bitboard b, bb; Score score = SCORE_ZERO; + Thread *thisThread = pos.this_thread(); attackedBy[Us][Pt] = 0; @@ -284,10 +286,26 @@ namespace { kingAttacksCount[Us] += popcount(b & attackedBy[Them][KING]); } - int mob = popcount(b & mobilityArea[Us]); + bb = b & mobilityArea[Us]; + int mob = popcount(bb); mobility[Us] += MobilityBonus[Pt - 2][mob]; + volatile int hist = -std::max(thisThread->mainHistory.divisor, thisThread->captureHistory.divisor); + while (bb) + { + Square to = pop_lsb(&bb); + Piece captured = pos.piece_on(to); + volatile int h; + + if (captured) + h = thisThread->captureHistory[movedPiece][to][type_of(captured)]; + else + h = thisThread->mainHistory[movedPiece][to]; + hist = std::max(h, hist); + } + score += make_score(hist / 100000, hist / 100000); + if (Pt == BISHOP || Pt == KNIGHT) { // Bonus if piece is on an outpost square or can reach one diff --git a/src/movepick.h b/src/movepick.h index 33c4b08602b..9a260d54d79 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -64,6 +64,8 @@ struct Stats : public std::array, Size> { typedef Stats stats; + static constexpr int divisor = D; + void fill(const T& v) { // For standard-layout 'this' points to first struct member