Sorry for resurrection dead thread, but anyway (maybe it will help anyone :P)
Within the calculation I depend on the nCr function, which simply grows very rapidly (exponentially in fact); with 16379 or more attackers to simulate it overflows even the Extended floating point type. I'd have to look into a reasonable approximation for bigger numbers; the current "Sorry, that's not supported" is not acceptable
Well, the fact is nCr value is not needed here. The whole formula for chance is:
nCr * probability^r * (1 - probability)^(n-r)
and it sure the result is between 0 and 1. So all we have to do is to change operations order to keep numbers low. It should looks like this:
double Chance(int n, int r, double probability)
{
double result = 1;
int power1counter = 0;
int power2counter = 0;
for (var i = 0; i <= r; i++)
{
if (i > 0)
result = result * (n + 1 - i) / i;
while (result > 1 && power1counter < r) //reducing if needed
{
result = result * probability;
power1counter++;
}
while (result > 1 && power2counter < n-r) //reducing if needed
{
result = result * (1 - probability);
power2counter++;
}
}
while (power1counter < r)
{
result = result * probability;
power1counter++;
}
while (power2counter < n - r)
{
result = result * (1 - probability);
power2counter++;
}
return result;
}
Ofc. it will be slower, but it allow calculations for any number without using special types for big numbers.