Skip to content
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

Merged
merged 4 commits into from
Mar 25, 2023
Merged

Whack-a-mole scenario #1026

merged 4 commits into from
Mar 25, 2023

Conversation

kostmo
Copy link
Member

@kostmo kostmo commented Jan 22, 2023

image

@kostmo kostmo requested review from byorgey and xsebek January 22, 2023 07:49
@kostmo kostmo force-pushed the whack-a-mole branch 2 times, most recently from 1b9def6 to 1ec0456 Compare January 22, 2023 08:06
@@ -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"
Copy link
Member Author

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.

Copy link
Member Author

@kostmo kostmo Jan 23, 2023

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;
Copy link
Member Author

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.

Copy link
Member

@byorgey byorgey left a 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

data/scenarios/Challenges/_gopher/gopher.sw Outdated Show resolved Hide resolved
data/scenarios/Challenges/_gopher/gopher.sw Outdated Show resolved Hide resolved
Copy link
Member

@xsebek xsebek left a 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. 😄

data/scenarios/Challenges/_gopher/gopher.sw Outdated Show resolved Hide resolved
@kostmo kostmo requested a review from byorgey March 25, 2023 20:20
@kostmo
Copy link
Member Author

kostmo commented Mar 25, 2023

I think this is ready now.

Copy link
Member

@byorgey byorgey left a 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...

@kostmo kostmo added the merge me Trigger the merge process of the Pull request. label Mar 25, 2023
@mergify mergify bot merged commit dc8c21a into main Mar 25, 2023
@mergify mergify bot deleted the whack-a-mole branch March 25, 2023 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Trigger the merge process of the Pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants