aboutsummaryrefslogtreecommitdiff
path: root/src/main/input-output
diff options
context:
space:
mode:
authorthecharlesblake2018-03-08 22:42:35 +0000
committerthecharlesblake2018-03-08 22:42:35 +0000
commit4ae4a8a0832048d37e2593afa8f33f629fdae20e (patch)
tree616323e505d846aa827394883e6a2d1e0cdcdd54 /src/main/input-output
parentMerge pull request #42 from thecharlesblake/solvability-percentages (diff)
downloadmetasol-4ae4a8a0832048d37e2593afa8f33f629fdae20e.tar.gz
metasol-4ae4a8a0832048d37e2593afa8f33f629fdae20e.zip

Add ID search to solver for short sols

Diffstat (limited to 'src/main/input-output')
-rw-r--r--src/main/input-output/input/command_line_helper.cpp18
-rw-r--r--src/main/input-output/input/command_line_helper.h3
2 files changed, 21 insertions, 0 deletions
diff --git a/src/main/input-output/input/command_line_helper.cpp b/src/main/input-output/input/command_line_helper.cpp
index 05cb86e..7853b55 100644
--- a/src/main/input-output/input/command_line_helper.cpp
+++ b/src/main/input-output/input/command_line_helper.cpp
@@ -30,6 +30,8 @@ command_line_helper::command_line_helper()
("random", po::value<int>(), "create and solve a random solitaire "
"deal based on a seed. Must supply either 'random',"
"'solvability' or list of deals to be solved.")
+ ("shortest-sols", "for each instance returns the shortest possible "
+ "solution. cannot be supplied alongside '--solvability'")
("solvability", "calculates the solvability "
"percentage of the supplied solitaire game. Must supply "
"either 'random', 'solvability' or list of deals to be "
@@ -88,6 +90,8 @@ bool command_line_helper::parse(int argc, const char* argv[]) {
solvability = (vm.count("solvability") != 0);
+ shortest_sols = (vm.count("shortest-sols") != 0);
+
// Handle logic error scenarios
return assess_errors();
}
@@ -117,6 +121,11 @@ bool command_line_helper::assess_errors() {
return false;
}
+ if (shortest_sols && solvability) {
+ print_shortest_sols_error();
+ return false;
+ }
+
if (!solitaire_type.empty()) {
return assess_sol_type();
} else {
@@ -159,6 +168,11 @@ void command_line_helper::print_too_many_opts_error() {
print_help();
}
+void command_line_helper::print_shortest_sols_error() {
+ LOG_ERROR ("Error: User cannot supply '--shortest-sols' and '--solvability'");
+ print_help();
+}
+
const vector<string> command_line_helper::get_input_files() {
return input_files;
}
@@ -186,3 +200,7 @@ bool command_line_helper::get_classify() {
bool command_line_helper::get_solvability() {
return solvability;
}
+
+bool command_line_helper::get_short_sols() {
+ return shortest_sols;
+}
diff --git a/src/main/input-output/input/command_line_helper.h b/src/main/input-output/input/command_line_helper.h
index 36049bf..f3ed443 100644
--- a/src/main/input-output/input/command_line_helper.h
+++ b/src/main/input-output/input/command_line_helper.h
@@ -19,6 +19,7 @@ public:
bool get_help();
bool get_classify();
bool get_solvability();
+ bool get_short_sols();
private:
bool assess_errors();
@@ -27,6 +28,7 @@ private:
void print_sol_type_rules_error();
void print_no_opts_error();
void print_too_many_opts_error();
+ void print_shortest_sols_error();
boost::program_options::options_description cmdline_options;
boost::program_options::options_description main_options;
@@ -39,6 +41,7 @@ private:
bool help;
bool classify;
bool solvability;
+ bool shortest_sols;
};
#endif //SOLVITAIRE_COMMAND_LINE_HELPER_H