]>
git.scottworley.com Git - slidingtile/blob - sliding_tile_lib.h
11d9de33b810b8410a06e37fc240b69a8270bc7f
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
);
36 std::shared_ptr
<Step
> prev
;
38 std::vector
<std::shared_ptr
<Step
>> successors(std::shared_ptr
<Step
> shared_this
) const;
40 int cost(const InvertedBoard
& invgoal
) const;
42 static signed char adjacent
[BOARD_SIZE
][5];
45 std::ostream
& operator<<(std::ostream
& os
, const Step
& step
);
47 std::shared_ptr
<Step
> find_path(const std::string
& start
, const std::string
& goal
);
48 std::shared_ptr
<Step
> find_path(const Board
& start
, const Board
& goal
);
50 #endif /* _SLIDING_TILE_LIB_H */