aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorCharlie Blake2018-08-04 17:31:25 +0100
committerCharlie Blake2018-08-04 17:31:25 +0100
commit900cd63d095cdc1b9637a4873326e075467ade7a (patch)
tree11fd908f6b081e685776281bee48329066cbe565 /src/main
parentMerge pull request #81 from thecharlesblake/streamliner-fixup (diff)
downloadmetasol-900cd63d095cdc1b9637a4873326e075467ade7a.tar.gz
metasol-900cd63d095cdc1b9637a4873326e075467ade7a.zip

Add two-deck presets & edit mv order to make work

Diffstat (limited to 'src/main')
-rw-r--r--src/main/game/search-state/game_state.dominance_moves.cpp2
-rw-r--r--src/main/game/search-state/game_state.h3
-rw-r--r--src/main/game/search-state/game_state.legal_moves.cpp44
-rw-r--r--src/main/input-output/input/sol_preset_types.cpp209
4 files changed, 243 insertions, 15 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 b7e6e15..bc20cb5 100644
--- a/src/main/game/search-state/game_state.dominance_moves.cpp
+++ b/src/main/game/search-state/game_state.dominance_moves.cpp
@@ -15,7 +15,7 @@ using std::max;
using boost::optional;
bool game_state::is_valid_auto_foundation_move(pile::ref target_pile) const {
- if (rules.foundations_only_comp_piles)
+ if (rules.foundations_only_comp_piles || rules.two_decks)
return false;
else if ( stream_opts == sos::AUTO_FOUNDATIONS
|| stream_opts == sos::BOTH
diff --git a/src/main/game/search-state/game_state.h b/src/main/game/search-state/game_state.h
index d8d9f12..3df67ec 100644
--- a/src/main/game/search-state/game_state.h
+++ b/src/main/game/search-state/game_state.h
@@ -9,6 +9,7 @@
#include <list>
#include <string>
#include <random>
+#include <functional>
#include <boost/functional/hash.hpp>
#include <boost/optional/optional.hpp>
@@ -95,7 +96,7 @@ private:
bool stock_can_deal_all_tableau() const;
move get_stock_to_all_tableau_move() const;
- std::set<std::pair<int8_t, bool>> generate_k_plus_moves_to_check() const;
+ std::set<std::pair<int8_t, bool>, std::greater<>> generate_k_plus_moves_to_check() const;
void add_stock_to_cell_move(std::vector<move>&, pile::ref) const;
void add_stock_to_tableau_moves(std::vector<move>&) const;
void add_stock_to_hole_foundation_moves(std::vector<move>&) const;
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 f97814a..b4ed810 100644
--- a/src/main/game/search-state/game_state.legal_moves.cpp
+++ b/src/main/game/search-state/game_state.legal_moves.cpp
@@ -14,6 +14,7 @@ using std::min;
using std::list;
using std::pair;
using std::set;
+using std::greater;
using namespace rapidjson;
typedef sol_rules::build_policy pol;
@@ -33,14 +34,16 @@ vector<move> game_state::get_legal_moves(move parent_move) {
// Order:
// Accordion moves
// Foundations complete piles moves
- // Tableau / cells / reserve / stock-waste to hole / foundation moves ---
+ // Tableau / cells / reserve / stock-waste (redeal) to hole / foundation moves
// Cell to tableau moves
// Sequence to sequence moves
// Tableau to tableau moves
// Tableau built group moves
- // Stock-waste to tableau moves
+ // Stock-waste to tableau moves (redeal)
// Reserve to tableau moves
// Foundation to tableau moves
+ // Stock-waste to tableau moves (no redeal)
+ // Stock-waste (no redeal) to hole / foundation moves
// Tableau / reserve / stock-waste to cell moves
// Stock to all tableau moves
@@ -50,7 +53,7 @@ vector<move> game_state::get_legal_moves(move parent_move) {
if (rules.stock_size > 0 && stock_can_deal_all_tableau())
moves.emplace_back(get_stock_to_all_tableau_move());
- // Tableau / stock to cell moves
+ // Tableau / reserve / stock-waste to cell moves
pile::ref empty_cell = 255;
for (auto c : cells) {
if (piles[c].empty()) empty_cell = c;
@@ -69,6 +72,16 @@ vector<move> game_state::get_legal_moves(move parent_move) {
add_stock_to_cell_move(moves, empty_cell);
}
+ // Stock-waste (no redeal) to hole / foundation moves
+ if (rules.hole || (rules.foundations_present && !rules.foundations_only_comp_piles)) {
+ if (rules.stock_size > 0 && rules.stock_deal_t == sdt::WASTE && !rules.stock_redeal)
+ add_stock_to_hole_foundation_moves(moves);
+ }
+
+ // Stock-waste to tableau moves (no redeal)
+ if (rules.stock_size > 0 && rules.stock_deal_t == sdt::WASTE && !rules.stock_redeal)
+ add_stock_to_tableau_moves(moves);
+
// Foundation to tableau / empty cell moves
if (rules.foundations_removable) {
for (auto f : foundations) {
@@ -88,8 +101,8 @@ vector<move> game_state::get_legal_moves(move parent_move) {
add_valid_tableau_moves(moves, r);
}
- // Stock-waste to tableau moves
- if (rules.stock_size > 0 && rules.stock_deal_t == sdt::WASTE)
+ // Stock-waste to tableau moves (redeal)
+ if (rules.stock_size > 0 && rules.stock_deal_t == sdt::WASTE && rules.stock_redeal)
add_stock_to_tableau_moves(moves);
// Tableau built group moves
@@ -108,9 +121,16 @@ vector<move> game_state::get_legal_moves(move parent_move) {
// If only whole pile moves are available, doesn't make regular ones
if (rules.move_built_group != bgt::WHOLE_PILE) {
for (auto t_from : tableau_piles) {
- if (piles[t_from].empty() || parent_move.to == t_from) continue;
-
- add_valid_tableau_moves(moves, t_from);
+ // Forbids moves from empty piles, reversing parent moves, or from single-
+ // card piles to empty piles
+ if (piles[t_from].empty() || parent_move.to == t_from || tableau_space_and_auto_reserve()) continue;
+
+ for (auto to : tableau_piles) {
+ if (is_valid_tableau_move(t_from, to)
+ && !(piles[t_from].size() == 1 && piles[to].empty())) {
+ moves.emplace_back(move::mtype::regular, t_from, to);
+ }
+ }
}
}
@@ -126,10 +146,10 @@ vector<move> game_state::get_legal_moves(move parent_move) {
add_valid_tableau_moves(moves, c);
}
- // Tableau / cells / reserve / stock-waste to hole / foundation moves
+ // Tableau / cells / reserve / stock-waste (redeal) to hole / foundation moves
if (rules.hole || (rules.foundations_present && !rules.foundations_only_comp_piles)) {
// Stock
- if (rules.stock_size > 0 && rules.stock_deal_t == sdt::WASTE)
+ if (rules.stock_size > 0 && rules.stock_deal_t == sdt::WASTE && rules.stock_redeal)
add_stock_to_hole_foundation_moves(moves);
list<pile::ref> from_piles = tableau_piles;
@@ -182,8 +202,8 @@ move game_state::get_stock_to_all_tableau_move() const {
return move(move::mtype::stock_to_all_tableau, 0, 0, stock_moves);
}
-set<pair<int8_t, bool>> game_state::generate_k_plus_moves_to_check() const {
- set<pair<int8_t, bool>> stock_moves_to_check;
+set<pair<int8_t, bool>, greater<>> game_state::generate_k_plus_moves_to_check() const {
+ set<pair<int8_t, bool>, greater<>> stock_moves_to_check;
// If the waste isn't empty, adds the move from the top of the current waste
if (!piles[waste].empty()) stock_moves_to_check.insert(pair<int8_t, bool>(0, false));
diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp
index e380225..93a609a 100644
--- a/src/main/input-output/input/sol_preset_types.cpp
+++ b/src/main/input-output/input/sol_preset_types.cpp
@@ -1177,7 +1177,214 @@ map<string, string> sol_preset_types::mp = {
"build policy": "same-suit"
},
"stock": {
- "size": 64
+ "size": 64,
+ "redeal": false
+ },
+ "two decks": true
+}
+)"
+
+ },
+ {
+ "lucas",
+
+ R"(
+{
+ "tableau piles": {
+ "count": 13,
+ "build policy": "same-suit"
+ },
+ "stock": {
+ "size": 61,
+ "redeal": false
+ },
+ "foundations": {
+ "initial cards": "all"
+ },
+ "two decks": true
+}
+)"
+
+ },
+ {
+ "maria",
+
+ R"(
+{
+ "tableau piles": {
+ "count": 9,
+ "build policy": "red-black"
+ },
+ "stock": {
+ "size": 68,
+ "redeal": false
+ },
+ "two decks": true
+}
+)"
+
+ },
+ {
+ "limited",
+
+ R"(
+{
+ "tableau piles": {
+ "count": 12,
+ "build policy": "same-suit"
+ },
+ "stock": {
+ "size": 68,
+ "redeal": false
+ },
+ "two decks": true
+}
+)"
+
+ },
+ {
+ "streets",
+
+ R"(
+{
+ "tableau piles": {
+ "count": 10,
+ "build policy": "red-black"
+ },
+ "stock": {
+ "size": 64,
+ "redeal": false
+ },
+ "two decks": true
+}
+)"
+
+ },
+ {
+ "rank-and-file",
+
+ R"(
+{
+ "tableau piles": {
+ "count": 10,
+ "build policy": "red-black",
+ "face up cards": "top",
+ "move built group": "yes"
+ },
+ "stock": {
+ "size": 64,
+ "redeal": false
+ },
+ "two decks": true
+}
+)"
+
+ },
+ {
+ "american-toad",
+
+ R"(
+{
+ "tableau piles": {
+ "count": 8,
+ "build policy": "same-suit",
+ "move built group": "whole-pile",
+ "spaces policy": "auto-reserve-then-waste",
+ "wraps": true
+ },
+ "foundations": {
+ "initial cards": "one",
+ "base card": "random"
+ },
+ "stock": {
+ "size": 75,
+ "deal count": 1,
+ "redeal": false
+ },
+ "reserve": {
+ "size": 20,
+ "stacked": true
+ },
+ "two decks": true
+}
+)"
+
+ },
+
+ {
+ "gargantua",
+
+ R"(
+{
+ "tableau piles": {
+ "count": 9,
+ "build policy": "red-black",
+ "spaces policy": "kings",
+ "move built group": "yes",
+ "diagonal deal": true,
+ "face up cards": "top"
+ },
+ "foundations": {
+ "removable": true
+ },
+ "stock": {
+ "size": 59,
+ "deal count": 1,
+ "redeal": false
+ },
+ "two decks": true
+}
+)"
+
+ },
+
+ {
+ "gargantua-redeal",
+
+ R"(
+{
+ "tableau piles": {
+ "count": 9,
+ "build policy": "red-black",
+ "spaces policy": "kings",
+ "move built group": "yes",
+ "diagonal deal": true,
+ "face up cards": "top"
+ },
+ "foundations": {
+ "removable": true
+ },
+ "stock": {
+ "size": 59,
+ "deal count": 1,
+ "redeal": true
+ },
+ "two decks": true
+}
+)"
+
+ },
+
+ {
+ "ultra-klondike-2-deck",
+
+ R"(
+{
+ "tableau piles": {
+ "count": 12,
+ "build policy": "red-black",
+ "spaces policy": "kings",
+ "move built group": "yes",
+ "diagonal deal": true,
+ "face up cards": "top"
+ },
+ "foundations": {
+ "removable": true
+ },
+ "stock": {
+ "size": 26,
+ "deal count": 3,
+ "redeal": true
},
"two decks": true
}