fix(client): address PR #78 review comments
- Widen world_seed entropy from u32 to full u64 by combining two randi() calls (Hoshe warning #1) - Persist world_seed to save directory and restore on resume_game() so loaded sessions maintain D-010 deterministic replay (Tyre warning #2) - Constrain EntanglementConfig intrigue range based on flat value so mundane_ratio stays within D-029 spec [45,55]% (both reviewers) - Remove dead VIS_PERIPHERAL constant and _grow_bounds() method - Update test_client_p1 peripheral test for forward-only simplification - Fix misleading exp_fade shader comment (filter_nearest = hard step) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -44,9 +44,13 @@ impl EntanglementConfig {
|
||||
pub fn from_rng(rng: &mut SimRng) -> Self {
|
||||
// Sample flat_ratio ∈ [25, 35] — step of 1%
|
||||
let flat: u8 = rng.rng.random_range(25u8..=35u8);
|
||||
// Sample intrigue_ratio ∈ [15, 25] — step of 1%
|
||||
let intrigue: u8 = rng.rng.random_range(15u8..=25u8);
|
||||
// Mundane fills the remainder (ensures sum = 100)
|
||||
// Constrain intrigue range so mundane = 100 - flat - intrigue stays in [45, 55].
|
||||
// mundane ≥ 45 → intrigue ≤ 55 - flat; mundane ≤ 55 → intrigue ≥ 45 - flat.
|
||||
// Intersect with D-029 base range [15, 25].
|
||||
let intrigue_min: u8 = (45u8.saturating_sub(flat)).max(15);
|
||||
let intrigue_max: u8 = (55u8.saturating_sub(flat)).min(25);
|
||||
let intrigue: u8 = rng.rng.random_range(intrigue_min..=intrigue_max);
|
||||
// Mundane fills the remainder (ensures sum = 100, stays in [45, 55])
|
||||
let mundane: u8 = 100 - flat - intrigue;
|
||||
Self {
|
||||
flat_ratio: flat,
|
||||
@@ -178,24 +182,17 @@ mod tests {
|
||||
#[test]
|
||||
fn mundane_ratio_within_bounds() {
|
||||
// D-029: mundane ∈ [45, 55]%
|
||||
// Derivation: flat ∈ [25,35], intrigue ∈ [15,25], mundane = 100 - flat - intrigue
|
||||
// worst case: flat=35, intrigue=25 → mundane=40 (below 45!)
|
||||
// CAVEAT: this reveals a potential spec inconsistency — if flat and intrigue
|
||||
// are sampled independently, mundane can fall outside [45,55].
|
||||
// Resolution options: (a) constrain sampling so mundane stays in range,
|
||||
// (b) accept mundane range as derived. This test documents the actual range.
|
||||
// TODO: coordinate with Tyre on intended sampling strategy.
|
||||
// Achieved by constraining intrigue range based on flat value so that
|
||||
// mundane = 100 - flat - intrigue always stays within spec bounds.
|
||||
for seed in 0u64..200 {
|
||||
let c = EntanglementConfig::from_seed(seed);
|
||||
assert!(
|
||||
c.is_valid(),
|
||||
"Seed {seed}: ratios must sum to 100 regardless of mundane derivation"
|
||||
"Seed {seed}: ratios must sum to 100"
|
||||
);
|
||||
// Derived mundane range: 100 - 35 - 25 = 40 minimum, 100 - 25 - 15 = 60 maximum
|
||||
// Note: if spec requires strict [45,55], the sampling ranges must be tighter.
|
||||
assert!(
|
||||
c.mundane_ratio >= 40 && c.mundane_ratio <= 60,
|
||||
"Seed {seed}: mundane_ratio {} out of derived [40, 60] range",
|
||||
c.mundane_ratio >= 45 && c.mundane_ratio <= 55,
|
||||
"Seed {seed}: mundane_ratio {} out of D-029 [45, 55] bounds",
|
||||
c.mundane_ratio
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user