A Searches: Click To Edit Master Subtitle Style
A Searches: Click To Edit Master Subtitle Style
4/17/12
Introduction
First described Nils Nilsson, Bertram
common sense
4/17/12
Basics of A*
Informed search algorithms- searches the
expanding the most promising node chosen according to a specified rule. 4/17/12
Calculation
Distance-plus-cost heuristic is a sum of:
the path-cost function
which is the cost from the starting node to the
current node
goal
F=G+H
4/17/12
Properties
A* is complete and will always find a
4/17/12
Setup
Divide search area into a square grid. Lets assume that we Simplifying the search have someone whoin area is the first step wants to get from pathfinding. Simplified to B. point A to point two-A dimensional array. wall separates the array Each item in the two points. represents one of the squares on the grid, and its status is recorded as walkable
4/17/12
4/17/12
Path Scoring
The key to determining which squares to
use when figuring out the path is the following equation: F = G + H, where :
a given square on the grid, following the path generated to get there. from that given square on the grid to the final destination, point B.
Like an educated guess
4/17/12
Path Scoring
H can be estimated in a variety of ways. Manhattan 2 For simplicity, lets method 1.4horizontal 1 assume a number of or vertical movement squares to move will have a cost of 10 horizontally and 1 vertically to reach the target square from the current square Ignore diagonal
4/17/12
Drop it from the open list and add it to the closed list Check all of the adjacent squares
a) b)
Ignoring those that are on the closed list or unwalkable, add new squares to the open list Make the selected square the parent of the new squares
6.
Check if the G score for that square is lower if we use the current square to get there
a)
b)
If lower
4/17/12
Looking at the square right below Repeat process for all 4 of (or above) our selected square the adjacent squares already G score 14 on the openFisscore is the Lowest list If went through the Immediate paths are oneNone of immediate to the the to get current square right of improved score is there, the starting right of the Gby going square are wall 20
4/17/12
wall square, ignore it Ready to move to Of the other three squares Two are already on the closed list the next square (the starting square, and the one (Note: This following rule above the current square), ignore is optional.) List of squares on our them In certain cases we ignore open list, now down to the Last square, to the immediate left of7 the square just below the current square squares wall. Check to see if the G score is any Pick the through F lower if you golowestthe current Cant get to that square to get there cost Its not square directly from Done and to the current ready on check square the next square our In this case, two squares open list. without cutting across have a score of 54
4/17/12
Final Steps
Determining the path: Start at the red target square. Work backwards moving from one square to its parent, following the arrows Eventually you reach the starting square, and thats your path
Moving from A to B is just moving from the center of each square to the center of the next square on the path, until you reach the target.
4/17/12
Summary of A*
1. 2.
Add the starting square (or node) to the open list. Repeat the following:
a)
Look for the lowest F cost square on the open list. This is our current square. Switch it to the closed list. For each of the 8 squares adjacent to this current square
b) c)
If it isnt on the open list, add it to the open list. Make the current square the parent of this square. Record the F, G, and H costs of the square. If it is on the open list already, check to see if this path to that square is better, using G cost as the measure. A lower G cost means that this is a better path. If so, change the parent of the square to the current square, and recalculate the G and F scores of the square. 4/17/12
a)
Graph Traversal
4/17/12
Weighted A*
Variant of A* algorithm that speeds-up a
4/17/12
Representation
A* Weighted A* F = G + H F = G+ EH Dijkstras Algorithm F=G
4/17/12