diff options
| author | Charlie Blake | 2017-12-25 22:39:46 +0000 |
|---|---|---|
| committer | GitHub | 2017-12-25 22:39:46 +0000 |
| commit | 846b3d141352a492a5b8e0f61a2707b8feacbcc6 (patch) | |
| tree | 3e10925da099bac8deb71e90d111fad2cd7abb2b /src/main/game/game_state.cpp | |
| parent | Merge pull request #23 from thecharlesblake/benchmark-script (diff) | |
| parent | Add necessary features for profiler (diff) | |
| download | metasol-846b3d141352a492a5b8e0f61a2707b8feacbcc6.tar.gz metasol-846b3d141352a492a5b8e0f61a2707b8feacbcc6.zip | |
Merge pull request #24 from thecharlesblake/basic-optimisations
Basic optimisations
Diffstat (limited to 'src/main/game/game_state.cpp')
| -rw-r--r-- | src/main/game/game_state.cpp | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/main/game/game_state.cpp b/src/main/game/game_state.cpp index 1814a41..2b77fec 100644 --- a/src/main/game/game_state.cpp +++ b/src/main/game/game_state.cpp @@ -9,11 +9,13 @@ #include <functional> #include <rapidjson/document.h> +#include <boost/functional/hash.hpp> #include "game_state.h" -using namespace rapidjson; using namespace std; +using namespace rapidjson; +using namespace boost; typedef sol_rules::build_order ord; typedef sol_rules::build_policy pol; @@ -324,4 +326,35 @@ bool operator==(const game_state& a, const game_state& b) { ostream& operator <<(ostream& stream, const game_state& gs) { return gs.print(stream); -}
\ No newline at end of file +} + +size_t hash_value(game_state const& gs) { + size_t seed = 0; + + if (gs.rules.foundations) { + hash_combine(seed, gs.foundations); + } + if (gs.rules.cells) { + hash_combine(seed, gs.cells); + } + if (gs.rules.tableau_pile_count > 0) { + hash_combine(seed, gs.tableau_piles); + } + if (gs.rules.reserve_size > 0) { + hash_combine(seed, gs.reserve); + } + if (gs.rules.stock_size > 0) { + hash_combine(seed, gs.stock); + hash_combine(seed, gs.waste); + } + if (gs.rules.hole) { + hash_combine(seed, gs.hole); + } + + return seed; +} + +size_t hash_value(vector<pile> const& vp) { + return hash_range(begin(vp), end(vp)); +} + |
