spaceship/tests/test_biome_generation.gd
Loïc Wisniewski 85814ce88c Initial commit: SpaceshipTest, a top-down space RTS in Godot 4.7.1
A fleet of neon-outlined ships explores a procedurally generated, seeded
infinite world: tap/joystick steering, pinch zoom, formation pivoting,
planet landings, an ore economy with extractors and haulers, and player
built structures (mothership, ship crafter, command centre).

All art is hand-drawn with draw_* calls rather than textures, and the
backgrounds are camera-relative shaders so they stay precise at large
world coordinates.

Includes a 35-test headless suite (tests/run_tests.sh) plus screenshot
tooling that renders real frames through Xvfb and Mesa softpipe, since
--headless has no GPU.

Excluded from version control: .godot/ (import cache, and it holds
export credentials), builds/, android/build/ and packaged APKs - all
regenerable, and ~325 MB combined.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-10 18:41:58 +02:00

38 lines
1.3 KiB
GDScript

extends SceneTree
# Headless gameplay test: run with
# godot --headless -s res://tests/test_biome_generation.gd
# Verifies WorldGen's biome-per-chunk function is deterministic (querying
# the same chunk twice gives the same biome) and that the seeded noise
# field actually produces both biome types within a reasonably large
# sampled area - a regression guard against a threshold tuned so one biome
# never appears at all.
func _initialize() -> void:
var deterministic_ok: bool = true
for i in range(20):
var chunk: Vector2i = Vector2i(i * 3 - 10, i * 2 - 5)
var a: int = WorldGen.biome_at_chunk(chunk)
var b: int = WorldGen.biome_at_chunk(chunk)
if a != b:
deterministic_ok = false
print("FAIL: chunk %s gave %d then %d" % [chunk, a, b])
var space_count: int = 0
var asteroid_count: int = 0
for x in range(-25, 25):
for y in range(-25, 25):
var biome: int = WorldGen.biome_at_chunk(Vector2i(x, y))
if biome == WorldGen.Biome.SPACE:
space_count += 1
elif biome == WorldGen.Biome.ASTEROID_FIELD:
asteroid_count += 1
print("deterministic_ok=%s space_count=%d asteroid_count=%d" % [deterministic_ok, space_count, asteroid_count])
if deterministic_ok and space_count > 0 and asteroid_count > 0:
print("TEST_BIOME_GENERATION: PASS")
quit(0)
else:
print("TEST_BIOME_GENERATION: FAIL")
quit(1)