How to quickly and easily produce random numbers that will always be different each time.

ETGgamesETGgames Member, PRO Posts: 190

Just thought I'd let you guys know considering I can't really find anything on the forums, the next best alternative is using table. I just created an index attribute, call it index1. To get a random value thats always different, you do

change attribute index1 to (index1 + random(1,(max value - 1))%max value

Using simple modulus, this makes it easily achievable. Note how the minimum value of index1 will be 0, as modulus always starts at remainder of 0. You don't want the upper boundary of the random value to be the max value, because if the random function did in fact give the value as the max value you wanted, then you would get the same number, hence index1 would be the same two or more times, which is not what is wanted!!!

Comments

Sign In or Register to comment.