Competing · Robot club · about 14 min
others() and the camera tags, and giving way early so contact never costs you the game.
[1 mark]In the traffic task, a student calls others() to find the moving robots. What happens?
others() is only there in games, so in a task use the camera[1 mark]What does this program print?
import math
bots = [{"name": "red-1", "x": 30, "y": 40}, {"name": "blue-2", "x": -6, "y": 8}, {"name": "blue-3", "x": 20, "y": 0}]
closest, best = None, 1e9
for bot in bots:
d = math.hypot(bot["x"], bot["y"])
if d < best:
closest, best = bot["name"], d
print(closest, best)[1 mark]You touch another robot that drove into you. Whose fault is it, in most games?
[1 mark]Which habits keep you out of trouble on a busy mat?
Tick every answer that is true.
left() or right()[1 mark]robots() comes back as [['red', 160, 118, 35.0]]. What is 35.0?
[1 mark]What does this program print?
for gap in [40, 25, 12]:
if gap < 25:
print(gap, "step aside")
else:
print(gap, "carry on")Two robots are driving back and forth across the mat, 35 cm and 55 cm ahead of you. Get from the start to the green zone without touching either of them, or anything else.
from bugbot import *
connect()
while position()[1] < 80:
forward(50)
wait(0.1)
stop()Plan your program here, then type it in and press Run.