Variable | Meaning
|
---|
time | The time in frames since the simulation started.
|
world-size | Vector: the size of the world.
|
world-width | the width of the world.
|
world-height | the height of the world.
|
position | Vector: current position of this cell.
|
velocity | Vector: current velocity of this cell.
|
radius |
|
mass |
|
speed |
|
side | ID of this side
|
type | ID of this type
|
id | ID of this robot, unique within the side
|
parent-id | ID of this robot's parent, or 0 if it was seeded
|
processor |
|
remaining | Instructions remaining this frame.
|
engine-power | Writable.
|
engine-max-power |
|
engine-velocity | Vector: the velocity the engine will seek.
|
collision | Number of robots or walls this cell is currently touching.
|
friendly-collision | Number of friendly robots this cell is currently touching.
|
enemy-collision | Number of enemy robots this cell is currently touching.
|
food-collision | Number of foods this cell is currently touching.
|
shot-collision | Number of shots this cell is currently touching.
|
wall-collision | Number of walls this cell is currently touching.
|
flag | Variable visible to other robots, for communication.
|
Operator | Stack diagram | Comments
|
---|
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.
|
Only robot sensor is shown here; the food and shot sensors are identical except where noted.
Variable | Meaning
|
---|
robot-sensor-range |
|
robot-sensor-firing-cost |
|
robot-sensor-time | Time the sensor was last fired.
|
robot-found | Number of robots seen. May be more than num-robot-results .
|
robot-position | Vector.
|
robot-velocity | Vector.
|
robot-position-overall | Vector: average position of all robots seen.
|
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). Writable.
|
robot-sensor-sees-friends | Writable boolean: whether the sensor will see friendly robots. 0 by default.
|
robot-sensor-sees-enemies | Writable boolean: whether the sensor will see enemies. 1 by default.
|
shot-sensor-sees-friendly | Shot sensor equivalent to robot-sensor-sees-friends /enemies . There is no equivalent for food sensors.
|
shot-sensor-sees-enemy
|
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
|
Variable | Meaning
|
---|
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 | Writable.
|
force-field-direction | Writable.
|
force-field-power | Current setting. Writable.
|
force-field-angle | Direction the field pushes in. Writable.
|
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.
|