Registry
The colour palette and the on-disk sprite tiles used to render rgb
observations. Everything is loaded once at import into the module-level
SPRITES_REGISTRY.
MIN_TILE_SIZE = 8
module-attribute
Smallest supported tile edge, in pixels.
SPRITES_DIR = os.path.normpath(os.path.join(__file__, '..', '..', '..', 'assets', 'sprites'))
module-attribute
Directory the .png sprite files are loaded from.
SPRITES_REGISTRY = SpritesRegistry().registry
module-attribute
The loaded sprites: dict from an Entities name ("wall", "key",
"door", ...) to a uint8 sprite array. State.get_sprites reads it.
TILE_SIZE = MIN_TILE_SIZE
module-attribute
Edge length (pixels) of one rendered grid cell. An rgb observation
of an H x W grid is H * TILE_SIZE by W * TILE_SIZE.
PALETTE
The six entity colours, as uint8 indices. HasColour.colour
holds one of these; it is the colour channel of a symbolic
observation and selects the coloured sprite variant for rgb.
UNSET = jnp.asarray(255, dtype=jnp.uint8)
class-attribute
instance-attribute
Sentinel for "no colour" - used by colourless entities and empty event slots. Not a real palette index.
as_array()
classmethod
[RED, GREEN, BLUE, PURPLE, YELLOW, GREY] - the index values
in the same order as as_string.
as_string()
classmethod
The colour names in index order: ["red", "green", "blue",
"purple", "yellow", "grey"]. Sprite files are named
<entity>_<name>.png.
SpritesRegistry
Loads every entity sprite from disk into a dict keyed by
Entities name. Coloured / directional entities map to a stacked
array (leading axis = colour, or direction, or (colour, state) for
doors). Instantiated once at import as SPRITES_REGISTRY.
__init__()
Builds the registry immediately (reads the PNG files).
build_registry()
Loads and stores the sprite array for every entity type. Each
set_*_sprite helper populates one registry key.
load_sprite(name)
Loads assets/sprites/<name>.png, resized to TILE_SIZE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
sprite basename without extension, e.g. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Array |
Array
|
|