multigrid.core.world_object module#
- class multigrid.core.world_object.WorldObj[source]#
Bases:
ndarray
Base class for grid world objects.
- Attributes:
- typeType
The object type
color
ColorReturn the object color.
state
StateReturn the name of the object state.
- containsWorldObj or None
The object contained by this object, if any
- init_postuple[int, int] or None
The initial position of the object
- cur_postuple[int, int] or None
The current position of the object
- TYPE = 0#
- COLOR = 1#
- STATE = 2#
- dim = 3#
- static __new__(cls, type: str | None = None, color: str = Color.red)[source]#
- Parameters:
- typestr or None
Object type
- colorstr
Object color
- static from_array(arr: ArrayLike[int]) 'WorldObj' | None [source]#
Convert an array to a WorldObj instance.
- Parameters:
- arrArrayLike[int]
Array encoding the object type, color, and state
- property state: str#
Return the name of the object state.
- toggle(env: MultiGridEnv, agent: Agent, pos: tuple[int, int]) bool [source]#
Toggle the state of this object or trigger an action this object performs.
- Parameters:
- envMultiGridEnv
The environment this object is contained in
- agentAgent
The agent performing the toggle action
- postuple[int, int]
The (x, y) position of this object in the environment grid
- Returns:
- successbool
Whether the toggle action was successful
- encode() tuple[int, int, int] [source]#
Encode a 3-tuple description of this object.
- Returns:
- type_idxint
The index of the object type
- color_idxint
The index of the object color
- state_idxint
The index of the object state
- class multigrid.core.world_object.Goal[source]#
Bases:
WorldObj
Goal object an agent may be searching for.
- class multigrid.core.world_object.Floor[source]#
Bases:
WorldObj
Colored floor tile an agent can walk over.
- class multigrid.core.world_object.Wall[source]#
Bases:
WorldObj
Wall object that agents cannot move through.
- class multigrid.core.world_object.Door[source]#
Bases:
WorldObj
Door object that may be opened or closed. Locked doors require a key to open.
- Attributes:
- is_open: bool
Whether the door is open
- is_locked: bool
Whether the door is locked
- static __new__(cls, color: str = Color.blue, is_open: bool = False, is_locked: bool = False)[source]#
- Parameters:
- colorstr
Object color
- is_openbool
Whether the door is open
- is_lockedbool
Whether the door is locked
- property is_open: bool#
Whether the door is open.
- property is_locked: bool#
Whether the door is locked.
- class multigrid.core.world_object.Key[source]#
Bases:
WorldObj
Key object that can be picked up and used to unlock doors.