REFERENCE: “ARTIFICIAL INTELLIGENCE FOR GAMES”, IAN MILLINGTON. A* (A-STAR)

Slides:



Advertisements
Similar presentations
AI Pathfinding Representing the Search Space
Advertisements

An Introduction to Artificial Intelligence
Heuristics CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Lecture 4 Jim Martin.
Graphs CSC 220 Data Structure. Introduction One of the Most versatile data structures like trees. Terminology –Nodes in trees are vertices in graphs.
Artificial Intelligence Chapter 9 Heuristic Search Biointelligence Lab School of Computer Sci. & Eng. Seoul National University.
Problem Solving Agents A problem solving agent is one which decides what actions and states to consider in completing a goal Examples: Finding the shortest.
Solving Problems by Searching Currently at Chapter 3 in the book Will finish today/Monday, Chapter 4 next.
CPSC 322, Lecture 5Slide 1 Uninformed Search Computer Science cpsc322, Lecture 5 (Textbook Chpt 3.4) January, 14, 2009.
CSE 380 – Computer Game Programming Pathfinding AI
© 2006 Pearson Addison-Wesley. All rights reserved14 A-1 Chapter 14 excerpts Graphs (breadth-first-search)
Uninformed Search Jim Little UBC CS 322 – Search 2 September 12, 2014
CPSC 322, Lecture 9Slide 1 Search: Advanced Topics Computer Science cpsc322, Lecture 9 (Textbook Chpt 3.6) January, 23, 2009.
CPSC 322, Lecture 9Slide 1 Search: Advanced Topics Computer Science cpsc322, Lecture 9 (Textbook Chpt 3.6) January, 22, 2010.
Review: Search problem formulation
Artificial Intelligence
MAE 552 – Heuristic Optimization Lecture 27 April 3, 2002
Alyce Brady CS 510: Computer Algorithms Breadth-First Graph Traversal Algorithm.
Using Search in Problem Solving
COMP171 Depth-First Search.
Pathfinding Algorithms Josh Palmer Rachael Beers.
Problem Solving and Search in AI Heuristic Search
Using Search in Problem Solving
Graphs & Graph Algorithms Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
CS 188: Artificial Intelligence Spring 2006 Lecture 2: Queue-Based Search 8/31/2006 Dan Klein – UC Berkeley Many slides over the course adapted from either.
Uninformed Search (cont.)
Chapter 5.4 Artificial Intelligence: Pathfinding.
State-Space Searches. 2 State spaces A state space consists of –A (possibly infinite) set of states The start state represents the initial problem Each.
Solving Problems by Searching
State-Space Searches.
Informed Search Idea: be smart about what paths to try.
CMU Snake Robot
Dijkstra’s Algorithm and Heuristic Graph Search David Johnson.
Busby, Dodge, Fleming, and Negrusa. Backtracking Algorithm Is used to solve problems for which a sequence of objects is to be selected from a set such.
Chapter 5.4 Artificial Intelligence: Pathfinding.
Lab 3 How’d it go?.
GRAPHS
WAES 3308 Numerical Methods for AI
Introduction to search Chapter 3. Why study search? §Search is a basis for all AI l search proposed as the basis of intelligence l inference l all learning.
How are things going? Core AI Problem Mobile robot path planning: identifying a trajectory that, when executed, will enable the robot to reach the goal.
BackTracking CS335. N-Queens The object is to place queens on a chess board in such as way as no queen can capture another one in a single move –Recall.
P ROBLEM Write an algorithm that calculates the most efficient route between two points as quickly as possible.
State-Space Searches. 2 State spaces A state space consists of A (possibly infinite) set of states The start state represents the initial problem Each.
Artificial Intelligence in Game Design Dynamic Path Planning Algorithms.
COMP261 Lecture 7 A* Search. A* search Can we do better than Dijkstra's algorithm? Yes! –want to explore more promising paths, not just shortest so far.
Review: Tree search Initialize the frontier using the starting state While the frontier is not empty – Choose a frontier node to expand according to search.
Advanced Artificial Intelligence Lecture 2: Search.
Artificial Intelligence for Games Informed Search (2) Patrick Olivier
Search (continued) CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Ricochet Robots Mitch Powell Daniel Tilgner. Abstract Ricochet robots is a board game created in Germany in A player is given 30 seconds to find.
COSC 2007 Data Structures II
Search Techniques CS480/580 Fall Introduction Trees: – Root, parent, child, sibling, leaf node, node, edge – Single path from root to any node Graphs:
CPSC 322, Lecture 6Slide 1 Uniformed Search (cont.) Computer Science cpsc322, Lecture 6 (Textbook finish 3.5) Sept, 17, 2012.
Graph Search II GAM 376 Robin Burke. Outline Homework #3 Graph search review DFS, BFS A* search Iterative beam search IA* search Search in turn-based.
A* Reference: “Artificial Intelligence for Games”, Ian Millington.
CSCE 552 Spring 2010 AI (III) By Jijun Tang. A* Pathfinding Directed search algorithm used for finding an optimal path through the game world Used knowledge.
CPSC 322, Lecture 5Slide 1 Uninformed Search Computer Science cpsc322, Lecture 5 (Textbook Chpt 3.5) Sept, 13, 2013.
Optimization Problems The previous examples simply find a single solution What if we have a cost associated with each solution and we want to find the.
Best-first search is a search algorithm which explores a graph by expanding the most promising node chosen according to a specified rule.
CSCE 552 Fall 2012 AI By Jijun Tang. Homework 3 List of AI techniques in games you have played; Select one game and discuss how AI enhances its game play.
A* Reference: “Artificial Intelligence for Games”, Ian Millington.
Review: Tree search Initialize the frontier using the starting state
Uniformed Search (cont.) Computer Science cpsc322, Lecture 6
Chapter 5.4 Artificial Intelligence: Pathfinding
Uniformed Search (cont.) Computer Science cpsc322, Lecture 6
Search Related Algorithms
Reference: “Artificial Intelligence for Games”, Ian Millington.
Team 17c ****** Pathfinding
Breadth-First Search L0 L1 L2 C B A E D F Breadth-First Search
Presentation transcript:

REFERENCE: “ARTIFICIAL INTELLIGENCE FOR GAMES”, IAN MILLINGTON. A* (A-STAR)

GOALS Find a “pretty-short” path from point A to point B. The best path is often prohibitively expensive to find. S G

GRAPH-BASED ALGORITHM Graph Vertices (Nodes) Edges Single edge Double edge Cost (For map traversal), distance is the norm Cost multiplier (>1) for rough terrain. Representation Adjacency Matrix Adjacency List

GRAPH NODES VS. SEARCH NODES Graph Start == 0, Goal == 6 Search Tree There are usually many search trees for the same graph. 2.0

GRAPH NODES VS. SEARCH NODES, CONT. One approach: GraphNode(id, …) Id … Neighbor_ pointers = […] # Or this could be stored in map SearchNode(graphNode Pointer, parent) Parent is None for the starting node Create a search node as you traverse the graph.

DEPTH-FIRST SEARCH S G Need a (bool) visited value for each graph node (to prevent re-visiting). Visit a (“random”) new node from the current node. Total Cost is the edge cost of all edges traversed. We have to try all possible search graphs to find the least costly path – EXPENSIVE! Total=17 Total=19

BREADTH-FIRST SEARCH S G Need a list of “frontier” nodes and a (bool) visited flag. Expand the frontier by one hop each iteration. We end up with several search trees. Problem: A lot of search trees – MEMORY + TIME INTENSIVE (especially for large graphs). The search trees are dependent on the graph structure (2=>6 vs 0=>6)

HEURISTICS "A trial-and-error guess ". Used a lot in AI Often leads to an OK solution (but much more quickly) when compared to an exhaustive search In A*: an estimate of how far a given node is from the goal state. Accuracy is critical to good performance of A* For path-finding, often use the straight-line distance. Or c * dist (where c >= 1.0) We'll store 3 things for each search node: The parent search node (if any) The cost-so-far value (g) The cost-heuristic (h) A* is basically a "best-first" search (based on g and h)

OPEN, CLOSED “LISTS” We'll maintain two "lists" of search nodes: OPEN: Those on the search "frontier" CLOSED: Those we've already visited anything not on these lists is unexplored The graph node doesn't have a search node. Often more efficient to maintain: A Priority Queue for OPEN A state variable for each search node (OPEN or CLOSED)

A* ALGORITHM 1.Create search node for Start Node a)Parent = None, Cost-so-far = 0, H = (distance to goal) 2.Add this new node to OPEN 3.Repeat these steps as long as OPEN isn’t empty. a)Take the best node, C, off OPEN i.If C is the goal, construct a Graph-node sequence and return. ii.If not, add C to CLOSED. b)Repeat for each of C's neighbors, N : i.If N is unexplored, create a Search Node for it and add it to OPEN. ii.If N is on OPEN and path from C c.s.f. + cost(C,N) < N c.s.f. : Update the parent and cost-so-far of N Reheapify that node on OPEN iii.If N is on CLOSED and path from C c.s.f. + cost(C,N) < N c.s.f. : remove it from CLOSED and put it on OPEN Update the parent and cost-so-far of N #NOTE: This case shouldn't happen if your heuristic is well- formed 4.Return False (no path found)

MINHEAP + A* A* uses this as its "metric" CostSoFar (actual cost from start to this node) + Heuristic (estimated cost from this node to the goal) Note: The heuristic is almost always an under- estimate. So…we give priority to those nodes that appear to take us closer to the goal.

UNDER-/OVER-ESTIMATING HEURISTIC Very important to get as close as possible! 0 => breadth-first search. The closer they get to the real cost, the more the "countours" will bend towards the goal. >= actual cost => explore all nodes. Too high => find a "bad" path before a "good" Too low => look at too many nodes.

NAV-MESHES A common way to represent: Walkable areas of a map. Cover-spots Jumping-points (to cross a chasm) Ladders Save points, ammo drops, etc. Key Ideas: Not usually visible Usually much lower poly-count than the actual ground

NAV-MESHES, CONT. Display Mesh (16541 faces) Nav Mesh (301 faces)

NAV-MESHES, CONT. We can use these for pathfinding… Nodes are faces (their center?) Edges are connections between neighboring faces Cost is just the euclidean distance between centers. Probably best done off-line Finding neighbors can be costly.

ANOTHER APPLICATION OF A*

A* VARIANTS / IMPROVEMENTS IDA* Iterative Deepening Algorithm Slightly slower, but less memory than A* Pruning A* often produces "jerky" paths Some post-processing makes the paths nicer Curves Simplification / pruning. Saving the results Often (esp. in games), the new search is similar to the last (except perhaps the first and last nodes) – temporal coherency. You can eliminate long searches by re-using parts of the last search.

HEAP-BASED PRIORITY QUEUES …