
0AD Pathfinder Design [pdf] - evolve2k
https://github.com/0ad/0ad/blob/master/docs/pathfinder.pdf
======
laarc
As for an effective A* algorithm, bidirectional A* turns out to be both rugged
and efficient.

Basically, grab some graph paper. Put your left index finger on start. Right
index finger on end.

Move your fingers towards each other, avoiding obstacles as you go.

Wherever they happen to meet, the path formed by the trail of both your
fingers combined is the path to use.

That's the general idea. It's important to trace from both simultaneously,
otherwise you run into some degeneracies.

~~~
karussell
Just as a side note: bidir A* is not that straight forward as you need a
special finish condition to keep the algorithm optimal. (For games you
probably don't need this but for tests and real world road routing it is
important IMO)

------
keerthiko
> The long-range pathfinder can be simpler and more efficient if it has a grid
> representation of the map.

> (Since our maps are large and open [] and must support dynamic generation []
> and dynamic modification [], a grid is likely better than a nav mesh)

Can someone explain why this is the case? I feel like using a grid will result
in them generating the equivalent of a fresh nav mesh every time they want to
pathfind, as opposed to using a cached navmesh (generated when terrain is
loaded) which they can modify in place every time a dynamic event occurs
(building placed).

------
nomercy400
I like how this article gives some insights on how to go from A* to a
practical AI pathfinder. You always hear about 'use A* for pathfinding', only
to get yourself stuck in the actual wiring the A* algorithm into your
application.

~~~
seivan
I really recommend [http://www.amazon.com/Programming-Example-Wordware-
Developer...](http://www.amazon.com/Programming-Example-Wordware-Developers-
Library/dp/1556220782). I don't recall if it contained a segment of Behaviour
Trees at this moment, but read up on BTs and replace any section containing
FSM with that.

~~~
douche
Really an excellent book. I've been through a bunch, but I think that is still
the best general-purpose, entry-level game AI book on the market.

------
evolve2k
Does anyone know if this is basically the same sort of Algorithm used in say
the age of Age of Empires and Age of Mythology games?

~~~
JoshuaJB
Yep! It's based pretty heavily off how AoE and later games do it.

~~~
pbhjpbhj
Are those games open source or has it been possible to reverse engineer the
algorithm, or ...?

~~~
JoshuaJB
Engineers have presented some of how their algorithms work at conferences and
in other places.

~~~
evolve2k
Know of any video links to talks that you could share?

------
socceroos
As an aside, 0AD is quite impressive as a 'golden-days' RTS. I've had lots of
fun in it with my friends.

------
lunchTime42
Really nice docu. Regarding A* sorry, but QTFPS is superior.

[https://github.com/spring/spring/tree/9bec15418279f1ecd87a55...](https://github.com/spring/spring/tree/9bec15418279f1ecd87a5586d5f4ae44f8fee0ad/rts/Sim/Path/QTPFS)

Always fascinating is the actual Edge-Case Handling (UnitsStuck). Setting
Collission off and sending Units back shortest path can yield unexpected
results there.

~~~
evolve2k
For those of us who know little about all of this can you explain in simple
terms the different approaches and why you think one might be better.

~~~
lunchTime42
Well you use a Quadtree for path-finding. That gives you some advantages-
regarding a) Resolution, (Long stretches of open terrain can be handled in one
entry) b) Memory needed (Quadtrees are always just resolved as deep as needed
and can be placed cache friendly in mem) c) Ask kloot.
[https://www.youtube.com/user/Kleaut](https://www.youtube.com/user/Kleaut)

Regards

