Pin the Actor's oxygen wiring: arousal and post-ceiling effort reach Physiology (lockstep twin); PhysiologyInput doc says applied, not asked

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-25 23:33:48 +01:00
commit ce5a0997ab
2 changed files with 37 additions and 1 deletions

View file

@ -6,7 +6,7 @@ namespace Lodur
/// <summary>Why a body died; the first rule that held at the end of the step that killed it (ruling bds-death).</summary>
public enum DeathCause { None, VitalTissue, BloodLoss, Consciousness }
/// <summary>What the stepping Actor reports each step, each in [0, 1]: Arousal is the sensory load carried over time, Effort the mean strength it asked of the muscles. The default is rest.</summary>
/// <summary>What the stepping Actor reports each step, each in [0, 1]: Arousal is the sensory load carried over time, Effort the mean strength the muscles actually applied last tick, after each joint's motor ceiling (the Actor reports it so, not what the behaviour asked). The default is rest.</summary>
public readonly record struct PhysiologyInput(double Arousal, double Effort);
/// <summary>

View file

@ -150,6 +150,42 @@ public sealed class ActorPhysiologyTests
Assert.True(strong < idle, $"strong {strong}, idle {idle}");
}
[Fact]
public void The_actor_steps_its_physiology_on_the_drives_arousal_and_the_strength_it_applied_after_the_ceiling()
{
Physiology Body()
{
var q = Make3();
Assert.True(q.Afflict(Af("Choke"), 0, 0, 1e9)); // the stores move every tick
Assert.True(q.Afflict(Af("MotorHalf"), 1, 0, 1)); // joint 0 at half: the ceiling makes the applied strength differ from the asked one
return q;
}
var p = Body();
var twin = Body();
var a = new Actor(0.01, 1, new NerveParameters(), new WithdrawalParameters(), new DriveParameters(), HoldBrain(),
new NerveParameters { Threshold = 0.05, SensitisationGrowth = 0.0 }, 0, physiology: p);
var loud = SensoryRig.One(0.55);
var s = new float[2];
var q = new Quat[2];
double arousalBefore = 0.0, effortBefore = 0.0, peakArousal = 0.0;
var peakEffort = 0.0;
for (var i = 0; i < 1500; i++)
{
twin.Step(0.01, new PhysiologyInput(arousalBefore, effortBefore));
a.Tick(NoPoint, NoPoint, NoPoint, ReadOnlySpan<BoxStimulus>.Empty, s, q, loud);
Assert.Equal(twin.BloodOxygen, p.BloodOxygen);
Assert.Equal(twin.BrainOxygen, p.BrainOxygen);
arousalBefore = a.Drive.Arousal;
effortBefore = ((double)s[0] + s[1]) / 2.0;
peakArousal = Math.Max(peakArousal, arousalBefore);
peakEffort = Math.Max(peakEffort, effortBefore);
}
Assert.True(peakArousal > 0.1, $"arousal never rose: {peakArousal}");
Assert.True(peakEffort > 0.1, $"no strength was applied: {peakEffort}");
}
[Fact]
public void A_healthy_physiology_changes_nothing_bit_for_bit()
{