3 unique random numbers needed. How? More challenging than you would think.
Hi Gamesaladers,
Here is a great puzzler for you! Generate 3 unique random numbers from the same set of numbers. Go!
x=rnd(1,25)
y=rnd(1,25)
z=rnd(1,25)
Seems simple so far, but here is the catch... none can be equal to each other!
How, I ask? How dear community, dose one check if it is equal - and then if it is equal, order another random number, then another, then another if need be... until satisfied with a unique one for x,y and z?
Was that too easy?! Then, may I then present the ULTIMATE mind bender for you!
Solve for w! w represents 1 of 10 widgets that we are choosing among. However, each potential widget may be locked or unlocked at any given time, and thus unavailable for selection. Ready... GO!
Let's imagine widgets 3,5,and 8 are locked right now! Generate for w!
w=rnd(1,10)
On no, the selected number 3 is locked. Regenerate! Oh yes, the selected number 5 is unlocked! We are clear and will take 5 for our w. How, my friends? How can you pull off something like THAT in GameSalad???
Do these questions seem too easy? Why am I using forum time for something so basic as random numbers? The reality is my inquiry goes much deeper then generating random numbers. I'm grappling with how logic works in general in Gamesalad. My specific confusion seems to center around how to handle loops. If the random number generated is not available, how do you go back and try again? I have made many, many attempts to model this with attributes. I have an attribute saying if all is good, move onto the next step, next step, next step, however if it is bad go back to an earlier step and regenerate a new random number. This "go back" point is where things break down in Gamesalad. My tests, show Gamesalad dose not do "go back." I think I need a new way to think about approaching this problem. But how? Also, my first 2 questions are real and I need to answer them before my game can move forward.
Optional reading: Background. I'm new here. I've been joyously learning Gamesalad all week. I'm trying to make a trivia game for toddlers. This requires some sort of "logic engine" to select a category, select a question, select alternative wrong answers, etc. I've wanted to engage the forum earlier, but I've been struggling with isolating my specific problems and then articulating my questions.
Thank you in advance,
CircleTime
Here is a great puzzler for you! Generate 3 unique random numbers from the same set of numbers. Go!
x=rnd(1,25)
y=rnd(1,25)
z=rnd(1,25)
Seems simple so far, but here is the catch... none can be equal to each other!
How, I ask? How dear community, dose one check if it is equal - and then if it is equal, order another random number, then another, then another if need be... until satisfied with a unique one for x,y and z?
Was that too easy?! Then, may I then present the ULTIMATE mind bender for you!
Solve for w! w represents 1 of 10 widgets that we are choosing among. However, each potential widget may be locked or unlocked at any given time, and thus unavailable for selection. Ready... GO!
Let's imagine widgets 3,5,and 8 are locked right now! Generate for w!
w=rnd(1,10)
On no, the selected number 3 is locked. Regenerate! Oh yes, the selected number 5 is unlocked! We are clear and will take 5 for our w. How, my friends? How can you pull off something like THAT in GameSalad???
Do these questions seem too easy? Why am I using forum time for something so basic as random numbers? The reality is my inquiry goes much deeper then generating random numbers. I'm grappling with how logic works in general in Gamesalad. My specific confusion seems to center around how to handle loops. If the random number generated is not available, how do you go back and try again? I have made many, many attempts to model this with attributes. I have an attribute saying if all is good, move onto the next step, next step, next step, however if it is bad go back to an earlier step and regenerate a new random number. This "go back" point is where things break down in Gamesalad. My tests, show Gamesalad dose not do "go back." I think I need a new way to think about approaching this problem. But how? Also, my first 2 questions are real and I need to answer them before my game can move forward.
Optional reading: Background. I'm new here. I've been joyously learning Gamesalad all week. I'm trying to make a trivia game for toddlers. This requires some sort of "logic engine" to select a category, select a question, select alternative wrong answers, etc. I've wanted to engage the forum earlier, but I've been struggling with isolating my specific problems and then articulating my questions.
Thank you in advance,
CircleTime
Comments
Generate X first
Generate Y
If Y = X, then generate Y again. Otherwise, generate Z.
Generate Z
If Z = X OR Z=Y
Generate Z again.
That should do it maybe.
Hope it helps,
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
also QS please check your PM
___________________________________________________
http://gshelper.com/
http://www.gamesaladforum.com/
@quantumsheep I will test this out. Thank you.
@BarrytheBrave I will watch this now. Thank you.
I am actively working on this now and will report back with progress. Any additional comments in the meantime are welcome.
CircleTime
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
I'm certain tshirtbooth's video will do the trick, but here's the way I worked out non-repeating sets of numbers. (I wonder if it's the same way as TSB's?)
I'll show just non-repeating 2 numbers so you get the gist of it, the Rules for the 3rd number follow the pattern of Rules for the second number with additions of course.
3 integer atts: x, y and z
2 integer atts: choice1, choice 2
boolean attribute: Juggle
Rule: When touch is pressed/released or when certain att. is true:
Change att scene.x to rand(1,25)
Change att scene.y to rand(1,25)
Rule:
When All valid:
att. scene.y = scene.x
att. scene.x =25
Change att. scene.y to rand(1,24)
Rule:
When All valid:
att. scene.y = scene.x
att. scene.x =1
Change att. scene.y to rand(2,25)
Rule:
When All valid:
att. scene.y = scene.x
att. scene.x does not equal 1
att. scene.x does not equal 25
Change att. scene.y To rand(1,scene.x-1)
Change att scene.choice1 to scene.y
Change att scene.y To rand(scene.x+1, 25)
Change att scene.choice2 to scene.y
Change att. scene.juggle To rand(0,1)
rule: when scene.Juggle is false
Change att. scene.y To scene.choice1
otherwise
Change att. scene.y To scene.choice2
---then the stuff for third number z (remembering to add: Change att scene.z to rand(1,25) to the very first Rule).
:-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Current Status: Actively studying / testing TSB's video and gyroscopes solution. Will post more updates as I progress.
As always, additional comments welcome.
CircleTime
Excellent feedback from everybody. Thank you.
I am completely enamored by TSB's video solution to use a timer firing off every 0 seconds to basically repeatedly execute and run checks on my random numbers. WOW!!! Love it, and have done some simple things with it thus far...
Here is the problem, on other posts, there has been plenty of warning about using timers because of a performance ding. How scared should I be? I would like to run a handful of checks with this timer for my trivia type game. I could use this method to prevent picking 2 identical questions in a row, and then to check if any of the 10 potential question categories are locked. I'm about to implement this... Any words of sage advice before I move forth.
I think all my checks for my trivia generation logic can be handled this way.
@TSB Cool, now I know how to adjust, only if my frame rate is suffering. Thank you!
Resolved.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
The timer allowed me to answer the part B of my original question - solving for w. Being game specific now, this means I can pick a trivia category 1-10 and not repeat. Also, I can individually check if each category is locked, and reject the locked categories. This is how far I have gotten.
The next step will be to pick a question in the given category - and then select 2 unique false answers. This is the x, y, z part, the 3 unique numbers. I assumed with the luck I had with timers so far, the good times would just continue to roll.
I will keep you posted on the progress.
Current status: studying gyroscope's original solution.
Any comments as I continue are welcome.
Matt
Matthewredler@gmail.com
Status update: Struggling. I think gyroscope has pointed me correctly for part A, it just takes me time to fiddle because I am so new to this. Thank you. Any additional feedback appreciated.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Status update: having fun working with gyroscopes ideas and reviewing NextGenEntertainment's awesome template.