Skip to content

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.

C#
public class StateTrace

Inheritance

object ← StateTrace

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()

C#
public StateTrace()

Properties

Sections

Whether each step also records the hash of every section (false by default: the whole hash only).

C#
public bool Sections { get; init; }

Property Value

bool

Steps

The steps recorded so far, in order.

C#
public IReadOnlyList<StepHash> Steps { get; }

Property Value

IReadOnlyList<StepHash>

Methods

FirstDivergence(StateTrace, StateTrace)

The first step and section where first and second differ, or null when they are identical.

C#
public static StateDivergence? FirstDivergence(StateTrace first, StateTrace second)

Parameters

first StateTrace

second StateTrace

Returns

StateDivergence?

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.

C#
public static StateDivergence? FirstDivergence(IReadOnlyList<StepHash> first, IReadOnlyList<StepHash> second)

Parameters

first IReadOnlyList<StepHash>

second IReadOnlyList<StepHash>

Returns

StateDivergence?

Format(StepHash)

One step as a line of text, without the line break: update TAB hash [TAB section=hash]….

C#
public static string Format(StepHash step)

Parameters

step StepHash

Returns

string

Parse(string)

Reads a trace written by Write; it records sections when any step has them.

C#
public static StateTrace Parse(string text)

Parameters

text string

Returns

StateTrace

Exceptions

FormatException

A line is not a step.

Record(StepHash)

Receives the hash of a step; the default keeps it in Steps.

C#
public virtual void Record(StepHash step)

Parameters

step StepHash

ToText()

The steps as text, one line per step.

C#
public string ToText()

Returns

string

Write(TextWriter)

Writes the steps as text, one line per step (see the remarks of StateTrace).

C#
public void Write(TextWriter writer)

Parameters

writer TextWriter