-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
158 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
def doN = \n. \f. if (n > 0) {f; doN (n - 1) f} {}; end; | ||
|
||
def intersperse = \n. \f2. \f1. if (n > 0) { | ||
f1; | ||
if (n > 1) { | ||
f2; | ||
} {}; | ||
intersperse (n - 1) f2 f1; | ||
} {}; | ||
end; | ||
|
||
def placeBoulder = \border. | ||
create border; | ||
|
||
isEmptyHere <- isempty; | ||
if isEmptyHere { | ||
place border | ||
} { | ||
swap border; | ||
return (); | ||
}; | ||
|
||
return (); | ||
end | ||
|
||
def spinWeb = \border. | ||
move; | ||
turn left; | ||
|
||
try { | ||
intersperse 2 move $ placeBoulder border; | ||
doN 3 ( | ||
turn left; | ||
doN 2 (placeBoulder border; move); | ||
); | ||
placeBoulder border; | ||
} {}; | ||
end | ||
|
||
def goDir = \f. \result. | ||
let d = fst result in | ||
if (d == down) { | ||
spinWeb "mountain"; | ||
} { | ||
turn d; move; | ||
}; | ||
f; | ||
end; | ||
|
||
def followRoute = \item. | ||
nextDir <- path (inL ()) (inR item); | ||
case nextDir return $ goDir $ followRoute item; | ||
end; | ||
|
||
followRoute "tree"; |
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,55 @@ | ||
def doN = \n. \f. if (n > 0) {f; doN (n - 1) f} {}; end; | ||
|
||
def intersperse = \n. \f2. \f1. if (n > 0) { | ||
f1; | ||
if (n > 1) { | ||
f2; | ||
} {}; | ||
intersperse (n - 1) f2 f1; | ||
} {}; | ||
end; | ||
|
||
def placeBoulder = \border. | ||
create border; | ||
|
||
isEmptyHere <- isempty; | ||
if isEmptyHere { | ||
place border | ||
} { | ||
swap border; | ||
return (); | ||
}; | ||
|
||
return (); | ||
end | ||
|
||
def spinWeb = \border. | ||
move; | ||
turn left; | ||
|
||
try { | ||
intersperse 2 move $ placeBoulder border; | ||
doN 3 ( | ||
turn left; | ||
doN 2 (placeBoulder border; move); | ||
); | ||
placeBoulder border; | ||
} {}; | ||
end | ||
|
||
def goDir = \f. \result. | ||
let d = fst result in | ||
if (d == down) { | ||
spinWeb "mountain"; | ||
} { | ||
turn d; move; | ||
}; | ||
f; | ||
end; | ||
|
||
def followRoute = \item. | ||
nextDir <- path (inL ()) (inR item); | ||
case nextDir return $ goDir $ followRoute item; | ||
end; | ||
|
||
followRoute "flower"; |
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: Spiders | ||
description: | | ||
Spiders catching prey by spinning webs | ||
creative: true | ||
robots: | ||
- name: base | ||
dir: north | ||
loc: [5, 0] | ||
- name: spider | ||
display: | ||
invisible: false | ||
attr: blue | ||
dir: north | ||
system: true | ||
loc: [0, 0] | ||
program: | | ||
run "scenarios/Fun/_spider/spider.sw" | ||
- name: monkey | ||
display: | ||
invisible: false | ||
attr: red | ||
dir: north | ||
system: true | ||
loc: [0, 0] | ||
program: | | ||
run "scenarios/Fun/_spider/monkey.sw" | ||
structures: | ||
- name: cocoon | ||
recognize: [north] | ||
structure: | ||
mask: '.' | ||
palette: | ||
'b': [grass, mountain] | ||
map: | | ||
bbb | ||
b.b | ||
bbb | ||
known: [tree] | ||
world: | ||
dsl: | | ||
overlay | ||
[ {grass} | ||
, mask ((hash % 200) == 0) {flower} | ||
, mask (((hash+1) % 200) == 0) {tree} | ||
] |
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