BooBot Programming Guide

This guide will fall into three sections. An overview, a language reference, and a series of short walk-throughs.

Overview

To program BooBot you need to use the program page and follow these simple instructions:

  1. Type code in the code box.
  2. Type/paste a map into the map box.
  3. Load BooBot and hit "Get ID". Copy the six-digit id into the ID box on the program page.
  4. Hit Save to Server.
  5. On BooBot, hit "Get Code".
  6. On BooBot, hit Run.
  7. Return to (1) and fix everything you did wrong. Note you can keep the same ID for as long as BooBot is open.

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.

Language Reference

CommandOperandsDescription
MOVENoneMoves the bot forward one square.
TURNDirection Direction is either CW or CCW (clockwise or counter-clockwise).
SETVariableName & ValueCreates a new variable with the given name and sets it to value. Value must be an integer.
ADDVariableName & ValueAdds value (an integer) to the given variable.
COMPVariableNameA & VariableNameBCompares 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.
JUMPLabelJumps execution to the line of code identified by label.
JUMPEQLabel/td>Jumps execution to the line of code identified by label IF the last COMP command resulted in the EQUAL flag being set.
JUMPNEQLabelJumps execution to the line of code identified by label IF the last COMP command resulted in the INEQUAL flag being set.
JUMPGTLabelJumps 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).
JUMPLTLabelJumps 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).
TESTGROUNDNoneTests 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.
DIGGROUNDNoneAttempts 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

Walk Throughs

1: Walk forwards and turn a bit

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

2: Walk in circles

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

3: Walk in circles - but only twice

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

4: Dig up some water

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