Mapping · University · about 30 min
The edge between what is known and what is not, and why a map with holes is still useful.
[1 mark]What does this program print?
rows = ["FFFU",
"FOFU",
"FFFF",
"UUFF"]
H, W = len(rows), len(rows[0])
count = 0
for r in range(H):
for c in range(W):
if rows[r][c] == "F":
for dr, dc in ((1, 0), (-1, 0), (0, 1), (0, -1)):
rr, cc = r + dr, c + dc
if 0 <= rr < H and 0 <= cc < W and rows[rr][cc] == "U":
count += 1
break
print(count)
[1 mark]Why is driving to a frontier cell guaranteed to produce new information?
[1 mark]Why can a feature map not support frontier exploration?
[1 mark]Put the frontier exploration pipeline in order.
Number the lines 1 to 5 to put them in the right order.
Group adjacent frontier cells into regions with a flood fillDiscard regions smaller than the robotScore each remaining regionFind every free cell with an unknown neighbourDrive to the best one[1 mark]The robot alternates for ever between two frontiers of equal value on opposite sides of the room. What is the fix?
[1 mark]A small post leaves a wedge of unknown behind it. Why does moving a short distance sideways often beat driving a long way forward?
Turn on the spot, building a grid as you go. Plot known, then print explored:, the fraction of cells that are no longer unknown, and frontier:, how many free cells have an unknown neighbour.
from bugbot import * import math connect() CELL, W = 5.0, 40 L_OCC, L_FREE, L_MAX, FAR = 0.85, -0.4, 8.0, 170.0 START_X, START_Y = 100.0, 100.0 grid = [0.0] * (W * W)
Plan your program here, then type it in and press Run.