diff --git a/data/scenarios/World Examples/00-ORDER.txt b/data/scenarios/World Examples/00-ORDER.txt index f554a1c321..57fc6a4aa7 100644 --- a/data/scenarios/World Examples/00-ORDER.txt +++ b/data/scenarios/World Examples/00-ORDER.txt @@ -1,3 +1,4 @@ clearing.yaml rorschach.yaml stretch.yaml +translate.yaml diff --git a/data/scenarios/World Examples/rorschach.yaml b/data/scenarios/World Examples/rorschach.yaml index 4fa9d22e32..bb03b3f401 100644 --- a/data/scenarios/World Examples/rorschach.yaml +++ b/data/scenarios/World Examples/rorschach.yaml @@ -2,7 +2,7 @@ version: 1 name: Rorschach description: | A world with both horizontal and vertical reflection symmetry, - created with 'imap'. + created with `imap`{=snippet}. creative: true robots: - name: base diff --git a/data/scenarios/World Examples/translate.yaml b/data/scenarios/World Examples/translate.yaml new file mode 100644 index 0000000000..bb4b7bcb85 --- /dev/null +++ b/data/scenarios/World Examples/translate.yaml @@ -0,0 +1,24 @@ +version: 1 +name: Translate +description: | + An illustration of how to use `imap`{=snippet} to translate. A basic patch is + created and then overlaid at various translations. Note that since + `imap`{=snippet} works by mapping a function over the coordinates, translation + is "backwards": for example, `imap (x+4)`{=snippet} translates 4 units to the + *left*. +creative: true +robots: + - name: base + dir: north + loc: [0, 0] +known: [rock] +world: + dsl: | + let patch = mask (abs(x) <= 4 && abs(y) <= 4) (if ((x + y) % 2 == 0) then {rock, dirt} else {dirt}) + in + overlay + [ patch + , imap (x+6) (y+3) patch + , imap (x-10) (y-7) patch + , imap (x-14) (y+5) patch + ]