aboutsummaryrefslogtreecommitdiff
path: root/src/main/solver/solver.cpp
diff options
context:
space:
mode:
authorCharlie Blake2018-01-10 18:16:34 +0000
committerGitHub2018-01-10 18:16:34 +0000
commit2a62143fb9edb929f410b1b9b3aed16a16ceba39 (patch)
treed5d7839783cebb097af9f071751d693f47e3af6d /src/main/solver/solver.cpp
parentMerge pull request #28 from thecharlesblake/all-canonical-games (diff)
parentAdd asserts to program and fix bugs they raise (diff)
downloadmetasol-2a62143fb9edb929f410b1b9b3aed16a16ceba39.tar.gz
metasol-2a62143fb9edb929f410b1b9b3aed16a16ceba39.zip

Merge pull request #29 from thecharlesblake/refactor-improve-debug

Refactor improve debug

Diffstat (limited to 'src/main/solver/solver.cpp')
-rw-r--r--src/main/solver/solver.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main/solver/solver.cpp b/src/main/solver/solver.cpp
index aaaf530..bd19351 100644
--- a/src/main/solver/solver.cpp
+++ b/src/main/solver/solver.cpp
@@ -26,7 +26,8 @@ bool solver::run() {
states_searched++;
LOG_DEBUG (state);
- frontier.emplace_back(game_state::null_move(), state.get_legal_moves());
+ frontier.emplace_back(game_state::move(0,0), state.get_legal_moves());
+ global_cache.insert(state.get_data());
while (!frontier.empty()) {
node& current = frontier.back();
@@ -40,11 +41,13 @@ bool solver::run() {
// (unless it's the null first move)
if (frontier.size() > 1) {
state.undo_move(current.move);
+ assert(global_cache.count(state.get_data()) == 1);
+ LOG_DEBUG (state);
}
// Returns to the previous state
frontier.pop_back();
} else {
- game_state::move next_move = current.unsearched_children[current.unsearched_children.size()-1];
+ game_state::move next_move = current.unsearched_children.back();
current.unsearched_children.pop_back();
// Applies the first possible move in this state
@@ -61,6 +64,7 @@ bool solver::run() {
} else {
// If we've seen the state before, undoes the move
state.undo_move(next_move);
+ assert(global_cache.count(state.get_data()) == 1);
}
}
}