packages feed

swarm-0.4: data/scenarios/Tutorials/types.yaml

version: 1
name: Types
description: |
  Learn about the Swarm type system.
objectives:
  - goal:
      - The Swarm programming language has a strong static type system.  That is,
        every expression in the language has a type, and all the types must match up
        properly before a program can be executed.
      - To see the type of an expression, enter the expression at the
        REPL prompt (you do not need to execute it).  If the expression type checks,
        its type will be displayed in gray text at the top right of the window.
      - For example, if you try typing `move`, you can see that it has
        type `cmd unit`{=type}, which means that `move` is a command which
        returns a value of the `unit`{=type} type (also written `()`).
      - As another example, you can see that `turn` has type `dir -> cmd unit`{=type},
        meaning that `turn` is a function which takes a direction as input
        and results in a command.
      - "Here are a few more expressions for you to try (feel free to try others as well):"
      - |
        `north`
      - |
        `move; move`
      - |
        `grab`
      - |
        `make`
      - |
        `3`
      - |
        `"tree"`
      - Once you are done experimenting, execute `place "Win"` to finish this challenge and
        move on to the next.
    condition: |
      try {
        w <- as base {has "Win"};
        return (not w);
      } { return false }
entities:
  - name: Win
    display:
      attr: device
      char: 'W'
    description:
      - Do `place "Win"` once you are done with this challenge.
    properties: [known, portable]
solution: |
  place "Win"

robots:
  - name: base
    dir: [1,0]
    devices:
      - treads
      - compass
      - logger
      - grabber
    inventory:
      - [1, Win]
world:
  palette:
    '>': [grass, null, base]
    '.': [grass]
    '┌': [stone, upper left corner]
    '┐': [stone, upper right corner]
    '└': [stone, lower left corner]
    '┘': [stone, lower right corner]
    '─': [stone, horizontal wall]
    '│': [stone, vertical wall]
  upperleft: [-1, 1]
  map: |
    ┌───┐
    │>..│
    │...│
    └───┘