RogueSharp
Show / Hide Table of Contents

Interface IRandom

An Interface for pseudo-random number generators to implement. Useful when mocking out systems for tests, as the the random number generator can be swapped for a mock implementation that returns known and expected values

Namespace: RogueSharp.Random
Assembly: RogueSharp.dll
Syntax
public interface IRandom
Remarks

Pseudo-random number generators are devices that produces a sequence of numbers that meet certain statistical requirements for randomness

Methods

| Improve this Doc View Source

Next(Int32)

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

Declaration
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
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

| Improve this Doc View Source

Restore(RandomState)

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

Declaration
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.

| Improve this Doc View Source

Save()

Saves the current state of the pseudo-random number generator

Declaration
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.

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