Class RepeatAction<TObs, TAct>
Steps the env num_repeats times with each action, sums the rewards, and returns the last step's
observation, flags and info, as Gymnasium's RepeatAction does: a lower decision frequency, for envs whose
agent need not act at every step. An episode that ends stops the repetition early.
public class RepeatAction<TObs, TAct> : Wrapper<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>Wrapper<TObs, TAct>RepeatAction<TObs, TAct>
- Implements
- Inherited Members
- Extension Methods
Remarks
Unlike StickyAction<TObs, TAct>, which replaces the agent's action by the previous one at random,
this repeats the current action deterministically. The rewards are summed as Python floats; the intermediate
observations are the env's and left to their owner. Gymnasium refuses a non-integer num_repeats with
TypeError; here it is a long.
Reference: gymnasium/wrappers/stateful_action.py.
Constructors
RepeatAction(Env<TObs, TAct>, RepeatActionOptions)
Builds the instance from its options record: the properties set, the constructor's defaults for the rest.
public RepeatAction(Env<TObs, TAct> env, RepeatActionOptions options)
Parameters
envEnv<TObs, TAct>The env to wrap.
optionsRepeatActionOptionsThe options.
Exceptions
- ArgumentNullException
Thrown when
optionsis null.- TypeError
Thrown when a required argument is unset, with Python's missing-argument message.
RepeatAction(Env<TObs, TAct>, long)
Wraps env.
public RepeatAction(Env<TObs, TAct> env, long numRepeats)
Parameters
Exceptions
- ValueError
Thrown for a count below 1:
The num_repeats value needs to be equal or greater than one, actual value: 0.- TypeError
Thrown when
envis null.
Properties
NumRepeats
The number of steps each action is taken (num_repeats).
public long NumRepeats { get; }
Property Value
SavedKwargs
The recorded constructor arguments, {'num_repeats': 4} (Python's _saved_kwargs).
[PyName("_saved_kwargs")]
public Info SavedKwargs { get; }
Property Value
Methods
Step(TAct)
Steps the env NumRepeats times with the action, stopping when the episode ends.
public override StepResult<TObs> Step(TAct action)
Parameters
actionTActThe action, repeated.
Returns
- StepResult<TObs>
The last step's observation, flags and info, and the summed reward.