aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/game/card.cpp21
-rw-r--r--src/main/game/card.h11
-rw-r--r--src/main/game/search-state/game_state.cpp13
-rw-r--r--src/main/game/sol_rules.h6
-rw-r--r--src/main/input-output/input/json-parsing/deal_parser.cpp4
-rw-r--r--src/main/input-output/input/json-parsing/rules_parser.cpp24
-rw-r--r--src/main/input-output/input/sol_preset_types.cpp9
-rw-r--r--src/test/test_helper.cpp6
-rw-r--r--src/test/test_helper.h2
-rw-r--r--src/test/unit_tests/built_group_move_gen_test.cpp56
-rw-r--r--src/test/unit_tests/face_up_cards_test.cpp273
11 files changed, 380 insertions, 45 deletions
diff --git a/src/main/game/card.cpp b/src/main/game/card.cpp
index cfb94a9..12e577f 100644
--- a/src/main/game/card.cpp
+++ b/src/main/game/card.cpp
@@ -22,11 +22,12 @@ const card::colour_t card::colour::Red = 1;
// A card can either be created using two int values (rank & suit), or
// using a string (e.g. "AS")
-card::card(suit_t s, rank_t r) : card_rank(r), card_suit(s) {}
+card::card(suit_t s, rank_t r, bool fd) : card_rank(r), card_suit(s), face_down(fd) {}
-card::card(const char* c) : card_rank(rank_from_str(c)), card_suit(suit_from_str(c)) {}
+card::card(const char* c, bool face_down_possible) :
+ card_rank(rank_from_str(c)), card_suit(suit_from_str(c)), face_down(face_down_possible) {} // TODO: CHANGE!
-card::card() : card(0, 0) {}
+card::card() : card(0, 0, false) {}
card::suit_t card::suit_from_str(const char* c) {
switch(tolower(c[strlen(c) - 1])) {
@@ -68,6 +69,8 @@ card::rank_t card::get_rank() const {
}
std::string card::to_string() const {
+ if (face_down) return "##";
+
string s;
switch(card_rank) {
case 1 : s += "A"; break;
@@ -85,7 +88,17 @@ std::string card::to_string() const {
return s;
}
-const card card::divider = card(0, 0);
+bool card::is_face_up() const {
+ return true;
+}
+
+void card::turn_face_up() {
+}
+
+void card::turn_face_down() {
+}
+
+const card card::divider = card();
bool operator==(const card& l, const card& r) {
return l.get_rank() == r.get_rank() && l.get_suit() == r.get_suit();
diff --git a/src/main/game/card.h b/src/main/game/card.h
index a4c6b1e..ea808b4 100644
--- a/src/main/game/card.h
+++ b/src/main/game/card.h
@@ -31,14 +31,18 @@ public:
// A card can either be created using two int values (rank & suit), or
// using a string (e.g. "AS")
- card(suit_t, rank_t);
- card(const char*);
+ card(suit_t, rank_t, bool face_down=false);
+ card(const char*, bool face_down_possible=false);
card();
suit_t get_suit() const;
colour_t get_colour() const;
rank_t get_rank() const;
+ bool is_face_up() const;
+ void turn_face_up();
+ void turn_face_down();
+
std::string to_string() const;
private:
@@ -46,7 +50,8 @@ private:
static rank_t rank_from_str(const char* c);
rank_t card_rank : 4;
- suit_t card_suit : 4;
+ suit_t card_suit : 2;
+ bool face_down : 1;
};
bool operator==(const card&, const card&);
diff --git a/src/main/game/search-state/game_state.cpp b/src/main/game/search-state/game_state.cpp
index 82e413b..8a1298b 100644
--- a/src/main/game/search-state/game_state.cpp
+++ b/src/main/game/search-state/game_state.cpp
@@ -18,6 +18,7 @@
#include "../../input-output/output/state_printer.h"
#include "../../input-output/output/log_helper.h"
#include "../move.h"
+#include "../sol_rules.h"
using namespace rapidjson;
using std::vector;
@@ -34,6 +35,7 @@ using std::mt19937;
typedef sol_rules::build_policy pol;
typedef sol_rules::stock_deal_type sdt;
+typedef sol_rules::face_up_policy fu;
//////////////////
// CONSTRUCTORS //
@@ -155,7 +157,10 @@ game_state::game_state(const sol_rules& s_rules, int seed, bool streamliners_)
for (int t = 0; !deck.empty(); t++) {
card c = deck.back();
- // Add the randomly generated card to the tableau piles
+ // If only the top cards are face up, initially deals all face down
+ if (rules.face_up == fu::TOP_CARDS) c.turn_face_down();
+
+ // Adds the randomly generated card to the tableau piles
auto p = t % original_tableau_piles.size();
// If we are doing a diagonal deal, each row should have one fewer card.
@@ -176,6 +181,12 @@ game_state::game_state(const sol_rules& s_rules, int seed, bool streamliners_)
}
}
+ // Now if necessary, turns the top cards face up
+ if (rules.face_up == fu::TOP_CARDS)
+ for (auto& p : piles)
+ if (!p.empty())
+ p[0].turn_face_up();
+
// The size of all piles must equal the deck size
int piles_sz = 0;
for (auto& p : piles) piles_sz += p.size();
diff --git a/src/main/game/sol_rules.h b/src/main/game/sol_rules.h
index adab00d..a7b9ae6 100644
--- a/src/main/game/sol_rules.h
+++ b/src/main/game/sol_rules.h
@@ -28,6 +28,10 @@ struct sol_rules {
WASTE,
TABLEAU_PILES
};
+ enum class face_up_policy {
+ ALL,
+ TOP_CARDS
+ };
uint8_t tableau_pile_count;
build_policy build_pol;
@@ -49,6 +53,8 @@ struct sol_rules {
bool stock_redeal;
uint8_t reserve_size;
bool reserve_stacked;
+ face_up_policy face_up;
+
};
#endif //SOLVITAIRE_SOL_RULES_H
diff --git a/src/main/input-output/input/json-parsing/deal_parser.cpp b/src/main/input-output/input/json-parsing/deal_parser.cpp
index 29ac3b1..e776cbd 100644
--- a/src/main/input-output/input/json-parsing/deal_parser.cpp
+++ b/src/main/input-output/input/json-parsing/deal_parser.cpp
@@ -5,11 +5,13 @@
#include "deal_parser.h"
#include "../../../game/search-state/game_state.h"
#include "json_helper.h"
+#include "../../../game/sol_rules.h"
using namespace std;
using namespace rapidjson;
typedef sol_rules::build_policy pol;
+typedef sol_rules::face_up_policy fu;
void deal_parser::parse(game_state &gs, const rapidjson::Document& doc) {
// There are two stages to reading in the supplied deal. It is both put
@@ -100,7 +102,7 @@ void deal_parser::parse_tableau_piles(game_state &gs, const rapidjson::Document&
for (auto& json_card : p.first->GetArray()) {
assert(json_card.IsString());
- gs.place_card(*p.second, card(json_card.GetString()));
+ gs.place_card(*p.second, card(json_card.GetString(), gs.rules.face_up != fu::ALL));
}
}
}
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 d4879de..29e755b 100644
--- a/src/main/input-output/input/json-parsing/rules_parser.cpp
+++ b/src/main/input-output/input/json-parsing/rules_parser.cpp
@@ -9,6 +9,7 @@
#include "json_helper.h"
#include "../sol_preset_types.h"
#include "../../../game/card.h"
+#include "../../../game/sol_rules.h"
using namespace std;
using namespace rapidjson;
@@ -20,6 +21,7 @@ using namespace rapidjson;
typedef sol_rules::build_policy pol;
typedef sol_rules::spaces_policy s_pol;
typedef sol_rules::stock_deal_type sdt;
+typedef sol_rules::face_up_policy fu;
const sol_rules rules_parser::from_file(const string rules_file) {
sol_rules sr = get_default();
@@ -160,6 +162,25 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) {
}
}
+ string face_up_str;
+ if (d["tableau piles"].HasMember("face up cards")) {
+ if (d["tableau piles"]["face up cards"].IsString()) {
+ face_up_str = d["tableau piles"]["face up cards"].GetString();
+
+ if (face_up_str == "all") {
+ sr.face_up = fu::ALL;
+ } else if (face_up_str == "top") {
+ sr.face_up = fu::TOP_CARDS;
+ } else {
+ string err = "[tableau piles][face up cards] is invalid: " + face_up_str;
+ json_helper::json_parse_err(err);
+ }
+
+ } else {
+ json_helper::json_parse_err("[tableau piles][face up cards] must be a string");
+ }
+ }
+
} else {
json_helper::json_parse_err("[tableau piles] must be an object");
}
@@ -318,7 +339,8 @@ string rules_parser::rules_schema_json() {
"spaces policy": {"type": "string", "enum": ["any", "no-build", "kings"]},
"diagonal deal": {"type": "boolean"},
"move built group": {"type": "boolean"},
- "move built group policy": {"type": "string", "enum": ["same-as-build", "any-suit", "red-black", "same-suit", "no-build"]}
+ "move built group policy": {"type": "string", "enum": ["same-as-build", "any-suit", "red-black", "same-suit", "no-build"]},
+ "face up cards": {"type": "string", "enum": ["all", "top"]}
}, "additionalProperties": false
},
"max rank": {"type": "integer", "minimum": 1, "maximum": 13},
diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp
index 5b751af..a10df54 100644
--- a/src/main/input-output/input/sol_preset_types.cpp
+++ b/src/main/input-output/input/sol_preset_types.cpp
@@ -26,7 +26,8 @@ map<string, string> sol_preset_types::mp = {
"spaces policy": "any",
"diagonal deal": false,
"move built group": false,
- "move built group policy": "same-as-build"
+ "move built group policy": "same-as-build",
+ "face up cards": "all"
},
"max rank": 13,
"two decks": false,
@@ -388,7 +389,8 @@ map<string, string> sol_preset_types::mp = {
"build policy": "red-black",
"spaces policy": "kings",
"move built group": true,
- "diagonal deal": true
+ "diagonal deal": true,
+ "face up cards": "top"
},
"stock size": 24,
"stock deal count": 1,
@@ -408,7 +410,8 @@ map<string, string> sol_preset_types::mp = {
"build policy": "red-black",
"spaces policy": "kings",
"move built group": true,
- "diagonal deal": true
+ "diagonal deal": true,
+ "face up cards": "top"
},
"stock size": 24,
"stock deal count": 3,
diff --git a/src/test/test_helper.cpp b/src/test/test_helper.cpp
index ab9e0cb..e1aa0a7 100644
--- a/src/test/test_helper.cpp
+++ b/src/test/test_helper.cpp
@@ -62,9 +62,9 @@ void test_helper::run_foundations_dominance_test(sol_rules::build_policy policy,
ASSERT_TRUE(i->child_moves.empty());
}
-void test_helper::run_built_group_test(sol_rules sr,
- initializer_list<pile> piles,
- vector<move> exp_moves) {
+void test_helper::expected_moves_test(sol_rules sr,
+ initializer_list<pile> piles,
+ vector<move> exp_moves) {
game_state gs(sr, piles);
vector<move> actual_moves = gs.get_legal_moves();
diff --git a/src/test/test_helper.h b/src/test/test_helper.h
index 463a935..0690d0e 100644
--- a/src/test/test_helper.h
+++ b/src/test/test_helper.h
@@ -17,7 +17,7 @@ public:
static bool is_solvable(const std::string&, const std::string&);
static void run_foundations_dominance_test(sol_rules::build_policy policy,
std::vector<card> cards);
- static void run_built_group_test(sol_rules sr, std::initializer_list<pile>, std::vector<move>);
+ static void expected_moves_test(sol_rules sr, std::initializer_list<pile>, std::vector<move>);
static bool moves_eq(std::vector<move>&, std::vector<move>&);
};
diff --git a/src/test/unit_tests/built_group_move_gen_test.cpp b/src/test/unit_tests/built_group_move_gen_test.cpp
index 34e2b07..37a2cf0 100644
--- a/src/test/unit_tests/built_group_move_gen_test.cpp
+++ b/src/test/unit_tests/built_group_move_gen_test.cpp
@@ -20,13 +20,13 @@ TEST(BuiltGroupMoveGen, SameSuitEmpty) {
sr.built_group_pol = pol::SAME_SUIT;
sr.move_built_group = true;
- test_helper::run_built_group_test(
+ test_helper::expected_moves_test(
sr,
{
{},
- {"3C","2C","AC"}, // Same suit
- {"3H","2S","AH"}, // Red black
- {"3D","2D","AS"}, // Any suit
+ {"3C", "2C", "AC"}, // Same suit
+ {"3H", "2S", "AH"}, // Red black
+ {"3D", "2D", "AS"}, // Any suit
{}
},
{
@@ -53,13 +53,13 @@ TEST(BuiltGroupMoveGen, RedBlackEmpty) {
sr.built_group_pol = pol::RED_BLACK;
sr.move_built_group = true;
- test_helper::run_built_group_test(
+ test_helper::expected_moves_test(
sr,
{
{},
- {"3C","2C","AC"}, // Same suit
- {"3H","2S","AH"}, // Red black
- {"3D","2D","AS"}, // Any suit
+ {"3C", "2C", "AC"}, // Same suit
+ {"3H", "2S", "AH"}, // Red black
+ {"3D", "2D", "AS"}, // Any suit
{}
},
{
@@ -89,13 +89,13 @@ TEST(BuiltGroupMoveGen, AnySuitEmpty) {
sr.built_group_pol = pol::ANY_SUIT;
sr.move_built_group = true;
- test_helper::run_built_group_test(
+ test_helper::expected_moves_test(
sr,
{
{},
- {"3C","2C","AC"}, // Same suit
- {"3H","2S","AH"}, // Red black
- {"3D","2D","AS"}, // Any suit
+ {"3C", "2C", "AC"}, // Same suit
+ {"3H", "2S", "AH"}, // Red black
+ {"3D", "2D", "AS"}, // Any suit
{}
},
{
@@ -132,13 +132,13 @@ TEST(BuiltGroupMoveGen, CantMove) {
sr.built_group_pol = pol::ANY_SUIT;
sr.move_built_group = false;
- test_helper::run_built_group_test(
+ test_helper::expected_moves_test(
sr,
{
{},
- {"3C","2C","AC"}, // Same suit
- {"3H","2S","AH"}, // Red black
- {"3D","2D","AS"}, // Any suit
+ {"3C", "2C", "AC"}, // Same suit
+ {"3H", "2S", "AH"}, // Red black
+ {"3D", "2D", "AS"}, // Any suit
{}
},
{
@@ -159,13 +159,13 @@ TEST(BuiltGroupMoveGen, SameSuitOccupied) {
sr.built_group_pol = pol::SAME_SUIT;
sr.move_built_group = true;
- test_helper::run_built_group_test(
+ test_helper::expected_moves_test(
sr,
{
{"4C"},
- {"3C","2C","AC"}, // Same suit
- {"3H","2S","AH"}, // Red black
- {"3D","2D","AS"}, // Any suit
+ {"3C", "2C", "AC"}, // Same suit
+ {"3H", "2S", "AH"}, // Red black
+ {"3D", "2D", "AS"}, // Any suit
{}
},
{
@@ -189,13 +189,13 @@ TEST(BuiltGroupMoveGen, RedBlackOccupied) {
sr.built_group_pol = pol::RED_BLACK;
sr.move_built_group = true;
- test_helper::run_built_group_test(
+ test_helper::expected_moves_test(
sr,
{
{"4C"},
- {"3C","2C","AC"}, // Same suit
- {"3H","2S","AH"}, // Red black
- {"3D","2D","AS"}, // Any suit
+ {"3C", "2C", "AC"}, // Same suit
+ {"3H", "2S", "AH"}, // Red black
+ {"3D", "2D", "AS"}, // Any suit
{}
},
{
@@ -220,13 +220,13 @@ TEST(BuiltGroupMoveGen, AnySuitOccupied) {
sr.built_group_pol = pol::ANY_SUIT;
sr.move_built_group = true;
- test_helper::run_built_group_test(
+ test_helper::expected_moves_test(
sr,
{
{"4C"},
- {"3C","2C","AC"}, // Same suit
- {"3H","2S","AH"}, // Red black
- {"3D","2D","AS"}, // Any suit
+ {"3C", "2C", "AC"}, // Same suit
+ {"3H", "2S", "AH"}, // Red black
+ {"3D", "2D", "AS"}, // Any suit
{}
},
{
diff --git a/src/test/unit_tests/face_up_cards_test.cpp b/src/test/unit_tests/face_up_cards_test.cpp
new file mode 100644
index 0000000..6e2d6a3
--- /dev/null
+++ b/src/test/unit_tests/face_up_cards_test.cpp
@@ -0,0 +1,273 @@
+//
+// Created by thecharlesblake on 1/11/18.
+//
+
+#include <gtest/gtest.h>
+
+#include "../test_helper.h"
+#include "../../main/game/search-state/game_state.h"
+#include "../../main/game/sol_rules.h"
+
+typedef sol_rules::build_policy pol;
+typedef sol_rules::face_up_policy fu;
+typedef move::mtype mt;
+
+using std::vector;
+using std::ostream;
+using std::initializer_list;
+
+#define ASSERT_FACE_UP(card) ASSERT_TRUE(card.is_face_up()) << card.to_string() << " should be face up"
+#define ASSERT_FACE_DOWN(card) ASSERT_FALSE(card.is_face_up()) << card.to_string() << " should be face down"
+
+
+TEST(FaceUpCards, CapsFaceUpIfFaceUpNotAll) {
+ sol_rules sr;
+ sr.tableau_pile_count = 3;
+ sr.built_group_pol = pol::SAME_SUIT;
+ sr.build_pol = pol::SAME_SUIT;
+ sr.move_built_group = true;
+ sr.face_up = fu::TOP_CARDS;
+
+ initializer_list<pile> piles = {
+ {"3S"},
+ {"2s","AS"},
+ {}
+ };
+
+ game_state gs(sr, piles);
+
+ ASSERT_FACE_UP(gs.get_data()[0][0]);
+ ASSERT_FACE_UP(gs.get_data()[1][0]);
+ ASSERT_FACE_DOWN(gs.get_data()[1][1]);
+}
+
+TEST(FaceUpCards, IgnoreCapsIfFaceUpAll) {
+ sol_rules sr;
+ sr.tableau_pile_count = 3;
+ sr.built_group_pol = pol::SAME_SUIT;
+ sr.build_pol = pol::SAME_SUIT;
+ sr.move_built_group = true;
+ sr.face_up = fu::ALL;
+
+ initializer_list<pile> piles = {
+ {"3S"},
+ {"2s","AS"},
+ {}
+ };
+
+ game_state gs(sr, piles);
+
+ ASSERT_FACE_UP(gs.get_data()[0][0]);
+ ASSERT_FACE_UP(gs.get_data()[1][0]);
+ ASSERT_FACE_UP(gs.get_data()[1][1]);
+}
+
+TEST(FaceUpCards, MoveTurnsFaceUp) {
+ sol_rules sr;
+ sr.tableau_pile_count = 3;
+ sr.built_group_pol = pol::SAME_SUIT;
+ sr.build_pol = pol::SAME_SUIT;
+ sr.move_built_group = true;
+ sr.face_up = fu::TOP_CARDS;
+
+ initializer_list<pile> piles = {
+ {"3S"},
+ {"2s","AS"}, // from
+ {} // to
+ };
+
+ game_state gs(sr, piles);
+ gs.make_move(move(mt::regular, 1, 2));
+
+ ASSERT_FACE_UP(gs.get_data()[0][0]);
+ ASSERT_FACE_UP(gs.get_data()[1][0]);
+ ASSERT_FACE_UP(gs.get_data()[2][0]);
+}
+
+TEST(FaceUpCards, BuiltGroupMoveTurnsFaceUp) {
+ sol_rules sr;
+ sr.tableau_pile_count = 3;
+ sr.built_group_pol = pol::SAME_SUIT;
+ sr.build_pol = pol::SAME_SUIT;
+ sr.move_built_group = true;
+ sr.face_up = fu::TOP_CARDS;
+
+ initializer_list<pile> piles = {
+ {"4S"},
+ {"3s","2S","AS"}, // from
+ {} // to
+ };
+
+ game_state gs(sr, piles);
+ gs.make_move(move(mt::built_group, 1, 2, 2));
+
+ ASSERT_FACE_UP(gs.get_data()[0][0]);
+ ASSERT_FACE_UP(gs.get_data()[1][0]);
+ ASSERT_FACE_UP(gs.get_data()[2][0]);
+ ASSERT_FACE_UP(gs.get_data()[2][1]);
+}
+
+TEST(FaceUpCards, MoveAlreadyFaceUpNoChange) {
+ sol_rules sr;
+ sr.tableau_pile_count = 3;
+ sr.built_group_pol = pol::SAME_SUIT;
+ sr.build_pol = pol::SAME_SUIT;
+ sr.move_built_group = true;
+ sr.face_up = fu::TOP_CARDS;
+
+ initializer_list<pile> piles = {
+ {"3S"},
+ {"2S","AS"}, // from
+ {} // to
+ };
+
+ game_state gs(sr, piles);
+ gs.make_move(move(mt::regular, 1, 2));
+
+ ASSERT_FACE_UP(gs.get_data()[0][0]);
+ ASSERT_FACE_UP(gs.get_data()[1][0]);
+ ASSERT_FACE_UP(gs.get_data()[2][0]);
+}
+
+TEST(FaceUpCards, FaceDownNoBuiltGroup) {
+ sol_rules sr;
+ sr.tableau_pile_count = 3;
+ sr.built_group_pol = pol::SAME_SUIT;
+ sr.build_pol = pol::SAME_SUIT;
+ sr.move_built_group = true;
+ sr.face_up = fu::TOP_CARDS;
+
+ initializer_list<pile> piles = {
+ {"3S"},
+ {"2s","AS"},
+ {}
+ };
+
+ test_helper::expected_moves_test(
+ sr,
+ {
+ {"3S"},
+ {"2s","AS"},
+ {}
+ },
+ {
+ // Regular moves
+ move(move::mtype::regular, 0, 2, 1),
+ move(move::mtype::regular, 1, 2, 1),
+ }
+ );
+}
+
+TEST(FaceUpCards, FaceUpBuiltGroup) {
+ sol_rules sr;
+ sr.tableau_pile_count = 3;
+ sr.built_group_pol = pol::SAME_SUIT;
+ sr.build_pol = pol::SAME_SUIT;
+ sr.move_built_group = true;
+ sr.face_up = fu::TOP_CARDS;
+
+ initializer_list<pile> piles = {
+ {"3S"},
+ {"2s","AS"},
+ {}
+ };
+
+ test_helper::expected_moves_test(
+ sr,
+ {
+ {"3S"},
+ {"2S","AS"},
+ {}
+ },
+ {
+ // Regular moves
+ move(mt::regular, 0, 2, 1),
+ move(mt::regular, 1, 2, 1),
+
+ // Built group moves
+ move(mt::built_group, 1, 0, 2),
+ move(mt::built_group, 1, 2, 2)
+ }
+ );
+}
+
+TEST(FaceUpCards, FaceUpBuiltGroup2Not3) {
+ sol_rules sr;
+ sr.tableau_pile_count = 3;
+ sr.built_group_pol = pol::SAME_SUIT;
+ sr.build_pol = pol::SAME_SUIT;
+ sr.move_built_group = true;
+ sr.face_up = fu::TOP_CARDS;
+
+ initializer_list<pile> piles = {
+ {"3S"},
+ {"2s","AS"},
+ {}
+ };
+
+ test_helper::expected_moves_test(
+ sr,
+ {
+ {"4S"},
+ {"3s","2S","AS"},
+ {}
+ },
+ {
+ // Regular moves
+ move(mt::regular, 0, 2, 1),
+ move(mt::regular, 1, 2, 1),
+
+ // Built group moves
+ move(mt::built_group, 1, 2, 2)
+ }
+ );
+}
+
+TEST(FaceUpCards, UndoTurnsBackFaceDown) {
+ sol_rules sr;
+ sr.tableau_pile_count = 3;
+ sr.built_group_pol = pol::SAME_SUIT;
+ sr.build_pol = pol::SAME_SUIT;
+ sr.move_built_group = true;
+ sr.face_up = fu::TOP_CARDS;
+
+ initializer_list<pile> piles = {
+ {"3S"},
+ {"2s","AS"}, // from
+ {} // to
+ };
+
+ game_state gs(sr, piles);
+ move m = move(mt::regular, 1, 2);
+ gs.make_move(m);
+ gs.undo_move(m);
+
+ ASSERT_FACE_UP(gs.get_data()[0][0]);
+ ASSERT_FACE_UP(gs.get_data()[1][0]);
+ ASSERT_FACE_DOWN(gs.get_data()[1][1]);
+}
+
+TEST(FaceUpCards, UndoBuiltGroupTurnsBackFaceDown) {
+ sol_rules sr;
+ sr.tableau_pile_count = 3;
+ sr.built_group_pol = pol::SAME_SUIT;
+ sr.build_pol = pol::SAME_SUIT;
+ sr.move_built_group = true;
+ sr.face_up = fu::TOP_CARDS;
+
+ initializer_list<pile> piles = {
+ {"4S"},
+ {"3s","2S","AS"}, // from
+ {} // to
+ };
+
+ game_state gs(sr, piles);
+ move m = move(mt::built_group, 1, 2, 2);
+ gs.make_move(m);
+ gs.undo_move(m);
+
+ ASSERT_FACE_UP(gs.get_data()[0][0]);
+ ASSERT_FACE_UP(gs.get_data()[1][0]);
+ ASSERT_FACE_UP(gs.get_data()[1][1]);
+ ASSERT_FACE_DOWN(gs.get_data()[1][2]);
+}