]>
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; | |
19bd29f9 | 23 | }; |
32688d85 | 24 | std::istream& operator>>(std::istream& is, Board& board); |
cada47bf | 25 | std::ostream& operator<<(std::ostream& os, const Board& board); |
32688d85 | 26 | |
5d2f7c7c SW |
27 | struct Step { |
28 | Board board; | |
29 | std::shared_ptr<Step> prev; | |
30 | std::vector<Step*> successors(std::shared_ptr<Step> shared_this); | |
31 | static signed char adjacent[BOARD_SIZE][5]; | |
32 | }; | |
49358f36 | 33 | std::ostream& operator<<(std::ostream& os, const Step& step); |
5d2f7c7c | 34 | |
82d6eed5 SW |
35 | |
36 | #endif /* _SLIDING_TILE_LIB_H */ |