Use CounterModule.cs and counter.replay from the zip. A tick is one simulation step.
dotnet add package RecursiveAI.OneScope.SdkRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
var history = CounterModule .OpenHistory("counter.replay"); history.Seek(3); var world = (CounterWorld)history.World; long tick = history.CurrentStep; Console.WriteLine($"Tick: {tick}"); Console.WriteLine($"Count: {world.Count}");
Unzip the example, then dotnet run.
Tick: 3 Count: 6
Program and rewind
A OneScope module reads a recording format and steps its simulation world. If you have your own recording format, see Writing a module.
The included counter.replay uses the sample module’s toy format; COUNT 4 records four ticks:
COUNT 4OpenHistory is a helper in CounterModule.cs that reads the file, calls the module’s Open method, and creates a History. The full program does those steps directly.
The module starts at tick 0 with a count of 0 and adds two per tick. The program seeks to tick 3 and then rewinds to tick 1:
using OneScope.Sdk; const string path = "counter.replay"; var bytes = File.ReadAllBytes(path); var source = new CounterModule() .Open(bytes, path); var history = new History(source); history.Seek(3); var world = (CounterWorld)history.World; long tick = history.CurrentStep; Console.WriteLine($"Tick: {tick}"); Console.WriteLine($"Count: {world.Count}"); history.Seek(1); Console.WriteLine($"Rewound to tick {history.CurrentStep}."); Console.WriteLine($"Count: {((CounterWorld)history.World).Count}");
Tick: 3 Count: 6 Rewound to tick 1. Count: 2
A tick outside the inclusive StartStep to EndStep range throws ArgumentOutOfRangeException.
Variations
To jump to the final tick without knowing how long the recording is, replace history.Seek(3):
history.Seek(history.EndStep);Tick: 4 Count: 8
Related recipes
The short answer
Use History.Seek(tick) with the recorded tick number, then read History.World. A seek restores a suitable keyframe (a saved world state) when needed and replays recorded inputs up to the target. The snippet reaches tick 3 with a count of 6; the full example then seeks backward to tick 1 and reads a count of 2.
What makes a seek in a deterministic simulation land on the exact tick?
The module has to restore the same state its world reached when it first saved the keyframe. Replaying the same inputs from that state must produce the same result as stepping straight through. Seek uses the nearest retained keyframe at or before the target, unless it can continue forward from the current world. It does not interpolate between visible frames. This is useful when comparing state at the exact tick a simulation first diverges, regardless of how often a viewer draws the screen.
The argument is an absolute tick, not an offset and not a wall-clock time. Use StartStep and EndStep for a scrubber’s range. In the sample, four recorded advances take the world from tick 0 to tick 4, so both endpoints are valid. If you have an offset from the start of a recording, add it to StartStep before seeking. Read the world state you need before the next seek or step: History.World is the current world, not a snapshot you can hold onto as the cursor moves.