This page offers a list of keywords that, in a side file, help you utilize the hardware on your side's bots. Some are recognized as special variables you can use to get a better picture of the environment and your own bot/side. Others are procedures called to use weapons or perform other actions.
Number of robots or walls this cell is currently touching.
friendly-collision
Integer
Number of friendly robots this cell is currently touching.
enemy-collision
Integer
Number of enemy robots this cell is currently touching.
food-collision
Integer
Number of foods this cell is currently touching.
shot-collision
Integer
Number of shots this cell is currently touching.
wall-collision
Integer
Number of walls this cell is currently touching.
flag
Integer
Variable visible to other robots, for communication.
Operator
Stack diagram
Comment
seek-location
x y --
A convenient way to set engine-velocity to go toward a location, or stop if close. Typical use: food-position seek-location.
seek-moving-location
x y vx vy --
Like seek-location, but seeks a moving target. Typical use: robot-position robot-velocity seek-moving-location.
restrict-position
x y walldist -- x y
Move position to stay walldist awy from the walls.
die
--
Blows up the robot. Useful for missiles and maybe apoptosis.
write
value address --
Write value to address in shared memory. Addresses range from 1 to 1000.
read
address --
value Read value from address in shared memory.
vwrite
vector address --
Write vector to address and address + 1.
vread
address --
vector Read vector from address and address + 1.
messages
channel -- n
Return the number of messages waiting on the given channel.
send
message length channel --
A message-passing style communications system. Each of the 10 channels contains a queue of up to 50 messages, each of which can be up to 8 values long. Typical use: food-position time 3 1 send.
receive
channel -- message length
Length returned is zero if no message is available. Length 0 messages are prohibited to avoid confusion. The following code goes to the location specified in the message if the timestamp included in the message is recent. (This assumes that all messages on channel 1 are food-position / time pairs, length in this example is used only to decide if a message was received. Reliable code might want to check to see if the length is as expected): 1 receive if time 50 - > if seek-location else 2drop then then
clear-messages
channel --
Skips over (for this cell) all messages currently waiting on the given channel.
skip-messages
n channel --
Skips over up to n messages.
type-population
type-id -- n
return the number of cells of the given type.
Energy-related[]
Variable
Type
Comment
energy
Integer
How much energy this bot is storing.
max-energy
Integer
The maximum amount of energy that can be stored.
solar-cells
N/A
Constructor.
eater
N/A
Constructor.
eaten
Integer
How much food was eaten this frame.
syphon-max-rate
Integer
The maximum syphon rate.
syphon-range
Integer
The maximum syphon distance.
syphon-distance
Integer
The current syphon distance.
syphon-direction
syphon-rate
Integer
How fast (and which way) to move energy. Set to zero to turn off the syphon.
syphoned
Amount of energy the syphon provided last frame. Negative if energy was given instead of taken.
Constructor[]
Variable
Type
Comment
constructor-max-rate
Integer
How fast the constructor can run.
constructor-rate
Integer
How fast the constructor is running.
constructor-type
Integer
ID of the child's type. Upon birth, this is automatically reset to 0.
constructor-progress
Integer
How much energy we've put into the child so far.
constructor-remaining
Integer
How much energy is needed to finish the child.
child-id
Integer
ID of the last child created, or 0.
Operator
Stack diagram
Comment
autoconstruct
--
Turn the constructor on if we have plenty of energy. Start a new child if necessary.
balance-type
fraction type --
Sets constructor-type if type's fraction of population is less than fraction.
Sensors[]
Only robot sensor is shown here; the food and shot sensors are identical except where noted.
Variable
Type
Comment
robot-sensor-range
robot-sensor-firing-cost
robot-sensor-time
Time the sensor was last fired.
robot-found
Integer
Number of robots seen. May be more than num-robot-results.
robot-position
Vector
Coordinate location of the active sensor contact
robot-velocity
Vector
robot-position-overall
Vector
Average position of all robots seen.
robot-relative-position
Vector
Position of sensed robot in relation to the sensor
robot-distance
robot-direction
robot-distance-overall
Distance to robot-position-overall.
robot-direction-overall
Direction of robot-position-overall.
robot-side
ID, or 0 if neutral.
robot-type
For robots, the type's ID. For shots, 1 = blaster, 2 = grenade, 3 = syphon, 4 = enemy-syphon, 5 = forcefield, 0 otherwise. Not available for food.
robot-id
Only for robots.
robot-radius
robot-mass
Not available for shots.
robot-energy
Not available for shots.
robot-flag
For robots only, the cell's flag variable.
shot-power
How powerful the shot is. Units depend on the type of shot. Only for shots.
robot-shield-fraction
The fraction of damage that will get through the robot's shield. Only for robots.
robot-bomb
How large a bomb the robot has. Only for robots.
robot-reloading
Whether the robot has fired a weapon lately. Only for robots.
num-robot-results
Number of available sensor results.
current-robot-result
Current sensor result (0 to num - 1). Writeable.
robot-sensor-sees-friends
Boolean
Whether the sensor will see friendly bots. False by default. Writeable. No equivalent for food.
robot-sensor-sees-enemies
Boolean
Whether the sensor will see enemy bots. True by default. Writeable. No equivalent for food.
robot-sensor-focus-distance
Results are sorted by distance from the focus, which is (awkwardly) in polar coordinates relative to the robot firing the sensor.
robot-sensor-focus-direction
Operator
Stack diagram
Comment
fire-robot-sensor
--
next-robot
-- success
Advances to the next sensor result. If there are no more results, returns to the first result. Returns 0 if wraparound occured, 1 otherwise. Suggested use: robot-found if do process sensor result next-robot while-loop then
periodic-robot-sensor
period -- fired?
If the sensor hasn't fired in (period - 1) frames, fire it and sync. Return whether we fired.
Defenses[]
Variable
Type
Comment
armor
Armor remaining.
max-armor
Maximum (= initial) armor.
repair-rate
Current repair power. Writeable.
max-repair-rate
shield
Shield setting. Writeable.
max-shield
shield-fraction
Fraction of damage that will get through the shield.
last-hit
ID of the last side that damaged this cell, or 0.
Weapons[]
Variable
Type
Comment
blaster-damage
blaster-range
blaster-speed
blaster-lifetime
blaster-reload-time
blaster-firing-cost
blaster-cooldown
How many frames before the blaster can fire again.
grenades-damage
grenades-range
grenades-speed
grenades-lifetime
grenades-reload-time
grenades-firing-cost
grenades-cooldown
How many frames before the grenade launcher can fire again.
grenades-radius
The radius of the explosion the grenade will make.
force-field-max-power
force-field-range
force-field-distance
Writeable.
force-field-direction
Writeable.
force-field-power
Current setting. Writeable.
force-field-angle
Direction the field pushes in. Writeable.
force-field-radius
The radius the forcefield will have at the current power.
enemy-syphon-max-rate
enemy-syphon-range
Maximum distance the syphon can reach.
enemy-syphon-distance
Current distance.
enemy-syphon-direction
enemy-syphon-rate
How fast (and which way) to move energy. Set to zero to turn off the syphon.
enemy-syphoned
Amount of energy the syphon provided last frame. Negative if energy was given instead of stolen.
Operator
Stack diagram
Comment
fire-blaster
direction --
fire-grenade
distance direction --
lead-blaster
target-position target-velocity --
Fires at a moving target, if the target will still be in range when the shot hits.
lead-grenade
target-position target-velocity --
set-force-field
position angle --
Turns the forcefield on at full power at the given location and angle.