-
Notifications
You must be signed in to change notification settings - Fork 54
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
Challenge scenario requiring the use of a stack #932
Comments
I think you can emulate a stack within the "environment" of a recursive function1. Have the "state machine" of whatever algorithm you're carrying out exist inside the body of the recursive function. The "top" of the stack is an argument to the function. Recurse again with a new argument to "push" onto the stack, or allow the current layer to exit to "pop" from the stack. Footnotes
|
In parallel, we should contrive a challenge scenario where the player is required to use a stack. |
Ah, excellent, this got me on the right track. Something like this (pseudocode) should work:
|
Hmm, I had a potentially interesting idea for a challenge scenario: there is a line of entities on the ground, and you are required to reverse them, i.e. pick them up and place them down in the same locations but in reversed order. However, you have a limited number of ticks in which to complete the challenge --- so that you have to use an O(n) solution instead of O(n^2). i.e. you can't walk back and forth swapping the items on the ends, then the items one from the ends, and so on. You have to walk down the line and pick them all up, then walk back and somehow place them down in reverse order --- of course the way to do this is to simulate a stack internally with recursion. To solve the challenge you would have to program a solution and run it with Of course someone could always cheese it by writing a really tedious program like |
A challenge that utilizes a stack. Closes #932. Demo: ``` scripts/play.sh --scenario data/scenarios/Challenges/dna.yaml --autoplay ``` 
I was thinking the other day that it would be really cool to have stacks somehow. Like a physical thing that you could push and pop entities on. This would let you simulate pushdown automata and would probably allow for some cool automated production scenarios.
However, I don't necessarily want to just create a new device or built-in thing. What I really want to think about is, what would you need to be able to program a stack yourself? I'm thinking something like this:
place
the item you want to push and then send apush
message to the stack robot, which will pick up the item and store it. To pop, you send apop
message, and it will place an item down.Would be happy to hear about other approaches I haven't thought of.
The text was updated successfully, but these errors were encountered: