packages feed

swarm-0.7.0.0: data/scenarios/Tutorials/debug.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 closest mountain, crashing deliberately.
      - |
        However, you must make sure it has a `logger`{=entity},
        so we can see the failure in its logs. 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 { turn east; move; move; move; log "brace for impact"; move; }
        ```
      - |
        `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 will
        appear in the crashed robot's log and `give` you an opportunity to `salvage`
        the situation...
    condition: |
      try {
        as base {has "Win"}
      } { pure false }
entities:
  - name: Win
    display:
      attr: device
      char: 'W'
    description:
      - Once the base has this, you win!
    properties: [known, pickable]
solution: |
  crasher <- build {
    turn east; move; move; move; log "brace for impact"; move
  };
  salvager <- build {
    log "I will bring home the Win!"; // This allows log messages to transfer over
    turn right; turn right; turn right; turn right;
    turn east; move; move; move; salvage; turn back; move; move; give base "Win"
  };
robots:
  - name: base
    dir: north
    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: hint
    dir: [0, 0]
    devices:
      - logger
      - hearing aid
      - flash memory
      - dictionary
      - 3D printer
    inventory:
      - [100000, Win]
    display:
      invisible: true
    system: true
    program: |
      run "scenarios/Tutorials/debug-hint.sw"
known: [water, wavy water, tree, mountain]
world:
  palette:
    'Ω': [grass, null, base]
    '!': [dirt, null, hint]
    '.': [grass]
    '_': [ice, water]
    '~': [ice, wavy water]
    'T': [grass, tree]
    'A': [stone, mountain]
    '+': [stone, wall]
  upperleft: [-1, 3]
  map: |
    +++++++++
    +...AAT_+
    +.....A~+
    +Ω..!AAA+
    +.~_...A+
    +~__~...+
    +++++++++