datagen could get in an inf loop if random moves resulted in game over

This commit is contained in:
rektdie committed 2025-04-15 14:27:19 +02:00
1 parent 55b73dc85d
commit c6eb3f464b
3 files changed
+43 -28

No files matched your search

+12 -7
View File
@@ -138,11 +138,16 @@ static SearchResults Quiescence(Board& board, int alpha, int beta, int ply, Sear
}
}
}
} else {
} else if constexpr (mode == nodesMode) {
if (ctx.nodes > ctx.nodesToGo) {
ctx.searchStopped = true;
return 0;
}
} else if constexpr (mode == datagen) {
if (ctx.nodes > DATAGEN::HARD_NODES) {
ctx.searchStopped = true;
return 0;
}
}
int bestScore = HCE::Evaluate(board);
@@ -194,18 +199,13 @@ static SearchResults Quiescence(Board& board, int alpha, int beta, int ply, Sear
template <bool isPV, searchMode mode>
SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchContext& ctx) {
if constexpr (mode != bench || mode != nodesMode) {
if constexpr (mode != bench && mode != nodesMode) {
if (ctx.nodes % 1024 == 0) {
if constexpr (mode == normal) {
if (ctx.sw.GetElapsedMS() >= ctx.timeToSearch) {
ctx.searchStopped = true;
return 0;
}
} else if constexpr (mode == datagen) {
if (ctx.nodes >= DATAGEN::HARD_NODES) {
ctx.searchStopped = true;
return 0;
}
}
}
} else if constexpr (mode == nodesMode) {
@@ -213,6 +213,11 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
ctx.searchStopped = true;
return 0;
}
} else if constexpr (mode == datagen) {
if (ctx.nodes > DATAGEN::HARD_NODES) {
ctx.searchStopped = true;
return 0;
}
}
ctx.pvLine.SetLength(ply);