ludic/packages/ludic.weather/bias.ludic
Orkuncakilkaya 71735b10a2 feat(base): 0.R4 - a queue keeps its own count, so every package verb takes only its own state; ludic migrate state --prune
ludic.base's Queue<T> carries a QueueTag (its name and pending count): queue_new(name), q_push(q, v),
q_drain(q), q_clear(q) take no BaseState, and core_undrained(tags) names the given queues still holding
facts. A reducer on a package's state can now call that package's verbs (wallet_earn(wallet_st, n)).

ludic migrate state --prune (ludicc --migrate-prune) takes out each state parameter a function no
longer uses, nor anything it calls, and the argument that fills it - including an argument for a
parameter the callee has dropped, which is taken out before the call is checked, so a generic's T is
told by the argument that says it. A reducer keeps its state. --dry-run now counts the edits it would
make. Every package was moved with it: 608 base_st parameters and their arguments, 1889 edits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 04:19:56 +03:00

42 lines
1.5 KiB
Text

# bias.ludic - the story leaning on the sky. Weather is a chain of chances, and a goal that needs
# rain could wait a week for it; so while the world says it wants a front, one is forecast and
# arrives within the hour and a half, and while it wants clear sky, the sky clears and holds.
function wx_front_kind() -> int {
return WeatherWorld.front()
}
function wx_want_wet(weather_st: mut WeatherState) -> void {
if weather_st.wx_kinds[weather_st.wx_state].wet or weather_st.wx_forced { return }
let front = wx_front_kind()
weather_st.wx_next = front
weather_st.wx_forecast = front
weather_st.wx_forced = true
if weather_st.wx_left > 1.5 { weather_st.wx_left = 1.5 }
wx_fact(weather_st, WEATHER_FRONT, front, weather_st.wx_state)
}
function wx_hold(weather_st: mut WeatherState) -> void {
if weather_st.wx_left < 1.2 {
weather_st.wx_left = 1.2
weather_st.wx_next = weather_st.wx_state
}
}
function wx_want_clear(weather_st: mut WeatherState) -> void {
let clear = wx_clear_kind(weather_st)
if weather_st.wx_state != clear and not weather_st.wx_forced {
if weather_st.wx_left > 0.5 { weather_st.wx_left = 0.5 }
weather_st.wx_next = clear
}
if weather_st.wx_state == clear and weather_st.wx_left < 1.0 {
weather_st.wx_left = 1.0
weather_st.wx_next = clear
}
}
function wx_apply_bias(weather_st: mut WeatherState) -> void {
let b = wx_bias()
if b == WEATHER_WANT_WET { wx_want_wet(weather_st) }
if b == WEATHER_HOLD { wx_hold(weather_st) }
if b == WEATHER_WANT_CLEAR { wx_want_clear(weather_st) }
}