aboutsummaryrefslogtreecommitdiff
path: root/src/main/game/search-state
diff options
context:
space:
mode:
authorCharlie Blake2018-06-20 17:37:22 +0100
committerCharlie Blake2018-06-21 09:57:44 +0100
commitabae8e0529cf2e6048e9b2eb8248434e1f9551de (patch)
treea14ec5c1ec201fd1dc63f6d751ccc2a87b68612d /src/main/game/search-state
parentSwitch to wilson interval (diff)
downloadmetasol-abae8e0529cf2e6048e9b2eb8248434e1f9551de.tar.gz
metasol-abae8e0529cf2e6048e9b2eb8248434e1f9551de.zip

Add streamliner command line option (inc for spgs)

Diffstat (limited to 'src/main/game/search-state')
-rw-r--r--src/main/game/search-state/game_state.auto_foundation_moves.cpp4
-rw-r--r--src/main/game/search-state/game_state.cpp20
-rw-r--r--src/main/game/search-state/game_state.h7
3 files changed, 16 insertions, 15 deletions
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 0b62af4..1bec3fe 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
@@ -11,9 +11,7 @@ using std::max;
bool game_state::is_valid_auto_foundation_move(pile::ref target_pile) const {
-#ifndef AUTO_FOUNDATIONS_STREAMLINER
- if (rules.build_pol == pol::NO_BUILD || rules.build_pol == pol::SAME_SUIT)
-#endif
+ if (streamliners || 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 0a20f60..5d80d3e 100644
--- a/src/main/game/search-state/game_state.cpp
+++ b/src/main/game/search-state/game_state.cpp
@@ -40,10 +40,12 @@ typedef sol_rules::stock_deal_type sdt;
// 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) : rules(s_rules),
- stock(255),
- waste(255),
- hole(255) {
+game_state::game_state(const sol_rules& s_rules, bool streamliners_)
+ : rules(s_rules)
+ , streamliners(streamliners_)
+ , stock(255)
+ , waste(255)
+ , hole (255) {
// If there is a hole, creates pile
if (rules.hole) {
piles.emplace_back();
@@ -100,14 +102,14 @@ game_state::game_state(const sol_rules& s_rules) : rules(s_rules),
}
// Constructs an initial game state from a JSON doc
-game_state::game_state(const sol_rules& s_rules, const Document& doc)
- : game_state(s_rules) {
+game_state::game_state(const sol_rules& s_rules, const Document& doc, bool streamliners_)
+ : game_state(s_rules, streamliners_) {
deal_parser::parse(*this, doc);
}
// Constructs an initial game state from a seed
-game_state::game_state(const sol_rules& s_rules, int seed)
- : game_state(s_rules) {
+game_state::game_state(const sol_rules& s_rules, int seed, bool streamliners_)
+ : game_state(s_rules, streamliners_) {
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
@@ -183,7 +185,7 @@ game_state::game_state(const sol_rules& s_rules, int seed)
game_state::game_state(const sol_rules& s_rules,
std::initializer_list<pile> il)
- : game_state(s_rules) {
+ : game_state(s_rules, false) {
pile::ref pr = 0;
for (const pile& p : il) {
for (const card c : p.pile_vec) {
diff --git a/src/main/game/search-state/game_state.h b/src/main/game/search-state/game_state.h
index 7c0f9ca..a0a74ea 100644
--- a/src/main/game/search-state/game_state.h
+++ b/src/main/game/search-state/game_state.h
@@ -28,9 +28,9 @@ public:
/* Constructors */
// Creates a game state representation from a JSON doc
- game_state(const sol_rules&, const rapidjson::Document&);
+ game_state(const sol_rules&, const rapidjson::Document&, bool);
// Does the same from a seed
- game_state(const sol_rules&, int seed);
+ game_state(const sol_rules&, int seed, bool);
// Does the same but with an initialiser list (useful for testing)
game_state(const sol_rules&, std::initializer_list<pile>);
@@ -58,7 +58,7 @@ public:
private:
/* Constructors (& helper function) */
- explicit game_state(const sol_rules&);
+ explicit game_state(const sol_rules&, bool);
static std::vector<card> gen_shuffled_deck(int, card::rank_t, bool);
/* Pile order logic */
@@ -116,6 +116,7 @@ private:
/* Game rules */
const sol_rules rules;
+ bool streamliners;
/* Pile references */