AI draws from its own dice: the range-sample offset and the patrol circuit leave ItemManager.Random

Combat.SampleDps and Zone.CreateAgent's patrol circuit drew from the item stream, so minting items moved
how a pilot fights and where it patrols. Both now draw SimulationDice.For(CombatSeed, stream, Agent.Id);
Agent.Id is the zone-scoped ordinal Zone.NextAgentId gives a pilot at admission (ruling
ai-sample-offset-off-item-stream).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-17 20:46:37 +02:00
commit 72d7e25df0
5 changed files with 40 additions and 3 deletions

View file

@ -23,6 +23,9 @@ public class Agent
private VelocityLimit _velocityLimit;
public AgentTask Task { get; set; }
// Zone-scoped, from 1: the ordinal of this pilot's own dice, set by Zone.CreateAgent as it admits the pilot (0 for
// an agent built outside a zone's admission).
public uint Id { get; init; }
public Ship Ship { get; }
public ItemManager ItemManager { get; }
public GameplaySettings Settings { get; }

View file

@ -173,7 +173,10 @@ public class CombatState : BaseState
maxRange = weapon.Range;
}
var offset = _agent.ItemManager.Random.NextFloat((maxRange - minRange) / DPS_SAMPLE_COUNT);
// The pilot's own dice, a pure function of the zone seed and its id: the same offset at every resample, and
// nothing that mints an item can move it.
var offset = SimulationDice.For(_agent.Ship.Zone.CombatSeed, SimulationDice.CombatSampleStream, _agent.Id)
.NextFloat((maxRange - minRange) / DPS_SAMPLE_COUNT);
var optimumDPS = 0f;
for (int i = 0; i < DPS_SAMPLE_COUNT; i++)
{