]> git.scottworley.com Git - slidingtile/blame - sliding_tile_lib.h
Board equality operator
[slidingtile] / sliding_tile_lib.h
CommitLineData
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
9const int BOARD_DIM = 4;
10const int BOARD_SIZE = BOARD_DIM * BOARD_DIM;
32688d85 11
9c32325f
SW
12struct InvertedBoard {
13 signed char pos[BOARD_SIZE];
14};
15
19bd29f9
SW
16struct 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;
19bd29f9 25};
32688d85 26std::istream& operator>>(std::istream& is, Board& board);
cada47bf 27std::ostream& operator<<(std::ostream& os, const Board& board);
32688d85 28
5d2f7c7c
SW
29struct Step {
30 Board board;
31 std::shared_ptr<Step> prev;
32 std::vector<Step*> successors(std::shared_ptr<Step> shared_this);
33 static signed char adjacent[BOARD_SIZE][5];
34};
49358f36 35std::ostream& operator<<(std::ostream& os, const Step& step);
5d2f7c7c 36
82d6eed5
SW
37
38#endif /* _SLIDING_TILE_LIB_H */