Random Number without repeating 2 numbers twice and without repeating itself during a cicle...
Hi everybody im quite new here and on the gamesalad world :-)
I'd like to know if anyone could help me with this...
I'm trying to create a random sequence of numbers, let's say 1 to 5. What i need is not to repeat them on a the same sequence twice.
I've seen a tutorial of tshirtbooth which helped me to avoid that 2 numbers repeat themselves in a row, but i need also that none of those numbers repeat untill the 5 of them have passed.
Thank you and Happy New Year!!!
Animus
I'd like to know if anyone could help me with this...
I'm trying to create a random sequence of numbers, let's say 1 to 5. What i need is not to repeat them on a the same sequence twice.
I've seen a tutorial of tshirtbooth which helped me to avoid that 2 numbers repeat themselves in a row, but i need also that none of those numbers repeat untill the 5 of them have passed.
Thank you and Happy New Year!!!
Animus
Comments
Welcome to the forums by the way!
-------
Gamesalad tutorials and free demos: http://www.thermo-apps.com/gamesalad
What i'm exactly trying to do is to create a sequence of background images that change randomly after a touch of the user. But I need to do it without having to change from one scene to another. I've seen a couple of tutorials about changing images without charging them (
The thing is that I'm not only needing to avoid repeating this images on a row but also not repeating them until the sequence of five images (to set an example) has finished.
i.e.:
Images 1, 4, 3 , 2, 5 (here should start another sequence) 3 , 2 , 5 , 4, 1 (here should start another sequence) 5 , 3 , 4, 2, 1
This would be wrong 1, 5, 4, 3, 5 because i'm repeating the number 5. Also this would be wrong 1,4,3,5,2 and then start the sequence of images on the same number 2, 4,5,3,1
I've been searching some tutorial about this and i've bought a template about changing scenes without repeating any but couldn't adapt it to do what i want.
Could you help me? Thanks a lot for your time!
Happy new year!! Animus Prografo
1 - Generate a random number between 1 and 5 and assign it to the attribute: "NewNumber"
2 - If "NewNumber" is equal to Num1, then go back to line one.
Otherwise - if "Num1" is equal to 0, change attribute "Num1" to equal "NewNumber"
3 - If "NewNumber" is equal to Num2, then go back to line one.
Otherwise - if "Num2" is equal to 0, change attribute "Num2" to equal "NewNumber"
4 - If "NewNumber" is equal to Num3, then go back to line one.
Otherwise - if "Num3" is equal to 0, change attribute "Num3" to equal "NewNumber"
... and so on.
Does that make any sense?
gameAttribute index type … name it currentNumber
either in rule or a timer (however you want to active the random)
I will use:
Rule: when
Event: touch is pressed
--changeAttribute: game.currentNumber To: random(1,5)
--Rule: when (this is nested in the touch rule)
---Attribute: game.pickedNumbers contains game.currentNumber
----changeAttribute: game.currentNumber To: random(1,5)
--Otherwise: (to the nested rule)
----changeAttribute: game.pickedNumbers To: game.pickedNumbers.." "..game.currentNumber
(to get the spaces in the expressionEditor … [option]+[spaceBar] )
think of what you want the computer to do
-changeAttribute to a random number
-check that the random number hasn't been used
--when used … pick another
--when not used … store it, so it wont be used again
@};- MH