diff options
| author | Charlie Blake | 2018-02-23 11:51:06 +0000 |
|---|---|---|
| committer | GitHub | 2018-02-23 11:51:06 +0000 |
| commit | dd731b92b0a8f984ddbef11d31bc70acfa266510 (patch) | |
| tree | 071d463dc62ec584ef275759f7dbc450027a99d7 /src/main/game/global_cache.cpp | |
| parent | Merge pull request #39 from thecharlesblake/update-objectives (diff) | |
| parent | Enable suit reduction for non-foundation games (diff) | |
| download | metasol-dd731b92b0a8f984ddbef11d31bc70acfa266510.tar.gz metasol-dd731b92b0a8f984ddbef11d31bc70acfa266510.zip | |
Merge pull request #40 from thecharlesblake/test-optimisations
Test optimisations
Diffstat (limited to 'src/main/game/global_cache.cpp')
| -rw-r--r-- | src/main/game/global_cache.cpp | 64 |
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 |
