ratios

GameBoy
31 Mar 2005, 07:14
when using the random number function, is there way you can use ratios to determine how much the user will get the top number?

francisstokes
03 Apr 2005, 18:43
because its a random number theres no way to determine this.

davidw
03 Apr 2005, 20:24
I'd have thought it depended on how many numbers there are.

6 numbers: 1/6 chance that it'll be the top number.

paul_one
03 Apr 2005, 23:26
Add the ratio's together... Let's say that there's 6 ratio's:
1. 4/10
2. 6/10
3. 2/10
4. 9/10
5. 2/10
6. 1/10

so that's 4+6+2+9+2+1 = 24.
random number between 1 and 24, then go through like so:

number = number + ratio[index number]
if random number < number and flag 'found' off then:
== set flag found on
== set chosen ratio = index number
index number = index number + 1
repeat

You'd put something like that into a loop, and it'd go through the ratio's.