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 <noreply@anthropic.com>
This commit is contained in:
parent
b2550ca58a
commit
509b5ef111
3 changed files with 7 additions and 4 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
# ludic.zones
|
# ludic.zones
|
||||||
|
|
||||||
Where a world is simulated: a disc per player - `(x, z, r)`, `r = zones_radius(fog)`, that is the
|
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.
|
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
|
- `zones_set(pid, x, z, r)`, `zones_clear(pid)`, `zones_reset()`; `zones_merge()` once a frame
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,11 @@ export state ZonesState {
|
||||||
zn_cn: words = words(ZONES_MAX) # how many discs it holds
|
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 {
|
export function zones_radius(fog_dist: float) -> float {
|
||||||
if fog_dist <= 0.0 { return ZONES_NO_FOG }
|
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 {
|
export function zones_set(zones_st: mut ZonesState, pid: int, x: float, z: float, r: float) -> void {
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,11 @@ program ZonesTest {
|
||||||
expect(Math.abs(zones_nearest(zones_st, 350.0, 100.0) - 100.0) < 0.001)
|
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(0.0) == ZONES_NO_FOG)
|
||||||
expect(zones_radius(30.0) == ZONES_LEAST)
|
expect(zones_radius(30.0) == ZONES_LEAST)
|
||||||
expect(zones_radius(500.0) == 540.0)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue