HeightMap: core class with scalar operations (closes #193)

Implement the foundational HeightMap class for procedural generation:

- HeightMap(size, fill=0.0) constructor with libtcod backend
- Immutable size property after construction
- Scalar operations returning self for method chaining:
  - fill(value), clear()
  - add_constant(value), scale(factor)
  - clamp(min=0.0, max=1.0), normalize(min=0.0, max=1.0)

Includes procedural generation spec document and unit tests.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John McCardle 2026-01-11 20:07:55 -05:00
commit c095be4b73
5 changed files with 1586 additions and 1 deletions

View file

@ -21,6 +21,7 @@
#include "PyKeyboard.h"
#include "PyMouse.h"
#include "UIGridPathfinding.h" // AStarPath and DijkstraMap types
#include "PyHeightMap.h" // Procedural generation heightmap (#193)
#include "McRogueFaceVersion.h"
#include "GameEngine.h"
#include "ImGuiConsole.h"
@ -415,6 +416,9 @@ PyObject* PyInit_mcrfpy()
&mcrfpydef::PyAStarPathType,
&mcrfpydef::PyDijkstraMapType,
/*procedural generation (#192)*/
&mcrfpydef::PyHeightMapType,
nullptr};
// Types that are used internally but NOT exported to module namespace (#189)
@ -439,7 +443,11 @@ PyObject* PyInit_mcrfpy()
// Set up PySceneType methods and getsetters
PySceneType.tp_methods = PySceneClass::methods;
PySceneType.tp_getset = PySceneClass::getsetters;
// Set up PyHeightMapType methods and getsetters (#193)
mcrfpydef::PyHeightMapType.tp_methods = PyHeightMap::methods;
mcrfpydef::PyHeightMapType.tp_getset = PyHeightMap::getsetters;
// Set up weakref support for all types that need it
PyTimerType.tp_weaklistoffset = offsetof(PyTimerObject, weakreflist);
PyUIFrameType.tp_weaklistoffset = offsetof(PyUIFrameObject, weakreflist);