aboutsummaryrefslogtreecommitdiff
path: root/src/main/input-output
diff options
context:
space:
mode:
authorCharlie Blake2018-06-14 10:55:55 +0100
committerCharlie Blake2018-06-14 10:55:55 +0100
commit1401b0cfa53e1b1f550a2128a9d72afb52575435 (patch)
treec30bf5f74a59b6f953501f17399ec4db72cd2047 /src/main/input-output
parentMerge pull request #60 from thecharlesblake/cache-mem-limit (diff)
downloadmetasol-1401b0cfa53e1b1f550a2128a9d72afb52575435.tar.gz
metasol-1401b0cfa53e1b1f550a2128a9d72afb52575435.zip

Simplify solvability script and make atomic

Diffstat (limited to 'src/main/input-output')
-rw-r--r--src/main/input-output/input/command_line_helper.cpp14
-rw-r--r--src/main/input-output/input/command_line_helper.h4
2 files changed, 11 insertions, 7 deletions
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<uint64_t>(), "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<int>(), "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<int>();
+ } 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;