aboutsummaryrefslogtreecommitdiff
path: root/src/main/game/search-state
diff options
context:
space:
mode:
authorthecharlesblake2018-09-16 21:54:38 +0100
committerthecharlesblake2018-09-16 21:54:38 +0100
commit71b9144dedb83399232eea19645fd0ec581a36ba (patch)
treee9b1d6836f4dc968b4609d09db262740eea59f66 /src/main/game/search-state
parentAdd parsing logic for sequence fixed suit rule (diff)
downloadmetasol-71b9144dedb83399232eea19645fd0ec581a36ba.tar.gz
metasol-71b9144dedb83399232eea19645fd0ec581a36ba.zip

Add legal moves logic for fixed suit sequences

Diffstat (limited to 'src/main/game/search-state')
-rw-r--r--src/main/game/search-state/game_state.legal_moves.cpp14
1 files changed, 13 insertions, 1 deletions
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 76407d1..25b8221 100644
--- a/src/main/game/search-state/game_state.legal_moves.cpp
+++ b/src/main/game/search-state/game_state.legal_moves.cpp
@@ -511,7 +511,19 @@ void game_state::add_sequence_moves(std::vector<move>& moves) const {
// Only twos in the far left column
if (space_loc.second == piles[sequences[i]].size() - 1) {
if (from_card.get_rank() == 2) {
- moves.emplace_back(move::mtype::sequence, from_idx, space_idx);
+ bool is_legal = false;
+
+ if (rules.sequence_fixed_suit) {
+ if (from_card.get_suit() == space_loc.first) {
+ is_legal = true;
+ }
+ } else {
+ is_legal = true;
+ }
+
+ if (is_legal) {
+ moves.emplace_back(move::mtype::sequence, from_idx, space_idx);
+ }
}
}
// Otherwise must agree with left neighbour