aboutsummaryrefslogtreecommitdiff
path: root/src/main/game/search-state
diff options
context:
space:
mode:
authorCharlie Blake2018-09-16 21:55:57 +0100
committerGitHub2018-09-16 21:55:57 +0100
commit7649c0d74a40df0d85ca118354650dd323bf4530 (patch)
treee9b1d6836f4dc968b4609d09db262740eea59f66 /src/main/game/search-state
parentMerge pull request #88 from thecharlesblake/fix-comma-bug (diff)
parentAdd legal moves logic for fixed suit sequences (diff)
downloadmetasol-7649c0d74a40df0d85ca118354650dd323bf4530.tar.gz
metasol-7649c0d74a40df0d85ca118354650dd323bf4530.zip

Merge pull request #89 from thecharlesblake/add-gaps-basic

Add gaps basic

Diffstat (limited to 'src/main/game/search-state')
-rw-r--r--src/main/game/search-state/game_state.legal_moves.cpp17
1 files changed, 15 insertions, 2 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 b4ed810..25b8221 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,21 @@ void game_state::add_sequence_moves(std::vector<move>& 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)
- moves.emplace_back(move::mtype::sequence, from_idx, space_idx);
+ if (from_card.get_rank() == 2) {
+ 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
else {