diff --git a/docs/generate_training_data.md b/docs/generate_training_data.md index a02d6e0c..734f7e81 100644 --- a/docs/generate_training_data.md +++ b/docs/generate_training_data.md @@ -60,6 +60,4 @@ Currently the following options are available: `data_format` - format of the training data to use. Either `bin` or `binpack`. Default: `binpack`. -`ensure_quiet` - this is a flag option. When specified the positions will be from the qsearch leaf. - `seed` - seed for the PRNG. Can be either a number or a string. If it's a string then its hash will be used. If not specified then the current time will be used. diff --git a/src/tools/training_data_generator.cpp b/src/tools/training_data_generator.cpp index a8804fef..24498917 100644 --- a/src/tools/training_data_generator.cpp +++ b/src/tools/training_data_generator.cpp @@ -93,8 +93,6 @@ namespace Stockfish::Tools bool detect_draw_by_consecutive_low_score = true; bool detect_draw_by_insufficient_mating_material = true; - bool ensure_quiet = false; - uint64_t num_threads; std::string book; @@ -349,86 +347,17 @@ namespace Stockfish::Tools // Discard stuff before write_minply is reached // because it can harm training due to overfitting. // Initial positions would be too common. - if (ply >= params.write_minply) + if (ply >= params.write_minply && !was_seen_before(pos)) { - packed_sfens.emplace_back(PackedSfenValue()); + auto& psv = packed_sfens.emplace_back(); - auto& psv = packed_sfens.back(); + // Here we only write the position data. + // Result is added after the whole game is done. + pos.sfen_pack(psv.sfen); - if (params.ensure_quiet) - { - auto [qsearch_value, qsearch_pv] = Search::qsearch(pos); - if (qsearch_pv.empty()) - { - // Here we only write the position data. - // Result is added after the whole game is done. - pos.sfen_pack(psv.sfen); - - // Already a quiet position - psv.score = search_value; - psv.move = search_pv[0]; - psv.gamePly = ply; - } - else - { - // Navigate to a quiet - int old_ply = ply; - for (auto m : qsearch_pv) - { - pos.do_move(m, states[ply++]); - } - - if (was_seen_before(pos)) - { - // Just skip the move. - packed_sfens.pop_back(); - } - else - { - // Reevaluate - auto [quiet_search_value, quiet_search_pv] = Search::search(pos, depth, 1, params.nodes); - if (quiet_search_pv.empty()) - { - // Just skip the move. - packed_sfens.pop_back(); - } - else - { - // Here we only write the position data. - // Result is added after the whole game is done. - pos.sfen_pack(psv.sfen); - - psv.score = quiet_search_value; - psv.move = quiet_search_pv[0]; - psv.gamePly = ply; - } - } - - // Get back to the game - for (auto it = qsearch_pv.rbegin(); it != qsearch_pv.rend(); ++it) - { - pos.undo_move(*it); - } - ply = old_ply; - } - } - else - { - if (was_seen_before(pos)) - { - packed_sfens.pop_back(); - } - else - { - // Here we only write the position data. - // Result is added after the whole game is done. - pos.sfen_pack(psv.sfen); - - psv.score = search_value; - psv.move = search_pv[0]; - psv.gamePly = ply; - } - } + psv.score = search_value; + psv.move = search_pv[0]; + psv.gamePly = ply; } // Update the next move according to best search result or random move. @@ -891,10 +820,6 @@ namespace Stockfish::Tools UCI::setoption("PruneAtShallowDepth", "false"); UCI::setoption("EnableTranspositionTable", "true"); } - else if (token == "ensure_quiet") - { - params.ensure_quiet = true; - } else { cout << "ERROR: Unknown option " << token << ". Exiting...\n"; @@ -912,12 +837,6 @@ namespace Stockfish::Tools cout << "WARNING: Unknown sfen format `" << sfen_format << "`. Using bin\n"; } - if (params.ensure_quiet) - { - // Otherwise we can't ensure quiet positions... - UCI::setoption("EnableTranspositionTable", "false"); - } - if (random_file_name) { // Give a random number to output_file_name at this point.