DM810 Computer Game Programming II: AI Lecture 6
Pathfinding
Marco Chiarandini
Department of Mathematics & Computer Science University of Southern Denmark
Pathfinding Marco Chiarandini Department of Mathematics & - - PowerPoint PPT Presentation
DM810 Computer Game Programming II: AI Lecture 6 Pathfinding Marco Chiarandini Department of Mathematics & Computer Science University of Southern Denmark Pathfinding Heuristics Outline World Rerpresentations 1. Pathfinding 2.
Department of Mathematics & Computer Science University of Southern Denmark
Pathfinding Heuristics World Rerpresentations
2
Pathfinding Heuristics World Rerpresentations
3
Pathfinding Heuristics World Rerpresentations
4
Pathfinding Heuristics World Rerpresentations
5
Pathfinding Heuristics World Rerpresentations
Put start on OPEN While(OPEN is not empty) Pop best node n from OPEN if (n == goal) return path(n, goal) for each child of n: # generate children put/update value on OPEN/CLOSED return NO PATH
If child on OPEN, and new cost is less Update cost and parent pointer If child on CLOSED, and new cost is less Update cost and parent pointer, move node to OPEN Otherwise Add to OPEN list
6
Pathfinding Heuristics World Rerpresentations
7
Pathfinding Heuristics World Rerpresentations
8
Pathfinding Heuristics World Rerpresentations
9
Pathfinding Heuristics World Rerpresentations
1
10
Pathfinding Heuristics World Rerpresentations
11
Pathfinding Heuristics World Rerpresentations
O Z A T L M D C R F P G B U H E V I N 380 400 420 S 12
Pathfinding Heuristics World Rerpresentations
13
Pathfinding Heuristics World Rerpresentations
14
Pathfinding Heuristics World Rerpresentations
15
Pathfinding Heuristics World Rerpresentations
16
Pathfinding Heuristics World Rerpresentations
17
Pathfinding Heuristics World Rerpresentations
pathfindAStar(graph, start, end, new Heuristic(end))
18
Pathfinding Heuristics World Rerpresentations
19
Pathfinding Heuristics World Rerpresentations
20
Pathfinding Heuristics World Rerpresentations
21
Pathfinding Heuristics World Rerpresentations
22
Pathfinding Heuristics World Rerpresentations
23
Pathfinding Heuristics World Rerpresentations
24
Pathfinding Heuristics World Rerpresentations
25
Pathfinding Heuristics World Rerpresentations
26
Pathfinding Heuristics World Rerpresentations
28
Pathfinding Heuristics World Rerpresentations
29
Pathfinding Heuristics World Rerpresentations
tileX = floor(x / tileSize) tileZ = floor(z / tileSize)
30
Pathfinding Heuristics World Rerpresentations
31
Pathfinding Heuristics World Rerpresentations
32
Pathfinding Heuristics World Rerpresentations
33
Pathfinding Heuristics World Rerpresentations
34
Pathfinding Heuristics World Rerpresentations
35
Pathfinding Heuristics World Rerpresentations
36
Pathfinding Heuristics World Rerpresentations
def smoothPath(inputPath): if len(inputPath) == 2: return inputPath
# We start at 2, because we assume two adjacent # nodes will pass the ray cast inputIndex = 2 while inputIndex < len(inputPath)-1: if not rayClear(outputPath[len(outputPath)-1], inputPath[inputIndex]):
inputIndex ++
return outputPath
37
Pathfinding Heuristics World Rerpresentations
38
Pathfinding Heuristics World Rerpresentations
39