Entities
Ball
Directions
Directions enum class to store the directions in the game.
Door
Bases: Entity
, Openable
, HasColour
Consumable items are world objects that can be consumed by the player.
Consuming an item requires a tool (e.g. a key to open a door).
A tool is an id (int) of another item, specified in the requires
field (-1 if no tool is required).
After an item is consumed, it is both removed from the state.entities
collection, and replaced in the grid
by the item specified in the replacement
field (0 = floor by default).
Examples of consumables are doors (to open) food (to eat) and water (to drink), etc.
Entities
Bases: PyTreeNode
Entities enum class to store the names of the entities in the game.
Entity
Bases: Positionable
, HasTag
, HasSprite
Entities are components that can be placed in the environment, and have a position and a tag.
To create an entity, use the create
method.
name: str
property
The name of the entity
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the name of the entity |
ndim: int
property
The number of dimensions of the entity. The number of dimensions is the number of dimensions of the position minus 1.
shape: Tuple[int, ...]
property
The batch shape of the entity. The batch shape is the shape of the entity excluding the dimensions of the component. For example, if the entity has a position of shape (batch_size, 2), the shape of the entity is (batch_size,).
transparent: Array
property
The transparent attribute of the entity. The transparent attribute is a boolean array that indicates if the entity is transparent to rendering.
walkable: Array
property
The walkable attribute of the entity. The walkable attribute is a boolean array that indicates if the entity can be walked on.
EntityIds
EntityIds enum class to store the ids of the entities in the game.