aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/game/search-state/game_state.cpp2
-rw-r--r--src/main/game/search-state/game_state.h2
-rw-r--r--src/main/game/search-state/game_state.legal_moves.cpp21
-rw-r--r--src/main/game/sol_rules.cpp1
-rw-r--r--src/main/input-output/input/json-parsing/rules_parser.cpp11
-rw-r--r--src/main/input-output/input/sol_preset_types.cpp10
-rw-r--r--src/test/integration_tests/canfield_test.cpp8
7 files changed, 19 insertions, 36 deletions
diff --git a/src/main/game/search-state/game_state.cpp b/src/main/game/search-state/game_state.cpp
index 17fdc29..36f92d7 100644
--- a/src/main/game/search-state/game_state.cpp
+++ b/src/main/game/search-state/game_state.cpp
@@ -640,7 +640,7 @@ bool game_state::is_solved() const {
} else if (rules.sequence_count > 0) {
for (pile::ref i = 0; i < sequences.size() && solved; i++) {
for (pile::ref j = piles[sequences[i]].size(); j-- > 2;) {
- if (!is_next_legal_card(rules.sequence_build_pol, piles[sequences[i]][j-1], piles[sequences[i]][j], false)) {
+ if (!is_next_legal_card(rules.sequence_build_pol, piles[sequences[i]][j-1], piles[sequences[i]][j])) {
solved = false;
break;
}
diff --git a/src/main/game/search-state/game_state.h b/src/main/game/search-state/game_state.h
index 08391d6..8b14079 100644
--- a/src/main/game/search-state/game_state.h
+++ b/src/main/game/search-state/game_state.h
@@ -125,7 +125,7 @@ private:
void add_sequence_moves(std::vector<move>&) const;
bool tableau_space_and_auto_reserve() const;
- bool is_next_legal_card(sol_rules::build_policy, card, card, bool) const;
+ bool is_next_legal_card(sol_rules::build_policy, card, card) const;
bool is_next_legal_card(std::vector<sol_rules::accordion_policy>, card, card) const;
void turn_face_down_cards(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 a842cd0..6f167b4 100644
--- a/src/main/game/search-state/game_state.legal_moves.cpp
+++ b/src/main/game/search-state/game_state.legal_moves.cpp
@@ -313,7 +313,7 @@ bool game_state::is_valid_tableau_move(const card rem_c,
}
bool game_state::is_next_tableau_card(card a, card b) const {
- return is_next_legal_card(rules.build_pol, a, b, rules.tableau_wraps);
+ return is_next_legal_card(rules.build_pol, a, b);
}
bool game_state::is_valid_foundations_move(const pile::ref rem_ref,
@@ -447,7 +447,7 @@ pile::size_type game_state::get_built_group_height(pile::ref ref) const {
}
bool game_state::is_next_built_group_card(card a, card b) const {
- return is_next_legal_card(rules.built_group_pol, a, b, rules.tableau_wraps);
+ return is_next_legal_card(rules.built_group_pol, a, b);
}
// Loops through each possible built group move to an empty pile and adds it to the list
@@ -529,7 +529,7 @@ void game_state::add_sequence_moves(std::vector<move>& moves) const {
// Otherwise must agree with left neighbour
else {
card neighbour_card = piles[sequences[space_loc.first]][space_loc.second + 1];
- if (neighbour_card != "AS" && is_next_legal_card(rules.sequence_build_pol, from_card, neighbour_card, false))
+ if (neighbour_card != "AS" && is_next_legal_card(rules.sequence_build_pol, from_card, neighbour_card))
moves.emplace_back(move::mtype::sequence, from_idx, space_idx);
}
}
@@ -543,7 +543,7 @@ void game_state::add_sequence_moves(std::vector<move>& moves) const {
// Otherwise must agree with right neighbour
else {
card neighbour_card = piles[sequences[space_loc.first]][space_loc.second - 1];
- if (neighbour_card != "AS" && is_next_legal_card(rules.sequence_build_pol, neighbour_card, from_card, false))
+ if (neighbour_card != "AS" && is_next_legal_card(rules.sequence_build_pol, neighbour_card, from_card))
moves.emplace_back(move::mtype::sequence, from_idx, space_idx);
}
}
@@ -582,7 +582,7 @@ bool game_state::tableau_space_and_auto_reserve() const {
///////////////////////
-bool game_state::is_next_legal_card(pol p, card a, card b, bool wraps) const {
+bool game_state::is_next_legal_card(pol p, card a, card b) const {
// Checks build pol violations
switch(p) {
case sol_rules::build_policy::SAME_SUIT:
@@ -594,14 +594,13 @@ bool game_state::is_next_legal_card(pol p, card a, card b, bool wraps) const {
default:;
}
// Checks rank
- auto base = rules.foundations_base ? *rules.foundations_base : 0;
- auto final_rank = base == 0
+ auto final_rank = foundations_base == 1
? rules.max_rank
- : base - card::rank_t(1);
- if (wraps || b.get_rank() != final_rank) {
- return (b.get_rank() % rules.max_rank) + 1 == a.get_rank();
- } else {
+ : foundations_base - card::rank_t(1);
+ if (b.get_rank() == final_rank) {
return false;
+ } else {
+ return (b.get_rank() % rules.max_rank) + 1 == a.get_rank();
}
}
diff --git a/src/main/game/sol_rules.cpp b/src/main/game/sol_rules.cpp
index 2778241..55c6757 100644
--- a/src/main/game/sol_rules.cpp
+++ b/src/main/game/sol_rules.cpp
@@ -20,7 +20,6 @@ sol_rules::sol_rules() :
spaces_pol(s_pol::ANY),
move_built_group(bgt::NO),
built_group_pol(pol::ANY_SUIT),
- tableau_wraps(false),
two_decks(false),
max_rank(13),
hole(false),
diff --git a/src/main/input-output/input/json-parsing/rules_parser.cpp b/src/main/input-output/input/json-parsing/rules_parser.cpp
index 2698e68..bcff1fd 100644
--- a/src/main/input-output/input/json-parsing/rules_parser.cpp
+++ b/src/main/input-output/input/json-parsing/rules_parser.cpp
@@ -201,14 +201,6 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) {
}
}
- if (d["tableau piles"].HasMember("wraps")) {
- if (d["tableau piles"]["wraps"].IsBool()) {
- sr.tableau_wraps = d["tableau piles"]["wraps"].GetBool();
- } else {
- json_helper::json_parse_err("[tableau piles][wraps] must be a boolean");
- }
- }
-
} else {
json_helper::json_parse_err("[tableau piles] must be an object");
}
@@ -552,9 +544,6 @@ string rules_parser::rules_schema_json() {
"diagonal deal": {
"type": "boolean"
},
- "wraps": {
- "type": "boolean"
- },
"move built group": {
"type": "string",
"enum": [
diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp
index 1f2df69..b7acd1b 100644
--- a/src/main/input-output/input/sol_preset_types.cpp
+++ b/src/main/input-output/input/sol_preset_types.cpp
@@ -25,7 +25,6 @@ map<string, string> sol_preset_types::mp = {
"build policy": "any-suit",
"spaces policy": "any",
"diagonal deal": false,
- "wraps": false,
"move built group": "no",
"move built group policy": "same-as-build",
"face up cards": "all"
@@ -279,8 +278,7 @@ map<string, string> sol_preset_types::mp = {
"count": 4,
"build policy": "red-black",
"move built group": "whole-pile",
- "spaces policy": "auto-reserve-then-waste",
- "wraps": true
+ "spaces policy": "auto-reserve-then-waste"
},
"foundations": {
"initial cards": "one",
@@ -308,8 +306,7 @@ map<string, string> sol_preset_types::mp = {
"count": 3,
"build policy": "red-black",
"move built group": "whole-pile",
- "spaces policy": "auto-reserve-then-waste",
- "wraps": true
+ "spaces policy": "auto-reserve-then-waste"
},
"foundations": {
"initial cards": "one",
@@ -1316,8 +1313,7 @@ map<string, string> sol_preset_types::mp = {
"count": 8,
"build policy": "same-suit",
"move built group": "whole-pile",
- "spaces policy": "auto-reserve-then-waste",
- "wraps": true
+ "spaces policy": "auto-reserve-then-waste"
},
"foundations": {
"initial cards": "one",
diff --git a/src/test/integration_tests/canfield_test.cpp b/src/test/integration_tests/canfield_test.cpp
index 006f4fb..0cb14b2 100644
--- a/src/test/integration_tests/canfield_test.cpp
+++ b/src/test/integration_tests/canfield_test.cpp
@@ -62,16 +62,16 @@ TEST(Canfield, MoveWholePile) {
sol_rules sr = rules_parser::from_preset("simple-canfield");
game_state gs(sr, string_il{
- {"3C"},{},{},{}, // Foundations
+ {"AC"},{},{},{}, // Foundations
{},{}, // Stock-waste
{}, // Reserve
- {"3H","2S","AH"},{"AS"},{"2D"} // Tableau piles
+ {"2C","AH"},{"3H"},{"3C","2D"} // Tableau piles
});
vector<move> actual_moves = gs.get_legal_moves();
vector<move> exp_moves = {
- move(move::mtype::built_group, 7, 8, 3),
- move(move::mtype::built_group, 8, 9, 1),
+ move(move::mtype::built_group, 7, 8, 2),
+ move(move::mtype::regular, 7, 1, 1),
};
ASSERT_TRUE(test_helper::moves_eq(exp_moves, actual_moves)) << actual_moves;