<s>
Pathfinding	B-Algorithm
or	O
pathing	B-Algorithm
is	O
the	O
plotting	O
,	O
by	O
a	O
computer	O
application	O
,	O
of	O
the	O
shortest	O
route	O
between	O
two	O
points	O
.	O
</s>
<s>
It	O
is	O
a	O
more	O
practical	O
variant	O
on	O
solving	B-Algorithm
mazes	I-Algorithm
.	O
</s>
<s>
This	O
field	O
of	O
research	O
is	O
based	O
heavily	O
on	O
Dijkstra	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
for	O
finding	O
the	O
shortest	O
path	O
on	O
a	O
weighted	O
graph	B-Application
.	O
</s>
<s>
Pathfinding	B-Algorithm
is	O
closely	O
related	O
to	O
the	O
shortest	O
path	O
problem	O
,	O
within	O
graph	B-Application
theory	O
,	O
which	O
examines	O
how	O
to	O
identify	O
the	O
path	O
that	O
best	O
meets	O
some	O
criteria	O
(	O
shortest	O
,	O
cheapest	O
,	O
fastest	O
,	O
etc	O
)	O
between	O
two	O
points	O
in	O
a	O
large	O
network	O
.	O
</s>
<s>
At	O
its	O
core	O
,	O
a	O
pathfinding	B-Algorithm
method	O
searches	O
a	O
graph	B-Application
by	O
starting	O
at	O
one	O
vertex	O
and	O
exploring	O
adjacent	O
nodes	O
until	O
the	O
destination	O
node	B-Data_Structure
is	O
reached	O
,	O
generally	O
with	O
the	O
intent	O
of	O
finding	O
the	O
cheapest	O
route	O
.	O
</s>
<s>
Although	O
graph	B-Application
searching	O
methods	O
such	O
as	O
a	O
breadth-first	B-Algorithm
search	I-Algorithm
would	O
find	O
a	O
route	O
if	O
given	O
enough	O
time	O
,	O
other	O
methods	O
,	O
which	O
"	O
explore	O
"	O
the	O
graph	B-Application
,	O
would	O
tend	O
to	O
reach	O
the	O
destination	O
sooner	O
.	O
</s>
<s>
Two	O
primary	O
problems	O
of	O
pathfinding	B-Algorithm
are	O
(	O
1	O
)	O
to	O
find	O
a	O
path	O
between	O
two	O
nodes	O
in	O
a	O
graph	B-Application
;	O
and	O
(	O
2	O
)	O
the	O
shortest	O
path	O
problem	O
—	O
to	O
find	O
the	O
optimal	O
shortest	O
path	O
.	O
</s>
<s>
Basic	O
algorithms	O
such	O
as	O
breadth-first	B-Algorithm
and	O
depth-first	B-Algorithm
search	I-Algorithm
address	O
the	O
first	O
problem	O
by	O
exhausting	B-Algorithm
all	O
possibilities	O
;	O
starting	O
from	O
the	O
given	O
node	B-Data_Structure
,	O
they	O
iterate	O
over	O
all	O
potential	O
paths	O
until	O
they	O
reach	O
the	O
destination	O
node	B-Data_Structure
.	O
</s>
<s>
The	O
exhaustive	O
approach	O
in	O
this	O
case	O
is	O
known	O
as	O
the	O
Bellman	B-Algorithm
–	I-Algorithm
Ford	I-Algorithm
algorithm	I-Algorithm
,	O
which	O
yields	O
a	O
time	O
complexity	O
of	O
,	O
or	O
quadratic	O
time	O
.	O
</s>
<s>
Algorithms	O
such	O
as	O
A*	B-Protocol
and	O
Dijkstra	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
strategically	O
eliminate	O
paths	O
,	O
either	O
through	O
heuristics	B-Algorithm
or	O
through	O
dynamic	B-Algorithm
programming	I-Algorithm
.	O
</s>
<s>
The	O
above	O
algorithms	O
are	O
among	O
the	O
best	O
general	O
algorithms	O
which	O
operate	O
on	O
a	O
graph	B-Application
without	O
preprocessing	O
.	O
</s>
<s>
However	O
,	O
in	O
practical	O
travel-routing	O
systems	O
,	O
even	O
better	O
time	O
complexities	O
can	O
be	O
attained	O
by	O
algorithms	O
which	O
can	O
pre-process	O
the	O
graph	B-Application
to	O
attain	O
better	O
performance	O
.	O
</s>
<s>
One	O
such	O
algorithm	O
is	O
contraction	B-Protocol
hierarchies	I-Protocol
.	O
</s>
<s>
A	O
common	O
example	O
of	O
a	O
graph-based	O
pathfinding	B-Algorithm
algorithm	O
is	O
Dijkstra	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
.	O
</s>
<s>
This	O
algorithm	O
begins	O
with	O
a	O
start	O
node	B-Data_Structure
and	O
an	O
"	O
open	O
set	O
"	O
of	O
candidate	O
nodes	O
.	O
</s>
<s>
At	O
each	O
step	O
,	O
the	O
node	B-Data_Structure
in	O
the	O
open	O
set	O
with	O
the	O
lowest	O
distance	O
from	O
the	O
start	O
is	O
examined	O
.	O
</s>
<s>
The	O
node	B-Data_Structure
is	O
marked	O
"	O
closed	O
"	O
,	O
and	O
all	O
nodes	O
adjacent	O
to	O
it	O
are	O
added	O
to	O
the	O
open	O
set	O
if	O
they	O
have	O
not	O
already	O
been	O
examined	O
.	O
</s>
<s>
Dijkstra	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
fails	O
if	O
there	O
is	O
a	O
negative	O
edge	O
weight	O
.	O
</s>
<s>
In	O
the	O
hypothetical	O
situation	O
where	O
Nodes	O
A	O
,	O
B	O
,	O
and	O
C	O
form	O
a	O
connected	O
undirected	O
graph	B-Application
with	O
edges	O
AB	O
=	O
3	O
,	O
AC	O
=	O
4	O
,	O
and	O
BC	O
=	O
−2	O
,	O
the	O
optimal	O
path	O
from	O
A	O
to	O
C	O
costs	O
1	O
,	O
and	O
the	O
optimal	O
path	O
from	O
A	O
to	O
B	O
costs	O
2	O
.	O
</s>
<s>
Dijkstra	B-Algorithm
's	I-Algorithm
Algorithm	I-Algorithm
starting	O
from	O
A	O
will	O
first	O
examine	O
B	O
,	O
as	O
that	O
is	O
the	O
closest	O
.	O
</s>
<s>
However	O
,	O
since	O
for	O
many	O
practical	O
purposes	O
there	O
will	O
never	O
be	O
a	O
negative	O
edgeweight	O
,	O
Dijkstra	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
is	O
largely	O
suitable	O
for	O
the	O
purpose	O
of	O
pathfinding	B-Algorithm
.	O
</s>
<s>
A*	B-Protocol
is	O
a	O
variant	O
of	O
Dijkstra	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
commonly	O
used	O
in	O
games	O
.	O
</s>
<s>
A*	B-Protocol
assigns	O
a	O
weight	O
to	O
each	O
open	O
node	B-Data_Structure
equal	O
to	O
the	O
weight	O
of	O
the	O
edge	O
to	O
that	O
node	B-Data_Structure
plus	O
the	O
approximate	O
distance	O
between	O
that	O
node	B-Data_Structure
and	O
the	O
finish	O
.	O
</s>
<s>
This	O
approximate	O
distance	O
is	O
found	O
by	O
the	O
heuristic	B-Algorithm
,	O
and	O
represents	O
a	O
minimum	O
possible	O
distance	O
between	O
that	O
node	B-Data_Structure
and	O
the	O
end	O
.	O
</s>
<s>
If	O
there	O
is	O
a	O
path	O
of	O
length	O
x	O
between	O
the	O
start	O
and	O
finish	O
,	O
and	O
the	O
minimum	O
distance	O
between	O
a	O
node	B-Data_Structure
and	O
the	O
finish	O
is	O
greater	O
than	O
x	O
,	O
that	O
node	B-Data_Structure
need	O
not	O
be	O
examined	O
.	O
</s>
<s>
A*	B-Protocol
uses	O
this	O
heuristic	B-Algorithm
to	O
improve	O
on	O
the	O
behavior	O
relative	O
to	O
Dijkstra	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
.	O
</s>
<s>
When	O
the	O
heuristic	B-Algorithm
evaluates	O
to	O
zero	O
,	O
A*	B-Protocol
is	O
equivalent	O
to	O
Dijkstra	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
.	O
</s>
<s>
As	O
the	O
heuristic	B-Algorithm
estimate	O
increases	O
and	O
gets	O
closer	O
to	O
the	O
true	O
distance	O
,	O
A*	B-Protocol
continues	O
to	O
find	O
optimal	O
paths	O
,	O
but	O
runs	O
faster	O
(	O
by	O
virtue	O
of	O
examining	O
fewer	O
nodes	O
)	O
.	O
</s>
<s>
When	O
the	O
value	O
of	O
the	O
heuristic	B-Algorithm
is	O
exactly	O
the	O
true	O
distance	O
,	O
A*	B-Protocol
examines	O
the	O
fewest	O
nodes	O
.	O
</s>
<s>
(	O
However	O
,	O
it	O
is	O
generally	O
impractical	O
to	O
write	O
a	O
heuristic	B-Algorithm
function	I-Algorithm
that	O
always	O
computes	O
the	O
true	O
distance	O
,	O
as	O
the	O
same	O
comparison	O
result	O
can	O
often	O
be	O
reached	O
using	O
simpler	O
calculations	O
–	O
for	O
example	O
,	O
using	O
Chebyshev	O
distance	O
over	O
Euclidean	O
distance	O
in	O
two-dimensional	O
space	O
.	O
)	O
</s>
<s>
As	O
the	O
value	O
of	O
the	O
heuristic	B-Algorithm
increases	O
,	O
A*	B-Protocol
examines	O
fewer	O
nodes	O
but	O
no	O
longer	O
guarantees	O
an	O
optimal	O
path	O
.	O
</s>
<s>
This	O
is	O
claimed	O
to	O
be	O
the	O
simplest	O
and	O
fastest	O
of	O
all	O
pathfinding	B-Algorithm
methods	O
using	O
nodes	O
that	O
branch	O
out	O
from	O
central	O
corridor	O
'	O
A	O
 '	O
to	O
other	O
connected	O
Paths	O
.	O
</s>
<s>
Each	O
path	O
node	B-Data_Structure
should	O
be	O
coded	O
numerically	O
in	O
order	O
for	O
each	O
path	O
(	O
ie	O
B1	O
,	O
B2	O
,	O
B3	O
etc	O
descending	O
or	O
ascending	O
)	O
.	O
</s>
<s>
Open	O
paths	O
must	O
be	O
inserted	O
into	O
2	O
arrays	O
-	O
one	O
for	O
fast	O
check	O
path	O
points	O
(	O
ie	O
AB	O
or	O
BD	O
)	O
and	O
the	O
other	O
to	O
record	O
the	O
actual	O
node	B-Data_Structure
names	O
to	O
output	O
later	O
.	O
</s>
<s>
This	O
is	O
a	O
fairly	O
simple	O
and	O
easy-to-understand	O
pathfinding	B-Algorithm
algorithm	O
for	O
tile-based	O
maps	O
.	O
</s>
<s>
Chris	O
Crawford	O
in	O
1982	O
described	O
how	O
he	O
"	O
expended	O
a	O
great	O
deal	O
of	O
time	O
"	O
trying	O
to	O
solve	O
a	O
problem	O
with	O
pathfinding	B-Algorithm
in	O
Tanktics	B-Application
,	O
in	O
which	O
computer	O
tanks	O
became	O
trapped	O
on	O
land	O
within	O
U-shaped	O
lakes	O
.	O
</s>
<s>
The	O
concept	O
of	O
using	O
abstraction	O
and	O
heuristics	B-Algorithm
is	O
older	O
and	O
was	O
first	O
mentioned	O
under	O
the	O
name	O
ABSTRIPS	O
(	O
Abstraction-Based	O
STRIPS	B-Application
)	O
which	O
was	O
used	O
to	O
efficiently	O
search	O
the	O
state	O
spaces	O
of	O
logic	O
games	O
.	O
</s>
<s>
A	O
similar	O
technique	O
are	O
navigation	B-Algorithm
meshes	I-Algorithm
(	O
navmesh	B-Algorithm
)	O
,	O
which	O
are	O
used	O
for	O
geometrical	O
planning	O
in	O
games	O
and	O
multimodal	O
transportation	O
planning	O
which	O
is	O
utilized	O
in	O
travelling	B-Algorithm
salesman	I-Algorithm
problems	I-Algorithm
with	O
more	O
than	O
one	O
transport	O
vehicle	O
.	O
</s>
<s>
A	O
map	O
is	O
separated	O
into	O
clusters	B-Algorithm
.	O
</s>
<s>
On	O
the	O
high-level	O
layer	O
,	O
the	O
path	O
between	O
the	O
clusters	B-Algorithm
is	O
planned	O
.	O
</s>
<s>
That	O
means	O
,	O
the	O
planning	O
is	O
done	O
in	O
two	O
steps	O
which	O
is	O
a	O
guided	B-Algorithm
local	I-Algorithm
search	I-Algorithm
in	O
the	O
original	O
space	O
.	O
</s>
<s>
Planning	O
a	O
path	O
on	O
a	O
node	B-Data_Structure
base	O
would	O
take	O
very	O
long	O
.	O
</s>
<s>
The	O
number	O
of	O
clusters	B-Algorithm
overall	O
is	O
10x10	O
=	O
100	O
.	O
</s>
<s>
In	O
the	O
newly	O
created	O
graph	B-Application
the	O
amount	O
of	O
nodes	O
is	O
small	O
,	O
it	O
is	O
possible	O
to	O
navigate	O
between	O
the	O
100	O
clusters	B-Algorithm
,	O
but	O
not	O
within	O
the	O
detailed	O
map	O
.	O
</s>
<s>
If	O
a	O
valid	O
path	O
was	O
found	O
in	O
the	O
high-level-graph	O
the	O
next	O
step	O
is	O
to	O
plan	O
the	O
path	O
within	O
each	O
cluster	O
.	O
</s>
<s>
The	O
submap	O
has	O
300x200	O
nodes	O
which	O
can	O
be	O
handled	O
by	O
a	O
normal	O
A*	B-Protocol
pathplanner	I-Protocol
easily	O
.	O
</s>
<s>
Multi-agent	O
pathfinding	B-Algorithm
is	O
to	O
find	O
the	O
paths	O
for	O
multiple	O
agents	O
from	O
their	O
current	O
locations	O
to	O
their	O
target	O
locations	O
without	O
colliding	O
with	O
each	O
other	O
,	O
while	O
at	O
the	O
same	O
time	O
optimizing	O
a	O
cost	O
function	O
,	O
such	O
as	O
the	O
sum	O
of	O
the	O
path	O
lengths	O
of	O
all	O
agents	O
.	O
</s>
<s>
It	O
is	O
a	O
generalization	O
of	O
pathfinding	B-Algorithm
.	O
</s>
<s>
Many	O
multi-agent	O
pathfinding	B-Algorithm
algorithms	O
are	O
generalized	O
from	O
A*	B-Protocol
,	O
or	O
based	O
on	O
reduction	O
to	O
other	O
well	O
studied	O
problems	O
such	O
as	O
integer	O
linear	O
programming	O
.	O
</s>
