luvcraft/terrain.lisp
A stable coordinate hash for terrain readings and discrete features.
Sample deterministic smooth value noise at integer world position X,Z.
Choose a visible biome material from height, moisture, and local slope.
Materialize one deterministic terrain chunk at vertical layer zero.
Place deterministic, sparse landmarks after neighboring terrain exists.
A broad, clipped lower crown and a small bright upper crown make silhouettes much less like identical green boxes.
Edit one resident site, recording it in world's source when supported.
Regenerate one chunk from source, then replay its explicit edits.
Materialize a square resident window and evict everything outside it.
Return the entering and leaving chunk-coordinate keys. Entering chunks are created as one staged transaction: establish all desired domains, materialize terrain, populate landmarks, then replay sparse edits.
Establish the whole neighborhood first so every later stage observes resident air rather than confusing a not-yet-created neighbor with it.
Make a deterministic square of resident terrain chunks and landmarks.
Make a sourced block world whose resident set is initially empty.
Capture deterministic landmarks whose owned sites lie inside key.
This retains the current visual generator while making chunk production independent: cross-boundary canopy sites are attributed to their destination chunk and do not require neighboring live mutation.
A destination chunk can receive a two-cell canopy overhang from a landmark rooted in an immediate neighbor.
(source x z &optional (salt 0))Addition over compatible quantities.
Multiplication and scalar scaling.
(source x z salt)Subtraction or unary negation.
Division of two represented quantities.
(reading)(left right amount)(source x z period &optional (salt 0))(source x z height)The maximum of compatible quantities.
The minimum of compatible quantities.
(source x z surface height)The componentwise absolute value of a raw value.
Test whether one compatible scalar is at least another.
Logical disjunction of tests and raw truth values.
Test whether one compatible scalar is at most another.
Test whether one compatible scalar is less than another.
(source world chunk-x chunk-y chunk-z)(source world chunk-x chunk-y chunk-z)(source world chunk-x chunk-y chunk-z)(source world block x y z)(source world chunk-x chunk-z)((world) &body body)(world x y z)(domain)(chunk offset)Test whether two compatible scalars are equal.
(source world chunk-x chunk-z)The non-negative remainder of integer division.
(world x y z)Return one site as BLOCK and :RESIDENT, or NIL and :ABSENT. This sparse world-coordinate accessor constructs coordinate descriptors and a chunk lookup key. It is appropriate for inspectors, ray hits, collision probes, and sparse interaction. Algorithms over many cells should select a chunk/domain once and use…
Logical conjunction of tests and raw truth values.
Test whether one compatible scalar is greater than another.
(world x y z)(overlay world chunk)(overlay block x y z)(block world x y z)(source world chunk-x chunk-z)(world x y z)(chunk)(x y z)(source world center-x center-z &key (radius 4))Materialize a square resident window and evict everything outside it. Return the entering and leaving chunk-coordinate keys. Entering chunks are created as one staged transaction: establish all desired domains, materialize terrain, populate landmarks, then replay sparse edits.
(world)(&key (chunk-radius 4)
(chunk-width 16)
(chunk-height 16)
(chunk-depth 16)
(seed 121))(&key (id (gensym "BLOCK-WORLD-"))
(chunk-width 16)
(chunk-height 16)
(chunk-depth 16)
(cell-extent 1d0)
source)(&key (chunk-width 16)
(chunk-height 16)
(chunk-depth 16)
(seed 121))(source world key)Capture deterministic landmarks whose owned sites lie inside KEY. This retains the current visual generator while making chunk production independent: cross-boundary canopy sites are attributed to their destination chunk and do not require neighboring live mutation.
The little world: deterministic terrain, landmarks, and recorded edits.
A
little-world-sourceis a pure function of its seed. Terrain heights and biome materials come from stable value noise, landmarks (rocks and trees) from coordinate hashes, and player edits from a sparse replayable overlay, so any chunk can be regenerated bit-identically on any thread.