aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/evaluation/benchmark.cpp6
-rw-r--r--src/main/evaluation/benchmark.h3
-rw-r--r--src/main/evaluation/solvability_calc.cpp94
-rw-r--r--src/main/evaluation/solvability_calc.h14
-rw-r--r--src/main/game/global_cache.cpp10
-rw-r--r--src/main/game/search-state/game_state.auto_foundation_moves.cpp6
-rw-r--r--src/main/game/search-state/game_state.cpp15
-rw-r--r--src/main/game/search-state/game_state.h10
-rw-r--r--src/main/input-output/input/command_line_helper.cpp61
-rw-r--r--src/main/input-output/input/command_line_helper.h10
-rw-r--r--src/main/main.cpp9
11 files changed, 165 insertions, 73 deletions
diff --git a/src/main/evaluation/benchmark.cpp b/src/main/evaluation/benchmark.cpp
index 83207fb..9e1b7a9 100644
--- a/src/main/evaluation/benchmark.cpp
+++ b/src/main/evaluation/benchmark.cpp
@@ -13,11 +13,11 @@
using namespace std;
typedef chrono::microseconds microsec;
-void benchmark::run(const sol_rules &rules, uint64_t cache_capacity, bool streamliners) {
+void benchmark::run(const sol_rules &rules, uint64_t cache_capacity, game_state::streamliner_options streamliners) {
cout << "Seed "
- "| Median/Mean Solution Time(μs)"
+ "| Median/Mean Solution Time(μs) "
"| Median/Mean States Searched "
- "| Solvable/Unsolvable ";
+ "| Solvable/Unsolvable";
multiset<int> sol_times;
multiset<int> states_searched;
diff --git a/src/main/evaluation/benchmark.h b/src/main/evaluation/benchmark.h
index 70a5b76..b7b9a1d 100644
--- a/src/main/evaluation/benchmark.h
+++ b/src/main/evaluation/benchmark.h
@@ -8,10 +8,11 @@
#include <chrono>
#include "../game/sol_rules.h"
+#include "../game/search-state/game_state.h"
class benchmark {
public:
- static void run(const sol_rules &rules, uint64_t, bool);
+ static void run(const sol_rules &rules, uint64_t, game_state::streamliner_options);
};
diff --git a/src/main/evaluation/solvability_calc.cpp b/src/main/evaluation/solvability_calc.cpp
index b576548..1f1e76b 100644
--- a/src/main/evaluation/solvability_calc.cpp
+++ b/src/main/evaluation/solvability_calc.cpp
@@ -12,6 +12,9 @@
using namespace std;
using boost::optional;
+typedef command_line_helper::streamliner_opt cmd_sos;
+typedef game_state::streamliner_options sos;
+
///////////////////
// SETUP METHODS //
///////////////////
@@ -24,15 +27,16 @@ solvability_calc::solvability_calc(const sol_rules& r, uint64_t cache_capacity_)
// PRINTING METHODS //
//////////////////////
-void solvability_calc::print_header(long t, bool streamliners) const {
+void solvability_calc::print_header(long t, cmd_sos stream_opt) const {
cout << "Calculating solvability percentage...\n\n"
"Lower Bound"
", Upper Bound"
", Solvable"
", Unsolvable"
- ", Intractable, ";
- if (streamliners) {
- cout << "(Streamliner Results:) "
+ ", Timed-out"
+ ", Memory Limited, ";
+ if (stream_opt == cmd_sos::SMART) {
+ cout << "| (Streamliner Results:) "
"Attempted Seed"
", Outcome"
", Time Taken(ms)"
@@ -45,7 +49,7 @@ void solvability_calc::print_header(long t, bool streamliners) const {
", Final Buckets In Cache"
", Maximum Search Depth"
", Final Search Depth"
- "(Non-Streamliner Results:) ";
+ "| (Non-Streamliner Results:) ";
}
cout << "Attempted Seed"
", Outcome"
@@ -68,27 +72,31 @@ void solvability_calc::print_general_info(const seed_results& seed_res) {
pair<double, double> interval = binomial_ci::wilson(
seed_res.solvable,
seed_res.unsolvable,
- seed_res.intractable);
+ (seed_res.timed_out + seed_res.mem_limit));
cout << interval.first * 100
<< ", " << interval.second * 100
<< ", " << seed_res.solvable
<< ", " << seed_res.unsolvable
- << ", " << seed_res.intractable;
+ << ", " << seed_res.timed_out
+ << ", " << seed_res.mem_limit;
}
void solvability_calc::print_seed_info(sol_result res) {
cout << ", " << res.seed;
switch (res.sol_type) {
- case sol_result::type::timeout:
+ case sol_result::type::TIMEOUT:
cout << ", timed-out";
break;
- case sol_result::type::solved:
+ case sol_result::type::SOLVED:
cout << ", solved";
break;
- case sol_result::type::unsolvable:
+ case sol_result::type::UNSOLVABLE:
cout << ", unsolvable";
break;
+ case sol_result::type::MEM_LIMIT:
+ cout << ", mem-limit";
+ break;
}
cout << ", " << res.time.count();
@@ -124,7 +132,7 @@ void solvability_calc::print_seeds_in_prog(std::set<int>& seeds_in_progress) {
/////////////////////
void solvability_calc::calculate_solvability_percentage(uint64_t timeout_, int seed_count, uint cores,
- bool streamliners, const vector<int>& resume) {
+ cmd_sos stream_opt, const vector<int>& resume) {
vector<int> resume_seeds(begin(resume) + 3, end(resume));
sort(begin(resume_seeds), end(resume_seeds));
@@ -136,7 +144,7 @@ void solvability_calc::calculate_solvability_percentage(uint64_t timeout_, int s
mutex results_mutex;
millisec timeout(timeout_);
- print_header(timeout.count(), streamliners);
+ print_header(timeout.count(), stream_opt);
// Spin off 'cores' threads. Each one runs solve_seed and then print_row repeatedly, taking the seed from am
// atomic int
@@ -149,7 +157,7 @@ void solvability_calc::calculate_solvability_percentage(uint64_t timeout_, int s
futures.push_back(async(
launch::async,
[&current_seed, &seed_res, &seeds_in_progress, &results_mutex, seed_count, timeout, sr, cc, i,
- resume_seeds, streamliners](){
+ resume_seeds, stream_opt](){
int my_seed = resume_seeds.size() > i ? resume_seeds[i] : current_seed++;
@@ -161,16 +169,22 @@ void solvability_calc::calculate_solvability_percentage(uint64_t timeout_, int s
optional<sol_result> stream_res, no_stream_res;
sol_result final_res;
- if (streamliners) {
- stream_res = solve_seed(my_seed, timeout, sr, cc, true);
- if (stream_res->sol_type == sol_result::type::unsolvable) {
- no_stream_res = solve_seed(my_seed, timeout, sr, cc, false);
- final_res = *no_stream_res;
- } else {
- final_res = *stream_res;
+ if (stream_opt == cmd_sos::SMART) {
+ stream_res = solve_seed(my_seed, (timeout/10), sr, cc, sos::BOTH);
+
+ switch (stream_res->sol_type) {
+ case sol_result::type::UNSOLVABLE:
+ case sol_result::type::TIMEOUT:
+ no_stream_res = solve_seed(my_seed, timeout, sr, cc, sos::NONE);
+ final_res = *no_stream_res;
+ break;
+ default:
+ final_res = *stream_res;
+ break;
}
} else {
- no_stream_res = solve_seed(my_seed, timeout, sr, cc, false);
+ no_stream_res = solve_seed(my_seed, timeout, sr, cc,
+ command_line_helper::convert_streamliners(stream_opt));
final_res = *no_stream_res;
}
@@ -180,7 +194,7 @@ void solvability_calc::calculate_solvability_percentage(uint64_t timeout_, int s
seed_res.add_result(final_res.sol_type);
print_general_info(seed_res);
- if (streamliners) {
+ if (stream_opt == cmd_sos::SMART) {
print_seed_info(*stream_res);
if (no_stream_res) print_seed_info(*no_stream_res);
else print_null_seed_info();
@@ -201,8 +215,9 @@ void solvability_calc::calculate_solvability_percentage(uint64_t timeout_, int s
}
solvability_calc::sol_result solvability_calc::solve_seed(int seed, millisec timeout, const sol_rules& rules,
- uint64_t cache_capacity, bool streamliners) {
- game_state gs(rules, seed, streamliners);
+ uint64_t cache_capacity,
+ game_state::streamliner_options stream_opt) {
+ game_state gs(rules, seed, stream_opt);
solver sol(gs, cache_capacity);
atomic<bool> terminate_solver(false);
@@ -234,24 +249,24 @@ solvability_calc::sol_result solvability_calc::solve_seed(int seed, millisec tim
exception = true;
}
+ auto end = chrono::steady_clock::now();
+ millisec elapsed_millis =
+ chrono::duration_cast<chrono::milliseconds>(end - start);
+
if (exception) {
- res.sol_type = sol_result::type::timeout;
- res.time = timeout;
+ res.sol_type = sol_result::type::MEM_LIMIT;
+ res.time = elapsed_millis;
res.sol_info = get<1>(result);
} else if (terminate_solver) {
- res.sol_type = sol_result::type::timeout;
+ res.sol_type = sol_result::type::TIMEOUT;
res.time = timeout;
res.sol_info = get<1>(result);
} else {
- auto end = chrono::steady_clock::now();
- millisec elapsed_millis =
- chrono::duration_cast<chrono::milliseconds>(end - start);
res.time = elapsed_millis;
-
if (get<0>(result)) {
- res.sol_type = sol_result::type::solved;
+ res.sol_type = sol_result::type::SOLVED;
} else {
- res.sol_type = sol_result::type::unsolvable;
+ res.sol_type = sol_result::type::UNSOLVABLE;
}
res.sol_info = get<1>(result);
}
@@ -266,19 +281,22 @@ solvability_calc::sol_result solvability_calc::solve_seed(int seed, millisec tim
// SEED RESULTS CLASS //
////////////////////////
-solvability_calc::seed_results::seed_results(vector<int> v) : solvable(v[0]), unsolvable(v[1]), intractable(v[2]) {
+solvability_calc::seed_results::seed_results(vector<int> v) : solvable(v[0]), unsolvable(v[1]), timed_out(v[2]) {
}
void solvability_calc::seed_results::add_result(sol_result::type t) {
switch (t) {
- case sol_result::type::timeout:
- intractable++;
+ case sol_result::type::TIMEOUT:
+ timed_out++;
break;
- case sol_result::type::solved:
+ case sol_result::type::SOLVED:
solvable++;
break;
- case sol_result::type::unsolvable:
+ case sol_result::type::UNSOLVABLE:
unsolvable++;
break;
+ case sol_result::type ::MEM_LIMIT:
+ mem_limit++;
+ break;
}
}
diff --git a/src/main/evaluation/solvability_calc.h b/src/main/evaluation/solvability_calc.h
index 9307649..3d01c1b 100644
--- a/src/main/evaluation/solvability_calc.h
+++ b/src/main/evaluation/solvability_calc.h
@@ -12,18 +12,19 @@
#include "../game/sol_rules.h"
#include "../solver/solver.h"
+#include "../input-output/input/command_line_helper.h"
class solvability_calc {
public:
explicit solvability_calc(const sol_rules&, uint64_t);
- void calculate_solvability_percentage(uint64_t, int, uint, bool, const std::vector<int>&);
+ void calculate_solvability_percentage(uint64_t, int, uint, command_line_helper::streamliner_opt, const std::vector<int>&);
private:
typedef std::chrono::milliseconds millisec;
struct sol_result {
- enum class type { timeout, solved, unsolvable };
+ enum class type { TIMEOUT, SOLVED, UNSOLVABLE, MEM_LIMIT };
int seed;
type sol_type;
@@ -37,20 +38,19 @@ private:
std::atomic<int> solvable;
std::atomic<int> unsolvable;
- std::atomic<int> intractable;
- //millisec solvable_time;
- //millisec unsolvable_time;
+ std::atomic<int> timed_out;
+ std::atomic<int> mem_limit;
};
// Printing methods
- void print_header(long, bool) const;
+ void print_header(long, command_line_helper::streamliner_opt) const;
static void print_general_info(const seed_results&);
static void print_seed_info(sol_result);
static void print_null_seed_info();
static void print_seeds_in_prog(std::set<int>&);
// Solving methods
- static sol_result solve_seed(int, millisec, const sol_rules&, uint64_t, bool);
+ static sol_result solve_seed(int, millisec, const sol_rules&, uint64_t, game_state::streamliner_options);
const sol_rules& rules;
const uint64_t cache_capacity;
diff --git a/src/main/game/global_cache.cpp b/src/main/game/global_cache.cpp
index 2cec338..ee2a2b8 100644
--- a/src/main/game/global_cache.cpp
+++ b/src/main/game/global_cache.cpp
@@ -8,12 +8,14 @@
#include "global_cache.h"
#include "../input-output/output/log_helper.h"
+#include "search-state/game_state.h"
using namespace std;
using namespace boost;
typedef sol_rules::build_policy pol;
typedef sol_rules::stock_deal_type sdt;
+typedef game_state::streamliner_options sos;
typedef boost::multi_index::multi_index_container<
cached_game_state,
@@ -81,7 +83,9 @@ void cached_game_state::add_card(card c, const game_state& gs) {
// If the game is a 'hole-based' game, or suit-reduction is on, reduces
// the cached suit of the card where possible
- bool is_suit_symmetry = gs.streamliners || gs.rules.hole;
+ bool is_suit_symmetry = gs.stream_opts == sos::SUIT_SYMMETRY
+ || gs.stream_opts == sos::BOTH
+ || gs.rules.hole;
if (is_suit_symmetry) {
switch (gs.rules.build_pol) {
@@ -135,7 +139,9 @@ size_t hasher::hash_value(card const& c) const {
// If the game is a 'hole-based' game, or suit-reduction is enabled, hash
// the reduced suit
- bool is_suit_symmetry = init_gs.streamliners || init_gs.rules.hole;
+ bool is_suit_symmetry = init_gs.stream_opts == sos::SUIT_SYMMETRY
+ || init_gs.stream_opts == sos::BOTH
+ || init_gs.rules.hole;
uint8_t suit_val;
if (is_suit_symmetry) {
diff --git a/src/main/game/search-state/game_state.auto_foundation_moves.cpp b/src/main/game/search-state/game_state.auto_foundation_moves.cpp
index 99b43a2..43f8911 100644
--- a/src/main/game/search-state/game_state.auto_foundation_moves.cpp
+++ b/src/main/game/search-state/game_state.auto_foundation_moves.cpp
@@ -6,6 +6,7 @@
typedef sol_rules::build_policy pol;
+typedef game_state::streamliner_options sos;
using std::max;
@@ -13,7 +14,10 @@ using std::max;
bool game_state::is_valid_auto_foundation_move(pile::ref target_pile) const {
if (rules.foundations_comp_piles)
return false;
- else if (streamliners || rules.build_pol == pol::NO_BUILD || rules.build_pol == pol::SAME_SUIT)
+ else if ( stream_opts == sos::AUTO_FOUNDATIONS
+ || stream_opts == sos::BOTH
+ || rules.build_pol == pol::NO_BUILD
+ || rules.build_pol == pol::SAME_SUIT)
return true;
card::suit_t target_suit(target_pile - foundations.front());
diff --git a/src/main/game/search-state/game_state.cpp b/src/main/game/search-state/game_state.cpp
index 276d582..a1d60bf 100644
--- a/src/main/game/search-state/game_state.cpp
+++ b/src/main/game/search-state/game_state.cpp
@@ -37,6 +37,7 @@ using std::string;
typedef sol_rules::build_policy pol;
typedef sol_rules::stock_deal_type sdt;
typedef sol_rules::face_up_policy fu;
+typedef game_state::streamliner_options sos;
//////////////////
// CONSTRUCTORS //
@@ -44,9 +45,9 @@ typedef sol_rules::face_up_policy fu;
// A private constructor used by both of the public ones. Initializes all of the
// piles and pile refs specified by the rules
-game_state::game_state(const sol_rules& s_rules, bool streamliners_)
+game_state::game_state(const sol_rules& s_rules, streamliner_options stream_opts_)
: rules(s_rules)
- , streamliners(streamliners_)
+ , stream_opts(stream_opts_)
, stock(255)
, waste(255)
, hole (255) {
@@ -106,14 +107,14 @@ game_state::game_state(const sol_rules& s_rules, bool streamliners_)
}
// Constructs an initial game state from a JSON doc
-game_state::game_state(const sol_rules& s_rules, const Document& doc, bool streamliners_)
- : game_state(s_rules, streamliners_) {
+game_state::game_state(const sol_rules& s_rules, const Document& doc, streamliner_options s_opts)
+ : game_state(s_rules, s_opts) {
deal_parser::parse(*this, doc);
}
// Constructs an initial game state from a seed
-game_state::game_state(const sol_rules& s_rules, int seed, bool streamliners_)
- : game_state(s_rules, streamliners_) {
+game_state::game_state(const sol_rules& s_rules, int seed, streamliner_options s_opts)
+ : game_state(s_rules, s_opts) {
vector<card> deck = gen_shuffled_deck(seed, rules.max_rank, rules.two_decks);
// If there is a hole, moves the ace of spades to it
@@ -198,7 +199,7 @@ game_state::game_state(const sol_rules& s_rules, int seed, bool streamliners_)
game_state::game_state(const sol_rules& s_rules,
std::initializer_list<std::initializer_list<string>> il)
- : game_state(s_rules, false) {pile::ref pr = 0;
+ : game_state(s_rules, sos::NONE) {pile::ref pr = 0;
for (auto& p_il : il) {
for (const string& card_str : p_il) {
card c(card_str.c_str(), s_rules.face_up == fu::TOP_CARDS);
diff --git a/src/main/game/search-state/game_state.h b/src/main/game/search-state/game_state.h
index 78f1fb9..ecb8ace 100644
--- a/src/main/game/search-state/game_state.h
+++ b/src/main/game/search-state/game_state.h
@@ -26,12 +26,14 @@ class game_state {
friend class state_printer;
friend class test_helper;
public:
+ enum class streamliner_options {NONE, AUTO_FOUNDATIONS, SUIT_SYMMETRY, BOTH};
+
/* Constructors */
// Creates a game state representation from a JSON doc
- game_state(const sol_rules&, const rapidjson::Document&, bool);
+ game_state(const sol_rules&, const rapidjson::Document&, streamliner_options);
// Does the same from a seed
- game_state(const sol_rules&, int seed, bool);
+ game_state(const sol_rules&, int seed, streamliner_options);
// Does the same but with an initialiser list (useful for testing)
game_state(const sol_rules&, std::initializer_list<std::initializer_list<std::string>>);
@@ -59,7 +61,7 @@ public:
private:
/* Constructors (& helper function) */
- explicit game_state(const sol_rules&, bool);
+ explicit game_state(const sol_rules&, streamliner_options);
static std::vector<card> gen_shuffled_deck(int, card::rank_t, bool);
template<class RandomIt, class URBG> static void shuffle(RandomIt, RandomIt, URBG&&);
@@ -124,7 +126,7 @@ private:
/* Game rules */
const sol_rules rules;
- bool streamliners;
+ streamliner_options stream_opts;
/* Pile references */
diff --git a/src/main/input-output/input/command_line_helper.cpp b/src/main/input-output/input/command_line_helper.cpp
index ec9a375..67224d2 100644
--- a/src/main/input-output/input/command_line_helper.cpp
+++ b/src/main/input-output/input/command_line_helper.cpp
@@ -49,9 +49,12 @@ command_line_helper::command_line_helper()
"Syntax: [sol unsol intract in-progress-1 in-progress-2 ...]")
("cores", po::value<uint>(), "the number of cores for the solvability percentages to be run across. "
"Must be supplied with the solvability option.")
- ("streamliners", "applies any relevant streamliners to the search. If the --solvability option is supplied,"
- " runs the streamliner version of the search first and then if unsuccessful, the full"
- " search for each seed.")
+ ("streamliners", po::value<string>(),
+ "Applies streamliners to the search. Options include 'none', 'both', 'suit-symmetry',"
+ " 'auto-foundations', and 'smart-solvability'. Defaults to 'none', unless '--solvability' is"
+ " also supplied, in which case defaults to 'smart-solvability'. 'smart-solvability' mode is only"
+ " available with '--solvability', and runs first with both streamliners and a 10% timeout. If this"
+ " is unsuccessful (unsolvable or timeout), then runs again without streamliners.")
("benchmark", "outputs performance statistics for the solver on the "
"supplied solitaire game. Must supply "
"either 'random', 'benchmark', 'solvability' or list of deals to be "
@@ -143,7 +146,29 @@ bool command_line_helper::parse(int argc, const char* argv[]) {
for (uint i = 0; i < cores; i++) resume.push_back(i);
}
- streamliners = (vm.count("streamliners") != 0);
+ if (vm.count("streamliners")) {
+ auto& s = vm["streamliners"].as<string>();
+
+ if (s == "auto-foundations" ) streamliners = streamliner_opt::AUTO_FOUNDATIONS;
+ else if (s == "suit-symmetry") streamliners = streamliner_opt::SUIT_SYMMETRY;
+ else if (s == "both") streamliners = streamliner_opt::BOTH;
+ else if (s == "smart-solvability") {
+ if (solvability == -1) {
+ print_streamliner_solvability_error();
+ return false;
+ } else {
+ streamliners = streamliner_opt::SMART;
+ }
+ }
+ else if (s == "none") streamliners = streamliner_opt::NONE;
+ else {
+ print_streamliner_error(s);
+ return false;
+ }
+ } else {
+ if (solvability == -1) streamliners = streamliner_opt::NONE;
+ else streamliners = streamliner_opt::SMART;
+ }
benchmark = (vm.count("benchmark") != 0);
@@ -230,6 +255,15 @@ void command_line_helper::print_resume_error() {
print_help();
}
+void command_line_helper::print_streamliner_error(const string& str) {
+ LOG_ERROR ("Error: invalid streamliner: " + str + ".\nAvailable options are: 'none', 'both', 'suit-symmetry',"
+ " 'auto-foundations', and 'smart-solvability'");
+}
+
+void command_line_helper::print_streamliner_solvability_error() {
+ LOG_ERROR ("Smart streamliner mode can only be used with '--solvability'");
+}
+
const vector<string> command_line_helper::get_input_files() {
return input_files;
}
@@ -282,6 +316,23 @@ bool command_line_helper::get_benchmark() {
return benchmark;
}
-bool command_line_helper::get_streamliners() {
+command_line_helper::streamliner_opt command_line_helper::get_streamliners() {
return streamliners;
}
+
+game_state::streamliner_options command_line_helper::get_streamliners_game_state() {
+ return convert_streamliners(streamliners);
+}
+
+game_state::streamliner_options command_line_helper::convert_streamliners(streamliner_opt so) {
+ switch (so){
+ case command_line_helper::streamliner_opt::NONE: return game_state::streamliner_options::NONE;
+ case command_line_helper::streamliner_opt::AUTO_FOUNDATIONS: return game_state::streamliner_options::AUTO_FOUNDATIONS;
+ case command_line_helper::streamliner_opt::SUIT_SYMMETRY: return game_state::streamliner_options::SUIT_SYMMETRY;
+ case command_line_helper::streamliner_opt::BOTH: return game_state::streamliner_options::BOTH;
+ case command_line_helper::streamliner_opt::SMART:
+ default:
+ assert(false);
+ return game_state::streamliner_options::NONE;;
+ }
+}
diff --git a/src/main/input-output/input/command_line_helper.h b/src/main/input-output/input/command_line_helper.h
index c12bb69..862e39f 100644
--- a/src/main/input-output/input/command_line_helper.h
+++ b/src/main/input-output/input/command_line_helper.h
@@ -6,10 +6,12 @@
#define SOLVITAIRE_COMMAND_LINE_HELPER_H
#include <boost/program_options.hpp>
+#include "../../game/search-state/game_state.h"
class command_line_helper {
public:
command_line_helper();
+ enum class streamliner_opt {NONE, AUTO_FOUNDATIONS, SUIT_SYMMETRY, BOTH, SMART};
bool parse(int argc, const char* argv[]);
const std::vector<std::string> get_input_files();
@@ -21,11 +23,13 @@ public:
uint get_cores();
bool get_available_game_types();
bool get_benchmark();
- bool get_streamliners();
+ streamliner_opt get_streamliners();
+ game_state::streamliner_options get_streamliners_game_state();
std::vector<int> get_resume();
uint64_t get_cache_capacity();
std::string get_describe_game_rules();
uint64_t get_timeout();
+ static game_state::streamliner_options convert_streamliners(streamliner_opt);
private:
bool assess_errors();
@@ -35,6 +39,8 @@ private:
void print_no_opts_error();
void print_too_many_opts_error();
void print_resume_error();
+ void print_streamliner_error(const std::string&);
+ void print_streamliner_solvability_error();
boost::program_options::options_description cmdline_options;
boost::program_options::options_description main_options;
@@ -52,7 +58,7 @@ private:
uint cores;
bool available_game_types;
bool benchmark;
- bool streamliners;
+ streamliner_opt streamliners;
uint64_t cache_capacity;
uint64_t timeout;
};
diff --git a/src/main/main.cpp b/src/main/main.cpp
index a6ed318..5c8708e 100644
--- a/src/main/main.cpp
+++ b/src/main/main.cpp
@@ -60,7 +60,7 @@ int main(int argc, const char* argv[]) {
}
// If the benchmark option has been supplied, generates it
else if (clh.get_benchmark()) {
- benchmark::run(*rules, clh.get_cache_capacity(), clh.get_streamliners());
+ benchmark::run(*rules, clh.get_cache_capacity(), clh.get_streamliners_game_state());
}
// Otherwise there are supplied input files which should be solved
else {
@@ -93,18 +93,21 @@ const optional<sol_rules> gen_rules(command_line_helper& clh) {
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, clh.get_streamliners());
+ game_state::streamliner_options stream_opts = clh.get_streamliners_game_state();
+ game_state gs(rules, seed, stream_opts);
solve_game(gs, clh);
}
void solve_input_files(const vector<string> input_files, const sol_rules& rules, command_line_helper& clh) {
+ game_state::streamliner_options stream_opts = clh.get_streamliners_game_state();
+
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, clh.get_streamliners());
+ game_state gs(rules, in_doc, stream_opts);
LOG_INFO ("Attempting to solve " << input_file << "...");
solve_game(gs, clh);