Code: Select all
count_min = 0,
count_max = 1,
probability = 1
The result is that nothing drops, ever.
Code: Select all
count_min = 0,
count_max = 2,
probability = 1
The result is that 50% of the time, nothing drops, the other 50% only 1 drops.
this is obviously wrong.
Theory: the random number generator is based on a floating point, where the literal values are between count_min and count_max. the problem is that you can't drop a fraction of an item, so in the case of 0 to 1, you almost never get an actual 0, or actual 1, there are thousands of possible results, so almost all the time it will land somewhere between the 2 points, meaning you'll get 0.99999 on the random generator, and still get 0 items drop.
I See 2 possible solutions:
1. replace the random number generator in such an instance with an integer random number generator, this could be done with a very simple function.
Code: Select all
return (rand() % max_count) + min_count
Another possible peice of code if you don't already have one is this extract from a peice of my own code
Code: Select all
inline int random(int min, int max)
{
return (int)((((long)(max + 1 - min) * rand()) / ((long)RAND_MAX + 1)) + min);
}
2. Use a round up/down function, so below 0.5 rounds down, and above 0.5 rounds up. in the case of min 0 and max 1, 0 to 0.5 will result in a 0, 0.5 to 1 will result in a 1. however in the case of 0 to 2, 0-0.5 and 1.5 to 2 will result in 0 and 2 respectively, but 0.5 to 1.5 will result in a 1. the chance of getting a 1 is twice as much as the chance to get a 0 or a 2, so not very ballanced.