diff options
| author | Tom Harley | 2019-01-24 12:10:15 +0000 |
|---|---|---|
| committer | Tom Harley | 2019-01-24 12:10:15 +0000 |
| commit | 1ef39e9ba6ce1a622c53f38929d1e77b4f2518fc (patch) | |
| tree | 7734126b8b4c2bd9f97d45137cf73c83fdf8c829 /src/main/game | |
| parent | wow a thing that works (diff) | |
| download | metasol-1ef39e9ba6ce1a622c53f38929d1e77b4f2518fc.tar.gz metasol-1ef39e9ba6ce1a622c53f38929d1e77b4f2518fc.zip | |
It works with fortune’s favor
It seems to be consistently running to completion successfully! It’s been renamed to metasol for now, since that’s a better name than test. Next step will probably be eliminating the namespace pollution in metasol.cpp.
Diffstat (limited to 'src/main/game')
| -rw-r--r-- | src/main/game/search-state/game_state.cpp | 30 | ||||
| -rw-r--r-- | src/main/game/search-state/game_state.h | 4 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/main/game/search-state/game_state.cpp b/src/main/game/search-state/game_state.cpp index a547f7e..6ea550c 100644 --- a/src/main/game/search-state/game_state.cpp +++ b/src/main/game/search-state/game_state.cpp @@ -306,6 +306,36 @@ game_state::game_state(const sol_rules& s_rules, } } +game_state::game_state(const sol_rules& s_rules, + std::vector<std::vector<card::suit_t>> suits, + std::vector<std::vector<card::rank_t>> ranks, + std::vector<std::vector<bool>> face_down) + : game_state(s_rules, sos::NONE) {pile::ref pr = 0; + assert(suits.size() == ranks.size()); + assert(ranks.size() == face_down.size()); + for (std::vector<std::vector<card::suit_t>>::size_type i = 0; + i < suits.size(); ++i) { + assert(suits[i].size() == ranks[i].size()); + assert(ranks[i].size() == face_down[i].size()); + for (std::vector<card::suit_t>::size_type j = 0; j < suits[i].size(); + ++j) { + card c(suits[i][j], ranks[i][j], face_down[i][j]); + place_card(pr, c); + } + pr++; + } + + // Sets foundations base appropriately + if (rules.foundations_present && rules.foundations_base == boost::none) { + for (auto f : foundations) { + if (!piles[f].empty()) { + foundations_base = piles[f].top_card().get_rank(); + return; + } + } + } +} + // Generates a randomly ordered vector of cards vector<card> game_state::gen_shuffled_deck(card::rank_t max_rank, bool two_decks, mt19937 rng) { diff --git a/src/main/game/search-state/game_state.h b/src/main/game/search-state/game_state.h index 9f8e3b9..1698122 100644 --- a/src/main/game/search-state/game_state.h +++ b/src/main/game/search-state/game_state.h @@ -41,6 +41,10 @@ public: game_state(const sol_rules&, std::initializer_list<std::initializer_list<std::string>>); // Does the same but with vectors game_state(const sol_rules&, std::vector<std::vector<std::string>>); + // Does the same but with lots of vectors + game_state(const sol_rules&, std::vector<std::vector<card::suit_t>>, + std::vector<std::vector<card::rank_t>>, + std::vector<std::vector<bool>>); /* Altering state */ |
