-
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
10 changed files
with
285 additions
and
38 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,35 @@ | ||
def win = | ||
try { | ||
firestarter <- robotNamed "firestarter"; | ||
halt firestarter | ||
} {}; | ||
try { | ||
fire <- robotNamed "fire"; | ||
halt fire; | ||
log "reprogramming..."; | ||
reprogram fire { selfdestruct }; // XXX WHY WON'T THIS WORK | ||
log "reprogrammed"; | ||
} {}; | ||
create "gold" | ||
end | ||
|
||
def judgeCount : Int -> Cmd Unit = \actual. | ||
watch down; | ||
wait 1024; | ||
s <- scan down; | ||
case s | ||
(\_. return ()) | ||
(\p. | ||
try { | ||
let c = (read p : Int) in | ||
if (c == actual) { win } {} | ||
} {} | ||
) | ||
end | ||
|
||
def judge = | ||
numFlowers <- resonate "flower" ((-58,-19),(61,20)); | ||
judgeCount numFlowers; | ||
end; | ||
|
||
judge |
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,170 @@ | ||
version: 1 | ||
name: Flower Count | ||
author: Brent Yorgey | ||
description: | | ||
Count the flowers quickly... or else! | ||
creative: false | ||
objectives: | ||
- id: count_flowers | ||
teaser: Count the flowers! | ||
goal: | ||
- | | ||
Your evil nemesis, the sadistic supervillain Dr. Nemesis, is | ||
at it again! They have wired up some explosives to your True | ||
Love and lit the fuse, but promised to stop it... IF you can | ||
count all the flowers in time! | ||
- | | ||
Specifically, Dr. Nemesis demands that you count the | ||
total number of flowers in the 120x40 field bounded by walls, | ||
`print` the number on a piece of `paper`{=entity}, and place | ||
the paper at the origin, `(0,0)`. If the number is correct, | ||
the countdown stops and your True Love is saved. If the | ||
number is incorrect... nothing happens, but the fuse continues | ||
to burn! | ||
- | | ||
And don't even think about trying to pick any of the flowers. | ||
condition: | | ||
judge <- robotNamed "judge"; | ||
as judge { has "gold" } | ||
- id: pick_flower | ||
hidden: true | ||
optional: true | ||
teaser: You just don't listen, do you | ||
goal: | ||
- | | ||
I told you not to pick any flowers! Now your True Love is | ||
dead... because of YOU! | ||
- | | ||
Perhaps you would like to go back in time and try again. | ||
condition: | | ||
f <- as base { has "flower" }; | ||
judge <- robotNamed "judge"; | ||
g <- as judge { has "gold" }; | ||
return (not g && f) | ||
- id: out_of_time | ||
hidden: true | ||
optional: true | ||
teaser: Not fast enough | ||
goal: | ||
- | | ||
You were not fast enough, and now your True Love is | ||
dead... because of YOU! | ||
- | | ||
Perhaps you would like to go back in time and try again. | ||
condition: | | ||
truelove <- robotNamed "truelove"; | ||
as truelove { b <- ishere "fuse"; return (not b) } | ||
- id: joinpoint | ||
hidden: true | ||
teaser: Follow instructions! | ||
prerequisite: | ||
logic: | ||
and: | ||
- count_flowers | ||
- not: pick_flower | ||
- not: out_of_time | ||
condition: | | ||
return true | ||
- id: win | ||
teaser: Give a flower | ||
prerequisite: joinpoint | ||
goal: | ||
- | | ||
Congratulations! You foiled the plan of evil Dr. Nemesis and | ||
saved your True Love! The only thing left is to give your | ||
True Love a flower! | ||
condition: | | ||
truelove <- robotNamed "truelove"; | ||
as truelove { has "flower" } | ||
solution: | | ||
run "scenarios/Challenges/_flower-count/solution.sw" | ||
robots: | ||
- name: base | ||
dir: north | ||
devices: | ||
- solar panel | ||
- treads | ||
- antenna | ||
- comparator | ||
- ADT calculator | ||
- workbench | ||
- grabber | ||
- dictionary | ||
- lambda | ||
- logger | ||
- welder | ||
- scanner | ||
- strange loop | ||
- typewriter | ||
inventory: [] | ||
- name: igniter | ||
system: true | ||
dir: east | ||
devices: | ||
- logger | ||
program: 'ignite down' | ||
- name: judge | ||
system: true | ||
dir: east | ||
devices: | ||
- logger | ||
program: | | ||
run "scenarios/Challenges/_flower-count/judge.sw" | ||
- name: truelove | ||
system: true | ||
display: | ||
invisible: false | ||
attr: red | ||
char: '♥' | ||
description: Your One True Love. | ||
attrs: | ||
- name: fuse | ||
fg: '#cccccc' | ||
bg: '#002f00' | ||
# - name: greyborder | ||
# fg: '#cccccc' | ||
# bg: '#002f00' | ||
# - name: blueborder | ||
# fg: '#4287f5' | ||
# bg: '#002f00' | ||
# - name: purpleborder | ||
# fg: '#d885ff' | ||
# bg: '#002f00' | ||
# - name: yg | ||
# fg: '#ffff8f' | ||
# bg: '#002f00' | ||
# - name: rg | ||
# fg: '#ff8f8f' | ||
# bg: '#002f00' | ||
entities: | ||
- name: fuse | ||
display: | ||
attr: fuse | ||
char: '-' | ||
description: | ||
- XXX fuse | ||
properties: [combustible, known, boundary] | ||
combustion: | ||
ignition: 20 | ||
duration: [64, 64] | ||
delay: 63 | ||
product: ash | ||
known: [flower, wall, ash] | ||
world: | ||
dsl: | | ||
overlay | ||
[ if (hash % 7 == 0) then {grass, flower} else {grass} | ||
, mask ((x == 61 || x == (-60)) && y <= 21 && y >= -20) {wall, stone} | ||
, mask ((y == 21 || y == (-20)) && x <= 61 && x >= -60) {wall, stone} | ||
] | ||
upperleft: [0, 0] | ||
offset: false | ||
palette: | ||
'B': [grass, null, base] | ||
'J': [grass, erase, judge] | ||
'.': [grass] | ||
'-': [grass, fuse] | ||
'L': [grass, fuse, truelove] | ||
'I': [grass, fuse, igniter] | ||
map: | | ||
JB..I---------------L |
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
Oops, something went wrong.