]> git.scottworley.com Git - slidingtile/blobdiff - sliding_tile_lib.h
find_path
[slidingtile] / sliding_tile_lib.h
index 772817ea5ea57d84d28aafa6f6d0a9d607e39187..de2ca1f7fb077295cccb7ae41ee6a5527f4ba2ef 100644 (file)
@@ -4,6 +4,7 @@
 #include <istream>
 #include <memory>
 #include <ostream>
 #include <istream>
 #include <memory>
 #include <ostream>
+#include <string>
 #include <vector>
 
 const int BOARD_DIM = 4;
 #include <vector>
 
 const int BOARD_DIM = 4;
@@ -28,12 +29,20 @@ std::istream& operator>>(std::istream& is, Board& board);
 std::ostream& operator<<(std::ostream& os, const Board& board);
 
 struct Step {
 std::ostream& operator<<(std::ostream& os, const Board& board);
 
 struct Step {
+  Step(Board board, std::shared_ptr<Step> prev);
+
   Board board;
   std::shared_ptr<Step> prev;
   Board board;
   std::shared_ptr<Step> prev;
-  std::vector<Step*> successors(std::shared_ptr<Step> shared_this);
+
+  std::vector<std::shared_ptr<Step>> successors(std::shared_ptr<Step> 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);
 
   static signed char adjacent[BOARD_SIZE][5];
 };
 std::ostream& operator<<(std::ostream& os, const Step& step);
 
+std::shared_ptr<Step> find_path(const std::string& start, const std::string& goal);
+std::shared_ptr<Step> find_path(const Board& start, const Board& goal);
 
 #endif /* _SLIDING_TILE_LIB_H */
 
 #endif /* _SLIDING_TILE_LIB_H */