From 1401b0cfa53e1b1f550a2128a9d72afb52575435 Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Thu, 14 Jun 2018 10:55:55 +0100 Subject: Simplify solvability script and make atomic --- src/main/input-output/input/command_line_helper.cpp | 14 +++++++++----- src/main/input-output/input/command_line_helper.h | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src/main/input-output') diff --git a/src/main/input-output/input/command_line_helper.cpp b/src/main/input-output/input/command_line_helper.cpp index e88f434..0f685cb 100644 --- a/src/main/input-output/input/command_line_helper.cpp +++ b/src/main/input-output/input/command_line_helper.cpp @@ -40,8 +40,8 @@ command_line_helper::command_line_helper() "classification") ("cache-capacity", po::value(), "sets an upper bound on the number of states allowed in " "the cache") - ("solvability", "calculates the solvability " - "percentage of the supplied solitaire game. Must supply " + ("solvability", po::value(), "calculates the solvability " + "percentage of the supplied solitaire game, given a timeout in milliseconds. Must supply " "either 'random', 'benchmark', 'solvability' or list of deals to be " "solved.") ("benchmark", "outputs performance statistics for the solver on the " @@ -110,7 +110,11 @@ bool command_line_helper::parse(int argc, const char* argv[]) { cache_capacity = 100000000; // One hundred-million } - solvability = (vm.count("solvability") != 0); + if (vm.count("solvability")) { + solvability = vm["solvability"].as(); + } else { + solvability = -1; + } benchmark = (vm.count("benchmark") != 0); @@ -128,7 +132,7 @@ bool command_line_helper::assess_errors() { // The user must either supply input files, a random seed, or ask for the // solvability percentage, or benchmark - int opt_count = (random_deal != -1) + !input_files.empty() + solvability + benchmark; + int opt_count = (random_deal != -1) + !input_files.empty() + (solvability > 0) + benchmark; if (opt_count > 1) { print_too_many_opts_error(); @@ -211,7 +215,7 @@ uint64_t command_line_helper::get_cache_capacity() { return cache_capacity; } -bool command_line_helper::get_solvability() { +int command_line_helper::get_solvability() { return solvability; } diff --git a/src/main/input-output/input/command_line_helper.h b/src/main/input-output/input/command_line_helper.h index ca58d5f..5220895 100644 --- a/src/main/input-output/input/command_line_helper.h +++ b/src/main/input-output/input/command_line_helper.h @@ -17,7 +17,7 @@ public: const std::string get_rules_file(); int get_random_deal(); bool get_classify(); - bool get_solvability(); + int get_solvability(); bool get_available_game_types(); bool get_benchmark(); uint64_t get_cache_capacity(); @@ -42,7 +42,7 @@ private: int random_deal; bool help; bool classify; - bool solvability; + int solvability; bool available_game_types; bool benchmark; uint64_t cache_capacity; -- cgit v1.2.1