Ejemplo n.º 1
0
 /// <summary>
 /// Determines if something happens based on a per mille chance.
 /// </summary>
 /// <param name="chance">The chance of something happening, between 0 and 1000.</param>
 /// <returns>Should something happen?</returns>
 public static bool PerMilleChance(double chance, PRNG prng = null)
 {
     return(Range(0d, 1000d, prng) < chance);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Generates a random number within a range (inclusive).
 /// </summary>
 /// <param name="min">The minimum.</param>
 /// <param name="max">The maximum.</param>
 /// <returns></returns>
 public static double Range(double min, double max, PRNG prng = null)
 {
     return((prng ?? PRNG).Range(min, max));
 }
Ejemplo n.º 3
0
 static RandomHelper()
 {
     PRNG = new PRNG((int)DateTime.Now.Ticks);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Generates a random number within a range (inclusive).
 /// </summary>
 /// <param name="min">The minimum.</param>
 /// <param name="max">The maximum.</param>
 /// <returns></returns>
 public static long Range(long min, long max, PRNG prng = null)
 {
     return((prng ?? PRNG).Range(min, max));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Generates a random number within a range (inclusive).
 /// </summary>
 /// <param name="min">The minimum.</param>
 /// <param name="max">The maximum.</param>
 /// <returns></returns>
 public static int Range(int min, int max, PRNG prng = null)
 {
     return((prng ?? PRNG).Range(min, max));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Generates a random number >= 0 but less than the upper bound.
 /// </summary>
 /// <param name="upper">The upper bound.</param>
 /// <returns></returns>
 public static double Next(double upper, PRNG prng = null)
 {
     return((prng ?? PRNG).Next(upper));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Generates a random number >= 0 but less than the upper bound.
 /// </summary>
 /// <param name="upper">The upper bound.</param>
 /// <returns></returns>
 public static long Next(long upper, PRNG prng = null)
 {
     return((prng ?? PRNG).Next(upper));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Generates a random number >= 0 but less than the upper bound.
 /// </summary>
 /// <param name="upper">The upper bound.</param>
 /// <returns></returns>
 public static int Next(int upper, PRNG prng = null)
 {
     return((prng ?? PRNG).Next(upper));
 }