From ec89c920655bade6524a888ed7447e62cfefe6db 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 | 24 ++++++++++++++++++++ data/scenarios/World Examples/rorschach.yaml | 21 +++++++++++++++++ data/scenarios/World Examples/stretch.yaml | 16 +++++++++++++ 5 files changed, 65 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 b310c7f816..8518f68224 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 0000000000..f554a1c321 --- /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 0000000000..8084e9c34e --- /dev/null +++ b/data/scenarios/World Examples/clearing.yaml @@ -0,0 +1,24 @@ +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: | + let trees = if (hash % 4 == 0) then {tree, dirt} else {dirt} + in + 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 0000000000..4fa9d22e32 --- /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 0000000000..9050f7ceb4 --- /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