]>
Commit | Line | Data |
---|---|---|
82d6eed5 SW |
1 | #ifndef _SLIDING_TILE_LIB_H |
2 | #define _SLIDING_TILE_LIB_H | |
3 | ||
32688d85 | 4 | #include <istream> |
5d2f7c7c | 5 | #include <memory> |
cada47bf | 6 | #include <ostream> |
5d2f7c7c | 7 | #include <vector> |
32688d85 | 8 | |
e86755d7 SW |
9 | const int BOARD_DIM = 4; |
10 | const int BOARD_SIZE = BOARD_DIM * BOARD_DIM; | |
32688d85 | 11 | |
9c32325f SW |
12 | struct InvertedBoard { |
13 | signed char pos[BOARD_SIZE]; | |
14 | }; | |
15 | ||
19bd29f9 SW |
16 | struct Board { |
17 | signed char board[BOARD_SIZE]; | |
cea272cf SW |
18 | bool is_valid() const; |
19 | signed char hole() const; | |
9c32325f SW |
20 | InvertedBoard invert() const; |
21 | int distance(const Board& o) const; | |
22 | int distance(const InvertedBoard& invo) const; | |
0e89d341 SW |
23 | bool operator==(const Board& o) const; |
24 | bool operator!=(const Board& o) const; | |
310a7132 | 25 | bool operator<(const Board& o) const; |
19bd29f9 | 26 | }; |
32688d85 | 27 | std::istream& operator>>(std::istream& is, Board& board); |
cada47bf | 28 | std::ostream& operator<<(std::ostream& os, const Board& board); |
32688d85 | 29 | |
5d2f7c7c SW |
30 | struct Step { |
31 | Board board; | |
32 | std::shared_ptr<Step> prev; | |
f92e9dca | 33 | std::vector<Step*> successors(std::shared_ptr<Step> shared_this) const; |
5d2f7c7c SW |
34 | static signed char adjacent[BOARD_SIZE][5]; |
35 | }; | |
49358f36 | 36 | std::ostream& operator<<(std::ostream& os, const Step& step); |
5d2f7c7c | 37 | |
82d6eed5 SW |
38 | |
39 | #endif /* _SLIDING_TILE_LIB_H */ |