W2: several lakes per worldlet, a beach block shelving into the sea with a current that turns swimmers back; testbay test worldlet through the water, edge and boundary suites; the two ways to play (journey, one land) recorded

This commit is contained in:
Paul Bailey
2026-11-06 16:48:20 +00:00
parent 68e6d814d9
commit 9b88a10609
9 changed files with 400 additions and 43 deletions

View File

@@ -19,18 +19,25 @@ const SEEDS := [1337, 1, 42, 777, 4242, 9001, 31337, 123456]
func _initialize() -> void:
_all.call_deferred()
## Each worldlet's edges (W2): the Valley, and a test worldlet with two
## ponds and a beach (tests/worldlets/testbay.json).
const WORLDLETS := ["valley", "testbay"]
func _all() -> void:
var failed := 0
for s in SEEDS:
var terrain: Node3D = load("res://scripts/world/terrain.gd").new()
terrain.noise_seed = s
root.add_child(terrain) # builds in _ready
var bad := _check(terrain)
print("seed %6d: %s" % [s, "ok" if bad == 0 else "%d bad samples" % bad])
if bad > 0:
failed += 1
terrain.free()
print("RESULT: %s (%d/%d seeds clean)" % ["PASS" if failed == 0 else "FAIL", SEEDS.size() - failed, SEEDS.size()])
for w in WORLDLETS:
for s in SEEDS:
var terrain: Node3D = load("res://scripts/world/terrain.gd").new()
terrain.noise_seed = s
terrain.worldlet_id = w
root.add_child(terrain) # builds in _ready
var bad := _check(terrain)
print("%-8s seed %6d: %s" % [w, s, "ok" if bad == 0 and terrain.worldlet_id == w else "%d bad samples" % bad])
if bad > 0 or terrain.worldlet_id != w:
failed += 1
terrain.free()
var n := WORLDLETS.size() * SEEDS.size()
print("RESULT: %s (%d/%d seeds clean)" % ["PASS" if failed == 0 else "FAIL", n - failed, n])
quit(1 if failed > 0 else 0)
func _check(terrain: Node3D) -> int:
@@ -42,7 +49,10 @@ func _check(terrain: Node3D) -> int:
while x < half:
var z := -half
while z < half:
if terrain.inside_boundary(x, z, 0.0) and not terrain.inside_boundary(x, z, BAND):
# (Off a beach the edge is open sea, and the current keeps you
# from the wall: tests/test_boundary.gd swims out there.)
if terrain.inside_boundary(x, z, 0.0) and not terrain.inside_boundary(x, z, BAND) \
and terrain.beach_weight(x, z) <= 0.5:
var h: float = terrain.sample_height(x, z)
# Hazard 1: a pit too deep to wade out of near the edge.
var too_deep: bool = h < terrain.water_level - MAX_EDGE_DEPTH