Validate the optional ``ladder_rules`` block and return ``(min_round_win_fraction, win_last_k)``. Defaults: win at least ``min_round_win_fraction`` (0.4) of the *agent* rounds AND win the last ``win_last_k`` (1) round(s). The baseline round 0 (identical, un-edited codebases) is excluded
(ladder_rules: dict, rounds: int)
| 19 | context_settings={"help_option_names": ["-h", "--help"]}, |
| 20 | ) |
| 21 | |
| 22 | |
| 23 | def _load_config(config_path: Path) -> dict: |
| 24 | yaml_content = config_path.read_text() |
| 25 | preprocessed_yaml = resolve_includes(yaml_content, base_dir=CONFIG_DIR) |
| 26 | return yaml.safe_load(preprocessed_yaml) |
| 27 | |
| 28 | |
| 29 | @ladder_app.command("make") |
| 30 | def make( |
| 31 | config_path: Path = typer.Argument(..., help="Path to the ladder (round-robin) config file."), |
| 32 | workers: int = typer.Option( |
| 33 | 1, "--workers", "-w", help="Pairwise tournaments to run concurrently (each pair is independent)." |
| 34 | ), |
| 35 | ): |
| 36 | """Build a ladder: run PvP tournaments across all pairs of players (for ranking). |
| 37 | |
| 38 | [dim]• codeclash ladder make configs/ladder/make_battlesnake.yaml[/dim] |
| 39 | """ |
| 40 | build_ladder(_load_config(config_path), workers=workers) |
| 41 | |
| 42 | |
| 43 | @ladder_app.command("run") |
| 44 | def run( |
| 45 | config_path: Path = typer.Argument(..., help="Path to the ladder config (with `player` + `ladder`)."), |
| 46 | cleanup: bool = typer.Option(False, "--cleanup", "-c", help="Clean up the game environment after running."), |
| 47 | output_dir: Path | None = typer.Option(None, "--output-dir", "-o", help="Output directory (default: logs/<user>)."), |
| 48 | suffix: str = typer.Option("", "--suffix", "-s", help="Suffix for the output folder name (no leading dot)."), |
| 49 | keep_containers: bool = typer.Option( |
| 50 | False, "--keep-containers", "-k", help="Do not remove containers after games/agent finish." |
| 51 | ), |
| 52 | resume_from: Path | None = typer.Option( |
| 53 | None, |
| 54 | "--resume", |
| 55 | "-r", |
| 56 | help="Resume an interrupted run: pass its log dir. Skips cleared rungs and seeds from the " |
| 57 | "last cleared rung's pushed codebase. Requires push: True and the same config.", |
| 58 | ), |
| 59 | ): |
| 60 | """Send a model up a ranked ladder, rung by rung, until it loses. |