aboutsummaryrefslogtreecommitdiff
path: root/src/main/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/game')
-rw-r--r--src/main/game/global_cache.cpp64
1 files changed, 37 insertions, 27 deletions
diff --git a/src/main/game/global_cache.cpp b/src/main/game/global_cache.cpp
index 5d2fd79..048cbc9 100644
--- a/src/main/game/global_cache.cpp
+++ b/src/main/game/global_cache.cpp
@@ -83,23 +83,27 @@ void cached_game_state::add_card(card c, const game_state& gs) {
auto& target = data;
#endif
- switch (gs.rules.build_pol) {
-#ifdef NO_CARD_SYMMETRY
- default:
- target.emplace_back(c);
- break;
-#else
- case pol::SAME_SUIT:
- target.emplace_back(c);
- break;
- case pol::RED_BLACK:
- target.emplace_back(c.get_colour(), c.get_rank());
- break;
- default:
- target.emplace_back(0, c.get_rank());
- break;
+ // If the game is a 'hole-based' game, or suit-reduction is on, reduces
+ // the cached suit of the card where possible
+#ifndef SUIT_REDUCTION_STREAMLINER
+ if (gs.rules.hole) {
#endif
+ switch (gs.rules.build_pol) {
+ case pol::SAME_SUIT:
+ target.emplace_back(c);
+ break;
+ case pol::RED_BLACK:
+ target.emplace_back(c.get_colour(), c.get_rank());
+ break;
+ default:
+ target.emplace_back(0, c.get_rank());
+ break;
+ }
+#ifndef SUIT_REDUCTION_STREAMLINER
+ } else {
+ target.emplace_back(c);
}
+#endif
}
void cached_game_state::add_card_divider() {
@@ -152,19 +156,25 @@ std::size_t hasher::combine(std::size_t& seed, std::size_t value) const {
size_t hasher::hash_value(card const& c) const {
boost::hash<uint8_t> boost_hasher;
-#ifdef NO_CARD_SYMMETRY
- uint8_t suit_val = c.get_suit();
-#else
+ // If the game is a 'hole-based' game, or suit-reduction is enabled, hash
+ // the reduced suit
uint8_t suit_val;
- switch (init_gs.rules.build_pol) {
- case pol::SAME_SUIT:
- suit_val = c.get_suit();
- break;
- case pol::RED_BLACK:
- suit_val = c.get_colour();
- break;
- default:
- suit_val = 0;
+#ifndef SUIT_REDUCTION_STREAMLINER
+ if (init_gs.rules.hole) {
+#endif
+ switch (init_gs.rules.build_pol) {
+ case pol::SAME_SUIT:
+ suit_val = c.get_suit();
+ break;
+ case pol::RED_BLACK:
+ suit_val = c.get_colour();
+ break;
+ default:
+ suit_val = 0;
+ }
+#ifndef SUIT_REDUCTION_STREAMLINER
+ } else {
+ suit_val = c.get_suit();
}
#endif