// // Created by thecharlesblake on 10/24/17. // #ifndef SOLVITAIRE_SOLVER_H #define SOLVITAIRE_SOLVER_H #include #include #include #include "../game/global_cache.h" #include "../game/sol_rules.h" class solver { public: enum class sol_state {solved, unsolvable, timed_out}; lru_cache cache; struct node { node(move); const move mv; std::vector child_moves; boost::optional cache_state; // Optional, as dominance moves aren't cached }; struct solution_info { int states_searched; int unique_states_searched; int backtracks; int dominance_moves; uint64_t states_removed_from_cache; lru_cache::item_list::size_type cache_size; lru_cache::item_list::size_type cache_bucket_count; int max_depth; int depth; }; friend std::ostream& operator<< (std::ostream&, const solution_info&); explicit solver(const game_state&, uint64_t); sol_state run(boost::optional &> = boost::none); void print_solution() const; int get_states_searched() const; int get_unique_states_searched() const; int get_cache_size() const; int get_states_rem_from_cache() const; const std::vector get_frontier() const; solution_info get_solution_info(); private: bool revert_to_last_node_with_children(boost::optional = boost::none); void set_to_child(); const game_state init_state; game_state state; std::vector frontier; int states_searched; int unique_states_searched; int backtracks; int dominance_moves; int depth; int max_depth; node root; std::vector::iterator current_node; }; #endif //SOLVITAIRE_SOLVER_H