swarm-0.7.0.0: data/scenarios/Tutorials/move.yaml
version: 1
name: Moving
description: |
Learn how to move and chain commands.
objectives:
- id: move_to_first_flower
teaser: Get the flower
goal:
- |
Robots can use the `move` command to move forward one unit in the direction they are currently facing.
To complete this challenge, move your robot two spaces to the right, to the coordinates `(2,0)`
marked with the purple `flower`{=entity}.
Note that you can chain commands with semicolon, `;`{=snippet}.
You can open this popup window at any time to remind yourself of the goal using **Ctrl+G**.
condition: |
as base {l <- whereami; pure (l == (2,0))}
- id: move_along_corridor
teaser: Down the corridor
goal:
- |
Good! Now you need to learn how to effectively repeat actions.
Previously you could move twice by chaining the move command:
`move; move`
To reuse that command without having to retype it, press the up arrow on your keyboard.
This will allow you to select previously entered commands.
Ahead of you is a six steps long corridor. Move to its end, i.e. the coordinates `(8,0)` marked
with the second purple `flower`{=entity}.
Note that you do not need to type everything in one go; you
can enter multiple commands, as long as they eventually get
you to the flower.
You can open this popup window at any time to remind yourself of the goal using **Ctrl+G**.
condition: |
as base {l <- whereami; pure (l == (8,0))}
prerequisite: move_to_first_flower
- id: move_northeast_corner
teaser: To northeast corner
goal:
- |
Well done! In addition to `move`, you can use the `turn` command to turn your robot, for example,
`turn right` or (if you have a `compass`{=entity}) `turn east`.
Switch to the inventory view in the upper left (by clicking on it or typing **Alt+E**) and select
the `treads`{=entity} device to read about the details.
If the bottom-left info panel is not big enough to read the whole thing, you can hit **Enter**
on the `treads`{=entity} device to pop out the description, or you can focus the info panel
(with **Alt+T** or by clicking) and scroll it with arrow keys or **PgUp**/**PgDown**.
When you're done reading, you can come back to the REPL prompt by clicking on it or typing **Alt+R**.
Afterwards, move your robot to the coordinates `(8,4)` in the northeast corner marked with another flower.
Remember, you can chain commands with `;`{=snippet}, for example:
`move; move; move; move`
You can open this popup window at any time to remind yourself of the goal using **Ctrl+G**.
condition: |
as base {l <- whereami; pure (l == (8,4))}
prerequisite: move_along_corridor
- goal:
- Good job! You are now ready to move and turn on your own.
- To complete this challenge, move your robot to the northeast corner, to the coordinates `(8,8)` marked with one `flower`{=entity}.
- Remember you can press the upward arrow on your keyboard to select previous commands.
- You can open this popup window at any time to remind yourself of the goal using **Ctrl+G**.
condition: |
as base {l <- whereami; pure (l == (8,8))}
prerequisite: move_northeast_corner
solution: |
// 0
move;move;
// 1
move;move;
move;move;move;move;
// 2
turn left;
move;move;move;move; // go 6 north
// 3
turn left;
move;move;move;move; // go 8 west
move;move;move;move;
turn right;
move;move;move;move; // go 4 north
turn right;
move;move;move;move; // go 8 east
move;move;move;move;
known:
- flower
world:
palette:
'.': [blank]
# FIRST ROOM
'0': [blank, wall]
'A': [blank, flower, check]
# SECOND ROOM
'1': [blank, null, 1P wall]
'B': [blank, null, 1P flower]
# THIRD ROOM
'2': [blank, null, 2P wall]
'C': [blank, null, 2P flower]
# FOURTH ROOM
'3': [blank, null, 3P wall]
'D': [blank, null, 3P flower]
upperleft: [-1, 9]
map: |
33333333333
3........D3
3..33333333
3..3.......
3..33332222
3......2.C2
33333332..2
.......2..2
00000111111
0..A0....B1
00000111111
# Font inspiration and a nicely visible separator:
#
# ███████ ██ ██ █████ ██████ ███ ███
# ██ ██ ██ ██ ██ ██ ██ ████ ████
# ███████ ██ █ ██ ███████ ██████ ██ ████ ██
# ██ ██ ███ ██ ██ ██ ██ ██ ██ ██ ██
# ███████ ███ ███ ██ ██ ██ ██ ██ ██
stepsPerTick: 300
robots:
- name: base
dir: east
loc: [0, 0]
devices:
- treads
- logger
- compass
#################
## OBJECTIVES ##
#################
- name: check
system: true
program: instant (run "scenarios/Tutorials/move_check.sw")
#################
## WALLS ##
#################
- name: 1P wall
system: true
program: |
def main = \a. pure noop end
instant (
run "scenarios/Tutorials/move_surveil.sw";
main [entity="wall", room=1]
)
- name: 2P wall
system: true
program: |
def main = \a. noop end
instant (
run "scenarios/Tutorials/move_surveil.sw";
main [entity="wall", room=2]
)
- name: 3P wall
system: true
program: |
def main = \a. noop end
instant (
run "scenarios/Tutorials/move_surveil.sw";
main [entity="wall", room=3]
)
#################
## GARDENERS ##
#################
- name: 1P flower
system: true
program: |
def main = \a. noop end
instant (
run "scenarios/Tutorials/move_surveil.sw";
main [entity="flower", room=1]
)
- name: 2P flower
system: true
program: |
def main = \a. noop end
instant (
run "scenarios/Tutorials/move_surveil.sw";
main [entity="flower", room=2]
)
- name: 3P flower
system: true
program: |
def main = \a. noop end
instant (
run "scenarios/Tutorials/move_surveil.sw";
main [entity="flower", room=3]
)
entities:
- name: door
display:
char: 'D'
attr: entity
invisible: true
description:
- A wall
properties: [boundary]