Welcome back! I'm excited to present the 3rd CodeBots challenge. This one has been a long time in the making. This challenge will be split up in 3 sections: the short version, the long version, and additional details.
The Short Version
Each competitor will write a 24-command program. These bots will move around the world and copy their code into other bots, while trying to prevent other bots to do the same. One of the possible commands is the no-op
Flag. If a bot has more of your
Flag than any other bot's
Flag, you get a point. You win by having the most points.
All of the above was true for the past two challenges. This time around, bots will be able to run multiple lines of code at the same time.
The Long Version
Every bot will have exactly 24 lines, where each line is in the following format:
$label command parameters //comments
Labels and comments are optional, and each command has a different number of parameters. Everything is case-insensitive.
Parameters are typed, and can be in the following formats:
- A value from 0 to 23.
- A variable:
- A value using addition:
- A line of code, which is designated using the
#4would represent the 5th line, while
#C+2would represent the line calculated by
- You can use a
$labelinstead of designating a line of code.
- Your opponent's variable or line of code, designated by
*. Your opponent is the bot in the square that you are facing. (
*Brepresents your opponent's
*#9represents your opponent's 10th line). If there is nobody in that square, the command is not executed.
Moves the bot
North+(V*90 degrees clockwise). Movement does not change direction.
Turns the bot
V*90 degrees clockwise.
Copy V W
Copies whatever is in
V is a line number, then
W has to be a line number. If
V is a variable or value, then
W must be a variable.
Starts a new thread attached to the variable
V. Immediately, and on each future turn, the thread will execute the command on line
V is already attached to a thread, then this command is a no-op. If
V is an opponent's variable, then the opponent will start a thread attached to that variable.
Stops the thread attached to the variable
V at the end of this turn.
Prevent the line or variable
V from being used in any way except by the thread that called
Lock. A subsequent call to
Lock by the same thread unlocks
V. Locks cannot be called on opponent's variables or lines.
If Cond V W
This will test
Cond. If the condition is true, then it will move the thread pointer to the line number
V, otherwise to the line number
W. That line will then be immediately executed.
Conditionals can be
X=Ytests whether two lines are of the same type and from the same bot, or you test whether two values equal the same amount.
X<Ytests whether the value of
Xis less than
!Xtests whether the variable or line
Xis locked (returns true if locked)
?Xtests whether a given variable has a thread attached to it
Actions of the same type are executed at the same time. Actions are executed in the following order:
Lock. If several threads attempt to lock a variable, they will all fail. If a thread is unlocking a variable while another is attempting to lock it, the variable will remain unlocked.
Start. If several threads attempt to start a thread on a variable, it will count as a single start.
Copy. If two threads both copy to the same variable, the variable will end up as a random value. If they both copy to the same line, neither will work. If a thread copies to the same variable another thread is copying from, then the latter thread will copy a random value. If two threads are both copying from the same variable, they will both work fine.
If. All conditionals will be tested simultaneously, and then the thread variables will be updated after. Executing an
Ifcan cause an action with a higher priority to be added. Actions with higher priority will be executed before moving on past the
If, while actions with a lower priority will execute after the
Move. Multiple moves on the same bot will move the bot the sum of all of the moves. If multiple bots would end up in the same spot, they will be returned to their starting spot.
Turn. Multiple turns on the same bot will sum.
Stop. Multiple stop commands on the same variable will count as a single stop.
Your initial thread starts attached to the
Recursing with an
If (having an
If statement pointed to itself) will cause your bot to do nothing
If a thread is stopped after locking, those locks will be unlocked
Actions to use a locked variable or line will do nothing.
If a bot is shorter than 24 lines, remaining lines will be filled with
Performing a write on a variable that is also attached to a starting thread will actually have the thread start its execution on the new value as the thread starts the following turn.
Bots are placed in a toroidal world in the following pattern:
B...B...B... ..B...B...B. B...B...B...
The controller is located here. I've worked a long time on it, but it probably still has bugs. When the spec and the controller contradict, the spec is correct.
1. 771 LockedScannerBot 2. 297 CopyAndSelfFlag 3. 289 DoubleTapBot 4. 197 ThreadCutterBot 5. 191 TripleThread 6. 180 ThickShelled 7. 155 Attacker 8. 99 RandomMover 9. 90 BananaBot 10. 56 LockedStationaryDoubleTap