I figured it was something along these lines, but I thought there might be a better way to do it.
Here's the completed code:
Code:
public int runEvent()
{
double total = predators + competitors + food;
double pThreshold = predators / total;
double cThreshold = pThreshold + (competitors / total);
double eventSeed = (Math.random());
if (eventSeed <= pThreshold)
return 0; // predator
if (eventSeed <= cThreshold)
return 1; // competitor
return 2; // food
}
Thanks