From 37a7bb76f7c28f3909cab410bd8eabe38092f8f4 Mon Sep 17 00:00:00 2001 From: soul Date: Fri, 23 Oct 2026 01:47:50 +0200 Subject: [PATCH] Scenario tests step the arena at SimClock.GameStep, the rate the game runs Co-Authored-By: Claude Sonnet 5.5 --- tests/Aetheria.Shared.Tests/ApproachKnowledgeTests.cs | 10 +++++----- tests/Aetheria.Shared.Tests/BeltScenarioTests.cs | 2 +- tests/Aetheria.Shared.Tests/CrossingScenarioTests.cs | 6 +++--- tests/Aetheria.Shared.Tests/FlowFieldTests.cs | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/Aetheria.Shared.Tests/ApproachKnowledgeTests.cs b/tests/Aetheria.Shared.Tests/ApproachKnowledgeTests.cs index 5fdf7bffd..7a19d8173 100644 --- a/tests/Aetheria.Shared.Tests/ApproachKnowledgeTests.cs +++ b/tests/Aetheria.Shared.Tests/ApproachKnowledgeTests.cs @@ -30,12 +30,12 @@ public sealed partial class RunStartTests var view = arena.Agents.Single(a => a.Ship == east).View; var startGap = east.Position.x - west.Position.x; - arena.Update(1f / 60f); - arena.Update(1f / 60f); + arena.Update(SimClock.GameStep); + arena.Update(SimClock.GameStep); Assert.NotNull(view.TrackOf(east, PilotView.Handle(west))); Assert.True(east.Velocity.x < -.5f, $"the follower thrusts toward its anchor from the first steps (vx {east.Velocity.x})"); - for (var i = 0; i < 120; i++) arena.Update(1f / 60f); + for (var i = 0; i < System.MathF.Round(2f / SimClock.GameStep); i++) arena.Update(SimClock.GameStep); Assert.True(east.Position.x - west.Position.x < startGap - 20f, "the follower closed on its anchor"); } @@ -50,10 +50,10 @@ public sealed partial class RunStartTests var sentinel = new float3(0, 0, 12345); Assert.NotNull(view.TrackOf(east, PilotView.Handle(west))); - for (var i = 0; i < 3; i++) arena.Update(1f / 60f); + for (var i = 0; i < 3; i++) arena.Update(SimClock.GameStep); Assert.NotNull(view.TrackOf(east, PilotView.Handle(west))); east.Command.Aim = sentinel; - arena.Update(1f / 60f); + arena.Update(SimClock.GameStep); Assert.NotEqual(sentinel, east.Command.Aim.Value); var steps = 0; diff --git a/tests/Aetheria.Shared.Tests/BeltScenarioTests.cs b/tests/Aetheria.Shared.Tests/BeltScenarioTests.cs index 2c352b6e8..d8eaa848a 100644 --- a/tests/Aetheria.Shared.Tests/BeltScenarioTests.cs +++ b/tests/Aetheria.Shared.Tests/BeltScenarioTests.cs @@ -35,7 +35,7 @@ public sealed partial class RunStartTests var field = arena.Planets.Single(body => body.Value == belt).Key; // A weapon's reach and a sensor's gain are read once the ship's stats have settled, so the first second passes first. - for (var tick = 0; tick < 60; tick++) arena.Update(1f / 60f); + for (var tick = 0; tick < System.MathF.Round(1f / SimClock.GameStep); tick++) arena.Update(SimClock.GameStep); var inReach = new List(); player.VisibleChunksInReach(inReach); Assert.NotEmpty(inReach); diff --git a/tests/Aetheria.Shared.Tests/CrossingScenarioTests.cs b/tests/Aetheria.Shared.Tests/CrossingScenarioTests.cs index a21aa7f19..9c827b968 100644 --- a/tests/Aetheria.Shared.Tests/CrossingScenarioTests.cs +++ b/tests/Aetheria.Shared.Tests/CrossingScenarioTests.cs @@ -119,16 +119,16 @@ public sealed partial class RunStartTests private static CrossingPass FlyPass(Zone arena, Ship player, Entity crosser) { - for (var tick = 0; tick < 60 * CrossingSeconds; tick++) + for (var tick = 0; tick < System.MathF.Round(CrossingSeconds / SimClock.GameStep); tick++) { var before = crosser.Position - player.Position; - arena.Update(1f / 60f); + arena.Update(SimClock.GameStep); var after = crosser.Position - player.Position; if (before.x < 0 && after.x >= 0) { var at = float2(after.x, after.z); var relative = crosser.Velocity - player.Velocity; - return new CrossingPass(true, (tick + 1) / 60f, at, length(relative), abs(at.x * relative.y - at.y * relative.x) / dot(at, at)); + return new CrossingPass(true, (tick + 1) * SimClock.GameStep, at, length(relative), abs(at.x * relative.y - at.y * relative.x) / dot(at, at)); } } diff --git a/tests/Aetheria.Shared.Tests/FlowFieldTests.cs b/tests/Aetheria.Shared.Tests/FlowFieldTests.cs index 380ffe62c..f93b24df0 100644 --- a/tests/Aetheria.Shared.Tests/FlowFieldTests.cs +++ b/tests/Aetheria.Shared.Tests/FlowFieldTests.cs @@ -183,9 +183,9 @@ public sealed class FlowFieldTests : IDisposable // Zone.Flow and the lowered scroll are one zone-time value: the flow at p is the law evaluated at the zone's // own FlowScroll, after any run of steps (a flow that ran ahead of or behind the shader's scroll differs here). var zone = ZoneWith(Flow(), 3.25); - for (var step = 0; step < 90; step++) + for (var step = 0; step < System.MathF.Round(1.5f / SimClock.GameStep); step++) { - zone.Update(1f / 60f); + zone.Update(SimClock.GameStep); foreach (var p in Probes) AssertClose(FlowField.Global(Flow(), p, zone.FlowScroll), zone.Flow(p), 1e-4f); } }