From bba8775ce7c63783303240470d4a4b8404c9498b Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Sat, 11 Nov 2017 11:36:27 +0000 Subject: Add src file directory structure --- src/main/solver/solver.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/solver/solver.h (limited to 'src/main/solver/solver.h') diff --git a/src/main/solver/solver.h b/src/main/solver/solver.h new file mode 100644 index 0000000..c1a72d3 --- /dev/null +++ b/src/main/solver/solver.h @@ -0,0 +1,39 @@ +// +// Created by thecharlesblake on 10/24/17. +// + +#ifndef SOLVITAIRE_SOLVER_H +#define SOLVITAIRE_SOLVER_H + +#include +#include + +#include + +#include "game/game_state.h" +#include "game/sol_rules.h" + +class solver { +public: + solver(const game_state, const sol_rules&); + bool run(); + + friend std::ostream& operator<< (std::ostream&, const solver&); + +private: + struct node { + node(const game_state); + std::vector history; + game_state state; + }; + + const node root; + const sol_rules rules; + bool been_run; + node solution; + bool solution_found; + int states_searched; +}; + + +#endif //SOLVITAIRE_SOLVER_H -- cgit v1.2.1 From 4b66501286a4e7e87f5a310ff060b5f4ee4c8315 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Sun, 12 Nov 2017 09:50:25 +0000 Subject: Improve game state gen + run() returns opt --- src/main/solver/solver.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/main/solver/solver.h') diff --git a/src/main/solver/solver.h b/src/main/solver/solver.h index c1a72d3..6dfccc2 100644 --- a/src/main/solver/solver.h +++ b/src/main/solver/solver.h @@ -15,18 +15,22 @@ class solver { public: - solver(const game_state, const sol_rules&); - bool run(); - - friend std::ostream& operator<< (std::ostream&, const solver&); - -private: struct node { - node(const game_state); + node(const node*, const game_state&); std::vector history; game_state state; + + static const std::vector gen_history(const node* parent); }; + solver(const game_state, const sol_rules&); + boost::optional run(); + const node get_root() const; + int get_states_searched() const; + + friend std::ostream& operator<< (std::ostream&, const solver::node&); + +private: const node root; const sol_rules rules; bool been_run; -- cgit v1.2.1 From 16556a7f36da4fc8093285392f81409b1cfa7aa7 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Sun, 12 Nov 2017 22:48:15 +0000 Subject: Refactor solver --- src/main/solver/solver.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/main/solver/solver.h') diff --git a/src/main/solver/solver.h b/src/main/solver/solver.h index 6dfccc2..91c93d6 100644 --- a/src/main/solver/solver.h +++ b/src/main/solver/solver.h @@ -24,18 +24,18 @@ public: }; solver(const game_state, const sol_rules&); - boost::optional run(); + const node get_root() const; int get_states_searched() const; + const boost::optional run(); + friend std::ostream& operator<< (std::ostream&, const solver::node&); private: const node root; const sol_rules rules; - bool been_run; node solution; - bool solution_found; int states_searched; }; -- cgit v1.2.1