aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorthecharlesblake2017-11-12 09:52:23 +0000
committerthecharlesblake2017-11-12 09:52:23 +0000
commitb1809820b192fb93e95daa50c5993da0b35fa03d (patch)
treebc71e701fdcee991991fee88a2071249ec5d9d4b /src
parentMake log macros proper functions (diff)
downloadmetasol-b1809820b192fb93e95daa50c5993da0b35fa03d.tar.gz
metasol-b1809820b192fb93e95daa50c5993da0b35fa03d.zip

Solution output printing moved to main

Diffstat (limited to 'src')
-rw-r--r--src/main/main.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/main/main.cpp b/src/main/main.cpp
index 803b587..d748c80 100644
--- a/src/main/main.cpp
+++ b/src/main/main.cpp
@@ -1,4 +1,5 @@
#include <boost/program_options.hpp>
+#include <boost/optional.hpp>
#include <rapidjson/document.h>
#include "input-output/command_line_helper.h"
@@ -10,6 +11,7 @@
using namespace rapidjson;
using namespace std;
+using namespace boost;
namespace po = boost::program_options;
@@ -44,7 +46,7 @@ int main(int argc, const char* argv[]) {
}
void solve_random_game(int seed, const sol_rules& rules) {
- LOG_INFO << "Attempting to solve with seed: " << seed << "...\n";
+ LOG_INFO ("Attempting to solve with seed: " << seed << "...");
game_state gs(seed, rules);
solve_game(gs, rules);
}
@@ -58,7 +60,7 @@ void solve_input_files(const vector<string> input_files, const sol_rules rules)
// Creates a game state object from the json, plus a solver
game_state gs(doc);
- LOG_INFO << "Attempting to solve " << input_json << "...\n";
+ LOG_INFO ("Attempting to solve " << input_json << "...");
solve_game(gs, rules);
}
}
@@ -66,6 +68,11 @@ void solve_input_files(const vector<string> input_files, const sol_rules rules)
void solve_game(const game_state& gs, const sol_rules& rules) {
solver sol(gs, rules);
- sol.run();
- cout << sol;
+ optional<solver::node> solution = sol.run();
+ if (solution) {
+ cout << "Solution:\n" << *solution << "States Searched: "
+ << sol.get_states_searched() << "\n";
+ } else {
+ cout << "Deal:\n" << sol.get_root() << "\nNo Possible Solution\n";
+ }
}