Island.generate(seed) builds a 513 x 513 heightfield (2 m spacing, the whole 1,024 m world) from the match seed's "worldgen" stream: a warped coastline, a coastal shelf and interior dome, two to four summits joined by ridges, rolling and rocky detail, and flattened marsh in wet lowland. Land is scaled so the tallest summit lands between ISLAND_PEAK_MIN and ISLAND_PEAK_MAX, under the last tide. Each sample gets an elevation band (sea, beach, marsh, forest, highland, summit) for terrain materials. - Simulation generates the island unless a test supplies its own ground, and spawns players on dry land until the drop arrives. - The headless server logs world_hash in its start line. - Island.heightmap_hash() is SHA-256 over millimetre heights and bands. - tools/island_map.gd draws a top-down map with tide contours. - New island constants in tuning.gd; GDD gains an island section. Tests: a 100-seed sweep checks generation time (slowest 617 ms against 5 s), land area, at least two distinct high points, walkable land, bands, and that no more than 3% of dry land is cut off at sea levels 0 and 8 m (worst seen 0.87%). A separate server process given only the seed must log the same heightmap hash. Closes #9 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
50 lines
2.0 KiB
GDScript
50 lines
2.0 KiB
GDScript
## Writes a top-down map of an island: band colours with hillshading and a contour line
|
|
## at each tide phase's sea level. For eyeballing worldgen, not for the game.
|
|
##
|
|
## tools/godot.sh --script res://tools/island_map.gd -- --seed=N --out=path.png
|
|
extends SceneTree
|
|
|
|
const COLOURS: Dictionary = {
|
|
Island.Band.SEA: Color(0.16, 0.29, 0.36),
|
|
Island.Band.BEACH: Color(0.82, 0.74, 0.55),
|
|
Island.Band.MARSH: Color(0.42, 0.47, 0.30),
|
|
Island.Band.FOREST: Color(0.27, 0.40, 0.22),
|
|
Island.Band.HIGHLAND: Color(0.50, 0.46, 0.38),
|
|
Island.Band.SUMMIT: Color(0.80, 0.78, 0.74),
|
|
}
|
|
|
|
|
|
func _init() -> void:
|
|
var seed_value: int = 1
|
|
var out: String = "res://captures/island.png"
|
|
for arg: String in OS.get_cmdline_user_args():
|
|
if arg.begins_with("--seed="):
|
|
seed_value = arg.get_slice("=", 1).to_int()
|
|
elif arg.begins_with("--out="):
|
|
out = arg.get_slice("=", 1)
|
|
var island: Island = Island.generate(seed_value)
|
|
var ground: SimGround = island.ground
|
|
var side: int = ground.samples
|
|
var image: Image = Image.create(side, side, false, Image.FORMAT_RGB8)
|
|
var light: Vector3 = Vector3(-1.0, 1.4, -1.0).normalized()
|
|
for gz: int in side:
|
|
for gx: int in side:
|
|
var x: float = gx * ground.cell
|
|
var z: float = gz * ground.cell
|
|
var height: float = ground.heights[gz * side + gx]
|
|
var colour: Color = COLOURS[island.bands[gz * side + gx]]
|
|
if height > 0.0:
|
|
var shade: float = clampf(ground.terrain_normal(x, z).dot(light), 0.0, 1.0)
|
|
colour = colour * (0.55 + 0.6 * shade)
|
|
for phase: Dictionary in Tuning.TIDE_PHASES:
|
|
if absf(height - float(phase["level"])) < 0.25:
|
|
colour = colour.darkened(0.45)
|
|
else:
|
|
colour = colour.lightened(clampf((height + 3.0) / 3.0, 0.0, 0.5))
|
|
image.set_pixel(gx, gz, colour)
|
|
DirAccess.make_dir_recursive_absolute(ProjectSettings.globalize_path(out).get_base_dir())
|
|
image.save_png(out)
|
|
print("seed %d -> %s, max %.1f m, %d summits, hash %s" % [
|
|
seed_value, out, island.max_height(), island.summits.size(), island.heightmap_hash()])
|
|
quit()
|