packages feed

swarm-0.7.0.0: data/scenarios/Testing/920-meet.yaml

version: 1
name: Test meet and meetAll commands
description: |
  Make sure meet prefers a robot on the same cell, and test meetAll
  by giving everyone a boat.
objectives:
  - condition: |
      r0 <- robotNamed "other0";
      b0 <- as r0 { has "boat" };
      teleport self (0,0);
      def all : (rec l. Unit + a * l) -> (a -> Cmd Bool) -> Cmd Bool =
        \xs. \f. case xs
          (\_. pure true)
          (\cons. match cons \hd. \tl. b <- f hd; if b {all tl f} {pure false})
      end;
      rs <- meetAll;
      b1 <- all rs (\r. as r {has "boat"});
      n2 <- as r0 { count "boat" };
      pure (b0 && b1 && (n2 == 2))
solution: |
  mr0 <- meet;
  case mr0 (\_. pure ()) (\r0. give r0 "boat");
  def forM_ : (rec l. Unit + a * l) -> (a -> Cmd b) -> Cmd Unit =
    \xs. \f. case xs
      (\_. pure ())
      (\cons. match cons \hd. \tl. f hd; forM_ tl f)
  end;
  rs <- meetAll;
  forM_ rs (\r. give r "boat")
robots:
  - name: base
    loc: [0, 0]
    dir: east
    devices:
      - logger
      - antenna
      - hyperloop
      - grabber
    inventory:
      - [7, boat]
  - name: other0
    loc: [0, 0]
    dir: east
  - name: other
    dir: east
world:
  palette:
    '.': [grass]
    'Ω': [grass, null]
    'o': [grass, null, other]
    '+': [stone, wall]
  upperleft: [-2, 2]
  map: |
    +++++
    +.o.+
    +oΩo+
    +.o.+
    +++++