Capture the Flag!
| (require ctf) |
Welcome to a new Virtual Robotics competition! This year’s competition is a step up in the complexity of the tasks, but writing bots should still be easy for beginners.
Everyone is going to work in teams of two, and those teams need to make two different robots together:
An offense bot, whose goal is to capture the flag, and bring it back to its home base.
A defense bot whose goal is to stop the offense bot from getting the flag.
The defense bot can stop the offense bot by firing lasers at it. The offense bot starts out with 3 lives, and each laser by default will make the offense bot lose 1 life. If the offense bot loses all of their lives, it will lose the flag and be teliported back to the start.
Also, for every 3 kills the defense bot gets, the offense bot will lose 1 flag.
1 Where to work
Each kind of robot (defense or offense) has its own library of commands. If you look in the manias/ctf directory, you should find three files, with starting templates and some very basic bots to build off of.
offense.rkt is for writing your offense bot.
defense.rkt is for writing your defense bot.
together.rkt brings them both together. This is where you click "run" to start the game.
Here’s an overview of the commands you have at your disposal for controlling your bot. Some of the commands work for both bots, and some are only available for offense or defense.
2 Common commands
Numbers beyond the range from -1 to 1 have no extra effect, so (set-motors -10 5) does the same thing as (set-motors -1 1).
Some examples.
(set-motors -1 1) will cause your car to turn left, without accelerating forward or backwards
(set-motors 1 0.5) will cause your car to circle forward and to the right.
procedure
procedure
These calls allow you to read off the state of your motors. So, if in a previous round you called (set-motors 0.3 0.6), then (get-left-input) will return 0.3, and (get-right-input) will return 0.6
For example, in degrees mode, (normalize-angle 320) will return -40.
Whether the value is returned in radians or degrees depends on the mode you’re running in.
3 Defense bot
These calls are only for the defense bot, and you should only use them in defense.rkt.
Here’s how it works.
First, call (load-laser). That puts you into loading mode. Important note: when you’re in loading mode, your motors won’t respond to your instructions.
After some period of time, your laser will get more powerful, first becoming worth two ordinary laser fires, then three. You can experiment to find the right timing. Note that the laser darkens when it goes up in power.
Call (shoot-laser) when you’re ready. That will take you out of loading mode.
If you want to exit loading mode without shooting, you can call (restock-laser).
If you don’t call (shoot-laser), loading mode will eventually time out on its own, and everything goes back to normal