Skip to content

Struct FDiscreteSpace

Struct FDiscreteSpace

  • Defined in File DiscreteSpace.h

Inheritance Relationships

Base Type

struct FDiscreteSpace : public FSpace

Source: Source/Schola/Public/Common/Spaces/DiscreteSpace.h

Dependencies: ConstSpaceVisitor, FPoint, SpaceVisitor

A struct representing a discrete space of possible observations or actions.

A discrete space represents a single choice from a finite set of options, numbered from 0 to High-1. This is commonly used for discrete action spaces where an agent selects from a fixed set of actions (e.g., move left, move right, jump).


Public Functions

SymbolDetails
FDiscreteSpaceConstructs an empty DiscreteSpace with High=0.
FDiscreteSpaceConstructs a DiscreteSpace with a specific upper bound.
CopyCopies the contents of another DiscreteSpace into this one.
GetMaxValueGets the index of the maximum value in an array.
GetNumDimensionsGets the number of dimensions in this space.
ValidateValidates that a point conforms to this space.
GetFlattenedSizeGets the flattened size of this space.
IsEmptyChecks if this space is empty.
AcceptAccepts a mutable visitor for the visitor pattern.
AcceptAccepts a const visitor for the visitor pattern.

FDiscreteSpace

FDiscreteSpace()

Constructs an empty DiscreteSpace with High=0.

Source: Source/Schola/Public/Common/Spaces/DiscreteSpace.h

Implementation: Source/Schola/Private/Common/Spaces/DiscreteSpace.cpp

FDiscreteSpace

inline FDiscreteSpace(int High)

Constructs a DiscreteSpace with a specific upper bound.

Parameters

High – The exclusive upper bound (number of discrete options).

Source: Source/Schola/Public/Common/Spaces/DiscreteSpace.h

Implementation: Source/Schola/Private/Common/Spaces/DiscreteSpace.cpp

Copy

void Copy(const FDiscreteSpace &Other)

Copies the contents of another DiscreteSpace into this one.

Parameters

Other – [in] The DiscreteSpace to copy from.

#DirectionNameTypeDescription
1Otherconst FDiscreteSpace &The DiscreteSpace to copy from.

Source: Source/Schola/Public/Common/Spaces/DiscreteSpace.h

Implementation: Source/Schola/Private/Common/Spaces/DiscreteSpace.cpp

GetMaxValue

int GetMaxValue(const TArray<float> &Vector) const

Gets the index of the maximum value in an array.

Parameters

Vector – [in] The vector to find the maximum value in.

Returns:

The index of the maximum value.

#DirectionNameTypeDescription
1Vectorconst TArray< float > &The vector to find the maximum value in.

Attributes: const

Source: Source/Schola/Public/Common/Spaces/DiscreteSpace.h

Implementation: Source/Schola/Private/Common/Spaces/DiscreteSpace.cpp

GetNumDimensions

virtual int GetNumDimensions() const override

Gets the number of dimensions in this space.

Returns:

Always returns 1 for discrete spaces.

Attributes: const, virtual

Source: Source/Schola/Public/Common/Spaces/DiscreteSpace.h

Implementation: Source/Schola/Private/Common/Spaces/DiscreteSpace.cpp

Validate

virtual ESpaceValidationResult
Validate(const TInstancedStruct<FPoint> &InPoint) const override

Validates that a point conforms to this space.

Parameters

InPoint – [in] The point to validate.

Returns:

Validation result indicating success or failure reason.

#DirectionNameTypeDescription
1InPointconst TInstancedStruct< FPoint > &The point to validate.

Attributes: const, virtual

Source: Source/Schola/Public/Common/Spaces/DiscreteSpace.h

Implementation: Source/Schola/Private/Common/Spaces/DiscreteSpace.cpp

GetFlattenedSize

virtual int GetFlattenedSize() const override

Gets the flattened size of this space.

Returns:

The value of High.

Attributes: const, virtual

Source: Source/Schola/Public/Common/Spaces/DiscreteSpace.h

Implementation: Source/Schola/Private/Common/Spaces/DiscreteSpace.cpp

IsEmpty

virtual bool IsEmpty() const override

Checks if this space is empty.

Returns:

True if High is 0, false otherwise.

Attributes: const, virtual

Source: Source/Schola/Public/Common/Spaces/DiscreteSpace.h

Implementation: Source/Schola/Private/Common/Spaces/DiscreteSpace.cpp

Accept

inline virtual void Accept(SpaceVisitor &InVisitor)

Accepts a mutable visitor for the visitor pattern.

Parameters

InVisitor – [inout] The visitor to accept.

#DirectionNameTypeDescription
1InVisitorSpaceVisitor &The visitor to accept.

Attributes: inline, virtual

Source: Source/Schola/Public/Common/Spaces/DiscreteSpace.h

Accept

inline virtual void Accept(ConstSpaceVisitor &InVisitor) const

Accepts a const visitor for the visitor pattern.

Parameters

InVisitor – [inout] The const visitor to accept.

#DirectionNameTypeDescription
1InVisitorSpaceVisitor &The visitor to accept.

Attributes: inline, virtual

Source: Source/Schola/Public/Common/Spaces/DiscreteSpace.h


Public Members

SymbolDetails
HighThe exclusive upper bound (maximum value + 1) for this discrete space.

High

int High = 0

The exclusive upper bound (maximum value + 1) for this discrete space.

The lower bound is always 0. For example, High=2 gives valid values {0,1}.