-
Notifications
You must be signed in to change notification settings - Fork 15
/
search-interface.h
56 lines (41 loc) · 1.36 KB
/
search-interface.h
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
56
#ifndef SEARCH_INTERFACE_H
#define SEARCH_INTERFACE_H
#include "move.h"
#include "game.h"
#include <ostream>
class SearchState;
class AStarHeuristicItf;
class SearchAction {
public:
SearchAction(Location from, Location to) : from_(from), to_(to) {} ;
SearchState execute(const SearchState& state) const ;
friend std::ostream& operator<< (std::ostream& os, const SearchAction & action) ;
const Location& from() const;
const Location& to() const;
private:
Location from_;
Location to_;
};
class SearchState {
public:
explicit SearchState(GameState state) : state_(state) {}
bool isFinal() const;
std::vector<SearchAction> actions() const;
bool execute(const SearchAction &action);
static unsigned long long nbExpanded();
friend std::ostream& operator<< (std::ostream& os, const SearchState & state) ;
friend bool operator<(const SearchState &a, const SearchState &b) ;
friend bool operator==(const SearchState &a, const SearchState &b) ;
friend double compute_heuristic(const SearchState &state, const AStarHeuristicItf &heuristic);
friend size_t hash(const SearchState &state);
private:
void runSafeMoves_();
GameState state_;
static unsigned long long nb_expanded;
};
class SearchStrategyItf {
public:
virtual std::vector<SearchAction> solve(const SearchState &init_state) =0 ;
virtual ~SearchStrategyItf() {}
};
#endif