No globals #50
No files matched your search
@@ -65,7 +65,6 @@ void RunBenchmark() {
|
|||||||
Board board;
|
Board board;
|
||||||
int depth = BENCH_DEPTH;
|
int depth = BENCH_DEPTH;
|
||||||
int ply = 0;
|
int ply = 0;
|
||||||
searchStopped = false;
|
|
||||||
positionIndex = 0;
|
positionIndex = 0;
|
||||||
|
|
||||||
// Clearing
|
// Clearing
|
||||||
|
|||||||
+14
-18
@@ -134,14 +134,14 @@ static SearchResults Quiescence(Board board, int alpha, int beta, int ply, Searc
|
|||||||
if constexpr (mode != bench) {
|
if constexpr (mode != bench) {
|
||||||
if (ctx.nodes % 1024 == 0) {
|
if (ctx.nodes % 1024 == 0) {
|
||||||
if (ctx.sw.GetElapsedMS() >= ctx.timeToSearch) {
|
if (ctx.sw.GetElapsedMS() >= ctx.timeToSearch) {
|
||||||
StopSearch();
|
ctx.searchStopped = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ctx.nodes > ctx.nodesToGo) {
|
if (ctx.nodes > ctx.nodesToGo) {
|
||||||
StopSearch();
|
ctx.searchStopped = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -189,7 +189,7 @@ static SearchResults Quiescence(Board board, int alpha, int beta, int ply, Searc
|
|||||||
}
|
}
|
||||||
|
|
||||||
results.score = bestScore;
|
results.score = bestScore;
|
||||||
if (searchStopped) return 0;
|
if (ctx.searchStopped) return 0;
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,19 +199,19 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply, SearchCo
|
|||||||
if (ctx.nodes % 1024 == 0) {
|
if (ctx.nodes % 1024 == 0) {
|
||||||
if constexpr (mode == normal) {
|
if constexpr (mode == normal) {
|
||||||
if (ctx.sw.GetElapsedMS() >= ctx.timeToSearch) {
|
if (ctx.sw.GetElapsedMS() >= ctx.timeToSearch) {
|
||||||
StopSearch();
|
ctx.searchStopped = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else if constexpr (mode == datagen) {
|
} else if constexpr (mode == datagen) {
|
||||||
if (ctx.nodes >= DATAGEN::HARD_NODES) {
|
if (ctx.nodes >= DATAGEN::HARD_NODES) {
|
||||||
StopSearch();
|
ctx.searchStopped = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if constexpr (mode == nodesMode) {
|
} else if constexpr (mode == nodesMode) {
|
||||||
if (ctx.nodes > ctx.nodesToGo) {
|
if (ctx.nodes > ctx.nodesToGo) {
|
||||||
StopSearch();
|
ctx.searchStopped = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,7 +251,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply, SearchCo
|
|||||||
int score = -PVS<false, mode>(copy, depth - 3, -beta, -beta + 1, ply + 1, ctx).score;
|
int score = -PVS<false, mode>(copy, depth - 3, -beta, -beta + 1, ply + 1, ctx).score;
|
||||||
ctx.doingNullMove = false;
|
ctx.doingNullMove = false;
|
||||||
|
|
||||||
if (searchStopped) return 0;
|
if (ctx.searchStopped) return 0;
|
||||||
if (score >= beta) return score;
|
if (score >= beta) return score;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -318,7 +318,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply, SearchCo
|
|||||||
moveSeen++;
|
moveSeen++;
|
||||||
positionIndex--;
|
positionIndex--;
|
||||||
|
|
||||||
if (searchStopped) return 0;
|
if (ctx.searchStopped) return 0;
|
||||||
|
|
||||||
if (currMove.IsQuiet()) {
|
if (currMove.IsQuiet()) {
|
||||||
seenQuiets[seenQuietsCount] = currMove;
|
seenQuiets[seenQuietsCount] = currMove;
|
||||||
@@ -362,7 +362,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply, SearchCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchStopped) return 0;
|
if (ctx.searchStopped) return 0;
|
||||||
TT.WriteEntry(board.hashKey, depth, results.score, nodeType, results.bestMove);
|
TT.WriteEntry(board.hashKey, depth, results.score, nodeType, results.bestMove);
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
@@ -410,7 +410,7 @@ static SearchResults ID(Board &board, SearchParams params, SearchContext& ctx) {
|
|||||||
|
|
||||||
depth--;
|
depth--;
|
||||||
|
|
||||||
if (searchStopped) break;
|
if (ctx.searchStopped) break;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,7 +418,7 @@ static SearchResults ID(Board &board, SearchParams params, SearchContext& ctx) {
|
|||||||
beta = currentResults.score + delta;
|
beta = currentResults.score + delta;
|
||||||
delta = 50;
|
delta = 50;
|
||||||
|
|
||||||
if (searchStopped) {
|
if (ctx.searchStopped) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (currentResults.bestMove) {
|
if (currentResults.bestMove) {
|
||||||
@@ -438,13 +438,13 @@ static SearchResults ID(Board &board, SearchParams params, SearchContext& ctx) {
|
|||||||
|
|
||||||
if constexpr (mode == normal) {
|
if constexpr (mode == normal) {
|
||||||
if (ctx.sw.GetElapsedMS() >= softTime) {
|
if (ctx.sw.GetElapsedMS() >= softTime) {
|
||||||
StopSearch();
|
ctx.searchStopped = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if constexpr (mode == datagen) {
|
} else if constexpr (mode == datagen) {
|
||||||
if (ctx.nodes >= DATAGEN::SOFT_NODES) {
|
if (ctx.nodes >= DATAGEN::SOFT_NODES) {
|
||||||
StopSearch();
|
ctx.searchStopped = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -456,7 +456,7 @@ static SearchResults ID(Board &board, SearchParams params, SearchContext& ctx) {
|
|||||||
|
|
||||||
template <searchMode mode>
|
template <searchMode mode>
|
||||||
SearchResults SearchPosition(Board &board, SearchParams params, SearchContext& ctx) {
|
SearchResults SearchPosition(Board &board, SearchParams params, SearchContext& ctx) {
|
||||||
searchStopped = false;
|
ctx.searchStopped = false;
|
||||||
if constexpr (mode != bench) {
|
if constexpr (mode != bench) {
|
||||||
ctx.nodes = 0;
|
ctx.nodes = 0;
|
||||||
|
|
||||||
@@ -477,10 +477,6 @@ SearchResults SearchPosition(Board &board, SearchParams params, SearchContext& c
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StopSearch() {
|
|
||||||
searchStopped = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
template SearchResults PVS<true, searchMode::bench>(Board, int, int, int, int, SearchContext& ctx);
|
template SearchResults PVS<true, searchMode::bench>(Board, int, int, int, int, SearchContext& ctx);
|
||||||
template SearchResults PVS<false, searchMode::bench>(Board, int, int, int, int, SearchContext& ctx);
|
template SearchResults PVS<false, searchMode::bench>(Board, int, int, int, int, SearchContext& ctx);
|
||||||
template SearchResults PVS<true, searchMode::normal>(Board, int, int, int, int, SearchContext& ctx);
|
template SearchResults PVS<true, searchMode::normal>(Board, int, int, int, int, SearchContext& ctx);
|
||||||
|
|||||||
+1
-3
@@ -22,8 +22,6 @@ constexpr int MAX_HISTORY = 16384;
|
|||||||
|
|
||||||
constexpr int inf = 100000;
|
constexpr int inf = 100000;
|
||||||
|
|
||||||
inline bool searchStopped = false;
|
|
||||||
|
|
||||||
// [id][ply]
|
// [id][ply]
|
||||||
inline int killerMoves[2][MAX_PLY];
|
inline int killerMoves[2][MAX_PLY];
|
||||||
|
|
||||||
@@ -112,6 +110,7 @@ public:
|
|||||||
int timeToSearch = 0;
|
int timeToSearch = 0;
|
||||||
|
|
||||||
bool doingNullMove = false;
|
bool doingNullMove = false;
|
||||||
|
bool searchStopped = false;
|
||||||
|
|
||||||
PVLine pvLine;
|
PVLine pvLine;
|
||||||
History history;
|
History history;
|
||||||
@@ -130,7 +129,6 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply, SearchCo
|
|||||||
|
|
||||||
template <searchMode mode>
|
template <searchMode mode>
|
||||||
SearchResults SearchPosition(Board &board, SearchParams params, SearchContext& ctx);
|
SearchResults SearchPosition(Board &board, SearchParams params, SearchContext& ctx);
|
||||||
void StopSearch();
|
|
||||||
|
|
||||||
bool IsDraw(Board &board);
|
bool IsDraw(Board &board);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -159,7 +159,7 @@ void UCILoop(Board &board) {
|
|||||||
// parse UCI "stop" command
|
// parse UCI "stop" command
|
||||||
if (input.find("stop") != std::string::npos) {
|
if (input.find("stop") != std::string::npos) {
|
||||||
// stop the loop
|
// stop the loop
|
||||||
SEARCH::StopSearch();
|
ctx.searchStopped = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user