@its-not-rocket-science/ananke 0.1.54 → 0.1.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,20 @@ Versioning follows [Semantic Versioning](https://semver.org/).
6
6
 
7
7
  ---
8
8
 
9
+ ## [0.1.55] — 2026-03-30
10
+
11
+ ### Added
12
+
13
+ - **PA-6 — Unified Atmosphere Model (complete):**
14
+ - `src/atmosphere.ts` (new): single `AtmosphericState` struct derived from Phase 51 `WeatherState` and Phase 68 `BiomeContext`, with a unified per-pair query API.
15
+ - `deriveAtmosphericState(weather?, biome?)` → `AtmosphericState`: maps WeatherState wind to 3D `AtmosphericWind` (adds `dz_m`, derives `turbulence_Q` from speed); derives `precipIntensity_Q` from precipitation type; computes `baseVisibility_Sm` from fog × precipitation; computes `acousticMask_Q` from wind noise; maps biome `soundPropagation_Q` (vacuum = 0, water = 4×, standard air = 1×); derives `tractionMod_Q` and `thermalOffset_Q` from `deriveWeatherModifiers`.
16
+ - `queryAtmosphericModifiers(from, to, state)` → `AtmosphericModifiers`: single call yields all position-pair atmospheric effects — `crossWindSpeed_mps` (perpendicular wind for projectile drift), `hazardConeMul_Q` (gas/smoke cone range 0.5×–1.5× from headwind/tailwind), `acousticMaskMul_Q` (hearing range including upwind bonus and biome propagation), `visibilityRange_Sm` (headwind-boosted precipitation degradation), `tractionMod_Q`, `scentStrength_Q` (q(1.0) fully downwind of target, q(0) upwind — prerequisite for PA-7), `thermalOffset_Q`.
17
+ - `"./atmosphere"` subpath export added to `package.json`.
18
+ - Exports: `AtmosphericWind`, `AtmosphericState`, `AtmosphericModifiers`, `deriveAtmosphericState`, `queryAtmosphericModifiers`; constants `ATMO_BASE_VISIBILITY_Sm`, `ATMO_ACOUSTIC_FULL_MASK_MPS`, `ATMO_TURBULENCE_FULL_MPS`, `ATMO_HAZARD_TAILWIND_MUL_MAX`, `ATMO_HAZARD_HEADWIND_MUL_MIN`, `ATMO_HEARING_UPWIND_BONUS`.
19
+ - 53 new tests (186 test files, 5,452 tests total). Build: clean.
20
+
21
+ ---
22
+
9
23
  ## [0.1.54] — 2026-03-28
10
24
 
11
25
  ### Added
@@ -0,0 +1,222 @@
1
+ import { type Q } from "./units.js";
2
+ import { type WeatherState } from "./sim/weather.js";
3
+ import type { BiomeContext } from "./sim/biome.js";
4
+ /**
5
+ * Wind speed [WindField mps units, 100 per m/s] that produces maximum acoustic
6
+ * masking (q(1.0)). Calibrated at 40 m/s (gale / violent storm).
7
+ */
8
+ export declare const ATMO_ACOUSTIC_FULL_MASK_MPS = 4000;
9
+ /**
10
+ * Wind speed [WindField mps units] that produces maximum turbulence (q(1.0)).
11
+ * Calibrated at 50 m/s (hurricane-force).
12
+ */
13
+ export declare const ATMO_TURBULENCE_FULL_MPS = 5000;
14
+ /**
15
+ * Clear-sky baseline visibility range [SCALE.m]. 1 000 m = 10 000 000 SCALE.m.
16
+ */
17
+ export declare const ATMO_BASE_VISIBILITY_Sm = 10000000;
18
+ /**
19
+ * Maximum hazard-cone range multiplier from a strong tailwind (1.5× base range).
20
+ * Stored as a raw multiplier where SCALE.Q = 1.0.
21
+ */
22
+ export declare const ATMO_HAZARD_TAILWIND_MUL_MAX = 15000;
23
+ /**
24
+ * Minimum hazard-cone range multiplier from a strong headwind (0.5× base range).
25
+ */
26
+ export declare const ATMO_HAZARD_HEADWIND_MUL_MIN = 5000;
27
+ /**
28
+ * Acoustic hearing range bonus when the sound source is directly upwind
29
+ * (sound carries toward the listener): +20% of SCALE.Q.
30
+ */
31
+ export declare const ATMO_HEARING_UPWIND_BONUS = 2000;
32
+ /**
33
+ * 3-D wind field with vertical component and turbulence.
34
+ *
35
+ * Extends `WeatherState.WindField` (2-D) — `deriveAtmosphericState` maps the
36
+ * existing 2-D wind field and adds a zero vertical component when the source
37
+ * has no vertical wind data.
38
+ *
39
+ * Speed units: 100 units = 1 m/s (same convention as WeatherState.WindField).
40
+ */
41
+ export interface AtmosphericWind {
42
+ /** X component of wind direction — unit vector in SCALE.m space. */
43
+ dx_m: number;
44
+ /** Y component of wind direction — unit vector in SCALE.m space. */
45
+ dy_m: number;
46
+ /**
47
+ * Vertical (Z) component — positive = rising (updraft).
48
+ * Unit vector in SCALE.m space. `0` for standard horizontal wind.
49
+ */
50
+ dz_m: number;
51
+ /** Wind speed [100 units = 1 m/s]. */
52
+ speed_mps: number;
53
+ /**
54
+ * Turbulence intensity [Q 0..SCALE.Q].
55
+ * q(0) = laminar flow; q(1.0) = severe gusts (hurricane-force).
56
+ * Added to aim-error grouping radius for ranged attacks; derived from wind
57
+ * speed by `deriveAtmosphericState`.
58
+ */
59
+ turbulence_Q: Q;
60
+ }
61
+ /**
62
+ * Unified atmospheric state — combines wind, precipitation, visibility,
63
+ * acoustic environment, and thermal offset into a single queryable struct.
64
+ *
65
+ * Build once per tick from `WeatherState` and `BiomeContext` via
66
+ * `deriveAtmosphericState`, then query per entity-pair via
67
+ * `queryAtmosphericModifiers`.
68
+ */
69
+ export interface AtmosphericState {
70
+ /** 3-D wind field. */
71
+ wind: AtmosphericWind;
72
+ /**
73
+ * Precipitation intensity [Q 0..SCALE.Q].
74
+ * q(0) = none; q(1.0) = blizzard/torrential rain.
75
+ * Affects traction, visibility, and acoustic masking.
76
+ */
77
+ precipIntensity_Q: Q;
78
+ /**
79
+ * Baseline visibility range [SCALE.m] — clear-sky minus fog and precipitation.
80
+ * `queryAtmosphericModifiers` adjusts this for headwind-driven precipitation.
81
+ */
82
+ baseVisibility_Sm: number;
83
+ /**
84
+ * Surface traction multiplier [Q].
85
+ * Multiply `KernelContext.tractionCoeff` by this value (already derived from
86
+ * `deriveWeatherModifiers().tractionMul_Q`).
87
+ */
88
+ tractionMod_Q: Q;
89
+ /**
90
+ * Ambient acoustic masking from wind noise [Q 0..SCALE.Q].
91
+ * q(0) = still air (no masking); q(1.0) = severe wind noise (hearing near zero).
92
+ * Applied to base hearing range before directional adjustments in
93
+ * `queryAtmosphericModifiers`.
94
+ */
95
+ acousticMask_Q: Q;
96
+ /**
97
+ * Sound propagation multiplier from biome [Q].
98
+ * q(1.0) = normal air propagation (default).
99
+ * q(0.0) = vacuum (no sound).
100
+ * q(4.0) = water (~4× faster propagation).
101
+ * Multiplies the post-masking hearing range in `queryAtmosphericModifiers`.
102
+ */
103
+ soundPropagation_Q: Q;
104
+ /**
105
+ * Thermal offset in Phase-29 Q encoding.
106
+ * Add to `KernelContext.thermalAmbient_Q`.
107
+ */
108
+ thermalOffset_Q: number;
109
+ }
110
+ /**
111
+ * Per-pair atmospheric modifiers returned by `queryAtmosphericModifiers`.
112
+ *
113
+ * All values are ready to apply:
114
+ * - Multiply Q fields using `Math.round(value × mul / SCALE.Q)`.
115
+ * - Add offset fields directly.
116
+ *
117
+ * @see queryAtmosphericModifiers
118
+ */
119
+ export interface AtmosphericModifiers {
120
+ /**
121
+ * Perpendicular wind component relative to the shot/query direction
122
+ * [100 units = 1 m/s].
123
+ *
124
+ * Convert to projectile drift [SCALE.m]:
125
+ * ```
126
+ * drift_Sm = crossWindSpeed_mps × range_Sm / proj_speed_mps
127
+ * ```
128
+ * where `range_Sm` is in SCALE.m and `proj_speed_mps` is in the same
129
+ * 100-per-m/s wind units. Zero when the query pair is coincident.
130
+ */
131
+ crossWindSpeed_mps: number;
132
+ /**
133
+ * Hazard-cone range multiplier for gas/smoke cones aimed from `from` to `to`
134
+ * [raw factor, SCALE.Q = 1.0].
135
+ *
136
+ * Values > SCALE.Q are valid and intentional:
137
+ * - Tailwind extends range up to `ATMO_HAZARD_TAILWIND_MUL_MAX` (1.5×).
138
+ * - Headwind reduces range down to `ATMO_HAZARD_HEADWIND_MUL_MIN` (0.5×).
139
+ * - Crosswind or calm → SCALE.Q (1.0×, no change).
140
+ *
141
+ * Apply: `adjustedRange_Sm = Math.round(baseRange_Sm × hazardConeMul_Q / SCALE.Q)`.
142
+ */
143
+ hazardConeMul_Q: number;
144
+ /**
145
+ * Effective hearing range multiplier [Q 0..SCALE.Q + ATMO_HEARING_UPWIND_BONUS].
146
+ *
147
+ * Combines wind noise masking and directional propagation:
148
+ * - Values < SCALE.Q: hearing degraded (wind noise or vacuum).
149
+ * - Values up to SCALE.Q + ATMO_HEARING_UPWIND_BONUS: enhanced (sound downwind of listener).
150
+ *
151
+ * Apply: `effectiveRange_Sm = Math.round(baseRange_Sm × acousticMaskMul_Q / SCALE.Q)`.
152
+ */
153
+ acousticMaskMul_Q: number;
154
+ /**
155
+ * Effective visibility range [SCALE.m] for the query direction.
156
+ * Already adjusted for headwind-driven precipitation and fog.
157
+ * Use as maximum ranged-detection distance for this query pair.
158
+ */
159
+ visibilityRange_Sm: number;
160
+ /**
161
+ * Surface traction modifier [Q] — same as `AtmosphericState.tractionMod_Q`.
162
+ * Included here for convenience so callers can read all mods from one struct.
163
+ */
164
+ tractionMod_Q: Q;
165
+ /**
166
+ * Scent propagation strength from `to` toward `from` [Q 0..SCALE.Q].
167
+ *
168
+ * Physics: the observer at `from` smells the entity at `to` when the wind
169
+ * blows from `to` toward `from` (i.e., `from` is downwind of `to`).
170
+ *
171
+ * - q(1.0) = `from` is directly downwind of `to` (maximum scent).
172
+ * - q(0) = `from` is upwind of `to` (no scent reaches observer).
173
+ * - Intermediate values for crosswind/partial alignment.
174
+ *
175
+ * Used by PA-7 olfactory detection.
176
+ */
177
+ scentStrength_Q: Q;
178
+ /**
179
+ * Thermal offset in Phase-29 Q encoding.
180
+ * Same as `AtmosphericState.thermalOffset_Q`.
181
+ */
182
+ thermalOffset_Q: number;
183
+ }
184
+ /**
185
+ * Build an `AtmosphericState` from Phase 51 `WeatherState` and Phase 68
186
+ * `BiomeContext`.
187
+ *
188
+ * Both parameters are optional — absent values produce calm, clear-sky,
189
+ * standard-air atmosphere with no modifiers.
190
+ *
191
+ * @example
192
+ * ```ts
193
+ * const atmo = deriveAtmosphericState(ctx.weather, ctx.biome);
194
+ * // Use once per tick, query per entity-pair:
195
+ * const mods = queryAtmosphericModifiers(attacker, target, atmo);
196
+ * ```
197
+ */
198
+ export declare function deriveAtmosphericState(weather?: WeatherState, biome?: BiomeContext): AtmosphericState;
199
+ /**
200
+ * Query all atmospheric modifiers for a position pair.
201
+ *
202
+ * Computes wind-relative effects along the `from → to` vector:
203
+ * - Crosswind component for projectile drift.
204
+ * - Tailwind/headwind ratio for hazard-cone range.
205
+ * - Directional acoustic effects.
206
+ * - Headwind-boosted precipitation degrading visibility.
207
+ * - Scent propagation strength (downwind = strong, upwind = none).
208
+ *
209
+ * Pure function — no mutation, safe to call multiple times per tick.
210
+ *
211
+ * @param from Observer / attacker position [SCALE.m].
212
+ * @param to Target / source position [SCALE.m].
213
+ * @param state Atmospheric state built by `deriveAtmosphericState`.
214
+ * @returns All modifiers for this position pair.
215
+ */
216
+ export declare function queryAtmosphericModifiers(from: {
217
+ x_Sm: number;
218
+ y_Sm: number;
219
+ }, to: {
220
+ x_Sm: number;
221
+ y_Sm: number;
222
+ }, state: AtmosphericState): AtmosphericModifiers;
@@ -0,0 +1,200 @@
1
+ // src/atmosphere.ts — PA-6: Unified Atmosphere Model
2
+ //
3
+ // Provides a single `AtmosphericState` struct that derives from WeatherState
4
+ // (Phase 51) and BiomeContext (Phase 68) and exposes a unified query API.
5
+ //
6
+ // `queryAtmosphericModifiers(from, to, state)` returns all atmospheric effects
7
+ // relevant to a position pair in one call — projectile drift, hazard cone
8
+ // distortion, acoustic masking, visibility, traction, and scent propagation —
9
+ // so hosts no longer need per-system wind configuration.
10
+ //
11
+ // Integration:
12
+ // 1. Build once per tick: state = deriveAtmosphericState(weather, biome)
13
+ // 2. Query per-pair: mods = queryAtmosphericModifiers(from, to, state)
14
+ // 3. Apply mods to:
15
+ // - resolveShoot: gRadius_m += crossWindSpeed_mps × range / proj_speed
16
+ // - adjustConeRange: multiply result by hazardConeMul_Q / SCALE.Q
17
+ // - sensoryEnv.hearingRange_m: multiply by acousticMaskMul_Q / SCALE.Q
18
+ // - KernelContext.tractionCoeff: multiply by mods.tractionMod_Q / SCALE.Q
19
+ // - PA-7 senses: use scentStrength_Q for olfactory detection
20
+ import { SCALE, q, clampQ } from "./units.js";
21
+ import { deriveWeatherModifiers, } from "./sim/weather.js";
22
+ // ── Constants ─────────────────────────────────────────────────────────────────
23
+ /**
24
+ * Wind speed [WindField mps units, 100 per m/s] that produces maximum acoustic
25
+ * masking (q(1.0)). Calibrated at 40 m/s (gale / violent storm).
26
+ */
27
+ export const ATMO_ACOUSTIC_FULL_MASK_MPS = 4_000;
28
+ /**
29
+ * Wind speed [WindField mps units] that produces maximum turbulence (q(1.0)).
30
+ * Calibrated at 50 m/s (hurricane-force).
31
+ */
32
+ export const ATMO_TURBULENCE_FULL_MPS = 5_000;
33
+ /**
34
+ * Clear-sky baseline visibility range [SCALE.m]. 1 000 m = 10 000 000 SCALE.m.
35
+ */
36
+ export const ATMO_BASE_VISIBILITY_Sm = 10_000_000;
37
+ /**
38
+ * Maximum hazard-cone range multiplier from a strong tailwind (1.5× base range).
39
+ * Stored as a raw multiplier where SCALE.Q = 1.0.
40
+ */
41
+ export const ATMO_HAZARD_TAILWIND_MUL_MAX = 15_000; // 1.5 × SCALE.Q
42
+ /**
43
+ * Minimum hazard-cone range multiplier from a strong headwind (0.5× base range).
44
+ */
45
+ export const ATMO_HAZARD_HEADWIND_MUL_MIN = 5_000; // 0.5 × SCALE.Q
46
+ /**
47
+ * Acoustic hearing range bonus when the sound source is directly upwind
48
+ * (sound carries toward the listener): +20% of SCALE.Q.
49
+ */
50
+ export const ATMO_HEARING_UPWIND_BONUS = 2_000; // 0.2 × SCALE.Q
51
+ // ── Zero-wind sentinel ────────────────────────────────────────────────────────
52
+ const ZERO_WIND = {
53
+ dx_m: SCALE.m, // direction irrelevant at zero speed; default East
54
+ dy_m: 0,
55
+ dz_m: 0,
56
+ speed_mps: 0,
57
+ turbulence_Q: q(0),
58
+ };
59
+ // ── deriveAtmosphericState ────────────────────────────────────────────────────
60
+ /**
61
+ * Build an `AtmosphericState` from Phase 51 `WeatherState` and Phase 68
62
+ * `BiomeContext`.
63
+ *
64
+ * Both parameters are optional — absent values produce calm, clear-sky,
65
+ * standard-air atmosphere with no modifiers.
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * const atmo = deriveAtmosphericState(ctx.weather, ctx.biome);
70
+ * // Use once per tick, query per entity-pair:
71
+ * const mods = queryAtmosphericModifiers(attacker, target, atmo);
72
+ * ```
73
+ */
74
+ export function deriveAtmosphericState(weather, biome) {
75
+ // ── Wind ──────────────────────────────────────────────────────────────────
76
+ const srcWind = weather?.wind;
77
+ const turbulence_Q = srcWind
78
+ ? clampQ(Math.round(srcWind.speed_mps * SCALE.Q / ATMO_TURBULENCE_FULL_MPS), q(0), SCALE.Q)
79
+ : q(0);
80
+ const wind = srcWind
81
+ ? { dx_m: srcWind.dx_m, dy_m: srcWind.dy_m, dz_m: 0, speed_mps: srcWind.speed_mps, turbulence_Q }
82
+ : ZERO_WIND;
83
+ // ── Weather-derived modifiers ─────────────────────────────────────────────
84
+ const wmod = weather ? deriveWeatherModifiers(weather) : null;
85
+ const tractionMod_Q = (wmod?.tractionMul_Q ?? SCALE.Q);
86
+ const thermalOffset_Q = wmod?.thermalOffset_Q ?? 0;
87
+ // ── Precipitation intensity ───────────────────────────────────────────────
88
+ // Map WeatherModifiers.precipVisionMul_Q inversely: q(1.0) = none, q(0.30) = blizzard
89
+ const precipVisionMul = wmod?.precipVisionMul_Q ?? SCALE.Q;
90
+ // precipIntensity = 1.0 - precipVisionMul (inverted, clamped to [0, 1])
91
+ const precipIntensity_Q = clampQ((SCALE.Q - precipVisionMul), q(0), SCALE.Q);
92
+ // ── Visibility ────────────────────────────────────────────────────────────
93
+ // Fog: q(0) → full visibility; q(1.0) → 1% of baseline
94
+ const fogDensity = weather?.fogDensity_Q ?? 0;
95
+ const fogMul = Math.max(100, SCALE.Q - Math.round(fogDensity * 9_900 / SCALE.Q)); // 100..10000
96
+ const precipMul = precipVisionMul; // already in [q(0.30), q(1.0)]
97
+ // Combined: fog + precip (multiplicative)
98
+ const combinedVisionMul = Math.round(fogMul * precipMul / SCALE.Q);
99
+ const baseVisibility_Sm = Math.max(10 * SCALE.m, // minimum: 10 m visibility
100
+ Math.round(ATMO_BASE_VISIBILITY_Sm * combinedVisionMul / SCALE.Q));
101
+ // ── Acoustic masking (ambient wind noise) ─────────────────────────────────
102
+ const acousticMask_Q = clampQ(Math.round(wind.speed_mps * SCALE.Q / ATMO_ACOUSTIC_FULL_MASK_MPS), q(0), SCALE.Q);
103
+ // ── Sound propagation from biome ──────────────────────────────────────────
104
+ const soundPropagation_Q = biome?.soundPropagation !== undefined
105
+ ? biome.soundPropagation
106
+ : SCALE.Q;
107
+ return {
108
+ wind,
109
+ precipIntensity_Q,
110
+ baseVisibility_Sm,
111
+ tractionMod_Q,
112
+ acousticMask_Q,
113
+ soundPropagation_Q,
114
+ thermalOffset_Q,
115
+ };
116
+ }
117
+ // ── queryAtmosphericModifiers ─────────────────────────────────────────────────
118
+ /**
119
+ * Query all atmospheric modifiers for a position pair.
120
+ *
121
+ * Computes wind-relative effects along the `from → to` vector:
122
+ * - Crosswind component for projectile drift.
123
+ * - Tailwind/headwind ratio for hazard-cone range.
124
+ * - Directional acoustic effects.
125
+ * - Headwind-boosted precipitation degrading visibility.
126
+ * - Scent propagation strength (downwind = strong, upwind = none).
127
+ *
128
+ * Pure function — no mutation, safe to call multiple times per tick.
129
+ *
130
+ * @param from Observer / attacker position [SCALE.m].
131
+ * @param to Target / source position [SCALE.m].
132
+ * @param state Atmospheric state built by `deriveAtmosphericState`.
133
+ * @returns All modifiers for this position pair.
134
+ */
135
+ export function queryAtmosphericModifiers(from, to, state) {
136
+ const shotDx = to.x_Sm - from.x_Sm;
137
+ const shotDy = to.y_Sm - from.y_Sm;
138
+ const distSq = shotDx * shotDx + shotDy * shotDy;
139
+ const dist_Sm = distSq > 0 ? Math.trunc(Math.sqrt(distSq)) : 0;
140
+ const { wind } = state;
141
+ // ── Wind-direction geometry ────────────────────────────────────────────────
142
+ // Dot and cross products of wind direction (unit vector × SCALE.m) with shot
143
+ // direction (SCALE.m). Both raw values have units SCALE.m², scaled by dist.
144
+ // We normalise by dividing by dist_Sm to recover SCALE.m-range cosine/sine.
145
+ // dotNorm ∈ [-SCALE.m, SCALE.m]: positive = tailwind, negative = headwind.
146
+ // crossNorm ∈ [0, SCALE.m]: magnitude of perpendicular component.
147
+ let dotNorm = 0;
148
+ let crossNorm = 0;
149
+ if (dist_Sm > 0 && wind.speed_mps > 0) {
150
+ const dotRaw = wind.dx_m * shotDx + wind.dy_m * shotDy;
151
+ const crossRaw = wind.dx_m * shotDy - wind.dy_m * shotDx;
152
+ dotNorm = Math.trunc(dotRaw / dist_Sm); // SCALE.m units (cosine component)
153
+ crossNorm = Math.trunc(Math.abs(crossRaw) / dist_Sm); // SCALE.m units (sine component)
154
+ // Clamp to valid range (floating-point-free but integer rounding can exceed SCALE.m)
155
+ dotNorm = Math.max(-SCALE.m, Math.min(SCALE.m, dotNorm));
156
+ crossNorm = Math.min(SCALE.m, crossNorm);
157
+ }
158
+ // ── Crosswind speed (projectile drift) ───────────────────────────────────
159
+ // crossWindSpeed_mps = |sin θ| × wind.speed_mps
160
+ const crossWindSpeed_mps = Math.round(crossNorm * wind.speed_mps / SCALE.m);
161
+ // ── Hazard-cone multiplier ────────────────────────────────────────────────
162
+ // At full tailwind (dotNorm = +SCALE.m): 1.5× range.
163
+ // At full headwind (dotNorm = -SCALE.m): 0.5× range.
164
+ // Range: [ATMO_HAZARD_HEADWIND_MUL_MIN, ATMO_HAZARD_TAILWIND_MUL_MAX].
165
+ const HAZARD_HALF_RANGE = Math.round((ATMO_HAZARD_TAILWIND_MUL_MAX - ATMO_HAZARD_HEADWIND_MUL_MIN) / 2);
166
+ const hazardConeMul_Q = Math.max(ATMO_HAZARD_HEADWIND_MUL_MIN, Math.min(ATMO_HAZARD_TAILWIND_MUL_MAX, SCALE.Q + Math.round(dotNorm * HAZARD_HALF_RANGE / SCALE.m)));
167
+ // ── Acoustic masking multiplier ───────────────────────────────────────────
168
+ // Base: 1.0 − ambient wind noise masking.
169
+ // Directional bonus: source upwind of listener (negative dotNorm) → sound
170
+ // carries toward the listener → up to +ATMO_HEARING_UPWIND_BONUS.
171
+ const baseHearing = SCALE.Q - state.acousticMask_Q;
172
+ const upwindBonus = Math.max(0, Math.round(-dotNorm * ATMO_HEARING_UPWIND_BONUS / SCALE.m));
173
+ // Apply biome sound propagation (e.g. ×4 in water, ×0 in vacuum)
174
+ const rawAcousticMul = Math.round((baseHearing + upwindBonus) * state.soundPropagation_Q / SCALE.Q);
175
+ const acousticMaskMul_Q = Math.max(0, rawAcousticMul);
176
+ // ── Visibility (directional) ──────────────────────────────────────────────
177
+ // Headwind drives precipitation particles directly at the sensor, increasing
178
+ // effective precipitation density and reducing visibility further.
179
+ const headwindFrac = Math.max(0, -dotNorm); // 0..SCALE.m for headwind
180
+ // precipBoostPenalty: extra vision reduction from headwind-driven precipitation
181
+ const precipBoostPenalty = Math.round(headwindFrac * state.precipIntensity_Q / SCALE.m * q(0.30) / SCALE.Q);
182
+ const visionMul = Math.max(100, // ≥ 1% of base
183
+ SCALE.Q - Math.round(state.precipIntensity_Q * 3_000 / SCALE.Q) - precipBoostPenalty);
184
+ const visibilityRange_Sm = Math.max(10 * SCALE.m, Math.round(state.baseVisibility_Sm * visionMul / SCALE.Q));
185
+ // ── Scent strength ────────────────────────────────────────────────────────
186
+ // "from" smells "to" when wind blows from to→from (reversed shot direction
187
+ // aligns with wind direction).
188
+ // scentDotNorm = -dotNorm (positive = wind blows from `to` toward `from`).
189
+ const scentDotNorm = -dotNorm;
190
+ const scentStrength_Q = clampQ(Math.round(scentDotNorm * SCALE.Q / SCALE.m), q(0), SCALE.Q);
191
+ return {
192
+ crossWindSpeed_mps,
193
+ hazardConeMul_Q,
194
+ acousticMaskMul_Q,
195
+ visibilityRange_Sm,
196
+ tractionMod_Q: state.tractionMod_Q,
197
+ scentStrength_Q,
198
+ thermalOffset_Q: state.thermalOffset_Q,
199
+ };
200
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@its-not-rocket-science/ananke",
3
- "version": "0.1.54",
3
+ "version": "0.1.55",
4
4
  "type": "module",
5
5
  "description": "Deterministic lockstep-friendly SI-units RPG/physics core (fixed-point TS)",
6
6
  "license": "MIT",
@@ -185,6 +185,10 @@
185
185
  "./terrain-bridge": {
186
186
  "import": "./dist/src/terrain-bridge.js",
187
187
  "types": "./dist/src/terrain-bridge.d.ts"
188
+ },
189
+ "./atmosphere": {
190
+ "import": "./dist/src/atmosphere.js",
191
+ "types": "./dist/src/atmosphere.d.ts"
188
192
  }
189
193
  },
190
194
  "workspaces": [