diff --git a/src/Lodur.Core/Actor.cs b/src/Lodur.Core/Actor.cs index fd3b312..dab7755 100644 --- a/src/Lodur.Core/Actor.cs +++ b/src/Lodur.Core/Actor.cs @@ -50,6 +50,11 @@ namespace Lodur _driveP = drive; _brain = brain; _goal = brain.Start; + // The Start goal takes over at construction: its entry effect applies like any other goal's. + if (brain.Goals[brain.Start].EntryResolve is double startEntry) + { + _drive.Enter(drive, startEntry); + } _latency = Math.Max(1, (long)Math.Round(brain.DeliberateLatencySeconds / tickSeconds)); _dwell = new long[brain.Goals.Count]; _onset = new long[brain.Goals.Count]; diff --git a/src/Lodur.Core/Brain.cs b/src/Lodur.Core/Brain.cs index 54c0f16..33d3440 100644 --- a/src/Lodur.Core/Brain.cs +++ b/src/Lodur.Core/Brain.cs @@ -62,7 +62,7 @@ namespace Lodur public double MinDwellSeconds { get; init; } /// - /// The resolve the character has the tick this goal takes over, in [0, 1]; null leaves resolve as it is. Rage is what + /// The resolve the character has the tick this goal takes over (for the Start goal, at construction), in [0, 1]; null leaves resolve as it is. Rage is what /// the will breaking leads to, and it resets the will (lodur:ruling:rage-involuntary-onset-then-voluntary). /// public double? EntryResolve { get; init; } diff --git a/tests/Lodur.Core.Tests/WillTests.cs b/tests/Lodur.Core.Tests/WillTests.cs index c5bd39e..0351846 100644 --- a/tests/Lodur.Core.Tests/WillTests.cs +++ b/tests/Lodur.Core.Tests/WillTests.cs @@ -386,4 +386,15 @@ public sealed class WillTests Assert.Equal(ticks, firstDrain); Assert.Equal(ticks, firstWeighted); } + + [Fact] + public void A_puppet_that_starts_in_a_goal_with_an_entry_resolve_begins_at_it() + { + var brain = new Brain { Start = 1, Goals = new[] { new GoalSpec { Id = "calm", Behaviour = Pose }, new GoalSpec { Id = "rage", EntryResolve = 0.6, Behaviour = Pose } } }; + var actor = new Actor(0.01, 1, new NerveParameters(), new WithdrawalParameters(), new DriveParameters(), brain); + Assert.Equal(0.6, actor.Drive.Resolve); + + var calm = new Actor(0.01, 1, new NerveParameters(), new WithdrawalParameters(), new DriveParameters(), brain with { Start = 0 }); + Assert.Equal(1.0, calm.Drive.Resolve); + } }