Skip to content

Commit

Permalink
add a translation example for imap
Browse files Browse the repository at this point in the history
  • Loading branch information
byorgey committed Jun 26, 2024
1 parent fcd1f1b commit 88b6e53
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions data/scenarios/World Examples/00-ORDER.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
clearing.yaml
rorschach.yaml
stretch.yaml
translate.yaml
2 changes: 1 addition & 1 deletion data/scenarios/World Examples/rorschach.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions data/scenarios/World Examples/translate.yaml
Original file line number Diff line number Diff line change
@@ -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
]

0 comments on commit 88b6e53

Please sign in to comment.