Choosing random number but exclude a certain number?
Tiny_Ideas
Member Posts: 326
Good day everyone,
I have another question for you all,
I have five numbers , 1,2,3,4,5
I have an actor that changes to a random number from one to five.
However I would also like to have 'except' behaviour where it will not choose this number,
For example, randomvalue(1,5) but not select the number 3.
However that excluded number can change at any point.
Can this be done in a function if the excluded number is an attribute?
I also tried if self.number is equal to excluded. Number
Then random(1,5)
But this does not work for some reason. I think because once it picks 3 a second time it will not change again.
I am now looking for a way to have a random number but exclude a certain number. Perhaps use table cells?
I have another question for you all,
I have five numbers , 1,2,3,4,5
I have an actor that changes to a random number from one to five.
However I would also like to have 'except' behaviour where it will not choose this number,
For example, randomvalue(1,5) but not select the number 3.
However that excluded number can change at any point.
Can this be done in a function if the excluded number is an attribute?
I also tried if self.number is equal to excluded. Number
Then random(1,5)
But this does not work for some reason. I think because once it picks 3 a second time it will not change again.
I am now looking for a way to have a random number but exclude a certain number. Perhaps use table cells?
Comments
make another integer attribute and make a rule
if attribute1 = 1
change attribute2 to random(1,2)
else
if attribute1 = 2
change attribute2 to random(4,5)
hope this helped
✮ FREE templates at GSinvention ✮
✮ Available for hire! support@gsinvention.com ✮
I might have got that a little wrong (not at my computer so can't test) but that's the basic idea.
Quick demo (attached) - click on the white square to generate a new set of numbers - excluded number on the left - selection of a random number between 1-5 on the right (without choosing the excluded number).
I'm sure there's a ton of different ways to do this.
Hello
Sorry to bump the thread, but I was playing around with it and found an issue I couldn't resolve,
Your demo has it happening every time the actor is pressed.
I tried making a set excluded number, for example 1. And have it when pressed change to ((excluded number + random(1.4))%5) + 1
This, to my understanding have it so when the actor is pressed it should change to either 2,3.4,5
Yet it still comes up with 1 every now and then.
Can you share any light as to what I should be trying?
Edit: Never mind, I found the plus one was causing the issue
Keep on developing
Jeromy