This guide will fall into three sections. An overview, a language reference, and a series of short walk-throughs.
To program BooBot you need to use the program page and follow these simple instructions:
BooBot uses a (fairly) simple assembly-style programming language. Each instruction starts with a colon (:) and consists of an operation word written in capitals. This operation may need one or two operands or parameters, separated by spaces. The command TESTGROUND, for example, requires no operands. TURN needs a single operand (the direction) and SET needs two, the variable and the new value.
There is no IF or LOOP constructs in this language. You can COMPARE two variables, and can jump to a defined label based on the relationship between the variables resulting from the comparison.
A label is a single word and should be specified before the command colon. If no label is needed, then the colon should be the first charachter on the line.
The floor consists of 400 grass tiles in a 20x20 grid. BooBot starts on floor tile 1,1, and is facing floor tile 2,1 - so the first coordinate is the distance away from the code screen. The second coordinate is in the same plane as the code screen (so across) and away from where BooBot starts. The map is plain text, with the two coordinates, comma separated, followed by a colon. After that is a value which signifies what is there (at the moment, only water which is '1'), a comma, and then the amount of water that is in that tile. Any unspecified tiles default to grass with nothing diggable.
Command | Operands | Description |
MOVE | None | Moves the bot forward one square. |
TURN | Direction | Direction is either CW or CCW (clockwise or counter-clockwise). |
SET | VariableName & Value | Creates a new variable with the given name and sets it to value. Value must be an integer. |
ADD | VariableName & Value | Adds value (an integer) to the given variable. |
COMP | VariableNameA & VariableNameB | Compares the contents of VariableNameA with the contents of VariableNameB. Sets flags of EQUAL and INEQUAL, as well as GT if A>B and LT if A<B. These flags are then used by the jump commands. |
JUMP | Label | Jumps execution to the line of code identified by label. |
JUMPEQ | Label/td> | Jumps execution to the line of code identified by label IF the last COMP command resulted in the EQUAL flag being set. |
JUMPNEQ | Label | Jumps execution to the line of code identified by label IF the last COMP command resulted in the INEQUAL flag being set. |
JUMPGT | Label | Jumps execution to the line of code identified by label IF the last COMP command resulted in the GT flag being set (that is, the contents of VariableNameA was greater than the contents of VariableNameB). |
JUMPLT | Label | Jumps execution to the line of code identified by label IF the last COMP command resulted in the LT flag being set (that is, the contents of VariableNameA was less than the contents of VariableNameB). |
TESTGROUND | None | Tests the ground for things that can be dug up. At the moment, only water can be dug up. If water is found, the ground will turn blue, else it will turn brown. The variable LASTCHECKEDTYPE will be set to 1 if water is found, else set to 0. The variable LASTCHECKEDAMOUNT will be set to the amount of water (an integer) that is available to be dug up. |
DIGGROUND | None | Attempts to dig up whatever is in the ground. If there is nothing to dig up, the robot breaks and turns red. If there is something to be dug, it is added to the robot's carrying hopper (which is invisible) and removed from the tile. If it is the last thing that can be dug up, the tile turns brown. At the moment BooBot is very strong and has an infinite carry capacity |
The following code will make BooBot walk forward, turn counter-clockwise, forward a bit, clockwise, and then forward a bit. Exciting! Copy and paste the code into the code box, there is no need for map code for this one.
:MOVE
:TURN CCW
:MOVE
:TURN CW
:MOVE
The following code will make BooBot walk in a square. After each rotation, JUMP will be used to repeat the code.
START:MOVE
:TURN CCW
:MOVE
:TURN CCW
:MOVE
:TURN CCW
:MOVE
:TURN CCW
:JUMP START
The following code will make BooBot walk in a square twice. But actually - what it will be doing is walking and turning eight times. The variable COUNT will be initialised to 0, and NUMSIDES to 8 and the loop will only happen while COUNT is not equal to NUMSIDES. COUNT is incremented after each walk. Note for this example JUMPLT could also have been used.
:SET COUNT 0
:SET NUMSIDES 8
START:MOVE
:TURN CCW
:ADD COUNT 1
:COMP COUNT NUMSIDES
:JUMPNEQ START
The following code will make BooBot walk forwards, digging up water on each square. Watch what happens when BooBot tries to dig when there's nothing to dig! Don't forget to copy the map code as well.
Program Code:
START:TESTGROUND
:DIGGROUND
:MOVE
:JUMP START
Map Code (three squares from where BooBot starts and the two in front. Each contains one water):
1,1:1,1
2,1:1,1
3,1:1,1