mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-13 18:02:06 +00:00
feat(training): add opt-in teamplay evaluation
This commit is contained in:
@@ -33,6 +33,7 @@ def run_half(
|
||||
seed: int,
|
||||
grounded_a: bool = False,
|
||||
grounded_b: bool = False,
|
||||
team_size: int = 1,
|
||||
) -> dict:
|
||||
cmd = [
|
||||
godot_bin,
|
||||
@@ -47,6 +48,10 @@ def run_half(
|
||||
f"--speedup={speedup}",
|
||||
f"--env_seed={seed}",
|
||||
]
|
||||
if team_size not in (1, 2):
|
||||
raise ValueError("team_size must be 1 or 2")
|
||||
if team_size == 2:
|
||||
cmd.append("--eval_team_size=2")
|
||||
# Must match how each model was actually trained (see AIShipController's
|
||||
# allow_vertical/allow_pitch_roll) — a grounded pre-generation-4 model
|
||||
# never got a reward gradient on these axes, so leaving them unmasked here
|
||||
@@ -72,6 +77,7 @@ def evaluate_pair(
|
||||
seed: int,
|
||||
grounded_a: bool = False,
|
||||
grounded_b: bool = False,
|
||||
team_size: int = 1,
|
||||
) -> dict:
|
||||
"""Replay one seeded state sequence with the models on opposite sides."""
|
||||
if episodes < 2 or episodes % 2 != 0:
|
||||
@@ -81,10 +87,12 @@ def evaluate_pair(
|
||||
first = run_half(
|
||||
godot_bin, model_a, model_b, episodes_per_side, speedup, seed,
|
||||
grounded_a=grounded_a, grounded_b=grounded_b,
|
||||
team_size=team_size,
|
||||
)
|
||||
second = run_half(
|
||||
godot_bin, model_b, model_a, episodes_per_side, speedup, seed,
|
||||
grounded_a=grounded_b, grounded_b=grounded_a,
|
||||
team_size=team_size,
|
||||
)
|
||||
|
||||
a_team_0 = {
|
||||
@@ -133,6 +141,7 @@ def main():
|
||||
help="Path to the Godot binary (or set GODOT_BIN)",
|
||||
)
|
||||
parser.add_argument("--speedup", type=int, default=16)
|
||||
parser.add_argument("--team-size", type=int, choices=(1, 2), default=1)
|
||||
parser.add_argument("--seed", type=int, default=1, help="Seed for the paired starting-state sequence")
|
||||
parser.add_argument("--history", default=str(TRAINING_DIR / "eval_history.json"))
|
||||
parser.add_argument(
|
||||
@@ -149,6 +158,7 @@ def main():
|
||||
record = evaluate_pair(
|
||||
args.godot_bin, model_a, model_b, args.episodes, args.speedup, args.seed,
|
||||
grounded_a=args.grounded_a, grounded_b=args.grounded_b,
|
||||
team_size=args.team_size,
|
||||
)
|
||||
except ValueError as error:
|
||||
parser.error(str(error))
|
||||
|
||||
Reference in New Issue
Block a user