Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

AStar3D Class Reference

A 3D path finding algorithm, based on the 2D algorithm by Amit J. Patel. More...

#include <astar2.h>

Inheritance diagram for AStar3D:

Inheritance graph
[legend]
List of all members.

Public Types

typedef float DistanceType
typedef vector< PathPointPath

Public Member Functions

 AStar3D (GameMap *actmap, Vehicle *veh, bool markTemps_=true, int maxDistance=maxint)
void registerOperationLimiter (OperationLimiter *ol)
 the search can be restricted to certain operations
void findPath (const MapCoordinate3D &A, const vector< MapCoordinate3D > &B, Path &path)
 searches for a path from A to B and stores it in path
void findPath (Path &path, const MapCoordinate3D &dest)
 searches for a path from the unit's current position to dest and stores it in path
void findPath (Path &path, const vector< MapCoordinate3D > &dest)
 searches for a path from the units current position to one of the dest fields and stores it in path
void findAllAccessibleFields ()
 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
const NodefieldVisited (const MapCoordinate3D &fld)
 checks weather the field fld was among the visited fields during the last search
int & getFieldAccess (int x, int y)
int & getFieldAccess (const MapCoordinate &mc)
virtual ~AStar3D ()

Public Attributes

Container visited
 the reachable fields

Static Public Attributes

static const DistanceType longestPath = 1e9

Protected Member Functions

virtual DistanceType getMoveCost (const MapCoordinate3D &start, const MapCoordinate3D &dest, const Vehicle *vehicle, bool &canStop, bool &hasAttacked)
HexDirectiongetPosDir (const MapCoordinate3D &pos)
int & getPosHHop (const MapCoordinate3D &pos)
DistanceType dist (const MapCoordinate3D &a, const MapCoordinate3D &b)
DistanceType dist (const MapCoordinate3D &a, const vector< MapCoordinate3D > &b)
bool get_first (Container &v, Node &n)
void nodeVisited (const Node &n, HexDirection direc, Container &open, int prevHeight=-10, int heightChangeDist=0)

Protected Attributes

OperationLimiteroperationLimiter
int MAXIMUM_PATH_LENGTH
GameMaptempsMarked
Path_path
Vehicleveh
GameMapactmap
float vehicleSpeedFactor [8]
bool markTemps
WindMovementwind
HexDirectionposDirs
int * posHHops
int * fieldAccess

Classes

class  Container
struct  Node
class  OperationLimiter
class  PathPoint

Detailed Description

A 3D path finding algorithm, based on the 2D algorithm by Amit J. Patel.

Definition at line 97 of file astar2.h.


Member Typedef Documentation

typedef float AStar3D::DistanceType
 

Definition at line 99 of file astar2.h.

typedef vector<PathPoint> AStar3D::Path
 

Definition at line 122 of file astar2.h.


Constructor & Destructor Documentation

AStar3D::AStar3D GameMap actmap,
Vehicle veh,
bool  markTemps_ = true,
int  maxDistance = maxint
 

Definition at line 430 of file astar2.cpp.

References _path, actmap, chfliegend, chhochfliegend, chtieffliegend, DirNone, fieldAccess, Vehicle::getPosition(), Vehicletype::height, longestPath, markTemps, MAXIMUM_PATH_LENGTH, Vehicle::maxMovement(), Vehicletype::movement, posDirs, posHHops, tempsMarked, Vehicle::typ, veh, vehicleSpeedFactor, GameMap::weather, wind, GameMap::Weather::windSpeed, GameMap::xsize, and GameMap::ysize.

AStar3D::~AStar3D  )  [virtual]
 

Definition at line 480 of file astar2.cpp.

References GameMap::cleartemps(), fieldAccess, posDirs, posHHops, tempsMarked, and wind.


Member Function Documentation

AStar3D::DistanceType AStar3D::dist const MapCoordinate3D a,
const vector< MapCoordinate3D > &  b
[protected]
 

Definition at line 512 of file astar2.cpp.

References dist(), and longestPath.

AStar3D::DistanceType AStar3D::dist const MapCoordinate3D a,
const MapCoordinate3D b
[protected]
 

Definition at line 495 of file astar2.cpp.

References beeline(), chfliegend, chhochfliegend, chtieffliegend, MapCoordinate3D::getBitmappedHeight(), MapCoordinate3D::getNumericalHeight(), longestPath, minmalq, MapCoordinate::valid(), wind, and windbeeline().

Referenced by dist(), and findPath().

const AStar3D::Node * AStar3D::fieldVisited const MapCoordinate3D fld  ) 
 

checks weather the field fld was among the visited fields during the last search

Definition at line 926 of file astar2.cpp.

References AStar3D::Container::end(), AStar3D::Container::find(), and visited.

Referenced by findPath().

void AStar3D::findAllAccessibleFields  ) 
 

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 907 of file astar2.cpp.

References actmap, AStar3D::Container::begin(), GameMap::cleartemps(), AStar3D::Container::end(), findPath(), GameMap::getField(), getFieldAccess(), Vehicle::height, markTemps, tempsMarked, veh, visited, GameMap::xsize, and GameMap::ysize.

void AStar3D::findPath Path path,
const vector< MapCoordinate3D > &  dest
 

searches for a path from the units current position to one of the dest fields and stores it in path

Definition at line 901 of file astar2.cpp.

References findPath(), Vehicle::getPosition3D(), and veh.

void AStar3D::findPath Path path,
const MapCoordinate3D dest
 

searches for a path from the unit's current position to dest and stores it in path

Definition at line 894 of file astar2.cpp.

References findPath(), Vehicle::getPosition3D(), and veh.

void AStar3D::findPath const MapCoordinate3D A,
const vector< MapCoordinate3D > &  B,
Path path
 

searches for a path from A to B and stores it in path

Definition at line 616 of file astar2.cpp.

References _path, actmap, AStar3D::Container::add(), AStar3D::OperationLimiter::allowDocking(), AStar3D::OperationLimiter::allowHeightChange(), AStar3D::OperationLimiter::allowLeavingContainer(), AStar3D::OperationLimiter::allowMovement(), tfield::bdt, tfield::building, Vehicle::canMove(), AStar3D::Node::canStop, cbbuildingentry, cgp_movefrominvalidfields, Vehicletype::HeightChangeMethod::dist, dist(), AStar3D::Container::empty(), AStar3D::Node::enterHeight, fatalError(), fieldAccessible(), fieldVisited(), MapCoordinate3D::getBitmappedHeight(), tfield::getContainer(), getDirectionOrder(), GameMap::getField(), AStar3D::Container::getFirst(), GameMap::getgameparameter(), getMoveCost(), getNeighbouringFieldCoordinate(), getnextfield(), MapCoordinate3D::getNumericalHeight(), getPosDir(), getPosHHop(), getTerrainBitType(), AStar3D::Node::gval, AStar3D::Node::h, AStar3D::Node::hasAttacked, Vehicletype::HeightChangeMethod::heightDelta, AStar3D::Node::hval, longestPath, MAXIMUM_PATH_LENGTH, maxmalq, N, nodeVisited(), ContainerBaseType::OnlyMoveToAndFromTransports, operationLimiter, MapCoordinate3D::setnum(), veh, tfield::vehicle, visited, MapCoordinate::x, GameMap::xsize, MapCoordinate::y, and GameMap::ysize.

Referenced by ChangeVehicleHeight::execute(), VehicleMovement::execute(), BaseVehicleMovement::execute(), findAllAccessibleFields(), findPath(), and BaseVehicleMovement::PathFinder::getMovementFields().

bool AStar3D::get_first Container v,
Node n
[protected]
 

int AStar3D::getDistance  ) 
 

returns the distance of the last found path, or -1 on any error

int & AStar3D::getFieldAccess const MapCoordinate mc  ) 
 

Definition at line 941 of file astar2.cpp.

References actmap, fieldAccess, MapCoordinate::x, GameMap::xsize, and MapCoordinate::y.

int & AStar3D::getFieldAccess int  x,
int  y
 

Definition at line 936 of file astar2.cpp.

References actmap, fieldAccess, and GameMap::xsize.

Referenced by findAllAccessibleFields().

AStar3D::DistanceType AStar3D::getMoveCost const MapCoordinate3D start,
const MapCoordinate3D dest,
const Vehicle vehicle,
bool &  canStop,
bool &  hasAttacked
[protected, virtual]
 

Reimplemented in StratAStar3D, and HiddenAStar3D.

Definition at line 524 of file astar2.cpp.

References actmap, calcMoveMalus(), fieldAccessible(), MapCoordinate3D::getBitmappedHeight(), GameMap::getField(), longestPath, Vehicletype::movement, Vehicle::typ, veh, vehicleSpeedFactor, and wind.

Referenced by findPath(), HiddenAStar3D::getMoveCost(), and StratAStar3D::getMoveCost().

HexDirection& AStar3D::getPosDir const MapCoordinate3D pos  )  [inline, protected]
 

Definition at line 152 of file astar2.h.

References actmap, MapCoordinate3D::getNumericalHeight(), posDirs, MapCoordinate::x, GameMap::xsize, and MapCoordinate::y.

Referenced by findPath(), and nodeVisited().

int& AStar3D::getPosHHop const MapCoordinate3D pos  )  [inline, protected]
 

Definition at line 153 of file astar2.h.

References actmap, MapCoordinate3D::getNumericalHeight(), posHHops, MapCoordinate::x, GameMap::xsize, and MapCoordinate::y.

Referenced by findPath(), and nodeVisited().

int AStar3D::getTravelTime  ) 
 

returns the number of turns that the unit will need to travel along the last found path

void AStar3D::nodeVisited const Node n,
HexDirection  direc,
Container open,
int  prevHeight = -10,
int  heightChangeDist = 0
[protected]
 

Definition at line 567 of file astar2.cpp.

References AStar3D::Container::add(), DirNone, getPosDir(), getPosHHop(), longestPath, MAXIMUM_PATH_LENGTH, ReverseDirection(), and AStar3D::Container::update().

Referenced by findPath().

void AStar3D::registerOperationLimiter OperationLimiter ol  )  [inline]
 

the search can be restricted to certain operations

Definition at line 195 of file astar2.h.

References operationLimiter.


Member Data Documentation

Path* AStar3D::_path [protected]
 

Definition at line 139 of file astar2.h.

Referenced by AStar3D(), and findPath().

GameMap* AStar3D::actmap [protected]
 

Definition at line 141 of file astar2.h.

Referenced by AStar3D(), findAllAccessibleFields(), findPath(), getFieldAccess(), getMoveCost(), HiddenAStar3D::getMoveCost(), BaseVehicleMovement::PathFinder::getMovementFields(), getPosDir(), and getPosHHop().

int* AStar3D::fieldAccess [protected]
 

Definition at line 150 of file astar2.h.

Referenced by AStar3D(), getFieldAccess(), and ~AStar3D().

const AStar3D::DistanceType AStar3D::longestPath = 1e9 [static]
 

Definition at line 614 of file astar2.cpp.

Referenced by AStar3D(), dist(), findPath(), getMoveCost(), nodeVisited(), AStar3D::Node::operator<(), and operator>().

bool AStar3D::markTemps [protected]
 

Definition at line 143 of file astar2.h.

Referenced by AStar3D(), and findAllAccessibleFields().

int AStar3D::MAXIMUM_PATH_LENGTH [protected]
 

Definition at line 137 of file astar2.h.

Referenced by AStar3D(), findPath(), and nodeVisited().

OperationLimiter* AStar3D::operationLimiter [protected]
 

Definition at line 136 of file astar2.h.

Referenced by findPath(), and registerOperationLimiter().

HexDirection* AStar3D::posDirs [protected]
 

Definition at line 148 of file astar2.h.

Referenced by AStar3D(), getPosDir(), and ~AStar3D().

int* AStar3D::posHHops [protected]
 

Definition at line 149 of file astar2.h.

Referenced by AStar3D(), getPosHHop(), and ~AStar3D().

GameMap* AStar3D::tempsMarked [protected]
 

Definition at line 138 of file astar2.h.

Referenced by AStar3D(), findAllAccessibleFields(), and ~AStar3D().

Vehicle* AStar3D::veh [protected]
 

Definition at line 140 of file astar2.h.

Referenced by AStar3D(), findAllAccessibleFields(), findPath(), getMoveCost(), and BaseVehicleMovement::PathFinder::getMovementFields().

float AStar3D::vehicleSpeedFactor[8] [protected]
 

Definition at line 142 of file astar2.h.

Referenced by AStar3D(), and getMoveCost().

Container AStar3D::visited
 

the reachable fields

Definition at line 180 of file astar2.h.

Referenced by fieldVisited(), findAllAccessibleFields(), findPath(), and BaseVehicleMovement::PathFinder::getMovementFields().

WindMovement* AStar3D::wind [protected]
 

Definition at line 144 of file astar2.h.

Referenced by AStar3D(), dist(), getMoveCost(), and ~AStar3D().


The documentation for this class was generated from the following files:
Generated on Tue Jun 24 02:16:14 2008 for Advanced Strategic Command by  doxygen 1.4.2