This example uses Joiner's Interpersonal Theory of Suicide (ITS) to compute risk factors from state. The system tracks three dimensions: Thwarted Belongingness (TB), Perceived Burdensomeness (PB), and Acquired Capability (AC). Convergence across all three signals a high-risk pattern.
The Scenario
We model a character whose social world deteriorates over time. They experience social isolation, shaming, and exposure to pain. We then query their state and compute risk convergence.
Step 1: Create the Entity
use behavioral_pathways::entity::EntityBuilder;
use behavioral_pathways::enums::{EventType, Species};
use behavioral_pathways::event::EventBuilder;
use behavioral_pathways::simulation::Simulation;
use behavioral_pathways::types::Timestamp;
let person = EntityBuilder::new("casey", Species::Human)
.with_age(34)
.build();
let mut sim = Simulation::new();
let anchor = Timestamp::from_ymd_hms(2024, 1, 1, 0, 0, 0);
sim.add_entity(person, anchor);
Step 2: Apply ITS-Relevant Events
// Thwarted Belongingness (TB)
let isolation = EventBuilder::new(EventType::SocialIsolation)
.target("casey")
.severity(0.7)
.build()?;
// Perceived Burdensomeness (PB)
let shaming = EventBuilder::new(EventType::ShamingEvent)
.target("casey")
.severity(0.6)
.build()?;
// Acquired Capability (AC)
let exposure = EventBuilder::new(EventType::ViolenceExposure)
.target("casey")
.severity(0.5)
.build()?;
let t1 = Timestamp::from_ymd_hms(2024, 2, 10, 0, 0, 0);
let t2 = Timestamp::from_ymd_hms(2024, 3, 5, 0, 0, 0);
let t3 = Timestamp::from_ymd_hms(2024, 3, 20, 0, 0, 0);
sim.add_event(isolation, t1);
sim.add_event(shaming, t2);
sim.add_event(exposure, t3);
Step 3: Compute Risk Convergence
use behavioral_pathways::processor::compute_its_factors;
use behavioral_pathways::enums::ItsAlert;
let handle = sim.query_entity("casey");
let state = handle.state_at(Timestamp::from_ymd_hms(2024, 4, 1, 0, 0, 0));
let factors = compute_its_factors(&state);
if let Some(alert) = ItsAlert::from_convergence(&factors.convergence_status) {
println!("Risk: {}", alert.risk_level());
println!("Focus: {}", alert.intervention_focus());
}
Interpretation
- TB models disconnection and social isolation.
- PB models perceived burden and shame.
- AC models habituation to pain/fear.
When all three dimensions converge, the system emits the highest risk alert. You can then map that to in-game behaviors, narrative interventions, or content flags.