P4 hazards: food spoilage with rot speed setting, smoking rack and salt, food poisoning, harsher blizzards, hard winters with lake ice, lightning on trees, snow on roofs (protocol 11)

This commit is contained in:
Paul Bailey
2026-11-05 11:49:13 +00:00
parent 657c3140fe
commit 3389ec9a21
27 changed files with 1541 additions and 56 deletions

View File

@@ -59,20 +59,27 @@ func _weather_model() -> void:
var cold_days := 0
var snow_on_warm_day := false
var days := 60
var samples := 0
var t := 0.0
while t < days * 1200.0:
var s: String = wa.state_at(t)
if s != wb.state_at(t):
same = false
counts[s] = counts.get(s, 0) + 1
var day := int(t / 1200.0) + 1
if not wa.hard_winter(day): # (the mix over ordinary days; hard winters lean snowy)
counts[s] = counts.get(s, 0) + 1
samples += 1
if s in ["snow", "blizzard"] and not wa.is_cold_day(day):
snow_on_warm_day = true
t += 20.0
var ordinary := 0
for d in range(1, days + 1):
if wa.hard_winter(d):
continue # (P4's hard winters are always cold: tests/test_hazards.gd)
ordinary += 1
if wa.is_cold_day(d):
cold_days += 1
var total := float(days * 60)
var total := float(samples)
var frac := func(names: Array) -> float:
var n := 0
for k in names:
@@ -84,7 +91,7 @@ func _weather_model() -> void:
check(wet > 0.2 and wet < 0.4, "rain or snow about 30%% of the time (%.0f%%)" % (wet * 100))
var hard: float = frac.call(["storm", "blizzard"])
check(hard > 0.04 and hard < 0.16, "storms about 10%% of the time (%.0f%%)" % (hard * 100))
check(cold_days >= 8 and cold_days <= 24, "about a quarter of days are cold (%d of %d)" % [cold_days, days])
check(cold_days >= ordinary * 0.12 and cold_days <= ordinary * 0.4, "about a quarter of ordinary days are cold (%d of %d)" % [cold_days, ordinary])
check(not snow_on_warm_day, "it only snows in the valley on cold days")
check(wa.state_at(0.0) == "clear" and wa.state_at(500.0) == "clear", "a new world starts with clear weather")
var other: Node = load("res://scripts/world/weather.gd").new()