Table of Contents

Class TransformReward<TObs, TAct>

Namespace
Gym.Wrappers
Assembly
Gym.dll

Applies a function to every reward Step returns, as Gymnasium's TransformReward does.

public class TransformReward<TObs, TAct> : RewardWrapper<TObs, TAct>, IDynamicAttributes, IWrapper, IEnv, IDisposable, IRecordConstructorArgs

Type Parameters

TObs

The observation type, passed through.

TAct

The action type, passed through.

Inheritance
Env<TObs, TAct>
Wrapper<TObs, TAct, TObs, TAct>
RewardWrapper<TObs, TAct>
TransformReward<TObs, TAct>
Implements
Derived
Inherited Members
Extension Methods

Remarks

Rewards are doubles throughout Gym.NET, so the function maps a double to a double; Gymnasium's takes and returns anything that supports float().

Reference: gymnasium/wrappers/transform_reward.py.

Constructors

TransformReward(Env<TObs, TAct>)

Wraps env for a subclass that assigns Func and SavedKwargs in its own constructor.

protected TransformReward(Env<TObs, TAct> env)

Parameters

env Env<TObs, TAct>

The env.

Exceptions

TypeError

Thrown when env is null.

TransformReward(Env<TObs, TAct>, TransformRewardOptions)

Builds the instance from its options record: the properties set, the constructor's defaults for the rest.

public TransformReward(Env<TObs, TAct> env, TransformRewardOptions options)

Parameters

env Env<TObs, TAct>

The env to wrap.

options TransformRewardOptions

The options.

Exceptions

ArgumentNullException

Thrown when options is null.

TypeError

Thrown when a required argument is unset, with Python's missing-argument message.

TransformReward(Env<TObs, TAct>, Func<double, double>)

Wraps env.

public TransformReward(Env<TObs, TAct> env, Func<double, double> func)

Parameters

env Env<TObs, TAct>

The env.

func Func<double, double>

The transformation; null fails at the first step, as Python's None does when called.

Exceptions

TypeError

Thrown when env is null.

Properties

Func

The transformation (func).

[PyName("func")]
public Func<double, double> Func { get; protected set; }

Property Value

Func<double, double>

SavedKwargs

The recorded constructor arguments (Python's _saved_kwargs): a subclass's own, as Python records the first call's.

[PyName("_saved_kwargs")]
public Info SavedKwargs { get; protected set; }

Property Value

Info

Methods

Reward(double)

Applies Func (reward(reward)).

public override double Reward(double reward)

Parameters

reward double

The env's reward.

Returns

double

The transformed reward.

Exceptions

TypeError

Thrown when the function is null: 'NoneType' object is not callable.