swarm-0.4: data/scenarios/Tutorials/crash.yaml
version: 1
name: Debug
description: |
Learn how to view built robots and debug them.
objectives:
- goal:
- Before you send your robots far away from the `base` you need to learn how
to figure out what went wrong with them if they crash.
- |
In this challenge, you should start by
sending a robot to walk four steps straight east into the mountain,
crashing deliberately. However, you must make sure it has a `logger`{=entity},
so we can see what command failed. The simplest way to ensure
that is to have it execute the `log` command; `build` will
ensure it has the devices it needs to execute its commands.
For example:
- |
```
build {log "Hi!"; turn east; move; move; move; log "3"; move; log "OK"}
```
- |
`wait` for the robot to crash, then execute `view it0`{=snippet} (or whichever
`itN`{=snippet} variable corresponds to the result of the `build`
command) to see how far it got. Further instructions should
appear in the crashed robot's log and `give` you an opportunity to `salvage`
the situation...
condition: |
try {
as base {has "Win"}
} { return false }
entities:
- name: Win
display:
attr: device
char: 'W'
description:
- If you have this, you win!
properties: [known, portable]
solution: |
crasher <- build {
turn east; move; move; move; log "bye"; move
};
wait 32;
salvager <- build {
log "I will bring home the Win!";
turn east; move; move; move; salvage; turn back; move; move; give base "Win"
};
robots:
- name: base
dir: [0,1]
heavy: true
display:
char: Ω
attr: robot
devices:
- logger
- 3D printer
- clock
inventory:
- [10, logger]
- [10, compass]
- [10, scanner]
- [10, toolkit]
- [10, solar panel]
- [10, treads]
- [10, grabber]
- name: secret
dir: [0, 0]
devices:
- logger
- flash memory
- dictionary
- 3D printer
inventory:
- [100000, Win]
display:
invisible: true
system: true
program: |
run "scenarios/Tutorials/crash-secret.sw"
known: [water, tree, mountain]
world:
palette:
'Ω': [grass, null, base]
'!': [grass, null, secret]
'.': [grass]
'~': [ice, water]
'T': [grass, tree]
'A': [stone, mountain]
'┌': [stone, upper left corner]
'┐': [stone, upper right corner]
'└': [stone, lower left corner]
'┘': [stone, lower right corner]
'─': [stone, horizontal wall]
'│': [stone, vertical wall]
upperleft: [-1, 3]
map: |
┌─────┐
│AAAT~│
│..A.~│
│Ω..!A│
└─────┘