diff --git a/packages/ludic.wildlife/species.ludic b/packages/ludic.wildlife/species.ludic index 64940c78..bf15a1bd 100644 --- a/packages/ludic.wildlife/species.ludic +++ b/packages/ludic.wildlife/species.ludic @@ -59,6 +59,8 @@ export state WildlifeState { wl_hold: bool = false # staged: nobody thinks, everybody keeps their speed wl_spot_ask: WildSpot = new WildSpot wl_turned: int = 0 # steps refused and turned 75 degrees instead: the fallback, counted + wl_turned_wet: int = 0 # of those, for water ahead + wl_turned_steep: int = 0 # for a climb too steep } function wl_sp_all(wildlife_st: WildlifeState) -> []WildSpecies { diff --git a/packages/ludic.wildlife/steer.ludic b/packages/ludic.wildlife/steer.ludic index b3cba573..14a803ec 100644 --- a/packages/ludic.wildlife/steer.ludic +++ b/packages/ludic.wildlife/steer.ludic @@ -16,6 +16,9 @@ function wl_face(a: WildAnimal, tx: float, tz: float, rate: float, dt: float) -> # true when it moved; a walker is slid round a still thing (a trunk, a tent), a bird is not # how many steps were refused and turned from since the start: how often the way was not enough export function wildlife_turned(wildlife_st: WildlifeState) -> int { return wildlife_st.wl_turned } +# of those, how many for water ahead and how many for a climb (the rest: pushed back by a still thing) +export function wildlife_turned_wet(wildlife_st: WildlifeState) -> int { return wildlife_st.wl_turned_wet } +export function wildlife_turned_steep(wildlife_st: WildlifeState) -> int { return wildlife_st.wl_turned_steep } function wl_step(wildlife_st: mut WildlifeState, a: WildAnimal, dt: float) -> bool { let d = a.speed * dt @@ -29,7 +32,10 @@ function wl_step(wildlife_st: mut WildlifeState, a: WildAnimal, dt: float) -> bo } let nh = WildlifeWorld.ground(nx, nz) let moved = Math.abs(nx - a.x) + Math.abs(nz - a.z) - if nh < WildlifeWorld.water(nx, nz) + 0.6 or nh - a.y > d * 1.2 or moved < d * 0.2 { + let wet = nh < WildlifeWorld.water(nx, nz) + 0.6 + let steep = nh - a.y > d * 1.2 + if wet or steep or moved < d * 0.2 { + if wet { wildlife_st.wl_turned_wet += 1 } else if steep { wildlife_st.wl_turned_steep += 1 } a.yaw = a.yaw + Math.deg_to_rad(75.0) a.timer = 0.0 wildlife_st.wl_turned += 1