Datagen #46
+15
-6
@@ -142,7 +142,7 @@ static void WriteToFile(const Game &game, const std::string &filename) {
|
|||||||
uint32_t zero = 0;
|
uint32_t zero = 0;
|
||||||
std::memcpy(buffer.data() + offset, &zero, sizeof(zero));
|
std::memcpy(buffer.data() + offset, &zero, sizeof(zero));
|
||||||
|
|
||||||
std::ofstream file(filename, std::ios::binary | std::ios::out | std::ios::trunc);
|
std::ofstream file(filename, std::ios::binary | std::ios::out | std::ios::app);
|
||||||
if (!file) throw std::runtime_error("Failed to open file for writing");
|
if (!file) throw std::runtime_error("Failed to open file for writing");
|
||||||
|
|
||||||
file.write(buffer.data(), buffer.size());
|
file.write(buffer.data(), buffer.size());
|
||||||
@@ -234,8 +234,9 @@ void Run(int targetPositions, int threads) {
|
|||||||
|
|
||||||
int positions = 0;
|
int positions = 0;
|
||||||
int lastPrintedPosition = 0;
|
int lastPrintedPosition = 0;
|
||||||
|
double lastPrintedTime = stopwatch.GetElapsedSec();
|
||||||
|
|
||||||
while (positions < targetPositions * 1000000) {
|
while (positions < targetPositions * 1000) {
|
||||||
Game game;
|
Game game;
|
||||||
Board board;
|
Board board;
|
||||||
|
|
||||||
@@ -262,7 +263,10 @@ void Run(int targetPositions, int threads) {
|
|||||||
board.MakeMove(results.bestMove);
|
board.MakeMove(results.bestMove);
|
||||||
MOVEGEN::GenerateMoves<All>(board);
|
MOVEGEN::GenerateMoves<All>(board);
|
||||||
|
|
||||||
positions++;
|
// Increment positions, but do not exceed target
|
||||||
|
if (positions < targetPositions * 1000) {
|
||||||
|
positions++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::abs(safeResults.score) >= std::abs(SEARCH::MATE_SCORE) - SEARCH::MAX_PLY) {
|
if (std::abs(safeResults.score) >= std::abs(SEARCH::MATE_SCORE) - SEARCH::MAX_PLY) {
|
||||||
@@ -272,16 +276,21 @@ void Run(int targetPositions, int threads) {
|
|||||||
game.format.packFrom(board, staticEval, wdl);
|
game.format.packFrom(board, staticEval, wdl);
|
||||||
WriteToFile(game, "data.binpack");
|
WriteToFile(game, "data.binpack");
|
||||||
|
|
||||||
if (positions / 100 > lastPrintedPosition) {
|
// Print progress every second
|
||||||
lastPrintedPosition = positions / 1000;
|
double currentTime = stopwatch.GetElapsedSec();
|
||||||
PrintProgress(positions, targetPositions * 1000000, stopwatch, threads);
|
if (currentTime - lastPrintedTime >= 1) {
|
||||||
|
lastPrintedTime = currentTime;
|
||||||
|
PrintProgress(positions, targetPositions * 1000, stopwatch, threads);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PrintProgress(positions, targetPositions * 1000, stopwatch, threads);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
ShowCursor();
|
ShowCursor();
|
||||||
#else
|
#else
|
||||||
ShowCursorLinux();
|
ShowCursorLinux();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user