diff options
Diffstat (limited to 'src/main/game/search-state')
| -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 |
3 files changed, 14 insertions, 11 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 25b8221..7194930 100644 --- a/src/main/game/search-state/game_state.legal_moves.cpp +++ b/src/main/game/search-state/game_state.legal_moves.cpp @@ -157,7 +157,7 @@ vector<move> game_state::get_legal_moves(move parent_move) { if (rules.reserve_size > 0) from_piles.insert(from_piles.end(), reserve.begin(), reserve.end()); for (auto fp : from_piles) { - if (piles[fp].empty() || parent_move.to == fp) continue; + if (piles[fp].empty() || (parent_move.to == fp && parent_move.type != move::mtype::dominance)) continue; for (auto f : foundations) if (is_valid_foundations_move(fp, f)) @@ -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,10 +594,13 @@ bool game_state::is_next_legal_card(pol p, card a, card b, bool wraps) const { default:; } // Checks rank - if (wraps) { - return (b.get_rank() % rules.max_rank) + 1 == a.get_rank(); + auto final_rank = foundations_base == 1 + ? rules.max_rank + : foundations_base - card::rank_t(1); + if (b.get_rank() == final_rank) { + return false; } else { - return b.get_rank() + 1 == a.get_rank(); + return (b.get_rank() % rules.max_rank) + 1 == a.get_rank(); } } |
