Competing · Robot club · about 14 min
Radio in a game, agreeing roles without talking, and swapping jobs when the score says so.
[1 mark]In a game, who hears your send("striker")?
[1 mark]What does this program print?
team = ["bot-7", "bot-2"]
for me in team:
job = "attack" if me == min(team) else "defend"
print(me, job)bot-7 defend bot-2 attack
min of a list of names picks the one that sorts first, bot-2. Both robots run the same rule and agree without a word.
[1 mark]What does this program print?
team = ["bot-10", "bot-9"] print(min(team))
bot-10
Names sort as text, character by character, and 1 comes before 9. So bot-10 sorts first, which is fine as long as both robots use the same rule.
[1 mark]Why is a rule like the name that sorts first attacks often better than agreeing by radio?
[1 mark]Your attacker has been taken out. What should the defender do?
[1 mark]In the task, a robot sends attack and then drives to the near base. What is wrong?
attack should be in capitalsattack and go to the far base, or send defend and go to the near one. A team mate relies on both matching.Send a message saying which job you are taking, then do it: drive to the base zone that matches. This time the job is attack: send attack, then drive to the far base, up the mat and to the left. (Defending would mean the near base, down and to the right.)
from bugbot import *
connect()
# say what you are doing, then do it
send("attack")The hint students can ask for: Send attack, then drive to the far base. The message has to be the single word, and it has to go before you arrive.
from bugbot import *
connect()
send('attack')
while position()[1] < 38:
forward(50)
wait(0.1)
while position()[0] > -22:
left(50)
wait(0.1)
stop()
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.