diff options
| author | Charlie Blake | 2018-03-08 14:59:30 +0000 |
|---|---|---|
| committer | GitHub | 2018-03-08 14:59:30 +0000 |
| commit | dd97cf54cb0f76679a2323ab599a86fc4f005193 (patch) | |
| tree | db04a4886f4f622d4a6cddf65e35ebdd8e37c7a2 /src/main/solver/solver.cpp | |
| parent | Merge pull request #41 from thecharlesblake/profile-improve (diff) | |
| parent | Add results dir (diff) | |
| download | metasol-dd97cf54cb0f76679a2323ab599a86fc4f005193.tar.gz metasol-dd97cf54cb0f76679a2323ab599a86fc4f005193.zip | |
Merge pull request #42 from thecharlesblake/solvability-percentages
Solvability percentages
Diffstat (limited to 'src/main/solver/solver.cpp')
| -rw-r--r-- | src/main/solver/solver.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/main/solver/solver.cpp b/src/main/solver/solver.cpp index ab24824..463d059 100644 --- a/src/main/solver/solver.cpp +++ b/src/main/solver/solver.cpp @@ -23,13 +23,27 @@ solver::solver(const game_state& gs) , current_node(&root) { } +solver::~solver() { + // This code looks to be unnecessary, but on alpha-star 6212 without it, + // for reasons that I cannot fathom, it segfaults. + while (current_node != nullptr) { + current_node->children.clear(); + current_node = current_node->parent; + } +} + solver::node::node(node* p, const game_state::move m) : parent(p), move(m), children() { } -bool solver::run() { +bool solver::run(optional<atomic<bool> &> terminate_solver) { bool states_exhausted = false; while(!state.is_solved() && !states_exhausted) { + // If the terminate flag was supplied and has been set to true, return + if (terminate_solver && *terminate_solver) { + return false; + } + #ifndef NDEBUG if (current_node->move.is_dominance()) { LOG_DEBUG("(dominance move)"); |
