From fc981dd44fa25e5ea7fb22f4020d3f67fe0c861a Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Sun, 16 Sep 2018 23:03:07 +0100 Subject: Add logic for auto-waste-then-stock --- .../game/search-state/game_state.dominance_moves.cpp | 20 ++++++++++++++++++++ src/main/game/search-state/game_state.h | 1 + src/main/input-output/input/sol_preset_types.cpp | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) 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 game_state::get_dominance_move() const { if (rules.spaces_pol == s_pol::AUTO_RESERVE_THEN_WASTE) { optional arm = auto_reserve_move(); if (arm) return arm; + } else if (rules.spaces_pol == s_pol::AUTO_WASTE_THEN_STOCK) { + optional awsm = auto_waste_stock_move(); + if (awsm) return awsm; } // If there are 2 decks or no foundations, return @@ -124,6 +127,23 @@ optional game_state::auto_reserve_move() const { return boost::none; } +optional 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; diff --git a/src/main/game/search-state/game_state.h b/src/main/game/search-state/game_state.h index 3df67ec..08391d6 100644 --- a/src/main/game/search-state/game_state.h +++ b/src/main/game/search-state/game_state.h @@ -132,6 +132,7 @@ private: /* Auto-foundation moves */ boost::optional auto_reserve_move() const; + boost::optional auto_waste_stock_move() const; bool is_valid_auto_foundation_move(pile::ref) const; bool is_ordered_pile(pile::ref) const; bool dominance_blocks_foundation_move(pile::ref); diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp index 9ddf933..1f2df69 100644 --- a/src/main/input-output/input/sol_preset_types.cpp +++ b/src/main/input-output/input/sol_preset_types.cpp @@ -200,7 +200,8 @@ map sol_preset_types::mp = { { "tableau piles": { "count": 12, - "build policy": "same-suit" + "build policy": "same-suit", + "spaces policy": "auto-waste-then-stock" }, "foundations": { "initial cards": "all" -- cgit v1.2.1