aboutsummaryrefslogtreecommitdiff
path: root/src/main/main.cpp
diff options
context:
space:
mode:
authorthecharlesblake2018-02-22 23:05:00 +0000
committerthecharlesblake2018-02-22 23:05:00 +0000
commitbca053ac856431e594cf01dc6fda5e13bf1ecc28 (patch)
treed48c5dd201a2184031fcc601e5004c454ecb59d6 /src/main/main.cpp
parentAdd --classify to profiling instructions (diff)
downloadmetasol-bca053ac856431e594cf01dc6fda5e13bf1ecc28.tar.gz
metasol-bca053ac856431e594cf01dc6fda5e13bf1ecc28.zip

Add reduce suit streamliner: replace card symmetry

Diffstat (limited to 'src/main/main.cpp')
-rw-r--r--src/main/main.cpp38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/main/main.cpp b/src/main/main.cpp
index 975e6c8..be03e02 100644
--- a/src/main/main.cpp
+++ b/src/main/main.cpp
@@ -18,9 +18,9 @@ using namespace boost;
namespace po = boost::program_options;
const optional<sol_rules> gen_rules(command_line_helper&);
-void solve_random_game(int, const sol_rules&);
-void solve_input_files(vector<string>, const sol_rules&);
-void solve_game(const game_state&);
+void solve_random_game(int, const sol_rules&, bool);
+void solve_input_files(vector<string>, const sol_rules&, bool);
+void solve_game(const game_state&, bool);
int main(int argc, const char* argv[]) {
@@ -40,11 +40,11 @@ int main(int argc, const char* argv[]) {
// If there are no input files, solve a random deal based on the
// supplied seed
if (input_files.empty()) {
- solve_random_game(clh.get_random_deal(), *rules);
+ solve_random_game(clh.get_random_deal(), *rules, clh.get_classify());
}
// Otherwise, solve the input files
else {
- solve_input_files(input_files, *rules);
+ solve_input_files(input_files, *rules, clh.get_classify());
}
return EXIT_SUCCESS;
@@ -65,13 +65,14 @@ const optional<sol_rules> gen_rules(command_line_helper& clh) {
}
}
-void solve_random_game(int seed, const sol_rules& rules) {
+void solve_random_game(int seed, const sol_rules& rules, bool classify) {
LOG_INFO ("Attempting to solve with seed: " << seed << "...");
game_state gs(rules, seed);
- solve_game(gs);
+ solve_game(gs, classify);
}
-void solve_input_files(const vector<string> input_files, const sol_rules& rules) {
+void solve_input_files(const vector<string> input_files, const sol_rules& rules,
+ bool classify) {
for (const string& input_file : input_files) {
try {
// Reads in the input file to a json doc
@@ -81,7 +82,7 @@ void solve_input_files(const vector<string> input_files, const sol_rules& rules)
game_state gs(rules, in_doc);
LOG_INFO ("Attempting to solve " << input_file << "...");
- solve_game(gs);
+ solve_game(gs, classify);
} catch (const runtime_error& error) {
string errmsg = "Error parsing deal file: ";
@@ -91,15 +92,24 @@ void solve_input_files(const vector<string> input_files, const sol_rules& rules)
}
}
-void solve_game(const game_state& gs) {
+void solve_game(const game_state& gs, bool classify) {
solver solv(gs);
bool solution = solv.run();
ProfilerStop();
- if (solution) {
- solv.print_solution();
+ if (classify) {
+ if (solution) {
+ cout << "Solved\n";
+ } else {
+ cout << "No solution\n";
+ }
} else {
- cout << "Deal:\n" << gs << "\nNo Possible Solution\nStates Searched: "
- << solv.get_states_searched() << "\n";
+ if (solution) {
+ solv.print_solution();
+ } else {
+ cout << "Deal:\n" << gs
+ << "\nNo Possible Solution\nStates Searched: "
+ << solv.get_states_searched() << "\n";
+ }
}
}