How to choose random variable

How do I…

grab a random variable and check if its true or not.

What is the expected result

to grab a random variable in a defined in a set list and check if its false. if it is false change it to true and do actions. if the chosen variable is true than try choosing another random variable until it finds one that isnt true.

What is the actual result

infinite loop

Related screenshots

The wait action doesn’t work in loops like While or for each… Timers and waits get updated in between frames. So, the events after the waits wouldn’t be triggered until after the while has finished which must not be happening.

Instead of picking a random number you can pick a random object from the objects who’s animation is named “Empty”. You then change the animation so it won’t get picked again. Once the button is clicked it changes all of the images just as a way to demonstrate the technique. It then stops when all 9 objects aren’t “Empty”

This uses 9 instances of the same object but you can use 9 separate objects in a group. They have 3 animations “Empty”, “X” and “O” although it doesn’t use “O”. It also uses 1 button just for testing. The button’s default label is “Play” which is just a way to prevent the button from being clicked while the animation and timer is running.

so as im doing this im looking at the example you gave and what im changing to use in mine is instead of X its O and instead animation its frame so that would in theory pick a random object that is on frame 0 from the group i created XorO and only have to be run once im guessing.

It will work with any condition or value that you can changed. Whether it’s an animation, a frame or a variable. It’s just a matter of changing the value so it’s ignored the next time.

Yes, you can do it just once per turn. As long as there’s an empty space it will always choose a valid object.

This was just an example to show different parts like counting objects.

i tried implementing it the issue now is freezing. im in the discord if you wanted to voice chat and i show the project screen

If you post a screenshot I’ll take a look at it.