X-Git-Url: http://git.scottworley.com/slidingtile/blobdiff_plain/9c32325fbc48baf135d0d7840e99ded70cb738f5..537a8dc7ce26e6ab5cf3c82ecce388d08566a8b8:/sliding_tile_lib.h diff --git a/sliding_tile_lib.h b/sliding_tile_lib.h index c5d0a8b..de2ca1f 100644 --- a/sliding_tile_lib.h +++ b/sliding_tile_lib.h @@ -2,7 +2,10 @@ #define _SLIDING_TILE_LIB_H #include +#include #include +#include +#include const int BOARD_DIM = 4; const int BOARD_SIZE = BOARD_DIM * BOARD_DIM; @@ -18,10 +21,28 @@ struct Board { 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 { + Step(Board board, std::shared_ptr prev); + + Board board; + std::shared_ptr prev; + + std::vector> successors(std::shared_ptr shared_this) const; + int length() const; + int cost(const InvertedBoard& invgoal) const; + + static signed char adjacent[BOARD_SIZE][5]; +}; +std::ostream& operator<<(std::ostream& os, const Step& step); + +std::shared_ptr find_path(const std::string& start, const std::string& goal); +std::shared_ptr find_path(const Board& start, const Board& goal); #endif /* _SLIDING_TILE_LIB_H */