Skip to content

Swimmer-misc

Swimmer

Swimmer(num_urchins: int = 5)

Bases: Environment[EnvState, EnvParams]

Swim to a goal position in the plane while keeping away from urchins.

The action sets the acceleration of the swimmer, which is integrated with step size params.dt. At every reset the positions of the urchins, the swimmer and the goal are sampled uniformly in [-1, 1] for both coordinates and the swimmer starts at rest. Urchins and goal stay fixed for the whole episode. Supports differentiable transitions via with_transition_gradients().

  • Observation: Box of shape (2 * num_urchins + 6,) with the urchin positions, the swimmer position, the swimmer velocity and the goal position.
  • Actions: Box of shape (2,) with bounds [-1, 1]. The acceleration of the swimmer in x and y.
  • Reward: exp(-0.5 * d**2), where d is the distance between swimmer and goal after the step, multiplied by 1 - exp(-30 * u**2) for every urchin at distance u from the swimmer.
  • Termination: never.
  • Truncation: after params.max_steps_in_episode steps (500 by default).

Parameters:

  • num_urchins (int, default: 5 ) –

    Number of urchins placed in the environment.

References

Parameters and state

EnvParams

Bases: EnvParams

Parameters of the Swimmer environment.

Attributes:

  • dt (float) –

    Duration of one step, used for Euler integration.

  • max_steps_in_episode (int) –

    Number of steps after which the episode is truncated.

EnvState

Bases: EnvState

State of the Swimmer environment.

Attributes:

  • urchin_xys (Array) –

    Array of shape (num_urchins, 2) with the (x, y) position of each urchin.

  • xy (Array) –

    Position of the swimmer as (x, y).

  • xy_vel (Array) –

    Velocity of the swimmer as (x, y).

  • goal_xy (Array) –

    Position of the goal as (x, y).

  • time (float) –

    Number of steps taken in the current episode.