Randoloot/tests/previews/surface_landmarks_test.gd
2026-10-18 08:43:54 +02:00

43 lines
2.0 KiB
GDScript

extends SceneTree
const GENERATOR := preload("res://scripts/planets/surface_generator.gd")
const LANDMARKS := preload("res://scripts/planets/surface_landmarks.gd")
const DETAILS := preload("res://scripts/planets/surface_details.gd")
func _initialize() -> void:
var counts := {}
for biome in 6:
var base := GENERATOR.generate(200+biome, {"temperature":75 if biome == 4 else (-35 if biome == 5 else 20)})
for tree in base.trees:
assert(float(tree.size) <= 92.0)
for sample_index in 40:
var data: Dictionary = base.duplicate(true)
data.seed = 20000+sample_index*6+biome
LANDMARKS.generate(data)
var snapshot := var_to_str(data.landmarks)
LANDMARKS.generate(data)
assert(snapshot == var_to_str(data.landmarks))
var hamlets := 0
var craters := 0
for landmark in data.landmarks:
counts[landmark.kind] = int(counts.get(landmark.kind,0))+1
hamlets += int(landmark.kind == "abandoned_hamlet")
craters += int(landmark.kind == "meteor_crater")
var radius := float(landmark.size)*0.55
assert(landmark.position.length() > radius+210)
for offset in [Vector2.ZERO, Vector2.LEFT, Vector2.RIGHT, Vector2.UP, Vector2.DOWN]:
assert(DETAILS._height(data, landmark.position+offset*radius) > 0.315)
for poi in data.pois:
assert(landmark.position.distance_to(poi.position) > 135+radius)
for event in data.events:
assert(landmark.position.distance_to(event.position) > 115+radius)
for other in data.landmarks:
if other != landmark:
assert(landmark.position.distance_to(other.position) > radius+float(other.size)*0.55)
for tree in data.trees:
assert(tree.position.distance_to(landmark.position) > float(landmark.size)*0.48+float(tree.size)*0.4)
assert(hamlets <= 1 and craters <= 1)
assert(counts.size() == 5)
assert(int(counts.abandoned_hamlet) > 0 and int(counts.abandoned_hamlet) < 35)
print("LANDMARK PASS: 240 maps, dry footprints, separated landmarks, clear interactions, reproducibility, smaller trees. Counts: ",counts)
quit()