From d09ce7669e4ef4ad7f2cb7a640a0d973bf3e0114 Mon Sep 17 00:00:00 2001 From: Brent Yorgey Date: Tue, 25 Jun 2024 08:18:23 -0500 Subject: [PATCH] more `imap` examples --- data/scenarios/00-ORDER.txt | 1 + data/scenarios/World Examples/00-ORDER.txt | 3 +++ data/scenarios/World Examples/clearing.yaml | 22 ++++++++++++++++++++ data/scenarios/World Examples/rorschach.yaml | 21 +++++++++++++++++++ data/scenarios/World Examples/stretch.yaml | 16 ++++++++++++++ 5 files changed, 63 insertions(+) create mode 100644 data/scenarios/World Examples/00-ORDER.txt create mode 100644 data/scenarios/World Examples/clearing.yaml create mode 100644 data/scenarios/World Examples/rorschach.yaml create mode 100644 data/scenarios/World Examples/stretch.yaml diff --git a/data/scenarios/00-ORDER.txt b/data/scenarios/00-ORDER.txt index b310c7f81..8518f6822 100644 --- a/data/scenarios/00-ORDER.txt +++ b/data/scenarios/00-ORDER.txt @@ -8,3 +8,4 @@ Speedruns Testing Vignettes Mechanics +World Examples diff --git a/data/scenarios/World Examples/00-ORDER.txt b/data/scenarios/World Examples/00-ORDER.txt new file mode 100644 index 000000000..f554a1c32 --- /dev/null +++ b/data/scenarios/World Examples/00-ORDER.txt @@ -0,0 +1,3 @@ +clearing.yaml +rorschach.yaml +stretch.yaml diff --git a/data/scenarios/World Examples/clearing.yaml b/data/scenarios/World Examples/clearing.yaml new file mode 100644 index 000000000..0fac57c56 --- /dev/null +++ b/data/scenarios/World Examples/clearing.yaml @@ -0,0 +1,22 @@ +version: 1 +name: Clearing +description: | + The base is in a clearing in the forest: the area within a certain + radius of the base is completely clear of trees; then there are + random trees at increasing density up to another radius; outside of + the outer radius there are only trees. +creative: true +robots: + - name: base + display: + char: Ω + loc: [0, 0] + dir: north +world: + dsl: | + overlay + [ {dirt} + , mask ((x*x + 4*y*y) >= (6*6) && (x*x + 4*y*y) <= (30*30)) + (let h = hash % 24 in if (36 + h*h) <= (x*x + 4*y*y) then {tree,dirt} else {dirt} ) + , mask ((x*x + 4*y*y) > (30*30)) {tree, dirt} + ] diff --git a/data/scenarios/World Examples/rorschach.yaml b/data/scenarios/World Examples/rorschach.yaml new file mode 100644 index 000000000..4fa9d22e3 --- /dev/null +++ b/data/scenarios/World Examples/rorschach.yaml @@ -0,0 +1,21 @@ +version: 1 +name: Rorschach +description: | + A world with both horizontal and vertical reflection symmetry, + created with 'imap'. +creative: true +robots: + - name: base + dir: north + loc: [0, 0] +known: [tree] +world: + dsl: | + let trees = if (hash % 4 == 0) then {tree, dirt} else {stone} + in + overlay + [ mask (x >= 0 && y >= 0) trees + , mask (x >= 0 && y < 0) (imap x (-y) trees) + , mask (x < 0 && y >= 0) (imap (-x) y trees) + , mask (x < 0 && y < 0) (imap (-x) (-y) trees) + ] diff --git a/data/scenarios/World Examples/stretch.yaml b/data/scenarios/World Examples/stretch.yaml new file mode 100644 index 000000000..9050f7ceb --- /dev/null +++ b/data/scenarios/World Examples/stretch.yaml @@ -0,0 +1,16 @@ +version: 1 +name: Stretch +description: | + A world created by stretching a random pattern of trees, with the + amount of stretching determined by the distance from the origin. +creative: true +robots: + - name: base + dir: north + loc: [0, 0] +known: [tree] +world: + dsl: | + let trees = if (hash % 4 == 0) then {tree, dirt} else {stone} + in + imap (if (y == 0) then 0 else (x/abs(y))) (if (abs x <= 1) then 0 else (y/abs(x/2))) trees