aboutsummaryrefslogtreecommitdiff
path: root/src/main/solver
diff options
context:
space:
mode:
authorthecharlesblake2018-01-25 15:20:54 +0000
committerthecharlesblake2018-01-25 15:20:54 +0000
commit252c7398925b5267963c1a48251cd7ba2d4ec381 (patch)
tree48edb3c44e1a7e8e6008dc764ae960273d466427 /src/main/solver
parentMerge pull request #31 from thecharlesblake/profiling-fix (diff)
downloadmetasol-252c7398925b5267963c1a48251cd7ba2d4ec381.tar.gz
metasol-252c7398925b5267963c1a48251cd7ba2d4ec381.zip

Refactor game_state & cache to remove static hack

Diffstat (limited to 'src/main/solver')
-rw-r--r--src/main/solver/solver.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main/solver/solver.cpp b/src/main/solver/solver.cpp
index 19fa79b..072db18 100644
--- a/src/main/solver/solver.cpp
+++ b/src/main/solver/solver.cpp
@@ -16,7 +16,7 @@ using namespace std;
using namespace boost;
solver::solver(const game_state& gs)
- : initial_state(gs), states_searched(0) {}
+ : cache(gs), initial_state(gs), states_searched(0) {}
solver::node::node(const game_state::move m,
vector<game_state::move> uc)
@@ -30,7 +30,7 @@ bool solver::run() {
states_searched++;
LOG_DEBUG (state);
frontier.emplace_back(game_state::move(0,0), state.get_legal_moves());
- cache.insert(state);
+ cache.insert(state.get_data());
while (!frontier.empty()) {
node& current = frontier.back();
@@ -47,7 +47,7 @@ bool solver::run() {
// (unless it's the null first move)
if (frontier.size() > 1) {
state.undo_move(current.move);
- assert(cache.contains(state));
+ assert(cache.contains(state.get_data()));
LOG_DEBUG (state);
}
// Returns to the previous state
@@ -60,7 +60,7 @@ bool solver::run() {
state.make_move(next_move);
// Insert the state into the global cache
- bool is_new_state = cache.insert(state);
+ bool is_new_state = cache.insert(state.get_data());
if (is_new_state) {
states_searched++;
LOG_DEBUG (state);
@@ -70,7 +70,7 @@ bool solver::run() {
} else {
// If we've seen the state before, undoes the move
state.undo_move(next_move);
- assert(cache.contains(state));
+ assert(cache.contains(state.get_data()));
}
}
}