Skip to content

Entities cheat sheet

Brent Yorgey edited this page Apr 25, 2024 · 18 revisions

Note, this page is auto-generated by swarm-docs cheatsheet --entities. If you notice this page is out-of-date, instead of editing it, you can help by regenerating the tables using the most up-to-date swarm executable and pasting the result here!

Entities

This is a quick-overview table of entities - click the name for detailed description.

*) As a note, most entities have the Portable property, so we show it in a separate column.

? Name Capabilities Properties* Portable
T tree Growable ✔️
y branch ✔️
l log ✔️
w board ✔️
π workbench make ✔️
paper ✔️
P PhD thesis ✔️
o rock ✔️
o lodestone negation ✔️
@ boulder Unwalkable
A mountain Unwalkable
Å mountain tunnel
C copper ore ✔️
Å copper mine
| copper wire ✔️
8 strange loop recursion ✔️
I copper pipe ✔️
iron plate ✔️
* iron gear ✔️
F iron ore ✔️
Å iron mine
Q quartz ✔️
Å quartz mine
S silicon ✔️
Å deep mine
silver ✔️
gold ✔️
M mithril ✔️
# furnace ✔️
# big furnace ✔️
m small motor ✔️
M big motor ✔️
* flower Growable ✔️
i cotton Growable ✔️
~ string text ✔️
λ lambda lambda Growable ✔️
C curry ✔️
water Infinite, Liquid ✔️
~ wavy water Infinite, Liquid ✔️
B boat float ✔️
sand Infinite ✔️
glass ✔️
$ LaTeX Growable ✔️
% rubber ✔️
0 bit (0) Growable ✔️
1 bit (1) Growable ✔️
. pixel (R) Growable ✔️
. pixel (G) Growable ✔️
. pixel (B) Growable ✔️
@ camera ✔️
# circuit ✔️
! drill bit ✔️
box ✔️
* wooden gear ✔️
/ teeter-totter ✔️
L Linux ✔️
© gold coin ✔️
upper left corner Unwalkable, Known
upper right corner Unwalkable, Known
lower left corner Unwalkable, Known
lower right corner Unwalkable, Known
down and horizontal wall Unwalkable, Known
up and horizontal wall Unwalkable, Known
left and vertical wall Unwalkable, Known
right and vertical wall Unwalkable, Known
horizontal wall Unwalkable, Known
vertical wall Unwalkable, Known
bitcoin random ✔️
% treads move, turn ✔️
% tank treads move, turn, moveheavy ✔️
< grabber grab, give, place, install ✔️
fast grabber grab, swap, give, place, install, atomic ✔️
harvester grab, harvest, place ✔️
Ѣ toolkit salvage ✔️
# solar panel power ✔️
! drill drill ✔️
! metal drill drill ✔️
Д typewriter ✔️
3 3D printer build ✔️
D dictionary env ✔️
y branch predictor cond ✔️
* detonator selfdestruct ✔️
Ж life support system ✔️
$ scanner scan, sensefront, sensehere ✔️
§ flash memory reprogram ✔️
U mirror whoami ✔️
l logger log ✔️
@ hearing aid listen ✔️
C counter count ✔️
+ calculator arith ✔️
± ADT calculator arith, sum, prod ✔️
N compass orient ✔️
0 clock time ✔️
> comparator compare ✔️
Ю I/O cable ✔️
O rubber band atomic ✔️
# net try ✔️

tree

  • Char: T
  • Properties: Portable, Growable

A tall, living entity made of a tough cellular material called "wood". They regrow after being harvested and are an important raw ingredient used in making many different devices.

branch

  • Char: y
  • Properties: Portable

A branch cut from a tree. It's as if the tree had to make a decision and was exploring two options.

log

  • Char: l
  • Properties: Portable

A wooden log, obtained by harvesting a tree and cutting off its branches.

board

  • Char: w
  • Properties: Portable

A wooden board, made by cutting a log into pieces.

workbench

  • Char: π
  • Properties: Portable
  • Capabilities: make

A plain wooden workbench, providing space to make other things using the make command.

Example:

make "log"

paper

  • Char:
  • Properties: Portable

A flat material made of pressed and dried wood fibers, used as a surface on which to inscribe symbols.

PhD thesis

  • Char: P
  • Properties: Portable

Perhaps writing one of these will help gain the trust and respect of the native inhabitants.

rock

  • Char: o
  • Properties: Portable

A medium-sized rock, picked up from the ground or created by drilling. Can be used to build a simple furnace, among other things.

lodestone

  • Char: o
  • Properties: Portable
  • Capabilities: negation

A medium-sized rock... that looks a little different. It seems to react to iron and surprisingly also to naturally growing bits.

boulder

  • Char: @
  • Properties: Unwalkable

A very large, impassable rock. A drill can be used to get rid of it and turn it into smaller rocks.

mountain

  • Char: A
  • Properties: Unwalkable

A mountain. Can be tunneled through with a drill, but it takes time.

mountain tunnel

  • Char: Å

A tunnel in a mountain through which robots can freely move.

copper ore

  • Char: C
  • Properties: Portable

Raw copper ore, useful for making wires, pipes, and other metal things. Patches of copper ore can be found on the surface, but are quickly exhausted.

Scanners seem to indicate larger quantities of copper could be found beneath some of the mountains, but those would require a drill to access and mine.

copper mine

  • Char: Å

A copper vein that can be actively mined to produce copper ore.

copper wire

  • Char: |
  • Properties: Portable

Copper wire is very good at conducting electricity and useful for making various types of circuits and machines.

strange loop

  • Char: 8
  • Properties: Portable
  • Capabilities: recursion

Two copper wires twisted together in a strange shape that loops back on itself. It must be useful for something...

copper pipe

  • Char: I
  • Properties: Portable

A pipe made out of a thin sheet of copper. Great for transmitting water or steam.

iron plate

  • Char:
  • Properties: Portable

Worked iron suitable for crafting resilient tools.

It also possess some electro-magnetic properties.

iron gear

  • Char: *
  • Properties: Portable

An iron gear, suitable for constructing larger, more powerful machinery than a wooden gear.

iron ore

  • Char: F
  • Properties: Portable

Raw iron ore. Used to create more resilient tools than copper.

It can only be mined by drilling in the mountains.

iron mine

  • Char: Å

An iron vein that can be actively mined to produce iron ore.

quartz

  • Char: Q
  • Properties: Portable

Raw quartz crystals. Useful for creating devices like clocks, and can be processed to extract silicon.

It can only be mined by drilling in the mountains.

quartz mine

  • Char: Å

A quartz vein that can be actively mined to produce quartz.

silicon

  • Char: S
  • Properties: Portable

Extracted by processing quartz at high temperatures, silicon can be used to construct integrated circuits.

deep mine

  • Char: Å

A deep mine that yields rare and wonderful treasures to those who are patient.

But be careful lest you delve too greedily and too deep.

silver

  • Char:
  • Properties: Portable

A shiny, metallic substance, noted for its high reflectivity when polished.

gold

  • Char:
  • Properties: Portable

A shiny, metallic substance, with applications in specialized electronics.

It also seems to be highly valued by local aliens.

mithril

  • Char: M
  • Properties: Portable

Mithril can be beaten like copper, and polished like glass. One can also make of it a metal, light and yet harder than tempered steel. Its beauty is like to that of common silver, but the beauty of mithril does not tarnish or grow dim.

furnace

  • Char: #
  • Properties: Portable

A furnace can be used to turn metal ore into various useful products.

big furnace

  • Char: #
  • Properties: Portable

A big furnace can get even hotter than a normal furnace, and can be used to process quartz into silicon.

small motor

  • Char: m
  • Properties: Portable

A motor is useful for making devices that can turn when electric current is applied.

This one is rather small, but surprisingly efficient.

big motor

  • Char: M
  • Properties: Portable

A motor is useful for making devices that can turn when electric current is applied.

This one is huge and could be used to construct powerful machinery.

flower

  • Char: *
  • Properties: Portable, Growable

A beautiful flower that grows wild in local meadows. It is not clear what it might be useful for, but it looks nice.

cotton

  • Char: i
  • Properties: Portable, Growable

A plant with tufts of soft fibers that can be harvested and used to make things, including sheets of material that the local aliens like to drape over their bodies.

string

  • Char: ~
  • Properties: Portable
  • Capabilities: text

A long, flexible device for transferring either force or information, made of twisted cotton fibers. Multiple strings can also be woven into larger configurations such as cloth or nets.

A string device enables two commands: the first, format : a -> text, can turn any value into a suitable text representation. The second is the infix operator ++ : text -> text -> text which can be used to concatenate two text values. For example,

"Number of widgets: " ++ format numWidgets

lambda

  • Char: λ
  • Properties: Portable, Growable
  • Capabilities: lambda

A wild lambda. They are somewhat rare, but regrow when picked. Lambdas are delicious when cooked into curry.

Lambdas can also be used to create functions. For example,

def thrice : cmd unit -> cmd unit = \c. c;c;c end

defines the function thrice which repeats a command three times.

curry

  • Char: C
  • Properties: Portable

Delicious curry cooked from wild lambdas.

water

  • Char:
  • Properties: Portable, Infinite, Liquid

Liquid dihydrogen monoxide, which seems to be plentiful on this planet.

wavy water

  • Char: ~
  • Properties: Portable, Infinite, Liquid

A wavy section of water. The same as normal water, but with more waves.

boat

  • Char: B
  • Properties: Portable
  • Capabilities: float

A robot with a boat installed can float on top of water without drowning.

Note: most devices are automatically installed on robots that will require them; but this doesn't work in the case of boats since floating is not associated with any particular command. To manually ensure a boat is installed on a robot, just add the special command require "boat" to the robot's program.

sand

  • Char:
  • Properties: Portable, Infinite

A substance composed mostly of tiny rocks and mineral particles. It tends to be found near water, and can be used in a furnace to make glass.

glass

  • Char:
  • Properties: Portable

A pane of a brittle, clear substance, made from melting sand in a furnace.

LaTeX

  • Char: $
  • Properties: Portable, Growable

A naturally occurring substance derived from trees, useful for producing rubber and for typesetting mathematical documents.

rubber

  • Char: %
  • Properties: Portable

A flexible, durable material made from LaTeX.

bit (0)

  • Char: 0
  • Properties: Portable, Growable

A bit is used to represent the smallest possible amount of information. Useful for constructing various information-processing devices, as well as drills.

bit (1)

  • Char: 1
  • Properties: Portable, Growable

A bit is used to represent the smallest possible amount of information. Useful for constructing various information-processing devices, as well as drills.

pixel (R)

  • Char: .
  • Properties: Portable, Growable

A tiny picture element, used either to emit or detect red light.

pixel (G)

  • Char: .
  • Properties: Portable, Growable

A tiny picture element, used either to emit or detect green light.

pixel (B)

  • Char: .
  • Properties: Portable, Growable

A tiny picture element, used either to emit or detect blue light.

camera

  • Char: @
  • Properties: Portable

A camera is a device for capturing images.

circuit

  • Char: #
  • Properties: Portable

A circuit is needed for constructing various "smart" devices.

drill bit

  • Char: !
  • Properties: Portable

A drill bit is the most important component of a drill, and must be made out of two bits of opposite parity, for strength.

box

  • Char:
  • Properties: Portable

A wooden box. It can hold things or be used as housing for other devices.

wooden gear

  • Char: *
  • Properties: Portable

A wooden gear. Not quite as strong or versatile as an iron gear, but easy to produce.

teeter-totter

  • Char: /
  • Properties: Portable

A rotating board apparently popular with young aliens. Perhaps it could also be used as a primitive balance scale.

Linux

  • Char: L
  • Properties: Portable

A copy of the Linux operating system.

gold coin

  • Char: ©
  • Properties: Portable

A small round shaped piece of gold metal that the aliens pass between each other occasionaly.

Besides staying shiny it does not appear to have practical use.

upper left corner

  • Char:
  • Properties: Unwalkable, Known

Upper left corner.

upper right corner

  • Char:
  • Properties: Unwalkable, Known

An upper right corner wall.

lower left corner

  • Char:
  • Properties: Unwalkable, Known

A lower left corner wall.

lower right corner

  • Char:
  • Properties: Unwalkable, Known

A lower right corner wall.

down and horizontal wall

  • Char:
  • Properties: Unwalkable, Known

A down and horizontal wall.

up and horizontal wall

  • Char:
  • Properties: Unwalkable, Known

A up and horizontal wall.

left and vertical wall

  • Char:
  • Properties: Unwalkable, Known

A left and vertical wall.

right and vertical wall

  • Char:
  • Properties: Unwalkable, Known

A right and vertical wall.

horizontal wall

  • Char:
  • Properties: Unwalkable, Known

A horizontal wall.

vertical wall

  • Char:
  • Properties: Unwalkable, Known

A vertical wall.

bitcoin

  • Char:
  • Properties: Portable
  • Capabilities: random

A beautiful round shaped piece of metal that seems to be of great value to the aliens on this planet.

Just like the bit it has two sides and when you flip it, it lands perfectly randomly on one of the sides.

treads

  • Char: %
  • Properties: Portable
  • Capabilities: move, turn

Installing treads on a robot allows it to move and turn.

The move command moves the robot forward one unit.

Example:

move; move; // move two units

The turn command takes a direction as an argument, which can be either absolute (north, west, east, south) or relative (left, right, forward, back, down).

Example:

move; turn left; move; turn right

tank treads

  • Char: %
  • Properties: Portable
  • Capabilities: move, turn, moveheavy

Tank treads work like treads, but are large enough to move even heavy robots around.

grabber

  • Char: <
  • Properties: Portable
  • Capabilities: grab, give, place, install

A grabber arm is an all-purpose, hydraulically controlled device that can manipulate other items and robots via the grab, place, give, and install commands.

The grab command takes no arguments; it simply grabs whatever is available, and also returns the name of the grabbed thing as a string. It raises an exception if run in a cell that does not contain an item.

The place command takes one argument, the name of the item to place. The item is removed from the robot's inventory and placed in the robot's current cell (which must be empty). Raises an exception if the operation fails.

The give command takes two arguments: the robot to give an item to (which can be at most 1 cell away), and the name of the item to give. Raises an exception if the operation fails.

The install command takes two arguments: the robot on which to install a device (which can be at most 1 cell away), and the name of the device to install.

fast grabber

  • Char:
  • Properties: Portable
  • Capabilities: grab, swap, give, place, install, atomic

A fast grabber is an improved version of the basic grabber - not only can it 'grab', 'place', 'give', and 'install', it can also 'swap'.

The 'swap' command allows the robot to execute grab and place at the same time so that the location where the robot is standing does not become empty.

You can use this to prevent failures where multiple robots are trying to grab, place or scan a given location.

In addition you retain the capability to use the 'atomic' command, with which you can implement other commands that are safe when run in parallel.

harvester

  • Char:
  • Properties: Portable
  • Capabilities: grab, harvest, place

A harvester can be used via the harvest command, which is almost identical to the grab command. The big difference is that some entities, when harvested instead of grabbed, leave behind a seed which will eventually grow into another copy of the original entity.

For entities which do not grow, harvest behaves exactly the same as grab.

toolkit

  • Char: Ѣ
  • Properties: Portable
  • Capabilities: salvage

A toolkit can be used, via the salvage command, to take apart old robots.

salvage takes no arguments. It looks for an inactive robot (one which is not currently running a program) in the current cell. If an inactive robot is found, its log (if any) is downloaded and it is dismantled, transferring its knowledge, devices, and inventory to the robot running salvage. If no inactive robots are found in the current cell, salvage does nothing.

solar panel

  • Char: #
  • Properties: Portable
  • Capabilities: power

An extremely efficient solar panel, capable of generating sufficient power from ambient starlight alone. A robot powered by one of these can operate any time, including on cloudy days and at night.

drill

  • Char: !
  • Properties: Portable
  • Capabilities: drill

A drill allows robots to drill through rocks and mountains, and extract resources from mines.

metal drill

  • Char: !
  • Properties: Portable
  • Capabilities: drill

A metal drill allows robots to drill through rocks and mountains, and extract resources from mines, faster than a regular drill.

A metal drill is also able to drill deeper than a regular drill. Thus, some resources are only reachable using a metal drill.

typewriter

  • Char: Д
  • Properties: Portable

A typewriter is used to inscribe symbols on paper, thus reifying pure, platonic information into a physical form.

3D printer

  • Char: 3
  • Properties: Portable
  • Capabilities: build

A 3D printer gives you the capability of printing more robots! You can access the 3D printer via the build command.

Example:

build {move; grab; turn back; move; give base "tree"}

builds a robot to get the tree on the cell to the north (if there is one) and bring it back to the base. The build command always returns a reference to the newly constructed robot. For example,

r <- build {move}; view r

builds a robot and then views it.

dictionary

  • Char: D
  • Properties: Portable
  • Capabilities: env

A dictionary allows a robot to remember definitions and reuse them later. You can access this ability with either a def command, which creates a name for an expression or command that is available from then on, or with a let expression, which names an expression or command locally within another expression.

def m2 : cmd unit = move; move end

let x : int = 3 in x^2 + 2*x + 1

The type annotations in def and let are optional.

branch predictor

  • Char: y
  • Properties: Portable
  • Capabilities: cond

A branch predictor is a device which allows a robot to interpret conditional expressions. The syntax for a conditional expression is if followed by three arguments: a boolean test and then two delayed expressions (i.e. expressions in curly braces) of the same type.

Example:

if (x > 3) {move} {turn right; move}

detonator

  • Char: *
  • Properties: Portable
  • Capabilities: selfdestruct

An explosive device which can be used to self-destruct, via the selfdestruct command. Immediately vaporizes the robot and any inventory it is carrying. Can be useful, say, if you are sending out some exploratory robots and don't want them cluttering up the world once they are done.

life support system

  • Char: Ж
  • Properties: Portable

A state-of-the-art life support system which maintains the particular temperature and mixture of gases you need to survive. It uses a sophisticated recirculating system and can run pretty much indefinitely. Unfortunately, the atmosphere outside is severely toxic (why do the inhabitants of this planet need so much nitrogen!?), so you'll have to stay inside for now.

scanner

  • Char: $
  • Properties: Portable
  • Capabilities: scan, sensefront, sensehere

With a scanner device, robots can use the scan command to learn about their surroundings. Simply give scan a direction in which to scan, and information about the scanned item (if any) will be added to the robot's inventory.

A scanner also enables the blocked command, which returns a boolean value indicating whether the robot's path is blocked (i.e. whether executing a move command would fail).

Finally, robots can use the upload command to copy their accumulated knowledge to another nearby robot; for example, upload base.

flash memory

  • Char: §
  • Properties: Portable
  • Capabilities: reprogram

A compact, non-volatile memory device, capable of storing up to 8 pZ of data.

Flash memory can be used as a component of other devices. In addition, a flash memory device can be used to reprogram other robots using the reprogram command.

The robot being reprogrammed must be idle, and must possess enough capabilities to run the new command; otherwise reprogramming will fail.

mirror

  • Char: U
  • Properties: Portable
  • Capabilities: whoami

With a mirror, robots can reflect on themselves and see their own name.

A mirror enables the whoami command, which returns the robot's name as a string.

It also enables the special self variable, which gives a robot a reference to itself.

logger

  • Char: l
  • Properties: Portable
  • Capabilities: log

Allows a robot to generate and store messages for later viewing, using the log command, which takes a string. Log messages are also automatically generated by uncaught exceptions.

hearing aid

  • Char: @
  • Properties: Portable
  • Capabilities: listen

Allows a robot to hear what nearby robots are saying.

Simply having this device installed will automatically add messages said by nearby robots to this robot's log, assuming it has a logger installed.

That way you can view any heard message later either in the logger or the message window.

To wait for a message and get the string value, use:

l <- listen; log $ "I have waited for someone to say " ++ l

counter

  • Char: C
  • Properties: Portable
  • Capabilities: count

A counter enables the command count : string -> cmd int, which counts how many occurrences of an entity are currently in the inventory. This is an upgraded version of the has command, which returns a bool instead of an int and does not require any special device.

calculator

  • Char: +
  • Properties: Portable
  • Capabilities: arith

A calculator allows a robot to do basic arithmetic calculations: addition, subtraction, multiplication, division, and exponentiation.

ADT calculator

  • Char: ±
  • Properties: Portable
  • Capabilities: arith, sum, prod

A calculator with Advanced Display Technology (an attached typewriter that can print out the results). For some reason, in addition to the usual arithmetic on numbers, an ADT calculator can also do arithmetic on types! After all, the helpful typewritten manual explains, a type is just a collection of values, and a finite collection of values is just a fancy number. For example, the type bool is just a fancy version of the number 2, where the two things happen to be labelled false and true.

The product of two types is a type of pairs, since, for example, if t is a type with three elements, then there are 2 * 3 = 6 different pairs containing a bool and a t, that is, 6 elements of type bool * t. For working with products of types, the ADT calculator enables pair syntax (a, b) as well as the projection functions fst : a * b -> a and snd : a * b -> b.

The sum of two types is a type with two options; for example, a value of type bool + t is either a bool value or a t value, and there are 2 + 3 = 5 such values. For working with sums of types, the ADT calculator provides the injection functions inl : a -> a + b and inr : b -> a + b, as well as the case analysis function case : (a + b) -> (a -> c) -> (b -> c) -> c. For example, case (inl 3) (\x. 2*x) (\y. 3*y) == 6, and case (inr 3) (\x. 2*x) (\y. 3*y) == 9.

compass

  • Char: N
  • Properties: Portable
  • Capabilities: orient

A compass gives a robot the ability to orient using cardinal directions: north, south, west, and east.

Example:

turn west; move; turn north

clock

  • Char: 0
  • Properties: Portable
  • Capabilities: time

A clock is a device for keeping track of time. It enables the wait and time commands.

time : cmd int returns the current time, measured in game ticks since the beginning of the game.

wait : int -> cmd unit causes a robot to sleep for a specified amount of time (measured in game ticks).

comparator

  • Char: >
  • Properties: Portable
  • Capabilities: compare

A comparator allows comparing two values to see whether the first is less, equal, or greater than the second.

Valid comparison operators are <, <=, >, >=, ==, and !=.

I/O cable

  • Char: Ю
  • Properties: Portable

An I/O cable can be used to communicate with an adjacent robot.

rubber band

  • Char: O
  • Properties: Portable
  • Capabilities: atomic

A rubber band can tie multiple commands together so that other robots can't execute commands in between them. It can be used via the atomic command. For example, suppose robot A executes the following code:

b <- ishere "rock"; if b {grab} {}

This seems like a safe way to execute grab only when there is a rock to grab. However, it is actually possible for the grab to fail, if some other robot B snatches the rock right after robot A sensed it and before robot A got around to grab it on the next game tick.

This will make robot A very sad and it will crash.

To prevent this situation, robot A can wrap the commands in atomic, like so:

atomic (b <- ishere "rock"; if b {grab} {})

net

  • Char: #
  • Properties: Portable
  • Capabilities: try

A net is a device woven out of many strings. With a net installed, you can use the try command to catch errors. For example,

try {move} {turn left}

will attempt to move, but if that fails, turn left instead.