aboutsummaryrefslogtreecommitdiff
path: root/src/main/game/search-state/game_state.dominance_moves.cpp
diff options
context:
space:
mode:
authorthecharlesblake2018-09-16 23:03:07 +0100
committerthecharlesblake2018-09-16 23:03:07 +0100
commitfc981dd44fa25e5ea7fb22f4020d3f67fe0c861a (patch)
tree5d47d724fce79b0898e672d86dd167b3eebfcacc /src/main/game/search-state/game_state.dominance_moves.cpp
parentAdd parsing logic for auto-waste-then-stock spaces (diff)
downloadmetasol-fc981dd44fa25e5ea7fb22f4020d3f67fe0c861a.tar.gz
metasol-fc981dd44fa25e5ea7fb22f4020d3f67fe0c861a.zip

Add logic for auto-waste-then-stock

Diffstat (limited to 'src/main/game/search-state/game_state.dominance_moves.cpp')
-rw-r--r--src/main/game/search-state/game_state.dominance_moves.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main/game/search-state/game_state.dominance_moves.cpp b/src/main/game/search-state/game_state.dominance_moves.cpp
index bc20cb5..d0b4b43 100644
--- a/src/main/game/search-state/game_state.dominance_moves.cpp
+++ b/src/main/game/search-state/game_state.dominance_moves.cpp
@@ -71,6 +71,9 @@ optional<move> game_state::get_dominance_move() const {
if (rules.spaces_pol == s_pol::AUTO_RESERVE_THEN_WASTE) {
optional<move> arm = auto_reserve_move();
if (arm) return arm;
+ } else if (rules.spaces_pol == s_pol::AUTO_WASTE_THEN_STOCK) {
+ optional<move> awsm = auto_waste_stock_move();
+ if (awsm) return awsm;
}
// If there are 2 decks or no foundations, return
@@ -124,6 +127,23 @@ optional<move> game_state::auto_reserve_move() const {
return boost::none;
}
+optional<move> game_state::auto_waste_stock_move() const {
+ if (!piles[waste].empty()) {
+ for (auto to : tableau_piles) {
+ if (piles[to].empty()) {
+ return move(move::mtype::dominance, waste, to);
+ }
+ }
+ } else if (!piles[stock].empty()) {
+ for (auto to : tableau_piles) {
+ if (piles[to].empty()) {
+ return move(move::mtype::dominance, stock, to);
+ }
+ }
+ }
+ return boost::none;
+}
+
bool game_state::is_ordered_pile(pile::ref pr) const {
if (piles[pr].size() != rules.max_rank) return false;