packages feed

swarm-0.6.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";
        return $ 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: |
      // Returns true if prohibited item is in inventory.
      def checkProhibited = \idx.
        result <- tagmembers "junk" idx;
        let totalCount = fst result in
        let member = snd result in
        let nextIdx = idx + 1 in

        hasProhibited <- as base {has member};
        if hasProhibited {
          return false;
        } {
          if (nextIdx < totalCount) {
            checkProhibited nextIdx;
          } {
            return true;
          }
        }
        end;

      checkProhibited 0;
  - 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 locIsInsideEnclosure = \loc. \dims. \idx.
        foundBox <- structure "rubbish enclosure" idx;
        case foundBox (\_. return false) (\enclosure.
          let boxPos = snd enclosure in
          return $ snd loc >= snd boxPos
            && snd loc < snd dims + snd boxPos
            && fst loc >= fst boxPos
            && fst loc < fst dims + fst boxPos;
        );
        end;

      def junkOutsideEnclosure =
        result <- scan down;
        case result (\_. return false) (\item.
          isJunk <- hastag item "junk";
          if isJunk {
            foundBox <- structure "rubbish enclosure" 0;

            case foundBox (\_. return false) (\enclosure.

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

              insideFirst <- locIsInsideEnclosure loc dims 0;
              insideSecond <- locIsInsideEnclosure loc dims 1;
              return $ not $ insideFirst || insideSecond;
            );
          } {
            return 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` command. E.g.:
      - |
        `hastag "car tire" "junk"`
      - |
        Also allows you to iterate over the list of junk, e.g.:
      - |
        `tagmembers "junk" 0`
    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]
  placements:
    - src: rubbish enclosure
      offset: [19, -10]
    - src: rubbish enclosure
      offset: [19, -14]
      orient:
        up: south
  palette:
    'B': [grass, erase, base]
    '.': [grass]
    'w': [grass, lakewater]
    's': [grass, lakewater, shark]
    'A': [grass, avocado]
    'i': [grass, rice]
    'c': [grass, cucumber]
    'r': [dirt, erase]
    'h': [dirt, erase, hauler]
  map: |
    .........................h.
    .........................r.
    AAAA.....................r.
    AAAA.......wwwwww........r.
    ......B...wwwwwwww.......r.
    iiii......wwswwwww.......r.
    iiii.....wwwwwwwww.......r.
    .........wwwwwwww........r.
    cccc.......wwww..........r.
    cccc.....................r.
    .........................r.
    .........................r.
    .........................r.
    ....................rrrrrr.
    ...........................
    ...........................
    ...........................