From 7fbc0405828a1d71b8a2ef0a14e2476adc1550cb Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Wed, 4 Jul 2018 14:35:42 +0100 Subject: Add variants for streamliner cmd line options --- .../search-state/game_state.auto_foundation_moves.cpp | 6 +++++- src/main/game/search-state/game_state.cpp | 15 ++++++++------- src/main/game/search-state/game_state.h | 10 ++++++---- 3 files changed, 19 insertions(+), 12 deletions(-) (limited to 'src/main/game/search-state') 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 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> 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>); @@ -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 gen_shuffled_deck(int, card::rank_t, bool); template 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 */ -- cgit v1.2.1