OpenTTD Source 20250426-master-gbb1d561369
|
AyStar search algorithm struct. More...
#include <aystar.h>
Protected Member Functions | |
virtual int32_t | CalculateG (const AyStarNode ¤t, const PathNode &parent) const =0 |
Calculate the G-value for the AyStar algorithm. | |
virtual int32_t | CalculateH (const AyStarNode ¤t, const PathNode &parent) const =0 |
Calculate the H-value for the AyStar algorithm. | |
virtual void | GetNeighbours (const PathNode ¤t, std::vector< AyStarNode > &neighours) const =0 |
This function requests the tiles around the current tile. | |
virtual AyStarStatus | EndNodeCheck (const PathNode ¤t) const =0 |
Check whether the end-tile is found. | |
virtual void | FoundEndNode (const PathNode ¤t)=0 |
If the End Node is found, this function is called. | |
void | AddStartNode (AyStarNode *start_node, int g) |
Adds a node from where to start an algorithm. | |
AyStarStatus | Main () |
This is the function you call to run AyStar. | |
Private Member Functions | |
AyStarStatus | Loop () |
This function is the core of AyStar. | |
void | OpenListAdd (PathNode *parent, const AyStarNode *node, int f, int g) |
Adds a node to the open list. | |
void | CheckTile (AyStarNode *current, PathNode *parent) |
Checks one tile and calculate its f-value. | |
Private Attributes | |
NodeList< PathNode, 8, 10 > | nodes |
std::vector< AyStarNode > | neighbours |
|
protected |
Adds a node from where to start an algorithm.
Multiple nodes can be added if wanted.
start_node | Node to start with. |
g | the cost for starting with this node. |
Definition at line 161 of file aystar.cpp.
References Debug, OpenListAdd(), TileX(), and TileY().
Referenced by RiverBuilder::Exec().
|
protectedpure virtual |
Calculate the G-value for the AyStar algorithm.
Implemented in RiverBuilder.
Referenced by CheckTile().
|
protectedpure virtual |
Calculate the H-value for the AyStar algorithm.
Mostly, this must return the distance (Manhattan way) between the current point and the end point.
Implemented in RiverBuilder.
Referenced by CheckTile().
|
private |
Checks one tile and calculate its f-value.
Definition at line 38 of file aystar.cpp.
References AYSTAR_INVALID_NODE, CalculateG(), CalculateH(), NodeList< Titem, Thash_bits_open, Thash_bits_closed >::FindClosedNode(), NodeList< Titem, Thash_bits_open, Thash_bits_closed >::FindOpenNode(), NodeList< Titem, Thash_bits_open, Thash_bits_closed >::InsertOpenNode(), OpenListAdd(), and NodeList< Titem, Thash_bits_open, Thash_bits_closed >::PopOpenNode().
Referenced by Loop().
|
protectedpure virtual |
Check whether the end-tile is found.
current | Node to exam. |
Implemented in RiverBuilder.
Referenced by Loop().
|
protectedpure virtual |
If the End Node is found, this function is called.
It can do, for example, calculate the route and put that in an array.
Implemented in RiverBuilder.
|
protectedpure virtual |
This function requests the tiles around the current tile.
neighbours is never reset, so if you are not using directions, just leave it alone.
Implemented in RiverBuilder.
Referenced by Loop().
|
private |
This function is the core of AyStar.
It handles one item and checks its neighbour items. If they are valid, they are added to be checked too.
Definition at line 91 of file aystar.cpp.
References AYSTAR_DEF_MAX_SEARCH_NODES, CheckTile(), NodeList< Titem, Thash_bits_open, Thash_bits_closed >::ClosedCount(), EmptyOpenList, EndNodeCheck(), FoundEndNode, GetNeighbours(), NodeList< Titem, Thash_bits_open, Thash_bits_closed >::InsertClosedNode(), LimitReached, NodeList< Titem, Thash_bits_open, Thash_bits_closed >::PopBestOpenNode(), and StillBusy.
Referenced by Main().
|
protected |
This is the function you call to run AyStar.
Definition at line 132 of file aystar.cpp.
References Debug, EmptyOpenList, FoundEndNode, LimitReached, Loop(), NoPath, and StillBusy.
Referenced by RiverBuilder::Exec().
|
private |
Adds a node to the open list.
It makes a copy of node, and puts the pointer of parent in the struct.
Definition at line 25 of file aystar.cpp.
References NodeList< Titem, Thash_bits_open, Thash_bits_closed >::CreateNewNode(), and NodeList< Titem, Thash_bits_open, Thash_bits_closed >::InsertOpenNode().
Referenced by AddStartNode(), and CheckTile().
|
mutableprivate |