# 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) } }