From 2688194d44b9971ca3755d3dc7eba984b8c13350 Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Thu, 3 Sep 2020 11:47:36 +0200 Subject: [PATCH] Fix #91 --- src/learn/gensfen.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/learn/gensfen.cpp b/src/learn/gensfen.cpp index e69528ac..8b6bf951 100644 --- a/src/learn/gensfen.cpp +++ b/src/learn/gensfen.cpp @@ -506,6 +506,8 @@ namespace Learner // From the final stage (one step before) to the first stage, give information on the outcome of the game for each stage. // The phases stored in sfens are assumed to be continuous (in order). + bool quit = false; + int num_sfens_to_commit = 0; for (auto it = sfens.rbegin(); it != sfens.rend(); ++it) { // If is_win == 0 (draw), multiply by -1 and it will remain 0 (draw) @@ -517,19 +519,25 @@ namespace Learner auto now_loop_count = get_next_loop_count(); if (now_loop_count == LOOP_COUNT_FINISHED) { - return true; + quit = true; + break; } + ++num_sfens_to_commit; + } + + // Write sfens in move order to make potential compression easier + for (auto it = sfens.end() - num_sfens_to_commit; it != sfens.end(); ++it) + { // Write out one sfen. sfen_writer.write(thread_id, *it); - #if 0 pos.set_from_packed_sfen(it->sfen); cout << pos << "Win : " << it->is_win << " , " << it->score << endl; #endif } - return false; + return quit; } optional MultiThinkGenSfen::choose_random_move(