From 2061be473047b8d6703c70495b52eb34ea70c441 Mon Sep 17 00:00:00 2001 From: Tomasz Sobczyk Date: Thu, 17 Dec 2020 16:12:26 +0100 Subject: [PATCH] smart_fen_skipping at gensfen_nonpv level --- docs/gensfen_nonpv.md | 2 ++ src/learn/gensfen_nonpv.cpp | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/docs/gensfen_nonpv.md b/docs/gensfen_nonpv.md index 29dc1f17..0459d607 100644 --- a/docs/gensfen_nonpv.md +++ b/docs/gensfen_nonpv.md @@ -32,6 +32,8 @@ Currently the following options are available: `exploration_max_ply` the max ply for the exploration self play. Default: 200. +`smart_fen_skipping` - this is a flag option. When specified some position that are not good candidates for teaching are removed from the output. This includes positions where the best move is a capture or promotion, and position where a king is in check. + `book` - a path to an opening book to use for the starting positions. Currently only .epd format is supported. If not specified then the starting position is always the standard chess starting position. `sfen_format` - format of the training data to use. Either `bin` or `binpack`. Default: `binpack`. diff --git a/src/learn/gensfen_nonpv.cpp b/src/learn/gensfen_nonpv.cpp index a5c667b5..ca365034 100644 --- a/src/learn/gensfen_nonpv.cpp +++ b/src/learn/gensfen_nonpv.cpp @@ -72,6 +72,8 @@ namespace Learner std::string book; + bool smart_fen_skipping = false; + void enforce_constraints() { // Limit the maximum to a one-stop score. (Otherwise you might not end the loop) @@ -281,6 +283,12 @@ namespace Learner { pos.set_from_packed_sfen(ps.sfen, &si, &th); pos.state()->rule50 = 0; + + if (params.smart_fen_skipping && pos.checkers()) + { + continue; + } + auto [search_value, search_pv] = Search::search(pos, params.search_depth, 1); if (search_pv.empty()) @@ -293,6 +301,11 @@ namespace Learner continue; } + if (params.smart_fen_skipping && pos.capture_or_promotion(search_pv[0])) + { + continue; + } + auto& new_ps = psv.emplace_back(); pos.sfen_pack(new_ps.sfen); new_ps.score = search_value; @@ -418,6 +431,8 @@ namespace Learner is >> sfen_format; else if (token == "seed") is >> params.seed; + else if (token == "smart_fen_skipping") + params.smart_fen_skipping = true; else if (token == "set_recommended_uci_options") { UCI::setoption("Contempt", "0");