aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthecharlesblake2018-02-15 12:44:14 +0000
committerthecharlesblake2018-02-15 12:44:14 +0000
commit27ebe493056ee29045361f86eea20cd176ff9143 (patch)
tree1ccf4e775eca538e63d4cf2cb78cb19894accd69
parentFix benchmark path bug (diff)
downloadmetasol-27ebe493056ee29045361f86eea20cd176ff9143.tar.gz
metasol-27ebe493056ee29045361f86eea20cd176ff9143.zip

Fix solver bug for instant-solve games

-rw-r--r--src/main/solver/solver.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/main/solver/solver.cpp b/src/main/solver/solver.cpp
index 7638d92..e55a4e3 100644
--- a/src/main/solver/solver.cpp
+++ b/src/main/solver/solver.cpp
@@ -6,6 +6,7 @@
#include <ostream>
#include <iostream>
#include <algorithm>
+#include <list>
#include "solver.h"
#include "../input-output/output/log_helper.h"
@@ -23,15 +24,16 @@ solver::solver(const game_state& gs)
}
solver::node::node(node* p, const game_state::move m)
- : parent(p), move(m) {
+ : parent(p), move(m), children() {
}
bool solver::run() {
bool states_exhausted = false;
while(!state.is_solved() && !states_exhausted) {
#ifndef NDEBUG
- if (current_node->move.is_dominance())
+ if (current_node->move.is_dominance()) {
LOG_DEBUG("(dominance move)");
+ }
LOG_DEBUG(state);
#endif
@@ -127,12 +129,14 @@ void solver::print_solution() const {
cout << "Solution:\n";
cout << state_copy << "\n";
- // Ignores first move which is
- while (!n->children.empty()) {
- // TODO print move as well
- state_copy.make_move(n->move);
- cout << state_copy << "\n";
- n = &n->children.back();
+
+ if (states_searched > 1) {
+ while (!n->children.empty()) {
+ // TODO print move as well
+ state_copy.make_move(n->move);
+ cout << state_copy << "\n";
+ n = &n->children.back();
+ }
}
cout << "States Searched: " << states_searched << "\n";
}