This commit is contained in:
Nikolaj
2026-03-26 08:16:54 +01:00
parent ef4496aa5d
commit ec7dea2d72
5 changed files with 18 additions and 46 deletions

View File

@@ -21,8 +21,6 @@ SIMULATION_CARDS_PATH = os.path.join(os.path.dirname(__file__), "simulation_card
SIMULATION_CARD_COUNT = 1000
# ==================== Card pool ====================
def _card_to_dict(card: Card) -> dict:
return {
"name": card.name,
@@ -69,8 +67,6 @@ def get_simulation_cards() -> list[Card]:
return cards
# ==================== Single game ====================
PLAYER1_ID = "p1"
PLAYER2_ID = "p2"
MAX_TURNS = 300 # safety cap to prevent infinite games
@@ -176,7 +172,6 @@ def simulate_game(
return None
# ==================== Process-pool worker ====================
# These must be module-level so they are picklable.
_worker_cards: list[Card] = []
@@ -186,7 +181,6 @@ def _init_worker(cards: list[Card]) -> None:
_worker_cards = cards
def _run_game_sync(args: tuple) -> str | None:
"""Synchronous entry point for a worker process."""
d1, p1_name, d2, p2_name = args
return simulate_game(
_worker_cards,
@@ -195,8 +189,6 @@ def _run_game_sync(args: tuple) -> str | None:
)
# ==================== Tournament ====================
def _all_players(difficulties: list[int] | None = None) -> list[tuple[AIPersonality, int]]:
"""Return all (personality, difficulty) combinations for the given difficulties (default 1-10)."""
if difficulties is None:
@@ -232,7 +224,6 @@ async def run_tournament(
players = _all_players(difficulties)
n = len(players)
# Build the flat list of (i, j, args) for every game
indexed_args: list[tuple[int, int, tuple]] = []
for i in range(n):
p1_personality, p1_difficulty = players[i]