-
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
New ranching scenario #835
Conversation
I understand why you want to have a |
One of the first things I did was make a |
I think we'll have to go with the latter; I tried creating an empty
|
Good idea, will add it. |
Completed in 4m37s! 😁 Two of the stupid sheep had drowned themselves by the time I finished making fences but one was still around. Based on the goal description I was kind of surprised that there wasn't another step after building the fence (like harvesting wool or something). Are you intending to extend the scenario in the future? |
Yes, good catch. Figured I'd get some early feedback first. |
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 love it!
data/scenarios/Challenges/Ranching/gated-paddock/meandering-sheep.sw
Outdated
Show resolved
Hide resolved
@kostmo if you wait a little, I can look into optimizing the goal condition. 😉 But I would like to play it first without getting spoiled by having seen the solution. 😅 |
Does it require you to have all the sheep inside the fence, or at least one? I played again and made a small fence around one sheep but nothing happened... so I went to make a screenshot to report a bug, and when I was done making the screenshot it suddenly congratulated me on winning. @noahyor suggested it might be because all the other sheep died. Seems a little strange that you can win when a sheep dies rather than winning when you have actually completed something. |
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.
It took me a while to finish, but I enjoyed it a lot. 👨🌾 🐑
I have a lot of small suggestions for improvement, if you disagree with any of them please explain why so that I can understand the challenge better. 😉
display: | ||
invisible: false | ||
char: '@' | ||
system: true |
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.
If the sheep were not system robots, I would be able to see them in the robot panel.
I don't think there is any way to exploit sheep as normal robots.
If it's about all the devices that they would require, just create one device that has all the capabilities. You could call it the "golden fleece".
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.
If the sheep were not system robots, I would be able to see them in the robot panel.
I think I would prefer that they don't appear in the robot panel; they are "NPCs".
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.
Sure, but system robots have the powers of gods... such sheep could literally walk through walls. 🤣
Besides they belong to the farmer who owns the island, so they are more pets than NPCs. 🙂
data/scenarios/Challenges/Ranching/gated-paddock/meandering-sheep.sw
Outdated
Show resolved
Hide resolved
data/scenarios/Challenges/Ranching/gated-paddock/meandering-sheep.sw
Outdated
Show resolved
Hide resolved
data/scenarios/Challenges/Ranching/gated-paddock/enclosure-checking.sw
Outdated
Show resolved
Hide resolved
b <- blocked; | ||
if b {} { | ||
move; |
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 sheep could crash in rare cases, consider atomic:
b <- blocked; | |
if b {} { | |
move; | |
atomic (b <- blocked; if b {} {move}); |
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 tried adding atomic
, but now the blocked-checking logic is larger, and the compiler refuses to allow atomic around it.
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.
@kostmo AFAIK, we do not allow definitions. If you inline it then it should be fine, because only the move is observable.
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.
@kostmo did you try inlining the functions? I don't care as much about the sheep crashing into a fence as I would like to know if the atomic
command is usable. 😉
@kostmo I wrote #836 which could be used to speed up the objective checking if we used Haskell for pathfinding. 🙂 It could be useful in other situations too, but it would be a bit harder to implement. Also, it would allow us to taunt sheep with food like in Minecraft if that is something you are interested in. 😄 |
@byorgey The buggy behavior is an artifact of using
Perhaps it would have worked if I explored using |
@kostmo maybe you could name the individual sheep? Either funny names like With the latter, you can use |
Yes, that's one workaround. I guess I am being stubborn because I feel I should not have to create a new |
- [1, hinge] | ||
- [1, fence] | ||
out: | ||
- [1, gate] |
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.
👍
Such subdirectories can be used to e.g. organize `.sw` files, and will be ignored when recursively loading scenarios. This resolves an issue we noticed while reviewing #835, which uses a subdirectory to hold multiple `.sw` files for a scenario and was generating a lot of spurious warnings.
seed: 0 | ||
solution: | | ||
run "scenarios/Challenges/Ranching/gated-paddock/fence-construction.sw" | ||
world: |
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.
@kostmo maybe add seed, so that the sheep always do the same thing.
I hope it is unlikely, but it could save us some headaches in the future if the sheep randomly came up with some clever escape plan. 🐑
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.
It would also make the solution more stable. Currently, there is always the unlikely possibility the sheep will all decide to run straight into the ocean before you build the fence. 😆
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.
add seed
Actually I have seed: 0
already on line 136. But I wonder if there's global influence on the random number generation that causes the sheep to behave non-reproducibly? Perhaps robot-local random number generators would help?
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.
@kostmo Oh, my mistake then. 👍 The only other source of nondeterminism I can think of would be the order of elements in an unordered container. That may or may not have an effect here.
You can check that by listing the sheep location at the end and then testing that they are always the same
using testSolution'
.
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.
But I wonder if there's global influence on the random number generation that causes the sheep to behave non-reproducibly?
If there is, it's a bug.
@kostmo indeed we run into that before and there are issues discussing this: If you want, you can add a |
@kostmo are you sure? I was able to view the last surviving It very much should do a dynamic lookup based on the current robot map in the game state. If not then that is a bug in my implementation of EDIT: this looks dynamic to me: -- | Get the robot with a given name.
robotWithName :: (Has (State GameState) sig m) => Text -> m (Maybe Robot)
robotWithName rname = use (robotMap . to IM.elems . to (find $ \r -> r ^. robotName == rname)) |
I guess the point is that each time step, there is one specific "magic" sheep which has to be enclosed, but there is no way to know which one it is. If you guess wrong and enclose one of the other sheep, you will not win until such time as the magic sheep dies; then the next time the check runs a different sheep will be selected. If it is the one inside your fence, you win! Otherwise, you have to wait for that one to die too. |
@xsebek You're right - I made the wrong inference about the behavior of |
Ok, my solution checker now accounts for all three sheep. I'm pretty happy with the scenario now. Give it another try? |
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 game feels much more responsive now, great job @kostmo! 👍
Please just clarify the goal condition in the description or make it easier again.
I have a few other notes, but those are not blockers and I think we could merge this afterwards. 🙂
}; | ||
|
||
if (justFilledGap) { | ||
allSheep checkIsEnclosed 3; |
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.
Well, that is a lot harder now, previously it was enough to save some of the sheep. 😕
Now if just one of the sheep drowns, I can no longer win.
Imagine the following scenario:
- Sheep number 1 randomly runs straight into the ocean
- The player does not notice
- Player successfully paddocks all remaining sheep
- Player waits for the checks to finish
- The game slows down as it checks the condition every tick
- Player wonders what is wrong
Please do at least one:
- note what is actually required in the goal description
- simplify the goal condition to require just
anySheep
- move the goal condition to a helper "judge" robot
- judge robot is loaded once so it can use
run
- judge robot could run the condition in
as
on each tick - the goal condition would check that judge has "win" or something
- the judge can interact with the environment, in particular, it can
say
what the player is doing wrong- e.g.
say "One sheep has drowned, please start over!"
- e.g.
- judge robot is loaded once so it can use
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.
Also, the judge robot could remember that it already checked the fence connection and not check again on the next tick until the player moves. This would be another speedup. 🤔
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.
Ohh, I ran into exactly this scenario. One sheep drowned and I did not realize that would prevent me from winning. What's worse, when I completed the fence but was still sitting on top of the last fence I placed, it pegged my CPU at 100% and the game at 30 ticks per frame, 0.1 fps. =( It was so sluggish I had to wait like 5-10 seconds just to switch to a different panel in the UI. As soon as I moved off the fence (with great difficulty, waiting 5-10 seconds in between each UI action) the game suddenly sped up again.
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 relaxed the goal to just save one sheep.
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 judge robot could remember
Is there a way to have a persistent "judge" robot that can execute an entire program in one tick?
Also, my judge-algorithm modifies/destroys the environment, so it would have to execute in a "sandboxed" state that is rolled back/discarded upon completion of its program.
What may be useful (and would be facilitated by #795) is if there existed a god
-capability command that can check if a specific (named) goal has been already achieved.
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.
Is there a way to have a persistent "judge" robot that can execute an entire program in one tick?
We normally use system robots with the as
command, which is as powerful as you can get.
data/scenarios/Challenges/Ranching/_gated-paddock/meandering-sheep.sw
Outdated
Show resolved
Hide resolved
I have now restarted four times and have not yet been able to get all the sheep in a fence before they drown. It seems like the only way to win is to write a program that will automatically do all the actions of harvesting trees, making fence, and placing the fence so that it can happen fast enough to catch the sheep. But this feels very irritating. |
I also don't understand the point of the post puller and the fact that it leaves behind scrap wood that you cannot do anything with and cannot pick up. It means that once you have placed a fence somewhere you will never be able to use that spot for anything else. For example if you create an unbroken fence and then decide you want to place a gate in the fence, it is kind of difficult to do because you cannot place a gate on top of a pile of scrap wood. Why not just let players pick up scrap wood? |
Finally managed to beat it. The other two objectives are fun, though after the fence building the last objective seemed too easy. How about requiring a certain number of wool (say, 10?) instead of just one? |
Btw. sorry for being so perfectionist @kostmo, please understand that I am simply trying to make this as good and fun as possible. 😅 I have limited time due to work and school, so my comments might seem a little brisk. If you ever feel too tired to deal with all of my nitpicks, just comment which one you want to do and others I can do myself. 😉 |
Ah that's a pitfall of "writing to the integration test" as a scenario designer. I tend to forget that the player will have to re-invent the program that I spent so long perfecting :) I hope it's more reasonable now with the new single-sheep requirement.
Fixed. Using the
I've modified the goal to knit
Finally, for code reviews which may become large, may we adopt a practice of making every comment a "threaded" comment to make the replies easier to follow? The way to do this in GitHub seems to be to attach the comment to a line of code (that line may have to be arbitrary). The toplevel (non-code-attached) comments do not facilitate long reply chains well. |
Yes, indeed. The most recent time I played one sheep pretty much immediately drowned itself but I was able to fence the other two. I think this also solves my issue with the CPU being pegged at 100%, since that would only happen when the base is sitting on top of a fence, we just closed a gap, but you haven't won. I guess that could still happen in theory if there are NO sheep inside the fence? But that seems less likely.
Yes, that's much nicer, thanks!
I like it.
Hmm, strange. Not sure what's going on there.
Ah, good idea. I made top-level comments since they did not really pertain to a specific line of code, but you're right that the threading is much nicer for comments attached to lines of code. |
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 think it works great now and all my concerns have been addressed! Beat the most recent version in 6m 52s. 😄
@xsebek can you update the "requested changes" status of your review? As is, merging is blocked. |
Created #858 |
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.
data/scenarios/Challenges/Ranching/_gated-paddock/meandering-sheep.sw
Outdated
Show resolved
Hide resolved
🎉 🚀 ❤️ Pretty sure 118 comments is a new record. 😄 |
Demo with:
The primary element of this scenario is "testing for a closed loop" in the objective condition. As written, this test is performed every "tick", and introduces noticeable rendering lag at higher "ticks / s" speeds.
What may be better is for the player to "ask" for the condition to be checked, perhaps by standing somewhere specific, picking up a particular object, or even with
say "Ready!"
.