Random non-repeating variables

Hey there,

I’m creating a card game with questions and cards. I have a list of questions and want them to show up as a text object. When the game mode starts, one random question shows up. If you click on the question, the next random question out of the list shows up, but the questions are not allowed to repeat and that’s my problem. How to programe it, so that the questions out of the list do not repeat and the game ends when there no more questions ? I tried it several times but had no success. In the screenshot you see one of my fails. I hope you can help me

Use the Array Tools extension to shuffle the array of questions. Use a variable (say named question_number) which starts at 0. Every time a question is clicked, increment the question_number variable until it equals the number of children in the question array.

1 Like

A few days ago I had the same problem.

And I found two solutions.
1º As the previous post says, you should use the “array tools” extension
2º Another solution is to use the Fisher - Yates algorithm. there is a video.

In both options what you have to do is sort the “array” and then associate the chosen index to an object. Choosing the object by name is the best option. There is also a video.

Thank you very much. That helped me out!