diff options
| author | thecharlesblake | 2017-11-06 15:35:10 +0000 |
|---|---|---|
| committer | thecharlesblake | 2017-11-06 15:35:10 +0000 |
| commit | f91cd251fd40d927254246e9276924af3e046dd1 (patch) | |
| tree | d67d93459276986d373a163aeeefa75e2b5c9920 /src/main | |
| parent | Add FC (reg & simple) to cmdln parsing & sol_rules (diff) | |
| download | metasol-f91cd251fd40d927254246e9276924af3e046dd1.tar.gz metasol-f91cd251fd40d927254246e9276924af3e046dd1.zip | |
Add cells to game state and next state generation
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/game_state.cpp | 14 | ||||
| -rw-r--r-- | src/main/game_state.h | 1 | ||||
| -rw-r--r-- | src/main/pile.cpp | 2 | ||||
| -rw-r--r-- | src/main/sol_rules.h | 3 |
4 files changed, 18 insertions, 2 deletions
diff --git a/src/main/game_state.cpp b/src/main/game_state.cpp index 29ccdc3..2dd1ca8 100644 --- a/src/main/game_state.cpp +++ b/src/main/game_state.cpp @@ -55,7 +55,7 @@ game_state::game_state(int seed, const sol_rules& s_rules) hole(false, ord::BOTH, pol::ANY_SUIT, true, rules.max_rank) { vector<card> deck = shuffled_deck(seed, rules.max_rank); - // If there is a hole, move the ace to spades to it + // If there is a hole, move the ace of spades to it if (rules.hole) { deck.erase(find(begin(deck), end(deck), card("AS"))); hole.place("AS"); @@ -82,6 +82,14 @@ game_state::game_state(int seed, const sol_rules& s_rules) foundations.push_back(p); } } + + // If there are cell piles, create the relevant cell vectors + if (rules.cells > 0) { + for (int i = 0; i < rules.cells; i++) { + pile p(true, ord::SINGLE_CARD, pol::ANY_SUIT, false); + foundations.push_back(p); + } + } } // Generate a randomly ordered vector of cards @@ -129,6 +137,10 @@ vector<game_state> game_state::get_next_legal_states() { can_add.push_back(&foundations[i]); } } + for (vector<pile>::size_type i = 0; i < cells.size(); i++) { + can_remove.push_back(&cells[i]); + can_add.push_back(&cells[i]); + } if (rules.hole) { can_add.push_back(&hole); } diff --git a/src/main/game_state.h b/src/main/game_state.h index 311c97f..bb98ee3 100644 --- a/src/main/game_state.h +++ b/src/main/game_state.h @@ -40,6 +40,7 @@ private: void print_hole(std::ostream&) const; std::vector<pile> tableau_piles; + std::vector<pile> cells; std::vector<pile> foundations; sol_rules rules; pile hole; diff --git a/src/main/pile.cpp b/src/main/pile.cpp index cceda50..344e56c 100644 --- a/src/main/pile.cpp +++ b/src/main/pile.cpp @@ -34,6 +34,8 @@ bool pile::can_place(const card& c) const { if (build_order == ord::NO_BUILD) { return false; + } else if (build_order == ord::SINGLE_CARD) { + return empty(); } if (empty()) { diff --git a/src/main/sol_rules.h b/src/main/sol_rules.h index aabb57c..5699ef1 100644 --- a/src/main/sol_rules.h +++ b/src/main/sol_rules.h @@ -22,7 +22,8 @@ public: NO_BUILD, DESCENDING, ASCENDING, - BOTH + BOTH, + SINGLE_CARD }; enum class build_policy { CLUBS, |
