Grobots - Documentation - Hardware Interface

Basics

VariableMeaning
timeThe time in frames since the simulation started.
world-sizeVector: the size of the world.
world-widththe width of the world.
world-heightthe height of the world.
positionVector: current position of this cell.
velocityVector: current velocity of this cell.
radius
mass
speed
sideID of this side
typeID of this type
idID of this robot, unique within the side
parent-idID of this robot's parent, or 0 if it was seeded
processor
remainingInstructions remaining this frame.
engine-powerWritable.
engine-max-power
engine-velocityVector: the velocity the engine will seek.
collisionNumber of robots or walls this cell is currently touching.
friendly-collisionNumber of friendly robots this cell is currently touching.
enemy-collisionNumber of enemy robots this cell is currently touching.
food-collisionNumber of foods this cell is currently touching.
shot-collisionNumber of shots this cell is currently touching.
wall-collisionNumber of walls this cell is currently touching.
flagVariable visible to other robots, for communication.
OperatorStack diagramComments
seek-locationx 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-locationx y vx vy --Like seek-location, but seeks a moving target. Typical use: robot-position robot-velocity seek-moving-location.
restrict-positionx y walldist -- x yMove position to stay walldist awy from the walls.
die--Blows up the robot. Useful for missiles and maybe apoptosis.
writevalue address --Write value to address in shared memory. Addresses range from 1 to 1000.
readaddress -- valueRead value from address in shared memory.
vwritevector address --Write vector to address and address + 1.
vreadaddress -- vectorRead vector from address and address + 1.
messageschannel -- nReturn the number of messages waiting on the given channel.
sendmessage 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 lengthLength 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-messageschannel --Skips over (for this cell) all messages currently waiting on the given channel.
skip-messagesn channel --Skips over up to n messages.
type-populationtype-id -- nreturn the number of cells of the given type.

Energy-related

VariableMeaning
energy
max-energy
solar-cells
eater
eatenhow much food was eaten this frame
syphon-max-rate
syphon-rangeMaximum distance the syphon can reach
syphon-distanceCurrent distance.
syphon-direction
syphon-rateHow fast (and which way) to move energy. Set to zero to turn off the syphon.
syphonedAmount of energy the syphon provided last frame. Negative if energy was given instead of taken.

Constructor

VariableMeaning
constructor-max-rateHow fast the constructor can run.
constructor-rateHow fast the custructor is running.
constructor-typeID of the child's type. Upon birth, this is automatically reset to 0.
constructor-progressHow much energy we've put into the child so far.
constructor-remainingHow much energy is needed to finish the child.
child-idID of the last child created, or 0.
OperatorStack diagramComments
autoconstruct--Turn the constructor on iff we have plenty of energy. Start a new child if necessary.
balance-typefraction 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.

VariableMeaning
robot-sensor-range
robot-sensor-firing-cost
robot-sensor-timeTime the sensor was last fired.
robot-foundNumber of robots seen. May be more than num-robot-results.
robot-positionVector.
robot-velocityVector.
robot-position-overallVector: average position of all robots seen.
robot-distance
robot-direction
robot-distance-overallDistance to robot-position-overall.
robot-direction-overallDirection of robot-position-overall.
robot-sideID, or 0 if neutral.
robot-typeFor 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-idOnly for robots.
robot-radius
robot-massNot available for shots.
robot-energyNot available for shots.
robot-flagFor robots only, the cell's flag variable.
shot-powerHow powerful the shot is. Units depend on the type of shot. Only for shots.
robot-shield-fractionThe fraction of damage that will get through the robot's shield. Only for robots.
robot-bombHow large a bomb the robot has. Only for robots.
robot-reloadingWhether the robot has fired a weapon lately. Only for robots.
num-robot-resultsNumber of available sensor results.
current-robot-resultCurrent sensor result (0 to num - 1). Writable.
robot-sensor-sees-friendsWritable boolean: whether the sensor will see friendly robots. 0 by default.
robot-sensor-sees-enemiesWritable boolean: whether the sensor will see enemies. 1 by default.
shot-sensor-sees-friendlyShot sensor equivalent to robot-sensor-sees-friends/enemies. There is no equivalent for food sensors.
shot-sensor-sees-enemy
robot-sensor-focus-distanceResults are sorted by distance from the focus, which is (awkwardly) in polar coordinates relative to the robot firing the sensor.
robot-sensor-focus-direction
OperatorStack diagramComments
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-sensorperiod -- fired?If the sensor hasn't fired in (period - 1) frames, fire it and sync. Return whether we fired.

Defenses

VariableMeaning
armorArmor remaining.
max-armorMaximum (= initial) armor.
repair-rateCurrent repair power. Writable.
max-repair-rate
shieldShield setting. Writable.
max-shield
shield-fractionFraction of damage that will get through the shield.
last-hitID of the last side that damaged this cell, or 0.

Weapons

VariableMeaning
blaster-damage
blaster-range
blaster-speed
blaster-lifetime
blaster-reload-time
blaster-firing-cost
blaster-cooldownHow many frames before the blaster can fire again.
grenades-damage
grenades-range
grenades-speed
grenades-lifetime
grenades-reload-time
grenades-firing-cost
grenades-cooldownHow many frames before the grenade launcher can fire again.
grenades-radiusThe radius of the explosion the grenade will make.
force-field-max-power
force-field-range
force-field-distanceWritable.
force-field-directionWritable.
force-field-powerCurrent setting. Writable.
force-field-angleDirection the field pushes in. Writable.
force-field-radiusThe radius the forcefield will have at the current power.
enemy-syphon-max-rate
enemy-syphon-rangeMaximum distance the syphon can reach.
enemy-syphon-distanceCurrent distance.
enemy-syphon-direction
enemy-syphon-rateHow fast (and which way) to move energy. Set to zero to turn off the syphon.
enemy-syphonedAmount of energy the syphon provided last frame. Negative if energy was given instead of stolen.
OperatorStack diagramComments
fire-blasterdirection --
fire-grenadedistance direction --
lead-blastertarget-position target-velocity --Fires at a moving target, if the target will still be in range when the shot hits.
lead-grenadetarget-position target-velocity --
set-force-fieldposition angle --Turns the forcefield on at full power at the given location and angle.

Grobots by Devon Schudy and Warren Schudy