From 3ce4c07a3d78082590629d36d4039d68f0a84663 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Wed, 10 Jan 2018 18:15:14 +0000 Subject: Add asserts to program and fix bugs they raise --- src/main/solver/solver.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/main/solver') 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); } } } -- cgit v1.2.1