swarm-0.7.0.0: data/scenarios/Tutorials/bind2.yaml
version: 1
name: Bind notation
creative: false
description: |
Learn about command return types and how to bind the results.
objectives:
- id: grab_artifact
teaser: Retrieve artifact
goal:
- |
A pedestal stands conspicuously empty in the center of the room.
Perhaps its intended contents lie nearby?
- |
Build a robot to retrieve and restore the mystery artifact to its proper place
in the center of the pedestal!
- |
The robot will need to `place "ARTIFACT NAME"`{=snippet}, but you do not know the name yet!
Fortunatelly, the `grab` command has type `Cmd Text`{=type}, and returns
the name of the grabbed entity as a text value.
- |
To use the result of a command later, you need _bind notation_, which
consists of a variable name and a leftwards-pointing arrow
before the command. Like this:
- |
`move; art <- grab; place art`
- |
**NOTE:** If you find yourself stuck, you can select "Start over" from
the "Quit" (**Ctrl+Q**) dialog.
prerequisite:
not: fail_to_grab
condition: |
try {
teleport self (0,3);
ishere "Hastur"
} { pure false }
- id: fail_to_grab
teaser: Robot stopped
hidden: true
optional: true
goal:
- |
You sent a robot, but it failed to put the artifact in its rightful place.
- |
Try again by selecting "Start over" from the "Quit" (**Ctrl+Q**) dialog.
condition: |
as base {
try {
r <- robotnumbered 1;
reprogram r {};
teleport self (0,3);
h <- ishere "Hastur";
pure (not h)
} {
pure false
}
}
solution: |
build {
move; move;
turn right; move; move;
f <- grab;
turn back; move; move;
turn right; move;
place f
}
entities:
- name: Hastur
display:
attr: gold
char: 'H'
description:
- The Unspeakable One
properties: [pickable]
- name: pedestal
display:
attr: gold
char: '+'
description:
- A stone pedestal.
properties:
- boundary
robots:
- name: base
dir: north
display:
char: Ω
attr: robot
devices:
- 3D printer
- logger
inventory:
- [1, solar panel]
- [1, treads]
- [1, grabber]
- [1, compass]
world:
palette:
'Ω': [stone, null, base]
'.': [blank, null]
'x': [stone, pedestal]
's': [stone, null]
'H': [blank, Hastur]
'+': [stone, wall]
upperleft: [-5, 6]
map: |
+++++++++++
+.........+
+...xxx...+
+...xsx...+
+...xxxH..+
+.........+
+++++Ω+++++
....+++....