aboutsummaryrefslogtreecommitdiff
path: root/src/main/game/global_cache.cpp
diff options
context:
space:
mode:
authorCharlie Blake2018-07-12 00:04:09 +0100
committerCharlie Blake2018-07-12 00:04:09 +0100
commitf845a2eed1eb5a10977cba36e3c448397a455c68 (patch)
tree64ab75568e80890a6b5b66ab0481dd4ea24d1d24 /src/main/game/global_cache.cpp
parentAdd sequence state printing and fix small bugs (diff)
downloadmetasol-f845a2eed1eb5a10977cba36e3c448397a455c68.tar.gz
metasol-f845a2eed1eb5a10977cba36e3c448397a455c68.zip

Gaps / sequence implementation

Diffstat (limited to 'src/main/game/global_cache.cpp')
-rw-r--r--src/main/game/global_cache.cpp41
1 files changed, 12 insertions, 29 deletions
diff --git a/src/main/game/global_cache.cpp b/src/main/game/global_cache.cpp
index ee2a2b8..e24cb4c 100644
--- a/src/main/game/global_cache.cpp
+++ b/src/main/game/global_cache.cpp
@@ -68,6 +68,11 @@ cached_game_state::cached_game_state(const game_state& gs) : live(true) {
add_pile(pr, gs);
add_card_divider();
}
+
+ for (pile::ref pr : gs.sequences) {
+ add_pile(pr, gs);
+ add_card_divider();
+ }
}
@@ -83,9 +88,9 @@ void cached_game_state::add_card(card c, const game_state& gs) {
// If the game is a 'hole-based' game, or suit-reduction is on, reduces
// the cached suit of the card where possible
- bool is_suit_symmetry = gs.stream_opts == sos::SUIT_SYMMETRY
- || gs.stream_opts == sos::BOTH
- || gs.rules.hole;
+ bool is_suit_symmetry = (gs.rules.foundations_present
+ && (gs.stream_opts == sos::SUIT_SYMMETRY || gs.stream_opts == sos::BOTH))
+ || gs.rules.hole;
if (is_suit_symmetry) {
switch (gs.rules.build_pol) {
@@ -139,10 +144,10 @@ size_t hasher::hash_value(card const& c) const {
// If the game is a 'hole-based' game, or suit-reduction is enabled, hash
// the reduced suit
- bool is_suit_symmetry = init_gs.stream_opts == sos::SUIT_SYMMETRY
- || init_gs.stream_opts == sos::BOTH
- || init_gs.rules.hole;
-
+ bool is_suit_symmetry = (init_gs.rules.foundations_present
+ && (init_gs.stream_opts == sos::SUIT_SYMMETRY || init_gs.stream_opts == sos::BOTH))
+ || init_gs.rules.hole;
+
uint8_t suit_val;
if (is_suit_symmetry) {
switch (init_gs.rules.build_pol) {
@@ -164,28 +169,6 @@ size_t hasher::hash_value(card const& c) const {
}
-
-/*//////////////////
-// GLOBAL CACHE //
-//////////////////
-
-unlimited_cache::unlimited_cache(const game_state& gs)
- : cache(0, hasher(gs)) {
-}
-
-bool unlimited_cache::insert(const game_state& gs) {
- return cache.emplace(gs).second;
-}
-
-bool unlimited_cache::contains(const game_state& gs) const {
- return cache.count(cached_game_state(gs)) > 0;
-}
-
-void unlimited_cache::clear() {
- cache.clear();
-}*/
-
-
///////////////
// LRU CACHE //
///////////////