Administrative • Project due Tuesday: – Email your code to Yisheng Tang ([email protected]) 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?
Administrative. Project due Tuesday: Email your code to Yisheng Tang ([email protected]) no later than 11:59PM EST Monday February 6 (the day BEFORE the competition) - PowerPoint PPT Presentation
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Administrative
• Project due Tuesday:– Email your code to Yisheng Tang ([email protected])
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?
Pathfinding: Region Representation and Looking
Beyond A*
Sources:• My own• Joseph Siefers presentation 2008• Jeremy Christman 2008• Wikipedia• Michael Moll, 2006 (main source)
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
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
Uninformed Search Strategies
• estimated with b= 10, a search rate of 105 nodes/sec, and 1 KiB/node• 1 mebibyte is 220 bytes• 1 tebibyte = 240 bytes• 1 pebibyte = 250 bytes• 1 exbibyte = 260 bytes
Depth(Breadth First)
Nodes Time Memory
2 110 1 sec 1MiB
4 11,100 11 sec 106 MiB
6 107 19 minutes 10 GiB
8 109 31 hours 1 TiB
10 1011 129 days 101 TiB
12 1013 35 years 10 PiB
14 1015 3,523 years 1 EiB
Credit: AIMA fig 3.11, pg 74
Informed Search: A* AlgorithmAstar(G,v,d, h, cost) // h is the heuristic function; cost(v,w) is the weight of the (v,w) edgeopen emptyList(); open.add(v); closed emptyList();for each vertex u do g(u) ; predecessor(u) nullg(v) 0while (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)
• 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
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
Transition Table
Transition Table
• 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? n2
• …Is it possible to shrink transition tables?Yes; using hierarchies
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
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
Complete Hierarchy
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