A* Algorithms Flashcards
1
Q
What does A* algorithm do?
A
Finds shortest path from starting point to goal on graph
2
Q
7 steps of A* algorithm?
A
1 Initialisation
2 Cost calculation
3 Explore
4 Expand neighbours
5 Close node
6 Repeat
7 Reconstruct path
3
Q
Initialisation
A
- Start with open list and closed list
- Add starting point to open list with initial cost of 0
4
Q
Formula for total cost: f(n)
A
Cost from start to node: g(n) + Estimated cost from node to goal: h(n)
5
Q
Explore
A
While open list isn’t empty, select node with lowest f(n) (if it’s goal then reconstruct path and finish)
6
Q
Expand neighbours
A
- For each neighbour of current node calculate g(n)
- If it’s lower then update costs and set current node as neighbour’s parent
- Add neighbour to current list if not already present
7
Q
Close node
A
Move current node to closed list
8
Q
Repeat
A
Go back to step 3 until goal is found or no paths remain