aboutsummaryrefslogtreecommitdiff
path: root/src/main/solver/solver.cpp
diff options
context:
space:
mode:
authorthecharlesblake2018-01-03 12:30:14 +0000
committerthecharlesblake2018-01-03 12:30:14 +0000
commit77a7aeba7854d15b140cc6dc3c69b15ed5f3b936 (patch)
tree70b3b8315646ed38000a1627ec3f3efe20f31f92 /src/main/solver/solver.cpp
parentUpdate idea to python3 (diff)
downloadmetasol-77a7aeba7854d15b140cc6dc3c69b15ed5f3b936.tar.gz
metasol-77a7aeba7854d15b140cc6dc3c69b15ed5f3b936.zip

Major refactor, putting pile logic into game_state

Much of the logic that was in the pile class was beginning to seem out of place. A lot of the rules have fairly arbitrary interactons between piles, which weren’t best represented in the pile classes themselves, which were getting unweildy and inefficient. Hence, much of this logic has been moved to the game state class.

Diffstat (limited to 'src/main/solver/solver.cpp')
-rw-r--r--src/main/solver/solver.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/main/solver/solver.cpp b/src/main/solver/solver.cpp
index 694ad4e..66dcc07 100644
--- a/src/main/solver/solver.cpp
+++ b/src/main/solver/solver.cpp
@@ -25,9 +25,9 @@ solver::node::node(const game_state::move m,
bool solver::run() {
game_state state = initial_state;
- frontier.emplace_back(NULL_MOVE, state.get_legal_moves());
states_searched++;
LOG_DEBUG (state);
+ frontier.emplace_back(NULL_MOVE, state.get_legal_moves());
while (!frontier.empty()) {
node& current = frontier.back();
@@ -54,11 +54,11 @@ bool solver::run() {
// Insert the state into the global cache
bool is_new_state = global_cache.insert(state.get_data()).second;
if (is_new_state) {
+ states_searched++;
+ LOG_DEBUG (state);
// If the state is new, creates a new node in the frontier to
// represent the move just made, and those that are now possible
frontier.emplace_back(next_move, state.get_legal_moves());
- states_searched++;
- LOG_DEBUG (state);
} else {
// If we've seen the state before, undoes the move
state.undo_move(next_move);