Table of Contents

Class RepeatAction<TObs, TAct>

Namespace
Gym.Wrappers
Assembly
Gym.dll

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

TObs

The observation type, passed through.

TAct

The 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

env Env<TObs, TAct>

The env to wrap.

options RepeatActionOptions

The options.

Exceptions

ArgumentNullException

Thrown when options is 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

env Env<TObs, TAct>

The env.

numRepeats long

The number of steps each action is taken; at least 1.

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 env is null.

Properties

NumRepeats

The number of steps each action is taken (num_repeats).

public long NumRepeats { get; }

Property Value

long

SavedKwargs

The recorded constructor arguments, {'num_repeats': 4} (Python's _saved_kwargs).

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

Property Value

Info

Methods

Step(TAct)

Steps the env NumRepeats times with the action, stopping when the episode ends.

public override StepResult<TObs> Step(TAct action)

Parameters

action TAct

The action, repeated.

Returns

StepResult<TObs>

The last step's observation, flags and info, and the summed reward.