From 509b5ef111822b60070645acd89f2ae4fe98146f Mon Sep 17 00:00:00 2001 From: Orkuncakilkaya Date: Tue, 29 Sep 2026 16:42:43 +0300 Subject: [PATCH] ludic.zones: a player's radius never past no fog's 900 m A 1 km fog gave a 1040 m zone, more of the world than no fog's 900 m (2405 MB and 1029 nav tiles against 2294 MB and 753 in the fog profile). zones_radius is min(max(fog + 40, 150), 900); the test holds 1 km and 860 m at 900. Co-Authored-By: Claude Opus 5.5 --- packages/ludic.zones/README.md | 2 +- packages/ludic.zones/state.ludic | 5 +++-- packages/ludic.zones/tests/zones_test.ludic | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/ludic.zones/README.md b/packages/ludic.zones/README.md index 979d7f82..e4ae25cd 100644 --- a/packages/ludic.zones/README.md +++ b/packages/ludic.zones/README.md @@ -1,7 +1,7 @@ # ludic.zones Where a world is simulated: a disc per player - `(x, z, r)`, `r = zones_radius(fog)`, that is the -fog distance plus 40 m and never under 150 m, 900 m with no fog - and the discs that overlap merged +fog distance plus 40 m, never under 150 m nor over 900 m, and 900 m with no fog - and the discs that overlap merged into clusters with a bounding circle. Uses `ludic.base` and nothing else. - `zones_set(pid, x, z, r)`, `zones_clear(pid)`, `zones_reset()`; `zones_merge()` once a frame diff --git a/packages/ludic.zones/state.ludic b/packages/ludic.zones/state.ludic index 48a76c6e..6ea8fba4 100644 --- a/packages/ludic.zones/state.ludic +++ b/packages/ludic.zones/state.ludic @@ -18,10 +18,11 @@ export state ZonesState { zn_cn: words = words(ZONES_MAX) # how many discs it holds } -# a player's radius from how far they see: fog_dist <= 0 is no fog +# a player's radius from how far they see: fog_dist <= 0 is no fog; never past no fog's, so a far fog +# never keeps more of the world than none does export function zones_radius(fog_dist: float) -> float { if fog_dist <= 0.0 { return ZONES_NO_FOG } - return Math.max(fog_dist + ZONES_PAST_FOG, ZONES_LEAST) + return Math.min(Math.max(fog_dist + ZONES_PAST_FOG, ZONES_LEAST), ZONES_NO_FOG) } export function zones_set(zones_st: mut ZonesState, pid: int, x: float, z: float, r: float) -> void { diff --git a/packages/ludic.zones/tests/zones_test.ludic b/packages/ludic.zones/tests/zones_test.ludic index 1206f13b..a8348ea3 100644 --- a/packages/ludic.zones/tests/zones_test.ludic +++ b/packages/ludic.zones/tests/zones_test.ludic @@ -44,9 +44,11 @@ program ZonesTest { expect(Math.abs(zones_nearest(zones_st, 350.0, 100.0) - 100.0) < 0.001) } - test "a player's radius: past the fog, never under the least, the horizon with none" (zones_st: mut ZonesState) { + test "a player's radius: past the fog, never under the least nor over no fog's" (zones_st: mut ZonesState) { expect(zones_radius(0.0) == ZONES_NO_FOG) expect(zones_radius(30.0) == ZONES_LEAST) expect(zones_radius(500.0) == 540.0) + expect(zones_radius(1000.0) == ZONES_NO_FOG) # a kilometre's fog keeps no more than none + expect(zones_radius(860.0) == ZONES_NO_FOG) } }