diff options
Diffstat (limited to 'src/main/main.cpp')
| -rw-r--r-- | src/main/main.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/main/main.cpp b/src/main/main.cpp index 2de01d8..158ca07 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -3,10 +3,9 @@ #include <rapidjson/document.h> #include "input-output/command_line_helper.h" -#include "input-output/deal_parser.h" -#include "game/game_state.h" #include "solver/solver.h" #include "input-output/log_helper.h" +#include "util/util.h" using namespace rapidjson; @@ -17,7 +16,7 @@ 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(const vector<string>, const sol_rules); +void solve_input_files(const vector<string>, const sol_rules&); void solve_game(const game_state&, const sol_rules&); int main(int argc, const char* argv[]) { @@ -65,21 +64,27 @@ const optional<sol_rules> gen_rules(command_line_helper& clh) { void solve_random_game(int seed, const sol_rules& rules) { LOG_INFO ("Attempting to solve with seed: " << seed << "..."); - game_state gs(seed, rules); + game_state gs(rules, seed); solve_game(gs, rules); } -void solve_input_files(const vector<string> input_files, const sol_rules rules) { - for (const auto &input_json : input_files) { - // Attempts to read the user's json into a document - Document doc; - deal_parser::parse(doc, input_json); +void solve_input_files(const vector<string> input_files, const sol_rules& rules) { + for (const string& input_file : input_files) { + try { + // Reads in the input file to a json doc + const Document in_doc = util::get_file_json(input_file); - // Creates a game state object from the json, plus a solver - game_state gs(doc); + // Attempts to create a game state object from the json + game_state gs(rules, in_doc); - LOG_INFO ("Attempting to solve " << input_json << "..."); - solve_game(gs, rules); + LOG_INFO ("Attempting to solve " << input_file << "..."); + solve_game(gs, rules); + + } catch (const runtime_error& error) { + string errmsg = "Error parsing deal file: "; + errmsg += error.what(); + LOG_ERROR(errmsg); + } } } |
