-
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.
- Loading branch information
Showing
5 changed files
with
268 additions
and
0 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
beekeeping.yaml | ||
capture.yaml | ||
powerset.yaml | ||
gated-paddock.yaml |
52 changes: 52 additions & 0 deletions
52
data/scenarios/Challenges/Ranching/_beekeeping/queenbee.sw
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,52 @@ | ||
// Spawns worker bees when structures are detected | ||
|
||
def doN = \n. \f. if (n > 0) {f; doN (n - 1) f} {}; end; | ||
def mod : int -> int -> int = \a. \b. a - (a/b)*b end; | ||
|
||
def workerProgram = \hiveIdx. \structureLoc. | ||
foundStructure <- structure "beehive" hiveIdx; | ||
let stillHasStructure = case foundStructure (\_. false) (\fs. | ||
structureLoc == snd fs; | ||
) in | ||
|
||
if (stillHasStructure) { | ||
doN 10 (move; wait 4;); | ||
turn back; | ||
doN 10 (move; wait 4;); | ||
workerProgram hiveIdx structureLoc; | ||
} { | ||
selfdestruct; | ||
} | ||
end; | ||
|
||
def workerProgramInit = \hiveIdx. \structureLoc. | ||
teleport self structureLoc; | ||
appear "8"; | ||
if (mod hiveIdx 2 == 0) {turn left;} {}; | ||
workerProgram hiveIdx structureLoc; | ||
end; | ||
|
||
def observeHives = \lastHiveCount. | ||
|
||
foundStructure <- structure "beehive" lastHiveCount; | ||
newHiveCount <- case foundStructure (\_. return lastHiveCount) (\fs. | ||
let newHiveCount = fst fs in | ||
|
||
if (newHiveCount > lastHiveCount) { | ||
// Build worker bee, assign ID, location | ||
build {workerProgramInit lastHiveCount $ snd fs}; | ||
return (); | ||
} {}; | ||
|
||
return newHiveCount; | ||
); | ||
|
||
wait 1; | ||
observeHives newHiveCount; | ||
end; | ||
|
||
def go = | ||
observeHives 0; | ||
end; | ||
|
||
go; |
74 changes: 74 additions & 0 deletions
74
data/scenarios/Challenges/Ranching/_beekeeping/solution.sw
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,74 @@ | ||
|
||
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 nextRow = \d. | ||
turn d; | ||
move; | ||
turn d; | ||
end; | ||
|
||
def slatRow = | ||
make "slat"; | ||
intersperse 3 move (place "slat"); | ||
end; | ||
|
||
def buildHive = | ||
doN 4 (intersperse 4 move (place "board"); turn right; move;); | ||
turn right; | ||
move; | ||
|
||
slatRow; | ||
nextRow left; | ||
slatRow; | ||
nextRow right; | ||
slatRow; | ||
|
||
end; | ||
|
||
def moveToNextHive = | ||
turn left; | ||
doN 7 move; | ||
turn left; | ||
doN 3 move; | ||
turn right; | ||
end; | ||
|
||
def buildTankSide = \item. | ||
doN 3 (move; place item;); | ||
move; | ||
turn right; | ||
move; | ||
place item; | ||
turn left; | ||
move; | ||
turn right; | ||
end; | ||
|
||
def buildBrewery = | ||
turn right; | ||
doN 3 (place "copper pipe"; move;); | ||
move; | ||
turn right; | ||
doN 3 move; | ||
turn right; | ||
move; | ||
doN 4 $ buildTankSide "copper wall"; | ||
end; | ||
|
||
def go = | ||
intersperse 4 moveToNextHive buildHive; | ||
|
||
doN 10 move; | ||
buildBrewery; | ||
end; | ||
|
||
go; |
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,140 @@ | ||
version: 1 | ||
name: Beekeeping | ||
author: Karl Ostmo | ||
description: | | ||
Build an apiary | ||
creative: true | ||
seed: 2 | ||
objectives: | ||
- teaser: Construct hives | ||
goal: | ||
- | | ||
Build eight `beehive`{=entity}s | ||
condition: | | ||
foundStructure <- structure "beehive" 0; | ||
return $ case foundStructure (\_. false) (\_. true); | ||
- teaser: Collect honey | ||
goal: | ||
- | | ||
Collect 12 jars of honey | ||
condition: | | ||
return false; | ||
robots: | ||
- name: base | ||
dir: [1, 0] | ||
devices: | ||
- 3D printer | ||
- branch predictor | ||
- calculator | ||
- clock | ||
- comparator | ||
- dictionary | ||
- dozer blade | ||
- grabber | ||
- hearing aid | ||
- keyboard | ||
- lambda | ||
- logger | ||
- scanner | ||
- strange loop | ||
- treads | ||
- welder | ||
- workbench | ||
inventory: | ||
- [100, board] | ||
- [50, copper wall] | ||
- [3, copper pipe] | ||
- name: queenbee | ||
dir: [1, 0] | ||
system: true | ||
display: | ||
invisible: false | ||
program: | ||
run "scenarios/Challenges/Ranching/_beekeeping/queenbee.sw" | ||
solution: | | ||
run "scenarios/Challenges/Ranching/_beekeeping/solution.sw" | ||
structures: | ||
- name: beehive | ||
recognize: true | ||
structure: | ||
palette: | ||
'-': [dirt, slat] | ||
'b': [dirt, board] | ||
map: | | ||
bbbbb | ||
b---b | ||
b---b | ||
b---b | ||
bbbbb | ||
- name: brewery | ||
recognize: true | ||
structure: | ||
palette: | ||
'p': [dirt, copper wall] | ||
'I': [dirt, copper pipe] | ||
'.': [dirt] | ||
map: | | ||
..ppp.. | ||
.p...p. | ||
p.....p | ||
p.III.p | ||
p.....p | ||
.p...p. | ||
..ppp.. | ||
entities: | ||
- name: honeycomb | ||
display: | ||
char: 'x' | ||
attr: gold | ||
description: | ||
- Pushable rock | ||
properties: [known, unwalkable, portable] | ||
- name: slat | ||
display: | ||
char: '-' | ||
attr: ice | ||
description: | ||
- Internal component of a beehive | ||
properties: [known, portable] | ||
- name: copper wall | ||
display: | ||
char: 't' | ||
attr: copper | ||
description: | ||
- Material for brewery tank | ||
properties: [known, portable, unwalkable] | ||
recipes: | ||
- in: | ||
- [1, board] | ||
out: | ||
- [3, slat] | ||
known: [flower, tree] | ||
world: | ||
dsl: | | ||
let | ||
cl = perlin seed 1 0.15 0.0, | ||
flowers = cl > 0.7 | ||
in | ||
overlay | ||
[ {grass} | ||
, mask (flowers && (x + y) % 3 == 0) {flower} | ||
] | ||
upperleft: [0, 0] | ||
offset: false | ||
palette: | ||
'B': [grass, erase, base] | ||
'Q': [grass, erase, queenbee] | ||
'.': [grass, erase] | ||
'*': [grass, flower] | ||
map: | | ||
..........Q..... | ||
................ | ||
..B............. | ||
................ | ||
................ | ||
................ | ||
................ | ||
................ | ||
................ | ||
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