From fb20d1289ce87234bfae2cb8d784d9edf1d3ff16 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Wed, 15 Nov 2017 21:22:40 +0000 Subject: Change history to boost multi-index map --- src/main/game/game_state.cpp | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'src/main/game/game_state.cpp') 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 #include +#include #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 const& vp) { + return hash_range(begin(vp), end(vp)); +} + -- cgit v1.2.1