API Reference › Map — tilemap › Map.random_cell
method

Map.random_cell

Map.random_cell(glyph: g) -> IVec2

Picks a random cell whose glyph matches: random tries first, then a sweep, so a map with any such cell always yields one; (-1, -1) when none exists. Deterministic, from the seeded RNG.

Example

# doc-check: skip — illustrative
let tile = Map.random_cell(glyph: '.')
Spawn.enemy(kind, IVec2.scale(tile, 16))
← All symbols