-
Notifications
You must be signed in to change notification settings - Fork 53
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
Whack-a-mole scenario #1026
Whack-a-mole scenario #1026
Conversation
kostmo
commented
Jan 22, 2023
1b9def6
to
1ec0456
Compare
test/integration/Main.hs
Outdated
@@ -162,6 +162,7 @@ testScenarioSolution _ci _em = | |||
, testSolution (Sec 5) "Challenges/2048" | |||
, testSolution (Sec 3) "Challenges/word-search" | |||
, testSolution (Sec 3) "Challenges/ice-cream" | |||
, testSolution (Sec 90) "Challenges/gopher" |
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.
As is, this test take 45 seconds on my computer to complete. So I'm not sure whether we actually want this to be part of the test suite.
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 have now fixed this by adding a wait 64
in the "polling" loop of the built robots.
It also helped to reduce the map size and number of strikes against the gopher.
} { | ||
// Inserting this "wait" speeds up the | ||
// integration test significantly (more than 3x) | ||
wait 64; |
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.
The integration test runs much faster with this.
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.
Nice! My solution (written without looking at yours) is below. Looks like they are functionally pretty similar.
I think we definitely need to fix the race condition before merging. On the other hand I don't have a strong opinion about the teleport
, I just wanted to hear your thought process and why you designed it that way.
def mod = \a. \b. (a - b*(a/b)) end
def forever = \c. c ; forever c end
def x4 = \c. c;c;c;c end
def drill_mound = \d.
h <- scan d;
if (h == inr "mound") { drill d } {}
end
def gopher_turret =
forever (
x4 ( turn left; drill_mound forward );
drill_mound down
)
end
def idoN_rec : int -> int -> (int -> cmd unit) -> cmd unit = \k. \n. \c.
if (k == n) {} {c k; idoN_rec (k+1) n c}
end
def idoN : int -> (int -> cmd unit) -> cmd unit = idoN_rec 0 end
def doN : int -> cmd unit -> cmd unit = \n. \c. idoN n (\_. c) end
def place_turret = \row. \col.
if (mod (2*row + col) 5 == 0) { build {gopher_turret}; return () } {}
end
def carpet_row = \r.
idoN 28 (\c. place_turret r c; move);
turn back; doN 28 move; turn left; move; turn left
end
def carpet = idoN 19 carpet_row end
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.
Wow, this is a huge challenge, I am not sure I am ready to face that gopher. 😄
I think this is ready now. |
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.
Looks great! I had to make a minor change to my solution since the type of drill
changed but after that change it still worked, and I like the new non-teleporting gopher.
I especially like this challenge because it feels like it might just be possible if you type really fast but it quickly gets tedious/impossible and you start to wonder if there is a better way...