Planning · University · about 40 min
Guessing what is left to pay, why the guess must never be too high, and why greedy best first is not A*.
[1 mark]What does this program print?
import math CELL = 5.0 goal = (34, 34) c = (30, 20) dx, dy = abs(c[0] - goal[0]), abs(c[1] - goal[1]) octile = CELL * (max(dx, dy) + (math.sqrt(2) - 1) * min(dx, dy)) euclid = CELL * math.hypot(dx, dy) manhattan = CELL * (dx + dy) print(round(octile, 1), round(euclid, 1), round(manhattan, 1))
[1 mark]A* runs on an eight-connected grid with the Manhattan heuristic dx + dy. Is that heuristic admissible?
[1 mark]What is the difference between greedy best first search and A*?
[1 mark]Weighted A* with w = 1.5 is run on a map where the optimal path is 331 cm. What is the longest path, in cm, it is guaranteed never to exceed?
[1 mark]Which of these heuristics are admissible for A* on an eight-connected grid?
Tick every answer that is true.
[1 mark]What does a consistent heuristic buy A* beyond admissibility?
[1 mark]Why is octile distance a better heuristic than Euclidean distance on an eight-connected grid?
Run both searches over the same grid, eight neighbours, plain step costs of 5 cm and 5 root 2 cm, and print cost: (which should be identical either way), dijkstra: and a star:, the number of cells each expanded.
from bugbot import * import heapq import math connect() CELL = 5.0 N = 40 INFLATE = 8.0 WALLS = [(70.0, 0.0, 8.0, 115.0), (125.0, 85.0, 8.0, 115.0)]
Plan your program here, then type it in and press Run.
h = 10 * octile. The path will be far from optimal. Work out, from the bound, how far it is allowed to be.