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

@@ -20,8 +20,6 @@ P2 = "p2"
FIXED_PERSONALITIES = [p for p in AIPersonality if p != AIPersonality.ARBITRARY]
# ==================== Game runner ====================
def _build_player(pid: str, name: str, cards: list, difficulty: int, personality: AIPersonality) -> PlayerState:
deck = choose_cards(cards, difficulty, personality)
instances = _make_instances(deck)
@@ -82,8 +80,6 @@ def run_episode(
return state.result.winner_id if state.result else None
# ==================== Training loop ====================
def train(
n_episodes: int = 20_000,
self_play_start: int = 5_000,
@@ -124,7 +120,6 @@ def train(
nn_goes_first = random.random() < 0.5
if random.random() < self_play_prob:
# ---- Self-play ----
nn1 = NeuralPlayer(net, training=True, temperature=temperature)
nn2 = NeuralPlayer(net, training=True, temperature=temperature)
@@ -148,7 +143,6 @@ def train(
batch_count += 1
else:
# ---- NN vs fixed opponent ----
opp_personality = random.choice(FIXED_PERSONALITIES)
nn_player = NeuralPlayer(net, training=True, temperature=temperature)
opp_ctrl = lambda p, o, pers=opp_personality, diff=opp_difficulty: choose_plan(p, o, pers, diff)