The maze
S is the start and the flag is the goal. Black blocks are walls, brown cells are mud: entering mud costs 3, entering a plain cell costs 1.
Growing from the cheapest: 10 cells opened
The priority queue puts the cell with the lowest cost from the start first. The numbers are the cost of the cheapest path found so far to each cell, g. Paths through mud are expensive, so they fall behind. 5 cells are on the frontier.
Growing from the cheapest: 20 cells opened
The priority queue puts the cell with the lowest cost from the start first. The numbers are the cost of the cheapest path found so far to each cell, g. Paths through mud are expensive, so they fall behind. 5 cells are on the frontier.
Growing from the cheapest: 29 cells opened
The priority queue puts the cell with the lowest cost from the start first. The numbers are the cost of the cheapest path found so far to each cell, g. Paths through mud are expensive, so they fall behind. 6 cells are on the frontier.
Growing from the cheapest: 39 cells opened
The priority queue puts the cell with the lowest cost from the start first. The numbers are the cost of the cheapest path found so far to each cell, g. Paths through mud are expensive, so they fall behind. 4 cells are on the frontier.
Growing from the cheapest: 49 cells opened
The priority queue puts the cell with the lowest cost from the start first. The numbers are the cost of the cheapest path found so far to each cell, g. Paths through mud are expensive, so they fall behind. 4 cells are on the frontier.
Growing from the cheapest: 58 cells opened
The priority queue puts the cell with the lowest cost from the start first. The numbers are the cost of the cheapest path found so far to each cell, g. Paths through mud are expensive, so they fall behind. 1 cells are on the frontier.
The cheapest path
The path costs 23 and is 17 steps long. If there is mud, a longer path around it can be cheaper than one through it; uniform cost finds this by looking at the cost. 58 cells were opened.
Why it matters
In map apps roads differ in length and traffic; this idea finds the cheapest route. Dijkstra’s algorithm does the same job.