X-Git-Url: http://git.scottworley.com/slidingtile/blobdiff_plain/cada47bfe401f2084c4248df10cdf0488bc8750a..310a7132ffc617b93969703de7f3bf1c5ea0fa30:/sliding_tile_lib.h?ds=sidebyside diff --git a/sliding_tile_lib.h b/sliding_tile_lib.h index d144789..772817e 100644 --- a/sliding_tile_lib.h +++ b/sliding_tile_lib.h @@ -2,19 +2,38 @@ #define _SLIDING_TILE_LIB_H #include +#include #include +#include const int BOARD_DIM = 4; const int BOARD_SIZE = BOARD_DIM * BOARD_DIM; +struct InvertedBoard { + signed char pos[BOARD_SIZE]; +}; + struct Board { signed char board[BOARD_SIZE]; bool is_valid() const; signed char hole() const; + InvertedBoard invert() const; + int distance(const Board& o) const; + int distance(const InvertedBoard& invo) const; + bool operator==(const Board& o) const; + bool operator!=(const Board& o) const; + bool operator<(const Board& o) const; }; std::istream& operator>>(std::istream& is, Board& board); std::ostream& operator<<(std::ostream& os, const Board& board); -extern signed char adjacent[BOARD_SIZE][5]; +struct Step { + Board board; + std::shared_ptr prev; + std::vector successors(std::shared_ptr shared_this); + static signed char adjacent[BOARD_SIZE][5]; +}; +std::ostream& operator<<(std::ostream& os, const Step& step); + #endif /* _SLIDING_TILE_LIB_H */