Remove ensure_quiet parameter from generate_training_data.

This commit is contained in:
Tomasz Sobczyk
2021-05-21 11:09:50 +02:00
parent 733f22e7c2
commit abb7fa00ab
2 changed files with 8 additions and 91 deletions
-2
View File
@@ -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`. `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. `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.
+2 -83
View File
@@ -93,8 +93,6 @@ namespace Stockfish::Tools
bool detect_draw_by_consecutive_low_score = true; bool detect_draw_by_consecutive_low_score = true;
bool detect_draw_by_insufficient_mating_material = true; bool detect_draw_by_insufficient_mating_material = true;
bool ensure_quiet = false;
uint64_t num_threads; uint64_t num_threads;
std::string book; std::string book;
@@ -349,77 +347,10 @@ namespace Stockfish::Tools
// Discard stuff before write_minply is reached // Discard stuff before write_minply is reached
// because it can harm training due to overfitting. // because it can harm training due to overfitting.
// Initial positions would be too common. // 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();
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. // Here we only write the position data.
// Result is added after the whole game is done. // Result is added after the whole game is done.
pos.sfen_pack(psv.sfen); pos.sfen_pack(psv.sfen);
@@ -428,8 +359,6 @@ namespace Stockfish::Tools
psv.move = search_pv[0]; psv.move = search_pv[0];
psv.gamePly = ply; psv.gamePly = ply;
} }
}
}
// Update the next move according to best search result or random move. // Update the next move according to best search result or random move.
auto random_move = choose_random_move(prng, pos, random_move_flag, ply, actual_random_move_count); auto random_move = choose_random_move(prng, pos, random_move_flag, ply, actual_random_move_count);
@@ -891,10 +820,6 @@ namespace Stockfish::Tools
UCI::setoption("PruneAtShallowDepth", "false"); UCI::setoption("PruneAtShallowDepth", "false");
UCI::setoption("EnableTranspositionTable", "true"); UCI::setoption("EnableTranspositionTable", "true");
} }
else if (token == "ensure_quiet")
{
params.ensure_quiet = true;
}
else else
{ {
cout << "ERROR: Unknown option " << token << ". Exiting...\n"; cout << "ERROR: Unknown option " << token << ". Exiting...\n";
@@ -912,12 +837,6 @@ namespace Stockfish::Tools
cout << "WARNING: Unknown sfen format `" << sfen_format << "`. Using bin\n"; 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) if (random_file_name)
{ {
// Give a random number to output_file_name at this point. // Give a random number to output_file_name at this point.