Behavioral Pathways only processes events that occur after an entity's anchor for forward queries. Events before the anchor are ignored unless you query backward in time. This example shows the behavior and two ways to handle it.
Scenario
We model a person with a childhood trauma that occurred before they enter the simulation. We show how that event is excluded by default and how to include its effects.
Step 1: Anchor After the Event (Event Ignored)
// Anchor at age 20
sim.add_entity(john, Timestamp::from_ymd_hms(2010, 1, 1, 0, 0, 0));
// Trauma at age 5 (before anchor)
sim.add_event(trauma, Timestamp::from_ymd_hms(1995, 3, 15, 0, 0, 0));
// Query forward from anchor
let state = handle.state_at(Timestamp::from_ymd_hms(2010, 1, 1, 0, 0, 0));
// Trauma NOT included
Solution A: Anchor Earlier
// Anchor before trauma
sim.add_entity(john, Timestamp::from_ymd_hms(1995, 1, 1, 0, 0, 0));
// Trauma now occurs after anchor
sim.add_event(trauma, Timestamp::from_ymd_hms(1995, 3, 15, 0, 0, 0));
// Query later in life
let state = handle.state_at(Timestamp::from_ymd_hms(2010, 1, 1, 0, 0, 0));
// Trauma included
Solution B: Set Initial State
let john = EntityBuilder::new()
.id("john")
.species(Species::Human)
.mood(Mood::new().with_valence_base(-0.2))
.social_cognition(SocialCognition::new().with_loneliness_base(0.4))
.build()?;
sim.add_entity(john, Timestamp::from_ymd_hms(2010, 1, 1, 0, 0, 0));
// Trauma effects baked into baseline
Key Rule
Events before the anchor only affect results if you query a time before the anchor. For forward queries, only events after anchor matter.