[Proc Gen] TileLayer - apply_threshold and apply_ranges for tile indices #200

Closed
opened 2026-01-12 00:08:49 +00:00 by john · 0 comments
Owner

Parent Issue: #192
Depends On: #193 (HeightMap core)

Overview

Add methods to TileLayer (GridLayer with tile data) for applying HeightMap data to tile indices.

Specification

def apply_threshold(self,
                    source: HeightMap,
                    range: tuple[float, float],
                    tile: int) -> TileLayer

Set tile index where source value is in range.

def apply_ranges(self,
                 source: HeightMap,
                 ranges: list[tuple]) -> TileLayer

Apply multiple tile assignments in a single pass.

Example

tiles.apply_threshold(terrain, range=(0.0, 0.3), tile=WATER_TILE)

tiles.apply_ranges(terrain, [
    ((0.0, 0.2), DEEP_WATER),
    ((0.2, 0.3), SHALLOW_WATER),
    ((0.3, 0.5), SAND),
    ((0.5, 0.7), GRASS),
    ((0.7, 0.85), ROCK),
    ((0.85, 1.0), SNOW),
])

Implementation Notes

  • HeightMap size must match layer dimensions
  • Ranges in apply_ranges are ((min, max), tile_index) tuples
  • Later ranges override earlier ones if overlapping
  • Cells not matching any range are left unchanged

Acceptance Criteria

  • apply_threshold sets tile indices correctly
  • apply_ranges handles multiple ranges
  • Visual verification with terrain tiles
  • Unit tests for tile assignment
**Parent Issue:** #192 **Depends On:** #193 (HeightMap core) ## Overview Add methods to TileLayer (GridLayer with tile data) for applying HeightMap data to tile indices. ## Specification ```python def apply_threshold(self, source: HeightMap, range: tuple[float, float], tile: int) -> TileLayer ``` Set tile index where source value is in range. ```python def apply_ranges(self, source: HeightMap, ranges: list[tuple]) -> TileLayer ``` Apply multiple tile assignments in a single pass. ### Example ```python tiles.apply_threshold(terrain, range=(0.0, 0.3), tile=WATER_TILE) tiles.apply_ranges(terrain, [ ((0.0, 0.2), DEEP_WATER), ((0.2, 0.3), SHALLOW_WATER), ((0.3, 0.5), SAND), ((0.5, 0.7), GRASS), ((0.7, 0.85), ROCK), ((0.85, 1.0), SNOW), ]) ``` ## Implementation Notes - HeightMap size must match layer dimensions - Ranges in `apply_ranges` are `((min, max), tile_index)` tuples - Later ranges override earlier ones if overlapping - Cells not matching any range are left unchanged ## Acceptance Criteria - [ ] `apply_threshold` sets tile indices correctly - [ ] `apply_ranges` handles multiple ranges - [ ] Visual verification with terrain tiles - [ ] Unit tests for tile assignment
john closed this issue 2026-01-12 03:35:52 +00:00
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
john/McRogueFace#200
No description provided.