84 lines
2.8 KiB
Python
84 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Debug script for diplomacy relations."""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
|
|
from backend.core.engine import GameEngine
|
|
from backend.domain.diplomacy import FactionType, get_faction_relations, DiplomaticStatus
|
|
|
|
def main():
|
|
print("Debugging diplomacy relations...\n")
|
|
|
|
engine = GameEngine()
|
|
engine.initialize(50)
|
|
|
|
faction_relations = get_faction_relations()
|
|
|
|
print("Initial Relations:")
|
|
factions = [f for f in FactionType if f != FactionType.NEUTRAL]
|
|
for f1 in factions:
|
|
for f2 in factions:
|
|
if f1 != f2:
|
|
rel = faction_relations.get_relation(f1, f2)
|
|
status = faction_relations.get_status(f1, f2)
|
|
print(f" {f1.value:12s} -> {f2.value:12s}: {rel:3d} ({status.value})")
|
|
|
|
# Run 50 turns and check relations
|
|
print("\n\nRunning 50 turns...")
|
|
for step in range(50):
|
|
engine.next_step()
|
|
|
|
print("\nAfter 50 turns:")
|
|
hostile_pairs = []
|
|
for f1 in factions:
|
|
for f2 in factions:
|
|
if f1.value < f2.value: # Avoid duplicates
|
|
rel = faction_relations.get_relation(f1, f2)
|
|
status = faction_relations.get_status(f1, f2)
|
|
marker = "⚔️" if status == DiplomaticStatus.HOSTILE else ""
|
|
print(f" {f1.value:12s} <-> {f2.value:12s}: {rel:3d} ({status.value:8s}) {marker}")
|
|
if status == DiplomaticStatus.HOSTILE:
|
|
hostile_pairs.append((f1, f2, rel))
|
|
|
|
print(f"\nHostile pairs: {len(hostile_pairs)}")
|
|
for f1, f2, rel in hostile_pairs:
|
|
print(f" {f1.value} vs {f2.value}: {rel}")
|
|
|
|
# Run 50 more turns
|
|
print("\n\nRunning 50 more turns...")
|
|
for step in range(50):
|
|
engine.next_step()
|
|
|
|
print("\nAfter 100 turns:")
|
|
hostile_pairs = []
|
|
war_pairs = []
|
|
for f1 in factions:
|
|
for f2 in factions:
|
|
if f1.value < f2.value:
|
|
rel = faction_relations.get_relation(f1, f2)
|
|
status = faction_relations.get_status(f1, f2)
|
|
if status == DiplomaticStatus.HOSTILE:
|
|
hostile_pairs.append((f1, f2, rel))
|
|
elif status == DiplomaticStatus.WAR:
|
|
war_pairs.append((f1, f2, rel))
|
|
print(f" {f1.value:12s} <-> {f2.value:12s}: {rel:3d} ({status.value:8s})")
|
|
|
|
print(f"\nHostile pairs: {len(hostile_pairs)}")
|
|
print(f"War pairs: {len(war_pairs)}")
|
|
|
|
if war_pairs:
|
|
print("\n🔥 WARS ACTIVE:")
|
|
for f1, f2, rel in war_pairs:
|
|
print(f" {f1.value} vs {f2.value}")
|
|
|
|
stats = engine.world.get_statistics()
|
|
print(f"\nTotal wars declared: {stats.get('total_wars', 0)}")
|
|
print(f"Active wars: {faction_relations.active_wars}")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|