From c86f28e93f46125879642090bfa3455f4213708b Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 11 Oct 2026 20:34:59 +0200 Subject: [PATCH] MiningCut3Tests: ChunkInfo equals the bits recorded at base 12dfcef5 Co-Authored-By: Claude Opus 5.5 --- .../Aetheria.Shared.Tests/MiningCut3Tests.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/Aetheria.Shared.Tests/MiningCut3Tests.cs b/tests/Aetheria.Shared.Tests/MiningCut3Tests.cs index 289abb1bf..ea29e418b 100644 --- a/tests/Aetheria.Shared.Tests/MiningCut3Tests.cs +++ b/tests/Aetheria.Shared.Tests/MiningCut3Tests.cs @@ -313,6 +313,32 @@ public sealed partial class MiningCut3Tests : IDisposable $"per-tick loop settled at {perTick}, the on-demand value implies {discrete} (settled {settled})"); } + // ChunkInfo's value is not changed by moving its arithmetic under PassiveInfo: six observers at different + // places and bearings, one with a second sensor so the average is live, read the same chunk, and every value + // matches the bits recorded at base 12dfcef5, before the extraction (a different order of the multiplication + // by the chunk's brightness moves them in the last bits). + private static readonly uint[] ChunkInfoAtBase = new uint[] { 1045120030u, 1039274086u, 1030543422u, 1029120970u, 1036363351u, 1035122917u }; + + [Fact] + public void ChunkInfoIsBitIdenticalToItsValueBeforeTheExtraction() + { + var kind = Kind("Asteroid", 1f); + var s = BuildScene(new[] { kind }, Belt(kind, Rock(150f))); + var chunk = new ChunkId(s.Belts[0], 0); + var places = new[] { float2(50, -150), float2(-80, -60), float2(10, 200), float2(-300, 40), float2(120, 120), float2(0, -400) }; + var values = new List(); + for (var i = 0; i < places.Length; i++) + { + var observer = SpawnShip(s, places[i], sensor: true, secondSensor: i == 2); + Tick((observer, places[i])); // brings the sensors online + values.Add(observer.ChunkInfo(chunk)); + } + + Assert.All(values, v => Assert.InRange(v, 1e-4f, .99f)); // a live, unsaturated reading at every place + var actual = values.Select(Bits).ToArray(); + Assert.True(actual.SequenceEqual(ChunkInfoAtBase), "ChunkInfo bits: " + string.Join(",", actual)); + } + // A chunk outside every sun's light is dark: no visibility, no info, and it cannot be picked, while a lit // chunk of the same belt and kind can. [Fact]