packages feed

swarm-0.7.0.0: data/scenarios/Fun/horton.yaml

version: 1
name: Horton's Field
author: Karl Ostmo
seed: 1
description: |
  Horton picks all of the flowers
creative: false
objectives:
  - goal:
      - |
        Pluck every flower.
    condition: |
      as base {
        flowerCount <- count "flower";
        pure $ flowerCount >= 399;
      }
robots:
  - name: Horton
    dir: north
    devices:
      - ADT calculator
      - branch predictor
      - comparator
      - compass
      - dictionary
      - grabber
      - hourglass
      - clock
      - lambda
      - logger
      - net
      - scanner
      - strange loop
      - treads
      - wayfinder
solution: |
  def goDir = \f. \result.
    match result \d. \_.
    if (d == down) {grab; f;} {turn d; move; f;}
    end;

  def followRoute =
      nextDir <- path (inL ()) (inR "flower");
      case nextDir pure $ goDir followRoute;
      end;

  followRoute;
entities:
  - name: wayfinder
    display:
      char: 'w'
    description:
      - |
        Enables the `path` command:
      - |
        `path : (Unit + Int) -> ((Int * Int) + Text) -> Cmd (Unit + (Dir * Int))`
      - |
        Optionally supply a distance limit as the first argument, and
        supply either a location (`inL`) or an entity (`inR`) as the second argument.
      - |
        Example:
      - |
        `path (inL ()) (inR "tree");`
      - If a path exists, returns the direction to proceed along.
    properties: [known, pickable]
    capabilities: [path]
known: [water, boulder, flower]
world:
  dsl: |
    let
      cl  = perlin seed 4 0.08 0.5,
      patch = cl > 0.0,
      prize = cl < -0.8
    in
      overlay
      [ {dirt}
      , mask (patch) {boulder}
      , mask (prize) {flower}
      , mask (x < -80 || x > 80 || y < -60 || y > 60) (overlay [{water}])
      ]
  upperleft: [-4, 4]
  palette:
    'B': [grass, erase, Horton]
    '.': [grass, erase]
    'x': [blank]
  map: |
    xxx...xxx
    x.......x
    x.......x
    .........
    ....B....
    .........
    x.......x
    x.......x
    xxx...xxx