Created: 2025-12-11 Purpose: Systematic investigation of empathy's effects on multi-agent coordination
-
H1 - Empathy Improves Coordination: Cooperation (both agents reach goals) increases with empathy parameter alpha, especially in layouts allowing spatial separation.
-
H2 - Asymmetry Effects: In (alpha_i, alpha_j) space, there exist regions where:
- The altruist is exploited (one-sided sacrifice)
- Coordination works despite asymmetry
- System gets stuck in "paralysis" (mutual deference / oscillations)
-
H3 - Complexity Interaction: More constrained layouts require higher empathy levels to achieve coordination, showing sharper phase transitions.
-
H4 - Phase Diagrams: We can identify distinct behavioral regimes (collision, cooperation, paralysis) as functions of empathy parameters.
| Tag | Description | Conflict Type |
|---|---|---|
narrow |
Single-file corridor, 1 cell wide | Forced collision |
wide |
2+ rows, agents can pass | Optional coordination |
bottleneck |
Wide areas connected by 1-cell choke | Sequential coordination |
crossed_goals |
Agents must cross paths | Timing coordination |
risk_reward |
Short risky vs long safe path | Risk/empathy tradeoff |
double_bottleneck |
Two bottlenecks with passing bay between | Multi-stage coordination |
passing_bay |
Mostly 1-cell with one 2x2 bay | Pull-aside coordination |
asymmetric_detour |
One agent has shorter path to bottleneck | Fairness vs efficiency |
Symmetric sweeps:
alphas_symmetric = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
# alpha_i = alpha_j = alphaAsymmetric grid:
alphas_asymmetric = [0.0, 0.25, 0.5, 0.75, 1.0]
# All combinations of (alpha_i, alpha_j)For each layout, define two start configurations:
- Config A: Agent 0 on "advantaged" side (shorter path, first to bottleneck)
- Config B: Swapped positions
This tests whether empathic behavior depends on spatial advantage.
- Minimum 30 seeds per configuration for statistical power
- Recommended: 50 seeds for publication-quality results
| Metric | Description |
|---|---|
both_success |
Both agents reach goals without collision/lava |
single_success |
Exactly one agent reaches goal |
failure |
Neither agent reaches goal |
goal_reached_i/j |
Individual goal achievement |
| Metric | Description |
|---|---|
lava_collision |
Any agent hits lava |
cell_collision |
Both occupy same cell |
edge_collision |
Agents swap positions (cross paths) |
collision_timestep |
When first collision occurred |
Definition: Episode ends at T_max without success and without fatal collision.
Detection criteria (any of):
- Episode reaches T_max with
both_success == Falseand no lava/collision - State repetition: same (pos_i, pos_j) seen > K times (K=3)
- Oscillation: alternating between 2-3 states without goal progress
- Mutual stay: both agents choose STAY action for > M consecutive steps (M=3)
| Metric | Description |
|---|---|
paralysis |
Boolean flag for paralysis detection |
paralysis_type |
"timeout" / "cycle" / "oscillation" / "mutual_stay" |
cycle_length |
Length of detected cycle if applicable |
| Metric | Description |
|---|---|
steps_to_goal_i/j |
Timesteps for each agent to reach goal (or max) |
arrival_order |
Which agent arrived first (0, 1, or "tie") |
arrival_gap |
steps_to_goal_j - steps_to_goal_i (signed) |
efficiency |
(optimal_steps) / (actual_steps) |
| Metric | Description |
|---|---|
sacrifice_i |
Extra steps agent i took compared to selfish baseline |
sacrifice_j |
Extra steps agent j took compared to selfish baseline |
exploitation |
both_success AND high arrival_gap AND altruist arrives later |
| Metric | Description |
|---|---|
G_i_cumulative |
Total EFE for agent i over episode |
G_j_cumulative |
Total EFE for agent j over episode |
G_social_cumulative |
Total social EFE over episode |
File: results/empathy_sweeps_{timestamp}.csv
Columns:
layout, start_config, alpha_i, alpha_j, seed,
both_success, single_success, failure,
goal_reached_i, goal_reached_j,
lava_collision, cell_collision, edge_collision,
paralysis, paralysis_type,
steps_i, steps_j, timesteps,
arrival_order, arrival_gap,
sacrifice_i, sacrifice_j,
trajectory_i, trajectory_j,
G_i, G_j
Per (layout, start_config, alpha_i, alpha_j):
- P(both_success): Mean of
both_success - P(collision): Mean of any collision
- P(paralysis): Mean of
paralysis - Mean efficiency
- Mean arrival_gap
For each layout:
- X-axis: alpha (symmetric: alpha_i = alpha_j)
- Y-axis: P(both_success)
- Optional overlays: P(paralysis), P(collision)
Shows whether empathy smoothly improves coordination or shows phase transition.
For each layout and start_config:
- X-axis: alpha_i
- Y-axis: alpha_j
- Color: P(both_success) or P(paralysis) or P(exploitation)
Reveals:
- Cooperation region
- Exploitation region (one agent takes advantage)
- Paralysis region (too deferential)
- X-axis: Layout complexity index (num bottlenecks, constraint level)
- Y-axis: Critical alpha* where P(both_success) > 0.8 (symmetric case)
Shows how much empathy is needed as environment gets harder.
For constrained layouts:
- X-axis: alpha (symmetric)
- Y1: P(both_success)
- Y2: P(paralysis)
Watch for "too much empathy" regime.
For asymmetric layouts:
- Compare Config A vs Config B at same (alpha_i, alpha_j)
- Shows whether spatial advantage affects empathy dynamics
- Document roadmap (this file)
- Add new layouts:
double_bottleneck,passing_bay,asymmetric_detour,t_junction - Add
start_configsupport to layouts (A/B variants viaswap_agents()) - Add paralysis detection function (
src/metrics/paralysis_detection.py) - Add layout complexity indices
- Create
scripts/run_empathy_sweep.pyfor full sweep - Add all new metrics collection (paralysis, efficiency, fairness)
- Add progress logging with tqdm (falls back gracefully)
- Add verbose debug output showing empathy effects
- Verify JAX acceleration (
use_jax=Truedefault in planner) - CSV output with all metrics
- Create
analysis/plot_empathy_sweeps.py - Implement 1D cooperation curves
- Implement 2D heatmaps (success, paralysis, collision)
- Implement layout complexity plot
- Implement paralysis phase diagrams
- Implement exploitation analysis
- Implement role effect comparisons (Config A vs B)
- Run full experiment suite
- Generate all plots
- Document findings
| Component | File |
|---|---|
| Layout definitions | tom/envs/env_lava_variants.py |
| Environment | tom/envs/env_lava_v2.py |
| Empathic planner | tom/planning/si_empathy_lava.py |
| JAX planner | tom/planning/jax_si_empathy_lava.py |
| Paralysis detection | src/metrics/paralysis_detection.py |
| Experiment runner (sweep) | scripts/run_empathy_sweep.py |
| Experiment runner (original) | scripts/run_empathy_experiments.py |
| Analysis plots | analysis/plot_empathy_sweeps.py |
| Tests for new layouts | tests/test_new_layouts.py |
| Results output | results/empathy_sweep_*.csv |
# Planning
HORIZON = 3
GAMMA = 16.0 # Inverse temperature
MAX_TIMESTEPS = 25
# Sweep parameters
LAYOUTS = [
"narrow", "wide", "bottleneck", "crossed_goals",
"risk_reward", "double_bottleneck", "passing_bay", "asymmetric_detour"
]
ALPHAS_SYMMETRIC = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
ALPHAS_ASYMMETRIC = [0.0, 0.25, 0.5, 0.75, 1.0]
START_CONFIGS = ["A", "B"]
NUM_SEEDS = 50
# Paralysis detection
PARALYSIS_CYCLE_THRESHOLD = 3 # Same state seen K times
PARALYSIS_STAY_THRESHOLD = 3 # Both stay for M steps- Per episode: ~0.1-0.5s (with JAX)
- Total configurations: 8 layouts × 2 configs × 5 × 5 alphas × 50 seeds = 20,000 episodes
- Estimated total: ~30-60 minutes with JAX
If Claude crashes mid-session, resume by:
- Check
results/for any partial output files - Review this ROADMAP.md for current phase
- Check git status for uncommitted changes
- Continue from the appropriate phase
Key files to check:
tom/envs/env_lava_variants.py- for new layout definitionsscripts/run_empathy_experiments.py- for experiment runner updatesanalysis/plot_empathy_sweeps.py- for plotting code
The experiment suite is complete when:
- All 8 layouts implemented and tested
- Full parameter sweep executed (20,000+ episodes)
- CSV results saved with all metrics
- All 5 visualization types generated
- Clear phase diagrams showing cooperation/paralysis regions
- Documented findings on empathy-coordination relationship