ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic 1804 vars into 126 states, 64 into lets; 23498 edits in 460 files Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
1.6 KiB
Text
42 lines
1.6 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(base_st: mut BaseState, 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(base_st, 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(base_st: mut BaseState, weather_st: mut WeatherState) -> void {
|
|
let b = wx_bias()
|
|
if b == WEATHER_WANT_WET { wx_want_wet(base_st, weather_st) }
|
|
if b == WEATHER_HOLD { wx_hold(weather_st) }
|
|
if b == WEATHER_WANT_CLEAR { wx_want_clear(weather_st) }
|
|
}
|