Skip to content

SimulationRunner

namespace Griff.Simulations;
public static class SimulationRunner

Plays a Simulation: every pair of rows (each of the first side’s against each of the second’s), its Runs times, at each step of its sweep, headless and as fast as the computer goes, spread over the cores (see Workers). Each run is a game of its own (the arena loaded afresh, the rows set through Table Values, stepped until a side is beaten or time runs out), a whole scene played over time (a scene run, its script’s strategy acting as it goes; see Scene) or a call to the simulation’s script, with random numbers from a seed made of the simulation’s Seed, the step, the rows’ names and the run’s number, so the results are the same to the last bit on every machine, in the web player, and on any number of cores.

public static int CountRuns(Simulation simulation, SimulationHost host)

How many runs simulation plays in all: pairs times runs times steps (0 if it can’t run).

public static IReadOnlyList<string> Problems(Simulation simulation, SimulationHost host)

What’s wrong with simulation’s settings for playing it with host (no arena, a table, row, entity or column that isn’t there), a line each; empty when it can run.

public static SimulationResults Run(Simulation simulation, SimulationHost host, Action<int, int>? progress = null, int? threads = default, CancellationToken cancel = default)

Plays simulation and says what came of it. progress is told how many runs are done, from any thread, as they finish; cancel stops it (throwing OperationCanceledException). threads 1 plays everything on this thread; the results are the same either way.

public static int SeedOf(int seed, int step, string? first, string? second, int run)

The seed run run of a pair gets: from the simulation’s seed, the step, the rows’ names and the run’s number.

public const int MostPoints

The most points a value tracked over a run keeps; past it, the last point takes the latest value.

public const int MostTrackedPoints

The most points a value tracked every so many seconds (see TrackEvery) keeps: a point a game hour for over eleven years, or a point a game minute for over two months.