#include <astar2.h>
Inheritance diagram for AStar:

Public Types | |
| typedef vector< MapCoordinate > | Path |
| typedef std::vector< Node > | Container |
Public Member Functions | |
| AStar (GameMap *actmap, Vehicle *veh) | |
| int | dist (HexCoord a, HexCoord b) |
| void | get_first (Container &v, Node &n) |
| void | findPath (HexCoord A, HexCoord B, Path &path) |
| searches for a path from A to B and stores it in path | |
| void | findPath (Path &path, int x, int y) |
| searches for a path from the units current position to dest and stores it in path | |
| void | findAllAccessibleFields (int maxDist=maxint) |
| searches for all fields that are within the range of maxDist and marks them. | |
| int | getDistance () |
| returns the distance of the last found path, or -1 on any error | |
| int | getTravelTime () |
| returns the number of turns that the unit will need to travel along the last found path | |
| bool | fieldVisited (int x, int y) |
| checks weather the field fld was among the visited fields during the last search | |
| virtual | ~AStar () |
Public Attributes | |
| std::greater< Node > | comp |
| Container | visited |
Protected Member Functions | |
| virtual int | getMoveCost (int x1, int y1, int x2, int y2, const Vehicle *vehicle) |
| returns the movement cost for the unit to travel from x1/y1 to x2/y2 | |
Protected Attributes | |
| int | MAXIMUM_PATH_LENGTH |
| GameMap * | tempsMarked |
| Path * | _path |
| Vehicle * | _veh |
| GameMap * | gamemap |
Classes | |
| struct | HexCoord |
| A hexagonal Coordinate. This structure is used instead of MapCoordinate to reduce the amount of modifications to Amits path finding code. More... | |
| struct | Node |
Definition at line 23 of file astar2.h.
| typedef vector<MapCoordinate> AStar::Path |
| typedef std::vector<Node> AStar::Container |
Definition at line 63 of file astar2.cpp.
References _path, _veh, actmap, gamemap, MAXIMUM_PATH_LENGTH, maxint, and tempsMarked.
| AStar::~AStar | ( | ) | [virtual] |
| int AStar::getMoveCost | ( | int | x1, | |
| int | y1, | |||
| int | x2, | |||
| int | y2, | |||
| const Vehicle * | vehicle | |||
| ) | [protected, virtual] |
returns the movement cost for the unit to travel from x1/y1 to x2/y2
Reimplemented in StratAStar, and HiddenAStar.
Definition at line 105 of file astar2.cpp.
References calcMoveMalus(), fieldAccessible(), gamemap, GameMap::getField(), Vehicle::height, and MAXIMUM_PATH_LENGTH.
Referenced by findPath(), HiddenAStar::getMoveCost(), and StratAStar::getMoveCost().
Definition at line 78 of file astar2.cpp.
References beeline(), AStar::HexCoord::m, and AStar::HexCoord::n.
Referenced by findPath(), getDistance(), and getTravelTime().
searches for a path from A to B and stores it in path
Definition at line 139 of file astar2.cpp.
References _path, _veh, Vehicle::canMove(), GameMap::cleartemps(), comp, DirNone, dist(), GameMap::field, fieldAccessible(), gamemap, get_first(), GameMap::getField(), getMoveCost(), getnextfield(), AStar::Node::gval, AStar::Node::h, AStar::Node::hval, AStar::HexCoord::m, MAXIMUM_PATH_LENGTH, Vehicle::maxMovement(), N, AStar::HexCoord::n, random(), ReverseDirection(), MapField::temp3, MapField::unitHere(), visited, GameMap::xsize, and GameMap::ysize.
Referenced by findAllAccessibleFields(), findPath(), and findPath().
| void AStar::findPath | ( | Path & | path, | |
| int | x, | |||
| int | y | |||
| ) |
searches for a path from the units current position to dest and stores it in path
Definition at line 339 of file astar2.cpp.
References _veh, findPath(), Vehicle::xpos, and Vehicle::ypos.
| void AStar::findAllAccessibleFields | ( | int | maxDist = maxint |
) |
searches for all fields that are within the range of maxDist and marks them.
On each field one bit for each level of height will be set. The Destructor removes all marks.
Definition at line 324 of file astar2.cpp.
References MapField::a, GameMap::cleartemps(), findPath(), gamemap, GameMap::getField(), MAXIMUM_PATH_LENGTH, tempsMarked, visited, GameMap::xsize, and GameMap::ysize.
| int AStar::getDistance | ( | ) |
returns the distance of the last found path, or -1 on any error
Definition at line 290 of file astar2.cpp.
References _path, _veh, dist(), gamemap, GameMap::getField(), MapField::getmovemalus(), VehicleType::movemalustyp, and Vehicle::typ.
Referenced by getTravelTime().
| int AStar::getTravelTime | ( | ) |
returns the number of turns that the unit will need to travel along the last found path
Definition at line 305 of file astar2.cpp.
References _veh, dist(), getDistance(), getFirstBit(), Vehicle::height, VehicleType::movement, and Vehicle::typ.
| bool AStar::fieldVisited | ( | int | x, | |
| int | y | |||
| ) |
checks weather the field fld was among the visited fields during the last search
Definition at line 314 of file astar2.cpp.
References visited.
int AStar::MAXIMUM_PATH_LENGTH [protected] |
Definition at line 28 of file astar2.h.
Referenced by AStar(), findAllAccessibleFields(), findPath(), and getMoveCost().
GameMap* AStar::tempsMarked [protected] |
Definition at line 29 of file astar2.h.
Referenced by AStar(), findAllAccessibleFields(), and ~AStar().
Path* AStar::_path [protected] |
Vehicle* AStar::_veh [protected] |
Definition at line 31 of file astar2.h.
Referenced by AStar(), findPath(), getDistance(), and getTravelTime().
GameMap* AStar::gamemap [protected] |
Definition at line 32 of file astar2.h.
Referenced by AStar(), findAllAccessibleFields(), findPath(), getDistance(), and getMoveCost().
| std::greater<Node> AStar::comp |
Definition at line 65 of file astar2.h.
Referenced by fieldVisited(), findAllAccessibleFields(), and findPath().
1.5.1