-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_game.py
More file actions
80 lines (67 loc) · 2.15 KB
/
Copy pathrun_game.py
File metadata and controls
80 lines (67 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import argparse
import asyncio
import os
from pathlib import Path
import dotenv
dotenv.load_dotenv()
from islandsim.settings import load_settings
_settings = load_settings()
if _settings.langfuse and os.environ.get("LANGFUSE_SECRET_KEY"):
from pydantic_ai import Agent
Agent.instrument_all()
print("Langfuse tracing enabled")
else:
if not _settings.langfuse:
print("Langfuse tracing disabled (langfuse: false in config.yaml)")
else:
print("Langfuse tracing disabled (no LANGFUSE_SECRET_KEY found)")
from islandsim.game import run_game
from islandsim.models import NationName
def main():
parser = argparse.ArgumentParser(description="Run an IslandSim tabletop exercise")
parser.add_argument(
"turns",
nargs="?",
type=int,
default=None,
help="Number of turns to run (default: from config.yaml, or 4)",
)
parser.add_argument(
"--scenario",
default="reef_maru",
help="Scenario name — loads scenarios/<name>.yaml (default: reef_maru)",
)
parser.add_argument(
"--play",
type=str,
default=None,
choices=["naru", "veldara", "tauma"],
metavar="NATION",
help="Play as the specified nation in the TUI (other two remain AI-driven)",
)
parser.add_argument(
"--seed",
type=int,
default=None,
help="Random seed for reproducible skill-roll outcomes",
)
args = parser.parse_args()
human_nation = NationName(args.play) if args.play else None
summary, game_log = asyncio.run(
run_game(
scenario_name=args.scenario,
num_turns=args.turns,
human_nation=human_nation,
seed=args.seed,
)
)
print("\n" + summary.model_dump_json(indent=2))
# Save structured game log
logs_dir = Path("logs")
logs_dir.mkdir(exist_ok=True)
safe_ts = game_log.timestamp.replace(":", "").replace("-", "").split(".")[0]
log_path = logs_dir / f"islandsim_{safe_ts}.json"
log_path.write_text(game_log.model_dump_json(indent=2))
print(f"\nGame log saved to {log_path}")
if __name__ == "__main__":
main()