swarm-0.4: data/scenarios/Testing/1140-detect-command.yaml
version: 1
name: Detect test
creative: true
description: Locate a tree using the detector
objectives:
- goal:
- grab a tree.
condition: |
as base {has "tree"}
solution: |
def doN = \n. \f. if (n > 0) {f; doN (n - 1) f} {}; end;
loc <- detect "tree" ((0, 0), (6, 4));
case loc return (\delta.
let xDelta = fst delta in
let yDelta = snd delta in
if (yDelta < 0) {turn south;} {};
doN yDelta move; // y-movement
if (xDelta < 0) {turn west;} {turn east};
doN xDelta move; // x-movement
grab;
return ();
);
robots:
- name: base
dir: [0,1]
display:
char: Ω
attr: robot
devices:
- logger
- string
- grabber
- compass
- treads
- ADT calculator
known: []
world:
palette:
'Ω': [grass, null, base]
'.': [grass]
'T': [grass, tree]
upperleft: [-4, 4]
map: |
.........
.........
.........
.........
......T..
.........
.........
.Ω.......
.........