01.10.2020

+ Time controls (Stopwatch, Timers, Intervals)
+ Added smmeries to everything in SM.Base

~ Renamed Vectors to CVectors.
This commit is contained in:
Michel Fedde 2020-10-01 15:39:03 +02:00
parent 7acdba92f8
commit 97e638d9d9
44 changed files with 1092 additions and 289 deletions

View file

@ -2,20 +2,51 @@
namespace SM.Utility
{
/// <summary>
/// A global helper class for randomization.
/// </summary>
public class Randomize
{
/// <summary>
/// The randomizer.
/// </summary>
public static Random Randomizer = new Random();
/// <summary>
/// Sets the seed for the randomizer.
/// </summary>
/// <param name="seed">The specified seed.</param>
public static void SetSeed(int seed) { Randomizer = new Random(seed); }
public static bool GetBool(float tolerance) { return Randomizer.NextDouble() > tolerance; }
/// <summary>
/// Generates a double and checks if its under the tolerance.
/// </summary>
public static bool GetBool(float tolerance) { return Randomizer.NextDouble() < tolerance; }
/// <summary>
/// Generates a integer.
/// </summary>
public static int GetInt() { return Randomizer.Next(); }
/// <summary>
/// Generates a integer with a maximum.
/// </summary>
public static int GetInt(int max) { return Randomizer.Next(max); }
/// <summary>
/// Generates a integer with a minimum and maximum
/// </summary>
public static int GetInt(int min, int max) { return Randomizer.Next(min, max); }
/// <summary>
/// Generates a float between 0 and 1.
/// </summary>
public static float GetFloat() { return (float)Randomizer.NextDouble(); }
/// <summary>
/// Generates a float between 0 and the specified maximum.
/// </summary>
public static float GetFloat(float max) { return (float)Randomizer.NextDouble() * max; }
/// <summary>
/// Generates a float between the specified minimum and the specified maximum.
/// </summary>
public static float GetFloat(float min, float max) { return (float)Randomizer.NextDouble() * max + min; }
}