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:
@@ -295,3 +295,27 @@ def test_social_influence_deterministic(client):
|
||||
for aid in stances1:
|
||||
assert stances1[aid]["optimism"] == stances2[aid]["optimism"]
|
||||
assert stances1[aid]["fear"] == stances2[aid]["fear"]
|
||||
|
||||
|
||||
def test_factions_exists_in_world_state(client):
|
||||
"""测试 world_state 包含 factions 字段"""
|
||||
resp = client.post("/step", json={"events": []})
|
||||
data = resp.json()
|
||||
|
||||
assert "factions" in data["world_state"]
|
||||
factions = data["world_state"]["factions"]
|
||||
assert "optimists" in factions
|
||||
assert "fearful" in factions
|
||||
assert "neutral" in factions
|
||||
|
||||
|
||||
def test_factions_count_matches_agents(client):
|
||||
"""测试派系总数等于 agent 数量"""
|
||||
resp = client.post("/step", json={"events": []})
|
||||
data = resp.json()
|
||||
|
||||
factions = data["world_state"]["factions"]
|
||||
total = factions["optimists"] + factions["fearful"] + factions["neutral"]
|
||||
agent_count = len(data["world_state"]["agents"])
|
||||
|
||||
assert total == agent_count
|
||||
|
||||
Reference in New Issue
Block a user