Chapter 5.4 Artificial Intelligence: Pathfinding.

Slides:



Advertisements
Similar presentations
BEST FIRST SEARCH - BeFS
Advertisements

Informed Search Algorithms
Heuristic Search techniques
Problem solving with graph search
AI Pathfinding Representing the Search Space
Solving Problem by Searching
Pathfinding Basic Methods.
CS 484 – Artificial Intelligence1 Announcements Department Picnic: today, after class Lab 0 due today Homework 2 due Tuesday, 9/18 Lab 1 due Thursday,
Chapter 4 Search Methodologies.
CSE 380 – Computer Game Programming Pathfinding AI
CSC 423 ARTIFICIAL INTELLIGENCE
Review: Search problem formulation
State-Space Searches. State spaces A state space consists of –A (possibly infinite) set of states The start state represents the initial problem Each.
1 Chapter 4 Search Methodologies. 2 Chapter 4 Contents l Brute force search l Depth-first search l Breadth-first search l Properties of search methods.
MAE 552 – Heuristic Optimization Lecture 27 April 3, 2002
Using Search in Problem Solving
Pathfinding Algorithms Josh Palmer Rachael Beers.
Using Search in Problem Solving
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.
State-Space Searches.
Dijkstra’s Algorithm and Heuristic Graph Search David Johnson.
Lab 3 How’d it go?.
1 Game AI Path Finding. A Common Situation of Game AI A Common Situation of Game AI Path Planning Path Planning –From a start position to a destination.
1 CO Games Development 1 Week 6 Introduction To Pathfinding + Crash and Turn + Breadth-first Search Gareth Bellaby.
Representing and Using Graphs
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.
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.
1 Artificial Intelligence in Games Week 6 Steve Rabin TA: Chi-Hao Kuo TA: Allan.
Artificial Intelligence in Game Design Dynamic Path Planning Algorithms.
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.
Informed search strategies Idea: give the algorithm “hints” about the desirability of different states – Use an evaluation function to rank nodes and select.
Informed Search Strategies Lecture # 8 & 9. Outline 2 Best-first search Greedy best-first search A * search Heuristics.
1 Artificial Intelligence in Games Week 5 Steve Rabin TA: Chi-Hao Kuo TA: Allan.
For Monday Read chapter 4, section 1 No homework..
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.
Informed Search I (Beginning of AIMA Chapter 4.1)
Search (continued) CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Informed Search Reading: Chapter 4.5 HW #1 out today, due Sept 26th.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
REFERENCE: “ARTIFICIAL INTELLIGENCE FOR GAMES”, IAN MILLINGTON. A* (A-STAR)
© 2006 Pearson Addison-Wesley. All rights reserved 14 A-1 Chapter 14 Graphs.
CHAPTER 2 SEARCH HEURISTIC. QUESTION ???? What is Artificial Intelligence? The study of systems that act rationally What does rational mean? Given its.
1 CO Games Development 1 Week 8 A* Gareth Bellaby.
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.
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.
Chap 4: Searching Techniques Artificial Intelligence Dr.Hassan Al-Tarawneh.
Review: Tree search Initialize the frontier using the starting state
Chapter 5.4 Artificial Intelligence: Pathfinding
Chap 4: Searching Techniques Artificial Intelligence Dr.Hassan Al-Tarawneh.
Maze Implementation, Analysis and Design to find Shortest Paths
Mathematics & Path Planning for Autonomous Mobile Robots
Search-Based Footstep Planning
EA C461 – Artificial Intelligence
Informed search algorithms
Team 17c ****** Pathfinding
CO Games Development 1 Week 8 Depth-first search, Combinatorial Explosion, Heuristics, Hill-Climbing Gareth Bellaby.
Chap 4: Searching Techniques
CSCE 552 Spring 2009 AI (III) By Jijun Tang.
State-Space Searches.
State-Space Searches.
Reading: Chapter 4.5 HW#2 out today, due Oct 5th
State-Space Searches.
Presentation transcript:

Chapter 5.4 Artificial Intelligence: Pathfinding

2 Outline Introduction to pathfinding 5 pathfinding algorithms Summary

3 Introduction Almost every game requires pathfinding Agents must be able to find their way around the game world Pathfinding is not a trivial problem The fastest and most efficient pathfinding techniques tend to consume a great deal of resources

4 Pathfinding algorithms A* algorithm Random-Trace Breadth-First Best-First Dijkstra

5 Representing the Search Space Agents need to know where they can move Search space should represent either Clear routes that can be traversed Or the entire walkable surface Search space typically doesn’t represent: Small obstacles or moving objects Most common search space representations: Grids Waypoint graphs Navigation meshes

6 Grids 2D grids – intuitive world representation Works well for many games including some 3D games such as Warcraft III Each cell is flagged as either Passable or impassable Each object in the world can occupy one or more cells

7 Characteristics of Grids Fast look-up Easy access to neighboring cells Complete representation of the level

8 Waypoint Graph A waypoint graph specifies lines/routes that are “safe” for traversing Each line (or link) connects exactly two waypoints An agent can choose to walk along any of these lines without having to worry about running into major obstacles

9 Characteristics of Waypoint Graphs Waypoint node can be connected to any number of other waypoint nodes Waypoint graph can easily represent arbitrary 3D levels Can incorporate auxiliary information Such as ladders and jump pads Incomplete representation of the level

10 Navigation Meshes Combination of grids and waypoint graphs Every node of a navigation mesh represents a convex polygon (or area) As opposed to a single position in a waypoint node Advantage of convex polygon Any two points inside can be connected without crossing an edge of the polygon Navigation mesh can be thought of as a walkable surface

11 Navigation Meshes (continued)

12 Characteristics of Navigation Meshes Complete representation of the level Ties pathfinding and collision detection together Can easily be used for 2D and 3D games

13 Searching for a Path A path is a list of cells, points, or nodes that an agent must traverse A pathfinding algorithm finds a path From a start position to a goal position The following pathfinding algorithms can be used on Grids Waypoint graphs Navigation meshes

14 Criteria for Evaluating Pathfinding Algorithms Quality of final path Resource consumption during search CPU and memory Whether it is a complete algorithm A complete algorithm guarantees to find a path if one exists

15 Random Trace Simple algorithm Agent moves towards goal If goal reached, then done If obstacle Trace around the obstacle clockwise or counter-clockwise (pick randomly) until free path towards goal Repeat procedure until goal reached

16 Random Trace Characteristics Not a complete algorithm Found paths are unlikely to be optimal Incapable of considering a wide variety of paths Consumes very little memory

17 Random Trace (continued) How will Random Trace do on the following maps?

18 Understanding A* To understand A* First understand Breadth-First, Best-First, and Dijkstra algorithms A* is a combination of Best-First and Dijkstra These algorithms use nodes to represent candidate paths They keep track of numerous paths simultaneously

19 Understanding A* class PlannerNode { public: PlannerNode *m_pParent; int m_cellX, m_cellY;... }; The m_pParent member is used to chain nodes sequentially together to represent a path

20 Understanding A* All of the following algorithms use two lists The open list The closed list Open list keeps track of promising nodes When a node is examined from open list Taken off open list and checked to see whether it has reached the goal If it has not reached the goal Used to create additional nodes Then placed on the closed list The closed nodes are those that do not correspond to the goal cell and have been processed already

21 Overall Structure of the Algorithms 1. Create start point node – push onto open list 2. While open list is not empty A. Pop node from open list (call it currentNode) B. If currentNode corresponds to goal, break from step 2 C. Create new nodes (successors nodes) for cells around currentNode and push them onto open list D. Put currentNode onto closed list

22 Main different between 5 pathfinding algorithms Breadth-First always processes the node that has been waiting the longest Best-First always processes the one that is closest to the goal Dijkstra processes the one that is the cheapest to reach from the start cell A* chooses the node that is cheap and close to the goal

23 Breadth-First Finds a path from the start to the goal by examining the search space step by step It checks all the cells that are one step from the start, and then checks cells that are two plies from the start, and so on. This is because the algorithm always processes the node that has been waiting the longest.

24 Bread-First cont’ It uses a queue as the open list Once a node is created, it is pushed to the back of the queue So that the node at the front of the queue is always the one that has been waiting the longest

25 Breadth-First Characteristics Exhaustive search Systematic, but not clever Consumes substantial amount of CPU and memory Guarantees to find paths that have fewest number of nodes in them Not necessarily the shortest distance! Search as hard in the direction away from the goal as it does toward the goal Complete algorithm

26 Bread-First example

27 Best-First Uses problem specific knowledge to speed up the search process Head straight for the goal Computes the distance of every node to the goal Uses the distance (or heuristic cost) as a priority value to determine the next node that should be brought out of the open list

28 Best-First (continued)

29 Best-First (continued) Situation where Best-First finds a suboptimal path

30 Best-First Characteristics Heuristic search Uses fewer resources than Breadth-First Tends to find good paths No guarantee to find most optimal path Complete algorithm

31 Dijkstra Disregards distance to goal Keeps track of the cost of every path No guessing Computes accumulated cost paid to reach a node from the start Uses the cost (called the given cost) as a priority value to determine the next node that should be brought out of the open list

32 Dijkstra Characteristics Exhaustive search At least as resource intensive as Breadth-First Always finds the most optimal path Complete algorithm

33 A* It uses an admissible heuristic function that never overestimates the true cost Uses both heuristic cost (the estimated cost to reach the goal) and given cost (the actual cost paid to reach a node from the start) to order the open list Final Cost = Given Cost + (Heuristic Cost * Heuristic Weight)

34 A* cont’ Final Cost = Given Cost + (Heuristic Cost * Heuristic Weight) Heuristic weight can be used to control the amount of emphasis on the heuristic cost versus the given cost. It can control whether A* should behave more like Best-First or Dijkstra. If hw=0, final cost will be the given cost ->Dijkstra If hw >>1, it will behave just like Best-First

35 A* (continued) Avoids Best-First trap!

36 A* Characteristics Heuristic search On average, uses fewer resources than Dijkstra and Breadth-First Admissible heuristic guarantees it will find the most optimal path Complete algorithm

37 Summary Two key aspects of pathfinding: Representing the search space Searching for a path