RogueSharp
Show / Hide Table of Contents

Class DotNetRandom

A class implementing IRandom which used for generating pseudo-random numbers using the System.Random class from the .Net framework

Inheritance
System.Object
DotNetRandom
Implements
IRandom
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: RogueSharp.Random
Assembly: RogueSharp.dll
Syntax
public class DotNetRandom : IRandom

Constructors

| Improve this Doc View Source

DotNetRandom()

Constructs a new pseudo-random number generator with a seed based on the number of milliseconds elapsed since the system started

Declaration
public DotNetRandom()
| Improve this Doc View Source

DotNetRandom(Int32)

Constructs a new pseudo-random number generator with the specified seed

Declaration
public DotNetRandom(int seed)
Parameters
Type Name Description
System.Int32 seed

An integer used to calculate a starting value for the pseudo-random number sequence

Methods

| Improve this Doc View Source

Next(Int32)

Gets the next pseudo-random integer between 0 and the specified maxValue inclusive

Declaration
public int Next(int maxValue)
Parameters
Type Name Description
System.Int32 maxValue

Inclusive maximum result

Returns
Type Description
System.Int32

Returns a pseudo-random integer between 0 and the specified maxValue inclusive

| Improve this Doc View Source

Next(Int32, Int32)

Gets the next pseudo-random integer between the specified minValue and maxValue inclusive

Declaration
public int Next(int minValue, int maxValue)
Parameters
Type Name Description
System.Int32 minValue

Inclusive minimum result

System.Int32 maxValue

Inclusive maximum result

Returns
Type Description
System.Int32

Returns a pseudo-random integer between the specified minValue and maxValue inclusive

Exceptions
Type Condition
System.ArgumentOutOfRangeException

Thrown if maxValue equals Int32.MaxValue

| Improve this Doc View Source

Restore(RandomState)

Restores the state of the pseudo-random number generator based on the specified state parameter

Declaration
public void Restore(RandomState state)
Parameters
Type Name Description
RandomState state

The state to restore to, usually obtained from calling the Save method

Examples

If you generated three random numbers and then called Save to store the state and followed that up by generating 10 more numbers before calling Restore with the previously saved RandomState the Restore method should return the generator back to the state when Save was first called. This means that if you went on to generate 10 more numbers they would be the same 10 numbers that were generated the first time after Save was called.

Exceptions
Type Condition
System.ArgumentNullException

RandomState cannot be null

| Improve this Doc View Source

Save()

Saves the current state of the pseudo-random number generator

Declaration
public RandomState Save()
Returns
Type Description
RandomState

A RandomState class representing the current state of this pseudo-random number generator

Examples

If you generated three random numbers and then called Save to store the state and followed that up by generating 10 more numbers before calling Restore with the previously saved RandomState the Restore method should return the generator back to the state when Save was first called. This means that if you went on to generate 10 more numbers they would be the same 10 numbers that were generated the first time after Save was called.

Implements

IRandom
  • Improve this Doc
  • View Source
RogueSharp © 2014-2020 Faron Bracy
Back to top