aboutsummaryrefslogtreecommitdiff
path: root/src/main/game/game_state.cpp
diff options
context:
space:
mode:
authorthecharlesblake2017-11-15 21:22:40 +0000
committerthecharlesblake2017-11-15 21:22:40 +0000
commitfb20d1289ce87234bfae2cb8d784d9edf1d3ff16 (patch)
tree3ac8c53538ee65d3361fb7f879e5685b90af9aff /src/main/game/game_state.cpp
parentMake simple-spanish-patience easier (diff)
downloadmetasol-fb20d1289ce87234bfae2cb8d784d9edf1d3ff16.tar.gz
metasol-fb20d1289ce87234bfae2cb8d784d9edf1d3ff16.zip

Change history to boost multi-index map

Diffstat (limited to 'src/main/game/game_state.cpp')
-rw-r--r--src/main/game/game_state.cpp37
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));
+}
+