-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
imap
primitive to world DSL, and remove rot
and reflect
- Loading branch information
Showing
7 changed files
with
84 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ constant.yaml | |
erase.yaml | ||
override.yaml | ||
coords.yaml | ||
reflect.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
version: 1 | ||
name: Reflection (imap) test | ||
description: | | ||
A world with both horizontal and vertical reflection symmetry, | ||
created with 'imap'. | ||
creative: false | ||
objectives: | ||
- goal: | ||
- Pick up four trees | ||
condition: | | ||
as base {n <- count "tree"; return (n >= 4)} | ||
robots: | ||
- name: base | ||
loc: [0, 0] | ||
dir: north | ||
devices: | ||
- logger | ||
- grabber | ||
- treads | ||
- branch predictor | ||
- scanner | ||
- ADT calculator | ||
- comparator | ||
- GPS receiver | ||
- bitcoin | ||
solution: | | ||
def x = \n. \c. if (n==0) {} {c; x (n-1) c} end | ||
def ifC = \p. \t. \e. b <- p; if b t e end | ||
def findTree = ifC (ishere "tree") {whereami} {move; findTree} end | ||
def ell = \d. turn right; x (2*d) move; grab; return () end | ||
def grabTrees = \loc. let x = fst loc in let y = snd loc in grab; ell y; ell x; ell y end | ||
n <- random 10; | ||
x (n+1) move; turn right; move; | ||
loc <- findTree; | ||
grabTrees loc | ||
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) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters