carve caves as GenCaves does, and check them block by block

A cave's course depends only on the seed and the chunk it starts in,
so each source chunk's tunnels are traced once, in its own
coordinates, as the ellipsoids they carve. A chunk is carved as the
game carves it: its eleven by eleven sources in order, each ellipsoid
skipped where the terrain's water or earlier lava is near, lava and
basalt below y 12 by geologic activity, the height map lowered where a
cave opens. The terrain now keeps whether each block is solid, which
makes the water exact; story locations keep caves away as theirs do.

vsmv verify compares every stored block below our surface: 96.1% of
the 18.5 million carved blocks agree, and of the rest all but 0.28%
are what later passes put in caves or made of air themselves, the
vugs and the block layers above all. Carving lifts the columns
matching the stored height by 71,379.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-10 15:34:00 +03:00
parent 2c16f8caef
commit aeb6d3be22
10 changed files with 930 additions and 11 deletions

View File

@@ -706,6 +706,60 @@ saltpeter, and 373 thousand other rock (halite, marble, obsidian,
travertine). That is what the deposits, caves and block layers wrote,
and what the deposits phase can be checked against.
** Caves (done)
=src/caves.sex= ports =GenCaves= (terrain pass, after the strata).
- *Starts.* =chunkRand= (world seed), positioned at the chunk, starts
a cave with chance 0.37: a position, size and shape from its draws,
then =caveRand= reseeded from it. Tunnels run 108 to 144 steps, so
they reach 5 chunks; they branch (horizontally, and at level 0 into
vertical shafts that end in a fan of tunnels), widen, flatten, go
tall, and near y 12 open lava caverns. =FastSin=/=FastCos= are the
game's 4096-entry tables.
- *Traced once.* A tunnel's course depends only on the seed and its
chunk. It is traced once per source chunk, as the ordered list of
=SetBlocks= ellipsoids, in the source chunk's coordinates. The game
works in the target chunk's coordinates; the double sums are exact
at that size, so the two differ by whole chunks only. World
coordinates would round.
- *Carved per chunk.* A target chunk replays its 11 x 11 sources in
=GenPartial='s order (x outer, z inner):
- Each ellipsoid that reaches the chunk is skipped if any liquid is
in it or one size around it: the water the terrain pass left in
every open block below sea level, or lava an earlier ellipsoid put.
- Below y 12 a carved block becomes basalt above
=geologic activity * 16 / 128= and lava at or below it. At y 11,
=basaltNoise= over 0.65 makes basalt.
- A carve at the column's height lowers it, which later carving
reads through =CaveHeightDistort=.
- Story locations skip caves for chunks whose centre lies in their
"caves" radius, or in the village's footprint (195 x 225; the
story schematics aren't in the assets read here).
- *Terrain solidity.* =terra/chunk-solidity= keeps every block's solid
or open from the height scan, so the water check is exact, overhang
pockets below sea level included.
- *Not ported.* Hot springs, which a later pass puts where caves
flagged them.
Validation (=vsmv verify=, every stored chunk, blocks below our
terrain height):
- 17,794,389 of our 18,521,333 carved blocks agree with the save
(96.08%): air or lava where the save has air (lava is a fluid, so its
solid block is air), basalt where it has basalt, or basalt a deposit
later made obsidian, ore or cracked rock. Of the rest, 667,823 hold
what later passes put in caves (stalactites, gravel, ice).
- Air the save has where we leave rock: 656,515 inside generated
structures (vugs above all), 292,212 at or above the save's surface
(the block layers take away top blocks, glaciers especially),
26,749 otherwise.
- Rock the save has where we carve air: 28,562 inside structures,
25,388 otherwise. The 52,137 unexplained are 0.28% of what we carve;
the check fails over 0.5%.
- The terrain's own pockets: 334,438 air blocks, 99.4% matching.
- Terrain height after carving: 11,552,740 of 11,687,936 columns match
the stored height, against 11,481,361 before. The caves make up most
of the "stored lower on land" columns of the height check.
** Next: deposits (planned)
Placing the deposits themselves, not just the pick's reading of them.
Soil deposits come first: they sit at the surface, so they don't need