The office has no end: the death-tick gate goes, the knife is severity 20, the ruled bands are pinned

Ruling bds-office-is-a-sandbox-preset: StressSession loses Finished, MaxSeconds,
ReleaseSeconds, ReleaseGoalId and the Endured row; the will's break is an event, the
session ticks until the caller stops. The headless run, the sweep, OfficeBody.Run and the
CLI take a horizon (--max, 180). OfficeBodySession.Finished stays false for IBodyRun.

Ruling lodur-owns-dead-physiology-flows: Lodur's Actor steps a dead physiology (Lodur
c324570), so the session's _flows and deadBefore are deleted; Step reads the flows
every tick.

Knife severity 20. Tests pin the ruled bands in the session: ordinary cut 191.00 s
(120-240), a major vessel 29.73 s (21.9-48.6), the front of the throat drowns
(Consciousness, airway full at 1.29 s, within 12.9). Conservation bound 1.76e-5 and the
spill floor re-derived; the office golden hash re-captured (the old run's bytes are its
first 109 lines).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-27 23:29:59 +01:00
commit e5b6dbb94f
12 changed files with 160 additions and 194 deletions

View file

@ -27,7 +27,7 @@ Induction Chamber (the pain box), run headless or on a Ymir ragdoll. Question it
will breaks, or the box is disabled first?** The nervous model is Lodur's
(`Lodur.Actor`); this game holds the box, the seed, the restraint and the
recorder. It needs sibling checkouts of Lodur and Ymir (`LODUR_ROOT`, else
`..\Lodur`; Lodur finds `..\Ymir`, or `YMIR_ROOT`). Entry points:
`..\Lodur`, built against Lodur `c324570` (`nibu/lodur-dead-flows`: a dead physiology's flows read zero); Lodur finds `..\Ymir`, or `YMIR_ROOT`). Entry points:
- `src/BadDay.Core/PainBoxSimulation.cs`: the headless run over Lodur's Actor.
- `src/BadDay.Core/ChamberBrain.cs`: the volunteer's Brain, authored as data: his goals, and the payment's pull.
@ -120,7 +120,7 @@ The scenarios, one owner per decision:
| Owner | Inputs | Outputs | Derived state | Forbidden writers |
|---|---|---|---|---|
| `ChamberBrain`, `OfficeBrain` | `PainBoxParameters` or `StressParameters`, the poses | a Lodur `Brain`: goals and their rules as data, and the release goal's id (`withdraw`, `calm`) | none; Lodur's Actor commits each switch | a session choosing a goal; a goal rule outside the Brain |
| `ChamberBrain`, `OfficeBrain` | `PainBoxParameters` or `StressParameters`, the poses | a Lodur `Brain`: goals and their rules as data, and, for the chamber, the release goal's id (`withdraw`) | none; Lodur's Actor commits each switch | a session choosing a goal; a goal rule outside the Brain |
| `PainBoxSession`, `StressSession` | seed, traits, the box or the cause, the player's commands (`Silence`, box off) | the box's or the emitters' intensities each tick; rows read back from the Actor (the stress column is the drive's arousal, the goal column the Actor's goal); the end of the run | the release goal, found by id at construction (an unknown id refuses the build) | computing load, arousal, resolve or a goal; a goal index hard-coded for the release |
| Lodur (`Actor`, the drive, the Brain) | the sessions' stimuli, the body's region points | muscle strengths and targets; the events | resolve, strain, pain, arousal, the breaks, the sensory gain in force | BDS writing any of it |
| Lodur's `Physiology` | `Afflict` calls (only from `StressSession.Wound`) and the Actor's step input | blood loss, consciousness, air hunger, death and its cause (`Died` once; a dead body is limp) | tissue integrity, bleed, the motor ceiling | a session or client deciding death, bleed or consciousness; any `Afflict` outside `StressSession.Wound` |
@ -203,13 +203,13 @@ no pull) loops wind-up and strike with each arm at 0.25 s a key. It refills his
and breaks a second time (5-20 s after the snap) `Calm` takes over: his composed pose at normal strength, involuntary since his will is spent,
terminal as data (it gates on `Breaks >= 2`, which never falls, and nothing outranks it): he throws no further fit
(ruling `lodur:ruling:fella-calm-after-rage`). The Actor commits each switch 100 ms after its break,
the session logs a `GoalChanged` row for each, and the run goes on `ReleaseSeconds` (8 s, the settle: the seated body is under 0.025 m/s by then on every seed 1-100) after the Brain's release goal
(`ReleaseGoalId`, `calm`) takes over, or to 180 s if the will holds. `TimeToBreakMs` is the first break, the snap; the second `WillBroke` row is the rage running dry.
the session logs a `GoalChanged` row for each. The office has no end of its own (ruling `lodur:ruling:bds-office-is-a-sandbox-preset`): the break is an event in the scene, the body goes on, and a wound may kill it in its own time; whoever steps the session stops when the player ends it (the headless run, the sweep and `OfficeBody.Run` take a horizon in seconds, the CLI's `--max`, 180 by default).
`TimeToBreakMs` is the first break, the snap; the second `WillBroke` row is the rage running dry.
The chamber's release is declared the same way (`PainBoxParameters.ReleaseGoalId`, `withdraw`), and its withdrawal is one-way: a will that mends does not give the hand back. Who has the day is a `Character` (his senses; `Character.OfficeFella`),
apart from the setting and the cause. Each scenario builds its own Brain from its own parameters; one entry point keyed by character id
waits for Brains as content. Headless the rage moves nothing; `office --body` runs it on the puppet.
On the puppet the office is `OfficeBodySession`, stepped by its caller one 1/120 s step at a time like the chamber's session (`OfficeBody.Run` records one to its end). It builds a `SeatedBody`, the one owner of every BDS body world, and attaches a Lodur `Physiology` to the Actor (`StressParameters.SlowScale`, default 20 [P]: ruling `lodur:ruling:bds-physiology-clock`; Acute afflictions such as a cut do not move with it). The player's harm is `Wound(part, tool)`: a `WoundTool` is a depth and a severity; the hit point in the part's frame and Lodur's `PartTissuesDef.Reach` pick the layers, and `StressSession.Wound` binds one Cut affliction on each, the only path harm takes into the body. The knife (`WoundTool.Knife`, 0.02 m at 60 [P]: skin, fat and muscle on limbs and trunk, the larynx at the front of the throat) is the click-cut's content until contacts become afflictions. Lodur decides the rest: blood loss, consciousness, air hunger and death (`lodur:ruling:bds-death`). A cut on the left lower arm bleeds the body out in about 40 s; the Actor reports `Died` once, the body goes limp (it writes no strength from then on), the session logs a `Died` row, ends the run `ReleaseSeconds` later with `Outcome.Died`, and `StressResult` carries `DiedAtMs` and `DeathCause`. An unwounded run is unchanged: nothing in it can die.
On the puppet the office is `OfficeBodySession`, stepped by its caller one 1/120 s step at a time like the chamber's session (`OfficeBody.Run` records one for a horizon). It builds a `SeatedBody`, the one owner of every BDS body world, and attaches a Lodur `Physiology` to the Actor (`StressParameters.SlowScale`, default 20 [P]: ruling `lodur:ruling:bds-physiology-clock`; Acute afflictions such as a cut do not move with it). The player's harm is `Wound(part, tool)`: a `WoundTool` is a depth and a severity; the hit point in the part's frame and Lodur's `PartTissuesDef.Reach` pick the layers, and `StressSession.Wound` binds one Cut affliction on each, the only path harm takes into the body. The knife (`WoundTool.Knife`, 0.02 m at 60 [P]: skin, fat and muscle on limbs and trunk, the larynx at the front of the throat) is the click-cut's content until contacts become afflictions. Lodur decides the rest: blood loss, consciousness, air hunger and death (`lodur:ruling:bds-death`). A cut on the left lower arm bleeds the body out in about 40 s; the Actor reports `Died` once, the body goes limp (it writes no strength from then on), the session logs a `Died` row, ends the run `ReleaseSeconds` later with `Outcome.Died`, and `StressResult` carries `DiedAtMs` and `DeathCause`. An unwounded run is unchanged: nothing in it can die.
The stress bar is his arousal, how wound up he is right now, and reads **stress (arousal)** (`StressResult.StressBarLabel`; ruling `lodur:ruling:stress-bar-shows-arousal-calm-silences`).
It rises with each stressor and falls in quiet; will is not on it. Entering calm fades his arousal and his senses' gain to nothing over `CalmFadeSeconds` (3 s, the aftershock tail of

View file

@ -151,7 +151,7 @@ public partial class Hud : CanvasLayer
_text.Append($"airway {o.AirwayLiquid * 1e6:F0} mL ({o.Occlusion * 100:F0} % full)\n");
_text.Append($"airway bleed {o.AirwayBleed * 1e6:F2} mL/s drawn {o.AirwayDrawnLive * 1e6:F3} mL this step\n");
if (o.Dead) _text.Append($"DEAD: {o.DeathCause}\n");
else _text.Append(o.Finished ? "finished\n" : "running\n");
else _text.Append("running\n");
_text.Append(_main.Cuts.Count > 0 ? $"last cut: {_main.Cuts[^1].Part} at tick {_main.Cuts[^1].Tick}\n" : "no cuts yet\n");
var events = _main.Events;
for (int i = System.Math.Max(0, events.Count - LogLines); i < events.Count; i++)

View file

@ -106,9 +106,9 @@ public static class Program
var p = defaults with
{
Cause = (defaults.Cause with { ObjectivePull = Num(opts, "pull", defaults.Cause.ObjectivePull) }).Scaled(Num(opts, "scale", 1.0)),
MaxSeconds = Num(opts, "max", defaults.MaxSeconds),
SampleEverySeconds = Num(opts, "every", defaults.SampleEverySeconds),
};
double seconds = Num(opts, "max", 180); // the headless run's horizon: the office session has no end of its own
if (opts.ContainsKey("body") && opts.ContainsKey("silence")) throw new ArgumentException("--silence does not apply to --body");
var silences = new List<SilenceCommand>();
if (opts.TryGetValue("silence", out var list))
@ -123,7 +123,7 @@ public static class Program
if (opts.ContainsKey("body"))
{
var b = OfficeBody.Run(p with { TickSeconds = OfficeBody.TickSeconds }, seed);
var b = OfficeBody.Run(p with { TickSeconds = OfficeBody.TickSeconds }, seed, seconds);
output.WriteLine(OfficeTitle);
output.Write(b.Run.Render());
output.WriteLine(b.Run.Summary());
@ -139,14 +139,14 @@ public static class Program
$"(left {OfficeBody.CountStrikes(b.HandL, rage, end)}, right {OfficeBody.CountStrikes(b.HandR, rage, end)}), " +
$"{b.Strikes(0, rage)} before it");
}
else if (b.Run.Outcome == Outcome.WillBroke) output.WriteLine($"the will broke but --max ended the run at {b.Run.EndMs} ms, before the rage took over");
else if (b.Run.Outcome == Outcome.WillBroke) output.WriteLine($"the will broke but --max stopped the run at {b.Run.EndMs} ms, before the rage took over");
else output.WriteLine($"no rage: the will held to {b.Run.EndMs} ms");
return 0;
}
if (!sweep)
{
var r = StressSimulation.Run(p, seed, silences);
var r = StressSimulation.Run(p, seed, seconds, silences);
output.WriteLine(OfficeTitle);
output.Write(r.Render());
output.WriteLine(r.Summary());
@ -154,7 +154,7 @@ public static class Program
}
int count = (int)Num(opts, "count", 20);
var summary = StressSweep.Run(p, seed, count, silences);
var summary = StressSweep.Run(p, seed, count, seconds, silences);
foreach (var r in summary.Results) output.WriteLine(r.Summary());
output.WriteLine($"runs {summary.Runs}: broke {summary.Broke}, endured {summary.Endured}; " +
$"time to break min/median/max ms: {Fmt(summary.MinBreakMs)}/{Fmt(summary.MedianBreakMs)}/{Fmt(summary.MaxBreakMs)}; " +

View file

@ -38,7 +38,7 @@ public static class OfficeBrain
public const string RageId = "rage";
/// <summary>The calm goal's id: what the scenario's release waits for (<see cref="StressParameters.ReleaseGoalId"/>).</summary>
/// <summary>The calm goal's id.</summary>
public const string CalmId = "calm";
public static OfficeGoal GoalAt(int index) => index switch { RageIndex => OfficeGoal.Rage, CalmIndex => OfficeGoal.Calm, _ => OfficeGoal.KeepComposure };

View file

@ -8,13 +8,9 @@ namespace BadDay.Core;
public sealed record StressParameters
{
public double TickSeconds { get; init; } = 0.01;
public double MaxSeconds { get; init; } = 180.0;
public double SampleEverySeconds { get; init; } = 1.0;
/// <summary>How long the run goes on after the release goal (calm) takes over, seconds [P]: the settle time. Calibrated on the body so the seated puppet is still by the end: over seeds 1-100 the fastest hand in the last second is 0.0124 m/s at 8 s (0.0521 at 6 s, over the 0.05 m/s stillness limit; 0.0259 at 7 s), checked by the office body settle test; the headless run ends at the same time, one rule for every path.</summary>
public double ReleaseSeconds { get; init; } = 8.0;
/// <summary>How long calm takes to fade his arousal and his senses' gain to nothing, seconds [P] (rulings lodur:ruling:stress-bar-shows-arousal-calm-silences, lodur:ruling:flinch-tail-after-stimulus): the aftershock tail, a few seconds, then he stops. Below <see cref="ReleaseSeconds"/>, so the run's last seconds show an empty bar.</summary>
/// <summary>How long calm takes to fade his arousal and his senses' gain to nothing, seconds [P] (rulings lodur:ruling:stress-bar-shows-arousal-calm-silences, lodur:ruling:flinch-tail-after-stimulus): the aftershock tail, a few seconds, then he stops.</summary>
public double CalmFadeSeconds { get; init; } = 3.0;
/// <summary>What the rage costs his will per second while it is voluntary, resolve units [P]: the rage refills his will, and this is how fast it runs dry (about 20 s from full, so the rage lasts 5-20 s with the senses still pressing).</summary>
@ -26,9 +22,6 @@ public sealed record StressParameters
/// <summary>Seconds from one rage key to the next [P]: wind-up left, strike left, wind-up right, strike right.</summary>
public double RageKeySeconds { get; init; } = 0.25;
/// <summary>The id of the Brain goal whose takeover starts the release: the run ends <see cref="ReleaseSeconds"/> after that goal's GoalChanged, and a change to any other goal does not. The session refuses an id the Brain lacks.</summary>
public string ReleaseGoalId { get; init; } = OfficeBrain.CalmId;
public Setting Setting { get; init; } = Setting.Office;
public Character Character { get; init; } = Character.OfficeFella;
public Cause Cause { get; init; } = Cause.Office;

View file

@ -5,7 +5,7 @@ using Lodur;
namespace BadDay.Core;
public enum StressEntryKind { Sample, Silenced, WillBroke, GoalChanged, Died, Endured }
public enum StressEntryKind { Sample, Silenced, WillBroke, GoalChanged, Died }
/// <summary>One timeline row: end-of-tick state read from the Actor. Audio, Visual and Interrupt are the stimulus that reached the head on each channel.</summary>
public readonly record struct StressEntry(
@ -17,9 +17,9 @@ public readonly record struct SilenceCommand(string StressorId, double AtSeconds
public sealed record StressResult(
ulong Seed,
/// <summary>WillBroke (the run goes on through the release), Endured, or Died (a body with a physiology died); the office has no box to disable.</summary>
/// <summary>WillBroke, Endured (the will has held so far), or Died (a body with a physiology died); the office has no box to disable.</summary>
Outcome Outcome,
/// <summary>When the run ended: the release after calm took over, or MaxSeconds.</summary>
/// <summary>The time of the latest tick when the result was read, ms: the session has no end of its own.</summary>
long EndMs,
/// <summary>Time resolve hit zero, ms; null unless the will broke.</summary>
long? TimeToBreakMs,
@ -55,5 +55,5 @@ public sealed record StressResult(
? $"seed {Seed}: died of {DeathCause} at {DiedAtMs} ms"
: Outcome == Outcome.WillBroke
? $"seed {Seed}: will broke at {TimeToBreakMs} ms"
: $"seed {Seed}: endured to {EndMs} ms, will held, min resolve {MinResolve.ToString("F3", CultureInfo.InvariantCulture)}";
: $"seed {Seed}: will held to {EndMs} ms, min resolve {MinResolve.ToString("F3", CultureInfo.InvariantCulture)}";
}

View file

@ -9,8 +9,8 @@ namespace BadDay.Core;
/// <see cref="Actor"/>, and the recorder. The headless run, the sweep, the CLI and a client all drive it one
/// <see cref="Tick"/> per step, and the player's lever is <see cref="Silence"/>. The session never writes drive
/// state, computes load or arousal, or holds a stress field: rows are end-of-tick state read from the Actor, and
/// nothing reads them back. The rage and the calm after it are the Brain's (<see cref="OfficeBrain"/>): the session goes on past the break, logs each
/// tick the Actor commits a switch, and ends ReleaseSeconds after the Brain's release goal (<see cref="StressParameters.ReleaseGoalId"/>) takes over, or at MaxSeconds.
/// nothing reads them back. The rage and the calm after it are the Brain's (<see cref="OfficeBrain"/>): the session logs each tick the Actor commits a switch. It has no end of its own
/// (ruling bds-office-is-a-sandbox-preset): the will's break is an event in the scene, and the caller stops stepping when the player ends it.
/// </summary>
public sealed class StressSession
{
@ -21,10 +21,7 @@ public sealed class StressSession
private readonly bool[] _silenced;
private readonly Emitter[] _emitters;
private readonly List<StressEntry> _timeline = new();
private readonly long _maxTick;
private readonly long _sampleEvery;
private readonly long _releaseTicks;
private readonly int _releaseGoal;
private readonly Physiology? _physiology;
private readonly PhysiologyPlan? _physiologyPlan;
private readonly int[]? _stackOf;
@ -32,7 +29,6 @@ public sealed class StressSession
private long _breakTick = -1;
private double _minResolve = 1.0;
private Outcome _outcome = Outcome.Endured;
private long _endTick;
private long _diedTick = -1;
/// <param name="poses">What the Brain's goals write, one rotation per muscle; the Actor's muscle count is theirs.</param>
@ -82,13 +78,7 @@ public sealed class StressSession
OfficeBrain.Build(p, poses),
p.Character.Senses with { Gain = p.Character.Senses.Gain * gainTrait }, senseRegion,
physiology: physiology, body: body);
_maxTick = Ticks(p.MaxSeconds);
_sampleEvery = Math.Max(1, Ticks(p.SampleEverySeconds));
_releaseTicks = Ticks(p.ReleaseSeconds);
_releaseGoal = -1;
for (int g = 0; g < Actor.Brain.Goals.Count; g++) if (Actor.Brain.Goals[g].Id == p.ReleaseGoalId) _releaseGoal = g;
if (_releaseGoal < 0) throw new ArgumentException($"the Brain has no goal '{p.ReleaseGoalId}' to release on");
_endTick = _maxTick;
}
public ulong Seed { get; }
@ -100,9 +90,6 @@ public sealed class StressSession
/// <summary>Ticks run so far; the tick the next <see cref="Tick"/> runs.</summary>
public long TickIndex => Actor.TickCount;
/// <summary>True once the release after calm took over is over, or the time ran out.</summary>
public bool Finished { get; private set; }
/// <summary>
/// The player silences a stressor: from the current tick on it writes nothing. Silencing a silenced stressor
/// changes nothing; an unknown id is refused.
@ -120,13 +107,13 @@ public sealed class StressSession
/// The player wounds a part with a tool from the current tick on: one Cut affliction of the tool's severity on each layer its
/// <see cref="WoundTool.Depth"/> reaches at <paramref name="point"/> (in the part's frame) through the part's PartTissuesDef.Reach,
/// through <see cref="Physiology.Afflict"/>, the only way harm enters. All of the layers or none: false, and nothing wounded, for a
/// headless session, a body that is dead (death is permanent, bds-death) or a run that is <see cref="Finished"/>, a part the body
/// headless session, a body that is dead (death is permanent, bds-death), a part the body
/// lacks, or when the physiology has no room for every layer (its answer, not counted here).
/// </summary>
public bool Wound(int part, (float X, float Y, float Z) point, WoundTool tool)
{
if (_physiology is null || _physiologyPlan is null || _stackOf is null || (uint)part >= (uint)_stackOf.Length) return false;
if (Finished || _physiology.Dead) return false;
if (_physiology.Dead) return false;
var stack = _physiologyPlan.Parts[_stackOf[part]];
Span<int> layers = stackalloc int[stack.Tissues.Count];
int n = stack.Reach(point, tool.Depth, layers);
@ -160,28 +147,21 @@ public sealed class StressSession
}
if ((events & TickEvents.Died) != 0)
{
// The Actor reported the body's death (once); it is limp and frozen from here, and the run ends a release later.
// The Actor reported the body's death (once); it is limp and frozen from here.
_diedTick = tick;
_outcome = Outcome.Died;
_endTick = Math.Min(_endTick, tick + _releaseTicks);
Log(tick, StressEntryKind.Died);
}
if (tick % _sampleEvery == 0) Log(tick, StressEntryKind.Sample);
if ((events & TickEvents.GoalChanged) != 0)
{
if (Actor.GoalIndex == _releaseGoal) _endTick = Math.Min(_maxTick, tick + _releaseTicks);
Log(tick, StressEntryKind.GoalChanged);
}
if (tick >= _endTick)
{
if (_outcome == Outcome.Endured) Log(tick, StressEntryKind.Endured);
Finished = true;
}
return events;
}
public StressResult Result() => new(
Seed, _outcome, Ms(_endTick), _breakTick >= 0 ? Ms(_breakTick) : null, _minResolve, _timeline,
Seed, _outcome, Ms(TickIndex), _breakTick >= 0 ? Ms(_breakTick) : null, _minResolve, _timeline,
_diedTick >= 0 ? Ms(_diedTick) : null, _diedTick >= 0 ? _physiology!.Cause : DeathCause.None);
public long Ms(long tick) => (long)Math.Round(tick * _p.TickSeconds * 1000.0);

View file

@ -7,19 +7,20 @@ namespace BadDay.Core;
/// <summary>
/// The headless office: one virtual human with the head fixed at the sense point, run through
/// <see cref="StressSession"/> to the end of the release after the break, or MaxSeconds. The silences are what a player would have done, each
/// <see cref="StressSession"/> for <c>seconds</c> (the harness's horizon: the session has no end of its own). The silences are what a player would have done, each
/// applied at the tick its time falls on, before that tick runs.
/// </summary>
public static class StressSimulation
{
public static StressResult Run(StressParameters p, ulong seed, IReadOnlyList<SilenceCommand>? silences = null)
public static StressResult Run(StressParameters p, ulong seed, double seconds, IReadOnlyList<SilenceCommand>? silences = null)
{
var session = new StressSession(p, seed, 1, OfficePoses.Identity);
var point = new float[1]; // the head sits at the origin
var strengths = new float[1]; // the behaviour's output has no body to move
var targets = new Quat[1];
var pending = (silences ?? Array.Empty<SilenceCommand>()).OrderBy(s => s.AtSeconds).ToList();
while (!session.Finished)
long ticks = (long)Math.Round(seconds / p.TickSeconds);
while (session.TickIndex < ticks)
{
while (pending.Count > 0 && Math.Round(pending[0].AtSeconds / p.TickSeconds) <= session.TickIndex)
{
@ -39,10 +40,10 @@ public sealed record StressSweep(
double? MinEnduredResolve,
IReadOnlyList<StressResult> Results)
{
public static StressSweep Run(StressParameters p, ulong firstSeed, int count, IReadOnlyList<SilenceCommand>? silences = null)
public static StressSweep Run(StressParameters p, ulong firstSeed, int count, double seconds, IReadOnlyList<SilenceCommand>? silences = null)
{
var results = new List<StressResult>(count);
for (int i = 0; i < count; i++) results.Add(StressSimulation.Run(p, firstSeed + (ulong)i, silences));
for (int i = 0; i < count; i++) results.Add(StressSimulation.Run(p, firstSeed + (ulong)i, seconds, silences));
var breaks = results.Where(r => r.TimeToBreakMs.HasValue).Select(r => r.TimeToBreakMs!.Value).OrderBy(x => x).ToList();
var endured = results.Where(r => r.Outcome == Outcome.Endured).ToList();
return new StressSweep(

View file

@ -24,8 +24,8 @@ public sealed record WoundTool
public double Severity { get; }
/// <summary>
/// 2 cm at severity 60. At that depth: skin, fat and muscle on the limbs and trunk (bone lies past 2.26 cm there), skin and fat on the
/// 2 cm at severity 20 (ruling bds-bleed-by-vessels: an ordinary cut bleeds out in 2 to 4 minutes, a major vessel in about 30 s, the front of the throat drowns). At that depth: skin, fat and muscle on the limbs and trunk (bone lies past 2.26 cm there), skin and fat on the
/// face and sides of the head, the larynx at the front of the throat, and bone as well as muscle in the hands and feet.
/// </summary>
public static WoundTool Knife { get; } = new(0.02, 60.0);
public static WoundTool Knife { get; } = new(0.02, 20.0);
}

View file

@ -50,14 +50,15 @@ public static class OfficeBody
/// </summary>
public static OfficePoses Poses { get; } = BuildPoses();
/// <summary>Runs the office on the puppet to the end of the release; the tick rate must be 1/120 s.</summary>
public static OfficeBodyResult Run(StressParameters p, ulong seed)
/// <summary>Runs the office on the puppet for <paramref name="seconds"/> (the harness's horizon: the session has no end of its own); the tick rate must be 1/120 s.</summary>
public static OfficeBodyResult Run(StressParameters p, ulong seed, double seconds)
{
using var session = new OfficeBodySession(p, seed);
var handL = new List<BodyPoint>();
var handR = new List<BodyPoint>();
var pelvis = new List<BodyPoint>();
while (!session.Finished)
long ticks = (long)Math.Round(seconds * Hz);
while (session.TickIndex < ticks)
{
session.Step();
handL.Add(session.HandL);

View file

@ -13,8 +13,7 @@ namespace BadDay.Ymir;
/// sensed there. Per <see cref="Step"/>: the body reports its points and what its airway openings hold, the session decides (Lodur's Actor, which steps
/// the physiology first), the ragdoll is driven, the world steps. Harm enters only through <see cref="Wound"/>; the
/// session never decides death, blood or consciousness: the read-outs are Lodur's. A dead body is limp (the Actor writes
/// no strength) and the run ends a release after the death. After <see cref="Finished"/> <see cref="Step"/> only keeps
/// the body moving, as the chamber does.
/// no strength). The office has no end (ruling bds-office-is-a-sandbox-preset): <see cref="Finished"/> is never true, the will's break is an event, and the caller stops stepping.
/// </summary>
public sealed class OfficeBodySession : IBodyRun
{
@ -24,7 +23,6 @@ public sealed class OfficeBodySession : IBodyRun
private readonly double _tickSeconds;
private readonly double[] _bleeds;
private readonly int _handL, _handR, _pelvisLane;
private bool _flows; // the latest step's physiology flows are live: it stepped (a dead physiology is not stepped, so its flows stand only on the tick it died)
private bool _disposed;
public OfficeBodySession(StressParameters p, ulong seed, BloodParameters? blood = null)
@ -65,7 +63,8 @@ public sealed class OfficeBodySession : IBodyRun
/// <summary>Ticks run so far; the tick the next <see cref="Step"/> runs.</summary>
public long TickIndex { get { Live(); return _session.TickIndex; } }
public bool Finished { get { Live(); return _session.Finished; } }
/// <summary>Always false: the office is a sandbox preset that lasts until the player ends it. Here for <see cref="IBodyRun"/>, which the chamber ends.</summary>
public bool Finished { get { Live(); return false; } }
/// <summary>The Actor's state at the end of the latest tick, and the body's (Lodur's numbers, never BDS's).</summary>
public double Will { get { Live(); return _session.Actor.Drive.Will; } }
@ -84,8 +83,8 @@ public sealed class OfficeBodySession : IBodyRun
public double BloodBacklog { get { Live(); return _body.BloodBacklog; } }
public int LiveDrops { get { Live(); return _body.LiveDrops; } }
/// <summary>The blood bled into the airway (real m^3/s, entering the airway at the body's blood gain; the HUD reads it) and the live liquid drawn from it (world m^3) in the latest step, then what the airway owes the world (m^3, signed), the part of <see cref="BloodEmitted"/> that was cough and drain, and the cough and drain still waiting to be shed: the body's, display only.</summary>
public double AirwayBleed { get { Live(); return _flows ? _physiology.AirwayBleed : 0.0; } }
public double AirwayDrawnLive { get { Live(); return _flows ? _physiology.DrawnLive : 0.0; } }
public double AirwayBleed { get { Live(); return _physiology.AirwayBleed; } }
public double AirwayDrawnLive { get { Live(); return _physiology.DrawnLive; } }
public double AirwayOwed { get { Live(); return _body.Owed; } }
public double BloodExpelled { get { Live(); return _body.BloodExpelled; } }
public double ExpelBacklog { get { Live(); return _body.ExpelBacklog; } }
@ -105,31 +104,18 @@ public sealed class OfficeBodySession : IBodyRun
}
}
/// <summary>One step of 1/120 s; see the type's summary for what it does after <see cref="Finished"/>.</summary>
/// <summary>One step of 1/120 s: the body reports its points and what its airway openings hold, the session decides, the ragdoll is driven, the world steps.</summary>
public void Step()
{
Live();
if (!_session.Finished)
{
long tick = _session.TickIndex;
_body.ReadSenses();
var airway = _body.ReadAirway();
bool deadBefore = _physiology.Dead; // the Actor does not step a dead physiology, so its flows stand only on the tick it died
_flows = !deadBefore;
var events = _session.Tick(_body.X, _body.Y, _body.Z, _body.Strengths, _body.Targets, airway);
if (events != TickEvents.None) _body.Enqueue(tick, events);
if (!deadBefore)
{
_body.Exchange(_physiology.DrawnLive, _physiology.DrawnPooled, _physiology.Coughed, _physiology.Drained); // the dying step's flows are real
for (int part = 0; part < _bleeds.Length; part++) _bleeds[part] = _physiology.Bleed(part); // the dying step's bleed included: Lodur reports it
}
else Array.Clear(_bleeds);
_body.DriveAndStep(_tickSeconds, _bleeds);
return;
}
// After Finished the physiology no longer steps, so its last rates would run forever: no bleeds, and what is in flight settles.
_flows = false;
_body.DriveAndStep(_tickSeconds); // the last strengths and targets again
long tick = _session.TickIndex;
_body.ReadSenses();
var airway = _body.ReadAirway();
var events = _session.Tick(_body.X, _body.Y, _body.Z, _body.Strengths, _body.Targets, airway);
if (events != TickEvents.None) _body.Enqueue(tick, events);
_body.Exchange(_physiology.DrawnLive, _physiology.DrawnPooled, _physiology.Coughed, _physiology.Drained); // the dying step's flows are real; a dead physiology's read 0 (Lodur steps it)
for (int part = 0; part < _bleeds.Length; part++) _bleeds[part] = _physiology.Bleed(part);
_body.DriveAndStep(_tickSeconds, _bleeds);
}
/// <summary>Moves the queued events (oldest first) into <paramref name="buffer"/>; see <see cref="SeatedBody.DrainEvents"/>.</summary>

View file

@ -617,10 +617,10 @@ public static class Program
Check(Office(p, 1).Render() == Office(p, 1).Render(), "rendered timelines differ");
var a = NewOffice(p, 1);
var b = NewOffice(p, 2);
while (!a.Finished || !b.Finished)
while (a.TickIndex < OfficeSeconds / p.TickSeconds)
{
if (!a.Finished) Step(a);
if (!b.Finished) Step(b);
Step(a);
Step(b);
}
Check(a.Result().Render() == Office(p, 1).Render() && b.Result().Render() == Office(p, 2).Render(), "stepped sessions differ from runs alone");
}),
@ -630,12 +630,11 @@ public static class Program
var r = Office(new StressParameters { Cause = Cause.Office with { Stressors = Array.Empty<Stressor>() } }, 1);
Check(r.Outcome == Outcome.Endured && r.TimeToBreakMs is null && r.EndMs == 180000, $"outcome {r.Outcome} at {r.EndMs}");
Check(r.Timeline.All(e => e.Load == 0.0 && e.Arousal == 0.0 && e.Resolve == 1.0), "an empty office loaded the character");
Check(r.Timeline[^1].Kind == StressEntryKind.Endured, "no Endured row");
}),
("office tuning [P]: seeds 1..50, at least 80% break within 180 s, and p10 and p90 break times differ by more than 20%", () =>
{
var sweep = StressSweep.Run(new StressParameters(), 1, 50);
var sweep = StressSweep.Run(new StressParameters(), 1, 50, OfficeSeconds);
Check(sweep.Broke >= 40, $"only {sweep.Broke} of 50 broke");
var b = sweep.Results.Where(r => r.TimeToBreakMs.HasValue).Select(r => (double)r.TimeToBreakMs!.Value).OrderBy(x => x).ToArray();
double p10 = b[(int)(b.Length * 0.1)], p90 = b[(int)(b.Length * 0.9)];
@ -714,11 +713,11 @@ public static class Program
("office: after one 10 s burst resolve does not rise while arousal is at or above the threshold, then it rises", () =>
{
var burst = new Stressor("burst", "printer", 0, 0, null, 10, 0.5, 0);
var p = new StressParameters { MaxSeconds = 120, Cause = Cause.Office with { Stressors = new[] { burst } } };
var p = new StressParameters { Cause = Cause.Office with { Stressors = new[] { burst } } };
var s = NewOffice(p, 1);
double gate = p.Drive.ResolveRecoversBelowArousal, prev = 1.0, lowest = 1.0;
int heldDown = 0, rose = 0;
while (!s.Finished)
while (s.TickIndex < 120.0 / p.TickSeconds)
{
Step(s);
var d = s.Actor.Drive;
@ -808,8 +807,8 @@ public static class Program
Check(plain.Contains("will broke at"), "seed 1 should break at the default settings");
var quiet = Run("office", "--seed", "1", "--silence", "printer@0", "--silence", "desk-phone@0");
Check(quiet.Split('\n').Count(l => l.Contains(" Silenced ")) == 2, "two --silence options should give two Silenced rows");
Check(Run("office", "--seed", "1", "--scale", "0").Contains("endured to 180000 ms"), "--scale 0 should be a quiet office");
Check(Run("office", "--seed", "1", "--pull", "1").Contains("endured"), "--pull 1 never drains");
Check(Run("office", "--seed", "1", "--scale", "0").Contains("will held to 180000 ms"), "--scale 0 should be a quiet office");
Check(Run("office", "--seed", "1", "--pull", "1").Contains("will held to"), "--pull 1 never drains");
Check(Run("office-sweep", "--seed", "1", "--count", "5").Contains("min resolve of endured runs:"), "no sweep summary");
foreach (var bad in new[] { new[] { "office" }, new[] { "office", "--seed", "1", "--silence", "printer" }, new[] { "office", "--seed", "1", "--silence", "nope@1" }, new[] { "office-sweep", "--seed", "1", "--body" }, new[] { "office", "--seed", "1", "--body", "--silence", "printer@1" }, new[] { "office", "--seed", "1", "--pay", "5" } })
{
@ -868,7 +867,7 @@ public static class Program
}
}),
("office golden [P]: the rows up to the break are rung 3's bytes, the 50-seed sweep ends in its captured line, and the run's own bytes are captured (re-captured with the arc, again for the 8 s settle, and again for the arousal bar)", () =>
("office golden [P]: the rows up to the break are rung 3's bytes, the 50-seed sweep ends in its captured line, and the run's own bytes are captured (re-captured with the arc, again for the 8 s settle, and again for the arousal bar, and again when the session lost its end: the old run's bytes are the first 109 lines, then 77 more rows to the 180 s horizon)", () =>
{
string Out(params string[] a)
{
@ -890,12 +889,12 @@ public static class Program
}
rung3.Add(lines[^1]);
Check(Hash(string.Join('\n', rung3) + "\n") == "66098b69834c3c8b5e5b694f0059b8ed566e31d332f36be7e57baf70ae650823", "the office's rows up to the break differ from rung 3's");
Check(Hash(string.Join('\n', lines) + "\n") == "f52e70b641cde4bcb5c5f6286ed022ccd31950425656b23f302a041218396db6", $"office --seed 1 changed: {Hash(string.Join('\n', lines) + "\n")}");
Check(Hash(string.Join('\n', lines) + "\n") == "fd36bb482a2aa8ae2f8992686016e1bfbc21c3db0e7ecc51cab574f4b617b606", $"office --seed 1 changed: {Hash(string.Join('\n', lines) + "\n")}");
var last = Out("office-sweep", "--seed", "1", "--count", "50").TrimEnd('\n').Split('\n')[^1];
Check(last == "runs 50: broke 50, endured 0; time to break min/median/max ms: 72670/86570/113420; min resolve of endured runs: -", $"sweep line changed: {last}");
}),
("office arc: the snap, then a rage on a refilled will, a second break 5-20 s later, and calm for good: every switch 100 ms after its break, nothing after calm, and the run ends ReleaseSeconds after calm", () =>
("office arc: the snap, then a rage on a refilled will, a second break 5-20 s later, and calm for good: every switch 100 ms after its break, and nothing changes after calm to the 180 s horizon", () =>
{
for (ulong seed = 1; seed <= 20; seed++)
{
@ -913,12 +912,8 @@ public static class Program
Check(r.Timeline.Where(e => e.TimeMs < rage.TimeMs).All(e => e.Goal == OfficeGoal.KeepComposure), $"seed {seed}: a row before the rage is not KeepComposure");
Check(r.Timeline.Where(e => e.TimeMs >= rage.TimeMs && e.TimeMs < calm.TimeMs).All(e => e.Goal == OfficeGoal.Rage), $"seed {seed}: a row in the rage is not Rage");
Check(r.Timeline.Where(e => e.TimeMs >= calm.TimeMs).All(e => e.Goal == OfficeGoal.Calm), $"seed {seed}: a row from calm on is not Calm");
Check(r.Outcome == Outcome.WillBroke && r.EndMs == calm.TimeMs + 8000, $"seed {seed}: ended at {r.EndMs}, calm was at {calm.TimeMs}");
Check(r.Outcome == Outcome.WillBroke && r.EndMs == 180000, $"seed {seed}: outcome {r.Outcome}, read at {r.EndMs}, calm was at {calm.TimeMs}");
}
var short_ = Office(new StressParameters { ReleaseSeconds = 2.0 }, 1);
Check(short_.EndMs == short_.Timeline.Single(e => e.Kind == StressEntryKind.GoalChanged && e.Goal == OfficeGoal.Calm).TimeMs + 2000, "ReleaseSeconds did not set the settle time");
var clipped = Office(new StressParameters { MaxSeconds = 85.0 }, 1);
Check(clipped.Outcome == Outcome.WillBroke && clipped.EndMs == 85000 && clipped.Timeline.All(e => e.Kind != StressEntryKind.Endured && e.Goal != OfficeGoal.Calm), $"a release past MaxSeconds ended at {clipped.EndMs}");
}),
("office rage onset: the rage is involuntary for RageOnsetSeconds, so it costs no will in that first second and drains at RageEffort after it", () =>
@ -953,14 +948,14 @@ public static class Program
Check(early.Contains("before the rage took over"), $"clipped before the rage: {early}");
}),
("office calm is terminal: with the release moved off calm the run goes to MaxSeconds, and after the Calm row the goal never changes again, with the senses still pressing", () =>
("office calm is terminal: after the Calm row the goal never changes again to the 180 s horizon, with the senses still pressing", () =>
{
// Calm's fade is longer than the run here, so his senses stay open and the load keeps pressing for all 180 s. A default calm silences them: since that ruling no public path
// breaks the will a third time after calm (its mend needs arousal under 0.1, which only the quiet fade gives, and the quiet has no load), so "whatever the mending will does" is not yet reached.
var Bursty = Cause.Office with { Stressors = new[] { new Stressor("printer", "printer", 5.0, 0.0, 100.0, 40.0, 1.0, 0.0) } };
for (ulong seed = 1; seed <= 5; seed++)
{
var r = Office(new StressParameters { ReleaseGoalId = "keep-composure", Cause = Bursty, CalmFadeSeconds = 1.0e6 }, seed);
var r = Office(new StressParameters { Cause = Bursty, CalmFadeSeconds = 1.0e6 }, seed);
var calm = r.Timeline.Single(e => e.Kind == StressEntryKind.GoalChanged && e.Goal == OfficeGoal.Calm);
Check(r.EndMs == 180000, $"seed {seed}: ended at {r.EndMs}");
Check(r.Timeline.Count(e => e.Kind == StressEntryKind.GoalChanged) == 2, $"seed {seed}: a goal changed after calm");
@ -971,11 +966,11 @@ public static class Program
("office calm is terminal on the shipped calm: over a full-length run the goal never leaves Calm, though his will mends in the quiet", () =>
{
// The default fade, so the senses are silenced as shipped, and the release moved off calm so the run goes the 180 s. With no load his arousal stays 0 and resolve mends from 0:
// The default fade, so the senses are silenced as shipped, and the run read at the 180 s horizon. With no load his arousal stays 0 and resolve mends from 0:
// a calm that gated on a mended will would be lost here, which the open-senses test above cannot reach.
for (ulong seed = 1; seed <= 3; seed++)
{
var r = Office(new StressParameters { ReleaseGoalId = "keep-composure" }, seed);
var r = Office(new StressParameters(), seed);
var calm = r.Timeline.Single(e => e.Kind == StressEntryKind.GoalChanged && e.Goal == OfficeGoal.Calm);
Check(r.EndMs == 180000, $"seed {seed}: ended at {r.EndMs}");
Check(r.Timeline.Count(e => e.Kind == StressEntryKind.GoalChanged) == 2, $"seed {seed}: a goal changed after calm");
@ -984,16 +979,14 @@ public static class Program
}
}),
("office release: the run ends on the Brain's release goal, by id, not on any goal change; an id the Brain lacks is refused", () =>
("office has no end of its own: the session ticks on past the break and the calm to 600 s, its result is read at the latest tick, and no row says Endured", () =>
{
var r = Office(new StressParameters { ReleaseGoalId = "keep-composure" }, 1);
Check(r.EndMs == 180000 && r.Outcome == Outcome.WillBroke, $"releasing on a goal the Brain never switches to ended the run at {r.EndMs}");
var rage = Office(new StressParameters { ReleaseGoalId = OfficeBrain.RageId }, 1);
var sw = rage.Timeline.First(e => e.Kind == StressEntryKind.GoalChanged);
Check(sw.Goal == OfficeGoal.Rage && rage.EndMs == sw.TimeMs + 8000, $"releasing on the rage ended the run at {rage.EndMs}, the rage was at {sw.TimeMs}");
bool threw = false;
try { NewOffice(new StressParameters { ReleaseGoalId = "nowhere" }, 1); } catch (ArgumentException) { threw = true; }
Check(threw, "a release goal the Brain lacks was accepted");
var s = NewOffice(new StressParameters(), 1);
while (s.TickIndex < 60000) Step(s);
var r = s.Result();
Check(r.Outcome == Outcome.WillBroke && r.EndMs == 600000, $"outcome {r.Outcome}, read at {r.EndMs} ms");
Check(r.Timeline.Count(e => e.Kind == StressEntryKind.GoalChanged) == 2 && r.Timeline.Where(e => e.Kind == StressEntryKind.Sample).Max(e => e.TimeMs) >= 599000, "the session stopped logging");
Check(r.Timeline[^1].Goal == OfficeGoal.Calm, "the office left calm after its break");
}),
("office rage: a will that holds never switches, and the job's pull is the composure goal's alone", () =>
@ -1008,8 +1001,8 @@ public static class Program
("office body: the rage is visible: both hands move at least 3x faster, and over 1 m/s (a limp rage gives 0.6), in the 2 s after the switch than in the 2 s before, the pelvis stays within 1 cm, and two runs agree", () =>
{
var p = new StressParameters { TickSeconds = OfficeBody.TickSeconds };
var a = OfficeBody.Run(p, 1);
var b = OfficeBody.Run(p, 1);
var a = BodyArc(p, 1);
var b = BodyArc(p, 1);
Check(a.Run.Render() == b.Run.Render() && a.HandL.SequenceEqual(b.HandL) && a.HandR.SequenceEqual(b.HandR) && a.Pelvis.SequenceEqual(b.Pelvis), "two body runs differ");
Check(a.Run.Outcome == Outcome.WillBroke && a.RageTick is not null, $"outcome {a.Run.Outcome}");
int sw = a.RageTick!.Value;
@ -1046,7 +1039,7 @@ public static class Program
var p = new StressParameters { TickSeconds = OfficeBody.TickSeconds };
for (ulong seed = 1; seed <= 3; seed++)
{
var a = OfficeBody.Run(p, seed);
var a = BodyArc(p, seed);
int rage = a.RageTick!.Value;
int calm = (int)Math.Round(a.Run.Timeline.Single(e => e.Kind == StressEntryKind.GoalChanged && e.Goal == OfficeGoal.Calm).TimeMs * Hz / 1000.0);
double Speed(IReadOnlyList<BodyPoint> h, int i)
@ -1077,7 +1070,7 @@ public static class Program
ulong worstSeed = 0;
foreach (ulong seed in seeds)
{
var a = OfficeBody.Run(new StressParameters { TickSeconds = OfficeBody.TickSeconds }, seed);
var a = BodyArc(new StressParameters { TickSeconds = OfficeBody.TickSeconds }, seed);
foreach (var h in new[] { a.HandL, a.HandR })
{
for (int k = h.Count - Hz; k < h.Count; k++)
@ -1093,20 +1086,20 @@ public static class Program
("office body: the desk's emitters are sensed at the head, so the body breaks within 0.5 s of the headless run (sensed at a hand it is 3.6 s off)", () =>
{
var body = OfficeBody.Run(new StressParameters { TickSeconds = OfficeBody.TickSeconds }, 1).Run;
var body = OfficeBody.Run(new StressParameters { TickSeconds = OfficeBody.TickSeconds }, 1, OfficeSeconds).Run;
var headless = Office(new StressParameters(), 1);
Check(Math.Abs(body.TimeToBreakMs!.Value - headless.TimeToBreakMs!.Value) < 500, $"body {body.TimeToBreakMs} ms, headless {headless.TimeToBreakMs} ms");
}),
("office session: stepping OfficeBodySession to Finished gives OfficeBody.Run's timeline, seeds 1 and 2, and the pelvis and hands are the ones Run recorded", () =>
("office session: stepping OfficeBodySession to the horizon gives OfficeBody.Run's timeline, seeds 1 and 2, and the pelvis and hands are the ones Run recorded", () =>
{
var p = new StressParameters { TickSeconds = OfficeBody.TickSeconds };
foreach (ulong seed in new ulong[] { 1, 2 })
{
var run = OfficeBody.Run(p, seed);
var run = OfficeBody.Run(p, seed, OfficeSeconds);
using var s = new OfficeBodySession(p, seed);
int steps = 0;
while (!s.Finished) { s.Step(); steps++; }
while (s.TickIndex < Sandbox) { s.Step(); steps++; }
Check(s.Result().Render() == run.Run.Render(), $"seed {seed}: the stepped session's timeline differs from Run's");
Check(steps == run.HandL.Count && s.HandL == run.HandL[^1] && s.HandR == run.HandR[^1] && s.Pelvis == run.Pelvis[^1], $"seed {seed}: {steps} steps against {run.HandL.Count} recorded, or the last points differ");
bool threw = false;
@ -1115,7 +1108,7 @@ public static class Program
}
}),
("office wound kills by blood loss: Wound(LowerArm L, Knife) at tick 0 gives exactly one Died event, DeathCause BloodLoss, Outcome Died, a death 30-60 s in (probe: 42.1 s with skin and muscle) that two runs agree on, and a run that ends ReleaseSeconds later", () =>
("an ordinary knife cut bleeds out in 2-4 minutes: Wound(LowerArm L, Knife) at tick 0 gives exactly one Died event, DeathCause BloodLoss, Outcome Died, a death 120-240 s in (ruling bds-bleed-by-vessels; the band is the ruling's; shipped 191.00 s through skin, fat and muscle) that two runs agree on, and a limp body after it", () =>
{
var p = new StressParameters { TickSeconds = OfficeBody.TickSeconds };
var arm = SeatedPuppet.Plan.PartIndex("LowerArm", Lodur.Side.Left);
@ -1127,7 +1120,7 @@ public static class Program
var buffer = new BodyEvent[16];
int died = 0;
bool deadBefore = false;
while (!s.Finished)
while (s.TickIndex < 250 * Hz)
{
s.Step();
int n; while ((n = s.DrainEvents(buffer)) > 0) for (int i = 0; i < n; i++) if ((buffer[i].Events & Lodur.TickEvents.Died) != 0) died++;
@ -1136,15 +1129,34 @@ public static class Program
var r = s.Result();
Check(died == 1 && !deadBefore, $"{died} Died events drained");
Check(s.Dead && s.DeathCause == Lodur.DeathCause.BloodLoss && r.DeathCause == Lodur.DeathCause.BloodLoss, $"cause {s.DeathCause}");
Check(r.Outcome == Outcome.Died && r.DiedAtMs is long ms && ms >= 30000 && ms <= 60000, $"outcome {r.Outcome}, died at {r.DiedAtMs} ms");
Check(r.EndMs == r.DiedAtMs + (long)Math.Round(p.ReleaseSeconds * 1000.0), $"the run ended at {r.EndMs} ms, the death was at {r.DiedAtMs} ms");
Check(r.Outcome == Outcome.Died && r.DiedAtMs is long ms && ms >= 120000 && ms <= 240000, $"outcome {r.Outcome}, died at {r.DiedAtMs} ms");
Check(r.Timeline.Count(e => e.Kind == StressEntryKind.Died) == 1 && r.Summary().Contains("BloodLoss"), "the Died row or the summary is missing");
Check(s.Consciousness == 0.0 && s.BloodLoss >= 1.0, $"consciousness {s.Consciousness}, blood loss {s.BloodLoss}");
if (diedAt is null) diedAt = r.DiedAtMs; else Check(diedAt == r.DiedAtMs, $"two runs died at {diedAt} and {r.DiedAtMs} ms");
}
}),
("office death is limp and ends the run: after the Died tick every strength the session wrote is 0 and the goal never changes again, the death is before the run's end by exactly ReleaseSeconds, and before it the body was driving muscles", () =>
("a knife cut reaching a major vessel kills in about 30 s: Wound at the side of the neck (either carotid) or the inner thigh (femoral) at tick 0, DeathCause BloodLoss, death within (21.9, 48.6) s, the airway never touched", () =>
{
// Shipped 29.73 s at all three sites (ruling bds-bleed-by-vessels, about 30 s, a target and not a band). The bounds are Lodur's (VesselTests, the same physiology: shipped 29.73 s there too), the geometric midpoints
// sqrt(29.73 x 16.15) = 21.9 for a carotid with no site (reached at the front of the throat as well) and sqrt(29.73 x 79.35) = 48.6 for VesselV 1.0, separations 1.84 and 2.67.
var p = new StressParameters { TickSeconds = OfficeBody.TickSeconds };
var plan = SeatedPuppet.Plan;
foreach (var (part, side, point) in new[] { ("Head", Lodur.Side.Center, (0.0778f, -0.0778f, 0f)), ("Head", Lodur.Side.Center, (-0.0778f, -0.0778f, 0f)), ("Thigh", Lodur.Side.Left, (-0.0495f, 0.12f, 0.0495f)) })
{
using var s = new OfficeBodySession(p, 1);
int index = plan.PartIndex(part, side);
Check(s.Wound(HitAtPoint(s, index, point), WoundTool.Knife), $"the knife was refused at {part} {point}");
double maxOcclusion = 0.0;
while (!s.Dead && s.TickIndex < 120 * Hz) { s.Step(); maxOcclusion = Math.Max(maxOcclusion, s.Occlusion); }
double at = s.TickIndex / (double)Hz;
Console.WriteLine($" vessel at {part} {side} {point}: dead at {at:F2} s of {s.DeathCause}");
Check(s.Dead && s.DeathCause == Lodur.DeathCause.BloodLoss && at > 21.9 && at < 48.6, $"{part} {point}: dead {s.Dead} at {at:F2} s of {s.DeathCause}");
Check(maxOcclusion == 0.0, $"{part} {point}: the airway filled to {maxOcclusion:F3}");
}
}),
("office death is limp: after the Died tick every strength the session wrote is 0 and the goal never changes again, to 250 s, and before it the body was driving muscles", () =>
{
var p = new StressParameters { TickSeconds = OfficeBody.TickSeconds };
var plan = SeatedPuppet.Plan;
@ -1158,7 +1170,7 @@ public static class Program
float drivenBefore = 0f;
long diedTick = -1;
int goalAtDeath = -1;
while (!session.Finished)
while (session.TickIndex < 250 * Hz)
{
var ev = session.Tick(pts, pts, pts, strengths, targets);
if ((ev & Lodur.TickEvents.Died) != 0) { diedTick = session.TickIndex - 1; goalAtDeath = session.Actor.GoalIndex; }
@ -1168,7 +1180,6 @@ public static class Program
var r = session.Result();
Check(diedTick >= 0 && r.Outcome == Outcome.Died, "the body did not die");
Check(drivenBefore > 0f, "no muscle was driven before the death, so limp proves nothing");
Check(session.TickIndex - 1 == diedTick + (long)Math.Round(p.ReleaseSeconds / p.TickSeconds), $"the run ended at tick {session.TickIndex - 1}, the death was at {diedTick}");
}),
("office wound refusals: an out-of-range part and a headless session refuse, and a palm takes the knife on skin, muscle and metacarpals", () =>
@ -1201,7 +1212,7 @@ public static class Program
using var s = new OfficeBodySession(p with { SlowScale = scale }, 1);
Check(s.Wound(Hit(s, arm), new WoundTool(0.001, 0.006)), "the skin wound was refused");
bool bled = false;
while (!s.Finished)
while (s.TickIndex < Sandbox)
{
s.Step();
bled |= s.BloodLoss > 0.0;
@ -1220,7 +1231,7 @@ public static class Program
{
var arousal = new List<double>(); var resolve = new List<double>(); var goal = new List<OfficeGoal>();
double firstWill = -1, minWill = 1;
while (!s.Finished)
while (s.TickIndex < Sandbox)
{
s.Step();
if (firstWill < 0) firstWill = s.Will;
@ -1240,7 +1251,7 @@ public static class Program
{
Check(s.Wound(HitAt(s, SeatedPuppet.Plan.PartIndex("Torso", Lodur.Side.Center), (0f, 0.07f, -0.09f), alongZ: true), new WoundTool(0.065, 15.0)), "the lungs were refused");
double maxHunger = 0.0;
while (!s.Finished)
while (s.TickIndex < Sandbox)
{
s.Step();
maxHunger = Math.Max(maxHunger, s.AirHunger);
@ -1250,23 +1261,7 @@ public static class Program
}
}),
("office after Finished: Step ticks nothing (the tick index, the result and the event queue stay) and the world still steps (the hands and pelvis keep moving)", () =>
{
var p = new StressParameters { TickSeconds = OfficeBody.TickSeconds };
using var s = new OfficeBodySession(p, 1);
while (!s.Finished) s.Step();
var buffer = new BodyEvent[64];
while (s.DrainEvents(buffer) > 0) { }
long tick = s.TickIndex;
string result = s.Result().Render();
double will = s.Will;
var before = (s.HandL, s.HandR, s.Pelvis);
for (int i = 0; i < 60; i++) s.Step();
Check(s.TickIndex == tick && s.Result().Render() == result && s.Will == will && s.DrainEvents(buffer) == 0, "a step after Finished ticked the session");
Check(s.HandL != before.HandL && s.HandR != before.HandR && s.Pelvis != before.Pelvis, "the world stopped stepping after Finished");
}),
("office wound is refused once the body is dead or the run is finished, and a refused wound is whole or nothing: a tool the table lacks room for in full wounds no layer", () =>
("office wound is refused once the body is dead (not once the will has broken: the office has no end), and a refused wound is whole or nothing: a tool the table lacks room for in full wounds no layer", () =>
{
var p = new StressParameters { TickSeconds = OfficeBody.TickSeconds };
var plan = SeatedPuppet.Plan;
@ -1277,16 +1272,15 @@ public static class Program
var legHit = Hit(s, leg);
Check(s.Wound(Hit(s, arm), WoundTool.Knife), "the knife was refused");
while (!s.Dead) s.Step();
Check(!s.Finished, "the run finished at the death");
Check(!s.Wound(legHit, WoundTool.Knife), "a dead body was wounded");
while (!s.Finished) s.Step();
Check(!s.Wound(legHit, WoundTool.Knife), "a finished run was wounded");
while (s.TickIndex < 250 * Hz) s.Step();
Check(!s.Wound(legHit, WoundTool.Knife), "a body dead for a minute was wounded");
}
using (var s = new OfficeBodySession(p, 1))
{
var legHit = Hit(s, leg);
while (!s.Finished) s.Step();
Check(!s.Dead && !s.Wound(legHit, WoundTool.Knife), "a finished, living run was wounded");
while (s.TickIndex < Sandbox) s.Step();
Check(!s.Dead && s.Result().TimeToBreakMs is not null && s.Wound(legHit, WoundTool.Knife), "a living body whose will had broken could not be wounded");
}
var physiologyPlan = Lodur.PhysiologyPlans.Humanoid();
@ -1317,7 +1311,6 @@ public static class Program
var strengths = new float[plan.Joints.Count];
var targets = new Lodur.Quat[plan.Joints.Count];
for (int t = 0; t < 2000 && !healer.Wound(arm, default, graze); t++) healer.Tick(sensed, sensed, sensed, strengths, targets);
Check(!healer.Finished, "the run ended before the grazes healed");
Check(healer.Wound(arm, default, graze), "healed wounds did not free their room: the session still counts them");
}),
@ -1343,7 +1336,7 @@ public static class Program
for (ulong seed = 1; seed <= 3; seed++)
{
using var s = new OfficeBodySession(p, seed);
while (!s.Finished) s.Step();
while (s.TickIndex < Sandbox) s.Step();
var r = s.Result();
Check(!s.Dead && s.DeathCause == Lodur.DeathCause.None && r.DiedAtMs is null && r.Outcome != Outcome.Died && s.Consciousness == 1.0, $"seed {seed}: dead {s.Dead}, cause {s.DeathCause}, consciousness {s.Consciousness}");
}
@ -1363,7 +1356,8 @@ public static class Program
for (int t = 0; t < 10 * Hz; t++) s.Step();
double spilled = blood.NominalVolume * s.BloodLoss * blood.LethalLossFraction; // nominal - BloodVolume
double visible = bloodParameters.Gain * spilled;
Check(visible > 0.005, $"only {visible * 1000.0:F1} L was spilled in 10 s");
// Floor by deterministic-bound-margin and the zero-reading convention: shipped about 2.5 L (the knife at severity 20), the mutant that bleeds nothing reads 0, counted as one unit (1 mL); sqrt(2.5e-3 x 1e-6) = 5e-5 m^3.
Check(visible > 5e-5, $"only {visible * 1000.0:F1} L was spilled in 10 s");
Check(Math.Abs(s.BloodEmitted + s.BloodBacklog - visible) < 1e-9, $"emitted {s.BloodEmitted} + backlog {s.BloodBacklog} is not {visible} m^3");
Check(s.BloodBacklog >= 0.0 && s.BloodBacklog < bloodParameters.DropVolume, $"backlog {s.BloodBacklog} m^3 is not under one drop");
Console.WriteLine($" blood: {visible * 1000.0:F2} L visible in 10 s, {s.BloodEmitted / bloodParameters.DropVolume:F0} drops, backlog {s.BloodBacklog * 1e6:F2} mL, live {s.LiveDrops}");
@ -1456,14 +1450,14 @@ public static class Program
Console.WriteLine($" airway: liquid at the opening from tick {atAirway}, in the airway from tick {liquid}, peak {maxLiquid * 1e6:F2} mL, occlusion {maxOcclusion:F3}");
}),
("office throat click reaches the larynx and fills the airway: HitAt(Head, the front of the throat), Wound(hit, Knife) at tick 0 puts more than 20 mL in the airway within 5 s, occludes it fully before the death, and the death is BloodLoss", () =>
("the front of the throat drowns him: HitAt(Head, the front of the throat), Wound(hit, Knife) at tick 0 puts more than 20 mL in the airway within 5 s, fills it (occlusion 0.99) within 12.9 s, and the death is Consciousness, not BloodLoss", () =>
{
var p = new StressParameters { TickSeconds = OfficeBody.TickSeconds };
using var s = new OfficeBodySession(p, 1);
var head = SeatedPuppet.Plan.PartIndex("Head", Lodur.Side.Center);
Check(s.Wound(HitAt(s, head, (0f, -0.0778f, 0.0778f)), WoundTool.Knife), "the knife was refused at the throat");
double liquidAt5 = 0.0, maxOcclusion = 0.0, occludedAt = -1.0;
while (!s.Dead && !s.Finished)
while (!s.Dead && s.TickIndex < 250 * Hz)
{
s.Step();
if (s.TickIndex <= 5 * Hz) liquidAt5 = Math.Max(liquidAt5, s.AirwayLiquid);
@ -1472,8 +1466,9 @@ public static class Program
}
Console.WriteLine($" throat: {liquidAt5 * 1e6:F1} mL in the airway by 5 s, full at {occludedAt:F1} s, died at {s.TickIndex / (double)Hz:F1} s");
Check(liquidAt5 > 20e-6, $"the airway held {liquidAt5 * 1e6:F2} mL by 5 s");
Check(occludedAt >= 0.0 && maxOcclusion >= 0.99, $"the airway never filled: occlusion peaked at {maxOcclusion:F3}");
Check(s.Dead && s.DeathCause == Lodur.DeathCause.BloodLoss, $"cause {s.DeathCause}");
// Bounds are Lodur's (VesselTests, the same physiology and the same gain: shipped 1.29 s here and there): full within 12.9 s = sqrt(1.29 x 129.95), the cough-2.0 mutant at 129.95 s; separation 10.
Check(occludedAt >= 0.0 && occludedAt <= 12.9 && maxOcclusion >= 0.99, $"the airway filled at {occludedAt:F2} s, occlusion peaked at {maxOcclusion:F3}");
Check(s.Dead && s.DeathCause == Lodur.DeathCause.Consciousness, $"cause {s.DeathCause}");
}),
("the physiology bleeds into the airway at the body's gain: a throat cut at Gain 1 and at Gain 10 fills the airway, in its first tenth of a second, at least 3.16 times as far at Gain 10", () =>
@ -1490,13 +1485,13 @@ public static class Program
}
double ratio = rise[1] / rise[0];
Console.WriteLine($" gain: the airway held {rise[0] * 1e6:F3} mL after 0.1 s at gain 1 and {rise[1] * 1e6:F3} mL at gain 10 (ratio {ratio:F3})");
// Bound by deterministic-bound-margin: shipped ratio 10.000 (5.477 and 54.769 mL), least mutant 1.000 (the physiology at gain 1 under a body at gain 10: the airway filling at a tenth of the visible bleed), separation 10, bound sqrt(10.000 x 1.000) = 3.16.
// Bound by deterministic-bound-margin: shipped ratio 10.000 (1.380 and 13.803 mL at the Knife's severity 20), least mutant 1.000 (the physiology at gain 1 under a body at gain 10: the airway filling at a tenth of the visible bleed), separation 10, bound sqrt(10.000 x 1.000) = 3.16.
Check(rise[0] > 0.0 && ratio >= 3.16, $"the airway's first tenth of a second held {rise[0] * 1e6:F3} mL at gain 1 and {rise[1] * 1e6:F3} mL at gain 10 (ratio {ratio:F3}): the physiology did not bleed at the body's gain");
}),
("a cut throat conserves liquid over the whole cycle at Gain 1 and Gain 10: every tick the world's liquid, the airway's and the expulsion backlog, less what the airway owes, the drops the wounds shed and the gain times the blood bled into the airway, is what it started as (1.8e-5 of the world's liquid), and at Gain 10 more than a litre is coughed and drained", () =>
("a cut throat conserves liquid over the whole cycle at Gain 1 and Gain 10: every tick the world's liquid, the airway's and the expulsion backlog, less what the airway owes, the drops the wounds shed and the gain times the blood bled into the airway, is what it started as (1.76e-5 of the world's liquid), and at Gain 10 more than a litre is coughed and drained", () =>
{
// Bound by deterministic-bound-margin, as the fraction of the world's liquid over the 1e-9 m^3 constant (read once the world holds 100 mL): shipped worst 6.70e-6 (Gain 10; 1.72e-7 at Gain 1), least mutant 4.78e-5 (the bled-in term 5e-5 short, at Gain 1; 8.90e-5 at Gain 10), separation 7.1, bound sqrt(6.70e-6 x 4.78e-5) = 1.8e-5 (the bound it replaces was 2e-5). Leaving the gain out of the bled-in term is caught by the constant at the first tick.
// Bound by deterministic-bound-margin, as the fraction of the world's liquid over the 1e-9 m^3 constant (read once the world holds 100 mL): shipped worst 6.68e-6 (Gain 10; 5.66e-8 at Gain 1), least mutant 4.62e-5 (the bled-in term 5e-5 short, at Gain 1; 8.41e-5 at Gain 10), separation 6.9, bound sqrt(6.68e-6 x 4.62e-5) = 1.76e-5 (the bound it replaces was 2e-5). Leaving the gain out of the bled-in term is caught by the constant at the first tick.
var p = new StressParameters { TickSeconds = OfficeBody.TickSeconds };
var head = SeatedPuppet.Plan.PartIndex("Head", Lodur.Side.Center);
foreach (double gain in new[] { 1.0, 10.0 })
@ -1505,23 +1500,19 @@ public static class Program
Check(s.Wound(HitAt(s, head, (0f, -0.0778f, 0.0778f)), WoundTool.Knife), "the knife was refused at the throat");
double c0 = WorldLiquid(s) + s.AirwayLiquid, bledIn = 0.0, worst = 0.0, worstRel = 0.0, mutantRel = 0.0;
long worstTick = 0;
int settling = 0; // the 600 ticks after Finished: in-flight drops settle and the backlog sheds
for (int t = 0; settling < 600 && t < 20 * 60 * Hz; t++)
for (int t = 0; t < 200 * Hz; t++) // death comes at 175 s at Gain 10 (380 s at Gain 1): the whole bleed, cough and drain
{
bool running = !s.Finished;
s.Step();
if (running) bledIn += OfficeBody.TickSeconds * gain * s.AirwayBleed;
if (s.Finished) settling++;
bledIn += OfficeBody.TickSeconds * gain * s.AirwayBleed;
double w = WorldLiquid(s);
double rest = w + s.AirwayLiquid + s.ExpelBacklog - s.AirwayOwed - (s.BloodEmitted - s.BloodExpelled) - c0;
double residual = rest - bledIn;
double bound = 1.8e-5 * w + 1e-9;
double bound = 1.76e-5 * w + 1e-9;
mutantRel = Math.Max(mutantRel, Over(rest - (1.0 - 5e-5) * bledIn, w));
worstRel = Math.Max(worstRel, Over(residual, w));
if (Math.Abs(residual) > worst) { worst = Math.Abs(residual); worstTick = s.TickIndex; }
Check(Math.Abs(residual) <= bound, $"gain {gain}, tick {s.TickIndex}: residual {residual * 1e6:F4} mL against a bound of {bound * 1e6:F4} mL (world {w * 1e6:F1} mL, airway {s.AirwayLiquid * 1e6:F1}, backlog {s.ExpelBacklog * 1e6:F1}, owed {s.AirwayOwed * 1e6:F2})");
}
Check(s.Finished, $"gain {gain}: the run did not finish");
if (gain > 1.0) Check(s.BloodExpelled > 1e-3, $"gain {gain}: only {s.BloodExpelled * 1e6:F0} mL was coughed and drained as drops");
Console.WriteLine($" throat at gain {gain}: coughed and drained {s.BloodExpelled * 1e6:F0} mL as drops, {s.ExpelBacklog * 1e6:F0} mL waiting, owed {s.AirwayOwed * 1e6:F3} mL, worst residual {worst * 1e6:F4} mL ({worstRel:E2} of the world) at tick {worstTick}; the bled-in term 5e-5 short: {mutantRel:E2}");
}
@ -1533,7 +1524,7 @@ public static class Program
using var s = new OfficeBodySession(p, 1);
Check(s.Wound(MouthHit(s), WoundTool.Knife), "the knife was refused at the mouth");
double half = 0.5 * new BloodParameters().DropVolume, lowest = 0.0, highest = 0.0, drawn = 0.0;
for (int t = 0; t < 100 * Hz && !s.Finished; t++)
for (int t = 0; t < 100 * Hz; t++)
{
s.Step();
lowest = Math.Min(lowest, s.AirwayOwed);
@ -1650,10 +1641,10 @@ public static class Program
try { _ = new WoundTool(depth, 60.0); } catch (ArgumentException) { threw = true; }
Check(threw, $"a depth of {depth} was accepted");
}
Check(WoundTool.Knife.Depth == 0.02 && WoundTool.Knife.Severity == 60.0, "the knife changed");
Check(WoundTool.Knife.Depth == 0.02 && WoundTool.Knife.Severity == 20.0, "the knife changed");
}),
("office blood is conserved to death and the death tick's blood is shed: one Knife (and three on one point), run to Finished, Emitted + Backlog == Gain x the real spill within 1e-9 m^3 (the dying step bleeds, though Bleed reads 0 once dead)", () =>
("office blood is conserved to death and the death tick's blood is shed: one Knife (and three on one point), run to 250 s, Emitted + Backlog == Gain x the real spill within 1e-9 m^3 (the dying step bleeds, though Bleed reads 0 once dead)", () =>
{
var p = new StressParameters { TickSeconds = OfficeBody.TickSeconds };
var blood = Lodur.PhysiologyPlans.Humanoid().Blood;
@ -1662,7 +1653,7 @@ public static class Program
using var s = new OfficeBodySession(p, 1);
var hit = Hit(s, SeatedPuppet.Plan.PartIndex("LowerArm", Lodur.Side.Left));
for (int i = 0; i < cuts; i++) Check(s.Wound(hit, WoundTool.Knife), "the knife was refused");
while (!s.Finished) s.Step();
while (s.TickIndex < 250 * Hz) s.Step();
Check(s.Dead, "the body lived");
double visible = new BloodParameters().Gain * blood.NominalVolume * s.BloodLoss * blood.LethalLossFraction;
double shed = s.BloodEmitted + s.BloodBacklog;
@ -1670,19 +1661,6 @@ public static class Program
}
}),
("office blood stops when the run does: a living body still bleeding at Finished sheds nothing in the next 300 steps (the physiology no longer steps, so its last rates would run forever)", () =>
{
var p = new StressParameters { TickSeconds = OfficeBody.TickSeconds };
using var s = new OfficeBodySession(p, 1);
Check(s.Wound(Hit(s, SeatedPuppet.Plan.PartIndex("LowerArm", Lodur.Side.Left)), new WoundTool(WoundTool.Knife.Depth, 3.0)), "the wound was refused");
double before = 0.0;
while (!s.Finished) { s.Step(); if (s.TickIndex == 100) before = s.BloodEmitted; }
Check(!s.Dead && s.BloodEmitted > before + 1e-3, "the wound was not bleeding at the end of the run");
double shed = s.BloodEmitted + s.BloodBacklog;
for (int t = 0; t < 300; t++) s.Step();
Check(s.BloodEmitted + s.BloodBacklog == shed, $"{(s.BloodEmitted + s.BloodBacklog - shed) * 1e6:F3} mL more blood after Finished");
}),
("office blood never throws or flies at repeated clicks: the same PartHit cut five or six times (lower arm, upper arm, thigh) and six coincident cuts on a shin run 20 s with every drop under 12 m/s, no refused Settle, and wet volume + live drops == Emitted within 1e-6 m^3", () =>
{
var p = new StressParameters { TickSeconds = OfficeBody.TickSeconds };
@ -1773,7 +1751,7 @@ public static class Program
// One bound for both, 0.42 L = sqrt(0.094 x 1.86), the geometric mean of the shipped worst (0.094 L) and the least degraded claimed reading (3 spots at 1 cm, 1.86 L); 2 spots gave 4.24 L, no spread 14.84 and 7.36 L.
double bound = 0.42e-3, worst = 0.0, atDeath = -1.0;
int deadAt = -1;
for (int t = 0; !s.Finished; t++)
for (int t = 0; t < Sandbox; t++)
{
s.Step();
worst = Math.Max(worst, s.BloodBacklog);
@ -1943,6 +1921,20 @@ public static class Program
/// A hit on <paramref name="part"/> at <paramref name="local"/> (the part's frame) as it now stands: a ray from 0.5 m outside that point, in along the
/// outward direction (or along +z from behind when <paramref name="alongZ"/>), on through it; the ray must meet the part first.
/// </summary>
/// <summary>A hit on a part at a point of its frame, with no ray: the world point and the outward normal. For a side the camera does not see (the side of the neck, the inner thigh).</summary>
private static PartHit HitAtPoint(OfficeBodySession s, int part, (float X, float Y, float Z) local)
{
var v = s.View;
ulong id = SeatedPuppet.FirstStableId + (ulong)part;
int lane = -1;
for (int i = 0; i < v.StableId.Length; i++) if (v.StableId[i] == id) { lane = i; break; }
Check(lane >= 0, $"part {part} has no lane");
var q = new Quat(v.RotationX[lane], v.RotationY[lane], v.RotationZ[lane], v.RotationW[lane]);
q.Rotate(local.X, local.Y, local.Z, out var ox, out var oy, out var oz);
float len = MathF.Sqrt(ox * ox + oy * oy + oz * oz);
return new PartHit(part, new BodyPoint(v.PositionX[lane] + ox, v.PositionY[lane] + oy, v.PositionZ[lane] + oz), new BodyPoint(ox / len, oy / len, oz / len));
}
private static PartHit HitAt(OfficeBodySession s, int part, (float X, float Y, float Z) local, bool alongZ = false)
{
var v = s.View;
@ -1989,12 +1981,25 @@ public static class Program
return ray!.Value;
}
/// <summary>The office has no end (ruling bds-office-is-a-sandbox-preset): the tests' horizon, seconds, where a run is read.</summary>
private const double OfficeSeconds = 180.0;
private const int Sandbox = (int)(OfficeSeconds * Hz);
/// <summary>The body run to the horizon, cut where the old run ended: the calm switch and the 8 s the seated body needs to settle after it (the prefix of a longer run is the shorter run).</summary>
private static OfficeBodyResult BodyArc(StressParameters p, ulong seed)
{
var a = OfficeBody.Run(p, seed, OfficeSeconds);
int calm = (int)Math.Round(a.Run.Timeline.Single(e => e.Kind == StressEntryKind.GoalChanged && e.Goal == OfficeGoal.Calm).TimeMs * Hz / 1000.0);
int n = calm + 8 * Hz + 1;
return new OfficeBodyResult(a.Run, a.HandL.Take(n).ToList(), a.HandR.Take(n).ToList(), a.Pelvis.Take(n).ToList());
}
private static StressSession NewOffice(StressParameters p, ulong seed) => new(p, seed, 1, OfficePoses.Identity);
private static void Step(StressSession s) => s.Tick(Point, Point, Point, Strengths, Targets);
private static StressResult Office(StressParameters p, ulong seed, params SilenceCommand[] silences) =>
StressSimulation.Run(p, seed, silences);
StressSimulation.Run(p, seed, OfficeSeconds, silences);
/// <summary>The median break time over <paramref name="count"/> seeds; a run that endured counts as never.</summary>
private static long MedianBreak(StressParameters p, ulong first, int count, params SilenceCommand[] silences)