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.
Number of friendly robots this cell is currently touching.
Number of enemy robots this cell is currently touching.
Number of foods this cell is currently touching.
Number of shots this cell is currently touching.
Number of walls this cell is currently touching.
Variable visible to other robots, for communication.
x y --
A convenient way to set engine-velocity to go toward a location, or stop if close. Typical use: food-position seek-location.
x y vx vy --
Like seek-location, but seeks a moving target. Typical use: robot-position robot-velocity seek-moving-location.
x y walldist -- x y
Move position to stay walldist awy from the walls.
Blows up the robot. Useful for missiles and maybe apoptosis.
value address --
Write value to address in shared memory. Addresses range from 1 to 1000.
value Read value from address in shared memory.
vector address --
Write vector to address and address + 1.
vector Read vector from address and address + 1.
channel -- n
Return the number of messages waiting on the given channel.
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.
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
Skips over (for this cell) all messages currently waiting on the given channel.
Only robot sensor is shown here; the food and shot sensors are identical except where noted.
Time the sensor was last fired.
Number of robots seen. May be more than num-robot-results.
Coordinate location of the active sensor contact
Average position of all robots seen.
Position of sensed robot in relation to the sensor
Distance to robot-position-overall.
Direction of robot-position-overall.
ID, or 0 if neutral.
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.
Only for robots.
Not available for shots.
Not available for shots.
For robots only, the cell's flag variable.
How powerful the shot is. Units depend on the type of shot. Only for shots.
The fraction of damage that will get through the robot's shield. Only for robots.
How large a bomb the robot has. Only for robots.
Whether the robot has fired a weapon lately. Only for robots.
Number of available sensor results.
Current sensor result (0 to num - 1). Writeable.
Whether the sensor will see friendly bots. False by default. Writeable. No equivalent for food.
Whether the sensor will see enemy bots. True by default. Writeable. No equivalent for food.
Results are sorted by distance from the focus, which is (awkwardly) in polar coordinates relative to the robot firing the sensor.
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
period -- fired?
If the sensor hasn't fired in (period - 1) frames, fire it and sync. Return whether we fired.