changed raw ctx pointer to unique | bench 3415609

This commit is contained in:
rektdie committed 2025-06-06 06:18:57 +02:00
1 parent b1fd8e6021
commit dec219e4d7
3 files changed
+13 -12

No files matched your search

+3 -2
View File
@@ -1,6 +1,7 @@
#include <cstring>
#include <string_view>
#include <array>
#include <memory>
#include "benchmark.h"
#include "search.h"
#include "stopwatch.h"
@@ -64,12 +65,12 @@ void RunBenchmark() {
Board board;
int depth = BENCH_DEPTH;
SEARCH::SearchContext *ctx = new SearchContext();
auto ctx = std::make_unique<SearchContext>();
Stopwatch sw;
for (int i = 0; i < fenPositions.size(); i++) {
board.SetByFen(fenPositions[i]);
SearchPosition<bench>(board, SearchParams(), ctx);
SearchPosition<bench>(board, SearchParams(), ctx.get());
}
std::cout << ctx->nodes << " nodes " << int(ctx->nodes/sw.GetElapsedSec()) << " nps" << std::endl;
+6 -6
View File
@@ -130,9 +130,9 @@ static void PlayGames(int id, std::atomic<int>& positions, std::atomic<bool>& st
while (!stopFlag) {
Game game;
Board board;
SEARCH::SearchContext *ctx = new SEARCH::SearchContext();
PlayRandMoves(board, ctx);
if (IsGameOver(board, ctx)) continue;
auto ctx = std::make_unique<SEARCH::SearchContext>();
PlayRandMoves(board, ctx.get());
if (IsGameOver(board, ctx.get())) continue;
Board startpos = board;
@@ -141,8 +141,8 @@ static void PlayGames(int id, std::atomic<int>& positions, std::atomic<bool>& st
int staticEval = UTILS::ConvertToWhiteRelative(board, NNUE::net.Evaluate(board));
int wdl = 1;
while (!IsGameOver(board, ctx)) {
SearchResults results = SEARCH::SearchPosition<SEARCH::datagen>(board, SearchParams(), ctx);
while (!IsGameOver(board, ctx.get())) {
SearchResults results = SEARCH::SearchPosition<SEARCH::datagen>(board, SearchParams(), ctx.get());
if (!results.bestMove) break;
safeResults = results;
@@ -158,7 +158,7 @@ static void PlayGames(int id, std::atomic<int>& positions, std::atomic<bool>& st
MOVEGEN::GenerateMoves<All>(board);
}
if (!SEARCH::IsDraw(board, ctx)) {
if (!SEARCH::IsDraw(board, ctx.get())) {
wdl = board.sideToMove ? 2 : 0;
}
+4 -4
View File
@@ -111,7 +111,7 @@ static void PrintEngineInfo() {
void UCILoop(Board &board) {
std::string input = "";
SEARCH::SearchContext *ctx = new SEARCH::SearchContext();
auto ctx = std::make_unique<SEARCH::SearchContext>();
// main loop
while (true) {
@@ -125,7 +125,7 @@ void UCILoop(Board &board) {
// parse UCI "position" command
if (input.find("position") != std::string::npos) {
ParsePosition(board, input, ctx);
ParsePosition(board, input, ctx.get());
continue;
}
@@ -146,7 +146,7 @@ void UCILoop(Board &board) {
// parse UCI "go" command
if (input.find("go") != std::string::npos) {
ParseGo(board, input, ctx);
ParseGo(board, input, ctx.get());
continue;
}
@@ -171,7 +171,7 @@ void UCILoop(Board &board) {
}
if (input.find("setoption") != std::string::npos) {
SetOption(input, ctx);
SetOption(input, ctx.get());
continue;
}