feat(engine): add faction power system with event triggers

- Add FactionData model with power and members fields
- Add FactionEventResult model for faction event responses
- Add faction field to AgentState
- Implement faction classification based on emotion
- Add faction event triggers (festival/panic) when power >= 5
- Update StepResponse to include triggered_faction_event
- Add tests for new faction system

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
empty
2025-12-30 12:01:07 +08:00
parent 012956f817
commit 1fd318c9e3
6 changed files with 181 additions and 27 deletions

View File

@@ -1,6 +1,6 @@
import json
from pathlib import Path
from .models import WorldState, AgentState, GlobalMeter, Stance
from .models import WorldState, AgentState, GlobalMeter, Stance, Factions, FactionData
STATE_FILE = Path(__file__).parent.parent / "state.json"
@@ -17,16 +17,22 @@ def get_default_state() -> WorldState:
goal="探索小镇",
memory=[],
stance=Stance(optimism=0.6, fear=0.4),
faction="neutral",
),
"bob": AgentState(
emotion="calm",
goal="与人交流",
memory=[],
stance=Stance(optimism=0.4, fear=0.6),
faction="neutral",
),
},
events=[],
global_meter=GlobalMeter(value=0, threshold=100, cooldown=0),
factions=Factions(
optimists=FactionData(power=0, members=[]),
fearful=FactionData(power=0, members=[])
),
)