Skip to content

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.

Smallest supported tile edge, in pixels.

Directory the .png sprite files are loaded from.

The loaded sprites: dict from an Entities name ("wall", "key", "door", ...) to a uint8 sprite array. State.get_sprites reads it.

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.

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.

Sentinel for "no colour" - used by colourless entities and empty event slots. Not a real palette index.

[RED, GREEN, BLUE, PURPLE, YELLOW, GREY] - the index values in the same order as as_string.

The colour names in index order: ["red", "green", "blue", "purple", "yellow", "grey"]. Sprite files are named <entity>_<name>.png.

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.

Builds the registry immediately (reads the PNG files).

Loads and stores the sprite array for every entity type. Each set_*_sprite helper populates one registry key.

Loads assets/sprites/<name>.png, resized to TILE_SIZE.

Parameters:

Name Type Description Default
name str

sprite basename without extension, e.g. "key_red".

required

Returns:

Name Type Description
Array Array

u8[TILE_SIZE, TILE_SIZE, 3].