Table of Contents

Struct SpaceSeed

Namespace
Gym.Spaces
Assembly
Gym.dll

What a space constructor's seed accepts, Gymnasium's int | np.random.Generator | None: an integer seed for a fresh generator of the space's own, or an existing generator the space then shares. Callers never name this type: seed: 42, seed: someBigInteger and seed: generator convert implicitly, and a Nullable<T> null is None.

public readonly struct SpaceSeed : IEquatable<SpaceSeed>
Implements
Inherited Members
Extension Methods

Remarks

Sharing a generator couples two streams (each draw by one moves the other), which is why Gymnasium allows it only on purpose; generators are not synchronized, so a shared one must stay on one thread.

Properties

Generator

The generator to share, or null for an integer seed.

public Generator? Generator { get; }

Property Value

Generator

Value

The integer seed, when Generator is null.

public BigInteger Value { get; }

Property Value

BigInteger

Methods

Equals(SpaceSeed)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(SpaceSeed other)

Parameters

other SpaceSeed

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

Operators

implicit operator SpaceSeed?(Generator?)

A shared generator, or no seed for a null one: seed: maybeGenerator then means Gymnasium's seed=None when the variable is unset.

public static implicit operator SpaceSeed?(Generator? generator)

Parameters

generator Generator

The generator, or null.

Returns

SpaceSeed?

Remarks

The conversion targets Nullable<T> on purpose. Into the struct itself, a null generator would have to throw, and C# also routes a bare null literal through this operator wherever SpaceSeed is the natural type (x is null ? null : (SpaceSeed)x), which then threw on the branch meant to be "no seed".

implicit operator SpaceSeed(int)

An integer seed.

public static implicit operator SpaceSeed(int value)

Parameters

value int

The seed.

Returns

SpaceSeed

implicit operator SpaceSeed(long)

An integer seed.

public static implicit operator SpaceSeed(long value)

Parameters

value long

The seed.

Returns

SpaceSeed

implicit operator SpaceSeed(BigInteger)

An integer seed.

public static implicit operator SpaceSeed(BigInteger value)

Parameters

value BigInteger

The seed.

Returns

SpaceSeed

implicit operator SpaceSeed(ulong)

An integer seed.

public static implicit operator SpaceSeed(ulong value)

Parameters

value ulong

The seed.

Returns

SpaceSeed