aboutsummaryrefslogtreecommitdiff
path: root/solvitaire/src/main/game/global_cache.h
diff options
context:
space:
mode:
authorTom Harley2019-01-29 19:12:22 +0000
committerTom Harley2019-01-29 19:12:22 +0000
commit7b4f42242d277adeaec7a40eaac7d178141d4621 (patch)
treeeacece268545df914d730ad80d6a1b69f1448296 /solvitaire/src/main/game/global_cache.h
parentAdd support for reading gamestates from json files (diff)
downloadmetasol-7b4f42242d277adeaec7a40eaac7d178141d4621.tar.gz
metasol-7b4f42242d277adeaec7a40eaac7d178141d4621.zip

Reorganise submodules (and submodulise solvitaire)

The submodules should now point to repos I’ve made in order to produce static libraries from them. Also, solvitaire now points to a similar personal repo.

Diffstat (limited to 'solvitaire/src/main/game/global_cache.h')
m---------solvitaire0
-rw-r--r--solvitaire/src/main/game/global_cache.h76
2 files changed, 0 insertions, 76 deletions
diff --git a/solvitaire b/solvitaire
new file mode 160000
+Subproject b835e10bfb21a73b4f89e09ddeb400f41538483
diff --git a/solvitaire/src/main/game/global_cache.h b/solvitaire/src/main/game/global_cache.h
deleted file mode 100644
index e9bb412..0000000
--- a/solvitaire/src/main/game/global_cache.h
+++ /dev/null
@@ -1,76 +0,0 @@
-//
-// Created by thecharlesblake on 1/10/18.
-//
-
-#ifndef SOLVITAIRE_GLOBAL_CACHE_H
-#define SOLVITAIRE_GLOBAL_CACHE_H
-
-#include <vector>
-#include <unordered_set>
-#include <boost/pool/pool.hpp>
-#include <boost/pool/pool_alloc.hpp>
-#include <boost/multi_index_container.hpp>
-#include <boost/multi_index/sequenced_index.hpp>
-#include <boost/multi_index/identity.hpp>
-#include <boost/multi_index/hashed_index.hpp>
-
-#include "sol_rules.h"
-#include "search-state/game_state.h"
-
-struct cached_game_state {
- typedef std::vector<card> state_data;
- typedef state_data::size_type size_type;
-
- explicit cached_game_state(const game_state&);
- void add_pile(pile::ref, const game_state&);
- void add_pile_in_reverse(pile::ref, const game_state&);
- void add_card(card, const game_state&);
- void add_card_divider();
-
- state_data data;
- bool live; // Is a parent in the current search tree
-};
-
-bool operator==(const cached_game_state&, const cached_game_state&);
-
-struct hasher {
- explicit hasher(const game_state&);
- std::size_t operator() (const cached_game_state&) const;
-
- std::size_t hash_value(const card&) const;
- std::size_t combine(std::size_t&, std::size_t) const;
-
- const game_state& init_gs;
-};
-
-class lru_cache {
-public:
- typedef boost::multi_index::multi_index_container<
- cached_game_state,
- boost::multi_index::indexed_by<
- boost::multi_index::sequenced<>,
- boost::multi_index::hashed_unique<
- boost::multi_index::identity<cached_game_state>,
- hasher
- >
- >
- > item_list;
-
- explicit lru_cache(const game_state&, uint64_t);
- std::pair<item_list::iterator, bool> insert(const game_state&);
- bool contains(const game_state&) const;
- void clear();
- item_list::size_type size() const;
- item_list::size_type bucket_count() const;
- void set_non_live(item_list::iterator);
- uint64_t get_states_removed_from_cache() const;
-
-private:
- static item_list::ctor_args_list get_init_tuple(const game_state&);
-
- uint64_t max_num_items;
- item_list cache;
- uint64_t states_removed_from_cache;
-};
-
-#endif //SOLVITAIRE_GLOBAL_CACHE_H