Class TransformReward<TObs, TAct>
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
TObsThe observation type, passed through.
TActThe 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
envEnv<TObs, TAct>The env.
Exceptions
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
envEnv<TObs, TAct>The env to wrap.
optionsTransformRewardOptionsThe options.
Exceptions
- ArgumentNullException
Thrown when
optionsis 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
envEnv<TObs, TAct>The env.
funcFunc<double, double>The transformation; null fails at the first step, as Python's
Nonedoes when called.
Exceptions
Properties
Func
The transformation (func).
[PyName("func")]
public Func<double, double> Func { get; protected set; }
Property Value
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
Methods
Reward(double)
Applies Func (reward(reward)).
public override double Reward(double reward)
Parameters
rewarddoubleThe env's reward.
Returns
- double
The transformed reward.