X-Git-Url: http://git.scottworley.com/slidingtile/blobdiff_plain/f3f55aff4e3346b297215050c2076c821fd60c83..f548f940f95af83b788abf75625d5a5e7fe5617c:/sliding_tile_lib.h diff --git a/sliding_tile_lib.h b/sliding_tile_lib.h index 84d422e..c926761 100644 --- a/sliding_tile_lib.h +++ b/sliding_tile_lib.h @@ -2,17 +2,35 @@ #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(); - signed char hole(); + bool is_valid() const; + signed char hole() const; + InvertedBoard invert() const; + int distance(const Board& o) const; + int distance(const InvertedBoard& invo) const; }; std::istream& operator>>(std::istream& is, Board& board); +std::ostream& operator<<(std::ostream& os, const Board& board); + +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); -extern signed char adjacent[BOARD_SIZE][5]; #endif /* _SLIDING_TILE_LIB_H */