So, the Random command returns a random number between 0 and MAX.
But how would I make it return a random number between some specified minimum value higher than 0 and MAX?
Quote from: tor.brandt on Mon 19/12/2016 09:29:08
So, the Random command returns a random number between 0 and MAX.
But how would I make it return a random number between some specified minimum value higher than 0 and MAX?
Make it return value between 0 and (MAX - MIN), then add MIN to random result.
E.g. you need value between 10 and 20, do "Random(10) + 10".
Or write convenience function
int RandomMinMax(int min, int max)
{
return Random(max - min) + min;
}
Quote from: Crimson Wizard on Mon 19/12/2016 10:06:32
Make it return value between 0 and (MAX - MIN), then add MIN to random result.
E.g. you need value between 10 and 20, do "Random(10) + 10".
Aahhh yes, of course. So simple, and yet so very very hard for my brain to grasp (laugh)
Thanks!