diff options
| author | thecharlesblake | 2018-09-29 12:59:37 +0100 |
|---|---|---|
| committer | thecharlesblake | 2018-09-29 15:15:05 +0100 |
| commit | e55ca08eb9b3d46c8bb6fe0158450061c927a3e0 (patch) | |
| tree | 421352cc940c80aa34b234f2abda92534127be6e /src/main/game | |
| parent | Fix wrapping logic (diff) | |
| download | metasol-e55ca08eb9b3d46c8bb6fe0158450061c927a3e0.tar.gz metasol-e55ca08eb9b3d46c8bb6fe0158450061c927a3e0.zip | |
Correct legal moves for found base & remove wraps
Diffstat (limited to 'src/main/game')
| -rw-r--r-- | src/main/game/search-state/game_state.cpp | 2 | ||||
| -rw-r--r-- | src/main/game/search-state/game_state.h | 2 | ||||
| -rw-r--r-- | src/main/game/search-state/game_state.legal_moves.cpp | 21 | ||||
| -rw-r--r-- | src/main/game/sol_rules.cpp | 1 |
4 files changed, 12 insertions, 14 deletions
diff --git a/src/main/game/search-state/game_state.cpp b/src/main/game/search-state/game_state.cpp index 17fdc29..36f92d7 100644 --- a/src/main/game/search-state/game_state.cpp +++ b/src/main/game/search-state/game_state.cpp @@ -640,7 +640,7 @@ bool game_state::is_solved() const { } else if (rules.sequence_count > 0) { for (pile::ref i = 0; i < sequences.size() && solved; i++) { for (pile::ref j = piles[sequences[i]].size(); j-- > 2;) { - if (!is_next_legal_card(rules.sequence_build_pol, piles[sequences[i]][j-1], piles[sequences[i]][j], false)) { + if (!is_next_legal_card(rules.sequence_build_pol, piles[sequences[i]][j-1], piles[sequences[i]][j])) { solved = false; break; } diff --git a/src/main/game/search-state/game_state.h b/src/main/game/search-state/game_state.h index 08391d6..8b14079 100644 --- a/src/main/game/search-state/game_state.h +++ b/src/main/game/search-state/game_state.h @@ -125,7 +125,7 @@ private: void add_sequence_moves(std::vector<move>&) const; bool tableau_space_and_auto_reserve() const; - bool is_next_legal_card(sol_rules::build_policy, card, card, bool) const; + bool is_next_legal_card(sol_rules::build_policy, card, card) const; bool is_next_legal_card(std::vector<sol_rules::accordion_policy>, card, card) const; void turn_face_down_cards(std::vector<move>&) const; diff --git a/src/main/game/search-state/game_state.legal_moves.cpp b/src/main/game/search-state/game_state.legal_moves.cpp index a842cd0..6f167b4 100644 --- a/src/main/game/search-state/game_state.legal_moves.cpp +++ b/src/main/game/search-state/game_state.legal_moves.cpp @@ -313,7 +313,7 @@ bool game_state::is_valid_tableau_move(const card rem_c, } bool game_state::is_next_tableau_card(card a, card b) const { - return is_next_legal_card(rules.build_pol, a, b, rules.tableau_wraps); + return is_next_legal_card(rules.build_pol, a, b); } bool game_state::is_valid_foundations_move(const pile::ref rem_ref, @@ -447,7 +447,7 @@ pile::size_type game_state::get_built_group_height(pile::ref ref) const { } bool game_state::is_next_built_group_card(card a, card b) const { - return is_next_legal_card(rules.built_group_pol, a, b, rules.tableau_wraps); + return is_next_legal_card(rules.built_group_pol, a, b); } // Loops through each possible built group move to an empty pile and adds it to the list @@ -529,7 +529,7 @@ void game_state::add_sequence_moves(std::vector<move>& moves) const { // Otherwise must agree with left neighbour else { card neighbour_card = piles[sequences[space_loc.first]][space_loc.second + 1]; - if (neighbour_card != "AS" && is_next_legal_card(rules.sequence_build_pol, from_card, neighbour_card, false)) + if (neighbour_card != "AS" && is_next_legal_card(rules.sequence_build_pol, from_card, neighbour_card)) moves.emplace_back(move::mtype::sequence, from_idx, space_idx); } } @@ -543,7 +543,7 @@ void game_state::add_sequence_moves(std::vector<move>& moves) const { // Otherwise must agree with right neighbour else { card neighbour_card = piles[sequences[space_loc.first]][space_loc.second - 1]; - if (neighbour_card != "AS" && is_next_legal_card(rules.sequence_build_pol, neighbour_card, from_card, false)) + if (neighbour_card != "AS" && is_next_legal_card(rules.sequence_build_pol, neighbour_card, from_card)) moves.emplace_back(move::mtype::sequence, from_idx, space_idx); } } @@ -582,7 +582,7 @@ bool game_state::tableau_space_and_auto_reserve() const { /////////////////////// -bool game_state::is_next_legal_card(pol p, card a, card b, bool wraps) const { +bool game_state::is_next_legal_card(pol p, card a, card b) const { // Checks build pol violations switch(p) { case sol_rules::build_policy::SAME_SUIT: @@ -594,14 +594,13 @@ bool game_state::is_next_legal_card(pol p, card a, card b, bool wraps) const { default:; } // Checks rank - auto base = rules.foundations_base ? *rules.foundations_base : 0; - auto final_rank = base == 0 + auto final_rank = foundations_base == 1 ? rules.max_rank - : base - card::rank_t(1); - if (wraps || b.get_rank() != final_rank) { - return (b.get_rank() % rules.max_rank) + 1 == a.get_rank(); - } else { + : foundations_base - card::rank_t(1); + if (b.get_rank() == final_rank) { return false; + } else { + return (b.get_rank() % rules.max_rank) + 1 == a.get_rank(); } } diff --git a/src/main/game/sol_rules.cpp b/src/main/game/sol_rules.cpp index 2778241..55c6757 100644 --- a/src/main/game/sol_rules.cpp +++ b/src/main/game/sol_rules.cpp @@ -20,7 +20,6 @@ sol_rules::sol_rules() : spaces_pol(s_pol::ANY), move_built_group(bgt::NO), built_group_pol(pol::ANY_SUIT), - tableau_wraps(false), two_decks(false), max_rank(13), hole(false), |
