Skip to content

States

Bases: Positionable, HasColour

A struct representing an event that happened in the environment. It contains the position of the event, the colour of the entity involved in the event, whether the event happened, and the type of event that happened.

Note

Notice that we need the happened property, which flags if an event has happened or not, because JAX does not support variable size arrays. This means that we cannot add an event to the list in the middle of training. Instead, we initialise all events, and mask them out as not happened.

Attributes:

Name Type Description
position Array

The (row, column) position of the event in the grid.

colour Array

The colour of the entity involved in the event.

happened Array

A boolean flag indicating whether the event happened.

event_type Array

The type of event that happened.

Enumeration of the different types of events that can happen in the environment.

Bases: PyTreeNode

A struct that manages the events. It contains the different events that can happen in the environment, such as the goal being reached, the player being hit by a ball, etc.

Attributes:

Name Type Description
goal_reached Event

An event indicating that the goal has been reached.

ball_hit Event

An event indicating that the player has been hit by a ball.

wall_hit Event

An event indicating that the player has hit a wall.

lava_fall Event

An event indicating that the lava has fallen.

key_pickup Event

An event indicating that the player has picked up a key.

door_opening Event

An event indicating that the player has opened a door.

door_unlock Event

An event indicating that the player has unlocked a door.

ball_pickup Event

An event indicating that the player has picked up a ball.

Flags an event when the player is hit by a ball as happened and returns the updated events manager.

Parameters:

Name Type Description Default
ball Ball

The ball that hit the player.

required

Returns:

Name Type Description
EventsManager EventsManager

The updated events manager.

Flags an event when the player picks up a ball as happened and returns the updated events manager.

Parameters:

Name Type Description Default
ball Ball

The ball the player picked up.

required
position Array

The position of the ball in the grid.

required

Returns:

Name Type Description
EventsManager EventsManager

The updated events manager.

Flags an event when the player opens a door as happened and returns the updated events manager.

Parameters:

Name Type Description Default
door Door

The door the player opened.

required
position Array

The position of the door in the grid.

required

Returns:

Name Type Description
EventsManager EventsManager

The updated events manager.

Flags an event when the player unlocks a door as happened and returns the updated events manager.

Parameters:

Name Type Description Default
door Door

The door the player unlocked.

required
position Array

The position of the door in the grid.

required

Returns:

Name Type Description
EventsManager EventsManager

The updated events manager.

Flags an event when the player reaches the goal as happened and returns the updated events manager.

Parameters:

Name Type Description Default
goal Goal

The goal the player reached.

required
position Array

The position of the goal in the grid.

required

Returns:

Name Type Description
EventsManager EventsManager

The updated events manager.

Flags an event when the player hits a wall as happened and returns the updated events manager.

Parameters:

Name Type Description Default
position Array

The position of the wall in the grid.

required

Returns:

Name Type Description
EventsManager EventsManager

The updated events manager.

Flags an event when the player picks up a key as happened and returns the updated events manager.

Parameters:

Name Type Description Default
key Key

The key the player picked up.

required
position Array

The position of the key in the grid.

required

Returns:

Name Type Description
EventsManager EventsManager

The updated events manager.

Flags an event when the lava falls as happened and returns the updated events manager.

Parameters:

Name Type Description Default
lava Lava

The lava that fell.

required
position Array

The position of the lava in the grid.

required

Returns:

Name Type Description
EventsManager EventsManager

The updated events manager.

Flags an event when the player picks up an entity as happened and returns the updated events manager.

Parameters:

Name Type Description Default
entity Entity

The entity the player picked up.

required
position Array

The position of the entity in the grid.

required

Returns:

Name Type Description
EventsManager EventsManager

The updated events manager.

Flags an event when the player walks into an entity as happened and returns the updated events manager.

Parameters:

Name Type Description Default
entity Entity

The entity the player walked into.

required
position Array

The position of the entity in the grid.

required

Returns:

Name Type Description
EventsManager EventsManager

The updated events manager.

Flags an event when the player hits a wall as happened and returns the updated events manager.

Parameters:

Name Type Description Default
wall Wall

The wall the player hit.

required
position Array

The position of the wall in the grid.

required

Returns:

Name Type Description
EventsManager EventsManager

The updated events manager.

Bases: PyTreeNode

The Markovian state of the environment

The rendering cache to speed up rendering

The entities in the environment, indexed via entity type string representation. Batched over the number of entities for each type

A struct indicating which events happened this timestep. For example, the goal is reached, or the player is hit by a ball.

The base map of the environment that remains constant throughout the training

The random number generator state

Gets the ball entity from the state.

Gets the box entity from the state.

Gets the door entity from the state.

Get an entity from the state by its enum.

Parameters:

Name Type Description Default
entity_enum str

The enum of the entity to get.

required

Returns:

Name Type Description
Entity Entity

The entity from the state.

Gets the goal entity from the state.

Gets the key entity from the state.

Gets the lava entity from the state.

Gets the player entity from the state.

Get the positions of all the entities in the state.

Get the sprites of all the entities in the state.

Get the tags of all the entities in the state.

Get the transparency of all the entities in the state.

Gets all the WALL entities from the state.

Sets the ball entity in the state.

Sets the box entity in the state.

Sets the door entity in the state.

Set an entity in the state by its enum.

Parameters:

Name Type Description Default
entity_enum str

The enum of the entity to set.

required
entity Entity

The entity to set.

required

Returns:

Name Type Description
State State

The updated state.

Sets the events in the state.

Sets the goal entity in the state.

Sets the key entity in the state.

Sets the player entity in the state. Notice that we only support one player in the environment for now, but this can easily be extended to multiple players.

Sets the WALL entities in the state.