From 3a95f6d9a3be80795c095256b47c51be241df87e Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Wed, 25 Jul 2018 17:39:27 +0100 Subject: Update gen results script to work with changes --- .../input-output/input/command_line_helper.cpp | 17 +++------------ src/main/main.cpp | 25 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/main/input-output/input/command_line_helper.cpp b/src/main/input-output/input/command_line_helper.cpp index 65bbcd6..5a66aa6 100644 --- a/src/main/input-output/input/command_line_helper.cpp +++ b/src/main/input-output/input/command_line_helper.cpp @@ -52,8 +52,8 @@ command_line_helper::command_line_helper() ("streamliners", po::value(), "Applies streamliners to the search. Options include 'none', 'both', 'suit-symmetry'," " 'auto-foundations', and 'smart-solvability'. Defaults to 'none', unless '--solvability' is" - " also supplied, in which case defaults to 'smart-solvability'. 'smart-solvability' mode is only" - " available with '--solvability', and runs first with both streamliners and a 10% timeout. If this" + " also supplied, in which case defaults to 'smart-solvability'. 'smart-solvability' mode" + " runs first with both streamliners and a 10% timeout. If this" " is unsuccessful (unsolvable or timeout), then runs again without streamliners.") ("benchmark", "outputs performance statistics for the solver on the " "supplied solitaire game. Must supply " @@ -152,14 +152,7 @@ bool command_line_helper::parse(int argc, const char* argv[]) { if (s == "auto-foundations" ) streamliners = streamliner_opt::AUTO_FOUNDATIONS; else if (s == "suit-symmetry") streamliners = streamliner_opt::SUIT_SYMMETRY; else if (s == "both") streamliners = streamliner_opt::BOTH; - else if (s == "smart-solvability") { - if (solvability == -1) { - print_streamliner_solvability_error(); - return false; - } else { - streamliners = streamliner_opt::SMART; - } - } + else if (s == "smart-solvability") streamliners = streamliner_opt::SMART; else if (s == "none") streamliners = streamliner_opt::NONE; else { print_streamliner_error(s); @@ -260,10 +253,6 @@ void command_line_helper::print_streamliner_error(const string& str) { " 'auto-foundations', and 'smart-solvability'"); } -void command_line_helper::print_streamliner_solvability_error() { - LOG_ERROR ("Smart streamliner mode can only be used with '--solvability'"); -} - const vector command_line_helper::get_input_files() { return input_files; } diff --git a/src/main/main.cpp b/src/main/main.cpp index 55feedf..57540d6 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -125,13 +125,36 @@ void solve_input_files(const vector input_files, const sol_rules& rules, void solve_game(const game_state& gs, command_line_helper& clh, int seed) { solver solv(gs, clh.get_cache_capacity()); - solver::result result = solv.run(millisec(clh.get_timeout())); + solver::result result, streamliner_result; + bool smart = clh.get_streamliners() == command_line_helper::streamliner_opt::SMART; + bool run_again = false; + + if (smart) { + result = solv.run(millisec(clh.get_timeout() / 10)); + run_again = result.sol_type != solver::result::type::SOLVED; + if (run_again) + streamliner_result = solv.run(millisec(clh.get_timeout())); + } else { + result = solv.run(millisec(clh.get_timeout())); + } if (clh.get_classify()) { cout << seed; solver::print_result_csv(result); + if (smart) { + if (run_again) { + solver::print_result_csv(streamliner_result); + } else { + solver::print_null_seed_info(); + } + } cout << "\n"; } else { + if (run_again) { + cout << "Unsolvable using streamliner. Running again...\n"; + result = streamliner_result; + } + if (result.sol_type == solver::result::type::SOLVED) { solv.print_solution(); } else { -- cgit v1.2.1