public static float Range(MoRand rand, float min, float max) { float t = rand.GetFloat(); t = min * t + (1.0F - t) * max; return(t); }
public static bool Chance10000(MoRand rand, int value) { if (value <= 0) { return(false); } if (value >= 10000) { return(true); } return(Range(rand, 0, 10000) <= value); }
public static int Range(MoRand rand, int min, int max) { int dif; if (min < max) { dif = max - min; int t = (int)(rand.Get() % dif); t += min; return(t); } else if (min > max) { dif = min - max; int t = (int)(rand.Get() % dif); t = min - t; return(t); } else { return(min); } }