aboutsummaryrefslogtreecommitdiff
path: root/src/main/solver/solver.h
blob: 1ef841d65e1134315def152a83cfcda115b7ebfb (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
//
// Created by thecharlesblake on 10/24/17.
//

#ifndef SOLVITAIRE_SOLVER_H
#define SOLVITAIRE_SOLVER_H

#include <string>
#include <vector>
#include <unordered_set>

#include "../game/game_state.h"
#include "../game/sol_rules.h"

class solver {
public:
    std::unordered_set<
            std::vector<pile>,
            boost::hash<std::vector<pile>>
    > global_cache;

    struct node {
        explicit node(const game_state::move, std::vector<game_state::move>&&);
        const game_state::move move;
        std::vector<game_state::move> unsearched_children;
    };

    solver(const game_state&, const sol_rules&);

    bool run();
    void print_solution() const;

private:
    const game_state initial_state;
    const sol_rules rules;
    std::vector<node> frontier;
    int states_searched;
};


#endif //SOLVITAIRE_SOLVER_H