Skip to content

SpaceInvaders-MinAtar

MinSpaceInvaders

MinSpaceInvaders(use_minimal_action_set: bool = True)

Bases: Environment[EnvState, EnvParams]

Shoot down waves of aliens with a cannon before they reach the bottom.

JAX port of the MinAtar Space Invaders environment. The player controls a cannon in the bottom row of a 10x10 grid and can shoot bullets at a block of 4x6 aliens. The aliens move across the screen until one of them hits the edge, at which point they all move down one row and switch direction. Every params.enemy_shot_interval steps, the lowest alien in the column closest to the cannon shoots back. The aliens move faster when only few of them are left; a single remaining alien moves one cell per step. When a wave is cleared, a new, slightly faster one spawns.

  • Observation: Box of shape (10, 10, 6) with binary channels: 0 cannon, 1 alien, 2 alien while the aliens move left, 3 alien while the aliens move right, 4 friendly bullet, 5 enemy bullet.
  • Actions: Discrete(4) with the minimal action set: 0 no-op, 1 left, 2 right, 3 fire. Discrete(6) with the full action set: 0 no-op, 1 left, 3 right, 5 fire; the actions 2 and 4 have no effect.
  • Reward: +1 for each alien shot.
  • Termination: an enemy bullet or an alien hits the cannon, or the aliens move down while one of them is already in the bottom row.
  • Truncation: after params.max_steps_in_episode steps (1000 by default).

Parameters:

  • use_minimal_action_set (bool, default: True ) –

    Whether to expose only the actions that have an effect in this game instead of all six MinAtar actions.

References

Parameters and state

EnvParams

Bases: EnvParams

Parameters of the Space Invaders environment.

Attributes:

  • shot_cool_down (int) –

    Number of steps between two shots of the cannon.

  • enemy_move_interval (int) –

    Initial maximum number of steps between alien moves.

  • enemy_shot_interval (int) –

    Number of steps between alien shots.

  • max_steps_in_episode (int) –

    Number of steps after which the episode is truncated.

EnvState

Bases: EnvState

State of the Space Invaders environment.

Attributes:

  • pos (int) –

    Column of the cannon.

  • f_bullet_map (Array) –

    Array of shape (10, 10) marking the bullets of the player.

  • e_bullet_map (Array) –

    Array of shape (10, 10) marking the bullets of the aliens.

  • alien_map (Array) –

    Array of shape (10, 10) marking the aliens.

  • alien_dir (int) –

    Horizontal direction of the aliens: -1 left, 1 right.

  • enemy_move_interval (int) –

    Current maximum number of steps between alien moves. Decreases by one for each cleared wave, down to 6.

  • alien_move_timer (int) –

    Steps left until the aliens move next.

  • alien_shot_timer (int) –

    Steps left until the aliens shoot next.

  • ramp_index (int) –

    Number of difficulty increases so far.

  • shot_timer (int) –

    Steps left until the cannon can fire again.

  • ramping (bool) –

    Whether clearing a wave makes the next one faster. Set to True on reset.

  • time (int) –

    Number of steps taken in the current episode.

  • terminal (bool) –

    Whether the episode has terminated.