1 CO2301 - Games Development 1 Week 8 A* Gareth Bellaby.

Slides:



Advertisements
Similar presentations
Lights Out Issues Questions? Comment from me.
Advertisements

Heuristic Functions By Peter Lane
Greedy best-first search Use the heuristic function to rank the nodes Search strategy –Expand node with lowest h-value Greedily trying to find the least-cost.
1 Heuristic Search Chapter 4. 2 Outline Heuristic function Greedy Best-first search Admissible heuristic and A* Properties of A* Algorithm IDA*
Pathfinding. “PathEngine is a sophisticated middleware tool- kit for the implementation of intelligent agent movement, built around an advanced implementation.
AI – Week 5 Implementing your own AI Planner in Prolog – part II : HEURISTICS Lee McCluskey, room 2/09
CSC 423 ARTIFICIAL INTELLIGENCE
Search Strategies CPS4801. Uninformed Search Strategies Uninformed search strategies use only the information available in the problem definition Breadth-first.
Review: Search problem formulation
Problem Solving and Search in AI Heuristic Search
Informed Search Idea: be smart about what paths to try.
Informed search algorithms
Chapter 5.4 Artificial Intelligence: Pathfinding.
Graphs II Robin Burke GAM 376. Admin Skip the Lua topic.
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.
Heuristic Search In addition to depth-first search, breadth-first search, bound depth-first search, and iterative deepening, we can also use informed or.
Computer Science CPSC 322 Lecture A* and Search Refinements (Ch 3.6.1, 3.7.1, 3.7.2) Slide 1.
1 CO Games Development 1 Week 11 Search Methods Gareth Bellaby.
P ROBLEM Write an algorithm that calculates the most efficient route between two points as quickly as possible.
Informed search algorithms
1 Shanghai Jiao Tong University Informed Search and Exploration.
Informed search algorithms Chapter 4. Best-first search Idea: use an evaluation function f(n) for each node –estimate of "desirability"  Expand most.
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.
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.
Heuristic Search: A* 1 CPSC 322 – Search 4 January 19, 2011 Textbook §3.6 Taught by: Vasanth.
Heuristic Search Andrea Danyluk September 16, 2013.
CSC3203: AI for Games Informed search (1) Patrick Olivier
Informed Search I (Beginning of AIMA Chapter 4.1)
Informed Search Reading: Chapter 4.5 HW #1 out today, due Sept 26th.
Informed Search and Heuristics Chapter 3.5~7. Outline Best-first search Greedy best-first search A * search Heuristics.
Feng Zhiyong Tianjin University Fall  Best-first search  Greedy best-first search  A * search  Heuristics  Local search algorithms  Hill-climbing.
Best-first search Idea: use an evaluation function f(n) for each node –estimate of "desirability"  Expand most desirable unexpanded node Implementation:
1 CO Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby.
Informed Search II CIS 391 Fall CIS Intro to AI 2 Outline PART I  Informed = use problem-specific knowledge  Best-first search and its variants.
Informed Search CSE 473 University of Washington.
Heuristic Functions. A Heuristic is a function that, when applied to a state, returns a number that is an estimate of the merit of the state, with respect.
Searching for Solutions
A* optimality proof, cycle checking CPSC 322 – Search 5 Textbook § 3.6 and January 21, 2011 Taught by Mike Chiang.
Chapter 3.5 and 3.6 Heuristic Search Continued. Review:Learning Objectives Heuristic search strategies –Best-first search –A* algorithm Heuristic functions.
Heuristic Functions.
Artificial Intelligence Lecture No. 8 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
CPSC 420 – Artificial Intelligence Texas A & M University Lecture 5 Lecturer: Laurie webster II, M.S.S.E., M.S.E.e., M.S.BME, Ph.D., P.E.
CPSC 322, Lecture 7Slide 1 Heuristic Search Computer Science cpsc322, Lecture 7 (Textbook Chpt 3.6) Sept, 20, 2013.
Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
Review: Tree search Initialize the frontier using the starting state
Heuristic Functions.
Heuristic Search A heuristic is a rule for choosing a branch in a state space search that will most likely lead to a problem solution Heuristics are used.
Department of Computer Science
Heuristic Search Introduction to Artificial Intelligence
Heuristic Search Henry Kautz.
The A* Algorithm Héctor Muñoz-Avila.
Discussion on Greedy Search and A*
Discussion on Greedy Search and A*
CS 4100 Artificial Intelligence
Informed search algorithms
Informed search algorithms
Lecture 8 Heuristic search Motivational video Assignment 2
Artificial Intelligence
CO Games Development 1 Week 8 Depth-first search, Combinatorial Explosion, Heuristics, Hill-Climbing Gareth Bellaby.
CSE 473 University of Washington
HW 1: Warmup Missionaries and Cannibals
Informed Search Idea: be smart about what paths to try.
HW 1: Warmup Missionaries and Cannibals
Artificial Intelligence
Reading: Chapter 4.5 HW#2 out today, due Oct 5th
Informed Search Idea: be smart about what paths to try.
Informed Search.
Presentation transcript:

1 CO Games Development 1 Week 8 A* Gareth Bellaby

2 Best first searches Best first algorithm is estimate of distance to goal Dijkstra's algorithm is cost A* algorithm is cost + estimate

3 A* algorithm Combines cost with a prediction of how close the goal is. A* is an efficient pathfinding algorithm.

4 A* algorithm As with Dijkstra's Algorithm the algorithm itself is on the web site in "algorithms.doc" since it is too long to put up in a PowerPoint presentation. Note that the open list is a priority queue. Also note that the algorithm removes items from the closed list if a better route to a node is found during the course of the search.

5 A* algorithm f(n) = g(n) + h(n) f(n) is the evaluation function, i.e. the score assigned to node. g(n) is the actual cost of getting to n from the start. h(n) is the heuristic estimate of getting from n to the goal.

6 A* example - heuristic Use a simple heuristic: count the total number of squares to the destination. This is called the Manhattan distance. Simply sum together the number of squares horizontally and vertically. start

7 A* example - cost Need to include the actual cost incurred for moving to a particular square. Cost is 1 for a white square, 2 for a green square and the wall is impassable.

8 A* example 1 Red: start/end Black: wall Green: forest Apply the rules in the order N, E, S, W

9 A* example 1 - accumulated cost 5 Cost of the square + cost of the route taken to the square. Obviously the accumulated cost depends on the exact route taken

10 A* example 1 - heuristic 1 Red: start/end Black: wall Green: forest Apply the rules in the order N, E, S, W (So the cost to the square above the wood is 4 because the route was through the wood - a lower cost route does exist)

11 A* example 1 Red: start/end Black: wall Green: forest Apply the rules in the order N, E, S, W (So the cost to the square above the wood is 4 because the route was through the wood - a lower cost route does exist)

12 A* example 2 Red: start/end Black: wall Green: forest Apply the rules in the order N, E, S, W

13 A* example 2 Red: start/end Black: wall Green: forest Apply the rules in the order N, E, S, W

14 A* example 3 Red: start/end Black: wall Green: forest Apply the rules in the order N, E, S, W

15 A* example 3 Red: start/end Black: wall Green: forest Apply the rules in the order N, E, S, W

16 Admissibility If a grid is used, and the only allowed movement is horizontally or vertically, then the Manhattan distance is: admissible, i.e. it never overestimates the distance. the best possible heuristic that can be used.

17 Admissibility In A* proper the heuristic estimate must be admissible, i.e. it never uses a heuristic that overestimates the distance. A* is guaranteed to find the optimal solution, but only if the heuristic estimate is admissible. Why?

18 A* algorithm If A* uses a heuristic that overestimates the distance then the value calculated by the heuristic can be larger than the cost. Consider the boundary conditions. At the extreme, overestimating the heuristic is equivalent to ignoring the cost. If the cost is ignored then the algorithm is just based on the heuristic. This is the best-first search algorithm.

19 A* algorithm Now, consider the other extreme. If the heuristic estimation is ignored then the algorithm is just based on cost. This is Dijkstra's algorithm. The best situation is one where the heuristic evaluation approaches the cost but is never actually overestimated.

20 The graceful decay of admissibility In A* proper the heuristic estimate must be admissible, i.e. it never uses a heuristic that overestimates the distance. A* is guaranteed to find the optimal solution, but only if the heuristic estimate is admissible. Games pathfinding often ignores this: emphasising speed over optimality.

21 The graceful decay of admissibility If your heuristic rarely over-estimates the real distance to goal by more than a certain value (lets call it d) then the A* algorithm will rarely find a solution which costs more than d over the cost of the optimal solution. Graceful decay of admissability. Be strict about admissability at the beginning of the search but as the search is assumed to get closer to the destination relax the admissability criterion.