Upload
aria-mayne
View
224
Download
4
Embed Size (px)
Citation preview
A* Pathfinding
Basis A* Algorithmusadd the starting node to the open listwhile the open list is not empty{
current node=node from open list with the lowest costif current node = goal node then
path completeelse
move current node to the closed listexamine each node adjacent to the current nodefor each adjacent nodeif it isn‘t on the open list and isn‘t on the closed list and isn‘t an obstacle then move it to open list and calculate cost
}
• Open List: valide Nodes, die noch geprüft werden müssen
(Invalide Nodes sind Nodes, die Hindernisse beinhalten)
• Closed List: Nodes, die schon geprüft worden sind
• Parent Node: Jedes Node hat ein Parent-Node, und zwar dasjenige von dem der Spielcharakter kommt. Pointer zeigt immer zum Parent Node
Spiel
E
A
Open List
Closed List
Hindernis
Offenes Terrain
Sumpfgelände
Graslandschaft
Basis A* Algorithmusadd the starting node to the open listwhile the open list is not empty{
current node=node from open list with the lowest costif current node = goal node then
path completeelse
move current node to the closed listexamine each node adjacent to the current nodefor each adjacent nodeif it isn‘t on the open list and isn‘t on the closed list and isn‘t an obstacle then move it to open list and calculate cost
}
add the starting node to the open list
E
A
Open List
Closed List
Hindernis
Offenes Terrain
Sumpfgelände
Graslandschaft
Basis A* Algorithmusadd the starting node to the open listwhile the open list is not empty{
current node=node from open list with the lowest costif current node = goal node then
path completeelse
move current node to the closed listexamine each node adjacent to the current nodefor each adjacent nodeif it isn‘t on the open list and isn‘t on the closed list and isn‘t an obstacle then move it to open list and calculate cost
}
CostCost = (Cost from Start + Terrain Cost) + Heuristic
Cost from Start: Kosten von Startpunkt zum aktuellen Node (über wie viele Pointer kommt man vom aktuellen Node zum Startnode)
Terrain Cost: Kosten des Terrains (zum Beispiel, wie viele Sekunden braucht Spielcharakter um Terrain zu durchqueren)
Unser Beispiel: Offenes Terrain: 1
Graslandschaft: 3
Sumpfgelände: 5
Heuristic: Kosten vom Endpunkt zum aktuellen Node
Schätzungswert, da der Weg noch nicht determiniert ist.
Man nimmt die Anzahl der Schritte, die zum Endpunkt führen, jedoch ohne Berücksichtung von Terrain oder Hindernis.
current node=node from open list with the lowest cost
E
T:3,S:1,
H:3,C:7
T:1,S:1,
H:3,C:5
T:3,S:1
H:3,C:7
T:1,S:1
H:4,C:6 A
T:1,S:1
H:4,C:6
T:1,S:1
H:5,
T:1,S:1,
H:5,C:7
T:1,S:1,H:5,C:7
Open ListT=Terraincost
S=Cost from Start
H=Heuristic
C=Cost
Closed List
Hindernis (wird ignoriert)
Offenes Terrain (1)
Sumpfgelände (5)
Graslandschaft (3)
Basis A* Algorithmusadd the starting node to the open listwhile the open list is not empty{
current node=node from open list with the lowest costif current node = goal node then
path completeelse
move current node to the closed listexamine each node adjacent to the current nodefor each adjacent nodeif it isn‘t on the open list and isn‘t on the closed list and isn‘t an obstacle then move it to open list and calculate cost
}
current node=node from open list with the lowest cost
E
T:3,S:1,
H:3,C:7
T:1,S:1,
H:3,C:5
T:3,S:1
H:3,C:7
T:1,S:1
H:4,C:6 A
T:1,S:1
H:4,C:6
T:1,S:1
H:5,C:7
T:1,S:1,
H:5,C:7
T:1,S:1,H:5,C:7
Open ListT=Terraincost
S=Cost from Start
H=Heuristic
C=Cost
Closed List
Hindernis (wird ignoriert)
Offenes Terrain (1)
Sumpfgelände (5)
Graslandschaft (3)
current node=node from open list with the lowest cost
E
T:3,S:2
H:4,C:9
T:3,S:1,
H:3,C:7
T:1,S:1,
H:3,C:5
T:3,S:1
H:3,C:7
T:1,S:2,
H:3;C:6
T:1,S:2
H:4,C:7
T:1,S:1
H:4,C:6 A
T:1,S:1
H:4,C:6
T:1,S:2,
H:4,C:7
T:1,S:2
H:5;C:8 T:1,S:1
H:5,C:7
T:1,S:1,
H:5,C:7
T:1,S:1,H:5,C:7
T:1,S:2
H:5,C:8
Open ListT=Terraincost
S=Cost from Start
H=Heuristic
C=Cost
Closed List
Hindernis (wird ignoriert)
Offenes Terrain (1)
Sumpfgelände (5)
Graslandschaft (3)
current node=node from open list with the lowest cost(worst case, alle 7 Nodes werden überprüft)
E
T:3,S:2
H:4,C:9
T:3,S:1,
H:3,C:7
T:1,S:1,
H:3,C:5
T:3,S:1
H:3,C:7
T:1,S:2,
H:3;C:6
T:1,S:2
H:4,C:7
T:1,S:1
H:4,C:6 A
T:1,S:1
H:4,C:6
T:1,S:2,
H:4,C:7
T:1,S:2
H:5;C:8 T:1,S:1
H:5,C:7
T:1,S:1,
H:5,C:7
T:1,S:1,H:5,C:7
T:1,S:2
H:5,C:8
Open ListT=Terraincost
S=Cost from Start
H=Heuristic
C=Cost
Closed List
Hindernis (wird ignoriert)
Offenes Terrain (1)
Sumpfgelände (5)
Graslandschaft (3)
current node=node from open list with the lowest cost(worst case, alle Nodes mit lowest cost werden überprüft)
E
T:5,S:3
H:4,
C:12
T:1,S:3
H:5,C:9
T:3,S:2
H:4,C:9
T:3,S:1,
H:3,C:7
T:1,S:1,
H:3,C:5
T:3,S:1
H:3,C:7
T:1,S:2,
H:3;C:6
T:5,S:3
H:5,
C:13
T:1,S:2
H:4,C:7
T:1,S:1
H:4,C:6 A
T:1,S:1
H:4,C:6
T:1,S:2,
H:4,C:7
T:3,S3
H:5,
C:11
T:1,S:2
H:5;C:8
T:1,S:1
H:5,C:7
T:1,S:1,
H:5,C:7
T:1,S:1,H:5,C:7
T:1,S:2
H:5,C:8
T:3,S:2
H:6,
C:6
T:3,S:2
H:6,
C:11
T:3,S:2
H:6,
C:11
T:5,S:2
H:6;
C:13
Open ListT=Terraincost
S=Cost from Start
H=Heuristic
C=Cost
Closed List
Hindernis (wird ignoriert)
Offenes Terrain (1)
Sumpfgelände (5)
Graslandschaft (3)
current node=node from open list with the lowest cost(hier kommt nur 1 Node auf Open List,2 auf Closed list)
E
T:5,S:3
H:4,
C:12
T:1,S:3
H:5,C:9
T:3,S:2
H:4,C:9
T:3,S:1,
H:3,C:7
T:1,S:1,
H:3,C:5
T:3,S:1
H:3,C:7
T:1,S:2,
H:3;C:6
T:5,S:3
H:5,
C:13
T:1,S:2
H:4,C:7
T:1,S:1
H:4,C:6 A
T:1,S:1
H:4,C:6
T:1,S:2,
H:4,C:7
T:3,S3
H:5,
C:11
T:1,S:2
H:5;C:8
T:1,S:1
H:5,C:7
T:1,S:1,
H:5,C:7
T:1,S:1,H:5,C:7
T:1,S:2
H:5,C:8
T:3,S:2
H:6,
C:6
T:3,S:2
H:6,
C:11
T:3,S:2
H:6,
C:11
T:5,S:2
H:6;
C:13
T:3,S:3
H:6
C:12
Open ListT=Terraincost
S=Cost from Start
H=Heuristic
C=Cost
Closed List
Hindernis (wird ignoriert)
Offenes Terrain (1)
Sumpfgelände (5)
Graslandschaft (3)
current node=node from open list with the lowest cost(worst case: alle Nodes mit lowest cost werden überprüft)
E
T:1,S:4
H:6,
C:11
T:1,S:3,
H:5,C:9
T:5,S:3
H:4,
C:12
T:5,S:4
H:6
C:15
T:1,S:3
H:5,C:9
T:3,S:2
H:4,C:9
T:3,S:1,
H:3,C:7
T:1,S:1,
H:3,C:5
T:3,S:1
H:3,C:7
T:1,S:2,
H:3;C:6
T:1,S:4
H:6
C:11
T:5,S:3
H:5,
C:13
T:1,S:2
H:4,C:7
T:1,S:1
H:4,C:6 A
T:1,S:1
H:4,C:6
T:1,S:2,
H:4,C:7
T:3,S3
H:5,
C:11
T:1,S:2
H:5;C:8
T:1,S:1
H:5,C:7
T:1,S:1,
H:5,C:7
T:1,S:1,H:5,C:7
T:1,S:2
H:5,C:8
T:3,S:2
H:6,
C:6
T:3,S:2
H:6,
C:11
T:3,S:2
H:6,
C:11
T:5,S:2
H:6;
C:13
T:3,S:3
H:6
C:12
Open ListT=Terraincost
S=Cost from Start
H=Heuristic
C=Cost
Closed List
Hindernis (wird ignoriert)
Offenes Terrain (1)
Sumpfgelände (5)
Graslandschaft (3)
if current node= goal node then path complete
T:3,S:6
H:4
C:13
T:1,S:6,
H:3,
C:10
T:3,S:7
H:2,
C:12
T:1,S:8
H:1
C:10
T:1,S:9
H:1
C:11
T:1,S:5
H:5
C:11
T:1,S:5
H:4
C:10
T:5,S:5
H:3
C:13
T:1,S:7
H:2
C:10
T:1,S:8
H:1
C:10E C:10
T:1,S:4
H:6
C:11
T:1,S:4
H:5
C:10
T:1,S:4
H:4
C:9
T:3,S:5
H:3
C:11
T:1,S:8
H:2,
C:11
T:1,S:8
H1
C:10
T:1,S:9
H:1
C:11
T:1,S:4
H:6
C:11
T:1,S:3
H:5
C:9
T:5,S:2
H:4,
C:11
T:5,S:4
H:6
C:15
T:1,S:3
H:5,C:9
T:3,S:2
H:4,C:9
T:3,S:1,
H:3,C:7
T:1,S:1,
H:3,C:5
T:3,S:1
H:3,C:7
T:1,S:2,
H:3;C:6
T:1,S:4
H:6
C:11
T:5,S:3
H:5,
C:13
T:1,S:2
H:4,C:7
T:1,S:1
H:4,C:6 A
T:1,S:1
H:4,C:6
T:1,S:2,
H:4,C:7
T:3,S3
H:5,
C:11
T:1,S:2
H:5;C:8
T:1,S:1
H:5,C:7
T:1,S:1,
H:5,C:7
T:1,S:1,H:5,C:7
T:1,S:2
H:5,C:8
T:3,S:2
H:6,
C:11
T:3,S:2
H:6,
C:11
T:3,S:2
H:6,
C:11
T:5,S:2
H:6;
C:13
T:3,S:3
H:6,
C:12
Open ListT=Terraincost
S=Cost from Start
H=Heuristic
C=Cost
Closed List
Hindernis (wird ignoriert)
Offenes Terrain (1)
Sumpfgelände (5)
Graslandschaft (3)
Schnellster Pfad
E
A
Open List
Closed List
Hindernis
Offenes Terrain
Sumpfgelände
Graslandschaft