KernelAPI reference
Class StateTrace
Namespace: MicroEngine.Kernel
Assembly: MicroEngine.Kernel.dll
Guide: Modules and the frame schedule
A run’s per-step state hashes: the loop records one StepHash after every fixed step when a run is given
one (RunOptions.StateTrace). Two runs of the same build, script and seed must record the same trace;
FirstDivergence names the first update and section where two differ.
public class StateTraceInheritance
Remarks
The trace keeps its steps in memory; override Record to send them elsewhere (a file, as they come).
ToText and Parse give one line per step:
update TAB hash [TAB section=hash]…, hashes as 16 hexadecimal digits.
Constructors
StateTrace()
public StateTrace()Properties
Sections
Whether each step also records the hash of every section (false by default: the whole hash only).
public bool Sections { get; init; }Property Value
Steps
The steps recorded so far, in order.
public IReadOnlyList<StepHash> Steps { get; }Property Value
Methods
FirstDivergence(StateTrace, StateTrace)
The first step and section where first and second differ, or null when they are identical.
public static StateDivergence? FirstDivergence(StateTrace first, StateTrace second)Parameters
first StateTrace
second StateTrace
Returns
FirstDivergence(IReadOnlyList<StepHash>, IReadOnlyList<StepHash>)
The first step and section where two lists of steps differ, or null when they are identical. Steps are compared by position: their update numbers and whole hashes; then, when both carry section hashes, the first section whose name or hash differs is named.
public static StateDivergence? FirstDivergence(IReadOnlyList<StepHash> first, IReadOnlyList<StepHash> second)Parameters
first IReadOnlyList<StepHash>
second IReadOnlyList<StepHash>
Returns
Format(StepHash)
One step as a line of text, without the line break: update TAB hash [TAB section=hash]….
public static string Format(StepHash step)Parameters
step StepHash
Returns
Parse(string)
Reads a trace written by Write; it records sections when any step has them.
public static StateTrace Parse(string text)Parameters
text string
Returns
Exceptions
A line is not a step.
Record(StepHash)
Receives the hash of a step; the default keeps it in Steps.
public virtual void Record(StepHash step)Parameters
step StepHash
ToText()
The steps as text, one line per step.
public string ToText()Returns
Write(TextWriter)
Writes the steps as text, one line per step (see the remarks of StateTrace).
public void Write(TextWriter writer)Parameters
writer TextWriter