different indexing for conthist | bench 2298837
This commit is contained in:
1 parent
cdfb752bfa
commit
f581d919b9
2 files changed
+21
-14
No files matched your search
+12
-8
@@ -22,6 +22,15 @@ void InitLMRTable() {
|
||||
}
|
||||
}
|
||||
|
||||
int16_t ContHistory::GetOnePly(Board& board, Move& move, bool otherColor, SearchContext* ctx, int ply) {
|
||||
int prevType = ctx->ss[ply-1].pieceType;
|
||||
int prevTo = ctx->ss[ply-1].moveTo;
|
||||
int pieceType = board.GetPieceType(move.MoveFrom());
|
||||
int to = move.MoveTo();
|
||||
|
||||
return ctx->conthist[otherColor][prevType][prevTo][board.sideToMove][pieceType][to];
|
||||
}
|
||||
|
||||
static int ScoreMove(Board &board, Move &move, int ply, SearchContext* ctx) {
|
||||
TTEntry *current = ctx->TT.GetRawEntry(board.hashKey);
|
||||
if (current->hashKey == board.hashKey && current->bestMove == move) {
|
||||
@@ -47,12 +56,7 @@ static int ScoreMove(Board &board, Move &move, int ply, SearchContext* ctx) {
|
||||
int conthistScore = 0;
|
||||
|
||||
if (ply > 0) {
|
||||
int prevType = ctx->ss[ply-1].pieceType;
|
||||
int prevTo = ctx->ss[ply-1].moveTo;
|
||||
int pieceType = board.GetPieceType(move.MoveFrom());
|
||||
int to = move.MoveTo();
|
||||
|
||||
conthistScore = ctx->conthist[board.sideToMove][prevType][prevTo][pieceType][to];
|
||||
conthistScore = ctx->conthist.GetOnePly(board, move, !board.sideToMove, ctx, ply);
|
||||
}
|
||||
|
||||
return 20000 + historyScore + conthistScore;
|
||||
@@ -530,14 +534,14 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
||||
int pieceType = ctx->ss[ply].pieceType;
|
||||
int to = ctx->ss[ply].moveTo;
|
||||
|
||||
ctx->conthist.Update(board.sideToMove, prevType, prevTo, pieceType, to, bonus);
|
||||
ctx->conthist.Update(board.sideToMove, !board.sideToMove, prevType, prevTo, pieceType, to, bonus);
|
||||
|
||||
// Malus
|
||||
for (int moveIndex = 0; moveIndex < seenQuietsCount - 1; moveIndex++) {
|
||||
pieceType = board.GetPieceType(seenQuiets[moveIndex].MoveFrom());
|
||||
to = seenQuiets[moveIndex].MoveTo();
|
||||
|
||||
ctx->conthist.Update(board.sideToMove, prevType, prevTo, pieceType, to, -bonus);
|
||||
ctx->conthist.Update(board.sideToMove, !board.sideToMove, prevType, prevTo, pieceType, to, -bonus);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-6
@@ -33,23 +33,26 @@ constexpr std::array<int, 6> SEEPieceValues = {
|
||||
};
|
||||
|
||||
void InitLMRTable();
|
||||
class SearchContext;
|
||||
|
||||
class ContHistory {
|
||||
private:
|
||||
// indexed by [stm][prev move piece][prev move to][piece][to]
|
||||
MultiArray<int16_t, 2, 6, 64, 6, 64> contHistMoves;
|
||||
// indexed by [other color][prev move piece][stm][prev move to][piece][to]
|
||||
MultiArray<int16_t, 2, 6, 64, 2, 6, 64> contHistMoves;
|
||||
public:
|
||||
void Update(bool stm, int prevType, int prevTo, int type, int to, int bonus) {
|
||||
void Update(bool stm, bool otherColor, int prevType, int prevTo, int type, int to, int bonus) {
|
||||
int clampedBonus = std::clamp(bonus, -MAX_HISTORY, MAX_HISTORY);
|
||||
|
||||
contHistMoves[stm][prevType][prevTo][type][to] +=
|
||||
clampedBonus - contHistMoves[stm][prevType][prevTo][type][to] * std::abs(clampedBonus) / MAX_HISTORY;
|
||||
contHistMoves[otherColor][prevType][prevTo][stm][type][to] +=
|
||||
clampedBonus - contHistMoves[otherColor][prevType][prevTo][stm][type][to] * std::abs(clampedBonus) / MAX_HISTORY;
|
||||
}
|
||||
|
||||
void Clear() {
|
||||
std::fill(&contHistMoves[0][0][0][0][0], &contHistMoves[0][0][0][0][0] + sizeof(contHistMoves) / sizeof(int16_t), 0);
|
||||
std::fill(&contHistMoves[0][0][0][0][0][0], &contHistMoves[0][0][0][0][0][0] + sizeof(contHistMoves) / sizeof(int16_t), 0);
|
||||
}
|
||||
|
||||
int16_t GetOnePly(Board& board, Move& move, bool otherColor, SearchContext* ctx, int ply);
|
||||
|
||||
auto& operator[](int index) {
|
||||
return contHistMoves[index];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user