]> git.scottworley.com Git - slidingtile/blobdiff - sliding_tile_lib.h
successors is const
[slidingtile] / sliding_tile_lib.h
index 8967324fb745eba07d8cd98743edac3ae597757b..1b56da4c80a7e4fbc18947abc4a6f193c0eb057c 100644 (file)
@@ -2,13 +2,38 @@
 #define _SLIDING_TILE_LIB_H
 
 #include <istream>
+#include <memory>
+#include <ostream>
+#include <vector>
 
 const int BOARD_DIM = 4;
 const int BOARD_SIZE = BOARD_DIM * BOARD_DIM;
 
-typedef signed char Board[BOARD_SIZE];
+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);
+
+struct Step {
+  Board board;
+  std::shared_ptr<Step> prev;
+  std::vector<Step*> successors(std::shared_ptr<Step> shared_this) const;
+  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 */