PseudoRandom ClassDelta Engine Documentation
Default implementation of Randomizer, returns quick random integers and floats (faster than System.Random). See http://www.codeproject.com/Articles/25172/Simple-Random-Number-Generation which is based on: http://www.bobwheeler.com/statistics/Password/MarsagliaPost.txt View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.Core Randomizer
    DeltaEngine.Core PseudoRandom

Namespace: DeltaEngine.Core
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class PseudoRandom : Randomizer

The PseudoRandom type exposes the following members.

Constructors

  NameDescription
Public methodPseudoRandom
Initializes a new instance of the PseudoRandom class
Top
Methods

  NameDescription
Public methodGet(Int32, Int32) (Overrides Randomizer Get(Int32, Int32).)
Public methodGet(Single, Single) (Overrides Randomizer Get(Single, Single).)
Top
Remarks

Tests: DeltaEngine.Tests.Core.PseudoRandomTests
Examples

4 unit tests call DeltaEngine.Core.PseudoRandom
[Test]
public void UseDefaultRandomizer()
{
    Assert.Less(Randomizer.Current.Get(1, 100), 100);
}
[Test]
public void GetRandomBrightColorUsingFixedRandomValues()
{
    using (Randomizer.Use(new FixedRandom(new[] { 0.0f, 0.5f})))
    {
        Assert.AreEqual(0, Randomizer.Current.Get(0, 10));
        Assert.AreEqual(5, Randomizer.Current.Get(0, 10));
        Assert.AreEqual(2, Randomizer.Current.Get(2, 4));
    }
}
[Test, Category("Slow")]
public void RandomIntSanityTest()
{
    var random = new PseudoRandom();
    const int Max = 10;
    var wasChosen = new bool[Max];
    const int Trials = Max * 1000;
    for (int i = 0; i < Trials; i++)
        wasChosen[random.Get(0, Max)] = true;
    for (int i = 0; i < Max; i++)
        Assert.IsTrue(wasChosen[i]);
}
See Also