]>
git.scottworley.com Git - slidingtile/blob - sliding_tile_lib.h
de2ca1f7fb077295cccb7ae41ee6a5527f4ba2ef
1 #ifndef _SLIDING_TILE_LIB_H
2 #define _SLIDING_TILE_LIB_H
10 const int BOARD_DIM
= 4;
11 const int BOARD_SIZE
= BOARD_DIM
* BOARD_DIM
;
13 struct InvertedBoard
{
14 signed char pos
[BOARD_SIZE
];
18 signed char board
[BOARD_SIZE
];
19 bool is_valid() const;
20 signed char hole() const;
21 InvertedBoard
invert() const;
22 int distance(const Board
& o
) const;
23 int distance(const InvertedBoard
& invo
) const;
24 bool operator==(const Board
& o
) const;
25 bool operator!=(const Board
& o
) const;
26 bool operator<(const Board
& o
) const;
28 std::istream
& operator>>(std::istream
& is
, Board
& board
);
29 std::ostream
& operator<<(std::ostream
& os
, const Board
& board
);
32 Step(Board board
, std::shared_ptr
<Step
> prev
);
35 std::shared_ptr
<Step
> prev
;
37 std::vector
<std::shared_ptr
<Step
>> successors(std::shared_ptr
<Step
> shared_this
) const;
39 int cost(const InvertedBoard
& invgoal
) const;
41 static signed char adjacent
[BOARD_SIZE
][5];
43 std::ostream
& operator<<(std::ostream
& os
, const Step
& step
);
45 std::shared_ptr
<Step
> find_path(const std::string
& start
, const std::string
& goal
);
46 std::shared_ptr
<Step
> find_path(const Board
& start
, const Board
& goal
);
48 #endif /* _SLIDING_TILE_LIB_H */