View Single Post
Kraetos
Lovable Bastard
 
Join Date: Dec 2005
Location: Boston-ish
 
2009-10-04, 18:33

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
  quote