Revert "Lmr rework" #123

Closed
rektdie wants to merge 5 commits from revert-122-lmr-rework into main
pull from: revert-122-lmr-rework
2 changed files with 8 additions and 20 deletions
Showing only changes of commit 0e0eb633d8 - Show all commits

No files matched your search

+7 -18
View File
@@ -28,22 +28,12 @@ void InitLMRTable() {
} }
} }
int16_t ContHistory::GetOnePly(Board& board, Move& move, SearchContext* ctx, int ply) { int16_t ContHistory::GetNPly(Board& board, Move& move, SearchContext* ctx, int ply, int n) {
int prevType = ctx->ss[ply-1].pieceType; int prevType = ctx->ss[ply-n].pieceType;
int prevTo = ctx->ss[ply-1].moveTo; int prevTo = ctx->ss[ply-n].moveTo;
int pieceType = board.GetPieceType(move.MoveFrom()); int pieceType = board.GetPieceType(move.MoveFrom());
int to = move.MoveTo(); int to = move.MoveTo();
bool otherColor = ctx->ss[ply-1].side; bool otherColor = ctx->ss[ply-n].side;
return ctx->conthist[otherColor][prevType][prevTo][board.sideToMove][pieceType][to];
}
int16_t ContHistory::GetTwoPly(Board& board, Move& move, SearchContext* ctx, int ply) {
int prevType = ctx->ss[ply-2].pieceType;
int prevTo = ctx->ss[ply-2].moveTo;
int pieceType = board.GetPieceType(move.MoveFrom());
int to = move.MoveTo();
bool otherColor = ctx->ss[ply-2].side;
return ctx->conthist[otherColor][prevType][prevTo][board.sideToMove][pieceType][to]; return ctx->conthist[otherColor][prevType][prevTo][board.sideToMove][pieceType][to];
} }
@@ -84,7 +74,7 @@ static int ScoreMove(Board &board, Move &move, int ply, SearchContext* ctx) {
int conthistScore = 0; int conthistScore = 0;
if (ply > 0) { if (ply > 0) {
conthistScore = ctx->conthist.GetOnePly(board, move, ctx, ply); conthistScore = ctx->conthist.GetNPly(board, move, ctx, ply, 1);
/* /*
if (ply > 1) { if (ply > 1) {
conthistScore += ctx->conthist.GetTwoPly(board, move, ctx, ply); conthistScore += ctx->conthist.GetTwoPly(board, move, ctx, ply);
@@ -187,7 +177,6 @@ static int GetReductions(Board &board, Move &move, int depth, int moveSeen, int
int historyReduction = ctx->history[board.sideToMove][move.MoveFrom()][move.MoveTo()][sourceThreatened][targetThreatened]; int historyReduction = ctx->history[board.sideToMove][move.MoveFrom()][move.MoveTo()][sourceThreatened][targetThreatened];
if (ply > 0) { if (ply > 0) {
historyReduction += ctx->conthist.GetOnePly(board, move, ctx, ply); historyReduction += ctx->conthist.GetOnePly(board, move, ctx, ply);
if (ply > 1) if (ply > 1)
historyReduction += ctx->conthist.GetTwoPly(board, move, ctx, ply); historyReduction += ctx->conthist.GetTwoPly(board, move, ctx, ply);
} }
@@ -573,10 +562,10 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
int historyScore = ctx->history[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()][sourceThreatened][targetThreatened]; int historyScore = ctx->history[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()][sourceThreatened][targetThreatened];
if (ply > 0) { if (ply > 0) {
historyScore += ctx->conthist.GetOnePly(board, currMove, ctx, ply); historyScore += ctx->conthist.GetNPly(board, currMove, ctx, ply, 1);
if (ply > 1) if (ply > 1)
historyScore += ctx->conthist.GetTwoPly(board, currMove, ctx, ply); historyScore += ctx->conthist.GetNPly(board, currMove, ctx, ply, 2);
} }
int margin = fpMargin * (depth + improving) + historyScore / 32; int margin = fpMargin * (depth + improving) + historyScore / 32;
+1 -2
View File
@@ -96,8 +96,7 @@ public:
std::fill(&contHistMoves[0][0][0][0][0][0], &contHistMoves[0][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, SearchContext* ctx, int ply); int16_t GetNPly(Board& board, Move& move, SearchContext* ctx, int ply, int n);
int16_t GetTwoPly(Board& board, Move& move, SearchContext* ctx, int ply);
auto& operator[](int index) { auto& operator[](int index) {
return contHistMoves[index]; return contHistMoves[index];