diff options
| author | thecharlesblake | 2017-10-28 15:15:49 +0100 |
|---|---|---|
| committer | thecharlesblake | 2017-10-28 15:15:49 +0100 |
| commit | d472356d4e01c72e3b51deb28f694b9d0dd4fd6e (patch) | |
| tree | cf0f84f8eb51227712566bcdd535185c74d2a094 /src/main/main.cpp | |
| parent | Refactor game generation to make more generic (diff) | |
| download | metasol-d472356d4e01c72e3b51deb28f694b9d0dd4fd6e.tar.gz metasol-d472356d4e01c72e3b51deb28f694b9d0dd4fd6e.zip | |
Add rules class to represent solitaire type
Diffstat (limited to 'src/main/main.cpp')
| -rw-r--r-- | src/main/main.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/main/main.cpp b/src/main/main.cpp index 245b737..d39d35c 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -7,6 +7,7 @@ #include "deal_parser.h" #include "game_state.h" #include "solver.h" +#include "sol_rules.h" using namespace rapidjson; @@ -14,6 +15,8 @@ using namespace std; namespace po = boost::program_options; +void solve_game(const game_state&, const sol_rules&); + int main(int argc, const char* argv[]) { // Parses the command-line options command_line_helper clh; @@ -21,14 +24,14 @@ int main(int argc, const char* argv[]) { return 1; } + // Generates the rules of the solitaire from the game type + const sol_rules rules(clh.get_solitaire_type()); + int seed = clh.get_random_deal(); if (seed >= 0) { - game_state gs(seed, clh.get_solitaire_type()); - solver sol(gs); - cout << "Attempting to solve with seed: " << seed << "...\n"; - sol.run(); - cout << sol; + game_state gs(seed, sol_rules); + solve_game(gs, sol_rules); } for (auto input_json : clh.get_input_files()) { @@ -39,11 +42,9 @@ int main(int argc, const char* argv[]) { // Creates a game state object from the json, plus a solver game_state gs(doc, clh.get_solitaire_type()); - solver sol(gs); cout << "Attempting to solve " << input_json << "...\n"; - sol.run(); - cout << sol; + solve_game(gs, sol_rules); } catch (runtime_error& e) { cerr << "Error: " << e.what() << "\n"; @@ -52,3 +53,10 @@ int main(int argc, const char* argv[]) { return 0; } + +void solve_game(const game_state& gs, const sol_rules& rules) { + solver sol(gs, rules); + + sol.run(); + cout << sol; +} |
