feat(engine): add faction system for social emergence
- Add Factions model (optimists/fearful/neutral) - Implement classify_faction() based on stance thresholds - Add update_factions() to track faction distribution - Add apply_faction_influence() for faction→mood feedback - Integrate faction system into tick flow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ from .models import (
|
||||
from .global_events import GLOBAL_EVENT_POOL, GlobalEvent
|
||||
from .opinions import generate_opinions
|
||||
from .social_influence import apply_social_influence
|
||||
from .factions import update_factions, apply_faction_influence
|
||||
|
||||
MAX_EVENTS = 20
|
||||
MAX_MEMORY_PER_AGENT = 3
|
||||
@@ -90,6 +91,12 @@ def process_events(state: WorldState, events: List[Event]) -> WorldState:
|
||||
# 应用社交影响
|
||||
apply_social_influence(state)
|
||||
|
||||
# 更新派系分布
|
||||
update_factions(state)
|
||||
|
||||
# 派系影响世界情绪
|
||||
apply_faction_influence(state)
|
||||
|
||||
return state
|
||||
|
||||
|
||||
@@ -126,6 +133,12 @@ def check_and_trigger_global_event(
|
||||
# 应用社交影响
|
||||
apply_social_influence(state)
|
||||
|
||||
# 更新派系分布
|
||||
update_factions(state)
|
||||
|
||||
# 派系影响世界情绪
|
||||
apply_faction_influence(state)
|
||||
|
||||
result = GlobalEventResult(
|
||||
triggered=True,
|
||||
event=global_event.to_info()
|
||||
|
||||
Reference in New Issue
Block a user