Python code needed to implement a puzzle

Help bring our custom Ages to life! Share tips and tricks, as well as code samples with other developers.

Python code needed to implement a puzzle

Postby dendwaler » Wed Jul 18, 2012 11:44 am

Hi all,
I need some help with pythoncode for a puzzle.
The puzzle has 12 touchables.
Its state must be remembered in a Boolset.
Default is all " zero" (untouched)
The player must touch 5 out of these 12 .
When the 5 correct ones are choosen there will be some other object's that can be activated as a reward.

When a wrong button is choosen the whole boolset must reset to default.

I hope this is enough info for making some code for me if not please ask what more is needed.
Thx in advance.
Those wonderfull Worlds are called " Ages" , because that is what it takes to build one.



Watch my latest Video Or even better..... watch the Cathedral's Complete Walkthrough made by Suleika!
User avatar
dendwaler
 
Posts: 936
Joined: Mon Jun 22, 2009 10:49 am
Location: Nederland

Re: Python code needed to implement a puzzle

Postby Sirius » Thu Jul 19, 2012 6:20 am

I'm not sure I understand the whole of it... the thing that troubles me most is resetting the boolset when a wrong button is pressed. As I see it, the puzzle can be solved by brute force quite easily. Specifying whether there is a particular order to press the buttons would be welcome too... That's the kind of things most people easily forget, but that really matters ;)

Currently here is how I understand it should be working:

There are twelve buttons, the player can press any one of them. There is no particular order to press the five solution buttons, as long as you don't press a wrong button. Once pressed, a button will remain pushed if it is one of the five.

Let's say player touches a first button.
- If it is a wrong button, the button is released, and nothing happens.
- If it is is a correct button, it remains pushed and cannot be used another time until it is released.
Assuming the first button is correct and is pushed (so can't be used another time), the avatar touches another button.
- if it is wrong, then the previously pressed button is released, and the current one as well (since the boolset is resetted)
- if it is a correct button, it remains pushed and cannot be used another time until it is released, and player can choose a third button, etc.

Now, as it is currently described, the player can use brute force and press all twelve buttons one by one until he finds five buttons that won't reset the boolset... and that can be quite quick, since in the end the player can find the solution with at worse 12+5 button press.

Now, assuming there is a special order to press them... and buttons will remain pushed until a wrong button is pressed.
Then brute force will be a bit longer, the first button is still easy to find, but to find the second, you always have to re-press the first until you find it, etc. But it is solvable in a short time.

Is there something I didn't understand ? I think in both cases the boolset should be resetted only once FIVE buttons have been pressed, no matter how many wrong buttons were pressed.
If there is a special order for the buttons, then it works the way the Kadish Vault doors work (except that it requires every 6 buttons to be pressed, your puzzle requires only 5 out of 12).
I don't know exactly how many solutions there are, but brute force won't be of any help.



Another way is the hut door in Ahnonay's vortex: there is an order to push them, and buttons won't remain pushed. This way you just have to take the last 5 pressed buttons, and check if they are the five correct ones. There are now 5^12 solutions, if I remember my math lessons. I put these numbers in my calculator and it makes a happy face: 244.140.625 solutions, if I'm not mistaking.

Thanks for reading it through, I hope you understand what I mean...
User avatar
Sirius
 
Posts: 1506
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Re: Python code needed to implement a puzzle

Postby D'Lanor » Thu Jul 19, 2012 8:44 am

If I'm not mistaken I made a puzzle exactly like that for Jonnee's age Breldur. Unfortunately he has not logged in since I finished it and the code has been sitting unread in my outbox since April 2011. :( So I guess it will be OK if I send it to you as well.

I'll have to check if it does what you want later today, because it's been a while since I wrote it.
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Python code needed to implement a puzzle

Postby D'Lanor » Thu Jul 19, 2012 11:06 am

Yes, I think my code does what you need. It only took a very small change in the Python code. Check your PMs.
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Python code needed to implement a puzzle

Postby dendwaler » Thu Jul 19, 2012 1:55 pm

Thank you both for your replies!

Sirius i will think about what you said about the brute force method, i did not look to it that way.

First i will study the code D'Lanor sended to me .
When i don't succeed in getting it to work as intended, i will come back with more questions.

But you already helped me a bit further, thx!
Sorry that it is all a bit vague , but i do not want to spoil to much on the forum.
Those wonderfull Worlds are called " Ages" , because that is what it takes to build one.



Watch my latest Video Or even better..... watch the Cathedral's Complete Walkthrough made by Suleika!
User avatar
dendwaler
 
Posts: 936
Joined: Mon Jun 22, 2009 10:49 am
Location: Nederland


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests