A* pathfinding algorithm implementation class.
More...
#include <path.h>
List of all members.
Classes |
struct | area_coord |
| (x, y) coordinates of a point on a submap. More...
|
struct | compare_squarecost |
Public Member Functions |
void | clear () |
| Totally clears the path.
|
bool | calculate () |
| Tries to find the shortest path possible between the start point and the goal point.
|
u_int16 | nbr_moves () const |
| Returns the number of moves between start and goal.
|
u_int16 | get_move (u_int16 nbr) const |
| Returns the move to perform when at position nbr.
|
s_int8 | get_state (igzstream &file) |
| Restore the path's state from an opened file.
|
s_int8 | put_state (ogzstream &file) const |
| Saves the path's state into an opened file.
|
Public Attributes |
landmap * | refmap |
| Landmap where the pathfinding will occur.
|
u_int16 | submap |
| Submap where the pathfinding will occur.
|
u_int16 | dir |
| Direction to face once the goal is reached.
|
area_coord | start |
| Start point.
|
area_coord | goal |
| Goal point.
|
Detailed Description
A* pathfinding algorithm implementation class.
This class calculates the shortest way from a begin point to a goal point on a landmap using the A* algorithm. It stores a list of directions that when followed lead from the start to the goal.
This class is particularly well designed for mapcharacters, who will often need to walk from one point to another.
Definition at line 48 of file path.h.
Member Function Documentation
void path::clear |
( |
|
) |
[inline] |
Totally clears the path.
Definition at line 115 of file path.h.
Tries to find the shortest path possible between the start point and the goal point.
- Returns:
- true if a path was found, false otherwise.
Definition at line 43 of file path.cc.
u_int16 path::nbr_moves |
( |
|
) |
const [inline] |
Returns the number of moves between start and goal.
- Returns:
- Number of moves between start and goal.
Definition at line 134 of file path.h.
u_int16 path::get_move |
( |
u_int16 |
nbr |
) |
const [inline] |
Returns the move to perform when at position nbr.
- Parameters:
-
| nbr | Index of the move to get. |
- Returns:
- Direction (move) at index nbr.
Definition at line 146 of file path.h.
Restore the path's state from an opened file.
- Parameters:
-
| file | the opened file from which to load the state. |
- Returns:
- 0 in case of success, error code otherwise.
- Bug:
- the landmap this path belongs to must be restored manually!
Definition at line 261 of file path.cc.
s_int8 path::put_state |
( |
ogzstream & |
file |
) |
const |
Saves the path's state into an opened file.
- Parameters:
-
| file | the opened file where to the state. |
- Returns:
- 0 in case of success, error code otherwise.
- Bug:
- the landmap this path belongs to can't be saved (as it's a pointer)!
Definition at line 285 of file path.cc.
Member Data Documentation
Landmap where the pathfinding will occur.
Definition at line 84 of file path.h.
Submap where the pathfinding will occur.
Definition at line 90 of file path.h.
Direction to face once the goal is reached.
Definition at line 96 of file path.h.
Start point.
Definition at line 102 of file path.h.
Goal point.
Definition at line 108 of file path.h.
The documentation for this class was generated from the following files: