Competing · Robot club · about 15 min
A mat that fills up: seeing trails, turning early, keeping to the outside, and turning without stopping.
[1 mark]In Light Cycles you want a moment to think. What happens if you stop?
[1 mark]Which line turns a corner without stopping?
drive(35, 0, 80)stop() then turn_right(40, angle=90)turn_right(40)backward(30) then turn_left(40)drive(forward, sideways, turn) sets all three at once, so you keep moving forward while turning.[1 mark]Which of these keep you alive longer in Light Cycles?
Tick every answer that is true.
[1 mark]What does this program print?
import math trail = [(0, 30), (10, 30), (20, 30)] x, y = 8, 12 closest = min(math.hypot(px - x, py - y) for px, py in trail) print(round(closest, 1))
18.1
The point (10, 30) is 2 across and 18 up from (8, 12), about 18.1 cm. The other two points are farther.
[1 mark]What does this program print?
found = None
print("line ahead?", bool(found))
found = [200, 5]
print("line ahead?", bool(found))line ahead? False line ahead? True
None counts as false and a list with something in it counts as true, which is how if found: works.
[1 mark]Does info()['trails'] include your own trail?
Two trails lie across the mat, each with a gap at one end, and the gaps are at opposite ends. Drive from the start to the green zone at the top without touching a trail. In this task the trails are low walls, 6 cm high, so the depth sensor sees them and the line detector does not.
from bugbot import *
connect()
while position()[1] < 85:
forward(45)
wait(0.1)
stop()The hint students can ask for: Each trail has a gap at one end, and the gaps are at opposite ends. Cross the mat between the trails, not over one.
from bugbot import *
connect()
def across(to_x):
while abs(position()[0] - to_x) > 2:
if position()[0] < to_x:
right(45)
else:
left(45)
wait(0.1)
stop()
def up_to(y):
while position()[1] < y:
forward(45)
wait(0.1)
stop()
across(30)
up_to(41)
across(-30)
up_to(72)
across(20)
up_to(84)
stop()
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.