Mapping · University · about 50 min
An unknown layout, a grid built from scratch, and a measurement taken off the map.
[1 mark]What does this program print?
CELL = 5.0
T, F = True, False
band = [T, F, F, T, T, T, F, F, F, F, T, T, F, F]
best = None
c = 0
while c < len(band):
if not band[c]:
start = c
while c < len(band) and not band[c]:
c += 1
bounded = start > 0 and c < len(band)
if bounded and (best is None or c - start > best[1] - best[0]):
best = (start, c)
else:
c += 1
print(best, (best[0] * CELL + best[1] * CELL) / 2)
[1 mark]When searching the band for the doorway, why must a clear run have wall on both sides?
[1 mark]A program reports the wall at y = 0 on every run. What has it most likely found?
[1 mark]The reported doorway is always off by exactly one cell. What should you check first?
[1 mark]Why does the project sweep from a second viewpoint as well as the first?
[1 mark]After a full turn on the spot, the robot calls forward() and drives sideways across the mat. Why?
The robot starts at (100, 25) facing up the mat. Map it, and print explored:, wall y: and gap x:. Do not touch anything.
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, 25.0 grid = [0.0] * (W * W)
Plan your program here, then type it in and press Run.