swarm-0.6.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
(\_. return true)
(\cons. b <- f (fst cons); if b {all (snd cons) f} {return false})
end;
rs <- meetAll;
b1 <- all rs (\r. as r {has "boat"});
n2 <- as r0 { count "boat" };
return (b0 && b1 && (n2 == 2))
solution: |
mr0 <- meet;
case mr0 (\_. return ()) (\r0. give r0 "boat");
def forM_ : (rec l. Unit + a * l) -> (a -> Cmd b) -> Cmd Unit =
\xs. \f. case xs
(\_. return ())
(\cons. f (fst cons); forM_ (snd cons) 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, upper left corner]
'┐': [stone, upper right corner]
'└': [stone, lower left corner]
'┘': [stone, lower right corner]
'─': [stone, horizontal wall]
'│': [stone, vertical wall]
upperleft: [-2, 2]
map: |
┌───┐
│.o.│
│oΩo│
│.o.│
└───┘