packages feed

swarm-0.4: data/scenarios/Challenges/hackman.yaml

version: 1
name: Hackman
author: Karl Ostmo
description: |
  Feed Hackman caffeine pellets
creative: false
attrs:
  - name: ghost1
    fg: "#ff0000"
  - name: ghost2
    fg: "#ffb8ff"
  - name: ghost3
    fg: "#00ffff"
  - name: ghost4
    fg: "#ffb852"
  - name: strawberry
    fg: "#ff0000"
objectives:
  - teaser: Get pellets
    goal:
      - |
        Pick up all of the caffeine "pellets" so that Hackman can write more code.
      - |
        Pay no mind to the colorful ghosts meandering about. That is, unless
        you are feeling generous with your "donuts"...
      - |
        Can you find all of the secret objectives?
    condition: |
      as base {
        pcount <- count "pellet";
        donut_count <- count "donut";
        return $ pcount >= 181;
      };
  - id: donut_given
    teaser: Give to ghost
    hidden: true
    optional: true
    goal:
      - |
        Give a ghost a donut.
    condition: |
      def anyHasPowerup = \n.
          let ghost_name = "ghost" ++ format n in
          ghost <- robotnamed ghost_name;
          hasPowerup <- as ghost {
              has "donut";
          };
          
          if hasPowerup {
              return true;
          } {
              if (n > 1) {
                  anyHasPowerup $ n - 1;
              } {
                  return false;
              }
          }
          end;

      anyHasPowerup 4;
  - teaser: Interloper
    hidden: true
    optional: true
    goal:
      - |
        Invade the ghost den
    condition: |
      loc <- as base {
        whereami;
      };
      return $ loc == (0, 0);
  - teaser: World wrap
    hidden: true
    optional: true
    goal:
      - |
        Be teleported
    condition: |
      r <- robotnamed "teleporter";
      loc <- as r {
        has "bit (0)"
      };
  - teaser: Balanced diet
    hidden: true
    optional: true
    goal:
      - |
        Get the strawberry
    condition: |
      as base {
        has "strawberry";
      };
  - teaser: Magnanimity
    hidden: true
    optional: true
    prerequisite: donut_given
    goal:
      - |
        Give all ghosts a donut.
    condition: |
      def allHasPowerup = \n.
          let ghost_name = "ghost" ++ format n in
          ghost <- robotnamed ghost_name;
          hasPowerup <- as ghost {
              has "donut";
          };
          
          if hasPowerup {
              if (n > 1) {
                  allHasPowerup $ n - 1;
              } {
                  return true;
              }
          } {
              return false;
          }
          end;

      allHasPowerup 4;
robots:
  - name: base
    display:
      orientationMap:
        east: 'c'
        north: 'u'
        west: 'ↄ'
        south: 'n'
      char: 'U'
      attr: gold
    dir: [1, 0]
    devices:
      - ADT calculator
      - antenna
      - bitcoin
      - branch predictor
      - clock
      - compass
      - comparator
      - counter
      - dictionary
      - drill
      - grabber
      - lambda
      - lodestone
      - logger
      - mirror
      - net
      - scanner
      - strange loop
      - treads
      - workbench
  - name: teleporter
    dir: [0, 1]
    system: true
    display:
      invisible: true
      char: 'T'
    program: |
      run "scenarios/Challenges/_hackman/teleporter.sw"
  - name: ghost1
    dir: [0, 1]
    system: true
    display:
      invisible: false
      char: '∩'
      attr: ghost1
    program: |
      run "scenarios/Challenges/_hackman/ghost.sw"
  - name: ghost2
    dir: [0, 1]
    system: true
    display:
      invisible: false
      char: '∩'
      attr: ghost2
    program: |
      run "scenarios/Challenges/_hackman/ghost.sw"
  - name: ghost3
    dir: [0, 1]
    system: true
    display:
      invisible: false
      char: '∩'
      attr: ghost3
    program: |
      run "scenarios/Challenges/_hackman/ghost.sw"
  - name: ghost4
    dir: [0, 1]
    system: true
    display:
      invisible: false
      char: '∩'
      attr: ghost4
    program: |
      run "scenarios/Challenges/_hackman/ghost.sw"
  - name: fruit_maker
    dir: [0, 1]
    system: true
    display:
      invisible: true
      char: 'f'
    inventory:
      - [1, strawberry]
    program: |
      run "scenarios/Challenges/_hackman/fruit_maker.sw"
entities:
  - name: pellet
    display:
      char: '•'
      attr: silver
    description:
      - A caffeine pellet.
      - Helps Hackman produce more code.
    properties: [known, portable]
  - name: donut
    display:
      char: 'o'
      attr: gold
    description:
      - Breakfast of champions.
      - Fancied by ghosts. Will you share?
    properties: [known, portable]
  - name: den key
    display:
      char: 'k'
      attr: gold
    description:
      - Opens a gate
    properties: [known, portable]
  - name: strawberry
    display:
      char: 'v'
      attr: strawberry
    description:
      - A tart berry
      - Possessing this fruit gives you great satisfaction.
    properties: [known, portable]
  - name: gate
    display:
      char: '='
    description:
      - A gate.
    properties: [known, unwalkable]
  - name: wall
    display:
      char: '▒'
    description:
      - A wall.
    properties: [known, unwalkable]
recipes:
  - in:
    - [181, "pellet"]
    out:
    - [1, "den key"]
  - in:
    - [1, "den key"]
    - [1, "gate"]
    out:
    - [1, "den key"]
    required:
    - [1, drill]
solution:
  run "scenarios/Challenges/_hackman/solution.sw"
known: []
seed: 0
world:
  palette:
    'B': [blank]
    'Ω': [blank, null, base]
    'f': [blank, null, fruit_maker]
    'a': [blank, null, ghost1]
    'b': [blank, null, ghost2]
    'c': [blank, null, ghost3]
    'd': [blank, null, ghost4]
    'T': [blank, null, teleporter]
    '.': [blank, pellet]
    '*': [blank, donut]
    'x': [blank, wall]
    '=': [blank, gate]
    '┌': [stone, upper left corner]
    '┐': [stone, upper right corner]
    '└': [stone, lower left corner]
    '┘': [stone, lower right corner]
    '─': [stone, horizontal wall]
    '│': [stone, vertical wall]
  upperleft: [-11, 10]
  map: |-
    xxxxxxxxxxxxxxxxxxxxxxx
    x..........x..........x
    x*xxx.xxxx.x.xxxx.xxx*x
    x.xxx.xxxx.x.xxxx.xxx.x
    x.....................x
    x.xxx.x.xxxxxxx.x.xxx.x
    x.....x....x....x.....x
    xxxxx.xxxxBxBxxxx.xxxxx
    BBBBx.xBBBBBBBBBx.xBBBB
    xxxxx.xB┌──=──┐Bx.xxxxx
    TBBBB.BB│abBcd│BB.BBBBT
    xxxxx.xB└─────┘Bx.xxxxx
    BBBBx.xBBBfΩBBBBx.xBBBB
    xxxxx.xBxxxxxxxBx.xxxxx
    x..........x..........x
    x.xxx.xxxx.x.xxxx.xxx.x
    x*..x.............x..*x
    xxx.x.x.xxxxxxx.x.x.xxx
    x.....x....x....x.....x
    x.xxxxxxxx.x.xxxxxxxx.x
    x.....................x
    xxxxxxxxxxxxxxxxxxxxxxx