using System;
using System.Collections.Generic;
namespace GlitchyEngine.Math;
public static class RandomExtension
{
/// Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0.
/// A double-precision floating point number that is greater than or equal to 0.0, and less than 1.0.
public static float NextFloat(this Random random) => (float)random.NextDouble();
/// Returns a random integer that is within a specified range.
///
/// The inclusive lower bound of the random number returned.
/// The exclusive upper bound of the random number returned. must be greater than or equal to .
/// A 32-bit signed integer greater than or equal to and less than ; that is, the range of return values includes but not . If equals , is returned.
/// is greater than .
public static int Range(this Random random, int min, int max) => random.Next(min, max);
/// Returns a random floating-point number that is within a specified range.
///
/// The inclusive lower bound of the random number returned.
/// The exclusive upper bound of the random number returned. must be greater than or equal to .
/// A 32-bit signed integer greater than or equal to and less than ; that is, the range of return values includes but not . If equals , is returned.
/// is greater than .
public static float Range(this Random random, float min, float max) => (float)(random.NextDouble() * (max - min) + min);
/// Returns a random floating-point number that is within a specified range.
///
/// The inclusive lower bound of the random number returned.
/// The exclusive upper bound of the random number returned. must be greater than or equal to .
/// A 32-bit signed integer greater than or equal to and less than ; that is, the range of return values includes but not . If equals , is returned.
/// is greater than .
public static double Range(this Random random, double min, double max) => random.NextDouble() * (max - min) + min;
///
/// Picks a random element from the given list.
///
///
/// The list to pick an element from.
/// The type of elements in the list.
/// The randomly picked element.
public static T Pick(this Random random, IList list) => list[random.Range(0, list.Count)];
}