packages feed

swarm-0.7.0.0: data/scenarios/Challenges/Ranching/fishing.yaml

version: 1
name: Responsible Fishing
author: Karl Ostmo
description: |
  Catch the appropriate seafood to make lunch.

  If you haul any trash out of the lake, you
  must throw it away in the enclosures to the southeast.
  No littering!
creative: false
seed: 0
attrs:
  - name: shark
    bg: "#2040bb"
objectives:
  - teaser: Hot rod
    goal:
      - |
        `equip` your `fishing tackle`{=entity}, i.e. a rod and its accoutrements.
    condition: |
      as base {
        equipped "fishing tackle";
      }
  - teaser: Sushi chain
    id: lots_of_sushi
    goal:
      - |
        Make 16 `california roll`{=entity}s
    condition: |
      as base {
        rollCount <- count "california roll";
        pure $ rollCount >= 16;
      }
    prerequisite: made_sushi
  - teaser: Sushi chef
    id: made_sushi
    goal:
      - |
        Make a `california roll`{=entity}
    condition: |
      as base {
        has "california roll"
      }
  - teaser: Waste disposal
    prerequisite:
      logic:
        and:
          - lots_of_sushi
          - not: littered
    goal:
      - |
        Inventory must be free of all `junk`{=tag}.
      - |
        Dispose of `junk`{=tag} only in designated `rubbish enclosure`{=structure}s.
      - |
        Certain items can be burned to make room.
        Good thing you brought your `torch`{=entity}!
      - |
        Otherwise, when the enclosure becomes full, the trash
        hauler will come to empty it.
    condition: |
      def hasAny : (rec l. Unit + Text * l) -> Cmd Bool = \items.
        case items
          (\_. pure false)
          (\c. match c \hd. \tl. b <- has hd; if b {pure true} {hasAny tl})
      end;

      let prohibited = tagmembers "junk" in
      h <- hasAny prohibited; pure (not h)
  - teaser: No littering
    id: littered
    hidden: true
    optional: true
    goal:
      - |
        You may dispose of `junk`{=tag} only in either of the designated `rubbish enclosure`{=structure}s.
      - |
        Note that certain items can be burned with a `torch`{=entity} to make room.
    condition: |
      def λmatch = \f. \p. match p f end
      def λcase = \f. \g. \s. case s f g end

      def locIsInsideEnclosure =
        λmatch \locx. \locy.
        λmatch \dimx. \dimy.
        λmatch \boxx. \boxy.
        pure $ locy >= boxy
          && locy < dimy + boxy
          && locx >= boxx
          && locx < dimx + boxx;
        end;

      def junkOutsideEnclosure =
        result <- scan down;
        case result (\_. pure false) (\item.
          let isJunk = hastag item "junk" in
          if isJunk {
            enclosures <- structures "rubbish enclosure";

            case enclosures (\_. pure false) (
              λmatch \enclosure0.
              λcase (\_. pure false) (
                λmatch \enclosure1. \_.

                dims <- floorplan "rubbish enclosure";
                loc <- whereami;

                insideFirst <- locIsInsideEnclosure loc dims enclosure0;
                insideSecond <- locIsInsideEnclosure loc dims enclosure1;
                pure $ not $ insideFirst || insideSecond;
              )
            )
          } {
            pure false;
          };
        );
        end;

      // If a junk entity was placed on the ground,
      // it will be in the same cell as the base robot.
      as base {
        junkOutsideEnclosure;
      }
robots:
  - name: base
    dir: [1, 0]
    devices:
      - branch predictor
      - ADT calculator
      - hourglass
      - comparator
      - compass
      - dictionary
      - grabber
      - harvester
      - keyboard
      - lambda
      - logger
      - net
      - pawn star
      - rolex
      - scanner
      - strange loop
      - torch
      - treads
      - welder
      - workbench
    inventory:
      - [1, branch]
      - [1, string]
      - [1, fish hook]
      - [1, lead weight]
  - name: hauler
    dir: [1, 0]
    system: true
    display:
      char: W
      invisible: false
    program: |
      run "scenarios/Challenges/Ranching/_fishing/hauler.sw"
  - name: shark
    dir: [1, 0]
    system: true
    display:
      char: ' '
      attr: shark
      invisible: false
    program: |
      run "scenarios/Challenges/Ranching/_fishing/shark.sw"
solution: |
  run "scenarios/Challenges/Ranching/_fishing/solution.sw"
structures:
  - name: rubbish enclosure
    recognize: [north, south]
    structure:
      palette:
        'j': [grass, concrete wall]
        '.': [stone, null]
      map: |
        jjjjj
        j...j
        j...j
entities:
  - name: concrete wall
    display:
      attr: rock
      char: '-'
    description:
      - Enclosure for rubbish
    properties: [known, unwalkable]
  - name: lakewater
    display:
      attr: water
      char: ' '
    description:
      - Potable water from a lake
    properties: [known, infinite, liquid]
  - name: pawn star
    display:
      attr: gold
      char: '*'
    description:
      - |
        Can tell you if something is `junk`{=tag}
        via the `hastag` function. E.g.:
      - |
        `hastag "car tire" "junk"`
      - |
        Also allows you to get the list of all junk items with `tagmembers "junk"`.
    capabilities: [hastag, tagmembers]
  - name: torch
    display:
      attr: wood
      char: 't'
    description:
      - Can set things on fire
    properties: [known, pickable]
    capabilities: [ignite]
  - name: fishing tackle
    display:
      char: 'r'
      attr: wood
    description:
      - A fishing rod equipped with hook, line and sinker.
      - Use on `water`{=entity} to catch fish
    properties: [known, pickable]
  - name: lead weight
    display:
      char: 'w'
      attr: device
    description:
      - Used as a fishing sinker
    properties: [known, pickable]
  - name: fish hook
    display:
      char: 'j'
      attr: device
    description:
      - Use to catch fish
    properties: [known, pickable]
  - name: california roll
    display:
      char: 'c'
    description:
      - Delicious
    properties: [known, pickable]
  - name: rice
    display:
      char: 'i'
      attr: plant
    description:
      - Perfect for sushi
    properties: [known, pickable, growable]
  - name: avocado
    display:
      char: 'A'
      attr: plant
    description:
      - Perfect for sushi
    properties: [known, pickable, growable]
  - name: cucumber
    display:
      char: 'u'
      attr: plant
    description:
      - Perfect for sushi
    properties: [known, pickable, growable]
  - name: tuna
    display:
      char: 't'
    description:
      - Edible fish
    properties: [known, pickable]
  - name: crab
    display:
      char: 'c'
    description:
      - Perfect for sushi
    properties: [known, pickable]
  - name: pufferfish
    display:
      char: 'p'
    description:
      - Poisonous
    properties: [known, pickable]
  - name: trout
    display:
      char: 't'
    description:
      - Good to eat
    properties: [known, pickable]
  - name: salmon
    display:
      char: 't'
    description:
      - Good to eat
    properties: [known, pickable]
  - name: oarfish
    display:
      char: 'r'
    description:
      - Too long
    properties: [known, pickable]
  - name: narwhal
    display:
      char: 'n'
    description:
      - Too big
    properties: [known, pickable]
  - name: marlin
    display:
      char: 'm'
    description:
      - Pointy
    properties: [known, pickable]
  - name: seaweed
    display:
      char: 'w'
    description:
      - Inedible...?
    properties: [known, pickable]
  - name: nori
    display:
      char: 'n'
    description:
      - Dried seaweed wrap for sushi rolls
    properties: [known, pickable]
  - name: car tire
    display:
      char: 'o'
    description:
      - Rubber waste. Flammable.
    tags: [junk]
    properties: [known, pickable, combustible]
    combustion:
      ignition: 0.5
      duration: [40, 80]
      product: null
  - name: kitchen sink
    display:
      char: 'i'
    description:
      - Everything but!
    tags: [junk]
    properties: [known, pickable]
  - name: boot
    display:
      char: 'b'
    description:
      - A soggy, worn-out boot.
    tags: [junk]
    properties: [known, pickable]
  - name: rusty bicycle
    display:
      char: '8'
    description:
      - Its riding days are over.
    tags: [junk, metal]
    properties: [known, pickable]
recipes:
  - in:
      - [1, lakewater]
    out:
      - [1, rusty bicycle]
      - [1, lakewater]
    required:
      - [1, fishing tackle]
    time: 10
    weight: 1
  - in:
      - [1, lakewater]
    out:
      - [1, car tire]
      - [1, lakewater]
    required:
      - [1, fishing tackle]
    time: 10
    weight: 6
  - in:
      - [1, lakewater]
    out:
      - [1, boot]
      - [1, lakewater]
    required:
      - [1, fishing tackle]
    time: 10
    weight: 1
  - in:
      - [1, lakewater]
    out:
      - [1, kitchen sink]
      - [1, lakewater]
    required:
      - [1, fishing tackle]
    time: 10
    weight: 1
  - in:
      - [1, lakewater]
    out:
      - [1, seaweed]
      - [1, lakewater]
    required:
      - [1, fishing tackle]
    time: 10
    weight: 1
  - in:
      - [1, lakewater]
    out:
      - [1, tuna]
      - [1, lakewater]
    required:
      - [1, fishing tackle]
    time: 10
    weight: 1
  - in:
      - [1, lakewater]
    out:
      - [1, salmon]
      - [1, lakewater]
    required:
      - [1, fishing tackle]
    time: 10
    weight: 1
  - in:
      - [1, lakewater]
    out:
      - [1, narwhal]
      - [1, lakewater]
    required:
      - [1, fishing tackle]
    time: 10
    weight: 1
  - in:
      - [1, lakewater]
    out:
      - [1, oarfish]
      - [1, lakewater]
    required:
      - [1, fishing tackle]
    time: 10
    weight: 1
  - in:
      - [1, lakewater]
    out:
      - [1, trout]
      - [1, lakewater]
    required:
      - [1, fishing tackle]
    time: 10
    weight: 1
  - in:
      - [1, lakewater]
    out:
      - [1, marlin]
      - [1, lakewater]
    required:
      - [1, fishing tackle]
    time: 10
    weight: 1
  - in:
      - [1, lakewater]
    out:
      - [1, pufferfish]
      - [1, lakewater]
    required:
      - [1, fishing tackle]
    time: 10
    weight: 1
  - in:
      - [1, lakewater]
    out:
      - [1, crab]
      - [1, lakewater]
    required:
      - [1, fishing tackle]
    time: 10
    weight: 1
  - in:
      - [1, seaweed]
    out:
      - [1, nori]
  - in:
      - [1, crab]
      - [1, rice]
      - [1, nori]
      - [1, cucumber]
      - [1, avocado]
    out:
      - [1, california roll]
  - in:
      - [1, branch]
      - [1, fish hook]
      - [1, string]
      - [1, lead weight]
    out:
      - [1, fishing tackle]
known: []
world:
  dsl: |
    {grass}
  upperleft: [0, 0]
  palette:
    'B': [grass, erase, base]
    '.': [grass]
    'x': [blank]
    'w': [grass, lakewater]
    's': [grass, lakewater, shark]
    'A': [grass, avocado]
    'i': [grass, rice]
    'c': [grass, cucumber]
    'r': [dirt, erase]
    'h': [dirt, erase, hauler]
    'e':
      structure:
        name: rubbish enclosure
      cell: [grass]
    'f':
      structure:
        name: rubbish enclosure
        orientation:
          up: south
      cell: [grass]
  map: |
    .........................h.
    .........................r.
    AAAA.....................r.
    AAAA.......wwwwww........r.
    ......B...wwwwwwww.......r.
    iiii......wwswwwww.......r.
    iiii.....wwwwwwwww.......r.
    .........wwwwwwww........r.
    cccc.......wwww..........r.
    cccc.....................r.
    ...................exxxx.r.
    ...................xxxxx.r.
    ...................xxxxx.r.
    ....................rrrrrr.
    ...................fxxxx...
    ...................xxxxx...
    ...................xxxxx...