[Proc Gen] HeightMap - Core class with scalar operations #193

Closed
opened 2026-01-12 00:07:42 +00:00 by john · 0 comments
Owner

Parent Issue: #192

Overview

Implement the foundational HeightMap class - a 2D grid of float values that serves as the universal canvas for procedural generation.

Specification

Constructor

HeightMap(size: tuple[int, int], fill: float = 0.0)

Properties

Property Type Description
size (int, int) Read-only. Width and height of the heightmap.

Scalar Operations

All operations mutate in place and return self for chaining.

def fill(self, value: float) -> HeightMap
def clear(self) -> HeightMap  # Equivalent to fill(0.0)
def add_constant(self, value: float) -> HeightMap
def scale(self, factor: float) -> HeightMap
def clamp(self, min: float = 0.0, max: float = 1.0) -> HeightMap
def normalize(self, min: float = 0.0, max: float = 1.0) -> HeightMap

Implementation Notes

  • Wrap TCODHeightMap internally
  • Store as contiguous float array (4 bytes per cell)
  • Size is immutable after construction
  • normalize() maps to TCOD_heightmap_normalize

Acceptance Criteria

  • HeightMap can be constructed with size tuple
  • size property returns correct dimensions
  • All scalar operations work and return self
  • Chaining works: hmap.fill(0.5).scale(2.0).clamp(0.0, 1.0)
  • Unit tests in tests/unit/test_heightmap_basic.py
**Parent Issue:** #192 ## Overview Implement the foundational `HeightMap` class - a 2D grid of float values that serves as the universal canvas for procedural generation. ## Specification ### Constructor ```python HeightMap(size: tuple[int, int], fill: float = 0.0) ``` ### Properties | Property | Type | Description | |----------|------|-------------| | `size` | `(int, int)` | Read-only. Width and height of the heightmap. | ### Scalar Operations All operations mutate in place and return `self` for chaining. ```python def fill(self, value: float) -> HeightMap def clear(self) -> HeightMap # Equivalent to fill(0.0) def add_constant(self, value: float) -> HeightMap def scale(self, factor: float) -> HeightMap def clamp(self, min: float = 0.0, max: float = 1.0) -> HeightMap def normalize(self, min: float = 0.0, max: float = 1.0) -> HeightMap ``` ## Implementation Notes - Wrap `TCODHeightMap` internally - Store as contiguous float array (4 bytes per cell) - Size is immutable after construction - `normalize()` maps to `TCOD_heightmap_normalize` ## Acceptance Criteria - [ ] `HeightMap` can be constructed with size tuple - [ ] `size` property returns correct dimensions - [ ] All scalar operations work and return self - [ ] Chaining works: `hmap.fill(0.5).scale(2.0).clamp(0.0, 1.0)` - [ ] Unit tests in `tests/unit/test_heightmap_basic.py`
john closed this issue 2026-01-12 01:28:38 +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#193
No description provided.