_________ __ __
/ _____// |_____________ _/ |______ ____ __ __ ______
\_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
/ \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \
/_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
\/ \/ \//_____/ \/
______________________ ______________________
T H E W A R B E G I N S
Stratagus - A free fantasy real time strategy game engine
Go to the documentation of this file.
30 #ifndef __PATH_FINDER_H__
31 #define __PATH_FINDER_H__
35 #if defined(DEBUG_ASTAR)
36 #define AstarDebugPrint(x) DebugPrint(x)
38 #define AstarDebugPrint(x)
88 void Load(lua_State *l);
97 bool isRecalculatePathNeeded;
107 void Load(lua_State *l);
139 void SetSize(
unsigned int width,
unsigned int height);
146 template <
typename T>
147 bool Run(T &context);
160 PosNode(
const Vec2i &pos,
const Vec2i &from) : pos(pos), from(from) {}
166 std::vector<dataType> m_values;
167 std::queue<PosNode> m_queue;
168 unsigned int m_extented_width;
169 unsigned int m_height;
172 template <
typename T>
175 for (; m_queue.empty() ==
false; m_queue.pop()) {
176 const PosNode &posNode = m_queue.front();
178 switch (context.Visit(*
this, posNode.pos, posNode.from)) {
227 const int minrange,
const int range);
230 int minrange,
int maxrange,
bool from_outside_container);
252 #endif // !__PATH_FINDER_H__
int UnitReachable(const CUnit &src, const CUnit &dst, int range, bool from_outside_container)
Return path length to unit 'dst'.
Definition: pathfinder.cpp:259
Definition: pathfinder.h:115
int GetAStarFixedUnitCrossingCost()
Definition: astar.cpp:1102
bool IsVisited(const Vec2i &pos) const
Definition: pathfinder.cpp:125
void Load(lua_State *l)
Definition: script_unit.cpp:239
void SetSize(unsigned int width, unsigned int height)
Definition: pathfinder.cpp:64
_move_return_
Definition: pathfinder.h:59
@ MAX_PATH_LENGTH
Definition: pathfinder.h:103
int AStarMaxSearchIterations
Maximum number of iterations of A* before giving up.
Definition: astar.cpp:99
int CalcPathLengthToUnit(const CUnit &src, const CUnit &dst, const int minrange, const int range)
Return path length to unit 'dst' or error code.
Definition: pathfinder.cpp:284
int AStarMovingUnitCrossingCost
cost associated to move on a tile occupied by a moving unit
Definition: astar.cpp:98
char Length
Flag fast move (one step)
Definition: pathfinder.h:111
void PathfinderCclRegister()
Definition: script_pathfinder.cpp:116
PathFinderInput input
Definition: pathfinder.h:118
int AStarFixedUnitCrossingCost
cost associated to move on a tile occupied by a fixed unit
Definition: astar.cpp:97
VisitResult
Definition: pathfinder.h:127
void SetAStarFixedEnemyUnitsUnpassable(const bool value)
Definition: astar.cpp:1133
char Path[MAX_PATH_LENGTH]
stored path length
Definition: pathfinder.h:112
bool IsInvalid(const Vec2i &pos) const
Definition: pathfinder.cpp:135
void SetAStarFixedUnitCrossingCost(int cost)
Definition: astar.cpp:1096
Definition: pathfinder.h:100
bool AStarKnowUnseenTerrain
Whether to have knowledge of terrain that we haven't visited yet.
Definition: astar.cpp:100
@ VisitResult_DeadEnd
Definition: pathfinder.h:129
int AStarUnknownTerrainCost
Cost of using a square we haven't seen before.
Definition: astar.cpp:101
void PushNeighboor(const Vec2i &pos)
Definition: pathfinder.cpp:94
@ PF_WAIT
Reached goal stop.
Definition: pathfinder.h:63
int NextPathElement(CUnit &unit, short int *xdp, short int *ydp)
Returns the next element of the path.
Definition: pathfinder.cpp:434
dataType Get(const Vec2i &pos) const
Definition: pathfinder.cpp:140
char Fast
how much Cycles we move.
Definition: pathfinder.h:110
int GetAStarMovingUnitCrossingCost()
Definition: astar.cpp:1114
bool Run(T &context)
Definition: pathfinder.h:173
bool IsReached(const Vec2i &pos) const
Definition: pathfinder.cpp:130
const int XY2Heading[3][3]
Definition: astar.cpp:85
const int Heading2X[9]
Definition: astar.cpp:82
bool GetAStarFixedEnemyUnitsUnpassable()
Definition: astar.cpp:1138
void Init()
Definition: pathfinder.cpp:71
Definition: pathfinder.h:134
w
Definition: update-images.py:53
void FreePathfinder()
Free the pathfinder.
Definition: pathfinder.cpp:165
int GetAStarUnknownTerrainCost()
Definition: astar.cpp:1128
PathFinderOutput()
max length of precalculated path
Definition: pathfinder.cpp:380
void Save(CFile &file) const
Definition: unit_save.cpp:98
void SetAStarUnknownTerrainCost(int cost)
Definition: astar.cpp:1120
@ VisitResult_Finished
Definition: pathfinder.h:128
void InitPathfinder()
Init the pathfinder.
Definition: pathfinder.cpp:157
unsigned short int Cycles
Definition: pathfinder.h:109
@ PF_REACHED
Unreachable stop.
Definition: pathfinder.h:62
@ PF_UNREACHABLE
This Pathfinder failed, try another.
Definition: pathfinder.h:61
int PlaceReachable(const CUnit &src, const Vec2i &pos, int w, int h, int minrange, int maxrange, bool from_outside_container)
Can the unit 'src' reach the place x,y.
Definition: pathfinder.cpp:186
#define Assert(cond)
Definition: stratagus.h:142
@ PF_FAILED
Definition: pathfinder.h:60
@ VisitResult_Cancel
Definition: pathfinder.h:131
h
Definition: update-images.py:53
const int Heading2Y[9]
Definition: astar.cpp:83
void PushPos(const Vec2i &pos)
Definition: pathfinder.cpp:86
PathFinderOutput output
Definition: pathfinder.h:119
@ PF_MOVE
Wait, no time or blocked.
Definition: pathfinder.h:64
The big unit structure.
Definition: unit.h:135
void PushUnitPosAndNeighboor(const CUnit &unit)
Definition: pathfinder.cpp:110
@ VisitResult_Ok
Definition: pathfinder.h:130
short int dataType
Definition: pathfinder.h:137
void SetAStarMovingUnitCrossingCost(int cost)
Definition: astar.cpp:1108
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.