aboutsummaryrefslogtreecommitdiff
path: root/src/main/main.cpp
diff options
context:
space:
mode:
authorCharlie Blake2018-06-21 15:13:19 +0100
committerGitHub2018-06-21 15:13:19 +0100
commit4c617d49ce2fc162f25379df7715de34c0bbc349 (patch)
tree49d507a2024cdbbf68be95719ff60d4fee04fc99 /src/main/main.cpp
parentMerge pull request #64 from thecharlesblake/solvability-csv-output (diff)
parentFixup randomness (diff)
downloadmetasol-4c617d49ce2fc162f25379df7715de34c0bbc349.tar.gz
metasol-4c617d49ce2fc162f25379df7715de34c0bbc349.zip

Merge pull request #65 from thecharlesblake/solvability-improvements

Solvability improvements

Diffstat (limited to 'src/main/main.cpp')
-rw-r--r--src/main/main.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/main/main.cpp b/src/main/main.cpp
index a492c26..a6ed318 100644
--- a/src/main/main.cpp
+++ b/src/main/main.cpp
@@ -19,9 +19,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&, bool, uint64_t);
-void solve_input_files(vector<string>, const sol_rules&, bool, uint64_t);
-void solve_game(const game_state&, bool, uint64_t);
+void solve_random_game(int, const sol_rules&, command_line_helper&);
+void solve_input_files(vector<string>, const sol_rules&, command_line_helper&);
+void solve_game(const game_state&, command_line_helper&);
// Decides what to do given supplied command-line options
int main(int argc, const char* argv[]) {
@@ -51,15 +51,16 @@ int main(int argc, const char* argv[]) {
// If the user has asked for a solvability percentage, calculates it
if (clh.get_solvability() > 0) {
solvability_calc solv_c(*rules, clh.get_cache_capacity());
- solv_c.calculate_solvability_percentage(clh.get_solvability(), clh.get_cores(), clh.get_resume());
+ solv_c.calculate_solvability_percentage(clh.get_timeout(), clh.get_solvability(), clh.get_cores(),
+ clh.get_streamliners(), clh.get_resume());
}
// If a random deal seed has been supplied, solves it
else if (clh.get_random_deal() != -1) {
- solve_random_game(clh.get_random_deal(), *rules, clh.get_classify(), clh.get_cache_capacity());
+ solve_random_game(clh.get_random_deal(), *rules, clh);
}
// If the benchmark option has been supplied, generates it
else if (clh.get_benchmark()) {
- benchmark::run(*rules, clh.get_cache_capacity());
+ benchmark::run(*rules, clh.get_cache_capacity(), clh.get_streamliners());
}
// Otherwise there are supplied input files which should be solved
else {
@@ -67,8 +68,8 @@ int main(int argc, const char* argv[]) {
// If there are no input files, solve a random deal based on the
// supplied seed
- assert (!input_files.empty());
- solve_input_files(input_files, *rules, clh.get_classify(), clh.get_cache_capacity());
+ assert(!input_files.empty());
+ solve_input_files(input_files, *rules, clh);
}
return EXIT_SUCCESS;
@@ -90,24 +91,23 @@ const optional<sol_rules> gen_rules(command_line_helper& clh) {
}
}
-void solve_random_game(int seed, const sol_rules& rules, bool classify, uint64_t cache_capacity) {
+void solve_random_game(int seed, const sol_rules& rules, command_line_helper& clh) {
LOG_INFO ("Attempting to solve with seed: " << seed << "...");
- game_state gs(rules, seed);
- solve_game(gs, classify, cache_capacity);
+ game_state gs(rules, seed, clh.get_streamliners());
+ solve_game(gs, clh);
}
-void solve_input_files(const vector<string> input_files, const sol_rules& rules,
- bool classify, uint64_t cache_capacity) {
+void solve_input_files(const vector<string> input_files, const sol_rules& rules, command_line_helper& clh) {
for (const string& input_file : input_files) {
try {
// Reads in the input file to a json doc
const Document in_doc = json_helper::get_file_json(input_file);
// Attempts to create a game state object from the json
- game_state gs(rules, in_doc);
+ game_state gs(rules, in_doc, clh.get_streamliners());
LOG_INFO ("Attempting to solve " << input_file << "...");
- solve_game(gs, classify, cache_capacity);
+ solve_game(gs, clh);
} catch (const runtime_error& error) {
string errmsg = "Error parsing deal file: ";
@@ -117,16 +117,16 @@ void solve_input_files(const vector<string> input_files, const sol_rules& rules,
}
}
-void solve_game(const game_state& gs, bool classify, uint64_t cache_capacity) {
- solver solv(gs, cache_capacity);
+void solve_game(const game_state& gs, command_line_helper& clh) {
+ solver solv(gs, clh.get_cache_capacity());
bool solution = solv.run() == solver::sol_state::solved;
if (solution) {
- if (!classify) solv.print_solution();
+ if (!clh.get_classify()) solv.print_solution();
cout << "Solved\n";
} else {
- if (!classify) cout << "Deal:\n" << gs << "\n";
+ if (!clh.get_classify()) cout << "Deal:\n" << gs << "\n";
cout << "No Possible Solution\n";
}