Merge pull request #73 from rektdie/asp-fix
fixed asp windows | bench 3975258
This commit was merged in pull request #73.
This commit is contained in:
2 files changed
+34
-21
No files matched your search
@@ -63,7 +63,6 @@ constexpr std::array<std::string_view, 50> fenPositions = {
|
|||||||
void RunBenchmark() {
|
void RunBenchmark() {
|
||||||
Board board;
|
Board board;
|
||||||
int depth = BENCH_DEPTH;
|
int depth = BENCH_DEPTH;
|
||||||
int ply = 0;
|
|
||||||
|
|
||||||
SearchContext ctx;
|
SearchContext ctx;
|
||||||
|
|
||||||
|
|||||||
+34
-20
@@ -507,6 +507,30 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class AspirationWindow {
|
||||||
|
public:
|
||||||
|
int delta = 50;
|
||||||
|
|
||||||
|
int alpha = -inf;
|
||||||
|
int beta = inf;
|
||||||
|
|
||||||
|
void WidenDown() {
|
||||||
|
alpha -= delta;
|
||||||
|
delta *= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WidenUp() {
|
||||||
|
beta += delta;
|
||||||
|
delta *= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Set(int score) {
|
||||||
|
delta = 50;
|
||||||
|
alpha = score - delta;
|
||||||
|
beta = score + delta;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Iterative deepening
|
// Iterative deepening
|
||||||
template <searchMode mode>
|
template <searchMode mode>
|
||||||
static SearchResults ID(Board &board, SearchParams params, SearchContext& ctx) {
|
static SearchResults ID(Board &board, SearchParams params, SearchContext& ctx) {
|
||||||
@@ -522,12 +546,7 @@ static SearchResults ID(Board &board, SearchParams params, SearchContext& ctx) {
|
|||||||
toDepth = BENCH_DEPTH;
|
toDepth = BENCH_DEPTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
int alpha = -inf;
|
AspirationWindow aw;
|
||||||
int beta = inf;
|
|
||||||
|
|
||||||
int delta = 50;
|
|
||||||
|
|
||||||
int ply = 0;
|
|
||||||
|
|
||||||
int elapsed = 0;
|
int elapsed = 0;
|
||||||
|
|
||||||
@@ -537,26 +556,21 @@ static SearchResults ID(Board &board, SearchParams params, SearchContext& ctx) {
|
|||||||
ctx.timeToSearch = std::max((fullTime / 20) + (inc / 2), 4);
|
ctx.timeToSearch = std::max((fullTime / 20) + (inc / 2), 4);
|
||||||
int softTime = ctx.timeToSearch * 0.65;
|
int softTime = ctx.timeToSearch * 0.65;
|
||||||
|
|
||||||
SearchResults currentResults = PVS<true, mode>(board, depth, alpha, beta, ply, ctx, false);
|
SearchResults currentResults = PVS<true, mode>(board, depth, aw.alpha, aw.beta, 0, ctx, false);
|
||||||
elapsed = ctx.sw.GetElapsedMS();
|
elapsed = ctx.sw.GetElapsedMS();
|
||||||
|
|
||||||
// If we fell outside the window, try again with full width
|
if (aw.alpha != -inf && currentResults.score <= aw.alpha) {
|
||||||
if ((currentResults.score <= alpha)
|
aw.WidenDown();
|
||||||
|| (currentResults.score >= beta)) {
|
depth--;
|
||||||
delta *= 2;
|
continue;
|
||||||
|
}
|
||||||
alpha -= delta;
|
if (aw.beta != inf && currentResults.score >= aw.beta) {
|
||||||
beta += delta;
|
aw.WidenUp();
|
||||||
|
|
||||||
depth--;
|
depth--;
|
||||||
|
|
||||||
if (ctx.searchStopped) break;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
alpha = currentResults.score - delta;
|
aw.Set(currentResults.score);
|
||||||
beta = currentResults.score + delta;
|
|
||||||
delta = 50;
|
|
||||||
|
|
||||||
if (ctx.searchStopped) {
|
if (ctx.searchStopped) {
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in new issue
Block a user