From 297578705ec757d19c5c7db113bc91c21e07d62f Mon Sep 17 00:00:00 2001 From: Orkuncakilkaya Date: Sun, 27 Sep 2026 22:38:37 +0300 Subject: [PATCH] ludic.wildlife (17.10): count the steps refused and turned from The count is wildlife_turned(), the 75-degree fallback an animal takes when the way was not enough. It is a measure only and is not saved. Co-Authored-By: Claude Opus 5.5 --- packages/ludic.wildlife/species.ludic | 1 + packages/ludic.wildlife/steer.ludic | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/packages/ludic.wildlife/species.ludic b/packages/ludic.wildlife/species.ludic index df213e6b..64940c78 100644 --- a/packages/ludic.wildlife/species.ludic +++ b/packages/ludic.wildlife/species.ludic @@ -58,6 +58,7 @@ export state WildlifeState { wl_dice: Rng = rng_new(97) 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 } function wl_sp_all(wildlife_st: WildlifeState) -> []WildSpecies { diff --git a/packages/ludic.wildlife/steer.ludic b/packages/ludic.wildlife/steer.ludic index 4e73371e..b3cba573 100644 --- a/packages/ludic.wildlife/steer.ludic +++ b/packages/ludic.wildlife/steer.ludic @@ -14,6 +14,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 } + function wl_step(wildlife_st: mut WildlifeState, a: WildAnimal, dt: float) -> bool { let d = a.speed * dt if d < 0.0001 { return false } @@ -29,6 +32,7 @@ function wl_step(wildlife_st: mut WildlifeState, a: WildAnimal, dt: float) -> bo if nh < WildlifeWorld.water(nx, nz) + 0.6 or nh - a.y > d * 1.2 or moved < d * 0.2 { a.yaw = a.yaw + Math.deg_to_rad(75.0) a.timer = 0.0 + wildlife_st.wl_turned += 1 return false } a.x = nx