diff options
Diffstat (limited to 'src/main/game')
| -rw-r--r-- | src/main/game/global_cache.cpp | 16 | ||||
| -rw-r--r-- | src/main/game/search-state/game_state.auto_foundation_moves.cpp | 4 | ||||
| -rw-r--r-- | src/main/game/search-state/game_state.cpp | 20 | ||||
| -rw-r--r-- | src/main/game/search-state/game_state.h | 7 |
4 files changed, 18 insertions, 29 deletions
diff --git a/src/main/game/global_cache.cpp b/src/main/game/global_cache.cpp index db0c6de..f688c33 100644 --- a/src/main/game/global_cache.cpp +++ b/src/main/game/global_cache.cpp @@ -81,13 +81,7 @@ 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.rules.hole; -#ifdef SUIT_REDUCTION_STREAMLINER - is_suit_symmetry = true; -#endif -#ifdef NO_SUIT_SYMMETRY - is_suit_symmetry = false; -#endif + bool is_suit_symmetry = gs.streamliners || gs.rules.hole; if (is_suit_symmetry) { switch (gs.rules.build_pol) { @@ -141,13 +135,7 @@ 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.rules.hole; -#ifdef SUIT_REDUCTION_STREAMLINER - is_suit_symmetry = true; -#endif -#ifdef NO_SUIT_SYMMETRY - is_suit_symmetry = false; -#endif + bool is_suit_symmetry = init_gs.streamliners || 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 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 */ |
