added adj to datagen + skipping uneven starting positions + no pruninging in movesloop in datagen | bench 26088050
This commit is contained in:
1 parent
7887e04cc5
commit
e6318f6ff4
2 files changed
+88
-20
No files matched your search
+67
-2
@@ -127,13 +127,30 @@ static void PlayGames(int id, std::atomic<int>& positions, std::atomic<bool>& st
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int evenityMargin = 200;
|
||||||
|
|
||||||
|
const int winAdjMoveCount = 3;
|
||||||
|
const int winAdjScore = 400;
|
||||||
|
|
||||||
|
const int drawAdjMoveNumber = 40;
|
||||||
|
const int drawAdjMoveCount = 8;
|
||||||
|
const int drawAdjScore = 10;
|
||||||
|
|
||||||
while (!stopFlag) {
|
while (!stopFlag) {
|
||||||
Game game;
|
|
||||||
Board board;
|
Board board;
|
||||||
auto ctx = std::make_unique<SEARCH::SearchContext>();
|
auto ctx = std::make_unique<SEARCH::SearchContext>();
|
||||||
|
|
||||||
PlayRandMoves(board, ctx.get());
|
PlayRandMoves(board, ctx.get());
|
||||||
if (IsGameOver(board, ctx.get())) continue;
|
if (IsGameOver(board, ctx.get())) continue;
|
||||||
|
|
||||||
|
// Filter out games with a highly uneven starting position
|
||||||
|
const int startingScore = SEARCH::SearchPosition<SEARCH::datagen>(board, SearchParams(), ctx.get()).score;
|
||||||
|
|
||||||
|
if (std::abs(startingScore) >= evenityMargin) continue;
|
||||||
|
|
||||||
|
ctx->nodes = 0;
|
||||||
|
|
||||||
|
Game game;
|
||||||
Board startpos = board;
|
Board startpos = board;
|
||||||
|
|
||||||
SearchResults safeResults;
|
SearchResults safeResults;
|
||||||
@@ -141,6 +158,14 @@ static void PlayGames(int id, std::atomic<int>& positions, std::atomic<bool>& st
|
|||||||
int staticEval = UTILS::ConvertToWhiteRelative(board, NNUE::net.Evaluate(board));
|
int staticEval = UTILS::ConvertToWhiteRelative(board, NNUE::net.Evaluate(board));
|
||||||
int wdl = 1;
|
int wdl = 1;
|
||||||
|
|
||||||
|
int whiteWinAdjCurrentMoveCount = 0;
|
||||||
|
int blackWinAdjCurrentMoveCount = 0;
|
||||||
|
|
||||||
|
int moveNumber = 0;
|
||||||
|
int drawAdjCurrentMoveCount = 0;
|
||||||
|
|
||||||
|
bool earlyDraw = false;
|
||||||
|
|
||||||
while (!IsGameOver(board, ctx.get())) {
|
while (!IsGameOver(board, ctx.get())) {
|
||||||
SearchResults results = SEARCH::SearchPosition<SEARCH::datagen>(board, SearchParams(), ctx.get());
|
SearchResults results = SEARCH::SearchPosition<SEARCH::datagen>(board, SearchParams(), ctx.get());
|
||||||
|
|
||||||
@@ -150,15 +175,55 @@ static void PlayGames(int id, std::atomic<int>& positions, std::atomic<bool>& st
|
|||||||
game.moves.emplace_back(ScoredMove(results.bestMove.ConvertToViriMoveFormat(),
|
game.moves.emplace_back(ScoredMove(results.bestMove.ConvertToViriMoveFormat(),
|
||||||
UTILS::ConvertToWhiteRelative(board, results.score)));
|
UTILS::ConvertToWhiteRelative(board, results.score)));
|
||||||
|
|
||||||
|
if (moveNumber >= drawAdjMoveNumber) {
|
||||||
|
if (!results.bestMove.IsCapture() && board.GetPieceType(results.bestMove) != Pawn
|
||||||
|
&& results.score > -drawAdjScore && results.score < drawAdjScore) {
|
||||||
|
drawAdjCurrentMoveCount++;
|
||||||
|
|
||||||
|
if (drawAdjCurrentMoveCount >= drawAdjMoveCount) {
|
||||||
|
earlyDraw = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
drawAdjCurrentMoveCount = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
board.MakeMove(results.bestMove);
|
board.MakeMove(results.bestMove);
|
||||||
|
moveNumber++;
|
||||||
ctx->positionHistory[board.positionIndex] = board.hashKey;
|
ctx->positionHistory[board.positionIndex] = board.hashKey;
|
||||||
|
|
||||||
positions++;
|
positions++;
|
||||||
|
|
||||||
|
// We are checking after making the move, so that's why it's inversed
|
||||||
|
if (board.sideToMove == Black) {
|
||||||
|
if (safeResults.score >= winAdjScore) {
|
||||||
|
whiteWinAdjCurrentMoveCount++;
|
||||||
|
|
||||||
|
if (whiteWinAdjCurrentMoveCount >= winAdjMoveCount)
|
||||||
|
break;
|
||||||
|
} else if (safeResults.score <= winAdjScore) {
|
||||||
|
blackWinAdjCurrentMoveCount++;
|
||||||
|
} else {
|
||||||
|
whiteWinAdjCurrentMoveCount = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (safeResults.score >= winAdjScore) {
|
||||||
|
blackWinAdjCurrentMoveCount++;
|
||||||
|
|
||||||
|
if (blackWinAdjCurrentMoveCount >= winAdjMoveCount)
|
||||||
|
break;
|
||||||
|
} else if (safeResults.score <= winAdjScore) {
|
||||||
|
whiteWinAdjCurrentMoveCount++;
|
||||||
|
} else {
|
||||||
|
blackWinAdjCurrentMoveCount = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MOVEGEN::GenerateMoves<All>(board);
|
MOVEGEN::GenerateMoves<All>(board);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SEARCH::IsDraw(board, ctx.get())) {
|
if (!earlyDraw && !SEARCH::IsDraw(board, ctx.get())) {
|
||||||
wdl = board.sideToMove ? 2 : 0;
|
wdl = board.sideToMove ? 2 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+21
-18
@@ -410,31 +410,34 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
|
|
||||||
bool notMated = results.score > (-MATE_SCORE + MAX_PLY);
|
bool notMated = results.score > (-MATE_SCORE + MAX_PLY);
|
||||||
|
|
||||||
// Late move pruning
|
// We disable pruning in PV nodes in datagen
|
||||||
// If we are near a leaf node we prune moves
|
if constexpr(!(mode == datagen && isPV)) {
|
||||||
// that are late in the list
|
// Late move pruning
|
||||||
if (!isPV && !board.InCheck() && currMove.IsQuiet() && notMated) {
|
// If we are near a leaf node we prune moves
|
||||||
int lmpBase = 7;
|
// that are late in the list
|
||||||
|
if (!isPV && !board.InCheck() && currMove.IsQuiet() && notMated) {
|
||||||
|
int lmpBase = 7;
|
||||||
|
|
||||||
|
|
||||||
int lmpThreshold = lmpBase + 4 * depth;
|
int lmpThreshold = lmpBase + 4 * depth;
|
||||||
|
|
||||||
if (moveSeen >= lmpThreshold) {
|
if (moveSeen >= lmpThreshold) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Futility pruning
|
||||||
|
// If our static eval is far below alpha, there is only a small chance
|
||||||
|
// that a quiet move will help us so we skip them
|
||||||
|
int historyScore = ctx->history[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()];
|
||||||
|
int fpMargin = 100 * depth + historyScore / 32;
|
||||||
|
|
||||||
|
if (!isPV && ply && currMove.IsQuiet()
|
||||||
|
&& depth <= 5 && staticEval + fpMargin < alpha && notMated) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Futility pruning
|
|
||||||
// If our static eval is far below alpha, there is only a small chance
|
|
||||||
// that a quiet move will help us so we skip them
|
|
||||||
int historyScore = ctx->history[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()];
|
|
||||||
int fpMargin = 100 * depth + historyScore / 32;
|
|
||||||
|
|
||||||
if (!isPV && ply && currMove.IsQuiet()
|
|
||||||
&& depth <= 5 && staticEval + fpMargin < alpha && notMated) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Board copy = board;
|
Board copy = board;
|
||||||
bool isLegal = copy.MakeMove(currMove);
|
bool isLegal = copy.MakeMove(currMove);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user