swarm-0.7.0.0: data/scenarios/Tutorials/require.yaml
version: 1
name: Require devices
description: |
Learn how to require additional devices that would otherwise not be equipped.
objectives:
- goal:
- |
The `build` command automatically equips devices on the newly built robot that it knows will be required.
For example, if you `build {move}`, some `treads`{=entity} will automatically be equipped on the new robot
since it needs them to `move`.
- |
However, sometimes you need a device but `build` can't tell that you need it.
In this case, you can use the special `require`{=snippet} command to require a particular device.
For example, if you run:
```
build {require "boat"; move}
```
Then a `boat`{=entity} will be equipped on the new robot in addition to `treads`{=entity}.
- |
Unlike other devices used so far in the tutorial, `boat`{=entity} does not provide any commands,
but robots that have it equipped will not drown in the `water`{=entity}.
- |
Your goal is to pick a flower on the other side of the river and bring it back to your base.
You win when the base has a `periwinkle`{=entity} flower in its inventory.
- |
**TIP:** To see what the `build` command will equip, you can type `requirements <e>`{=snippet}
where `<e>`{=snippet} is any expression.
condition: |
try {
as base {has "periwinkle"}
} { pure false }
entities:
- name: periwinkle
display:
attr: flower
char: '*'
description:
- A flower.
properties: [known, infinite, pickable]
# The player has just done the lambda tutorial, so this neat version is available:
solution: |
def x5 = \c. c;c;c;c;c end;
build {
require "boat";
turn right; x5 move; f <- grab;
turn back; x5 move; give base f
}
robots:
- name: base
heavy: true
dir: north
display:
char: Ω
attr: robot
devices:
- logger
- 3D printer
- dictionary
inventory:
- [10, solar panel]
- [10, logger]
- [10, treads]
- [10, boat]
- [10, grabber]
- [10, scanner]
- [10, compass]
- [10, lambda]
known: [water, wavy water]
world:
palette:
'Ω': [grass, null, base]
'.': [grass]
'_': [ice, water]
'~': [ice, wavy water]
'*': [grass, periwinkle]
'+': [stone, wall]
upperleft: [-1, 3]
map: |
++++++++
+..~_..+
+.._~..+
+Ω.__.*+
+..~_..+
+.._~..+
++++++++