blob: b1455e57e245aac367075a5ba4c590cd51d6ed42 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
//
// Created by thecharlesblake on 10/24/17.
//
#ifndef SOLVITAIRE_SOLVER_H
#define SOLVITAIRE_SOLVER_H
#include <string>
#include <vector>
#include <atomic>
#include "../game/global_cache.h"
#include "../game/sol_rules.h"
class solver {
public:
enum class sol_state {solved, unsolvable, cutoff};
global_cache cache;
struct node {
node(node*, game_state::move);
node* parent;
const game_state::move move;
std::vector<node> children;
};
explicit solver(const game_state&);
~solver();
sol_state run(boost::optional<std::atomic<bool> &> = boost::none);
sol_state run_with_cutoff(boost::optional<std::atomic<bool> &>,
boost::optional<uint> = boost::none);
void print_solution() const;
int get_states_searched() const;
int get_final_depth() const;
const node& get_search_tree() const;
private:
bool revert_to_last_node_with_children();
void add_children(std::vector<game_state::move>&);
void add_child(game_state::move);
std::vector<game_state::move> get_next_moves();
const game_state init_state;
game_state state;
int states_searched;
uint depth;
node root;
node* current_node;
};
#endif //SOLVITAIRE_SOLVER_H
|