Download presentation
Presentation is loading. Please wait.
Published byMaurice Wootton Modified over 9 years ago
1
Administrative Project due Tuesday: –Email your code to Yisheng Tang (yit311@lehigh.edu) no later than 11:59PM EST Monday February 6 (the day BEFORE the competition) –Presentation - A 3-5 slide power point presentation giving the basics of your bot design. What makes your bot different? Why will it win? This must be short (i.e., 5 minutes). Please bring a printout of your presentation A question: how many of you are interested in a career in the game industry?
2
Pathfinding: Region Representation and Looking Beyond A* Sources: My own Joseph Siefers presentation 2008 Jeremy Christman 2008 Wikipedia Michael Moll, 2006 (main source)
3
Uninformed Search: Depth-First Search (DFS) DFS(G,v,d) // G is a graph, v is the start and d is the destination s emptyStack() for each vertex u do visited[u] false; predecessor[u] null. s.push(v) while (not(s.empty()) do v pop(s); if (v = d) then return true; if (not(visited[v])) then visited[v] true; for each unvisited neighbor w of v do s.push(w); predecessor[w] v; return false
4
Uninformed Search: Breadth-First Search (BFS) BFS(G,v,d) s emptyQueue () for each vertex u do visited[u] false; predecessor[u] null. s.push(v) while (not(s.empty()) do v pop(s); if (v = d) then return true; if (not(visited[v])) then visited[v] true; for each unvisited neighbor w of v do s.push(w); predecessor[w] v; return false
5
Uninformed Search Strategies estimated with b= 10, a search rate of 10 5 nodes/sec, and 1 KiB/node 1 mebibyte is 2 20 bytes 1 tebibyte = 2 40 bytes 1 pebibyte = 2 50 bytes 1 exbibyte = 2 60 bytes Credit: AIMA fig 3.11, pg 74
6
Informed Search: A* Algorithm Astar(G,v,d, h, cost) // h is the heuristic function; cost(v,w) is the weight of the (v,w) edge open emptyList(); open.add(v); closed emptyList(); for each vertex u do g(u) ; predecessor(u) null g(v) 0 while (not(open.empty())) do v open.select-element-with-lowest-f-value(g,h); //also removes v from open; f=g+h if (v = d) then return true; closed.add(v); for each neighbor w of v do if (open.contains(w)) then // if the function is not consistent has to check the if (g(v) + cost(v,w) < g(w)) then // closed nodes as well g(w) g(v) + cost(v,w) predecessor[w] v else if (not (closed.contains(w))) then open.add(w) g(w) g(v) + cost(v,w) predecessor[w] v return false
7
A* Search: A Look Back… Breadth-First SearchA*, Manhattan, W=3 75% LESS NODES! But we also show examples where A* performs poorly
8
Memory Capacity Why not exploit this (i.e., use memory to improve pathfinding speed? What is the memory complexity of A*? O(size of the graph)
9
The Increase in Memory Capabilities has Consequences Every year, computers are made with more and more memory This makes for bigger and bigger maps in games Significant CPU time must be spent on pathfinding which could be better utilized elsewhere What can be done?
10
Representation of regions (1): Regular Grids
11
Regular Grids Advantages –Random access lookup (O(1)) to determine what tile lies at any coordinate –Complete Negatives –Usually requires large number of nodes to accurately represent world O(n 2 ) –Path Quality -Agent can only walk in four cardinal directions? That’s no fun. -Let them walk diagonals! Still not much fun
12
Navigation Forms in Regular Grids NWSE Diagonals String-Pulling Catmull-Rom Spline
13
Representation of regions (2): Graphs Regions can be represented as graphs Grids are graphs too –Each cell is a node and edges are adjoining cells –Undirected graph could tell us about topography, etc, whereas array can’t
14
Grids as Graphs
15
Corner Graphs Waypoints around obstacles
16
Corner Graphs How do we generate them? 1.Identify convex corners 2. Check if character can walk in straight line between them 3. Add edge if needed Advantages –Less memory –Faster generation Negatives –Character will “walk on a rail” hugging edges of obstacles instead of walking through open space –And what about different sized characters? –Lookup is O(n 2 ), have to check every node in graph against every other.
17
Corner Graphs
18
Waypoint Graphs Place nodes in middle of rooms instead of at convex corners
19
How do we generate? –Place nodes wherever we want (suits 3-D worlds But requires hand tuning to be effective ) Advantages –Reduce memory footprint from regular grids, reduce wall hugging from corner graphs –Work well in “human” architectures Negatives –Still O(n 2 ) –Path Quality vs. Simplicity –Works poorly in open areas Waypoint Graphs
21
Circle-Based Waypoint Graphs Add radius parameter to indicate open space near waypoint
22
Circle-Based Waypoint Advantages –Only look at overlapping circles, alleviating O(n 2 ) problem from before –Easier to obtain optimal paths –Works well in open terrain Negatives –Doesn’t work as well in maps that aren’t circle friendly
23
Space-Filling Volumes Use rectangles or 3-D Boxes instead of circles
24
Space-Filling Volumes How do we generate? –Seed and Grow (heuristic – best fill is NP-hard) –Make Grid and Merge Very similar to circle-based, but handles angles better
25
Representation of regions (3): Navigation Meshes Enough with the graphs already! Let’s try and cover walkable surfaces with convex polygons Character can travel between adjoining polygons
26
Navigation Meshes
27
How do we generate? –By hand (time consuming) Automated tools to analyze and optimize geometry of world Too complex and not represented as a single polygon mesh, instead may be overlapping, etc
28
Navigation Meshes Advantages –Quickly find optimal paths independent of character shapes and capabilities –Handle indoor and outdoor terrains well Negatives –Can become complex and expensive memory wise –Difficult to generate
29
Problem with N-Sided Meshes
30
Interacting with Pathfinding What about dynamic objects in world? All the representations discussed are static and obviously can’t handle a dynamic world directly These representations need to be able to provide information to the pathfinding algorithm –Waypoint Graphs and Corner Graphs don’t illustrate walkable surfaces –Meshes and Grids do map every walkable surface –Space-filling volumes and Circle Waypoints provide some representation of walk able areas
31
Further Options for Representation Any other ideas of what we can do to make job of path finding algorithm easier? Hierarchical Representations –Choose most suitable scheme for given world, and break up into more manageable pieces
32
Cautionary Tale: Automatic Generation of Navigation Mesh Two clips: –http://www.youtube.com/watch?v=swvLJ_DcXPA&featur e=relatedhttp://www.youtube.com/watch?v=swvLJ_DcXPA&featur e=related –http://www.youtube.com/watch?v=6XbiBDMCJ98http://www.youtube.com/watch?v=6XbiBDMCJ98 –http://www.youtube.com/watch?v=9clDHkbRbUshttp://www.youtube.com/watch?v=9clDHkbRbUs –http://www.youtube.com/watch?v=jUO-qoH7twMhttp://www.youtube.com/watch?v=jUO-qoH7twM It still needs manual adjustment (and/or wait until players find it and complain)
33
Pathfinding Now that we have world represented, how do we plan movement? –A*, Depth-First search, Dijkstra But: dynamic path finding is expensive –Precompiled solutions can eliminate runtime cost, but memory expensive Although memory is less of a problem nowadays Navigation with transition tables works well Navigation Set Hierarchy have shown to be particularly effective
34
Transition Table Main element in pre computed solutions is a lookup table. This is how navigation in many games is implemented. Each entry represents next step to take from one node to some goal node
35
Transition Table
36
Do not need to search nodes at running time, just series of lookups. So it is O(|length of the path|) –Very fast But becomes memory expensive as size of world grows –How expensive? n 2 …Is it possible to shrink transition tables? Yes; using hierarchies
37
Building a Transition Table: The Floyd–Warshall algorithm F-W(G,cost) // G is a graph //cost(v,w) is the weight of (v,w) (if no (v,w) edge, then cost(v,w)= ) (cos(u,u) = 0 for all u) return transition for each pair vertex (v,w) do path(v,w) cost(v,w) if (path(v,w) ) then transition(v,w) w else transition(v,w) null for each node u do for each node v do for each node w do if path(v,u) + path(u,w) < path(v,w) then path(v,w) path(v,u) + path(u,w) transition(v,w) u Time: O(|V| 3 ) Space: |V| 2
38
Navigation Set Self-contained collection of nodes that requires no links to external nodes to complete a path Nodes can be members of more than one set Goal: Find some way to partition large Navigation Sets into smaller ones
39
Complete Hierarchy
40
Interface Nodes and Sets Need to account for paths that cross navigation sets Any node that connects to a node in another navigation set is an interface node Have a second layer of nodes in addition to navigation sets, called interface set Interface set itself is a navigation set –Therefore, can make transition table for it too
41
Complete Hierarchy 21 nodes –1 Navigation Set = 441 Table Entries (21*21) –4 Navigation Sets = 183 Table Entries (7*7 + 7*7 + 7*7 + 6*6)
42
Constructing the Hierarchy Two goals to process –How many tables to create? Amount of data needed is 1/n of original size + interface set As size of navigation sets increase, cost of interface set becomes less a factor –Where to place boundaries? Keep interface nodes as low as possible
43
Constructing the Hierarchy
44
Building a Hierarchical Navigation Map F-W(SG,I,cost) // SG is an array of graphs, I is the interface graph //cost(v,w) is the weight of (v,w) (if no (v,w) edge, then cost(v,w)= ) return HT How is SG computed? Areas are user defined Automatically computed with specialized procedures for each G in SG do HT(G) F-W(G, cost) HT(I) F-W(I,cost) Time: O(|SG|*max G SG,{I} |V(G)| 3 ) Space: G SG,{I} |V(G)| 2 )
45
Pathfinding Determine best paths leading from source node to boundary of source set Determine best path from source set boundary to goal set boundary Determine best path from goal set boundary to goal node Compile list of complete paths and choose one with least cost
46
Pathfinding Cost Amount of searching is limited to number of interface nodes in goal and source sets only Cost of searching between sets does not scale up with increases in navigation set size –Dependent on number of interface nodes
47
Applications of Navigation Set Hierarchy Interfacing heterogeneous navigation regions Navigation data on demand Extending beyond two tiers
48
Influence Fields Used in a previous competition in Robocode –And related to strategy employed by the “teenage mutant ninja turtles” team Reactive approach to path finding –Setup virtual potential or force field around objects –Must define field and agents reaction to field Interactions in general are explicitly stated and movement “emerges” –Paths are not planned explicitly
49
Influence Fields Can be represented as a matrix –Each point has value representing the strength of field under it –Assigns priority based on a variety of factors: Location of opponents Location of friendlies –Result: “Glide down gradient/path of least resistance”
50
Influence Fields Advantages? –Works in continuous space! No need to place waypoints Disadvantages? –Can get stuck in obstacles –It’s emergent, not sure what it will do
51
Pathfinding: Commercial Implementations Unreal Tournament –Waypoints with pre-computed paths Navigation Points placed throughout world –Assume world is generally static Run local path finding on top of global path finding for dealing with dynamic environments Local path finder constants queries physics engine to find dynamic objects
52
Commercial Implementations Area Awareness System –Designed for Quake 3, also used in Doom 3 –Do not use waypoints, instead 3-D bounded hulls, called areas Cost of moving from one point to another within a hull (reachable area) is minimal Reachability can also be determined if a hull touches another –So akin to meshes but 3-D
53
Commercial Implementations Half Life 2 –Waypoint Based Call of Duty –Based of Quake 3 Area Aware System
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.