prometeu-runtime/discussion/lessons/DSC-0016-tilemap-empty-cell-semantics/LSN-0022-tilemap-empty-cell-convergence.md

1.4 KiB

LSN-0022: Tilemap Empty Cell Semantics and Glyph Convergence

Context

During the initial runtime design, tile_id = 0 was used as a sentinel value for "empty" or "missing" tiles in tilemaps. However, as the asset banking and packer systems evolved, it became clear that 0 should be a valid index for any asset bank, including glyph banks. This conflict was formally tracked in AGD-0015.

Lessons Learned

1. Explicit Presence Over Magic Values

Modeling absence with a magic value (like tile_id = 0) creates friction when that value is also a valid member of the domain (index 0). The project moved towards explicit presence checks.

2. Convergence During Parallel Implementation

The resolution of the tilemap empty cell semantics (moving to explicit presence) was crystallized during the implementation of the glyph system. Instead of maintaining two different ways of handling "empty" slots, the tilemap logic was harmonized with the newer, cleaner approach used for glyphs and other render paths.

3. Impact on Render Pipeline

By allowing tile_id = 0 to be a valid tile, the render pipeline now relies on a separate bit or Option-like structure to determine if a cell should be drawn. This makes the code more robust and the asset indices more intuitive.

References

  • Discussion: DSC-0016
  • Agenda: AGD-0015 (Tilemap Empty Cell vs Tile ID Zero)
  • Implementation: Glyph system integration