Scenario tests step the arena at SimClock.GameStep, the rate the game runs

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
soul 2026-10-23 01:47:50 +02:00
commit 37a7bb76f7
4 changed files with 11 additions and 11 deletions

View file

@ -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;

View file

@ -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<ChunkId>();
player.VisibleChunksInReach(inReach);
Assert.NotEmpty(inReach);

View file

@ -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));
}
}

View file

@ -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);
}
}