From 48517141b32123f847dcb8d88e0dac999b9142ba Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Sun, 16 Sep 2018 21:27:36 +0100 Subject: Add parsing logic for sequence fixed suit rule --- src/main/game/search-state/game_state.legal_moves.cpp | 3 ++- src/main/game/sol_rules.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/main/game') 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 b4ed810..76407d1 100644 --- a/src/main/game/search-state/game_state.legal_moves.cpp +++ b/src/main/game/search-state/game_state.legal_moves.cpp @@ -510,8 +510,9 @@ void game_state::add_sequence_moves(std::vector& moves) const { if (rules.sequence_direction == dir::LEFT || rules.sequence_direction == dir::BOTH) { // Only twos in the far left column if (space_loc.second == piles[sequences[i]].size() - 1) { - if (from_card.get_rank() == 2) + if (from_card.get_rank() == 2) { moves.emplace_back(move::mtype::sequence, from_idx, space_idx); + } } // Otherwise must agree with left neighbour else { diff --git a/src/main/game/sol_rules.h b/src/main/game/sol_rules.h index 2384b21..5e2dd40 100644 --- a/src/main/game/sol_rules.h +++ b/src/main/game/sol_rules.h @@ -84,6 +84,7 @@ struct sol_rules { uint8_t sequence_count; direction sequence_direction; build_policy sequence_build_pol; + bool sequence_fixed_suit; uint8_t accordion_size; std::vector> accordion_moves; std::vector accordion_pol; -- cgit v1.2.1 From 71b9144dedb83399232eea19645fd0ec581a36ba Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Sun, 16 Sep 2018 21:54:38 +0100 Subject: Add legal moves logic for fixed suit sequences --- src/main/game/search-state/game_state.legal_moves.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/main/game') 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& 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 -- cgit v1.2.1