random
#1

Hi,

I use now random like that

new randomnumber = random( 10 );

but i want to make that numbers bellow 5 : 6 7 8 9 make chance that they will be random is bigger than others it's possible?
Reply
#2

I assume you want something like this, correct me if I'm wrong.

Код:
new firstrand = random(3)+1, secondrand;
if(firstrand == 1 || firstrand == 2) // 5, 6, 7, 8, 9 have 2/3 chances to come. ( 66.66% chances )
{
       secondrand = random(5)+5; // 5, 6, 7, 8, 9
}
else if(firstrand == 3) // 1, 2, 3, 4 have only 1/3 chances to come ( 33.33% chances )
{
       secondrand = random(4)+1; // 1, 2, 3, 4
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)