GridObject#

class curiosity_gym.core.objects.GridObject(position: tuple[int, int], color: int = 0, state: int = 0)#

Abstract class representing elements that can be placed in a grid environment.

It contains the attributes position, color, and state, which define the characteristics and behavior of the object. The class maintains a unique identifier for each subclass and provides default implementations of the reset(), simulate(), get_identity(), is_walkable() and is_harmful() methods. It enforces the implementation of a render() method by all subclasses.

Parameters:
  • position (tuple[int,int]) – Position in the grid where the object will be placed. Values must be in range (width - 1, height - 1).

  • color (int) – Color of the grid object. Values must be in range(0,10). Color mappings are defined in IX_TO_COLOR.

  • state (int) – State of the grid object. State characteristics vary by object type. Values must be in range(0,4).

Methods

get_identity

Return a tuple that identifies the grid object and its state in the enviroment.

interact

Interact with agent.

is_harmful

Determine whether grid object is harmful to the agent.

is_walkable

Determine whether agent can move on grid object.

render

Render grid object in PyGame.

reset

Reset attributes of the grid object to their starting values.

simulate

Simulate how grid object would change if a given action were taken.

step

Compute grid object changes after single timestep.

Attributes

id_map

Dictionary for all ids and their corresponding subclasses.

identifier

Unique id number for each subclass.