-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
robot wave scenario #1556
robot wave scenario #1556
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
def go = | ||
move; | ||
go; | ||
end; | ||
|
||
def start = | ||
turn right; | ||
wait 5; | ||
try { | ||
go; | ||
} {}; | ||
grab; | ||
end; | ||
|
||
start; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
def doN = \n. \f. if (n > 0) {f; doN (n - 1) f} {}; end; | ||
|
||
def crossPath = | ||
doN 6 move; | ||
turn back; | ||
wait 5; | ||
end; | ||
|
||
def go = | ||
crossPath; | ||
go; | ||
end; | ||
|
||
def start = | ||
pos <- whereami; | ||
wait $ fst pos; | ||
go; | ||
end; | ||
|
||
start; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
version: 1 | ||
name: Wave | ||
author: Karl Ostmo | ||
description: | | ||
Ride the wave | ||
creative: false | ||
objectives: | ||
- goal: | ||
- | | ||
Grab the `bitcoin`{=entity} at the east end of the path. | ||
Don't let the patrolling robots catch you! | ||
prerequisite: | ||
not: got_caught | ||
condition: | | ||
as base {has "bitcoin"}; | ||
- id: got_caught | ||
teaser: Got caught | ||
optional: true | ||
hidden: true | ||
goal: | ||
- | | ||
The robots caught you! | ||
condition: | | ||
as base {x <- meet; return $ case x (\_. false) (\_. true)}; | ||
robots: | ||
- name: base | ||
dir: [0, 1] | ||
devices: | ||
- branch predictor | ||
- comparator | ||
- dictionary | ||
- grabber | ||
- hourglass | ||
kostmo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- lambda | ||
- logger | ||
- net | ||
- scanner | ||
- strange loop | ||
- treads | ||
- name: wavebot | ||
system: true | ||
dir: [0, 1] | ||
display: | ||
invisible: false | ||
attr: 'plant' | ||
program: | | ||
run "scenarios/Challenges/_wave/wavebot.sw" | ||
kostmo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
solution: | | ||
run "scenarios/Challenges/_wave/solution.sw" | ||
entities: [] | ||
known: [wavy water, water, bitcoin] | ||
world: | ||
dsl: | | ||
overlay | ||
[ {dirt, water} | ||
, if x % 7 + y % 5 == 0 then {dirt, wavy water} else {blank} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, I like the repeating pattern, it looks like old school games. 🎮 |
||
] | ||
upperleft: [-3, 6] | ||
offset: false | ||
palette: | ||
'B': [grass, erase, base] | ||
'w': [grass, erase, wavebot] | ||
'x': [dirt, water] | ||
'z': [grass, bitcoin] | ||
'.': [grass, erase] | ||
map: | | ||
xxxxxx..................................................................................................................................................................................................................................................xxxxxx | ||
xxx........................................................................................................................................................................................................................................................xxx | ||
x............................................................................................................................................................................................................................................................x | ||
B............................................................................................................................................................................................................................................................z | ||
x............................................................................................................................................................................................................................................................x | ||
xxx........................................................................................................................................................................................................................................................xxx | ||
xxxxxxwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwxxxxxx | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this could be a bit shorter? Though it does work well as a performance test. 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this is needlessly slow because we do not inline it.
I also tried replacingBut do not do this, I measured it andwait
withturn forward
.wait
is better!Subjectively, the simulation seemed to keep playing better without lag on my computer once inlined.
EDIT: I will try to rebuild with profiling enabled and see if the difference is measurable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just following a blog post about profiling with cabal, I can see some difference in the graphs:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xsebek Great work looking at performance, memory profiling, etc.! We haven't paid much attention to it so far but I'm sure there is tons of low-hanging fruit to improve performance.
I'm not sure inlining things in scenario programs is the right way to go, though. Ideally we should be able to encourage nice, modular code and work hard to make that nice, abstracted, modular code run fast.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@byorgey it’s definitely not ideal to do it manually, thats why I made an issue to do it automatically. 🙂
@kostmo I would suggest inlining and adding a TODO linking the inline issue, but up to you.