diff --git a/.agents/skills/change-strategy/SKILL.md b/.agents/skills/change-strategy/SKILL.md new file mode 100644 index 000000000..0aabe31d9 --- /dev/null +++ b/.agents/skills/change-strategy/SKILL.md @@ -0,0 +1,94 @@ +--- +name: change-strategy +description: Write a new strategy or change an existing one, then test it, evaluate it against the champion and promote it if it wins - from branch to pull request. Use when asked to try a strategy idea, improve how a strategy plays, add a tactic for a strategy, or promote a strategy to the core. Not for explaining an existing result (explain-result) or fixing one incident (debug-incident). +--- + +# Change a strategy + +The model behind every step (tactics, partitioners, referee restarts, past tactic bugs) is +`docs/strategy.md`; read its "Writing and evaluating a strategy" and "Strategy +branches" sections first. This skill is the order of the steps and the rules that are easy +to forget. + +## 1. Branch + +`strategy/` from `main`. In a git worktree run `tools/dev/setup_worktree.sh`, and symlink +`replays` from the main checkout so the match results store is shared. + +## 2. Change one thing + +- **New strategy:** a new file `utama_core/strategy/.py` with + `build(outfield_robot_ids, motion_controller)` returning a `Strategy`. The catalog finds it; it + plays as a reserve until it is added to the core. Reuse `strategy/pickers.py`. +- **Changed strategy:** edit exactly one existing strategy module. Never new modules and an + edited one in the same branch. +- **New tactic:** a new module in `tactics/`. Never edit an existing tactic, `pickers.py` or + `catalog.py` on a strategy branch: the opponents run them. To improve a tactic, copy it and + change the copy. +- No module-level state (keep it inside `build`), no import-time effects, no imports of another + strategy. CI checks a `strategy/*` branch touches only `strategy/`, new `tactics/` modules, + `tests/strategy/` (`tools/dev/check_strategy_branch.py`). +- Every change needs a reason in game terms (what the robots will do differently, and why + that wins goals), not a threshold nudged until results move. + +## 3. Test + +1. Pure partitioner tests in `utama_core/tests/strategy/test_.py` (a hand-built `Game`, no rsim). +2. `pixi run pytest utama_core/tests/engine/test_all_strategy_configs.py --headless`. +3. `git add` new files, then `pixi run test` and `pixi run lint`. + +## 4. Evaluate (ask first) + +Never start matches without the user's yes. Then: + +``` +pixi run evaluate NAME [NAME ...] +``` + +- Read the first line of each round: "N matches, X from the match results store, M to play". + After a change to one strategy, M is its own matches: one against each other player (5 with + today's core, 6 for a new strategy). Much more means shared code changed since the store was + filled (then the whole round robin plays); say so before waiting on it. +- Round 1 is a round robin: a stall reported there is a bug. Fix it (the `debug-incident` + skill) before reading the verdict. +- The verdict is goals only, in two stages of 6 rounds. The screen (seeds 1-6) only drops: a mean + paired diff ≤ 0 is "dropped" (not promising, not "worse"). A survivor plays on fresh seeds 101-106 + in the same run: "better" if p ≤ 0.05 there, else "undecided". Every other signal explains the + verdict (the `explain-result` skill), never overrules it. +- On a "better", read the line "against today's ": the reference carries the release's + shared code, so if shared code changed since, that line is the strategy change alone. + +## 5. Record and promote + +- Write the strategy's one-line description in its module docstring: the dashboard shows it. +- Open a draft pull request into `main` with the result. An agent never merges. +- Better than the champion: promoting is one line in `tools/evaluation/reference/players.json` + (`champion`, and the core if it should play every round), in its own small pull request after + the strategy's is merged: CI rejects a `strategy/*` branch that touches anything outside the + strategy files. It becomes the reference at the next release (evaluate.py reads the champion + from `players.json` as it was at that release). + +## Searching (many candidates) + +- Every candidate meets the same reference results on seeds 1-6, so a search can fit them; that is + why only seeds 101-106 accept. Those are shared too: the more candidates reach them, the likelier + one "better" is luck. +- Keep a list of every variant tried, with its verdict, stage and mean diff, in the PR, so a reviewer sees + how many tries one winner came from. +- Change one idea per candidate; several candidates go in one `evaluate.py` call. + +## Judging a shared-code change + +Not on a strategy branch. Batch the changes, then (ask first) `evaluate.py `: today's +champion on today's shared code against itself frozen at the last release. Its margin is what the +shared code did. Every stored match replays, so it is a full run. + +## Rules + +- **Shared code is not a strategy change.** A change to `tactics/` (existing modules), `skills/`, + `pickers.py`, the planner or the referee reruns most matches: put it on an ordinary branch, + batch such changes, and evaluate once at the end. +- **Strategy and evaluation in separate commits**, so results stay comparable. +- **`world.json` / `robots.json` changes** replay every stored match: batch them and ask first. +- Keep evaluation at the sim settings in `tools/evaluation/reference/`; don't tune a strategy + to real-robot limits in sim (those are compensated in the control layer). diff --git a/.agents/skills/debug-incident/SKILL.md b/.agents/skills/debug-incident/SKILL.md new file mode 100644 index 000000000..786d38c58 --- /dev/null +++ b/.agents/skills/debug-incident/SKILL.md @@ -0,0 +1,73 @@ +--- +name: debug-incident +description: Take one bad moment in a match (a foul, a stall, a robot thrashing, driving into the ball at a restart, a strange path near an obstacle) from symptom to a fixed cause with a regression test. Use when tools/debug/find_bugs.py or a replay shows a specific incident, or the user points at a time in a match. Not for "why did this strategy lose" in general (that is the explain-result skill). +--- + +# Debug one incident + +A foul or failure is a symptom. The cause may be the robot's tactic, the shared referee +override, the motion planner, the referee itself, or the check that flagged it: of the first +six found this way, two were the referee or the check. The full workflow, with the bugs found +so far, is `docs/strategy.md`, "Debugging a foul or failure"; read it for anything +below that is unclear. + +Inputs: a replay `REPLAY` (`replays/eval_/round_/_vs_.npz`, or any `.npz`) and a +time `S` in seconds. In a parallel worktree, run `tools/dev/setup_worktree.sh` first. + +## 1. Find it + +`pixi run python tools/debug/find_bugs.py ROUND_DIR --strategy NAME` → `find_bugs/index.md`, then +filter `find_bugs/findings.jsonl` on the kind you care about. Open the finding's picture, +then confirm with the numbers in its message. Only the friendly side (config_a) is checked. + +## 2. Look at it + +Pick the tool by the question. `tools/debug/match_timeline.py`, `tools/debug/restart_picture.py` and `tools/debug/plan_trace.py` take +`--findings` to write their flags as JSON. + +| Question | Command | +|---|---| +| What happened in this window, in text? | `tools/debug/replay_trace.py REPLAY T0 T1` (`--events`: kicks, possession, referee changes, fouls) | +| Which tactic was each robot in, and what was it aiming at? | `tools/debug/repro_from_replay.py REPLAY --t S --summary IDS` (replays the state with tracing on, prints tactic, position, target every 0.25 s) | +| Swimlanes: referee, each robot's tactic, distance to ball | `tools/debug/match_timeline.py REPLAY T0 T1 --side friendly` | +| Where did the referee override send everyone at this restart? Legal? | `tools/debug/restart_picture.py REPLAY --t S` (`--all-restarts`, `--side enemy`) | +| What did the planner decide on this tick? | `tools/debug/plan_snapshot.py REPLAY --t S --robot ID --target X Y` (`--side enemy`) | +| How did the plan evolve over a few seconds? | `tools/debug/plan_trace.py REPLAY --t0 S --t1 S --robot ID [--target X Y]` | +| Run a fresh short match with my own traces | `tools/debug/debug_match.py --strategy A --opponent B --duration 60 --stop-on-goal`, with `ctx.match_log.trace(...)` calls added in the tactic | + +All run as `pixi run python tools/.py ...`. Never conclude from a picture alone. + +## 3. Find the cause in the code + +From the trace: which tactic or override sent the robot there, with which target, waypoint +and obstacles. Then ask whether the rule was really broken (`docs/referee.md ("Design decisions")`) +and whether the check reads it right. Frame trap: rsim stores y negated; anything written into +the sim negates y and heading. + +## 4. Fix it, with a unit test at the boundary + +The fix is not done without a test that fails before and passes after, pinning the exact +boundary (a tolerance, a tie, a target off the field). Prefer a pure unit test over an rsim +fixture. Add a row to the bug table in `docs/strategy.md` if it is a new kind. + +## 5. Optionally keep a moment + +Only when a field state alone decides the behaviour (restart and placement geometry under the +referee override); open-play fouls almost never reproduce from a captured state. + +``` +pixi run python tools/debug/moments.py capture REPLAY --t S --name NAME --check CHECK --note "..." +pixi run python tools/debug/moments.py play utama_core/tests/moments/NAME.json --seeds 0-4 +``` + +It must fail on at least 4 of 5 seeds before the fix. If the fix is not in the same change, +set `"known_failure": ""` (a strict xfail). Moments pin shared-code bugs; they are not a +gate on strategies. + +## Rules + +- A shared-code fix (skills, tactics, planner, referee) changes every strategy: batch such + fixes and evaluate once at the end, and ask before starting any `evaluate.py` run. +- Determinism: replaying the same fixture gives the same match. If a rerun differs, suspect + module-level state in a tactic or skill not keyed by team and cleared at match start. +- Don't chase rsim-only dribble failures as kernel bugs. diff --git a/.agents/skills/explain-result/SKILL.md b/.agents/skills/explain-result/SKILL.md new file mode 100644 index 000000000..18e149025 --- /dev/null +++ b/.agents/skills/explain-result/SKILL.md @@ -0,0 +1,63 @@ +--- +name: explain-result +description: Explain how a strategy plays and why it won, lost or came out undecided, from the replays of an evaluate.py run (or an older round robin). Use after an evaluation, when asked "why did it lose?", "how does X play?", "where do its goals come from?", or before changing a strategy to see what to change. Never use it to rank strategies; goals in evaluate.py's verdict are the only ranking. +--- + +# Explain a result + +Every tool here reads a **round folder**: `replays/eval_/round_/` (older round robins: +`replays/tournament_/`). A round folder holds all of its matches as `_vs_.*`: those +the run played, and links to those it reused from the match results store. `config_a` (the +name before `_vs_`) is the friendly side, the only side with an intentions log. + +Nothing here judges. A signal explains a result; fewer ball losses or more shots is not +"better" on its own (`docs/signals.md`, "Ranking"). Report what the numbers show and what +they suggest changing, never a new ranking. + +## Steps, cheapest first + +1. **Read the run's own report** (no tool to run). + `replays/eval_/report.json`: per candidate the verdict, the stage that decided it + with its mean diff ± SE and p (`screen`, `confirm`), and + `per_opponent` (candidate's and reference's goal difference against each opponent, same seed + and colour). Which opponents moved the margin? `round_1/summary.json` has every signal and + the stall coverage. Look up any signal in `docs/signals.md`: where it lives, its reference + range, and what an off value usually means. + +2. **Is something broken?** `pixi run python tools/debug/find_bugs.py ROUND_DIR --strategy NAME` + (about 20 s a match; `--restarts` adds restart geometry, a minute a match). Open + `find_bugs/index.md` first: the worst matches, findings by kind, a picture each. Our fouls by + rule: `--fouls --by strategy,rule`. A stall, thrash or foul is a bug, not a style: hand it to + the `debug-incident` skill. + +3. **Where do goals come from?** + `pixi run python -m utama_core.analysis.goal_sources ROUND_DIR --out ROUND_DIR/goal_sources.json`. + Goals per match = Σ over situation types (restart or ball won, by third) of situations per + match × P(goal). Tells whether a change should create more situations, convert better, or + allow fewer. Situation names: AGENTS.md glossary and `docs/signals.md`, "Where do goals come + from?". + +4. **How does it play, on the pitch?** + - One strategy against the field: `pixi run python tools/debug/pitch_maps.py ROUND_DIR --out DIR` + (positions with and without the ball, shots, fouls; every panel turned so the strategy + attacks right). + - A candidate against the champion, side by side on one scale: + `pixi run python tools/evaluation/explain.py ROUND_DIR CANDIDATE REFERENCE --out DIR` + (`positions.png`, `shots.png`, `fouls.png`, `summary.json`). REFERENCE is the name as + `report.json` gives it (a frozen file is named by its stem, e.g. `split_shape@cffe3a28`). + Zones: use the names in `docs/signals.md ("Pitch zones")` (defensive / middle / attacking third, wings, box). + +5. **Write it up** in a few lines: the verdict and margin; which opponents decided it; the + two or three signals or pictures that explain it, with numbers; any bug found (handed to + `debug-incident`); what to try next. Look at every picture before citing it. + +## Traps + +- A round has 15 matches (more with `--all`); one strategy is config_a in only some of them, so + friendly-side analyses (intentions, stalls) cover those only. `summary.json`'s + `stalls_checked` says how many. +- Matches from before 2026-11-12, or whose original run folder was deleted, have no replay to + link: tools then see fewer matches than the round lists. Say so when numbers look thin. +- Catch rate moves ±4–8 points between identical runs: never a reason on its own. +- `ball_travel` is not a quality signal. +- Don't start new matches to explain a result; if more data is needed, ask first. diff --git a/.agents/skills/field-session/SKILL.md b/.agents/skills/field-session/SKILL.md new file mode 100644 index 000000000..36cb26bab --- /dev/null +++ b/.agents/skills/field-session/SKILL.md @@ -0,0 +1,63 @@ +--- +name: field-session +description: Run a test day on the real robots, and process what it recorded - checking vision and radio, pairing robots with lids, calibrating a robot, then trimming, measuring and packaging the field logs. Use when the user is at the field, sets up real robots, sees dropouts or a robot misbehaving on the pitch, or brings back field logs. Not for simulated matches. +--- + +# A field session + +Setup and the meaning of each check: `tutorials/field_day.md`. Log format and readers: +`docs/real_robots.md ("Field logs")`. On the field, time is short: run the one command, read its "!!" lines, +fix only those. + +## At the start + +1. `pixi run field-check` (radios 0-7; `--radios 0 1` for fewer). It checks vision for 2 s + (cameras, packets per second, field size, ball, lids), then finds the robots: each radio + turns ~70° on the spot (keep 15 cm clear), the lid that turned is its, with the share of + commands answered and whether its profile was calibrated on that lid. Every line is "ok" or + "!!". It cannot see batteries or kicker charge. +2. On a "!!": + - **Vision quiet or dropping**: check the network link before any code. Multicast over a + 2.4 GHz phone hotspot dropped frames on 2026-10-29. `pixi run python tools/field/vision_check.py + --seconds 5` listens alone; `--guided ball` checks cameras against 9 known spots. + - **Under 80% of commands answered**: range, interference or a flat battery. + - **Lid swapped**: `pixi run find-robots`, and calibrate again (the profile's tag offset + belongs to the lid). + +## Measuring a robot + +`pixi run calibrate --radio N` (65 s of driving, then the robot fetches a ball for the carry +ladder and kicks). It writes `config/robots/radio_.json`; `--check` compares with the +committed profile, `--ball-only` redoes the ball part. Commit a new profile only when it +repeats. Known numbers: ~79 ms loop delay, sideways acceleration well below forward; carry +caps are 0.3 m/s and 0.6 rad/s on real robots (balls are lost turning faster). + +## Things not to chase on the day + +- Kick strength varies (battery, charge, many causes). The kicker is fixed power and holds its + charge ~30 s; `team_controller/controllers/real/kicker_charge.py` keeps it up in play. +- Kick bend comes from the ball's offset on the dribbler (fitted per radio). +- The sim does not model a robot's shortfalls: robot capability is assumed league-level in sim, + and real robots' gaps are compensated in the control layer, not in sim settings. + +## After the session + +1. **Keep the raw logs.** `replays/field/_real_.log.gz`. Never delete + an untrimmed log or archive; ask before deleting anything under `replays/`. +2. **Trim dead time** to new files: `pixi run python tools/field/trim_idle_log.py + replays/field/.log.gz --dry-run`, then without `--dry-run` (`--in-place` only on copies). +3. **Register the session** in `tools/field/field_sessions.json`: its setup, and which measurements + (`loop_delay`, `ball_roll`, `ball_noise`, `robot_noise`) it may be used for. Only registered + sessions are read. +4. **Measure the world**: `pixi run python tools/field/field_physics.py [--json OUT]` prints each + measurement per (day, radio) with its spread and whether the days agree. Stop rule: a number + enters the sim (`tools/evaluation/reference/world.json`) only if it repeats across days, or + its spread is deliberately used as the range. Changing `world.json` changes every match's + environment: every stored result plays again, so batch it and ask first. +5. **One robot's numbers from a log**: `pixi run python tools/field/robot_calibration.py + replays/field/.log [--json OUT]`. +6. **Share**: `pixi run python tools/field/package_logs.py field [DIR] [--dry-run]` compresses the + logs and bundles calibration and hardware config. +7. **Write down** what broke and what was measured (a dated note; open follow-ups listed). + Bugs seen on the pitch go through the `debug-incident` skill with the field log as the + replay. diff --git a/.claude/skills b/.claude/skills new file mode 120000 index 000000000..2b7a412b8 --- /dev/null +++ b/.claude/skills @@ -0,0 +1 @@ +../.agents/skills \ No newline at end of file diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 1a953d02c..b8064f9d3 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,3 +1,3 @@ # Changes here decide what a strategy branch may touch and how it is scored. /.github/ @isaac0804 -/tools/check_strategy_branch.py @isaac0804 +/tools/dev/check_strategy_branch.py @isaac0804 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9d7cb4b4..c8557f7d8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ concurrency: cancel-in-progress: true jobs: - # A strategy branch may change only strategy code, not its opponents (tools/check_strategy_branch.py). + # A strategy branch may change only strategy code, not its opponents (tools/dev/check_strategy_branch.py). # Runs the base branch's copy of the checker, so the branch under test can't loosen it. strategy-branch: if: github.event_name == 'pull_request' && startsWith(github.head_ref, 'strategy/') @@ -21,7 +21,7 @@ jobs: fetch-depth: 0 - name: Only strategy code changed run: | - git show "origin/${{ github.base_ref }}:tools/check_strategy_branch.py" > "$RUNNER_TEMP/check_strategy_branch.py" + git show "origin/${{ github.base_ref }}:tools/dev/check_strategy_branch.py" > "$RUNNER_TEMP/check_strategy_branch.py" python3 "$RUNNER_TEMP/check_strategy_branch.py" --base "origin/${{ github.base_ref }}" test: diff --git a/.gitignore b/.gitignore index 775569860..8a0b05140 100644 --- a/.gitignore +++ b/.gitignore @@ -208,8 +208,10 @@ benchmark_results/ # local agent-tool config dirs .codex/ -.agents/ -.claude/ +.agents/* +!.agents/skills/ +.claude/* +!.claude/skills .vscode diff --git a/AGENTS.md b/AGENTS.md index 524c6c3f3..78a200853 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -5,67 +5,98 @@ Durable context for any coding agent (not just Claude) working in this repo. ## What this repo is Utama-Core is the RoboCup SSL (Small Size League) team's robot-control stack: vision -ingestion, motion planning, robot control, a simulator (`rsoccer_simulator`, "rsim"), and +ingestion, motion planning, robot control, a simulator (`utama_core/simulator`, "rsim"), and the strategy layer that decides what each robot does. `Utama-Strategy` is a sibling repo and is stale — all active strategy work happens here, on top of the tactic-kernel model. ## Work areas -Pick the row for what you are changing and read its doc first. "Doc" is `TODO` where none +Pick the row for what you are changing and read its doc first. `tutorials/` holds step-by-step +pages for people (follow them in order); `docs/` holds the reference (look things up). Keep that split. "Doc" is `TODO` where none exists yet: say so in your change rather than guessing. | Area | Paths | Doc | Notes | |---|---|---|---| -| Strategy / tactics | `utama_core/engine/`, `strategy/`, `tactics/`, `skills/` | `docs/STRATEGY_DEVELOPMENT.md` | Engine changes are rare: a new primitive, not a new strategy | -| Strategy evaluation | `tools/evaluation/`, `utama_core/replay/`, `utama_core/analysis/` | `docs/STRATEGY_DEVELOPMENT.md`, `docs/signals.md` | Change evaluation and strategy in separate commits, so results stay comparable | -| Referee | `utama_core/custom_referee/` | `docs/custom_referee.md` | | -| Motion planning | `utama_core/motion_planning/`, `tools/motion_planning_benchmark.py` | `docs/motion_planning_comparison.md` | | -| Simulation | `utama_core/rsoccer_simulator/`, `vendor/rSim/` | `vendor/rSim/FORK_NOTES.md` | `vendor/rSim` is the C++ physics fork; `rsoccer_simulator` is the Python env on top of it | -| Real robots (radio, vision, controllers) | `utama_core/team_controller/`, `utama_core/data_processing/` | `utama_core/team_controller/README.md` (brief) | | +| Strategy / tactics | `utama_core/engine/`, `strategy/`, `tactics/`, `skills/` | `docs/strategy.md` | Engine changes are rare: a new primitive, not a new strategy | +| Strategy evaluation | `tools/evaluation/`, `utama_core/replay/`, `utama_core/analysis/` | `docs/strategy.md`, `docs/signals.md` | Change evaluation and strategy in separate commits, so results stay comparable | +| Referee | `utama_core/referee/` | `docs/referee.md` | | +| Motion planning | `utama_core/motion_planning/`, `tools/motion_planning_benchmark.py` | `docs/motion_planning.md` | | +| Simulation | `utama_core/simulator/`, `vendor/rSim/` | `vendor/rSim/FORK_NOTES.md` | `vendor/rSim` is the C++ physics fork; `utama_core/simulator` is the Python env on top of it | +| Real robots (radio, vision, controllers) | `utama_core/team_controller/`, `utama_core/data_processing/` | `tutorials/field_day.md`, `docs/real_robots.md` | | ## Glossary One term per thing; reuse these instead of coining new ones. -- **Round-robin / tournament run** — every strategy config plays every other once - (`tools/evaluation/round_robin.py`); writes `replays/tournament_/summary.json` and adds its matches to the evaluation ledger. - The check for stalls and the occasional health check of the whole catalog; a single - strategy is judged with `evaluate.py` (below). With `--reuse` only matches whose code changed rerun. -- **Standings** — only a round-robin's ranking: wins and draws as `round_robin.py` prints them, - or points per match (3 a win, 1 a draw) as `metric_correlation.py` computes them. Not the - verdict on a strategy; see Evaluation. +- **Round robin / health check** — round 1 of `evaluate.py` (below): every player meets every other + once; with no candidate it is the whole run. Reports stalls (with how many matches checked them) and + every signal, in `replays/eval_/round_1/summary.json`. Older runs of the deleted `round_robin.py` + are `replays/tournament_/`. W-D-L there is a signal, never a verdict: there are no standings. +- **Core / reserve strategies** — the core (`tools/evaluation/reference/players.json`) plays every + round; every other strategy in the catalog is reserve and plays only in an occasional `--all` run, + for a wider field. The verdict needs only fixed opponents, the same for candidate and reference. - **Motion planning benchmark** — `tools/motion_planning_benchmark.py`: the planner alone on fixed scenarios. Unrelated to any strategy. -- **Moment / regression moment** — a field state (from a replay or by hand) that reproduced a - bug, with a check of the right behaviour (`utama_core/tests/moments/*.json`, `tools/moments.py`). +- **Moment / regression moment** — a field state (captured from a replay) that reproduced a + bug, with a check of the right behaviour (`utama_core/tests/moments/*.json`, `tools/debug/moments.py`). A cheap end-to-end check, run in `pixi run test`, that a fixed bug stays fixed; the unit test at the cause is the real protection. Not a ranking and not a gate on strategies. The workflow and - the bugs found so far: `docs/STRATEGY_DEVELOPMENT.md`, "Debugging a foul or failure". + the bugs found so far: `docs/strategy.md`, "Debugging a foul or failure". - **Pitch zones** — defensive / middle / attacking third, left wing / centre / right wing, the - box, danger: defined once, with a diagram, in `docs/pitch_zones.md`. Use those names. + box, danger: defined once, with a diagram, in `docs/signals.md ("Pitch zones")`. Use those names. - **Catch rate** — a diagnostic (share of reachable passes received), never a gate (±4–8 pts between runs). - **Position map / shot map** — on-pitch pictures of a strategy over many matches, drawn by - `tools/pitch_maps.py` (and `evaluate.py --explain` for a candidate against the champion), always + `tools/debug/pitch_maps.py` (and `tools/evaluation/explain.py` for a candidate against the champion), always turned so the strategy attacks right. Position map: a heatmap of where the outfield robots stand in live play, with the ball and without it, plus each robot's mean position. Shot map: every shot at the spot it was struck from, own and conceded. They explain how a strategy plays; never a ranking. - **Signal** — an interpretable measure of how a strategy plays (shots, danger conceded, real ball losses, stalls ...), for explaining results, never a target. All listed in `docs/signals.md`. -- **Evaluation / ratings / reference pool / ledger** — `tools/evaluation/evaluate.py`: is a - candidate stronger than the champion of a fixed, versioned reference pool - (`tools/evaluation/pools/pool_vN.json`)? Rounds of matches against the pool's opponents under - seeded sim noise, decided on paired results (candidate and champion against the same opponent - under the same noise) and stopping once the answer is clear; ratings (strength ± SD in goals - per match, `analysis/ratings.py`) over every match in the ledger (`replays/eval/ledger.jsonl`). +- **Evaluation / reference / match results** — `pixi run evaluate NAME` (`tools/evaluation/evaluate.py`): is a candidate + stronger than the reference, the champion at the last release (`--at REF` for another + release)? A screen on seeds 1-6 only drops; a candidate that survives it is accepted or not on fresh + seeds 101-106 (paired t-test). Each round plays under one sim-noise seed in the simulated world and robots + (`tools/evaluation/reference/world.json`, `robots.json`): every round the same round robin, repeated + while a candidate is open, decided on paired results (candidate and reference against the same + opponent under the same noise, `analysis/ratings.py`) and stopping once the answer is clear. Every + match goes to the match results store (`replays/match_results/`, `replay/match_results.py`); a match + the store holds is never played again. Promoting is a one-line change to `players.json` in a PR; it takes effect as the reference at the next release. Goals only: shots, xG and the other signals were tested as rankers and rejected (`docs/signals.md`, "Ranking"). The day-to-day way to judge a strategy. -- **Situation / goal ledger** — a situation starts when a restart goes live or a side wins the - ball in open play; the goal ledger (`utama_core/analysis/goal_ledger.py`) gives each goal to +- **Strategy file** — a `.strategy` file (`utama_core/bundle/`, `tools/dev/build_strategy.py`) is a + zip of one strategy and the whole `utama_core` package at one commit; it plays in its own process, game frames in and + robot commands out, in simulation or on real robots (`BundledStrategy(path, robot_ids)`). `evaluate.py` plays the reference from + such a file of the last release (kept in `replays/eval/frozen/`), so a change to shared code never moves + the reference. The referee and the simulator stay today's for both sides. A file is a player like any strategy name wherever one is named (`evaluate.py`, `players.json`), with the same replays, stats and logs. Its fingerprint is computed like the code's, so a file and the code it was built from are one player in the match results. +- **World / robot capability** — simulator settings fall into two kinds: the world (ball + friction, vision noise and dropouts, latency) comes from measurements; robot capability (kick, + dribbler, motors) is assumed good at league level, and real robots' shortfalls are compensated + in the control layer. The test: would better robots change it? Two decisions follow: evaluation runs + robots at 2 m/s, the speed we are building toward, not today's 1 m/s; and kicks have one power, + as our kicker does, so no variable-kick settings in sim or skills. What we measured on our robots: + `docs/real_robots.md`, "Our robots". `tools/evaluation/reference/ + world.json`, `robots.json`; field sessions in `tools/field/field_sessions.json`. +- **Situation / goal sources** — a situation starts when a restart goes live or a side wins the + ball in open play; the goal sources (`utama_core/analysis/goal_sources.py`) gives each goal to the latest situation less than 10 s before it, so goals per match = Σ situations per match × P(goal). Situation types: own / opponent ball won or free kick in each third, own / opponent kickoff or penalty, force start. See `docs/signals.md`. - **Situation rates** — how often each situation type happens per team per live minute, from - real Division B matches or our round-robin (`goal_ledger --rates PATH`). + real Division B matches or our matches (`goal_sources --rates PATH`). + +## Skills + +Step-by-step playbooks for the jobs that chain several scripts, in `.agents/skills//SKILL.md` +(plain Markdown with a `name`/`description` header; `.claude/skills` is a symlink to the folder). +When a task matches one, read that file and follow it, whatever agent you are. The docs keep the +reasons; the skills keep the steps. + +| Skill | Use it to | +|---|---| +| `change-strategy` | write or change a strategy, test it, evaluate it against the champion, promote it | +| `explain-result` | explain how a strategy plays and why it won or lost, from an evaluation's replays | +| `debug-incident` | take one bad moment in a match from symptom to a fixed cause with a regression test | +| `field-session` | run a test day on the real robots and process its logs | ## Repo map @@ -73,31 +104,30 @@ One term per thing; reuse these instead of coining new ones. `MatchLog`, `AbstractStrategy`, referee-override plumbing. Strategy-dev work touches this rarely, mostly to add a new primitive, not a new strategy. Named `engine/`, not `kernel/`, specifically to avoid colliding with "kernel strategy" — the model's own established - vocabulary (every factory is `build_*_kernel_strategy`, e.g. `build_tiki_taka_kernel_strategy`) - — so "where do I find the kernel strategies" unambiguously means `strategy/` below, not here. + vocabulary — so "where do I find the kernel strategies" unambiguously means `strategy/` below, not here. - `utama_core/strategy/` — the actual strategies people write, run, and compare - (`build_*_kernel_strategy` factories — `tiki_taka`, `counter_flow`, etc.), one module per - strategy (`strategy/.py`, with the pickers only it uses) plus `pickers.py` for helpers - shared by several; `kernel_strategy.py` re-exports every factory, so a new strategy must be - imported there to be discovered. This is where day-to-day strategy-dev edits land. + (`tiki_taka`, `riptide`, etc.), one module per strategy (`strategy/.py`, with one + `build(outfield_robot_ids, motion_controller)` and the pickers only it uses) plus `pickers.py` + for helpers shared by several. The module's name is the strategy's name and `catalog.py` finds + them, so a new strategy is a new file. This is where day-to-day strategy-dev edits land. - `utama_core/tactics/` — reusable `Tactic` implementations (`GiveAndGoTactic`, `PressAndContainTactic`, ...) that strategies compose. - `utama_core/skills/` — lower-level per-robot primitives (`go_to_ball`, `block_attacker`, ...) tactics call directly. -- `utama_core/custom_referee/` — the in-process referee (rules, restart positioning). +- `utama_core/referee/` — the in-process referee (rules, restart positioning). - `utama_core/replay/` — the replay file format (writer, player, columnar reader/writer), scenario rebuilding from a replay, and the match-result cache/fingerprint. - `utama_core/analysis/` — offline analyses of tournament runs and replays (`turnover_breakdown`, `restart_outcomes`, `stuck_detector`, `render_window`, `render_clip`, `list_runs`). Imports `replay/`; `replay/` never imports it. -- Everything else (`motion_planning/`, `rsoccer_simulator/`, `team_controller/`, - `data_processing/`, `entities/`, `global_utils/`) is infrastructure the strategy layer +- Everything else (`motion_planning/`, `simulator/`, `team_controller/`, + `data_processing/`, `entities/`, `geometry/`) is infrastructure the strategy layer sits on top of. Writing a strategy rarely needs to change it, but it is the main work area for planner, simulator, vision and hardware work: see the Work areas table above. **Before touching `utama_core/engine/`, `utama_core/tactics/`, `utama_core/strategy/`, -`utama_core/skills/`, or `tools/evaluation/`/`docs/strategies.md`, read -[`docs/STRATEGY_DEVELOPMENT.md`](docs/STRATEGY_DEVELOPMENT.md)** — the tactic-kernel model, +`utama_core/skills/`, or `tools/evaluation/`, read +[`docs/strategy.md`](docs/strategy.md)** — the tactic-kernel model, referee-restart handling, lessons from past tactic bugs, and the observability tooling (`MatchLog.trace()`, `render_window()`, the strategy catalog) all live there, scoped to that half of the repo rather than duplicated here for every task. @@ -109,7 +139,7 @@ after a concrete case forces it — not in anticipation of one. If a change star accumulating multiple new named concepts, stop and check whether that was actually asked for. This is a deliberate, repeatedly-stated project preference, not an oversight to fix: prefer the smallest mechanism that solves the problem actually in front of you. `docs/ -tactic_model_design_decisions.md` documents several concepts explicitly deferred for +strategy_design.md` documents several concepts explicitly deferred for exactly this reason (concurrent-slot priority tuning, `Tactic` min/max robot-count declarations) — check there before reintroducing one of them. @@ -118,7 +148,7 @@ declarations) — check there before reintroducing one of them. - **Always pass `--headless`** when running any simulator/integration test: `pixi run pytest utama_core/tests/ --headless`. Much faster; there is no reason to run with graphics in an agent loop. -- A git worktree for a parallel agent: run `tools/setup_worktree.sh` inside it (links `.pixi`, +- A git worktree for a parallel agent: run `tools/dev/setup_worktree.sh` inside it (links `.pixi`, copies the compiled planner/simulator `.so` files; without them tests differ). - `pixi run test` runs the default suite; `pixi run lint` runs the full pre-commit stack (black, ruff, isort) — run both before considering a change done. @@ -131,9 +161,13 @@ declarations) — check there before reintroducing one of them. In rsim, `run_test`'s `episode_timeout` is game time (rsim runs several times faster than real time), so a test's budget doesn't depend on machine load. - A known defect is a `strict=True` xfail on exactly the cases that hit it (see - `bang_bang_edge_cases_test.py`'s `_seeds_with_known_defect`), so a fix shows as XPASS and + `test_bang_bang_edge_cases.py`'s `_seeds_with_known_defect`), so a fix shows as XPASS and a regression elsewhere fails. Don't chase rsim-only dribble test failures as if they were kernel bugs; verify on grsim if genuinely unsure. +- rsim is deterministic on one machine but not across CPUs (the planner's numba kernels are compiled + `fastmath` for the host), so CI plays a slightly different game. Don't assert outcomes of + multi-second rsim games: assert invariants, or write a pure unit test. A CI-only rsim failure is + CPU numerics first. - Before trusting any test result (yours or another agent's), prefer independently re-running it and reading real output over trusting a self-report — this codebase has been touched by both humans and agents, and a claimed "all tests pass" is only as @@ -150,22 +184,24 @@ declarations) — check there before reintroducing one of them. `docs/README.md` indexes every doc by kind and `docs/tools.md` every script; the ones agents need most: -- `docs/STRATEGY_DEVELOPMENT.md` — tactic-kernel model, referee handling, writing a +- `.agents/skills/` — step-by-step playbooks over those scripts (see "Skills" below). + +- `tutorials/first_strategy.md` — the beginner tutorial (a toy strategy, then evaluation). Keep it short, + simple and runnable: `tests/strategy/test_first_strategy_doc.py` builds its code. +- `docs/strategy.md` — tactic-kernel model, referee handling, writing a `Tactic`, observability tooling. Read before any strategy-layer change. -- `docs/tactic_model_design_decisions.md` — kernel/Tactic/Partitioner design rationale. -- `docs/custom_referee.md` — `CustomReferee` architecture/usage; its "Known gaps" section +- `docs/strategy_design.md` — kernel/Tactic/Partitioner design rationale. +- `docs/referee.md` — `CustomReferee` architecture/usage; its "Known gaps" section tracks genuinely open items (don't assume something is missing without checking there first — it may already be resolved and the surrounding doc just stale). -- `docs/custom_referee_design_decisions.md` — referee rule-by-rule design decisions. -- `docs/roadmap.md` — running list of larger, not-yet-scheduled workstreams; check before - assuming a doc's claim about "not yet built" is still accurate — these drift. +- `docs/referee.md ("Design decisions")` — referee rule-by-rule design decisions. - `docs/signals.md` — every signal we record about how a strategy plays (stalls, fouls, chances created and conceded, ball losses, pass receptions, restarts), grouped by the question it answers, with where it lives in `summary.json`, a reference range and what an off value means. Read it when designing or debugging a strategy, and before adding a metric; they are diagnostics, not objectives. -- `docs/strategies.md` — strategy catalog: status, description, and real round-robin - results per `build_*_kernel_strategy` factory. -- `utama_core/tests/engine/` and `utama_core/tests/strategy_runner/` — the real +- `pixi run dashboard`, Strategies tab — every strategy: core or reserve, its description (the + module docstring), verdicts, maps and matches, read from the code and `replays/`. +- `utama_core/tests/engine/` and `utama_core/tests/run/` — the real tactic-kernel test surface; everywhere else is largely infrastructure (motion planning, vision, controllers) that predates and sits below the kernel model. diff --git a/README.md b/README.md index 05147fda8..fc49c6f81 100644 --- a/README.md +++ b/README.md @@ -14,27 +14,26 @@ strategy layer that decides what every robot does. 2. `pixi install` in the repository root, then `pixi run precommit-install` so every commit is linted. 3. `pixi run test` runs the test suite (add `--headless` when calling pytest directly). -4. Play one headless match between two strategies and save its replay: +4. `pixi run main` to watch a match in the simulator (Ctrl+C to stop). - pixi run python tools/evaluation/round_robin.py --pair tiki_taka low_block - -5. `pixi run python dashboard_server.py` and open http://localhost:8080 to watch replays and - browse tournament results. +**New here? Write your first strategy: [tutorials/first_strategy.md](tutorials/first_strategy.md).** Everything runs in rsim with the in-process referee; grSim, the official GameController and -real robots are optional ([external setup](docs/setup_external.md)). +real robots are optional ([external setup](docs/real_robots.md#external-tools-grsim-gamecontroller-autoreferee-ssl-vision)). ## What are you working on? | Task | Start here | |---|---| -| Writing or changing a strategy, tactic or skill | [docs/STRATEGY_DEVELOPMENT.md](docs/STRATEGY_DEVELOPMENT.md), [docs/strategies.md](docs/strategies.md) | -| Seeing what the robots did, and why | [docs/visual_guide.md](docs/visual_guide.md); `tools/triage.py RUN_DIR` for a run's worst problems | -| Judging whether a strategy is better | [docs/STRATEGY_DEVELOPMENT.md](docs/STRATEGY_DEVELOPMENT.md), [docs/signals.md](docs/signals.md), [docs/signal_report.md](docs/signal_report.md) | -| The referee | [docs/custom_referee.md](docs/custom_referee.md) | -| Motion planning | [docs/motion_planning_comparison.md](docs/motion_planning_comparison.md) | +| Your first strategy | [tutorials/first_strategy.md](tutorials/first_strategy.md) | +| Writing or changing a strategy, tactic or skill | [docs/strategy.md](docs/strategy.md) | +| Seeing what the robots did, and why | `pixi run dashboard` (every strategy's maps and replays); `tools/debug/find_bugs.py RUN_DIR` for a run's worst problems | +| Judging whether a strategy is better | [docs/strategy.md](docs/strategy.md), [docs/signals.md](docs/signals.md) | +| The referee | [docs/referee.md](docs/referee.md) | +| Motion planning | [docs/motion_planning.md](docs/motion_planning.md) | | The simulator | [vendor/rSim/FORK_NOTES.md](vendor/rSim/FORK_NOTES.md) | -| Real robots, vision, radio | [utama_core/team_controller/README.md](utama_core/team_controller/README.md), [docs/setup_external.md](docs/setup_external.md) | +| A test day with real robots | [tutorials/field_day.md](tutorials/field_day.md) | +| Real robots, vision, radio | [utama_core/team_controller/README.md](utama_core/team_controller/README.md), [docs/real_robots.md, "External tools"](docs/real_robots.md#external-tools-grsim-gamecontroller-autoreferee-ssl-vision) | | Which script does what | [docs/tools.md](docs/tools.md) | | Everything else | [docs/README.md](docs/README.md), the index of every doc | @@ -44,21 +43,22 @@ Coding agents: read [AGENTS.md](AGENTS.md) first (`CLAUDE.md` is a symlink to it Everything lives under `utama_core/`: -- `strategy/`: the strategies (one module per `build_*_kernel_strategy` factory, re-exported by `kernel_strategy.py`) -- `tactics/`, `skills/`, `shared/`: reusable tactics, per-robot skills, and geometry they share +- `strategy/`: the strategies (one module each, named after the strategy) +- `tactics/`, `skills/`, `geometry/`: reusable tactics, per-robot skills, and the geometry they share - `engine/`: the tactic-kernel infrastructure (`Strategy`, `Tactic`, `TickContext`, `MatchLog`, referee overrides) -- `custom_referee/`: the in-process referee (rules, state machine, restart positioning, profiles) +- `referee/`: the in-process referee (rules, state machine, restart positioning, profiles) - `motion_planning/`: path planning and motion control - `run/`: the main loop (`StrategyRunner`) - `replay/`: replay files, the match-result cache and code fingerprints - `analysis/`: offline analyses of tournament runs and replays (ball losses, chances, restarts, stalls) -- `rsoccer_simulator/`: the Python simulator environment over the rSim physics fork in `vendor/rSim/` +- `simulator/`: the Python simulator environment over the rSim physics fork in `vendor/rSim/` - `team_controller/`, `data_processing/`: vision, robot radio and referee input - `dashboard/`: the browser dashboard -- `entities/`, `config/`, `global_utils/`: data classes, settings and constants, utilities +- `entities/`, `config/`, `geometry/`: data classes, settings and constants, geometry helpers - `tests/`: all tests -Scripts live in `tools/` (tournaments in `tools/evaluation/`) and `examples/`; see +Scripts live in `tools/` (grouped by who uses them: `debug/`, `field/`, `realism/`, `dev/`; the +strategy evaluation in `tools/evaluation/`) and `examples/`; see [docs/tools.md](docs/tools.md). ## Field conventions @@ -77,7 +77,7 @@ One tick of `StrategyRunner`, from vision, robot and referee data to robot comma ![One tick of StrategyRunner](docs/img/pipeline/one_tick.png) The same tick as a diagram, with every module: [docs/architecture.md](docs/architecture.md). How -vision, robot and referee data become one `Game`: [docs/pipeline_method.md](docs/pipeline_method.md). +vision, robot and referee data become one `Game`: [docs/architecture.md, "Pipeline method"](docs/architecture.md#pipeline-method). ## Contributing @@ -90,4 +90,15 @@ Work on a branch and open a pull request into `main`. A pull request needs: 4. every Copilot comment reviewed (not necessarily accepted); 5. an approval from an assigned reviewer. -Editor setup, pre-commit troubleshooting and the pixi environments: [docs/contributing.md](docs/contributing.md). +Tips: + +- Run `pixi install` again after adding a package (a folder with an `__init__.py`). +- In VS Code, if the run button picks the wrong environment, choose the interpreter by hand + (`Ctrl + Shift + P` → `Select Interpreter`). Format on save with the `Black Formatter` extension. +- When a commit fails the pre-commit checks, the hook has often fixed the files already: stage + them and commit again. +- A strategy branch (`strategy/*`) may change strategy code only + (`tools/dev/check_strategy_branch.py`), so it can't change what it is scored against. +- `CLAUDE.md` is a symlink to `AGENTS.md`, and `.claude/skills` to `.agents/skills`: edit the + targets. On native Windows without Developer + Mode, fix it with `git config --global core.symlinks true && git checkout -- CLAUDE.md .claude/skills`. diff --git a/docs/README.md b/docs/README.md index b09709a07..3caea1969 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,43 +1,15 @@ # Docs -Every doc in this folder, by kind. New to the repo: the [README](../README.md) first. - -## How to - -- [STRATEGY_DEVELOPMENT.md](STRATEGY_DEVELOPMENT.md): writing and evaluating strategies and tactics: the tactic-kernel model, referee restarts, lessons from past tactic bugs, round-robins, observability tools. Read before any strategy-layer change. -- [custom_referee.md](custom_referee.md): the in-process `CustomReferee`: architecture, usage, profiles, and its known gaps. -- [custom_referee_gui.md](custom_referee_gui.md): the referee operator panel in the dashboard. -- [referee_integration.md](referee_integration.md): how referee commands reach robots (`RefereeOverride`) and what each command requires. -- [motion_planning_comparison.md](motion_planning_comparison.md): the motion-planning benchmark and how to read it. -- [motion_planning_results.md](motion_planning_results.md): its latest full run. +How the code works and why: look things up here. To learn by doing, start with the step-by-step +pages in [tutorials/](../tutorials/): [first_strategy.md](../tutorials/first_strategy.md) (new members +start there) and [field_day.md](../tutorials/field_day.md) (a test day with real robots). Docs that +code comments cite but that were deleted are in git history. + +- [strategy.md](strategy.md): the strategy layer and its evaluation: the tactic-kernel model, referee restarts, lessons from past bugs, the debugging tools. +- [strategy_design.md](strategy_design.md): why the strategy layer is shaped as it is, and what was deliberately not built. +- [signals.md](signals.md): every signal recorded about how a strategy plays, and the names of the pitch zones. +- [referee.md](referee.md): the in-process referee, how its commands reach robots, the operator panel, and its rule-by-rule design decisions. +- [motion_planning.md](motion_planning.md): the motion-planning benchmark and how to read it. +- [real_robots.md](real_robots.md): field logs and the tools that read them; grSim, the GameController and ssl-vision. +- [architecture.md](architecture.md): how the packages depend on each other, and how one tick turns vision, robot and referee data into commands. - [tools.md](tools.md): every script and pixi task, by purpose. -- [visual_guide.md](visual_guide.md): the game drawn on the pitch from real replays (how each strategy plays, one match over time, a restart, the motion planner), what each picture has shown us, and how to draw it. -- [setup_external.md](setup_external.md): grSim, the official GameController and AutoReferee. -- [real_robot_setup.md](real_robot_setup.md): a test day with real robots: ssl-vision on its own laptop, WSL networking and USB, the radio, and the checks before a robot moves. -- [field_logs.md](field_logs.md): real robot game logs: format, record types, calibration analysis, dead-time trimming, and release packaging. -- [contributing.md](contributing.md): editor setup, commits, pull requests and releases. - -## Design rationale - -- [tactic_model_design_decisions.md](tactic_model_design_decisions.md): why the strategy layer (engine, tactics, strategies) is shaped the way it is, and what was deliberately not built. -- [scheduling_math_model.md](scheduling_math_model.md): a mathematical model of tactic scheduling and role allocation, a companion to the above. -- [custom_referee_design_decisions.md](custom_referee_design_decisions.md): rule-by-rule decisions from auditing `CustomReferee` against the SSL rulebook. -- [pipeline_method.md](pipeline_method.md): how vision, robot and referee data are refined into one `Game` state, and one tick from state to robot commands. -- [architecture.md](architecture.md): the one-tick diagram, and the generated package dependency graph with its import-rule check. - -## Current results - -- [strategies.md](strategies.md): the strategy catalog: every `build_*_kernel_strategy`, its status, and its latest round-robin results. -- [pitch_zones.md](pitch_zones.md): names for the parts of the pitch (thirds, wings, centre, the box, danger), with a diagram. -- [signals.md](signals.md): every signal recorded about how a strategy plays, grouped by question, with reference ranges and what an off value means. -- [signal_report.md](signal_report.md): figures of the main signals for every strategy in the latest full round-robin. - -## Open work - -- [roadmap.md](roadmap.md): larger open workstreams, and one-line pointers to finished ones. -- [sim_realism.md](sim_realism.md): how far rsim is from real matches, the realism scorecard, and the plan to close the gap with measured, randomized physics. -- [in_house_vision.md](in_house_vision.md): our own vision stack for lab days (per-session tag calibration, tags on robots), the experiments that decide it, and the 2026-10-22 test day's vision findings. -- [field_log_replay.md](field_log_replay.md): design for finding a moment in a field log and rerunning the decision code on its recorded inputs, and the physical setup's own errors (tag yaw and offset, kicker offset, cameras) as per-robot profiles. -- [testing_gaps.md](testing_gaps.md): kinds of testing gap that let bugs through, numbered (code cites them by number). -- [investigation_default_vs_lowblock_stalemate.md](investigation_default_vs_lowblock_stalemate.md): why `default` vs `low_block` stays 0-0; partly fixed. -- [investigation_ball_contact_orientation_divergence.md](investigation_ball_contact_orientation_divergence.md): a robot pinned against the ball rotates away from contact; localized, not fixed. diff --git a/docs/architecture.md b/docs/architecture.md index 00c44c7d7..f901e4381 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -5,14 +5,14 @@ How the packages under `utama_core/` depend on each other, and how one tick flow ## One tick The flow of one tick of `StrategyRunner`, from vision to robot (module paths under `utama_core/`; the -same steps in words: [README](../README.md#system-design)). [pipeline_method.md](pipeline_method.md) +same steps in words: [README](../README.md#system-design)). [Pipeline method](#pipeline-method) below describes the same path in more detail. ```mermaid flowchart TD subgraph input["Input"] vis["Vision frames
data_processing/receivers/vision_receiver.py (real, grSim)
or rsim observations"] - refsrc["Referee data
custom_referee/custom_referee.py (rsim)
or data_processing/receivers/referee_receiver.py"] + refsrc["Referee data
referee/custom_referee.py (rsim)
or data_processing/receivers/referee_receiver.py"] end subgraph world["World model (data_processing/refiners/)"] @@ -27,19 +27,19 @@ flowchart TD strat["Strategy.tick
engine/strategy.py"] restart{"Restart, STOP or TIMEOUT?
engine/referee_override.py"} halt{"HALT?
engine/referee_reset.py"} - ovr["RefereeOverride.tick
engine/referee_override.py
custom_referee/actions.py"] + ovr["RefereeOverride.tick
engine/referee_override.py
referee/actions.py"] part["Partitioner (robots per tactic)
engine/strategy.py, strategy/*.py"] tac["Tactic.tick
tactics/*.py"] - skill["Skills
skills/src/*.py"] + skill["Skills
skills/*.py"] end subgraph motion["Motion (motion_planning/)"] - mc["MotionController.calculate
motion_planning/src/controllers/
fpp, dwa, trajsample"] + mc["MotionController.calculate
motion_planning/controllers/
fpp, dwa, trajsample"] end subgraph output["Output (team_controller/)"] - ctrl["RobotController.send_robot_commands
team_controller/src/controllers/"] - rsim["rsim
rsoccer_simulator/ (sim/rsim_robot_controller.py)"] + ctrl["RobotController.send_robot_commands
team_controller/controllers/"] + rsim["rsim
simulator/ (sim/rsim_robot_controller.py)"] grsim["grSim over UDP
sim/grsim_robot_controller.py"] real["Real robots over radio
real/real_robot_controller.py"] end @@ -66,117 +66,205 @@ flowchart TD ## Match data flow Every rsim match writes files under `replays/` (`REPLAY_BASE_PATH`), and the analyses, tools and -evaluation read them back. A match's file stem is `A_vs_B` (`round_robin.py`'s `_tag`); the names -below are from a real run directory. `--reuse` reads the match cache, and only matches whose -fingerprint changed are played again. +evaluation read them back. A match's file stem is `A_vs_B` (`evaluate.py`'s `tag`); the names +below are from a real run directory. The match results store (`replays/match_results/`) is read first: +a match it holds is not played again, so only matches whose fingerprint changed are played. ![Match data flow: drivers, StrategyRunner, the per-match files, the stores and the readers](img/architecture/match_data_flow.png) Drawn by `docs/img/architecture/make_match_data_flow.py`; rerun it when a name in it changes. `evaluate.py` removes its own scratch run directory when it finishes, so its matches survive only -in the ledger. +in the match results store. ## Package dependencies -Generated by `tools/package_graph.py` from the imports of every `.py` under `utama_core/` (tests +Generated by `tools/dev/package_graph.py` from the imports of every `.py` under `utama_core/` (tests excluded as sources). Each edge is one first-level package importing another, labelled with its number of imports; packages with no edges are left out. Regenerate and paste the output below: - pixi run python tools/package_graph.py + pixi run python tools/dev/package_graph.py The only edge into `tests` is `run` (the runner imports `utama_core/tests/common`'s test manager). The rule the script checks: `replay/` never imports `analysis/` (see [AGENTS.md](../AGENTS.md)). ```mermaid flowchart LR - p_analysis["analysis"] -->|11| p_config["config"] - p_analysis["analysis"] -->|3| p_engine["engine"] - p_analysis["analysis"] -->|11| p_entities["entities"] - p_analysis["analysis"] -->|8| p_replay["replay"] - p_analysis["analysis"] -->|1| p_rsoccer_simulator["rsoccer_simulator"] - p_config["config"] -->|1| p_global_utils["global_utils"] - p_custom_referee["custom_referee"] -->|20| p_config["config"] - p_custom_referee["custom_referee"] -->|48| p_entities["entities"] - p_custom_referee["custom_referee"] -->|2| p_global_utils["global_utils"] - p_custom_referee["custom_referee"] -->|1| p_shared["shared"] - p_custom_referee["custom_referee"] -->|1| p_skills["skills"] - p_dashboard["dashboard"] -->|1| p_analysis["analysis"] + p_analysis["analysis"] -->|20| p_config["config"] + p_analysis["analysis"] -->|4| p_engine["engine"] + p_analysis["analysis"] -->|26| p_entities["entities"] + p_analysis["analysis"] -->|2| p_motion_planning["motion_planning"] + p_analysis["analysis"] -->|1| p_referee["referee"] + p_analysis["analysis"] -->|16| p_replay["replay"] + p_analysis["analysis"] -->|1| p_simulator["simulator"] + p_analysis["analysis"] -->|6| p_strategy["strategy"] + p_analysis["analysis"] -->|2| p_team_controller["team_controller"] + p_bundle["bundle"] -->|3| p_config["config"] + p_bundle["bundle"] -->|5| p_engine["engine"] + p_bundle["bundle"] -->|7| p_entities["entities"] + p_bundle["bundle"] -->|1| p_motion_planning["motion_planning"] + p_bundle["bundle"] -->|2| p_strategy["strategy"] + p_config["config"] -->|1| p_geometry["geometry"] + p_dashboard["dashboard"] -->|2| p_analysis["analysis"] p_dashboard["dashboard"] -->|3| p_config["config"] - p_dashboard["dashboard"] -->|3| p_custom_referee["custom_referee"] - p_dashboard["dashboard"] -->|1| p_engine["engine"] + p_dashboard["dashboard"] -->|2| p_engine["engine"] p_dashboard["dashboard"] -->|2| p_entities["entities"] + p_dashboard["dashboard"] -->|3| p_referee["referee"] p_dashboard["dashboard"] -->|2| p_replay["replay"] - p_data_processing["data_processing"] -->|6| p_config["config"] - p_data_processing["data_processing"] -->|26| p_entities["entities"] - p_data_processing["data_processing"] -->|2| p_global_utils["global_utils"] + p_dashboard["dashboard"] -->|2| p_run["run"] + p_dashboard["dashboard"] -->|1| p_strategy["strategy"] + p_dashboard["dashboard"] -->|1| p_tactics["tactics"] + p_data_processing["data_processing"] -->|7| p_config["config"] + p_data_processing["data_processing"] -->|27| p_entities["entities"] + p_data_processing["data_processing"] -->|1| p_geometry["geometry"] p_data_processing["data_processing"] -->|4| p_team_controller["team_controller"] p_engine["engine"] -->|3| p_config["config"] - p_engine["engine"] -->|2| p_custom_referee["custom_referee"] - p_engine["engine"] -->|17| p_entities["entities"] - p_engine["engine"] -->|1| p_global_utils["global_utils"] + p_engine["engine"] -->|25| p_entities["entities"] + p_engine["engine"] -->|3| p_geometry["geometry"] p_engine["engine"] -->|3| p_motion_planning["motion_planning"] - p_engine["engine"] -->|1| p_rsoccer_simulator["rsoccer_simulator"] - p_engine["engine"] -->|1| p_skills["skills"] + p_engine["engine"] -->|2| p_referee["referee"] + p_engine["engine"] -->|1| p_simulator["simulator"] + p_engine["engine"] -->|3| p_skills["skills"] + p_engine["engine"] -->|1| p_strategy["strategy"] p_engine["engine"] -->|1| p_tactics["tactics"] - p_engine["engine"] -->|1| p_team_controller["team_controller"] + p_engine["engine"] -->|2| p_team_controller["team_controller"] p_entities["entities"] -->|1| p_config["config"] - p_global_utils["global_utils"] -->|1| p_config["config"] - p_global_utils["global_utils"] -->|2| p_entities["entities"] - p_motion_planning["motion_planning"] -->|23| p_config["config"] - p_motion_planning["motion_planning"] -->|23| p_entities["entities"] - p_motion_planning["motion_planning"] -->|3| p_global_utils["global_utils"] - p_motion_planning["motion_planning"] -->|8| p_rsoccer_simulator["rsoccer_simulator"] - p_replay["replay"] -->|6| p_config["config"] - p_replay["replay"] -->|1| p_custom_referee["custom_referee"] + p_geometry["geometry"] -->|4| p_config["config"] + p_geometry["geometry"] -->|6| p_entities["entities"] + p_geometry["geometry"] -->|1| p_motion_planning["motion_planning"] + p_geometry["geometry"] -->|1| p_skills["skills"] + p_motion_planning["motion_planning"] -->|25| p_config["config"] + p_motion_planning["motion_planning"] -->|25| p_entities["entities"] + p_motion_planning["motion_planning"] -->|3| p_geometry["geometry"] + p_motion_planning["motion_planning"] -->|8| p_simulator["simulator"] + p_referee["referee"] -->|20| p_config["config"] + p_referee["referee"] -->|47| p_entities["entities"] + p_referee["referee"] -->|4| p_geometry["geometry"] + p_referee["referee"] -->|2| p_skills["skills"] + p_replay["replay"] -->|1| p_bundle["bundle"] + p_replay["replay"] -->|4| p_config["config"] p_replay["replay"] -->|1| p_data_processing["data_processing"] - p_replay["replay"] -->|20| p_entities["entities"] - p_replay["replay"] -->|2| p_global_utils["global_utils"] - p_replay["replay"] -->|5| p_rsoccer_simulator["rsoccer_simulator"] - p_replay["replay"] -->|3| p_team_controller["team_controller"] - p_rsoccer_simulator["rsoccer_simulator"] -->|4| p_config["config"] - p_rsoccer_simulator["rsoccer_simulator"] -->|3| p_entities["entities"] - p_rsoccer_simulator["rsoccer_simulator"] -->|2| p_global_utils["global_utils"] - p_run["run"] -->|8| p_config["config"] - p_run["run"] -->|4| p_custom_referee["custom_referee"] + p_replay["replay"] -->|22| p_entities["entities"] + p_replay["replay"] -->|1| p_geometry["geometry"] + p_replay["replay"] -->|1| p_referee["referee"] + p_replay["replay"] -->|5| p_simulator["simulator"] + p_replay["replay"] -->|1| p_strategy["strategy"] + p_replay["replay"] -->|4| p_team_controller["team_controller"] + p_run["run"] -->|1| p_bundle["bundle"] + p_run["run"] -->|9| p_config["config"] p_run["run"] -->|4| p_data_processing["data_processing"] - p_run["run"] -->|4| p_engine["engine"] - p_run["run"] -->|12| p_entities["entities"] - p_run["run"] -->|2| p_global_utils["global_utils"] - p_run["run"] -->|2| p_motion_planning["motion_planning"] - p_run["run"] -->|2| p_replay["replay"] - p_run["run"] -->|6| p_rsoccer_simulator["rsoccer_simulator"] - p_run["run"] -->|1| p_shared["shared"] + p_run["run"] -->|5| p_engine["engine"] + p_run["run"] -->|18| p_entities["entities"] + p_run["run"] -->|2| p_geometry["geometry"] + p_run["run"] -->|3| p_motion_planning["motion_planning"] + p_run["run"] -->|6| p_referee["referee"] + p_run["run"] -->|3| p_replay["replay"] + p_run["run"] -->|7| p_simulator["simulator"] p_run["run"] -->|1| p_skills["skills"] - p_run["run"] -->|1| p_team_controller["team_controller"] + p_run["run"] -->|2| p_strategy["strategy"] + p_run["run"] -->|2| p_team_controller["team_controller"] p_run["run"] -->|1| p_tests["tests"] - p_shared["shared"] -->|3| p_config["config"] - p_shared["shared"] -->|4| p_entities["entities"] - p_shared["shared"] -->|1| p_motion_planning["motion_planning"] - p_shared["shared"] -->|1| p_skills["skills"] - p_skills["skills"] -->|6| p_config["config"] + p_simulator["simulator"] -->|4| p_config["config"] + p_simulator["simulator"] -->|3| p_entities["entities"] + p_simulator["simulator"] -->|2| p_geometry["geometry"] + p_skills["skills"] -->|7| p_config["config"] p_skills["skills"] -->|2| p_data_processing["data_processing"] - p_skills["skills"] -->|1| p_engine["engine"] - p_skills["skills"] -->|26| p_entities["entities"] - p_skills["skills"] -->|2| p_global_utils["global_utils"] + p_skills["skills"] -->|2| p_engine["engine"] + p_skills["skills"] -->|25| p_entities["entities"] + p_skills["skills"] -->|5| p_geometry["geometry"] p_skills["skills"] -->|8| p_motion_planning["motion_planning"] - p_skills["skills"] -->|3| p_shared["shared"] - p_strategy["strategy"] -->|65| p_engine["engine"] - p_strategy["strategy"] -->|22| p_entities["entities"] - p_strategy["strategy"] -->|23| p_motion_planning["motion_planning"] - p_strategy["strategy"] -->|63| p_tactics["tactics"] - p_tactics["tactics"] -->|6| p_config["config"] - p_tactics["tactics"] -->|25| p_engine["engine"] - p_tactics["tactics"] -->|40| p_entities["entities"] + p_strategy["strategy"] -->|36| p_engine["engine"] + p_strategy["strategy"] -->|12| p_entities["entities"] + p_strategy["strategy"] -->|13| p_motion_planning["motion_planning"] + p_strategy["strategy"] -->|36| p_tactics["tactics"] + p_tactics["tactics"] -->|7| p_config["config"] + p_tactics["tactics"] -->|29| p_engine["engine"] + p_tactics["tactics"] -->|43| p_entities["entities"] + p_tactics["tactics"] -->|16| p_geometry["geometry"] p_tactics["tactics"] -->|1| p_motion_planning["motion_planning"] - p_tactics["tactics"] -->|15| p_shared["shared"] p_tactics["tactics"] -->|36| p_skills["skills"] - p_team_controller["team_controller"] -->|10| p_config["config"] - p_team_controller["team_controller"] -->|7| p_entities["entities"] - p_team_controller["team_controller"] -->|1| p_global_utils["global_utils"] - p_team_controller["team_controller"] -->|2| p_rsoccer_simulator["rsoccer_simulator"] + p_team_controller["team_controller"] -->|12| p_config["config"] + p_team_controller["team_controller"] -->|12| p_entities["entities"] + p_team_controller["team_controller"] -->|1| p_geometry["geometry"] + p_team_controller["team_controller"] -->|2| p_simulator["simulator"] p_team_controller["team_controller"] -->|1| p_skills["skills"] ``` Violations of the import rules (`replay/` never imports `analysis/`): none + +## Pipeline method + +![One tick of StrategyRunner](img/pipeline/one_tick.png) + +Drawn by `docs/img/pipeline/make_one_tick.py`; rerun it when a box's name changes. The same tick as a +Mermaid diagram with every module path: [One tick](#one-tick) above. + +How vision, robot and referee data become one `Game` state, and how one tick turns that +state into robot commands. Everything below runs inside `StrategyRunner` +(`utama_core/run/strategy_runner.py`). + +### Data in + +The referee is one of three sources (`run/referee_source.py`): none, the official +GameController over the network, or `CustomReferee`, which runs in the same process and is what +rsim matches and tournaments use (`docs/referee.md`). + +**Problem.** Combining new data with prior knowledge (e.g. a Kalman filter) kept bloating +`GameFrame` with new functions, and access to past and current state wasn't uniform. + +**Solution.** `Game` holds our best estimate of the true current state and is updated by a +chain of **refiners**: each takes the current game frame and one kind of new data and returns +an updated frame. Later refiners see earlier updates: `RobotInfoRefiner` takes has-ball from our +robots' IR, or infers it from the refined positions for a robot whose IR isn't trusted, and +takes the enemy's from their responses when the sim provides them (both teams in rsim). +Friendly and enemy robots expose the same fields, estimated from different sources. + +- **Multiple cameras** are combined inside `PositionRefiner`. +- **Falling behind:** receivers fill one-slot buffers (`deque(maxlen=1)`), and the main loop + runs at a fixed rate and takes only the latest vision and referee data each tick. +- `GameFrame` is immutable; receivers (network) are separate from refiners, which makes + testing easier. +- `GameHistory` (`utama_core/entities/game/game_history.py`) stores past frames. +- Before the first tick, `GameGater` waits until the frames hold the expected robots and ball. + +The uniform `GameTimeline`/`Predictions` interface (pluggable per-property predictors) from +earlier drafts was never built; predictions are ad hoc per call site. + +#### Inside PositionRefiner + +Camera combining and the Kalman filters (`data_processing/refiners/position.py`, +`data_processing/refiners/filters/kalman.py`). Smoothing and vanished-robot imputation are +separate switches; both run on the same per-robot filters. + +```mermaid +flowchart TD + cams["Raw vision, one RawVisionData per camera"] + comb["CameraCombiner.combine_cameras
_avg_robots per robot id, _combine_balls_by_proximity,
_bounds_check against VisionBounds"] + vd["VisionData
combined robots and balls"] + sw{"smooth_positions?"} + kf["KalmanFilter per robot, KalmanFilterBall
filters/kalman.py"] + imp{"impute_vanished?"} + vanish["_include_vanished_robots
Kalman predict for robots missing from vision"] + game["Game, GameFrame
entities/game/game.py"] + + cams --> comb --> vd --> sw + sw -->|yes| kf --> imp + sw -->|no| imp + imp -->|yes| vanish --> game + imp -->|no| game +``` + +### One tick + +`CustomReferee` steps first (when in-process), then each side refines its frame, the replay +writer and `MatchStats` record it, and `AbstractStrategy.step` runs the strategy layer: +`Strategy.tick` (referee overrides, tactic slots), tactics, skills, then the `MotionController` +(fpp, dwa or trajsample) turns targets into one `RobotCommand` per robot for rsim, grSim or the +real robots. + +In rsim both teams run in one `StrategyRunner`: each side has its own refiners, strategy and +motion controller and steps in turn, alternating which goes first. `MatchStats` and the replay +writer follow one side's frames. The dashboard's vision stream renders the same frames. +`docs/strategy.md` covers the strategy layer; `docs/motion_planning.md` +the motion controllers. diff --git a/docs/contributing.md b/docs/contributing.md deleted file mode 100644 index 5a3d39caf..000000000 --- a/docs/contributing.md +++ /dev/null @@ -1,78 +0,0 @@ -# Contributing - -How to set up an editor, commit, and get a pull request merged. Quick start and repository -layout: the [README](../README.md). Context for coding agents: [`AGENTS.md`](../AGENTS.md). - -## pixi - -- `pixi install` installs the environment, including every package with an `__init__.py`: - run it again after adding one. -- `pixi shell` enters the environment; `pixi run ` runs a task from `pixi.toml` without - entering it (see [tools.md](tools.md#pixi-tasks)). -- For a one-off run of a module, `pixi run python -m path.to.your_file` (`/` replaced by `.`, - no `.py`). -- In VS Code, if the run button picks the wrong environment (`robosim`), choose the interpreter - by hand: `Ctrl + Shift + P` → `Select Interpreter`. - -## Code style - -- Type every variable. -- Format with Black. In VS Code, install the `Black Formatter` extension, open - `Open User Settings (JSON)` from the command palette and add to the `"[python]"` field: - - ```json - "[python]": { - "editor.defaultFormatter": "ms-python.black-formatter", - "editor.formatOnSave": true - } - ``` - -- `pixi run lint` runs the whole pre-commit stack (black, ruff, isort) on every file; - `pixi run test` runs the tests. Run both before calling a change done. - -## Commits - -1. Each feature lives on its own branch. Clear out stale branches. -2. Run `pixi run precommit-install` once, so the pre-commit checks run on every commit. -3. If a commit fails the pre-commit checks, the hook has often already fixed the files: look at - the output (`Open Git Log` in VS Code's popup), stage the changes and commit again. -4. On Windows the popup may show `bash: warning: setlocale: LC_ALL: cannot change locale - (en_US.UTF-8)`. That is not the failure, just the first warning in the output. To silence it: - - ```bash - sudo apt-get update - sudo apt-get install -y locales - sudo locale-gen en_US.UTF-8 - sudo update-locale LANG=en_US.UTF-8 - source ~/.bashrc - ``` - -## Pull requests - -A pull request into `main` needs: - -1. a `release:major`, `release:minor` or `release:patch` label: every merge to `main` releases - a new version automatically (`.github/workflows/release.yml`); -2. passing CI, tests and lint; -3. to be up to date with `main`: - - ```bash - git checkout main - git pull - git checkout - git merge main - ``` - -4. every Copilot comment reviewed (not all must be addressed: Copilot makes mistakes too); -5. an approval from an assigned reviewer. - -A strategy branch (`strategy/*`) is also checked by `tools/check_strategy_branch.py`: it must not -change the evaluation or the opponents it is scored against. - -## `CLAUDE.md` and `AGENTS.md` - -`CLAUDE.md` is a symlink to `AGENTS.md`, the single source of agent context (`AGENTS.md` is the -cross-vendor default; Claude Code reads `CLAUDE.md`). Edit `AGENTS.md`, never the symlink. -Linux, macOS and WSL check it out correctly. On native Windows, git only creates symlinks with -Developer Mode or Administrator privileges; without them `CLAUDE.md` arrives as a 9-byte text -file, fixed by `git config --global core.symlinks true && git checkout -- CLAUDE.md`. diff --git a/docs/custom_referee.md b/docs/custom_referee.md deleted file mode 100644 index 5568f2110..000000000 --- a/docs/custom_referee.md +++ /dev/null @@ -1,168 +0,0 @@ -# Custom Referee - -`CustomReferee` (`utama_core/custom_referee/`) is an in-process referee: it steps -synchronously on `GameFrame`s and produces `RefereeData`, which `RefereeOverride` -(`engine/referee_override.py`) reads each tick via `game.referee`. No network, no AutoReferee -process, no simulator-specific code — identical in RSim, grSim and Real. - -**Why not the TIGERs AutoReferee?** It is an asynchronous real-time Java/UDP process: unusable -in RSim and for faster-than-real-time RL, its thresholds are hardcoded (break on small test -fields), and strict rules ruin human-vs-robot exhibition play. Profiles solve the last two. - -## Architecture - -``` -CustomReferee.step(game_frame, t) - ├─ for rule in rules (priority order): rule.check(frame, geometry, command, placement_target) - │ first *stopping* violation wins; a non-stopping foul (SSL §8.4.2) only feeds the - │ foul counter and never suppresses a later stopping rule - └─ GameStateMachine.step(t, violation) # command, score, stage, next_command, - → RefereeData(source_identifier="custom_referee") designated_position -``` - -- 0.3s transition cooldown (`_TRANSITION_COOLDOWN`) stops one violation applying repeatedly. -- One-frame lag (the frame is from the previous step) — acceptable in every mode. -- `RefereeGeometry` is a frozen dataclass decoupled from `Field`; `StrategyRunner` overrides it - from `full_field_dims` at startup (default `STANDARD_FIELD_DIMS`). YAML never sets geometry. - In grSim/Real, `StrategyRunner` raises if the first vision geometry packet disagrees with - `full_field_dims`. - -Each tick, the rule checks decide which violation (if any) reaches the state machine, and the -state machine's output reaches the strategy through `RefereeRefiner` and `RefereeOverride`: - -![CustomReferee tick: rule checks, game state machine, and the path to the strategy and simulator](img/custom_referee/architecture.png) - -Drawn by `docs/img/custom_referee/make_architecture.py`; rerun it when a name in it changes. - -## Rules - -Built in `_build_active_rules` (`custom_referee.py`), in this priority order; defaults live in -`profiles/profile_loader.py`'s config dataclasses. - -| Rule | Active during | Notes | -|---|---|---| -| `GoalRule` | live play | Scoring team from `my_team_is_right`/`my_team_is_yellow`; 1s cooldown; `designated_position=(0,0)`. `CustomReferee.step` turns it into a goal kick (`invalid_goal`) when the scorer committed a non-stopping foul in the previous 2 s (§7). | -| `OutOfBoundsRule` | live play | Free kick to the team that didn't touch last, placed 0.25m infield; over a goal line, a corner or goal kick in the corner, or, for a ball last touched in the kicker's own half that crossed the opponent's goal line untouched, a free kick from where it was touched (aimless kick, §6.2.3, Division B; `out_of_bounds.aimless_kick`, on in both profiles). Last touch: `rules/last_touch.py`'s colour-blind `infer_last_touch_team` (both teams' contact data; closest robot only when there is no prior attribution; unresolved rather than a default colour). | -| `BallSpeedRule` | live play | Ground speed > 6.5 m/s, edge-detected; same last-touch attribution. Non-stopping (§8.4.2). | -| `DoubleTouchRule` | `NORMAL_START` after a restart | Only the restart kicker (first toucher after arming) is barred; disarms when any other robot touches. Open-play release-and-reacquire dribbling is legal. Keeps `_prev_command` across `reset()` because `reset()` runs on the very transition it must observe. | -| `DefenseAreaRule` | live play | An extra defender (> `max_defenders`) touching the ball in its own area: penalty. An attacker touching the ball while at least partly in ours: non-stopping, 2 s re-raise (§8.4.2). With `defense_area.enabled: false` (`human`, and the real examples' profiles) our robots also stop keeping out of the boxes: `StrategyRunner` sets `Field.defense_area_rules` from it, for the planners, tactics and restart positioning; a ball resting in our own box stays the keeper's. | -| `KeepOutRule` | `DIRECT_FREE_*`, `PREPARE_KICKOFF_*` | Defending team within 0.5m for 30 consecutive frames: non-stopping, 2 s re-raise, restarts the free kick's 10 s clock (§8.4.3). Not during bare `STOP` or penalties, nor once a free kick is taken (stage 3 of the state machine: the ball moved 0.05m, so it is live). | -| `PenaltyTimeLimitRule` | `NORMAL_START`/`FORCE_START` after `PREPARE_PENALTY_*` | Penalty still in play 10 s after its normal start: goal kick for the defenders (§5.3.5). | -| `NoProgressRule` | live play | Ball hasn't moved 0.05 m in 10 s: `STOP` then `FORCE_START` where it lies, moved out of the opponent's defense area if it is inside it (`legal_restart_position`, §8.1). The clock waits for the ball to be in play (a `NORMAL_START` restart: 0.05 m of movement or the 10 s auto-in-play) and is held while the ball is inside either defense area. Last in the list, so a real foul on the same tick wins. | -| `PushingRule`, `KeeperHeldBallRule`, `ExcessiveDribblingRule`, `RobotStopSpeedRule`, `CrashingRule`, `DefenseAreaStoppageRule`, `BallPlacementInterferenceRule` | see each rule file | SSL §8.3/8.4 audit (`434ab29`). Rationale per rule: `custom_referee_design_decisions.md`. | - -## State machine and auto-advance - -`GameStateMachine` starts in `HALT`. Violations move live play to `STOP` with a queued -`next_command`; then, when the profile's `auto_advance` flags allow (constants at the top of -`state_machine.py`): - -| # | Transition | Trigger | -|---|---|---| -| 1 | `STOP` → queued restart | all robots ≥0.5m from ball (15s clear timeout) | -| 2 | `PREPARE_KICKOFF_*`/`PREPARE_PENALTY_*` → `NORMAL_START` | prepare timer + kicker in position (kick-off: and every robot in its own half, waited for at most 10 s past the prepare timer, `_KICKOFF_POSITIONING_CAP_S`), held 2s | -| 3 | `DIRECT_FREE_*` → `NORMAL_START` | the free kick is taken: the ball has moved ≥0.05m from where it was when the command began (at once, from any kick during the preparation); or kicker ≤0.3m from ball, defenders ≥0.5m, held 2s | -| 4 | `BALL_PLACEMENT_*` → next command | ball ≤0.15m from target, held 2s (10s placement timeout) | -| 5 | `NORMAL_START` → `FORCE_START` | `kickoff_timeout_seconds` elapsed and ball unmoved | -| 6 | end of a half → second half, then `POST_GAME` | the half's playing time (`half_duration_seconds`) used up | - -The same transitions as a state diagram, with the command each one leaves and enters (team-specific -commands are shown as `*`; the restart team is the one named in the command): - -![Referee commands and the transitions between them, with the trigger or timer on each](img/custom_referee/state_machine.png) - -Drawn by `docs/img/custom_referee/make_state_machine.py`; rerun it when a name in it changes. - -Nothing leaves `HALT` on its own: a person or the game controller resumes it. In the sim, -`StrategyRunner` resumes after 5 s with `resume_from_halt`, which goes to `STOP` and keeps the -queued restart, so play continues into it (transition 1). A `HALT` that interrupts a restart in -progress (a kick-off being prepared, a ball being placed, a free kick) queues that restart again. -With nothing queued, the runner holds `STOP` for 4 s to clear robots, then `NORMAL_START`. - -The match clock (`stage_time_left`) counts playing time only: it runs under `NORMAL_START`, -`FORCE_START` and free kicks and is paused in `STOP`, `HALT`, kick-off and penalty preparation and -ball placement, as the rulebook's Game Stages section says. When the first half's time is up -(transition 6), play stops, the stage becomes `NORMAL_SECOND_HALF_PRE` (half-time takes 0 s), the -ball goes to the centre and the team that didn't kick off the first half (`kickoff_team`) kicks -off the second, and the teams change ends. - -**Ends.** The referee says which team defends the +x goal in `blue_team_on_positive_half`, the -game controller's field: taken from the side the teams start on, swapped at half-time. -`StrategyRunner` follows it every tick, from `CustomReferee` or the real game controller: when it -disagrees with the side a team plays on, both teams' frames, `Field`s and game history start -again on the other side (tactic memory is already cleared by the stoppage it happens in). In the -sim, every robot is also carried to the other end, turned half a turn about the centre spot, as -people do in the break: driving there crosses both defense areas. The -columnar replay stores the side on every tick (`side_is_right`; `ColumnarReplay.is_right_at`), -and replay analyses read it per frame (`frame.my_team_is_right`), never once per file. -`scenario_from_replay` turns a second-half frame half a turn, so a scenario is still played with -config_a defending the right goal. Replays written before this have one side throughout. - -When the second half's time is up, the stage becomes `POST_GAME` with a plain -`STOP` (no `designated_position`, so the sim runner doesn't restart play), and violations are -ignored from then on. `round_robin.py` ends a match there. - -`force_start_after_goal` is a legacy path (STOP → FORCE_START after `stop_duration_seconds`). -Scripts resume play with `referee.set_command(RefereeCommand.NORMAL_START, timestamp=...)`. - -## Profiles - -`CustomReferee.from_profile_name("simulation" | "human" | "/path/to.yaml", n_robots_yellow=, -n_robots_blue=)`. - -- **`simulation`** — every rule on, all auto-advances on. Simulator, AI-vs-AI, RL. -- **`human`** — every rule off, auto-advances off; an operator issues every command. Real-field - testing and human-vs-robot exhibition play. - -Give every rule an explicit `enabled:` — an omitted rule block silently falls back to enabled -with sim defaults (`load_profile()` warns listing them; this once ran 9 strict rules in a -relaxed profile). Copy `simulation.yaml`/`human.yaml` to start a new profile. - -## StrategyRunner integration - -Pass `StrategyRunner(..., referee=CustomReferee(...))`. Then the UDP `RefereeMessageReceiver` is -not started; `referee.step()` runs each tick and feeds `ref_buffer` -(→ `RefereeRefiner` → `game.referee` → `RefereeOverride`); and when a `sim_controller` exists (skipped in -Real) the ball is teleported to the restart's `designated_position`: on entry to `BALL_PLACEMENT_*` -for a restart with a spot (fouls, goals, half time; the restart itself follows), or on the edge into -a `STOP` whose next command is `FORCE_START` (no progress), which then force-starts. `StrategyRunner` only checks `isinstance(referee, CustomReferee)`, so subclasses work -unchanged. `CustomReferee.reset()` restores score/stage/command/timers for a new RL episode -(`BaseRule.reset_for_new_episode()` also clears `GoalRule`'s cooldown); call `seed_clock()` -again afterwards. - -## Restart fuzzing (`RestartFuzzingReferee`) - -`custom_referee/restart_fuzzer.py`: an opt-in subclass that injects legal restarts at -seeded-random sim times during live play (never on top of a queued restart), via the same -public `set_command` path an operator uses, so a stall it exposes is a real one. rsim is -deterministic, so this is how a round-robin explores new restart geometries. Kinds: ball -placement → `DIRECT_FREE_*` (position ≥0.25m infield, ≥0.2m from both defense areas), -`PREPARE_KICKOFF_*`, and `STOP` → `FORCE_START`. `referee.injections` records each one; with a -`MatchLog` attached, they are traced as `restart_fuzzer_injection`. Used by -`round_robin.py --fuzz-restarts SEED`. - -```python -referee = RestartFuzzingReferee.from_profile_name("simulation", seed=1, interval_s=(8.0, 20.0), - n_robots_yellow=6, n_robots_blue=6) -``` - -## Known gaps - -- **Last-touch attribution needs contact data for both teams.** Enemy `has_ball` is filled - by `RobotInfoRefiner` from sim contact physics (`data_processing/refiners/robot_info.py`). - -Resolved (kept here so nobody re-reports them): the old friendly-first, ≤0.15m proximity -last-touch heuristic and its yellow default (replaced by `infer_last_touch_team`), double touch, -ball speed, full-episode reset, teams changing ends at half-time, -`bt_nodes` → `debug_status` rename, auto-advance after goals/timeouts, keep-out during bare -`STOP`, blue-perspective goal tests, `StrategyRunner` integration tests -(`tests/strategy_runner/test_referee_rsim.py`, `test_ball_placement_rsim.py`), -`force_start_after_goal`. - -## Running - -```bash -pixi run pytest utama_core/tests/custom_referee/ --headless -pixi run python examples/demo_custom_referee.py # pygame, 6 scripted rule scenes; SPACE pause, R restart, ←/→ skip -pixi run python examples/demo_referee_gui_rsim.py # RSim + dashboard referee tab, see custom_referee_gui.md -``` diff --git a/docs/custom_referee_design_decisions.md b/docs/custom_referee_design_decisions.md deleted file mode 100644 index e1245330e..000000000 --- a/docs/custom_referee_design_decisions.md +++ /dev/null @@ -1,91 +0,0 @@ -# Custom Referee — Design Decisions - -Decisions from the audit of `CustomReferee` against the SSL rulebook. Numbers are stable. - -## Resolved - -1. **`human` profile keeps `STOP` after goals** (2026-03-31) — every auto-advance is off in - `human`, so an operator advances each stoppage. `simulation` auto-progresses. -2. **`PrepareKickoffTheirsStep` enforces own half** (2026-03-13) — after radial clearance, each - robot's x is clamped to our half. -3. **Unknown last touch no longer defaults to yellow** — `infer_last_touch_team` - (`rules/last_touch.py`) attributes colour-blind, and `OutOfBoundsRule` leaves the restart - unresolved rather than favouring a colour. -4. **`KeepOutRule`'s violation count doesn't carry over** — `CustomReferee.step()` calls - `rule.reset()` on every command transition. -5. **`BallPlacementTheirsStep` actively clears** (2026-03-13) — robots within 0.55m of the ball - are pushed radially outward, as in `DirectFreeTheirsStep`. Line-segment clearance (ball to - target) is deferred. -6. **`GoalRule` only fires in live play** — no change needed: the ball isn't in play during a - stoppage, so a goal then doesn't count. -7. **Penalty positioning, partial** (2026-03-13) — non-kickers go to the touch line - (y = ±3.0m) behind the mark. Fully off-field placement is deferred until the simulator - supports it. Penalties stay disabled in the built-in profiles. - -## Foul to restart - -Which violation gives which restart, and to whom, as the code does it (`_handle_goal` and -`_handle_foul` in `state_machine.py`). A stopping violation always goes through STOP first; when it -carries a spot, the team that gets the restart places the ball there before the restart. - -```mermaid -flowchart LR - goal["Goal
rules/goal_rule.py"] - ft["Free-kick fouls
out_of_bounds_rule.py (incl. aimless kick), double_touch_rule.py,
keeper_held_ball_rule.py, excessive_dribbling_rule.py,
pushing_rule.py (one side at fault), penalty_time_limit_rule.py"] - pen["Extra defender touches ball in own box
defense_area_rule.py"] - fs["Pushing with similar force, no progress
pushing_rule.py, no_progress_rule.py"] - stop2["2nd Defense Area Stoppage foul
defense_area_stoppage_rule.py"] - nons["Non-stopping: ball speed, crashing, keep-out, attacker in box,
robot stop speed, placement interference, 1st stoppage foul"] - o1["Kick-off for the team that conceded
BALL_PLACEMENT at centre, then PREPARE_KICKOFF"] - o2["Free kick for the other team
BALL_PLACEMENT at spot, then DIRECT_FREE
out of bounds with no known last touch: STOP only"] - o3["Penalty for the attacking team, no foul counter
BALL_PLACEMENT at penalty mark, then PREPARE_PENALTY"] - o4["FORCE_START where the ball lies
no placement, sim teleports the ball"] - o5["HALT; the interrupted restart is queued again on resume"] - o6["Foul counter and cards only
command unchanged"] - - goal -- "goal" --> o1 - goal -- "scorer fouled in last 2 s: invalid_goal" --> o2 - ft --> o2 - pen --> o3 - fs --> o4 - stop2 --> o5 - nons --> o6 -``` - -## Rulebook audit (2026-09-28, Division B) - -Checked against the [SSL rulebook](https://robocup-ssl.github.io/ssl-rules/sslrules.html). -"Sim" rows are deliberate deviations kept for the simulator; the reason is given. - -| Rule | Rulebook | Ours before | Action | -|---|---|---|---| -| Defender Too Close To Ball (§8.4.3) | 0.5 m during an opponent kick-off or free kick; non-stopping; resets the kick timer; 2 s grace per team; no automatic sanction during STOP | Stopped play and re-awarded the restart, also during penalties | Fixed: non-stopping, 2 s re-raise, off during penalties. Only the first foul of a free kick resets its clock: our cards never remove a robot, so a defender parked inside 0.5 m held a free kick for the rest of a match | -| Keeper during a penalty (§5.3.5) | Keeper on the goal line; others 1 m behind the ball; a positioning breach is a human call (§8.3.4), not Defender Too Close | `KeepOutRule` checked every defender, keeper included | Fixed by the row above: `KeepOutRule` no longer runs during penalties, so the keeper question is moot. Our non-kickers now walk round the ball to stand 1 m behind it | -| Attacker Touched Ball In Opponent Defense Area (§8.4.2) | Touching the ball while partly or fully inside; non-stopping | Presence (centre inside) stopped play with a free kick | Fixed: needs a touch, counts partial overlap (`ROBOT_RADIUS`), non-stopping, 2 s re-raise | -| Ball Speed (§8.4.2) | Over 6.5 m/s in 3D; non-stopping | Stopped play, free kick to the other team | Fixed: non-stopping. Gap: still measured on ground (x, y) speed, not 3D | -| Goal validity (§7) | No goal if the scorer committed a non-stopping foul in the last 2 s, or the ball went above 0.15 m | Any ball in the goal scored | Fixed: foul in the last 2 s turns the goal into a goal kick. Gap: ball height is not checked | -| No Progress In Game (§8.1) | 10 s without progress while both teams may play: stop, then force start | Missing | Fixed: `NoProgressRule`; STOP now continues to a queued FORCE_START once robots clear. The clock starts once the ball is in play (after a kickoff/penalty `NORMAL_START` that means 0.05 m of movement or the 10 s auto-in-play; it was firing 10 s after an unmoved restart, 226 of 422 false alarms in real matches). Not counted while the ball is inside either defense area (0 of 506 real calls there) | -| Penalty kick (§5.3.5) | Still in play after 10 s: stopped, no goal, goal kick for the defenders | The normal start turned into open play | Fixed: `PenaltyTimeLimitRule`. Not implemented: the keeper's 90° deflection and ball-moving-backwards endings | -| Ball in play after a free kick (§5.4) | In play 10 s after the free kick command | `DIRECT_FREE_*` waited for the kicker forever | Fixed: `FORCE_START` after 10 s (clock restarted once, by the first Defender Too Close foul) | -| Ball in play after a kick-off (§5.4) | In play 10 s after the kick-off | `NORMAL_START` → `FORCE_START` after 10 s if the ball hasn't moved | Already correct | -| Free-kick position (§5.3.3) | ≥ 0.2 m from all lines and ≥ 1 m from either defense area, else the closest valid spot | 0.65 m from a defense area (planner margin) | Fixed: 1 m. Sim: the spot is pushed out along x only (a square corner), not to the Euclidean closest point, and lines aren't re-clamped for in-field positions | -| Throw-in, goal kick, corner kick (§6.1.1, §6.2.1–2) | Throw-in 0.2 m in from the touch line; goal kick 1 m / 0.2 m; corner kick 0.2 m / 0.2 m, in the corner | Ball placed where it crossed, 0.25 m infield, 0.5 m on both axes near a corner, then kept 1 m off the box | Fixed: over a goal line, a corner kick 0.5 m from both lines or a goal kick 1 m from the goal line, 0.5 m from the touch line, the same spot as every other goal kick (`RefereeGeometry.goal_kick_position`; a disallowed goal or a penalty out of time put it 0.2 m from the touch line) (placing it where it crossed made a free kick 2 m in front of goal: 521 kicks, 150 goals in one round-robin). Sim: 0.5 m, not 0.2 m, from the touch line, and a throw-in stays 0.25 m in; 0.2 m from two lines at once let a drifting ball go straight back out (the corner-loop fix in `OutOfBoundsRule`) | -| Aimless kick (§6.2.3, Div B) | A ball touched by a robot that then crosses the halfway line and the opponent's goal line outside the goal, touching no other robot: free kick for the opponent from where it was kicked | Not implemented: a goal kick in the opponent's corner, so a blind clearance cost nothing (28% of goal kicks led to one at the other end within seconds, tournament_20261005_170958) | Fixed: `OutOfBoundsRule` keeps where the ball was last touched in this spell of play (`last_touch.touching_team`), and restarts from there when the touch was on the far side of the halfway line, strictly (a kick-off from the line itself is not aimless); the spot is kept 0.25 m inside the lines and 1 m off the defense areas like any free kick. `out_of_bounds.aimless_kick`, on in both profiles: we play Division B | -| Free kick stages (§5.3.3) | One free-kick command; the kick puts the ball in play | `DIRECT_FREE_*` preparation, then `NORMAL_START` once the kicker is ready | Sim: kept. The two stages give the auto-advance a readiness check with no human referee. A kick during the preparation stage ends it too: the ball moved 0.05 m from where it was when the command began, so `NORMAL_START` (live play, as after a ready kick) and `KeepOutRule` stops. Before, the referee missed the kick and charged a defender the ball rolled onto with keep_out (`free_kick_robot_drives_in_at_start`). Auto-advance profiles only (`direct_free_to_normal`); a human-run referee issues `NORMAL_START` itself | -| Ball placement (§5.2) | The team places the ball | With a simulator controller, `StrategyRunner` teleports the ball to `designated_position` on entry to `BALL_PLACEMENT_*`, then the restart itself follows (only a `STOP` queued for `FORCE_START`, no progress, force-starts) | Sim: kept, so matches don't wait on physical placement. Real mode still places | -| Multiple Defenders (§8.4.1) | A non-keeper entirely inside its own area touching the ball: penalty | More than `max_defenders` (1) with centres inside, one touching | Fixed: the goalkeeper's own touch is exempt. The keeper id comes from the referee data on the frame (`GameFrame.referee`, the team info's `goalkeeper`); with no referee data attached every touch counts. The occupancy proxy (`max_defenders`) is kept | -| Double Touch (§8.2) | Kicker may not touch again before another robot; free kick from the ball position | Same | Already correct | -| Crashing | §8.4.2 | Any contact with closing speeds within 0.3 m/s of each other was a "both at fault" crash, including robots at rest against each other (6694 fouls in 231 matches; 30 of 97 goals then voided by the goal-validity rule) | Fixed: a crash needs > 1.5 m/s projected on the line between the robots; the 0.3 m/s band then compares the robots' own speeds, as TIGERs AutoReferee's `BotCollisionDetector` does. Its 0.1 s brake lookahead is modelled too (each robot's speed less 0.4 m/s, floored at 0, where TIGERs reverses it): without it a round-robin had 226 crashes to TIGERs' 8 over the same frames | -| Pushing, Keeper Held Ball, Excessive Dribbling, Robot Stop Speed, Too Close To Opponent Defense Area, Ball Placement Interference | §8.3–8.4 | Audited in `434ab29` | Already correct; not re-checked beyond thresholds (10 s, 1 m, 1.5 m/s, 0.2 m, 0.5 m, 2 s grace) | -| Match timing (Game Stages) | Two halves of 300 s of playing time with a 300 s half-time; the timer "is paused whenever no team is allowed to manipulate the ball" (stop, halt, kick-off and penalty preparation, ball placement); each half starts with a kick-off; the coin-toss winner chooses the goal it attacks in the first half | The clock was sim time since the stage began, running through every stoppage; nothing ended a half, so it stopped at 0 at 300 s of sim time and stayed there (score-aware strategies, via `is_late_in_half`, played their last-minute mode from 240 s on) | Fixed: the clock runs only under `NORMAL_START`, `FORCE_START` and free kicks; with `auto_advance.end_of_half` (on in `simulation`, off in `human`) the first half ends in a `STOP`, the ball goes to the centre and the team that didn't kick off the first half kicks off the second; the second half ends in `POST_GAME`, after which the referee ignores violations. At half-time the teams change ends (`blue_team_on_positive_half` swaps; `StrategyRunner` follows it). Sim: half-time takes 0 s | -| Boundary Crossing (§8.4.1) | Kicking the ball over the field boundary | Not implemented | Gap: rsim has no boundary wall to kick over | - -## Open - -8. **`TeamInfo` should be a frozen dataclass.** It is mutable, and `RefereeRefiner` stores - `RefereeData` records that referenced the live objects, so a later `increment_score()` - rewrote history and made `__eq__` drop new records. Workaround (2026-04-07): - `GameStateMachine._generate_referee_data()` snapshots with `copy.copy`. Long-term: make it - `@dataclass(frozen=True)` and replace mutations (`increment_score()`, - `parse_referee_packet()`, ...) with `dataclasses.replace()`, including the network referee - path. Deferred because it touches that path. diff --git a/docs/custom_referee_gui.md b/docs/custom_referee_gui.md deleted file mode 100644 index 52ae6b854..000000000 --- a/docs/custom_referee_gui.md +++ /dev/null @@ -1,85 +0,0 @@ -# Custom Referee Operator GUI - -The browser operator panel for `CustomReferee` is the dashboard's referee tab -(`utama_core/dashboard/views/referee.py`). Attach it with: - -```python -server = attach_dashboard() # utama_core.dashboard -referee_view.attach(server, referee, profile) # utama_core.dashboard.views.referee -``` - -`examples/demo_referee_gui_rsim.py` does this with RSim, the `human` profile and -`tiki_taka_plus` (constants `PROFILE`, `N_ROBOTS`, `MY_TEAM_IS_YELLOW`, `MY_TEAM_IS_RIGHT` at -the top of the file): - -```bash -pixi run python examples/demo_referee_gui_rsim.py # then open http://localhost:8080 -``` - -The page shows the score, current/next command, stage and time left, `designated_position`, the -field, the active profile and an event log; a button issues each command. - -## Field check (camera runs) - -With vision from a camera (real robots or grSim) the Live tab also shows the field check -(`utama_core/run/field_check.py`), one row per question, red / amber / green: - -| Row | Fails (red) when | Warns (amber) when | -|---|---|---| -| Camera | no vision packet for 0.5 s | | -| Field size | ssl-vision's geometry differs from `full_field_dims` | no geometry packet yet | -| ` ` (each robot we drive) | never seen, lost by vision 0.5 s, or more than 0.3 m outside `field_bounds` | | -| ` radio` (real only) | it answered on the radio, then stopped | it has not answered yet (the firmware may send no feedback) | -| ` ` (any other) | | seen inside `field_bounds` but not configured: our planners cannot see it, often a wrong ID | -| Ball | | not seen, or outside `field_bounds` | - -Before it gets that far, the runner keeps our robots inside `field_bounds` on camera runs -(`utama_core/run/field_fence.py`): each robot's speed towards an edge is capped to what it can -stop from before the line, whatever tactic sent the command, so a robot chasing a ball out of the -camera's area stops at the line. The planners' walls at `field_bounds` are only obstacles to plan -around, and did not stop it (0.5–0.9 m out in grSim before the fence). - -Only the red and amber rows are listed; the green ones fold into an "N ok" line that opens on -click. On real robots any red row forces `HALT`, whatever the command and whether or not the page is -open; the red banner says why. Pressing Force Start while a row is red halts again at once, so -the check is also the pre-start gate. The field is drawn as ssl-vision sees it (+x to the right), -with everything outside `field_bounds` dimmed, so a half-field test shows which half the runner -expects. Space halts; nothing on the keyboard starts the robots. The Kickoff and Free Kick -buttons are hidden when the profile has no rule that sets up a restart (goal detection only). - -## Strategy panel - -A script can let the page change what each side plays, or restart it, without restarting the -run (`utama_core/dashboard/views/strategy.py`): - -```python -strategy_view.attach(server, runner, - choices={"my": {"lead": make_lead, "press": make_press}}, # name -> builds a fresh AbstractStrategy - running={"my": "lead"}) -``` - -The Live tab then lists the choices per side with a Run button; Run on the one running restarts -it. `StrategyRunner.replace_strategy` takes the new strategy at the next tick and only while -halted, so the page refuses otherwise. `examples/shooting_drill.py` offers its attacker -and defender tactics this way. - -## Commands and what robots do - -| Button | Command | Use | Robots | -|---|---|---|---| -| Halt | `HALT` | Emergency / unsafe | Zero velocity | -| Stop | `STOP` | Between incidents, pre-match | ≤1.5 m/s, stay ≥0.5m from the ball | -| Normal Start | `NORMAL_START` | Restart formation is in position | Live play | -| Force Start | `FORCE_START` | Stalled play | Live play from the ball's current position (a tactic barrier reset, see `tactic_model_design_decisions.md` §4) | -| Kickoff Y/B | `PREPARE_KICKOFF_*` | Half start, after a goal | Kicker to centre, others to own half | -| Free Kick Y/B | `DIRECT_FREE_*` | Foul by the other team | Kicker to ball, opponents ≥0.5m | -| Penalty Y/B *(advanced)* | `PREPARE_PENALTY_*` | Manual override | Kicker at mark, others behind the line | -| Ball Placement Y/B *(advanced)* | `BALL_PLACEMENT_*` | Manual placement | One robot carries ball to `designated_position` | - -Typical sequences: `Halt → Stop → Kickoff Yellow → Normal Start` to start a half; -`Stop → Free Kick → Normal Start` for a manual free kick. With `human`, nothing auto-advances — -after a goal the referee stays in `STOP` until the operator acts. - -For a physical field, keep every `auto_advance` flag false so robots never start moving until -the operator presses a button. Profile keys, auto-advance triggers and making a custom profile: -`custom_referee.md`. diff --git a/docs/field_log_replay.md b/docs/field_log_replay.md deleted file mode 100644 index 6487f10e7..000000000 --- a/docs/field_log_replay.md +++ /dev/null @@ -1,144 +0,0 @@ -# Field logs: finding a moment and replaying it offline (design) - -Status: design, 2026-10-28. Nothing here is built yet except what "Today" lists. - -## Why - -On the 2026-10-27 field day every bug was found the same way: a symptom someone saw ("it drives -sideways and back", "blue misses passes", "placement throws the ball away"), then a throwaway -script to find the moment in the log, then another to rebuild what the robot saw and decided at -that moment. The second step found every cause. Running the recorded camera packets through the -same refiners and tactic offline showed blue's receive point clamped to x 0.43, and the -attacker's hold point at (0.43, +0.07) wherever the ball was. Each script took 10-30 minutes -to write, and all of them were lost when `/tmp` was cleared. This doc designs one tool for the -whole loop, so a field symptom becomes a cause, and then a regression test, in minutes. - -## Today - -- Every real run records `replays/field/
--opponent [--dump-ticks PATH]` — one - instrumented matchup. - -rsim is deterministic: re-running an identical pair gives an identical result. Variance comes -only from `--both-sides`, side/kickoff cells, or `--fuzz-restarts`. - -**In the round-robin**, in order of the 2026-10-10 standings (below). A round-robin with no -strategies named plays these. - -| Strategy | Description | -|---|---| -| `split_shape` | `LeadAndSupportTactic` + `ShadowAndMarkTactic`, split by possession edge. | -| `counter_flow` | Give-and-go attack, press on the ball, `BlockShapeTactic` screen; 3/2 with possession hysteresis. | -| `score_aware_counter_flow` | `counter_flow` plus a late-half scoreline shift (protect a lead / chase). | -| `press_and_pass` | `GiveAndGoTactic` + `PressAndContainTactic`, possession-edge split. | -| `clear_press_plus` | `clear_danger` plus `tiki_taka_plus`'s final-third overload. | -| `high_press` | Same pair as `press_and_pass`, fixed 80/20 attack-heavy split ignoring possession. | -| `tiki_taka_plus` | `tiki_taka`, handing off to `DecoyOverloadTactic`'s duet in the final third. | -| `give_and_go_solo` | Whole pool runs `GiveAndGoTactic`, no defense slot. | -| `overload_press` | 4-robot overload/switch attack + 1 block, built to outnumber tiki_taka's shadow line. | -| `press_trigger_flow` | `counter_flow`, but an all-in press when the ball is lost in our own third. | -| `decoy_and_overload` | `DecoyOverloadTactic` (min 2) + `ShadowAndMarkTactic`, fixed 50/50. | -| `clear_danger` | `counter_flow` postures plus an own-third `ClearBallTactic` danger-clearance valve. | - -**Retired** (2026-10-10): the bottom ten of the 2026-10-05 round-robin. Left out of a round-robin -unless named (`RETIRED` in `tools/evaluation/round_robin.py`). Their code stays: -kept strategies and tests build on some of them. A retired strategy comes back by being judged -with `evaluate.py` against the pool. - -| Strategy | Description | -|---|---| -| `tiki_taka` | 3 give-and-go + 2 shadow-and-mark with the ball; 3 press + 2 shadow without. | -| `counter_press` | Full press on loss, low block otherwise, 4-up switch-of-play on winning the ball. | -| `high_line_zone` | Zone screen (`BlockShapeTactic`) + switch attack, built to deny tiki_taka 1v1s. | -| `three_slot` | Three concurrent slots: press + mark + give-and-go. Exercises N>2 scheduling. | -| `switch_of_play` | `SwitchOfPlayTactic` (min 3) + `DefenseTactic`, fixed 50/50. | -| `low_block` | `PassAndShootTactic` (min 2) + `DefenseTactic`, fixed 20/80 defense-heavy split. | -| `zone_fluid` | Man-shape defense; give-and-go through the middle, decoy/overload in the final third. | -| `score_aware_zone_flow` | `zone_fluid` plus a late-half scoreline shift (protect a lead / chase). | -| `overload_flow` | `zone_fluid`; give-and-go grows 3→4 only after the possession edge holds ~1.5s. | -| `shadow_switch` | `SwitchOfPlayTactic` relay attack + `ShadowAndMarkTactic` defense, 3/2. | - -`default`: Everyone runs `PassAndShootTactic`; only 2 robots are ever commanded (see bugs). Excluded from round-robin discovery. - -Strategies are judged with `evaluate.py` against the reference pool `pool_v1` -(`docs/STRATEGY_DEVELOPMENT.md`, "Evaluating a strategy"). The round-robin results below are a -snapshot of the catalog, not the verdict on any one strategy. - -## Latest results - -**Round-robin** (2026-10-17, sim-realism-20261016 at 423f63a0, the 12 strategies above, 66 -matches, two halves of 300 s of playing time, seeded sim noise `v3_seed2`, -`replays/tournament_20261017_151052/summary.json`). Points are 3 a win, 1 a draw; 14 of 66 -matches were draws. 4 matches stalled (three committed robots frozen about 10 s, and one kick-off -that waited the referee's 15 s cap, fixed after this run in 1731e904); 97% of 3232 restarts -reached NORMAL_START. - -Against the 2026-10-10 run: rsim is our fork with the v3 sim noise (latency, motion limits, ball -friction, kick direction), and restarts, ball placement and the carry limit were fixed, so goals -fell from 7.1 a match to 4.0 and the results are not comparable with earlier runs. -`split_shape` is still first, unbeaten; `counter_flow`, second before, is eleventh. -What each strategy does well and badly in this run, in figures: [`signal_report.md`](signal_report.md). - -| Strategy | W-D-L | GF-GA | Points per match | -|---|---|---|---| -| `split_shape` | 10-1-0 | 66-14 | 2.82 | -| `clear_press_plus` | 5-5-1 | 14-9 | 1.82 | -| `overload_press` | 6-2-3 | 22-18 | 1.82 | -| `clear_danger` | 5-2-4 | 20-24 | 1.55 | -| `tiki_taka_plus` | 5-1-5 | 23-21 | 1.45 | -| `high_press` | 4-3-4 | 24-27 | 1.36 | -| `press_trigger_flow` | 4-1-6 | 13-19 | 1.18 | -| `give_and_go_solo` | 3-3-5 | 20-30 | 1.09 | -| `press_and_pass` | 3-3-5 | 14-28 | 1.09 | -| `decoy_and_overload` | 3-2-6 | 16-27 | 1.00 | -| `counter_flow` | 2-4-5 | 17-21 | 0.91 | -| `score_aware_counter_flow` | 2-1-8 | 16-27 | 0.64 | - -## Known open bugs - -Writeups of bugs since fixed were removed from this file; code comments that cite "Known open -bugs" refer to them — read them with `git log -p -- docs/strategies.md`. Still open: - -- **`default` commands only 2 of 5 robots** (robots 3-5 idle) and draws 0-0 with - `low_block`; see `docs/investigation_default_vs_lowblock_stalemate.md`. `default` is the - kernel's smoke-test scaffold and `low_block` is retired, so not worth fixing for its own sake. - -## Updating this file - -- New factory → add a row with a one-line description to the round-robin table. -- New tournament → replace the matching results table (one table per tournament type) and - record the run directory; don't append narrative. Findings belong in commit messages. -- Strategy abandoned after losing → add it to `RETIRED` and move its row to the retired table. -- Only single matches (`--pair`), no round-robin → put them in the pull request, not here: this - file holds round-robin and full-match results only. diff --git a/docs/STRATEGY_DEVELOPMENT.md b/docs/strategy.md similarity index 57% rename from docs/STRATEGY_DEVELOPMENT.md rename to docs/strategy.md index df41ca6bf..5d3ab8d01 100644 --- a/docs/STRATEGY_DEVELOPMENT.md +++ b/docs/strategy.md @@ -1,12 +1,14 @@ # Strategy development +New to the repo? Start with [first_strategy.md](../tutorials/first_strategy.md); this page is the reference. + Context for work under `utama_core/engine/`, `utama_core/tactics/`, `utama_core/skills/`, -`utama_core/strategy/`, or `tools/evaluation/`/`docs/strategies.md`. Assumes you've read the -root `AGENTS.md`. Design rationale and rejected alternatives: `docs/tactic_model_design_decisions.md` +`utama_core/strategy/`, or `tools/evaluation/`. Assumes you've read the +root `AGENTS.md`. Design rationale and rejected alternatives: `docs/strategy_design.md` — read it before proposing a change to the kernel's shape. -`engine/` is the scheduler/protocol infra; `strategy/` holds the `build_*_kernel_strategy` -factories (one module per strategy, `kernel_strategy.py` re-exporting them), where day-to-day +`engine/` is the scheduler/protocol infra; `strategy/` holds the strategies (one module +each, named after the strategy, with one `build`), where day-to-day strategy edits land. (`engine/` was renamed from `kernel/` so it can't be confused with "kernel strategy", the model's own term.) @@ -54,9 +56,9 @@ sequenceDiagram participant AS as AbstractStrategy
engine/abstract_strategy.py participant S as Strategy
engine/strategy.py participant RO as RefereeOverride
engine/referee_override.py - participant P as Partitioner
e.g. strategy/split_shape.py + participant P as Partitioner
e.g. strategy/pendulum.py participant T as Tactic
tactics/*.py - participant SK as Skills
skills/src/ + participant SK as Skills
skills/ participant RC as robot controller SR->>AS: step() (side.strategy, after the frame is refined) @@ -89,13 +91,13 @@ sequenceDiagram ## Referee handling -`CustomReferee` (`utama_core/custom_referee/`) runs in-process and identically across +`CustomReferee` (`utama_core/referee/`) runs in-process and identically across rsim/grsim/real. During a restart, `RefereeOverride` (`engine/referee_override.py`) takes over every outfield robot *before* any `Tactic` ticks, reusing the `*Step` classes in -`custom_referee/actions.py`. Strategies can override a restart formation via -`Strategy(referee_overrides=...)`. See `docs/custom_referee.md`. +`referee/actions.py`. Strategies can override a restart formation via +`Strategy(referee_overrides=...)`. See `docs/referee.md`. -To see where the override sends every robot for a restart, run `tools/restart_picture.py` +To see where the override sends every robot for a restart, run `tools/debug/restart_picture.py` (`REPLAY.npz --t S`, or `--all-restarts` for one small panel per restart command in the replay). It records each commanded target without changing the engine, and flags a target inside the 0.8 m keep-out or a defence area it must avoid. Shown below: one match's restarts from our side (top) and from the other @@ -119,7 +121,7 @@ flowchart TD ko_t["PREPARE_KICKOFF (theirs)
PrepareKickoffTheirsStep: non-keepers to own half,
outside the centre circle"] pe_o["PREPARE_PENALTY (ours)
PreparePenaltyOursStep: kicker to the penalty mark,
others on a line behind it"] pe_t["PREPARE_PENALTY (theirs)
PreparePenaltyTheirsStep: keeper to our goal line centre,
others behind the penalty mark"] - fk_o["DIRECT_FREE or INDIRECT_FREE (ours)
DirectFreeOursStep: nearest robot becomes kicker,
others stop"] + fk_o["DIRECT_FREE or INDIRECT_FREE (ours)
DirectFreeOursStep: nearest robot takes the kick,
others stop"] fk_t["DIRECT_FREE or INDIRECT_FREE (theirs)
DirectFreeTheirsStep: clear robots out of keep-out"] bp_o["BALL_PLACEMENT (ours)
BallPlacementOursStep: closest robot carries ball to the spot,
others clear"] bp_t["BALL_PLACEMENT (theirs)
BallPlacementTheirsStep: clear away from ball and target"] @@ -140,6 +142,16 @@ flowchart TD sel --> resume ``` +## After the tactics: team-level ball handling + +Two passes run in live play on the commands every tactic returned, so they apply to all strategies. +`engine/ball_release.py` kicks a ball that cannot be held longer (carry limit, or pinned by an enemy). +`engine/ball_roles.py` then settles who deals with the ball: the first robot a free ball rolls to +meets it, a robot about to be passed to stops and faces the ball (`ctx.expected_receivers`), and of +the robots driving at the ball (`ctx.ball_claims`, set by `go_to_ball` and pressers) one carries on +and the rest cover it. A tactic's command for a robot can be replaced here: their trace is `ball[id]` +or `release[id]`. + ## Writing a Tactic Lessons from bugs that recurred (mostly `SwitchOfPlayTactic`, `tactics/switch_of_play.py`): @@ -147,7 +159,7 @@ Lessons from bugs that recurred (mostly `SwitchOfPlayTactic`, `tactics/switch_of - **`go_to_point()` always faces the ball.** If orientation matters while stationary (facing a pass target), use `move()` with `target_oren`. Check every `go_to_point(` call site — fixing one doesn't fix the pattern. -- **`intercept_point()` (`shared/pass_and_score_geometry.py`) projects along the passer's +- **`intercept_point()` (`geometry/pass_and_score_geometry.py`) projects along the passer's current orientation,** not toward the receiver. A mis-facing passer sends the receiver to a nonsense point; it fails quietly and looks like a vague stall. - **Every path that sets `is_committed()` True needs a path back to False** — success, failure @@ -160,11 +172,13 @@ Lessons from bugs that recurred (mostly `SwitchOfPlayTactic`, `tactics/switch_of ## Writing and evaluating a strategy +The steps from branch to pull request, as a checklist: the `change-strategy` skill (`.agents/skills/`). + A strategy is a combination of existing tactics plus a partitioner that decides how many robots each gets. Most new strategies need no new tactic. When one does, add it as a new module in `tactics/` (on a strategy branch, never by changing an existing tactic: see below). -How a strategy composes tactics, using `build_split_shape_kernel_strategy`: two tactic slots and +How a strategy composes tactics, using `pendulum`: two tactic slots and one hand-written partitioner that switches on which side has the ball. ```mermaid @@ -175,7 +189,7 @@ flowchart TD free["free pool = outfield robots not pinned"] avail{"both slots available?
(not pinned, applicable)"} only["the one available slot
takes every free robot"] - subgraph picker["_possession_split_picker
strategy/split_shape.py"] + subgraph picker["_possession_split_picker
strategy/pendulum.py"] order["carrier_first(game, free)
strategy/pickers.py: ball carrier first"] edge{"friendly closer to the ball
than the enemy?"} hi["attack = (n+1)//2 + 1"] @@ -200,129 +214,145 @@ flowchart TD split --> validate ``` -**Writing one.** Add `strategy/.py` with `build__kernel_strategy(outfield_robot_ids)`, -returning a `Strategy(tactics={...}, partitioner=...)`, and the pickers only it uses; then import -the factory in `strategy/kernel_strategy.py`. Every `build_*_kernel_strategy` that module -re-exports is discovered by name (`match`), so it joins round-robins and `evaluate.py` as -`` (a test fails if a factory is defined but not re-exported). Reuse the shared partitioner +**Writing one.** Add `strategy/.py` with `build(outfield_robot_ids, motion_controller)`, +returning a `Strategy(tactics={...}, partitioner=...)`, and the pickers only it uses. The file is +all it takes: `strategy/catalog.py` finds it, so it joins `evaluate.py` as `` +(a reserve player until it is added to the core). Reuse the shared partitioner pieces in `strategy/pickers.py` rather than re-deriving them: - `friendly_closer_to_ball(game)` — the possession edge. True/False is a clear edge; None is a near-tie or unreadable state, where a sticky picker keeps its previous split. - `carrier_first(game, free)` / `clearer_first(game, ordered)` — robot order for a slot that must take the ball: the carrier (or the kicker at a still ball) first, else the nearest. -- `fixed_ratio_picker` (in `pickers.py`), `_possession_split_picker` (in `split_shape.py`) — the +- `fixed_ratio_picker` (in `pickers.py`), `_possession_split_picker` (in `pendulum.py`) — the two common split shapes. `tests/engine/test_all_strategy_configs.py` picks it up the same way and runs it through the kernel invariants. Give its partitioner pure-function tests in `tests/strategy/test_.py` (a -`Game` built by hand, no rsim), and add a row to `docs/strategies.md`'s round-robin table. +`Game` built by hand, no rsim), and give the module a one-line docstring: the dashboard shows it. **Evaluating one,** cheapest first; stop as soon as a step fails: 1. **Tests:** its own, `test_all_strategy_configs.py`, then the full suite `--headless`. -2. **One saved match** against a few opponents: `round_robin.py --pair `. - Saved, so stalls are recorded (`--no-save` cannot see them). A stall is a bug to fix - before anything else. -3. **Matches:** `tools/evaluation/evaluate.py ` (see [Evaluating a strategy](#evaluating-a-strategy)): - is it better than the pool's champion, worse, or not clearly either? Several candidates go in - one call. A strict round-robin (`round_robin.py --strict --reuse`) is the check for stalls - and the occasional health check of the whole catalog, no longer the way to judge one change. +2. **Matches:** `tools/evaluation/evaluate.py ` (see [Evaluating a strategy](#evaluating-a-strategy)): + is it better than the champion at the last release, dropped (not promising), or not clearly either? Several + candidates go in one call. Its round 1 is a round robin, so the same run reports stalls and + signals; a stall is a bug to fix before anything else. A change to `tactics/`, `skills/` or `pickers.py` is the other way round: reuse saves little, because most strategies import the changed code and their matches all rerun. Batch such -changes and run one round-robin over the batch. - -**`--reuse`** takes a match's result from -`replays/match_cache/` when nothing it runs has changed since it was stored, so after a change -to one strategy only its matches play, one per other config (21 of 231 with 22 configs). What counts as -"runs" is `utama_core/replay/fingerprint.py`'s: the factory's own module, every module that -imports (`strategy/pickers.py` and the tactics among them, whole files), and the shared code and -environment (planner, referee, runner, simulator build, packages, CPU). Editing `pickers.py` -reruns every config that imports it, which is most of them; changing shared code reruns -everything, correctly. Each run replays 5% of what it would reuse (`--spot-check`) and compares; a -difference evicts the records, says the fingerprint missed a dependency, and fails the run. -Use `--reuse` on every run. - -**What counts as better.** The verdict is `evaluate.py`'s: goal difference per match, paired against the champion of the reference pool. A round-robin's W-D-L is a diagnostic. -Everything in [Reading a tournament run](#reading-a-tournament-run) explains a result; none of -it is a target. Don't tune a threshold until results move: a change needs a reason in game -terms. Two round-robins of near-identical code agree -at Spearman +0.97, but that is not a ceiling: rsim is deterministic, so they agree largely -because the code is near-identical. +changes and run one evaluation over the batch. + +**Reuse is automatic.** A match the match results store holds (`replays/match_results/`, +`replay/match_results.py`) is taken from it, not played; there is no flag. A match's fixture is its +environment (the shared code and machine, the match length, the sim noise without its +seed), both players' fingerprints, their sides and the noise seed. So after a +change to one strategy only its matches play. What counts as "runs" is +`utama_core/replay/fingerprint.py`'s: the strategy's own module, every module that imports +(`strategy/pickers.py`, the tactics, the planner and its compiled library among them, whole files), +and the shared code and environment (referee, runner, simulator build, packages, CPU). Editing +`pickers.py` reruns every strategy that imports it, which is most of them; changing shared code reruns +everything, correctly. The store does not check itself: if a fingerprint misses a dependency, delete +the store, or one environment's folder inside it, to play everything again. Each round prints +"N matches, X from the match results store, M to play" first; read it. + +**What counts as better.** The verdict is `evaluate.py`'s: goal difference per match, paired against +the champion at the last release. W-D-L and every other signal are diagnostics. +Everything in [Reading a round](#reading-a-round) explains a result; none of +it is a target. Don't tune a threshold until results move: a change needs a reason in game terms. ### Evaluating a strategy -`tools/evaluation/evaluate.py CANDIDATE [CANDIDATE ...]` answers one question per candidate: is -it stronger than the champion of a fixed reference pool, in goals, under the realistic sim noise? - -The flowchart contrasts it with the round-robin, which answers a different question. +`tools/evaluation/evaluate.py [CANDIDATE ...]` is the one tool for matches. With no candidate it +plays one round, a round robin: the health check of the catalog (stalls, fouls, every signal). With +candidates it also answers, per candidate: is it stronger than the champion at the last release, in +goals, under the realistic sim noise? ```mermaid flowchart TD - subgraph rr["round_robin.py: is the whole catalog healthy?"] - r1["Every build_*_kernel_strategy config plays
every other once (one full match per pair)"] - r2["Stall and error check
--strict fails on a stall"] - r3["Standings in summary.json
not a verdict on any one strategy"] - r1 --> r2 --> r3 - end - - subgraph ev["evaluate.py: is this candidate stronger than the champion?"] - e1["Pool pool_v1.json: champion, six opponents,
three held-out opponents, sim noise"] - e2["Round k, noise seed k
candidate and champion each play every opponent"] - e7["Every match appended to the ledger
replays/eval/ledger.jsonl"] - e3{"P(candidate stronger), paired
with the champion's results"} - e4["better: P >= 0.99
then --held-out before promoting"] - e5["worse: P <= 0.2
drop it"] - e6["undecided after 6 rounds
drop it"] - e1 --> e2 --> e3 - e2 -.-> e7 - e3 -- "P >= 0.99" --> e4 - e3 -- "P <= 0.2" --> e5 - e3 -- "neither, rounds left" --> e2 - e3 -- "neither, no rounds left" --> e6 - end + p["Players: core (reference/players.json); --all: every strategy
+ the reference: the champion at the last release, a .strategy file"] + r1["One round, one noise seed: every pair once
(only open candidates stay after round 1)"] + st0{"in the match results?"} + st["Every match stored in the match results
replays/match_results/"] + d{"mean paired diff against the reference,
this stage's seeds only"} + w["dropped: mean diff <= 0 from a stage's round 2
not promising"] + c["screen passed (seeds 1-6)
go on to seeds 101-106"] + t{"confirm stage done:
paired t-test p <= 0.05?"} + b["better
promote by hand in players.json"] + u["undecided
drop it"] + p --> r1 --> st0 + st0 -- "yes: reuse" --> d + st0 -- "no: play, then store" --> st --> d + d -- "<= 0" --> w + d -- "> 0, stage not done" --> r1 + d -- "> 0, screen done" --> c --> r1 + d -- "> 0, confirm done" --> t + t -- yes --> b + t -- no --> u ``` -- **The pool** (`tools/evaluation/pools/pool_v1.json`): a champion, six opponents chosen for - spread of styles, three held-out opponents and the sim noise. It changes only on purpose, as - a new version, so a result means the same thing next month; it does not follow the latest - standings. -- **Rounds.** In round k every candidate plays each opponent and the champion once, and the - champion plays each opponent, all with noise seed k and the side under test in the same colour - (the noise is drawn per colour and robot, so one seed can favour a colour by half a goal). A - candidate and the champion are compared on the same opponents under the same noise. -- **The decision** (`ratings.paired_difference`): the candidate's goal difference against each - opponent minus the champion's, same opponent, seed and colour, from rounds 1..k, plus their - head-to-head matches. Paired results face the same noise, so much of it cancels: all of it - for identical code (a byte copy of the champion gets 24 diffs of exactly 0 and stays - undecided), little for unrelated strategies. P(candidate stronger) >= 0.99 is **better**, - <= 0.2 **worse**, and after 6 rounds it is **undecided**: not clearly better, so drop it. - Simulated (match noise SD 1.9 goals): two equal strategies are called better at most 3% of the - time. An unrelated strategy one goal per match worse is dropped after ~2 rounds (~14 - matches), one goal better found 61% of the time, half a goal 20%. A small edit of the champion - (paired results correlated ~0.9): one goal better found every time in ~3 rounds, half a goal - 55%. Small gains of unrelated strategies are below what matches resolve at this cost. -- **Ratings** (`analysis/ratings.py`): a strength per strategy in goals per match with its SD, - fitted on every match in the ledger; printed at the end, and the match noise for the decision. -- **The ledger** (`replays/eval/ledger.jsonl`, `replay/eval_ledger.py`): one line per match from - evaluate.py and round-robins, keyed by the code that played it. A match is never played twice; - the champion's matches are played once per seed and reused by every candidate, and editing a - strategy starts its record afresh. Replays are not kept, except during a `--explain` run (rerun one with `round_robin.py --pair - A B --sim-noise` and the pool's noise with that seed). -- **Before promoting** a candidate called better, run `evaluate.py --held-out`: it must not - be clearly worse against opponents never used for selection. Then edit the pool's champion by - hand. Check its per-opponent table: a candidate far better against one opponent and worse - against the rest is a matchup, not a better strategy. -- **Pictures** (`evaluate.py --explain`, `tools/evaluation/explain.py`): for each candidate, +- **Players** (`tools/evaluation/reference/players.json`): the champion and the core strategies, + which play every round. Every other strategy in the catalog is reserve and plays only with `--all`, + an occasional run for a wider field (for example before a release). The simulated world and robots are `world.json` and `robots.json` in the same + folder (`sim_settings.py` loads them). +- **The reference** is the champion as it was at the latest release tag (`--at REF` for another + commit), played from a `.strategy` file built once into `replays/eval/frozen/`. A change to shared + code (skills, tactics, motion, engine) therefore moves the candidates and the working-tree + strategies, never the reference. A bundled match equals the same match run normally, frame for frame; the + referee and simulator are today's for both sides. An older commit may know the champion by its old + name (`catalog.RENAMED`); that is found. +- **Rounds.** Every round is the same round robin, every pair of players once, under noise seed k; + after round 1 only the candidates not yet decided stay. The match results store makes it cheap: a match + whose code is unchanged is never played again, so a run plays only the matches of edited strategies + (and of a seed never played before). The candidate (then the reference) is config_a under odd seeds + and config_b in even ones, so both meet each opponent in the same colour under the same noise (the + noise is drawn per colour and robot, so one seed can favour a colour by half a goal). +- **The decision** (`analysis/ratings.py`) is on diffs: the candidate's goal difference against an + opponent minus the reference's, same opponent, seed and colour. Paired results face the same noise, + so much of it cancels: all of it for identical code, little for unrelated strategies. Head-to-head + matches are reported, not counted. Two stages of ROUNDS (6) rounds each: + - **screen**, seeds 1-6: from round 2, a mean diff <= 0 is **dropped**. It never accepts; a + candidate that survives goes straight on to + - **confirm**, fresh seeds 101-106, on their diffs alone: the same drop rule, then **better** if a + one-sided paired t-test gives p <= ALPHA (0.05), else **undecided** (not clearly better: drop it). + + Why so many matches: one match's goal difference varies by about 3 goals between seeds (measured + 2026-10-12), so a 1-goal edge needs about 36 matches per pairing to show; paired diffs cancel much + of that. + Only fresh seeds accept, so a candidate chosen because it looked good on seeds 1-6, or fitted to + them, is not accepted on that luck. "Dropped" means not promising, not worse: an equal strategy is + dropped at the first look about half the time. ROUNDS and ALPHA are provisional: ROUNDS is to be set + from the measured spread of real diffs (enough rounds to find a 0.3-goal improvement 80% of the + time), ALPHA from how often edits turn out better. How often the rule is right, per effect size and + correlation: `tools/evaluation/verdict_sim.py` (simulated results, no matches; its test pins that an + equal strategy is called better at most ALPHA of the time). Check the per-opponent table: a candidate + far better against one opponent and worse against the rest is a matchup, not a better strategy. +- **Stalls** are reported, never judged on. The watchdog watches config_a only + (`run/strategy_runner.py` records stats for config_a), so the report says in how many matches each + strategy was checked; "unknown" means none was. +- **Output.** `replays/eval_/report.json` (verdicts, per-opponent tables, round 1's signals) and + per round `round_/`: each played match's replay, intention log and stats as `
_vs_.*`, + `summary.json` and `ball_losses.md`, the layout `tools/debug/find_bugs.py`, `tools/debug/pitch_maps.py` and `goal_sources` + read. A match taken from the store is linked in (symlinks) from the run that played it, so a + round folder holds all of its matches; one played before 2026-11-12, or whose run was deleted, has none. +- **Two traps in a "better".** The reference's results on every seed are stored and reused, so + candidates that reach the confirm stage share its luck on seeds 101-106: in a long search, count how + many candidates were confirmed for each "better" (few are; most are dropped in the screen). And the + reference carries the release's shared code (tactics, skills, planner, engine), so + a "better" can come from shared code changed since: the report adds the candidate against today's + champion, same opponents, seeds and colours, no extra matches, where the shared code is the same on + both sides. `evaluate.py ` measures shared-code changes alone. +- **Seeing it:** `pixi run dashboard`, Strategies tab: each strategy's verdicts, maps, signals beside + the average, and its matches to replay; Evaluation runs lists every run. +- **Promoting** is a decision, not a side effect: change the champion line in `reference/players.json` + in a pull request; the next release makes it the reference. +- **Pictures** (`tools/evaluation/explain.py RUN_DIR CANDIDATE CHAMPION --out DIR`): for a candidate, where both strategies' robots stand with and without the ball, their shots for and against, - their fouls by rule, and a `summary.json` of the numbers behind them, written to - `replays/eval/explain/_/`. The run's matches are kept until they are written. They - explain a verdict and never make one: the verdict is still goals, and a picture is not a ranking. - Matches reused from the ledger have no replay in the run, so the pictures cover only what was - played; the paired goal difference in `summary.json` is only as complete as that. Example, from a - round-robin (`explain.py replays/tournament_ split_shape clear_press_plus --out ...`): + their fouls by rule, and a `summary.json` of the numbers behind them, written to DIR. They explain a verdict and never make one. Example + (`explain.py replays/eval_/round_1 pendulum breakwater --out ...`): ![Where two strategies' robots stand, with and without the ball](img/explain/positions.png) -- **Cost.** ~45 min of laptop per 66 matches on 8 workers. A clearly worse candidate costs ~14 - matches (~10 min), a close one up to 42. +- **Cost.** A round is 15 matches (five core and the reference, plus one per extra candidate pair) of + up to 1200 s, roughly 20 min on 12 workers, when nothing is stored. Once stored, editing one strategy + replays only its 5 matches per round; a change to shared code replays everything. `--all` makes a + round 66 matches. A clearly worse candidate is dropped after 1-2 rounds. ### Strategy branches @@ -330,32 +360,29 @@ A new or changed strategy, whether a person or an agent writes it, goes on its o reaches `main` by pull request: 1. Branch from `main` as `strategy/`. In a git worktree, symlink `.pixi` and `replays` - from the main checkout first: pixi needs the environment, and `--reuse` needs - `replays/match_cache/`, or every match plays again. + from the main checkout first: pixi needs the environment, and the match results store + (`replays/match_results/`) is what keeps a match from playing again. 2. Change only `utama_core/strategy/`, `utama_core/tactics/` (new modules only), - `utama_core/tests/strategy/` (tests for your strategy and any tactic you add) and - `docs/strategies.md`. CI fails a `strategy/*` pull request that changes anything else - (`tools/check_strategy_branch.py`, run from `main`'s copy). Anything else it needs, such as a + and `utama_core/tests/strategy/` (tests for your strategy and any tactic you add). CI fails a `strategy/*` pull request that changes anything else + (`tools/dev/check_strategy_branch.py`, run from `main`'s copy). Anything else it needs, such as a skill or an engine primitive, is a separate change on an ordinary branch. -3. Leave the opponents as they are on `main`: either add new strategy modules (plus their import - lines in `kernel_strategy.py`) or change exactly one existing strategy, never both, and never - `pickers.py` or an existing tactic: the opponents run those. To improve a tactic, copy it into +3. Leave the opponents as they are on `main`: either add new strategy modules or change exactly one existing strategy, never both, and never + `pickers.py`, `catalog.py` or an existing tactic: the opponents run those. To improve a tactic, copy it into a new module and change the copy; making the improvement everyone's is a human change. Your strategy's and tactics' code may not reach outside its module: no import-time effects, - no module-level state (keep state in the factory's closure), no imports of another strategy, + no module-level state (keep state inside `build`), no imports of another strategy, no changing attributes of what it imports. CI checks all of this statically, from `main`'s copy of the checker; the reviewer still reads the diff. Tests import pickers from your module - directly, not through `kernel_strategy.py`. -4. Write, test and evaluate it as above, and record the round-robin in `docs/strategies.md`. + directly. +4. Write, test and evaluate it as above, and put the verdict in the pull request. `git add` new files before `pixi run lint`: it checks tracked files only. Before waiting on - a `--reuse` round-robin, read the "N reused ... M to play" line it prints: M much larger - than your own matches means the cache is stale (shared code changed since it was filled). - Let it run anyway (a full round-robin of 600 s matches has taken from about 1 h 50 min, on 15 workers plugged in, to 4.7 h for `tournament_20261005_170958`; matches are now two halves of 300 s of playing time: about 710 s of sim time on average by the final run's stoppages, 785 s in two measured matches, so expect roughly 20-30% longer): the other - strategies' matches run `main`'s code, so they refill the cache for everyone. -4. Open a draft pull request into `main` with the round-robin result. An agent never merges: a person reviews and merges. + an evaluation, read the "X from the match results store, M to play" line it prints: M much larger + than your own matches means the store is stale (shared code changed since it was filled). + Let it run anyway: the other strategies' matches run `main`'s code, so they refill the store for everyone. +5. Open a draft pull request into `main` with the evaluation result. An agent never merges: a person reviews and merges. Several branches can be worked on at once, each in its own worktree; they share -`replays/match_cache/`. A round-robin uses one worker per core (`--max-workers N` to cap it), so +`replays/match_results/`. `evaluate.py` uses one worker fewer than the CPUs (at most 12), so concurrent runs split the machine's cores and each takes longer; a machine with more cores runs more of them at once. How to organise a search (how many in parallel, which ideas) is up to whoever runs it. @@ -365,7 +392,7 @@ whoever runs it. - **`MatchLog`** (`engine/match_log.py`) — one JSONL per match. `Strategy` records an intention row per slot-assignment *change*; call `ctx.match_log.trace(tick, sim_time, key, value)` yourself from a `Tactic` or skill (guard with `if ctx.match_log is not None:`; it's - `None` on tournament/CI runs, so traces can stay in). Examples: `skills/src/go_to_ball.py`, + `None` on tournament/CI runs, so traces can stay in). Examples: `skills/go_to_ball.py`, `tactics/give_and_go.py`. Enable with `match_log_path=` or `match.run_match(..., run_dir=...)`; read back with `load_jsonl(path)`. A run with a dashboard or a game log keeps one in memory too: a plain value traced under a key naming a robot (`ctx.trace(game, f"shoot[{rid}]", @@ -376,7 +403,7 @@ whoever runs it. robot/ball trails over a window, optionally anchored on a `MatchLog` event. **Default to this over `load_frames_in_range()`**: a coordinate dump is expensive in context and easy to misread spatially. Use raw frames only for an exact number once the picture has localized the issue. -- **`tools/match_timeline.py`** — one match window as swimlanes on a shared time axis: the referee +- **`tools/debug/match_timeline.py`** — one match window as swimlanes on a shared time axis: the referee command band, one lane per robot coloured by the tactic it was in (a thin tick at each switch, a dark strip where it had the ball), each robot's distance to the ball, and goals, fouls and shots on top. Use it for thrashing (a robot switching tactics every few ticks), a tactic stuck committed, or @@ -384,68 +411,64 @@ whoever runs it. The dashboard draws the same lanes under the Replay tab's controls (click to seek; hover for what each mark is) and live in the Live tab. Beside a replay, its Play list reads the match as situations: who had the ball from which restart or regain, for how long, and how it ended. - Thrashing in `split_shape` against `tiki_taka_plus`: robots 2-4 flip between the attack and defence - slots about every 1.5 s, in pairs of rows at the same tick. It is not split_shape's alone: most + Thrashing in `pendulum` against `weaver`: robots 2-4 flip between the attack and defence + slots about every 1.5 s, in pairs of rows at the same tick. It is not pendulum's alone: most strategies that split attack and defence on possession take a tactic for under 1 s and revert about - 5 times a minute (the `tactic_thrash` finding, with the numbers per strategy in `match_timeline.py`): - ![split_shape lanes thrashing between attack and defence slots](img/match_timeline/split_shape_100-160.png) + 5 times a minute (the `tactic_thrash` finding, with the numbers per strategy in `tools/debug/match_timeline.py`): + ![pendulum lanes thrashing between attack and defence slots](img/match_timeline/split_shape_100-160.png) - **`render_clip()`** (`analysis/render_clip.py`) — MP4 of a window for humans, ball-following or full-pitch camera; sim ball teleports are never shown. Needs `ffmpeg`. Commands behind committed clips: `assets/clips/README.md`. -- **`docs/strategies.md`** — every factory, whether a round-robin plays it or it is retired, - and the latest results. -- **`tools/evaluation/round_robin.py`** — round-robin runner (`--max-workers N`, `--both-sides`, - `--strict`, `--stop-at-first-stall`, `--fuzz-restarts SEED`, `--fuzz-interval LO HI`, - `--sim-noise JSON`, `--no-save`, `--pair A B` for one fixture with A as config_a — reruns a stalled match from a - round-robin; see the determinism caveat below). +- **`pixi run dashboard`**, Strategies tab — every strategy, core or reserve, its verdicts, maps and matches. +- **`tools/evaluation/evaluate.py`** — every match run (`NAME ...`, `--at REF`, `--all`); see + [Evaluating a strategy](#evaluating-a-strategy). To look again at one stalled match, use its replay: + `tools/debug/repro_from_replay.py` restarts it from any moment with tracing on. - **Ball losses** (`analysis/turnover_breakdown.py`) — runs after every saved tournament and - writes `ball_losses.md`; see [Reading a tournament run](#reading-a-tournament-run). + writes `ball_losses.md`; see [Reading a round](#reading-a-round). `python -m utama_core.analysis.turnover_breakdown ` re-runs it on an older run. - **Stall watchdog** (`engine/match_stats.py`) — records `StallEvent`s, never affects play: `RESTART_STALL` (a restart/stoppage command held >15s) and `COMMITTED_FROZEN` (ball moved <5cm for >10s in live play while a slot is committed). Each `RESTART_STALL` carries a one-line `diagnosis` (ball in goal / past a line, taker not closing on the ball, taker at the ball but - not kicking). The tournament prints a STALLS section, writes it to `summary.json`, and `--strict` exits non-zero on any stall; a + not kicking). The tournament prints a STALLS section, and writes it to `summary.json`; a possession-pinned backstop flags what the watchdog misses. -- **Restart fuzzing** (`custom_referee/restart_fuzzer.py`) — injects legal restarts at - seeded-random times to exercise auto-advance paths; same seed and interval reproduce the - schedule. Details: `docs/custom_referee.md`. -- **Sim noise** (`rsoccer_simulator/src/Utils/sim_noise.py`, `--sim-noise JSON`) — seeded +- **Sim noise** (`simulator/utils/sim_noise.py`, `--sim-noise JSON`) — seeded command latency per robot, kick speed and direction noise (a per-robot offset plus kick-to-kick spread), two-phase ball friction (slide after a kick, then roll), per-robot - speed, acceleration and braking limits applied to the commands the sim acts on (hardware caps, + speed and braking limits applied to the commands the sim acts on (hardware caps, the 4 m/s^2 command cap, no per-match acceleration draw, below any planner), the physics substep count, and vision noise and dropped detections, all off by default. Ball friction, kick direction and substeps need a robosim binary built from `vendor/rSim` (`vendor/rSim/FORK_NOTES.md`); with the stock binary they raise. Draws depend on the seed, team colour and robot id only, so every pairing in a run gets the same physics and A/B comparisons stay paired; the same seed replays a match exactly. Settings and draws go into each replay (`columnar_reader.load_sim_noise`) and `summary.json`, and into the match key only when set. - Ranges come from `docs/sim_realism.md` Phase 1; until then the knobs have no calibrated values. -- **`tools/replay_trace.py REPLAY.npz T0 T1`** — text trace of a window: referee command and + Ranges and their sources are in `tools/evaluation/reference/world.json`. +- **`tools/debug/replay_trace.py REPLAY.npz T0 T1`** — text trace of a window: referee command and why it changed, ball, nearest robot per side. The first look at a stall or a voided restart. -- **`tools/repro_from_replay.py`** — reload a replay's field state at time *t* into a fresh headless +- **`tools/debug/repro_from_replay.py`** — reload a replay's field state at time *t* into a fresh headless match with tracing on, instead of re-running the whole match (`--help` for flags). ### Debugging a foul or failure A foul or failure seen in a match is a symptom: the cause may be the robot, the shared referee override, the planner, the referee itself, or the check that flagged it. Of the first six found -this way (table below), two were the referee or the check, not the robot. +this way (table below), two were the referee or the check, not the robot. The steps alone, as a +checklist, are the `debug-incident` skill (`.agents/skills/`); this section keeps the reasons and the bugs found. -Start with `tools/triage.py RUN_DIR --strategy NAME`: open its `index.md` for the worst matches, the finding counts by kind +Start with `tools/debug/find_bugs.py RUN_DIR --strategy NAME`: open its `index.md` for the worst matches, the finding counts by kind and the pictured findings. Filter `findings.jsonl` on the kind you care about, open that finding's picture to see what it -means, and confirm with the numbers in its message (or `replay_trace.py --events`) before concluding anything. Triage reads only the friendly side of -each match (the intentions log is written for it): a strategy's matches where it is config_a. In a round-robin each pair plays once, -so a strategy gets only the pairs where it comes first in the config order. +means, and confirm with the numbers in its message (or `tools/debug/replay_trace.py --events`) before concluding anything. `tools/debug/find_bugs.py` reads only the friendly side of +each match (the intentions log is written for it): a strategy's matches where it is config_a. In a round each pair plays once, +so a strategy is config_a in only some of its matches (`summary.json`'s `stalls_checked` counts them). The same steps as a flowchart; the moment branch is the optional step 5. ```mermaid flowchart TD - find["1. Find it
moments.py fouls RUN_DIR --by strategy,rule
(without --by: each foul, with its time and tactic)"] - look["2. Look at it
replay_trace.py REPLAY T0 T1 --events
repro_from_replay.py REPLAY --t S --summary IDS"] + find["1. Find it
tools/debug/find_bugs.py RUN_DIR --strategy NAME
(index.md, then findings.jsonl)"] + look["2. Look at it
tools/debug/replay_trace.py REPLAY T0 T1 --events
tools/debug/repro_from_replay.py REPLAY --t S --summary IDS"] q{"Restart or placement geometry?
a field state alone decides it"} - moment["Capture a moment
moments.py capture REPLAY --t S
play --seeds 0-4 must fail on 4 of 5"] + moment["Capture a moment
tools/debug/moments.py capture REPLAY --t S
play --seeds 0-4 must fail on 4 of 5"] cause["3. Find the cause in the code
tactic or override, target, planner;
was the rule really broken?"] fix["4. Fix the cause
with a unit test at the boundary"] done["Done: the unit test is the protection
(a captured moment stays as a check)"] @@ -456,26 +479,28 @@ flowchart TD cause --> fix --> done ``` -The picture tools (`match_timeline.py`, `restart_picture.py`, `plan_trace.py`, `pitch_maps.py`) write their flags as JSON with `--findings`: filter on that, open the picture to understand a flag, and never conclude from a picture alone. +The picture tools (`tools/debug/match_timeline.py`, `tools/debug/restart_picture.py`, `tools/debug/plan_trace.py`, `tools/debug/pitch_maps.py`) write their flags as JSON with `--findings`: filter on that, open the picture to understand a flag, and never conclude from a picture alone. -1. **Find it.** `pixi run python tools/moments.py fouls replays/tournament_ --by strategy,rule` - counts our side's fouls (any of strategy, rule, tactic, restart; `out_of_bounds`, the ball +1. **Find it.** `tools/debug/find_bugs.py` is the one starting point for "what went wrong in a run" (see the + start of this section). It flags thrashing and stalls, and restart geometry with `--restarts`. + For our side's fouls by rule, `pixi run python tools/debug/find_bugs.py ROUND_DIR --fouls --by + strategy,rule` counts our side's fouls (any of strategy, rule, tactic, restart; `out_of_bounds`, the ball leaving the field, is a stoppage and left out unless `--include-stoppages`); without `--by` it lists each with its time, robot, tactic and the referee command then active (`--skip-own-restart` drops fouls during our own restarts; `--json` writes either form as JSON). -2. **Look at it.** `tools/replay_trace.py REPLAY T0 T1` is the text timeline of the window: +2. **Look at it.** `tools/debug/replay_trace.py REPLAY T0 T1` is the text timeline of the window: referee command, ball, nearest robot per side; `--events` lists the kicks, possession, referee changes and fouls instead; `--json` gives either as JSON. - `tools/repro_from_replay.py REPLAY --t S --summary 3` replays that state with the tactics' + `tools/debug/repro_from_replay.py REPLAY --t S --summary 3` replays that state with the tactics' `match_log` tracing on and prints each listed robot's tactic, position and target every 0.25 s (trace keys name tactics, not strategies). In a parallel worktree, run - `tools/setup_worktree.sh` first. + `tools/dev/setup_worktree.sh` first. When a robot does something odd near an obstacle or a keep-out zone (a carrot that swings round a robot, - a robot parked just inside a circle), `tools/plan_snapshot.py REPLAY --t S --robot ID --target X Y` + a robot parked just inside a circle), `tools/debug/plan_snapshot.py REPLAY --t S --robot ID --target X Y` draws what the planner decided on that tick: the obstacles and clearance rings, the keep-out circle, the target and the carrot it returned (`--side enemy` for the other strategy's robot; example: ![kick-off robot parked inside the keep-out circle](img/plan_snapshot/kickoff_keep_out.png)). - `tools/plan_trace.py REPLAY --t0 S --t1 S --robot ID [--target X Y]` runs the same planner on every + `tools/debug/plan_trace.py REPLAY --t0 S --t1 S --robot ID [--target X Y]` runs the same planner on every tick of a window and draws the robot's path, each tick's carrot and the distances over time, so a defect that unfolds over seconds shows as a trace (example: the kick-off robot of ![a kick-off window](img/plan_trace/kickoff_keep_out.png)). The robot's positions are the replay's, @@ -483,16 +508,16 @@ The picture tools (`match_timeline.py`, `restart_picture.py`, `plan_trace.py`, ` ball, while the current planner's carrot from those states is the push-out point 0.85 m from the ball. 3. **Find the cause in the code**, from what the trace shows: which tactic or override sent the robot there, and the target, waypoint and obstacles it used. Ask whether the rule was really - broken (real rules, `docs/custom_referee_design_decisions.md`) and whether the check reads it + broken (real rules, `docs/referee.md ("Design decisions")`) and whether the check reads it right. 4. **Fix the cause, with a unit test at the boundary** (CLAUDE.md, Testing), e.g. "a computed target is off the field". That test is the protection, and it does not need the foul to reproduce. 5. **Optionally keep a moment**, where a field state alone decides the behaviour (restart and - placement geometry under the referee override). `tools/moments.py capture REPLAY --t S --name + placement geometry under the referee override). `tools/debug/moments.py capture REPLAY --t S --name ... --check ... --note "..." [--out PATH]` saves the state; `play JSON --seeds 0-4` must fail on at least 4 of 5 before the fix (`--against REF` plays the code at REF beside it; `--events` - lists referee changes, fouls, keep-out entries and kicks; `--strategy scratch.py:factory` + lists referee changes, fouls, keep-out entries and kicks; `--strategy scratch.py:function` tries a strategy from a scratch file). Its note names the fix; if the fix is not in the same change, set `"known_failure": ""` (a strict xfail). @@ -503,11 +528,11 @@ steered along their recorded paths for 1-2 s (tried 2026-10-17, reverted in `9c2 velocities cannot be set either: every rsim teleport resets all robots (`SSLWorld::replace`). So for open play, go from the trace to the code and a unit test. -A moment's `checks` are `tools/moments.py`'s `CHECKS` (`keeps_clear`, `stop_speed`) or referee rule names; its `requires` (`restart_lasts`, +A moment's `checks` are `tools/debug/moments.py`'s `CHECKS` (`keeps_clear`, `stop_speed`) or referee rule names; its `requires` (`restart_lasts`, `robot_near_ball`) fail it with `did not arise` when the situation it tests never happened. A restart moment plays one strategy, since the referee override moves every outfield robot the same -way whatever the strategy. `tools/moments.py new NAME --command CMD ...` writes a hand-made field -state to edit. Moments are not a gate on strategies: they pin shared-code bugs. +way whatever the strategy. Moments are captured from replays (`capture`); hand-made templates +(`tools/debug/moments.py new`) were removed on 2026-11-11. Moments are not a gate on strategies: they pin shared-code bugs. | Symptom | Looked like | Cause | Fix | Test | |---|---|---|---|---| @@ -521,7 +546,7 @@ state to edit. Moments are not a gate on strategies: they pin shared-code bugs. | STOP with the ball just out over the goal line: our robot drives into their keeper (field day 2026-10-27) | robot ignoring a robot | the clear-of-the-ball target, clamped back onto the pitch, was 0.23 m from the keeper standing on its line | field-day-20261027 branch: clearing targets keep `_ROBOT_SPACING_M` (2 robot radii + 10 cm) from every robot, moving on round the ball | `test_referee_unit.py` (TestClearingTargetsKeepOffRobots) | The last row matters on real robots only: in sim matches `StrategyRunner` teleports a placed ball -to its target (`docs/custom_referee_design_decisions.md`, Ball placement), so our placer never +to its target (`docs/referee.md ("Design decisions")`, Ball placement), so our placer never runs in a round-robin. Its moment was dropped for that reason: check that a moment's behaviour happens in sim matches at all before keeping it. The placer is still slow (about 5 s round the ball, and the carry curves off line), a real-robot item. @@ -530,28 +555,57 @@ ball, and the carry curves off line), a real-robot item. writes into the sim (e.g. `teleport_robot`) must negate y *and* heading — `543741e` fixed a teleported robot facing the mirrored heading, which had silently corrupted teleported scenarios. -**Determinism:** an rsim match is reproducible: `--pair A B` replays a round-robin match exactly (13 of +**Determinism:** an rsim match is reproducible: playing the same fixture again gives the same match exactly (13 of 13 sampled from `tournament_20260928_221404` at `1de1e18d`, every replay array and sidecar). One cause of "differs run to run" was state that outlived a match: `has_ball`'s and shielding's hysteresis were module dicts keyed by robot id, shared by both teams and carried from match to -match in a round-robin worker process (`c27bfad7`). Module-level state in a tactic or +match in an evaluation worker process (`c27bfad7`). Module-level state in a tactic or skill must be keyed by team and cleared at match start (`StrategyRunner.__init__`). If a -round-robin match and its `--pair` rerun still differ, suspect more of the same; compare the two +match and its rerun (delete its record from the store and evaluate again) still differ, suspect more of the same; compare the two replays' `ball_p` to find the first differing tick. **Fast and exact numerics:** the motion planner, refiners and Kalman filter use faster float code by default (about 19% less wall time per match under full load). `UTAMA_EXACT_MATH=1` restores the -original numpy paths, byte-identical to before (`8c191eea`); the round-robin pools and rsim +original numpy paths, byte-identical to before (`8c191eea`); the evaluation's worker pool and rsim all inherit it. The two modes agree to 1e-9 per call but matches diverge after the first differing tick, so a baseline recorded in one mode is only comparable with a candidate run in the same mode. -## Reading a tournament run +## Tried and rejected + +Ideas that look obvious from the signals and cost a day to disprove. Each was measured with paired +drills: the same moments from one run's replays, replayed with one side changed. Don't re-propose one +without new evidence (field data, a changed world), and add yours here when you reject one. -Every saved `round_robin.py` run prints its sections and writes the same data to -`replays//summary.json`. [`docs/signals.md`](signals.md) lists every signal it records +| Idea | Result | Date | +|---|---|---| +| Sprint at a contested ball (`go_to_ball`: within 1.2 m, an enemy within 0.6 m of it) | **Shipped**: +7 points of possession on free balls, +7 more on balls an enemy holds | 2026-11-10 | +| Face the ball before closing; line up in front of the enemy's dribbler; widen the sprint; carry speed and acceleration caps in sim | No gain over the sprint alone | 2026-11-10 | +| Receiver retreats as the ball arrives (a "cushion"); first-time shots | No gain below 5 m/s; receivers 10-20° off the ball's line caught 7% | 2026-11-09 | +| Brake harder when receiving | No gain. Most missed receptions are the kick noise in `robots.json`, chosen to match real pass completion: by design | 2026-11-10 | +| Faster free kicks (taker sprints) | Kick 1.5 s sooner, but passes received 92 → 75: an enemy is still crossing the lane | 2026-11-10 | +| Pass early when pressed (an enemy closing within 0.35-0.5 m) | Possession −9 to −12 points, more free kicks against: a 5 m/s kick reaches a mate 1 m away before they can adjust | 2026-11-10 | +| Clear towards the touch line instead of upfield | Fewer free kicks against in our half, more overall, less possession, same goals | 2026-11-10 | +| 1.5 m minimum distance for the restart pass (open play keeps 1.5 m, restarts 0.7 m) | No difference | 2026-11-10 | +| rsim's faster ODE solver (`dWorldQuickStep`) | 23% faster matches, but a robot driving sideways drifts 18-24 cm over 3 m | 2026-10-10 | + +Two facts behind several of these: passes under 1.5 m are half of all passes and only 28% are +received (1.5-3.5 m: about 50%); and a pass whose line passes within 4 cm of the receiver's centre is +caught 82-97% of the time, beyond 4 cm under 30%. + +## Known open bugs + +- **The keeper ignores a slow ball rolling through its own box.** `skills/goalkeep.py` fetches a + ball in the box only below `_RETRIEVE_BALL_SPEED` (0.3 m/s); a ball rolling slower than a shot but + faster than that, wide of the goal, is watched until it goes out. Seen in the v2.6.0 replays, + `pendulum_vs_wolfpack` at 3:52 (wolfpack's keeper). Left open on purpose as a first task. + +## Reading a round + +Every `evaluate.py` run prints round 1's sections and writes each round's data to +`replays/eval_/round_/summary.json` (older round-robins: `replays/tournament_/`). [`docs/signals.md`](signals.md) lists every signal it records (and the offline ones), grouped by the question each answers: is something broken, does it create chances, keep and move the ball, defend, take restarts. Each comes with where to find -it, a reference range from the latest round-robin and what an off value usually means. Look +it, a reference range from the latest run and what an off value usually means. Look there before adding a metric: it probably exists. These are diagnostics, not objectives. Fewer losses is not better on its own: a strategy that @@ -561,14 +615,15 @@ planner, the referee) is failing every strategy at once. ## Real matches -`tools/convert_ssl_log.py` turns the league's official game logs +`tools/realism/convert_ssl_log.py` turns the league's official game logs (https://ssl.robocup.org/game-logs/) into replays in our format, so `load_columnar_replay`, `render_window`, `scenario_from_replay` and the analyses read a real match like one of ours: - pixi run python -I tools/convert_ssl_log.py --corpus 2022-2026 --jobs 2 --out
+ pixi run python -I tools/realism/convert_ssl_log.py --corpus 2022-2026 --jobs 2 --out -Only the converted files are kept: each raw log (up to 370 MB) is deleted once converted, and a -converted match takes about 35 MB. The published Division B logs for 2022-2026 are 118 +Each raw log (up to 370 MB) is deleted once converted unless `--keep-raw` is given (keep them: +it moves them to `//`, and a later conversion needs no download); a converted match +takes about 35 MB. The published Division B logs for 2022-2026 are 118 matches. What a converted match holds, and where it differs from a sim replay (the details are in @@ -598,7 +653,7 @@ What a converted match holds, and where it differs from a sim replay (the detail `NORMAL_START` and keeps `DIRECT_FREE_*` until the next stoppage. The converter switches it to `NORMAL_START` once the ball has moved 0.05 m, as our referee does. - `.source.json` holds the teams, the final score, the tracker used and the field size. -- Sidecars for measuring physics and vision (sim realism, [sim_realism.md](sim_realism.md)), +- Sidecars for measuring physics and vision (sim realism), not read by any replay tool: `.kicks.json`, every kick the tracker reported (start, kicker, start position, velocity estimates, stop); `.tracker.zip`, per-tick ball and robot visibility and robot angular velocity; with `--raw-vision`, `.vision.zip`, every @@ -610,4 +665,19 @@ What a converted match holds, and where it differs from a sim replay (the detail filtering (ghost robots, ball jumps), and their referee also sends `GOAL_*` and `INDIRECT_FREE_*`. The corpus above starts in 2022. -The scenario bench (retired 2026-10-17) replayed 10 s starts harvested from replays; to look at one point in a replay use `tools/repro_from_replay.py --t `, and to pin a failure there add a regression moment ("Debugging a foul or failure", above), and `analysis/goal_ledger.py` lists a replay's situations and goals. +The scenario bench (retired 2026-10-17) replayed 10 s starts harvested from replays; to look at one point in a replay use `tools/debug/repro_from_replay.py --t `, and to pin a failure there add a regression moment ("Debugging a foul or failure", above), and `analysis/goal_sources.py` lists a replay's situations and goals. + +### What real matches showed (2026-10) + +From the 118 converted Division B matches, against our sim at the time. The scripts are outside the +repo (`~/dev/ssl/xg-analysis/`); the full write-up is in git history (`docs/sim_realism.md`, deleted +2026-11-13). + +- Real matches have about 3-4 goals and about 40 free kicks; most goals come from the ball won in + open play, about 19% from set pieces. Real matches are live only about 15% of the time. +- Shot totals and finishing roughly matched the sim's, but only because differences cancel: sim + keepers saved twice as often, and sim shots went wide far less often. Judge realism by component + (keeper reaction, ball slow-down, kick noise), never by goal totals. +- A value model fitted on real matches (who scores within 10 s; AUC 0.82 on held-out years) did not + rank strategies with fewer matches than goals do. xG failed as a ranker too (`docs/signals.md`, + "Ranking"). diff --git a/docs/tactic_model_design_decisions.md b/docs/strategy_design.md similarity index 96% rename from docs/tactic_model_design_decisions.md rename to docs/strategy_design.md index 62316bc46..a254f143b 100644 --- a/docs/tactic_model_design_decisions.md +++ b/docs/strategy_design.md @@ -4,13 +4,12 @@ Why the strategy layer (`utama_core/engine/`, `utama_core/tactics/`, `utama_core/strategy/`) is shaped the way it is. The code is the source of truth for *how*; this file records *why* and what was deliberately not built. The design borrowed vocabulary from Sumatra (TIGERs Mannheim) and OS process scheduling to stress-test -ideas, not as a mandate to copy either's weight. For the general allocation framework see -[`scheduling_math_model.md`](scheduling_math_model.md). +ideas, not as a mandate to copy either's weight. Section numbers are stable because code comments cite them. Gaps are sections merged or removed: §7 (splitting policy) was resolved by §11; §8/§9 (orphan robots, deadlock detection) -are under Deferred; §12/§17 (tactic and config inventories) live in `docs/strategies.md` and -the code. +are under Deferred; §12/§17 (tactic and config inventories) live in +the code (`utama_core/strategy/`, `utama_core/tactics/`). ## Settled @@ -87,12 +86,12 @@ and removed as duplicated machinery. Consequences, each learned from a bug: **§10. `AbstractStrategy` is kernel-native** (BT/py_trees removed: `087ee4b`, `960662c`, `48affd6`). `StrategyRunner` drives it unchanged; it builds the `Strategy` in -`load_motion_controller()` because `build_kernel_strategy(motion_controller)` needs the +`load_motion_controller()` because `build(motion_controller)` needs the controller but not `game`. **§13. Referee restarts are handled before any Tactic ticks** (`engine/referee_override.py`). For `STOP`, `TIMEOUT_*` and every restart command, `RefereeOverride` computes every outfield -robot's command from the long-lived `*Step` classes in `custom_referee/actions.py` (reused, +robot's command from the long-lived `*Step` classes in `referee/actions.py` (reused, not reimplemented — keep-out geometry has one home). Steps are driven through a three-attribute shim (`game`, `motion_controller`, `cmd_map`). The goalkeeper's pinned tactic ticks only if the override produced no command for it (kickoff steps exempt the keeper). A restart arriving diff --git a/docs/testing_gaps.md b/docs/testing_gaps.md deleted file mode 100644 index 849d223b1..000000000 --- a/docs/testing_gaps.md +++ /dev/null @@ -1,63 +0,0 @@ -# Testing gaps - -Found 2026-08-25 while three parallel agents added 7 `custom_referee` rules (SSL §8.3/8.4 -audit): every agent's own unit tests passed, yet a real bug reached the merged tree and only -the pre-existing full suite caught it. This file records the kinds of gap that allowed that, -plus adjacent ones. **Numbering is fixed** (code and docs cite gaps by number); append new -gaps, never renumber. Full writeups: `git log -p -- docs/testing_gaps.md`. - -## Open - -**4. No static type checking in CI.** CI runs Ruff (a linter), which cannot flag a subclass -override whose signature drifted from its abstract base — the structural fix for gap #1's -symptom. Adopting mypy/pyright is undecided given the codebase isn't typed to that standard. - -**6. New rules never systematically fuzzed against real match dynamics** — partly open. -`pushing` (closed, `a3f3795`) and `keeper_held_ball` (fired 10 times in 6 full matches) are -confirmed live. `ball_placement_interference` has never fired in real play: across ~200 -placements the longest non-placer dwell in the 0.5m stadium was 1.0s, under the rulebook's 2s -grace. Not treated as a bug; recheck if a real match produces a ≥2s linger, or build an -adversarial scenario. Our own sim does reach it, so it is no longer untested: -`tests/moments/placement_in_corner_traps_defender.json` (round-robin -`tournament_20261017_002337`) pins a corner placement that trapped a defender inside the -keep-out circle, and must keep passing. - -## Closed (one line each) - -1. **Unit-testing a rule in isolation skips the interface it's called through.** - `BaseRule.check()` gained a 4th parameter; 7 overrides kept 3 and their direct-call unit - tests still passed (Python doesn't check override signatures). Fix: one integration test - per §8.4 rule through `CustomReferee.step()` (`test_referee_rules_integration.py`, - `test_ball_contest_deadlock.py`) — `de5e69b`. -2. **Foul counter / yellow card never driven end-to-end.** `test_foul_counter_end_to_end.py` - — `de5e69b`. Non-stopping fouls don't touch the 0.3s transition cooldown, so several can - land at one timestamp. -3. **Two rules in one tick / non-stopping vs stopping foul untested.** - `test_referee_scan_order.py` — `de5e69b`. -5. **`game_frame=None` in a test.** No real caller passes `None`; the test was fixed to pass a - real `GameFrame` and the dead guard removed rather than copied to other rules — `f7e9a2a`. -7. **`RobotStopSpeedRule` fouled robots obeying `StopStep`'s clearing motion.** The rule now - exempts a robot while it is inside `BALL_KEEP_OUT_DISTANCE` — `ccb172b` - (`test_dribble_placement_stopspeed.py`). -8. **`HALT` had no automated resume**, so a sim run tripping it froze silently. - `StrategyRunner` now auto-resumes `HALT` → `NORMAL_START` after 5s, sim only — `ccb172b` - (`test_halt_auto_resumes_to_normal_start_in_sim`). -9. **`ball_placement_interference` was structurally unreachable in sim**: a sim-only - `StrategyRunner` fast path teleported the ball and jumped straight to `FORCE_START`, - skipping `BALL_PLACEMENT_*`. Gated on `next_command` — `f0ff450` - (`test_real_out_of_bounds_restart_reaches_ball_placement`). The physical-carry gap is - separate (`referee_integration.md`, Open). -10. **Replay investigations used raw numbers instead of `render_window()`** — the guidance now - lives in `STRATEGY_DEVELOPMENT.md`'s Observability section. -11. **No automated stuck-match detector.** `utama_core/analysis/stuck_detector.py`'s - `find_stuck_windows()` (`39257ee`): per-3s window, ball frozen (position std-dev) or robot - oscillating (FFT peak fraction); excludes non-live referee states, held/shielded ball, and - ball resting in a defense area (`ce6abe3`). Bugs it found, each with a regression test: - `PressAndContainTactic` loose-ball and `GiveAndGoTactic` hop timeout (`d6b3ff1`); - `shielding.shielded_approach_angle` hysteresis reset by an enemy stepping in and out of - range (the shielding fix, `ce6abe3`); a ~360s post-restart freeze with three layered causes - — `clear` picker holding other robots on `block` (`0e510a0`), `DecoyOverloadTactic`'s 12s - finish timeout (`ae6a6f3`), `ball_is_loose` ignoring a legally barred enemy near our - defense area (`10fc89c`); and a same-team two-robot ball scrum - (`_teammate_already_has_ball()`, `a59a8e5`). Cross-tactic convergence in general is - the roadmap's "Cross-tactic ball convergence". diff --git a/docs/tools.md b/docs/tools.md index dadd333c9..d267078ae 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -3,6 +3,37 @@ Every script in the repository, by what it is for. Run them from the repository root with `pixi run python `; each script's docstring has its full usage and flags. +## Start with these four + +New to the repo? You need only these ([first_strategy.md](../tutorials/first_strategy.md) walks through them): + +| Command | What it does | +|---|---| +| `pixi run main A B` | Watch strategy A (yellow) play strategy B in the simulator | +| `pixi run test`, `pixi run lint` | Check nothing broke, before every pull request | +| `pixi run evaluate NAME` | Is strategy NAME better than the champion? Read the verdict and the mean diff | +| `pixi run dashboard` | http://localhost:8080: the Strategies tab (every strategy, its tactics, verdict, position and shot maps, signals and newest matches; every evaluation run) and recorded replays | + +Everything below is for specialists. + +## Which tool? + +Pick the tool by the question you have. + +For the four jobs that chain several of them, follow a skill in `.agents/skills/`: `change-strategy`, `explain-result`, +`debug-incident`, `field-session`. + +| Question | Tool | +|---|---| +| Does it break? | `pixi run test` (it includes the regression moments). Stalls: every match records them; `evaluate.py` reports them with how many matches checked them | +| Is it better? | `tools/evaluation/evaluate.py CANDIDATE`, paired against the champion at the last release. The only verdict | +| Does everything still run after a shared-code change? | `tools/evaluation/evaluate.py` with no candidate: one round robin of the core and the reference (15 matches); `--all` for the whole catalog, occasionally | +| Did a shared-code change help? | `tools/evaluation/evaluate.py `: today's champion, on today's shared code, against itself at the last release | +| What went wrong in these matches (thrashing, stalls, restart geometry, fouls)? | `tools/debug/find_bugs.py RUN_DIR --strategy NAME`, then the picture tools; `--fouls` lists our side's fouls. It finds bugs, not why a strategy loses | +| Keep a fixed bug fixed? | A unit test at the cause. `tools/debug/moments.py capture` writes a regression moment, which runs in `pixi run test` | +| Look closely at one thing? | `tools/debug/repro_from_replay.py`, `tools/debug/replay_trace.py`, the picture tools, `tools/debug/debug_match.py` | +| Is the simulator realistic? | [Simulator realism](#simulator-realism). Not strategy development | + ## pixi tasks `pixi run ` (defined in `pixi.toml`): @@ -13,62 +44,54 @@ Every script in the repository, by what it is for. Run them from the repository | `lint` | the whole pre-commit stack (black, ruff, isort) on every file | | `precommit-install` / `precommit-uninstall` | install or remove the pre-commit hook | | `main` | `main.py`: watch one match between two strategies in rsim (below) | -| `build-planner` | build the C++ fast-path planner (`utama_core/motion_planning/src/fastpathplanning/cpp`) into `build/fpp` with cmake | +| `build-planner` | build the C++ fast-path planner (`utama_core/motion_planning/fastpathplanning/cpp`) into `build/fpp` with cmake | | `replay [-n NAME] [-p]` | play a legacy pickle replay `replays/NAME.pkl` in the rSoccer viewer (newest if no name; `-p` step by step). Today's `.npz` replays open in the dashboard instead | -| `runs` | list the tournament runs in `replays/`: start time, commit, matches, stalls, arguments | -| `debug-robots` | keyboard/click teleoperation GUI for real robots over the serial radio (robots chosen by radio ID; [real_robot_setup.md](real_robot_setup.md)) | -| `field-check` | the start of a test day in one command (`tools/field_check.py`): vision's cameras, packets per second, field size, ball and lids in view, then `find-robots` with each robot's share of commands answered and its profile; every line "ok" or "!!" ([real_robot_setup.md](real_robot_setup.md#each-test-day)) | -| `find-robots` | which robots are on the field and the lid each wears (`python -m utama_core.team_controller.src.controllers.real.find_robots`): each radio that answers turns a little on the spot and back, and the pattern that turned is its lid; prints radio, lid, whether its profile was calibrated on that lid, silent radios and stray patterns; saved for the examples, which check it against vision on start and find again when a lid is missing (`shooting_drill.on_field`, `find_robots.confirm`) ([real_robot_setup.md](real_robot_setup.md#5-measuring-a-robot)) | -| `demos` | every dashboard demo from one command (`examples/demos.py`, `--mode rsim` to rehearse, `--demo` the first): one dashboard stays up and the Live tab's Demo panel switches demo while halted (robots stopped, log saved, radio and vision released, the page reloads by itself), sets the first robot, camera half and rules for the next run, runs the field check, and offers teleop by keyboard ([real_robot_setup.md](real_robot_setup.md#running-the-demos)) | -| `calibrate` | measure one real robot from the terminal and write its profile (`examples/calibrate_robot.py`, `--radio 0`; finds the robots when not told which): fixed driving moves, then the robot fetches the ball itself for a carry ladder (the fastest it keeps the ball each way) and 10 charged kicks; asks only to roll the ball back; then DONE, its loop delay, speed gain, acceleration, vision noise and kick speed, and its tag offset, kick bend and bias and carry caps written to `utama_core/config/robots/radio_.json`; `--ball-only` repeats the ball part, `--check` tries the new profile against the committed one in alternating blocks ([real_robot_setup.md](real_robot_setup.md#5-measuring-a-robot)) | +| `runs` | list the runs in `replays/` (each evaluation round, and older round robins): start time, commit, matches, stalls, arguments | +| `debug-robots` | keyboard/click teleoperation GUI for real robots over the serial radio (robots chosen by radio ID; [field_day.md](../tutorials/field_day.md)) | +| `field-check` | the start of a test day in one command (`tools/field/field_check.py`): vision's cameras, packets per second, field size, ball and lids in view, then `find-robots` with each robot's share of commands answered and its profile; every line "ok" or "!!" ([field_day.md](../tutorials/field_day.md#each-test-day)) | +| `find-robots` | which robots are on the field and the lid each wears (`python -m utama_core.team_controller.controllers.real.find_robots`): each radio that answers turns a little on the spot and back, and the pattern that turned is its lid; prints radio, lid, whether its profile was calibrated on that lid, silent radios and stray patterns; saved for the examples, which check it against vision on start and find again when a lid is missing (`shooting_drill.on_field`, `find_robots.confirm`) ([field_day.md](../tutorials/field_day.md#5-measuring-a-robot)) | +| `demos` | every dashboard demo from one command (`examples/demos.py`, `--mode rsim` to rehearse, `--demo` the first): one dashboard stays up and the Live tab's Demo panel switches demo while halted (robots stopped, log saved, radio and vision released, the page reloads by itself), sets the first robot, camera half and rules for the next run, runs the field check, and offers teleop by keyboard ([field_day.md](../tutorials/field_day.md#running-the-demos)) | +| `calibrate` | measure one real robot from the terminal and write its profile (`tools/field/calibrate_robot.py`, `--radio 0`; finds the robots when not told which): fixed driving moves, then the robot fetches the ball itself for a carry ladder (the fastest it keeps the ball each way) and 10 charged kicks; asks only to roll the ball back; then DONE, its loop delay, speed gain, acceleration, vision noise and kick speed, and its tag offset, kick bend and bias and carry caps written to `utama_core/config/robots/radio_.json`; `--ball-only` repeats the ball part, `--check` tries the new profile against the committed one in alternating blocks ([field_day.md](../tutorials/field_day.md#5-measuring-a-robot)) | ## Worktrees | Script | Purpose | |---|---| -| `tools/setup_worktree.sh` | Run inside a git worktree: links `.pixi` to the main checkout's and copies the gitignored compiled `.so` extensions (planner, rsim). Idempotent; one line per action | +| `tools/dev/setup_worktree.sh` | Run inside a git worktree: links `.pixi` to the main checkout's and copies the gitignored compiled `.so` extensions (planner, rsim). Idempotent; one line per action. Symlink `replays` too, so the worktree shares the match results store; run one evaluation at a time per laptop | ## Playing matches | Script | Purpose | |---|---| -| `tools/evaluation/round_robin.py` | The whole-catalog health and stall check: every strategy config against every other, one full match per pair (two halves of 300 s of playing time); writes `replays/tournament_/` with `summary.json`, and adds its matches to the evaluation ledger. `--pair A B` plays one match; `--reuse` replays only matches whose code changed, plus a 5% spot-check of reused ones; `summary.json`'s `reuse.mismatches` lists any that came out different, which means a match no longer replays exactly. `--sim-noise JSON` (inline or a file) plays every match with the same seeded latency, kick speed and direction noise, ball friction, motion limits and vision noise (`SimNoise`, `docs/STRATEGY_DEVELOPMENT.md`). A single strategy is judged with `evaluate.py`, not by its place here | -| `tools/evaluation/evaluate.py` | One or more candidates against the champion of a fixed reference pool (`tools/evaluation/pools/pool_v1.json`), in rounds under seeded sim noise, until its paired results against the champion say better (P >= 0.99), worse (P <= 0.2) or undecided after 6 rounds; `--held-out` plays the pool's held-out opponents before promoting. Results go to the evaluation ledger `replays/eval/ledger.jsonl` (round-robins add theirs too), reports to `replays/eval/reports/`; no replays kept. The way to judge a strategy (`docs/STRATEGY_DEVELOPMENT.md`, "Evaluating a strategy"). `--explain` (off by default) also writes pictures and a `summary.json` of each candidate against the champion to `replays/eval/explain/` (`tools/evaluation/explain.py`); they explain the verdict, never change it | -| `tools/evaluation/explain.py` | `explain.py RUN_DIR CANDIDATE CHAMPION --out DIR`: positions (with and without the ball), shots for and against, and fouls by rule, for two strategies from the matches in a run dir (a round-robin's or an `evaluate.py` run's), plus `summary.json` with the numbers behind them; goals stay the verdict. Used by `evaluate.py --explain` | -| `tools/evaluation/match.py` | Match construction shared by the two above (not run directly) | -| `dashboard_server.py` | Standalone browser dashboard at http://localhost:8080: replays and tournament results | +| `tools/evaluation/evaluate.py` | Every match run. `evaluate.py [CANDIDATE ...]`: round 1 a round robin of the core strategies (`--all`: every strategy) and the reference, the champion at the last release played from a `.strategy` file (`--at REF` for another release); with candidates, the same round robin repeats under the next seed, with only the open candidates: a screen on seeds 1-6 that drops a candidate whose mean paired diff against the reference is <= 0, then the survivors on fresh seeds 101-106, better if a one-sided paired t-test gives p <= 0.05, else undecided (`analysis/ratings.py`). Each round uses one sim-noise seed in the reference world and robots; matches 1200 s at most. A match the store holds (`replays/match_results/`, `replay/match_results.py`) is taken from it, never played again: to play everything again, delete the store. Reports stalls with how many matches checked them (the watchdog sees config_a only) and every signal, never a ranking. Writes `replays/eval_/report.json` and `round_/` (replays, `summary.json`, `ball_losses.md`). See `docs/strategy.md`, "Evaluating a strategy" | +| `tools/evaluation/verdict_sim.py` | How often `evaluate.py`'s rule is right, on simulated results (no matches): better / dropped / undecided rates per effect size, correlation and number of opponents. Rerun after changing the rule or `analysis/ratings.py` | +| `utama_core/run/sim_setup.py` | Not a script: the one way every tool loads a strategy (a catalog name, a `.strategy` file, or `PATH.py:FUNCTION` from a scratch file) and sets up an rsim match: `sim_referee` (the referee, with the kickoff team) and `sim_runner` (the `StrategyRunner`). `match.py`, `tools/debug/repro_from_replay.py`, `tools/debug/moments.py`, `tools/debug/debug_match.py` and `main.py` all build their referee and runner here, and nothing else does | +| `tools/dev/build_strategy.py` | `tools/dev/build_strategy.py NAME OUT.strategy [--ref COMMIT]`: pack one strategy and the code it runs on into a file that plays in its own process (`utama_core/bundle/`). `evaluate.py` builds the reference's itself | +| `tools/evaluation/explain.py` | `explain.py RUN_DIR CANDIDATE CHAMPION --out DIR`: positions (with and without the ball), shots for and against, and fouls by rule, for two strategies from the matches in a run dir (an `evaluate.py` round's, or an older round-robin's), plus `summary.json` with the numbers behind them; goals stay the verdict. | +| `tools/evaluation/match.py` | Plays one match (`run_match`: the step loop to full time, the score and the stats) for `evaluate.py`, with the set-up from `utama_core/run/sim_setup.py` (not run directly) | +| `tools/evaluation/sim_settings.py` | Not a script: loads the players and the simulated world and robots (`tools/evaluation/reference/players.json`, `world.json`, `robots.json`) for `evaluate.py`. Kept in `reference/` so a new champion does not rerun every stored match | +| `utama_core/dashboard/__main__.py` | `pixi run dashboard`: standalone browser dashboard at http://localhost:8080: Strategies tab (`dashboard/views/strategies.py`) and Replay tab | ## Evaluating strategies -What these measure and how far to trust each: [STRATEGY_DEVELOPMENT.md](STRATEGY_DEVELOPMENT.md), +What these measure and how far to trust each: [strategy.md](strategy.md), [signals.md](signals.md). | Script | Purpose | |---|---| -| `tools/signal_report.py` | Figures of a round-robin's strategy signals for [signal_report.md](signal_report.md) | -| `tools/pitch_maps.py` | Where each strategy's robots stand, shoots and fouls, drawn on the pitch, for [signal_report.md](signal_report.md#on-the-pitch). `--findings PATH`: six descriptive `zone_share` facts per strategy (its in- and out-of-possession samples in each third; no threshold) | -| `utama_core/analysis/goal_ledger.py` | `python -m utama_core.analysis.goal_ledger `: every goal attributed to the situation that started its play (a restart, or the ball won in open play, by third); per strategy, situations per match × P(goal) = goals per match, scored and conceded. Reads only the replay and its referee file, so it runs on converted official logs too. `--rates` writes the situation rates per team per live minute. See [signals.md](signals.md#where-do-goals-come-from) | -| `utama_core/analysis/physics_ranges.py` | `python -m utama_core.analysis.physics_ranges --real --sim `: physics parameter ranges for the sim-realism plan ([sim_realism.md](sim_realism.md)): ball deceleration by speed and time since a kick, rolling-segment fits, robot speed, acceleration, braking and turn-rate percentiles per robot, and dropped detections, with spreads between matches, robots and teams | -| `tools/check_strategy_branch.py` | CI check on `strategy/*` pull requests: the branch must not change the evaluation or its opponents | - -### Validation studies - -These check how far cheap metrics agree with round-robin results. They do not judge a strategy: use `evaluate.py`. - -| Script | Purpose | -|---|---| -| `tools/metric_correlation.py` | Which cheap per-match metrics predict results; computes the *offline* signals in [signals.md](signals.md) | +| `tools/debug/pitch_maps.py` | Where each strategy's robots stand, shoots and fouls, drawn on the pitch. `--findings PATH`: six descriptive `zone_share` facts per strategy (its in- and out-of-possession samples in each third; no threshold). `--data PATH`: the position and shot maps' numbers as JSON, no figures (the dashboard runs it once per round and keeps `pitch_maps.json` beside the summary) | +| `utama_core/analysis/goal_sources.py` | `python -m utama_core.analysis.goal_sources `: every goal attributed to the situation that started its play (a restart, or the ball won in open play, by third); per strategy, situations per match × P(goal) = goals per match, scored and conceded. Reads only the replay and its referee file, so it runs on converted official logs too. `--rates` writes the situation rates per team per live minute. See [signals.md](signals.md#where-do-goals-come-from) | +| `tools/dev/check_strategy_branch.py` | CI check on `strategy/*` pull requests: the branch must not change the evaluation or its opponents | ## Real matches | Script | Purpose | |---|---| -| `tools/convert_ssl_log.py` | Official RoboCup SSL game logs to replays in our format, so the analyses run on real matches: given logs, or `--corpus 2022-2026` to download and convert every published Division B match, deleting each raw log once converted (`--keep-raw` keeps it; downloads cut short are resumed; each conversion's memory is capped by `--max-memory-gb`). Also writes sidecars for measuring physics: the tracker's kicks and visibility, and with `--raw-vision` every raw camera detection; `--backfill-extras` adds them to matches already converted. What a converted match holds and its limits: [STRATEGY_DEVELOPMENT.md](STRATEGY_DEVELOPMENT.md#real-matches) | -| `tools/realism_scorecard.py` | Our sim against real Division B matches, component by component: attempts per live minute (open play and set pieces), attempt distance, real xG per attempt, finishing, goal rate and keeper saves per xG band, shot outcomes (keeper, defender, wide, post, crossed with no goal), aim outside the posts and miss distance, ball slow-down, kick speed, keeper depth, keeper and nearest-defender reaction time (`utama_core/analysis/realism/reaction.py`), pass line offset and completion (`passes.py`). Each row: the real value and 95% interval, the sim value, and whether it is inside. `--real` rebuilds the committed reference (`utama_core/analysis/realism/real_2025_2026.json`: the real xG model and rows) from converted logs; `--sim RUN_DIR` scores a round-robin against it. Attempts exclude passes and kicks from beyond 6 m. See [sim_realism.md](sim_realism.md) | +| `tools/realism/convert_ssl_log.py` | Official RoboCup SSL game logs to replays in our format, so the analyses run on real matches: given logs, or `--corpus 2022-2026` to download and convert every published Division B match, deleting each raw log once converted (`--keep-raw` keeps it; downloads cut short are resumed; each conversion's memory is capped by `--max-memory-gb`). Also writes sidecars for measuring physics: the tracker's kicks and visibility, and with `--raw-vision` every raw camera detection; `--backfill-extras` adds them to matches already converted. What a converted match holds and its limits: [strategy.md](strategy.md#real-matches) | ## Debugging a match -The four picture tools (`match_timeline.py`, `restart_picture.py`, `plan_trace.py`, `pitch_maps.py`) each take +The four picture tools (`tools/debug/match_timeline.py`, `tools/debug/restart_picture.py`, `tools/debug/plan_trace.py`, `tools/debug/pitch_maps.py`) each take `--findings PATH` (`-` for stdout) and write the problems they flag as JSON lines, one `Finding` per line (`utama_core/analysis/findings.py`): @@ -82,52 +105,69 @@ Fields: `tool`, `kind`, `replay` (path or null), `side` (`friendly`, `enemy` or | Script | Purpose | |---|---| -| `tools/triage.py` | **Start here.** `RUN_DIR [--strategy NAME] [--matches 3] [--restarts] [--out DIR] [--max-pictures 8] [--workers 2]`: each strategy's N worst matches by goal difference, among those it played as config_a (the side with an intentions log: about half its round-robin matches, every other round in an evaluation), every flagged problem with its numbers (`tactic_thrash`, `stall`, and with `--restarts` the `target_in_keep_out` / `keep_out_short` / `target_in_defense_area` restart flags), the top K drawn with the picture tool for that kind. Writes `OUT/index.md` (read first), `OUT/findings.jsonl` and `OUT/pictures/`; default OUT is `RUN_DIR/triage/`. `--restarts` is slow (about 45 s a match). Read-only. See [STRATEGY_DEVELOPMENT.md](STRATEGY_DEVELOPMENT.md), "Debugging a foul or failure" | -| `tools/replay_trace.py` | Text trace of a replay window: referee commands, ball, nearest robot per side. `--events` lists the window's kicks (with the nearest robot as kicker), possession changes, referee changes and fouls, one line each; `--json` writes rows or events as JSON. The first thing to run on a stall, a voided restart or a foul | -| `tools/match_timeline.py` | One match window as swimlanes: `REPLAY.npz T0 T1 [--side friendly\|enemy]`. Referee command band, one lane per robot coloured by its tactic (ticks at switches, strip where it had the ball), distance of each robot to the ball, and goals, fouls and shots on top; prints switches per minute and the longest tactic span per robot. Use it for thrashing and everyone-chasing-the-ball; example in [STRATEGY_DEVELOPMENT.md](STRATEGY_DEVELOPMENT.md). `--findings PATH`: one `tactic_thrash` per robot at or above `FLIP_BACKS_PER_MIN` (2) flip-backs per minute of live play (a tactic held under 1 s, then reverted; raw switch rate is not the signal, most strategies switch 10-25 times a minute by design); `timeline_findings(replay, t0, t1, side)` computes it without drawing | -| `tools/repro_from_replay.py` | Load a replay's field state at a timestamp into a fresh headless rsim match and tick forward with tracing on. Plays with the replay's own sim noise by default (`--sim-noise none` for noiseless, `--sim-noise PATH` for another). `--summary ROBOT_IDS` prints each listed robot's tactic, position, distance to the ball, referee command and traced target every 0.25 s; `--trace-out` JSONL row kinds are in `--help` | -| `tools/plan_snapshot.py` | Picture of what the fast-path planner decided for one robot on one tick: `REPLAY.npz --t S --robot ID [--target X Y] [--side enemy]` runs the planner's `_path_to` on the replay's field state and draws the pitch around the robot: every robot with its id and radius, the ball and its keep-out circle, each clearance ring, the target, the carrot returned, and the referee command and distances. `--full-pitch` shows the whole pitch; with no `--target` the robot's position 0.5 s later stands in. Read-only. See [STRATEGY_DEVELOPMENT.md](STRATEGY_DEVELOPMENT.md), "Debugging a foul or failure" | -| `tools/restart_picture.py` | Picture of where the referee override sends every friendly robot for one restart: `REPLAY.npz --t S [--side enemy]`, or `--all-restarts` for one small panel per restart command in the replay's referee sidecar (at most 8). Runs `RefereeOverride.tick` for the replay's command and draws each robot's commanded target with its role (kicker, placer, keeper), the ball and its 0.8 m keep-out, the placement spot and the other team faded. A robot whose target is inside the keep-out or a defence area it must avoid is flagged in red, with the text box. Read-only. `--findings PATH`: `target_in_keep_out`, `keep_out_short` (the 1 cm stop deadband) and `target_in_defense_area` for every restart in the match, each occurrence, without drawing (`restart_findings(replay, side)`). See [STRATEGY_DEVELOPMENT.md](STRATEGY_DEVELOPMENT.md), "Referee handling" | -| `tools/plan_trace.py` | The fast-path planner over a time window: `REPLAY.npz --t0 S --t1 S --robot ID [--side enemy] [--target X Y] [--step 0.1] [--lookahead 0.5] [--json]` runs the planner's `_path_to` on every sampled tick and draws one PNG: the robot's path coloured by time with each tick's carrot joined to it, the ball path, the keep-out circle and clearance rings at the end, and time panels for robot-to-ball distance, robot-to-carrot length, speed and the referee command. Without `--target` each tick's target is the robot's position `--lookahead` s later. Robot positions are the replay's, not re-simulated: it shows what the current planner would do from each recorded state. Read-only; `--json` prints the per-tick rows. `--findings PATH` writes one `parked` or `pushed_out` finding per run of at least 1 s (`PARKED_MIN_S`) of short carrot with the target far. See [STRATEGY_DEVELOPMENT.md](STRATEGY_DEVELOPMENT.md), "Debugging a foul or failure" | -| `tools/moments.py` | Regression moments (`utama_core/tests/moments/`): `fouls RUN_DIR` lists our side's fouls in a round-robin with the restart side (`--skip-own-restart`, `--by strategy,rule` for counts, `--include-stoppages` for out_of_bounds, `--json` for either as JSON; each foul names its match's `replay` .npz relative to the repo root), `capture REPLAY --t S [--out PATH]` writes a moment from a replay, `new NAME --command CMD` writes a hand-made template, `play JSON [--seed N \| --seeds 0-4] [--against REF] [--events] [--strategy FILE.py:FACTORY]` plays one and prints what broke its checks (a seed table, the same moment at another commit, its events, a scratch strategy). See [STRATEGY_DEVELOPMENT.md](STRATEGY_DEVELOPMENT.md), "Debugging a foul or failure" | -| `tools/debug_match.py` | One ad hoc match between two strategies for tactic debugging; `--dump-ticks` writes per-tick poses and commanded targets | +| `tools/debug/find_bugs.py` | **Start here.** `RUN_DIR [--strategy NAME] [--matches 3] [--restarts] [--out DIR] [--max-pictures 8] [--workers 2]`: each strategy's N worst matches by goal difference, among those it played as config_a (the side with an intentions log: about half its matches in a round), every flagged problem with its numbers (`tactic_thrash`, `stall`, and with `--restarts` the `target_in_keep_out` / `keep_out_short` / `target_in_defense_area` restart flags), the top K drawn with the picture tool for that kind. Writes `OUT/index.md` (read first), `OUT/findings.jsonl` and `OUT/pictures/`; default OUT is `RUN_DIR/find_bugs/`. `--restarts` is slow (about 45 s a match). `--fouls` instead lists our side's fouls with the referee command then active and the restart side (`--rule`, `--skip-own-restart`, `--by strategy,rule` for counts, `--include-stoppages` for out_of_bounds, `--json`; until 2026-11-11 `tools/debug/moments.py fouls`). Read-only. See [strategy.md](strategy.md), "Debugging a foul or failure" | +| `tools/debug/replay_trace.py` | Text trace of a replay window: referee commands, ball, nearest robot per side. `--events` lists the window's kicks (with the nearest robot as kicker), possession changes, referee changes and fouls, one line each; `--json` writes rows or events as JSON. The first thing to run on a stall, a voided restart or a foul | +| `tools/debug/match_timeline.py` | One match window as swimlanes: `REPLAY.npz T0 T1 [--side friendly\|enemy]`. Referee command band, one lane per robot coloured by its tactic (ticks at switches, strip where it had the ball), distance of each robot to the ball, and goals, fouls and shots on top; prints switches per minute and the longest tactic span per robot. Use it for thrashing and everyone-chasing-the-ball; example in [strategy.md](strategy.md). `--findings PATH`: one `tactic_thrash` per robot at or above `FLIP_BACKS_PER_MIN` (2) flip-backs per minute of live play (a tactic held under 1 s, then reverted; raw switch rate is not the signal, most strategies switch 10-25 times a minute by design); `timeline_findings(replay, t0, t1, side)` computes it without drawing | +| `tools/debug/repro_from_replay.py` | Load a replay's field state at a timestamp into a fresh headless rsim match and tick forward with tracing on. Plays with the replay's own sim noise by default (`--sim-noise none` for noiseless, `--sim-noise PATH` for another). `--summary ROBOT_IDS` prints each listed robot's tactic, position, distance to the ball, referee command and traced target every 0.25 s; `--trace-out` JSONL row kinds are in `--help` | +| `tools/debug/plan_snapshot.py` | Picture of what the fast-path planner decided for one robot on one tick: `REPLAY.npz --t S --robot ID [--target X Y] [--side enemy]` runs the planner's `_path_to` on the replay's field state and draws the pitch around the robot: every robot with its id and radius, the ball and its keep-out circle, each clearance ring, the target, the carrot returned, and the referee command and distances. `--full-pitch` shows the whole pitch; with no `--target` the robot's position 0.5 s later stands in. Read-only. See [strategy.md](strategy.md), "Debugging a foul or failure" | +| `tools/debug/restart_picture.py` | Picture of where the referee override sends every friendly robot for one restart: `REPLAY.npz --t S [--side enemy]`, or `--all-restarts` for one small panel per restart command in the replay's referee sidecar (at most 8). Runs `RefereeOverride.tick` for the replay's command and draws each robot's commanded target with its role (kicker, placer, keeper), the ball and its 0.8 m keep-out, the placement spot and the other team faded. A robot whose target is inside the keep-out or a defence area it must avoid is flagged in red, with the text box. Read-only. `--findings PATH`: `target_in_keep_out`, `keep_out_short` (the 1 cm stop deadband) and `target_in_defense_area` for every restart in the match, each occurrence, without drawing (`restart_findings(replay, side)`). See [strategy.md](strategy.md), "Referee handling" | +| `tools/debug/plan_trace.py` | The fast-path planner over a time window: `REPLAY.npz --t0 S --t1 S --robot ID [--side enemy] [--target X Y] [--step 0.1] [--lookahead 0.5] [--json]` runs the planner's `_path_to` on every sampled tick and draws one PNG: the robot's path coloured by time with each tick's carrot joined to it, the ball path, the keep-out circle and clearance rings at the end, and time panels for robot-to-ball distance, robot-to-carrot length, speed and the referee command. Without `--target` each tick's target is the robot's position `--lookahead` s later. Robot positions are the replay's, not re-simulated: it shows what the current planner would do from each recorded state. Read-only; `--json` prints the per-tick rows. `--findings PATH` writes one `parked` or `pushed_out` finding per run of at least 1 s (`PARKED_MIN_S`) of short carrot with the target far. See [strategy.md](strategy.md), "Debugging a foul or failure" | +| `tools/debug/moments.py` | Regression moments (`utama_core/tests/moments/`): `capture REPLAY --t S [--out PATH]` writes a moment from a replay (starting points: `tools/debug/find_bugs.py RUN_DIR --fouls`), `play JSON [--seed N \| --seeds 0-4] [--against REF] [--events] [--strategy FILE.py:FACTORY]` plays one and prints what broke its checks (a seed table, the same moment at another commit, its events, a scratch strategy). See [strategy.md](strategy.md), "Debugging a foul or failure" | +| `tools/debug/debug_match.py` | One ad hoc match between two strategies for tactic debugging; `--dump-ticks` writes per-tick poses and commanded targets | Library helpers for the same job (`render_window`, `render_clip`, `MatchLog.trace()`) are -described in [STRATEGY_DEVELOPMENT.md](STRATEGY_DEVELOPMENT.md). +described in [strategy.md](strategy.md). + +## Simulator realism + +Is the simulator close to the real league, and are its physics settings measured? These tools judge +the simulator, not a strategy: none of them is part of strategy development. Their inputs are the official logs converted by +`tools/realism/convert_ssl_log.py` (its kick and visibility sidecars, see [Real matches](#real-matches)) and +the field logs in `replays/field/`. + +| Script | Purpose | +|---|---| +| `tools/realism/realism_scorecard.py` | Our sim against real Division B matches, component by component: attempts per live minute (open play and set pieces), attempt distance, real xG per attempt, finishing, goal rate and keeper saves per xG band, shot outcomes (keeper, defender, wide, post, crossed with no goal), aim outside the posts and miss distance, ball slow-down, kick speed, keeper depth, keeper and nearest-defender reaction time (`utama_core/analysis/realism/reaction.py`), pass line offset and completion (`passes.py`). Each row: the real value and 95% interval, the sim value, and whether it is inside. `--real` rebuilds the committed reference (`utama_core/analysis/realism/real_2025_2026.json`: the real xG model and rows) from converted logs; `--sim RUN_DIR` scores a round-robin against it. Attempts exclude passes and kicks from beyond 6 m. | +| `utama_core/analysis/physics_ranges.py` | `python -m utama_core.analysis.physics_ranges --real --sim `: physics parameter ranges: ball deceleration by speed and time since a kick, rolling-segment fits, robot speed, acceleration, braking and turn-rate percentiles per robot, and dropped detections, with spreads between matches, robots and teams | +| `tools/field/field_physics.py` | Measures the world settings from field logs, only from sessions `tools/field/field_sessions.json` allows, and prints how well runs, days and radios agree. | +| `tools/field/robot_calibration.py` | A robot's numbers from a recorded field test (`replays/field/*.log`): loop delay, speed gain and acceleration per axis (the sim's move model fitted to the camera's positions), vision noise at rest and missed detections, kick speed. Writes `.calibration.json`. The same log converts to a replay with `tools/realism/convert_ssl_log.py` | ## Architecture | Script | Purpose | |---|---| -| `tools/package_graph.py` | The import graph between `utama_core/` packages, as a Mermaid flowchart with import counts, from `ast` (nothing is imported), plus any violation of the stated import rules (`replay/` never imports `analysis/`). Its output is kept in [architecture.md](architecture.md) | +| `tools/dev/package_graph.py` | The import graph between `utama_core/` packages, as a Mermaid flowchart with import counts, from `ast` (nothing is imported), plus any violation of the stated import rules (`replay/` never imports `analysis/`). Its output is kept in [architecture.md](architecture.md) | ## Benchmarks | Script | Purpose | |---|---| -| `tools/motion_planning_benchmark.py` | The motion planners (`fpp`, `dwa`, `trajsample`) on fixed headless rsim scenarios; `--figures DIR` also writes trajectory and summary PNGs; see [motion_planning_comparison.md](motion_planning_comparison.md) | +| `tools/motion_planning_benchmark.py` | The motion planners (`fpp`, `dwa`, `trajsample`) on fixed headless rsim scenarios; `--figures DIR` also writes trajectory and summary PNGs; see [motion_planning.md](motion_planning.md) | ## Demos and external environments | Script | Purpose | |---|---| -| `main.py` | Watch one match in rsim with the referee and dashboard: `pixi run main [yellow] [blue]`, default `split_shape` vs `high_press` | +| `main.py` | Watch one match in rsim with the referee and dashboard: `pixi run main [yellow] [blue]`, default `pendulum` vs `wolfpack`. | | `examples/demo_custom_referee.py` | Every `CustomReferee` rule in a scripted scenario, in a pygame window; no simulator needed | | `examples/demo_referee_gui_rsim.py` | `CustomReferee` with the dashboard's referee tab, over rsim | | `examples/demo_referee_feedback_gui.py` | The referee UI's controller-feedback panel with fake feedback, no hardware | | `examples/demo_exhibition_road.py` | The Exhibition Road festival demo on the 4 m x 3 m field, over rsim | | `examples/demos.py` | `pixi run demos`: shooting drill, pass-receive, save-and-counter and score goal behind one dashboard, switched from the Live tab's Demo panel while halted | | `examples/teleop.py` | Drive either robot by keyboard from the Live tab's Teleop panel (after Force Start; stops on key release, Halt, or the page going quiet); also a demo in `pixi run demos` | -| `examples/calibrate_robot.py` | `pixi run calibrate`: one real robot's profile from the terminal, no dashboard; `--mode rsim --yes` rehearses it | -| `examples/ball_trials.py` | `pixi run calibrate`'s ball part: fetches the ball itself, carries it at rising speeds each way until it loses it, then kicks, each charged; aimed at a target for `--check` | -| `examples/shooting_drill.py` | One robot shoots at a goal the other defends (the keeper feeds the ball back, so it loops) on real robots (or `--mode rsim`/`grsim`): field, camera half, IDs and each robot's working hardware in one config block; the Live tab's field check gates the start. Records every camera run as an SSL game log in `replays/field/`; `--calibrate attacker\|defender` plays fixed moves for measuring that robot | -| `examples/save_and_counter.py` | A 1v1 game where a keeper that saves takes the ball and counterattacks, on real robots (or `--mode rsim`/`grsim`), a goal each: each robot keeps its goal and attacks the other's, reading every tick from the same world whether it attacks or keeps; a keeper's save turns it into the attacker. Field, rules and hardware type from `shooting_drill.py` | +| `tools/field/calibrate_robot.py` | `pixi run calibrate`: one real robot's profile from the terminal, no dashboard; `--mode rsim --yes` rehearses it | +| `tools/field/ball_trials.py` | `pixi run calibrate`'s ball part: fetches the ball itself, carries it at rising speeds each way until it loses it, then kicks, each charged; aimed at a target for `--check` | +| `tools/field/shooting_drill.py` | One robot shoots at a goal the other defends (the keeper feeds the ball back, so it loops) on real robots (or `--mode rsim`/`grsim`): field, camera half, IDs and each robot's working hardware in one config block; the Live tab's field check gates the start. Records every camera run as an SSL game log in `replays/field/`; `--calibrate attacker\|defender` plays fixed moves for measuring that robot | +| `examples/save_and_counter.py` | A 1v1 game where a keeper that saves takes the ball and counterattacks, on real robots (or `--mode rsim`/`grsim`), a goal each: each robot keeps its goal and attacks the other's, reading every tick from the same world whether it attacks or keeps; a keeper's save turns it into the attacker. Field, rules and hardware type from `tools/field/shooting_drill.py` | | `examples/pass_receive.py` | Two robots (one per team, so two colours) pass to each other on real robots (or `--mode rsim`/`grsim`): the robot nearer the ball passes once its partner is still and facing it, the other gets open and receives. The Live tab shows each robot's role | +| `examples/score_goal.py` | One robot, no opponent, takes the ball and scores, on a real robot (or `--mode rsim`); also a demo in `pixi run demos` | +| `examples/dribble_and_shoot.py` | `score_goal.py`'s robot dribbles a lap of the field, then scores | | `examples/passing_rally.py` | `pass_receive.py`'s pair passing their way along the field in two lanes, turning round `TURN_M` from each end line, for ever (no shots) | -| `tools/vision_check.py` | Does ssl-vision's multicast reach this machine: sender, packets per second per camera, detections and the field size, in 5 s with no radio or runner. The first check of a test day ([real_robot_setup.md](real_robot_setup.md)). `--guided ball` (or `"blue 2"`): each camera's error on 9 known spots, saved as a baseline | -| `tools/ssl-vision-lab-field.patch` | Not a script: adds a **Lab Field** preset (our 3 m x 2.25 m field, two cameras) to an ssl-vision checkout; `git apply` it there and rebuild | -| `tools/robot_calibration.py` | A robot's numbers from a recorded field test (`replays/field/*.log`): loop delay, speed gain and acceleration per axis (the sim's move model fitted to the camera's positions), vision noise at rest and missed detections, kick speed. Writes `.calibration.json`. The same log converts to a replay with `tools/convert_ssl_log.py` | +| `tools/field/vision_check.py` | Does ssl-vision's multicast reach this machine: sender, packets per second per camera, detections and the field size, in 5 s with no radio or runner. The first check of a test day ([field_day.md](../tutorials/field_day.md)). `--guided ball` (or `"blue 2"`): each camera's error on 9 known spots, saved as a baseline | +| `tools/field/trim_idle_log.py` | Cuts long HALT/STOP dead time out of a field log (`replays/field/.log.gz`, `--dry-run` first, `--in-place`) ([real_robots.md, "Field logs"](real_robots.md#field-logs)) | +| `tools/field/package_logs.py` | Small archives to share: a tournament's results without the large `.npz` arrays, or field logs compressed with their calibration files ([real_robots.md, "Field logs"](real_robots.md#field-logs)) | +| `tools/field/ssl-vision-lab-field.patch` | Not a script: adds a **Lab Field** preset (our 3 m x 2.25 m field, two cameras) to an ssl-vision checkout; `git apply` it there and rebuild | | `utama_core/analysis/close_calls.py` | Where two robots came within 0.25 m of each other in field logs (`replays/field/*.log`): how near, how fast they were closing, and the referee command in force; only the robots the run drove, `--tag` per robot. `python -m utama_core.analysis.close_calls replays/field/*real*.log` | | `examples/planner_ab.py` | Two robots swap ends head on and cross, again and again, in blocks alternating the planner (fpp, trajsample): contacts, close calls, nearest approach and time per planner; every block a game log. The field A/B of the motion planners | | `examples/demo_dribbler_test.py` | One robot dribbling round a rectangle on the Exhibition Road field | -| `examples/demo_split_shape_match.py` | Visible grSim 6v6 of `split_shape` against itself | +| `examples/demo_pendulum_match.py` | Visible grSim 6v6 of `pendulum` against itself | diff --git a/docs/visual_guide.md b/docs/visual_guide.md deleted file mode 100644 index b3e64745a..000000000 --- a/docs/visual_guide.md +++ /dev/null @@ -1,198 +0,0 @@ -# Seeing the game - -What our robots actually do, drawn on the pitch from real replays: how each strategy plays, one match -over time, a restart, and the motion planner, from fixed scenarios down to a single tick. Each section -gives the picture, how to read it, what it has shown us so far, and the command that draws it. - -A picture explains a result; it never makes one. Strategies are judged on goals -([STRATEGY_DEVELOPMENT.md](STRATEGY_DEVELOPMENT.md), "Evaluating a strategy"), and every claim a -picture suggests is confirmed with numbers before it is acted on. Each picture tool can also write the -problems it flags as JSON (`--findings`, format in [tools.md](tools.md)), for filtering without -opening images. An agent misread a planner trace once in this repo: the numbers caught it. - -Conventions in every pitch picture: blue is the side being studied, orange the other team (faded when it -is context), the pitch is in metres with the centre at (0, 0), and the strategy maps turn every match -so the studied strategy attacks right. Zone names (defensive third, the box, ...) are the ones in -[pitch_zones.md](pitch_zones.md). - -## Start here: triage - -`pixi run python tools/triage.py RUN_DIR --strategy NAME` picks the strategy's worst matches (by goal -difference, among those it played as config_a), collects every problem the tools flag (tactic flip-backs, -stalls, and with `--restarts` illegal restart targets), and draws the worst few with the picture for that -kind. Read its `index.md` first: each problem's numbers, then the picture path. About 20 s a match -(a minute with `--restarts`); `evaluate.py --explain` runs it on the candidate's two worst matches. - -A stall it found in `split_shape` against `tiki_taka_plus`: from 783 to 786 s, four of our robots -oscillate with the ball frozen. The picture is the match timeline around it, recorded data only: - -![a stall in the match timeline](img/match_timeline/stall_split_shape_773-796.png) - -Robots 2-4 switch between `ShadowAndMarkTactic` and `LeadAndSupportTactic` together, three times within -half a second at 780.5 s and again at 782.4, 783.2 and 785.2 s, while robots 0, 1, 2 and 5 stay within -about 2 m of the ball and robot 4 stays 5-8 m away. - -## 1. How a strategy plays - -### Where its robots stand: the position map - -![positions in possession](img/signals/positions_attack.png) - -One panel per strategy from the latest round-robin, in order of points per match (the number after the -name). Darker cells hold more of the outfield robots' samples while the strategy has the ball; black dots -are each robot's mean position. The same picture without the ball: - -![positions out of possession](img/signals/positions_defence.png) - -What it shows: - -- Most strategies stand on **vertical lines**: robots spread across the pitch at one depth, one line - just outside our box (x ≈ −2.6 m) and one near theirs (x ≈ +3.0 m), with or without the ball. - Which tactic draws them, from the intentions log (live play, robots on the line): - - the line in our half is mostly `BlockShapeTactic`'s screen, held at a fixed depth by design - (`_SCREEN_OFFSET` in front of our box, shifting only sideways with the ball): 73-83% of the - samples there in `clear_danger`, `counter_flow`, `press_trigger_flow`, `score_aware_counter_flow` - and `clear_press_plus`. Those robots stand still 57-63% of the time, with the ball a median - 2-3 m ahead of them. `split_shape` and `decoy_and_overload` draw the same kind of line with - `ShadowAndMarkTactic` a little deeper (x ≈ −3.0 m). - - the lines from `GiveAndGoTactic` (x ≈ −2.4 and +3.0 m in `give_and_go_solo` and `high_press`) - are not explained yet: the ball is at the same depth (median 0 m ahead), mostly near a - touchline (median |y| 2.4-2.6 m). - A fixed line is not by itself why a strategy loses: `clear_danger` holds the screen and ranks - fourth. Whether a ball-following depth beats it is a question for `evaluate.py`, not this - picture. -- `split_shape`, the top scorer, keeps most of its outfield robots in **its own defensive third even - with the ball**, and attacks with one or two. `overload_press` is the opposite: a block just past - halfway, in and out of possession. -- `decoy_and_overload` sits deep in a cluster in front of its own box. - -### Where it shoots from, and concedes: the shot map - -![shots for and against](img/signals/shots.png) - -Blue are the strategy's own shots at the spot they were struck from (filled: a goal), faded orange the -shots it conceded. `split_shape` takes 241 shots in its 11 matches, from all over the attacking half, -two and a half times the next strategy; the others take 69-98. - -### Where it fouls - -![fouls by rule](img/signals/fouls_map.png) - -Each foul at the ball's spot, coloured by rule (one fixed colour per rule, the same in every panel): -which rules a strategy breaks, and where on the pitch. - -Draw: `pixi run python tools/pitch_maps.py replays/tournament_` (a full round-robin, about 3 min). -The rest of the strategy report, as numbers: [signal_report.md](signal_report.md). - -## 2. A candidate against the champion - -![candidate against champion, positions](img/explain/positions.png) - -The same maps for just two strategies, a candidate and the champion, side by side on one colour scale; -`evaluate.py --explain` draws them (with shots, fouls and a `summary.json`) before an evaluation removes -its replays. This example is drawn from the round-robin: `split_shape` holds 37% of its possession in the -attacking half against `clear_press_plus`'s 65%, yet takes 21.9 shots a match against 6.3, and commits -twice the fouls (10.0 against 4.7 a match, mostly ball held in the defense area and crashing). - -Draw: `tools/evaluation/evaluate.py CANDIDATE --explain`, or `tools/evaluation/explain.py RUN_DIR -CANDIDATE CHAMPION --out DIR` on any run dir. - -## 3. One match over time - -![split_shape timeline](img/match_timeline/split_shape_100-160.png) - -Sixty seconds of `split_shape` against `tiki_taka_plus`. From the top: events (fouls, shots), the -referee command, one lane per robot coloured by the tactic it was in (a tick at each switch, a black strip -while it had the ball), and each robot's distance to the ball. Hatched lanes are stoppages, where the -referee override moves robots instead of their tactics. - -What it shows: robots 2-4 switch between `ShadowAndMarkTactic` and `LeadAndSupportTactic` together, -several times within a few seconds (112-117 s, 139-146 s), while robots 1 and 5 hold one tactic. Over a -whole round-robin, a tactic held under 1 s and then reverted (a flip-back) happens about 5 times a -minute in most strategies that split attack and defence on possession, 13 in `press_and_pass`, and -almost never in `give_and_go_solo`, `high_press` or `decoy_and_overload`. Not fixed yet. - -Draw: `pixi run python tools/match_timeline.py REPLAY.npz T0 T1`. - -## 4. A restart - -![free kick against us](img/restart_picture/free_kick_against_us.png) - -Where the referee override sends each of our robots at one restart: a free kick against us, ball at the -cross, the 0.8 m keep-out circle dashed. Each robot moves toward its commanded target (grey cross; red -when a target breaks a rule) or holds; the table lists each target and its distance from the ball. -Robot 3 starts inside the circle and is sent to exactly 0.80 m. - -Across more replays this picture found a real defect: the step that clears robots out of the circle -stops 1 cm short and leaves them at 0.79 m (`keep_out_short` in the findings). Fixed. - -Draw: `pixi run python tools/restart_picture.py REPLAY.npz --t S`, or `--all-restarts` for one panel per -restart command in the match. - -## 5. The motion planner on fixed scenarios - -The benchmark runs the three planners (`fpp`, the fast path planner we use, `dwa` and `trajsample`) on -fixed scenarios in headless rsim, with no strategy involved. - -![static slalom](img/motion_planning/trajectories_static_slalom.png) - -One robot crosses a staggered line of three parked opponents. `fpp` and `trajsample` drive almost -straight through (the gaps are wide enough) at 2 m/s, 12 cm from the nearest robot at worst; -`trajsample` brakes briefly at each obstacle. `dwa` slows down from 1.3 s, weaves, stalls beside the -middle obstacle at x = 0 and touches it. - -![crossing](img/motion_planning/trajectories_crossing.png) - -Two of our robots, both driven by the planner under test, cross at right angles (dashed is the -second robot). With `fpp` one robot holds its line and the other swerves round it: closest pass 0.18 m, -both arrive. With `dwa` they converge and collide, and neither arrives. With speed modulation and angular penalties, `trajsample` yields cleanly with a tight bypass (path ratio 1.09x, 3.4s vs fpp's 3.3s). - -![benchmark summary](img/motion_planning/summary.png) - -Every metric per planner and scenario, each on its own scale; hollow dots are failed runs. - -Draw: `pixi run python tools/motion_planning_benchmark.py --figures DIR`. How to read the full -benchmark: [motion_planning_comparison.md](motion_planning_comparison.md). - -## 6. The motion planner in a real match - -### One tick - -![planner snapshot](img/plan_snapshot/kickoff_keep_out.png) - -The planner's decision for one robot on one recorded tick: every robot with its clearance ring, the -ball's keep-out circle (dashed), the robot's target and the carrot (the point the planner steers to this -tick). Here `tiki_taka_plus`'s robot 4 (the replay's enemy side) sits on the keep-out circle at a kickoff, 0.799 m from the ball; its target -(−1.0, −0.3) is across the circle. The planner's answer is a carrot 5 cm away: push the robot out to -0.85 m first. - -Draw: `pixi run python tools/plan_snapshot.py REPLAY.npz --t S --robot ID [--side enemy] [--target X Y]`. - -### A window - -![planner trace](img/plan_trace/kickoff_keep_out.png) - -The same robot over 12 s: its path coloured by time, the carrot at each sample (green dots, joined to -where the robot was), then distance to the ball, distance to the carrot, speed and the referee command. -The robot runs in, reaches the circle at about 255.5 s (dipping to 0.76 m), then holds 0.80 m from the ball for the rest of the -prepare-kickoff, 1.76 m short of its target. That was the planner before the push-out fix: it -parked robots on the circle. - -The trace replays recorded positions and runs today's planner on them; it does not re-simulate. So the -robot's path is the old behaviour, and the carrot line (0.05 m, at 0.85 m from the ball) is what today's -planner would do from there: push out first. The annotation names it "pushed out of the keep-out"; a -short carrot with nothing to push out of is labelled "parked". - -Draw: `pixi run python tools/plan_trace.py REPLAY.npz --t0 S --t1 S --robot ID [--side enemy] -[--target X Y]`. - -## Which picture for which question - -| Question | Picture | -|---|---| -| How does this strategy play, overall? | pitch maps (1) | -| Why did the candidate win or lose against the champion? | `--explain` (2) | -| What were the robots doing in this stretch of a match? Thrashing, everyone chasing the ball? | match timeline (3) | -| Where did the referee override put us at this restart, and was it legal? | restart picture (4) | -| Is the planner itself good at driving, with no strategy involved? | benchmark (5) | -| Why did this robot stop, detour or go the wrong way? | plan snapshot, then plan trace (6) | diff --git a/examples/demo_custom_referee.py b/examples/demo_custom_referee.py index 3ad633371..26d84e1f8 100644 --- a/examples/demo_custom_referee.py +++ b/examples/demo_custom_referee.py @@ -40,20 +40,20 @@ import pygame from utama_core.config.field_params import STANDARD_FIELD_DIMS -from utama_core.custom_referee import CustomReferee, RefereeGeometry from utama_core.entities.data.vector import Vector2D, Vector3D from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.game.robot import Robot from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.rsoccer_simulator.src.Render import COLORS, SSLRenderField -from utama_core.rsoccer_simulator.src.Render.ball import RenderBall -from utama_core.rsoccer_simulator.src.Render.overlay import ( +from utama_core.referee import CustomReferee, RefereeGeometry +from utama_core.simulator.render import COLORS, SSLRenderField +from utama_core.simulator.render.ball import RenderBall +from utama_core.simulator.render.overlay import ( OverlayObject, OverlayType, RenderOverlay, ) -from utama_core.rsoccer_simulator.src.Render.robot import RenderSSLRobot +from utama_core.simulator.render.robot import RenderSSLRobot # --------------------------------------------------------------------------- # Scene definition diff --git a/examples/demo_dribbler_test.py b/examples/demo_dribbler_test.py index 948823748..12ed39a1e 100644 --- a/examples/demo_dribbler_test.py +++ b/examples/demo_dribbler_test.py @@ -21,7 +21,7 @@ from utama_core.engine.abstract_strategy import AbstractStrategy from utama_core.engine.context import TickContext from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController from utama_core.run import StrategyRunner from utama_core.tactics.dribble import DribbleTactic @@ -42,7 +42,7 @@ def _build_dribbler_kernel_strategy(motion_controller: MotionController) -> Kern def main() -> None: runner = StrategyRunner( - strategy=AbstractStrategy(build_kernel_strategy=_build_dribbler_kernel_strategy), + strategy=AbstractStrategy(build=_build_dribbler_kernel_strategy), my_team_is_yellow=MY_TEAM_IS_YELLOW, my_team_is_right=MY_TEAM_IS_RIGHT, mode="rsim", diff --git a/examples/demo_exhibition_road.py b/examples/demo_exhibition_road.py index 2127d4f48..c95814183 100644 --- a/examples/demo_exhibition_road.py +++ b/examples/demo_exhibition_road.py @@ -8,11 +8,11 @@ What it does: - Uses GREAT_EXHIBITION_FIELD_DIMS (4 m × 3 m) — the compact field sized for the Exhibition Road festival venue. - - Builds a custom RefereeProfile inline (same style as Utama-Strategy/main.py) + - Builds a custom RefereeProfile inline (same style as `main.py`, run with `pixi run main` in this repo) with all rules enabled and human-operator auto-advance settings so a festival steward can control the game from the browser GUI. - 2v2 format: two yellow robots vs two blue robots, matching the small field. - - WanderingStrategy is used so robots visibly move and you can watch the + - wandering_strategy is used so robots visibly move and you can watch the RefereeOverride tree interrupt them when you issue commands from the dashboard. - The referee is attached to the browser dashboard at @@ -35,8 +35,10 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[1])) from utama_core.config.field_params import GREAT_EXHIBITION_FIELD_DIMS -from utama_core.custom_referee import CustomReferee -from utama_core.custom_referee.profiles.profile_loader import ( +from utama_core.dashboard import attach_dashboard +from utama_core.dashboard.views import referee as referee_view +from utama_core.referee import CustomReferee +from utama_core.referee.profiles.profile_loader import ( AutoAdvanceConfig, DefenseAreaConfig, GameConfig, @@ -46,10 +48,8 @@ RefereeProfile, RulesConfig, ) -from utama_core.dashboard import attach_dashboard -from utama_core.dashboard.views import referee as referee_view from utama_core.run import StrategyRunner -from utama_core.tests.referee.wandering_strategy import WanderingStrategy +from utama_core.tests.referee.wandering_strategy import wandering_strategy # --------------------------------------------------------------------------- # Configuration @@ -122,8 +122,8 @@ def main() -> None: referee_view.attach(server, referee, _EXHIBITION_PROFILE) runner = StrategyRunner( - strategy=WanderingStrategy(field_dims=GREAT_EXHIBITION_FIELD_DIMS), - opp_strategy=WanderingStrategy(field_dims=GREAT_EXHIBITION_FIELD_DIMS), + strategy=wandering_strategy(tuple(range(N_ROBOTS)), GREAT_EXHIBITION_FIELD_DIMS), + opp_strategy=wandering_strategy(tuple(range(N_ROBOTS)), GREAT_EXHIBITION_FIELD_DIMS), my_team_is_yellow=MY_TEAM_IS_YELLOW, my_team_is_right=MY_TEAM_IS_RIGHT, mode="rsim", diff --git a/examples/demo_split_shape_match.py b/examples/demo_pendulum_match.py similarity index 83% rename from examples/demo_split_shape_match.py rename to examples/demo_pendulum_match.py index ad1ee16c4..ba34e0b9f 100644 --- a/examples/demo_split_shape_match.py +++ b/examples/demo_pendulum_match.py @@ -1,5 +1,5 @@ # ruff: noqa: E402 -"""Visible grsim 6v6: both teams run the split-shape kernel Strategy against each other. +"""Visible grsim 6v6: both teams run the pendulum Strategy against each other. Not a test — a manual/visual smoke run for reviewing LeadAndSupportTactic / ShadowAndMarkTactic / the possession-split picker actually contesting an @@ -23,20 +23,20 @@ import time -from utama_core.custom_referee import CustomReferee -from utama_core.custom_referee.profiles.profile_loader import load_profile from utama_core.dashboard import attach_dashboard from utama_core.dashboard.views import referee as referee_view from utama_core.engine.abstract_strategy import AbstractStrategy +from utama_core.referee import CustomReferee +from utama_core.referee.profiles.profile_loader import load_profile from utama_core.run import StrategyRunner -from utama_core.strategy.kernel_strategy import build_split_shape_kernel_strategy +from utama_core.strategy.catalog import builder DURATION_SECONDS = 90 def main(): - my_strategy = AbstractStrategy(build_kernel_strategy=build_split_shape_kernel_strategy((1, 2, 3, 4, 5))) - opp_strategy = AbstractStrategy(build_kernel_strategy=build_split_shape_kernel_strategy((1, 2, 3, 4, 5))) + my_strategy = AbstractStrategy(build=builder("pendulum", (1, 2, 3, 4, 5))) + opp_strategy = AbstractStrategy(build=builder("pendulum", (1, 2, 3, 4, 5))) profile = load_profile("simulation") referee = CustomReferee(profile, n_robots_yellow=6, n_robots_blue=6) diff --git a/examples/demo_referee_feedback_gui.py b/examples/demo_referee_feedback_gui.py index 1d43be039..5a8cd8810 100644 --- a/examples/demo_referee_feedback_gui.py +++ b/examples/demo_referee_feedback_gui.py @@ -22,8 +22,6 @@ import math import time -from utama_core.custom_referee import CustomReferee -from utama_core.custom_referee.profiles.profile_loader import load_profile from utama_core.dashboard import attach_dashboard from utama_core.dashboard.views import referee as referee_view from utama_core.entities.data.vector import Vector2D, Vector3D @@ -31,6 +29,8 @@ from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.game.robot import Robot from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee import CustomReferee +from utama_core.referee.profiles.profile_loader import load_profile def _robot( diff --git a/examples/demo_referee_gui_rsim.py b/examples/demo_referee_gui_rsim.py index 91c633f04..36682f9c9 100644 --- a/examples/demo_referee_gui_rsim.py +++ b/examples/demo_referee_gui_rsim.py @@ -11,7 +11,7 @@ - Passes the referee to StrategyRunner via referee=. StrategyRunner calls referee.step() on every tick and handles ball teleports on STOP automatically — no patching required. - - build_tiki_taka_plus_kernel_strategy() builds the give-and-go + + - builder("weaver", ...) builds the give-and-go + final-third decoy-overload kernel strategy (see docs/strategies.md) so you can watch real tactic assignments in the dashboard's Live tab instead of an aimless wandering tactic, and watch @@ -20,7 +20,7 @@ Operator workflow: 1. Open http://localhost:8080 in a browser. - 2. Robots start playing under tiki_taka_plus; the Live tab's Tactics panel + 2. Robots start playing under weaver; the Live tab's Tactics panel shows each robot's current slot ("attack"/"overload"/"press"/"defense"). 3. Click any command button (Halt, Stop, Kickoff Yellow…) — robots reposition. 4. Click Normal Start to resume free play. @@ -33,13 +33,13 @@ # Run as `pixi run python examples/.py`: utama_core is not installed, so put the repo on the path. sys.path.insert(0, str(Path(__file__).resolve().parents[1])) -from utama_core.custom_referee import CustomReferee -from utama_core.custom_referee.profiles.profile_loader import load_profile from utama_core.dashboard import attach_dashboard from utama_core.dashboard.views import referee as referee_view from utama_core.engine.abstract_strategy import AbstractStrategy +from utama_core.referee import CustomReferee +from utama_core.referee.profiles.profile_loader import load_profile from utama_core.run import StrategyRunner -from utama_core.strategy.kernel_strategy import build_tiki_taka_plus_kernel_strategy +from utama_core.strategy.catalog import builder # --------------------------------------------------------------------------- # Configuration @@ -47,7 +47,7 @@ PROFILE = "human" # "human" or "simulation" DASHBOARD_PORT = 8080 -N_ROBOTS = 6 # robots per side (5 outfield + 1 goalkeeper) — tiki_taka_plus's tournament size +N_ROBOTS = 6 # robots per side (5 outfield + 1 goalkeeper) — weaver's tournament size MY_TEAM_IS_YELLOW = True MY_TEAM_IS_RIGHT = True @@ -69,7 +69,7 @@ def main() -> None: outfield_robot_ids = tuple(range(1, N_ROBOTS)) runner = StrategyRunner( - strategy=AbstractStrategy(build_kernel_strategy=build_tiki_taka_plus_kernel_strategy(outfield_robot_ids)), + strategy=AbstractStrategy(build=builder("weaver", outfield_robot_ids)), my_team_is_yellow=MY_TEAM_IS_YELLOW, my_team_is_right=MY_TEAM_IS_RIGHT, mode="rsim", @@ -78,7 +78,7 @@ def main() -> None: exp_enemy=N_ROBOTS, referee=referee, # StrategyRunner drives referee.step() each tick show_live_status=True, - opp_strategy=AbstractStrategy(build_kernel_strategy=build_tiki_taka_plus_kernel_strategy(outfield_robot_ids)), + opp_strategy=AbstractStrategy(build=builder("weaver", outfield_robot_ids)), ) runner.run() diff --git a/examples/demos.py b/examples/demos.py index d97a1367f..7f7fc6f67 100644 --- a/examples/demos.py +++ b/examples/demos.py @@ -22,7 +22,7 @@ same demo again; - "teleop" (`teleop.py`): drive either robot by keyboard to place robots and the ball. -`planner_ab.py` and `calibrate_robot.py` are not here: they measure, with their own loop and +`planner_ab.py` and `tools/field/calibrate_robot.py` are not here: they measure, with their own loop and terminal prompts, rather than wait on the dashboard. """ @@ -30,19 +30,18 @@ from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent)) -sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "tools")) +sys.path.insert(0, str(Path(__file__).resolve().parents[1])) import argparse import signal import traceback -import field_check import pass_receive import save_and_counter import score_goal -import shooting_drill import teleop +from tools.field import field_check, shooting_drill from utama_core.dashboard import attach_dashboard from utama_core.dashboard.views import demo as demo_view diff --git a/examples/dribble_and_shoot.py b/examples/dribble_and_shoot.py index b9f52f995..164b1038f 100644 --- a/examples/dribble_and_shoot.py +++ b/examples/dribble_and_shoot.py @@ -7,7 +7,7 @@ # the dashboard is at http://localhost:8080: press Force Start to play, Halt to freeze Everything else is `score_goal.py`: the robot set there (`SHOOTER`), the field and camera -view from `shooting_drill.py`, HALT at start, the field check. The robot fetches the +view from `tools/field/shooting_drill.py`, HALT at start, the field check. The robot fetches the ball and dribbles it corner to corner round a rectangle at 55% of the field (`DribbleTactic`, letting go and taking the ball back every 0.8 m, inside the 1 m dribbling rule), and after `LAPS` laps shoots at the goal at +x (`LeadAndSupportTactic`). For another go: Halt, put the diff --git a/examples/pass_receive.py b/examples/pass_receive.py index 6fb1b71d0..81c60d50f 100644 --- a/examples/pass_receive.py +++ b/examples/pass_receive.py @@ -15,17 +15,17 @@ collects it and passes again. A ball outside the field (or unseen) holds both robots until the operator puts it back. - Everything to edit for a test day is in the "Test-day configuration" block. The field, the - ball-sensor/kicker profile type and the referee rules are `shooting_drill.py`'s + ball-sensor/kicker profile type and the referee rules are `tools/field/shooting_drill.py`'s (`FIELD`, `TestRobot`, `RULES`), so the examples agree. - Nothing advances on its own: every mode starts in HALT, play starts and stops from the dashboard. Ctrl+C sends stop commands to the robots before exiting. The Live tab's Strategy panel can stand either robot still ("still") or restart it ("pass_receive"), while halted. - The field check on the Live tab must be all green or amber before Force Start, as in - `shooting_drill.py` (docs/real_robot_setup.md, "Each test day"). + `tools/field/shooting_drill.py` (tutorials/field_day.md, "Each test day"). Why two teams: the robots wear different pattern colours (yellow 1, blue 0), and a runner team is one colour: there is no way to map a blue pattern into the yellow team. So each robot is its -own team (`strategy` and `opp_strategy`, as in `shooting_drill.py`), and each runs the +own team (`strategy` and `opp_strategy`, as in `tools/field/shooting_drill.py`), and each runs the same `PassReceiveTactic`, which reads the other robot (its only "enemy") as its partner. The two never share state: each decides its role from the same world they both see (who is nearer the ball, where the ball is rolling, whether the partner is set), so the pass needs no new @@ -56,7 +56,7 @@ import time from typing import Optional -from shooting_drill import ( +from tools.field.shooting_drill import ( FIELD, KEEP_OUT, RADIO_0, @@ -67,9 +67,7 @@ _referee_profile, on_field, ) - from utama_core.config.physical_constants import BALL_RADIUS, ROBOT_RADIUS -from utama_core.custom_referee import CustomReferee from utama_core.dashboard import DashboardServer, attach_dashboard from utama_core.dashboard.views import referee as referee_view from utama_core.dashboard.views import strategy as strategy_view @@ -80,9 +78,8 @@ from utama_core.entities.game import Game from utama_core.entities.game.robot import Robot from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.global_utils.math_utils import detour_around_circle -from utama_core.run import StrategyRunner -from utama_core.shared.pass_and_score_geometry import ( +from utama_core.geometry.math_utils import detour_around_circle +from utama_core.geometry.pass_and_score_geometry import ( ORIENTATION_TOLERANCE_RAD, ball_line_receive_point, clamp_outside_enemy_defense_area, @@ -92,12 +89,9 @@ kick_bend, oriented_towards, ) -from utama_core.skills.src.utils.move_utils import ( - empty_command, - kick, - move, - turn_on_spot, -) +from utama_core.referee import CustomReferee +from utama_core.run import StrategyRunner +from utama_core.skills.utils.move_utils import empty_command, kick, move, turn_on_spot from utama_core.tactics.scripted_moves import ScriptedMovesTactic # --------------------------------------------------------------------------- @@ -106,7 +100,7 @@ MODE = "real" # "real", "rsim" or "grsim"; --mode overrides it -# The part of the field the cameras see (see `shooting_drill.py`); both cameras: "full". +# The part of the field the cameras see (see `tools/field/shooting_drill.py`); both cameras: "full". CAMERA_HALF = "full" # Swapping a robot is a change here only. They must wear different colours (one per team). diff --git a/examples/passing_rally.py b/examples/passing_rally.py index 12de1695f..5ff7dd4dd 100644 --- a/examples/passing_rally.py +++ b/examples/passing_rally.py @@ -19,7 +19,7 @@ the ball back and Force Start. The Live tab shows each robot's role (pass, receive, get_open) under its tactic. - Robots and the readiness checks are `pass_receive.py`'s ("Test-day - configuration" there); the field and the referee rules are `shooting_drill.py`'s. + configuration" there); the field and the referee rules are `tools/field/shooting_drill.py`'s. """ import sys @@ -49,8 +49,8 @@ from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game from utama_core.entities.game.robot import Robot +from utama_core.geometry.pass_and_score_geometry import clamp_to_field from utama_core.run import StrategyRunner -from utama_core.shared.pass_and_score_geometry import clamp_to_field # --------------------------------------------------------------------------- # Test-day configuration (the robots and the pass distance are pass_receive.py's) diff --git a/examples/planner_ab.py b/examples/planner_ab.py index 37cd1a6c5..be1b59b1e 100644 --- a/examples/planner_ab.py +++ b/examples/planner_ab.py @@ -10,7 +10,7 @@ blocks (A B A B ...) so a battery running down or the floor changing over the session falls on both alike. In a block both robots run one planner (`--schemes`, default fpp then trajsample). -The robots are `pass_receive.py`'s pair (one per colour), on `shooting_drill.py`'s field. Each +The robots are `pass_receive.py`'s pair (one per colour), on `tools/field/shooting_drill.py`'s field. Each leg, both drive to a new spot at once, facing where they go, across each other's way: head on (`HEAD_ON`), back, then crossing on the diagonals (`CROSS`), back, and so on. A leg ends once both stand on their spots (within `ARRIVED_M`), or after `LEG_TIMEOUT_S`. Per leg it records how @@ -36,7 +36,8 @@ from typing import Optional from pass_receive import ROBOT_A, ROBOT_B -from shooting_drill import ( + +from tools.field.shooting_drill import ( CAMERA_HALF, FIELD, KEEP_OUT, @@ -45,7 +46,6 @@ no_rules_referee, on_field, ) - from utama_core.config.physical_constants import ROBOT_RADIUS from utama_core.engine.context import TickContext from utama_core.engine.tactic import BaseTactic, RobotId, TacticTag @@ -54,7 +54,7 @@ from utama_core.entities.game import Game from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.run import StrategyRunner -from utama_core.skills.src.utils.move_utils import move +from utama_core.skills.utils.move_utils import move # (robot A's spot, robot B's spot) per leg, in turn; the first is where they start. START = (Vector2D(-0.8, 0.0), Vector2D(0.8, 0.0)) diff --git a/examples/save_and_counter.py b/examples/save_and_counter.py index 6aba9acfa..31014e21b 100644 --- a/examples/save_and_counter.py +++ b/examples/save_and_counter.py @@ -21,12 +21,12 @@ - A ball rolling towards a robot's goal (a shot, a clearance) has that robot keeping and the other attacking, so nobody leaves the goal to chase a shot. A ball outside the field (or unseen) holds both robots until the operator puts it back. - - The field, the robot hardware type and the referee rules are `shooting_drill.py`'s + - The field, the robot hardware type and the referee rules are `tools/field/shooting_drill.py`'s (`FIELD`, `TestRobot`, `RULES`): only goals are detected. After a goal play stops; put the ball back and Force Start. Both goals must be in view (`CAMERA_HALF = "full"`). - Every mode starts in HALT; Ctrl+C sends stop commands to the robots before exiting. The Live tab's Strategy panel can stand either robot still or restart it, while halted. The field - check must be all green or amber before Force Start (docs/real_robot_setup.md). + check must be all green or amber before Force Start (tutorials/field_day.md). """ import sys @@ -40,7 +40,7 @@ import time from typing import Optional -from shooting_drill import ( +from tools.field.shooting_drill import ( FIELD, KEEP_OUT, RADIO_0, @@ -51,9 +51,7 @@ _referee_profile, on_field, ) - from utama_core.config.physical_constants import ROBOT_RADIUS -from utama_core.custom_referee import CustomReferee from utama_core.dashboard import DashboardServer, attach_dashboard from utama_core.dashboard.views import referee as referee_view from utama_core.dashboard.views import strategy as strategy_view @@ -63,14 +61,15 @@ from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.run import StrategyRunner -from utama_core.shared.pass_and_score_geometry import ( +from utama_core.geometry.pass_and_score_geometry import ( enemy_goal_line, has_ball, oriented_towards, ) -from utama_core.skills.src.go_to_ball import go_to_ball -from utama_core.skills.src.utils.move_utils import empty_command, move, turn_on_spot +from utama_core.referee import CustomReferee +from utama_core.run import StrategyRunner +from utama_core.skills.go_to_ball import go_to_ball +from utama_core.skills.utils.move_utils import empty_command, move, turn_on_spot from utama_core.tactics._pass_and_score import FACE_GOAL_RAD from utama_core.tactics.goalkeeper import GoalkeeperTactic from utama_core.tactics.lead_and_support import LeadAndSupportTactic diff --git a/examples/score_goal.py b/examples/score_goal.py index f5a659f09..cf851e845 100644 --- a/examples/score_goal.py +++ b/examples/score_goal.py @@ -5,21 +5,21 @@ pixi run python examples/score_goal.py # real robot pixi run python examples/score_goal.py --mode rsim pixi run python examples/score_goal.py --calibrate # fixed moves from the dashboard; - # pixi run calibrate (examples/calibrate_robot.py) does it from the terminal, with the ball + # pixi run calibrate (tools/field/calibrate_robot.py) does it from the terminal, with the ball # the dashboard is at http://localhost:8080: press Force Start to play, Halt to freeze -The field and the camera's view are `FIELD` and `CAMERA_HALF` in `shooting_drill.py`, +The field and the camera's view are `FIELD` and `CAMERA_HALF` in `tools/field/shooting_drill.py`, so the two examples always agree; the robot is set below. It attacks the goal at +x (the right one in ssl-vision's coordinates) with `LeadAndSupportTactic`: alone, it goes to the ball, turns to the open corner and shoots. It starts in HALT, and the field check gates Force Start as in -`shooting_drill.py`. Put the ball back and Force Start again for the next shot; Halt and +`tools/field/shooting_drill.py`. Put the ball back and Force Start again for the next shot; Halt and Run in the Live tab's Strategy panel restarts the tactic. -`--calibrate` measures the robot alone, as `shooting_drill.py --calibrate` does with two +`--calibrate` measures the robot alone, as `tools/field/shooting_drill.py --calibrate` does with two (that one halts on the second robot it never sees): it plays fixed moves (`tactics/scripted_moves.py`) instead of shooting. Put it near the middle of the camera's view facing +x, with 0.8 m clear ahead and 0.6 m to its left, and a ball at rest in view; Force Start. -Then: pixi run python tools/robot_calibration.py replays/field/_calibrate.log +Then: pixi run python tools/field/robot_calibration.py replays/field/_calibrate.log """ import sys @@ -31,7 +31,7 @@ import time from typing import Optional -from shooting_drill import ( +from tools.field.shooting_drill import ( CAMERA_HALF, DASHBOARD_PORT, FIELD, @@ -44,12 +44,11 @@ _referee_profile, on_field, ) - -from utama_core.custom_referee import CustomReferee from utama_core.dashboard import DashboardServer, attach_dashboard from utama_core.dashboard.views import referee as referee_view from utama_core.dashboard.views import strategy as strategy_view from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee import CustomReferee from utama_core.run import StrategyRunner from utama_core.tactics.lead_and_support import LeadAndSupportTactic from utama_core.tactics.scripted_moves import ScriptedMovesTactic diff --git a/examples/teleop.py b/examples/teleop.py index ae2e7fe35..268d1f0dc 100644 --- a/examples/teleop.py +++ b/examples/teleop.py @@ -10,7 +10,7 @@ Start. W/S forward and back, A/D sideways, Q/E turn, Shift faster, B kicks, F turns the dribbler on and off; Space halts as everywhere on the page. A robot stops when its keys are let go, when the page stops sending (closed, the network gone) and on Halt. No rules, no goals: nothing but -the operator stops play. Robots are `shooting_drill.py`'s (`ROBOT_A`, `ROBOT_B` here), each +the operator stops play. Robots are `tools/field/shooting_drill.py`'s (`ROBOT_A`, `ROBOT_B` here), each kept inside the area in play. """ @@ -22,7 +22,7 @@ import argparse from typing import Optional -from shooting_drill import ( +from tools.field.shooting_drill import ( CAMERA_HALF, DASHBOARD_PORT, FIELD, @@ -34,12 +34,11 @@ _referee_profile, on_field, ) - -from utama_core.custom_referee import CustomReferee from utama_core.dashboard import DashboardServer, attach_dashboard from utama_core.dashboard.views import referee as referee_view from utama_core.dashboard.views import teleop as teleop_view from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee import CustomReferee from utama_core.run import StrategyRunner from utama_core.tactics.teleop import TeleopDrive, TeleopTactic diff --git a/main.py b/main.py index cdacbaaa2..9ff1306bb 100644 --- a/main.py +++ b/main.py @@ -2,60 +2,45 @@ round-robin matches are. Run: - pixi run main # split_shape vs high_press - pixi run main tiki_taka counter_flow # any two names from docs/strategies.md + pixi run main # pendulum vs wolfpack + pixi run main pendulum riptide # any two names on the dashboard's Strategies tab + pixi run main a.strategy wolfpack # or a .strategy file (tools/dev/build_strategy.py) # the rsim window opens; the dashboard is at http://localhost:8080; Ctrl+C to stop Yellow (the first strategy) starts on the right and kicks off. For many matches with -results, use `tools/evaluation/round_robin.py`. +results, use `tools/evaluation/evaluate.py`. """ import argparse -from utama_core.custom_referee import CustomReferee -from utama_core.custom_referee.profiles.profile_loader import load_profile from utama_core.dashboard import attach_dashboard from utama_core.dashboard.views import referee as referee_view from utama_core.engine.abstract_strategy import AbstractStrategy -from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.run import StrategyRunner -from utama_core.strategy import kernel_strategy - -N_ROBOTS = 6 # per side: robot 0 keeps goal, robots 1-5 play outfield -OUTFIELD_ROBOT_IDS = tuple(range(1, N_ROBOTS)) +from utama_core.referee.profiles.profile_loader import load_profile +from utama_core.run.sim_setup import UnknownStrategy, load_side, sim_referee, sim_runner def _strategy(name: str) -> AbstractStrategy: - build = getattr(kernel_strategy, f"build_{name}_kernel_strategy", None) - if build is None: - raise SystemExit(f"Unknown strategy {name!r}: see docs/strategies.md for the names") - return AbstractStrategy(build_kernel_strategy=build(OUTFIELD_ROBOT_IDS)) + """A strategy by name, a `.strategy` file or `PATH.py:FUNCTION`; otherwise exit with the names there are.""" + try: + return load_side(name) + except UnknownStrategy as e: + raise SystemExit(f"{e} (the strategies: utama_core/strategy/)") from None def main() -> None: parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) - parser.add_argument("yellow", nargs="?", default="split_shape") - parser.add_argument("blue", nargs="?", default="high_press") + parser.add_argument("yellow", nargs="?", default="pendulum") + parser.add_argument("blue", nargs="?", default="wolfpack") args = parser.parse_args() + yellow, blue = _strategy(args.yellow), _strategy(args.blue) # fail on a bad name before the dashboard starts profile = load_profile("simulation") - referee = CustomReferee(profile, n_robots_yellow=N_ROBOTS, n_robots_blue=N_ROBOTS) + referee = sim_referee() server = attach_dashboard() referee_view.attach(server, referee, profile) - runner = StrategyRunner( - strategy=_strategy(args.yellow), - opp_strategy=_strategy(args.blue), - my_team_is_yellow=True, - my_team_is_right=True, - mode="rsim", - exp_friendly=N_ROBOTS, - exp_enemy=N_ROBOTS, - exp_ball=True, - referee=referee, - referee_initial_command=RefereeCommand.PREPARE_KICKOFF_YELLOW, - show_live_status=True, - ) + runner, _ = sim_runner(yellow, blue, referee=referee, show_live_status=True) runner.run() diff --git a/pixi.lock b/pixi.lock index a27a2962e..1dfa88030 100644 --- a/pixi.lock +++ b/pixi.lock @@ -1,4 +1,16 @@ -version: 6 +version: 7 +platforms: +- name: linux-64 + virtual-packages: + - __unix=0=0 + - __linux=4.18 + - __glibc=2.28 + - __archspec=0=x86_64 +- name: osx-arm64 + virtual-packages: + - __unix=0=0 + - __osx=13.0 + - __archspec=0=m1 environments: default: channels: @@ -8,48 +20,26 @@ environments: packages: linux-64: - conda: https://prefix.dev/conda-forge/linux-64/_openmp_mutex-4.5-20_gnu.conda - - conda: https://prefix.dev/conda-forge/noarch/adwaita-icon-theme-49.0-unix_0.conda - conda: https://prefix.dev/conda-forge/linux-64/alsa-lib-1.2.15.3-hb03c661_0.conda - - conda: https://prefix.dev/conda-forge/noarch/anyio-4.13.0-pyhcf101f3_0.conda - conda: https://prefix.dev/conda-forge/linux-64/aom-3.9.1-hac33072_0.conda - conda: https://prefix.dev/conda-forge/linux-64/at-spi2-atk-2.38.0-h0630a04_3.tar.bz2 - conda: https://prefix.dev/conda-forge/linux-64/at-spi2-core-2.40.3-h0630a04_0.tar.bz2 - conda: https://prefix.dev/conda-forge/linux-64/atk-1.0-2.38.0-h04ea711_2.conda - - conda: https://prefix.dev/conda-forge/noarch/backports-1.0-pyhd8ed1ab_5.conda - - conda: https://prefix.dev/conda-forge/noarch/backports.tarfile-1.2.0-pyhcf101f3_2.conda - conda: https://prefix.dev/conda-forge/linux-64/backports.zstd-1.4.0-py311h6b1f9c4_0.conda - conda: https://prefix.dev/conda-forge/linux-64/brotli-1.2.0-h505cf86_3.conda - conda: https://prefix.dev/conda-forge/linux-64/brotli-bin-1.2.0-h9908984_3.conda - conda: https://prefix.dev/conda-forge/linux-64/bzip2-1.0.8-hda65f42_9.conda - - conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2026.4.22-hbd8a1cb_0.conda - conda: https://prefix.dev/conda-forge/linux-64/cairo-1.18.4-he90730b_1.conda - - conda: https://prefix.dev/conda-forge/noarch/certifi-2026.4.22-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/linux-64/cffi-2.0.0-py311h03d9500_1.conda - - conda: https://prefix.dev/conda-forge/noarch/cfgv-3.5.0-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/click-8.3.3-pyhc90fa1f_0.conda - - conda: https://prefix.dev/conda-forge/noarch/cloudpickle-3.1.2-pyhcf101f3_1.conda - - conda: https://prefix.dev/conda-forge/noarch/colorama-0.4.6-pyhd8ed1ab_1.conda - conda: https://prefix.dev/conda-forge/linux-64/contourpy-1.3.3-py311h724c32c_4.conda - conda: https://prefix.dev/conda-forge/linux-64/cryptography-48.0.0-py311h2005dd1_0.conda - - conda: https://prefix.dev/conda-forge/noarch/cycler-0.12.1-pyhcf101f3_2.conda - conda: https://prefix.dev/conda-forge/linux-64/cyrus-sasl-2.1.28-hac629b4_1.conda - conda: https://prefix.dev/conda-forge/linux-64/dav1d-1.2.1-hd590300_0.conda - conda: https://prefix.dev/conda-forge/linux-64/dbus-1.16.2-h24cb091_1.conda - - conda: https://prefix.dev/conda-forge/noarch/distlib-0.4.0-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/linux-64/double-conversion-3.4.0-hecca717_0.conda - - conda: https://prefix.dev/conda-forge/noarch/editables-0.6-pyhcf101f3_0.conda - conda: https://prefix.dev/conda-forge/linux-64/epoxy-1.5.10-hb03c661_2.conda - - conda: https://prefix.dev/conda-forge/noarch/exceptiongroup-1.3.1-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/farama-notifications-0.0.4-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/filelock-3.29.0-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/linux-64/fluidsynth-2.5.4-h07a5eef_0.conda - - conda: https://prefix.dev/conda-forge/noarch/font-ttf-dejavu-sans-mono-2.37-hab24e00_0.tar.bz2 - - conda: https://prefix.dev/conda-forge/noarch/font-ttf-inconsolata-3.000-h77eed37_0.tar.bz2 - - conda: https://prefix.dev/conda-forge/noarch/font-ttf-source-code-pro-2.038-h77eed37_0.tar.bz2 - - conda: https://prefix.dev/conda-forge/noarch/font-ttf-ubuntu-0.83-h77eed37_3.conda - conda: https://prefix.dev/conda-forge/linux-64/fontconfig-2.17.1-h27c8c51_0.conda - - conda: https://prefix.dev/conda-forge/noarch/fonts-conda-ecosystem-1-0.tar.bz2 - - conda: https://prefix.dev/conda-forge/noarch/fonts-conda-forge-1-hc364b38_1.conda - conda: https://prefix.dev/conda-forge/linux-64/fonttools-4.63.0-py311h3778330_0.conda - conda: https://prefix.dev/conda-forge/linux-64/freetype-2.14.3-ha770c72_0.conda - conda: https://prefix.dev/conda-forge/linux-64/fribidi-1.0.16-hb03c661_0.conda @@ -60,30 +50,10 @@ environments: - conda: https://prefix.dev/conda-forge/linux-64/gtk3-3.24.43-h993cebd_6.conda - conda: https://prefix.dev/conda-forge/linux-64/gts-0.7.6-h977cf35_4.conda - conda: https://prefix.dev/conda-forge/linux-64/gymnasium-1.3.0-np2py311hec5889a_0.conda - - conda: https://prefix.dev/conda-forge/noarch/h11-0.16.0-pyhcf101f3_1.conda - - conda: https://prefix.dev/conda-forge/noarch/h2-4.3.0-pyhcf101f3_0.conda - conda: https://prefix.dev/conda-forge/linux-64/harfbuzz-14.3.1-ha770c72_0.conda - - conda: https://prefix.dev/conda-forge/noarch/hatch-1.16.5-pyhcf101f3_0.conda - - conda: https://prefix.dev/conda-forge/noarch/hatchling-1.29.0-pyhcf101f3_0.conda - conda: https://prefix.dev/conda-forge/linux-64/hicolor-icon-theme-0.17-ha770c72_3.conda - - conda: https://prefix.dev/conda-forge/noarch/hpack-4.1.0-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/httpcore-1.0.9-pyh29332c3_0.conda - - conda: https://prefix.dev/conda-forge/noarch/httpx-0.28.1-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/hyperframe-6.1.0-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/hyperlink-21.0.0-pyh29332c3_1.conda - conda: https://prefix.dev/conda-forge/linux-64/icu-78.3-py310h44b86e0_2.conda - - conda: https://prefix.dev/conda-forge/noarch/identify-2.6.19-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/idna-3.13-pyhcf101f3_0.conda - - conda: https://prefix.dev/conda-forge/noarch/importlib-metadata-8.8.0-pyhcf101f3_0.conda - - conda: https://prefix.dev/conda-forge/noarch/importlib_resources-7.1.0-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/iniconfig-2.3.0-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/linux-64/jack-1.9.22-hf4617a5_3.conda - - conda: https://prefix.dev/conda-forge/noarch/jaraco.classes-3.4.0-pyhcf101f3_3.conda - - conda: https://prefix.dev/conda-forge/noarch/jaraco.context-6.1.2-pyhcf101f3_0.conda - - conda: https://prefix.dev/conda-forge/noarch/jaraco.functools-4.4.0-pyhcf101f3_1.conda - - conda: https://prefix.dev/conda-forge/noarch/jax-jumpy-1.0.0-pyhd8ed1ab_1.conda - - conda: https://prefix.dev/conda-forge/noarch/jeepney-0.9.0-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/keyring-25.7.0-pyha804496_0.conda - conda: https://prefix.dev/conda-forge/linux-64/keyutils-1.6.3-hb9d3cd8_0.conda - conda: https://prefix.dev/conda-forge/linux-64/kiwisolver-1.5.0-py311h724c32c_0.conda - conda: https://prefix.dev/conda-forge/linux-64/krb5-1.22.2-ha1258a1_0.conda @@ -165,56 +135,34 @@ environments: - conda: https://prefix.dev/conda-forge/linux-64/libxslt-1.1.43-h711ed8c_1.conda - conda: https://prefix.dev/conda-forge/linux-64/libzlib-1.3.2-h25fd6f3_2.conda - conda: https://prefix.dev/conda-forge/linux-64/llvmlite-0.49.0-py311h1369f55_2.conda - - conda: https://prefix.dev/conda-forge/noarch/markdown-it-py-4.2.0-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/linux-64/matplotlib-3.11.1-py311h968eb38_2.conda - conda: https://prefix.dev/conda-forge/linux-64/matplotlib-base-3.11.1-py311he401cf6_2.conda - - conda: https://prefix.dev/conda-forge/noarch/mdurl-0.1.2-pyhd8ed1ab_1.conda - - conda: https://prefix.dev/conda-forge/noarch/more-itertools-11.0.2-pyhcf101f3_0.conda - conda: https://prefix.dev/conda-forge/linux-64/mpg123-1.32.9-hc50e24c_0.conda - - conda: https://prefix.dev/conda-forge/noarch/munkres-1.1.4-pyhd8ed1ab_1.conda - conda: https://prefix.dev/conda-forge/linux-64/ncurses-6.6-hdb14827_0.conda - - conda: https://prefix.dev/conda-forge/noarch/nodeenv-1.10.0-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/linux-64/numba-0.67.0-py311hdfc3925_1.conda - conda: https://prefix.dev/conda-forge/linux-64/numpy-2.0.2-py311h71ddf71_1.conda - conda: https://prefix.dev/conda-forge/linux-64/openjpeg-2.5.4-h55fea9a_0.conda - conda: https://prefix.dev/conda-forge/linux-64/openldap-2.6.13-hbde042b_0.conda - conda: https://prefix.dev/conda-forge/linux-64/openssl-3.6.2-h35e630c_0.conda - conda: https://prefix.dev/conda-forge/linux-64/opusfile-0.12-h3358134_2.conda - - conda: https://prefix.dev/conda-forge/noarch/packaging-26.2-pyhc364b38_0.conda - conda: https://prefix.dev/conda-forge/linux-64/pandas-3.0.1-py311h8032f78_0.conda - conda: https://prefix.dev/conda-forge/linux-64/pango-1.56.4-hadf4263_0.conda - - conda: https://prefix.dev/conda-forge/noarch/pathspec-1.1.1-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/linux-64/pcre2-10.47-haa7fec5_0.conda - - conda: https://prefix.dev/conda-forge/noarch/pexpect-4.9.0-pyhd8ed1ab_1.conda - conda: https://prefix.dev/conda-forge/linux-64/pillow-12.3.0-py311hf88fc01_0.conda - conda: https://prefix.dev/conda-forge/linux-64/pixman-0.46.4-h54a6638_1.conda - - conda: https://prefix.dev/conda-forge/noarch/platformdirs-4.9.6-pyhcf101f3_0.conda - - conda: https://prefix.dev/conda-forge/noarch/pluggy-1.6.0-pyhf9edf01_1.conda - conda: https://prefix.dev/conda-forge/linux-64/portaudio-19.7.0-hf4617a5_0.conda - conda: https://prefix.dev/conda-forge/linux-64/portmidi-2.0.8-h3cb78e3_0.conda - - conda: https://prefix.dev/conda-forge/noarch/pre-commit-4.6.0-pyha770c72_0.conda - conda: https://prefix.dev/conda-forge/linux-64/protobuf-3.20.2-py311ha362b79_1.conda - conda: https://prefix.dev/conda-forge/linux-64/pthread-stubs-0.4-hb9d3cd8_1002.conda - - conda: https://prefix.dev/conda-forge/noarch/ptyprocess-0.7.0-pyhd8ed1ab_1.conda - conda: https://prefix.dev/conda-forge/linux-64/pulseaudio-client-17.0-h9a6aba3_3.conda - - conda: https://prefix.dev/conda-forge/noarch/pycparser-2.22-pyh29332c3_1.conda - conda: https://prefix.dev/conda-forge/linux-64/pygame-2.6.1-py311h3209946_0.conda - - conda: https://prefix.dev/conda-forge/noarch/pygments-2.20.0-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/pyparsing-3.3.2-pyhcf101f3_0.conda - - conda: https://prefix.dev/conda-forge/noarch/pyproject_hooks-1.2.0-pyhd8ed1ab_1.conda - - conda: https://prefix.dev/conda-forge/noarch/pyserial-3.5-pyhcf101f3_2.conda - conda: https://prefix.dev/conda-forge/linux-64/pyside6-6.11.1-py311hf27b23e_1.conda - - conda: https://prefix.dev/conda-forge/noarch/pytest-8.3.4-pyhd8ed1ab_1.conda - conda: https://prefix.dev/conda-forge/linux-64/python-3.11.15-hd63d673_0_cpython.conda - - conda: https://prefix.dev/conda-forge/noarch/python-dateutil-2.9.0.post0-pyhe01879c_2.conda - - conda: https://prefix.dev/conda-forge/noarch/python-discovery-1.3.0-pyhcf101f3_0.conda - - conda: https://prefix.dev/conda-forge/noarch/python_abi-3.11-8_cp311.conda - conda: https://prefix.dev/conda-forge/linux-64/pyyaml-6.0.3-py311h3778330_1.conda - conda: https://prefix.dev/conda-forge/linux-64/qhull-2020.2-h434a139_5.conda - conda: https://prefix.dev/conda-forge/linux-64/qt6-main-6.11.1-pl5321h16c4a6b_0.conda - conda: https://prefix.dev/conda-forge/linux-64/rav1e-0.8.1-h1fbca29_0.conda - conda: https://prefix.dev/conda-forge/linux-64/readline-8.3-h853b02a_0.conda - - conda: https://prefix.dev/conda-forge/noarch/rich-14.3.4-pyhcf101f3_0.conda - conda: https://prefix.dev/conda-forge/linux-64/ruff-0.15.12-h994f30f_0.conda - conda: https://prefix.dev/conda-forge/linux-64/scipy-1.17.1-py311hbe70eeb_0.conda - conda: https://prefix.dev/conda-forge/linux-64/sdl2-2.32.56-h54a6638_0.conda @@ -223,25 +171,12 @@ environments: - conda: https://prefix.dev/conda-forge/linux-64/sdl2_ttf-2.24.0-h287479f_0.conda - conda: https://prefix.dev/conda-forge/linux-64/sdl3-3.4.8-hdeec2a5_0.conda - conda: https://prefix.dev/conda-forge/linux-64/secretstorage-3.4.1-py311h38be061_0.conda - - conda: https://prefix.dev/conda-forge/noarch/setuptools-82.0.1-pyh332efcf_0.conda - - conda: https://prefix.dev/conda-forge/noarch/shellingham-1.5.4-pyhd8ed1ab_2.conda - - conda: https://prefix.dev/conda-forge/noarch/six-1.17.0-pyhe01879c_1.conda - - conda: https://prefix.dev/conda-forge/noarch/snakeviz-2.2.2-pyhd8ed1ab_1.conda - - conda: https://prefix.dev/conda-forge/noarch/sniffio-1.3.1-pyhd8ed1ab_2.conda - conda: https://prefix.dev/conda-forge/linux-64/svt-av1-4.0.1-hecca717_0.conda - conda: https://prefix.dev/conda-forge/linux-64/tk-8.6.13-noxft_h366c992_103.conda - - conda: https://prefix.dev/conda-forge/noarch/tomli-2.4.1-pyhcf101f3_0.conda - - conda: https://prefix.dev/conda-forge/noarch/tomli-w-1.2.0-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/tomlkit-0.15.0-pyha770c72_0.conda - conda: https://prefix.dev/conda-forge/linux-64/tornado-6.5.5-py311h49ec1c0_0.conda - - conda: https://prefix.dev/conda-forge/noarch/trove-classifiers-2026.5.7.17-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/typing_extensions-4.15.0-pyhcf101f3_0.conda - - conda: https://prefix.dev/conda-forge/noarch/tzdata-2025c-hc9c84f9_1.conda - conda: https://prefix.dev/conda-forge/linux-64/ukkonen-1.1.0-py311hdf67eae_0.conda - conda: https://prefix.dev/conda-forge/linux-64/unicodedata2-17.0.1-py311h49ec1c0_0.conda - - conda: https://prefix.dev/conda-forge/noarch/userpath-1.9.2-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/linux-64/uv-0.11.12-h29f5ae7_0.conda - - conda: https://prefix.dev/conda-forge/noarch/virtualenv-21.3.1-pyhcf101f3_0.conda - conda: https://prefix.dev/conda-forge/linux-64/wayland-1.25.0-hd6090a7_0.conda - conda: https://prefix.dev/conda-forge/linux-64/xcb-util-0.4.1-h4f16b4b_2.conda - conda: https://prefix.dev/conda-forge/linux-64/xcb-util-cursor-0.1.6-hb03c661_0.conda @@ -269,70 +204,119 @@ environments: - conda: https://prefix.dev/conda-forge/linux-64/xorg-libxxf86vm-1.1.7-hb03c661_0.conda - conda: https://prefix.dev/conda-forge/linux-64/xorg-xorgproto-2025.1-hb03c661_0.conda - conda: https://prefix.dev/conda-forge/linux-64/yaml-0.2.5-h280c20c_3.conda - - conda: https://prefix.dev/conda-forge/noarch/zipp-3.23.1-pyhcf101f3_0.conda - conda: https://prefix.dev/conda-forge/linux-64/zlib-ng-2.3.3-hce19668_1.conda - conda: https://prefix.dev/conda-forge/linux-64/zstd-1.5.7-hb78ec9c_6.conda + - conda: https://prefix.dev/conda-forge/noarch/adwaita-icon-theme-49.0-unix_0.conda + - conda: https://prefix.dev/conda-forge/noarch/anyio-4.13.0-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/backports-1.0-pyhd8ed1ab_5.conda + - conda: https://prefix.dev/conda-forge/noarch/backports.tarfile-1.2.0-pyhcf101f3_2.conda + - conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2026.4.22-hbd8a1cb_0.conda + - conda: https://prefix.dev/conda-forge/noarch/certifi-2026.4.22-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/cfgv-3.5.0-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/click-8.3.3-pyhc90fa1f_0.conda + - conda: https://prefix.dev/conda-forge/noarch/cloudpickle-3.1.2-pyhcf101f3_1.conda + - conda: https://prefix.dev/conda-forge/noarch/colorama-0.4.6-pyhd8ed1ab_1.conda + - conda: https://prefix.dev/conda-forge/noarch/cycler-0.12.1-pyhcf101f3_2.conda + - conda: https://prefix.dev/conda-forge/noarch/distlib-0.4.0-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/editables-0.6-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/exceptiongroup-1.3.1-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/farama-notifications-0.0.4-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/filelock-3.29.0-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/font-ttf-dejavu-sans-mono-2.37-hab24e00_0.tar.bz2 + - conda: https://prefix.dev/conda-forge/noarch/font-ttf-inconsolata-3.000-h77eed37_0.tar.bz2 + - conda: https://prefix.dev/conda-forge/noarch/font-ttf-source-code-pro-2.038-h77eed37_0.tar.bz2 + - conda: https://prefix.dev/conda-forge/noarch/font-ttf-ubuntu-0.83-h77eed37_3.conda + - conda: https://prefix.dev/conda-forge/noarch/fonts-conda-ecosystem-1-0.tar.bz2 + - conda: https://prefix.dev/conda-forge/noarch/fonts-conda-forge-1-hc364b38_1.conda + - conda: https://prefix.dev/conda-forge/noarch/h11-0.16.0-pyhcf101f3_1.conda + - conda: https://prefix.dev/conda-forge/noarch/h2-4.3.0-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/hatch-1.16.5-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/hatchling-1.29.0-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/hpack-4.1.0-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/httpcore-1.0.9-pyh29332c3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/httpx-0.28.1-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/hyperframe-6.1.0-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/hyperlink-21.0.0-pyh29332c3_1.conda + - conda: https://prefix.dev/conda-forge/noarch/identify-2.6.19-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/idna-3.13-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/importlib-metadata-8.8.0-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/importlib_resources-7.1.0-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/iniconfig-2.3.0-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/jaraco.classes-3.4.0-pyhcf101f3_3.conda + - conda: https://prefix.dev/conda-forge/noarch/jaraco.context-6.1.2-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/jaraco.functools-4.4.0-pyhcf101f3_1.conda + - conda: https://prefix.dev/conda-forge/noarch/jax-jumpy-1.0.0-pyhd8ed1ab_1.conda + - conda: https://prefix.dev/conda-forge/noarch/jeepney-0.9.0-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/keyring-25.7.0-pyha804496_0.conda + - conda: https://prefix.dev/conda-forge/noarch/markdown-it-py-4.2.0-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/mdurl-0.1.2-pyhd8ed1ab_1.conda + - conda: https://prefix.dev/conda-forge/noarch/more-itertools-11.0.2-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/munkres-1.1.4-pyhd8ed1ab_1.conda + - conda: https://prefix.dev/conda-forge/noarch/nodeenv-1.10.0-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/packaging-26.2-pyhc364b38_0.conda + - conda: https://prefix.dev/conda-forge/noarch/pathspec-1.1.1-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/pexpect-4.9.0-pyhd8ed1ab_1.conda + - conda: https://prefix.dev/conda-forge/noarch/platformdirs-4.9.6-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/pluggy-1.6.0-pyhf9edf01_1.conda + - conda: https://prefix.dev/conda-forge/noarch/pre-commit-4.6.0-pyha770c72_0.conda + - conda: https://prefix.dev/conda-forge/noarch/ptyprocess-0.7.0-pyhd8ed1ab_1.conda + - conda: https://prefix.dev/conda-forge/noarch/pycparser-2.22-pyh29332c3_1.conda + - conda: https://prefix.dev/conda-forge/noarch/pygments-2.20.0-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/pyparsing-3.3.2-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/pyproject_hooks-1.2.0-pyhd8ed1ab_1.conda + - conda: https://prefix.dev/conda-forge/noarch/pyserial-3.5-pyhcf101f3_2.conda + - conda: https://prefix.dev/conda-forge/noarch/pytest-8.3.4-pyhd8ed1ab_1.conda + - conda: https://prefix.dev/conda-forge/noarch/python-dateutil-2.9.0.post0-pyhe01879c_2.conda + - conda: https://prefix.dev/conda-forge/noarch/python-discovery-1.3.0-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/python_abi-3.11-8_cp311.conda + - conda: https://prefix.dev/conda-forge/noarch/rich-14.3.4-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/setuptools-82.0.1-pyh332efcf_0.conda + - conda: https://prefix.dev/conda-forge/noarch/shellingham-1.5.4-pyhd8ed1ab_2.conda + - conda: https://prefix.dev/conda-forge/noarch/six-1.17.0-pyhe01879c_1.conda + - conda: https://prefix.dev/conda-forge/noarch/snakeviz-2.2.2-pyhd8ed1ab_1.conda + - conda: https://prefix.dev/conda-forge/noarch/sniffio-1.3.1-pyhd8ed1ab_2.conda + - conda: https://prefix.dev/conda-forge/noarch/tomli-2.4.1-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/tomli-w-1.2.0-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/tomlkit-0.15.0-pyha770c72_0.conda + - conda: https://prefix.dev/conda-forge/noarch/trove-classifiers-2026.5.7.17-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/typing_extensions-4.15.0-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/tzdata-2025c-hc9c84f9_1.conda + - conda: https://prefix.dev/conda-forge/noarch/userpath-1.9.2-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/virtualenv-21.3.1-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/zipp-3.23.1-pyhcf101f3_0.conda - pypi: https://files.pythonhosted.org/packages/fb/06/6a7c30c3519181263e1bbf0cbea67ef4a43a64443ee16717c7d760214943/lenses-1.2.0-py3-none-any.whl osx-arm64: - - conda: https://prefix.dev/conda-forge/osx-arm64/_openmp_mutex-4.5-7_kmp_llvm.conda - conda: https://prefix.dev/conda-forge/noarch/adwaita-icon-theme-49.0-unix_0.conda - conda: https://prefix.dev/conda-forge/noarch/anyio-4.13.0-pyhcf101f3_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/aom-3.9.1-h7bae524_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/atk-1.0-2.38.0-hd03087b_2.conda - conda: https://prefix.dev/conda-forge/noarch/backports-1.0-pyhd8ed1ab_5.conda - conda: https://prefix.dev/conda-forge/noarch/backports.tarfile-1.2.0-pyhcf101f3_2.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/backports.zstd-1.4.0-py311h36d4fbb_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/brotli-1.2.0-hf00d406_3.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/brotli-bin-1.2.0-he4a93e4_3.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/bzip2-1.0.8-hd037594_9.conda - conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2026.4.22-hbd8a1cb_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/cairo-1.18.4-he0f2337_1.conda - conda: https://prefix.dev/conda-forge/noarch/certifi-2026.4.22-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/cffi-2.0.0-py311hd10dc20_1.conda - conda: https://prefix.dev/conda-forge/noarch/cfgv-3.5.0-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/noarch/click-8.3.3-pyhc90fa1f_0.conda - conda: https://prefix.dev/conda-forge/noarch/cloudpickle-3.1.2-pyhcf101f3_1.conda - conda: https://prefix.dev/conda-forge/noarch/colorama-0.4.6-pyhd8ed1ab_1.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/contourpy-1.3.3-py311h7d85929_4.conda - conda: https://prefix.dev/conda-forge/noarch/cycler-0.12.1-pyhcf101f3_2.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/dav1d-1.2.1-hb547adb_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/dbus-1.16.2-h3ff7a7c_1.conda - conda: https://prefix.dev/conda-forge/noarch/distlib-0.4.0-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/noarch/editables-0.6-pyhcf101f3_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/epoxy-1.5.10-hc919400_2.conda - conda: https://prefix.dev/conda-forge/noarch/exceptiongroup-1.3.1-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/noarch/farama-notifications-0.0.4-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/noarch/filelock-3.29.0-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/fluidsynth-2.5.4-h985f16e_0.conda - conda: https://prefix.dev/conda-forge/noarch/font-ttf-dejavu-sans-mono-2.37-hab24e00_0.tar.bz2 - conda: https://prefix.dev/conda-forge/noarch/font-ttf-inconsolata-3.000-h77eed37_0.tar.bz2 - conda: https://prefix.dev/conda-forge/noarch/font-ttf-source-code-pro-2.038-h77eed37_0.tar.bz2 - conda: https://prefix.dev/conda-forge/noarch/font-ttf-ubuntu-0.83-h77eed37_3.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/fontconfig-2.17.1-h2b252f5_0.conda - conda: https://prefix.dev/conda-forge/noarch/fonts-conda-ecosystem-1-0.tar.bz2 - conda: https://prefix.dev/conda-forge/noarch/fonts-conda-forge-1-hc364b38_1.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/fonttools-4.63.0-py311hc290fe0_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/freetype-2.14.3-hce30654_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/fribidi-1.0.16-hc919400_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/gdk-pixbuf-2.44.6-h4e57454_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/glib-tools-2.88.3-h5f197ff_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/graphite2-1.3.15-h784d473_1.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/graphviz-13.1.2-hcd33d8b_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/gtk3-3.24.43-h5febe37_6.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/gts-0.7.6-he42f4ea_4.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/gymnasium-1.3.0-np2py311h56d0776_0.conda - conda: https://prefix.dev/conda-forge/noarch/h11-0.16.0-pyhcf101f3_1.conda - conda: https://prefix.dev/conda-forge/noarch/h2-4.3.0-pyhcf101f3_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/harfbuzz-14.3.1-hce30654_0.conda - conda: https://prefix.dev/conda-forge/noarch/hatch-1.16.5-pyhcf101f3_0.conda - conda: https://prefix.dev/conda-forge/noarch/hatchling-1.29.0-pyhcf101f3_0.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/hicolor-icon-theme-0.17-hce30654_3.conda - conda: https://prefix.dev/conda-forge/noarch/hpack-4.1.0-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/noarch/httpcore-1.0.9-pyh29332c3_0.conda - conda: https://prefix.dev/conda-forge/noarch/httpx-0.28.1-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/noarch/hyperframe-6.1.0-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/noarch/hyperlink-21.0.0-pyh29332c3_1.conda - - conda: https://prefix.dev/conda-forge/osx-arm64/icu-78.3-py310h579977c_2.conda - conda: https://prefix.dev/conda-forge/noarch/identify-2.6.19-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/noarch/idna-3.13-pyhcf101f3_0.conda - conda: https://prefix.dev/conda-forge/noarch/importlib-metadata-8.8.0-pyhcf101f3_0.conda @@ -343,6 +327,70 @@ environments: - conda: https://prefix.dev/conda-forge/noarch/jaraco.functools-4.4.0-pyhcf101f3_1.conda - conda: https://prefix.dev/conda-forge/noarch/jax-jumpy-1.0.0-pyhd8ed1ab_1.conda - conda: https://prefix.dev/conda-forge/noarch/keyring-25.7.0-pyh534df25_0.conda + - conda: https://prefix.dev/conda-forge/noarch/markdown-it-py-4.2.0-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/mdurl-0.1.2-pyhd8ed1ab_1.conda + - conda: https://prefix.dev/conda-forge/noarch/more-itertools-11.0.2-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/munkres-1.1.4-pyhd8ed1ab_1.conda + - conda: https://prefix.dev/conda-forge/noarch/nodeenv-1.10.0-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/packaging-26.2-pyhc364b38_0.conda + - conda: https://prefix.dev/conda-forge/noarch/pathspec-1.1.1-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/pexpect-4.9.0-pyhd8ed1ab_1.conda + - conda: https://prefix.dev/conda-forge/noarch/platformdirs-4.9.6-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/pluggy-1.6.0-pyhf9edf01_1.conda + - conda: https://prefix.dev/conda-forge/noarch/pre-commit-4.6.0-pyha770c72_0.conda + - conda: https://prefix.dev/conda-forge/noarch/ptyprocess-0.7.0-pyhd8ed1ab_1.conda + - conda: https://prefix.dev/conda-forge/noarch/pycparser-2.22-pyh29332c3_1.conda + - conda: https://prefix.dev/conda-forge/noarch/pygments-2.20.0-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/pyparsing-3.3.2-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/pyproject_hooks-1.2.0-pyhd8ed1ab_1.conda + - conda: https://prefix.dev/conda-forge/noarch/pyserial-3.5-pyhcf101f3_2.conda + - conda: https://prefix.dev/conda-forge/noarch/pytest-8.3.4-pyhd8ed1ab_1.conda + - conda: https://prefix.dev/conda-forge/noarch/python-dateutil-2.9.0.post0-pyhe01879c_2.conda + - conda: https://prefix.dev/conda-forge/noarch/python-discovery-1.3.0-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/python_abi-3.11-8_cp311.conda + - conda: https://prefix.dev/conda-forge/noarch/rich-14.3.4-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/setuptools-82.0.1-pyh332efcf_0.conda + - conda: https://prefix.dev/conda-forge/noarch/shellingham-1.5.4-pyhd8ed1ab_2.conda + - conda: https://prefix.dev/conda-forge/noarch/six-1.17.0-pyhe01879c_1.conda + - conda: https://prefix.dev/conda-forge/noarch/snakeviz-2.2.2-pyhd8ed1ab_1.conda + - conda: https://prefix.dev/conda-forge/noarch/sniffio-1.3.1-pyhd8ed1ab_2.conda + - conda: https://prefix.dev/conda-forge/noarch/tomli-2.4.1-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/tomli-w-1.2.0-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/tomlkit-0.15.0-pyha770c72_0.conda + - conda: https://prefix.dev/conda-forge/noarch/trove-classifiers-2026.5.7.17-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/typing_extensions-4.15.0-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/tzdata-2025c-hc9c84f9_1.conda + - conda: https://prefix.dev/conda-forge/noarch/userpath-1.9.2-pyhd8ed1ab_0.conda + - conda: https://prefix.dev/conda-forge/noarch/virtualenv-21.3.1-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/noarch/zipp-3.23.1-pyhcf101f3_0.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/_openmp_mutex-4.5-7_kmp_llvm.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/aom-3.9.1-h7bae524_0.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/atk-1.0-2.38.0-hd03087b_2.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/backports.zstd-1.4.0-py311h36d4fbb_0.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/brotli-1.2.0-hf00d406_3.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/brotli-bin-1.2.0-he4a93e4_3.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/bzip2-1.0.8-hd037594_9.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/cairo-1.18.4-he0f2337_1.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/cffi-2.0.0-py311hd10dc20_1.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/contourpy-1.3.3-py311h7d85929_4.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/dav1d-1.2.1-hb547adb_0.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/dbus-1.16.2-h3ff7a7c_1.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/epoxy-1.5.10-hc919400_2.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/fluidsynth-2.5.4-h985f16e_0.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/fontconfig-2.17.1-h2b252f5_0.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/fonttools-4.63.0-py311hc290fe0_0.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/freetype-2.14.3-hce30654_0.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/fribidi-1.0.16-hc919400_0.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/gdk-pixbuf-2.44.6-h4e57454_0.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/glib-tools-2.88.3-h5f197ff_0.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/graphite2-1.3.15-h784d473_1.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/graphviz-13.1.2-hcd33d8b_0.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/gtk3-3.24.43-h5febe37_6.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/gts-0.7.6-he42f4ea_4.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/gymnasium-1.3.0-np2py311h56d0776_0.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/harfbuzz-14.3.1-hce30654_0.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/hicolor-icon-theme-0.17-hce30654_3.conda + - conda: https://prefix.dev/conda-forge/osx-arm64/icu-78.3-py310h579977c_2.conda - conda: https://prefix.dev/conda-forge/osx-arm64/kiwisolver-1.5.0-py311h7d85929_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/lame-3.100-h1a8c8d9_1003.tar.bz2 - conda: https://prefix.dev/conda-forge/osx-arm64/lcms2-2.19.1-hdfa7624_1.conda @@ -392,52 +440,30 @@ environments: - conda: https://prefix.dev/conda-forge/osx-arm64/libzlib-1.3.2-h8088a28_2.conda - conda: https://prefix.dev/conda-forge/osx-arm64/llvm-openmp-22.1.4-hc7d1edf_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/llvmlite-0.49.0-py311h4a78e08_2.conda - - conda: https://prefix.dev/conda-forge/noarch/markdown-it-py-4.2.0-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/matplotlib-3.11.1-py311ha01d089_2.conda - conda: https://prefix.dev/conda-forge/osx-arm64/matplotlib-base-3.11.1-py311h3c3ad35_2.conda - - conda: https://prefix.dev/conda-forge/noarch/mdurl-0.1.2-pyhd8ed1ab_1.conda - - conda: https://prefix.dev/conda-forge/noarch/more-itertools-11.0.2-pyhcf101f3_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/mpg123-1.32.9-hf642e45_0.conda - - conda: https://prefix.dev/conda-forge/noarch/munkres-1.1.4-pyhd8ed1ab_1.conda - conda: https://prefix.dev/conda-forge/osx-arm64/ncurses-6.6-h1d4f5a5_0.conda - - conda: https://prefix.dev/conda-forge/noarch/nodeenv-1.10.0-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/numba-0.67.0-py311hf682900_1.conda - conda: https://prefix.dev/conda-forge/osx-arm64/numpy-2.0.2-py311h649a571_1.conda - conda: https://prefix.dev/conda-forge/osx-arm64/openjpeg-2.5.4-hd9e9057_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/openssl-3.6.2-hd24854e_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/opusfile-0.12-h5643135_2.conda - - conda: https://prefix.dev/conda-forge/noarch/packaging-26.2-pyhc364b38_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/pandas-3.0.1-py311h4a068b9_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/pango-1.56.4-h875632e_0.conda - - conda: https://prefix.dev/conda-forge/noarch/pathspec-1.1.1-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/pcre2-10.47-h30297fc_0.conda - - conda: https://prefix.dev/conda-forge/noarch/pexpect-4.9.0-pyhd8ed1ab_1.conda - conda: https://prefix.dev/conda-forge/osx-arm64/pillow-12.3.0-py311hd37aea2_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/pixman-0.46.4-h81086ad_1.conda - - conda: https://prefix.dev/conda-forge/noarch/platformdirs-4.9.6-pyhcf101f3_0.conda - - conda: https://prefix.dev/conda-forge/noarch/pluggy-1.6.0-pyhf9edf01_1.conda - conda: https://prefix.dev/conda-forge/osx-arm64/portaudio-19.7.0-h5833ebf_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/portmidi-2.0.8-haf25636_0.conda - - conda: https://prefix.dev/conda-forge/noarch/pre-commit-4.6.0-pyha770c72_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/protobuf-3.20.2-py311ha397e9f_1.conda - conda: https://prefix.dev/conda-forge/osx-arm64/pthread-stubs-0.4-h84a0fba_1003.conda - - conda: https://prefix.dev/conda-forge/noarch/ptyprocess-0.7.0-pyhd8ed1ab_1.conda - - conda: https://prefix.dev/conda-forge/noarch/pycparser-2.22-pyh29332c3_1.conda - conda: https://prefix.dev/conda-forge/osx-arm64/pygame-2.6.1-py311hc3e7c57_0.conda - - conda: https://prefix.dev/conda-forge/noarch/pygments-2.20.0-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/pyparsing-3.3.2-pyhcf101f3_0.conda - - conda: https://prefix.dev/conda-forge/noarch/pyproject_hooks-1.2.0-pyhd8ed1ab_1.conda - - conda: https://prefix.dev/conda-forge/noarch/pyserial-3.5-pyhcf101f3_2.conda - - conda: https://prefix.dev/conda-forge/noarch/pytest-8.3.4-pyhd8ed1ab_1.conda - conda: https://prefix.dev/conda-forge/osx-arm64/python-3.11.15-h8561d8f_0_cpython.conda - - conda: https://prefix.dev/conda-forge/noarch/python-dateutil-2.9.0.post0-pyhe01879c_2.conda - - conda: https://prefix.dev/conda-forge/noarch/python-discovery-1.3.0-pyhcf101f3_0.conda - - conda: https://prefix.dev/conda-forge/noarch/python_abi-3.11-8_cp311.conda - conda: https://prefix.dev/conda-forge/osx-arm64/pyyaml-6.0.3-py311hc290fe0_1.conda - conda: https://prefix.dev/conda-forge/osx-arm64/qhull-2020.2-h420ef59_5.conda - conda: https://prefix.dev/conda-forge/osx-arm64/rav1e-0.8.1-h8246384_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/readline-8.3-h46df422_0.conda - - conda: https://prefix.dev/conda-forge/noarch/rich-14.3.4-pyhcf101f3_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/ruff-0.15.12-hbd3f8a3_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/scipy-1.17.1-py311he9931d0_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/sdl2-2.32.56-h248ca61_0.conda @@ -445,29 +471,15 @@ environments: - conda: https://prefix.dev/conda-forge/osx-arm64/sdl2_mixer-2.6.3-h45fadf6_2.conda - conda: https://prefix.dev/conda-forge/osx-arm64/sdl2_ttf-2.24.0-h443c5de_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/sdl3-3.4.8-h6fa9c73_0.conda - - conda: https://prefix.dev/conda-forge/noarch/setuptools-82.0.1-pyh332efcf_0.conda - - conda: https://prefix.dev/conda-forge/noarch/shellingham-1.5.4-pyhd8ed1ab_2.conda - - conda: https://prefix.dev/conda-forge/noarch/six-1.17.0-pyhe01879c_1.conda - - conda: https://prefix.dev/conda-forge/noarch/snakeviz-2.2.2-pyhd8ed1ab_1.conda - - conda: https://prefix.dev/conda-forge/noarch/sniffio-1.3.1-pyhd8ed1ab_2.conda - conda: https://prefix.dev/conda-forge/osx-arm64/svt-av1-4.0.1-h0cb729a_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/tk-8.6.13-h010d191_3.conda - - conda: https://prefix.dev/conda-forge/noarch/tomli-2.4.1-pyhcf101f3_0.conda - - conda: https://prefix.dev/conda-forge/noarch/tomli-w-1.2.0-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/tomlkit-0.15.0-pyha770c72_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/tornado-6.5.5-py311hc949640_0.conda - - conda: https://prefix.dev/conda-forge/noarch/trove-classifiers-2026.5.7.17-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/typing_extensions-4.15.0-pyhcf101f3_0.conda - - conda: https://prefix.dev/conda-forge/noarch/tzdata-2025c-hc9c84f9_1.conda - conda: https://prefix.dev/conda-forge/osx-arm64/ukkonen-1.1.0-py311h572238d_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/unicodedata2-17.0.1-py311hc949640_0.conda - - conda: https://prefix.dev/conda-forge/noarch/userpath-1.9.2-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/uv-0.11.12-h2c65d96_0.conda - - conda: https://prefix.dev/conda-forge/noarch/virtualenv-21.3.1-pyhcf101f3_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/xorg-libxau-1.0.12-h84a0fba_2.conda - conda: https://prefix.dev/conda-forge/osx-arm64/xorg-libxdmcp-1.1.5-h84a0fba_2.conda - conda: https://prefix.dev/conda-forge/osx-arm64/yaml-0.2.5-h925e9cb_3.conda - - conda: https://prefix.dev/conda-forge/noarch/zipp-3.23.1-pyhcf101f3_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/zlib-ng-2.3.3-h31dac16_1.conda - conda: https://prefix.dev/conda-forge/osx-arm64/zstd-1.5.7-hbf9d68e_6.conda - pypi: https://files.pythonhosted.org/packages/fb/06/6a7c30c3519181263e1bbf0cbea67ef4a43a64443ee16717c7d760214943/lenses-1.2.0-py3-none-any.whl @@ -481,7 +493,6 @@ environments: - conda: https://prefix.dev/conda-forge/linux-64/_openmp_mutex-4.5-20_gnu.conda - conda: https://prefix.dev/conda-forge/linux-64/bzip2-1.0.8-hda65f42_9.conda - conda: https://prefix.dev/conda-forge/linux-64/c-ares-1.34.6-hb03c661_0.conda - - conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2026.4.22-hbd8a1cb_0.conda - conda: https://prefix.dev/conda-forge/linux-64/cmake-3.26.4-hcfe8598_0.conda - conda: https://prefix.dev/conda-forge/linux-64/expat-2.8.0-hecca717_0.conda - conda: https://prefix.dev/conda-forge/linux-64/keyutils-1.6.3-hb9d3cd8_0.conda @@ -513,22 +524,25 @@ environments: - conda: https://prefix.dev/conda-forge/linux-64/openssl-3.6.2-h35e630c_0.conda - conda: https://prefix.dev/conda-forge/linux-64/pthread-stubs-0.4-hb9d3cd8_1002.conda - conda: https://prefix.dev/conda-forge/linux-64/python-3.10.20-h3c07f61_0_cpython.conda - - conda: https://prefix.dev/conda-forge/noarch/python_abi-3.10-8_cp310.conda - conda: https://prefix.dev/conda-forge/linux-64/readline-8.3-h853b02a_0.conda - conda: https://prefix.dev/conda-forge/linux-64/rhash-1.4.3-hd590300_2.conda - conda: https://prefix.dev/conda-forge/linux-64/tk-8.6.13-noxft_h366c992_103.conda - - conda: https://prefix.dev/conda-forge/noarch/tzdata-2025c-hc9c84f9_1.conda - conda: https://prefix.dev/conda-forge/linux-64/xz-5.8.3-ha02ee65_0.conda - conda: https://prefix.dev/conda-forge/linux-64/xz-gpl-tools-5.8.3-ha02ee65_0.conda - conda: https://prefix.dev/conda-forge/linux-64/xz-tools-5.8.3-hb03c661_0.conda - conda: https://prefix.dev/conda-forge/linux-64/zlib-1.3.2-h25fd6f3_2.conda - conda: https://prefix.dev/conda-forge/linux-64/zstd-1.5.7-hb78ec9c_6.conda - - pypi: https://files.pythonhosted.org/packages/fa/66/f7177ab331876200ac7563a580140643d1179c8b4b6a6b0fc9838de2a9b8/numpy-2.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl + - conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2026.4.22-hbd8a1cb_0.conda + - conda: https://prefix.dev/conda-forge/noarch/python_abi-3.10-8_cp310.conda + - conda: https://prefix.dev/conda-forge/noarch/tzdata-2025c-hc9c84f9_1.conda - pypi: ./vendor/rSim + - pypi: https://files.pythonhosted.org/packages/fa/66/f7177ab331876200ac7563a580140643d1179c8b4b6a6b0fc9838de2a9b8/numpy-2.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl osx-arm64: + - conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2026.4.22-hbd8a1cb_0.conda + - conda: https://prefix.dev/conda-forge/noarch/python_abi-3.10-8_cp310.conda + - conda: https://prefix.dev/conda-forge/noarch/tzdata-2025c-hc9c84f9_1.conda - conda: https://prefix.dev/conda-forge/osx-arm64/bzip2-1.0.8-hd037594_9.conda - conda: https://prefix.dev/conda-forge/osx-arm64/c-ares-1.34.6-hc919400_0.conda - - conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2026.4.22-hbd8a1cb_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/cmake-3.26.4-hc0af03a_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/expat-2.8.0-hf6b4638_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/krb5-1.22.2-h385eeb1_0.conda @@ -551,18 +565,16 @@ environments: - conda: https://prefix.dev/conda-forge/osx-arm64/openssl-3.6.2-hd24854e_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/pthread-stubs-0.4-hd74edd7_1002.conda - conda: https://prefix.dev/conda-forge/osx-arm64/python-3.10.20-h1b19095_0_cpython.conda - - conda: https://prefix.dev/conda-forge/noarch/python_abi-3.10-8_cp310.conda - conda: https://prefix.dev/conda-forge/osx-arm64/readline-8.3-h46df422_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/rhash-1.4.3-hb547adb_2.conda - conda: https://prefix.dev/conda-forge/osx-arm64/tk-8.6.13-h010d191_3.conda - - conda: https://prefix.dev/conda-forge/noarch/tzdata-2025c-hc9c84f9_1.conda - conda: https://prefix.dev/conda-forge/osx-arm64/xz-5.8.3-hd0f0c4f_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/xz-gpl-tools-5.8.3-hd0f0c4f_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/xz-tools-5.8.3-h8088a28_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/zlib-1.3.2-h8088a28_2.conda - conda: https://prefix.dev/conda-forge/osx-arm64/zstd-1.5.7-hbf9d68e_6.conda - - pypi: https://files.pythonhosted.org/packages/05/33/26178c7d437a87082d11019292dce6d3fe6f0e9026b7b2309cbf3e489b1d/numpy-2.0.2-cp310-cp310-macosx_11_0_arm64.whl - pypi: ./vendor/rSim + - pypi: https://files.pythonhosted.org/packages/05/33/26178c7d437a87082d11019292dce6d3fe6f0e9026b7b2309cbf3e489b1d/numpy-2.0.2-cp310-cp310-macosx_11_0_arm64.whl packages: - conda: https://prefix.dev/conda-forge/linux-64/_openmp_mutex-4.5-20_gnu.conda build_number: 20 @@ -578,29 +590,6 @@ packages: purls: [] size: 28948 timestamp: 1770939786096 -- conda: https://prefix.dev/conda-forge/osx-arm64/_openmp_mutex-4.5-7_kmp_llvm.conda - build_number: 7 - sha256: 7acaa2e0782cad032bdaf756b536874346ac1375745fb250e9bdd6a48a7ab3cd - md5: a44032f282e7d2acdeb1c240308052dd - depends: - - llvm-openmp >=9.0.1 - license: BSD-3-Clause - license_family: BSD - purls: [] - size: 8325 - timestamp: 1764092507920 -- conda: https://prefix.dev/conda-forge/noarch/adwaita-icon-theme-49.0-unix_0.conda - sha256: a362b4f5c96a0bf4def96be1a77317e2730af38915eb9bec85e2a92836501ed7 - md5: b3f0179590f3c0637b7eb5309898f79e - depends: - - __unix - - hicolor-icon-theme - - librsvg - license: LGPL-3.0-or-later OR CC-BY-SA-3.0 - license_family: LGPL - purls: [] - size: 631452 - timestamp: 1758743294412 - conda: https://prefix.dev/conda-forge/linux-64/alsa-lib-1.2.15.3-hb03c661_0.conda sha256: d88aa7ae766cf584e180996e92fef2aa7d8e0a0a5ab1d4d49c32390c1b5fff31 md5: dcdc58c15961dbf17a0621312b01f5cb @@ -612,25 +601,6 @@ packages: purls: [] size: 584660 timestamp: 1768327524772 -- conda: https://prefix.dev/conda-forge/noarch/anyio-4.13.0-pyhcf101f3_0.conda - sha256: f09aed24661cd45ba54a43772504f05c0698248734f9ae8cd289d314ac89707e - md5: af2df4b9108808da3dc76710fe50eae2 - depends: - - exceptiongroup >=1.0.2 - - idna >=2.8 - - python >=3.10 - - typing_extensions >=4.5 - - python - constrains: - - trio >=0.32.0 - - uvloop >=0.22.1 - - winloop >=0.2.3 - license: MIT - license_family: MIT - purls: - - pkg:pypi/anyio?source=hash-mapping - size: 146764 - timestamp: 1774359453364 - conda: https://prefix.dev/conda-forge/linux-64/aom-3.9.1-hac33072_0.conda sha256: b08ef033817b5f9f76ce62dfcac7694e7b6b4006420372de22494503decac855 md5: 346722a0be40f6edc53f12640d301338 @@ -642,17 +612,6 @@ packages: purls: [] size: 2706396 timestamp: 1718551242397 -- conda: https://prefix.dev/conda-forge/osx-arm64/aom-3.9.1-h7bae524_0.conda - sha256: ec238f18ce8140485645252351a0eca9ef4f7a1c568a420f240a585229bc12ef - md5: 7adba36492a1bb22d98ffffe4f6fc6de - depends: - - __osx >=11.0 - - libcxx >=16 - license: BSD-2-Clause - license_family: BSD - purls: [] - size: 2235747 - timestamp: 1718551382432 - conda: https://prefix.dev/conda-forge/linux-64/at-spi2-atk-2.38.0-h0630a04_3.tar.bz2 sha256: 26ab9386e80bf196e51ebe005da77d57decf6d989b4f34d96130560bc133479c md5: 6b889f174df1e0f816276ae69281af4d @@ -696,44 +655,6 @@ packages: purls: [] size: 355900 timestamp: 1713896169874 -- conda: https://prefix.dev/conda-forge/osx-arm64/atk-1.0-2.38.0-hd03087b_2.conda - sha256: b0747f9b1bc03d1932b4d8c586f39a35ac97e7e72fe6e63f2b2a2472d466f3c1 - md5: 57301986d02d30d6805fdce6c99074ee - depends: - - __osx >=11.0 - - libcxx >=16 - - libglib >=2.80.0,<3.0a0 - - libintl >=0.22.5,<1.0a0 - constrains: - - atk-1.0 2.38.0 - license: LGPL-2.0-or-later - license_family: LGPL - purls: [] - size: 347530 - timestamp: 1713896411580 -- conda: https://prefix.dev/conda-forge/noarch/backports-1.0-pyhd8ed1ab_5.conda - sha256: e1c3dc8b5aa6e12145423fed262b4754d70fec601339896b9ccf483178f690a6 - md5: 767d508c1a67e02ae8f50e44cacfadb2 - depends: - - python >=3.9 - license: BSD-3-Clause - license_family: BSD - purls: [] - size: 7069 - timestamp: 1733218168786 -- conda: https://prefix.dev/conda-forge/noarch/backports.tarfile-1.2.0-pyhcf101f3_2.conda - sha256: 25abdb37e186f0d6ac3b774a63c81c5bc4bf554b5096b51343fa5e7c381193b1 - md5: bea46844deb274b2cc2a3a941745fa73 - depends: - - python >=3.10 - - backports - - python - license: MIT - license_family: MIT - purls: - - pkg:pypi/backports-tarfile?source=hash-mapping - size: 35739 - timestamp: 1767290467820 - conda: https://prefix.dev/conda-forge/linux-64/backports.zstd-1.4.0-py311h6b1f9c4_0.conda sha256: a23717f9dc06924b988b92ba8dca0f4cb9154cac954457a40adb2f19d57896de md5: aa8c3009fd8903bebdcb22fbcb4c0dea @@ -748,19 +669,6 @@ packages: - pkg:pypi/backports-zstd?source=hash-mapping size: 245341 timestamp: 1777848716685 -- conda: https://prefix.dev/conda-forge/osx-arm64/backports.zstd-1.4.0-py311h36d4fbb_0.conda - sha256: 2e6399a3663e7e20134a208cd09befc44ce1e9efe94d1d36d8911db04f186270 - md5: 3ee7e8ae532366221658b80baee36dc0 - depends: - - python - - __osx >=11.0 - - python_abi 3.11.* *_cp311 - - zstd >=1.5.7,<1.6.0a0 - license: BSD-3-Clause AND MIT AND EPL-2.0 - purls: - - pkg:pypi/backports-zstd?source=hash-mapping - size: 244743 - timestamp: 1777848723707 - conda: https://prefix.dev/conda-forge/linux-64/brotli-1.2.0-h505cf86_3.conda sha256: 1f2ccfebe6e0113bfc473b21906372c1ee4eb69bf6faef0ad7f3d4d79af63a98 md5: 6ff307b78fbfb7dcafb7e25ff8bc9c10 @@ -775,19 +683,6 @@ packages: purls: [] size: 20676 timestamp: 1786622810792 -- conda: https://prefix.dev/conda-forge/osx-arm64/brotli-1.2.0-hf00d406_3.conda - sha256: 7050e1b11876219bd0df375ef3d83fd00f94fb4e13c1ffb21dede0c506893079 - md5: aa7df8174ee3b34a5ad8a3160429db68 - depends: - - __osx >=11.0 - - brotli-bin 1.2.0 he4a93e4_3 - - libbrotlidec 1.2.0 h5295a6a_3 - - libbrotlienc 1.2.0 h2ddc9cb_3 - license: MIT - license_family: MIT - purls: [] - size: 20767 - timestamp: 1786622887445 - conda: https://prefix.dev/conda-forge/linux-64/brotli-bin-1.2.0-h9908984_3.conda sha256: 56b2e5e8a49f9887af74cc63e0d55a3654e60b667ad5558da089549a36ae6a0c md5: 8929291d9efc59715df1cfa7daf5e3ed @@ -801,18 +696,6 @@ packages: purls: [] size: 21598 timestamp: 1786622801722 -- conda: https://prefix.dev/conda-forge/osx-arm64/brotli-bin-1.2.0-he4a93e4_3.conda - sha256: 1e92cea587c2eaab169e45dae01c149b9889a8249eda296b8b6db39aee708531 - md5: d9de6c0ad7e008afdf62fb2ffd450b4a - depends: - - __osx >=11.0 - - libbrotlidec 1.2.0 h5295a6a_3 - - libbrotlienc 1.2.0 h2ddc9cb_3 - license: MIT - license_family: MIT - purls: [] - size: 18962 - timestamp: 1786622878369 - conda: https://prefix.dev/conda-forge/linux-64/bzip2-1.0.8-hda65f42_9.conda sha256: 0b75d45f0bba3e95dc693336fa51f40ea28c980131fec438afb7ce6118ed05f6 md5: d2ffd7602c02f2b316fd921d39876885 @@ -824,16 +707,6 @@ packages: purls: [] size: 260182 timestamp: 1771350215188 -- conda: https://prefix.dev/conda-forge/osx-arm64/bzip2-1.0.8-hd037594_9.conda - sha256: 540fe54be35fac0c17feefbdc3e29725cce05d7367ffedfaaa1bdda234b019df - md5: 620b85a3f45526a8bc4d23fd78fc22f0 - depends: - - __osx >=11.0 - license: bzip2-1.0.6 - license_family: BSD - purls: [] - size: 124834 - timestamp: 1771350416561 - conda: https://prefix.dev/conda-forge/linux-64/c-ares-1.34.6-hb03c661_0.conda sha256: cc9accf72fa028d31c2a038460787751127317dcfa991f8d1f1babf216bb454e md5: 920bb03579f15389b9e512095ad995b7 @@ -845,25 +718,6 @@ packages: purls: [] size: 207882 timestamp: 1765214722852 -- conda: https://prefix.dev/conda-forge/osx-arm64/c-ares-1.34.6-hc919400_0.conda - sha256: 2995f2aed4e53725e5efbc28199b46bf311c3cab2648fc4f10c2227d6d5fa196 - md5: bcb3cba70cf1eec964a03b4ba7775f01 - depends: - - __osx >=11.0 - license: MIT - license_family: MIT - purls: [] - size: 180327 - timestamp: 1765215064054 -- conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2026.4.22-hbd8a1cb_0.conda - sha256: c9dbcc8039a52023660d6d1bbf87594a93dd69c6ac5a2a44323af2c92976728d - md5: e18ad67cf881dcadee8b8d9e2f8e5f73 - depends: - - __unix - license: ISC - purls: [] - size: 131039 - timestamp: 1776865545798 - conda: https://prefix.dev/conda-forge/linux-64/cairo-1.18.4-he90730b_1.conda sha256: 06525fa0c4e4f56e771a3b986d0fdf0f0fc5a3270830ee47e127a5105bde1b9a md5: bb6c4808bfa69d6f7f6b07e5846ced37 @@ -891,36 +745,6 @@ packages: purls: [] size: 989514 timestamp: 1766415934926 -- conda: https://prefix.dev/conda-forge/osx-arm64/cairo-1.18.4-he0f2337_1.conda - sha256: cde9b79ee206fe3ba6ca2dc5906593fb7a1350515f85b2a1135a4ce8ec1539e3 - md5: 36200ecfbbfbcb82063c87725434161f - depends: - - __osx >=11.0 - - fontconfig >=2.15.0,<3.0a0 - - fonts-conda-ecosystem - - icu >=78.1,<79.0a0 - - libcxx >=19 - - libexpat >=2.7.3,<3.0a0 - - libfreetype >=2.14.1 - - libfreetype6 >=2.14.1 - - libglib >=2.86.3,<3.0a0 - - libpng >=1.6.53,<1.7.0a0 - - libzlib >=1.3.1,<2.0a0 - - pixman >=0.46.4,<1.0a0 - license: LGPL-2.1-only or MPL-1.1 - purls: [] - size: 900035 - timestamp: 1766416416791 -- conda: https://prefix.dev/conda-forge/noarch/certifi-2026.4.22-pyhd8ed1ab_0.conda - sha256: 989db6e5957c4b44fa600c68c681ec2f36a55e48f7c7f1c073d5e91caa8cd878 - md5: 929471569c93acefb30282a22060dcd5 - depends: - - python >=3.10 - license: ISC - purls: - - pkg:pypi/certifi?source=hash-mapping - size: 135656 - timestamp: 1776866680878 - conda: https://prefix.dev/conda-forge/linux-64/cffi-2.0.0-py311h03d9500_1.conda sha256: 3ad13377356c86d3a945ae30e9b8c8734300925ef81a3cb0a9db0d755afbe7bb md5: 3912e4373de46adafd8f1e97e4bd166b @@ -937,61 +761,9 @@ packages: - pkg:pypi/cffi?source=hash-mapping size: 303338 timestamp: 1761202960110 -- conda: https://prefix.dev/conda-forge/osx-arm64/cffi-2.0.0-py311hd10dc20_1.conda - sha256: 1ffde698463d6e7ed571bdb85cb17bfc1d3a107c026d20047995512dcc2749ec - md5: 4d7f6780e36f18e7601811dddf3bbec5 - depends: - - __osx >=11.0 - - libffi >=3.5.2,<3.6.0a0 - - pycparser - - python >=3.11,<3.12.0a0 - - python >=3.11,<3.12.0a0 *_cpython - - python_abi 3.11.* *_cp311 - license: MIT - license_family: MIT - purls: - - pkg:pypi/cffi?source=hash-mapping - size: 294848 - timestamp: 1761203196617 -- conda: https://prefix.dev/conda-forge/noarch/cfgv-3.5.0-pyhd8ed1ab_0.conda - sha256: aa589352e61bb221351a79e5946d56916e3c595783994884accdb3b97fe9d449 - md5: 381bd45fb7aa032691f3063aff47e3a1 - depends: - - python >=3.10 - license: MIT - license_family: MIT - purls: - - pkg:pypi/cfgv?source=hash-mapping - size: 13589 - timestamp: 1763607964133 -- conda: https://prefix.dev/conda-forge/noarch/click-8.3.3-pyhc90fa1f_0.conda - sha256: 37a5d8b10ea3516e2c42f870c9c351b9f7b31ff48c66d83490039f417e1e5228 - md5: 2266262ce8a425ecb6523d765f79b303 - depends: - - __unix - - python - - python >=3.10 - license: BSD-3-Clause - license_family: BSD - purls: - - pkg:pypi/click?source=hash-mapping - size: 100048 - timestamp: 1777219902525 -- conda: https://prefix.dev/conda-forge/noarch/cloudpickle-3.1.2-pyhcf101f3_1.conda - sha256: 4c287c2721d8a34c94928be8fe0e9a85754e90189dd4384a31b1806856b50a67 - md5: 61b8078a0905b12529abc622406cb62c - depends: - - python >=3.10 - - python - license: BSD-3-Clause - license_family: BSD - purls: - - pkg:pypi/cloudpickle?source=hash-mapping - size: 27353 - timestamp: 1765303462831 -- conda: https://prefix.dev/conda-forge/linux-64/cmake-3.26.4-hcfe8598_0.conda - sha256: 37533b572a676017704c989c392998c344e889010786d6555dccdfc524a8e238 - md5: 1714cf0f0facaeb609a0846e4270aff2 +- conda: https://prefix.dev/conda-forge/linux-64/cmake-3.26.4-hcfe8598_0.conda + sha256: 37533b572a676017704c989c392998c344e889010786d6555dccdfc524a8e238 + md5: 1714cf0f0facaeb609a0846e4270aff2 depends: - bzip2 >=1.0.8,<2.0a0 - expat @@ -1011,38 +783,6 @@ packages: purls: [] size: 16343060 timestamp: 1684460894541 -- conda: https://prefix.dev/conda-forge/osx-arm64/cmake-3.26.4-hc0af03a_0.conda - sha256: cba596b6bba58e347bd8be51fce82583f16c5707f6c98b22a7e7ba1ecdb09783 - md5: 84c170713e88c74f45fd87ce2a065cd3 - depends: - - bzip2 >=1.0.8,<2.0a0 - - expat - - libcurl >=8.1.0,<9.0a0 - - libcxx >=15.0.7 - - libexpat >=2.5.0,<3.0a0 - - libuv - - libzlib >=1.2.13,<2.0.0a0 - - ncurses >=6.3,<7.0a0 - - rhash <=1.4.3 - - xz >=5.2.6,<6.0a0 - - zlib - - zstd >=1.5.2,<1.6.0a0 - license: BSD-3-Clause - license_family: BSD - purls: [] - size: 13748747 - timestamp: 1684461655168 -- conda: https://prefix.dev/conda-forge/noarch/colorama-0.4.6-pyhd8ed1ab_1.conda - sha256: ab29d57dc70786c1269633ba3dff20288b81664d3ff8d21af995742e2bb03287 - md5: 962b9857ee8e7018c22f2776ffa0b2d7 - depends: - - python >=3.9 - license: BSD-3-Clause - license_family: BSD - purls: - - pkg:pypi/colorama?source=hash-mapping - size: 27011 - timestamp: 1733218222191 - conda: https://prefix.dev/conda-forge/linux-64/contourpy-1.3.3-py311h724c32c_4.conda sha256: fd7aca059253cff3d8b0aec71f0c1bf2904823b13f1997bf222aea00a76f3cce md5: d04e508f5a03162c8bab4586a65d00bf @@ -1059,22 +799,6 @@ packages: - pkg:pypi/contourpy?source=hash-mapping size: 320553 timestamp: 1769155975008 -- conda: https://prefix.dev/conda-forge/osx-arm64/contourpy-1.3.3-py311h7d85929_4.conda - sha256: 57b2c28cbb45e7dacb565541483d802a15c6beff5ccdabba19784a526191f4d3 - md5: bd91dd35d73638e5c0f520a18850f6ba - depends: - - numpy >=1.25 - - python - - python 3.11.* *_cpython - - __osx >=11.0 - - libcxx >=19 - - python_abi 3.11.* *_cp311 - license: BSD-3-Clause - license_family: BSD - purls: - - pkg:pypi/contourpy?source=hash-mapping - size: 286095 - timestamp: 1769156091585 - conda: https://prefix.dev/conda-forge/linux-64/cryptography-48.0.0-py311h2005dd1_0.conda sha256: 838cde68e70f4e0dc6458613316fa0e50eee5cf86cafb1cee4b7ca1a701a8436 md5: 96f6e551c7ff30c95c1c8b4d2d1c5c9f @@ -1093,18 +817,6 @@ packages: - pkg:pypi/cryptography?source=hash-mapping size: 1913519 timestamp: 1777966158377 -- conda: https://prefix.dev/conda-forge/noarch/cycler-0.12.1-pyhcf101f3_2.conda - sha256: bb47aec5338695ff8efbddbc669064a3b10fe34ad881fb8ad5d64fbfa6910ed1 - md5: 4c2a8fef270f6c69591889b93f9f55c1 - depends: - - python >=3.10 - - python - license: BSD-3-Clause - license_family: BSD - purls: - - pkg:pypi/cycler?source=hash-mapping - size: 14778 - timestamp: 1764466758386 - conda: https://prefix.dev/conda-forge/linux-64/cyrus-sasl-2.1.28-hac629b4_1.conda sha256: 7684da83306bb69686c0506fb09aa7074e1a55ade50c3a879e4e5df6eebb1009 md5: af491aae930edc096b58466c51c4126c @@ -1131,14 +843,6 @@ packages: purls: [] size: 760229 timestamp: 1685695754230 -- conda: https://prefix.dev/conda-forge/osx-arm64/dav1d-1.2.1-hb547adb_0.conda - sha256: 93e077b880a85baec8227e8c72199220c7f87849ad32d02c14fb3807368260b8 - md5: 5a74cdee497e6b65173e10d94582fae6 - license: BSD-2-Clause - license_family: BSD - purls: [] - size: 316394 - timestamp: 1685695959391 - conda: https://prefix.dev/conda-forge/linux-64/dbus-1.16.2-h24cb091_1.conda sha256: 8bb557af1b2b7983cf56292336a1a1853f26555d9c6cecf1e5b2b96838c9da87 md5: ce96f2f470d39bd96ce03945af92e280 @@ -1153,30 +857,6 @@ packages: purls: [] size: 447649 timestamp: 1764536047944 -- conda: https://prefix.dev/conda-forge/osx-arm64/dbus-1.16.2-h3ff7a7c_1.conda - sha256: a8207751ed261764061866880da38e4d3063e167178bfe85b6db9501432462ba - md5: 5a3506971d2d53023c1c4450e908a8da - depends: - - libcxx >=19 - - __osx >=11.0 - - libglib >=2.86.2,<3.0a0 - - libzlib >=1.3.1,<2.0a0 - - libexpat >=2.7.3,<3.0a0 - license: AFL-2.1 OR GPL-2.0-or-later - purls: [] - size: 393811 - timestamp: 1764536084131 -- conda: https://prefix.dev/conda-forge/noarch/distlib-0.4.0-pyhd8ed1ab_0.conda - sha256: 6d977f0b2fc24fee21a9554389ab83070db341af6d6f09285360b2e09ef8b26e - md5: 003b8ba0a94e2f1e117d0bd46aebc901 - depends: - - python >=3.9 - license: Apache-2.0 - license_family: APACHE - purls: - - pkg:pypi/distlib?source=hash-mapping - size: 275642 - timestamp: 1752823081585 - conda: https://prefix.dev/conda-forge/linux-64/double-conversion-3.4.0-hecca717_0.conda sha256: 40cdd1b048444d3235069d75f9c8e1f286db567f6278a93b4f024e5642cfaecc md5: dbe3ec0f120af456b3477743ffd99b74 @@ -1189,18 +869,6 @@ packages: purls: [] size: 71809 timestamp: 1765193127016 -- conda: https://prefix.dev/conda-forge/noarch/editables-0.6-pyhcf101f3_0.conda - sha256: bb826ff403b8195467e7cd5f504bc14767b424dac27bb225508ca2c1852554b2 - md5: 86b177231eecb011fe00e2117dbc3348 - depends: - - python >=3.10 - - python - license: MIT - license_family: MIT - purls: - - pkg:pypi/editables?source=hash-mapping - size: 13160 - timestamp: 1776172429816 - conda: https://prefix.dev/conda-forge/linux-64/epoxy-1.5.10-hb03c661_2.conda sha256: a5b51e491fec22bcc1765f5b2c8fff8a97428e9a5a7ee6730095fb9d091b0747 md5: 057083b06ccf1c2778344b6dabace38b @@ -1224,27 +892,6 @@ packages: purls: [] size: 411735 timestamp: 1758743520805 -- conda: https://prefix.dev/conda-forge/osx-arm64/epoxy-1.5.10-hc919400_2.conda - sha256: ba685b87529c95a4bf9de140a33d703d57dc46b036e9586ed26890de65c1c0d5 - md5: 3b87dabebe54c6d66a07b97b53ac5874 - depends: - - __osx >=11.0 - license: MIT - license_family: MIT - purls: [] - size: 296347 - timestamp: 1758743805063 -- conda: https://prefix.dev/conda-forge/noarch/exceptiongroup-1.3.1-pyhd8ed1ab_0.conda - sha256: ee6cf346d017d954255bbcbdb424cddea4d14e4ed7e9813e429db1d795d01144 - md5: 8e662bd460bda79b1ea39194e3c4c9ab - depends: - - python >=3.10 - - typing_extensions >=4.6.0 - license: MIT and PSF-2.0 - purls: - - pkg:pypi/exceptiongroup?source=hash-mapping - size: 21333 - timestamp: 1763918099466 - conda: https://prefix.dev/conda-forge/linux-64/expat-2.8.0-hecca717_0.conda sha256: ca4dc1da00a8aaa56c1088e7f45f1859ecea6f75874e67584f1af6e5cf8179f8 md5: 992e529e407c9d67d50be1d7543fde4c @@ -1257,38 +904,6 @@ packages: purls: [] size: 148114 timestamp: 1777846120303 -- conda: https://prefix.dev/conda-forge/osx-arm64/expat-2.8.0-hf6b4638_0.conda - sha256: 9f8657c32bcff353b218b1bd7369de34c0534dc5a461630b296265e65e94e2d8 - md5: 90f3b6fa818b07e9402d5ee89f3892d5 - depends: - - __osx >=11.0 - - libexpat 2.8.0 hf6b4638_0 - license: MIT - license_family: MIT - purls: [] - size: 135334 - timestamp: 1777846191235 -- conda: https://prefix.dev/conda-forge/noarch/farama-notifications-0.0.4-pyhd8ed1ab_0.conda - sha256: 8df190d75bac104c6c2317b13397eed9adfa6889b12405b0288ca2ca86855c06 - md5: 61f63fcf1c2deddeae7a85a516d46c94 - depends: - - python >=3.6 - license: MIT - license_family: MIT - purls: - - pkg:pypi/farama-notifications?source=hash-mapping - size: 8406 - timestamp: 1684258265351 -- conda: https://prefix.dev/conda-forge/noarch/filelock-3.29.0-pyhd8ed1ab_0.conda - sha256: 6b471a18372bbd52bdf32fc965f71de3bc1b5219418b8e6b3875a67a7b08c483 - md5: 8fa8358d022a3a9bd101384a808044c6 - depends: - - python >=3.10 - license: Unlicense - purls: - - pkg:pypi/filelock?source=hash-mapping - size: 34211 - timestamp: 1776621506566 - conda: https://prefix.dev/conda-forge/linux-64/fluidsynth-2.5.4-h07a5eef_0.conda sha256: bb759e354a9f383635e1982d5a7ea547ac2a3a9d73ec62b07e489f26b8967ebc md5: e48d6e1f837a307d824f2b3f9a7065d7 @@ -1311,55 +926,6 @@ packages: purls: [] size: 341443 timestamp: 1776634510786 -- conda: https://prefix.dev/conda-forge/osx-arm64/fluidsynth-2.5.4-h985f16e_0.conda - sha256: 6fab2acb6b1c7ba0fc06c3d4cefa552c3da4c3d6a79dcdd2158eea96931c3929 - md5: 1f716f3ba6477330807ed061637048c7 - depends: - - __osx >=11.0 - - libcxx >=19 - - libglib >=2.86.4,<3.0a0 - - libsndfile >=1.2.2,<1.3.0a0 - - llvm-openmp >=19.1.7 - - portaudio >=19.7.0,<19.8.0a0 - - readline >=8.3,<9.0a0 - - sdl2 >=2.32.56,<3.0a0 - license: GPL-2.0-or-later - license_family: LGPL - purls: [] - size: 291966 - timestamp: 1776634889426 -- conda: https://prefix.dev/conda-forge/noarch/font-ttf-dejavu-sans-mono-2.37-hab24e00_0.tar.bz2 - sha256: 58d7f40d2940dd0a8aa28651239adbf5613254df0f75789919c4e6762054403b - md5: 0c96522c6bdaed4b1566d11387caaf45 - license: BSD-3-Clause - license_family: BSD - purls: [] - size: 397370 - timestamp: 1566932522327 -- conda: https://prefix.dev/conda-forge/noarch/font-ttf-inconsolata-3.000-h77eed37_0.tar.bz2 - sha256: c52a29fdac682c20d252facc50f01e7c2e7ceac52aa9817aaf0bb83f7559ec5c - md5: 34893075a5c9e55cdafac56607368fc6 - license: OFL-1.1 - license_family: Other - purls: [] - size: 96530 - timestamp: 1620479909603 -- conda: https://prefix.dev/conda-forge/noarch/font-ttf-source-code-pro-2.038-h77eed37_0.tar.bz2 - sha256: 00925c8c055a2275614b4d983e1df637245e19058d79fc7dd1a93b8d9fb4b139 - md5: 4d59c254e01d9cde7957100457e2d5fb - license: OFL-1.1 - license_family: Other - purls: [] - size: 700814 - timestamp: 1620479612257 -- conda: https://prefix.dev/conda-forge/noarch/font-ttf-ubuntu-0.83-h77eed37_3.conda - sha256: 2821ec1dc454bd8b9a31d0ed22a7ce22422c0aef163c59f49dfdf915d0f0ca14 - md5: 49023d73832ef61042f6a237cb2687e7 - license: LicenseRef-Ubuntu-Font-Licence-Version-1.0 - license_family: Other - purls: [] - size: 1620504 - timestamp: 1727511233259 - conda: https://prefix.dev/conda-forge/linux-64/fontconfig-2.17.1-h27c8c51_0.conda sha256: aa4a44dba97151221100a637c7f4bde619567afade9c0265f8e1c8eed8d7bd8c md5: 867127763fbe935bab59815b6e0b7b5c @@ -1376,46 +942,9 @@ packages: purls: [] size: 270705 timestamp: 1771382710863 -- conda: https://prefix.dev/conda-forge/osx-arm64/fontconfig-2.17.1-h2b252f5_0.conda - sha256: 851e9c778bfc54645dcab7038c0383445cbebf16f6bb2d3f62ce422b1605385a - md5: d06ae1a11b46cc4c74177ecd28de7c7a - depends: - - __osx >=11.0 - - libexpat >=2.7.4,<3.0a0 - - libfreetype >=2.14.1 - - libfreetype6 >=2.14.1 - - libzlib >=1.3.1,<2.0a0 - license: MIT - license_family: MIT - purls: [] - size: 237308 - timestamp: 1771382999247 -- conda: https://prefix.dev/conda-forge/noarch/fonts-conda-ecosystem-1-0.tar.bz2 - sha256: a997f2f1921bb9c9d76e6fa2f6b408b7fa549edd349a77639c9fe7a23ea93e61 - md5: fee5683a3f04bd15cbd8318b096a27ab - depends: - - fonts-conda-forge - license: BSD-3-Clause - license_family: BSD - purls: [] - size: 3667 - timestamp: 1566974674465 -- conda: https://prefix.dev/conda-forge/noarch/fonts-conda-forge-1-hc364b38_1.conda - sha256: 54eea8469786bc2291cc40bca5f46438d3e062a399e8f53f013b6a9f50e98333 - md5: a7970cd949a077b7cb9696379d338681 - depends: - - font-ttf-ubuntu - - font-ttf-inconsolata - - font-ttf-dejavu-sans-mono - - font-ttf-source-code-pro - license: BSD-3-Clause - license_family: BSD - purls: [] - size: 4059 - timestamp: 1762351264405 -- conda: https://prefix.dev/conda-forge/linux-64/fonttools-4.63.0-py311h3778330_0.conda - sha256: ce5004df66a6bf4e3d634850ab43471b98700291065281eb1982eb54b7bf7d85 - md5: 498ede447c05b203be980ae1dceb06f3 +- conda: https://prefix.dev/conda-forge/linux-64/fonttools-4.63.0-py311h3778330_0.conda + sha256: ce5004df66a6bf4e3d634850ab43471b98700291065281eb1982eb54b7bf7d85 + md5: 498ede447c05b203be980ae1dceb06f3 depends: - __glibc >=2.17,<3.0.a0 - brotli @@ -1430,23 +959,6 @@ packages: - pkg:pypi/fonttools?source=hash-mapping size: 3045399 timestamp: 1778770357867 -- conda: https://prefix.dev/conda-forge/osx-arm64/fonttools-4.63.0-py311hc290fe0_0.conda - sha256: e339446253b5aec4342526334cb2575a20beaf15478469d9baa3c5a11c7aa498 - md5: 23ee082b5c5dc73c19dc0b6451d35079 - depends: - - __osx >=11.0 - - brotli - - munkres - - python >=3.11,<3.12.0a0 - - python >=3.11,<3.12.0a0 *_cpython - - python_abi 3.11.* *_cp311 - - unicodedata2 >=15.1.0 - license: MIT - license_family: MIT - purls: - - pkg:pypi/fonttools?source=hash-mapping - size: 2948507 - timestamp: 1778771011007 - conda: https://prefix.dev/conda-forge/linux-64/freetype-2.14.3-ha770c72_0.conda sha256: c934c385889c7836f034039b43b05ccfa98f53c900db03d8411189892ced090b md5: 8462b5322567212beeb025f3519fb3e2 @@ -1457,16 +969,6 @@ packages: purls: [] size: 173839 timestamp: 1774298173462 -- conda: https://prefix.dev/conda-forge/osx-arm64/freetype-2.14.3-hce30654_0.conda - sha256: 5952bd9db12207a18a112e8924aa2ce8c2f9d57b62584d58a97d2f6afe1ea324 - md5: 6dcc75ba2e04c555e881b72793d3282f - depends: - - libfreetype 2.14.3 hce30654_0 - - libfreetype6 2.14.3 hdfa99f5_0 - license: GPL-2.0-only OR FTL - purls: [] - size: 173313 - timestamp: 1774298702053 - conda: https://prefix.dev/conda-forge/linux-64/fribidi-1.0.16-hb03c661_0.conda sha256: 858283ff33d4c033f4971bf440cebff217d5552a5222ba994c49be990dacd40d md5: f9f81ea472684d75b9dd8d0b328cf655 @@ -1477,15 +979,6 @@ packages: purls: [] size: 61244 timestamp: 1757438574066 -- conda: https://prefix.dev/conda-forge/osx-arm64/fribidi-1.0.16-hc919400_0.conda - sha256: d856dc6744ecfba78c5f7df3378f03a75c911aadac803fa2b41a583667b4b600 - md5: 04bdce8d93a4ed181d1d726163c2d447 - depends: - - __osx >=11.0 - license: LGPL-2.1-or-later - purls: [] - size: 59391 - timestamp: 1757438897523 - conda: https://prefix.dev/conda-forge/linux-64/gdk-pixbuf-2.44.6-h2b0a6b4_0.conda sha256: c5594497f0646e9079705b3199dbb2d5b13c48173cf110000fa1c8818e2b3e0c md5: 7892f39a39ed39591a89a28eba03e987 @@ -1502,22 +995,6 @@ packages: purls: [] size: 577414 timestamp: 1774985848058 -- conda: https://prefix.dev/conda-forge/osx-arm64/gdk-pixbuf-2.44.6-h4e57454_0.conda - sha256: 07cbba4e12430de35ea608eb3006cf1f7f63832c4f89a081cd6f3872944c1aa6 - md5: e67ebd2f639f46e52af8531622fa6051 - depends: - - __osx >=11.0 - - libglib >=2.86.4,<3.0a0 - - libintl >=0.25.1,<1.0a0 - - libjpeg-turbo >=3.1.2,<4.0a0 - - liblzma >=5.8.2,<6.0a0 - - libpng >=1.6.56,<1.7.0a0 - - libtiff >=4.7.1,<4.8.0a0 - license: LGPL-2.1-or-later - license_family: LGPL - purls: [] - size: 548309 - timestamp: 1774986047281 - conda: https://prefix.dev/conda-forge/linux-64/glib-tools-2.88.3-h95f0039_0.conda sha256: ccdad3d9149ca12353583818bdfde9f66753da7e8ea6dd35a6312062e2fe60d2 md5: 841fd9387fd3f24ea69a4f679242e32c @@ -1530,18 +1007,6 @@ packages: purls: [] size: 238245 timestamp: 1785442107463 -- conda: https://prefix.dev/conda-forge/osx-arm64/glib-tools-2.88.3-h5f197ff_0.conda - sha256: 672b06a290ae9bd4443f9315334f2dbb6d0ba239b3a1f2ea40fd66321e7a3ac6 - md5: 607824e2f42f49049c999432385832e3 - depends: - - libglib ==2.88.3 ha08bb59_0 - - libffi - - __osx >=11.0 - - libintl >=0.25.1,<1.0a0 - license: LGPL-2.1-or-later - purls: [] - size: 205078 - timestamp: 1785442168180 - conda: https://prefix.dev/conda-forge/linux-64/graphite2-1.3.15-h54a6638_1.conda sha256: 7fa3b6a9c081fa3e545573152a788d061a0a0ba57df7251cc0f4f75225fc93e7 md5: f9fe2984587fa8235a6af6004760cd18 @@ -1554,17 +1019,6 @@ packages: purls: [] size: 102835 timestamp: 1786118485753 -- conda: https://prefix.dev/conda-forge/osx-arm64/graphite2-1.3.15-h784d473_1.conda - sha256: 471f34a187fdb4f2df33e26f2e471b16c239a5b277903f643d9c3a8c9a9f44ec - md5: 0c7b78d9ffff4f5a6ca28d346f734d8f - depends: - - libcxx >=19 - - __osx >=11.0 - license: LGPL-2.0-or-later - license_family: LGPL - purls: [] - size: 86493 - timestamp: 1786118637573 - conda: https://prefix.dev/conda-forge/linux-64/graphviz-13.1.2-h87b6fe6_0.conda sha256: efbd7d483f3d79b7882515ccf229eceb7f4ff636ea2019044e98243722f428be md5: 0adddc9b820f596638d8b0ff9e3b4823 @@ -1590,30 +1044,6 @@ packages: purls: [] size: 2427887 timestamp: 1754732581595 -- conda: https://prefix.dev/conda-forge/osx-arm64/graphviz-13.1.2-hcd33d8b_0.conda - sha256: f25e1828d02ebd78214966f483cfca5ac6a7b18824369c748d8cda99c66ff588 - md5: 81ab85a5a8481667660c7ce6e84bd681 - depends: - - __osx >=11.0 - - adwaita-icon-theme - - cairo >=1.18.4,<2.0a0 - - fonts-conda-ecosystem - - gdk-pixbuf >=2.42.12,<3.0a0 - - gtk3 >=3.24.43,<4.0a0 - - gts >=0.7.6,<0.8.0a0 - - libcxx >=19 - - libexpat >=2.7.1,<3.0a0 - - libgd >=2.3.3,<2.4.0a0 - - libglib >=2.84.3,<3.0a0 - - librsvg >=2.58.4,<3.0a0 - - libwebp-base >=1.6.0,<2.0a0 - - libzlib >=1.3.1,<2.0a0 - - pango >=1.56.4,<2.0a0 - license: EPL-1.0 - license_family: Other - purls: [] - size: 2201370 - timestamp: 1754732518951 - conda: https://prefix.dev/conda-forge/linux-64/gtk3-3.24.43-h993cebd_6.conda sha256: 004688fbb2c479b200a6d85ef38c3129fcd4ce13537b7ee2371d962b372761c1 md5: f9f33c65b20e6a61f21714785e3613ec @@ -1655,30 +1085,6 @@ packages: purls: [] size: 5587108 timestamp: 1761327349586 -- conda: https://prefix.dev/conda-forge/osx-arm64/gtk3-3.24.43-h5febe37_6.conda - sha256: bd66a3325bf3ce63ada3bf12eaafcfe036698741ee4bb595e83e5fdd3dba9f3d - md5: a99f96906158ebae5e3c0904bcd45145 - depends: - - __osx >=11.0 - - atk-1.0 >=2.38.0 - - cairo >=1.18.4,<2.0a0 - - epoxy >=1.5.10,<1.6.0a0 - - fribidi >=1.0.16,<2.0a0 - - gdk-pixbuf >=2.44.4,<3.0a0 - - glib-tools - - harfbuzz >=11.5.1 - - hicolor-icon-theme - - libexpat >=2.7.1,<3.0a0 - - libglib >=2.86.0,<3.0a0 - - libintl >=0.25.1,<1.0a0 - - liblzma >=5.8.1,<6.0a0 - - libzlib >=1.3.1,<2.0a0 - - pango >=1.56.4,<2.0a0 - license: LGPL-2.0-or-later - license_family: LGPL - purls: [] - size: 4768791 - timestamp: 1761328318680 - conda: https://prefix.dev/conda-forge/linux-64/gts-0.7.6-h977cf35_4.conda sha256: b5cd16262fefb836f69dc26d879b6508d29f8a5c5948a966c47fe99e2e19c99b md5: 4d8df0b0db060d33c9a702ada998a8fe @@ -1691,17 +1097,6 @@ packages: purls: [] size: 318312 timestamp: 1686545244763 -- conda: https://prefix.dev/conda-forge/osx-arm64/gts-0.7.6-he42f4ea_4.conda - sha256: e0f8c7bc1b9ea62ded78ffa848e37771eeaaaf55b3146580513c7266862043ba - md5: 21b4dd3098f63a74cf2aa9159cbef57d - depends: - - libcxx >=15.0.7 - - libglib >=2.76.3,<3.0a0 - license: LGPL-2.0-or-later - license_family: LGPL - purls: [] - size: 304331 - timestamp: 1686545503242 - conda: https://prefix.dev/conda-forge/linux-64/gymnasium-1.3.0-np2py311hec5889a_0.conda sha256: d1e8bc964d6a2a70b52ebd36f0815b9867a3db8a973e3f6da2e0c1a57b0144a2 md5: f7e72a66dea8ee8eeab367bd824a7d95 @@ -1719,50 +1114,6 @@ packages: - pkg:pypi/gymnasium?source=hash-mapping size: 1139365 timestamp: 1777204693923 -- conda: https://prefix.dev/conda-forge/osx-arm64/gymnasium-1.3.0-np2py311h56d0776_0.conda - sha256: ab03d30592506e1dfe9e6fc30cddea577dd42a7eb4b6da8a80de543928e2e6fd - md5: d64237fee1a064db6f7c53090a6844da - depends: - - python - - cloudpickle >=1.2.0 - - farama-notifications - - jax-jumpy >=1.0.0 - - typing_extensions >=4.3.0 - - python_abi 3.11.* *_cp311 - - numpy >=1.23,<3 - license: MIT - license_family: MIT - purls: - - pkg:pypi/gymnasium?source=hash-mapping - size: 1138451 - timestamp: 1777204698446 -- conda: https://prefix.dev/conda-forge/noarch/h11-0.16.0-pyhcf101f3_1.conda - sha256: 96cac6573fd35ae151f4d6979bab6fbc90cb6b1fb99054ba19eb075da9822fcb - md5: b8993c19b0c32a2f7b66cbb58ca27069 - depends: - - python >=3.10 - - typing_extensions - - python - license: MIT - license_family: MIT - purls: - - pkg:pypi/h11?source=hash-mapping - size: 39069 - timestamp: 1767729720872 -- conda: https://prefix.dev/conda-forge/noarch/h2-4.3.0-pyhcf101f3_0.conda - sha256: 84c64443368f84b600bfecc529a1194a3b14c3656ee2e832d15a20e0329b6da3 - md5: 164fc43f0b53b6e3a7bc7dce5e4f1dc9 - depends: - - python >=3.10 - - hyperframe >=6.1,<7 - - hpack >=4.1,<5 - - python - license: MIT - license_family: MIT - purls: - - pkg:pypi/h2?source=hash-mapping - size: 95967 - timestamp: 1756364871835 - conda: https://prefix.dev/conda-forge/linux-64/harfbuzz-14.3.1-ha770c72_0.conda sha256: d2b22411323270acf8199070fe3377d72f36830f467f09fb2f5bcd4dc3ef77dd md5: 15971d7910faa28aa5b0b2560b9a3bab @@ -1773,4569 +1124,5281 @@ packages: purls: [] size: 11076 timestamp: 1786970900409 -- conda: https://prefix.dev/conda-forge/osx-arm64/harfbuzz-14.3.1-hce30654_0.conda - sha256: 1120c57b917fb0bb8fef770d56f308564c94daea0eb29a643c9f5cf73195de78 - md5: 4fb57d98ef4b5f335d96d3ab0f25d6ea +- conda: https://prefix.dev/conda-forge/linux-64/hicolor-icon-theme-0.17-ha770c72_3.conda + sha256: 6d7e6e1286cb521059fe69696705100a03b006efb914ffe82a2ae97ecbae66b7 + md5: 129e404c5b001f3ef5581316971e3ea0 + license: GPL-2.0-or-later + license_family: GPL + purls: [] + size: 17625 + timestamp: 1771539597968 +- conda: https://prefix.dev/conda-forge/linux-64/icu-78.3-py310h44b86e0_2.conda + sha256: 9f07834f0c546ab14d885ce0366285f61f44e326c0edd1fc63b8294e113ae432 + md5: 72a381cbad04f24b1c2a43ef707f45b4 depends: - - libharfbuzz-devel 14.3.1 hcda0f7c_0 + - __glibc >=2.17,<3.0.a0 + - libstdcxx >=14 + - libgcc >=14 license: MIT license_family: MIT purls: [] - size: 11045 - timestamp: 1786970975481 -- conda: https://prefix.dev/conda-forge/noarch/hatch-1.16.5-pyhcf101f3_0.conda - sha256: e298f93e25d98f5b90f231cf9cd6467773fc3fd242a9a0dce2b82fcfa1b38971 - md5: 3191c464a2222e8af63e57926da9315c + size: 14459115 + timestamp: 1786545741408 +- conda: https://prefix.dev/conda-forge/linux-64/jack-1.9.22-hf4617a5_3.conda + sha256: 69f6b7228aa43177c82e21b90497adb1d7c61e70f1b8dd38d8ca8baa74a0cbf7 + md5: a071738556dc29fa1c844fb440506dc8 depends: - - click >=8.0.6 - - hatchling >=1.27.0 - - httpx >=0.22.0 - - hyperlink >=21.0.0 - - keyring >=23.5.0 - - packaging >=24.2 - - pexpect >=4.8,<5.dev0 - - platformdirs >=2.5.0 - - pyproject_hooks - - python >=3.10 - - rich >=11.2.0 - - shellingham >=1.4.0 - - tomli-w >=1.0 - - tomlkit >=0.11.1 - - userpath >=1.7,<2.dev0 - - uv >=0.5.23 - - virtualenv >=21 - - backports.zstd >=1.0.0 - - python-discovery >=1.1 - - python - license: MIT - license_family: MIT - purls: - - pkg:pypi/hatch?source=hash-mapping - size: 208420 - timestamp: 1772806610433 -- conda: https://prefix.dev/conda-forge/noarch/hatchling-1.29.0-pyhcf101f3_0.conda - sha256: bb86ff4ca54a2a0f63714766c7653a772c13d34c9e7cfb7be653db2fb806f961 - md5: 9d67ecd4cd5e6a9be36522be95951785 - depends: - - packaging >=24.2 - - pathspec >=0.10.1 - - pluggy >=1.0.0 - - python >=3.10 - - tomli >=1.2.2 - - trove-classifiers - - editables >=0.3 - - python - license: MIT - license_family: MIT - purls: - - pkg:pypi/hatchling?source=hash-mapping - size: 61052 - timestamp: 1773194193187 -- conda: https://prefix.dev/conda-forge/linux-64/hicolor-icon-theme-0.17-ha770c72_3.conda - sha256: 6d7e6e1286cb521059fe69696705100a03b006efb914ffe82a2ae97ecbae66b7 - md5: 129e404c5b001f3ef5581316971e3ea0 - license: GPL-2.0-or-later - license_family: GPL - purls: [] - size: 17625 - timestamp: 1771539597968 -- conda: https://prefix.dev/conda-forge/osx-arm64/hicolor-icon-theme-0.17-hce30654_3.conda - sha256: 46a4958f2f916c5938f2a6dc0709f78b175ece42f601d79a04e0276d55d25d07 - md5: cfb39109ac5fa8601eb595d66d5bf156 - license: GPL-2.0-or-later - license_family: GPL + - __glibc >=2.17,<3.0.a0 + - alsa-lib >=1.2.14,<1.3.0a0 + - libgcc >=13 + - libopus >=1.5.2,<2.0a0 + - libstdcxx >=13 + license: LGPL-2.0-only + license_family: LGPL purls: [] - size: 17616 - timestamp: 1771539622983 -- conda: https://prefix.dev/conda-forge/noarch/hpack-4.1.0-pyhd8ed1ab_0.conda - sha256: 6ad78a180576c706aabeb5b4c8ceb97c0cb25f1e112d76495bff23e3779948ba - md5: 0a802cb9888dd14eeefc611f05c40b6e + size: 461260 + timestamp: 1747574434594 +- conda: https://prefix.dev/conda-forge/linux-64/keyutils-1.6.3-hb9d3cd8_0.conda + sha256: 0960d06048a7185d3542d850986d807c6e37ca2e644342dd0c72feefcf26c2a4 + md5: b38117a3c920364aff79f870c984b4a3 depends: - - python >=3.9 - license: MIT - license_family: MIT - purls: - - pkg:pypi/hpack?source=hash-mapping - size: 30731 - timestamp: 1737618390337 -- conda: https://prefix.dev/conda-forge/noarch/httpcore-1.0.9-pyh29332c3_0.conda - sha256: 04d49cb3c42714ce533a8553986e1642d0549a05dc5cc48e0d43ff5be6679a5b - md5: 4f14640d58e2cc0aa0819d9d8ba125bb + - __glibc >=2.17,<3.0.a0 + - libgcc >=13 + license: LGPL-2.1-or-later + purls: [] + size: 134088 + timestamp: 1754905959823 +- conda: https://prefix.dev/conda-forge/linux-64/kiwisolver-1.5.0-py311h724c32c_0.conda + sha256: 3ff7e51c88f53f05e22ca5549e935d1ccb398665f6ec080a9c6a5c9e9b186b79 + md5: 3d82751e8d682068b58f049edc924ce4 depends: - - python >=3.9 - - h11 >=0.16 - - h2 >=3,<5 - - sniffio 1.* - - anyio >=4.0,<5.0 - - certifi - python + - libstdcxx >=14 + - libgcc >=14 + - __glibc >=2.17,<3.0.a0 + - python_abi 3.11.* *_cp311 license: BSD-3-Clause license_family: BSD purls: - - pkg:pypi/httpcore?source=hash-mapping - size: 49483 - timestamp: 1745602916758 -- conda: https://prefix.dev/conda-forge/noarch/httpx-0.28.1-pyhd8ed1ab_0.conda - sha256: cd0f1de3697b252df95f98383e9edb1d00386bfdd03fdf607fa42fe5fcb09950 - md5: d6989ead454181f4f9bc987d3dc4e285 - depends: - - anyio - - certifi - - httpcore 1.* - - idna - - python >=3.9 - license: BSD-3-Clause - license_family: BSD - purls: - - pkg:pypi/httpx?source=hash-mapping - size: 63082 - timestamp: 1733663449209 -- conda: https://prefix.dev/conda-forge/noarch/hyperframe-6.1.0-pyhd8ed1ab_0.conda - sha256: 77af6f5fe8b62ca07d09ac60127a30d9069fdc3c68d6b256754d0ffb1f7779f8 - md5: 8e6923fc12f1fe8f8c4e5c9f343256ac + - pkg:pypi/kiwisolver?source=hash-mapping + size: 77967 + timestamp: 1773067041763 +- conda: https://prefix.dev/conda-forge/linux-64/krb5-1.22.2-ha1258a1_0.conda + sha256: 3e307628ca3527448dd1cb14ad7bb9d04d1d28c7d4c5f97ba196ae984571dd25 + md5: fb53fb07ce46a575c5d004bbc96032c2 depends: - - python >=3.9 + - __glibc >=2.17,<3.0.a0 + - keyutils >=1.6.3,<2.0a0 + - libedit >=3.1.20250104,<3.2.0a0 + - libedit >=3.1.20250104,<4.0a0 + - libgcc >=14 + - libstdcxx >=14 + - openssl >=3.5.5,<4.0a0 license: MIT license_family: MIT - purls: - - pkg:pypi/hyperframe?source=hash-mapping - size: 17397 - timestamp: 1737618427549 -- conda: https://prefix.dev/conda-forge/noarch/hyperlink-21.0.0-pyh29332c3_1.conda - sha256: 6fc0a91c590b3055bfb7983e6521c7b780ab8b11025058eaf898049ea827d829 - md5: c27acdecaf3c311e5781b81fe02d9641 + purls: [] + size: 1386730 + timestamp: 1769769569681 +- conda: https://prefix.dev/conda-forge/linux-64/lame-3.100-h166bdaf_1003.tar.bz2 + sha256: aad2a703b9d7b038c0f745b853c6bb5f122988fe1a7a096e0e606d9cbec4eaab + md5: a8832b479f93521a9e7b5b743803be51 depends: - - python >=3.9 - - idna >=2.6 - - python + - libgcc-ng >=12 + license: LGPL-2.0-only + license_family: LGPL + purls: [] + size: 508258 + timestamp: 1664996250081 +- conda: https://prefix.dev/conda-forge/linux-64/lcms2-2.19.1-h0c24ade_1.conda + sha256: 112b5b9462572d970f4abd2912f76a25ee7db158b1e7260163d91dd8a630db84 + md5: 8b3ce45e929cd8e8e5f4d18586b56d8b + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + - libjpeg-turbo >=3.1.4.1,<4.0a0 + - libtiff >=4.7.1,<4.8.0a0 license: MIT license_family: MIT - purls: - - pkg:pypi/hyperlink?source=hash-mapping - size: 74751 - timestamp: 1733319972207 -- conda: https://prefix.dev/conda-forge/linux-64/icu-78.3-py310h44b86e0_2.conda - sha256: 9f07834f0c546ab14d885ce0366285f61f44e326c0edd1fc63b8294e113ae432 - md5: 72a381cbad04f24b1c2a43ef707f45b4 + purls: [] + size: 251971 + timestamp: 1780211695895 +- conda: https://prefix.dev/conda-forge/linux-64/ld_impl_linux-64-2.45.1-default_hbd61a6d_102.conda + sha256: 3d584956604909ff5df353767f3a2a2f60e07d070b328d109f30ac40cd62df6c + md5: 18335a698559cdbcd86150a48bf54ba6 + depends: + - __glibc >=2.17,<3.0.a0 + - zstd >=1.5.7,<1.6.0a0 + constrains: + - binutils_impl_linux-64 2.45.1 + license: GPL-3.0-only + license_family: GPL + purls: [] + size: 728002 + timestamp: 1774197446916 +- conda: https://prefix.dev/conda-forge/linux-64/lerc-4.1.0-hdb68285_0.conda + sha256: f84cb54782f7e9cea95e810ea8fef186e0652d0fa73d3009914fa2c1262594e1 + md5: a752488c68f2e7c456bcbd8f16eec275 depends: - __glibc >=2.17,<3.0.a0 + - libgcc >=14 - libstdcxx >=14 + license: Apache-2.0 + license_family: Apache + purls: [] + size: 261513 + timestamp: 1773113328888 +- conda: https://prefix.dev/conda-forge/linux-64/libavif16-1.4.1-hcfa2d63_0.conda + sha256: e29d8ed0334305c6bafecb32f9a1967cfc0a081eac916e947a1f2f7c4bb41947 + md5: f79415aee8862b3af85ea55dea37e46b + depends: + - __glibc >=2.17,<3.0.a0 + - aom >=3.9.1,<3.10.0a0 + - dav1d >=1.2.1,<1.2.2.0a0 - libgcc >=14 + - rav1e >=0.8.1,<0.9.0a0 + - svt-av1 >=4.0.1,<4.0.2.0a0 + license: BSD-2-Clause + license_family: BSD + purls: [] + size: 148710 + timestamp: 1774042709303 +- conda: https://prefix.dev/conda-forge/linux-64/libblas-3.11.0-6_h4a7cf45_openblas.conda + build_number: 6 + sha256: 7bfe936dbb5db04820cf300a9cc1f5ee8d5302fc896c2d66e30f1ee2f20fbfd6 + md5: 6d6d225559bfa6e2f3c90ee9c03d4e2e + depends: + - libopenblas >=0.3.32,<0.3.33.0a0 + - libopenblas >=0.3.32,<1.0a0 + constrains: + - blas 2.306 openblas + - liblapack 3.11.0 6*_openblas + - liblapacke 3.11.0 6*_openblas + - libcblas 3.11.0 6*_openblas + - mkl <2026 + license: BSD-3-Clause + license_family: BSD + purls: [] + size: 18621 + timestamp: 1774503034895 +- conda: https://prefix.dev/conda-forge/linux-64/libbrotlicommon-1.2.0-h39a168f_3.conda + sha256: e5864f257f839ffc27d681659bac95901f524f602b9121e5dcc5e2df18437f2d + md5: 7a2499a177753582fb7ae7e9dc4a908a + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc >=15 license: MIT license_family: MIT purls: [] - size: 14459115 - timestamp: 1786545741408 -- conda: https://prefix.dev/conda-forge/osx-arm64/icu-78.3-py310h579977c_2.conda - sha256: 6cdb5dee54c72e56ab189fb3ad33cb28533553d42590e7e831160248f4416a43 - md5: a5efc0b42bb8b42e97d0a29ae3e3c187 + size: 80265 + timestamp: 1786622773969 +- conda: https://prefix.dev/conda-forge/linux-64/libbrotlidec-1.2.0-ha411449_3.conda + sha256: dad31b6d104973deb89710929a35651033aad692d4e7793cdb5b786a9bd54678 + md5: 6ab3315dc56618d652c1da42a648a129 depends: - - __osx >=11.0 + - __glibc >=2.17,<3.0.a0 + - libbrotlicommon 1.2.0 h39a168f_3 + - libgcc >=15 license: MIT license_family: MIT purls: [] - size: 14070242 - timestamp: 1786545847761 -- conda: https://prefix.dev/conda-forge/noarch/identify-2.6.19-pyhd8ed1ab_0.conda - sha256: 381cedccf0866babfc135d65ee40b778bd20e927d2a5ec810f750c5860a7c5b8 - md5: 84a3233b709a289a4ddd7a2fd27dd988 + size: 34828 + timestamp: 1786622783405 +- conda: https://prefix.dev/conda-forge/linux-64/libbrotlienc-1.2.0-h018ffa1_3.conda + sha256: d37124d0f51816e7d5e3a94bfc9ed3d6174d077f9b4f832d20c5a08b52bebf1f + md5: 2ac965638d4c6b2b38383bb1aebaf543 depends: - - python >=3.10 - - ukkonen + - __glibc >=2.17,<3.0.a0 + - libbrotlicommon 1.2.0 h39a168f_3 + - libgcc >=15 license: MIT license_family: MIT - purls: - - pkg:pypi/identify?source=hash-mapping - size: 79757 - timestamp: 1776455344188 -- conda: https://prefix.dev/conda-forge/noarch/idna-3.13-pyhcf101f3_0.conda - sha256: 9ab620e6f64bb67737bd7bc1ad6f480770124e304c6710617aba7fe60b089f48 - md5: fb7130c190f9b4ec91219840a05ba3ac - depends: - - python >=3.10 - - python - license: BSD-3-Clause - license_family: BSD - purls: - - pkg:pypi/idna?source=hash-mapping - size: 59038 - timestamp: 1776947141407 -- conda: https://prefix.dev/conda-forge/noarch/importlib-metadata-8.8.0-pyhcf101f3_0.conda - sha256: 82ab2a0d91ca1e7e63ab6a4939356667ef683905dea631bc2121aa534d347b16 - md5: 080594bf4493e6bae2607e65390c520a + purls: [] + size: 298639 + timestamp: 1786622792145 +- conda: https://prefix.dev/conda-forge/linux-64/libcap-2.77-hd0affe5_1.conda + sha256: 37c41b1024d0c75da76822e3c079aabaf121618a32fe05e53a897b35a88008fc + md5: 499cd8e2d4358986dbe3b30e8fe1bf6a depends: - - python >=3.10 - - zipp >=3.20 - - python - license: Apache-2.0 - license_family: APACHE - purls: - - pkg:pypi/importlib-metadata?source=hash-mapping - size: 34387 - timestamp: 1773931568510 -- conda: https://prefix.dev/conda-forge/noarch/importlib_resources-7.1.0-pyhd8ed1ab_0.conda - sha256: a563a51aa522998172838e867e6dedcf630bc45796e8612f5a1f6d73e9c8125a - md5: 0ba6225c279baf7ea9473a62ea0ec9ae + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + license: BSD-3-Clause + license_family: BSD + purls: [] + size: 124432 + timestamp: 1774333989027 +- conda: https://prefix.dev/conda-forge/linux-64/libcblas-3.11.0-6_h0358290_openblas.conda + build_number: 6 + sha256: 57edafa7796f6fa3ebbd5367692dd4c7f552be42109c2dd1a7c89b55089bf374 + md5: 36ae340a916635b97ac8a0655ace2a35 depends: - - python >=3.10 - - zipp >=3.1.0 + - libblas 3.11.0 6_h4a7cf45_openblas constrains: - - importlib-resources >=7.1.0,<7.1.1.0a0 - license: Apache-2.0 - license_family: APACHE - purls: - - pkg:pypi/importlib-resources?source=hash-mapping - size: 34809 - timestamp: 1776068839274 -- conda: https://prefix.dev/conda-forge/noarch/iniconfig-2.3.0-pyhd8ed1ab_0.conda - sha256: e1a9e3b1c8fe62dc3932a616c284b5d8cbe3124bbfbedcf4ce5c828cb166ee19 - md5: 9614359868482abba1bd15ce465e3c42 + - blas 2.306 openblas + - liblapack 3.11.0 6*_openblas + - liblapacke 3.11.0 6*_openblas + license: BSD-3-Clause + license_family: BSD + purls: [] + size: 18622 + timestamp: 1774503050205 +- conda: https://prefix.dev/conda-forge/linux-64/libccd-double-2.1-h59595ed_3.conda + sha256: 4695ce68eda595b4f53146bea1096a9f2e0d33290618ba83a246b5ed8871ebc9 + md5: 6a3d962d34385e0a511b859d679f6ea2 depends: - - python >=3.10 - license: MIT - license_family: MIT - purls: - - pkg:pypi/iniconfig?source=hash-mapping - size: 13387 - timestamp: 1760831448842 -- conda: https://prefix.dev/conda-forge/linux-64/jack-1.9.22-hf4617a5_3.conda - sha256: 69f6b7228aa43177c82e21b90497adb1d7c61e70f1b8dd38d8ca8baa74a0cbf7 - md5: a071738556dc29fa1c844fb440506dc8 + - libgcc-ng >=12 + - libstdcxx-ng >=12 + constrains: + - libccd <1 + license: BSD-3-Clause + license_family: BSD + purls: [] + size: 36171 + timestamp: 1687341825064 +- conda: https://prefix.dev/conda-forge/linux-64/libclang-cpp22.1-22.1.8-default_h08c5240_6.conda + sha256: fc2981a8e45dd232ae88cf2580f7e75c258f4dccdc96f879b68ef0a9b45c9a2b + md5: 4fd9026a57bb45cd15bd08ff8bd0578e depends: + - libstdcxx >=14 + - libgcc >=14 - __glibc >=2.17,<3.0.a0 - - alsa-lib >=1.2.14,<1.3.0a0 - - libgcc >=13 - - libopus >=1.5.2,<2.0a0 - - libstdcxx >=13 - license: LGPL-2.0-only - license_family: LGPL + - libzlib >=1.3.2,<2.0a0 + - zstd >=1.5.7,<1.6.0a0 + - libxml2 + - libxml2-16 >=2.14.6 + - libllvm22 >=22.1.8,<22.2.0a0 + license: Apache-2.0 WITH LLVM-exception + license_family: APACHE purls: [] - size: 461260 - timestamp: 1747574434594 -- conda: https://prefix.dev/conda-forge/noarch/jaraco.classes-3.4.0-pyhcf101f3_3.conda - sha256: 3cc991f0f09dfd00d2626e745ba68da03e4f1dcbb7b36dd20f7a7373643cd5d5 - md5: d59568bad316413c89831456e691de29 - depends: - - python >=3.10 - - more-itertools - - python - license: MIT - license_family: MIT - purls: - - pkg:pypi/jaraco-classes?source=hash-mapping - size: 14831 - timestamp: 1767294269456 -- conda: https://prefix.dev/conda-forge/noarch/jaraco.context-6.1.2-pyhcf101f3_0.conda - sha256: 108b3919db8ef81b5585b38a3fedbe9eeccdf8fa576c250a13559a1188f597cc - md5: b9d2b1ffa307961f6bb7d83c8ba8a8be - depends: - - python >=3.10 - - backports.tarfile - - python - license: MIT - license_family: MIT - purls: - - pkg:pypi/jaraco-context?source=hash-mapping - size: 16222 - timestamp: 1776862415793 -- conda: https://prefix.dev/conda-forge/noarch/jaraco.functools-4.4.0-pyhcf101f3_1.conda - sha256: 6a91447b3bb4d7ae94cc0d77ed12617796629aee11111efe7ea43cbd0e113bda - md5: aa83cc08626bf6b613a3103942be8951 + size: 24171067 + timestamp: 1786527767794 +- conda: https://prefix.dev/conda-forge/linux-64/libclang13-22.1.8-default_hd70ba2e_6.conda + sha256: 8475136d3be6c2d16bdb801dcaf8769cb2ba372cad239c89ebd6a58912e14465 + md5: a8e147873eca89dc1c5d319b027a6cd3 depends: - - python >=3.10 - - more-itertools - - python - license: MIT - license_family: MIT - purls: - - pkg:pypi/jaraco-functools?source=hash-mapping - size: 18744 - timestamp: 1767294193246 -- conda: https://prefix.dev/conda-forge/noarch/jax-jumpy-1.0.0-pyhd8ed1ab_1.conda - sha256: c414b2be28e7d963e55c962caad1a25833d2e415a3d7a16e4f9da9e187dd37b3 - md5: d15bad1eca61880b5e465c4038d7c3f4 + - libclang-cpp22.1 ==22.1.8 default_h08c5240_6 + - libstdcxx >=14 + - libgcc >=14 + - __glibc >=2.17,<3.0.a0 + - libzlib >=1.3.2,<2.0a0 + - zstd >=1.5.7,<1.6.0a0 + - libxml2 + - libxml2-16 >=2.14.6 + - libllvm22 >=22.1.8,<22.2.0a0 + license: Apache-2.0 WITH LLVM-exception + license_family: APACHE + purls: [] + size: 14275196 + timestamp: 1786527767794 +- conda: https://prefix.dev/conda-forge/linux-64/libcups-2.3.3-h7a8fb5f_6.conda + sha256: 205c4f19550f3647832ec44e35e6d93c8c206782bdd620c1d7cf66237580ff9c + md5: 49c553b47ff679a6a1e9fc80b9c5a2d4 depends: - - numpy >=1.18.0 - - python >=3.9 + - __glibc >=2.17,<3.0.a0 + - krb5 >=1.22.2,<1.23.0a0 + - libgcc >=14 + - libstdcxx >=14 + - libzlib >=1.3.1,<2.0a0 license: Apache-2.0 - license_family: APACHE - purls: - - pkg:pypi/jax-jumpy?source=hash-mapping - size: 20757 - timestamp: 1734210042598 -- conda: https://prefix.dev/conda-forge/noarch/jeepney-0.9.0-pyhd8ed1ab_0.conda - sha256: 00d37d85ca856431c67c8f6e890251e7cc9e5ef3724a0302b8d4a101f22aa27f - md5: b4b91eb14fbe2f850dd2c5fc20676c0d + license_family: Apache + purls: [] + size: 4518030 + timestamp: 1770902209173 +- conda: https://prefix.dev/conda-forge/linux-64/libcurl-8.20.0-hcf29cc6_0.conda + sha256: 75963a5dd913311f59a35dbd307592f4fa754c4808aff9c33edb430c415e38eb + md5: c3cc2864f82a944bc90a7beb4d3b0e88 depends: - - python >=3.9 - license: MIT + - __glibc >=2.17,<3.0.a0 + - krb5 >=1.22.2,<1.23.0a0 + - libgcc >=14 + - libnghttp2 >=1.68.1,<2.0a0 + - libssh2 >=1.11.1,<2.0a0 + - libzlib >=1.3.2,<2.0a0 + - openssl >=3.5.6,<4.0a0 + - zstd >=1.5.7,<1.6.0a0 + license: curl license_family: MIT - purls: - - pkg:pypi/jeepney?source=hash-mapping - size: 40015 - timestamp: 1740828380668 -- conda: https://prefix.dev/conda-forge/noarch/keyring-25.7.0-pyh534df25_0.conda - sha256: 9def5c6fb3b3b4952a4f6b55a019b5c7065b592682b84710229de5a0b73f6364 - md5: c88f9579d08eb4031159f03640714ce3 + purls: [] + size: 468706 + timestamp: 1777461492876 +- conda: https://prefix.dev/conda-forge/linux-64/libdeflate-1.25-h17f619e_0.conda + sha256: aa8e8c4be9a2e81610ddf574e05b64ee131fab5e0e3693210c9d6d2fba32c680 + md5: 6c77a605a7a689d17d4819c0f8ac9a00 depends: - - __osx - - importlib-metadata >=4.11.4 - - importlib_resources - - jaraco.classes - - jaraco.context - - jaraco.functools - - python >=3.10 + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 license: MIT license_family: MIT - purls: - - pkg:pypi/keyring?source=hash-mapping - size: 37924 - timestamp: 1763320995459 -- conda: https://prefix.dev/conda-forge/noarch/keyring-25.7.0-pyha804496_0.conda - sha256: 010718b1b1a35ce72782d38e6d6b9495d8d7d0dbea9a3e42901d030ff2189545 - md5: 9eeb0eaf04fa934808d3e070eebbe630 + purls: [] + size: 73490 + timestamp: 1761979956660 +- conda: https://prefix.dev/conda-forge/linux-64/libdrm-2.4.125-hb03c661_1.conda + sha256: c076a213bd3676cc1ef22eeff91588826273513ccc6040d9bea68bccdc849501 + md5: 9314bc5a1fe7d1044dc9dfd3ef400535 depends: - - __linux - - importlib-metadata >=4.11.4 - - importlib_resources - - jaraco.classes - - jaraco.context - - jaraco.functools - - jeepney >=0.4.2 - - python >=3.10 - - secretstorage >=3.2 + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + - libpciaccess >=0.18,<0.19.0a0 license: MIT license_family: MIT - purls: - - pkg:pypi/keyring?source=hash-mapping - size: 37717 - timestamp: 1763320674488 -- conda: https://prefix.dev/conda-forge/linux-64/keyutils-1.6.3-hb9d3cd8_0.conda - sha256: 0960d06048a7185d3542d850986d807c6e37ca2e644342dd0c72feefcf26c2a4 - md5: b38117a3c920364aff79f870c984b4a3 + purls: [] + size: 310785 + timestamp: 1757212153962 +- conda: https://prefix.dev/conda-forge/linux-64/libedit-3.1.20250104-pl5321h7949ede_0.conda + sha256: d789471216e7aba3c184cd054ed61ce3f6dac6f87a50ec69291b9297f8c18724 + md5: c277e0a4d549b03ac1e9d6cbbe3d017b depends: + - ncurses - __glibc >=2.17,<3.0.a0 - libgcc >=13 - license: LGPL-2.1-or-later + - ncurses >=6.5,<7.0a0 + license: BSD-2-Clause + license_family: BSD purls: [] - size: 134088 - timestamp: 1754905959823 -- conda: https://prefix.dev/conda-forge/linux-64/kiwisolver-1.5.0-py311h724c32c_0.conda - sha256: 3ff7e51c88f53f05e22ca5549e935d1ccb398665f6ec080a9c6a5c9e9b186b79 - md5: 3d82751e8d682068b58f049edc924ce4 + size: 134676 + timestamp: 1738479519902 +- conda: https://prefix.dev/conda-forge/linux-64/libegl-1.7.0-ha4b6fd6_2.conda + sha256: 7fd5408d359d05a969133e47af580183fbf38e2235b562193d427bb9dad79723 + md5: c151d5eb730e9b7480e6d48c0fc44048 depends: - - python - - libstdcxx >=14 - - libgcc >=14 - __glibc >=2.17,<3.0.a0 - - python_abi 3.11.* *_cp311 - license: BSD-3-Clause - license_family: BSD - purls: - - pkg:pypi/kiwisolver?source=hash-mapping - size: 77967 - timestamp: 1773067041763 -- conda: https://prefix.dev/conda-forge/osx-arm64/kiwisolver-1.5.0-py311h7d85929_0.conda - sha256: bad01811dae8d727a7ff5a271c8304be495e7e594dfddb9f1d576e41ba7c1a76 - md5: 9b4b32f37ebf95463c38636ae2f2ec56 + - libglvnd 1.7.0 ha4b6fd6_2 + license: LicenseRef-libglvnd + purls: [] + size: 44840 + timestamp: 1731330973553 +- conda: https://prefix.dev/conda-forge/linux-64/libegl-devel-1.7.0-ha4b6fd6_2.conda + sha256: f6e7095260305dc05238062142fb8db4b940346329b5b54894a90610afa6749f + md5: b513eb83b3137eca1192c34bf4f013a7 depends: - - python - - __osx >=11.0 - - python 3.11.* *_cpython - - libcxx >=19 - - python_abi 3.11.* *_cp311 - license: BSD-3-Clause + - __glibc >=2.17,<3.0.a0 + - libegl 1.7.0 ha4b6fd6_2 + - libgl-devel 1.7.0 ha4b6fd6_2 + - xorg-libx11 + license: LicenseRef-libglvnd + purls: [] + size: 30380 + timestamp: 1731331017249 +- conda: https://prefix.dev/conda-forge/linux-64/libev-4.33-hd590300_2.conda + sha256: 1cd6048169fa0395af74ed5d8f1716e22c19a81a8a36f934c110ca3ad4dd27b4 + md5: 172bf1cd1ff8629f2b1179945ed45055 + depends: + - libgcc-ng >=12 + license: BSD-2-Clause license_family: BSD - purls: - - pkg:pypi/kiwisolver?source=hash-mapping - size: 66903 - timestamp: 1773067313219 -- conda: https://prefix.dev/conda-forge/linux-64/krb5-1.22.2-ha1258a1_0.conda - sha256: 3e307628ca3527448dd1cb14ad7bb9d04d1d28c7d4c5f97ba196ae984571dd25 - md5: fb53fb07ce46a575c5d004bbc96032c2 + purls: [] + size: 112766 + timestamp: 1702146165126 +- conda: https://prefix.dev/conda-forge/linux-64/libexpat-2.8.0-hecca717_0.conda + sha256: ea33c40977ea7a2c3658c522230058395bc2ee0d89d99f0711390b6a1ee80d12 + md5: a3b390520c563d78cc58974de95a03e5 depends: - __glibc >=2.17,<3.0.a0 - - keyutils >=1.6.3,<2.0a0 - - libedit >=3.1.20250104,<3.2.0a0 - - libedit >=3.1.20250104,<4.0a0 - libgcc >=14 - - libstdcxx >=14 - - openssl >=3.5.5,<4.0a0 + constrains: + - expat 2.8.0.* license: MIT license_family: MIT purls: [] - size: 1386730 - timestamp: 1769769569681 -- conda: https://prefix.dev/conda-forge/osx-arm64/krb5-1.22.2-h385eeb1_0.conda - sha256: c0a0bf028fe7f3defcdcaa464e536cf1b202d07451e18ad83fdd169d15bef6ed - md5: e446e1822f4da8e5080a9de93474184d + size: 77241 + timestamp: 1777846112704 +- conda: https://prefix.dev/conda-forge/linux-64/libffi-3.5.2-h3435931_0.conda + sha256: 31f19b6a88ce40ebc0d5a992c131f57d919f73c0b92cd1617a5bec83f6e961e6 + md5: a360c33a5abe61c07959e449fa1453eb depends: - - __osx >=11.0 - - libcxx >=19 - - libedit >=3.1.20250104,<3.2.0a0 - - libedit >=3.1.20250104,<4.0a0 - - openssl >=3.5.5,<4.0a0 + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 license: MIT license_family: MIT purls: [] - size: 1160828 - timestamp: 1769770119811 -- conda: https://prefix.dev/conda-forge/linux-64/lame-3.100-h166bdaf_1003.tar.bz2 - sha256: aad2a703b9d7b038c0f745b853c6bb5f122988fe1a7a096e0e606d9cbec4eaab - md5: a8832b479f93521a9e7b5b743803be51 - depends: - - libgcc-ng >=12 - license: LGPL-2.0-only - license_family: LGPL - purls: [] - size: 508258 - timestamp: 1664996250081 -- conda: https://prefix.dev/conda-forge/osx-arm64/lame-3.100-h1a8c8d9_1003.tar.bz2 - sha256: f40ce7324b2cf5338b766d4cdb8e0453e4156a4f83c2f31bbfff750785de304c - md5: bff0e851d66725f78dc2fd8b032ddb7e - license: LGPL-2.0-only - license_family: LGPL - purls: [] - size: 528805 - timestamp: 1664996399305 -- conda: https://prefix.dev/conda-forge/linux-64/lcms2-2.19.1-h0c24ade_1.conda - sha256: 112b5b9462572d970f4abd2912f76a25ee7db158b1e7260163d91dd8a630db84 - md5: 8b3ce45e929cd8e8e5f4d18586b56d8b + size: 58592 + timestamp: 1769456073053 +- conda: https://prefix.dev/conda-forge/linux-64/libflac-1.5.0-he200343_1.conda + sha256: e755e234236bdda3d265ae82e5b0581d259a9279e3e5b31d745dc43251ad64fb + md5: 47595b9d53054907a00d95e4d47af1d6 depends: - __glibc >=2.17,<3.0.a0 - libgcc >=14 - - libjpeg-turbo >=3.1.4.1,<4.0a0 - - libtiff >=4.7.1,<4.8.0a0 - license: MIT - license_family: MIT + - libiconv >=1.18,<2.0a0 + - libogg >=1.3.5,<1.4.0a0 + - libstdcxx >=14 + license: BSD-3-Clause + license_family: BSD purls: [] - size: 251971 - timestamp: 1780211695895 -- conda: https://prefix.dev/conda-forge/osx-arm64/lcms2-2.19.1-hdfa7624_1.conda - sha256: ccb5598fad3694e79bf54f0eb812e3b3c3dd63d1497e631f5978800eadb9bcc4 - md5: d2f2c7c10e2957647d45589b7701a453 + size: 424563 + timestamp: 1764526740626 +- conda: https://prefix.dev/conda-forge/linux-64/libfreetype-2.14.3-ha770c72_0.conda + sha256: 38f014a7129e644636e46064ecd6b1945e729c2140e21d75bb476af39e692db2 + md5: e289f3d17880e44b633ba911d57a321b depends: - - __osx >=11.0 - - libjpeg-turbo >=3.1.4.1,<4.0a0 - - libtiff >=4.7.1,<4.8.0a0 - license: MIT - license_family: MIT + - libfreetype6 >=2.14.3 + license: GPL-2.0-only OR FTL purls: [] - size: 213747 - timestamp: 1780212240694 -- conda: https://prefix.dev/conda-forge/linux-64/ld_impl_linux-64-2.45.1-default_hbd61a6d_102.conda - sha256: 3d584956604909ff5df353767f3a2a2f60e07d070b328d109f30ac40cd62df6c - md5: 18335a698559cdbcd86150a48bf54ba6 + size: 8049 + timestamp: 1774298163029 +- conda: https://prefix.dev/conda-forge/linux-64/libfreetype6-2.14.3-h73754d4_0.conda + sha256: 16f020f96da79db1863fcdd8f2b8f4f7d52f177dd4c58601e38e9182e91adf1d + md5: fb16b4b69e3f1dcfe79d80db8fd0c55d depends: - __glibc >=2.17,<3.0.a0 - - zstd >=1.5.7,<1.6.0a0 + - libgcc >=14 + - libpng >=1.6.55,<1.7.0a0 + - libzlib >=1.3.2,<2.0a0 constrains: - - binutils_impl_linux-64 2.45.1 - license: GPL-3.0-only - license_family: GPL + - freetype >=2.14.3 + license: GPL-2.0-only OR FTL purls: [] - size: 728002 - timestamp: 1774197446916 -- pypi: https://files.pythonhosted.org/packages/fb/06/6a7c30c3519181263e1bbf0cbea67ef4a43a64443ee16717c7d760214943/lenses-1.2.0-py3-none-any.whl - name: lenses - version: 1.2.0 - sha256: e03c81e35500e12e1d35504f76c26489c0a4e08b0881e96fc4e8a1b707c53f16 - requires_dist: - - sphinx ; extra == 'docs' - - pyrsistent ; extra == 'lints' - - ufmt ; extra == 'lints' - - flake8 ; extra == 'lints' - - mypy ; implementation_name == 'cpython' and extra == 'lints' - - pyrsistent ; extra == 'optional' - - pyrsistent ; extra == 'tests' - - pytest ; extra == 'tests' - - pytest-sugar ; extra == 'tests' - - coverage ; extra == 'tests' - - pytest-coverage ; extra == 'tests' - - hypothesis ; extra == 'tests' - requires_python: '>=3.7,<4' -- conda: https://prefix.dev/conda-forge/linux-64/lerc-4.1.0-hdb68285_0.conda - sha256: f84cb54782f7e9cea95e810ea8fef186e0652d0fa73d3009914fa2c1262594e1 - md5: a752488c68f2e7c456bcbd8f16eec275 + size: 384575 + timestamp: 1774298162622 +- conda: https://prefix.dev/conda-forge/linux-64/libgcc-15.2.0-he0feb66_19.conda + sha256: 8e0a3b5e41272e5678499b5dfc4cddb673f9e935de01eb0767ce857001229f46 + md5: 57736f29cc2b0ec0b6c2952d3f101b6a depends: - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - libstdcxx >=14 - license: Apache-2.0 - license_family: Apache + - _openmp_mutex >=4.5 + constrains: + - libgcc-ng ==15.2.0=*_19 + - libgomp 15.2.0 he0feb66_19 + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL purls: [] - size: 261513 - timestamp: 1773113328888 -- conda: https://prefix.dev/conda-forge/osx-arm64/lerc-4.1.0-h1eee2c3_0.conda - sha256: 66e5ffd301a44da696f3efc2f25d6d94f42a9adc0db06c44ad753ab844148c51 - md5: 095e5749868adab9cae42d4b460e5443 + size: 1041084 + timestamp: 1778269013026 +- conda: https://prefix.dev/conda-forge/linux-64/libgcc-ng-15.2.0-h69a702a_19.conda + sha256: 9dcf54adfaa5e861123c2da4f2f0451a685464ea7e5a41ad91cf67b31d658d98 + md5: 331ee9b72b9dff570d56b1302c5ab37d depends: - - __osx >=11.0 - - libcxx >=19 - license: Apache-2.0 - license_family: Apache + - libgcc 15.2.0 he0feb66_19 + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL purls: [] - size: 164222 - timestamp: 1773114244984 -- conda: https://prefix.dev/conda-forge/linux-64/libavif16-1.4.1-hcfa2d63_0.conda - sha256: e29d8ed0334305c6bafecb32f9a1967cfc0a081eac916e947a1f2f7c4bb41947 - md5: f79415aee8862b3af85ea55dea37e46b + size: 27694 + timestamp: 1778269016987 +- conda: https://prefix.dev/conda-forge/linux-64/libgd-2.3.3-h5fbf134_12.conda + sha256: 245be793e831170504f36213134f4c24eedaf39e634679809fd5391ad214480b + md5: 88c1c66987cd52a712eea89c27104be6 depends: - __glibc >=2.17,<3.0.a0 - - aom >=3.9.1,<3.10.0a0 - - dav1d >=1.2.1,<1.2.2.0a0 + - fontconfig >=2.15.0,<3.0a0 + - fonts-conda-ecosystem + - icu >=78.1,<79.0a0 + - libexpat >=2.7.3,<3.0a0 + - libfreetype >=2.14.1 + - libfreetype6 >=2.14.1 - libgcc >=14 - - rav1e >=0.8.1,<0.9.0a0 - - svt-av1 >=4.0.1,<4.0.2.0a0 - license: BSD-2-Clause + - libjpeg-turbo >=3.1.2,<4.0a0 + - libpng >=1.6.53,<1.7.0a0 + - libtiff >=4.7.1,<4.8.0a0 + - libwebp-base >=1.6.0,<2.0a0 + - libzlib >=1.3.1,<2.0a0 + license: GD license_family: BSD purls: [] - size: 148710 - timestamp: 1774042709303 -- conda: https://prefix.dev/conda-forge/osx-arm64/libavif16-1.4.1-hfce71f6_0.conda - sha256: 09e31e51026a3b74d947ba4b30a68dd99013aeef2860bcb03565bf43cad18da6 - md5: 2df04ee54a2ce2d34cf375eb02a63725 - depends: - - __osx >=11.0 - - aom >=3.9.1,<3.10.0a0 - - dav1d >=1.2.1,<1.2.2.0a0 - - rav1e >=0.8.1,<0.9.0a0 - - svt-av1 >=4.0.1,<4.0.2.0a0 - license: BSD-2-Clause - license_family: BSD + size: 177306 + timestamp: 1766331805898 +- conda: https://prefix.dev/conda-forge/linux-64/libgfortran-15.2.0-h69a702a_19.conda + sha256: 561a42758ef25b9ce308c4e2cf56daee4f06138385a17e29a492cd928e00be6f + md5: 42bf7eca1a951735fa06c0e3c0d5c8e6 + depends: + - libgfortran5 15.2.0 h68bc16d_19 + constrains: + - libgfortran-ng ==15.2.0=*_19 + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL purls: [] - size: 118959 - timestamp: 1774043016600 -- conda: https://prefix.dev/conda-forge/linux-64/libblas-3.11.0-6_h4a7cf45_openblas.conda - build_number: 6 - sha256: 7bfe936dbb5db04820cf300a9cc1f5ee8d5302fc896c2d66e30f1ee2f20fbfd6 - md5: 6d6d225559bfa6e2f3c90ee9c03d4e2e + size: 27655 + timestamp: 1778269042954 +- conda: https://prefix.dev/conda-forge/linux-64/libgfortran5-15.2.0-h68bc16d_19.conda + sha256: 057978bb69fea29ed715a9b98adf71015c31baecc4aeb2bfc20d4fd5d83579d4 + md5: 85072b0ad177c966294f129b7c04a2d5 depends: - - libopenblas >=0.3.32,<0.3.33.0a0 - - libopenblas >=0.3.32,<1.0a0 + - __glibc >=2.17,<3.0.a0 + - libgcc >=15.2.0 constrains: - - blas 2.306 openblas - - liblapack 3.11.0 6*_openblas - - liblapacke 3.11.0 6*_openblas - - libcblas 3.11.0 6*_openblas - - mkl <2026 - license: BSD-3-Clause - license_family: BSD + - libgfortran 15.2.0 + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL purls: [] - size: 18621 - timestamp: 1774503034895 -- conda: https://prefix.dev/conda-forge/osx-arm64/libblas-3.11.0-6_h51639a9_openblas.conda - build_number: 6 - sha256: 979227fc03628925037ab2dfda008eb7b5592644d9c2c21dd285cefe8c42553d - md5: e551103471911260488a02155cef9c94 + size: 2483673 + timestamp: 1778269025089 +- conda: https://prefix.dev/conda-forge/linux-64/libgl-1.7.0-ha4b6fd6_2.conda + sha256: dc2752241fa3d9e40ce552c1942d0a4b5eeb93740c9723873f6fcf8d39ef8d2d + md5: 928b8be80851f5d8ffb016f9c81dae7a depends: - - libopenblas >=0.3.32,<0.3.33.0a0 - - libopenblas >=0.3.32,<1.0a0 + - __glibc >=2.17,<3.0.a0 + - libglvnd 1.7.0 ha4b6fd6_2 + - libglx 1.7.0 ha4b6fd6_2 + license: LicenseRef-libglvnd + purls: [] + size: 134712 + timestamp: 1731330998354 +- conda: https://prefix.dev/conda-forge/linux-64/libgl-devel-1.7.0-ha4b6fd6_2.conda + sha256: e281356c0975751f478c53e14f3efea6cd1e23c3069406d10708d6c409525260 + md5: 53e7cbb2beb03d69a478631e23e340e9 + depends: + - __glibc >=2.17,<3.0.a0 + - libgl 1.7.0 ha4b6fd6_2 + - libglx-devel 1.7.0 ha4b6fd6_2 + license: LicenseRef-libglvnd + purls: [] + size: 113911 + timestamp: 1731331012126 +- conda: https://prefix.dev/conda-forge/linux-64/libglib-2.88.3-h0d30a3d_0.conda + sha256: 69ea4df61403531e5b3e5f3d52ba2837423df361b4eb8727f5b63aaf6de6768a + md5: 17c3b7b6bcbd35b688c933eb4834c0bc + depends: + - libgcc >=14 + - __glibc >=2.17,<3.0.a0 + - libiconv >=1.18,<2.0a0 + - libzlib >=1.3.2,<2.0a0 + - pcre2 >=10.47,<10.48.0a0 + - libffi >=3.5.2,<3.6.0a0 constrains: - - liblapacke 3.11.0 6*_openblas - - liblapack 3.11.0 6*_openblas - - blas 2.306 openblas - - libcblas 3.11.0 6*_openblas - - mkl <2026 - license: BSD-3-Clause - license_family: BSD + - glib >2.66 + license: LGPL-2.1-or-later purls: [] - size: 18859 - timestamp: 1774504387211 -- conda: https://prefix.dev/conda-forge/linux-64/libbrotlicommon-1.2.0-h39a168f_3.conda - sha256: e5864f257f839ffc27d681659bac95901f524f602b9121e5dcc5e2df18437f2d - md5: 7a2499a177753582fb7ae7e9dc4a908a + size: 4755324 + timestamp: 1785442107463 +- conda: https://prefix.dev/conda-forge/linux-64/libglvnd-1.7.0-ha4b6fd6_2.conda + sha256: 1175f8a7a0c68b7f81962699751bb6574e6f07db4c9f72825f978e3016f46850 + md5: 434ca7e50e40f4918ab701e3facd59a0 depends: - __glibc >=2.17,<3.0.a0 - - libgcc >=15 - license: MIT - license_family: MIT + license: LicenseRef-libglvnd purls: [] - size: 80265 - timestamp: 1786622773969 -- conda: https://prefix.dev/conda-forge/osx-arm64/libbrotlicommon-1.2.0-h1dcdb26_3.conda - sha256: 5e62b856b2e77ce98db44133bacab1281b42c1040dcbd69dbacfb80890cff5b0 - md5: b457450ba3f27c4749783c0204bd17b0 + size: 132463 + timestamp: 1731330968309 +- conda: https://prefix.dev/conda-forge/linux-64/libglx-1.7.0-ha4b6fd6_2.conda + sha256: 2d35a679624a93ce5b3e9dd301fff92343db609b79f0363e6d0ceb3a6478bfa7 + md5: c8013e438185f33b13814c5c488acd5c depends: - - __osx >=11.0 - license: MIT - license_family: MIT + - __glibc >=2.17,<3.0.a0 + - libglvnd 1.7.0 ha4b6fd6_2 + - xorg-libx11 >=1.8.10,<2.0a0 + license: LicenseRef-libglvnd purls: [] - size: 80027 - timestamp: 1786622846050 -- conda: https://prefix.dev/conda-forge/linux-64/libbrotlidec-1.2.0-ha411449_3.conda - sha256: dad31b6d104973deb89710929a35651033aad692d4e7793cdb5b786a9bd54678 - md5: 6ab3315dc56618d652c1da42a648a129 + size: 75504 + timestamp: 1731330988898 +- conda: https://prefix.dev/conda-forge/linux-64/libglx-devel-1.7.0-ha4b6fd6_2.conda + sha256: 0a930e0148ab6e61089bbcdba25a2e17ee383e7de82e7af10cc5c12c82c580f3 + md5: 27ac5ae872a21375d980bd4a6f99edf3 depends: - __glibc >=2.17,<3.0.a0 - - libbrotlicommon 1.2.0 h39a168f_3 - - libgcc >=15 - license: MIT - license_family: MIT + - libglx 1.7.0 ha4b6fd6_2 + - xorg-libx11 >=1.8.10,<2.0a0 + - xorg-xorgproto + license: LicenseRef-libglvnd purls: [] - size: 34828 - timestamp: 1786622783405 -- conda: https://prefix.dev/conda-forge/osx-arm64/libbrotlidec-1.2.0-h5295a6a_3.conda - sha256: 510c9fce0d9ffcf41741dd96fc05db381672109d5665ef002c2e58f0d4ca0118 - md5: e07a99c6fdd984f4d588060f2f936bf4 + size: 26388 + timestamp: 1731331003255 +- conda: https://prefix.dev/conda-forge/linux-64/libgomp-15.2.0-he0feb66_19.conda + sha256: 5abe4ab9d93f6c9757d654f1969ae2267d4505315c1f2f8fe705fd60af084f1b + md5: faac990cb7aedc7f3a2224f2c9b0c26c depends: - - __osx >=11.0 - - libbrotlicommon 1.2.0 h1dcdb26_3 - license: MIT - license_family: MIT + - __glibc >=2.17,<3.0.a0 + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL purls: [] - size: 29935 - timestamp: 1786622857695 -- conda: https://prefix.dev/conda-forge/linux-64/libbrotlienc-1.2.0-h018ffa1_3.conda - sha256: d37124d0f51816e7d5e3a94bfc9ed3d6174d077f9b4f832d20c5a08b52bebf1f - md5: 2ac965638d4c6b2b38383bb1aebaf543 + size: 603817 + timestamp: 1778268942614 +- conda: https://prefix.dev/conda-forge/linux-64/libharfbuzz-14.3.1-h23af247_0.conda + sha256: a4eac5a21b84e0fc753b72de01781f634fc9ab70fd32a28d6a40a19700c9188a + md5: 29709e61096dd490fff9e833e4c869f6 depends: - __glibc >=2.17,<3.0.a0 - - libbrotlicommon 1.2.0 h39a168f_3 + - cairo >=1.18.4,<2.0a0 + - graphite2 >=1.3.15,<2.0a0 + - icu >=78.3,<79.0a0 + - libfreetype >=2.14.3 + - libfreetype6 >=2.14.3 - libgcc >=15 + - libglib >=2.88.3,<3.0a0 + - libpng >=1.6.58,<1.7.0a0 + - libstdcxx >=15 + - libzlib >=1.3.2,<2.0a0 license: MIT license_family: MIT purls: [] - size: 298639 - timestamp: 1786622792145 -- conda: https://prefix.dev/conda-forge/osx-arm64/libbrotlienc-1.2.0-h2ddc9cb_3.conda - sha256: eac412417eee2e93c62e9d53559f1f9c14f40b6c41e2c432af8b517596898dd1 - md5: 954c78a9f591bfb12c79beaff7338ec8 + size: 1353639 + timestamp: 1786970872936 +- conda: https://prefix.dev/conda-forge/linux-64/libharfbuzz-devel-14.3.1-h23af247_0.conda + sha256: 9d9d620141102dcb580d8f42d1a6c9e7e691a8dfa0284783e712679723067d15 + md5: e0f17ce01589ffa7d773be573e97b36c depends: - - __osx >=11.0 - - libbrotlicommon 1.2.0 h1dcdb26_3 + - __glibc >=2.17,<3.0.a0 + - cairo >=1.18.4,<2.0a0 + - freetype + - graphite2 >=1.3.15,<2.0a0 + - icu >=78.3,<79.0a0 + - libfreetype >=2.14.3 + - libfreetype6 >=2.14.3 + - libgcc >=15 + - libglib >=2.88.3,<3.0a0 + - libharfbuzz 14.3.1 h23af247_0 + - libpng >=1.6.58,<1.7.0a0 + - libstdcxx >=15 + - libzlib >=1.3.2,<2.0a0 license: MIT license_family: MIT purls: [] - size: 295650 - timestamp: 1786622868044 -- conda: https://prefix.dev/conda-forge/linux-64/libcap-2.77-hd0affe5_1.conda - sha256: 37c41b1024d0c75da76822e3c079aabaf121618a32fe05e53a897b35a88008fc - md5: 499cd8e2d4358986dbe3b30e8fe1bf6a + size: 2114382 + timestamp: 1786970892473 +- conda: https://prefix.dev/conda-forge/linux-64/libiconv-1.18-h3b78370_2.conda + sha256: c467851a7312765447155e071752d7bf9bf44d610a5687e32706f480aad2833f + md5: 915f5995e94f60e9a4826e0b0920ee88 depends: - __glibc >=2.17,<3.0.a0 - libgcc >=14 - license: BSD-3-Clause - license_family: BSD + license: LGPL-2.1-only purls: [] - size: 124432 - timestamp: 1774333989027 -- conda: https://prefix.dev/conda-forge/linux-64/libcblas-3.11.0-6_h0358290_openblas.conda - build_number: 6 - sha256: 57edafa7796f6fa3ebbd5367692dd4c7f552be42109c2dd1a7c89b55089bf374 - md5: 36ae340a916635b97ac8a0655ace2a35 + size: 790176 + timestamp: 1754908768807 +- conda: https://prefix.dev/conda-forge/linux-64/libjpeg-turbo-3.1.4.1-hb03c661_0.conda + sha256: 10056646c28115b174de81a44e23e3a0a3b95b5347d2e6c45cc6d49d35294256 + md5: 6178c6f2fb254558238ef4e6c56fb782 depends: - - libblas 3.11.0 6_h4a7cf45_openblas + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 constrains: - - blas 2.306 openblas - - liblapack 3.11.0 6*_openblas - - liblapacke 3.11.0 6*_openblas - license: BSD-3-Clause - license_family: BSD + - jpeg <0.0.0a + license: IJG AND BSD-3-Clause AND Zlib purls: [] - size: 18622 - timestamp: 1774503050205 -- conda: https://prefix.dev/conda-forge/osx-arm64/libcblas-3.11.0-6_hb0561ab_openblas.conda + size: 633831 + timestamp: 1775962768273 +- conda: https://prefix.dev/conda-forge/linux-64/liblapack-3.11.0-6_h47877c9_openblas.conda build_number: 6 - sha256: 2e6b3e9b1ab672133b70fc6730e42290e952793f132cb5e72eee22835463eba0 - md5: 805c6d31c5621fd75e53dfcf21fb243a + sha256: 371f517eb7010b21c6cc882c7606daccebb943307cb9a3bf2c70456a5c024f7d + md5: 881d801569b201c2e753f03c84b85e15 depends: - - libblas 3.11.0 6_h51639a9_openblas + - libblas 3.11.0 6_h4a7cf45_openblas constrains: - - liblapacke 3.11.0 6*_openblas - blas 2.306 openblas - - liblapack 3.11.0 6*_openblas + - liblapacke 3.11.0 6*_openblas + - libcblas 3.11.0 6*_openblas license: BSD-3-Clause license_family: BSD purls: [] - size: 18863 - timestamp: 1774504433388 -- conda: https://prefix.dev/conda-forge/linux-64/libccd-double-2.1-h59595ed_3.conda - sha256: 4695ce68eda595b4f53146bea1096a9f2e0d33290618ba83a246b5ed8871ebc9 - md5: 6a3d962d34385e0a511b859d679f6ea2 - depends: - - libgcc-ng >=12 - - libstdcxx-ng >=12 - constrains: - - libccd <1 - license: BSD-3-Clause - license_family: BSD - purls: [] - size: 36171 - timestamp: 1687341825064 -- conda: https://prefix.dev/conda-forge/osx-arm64/libccd-double-2.1-h9a09cb3_2.tar.bz2 - sha256: eaba0b8153f4346229a0c52916a13fbedd689a3d3b31f4196bac65ece9050b8e - md5: 4d27a7d50c8d4bcafe33c9215e66251c - depends: - - libcxx >=13.0.1 - constrains: - - libccd <1 - license: BSD-3-Clause - license_family: BSD - purls: [] - size: 29852 - timestamp: 1654586481871 -- conda: https://prefix.dev/conda-forge/linux-64/libclang-cpp22.1-22.1.8-default_h08c5240_6.conda - sha256: fc2981a8e45dd232ae88cf2580f7e75c258f4dccdc96f879b68ef0a9b45c9a2b - md5: 4fd9026a57bb45cd15bd08ff8bd0578e + size: 18624 + timestamp: 1774503065378 +- conda: https://prefix.dev/conda-forge/linux-64/libllvm22-22.1.8-hf7376ad_1.conda + sha256: e9b5f301d6b001a9b8ce782157f56b75c92c4fbc9eba95dc6345c1139251d13b + md5: 298bb2483fc7d15396147cf1c1465359 depends: - - libstdcxx >=14 - - libgcc >=14 - __glibc >=2.17,<3.0.a0 - - libzlib >=1.3.2,<2.0a0 - - zstd >=1.5.7,<1.6.0a0 + - libgcc >=14 + - libstdcxx >=14 - libxml2 - libxml2-16 >=2.14.6 - - libllvm22 >=22.1.8,<22.2.0a0 - license: Apache-2.0 WITH LLVM-exception - license_family: APACHE - purls: [] - size: 24171067 - timestamp: 1786527767794 -- conda: https://prefix.dev/conda-forge/linux-64/libclang13-22.1.8-default_hd70ba2e_6.conda - sha256: 8475136d3be6c2d16bdb801dcaf8769cb2ba372cad239c89ebd6a58912e14465 - md5: a8e147873eca89dc1c5d319b027a6cd3 - depends: - - libclang-cpp22.1 ==22.1.8 default_h08c5240_6 - - libstdcxx >=14 - - libgcc >=14 - - __glibc >=2.17,<3.0.a0 - libzlib >=1.3.2,<2.0a0 - zstd >=1.5.7,<1.6.0a0 - - libxml2 - - libxml2-16 >=2.14.6 - - libllvm22 >=22.1.8,<22.2.0a0 license: Apache-2.0 WITH LLVM-exception - license_family: APACHE + license_family: Apache purls: [] - size: 14275196 - timestamp: 1786527767794 -- conda: https://prefix.dev/conda-forge/linux-64/libcups-2.3.3-h7a8fb5f_6.conda - sha256: 205c4f19550f3647832ec44e35e6d93c8c206782bdd620c1d7cf66237580ff9c - md5: 49c553b47ff679a6a1e9fc80b9c5a2d4 + size: 44320272 + timestamp: 1781788728739 +- conda: https://prefix.dev/conda-forge/linux-64/liblzma-5.8.3-hb03c661_0.conda + sha256: ec30e52a3c1bf7d0425380a189d209a52baa03f22fb66dd3eb587acaa765bd6d + md5: b88d90cad08e6bc8ad540cb310a761fb depends: - __glibc >=2.17,<3.0.a0 - - krb5 >=1.22.2,<1.23.0a0 - libgcc >=14 - - libstdcxx >=14 - - libzlib >=1.3.1,<2.0a0 - license: Apache-2.0 - license_family: Apache + constrains: + - xz 5.8.3.* + license: 0BSD purls: [] - size: 4518030 - timestamp: 1770902209173 -- conda: https://prefix.dev/conda-forge/linux-64/libcurl-8.20.0-hcf29cc6_0.conda - sha256: 75963a5dd913311f59a35dbd307592f4fa754c4808aff9c33edb430c415e38eb - md5: c3cc2864f82a944bc90a7beb4d3b0e88 + size: 113478 + timestamp: 1775825492909 +- conda: https://prefix.dev/conda-forge/linux-64/liblzma-devel-5.8.3-hb03c661_0.conda + sha256: 7858f6a173206bc8a5bdc8e75690483bb66c0dcc3809ac1cb43c561a4723623a + md5: 55c20edec8e90c4703787acaade60808 depends: - __glibc >=2.17,<3.0.a0 - - krb5 >=1.22.2,<1.23.0a0 - libgcc >=14 - - libnghttp2 >=1.68.1,<2.0a0 - - libssh2 >=1.11.1,<2.0a0 - - libzlib >=1.3.2,<2.0a0 - - openssl >=3.5.6,<4.0a0 - - zstd >=1.5.7,<1.6.0a0 - license: curl - license_family: MIT - purls: [] - size: 468706 - timestamp: 1777461492876 -- conda: https://prefix.dev/conda-forge/osx-arm64/libcurl-8.20.0-hd5a2499_0.conda - sha256: 38c0bc634b61e542776e97cfd15d5d41edd304d4e47c333004d2d622439b2381 - md5: 2f57b7d0c6adda88957586b7afd78438 - depends: - - __osx >=11.0 - - krb5 >=1.22.2,<1.23.0a0 - - libnghttp2 >=1.68.1,<2.0a0 - - libssh2 >=1.11.1,<2.0a0 - - libzlib >=1.3.2,<2.0a0 - - openssl >=3.5.6,<4.0a0 - - zstd >=1.5.7,<1.6.0a0 - license: curl - license_family: MIT + - liblzma 5.8.3 hb03c661_0 + license: 0BSD purls: [] - size: 400568 - timestamp: 1777462251987 -- conda: https://prefix.dev/conda-forge/osx-arm64/libcxx-22.1.5-h55c6f16_1.conda - sha256: dddd01bd6b338221342a89530a1caffe6051a70cc8f8b1d8bb591d5447a3c603 - md5: ff484b683fecf1e875dfc7aa01d19796 + size: 491429 + timestamp: 1775825511214 +- conda: https://prefix.dev/conda-forge/linux-64/libmad-0.15.1b-h0b41bf4_1001.conda + sha256: 9e94cec54c4baadaa652c761179b8d32771fe7fa55faf6c78c2e35f942367f74 + md5: dc5cc4700f02ffeecc48253c9f29025b depends: - - __osx >=11.0 - license: Apache-2.0 WITH LLVM-exception - license_family: Apache + - libgcc-ng >=12 + license: GPL-2.0-only + license_family: GPL purls: [] - size: 569359 - timestamp: 1778191546305 -- conda: https://prefix.dev/conda-forge/linux-64/libdeflate-1.25-h17f619e_0.conda - sha256: aa8e8c4be9a2e81610ddf574e05b64ee131fab5e0e3693210c9d6d2fba32c680 - md5: 6c77a605a7a689d17d4819c0f8ac9a00 + size: 78561 + timestamp: 1670815547616 +- conda: https://prefix.dev/conda-forge/linux-64/libnghttp2-1.68.1-h877daf1_0.conda + sha256: 663444d77a42f2265f54fb8b48c5450bfff4388d9c0f8253dd7855f0d993153f + md5: 2a45e7f8af083626f009645a6481f12d depends: - __glibc >=2.17,<3.0.a0 + - c-ares >=1.34.6,<2.0a0 + - libev >=4.33,<4.34.0a0 + - libev >=4.33,<5.0a0 - libgcc >=14 + - libstdcxx >=14 + - libzlib >=1.3.1,<2.0a0 + - openssl >=3.5.5,<4.0a0 license: MIT license_family: MIT purls: [] - size: 73490 - timestamp: 1761979956660 -- conda: https://prefix.dev/conda-forge/osx-arm64/libdeflate-1.25-hc11a715_0.conda - sha256: 5e0b6961be3304a5f027a8c00bd0967fc46ae162cffb7553ff45c70f51b8314c - md5: a6130c709305cd9828b4e1bd9ba0000c + size: 663344 + timestamp: 1773854035739 +- conda: https://prefix.dev/conda-forge/linux-64/libnsl-2.0.1-hb9d3cd8_1.conda + sha256: 927fe72b054277cde6cb82597d0fcf6baf127dcbce2e0a9d8925a68f1265eef5 + md5: d864d34357c3b65a4b731f78c0801dc4 depends: - - __osx >=11.0 - license: MIT - license_family: MIT + - __glibc >=2.17,<3.0.a0 + - libgcc >=13 + license: LGPL-2.1-only + license_family: GPL purls: [] - size: 55420 - timestamp: 1761980066242 -- conda: https://prefix.dev/conda-forge/linux-64/libdrm-2.4.125-hb03c661_1.conda - sha256: c076a213bd3676cc1ef22eeff91588826273513ccc6040d9bea68bccdc849501 - md5: 9314bc5a1fe7d1044dc9dfd3ef400535 + size: 33731 + timestamp: 1750274110928 +- conda: https://prefix.dev/conda-forge/linux-64/libntlm-1.8-hb9d3cd8_0.conda + sha256: 3b3f19ced060013c2dd99d9d46403be6d319d4601814c772a3472fe2955612b0 + md5: 7c7927b404672409d9917d49bff5f2d6 depends: - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - libpciaccess >=0.18,<0.19.0a0 - license: MIT - license_family: MIT + - libgcc >=13 + license: LGPL-2.1-or-later purls: [] - size: 310785 - timestamp: 1757212153962 -- conda: https://prefix.dev/conda-forge/linux-64/libedit-3.1.20250104-pl5321h7949ede_0.conda - sha256: d789471216e7aba3c184cd054ed61ce3f6dac6f87a50ec69291b9297f8c18724 - md5: c277e0a4d549b03ac1e9d6cbbe3d017b + size: 33418 + timestamp: 1734670021371 +- conda: https://prefix.dev/conda-forge/linux-64/libode-0.16.6-h18afd86_0.conda + sha256: 6ff25c1e497e384cc04e53ec45f0a024c8b2a85bd5afb3737cd1043869ef83a0 + md5: 49d678980383b08f99146ea8a7400806 depends: - - ncurses - __glibc >=2.17,<3.0.a0 + - libccd-double >=2.1,<2.2.0a0 + - libgcc >=14 + - libstdcxx >=14 + - pthread-stubs + - python_abi 3.10.* *_cp310 + license: LGPL-2.1-or-later OR BSD-4-Clause + purls: [] + size: 509471 + timestamp: 1760969190850 +- conda: https://prefix.dev/conda-forge/linux-64/libogg-1.3.5-hd0c01bc_1.conda + sha256: ffb066ddf2e76953f92e06677021c73c85536098f1c21fcd15360dbc859e22e4 + md5: 68e52064ed3897463c0e958ab5c8f91b + depends: - libgcc >=13 - - ncurses >=6.5,<7.0a0 - license: BSD-2-Clause + - __glibc >=2.17,<3.0.a0 + license: BSD-3-Clause license_family: BSD purls: [] - size: 134676 - timestamp: 1738479519902 -- conda: https://prefix.dev/conda-forge/osx-arm64/libedit-3.1.20250104-pl5321hafb1f1b_0.conda - sha256: 66aa216a403de0bb0c1340a88d1a06adaff66bae2cfd196731aa24db9859d631 - md5: 44083d2d2c2025afca315c7a172eab2b + size: 218500 + timestamp: 1745825989535 +- conda: https://prefix.dev/conda-forge/linux-64/libopenblas-0.3.32-pthreads_h94d23a6_0.conda + sha256: 6dc30b28f32737a1c52dada10c8f3a41bc9e021854215efca04a7f00487d09d9 + md5: 89d61bc91d3f39fda0ca10fcd3c68594 depends: - - ncurses - - __osx >=11.0 - - ncurses >=6.5,<7.0a0 - license: BSD-2-Clause + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + - libgfortran + - libgfortran5 >=14.3.0 + constrains: + - openblas >=0.3.32,<0.3.33.0a0 + license: BSD-3-Clause license_family: BSD purls: [] - size: 107691 - timestamp: 1738479560845 -- conda: https://prefix.dev/conda-forge/linux-64/libegl-1.7.0-ha4b6fd6_2.conda - sha256: 7fd5408d359d05a969133e47af580183fbf38e2235b562193d427bb9dad79723 - md5: c151d5eb730e9b7480e6d48c0fc44048 + size: 5928890 + timestamp: 1774471724897 +- conda: https://prefix.dev/conda-forge/linux-64/libopengl-1.7.0-ha4b6fd6_2.conda + sha256: 215086c108d80349e96051ad14131b751d17af3ed2cb5a34edd62fa89bfe8ead + md5: 7df50d44d4a14d6c31a2c54f2cd92157 depends: - __glibc >=2.17,<3.0.a0 - libglvnd 1.7.0 ha4b6fd6_2 license: LicenseRef-libglvnd purls: [] - size: 44840 - timestamp: 1731330973553 -- conda: https://prefix.dev/conda-forge/linux-64/libegl-devel-1.7.0-ha4b6fd6_2.conda - sha256: f6e7095260305dc05238062142fb8db4b940346329b5b54894a90610afa6749f - md5: b513eb83b3137eca1192c34bf4f013a7 + size: 50757 + timestamp: 1731330993524 +- conda: https://prefix.dev/conda-forge/linux-64/libopus-1.6.1-h280c20c_0.conda + sha256: f1061a26213b9653bbb8372bfa3f291787ca091a9a3060a10df4d5297aad74fd + md5: 2446ac1fe030c2aa6141386c1f5a6aed depends: - __glibc >=2.17,<3.0.a0 - - libegl 1.7.0 ha4b6fd6_2 - - libgl-devel 1.7.0 ha4b6fd6_2 - - xorg-libx11 - license: LicenseRef-libglvnd + - libgcc >=14 + license: BSD-3-Clause + license_family: BSD purls: [] - size: 30380 - timestamp: 1731331017249 -- conda: https://prefix.dev/conda-forge/linux-64/libev-4.33-hd590300_2.conda - sha256: 1cd6048169fa0395af74ed5d8f1716e22c19a81a8a36f934c110ca3ad4dd27b4 - md5: 172bf1cd1ff8629f2b1179945ed45055 - depends: - - libgcc-ng >=12 - license: BSD-2-Clause - license_family: BSD - purls: [] - size: 112766 - timestamp: 1702146165126 -- conda: https://prefix.dev/conda-forge/osx-arm64/libev-4.33-h93a5062_2.conda - sha256: 95cecb3902fbe0399c3a7e67a5bed1db813e5ab0e22f4023a5e0f722f2cc214f - md5: 36d33e440c31857372a72137f78bacf5 - license: BSD-2-Clause - license_family: BSD - purls: [] - size: 107458 - timestamp: 1702146414478 -- conda: https://prefix.dev/conda-forge/linux-64/libexpat-2.8.0-hecca717_0.conda - sha256: ea33c40977ea7a2c3658c522230058395bc2ee0d89d99f0711390b6a1ee80d12 - md5: a3b390520c563d78cc58974de95a03e5 + size: 324993 + timestamp: 1768497114401 +- conda: https://prefix.dev/conda-forge/linux-64/libpciaccess-0.18-hb9d3cd8_0.conda + sha256: 0bd91de9b447a2991e666f284ae8c722ffb1d84acb594dbd0c031bd656fa32b2 + md5: 70e3400cbbfa03e96dcde7fc13e38c7b depends: - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - constrains: - - expat 2.8.0.* - license: MIT - license_family: MIT - purls: [] - size: 77241 - timestamp: 1777846112704 -- conda: https://prefix.dev/conda-forge/osx-arm64/libexpat-2.8.0-hf6b4638_0.conda - sha256: f4b1cafc59afaede8fa0a2d9cf376840f1c553001acd72f6ead18bbc8ac8c49c - md5: 65466e82c09e888ca7560c11a97d5450 - depends: - - __osx >=11.0 - constrains: - - expat 2.8.0.* + - libgcc >=13 license: MIT license_family: MIT purls: [] - size: 68789 - timestamp: 1777846180142 -- conda: https://prefix.dev/conda-forge/linux-64/libffi-3.5.2-h3435931_0.conda - sha256: 31f19b6a88ce40ebc0d5a992c131f57d919f73c0b92cd1617a5bec83f6e961e6 - md5: a360c33a5abe61c07959e449fa1453eb + size: 28424 + timestamp: 1749901812541 +- conda: https://prefix.dev/conda-forge/linux-64/libpng-1.6.58-h421ea60_0.conda + sha256: 377cfe037f3eeb3b1bf3ad333f724a64d32f315ee1958581fc671891d63d3f89 + md5: eba48a68a1a2b9d3c0d9511548db85db depends: - __glibc >=2.17,<3.0.a0 - libgcc >=14 - license: MIT - license_family: MIT - purls: [] - size: 58592 - timestamp: 1769456073053 -- conda: https://prefix.dev/conda-forge/osx-arm64/libffi-3.5.2-hcf2aa1b_0.conda - sha256: 6686a26466a527585e6a75cc2a242bf4a3d97d6d6c86424a441677917f28bec7 - md5: 43c04d9cb46ef176bb2a4c77e324d599 - depends: - - __osx >=11.0 - license: MIT - license_family: MIT + - libzlib >=1.3.2,<2.0a0 + license: zlib-acknowledgement purls: [] - size: 40979 - timestamp: 1769456747661 -- conda: https://prefix.dev/conda-forge/linux-64/libflac-1.5.0-he200343_1.conda - sha256: e755e234236bdda3d265ae82e5b0581d259a9279e3e5b31d745dc43251ad64fb - md5: 47595b9d53054907a00d95e4d47af1d6 + size: 317729 + timestamp: 1776315175087 +- conda: https://prefix.dev/conda-forge/linux-64/libpq-18.6-h9d76c99_0.conda + sha256: b1eb210c180fda9c445b11cba1286ec250ce2c2a85ccb0551a4ed5423df51e68 + md5: 72e019c04ed02a179da38c56965802d1 depends: - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - libiconv >=1.18,<2.0a0 - - libogg >=1.3.5,<1.4.0a0 - - libstdcxx >=14 - license: BSD-3-Clause - license_family: BSD + - icu >=78.3,<79.0a0 + - krb5 >=1.22.2,<1.23.0a0 + - libgcc >=15 + - openldap >=2.6.13,<2.7.0a0 + - openssl >=3.5.7,<4.0a0 + license: PostgreSQL purls: [] - size: 424563 - timestamp: 1764526740626 -- conda: https://prefix.dev/conda-forge/osx-arm64/libflac-1.5.0-h6824b09_1.conda - sha256: 565e5c38e80eb5752bfa52f6b771fa2fd75c0551a1f61ea84a12a2fb4454900c - md5: b14b19359aed60c200b1ca58b53f5ca3 + size: 2719680 + timestamp: 1786641133110 +- conda: https://prefix.dev/conda-forge/linux-64/libprotobuf-3.20.2-h6239696_0.tar.bz2 + sha256: 158899bc39d00dc79e9b3fe8e39ed413a7ae266ddf69a7ff149be16859c24149 + md5: dd9c398d02aa82219a4ea5fa69739ae7 depends: - - __osx >=11.0 - - libcxx >=19 - - libiconv >=1.18,<2.0a0 - - libogg >=1.3.5,<1.4.0a0 + - libgcc-ng >=12 + - libstdcxx-ng >=12 + - libzlib >=1.2.13,<2.0.0a0 license: BSD-3-Clause license_family: BSD purls: [] - size: 321872 - timestamp: 1764527007890 -- conda: https://prefix.dev/conda-forge/linux-64/libfreetype-2.14.3-ha770c72_0.conda - sha256: 38f014a7129e644636e46064ecd6b1945e729c2140e21d75bb476af39e692db2 - md5: e289f3d17880e44b633ba911d57a321b + size: 2715070 + timestamp: 1668469845918 +- conda: https://prefix.dev/conda-forge/linux-64/libraqm-0.11.0-h6406941_0.conda + sha256: ab3ccb9fd5816f76b18ee8974d359cd2605ca87d8ddef55369dc461b9986f95c + md5: 3ac89a48d224409739dbf6200e524373 depends: + - libgcc >=14 + - __glibc >=2.28,<3.0.a0 + - fribidi >=1.0.16,<2.0a0 + - libfreetype >=2.14.3 - libfreetype6 >=2.14.3 - license: GPL-2.0-only OR FTL + - libharfbuzz >=14.2.1 + license: MIT + license_family: MIT purls: [] - size: 8049 - timestamp: 1774298163029 -- conda: https://prefix.dev/conda-forge/osx-arm64/libfreetype-2.14.3-hce30654_0.conda - sha256: a047a2f238362a37d484f9620e8cba29f513a933cd9eb68571ad4b270d6f8f3e - md5: f73b109d49568d5d1dda43bb147ae37f + size: 33983 + timestamp: 1784850267262 +- conda: https://prefix.dev/conda-forge/linux-64/librsvg-2.60.2-h61e6d4b_0.conda + sha256: 38b3189cf246f7265e06917f32d046ac375117c88834d045efe73ec48ceacc59 + md5: d62da3d560992bfa2feb611d7be813b8 depends: - - libfreetype6 >=2.14.3 - license: GPL-2.0-only OR FTL + - __glibc >=2.17,<3.0.a0 + - cairo >=1.18.4,<2.0a0 + - gdk-pixbuf >=2.44.5,<3.0a0 + - libgcc >=14 + - libglib >=2.86.4,<3.0a0 + - libxml2-16 >=2.14.6 + - pango >=1.56.4,<2.0a0 + constrains: + - __glibc >=2.17 + license: LGPL-2.1-or-later purls: [] - size: 8091 - timestamp: 1774298691258 -- conda: https://prefix.dev/conda-forge/linux-64/libfreetype6-2.14.3-h73754d4_0.conda - sha256: 16f020f96da79db1863fcdd8f2b8f4f7d52f177dd4c58601e38e9182e91adf1d - md5: fb16b4b69e3f1dcfe79d80db8fd0c55d + size: 4011590 + timestamp: 1771399906142 +- conda: https://prefix.dev/conda-forge/linux-64/libsndfile-1.2.2-hc7d488a_2.conda + sha256: 57cb5f92110324c04498b96563211a1bca6a74b2918b1e8df578bfed03cc32e4 + md5: 067590f061c9f6ea7e61e3b2112ed6b3 depends: - __glibc >=2.17,<3.0.a0 + - lame >=3.100,<3.101.0a0 + - libflac >=1.5.0,<1.6.0a0 - libgcc >=14 - - libpng >=1.6.55,<1.7.0a0 - - libzlib >=1.3.2,<2.0a0 - constrains: - - freetype >=2.14.3 - license: GPL-2.0-only OR FTL + - libogg >=1.3.5,<1.4.0a0 + - libopus >=1.5.2,<2.0a0 + - libstdcxx >=14 + - libvorbis >=1.3.7,<1.4.0a0 + - mpg123 >=1.32.9,<1.33.0a0 + license: LGPL-2.1-or-later + license_family: LGPL purls: [] - size: 384575 - timestamp: 1774298162622 -- conda: https://prefix.dev/conda-forge/osx-arm64/libfreetype6-2.14.3-hdfa99f5_0.conda - sha256: ff764608e1f2839e95e2cf9b243681475f8778c36af7a42b3f78f476fdbb1dd3 - md5: e98ba7b5f09a5f450eca083d5a1c4649 + size: 355619 + timestamp: 1765181778282 +- conda: https://prefix.dev/conda-forge/linux-64/libsqlite-3.53.1-h0c1763c_0.conda + sha256: 54cdcd3214313b62c2a8ee277e6f42150d9b748264c1b70d958bf735e420ef8d + md5: 7dc38adcbf71e6b38748e919e16e0dce depends: - - __osx >=11.0 - - libpng >=1.6.55,<1.7.0a0 + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 - libzlib >=1.3.2,<2.0a0 - constrains: - - freetype >=2.14.3 - license: GPL-2.0-only OR FTL + license: blessing purls: [] - size: 338085 - timestamp: 1774298689297 -- conda: https://prefix.dev/conda-forge/linux-64/libgcc-15.2.0-he0feb66_19.conda - sha256: 8e0a3b5e41272e5678499b5dfc4cddb673f9e935de01eb0767ce857001229f46 - md5: 57736f29cc2b0ec0b6c2952d3f101b6a + size: 954962 + timestamp: 1777986471789 +- conda: https://prefix.dev/conda-forge/linux-64/libssh2-1.11.1-hcf80075_0.conda + sha256: fa39bfd69228a13e553bd24601332b7cfeb30ca11a3ca50bb028108fe90a7661 + md5: eecce068c7e4eddeb169591baac20ac4 depends: - __glibc >=2.17,<3.0.a0 - - _openmp_mutex >=4.5 - constrains: - - libgcc-ng ==15.2.0=*_19 - - libgomp 15.2.0 he0feb66_19 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL + - libgcc >=13 + - libzlib >=1.3.1,<2.0a0 + - openssl >=3.5.0,<4.0a0 + license: BSD-3-Clause + license_family: BSD purls: [] - size: 1041084 - timestamp: 1778269013026 -- conda: https://prefix.dev/conda-forge/osx-arm64/libgcc-15.2.0-hcbb3090_19.conda - sha256: 06644fa4d34d57c9e48f4d84b1256f9e5f654fdb37f43acc8a58a396952d42b7 - md5: 644058123986582db33aebd4ae2ca184 + size: 304790 + timestamp: 1745608545575 +- conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-15.2.0-h934c35e_19.conda + sha256: dff1058c76ec6b8759e41cefa2508162d00e4a5e6721aa68ec3fd10094e702dc + md5: 5794b3bdc38177caf969dabd3af08549 depends: - - _openmp_mutex + - __glibc >=2.17,<3.0.a0 + - libgcc 15.2.0 he0feb66_19 constrains: - - libgcc-ng ==15.2.0=*_19 - - libgomp 15.2.0 19 + - libstdcxx-ng ==15.2.0=*_19 license: GPL-3.0-only WITH GCC-exception-3.1 license_family: GPL purls: [] - size: 404080 - timestamp: 1778273064154 -- conda: https://prefix.dev/conda-forge/linux-64/libgcc-ng-15.2.0-h69a702a_19.conda - sha256: 9dcf54adfaa5e861123c2da4f2f0451a685464ea7e5a41ad91cf67b31d658d98 - md5: 331ee9b72b9dff570d56b1302c5ab37d + size: 5852044 + timestamp: 1778269036376 +- conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-ng-15.2.0-hdf11a46_19.conda + sha256: 0672b6b6e1791c92e8eccad58081a99d614fcf82bca5841f9dfa3c3e658f83b9 + md5: e5ce228e579726c07255dbf90dc62101 depends: - - libgcc 15.2.0 he0feb66_19 + - libstdcxx 15.2.0 h934c35e_19 license: GPL-3.0-only WITH GCC-exception-3.1 license_family: GPL purls: [] - size: 27694 - timestamp: 1778269016987 -- conda: https://prefix.dev/conda-forge/linux-64/libgd-2.3.3-h5fbf134_12.conda - sha256: 245be793e831170504f36213134f4c24eedaf39e634679809fd5391ad214480b - md5: 88c1c66987cd52a712eea89c27104be6 + size: 27776 + timestamp: 1778269074600 +- conda: https://prefix.dev/conda-forge/linux-64/libsystemd0-257.13-hd0affe5_0.conda + sha256: c5008b602cb5c819f7b52d418b3ed17e1818cbbf6705b189e7ab36bb70cce3d8 + md5: 8ee3cb7f64be0e8c4787f3a4dbe024e6 depends: - __glibc >=2.17,<3.0.a0 - - fontconfig >=2.15.0,<3.0a0 - - fonts-conda-ecosystem - - icu >=78.1,<79.0a0 - - libexpat >=2.7.3,<3.0a0 - - libfreetype >=2.14.1 - - libfreetype6 >=2.14.1 + - libcap >=2.77,<2.78.0a0 - libgcc >=14 - - libjpeg-turbo >=3.1.2,<4.0a0 - - libpng >=1.6.53,<1.7.0a0 - - libtiff >=4.7.1,<4.8.0a0 - - libwebp-base >=1.6.0,<2.0a0 - - libzlib >=1.3.1,<2.0a0 - license: GD - license_family: BSD + license: LGPL-2.1-or-later purls: [] - size: 177306 - timestamp: 1766331805898 -- conda: https://prefix.dev/conda-forge/osx-arm64/libgd-2.3.3-h05bcc79_12.conda - sha256: 269edce527e204a80d3d05673301e0207efcd0dbeebc036a118ceb52690d6341 - md5: fa4a92cfaae9570d89700a292a9ca714 + size: 492799 + timestamp: 1773797095649 +- conda: https://prefix.dev/conda-forge/linux-64/libtiff-4.7.1-h9d88235_1.conda + sha256: e5f8c38625aa6d567809733ae04bb71c161a42e44a9fa8227abe61fa5c60ebe0 + md5: cd5a90476766d53e901500df9215e927 depends: - - __osx >=11.0 - - fontconfig >=2.15.0,<3.0a0 - - fonts-conda-ecosystem - - icu >=78.1,<79.0a0 - - libexpat >=2.7.3,<3.0a0 - - libfreetype >=2.14.1 - - libfreetype6 >=2.14.1 - - libiconv >=1.18,<2.0a0 - - libjpeg-turbo >=3.1.2,<4.0a0 - - libpng >=1.6.53,<1.7.0a0 - - libtiff >=4.7.1,<4.8.0a0 + - __glibc >=2.17,<3.0.a0 + - lerc >=4.0.0,<5.0a0 + - libdeflate >=1.25,<1.26.0a0 + - libgcc >=14 + - libjpeg-turbo >=3.1.0,<4.0a0 + - liblzma >=5.8.1,<6.0a0 + - libstdcxx >=14 - libwebp-base >=1.6.0,<2.0a0 - libzlib >=1.3.1,<2.0a0 - license: GD - license_family: BSD + - zstd >=1.5.7,<1.6.0a0 + license: HPND purls: [] - size: 159247 - timestamp: 1766331953491 -- conda: https://prefix.dev/conda-forge/linux-64/libgfortran-15.2.0-h69a702a_19.conda - sha256: 561a42758ef25b9ce308c4e2cf56daee4f06138385a17e29a492cd928e00be6f - md5: 42bf7eca1a951735fa06c0e3c0d5c8e6 + size: 435273 + timestamp: 1762022005702 +- conda: https://prefix.dev/conda-forge/linux-64/libudev1-257.13-hd0affe5_0.conda + sha256: 1a1e367c04d66030aa93b4d33905f7f6fbb59cfc292e816fe3e9c1e8b3f4d1e2 + md5: 2c2270f93d6f9073cbf72d821dfc7d72 depends: - - libgfortran5 15.2.0 h68bc16d_19 - constrains: - - libgfortran-ng ==15.2.0=*_19 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL + - __glibc >=2.17,<3.0.a0 + - libcap >=2.77,<2.78.0a0 + - libgcc >=14 + license: LGPL-2.1-or-later purls: [] - size: 27655 - timestamp: 1778269042954 -- conda: https://prefix.dev/conda-forge/osx-arm64/libgfortran-15.2.0-h07b0088_19.conda - sha256: d4837b3b9b30af3132d260225e91ab9dde83be04c59513f500cc81050fb37486 - md5: 1ea03f87cdb1078fbc0e2b2deb63752c + size: 145087 + timestamp: 1773797108513 +- conda: https://prefix.dev/conda-forge/linux-64/libunwind-1.8.3-h65a8314_0.conda + sha256: 71c8b9d5c72473752a0bb6e91b01dd209a03916cb71f36cc6a564e3a2a132d7a + md5: e179a69edd30d75c0144d7a380b88f28 depends: - - libgfortran5 15.2.0 hdae7583_19 - constrains: - - libgfortran-ng ==15.2.0=*_19 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + - libstdcxx >=14 + license: MIT + license_family: MIT purls: [] - size: 139675 - timestamp: 1778273280875 -- conda: https://prefix.dev/conda-forge/linux-64/libgfortran5-15.2.0-h68bc16d_19.conda - sha256: 057978bb69fea29ed715a9b98adf71015c31baecc4aeb2bfc20d4fd5d83579d4 - md5: 85072b0ad177c966294f129b7c04a2d5 + size: 75995 + timestamp: 1757032240102 +- conda: https://prefix.dev/conda-forge/linux-64/liburing-2.14-hb700be7_0.conda + sha256: 3d17b7aa90610afc65356e9e6149aeac0b2df19deda73a51f0a09cf04fd89286 + md5: 56f65185b520e016d29d01657ac02c0d depends: - __glibc >=2.17,<3.0.a0 - - libgcc >=15.2.0 - constrains: - - libgfortran 15.2.0 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL + - libgcc >=14 + - libstdcxx >=14 + license: MIT + license_family: MIT purls: [] - size: 2483673 - timestamp: 1778269025089 -- conda: https://prefix.dev/conda-forge/osx-arm64/libgfortran5-15.2.0-hdae7583_19.conda - sha256: d0a68b7a121d115b80c169e24d1265dcc25a3fe58d107df1bbc430797e226d88 - md5: ba36d8c606a6a53fe0b8c12d47267b3d + size: 154203 + timestamp: 1770566529700 +- conda: https://prefix.dev/conda-forge/linux-64/libusb-1.0.29-h73b1eb8_0.conda + sha256: 89c84f5b26028a9d0f5c4014330703e7dff73ba0c98f90103e9cef6b43a5323c + md5: d17e3fb595a9f24fa9e149239a33475d depends: - - libgcc >=15.2.0 - constrains: - - libgfortran 15.2.0 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL + - __glibc >=2.17,<3.0.a0 + - libgcc >=13 + - libudev1 >=257.4 + license: LGPL-2.1-or-later purls: [] - size: 599691 - timestamp: 1778273075448 -- conda: https://prefix.dev/conda-forge/linux-64/libgl-1.7.0-ha4b6fd6_2.conda - sha256: dc2752241fa3d9e40ce552c1942d0a4b5eeb93740c9723873f6fcf8d39ef8d2d - md5: 928b8be80851f5d8ffb016f9c81dae7a + size: 89551 + timestamp: 1748856210075 +- conda: https://prefix.dev/conda-forge/linux-64/libuuid-2.42-h5347b49_0.conda + sha256: bc1b08c92626c91500fd9f26f2c797f3eb153b627d53e9c13cd167f1e12b2829 + md5: 38ffe67b78c9d4de527be8315e5ada2c depends: - __glibc >=2.17,<3.0.a0 - - libglvnd 1.7.0 ha4b6fd6_2 - - libglx 1.7.0 ha4b6fd6_2 - license: LicenseRef-libglvnd + - libgcc >=14 + license: BSD-3-Clause + license_family: BSD purls: [] - size: 134712 - timestamp: 1731330998354 -- conda: https://prefix.dev/conda-forge/linux-64/libgl-devel-1.7.0-ha4b6fd6_2.conda - sha256: e281356c0975751f478c53e14f3efea6cd1e23c3069406d10708d6c409525260 - md5: 53e7cbb2beb03d69a478631e23e340e9 + size: 40297 + timestamp: 1775052476770 +- conda: https://prefix.dev/conda-forge/linux-64/libuv-1.51.0-hb03c661_1.conda + sha256: c180f4124a889ac343fc59d15558e93667d894a966ec6fdb61da1604481be26b + md5: 0f03292cc56bf91a077a134ea8747118 depends: - __glibc >=2.17,<3.0.a0 - - libgl 1.7.0 ha4b6fd6_2 - - libglx-devel 1.7.0 ha4b6fd6_2 - license: LicenseRef-libglvnd + - libgcc >=14 + license: MIT + license_family: MIT purls: [] - size: 113911 - timestamp: 1731331012126 -- conda: https://prefix.dev/conda-forge/linux-64/libglib-2.88.3-h0d30a3d_0.conda - sha256: 69ea4df61403531e5b3e5f3d52ba2837423df361b4eb8727f5b63aaf6de6768a - md5: 17c3b7b6bcbd35b688c933eb4834c0bc + size: 895108 + timestamp: 1753948278280 +- conda: https://prefix.dev/conda-forge/linux-64/libvorbis-1.3.7-h54a6638_2.conda + sha256: ca494c99c7e5ecc1b4cd2f72b5584cef3d4ce631d23511184411abcbb90a21a5 + md5: b4ecbefe517ed0157c37f8182768271c depends: + - libogg - libgcc >=14 - __glibc >=2.17,<3.0.a0 - - libiconv >=1.18,<2.0a0 - - libzlib >=1.3.2,<2.0a0 - - pcre2 >=10.47,<10.48.0a0 - - libffi >=3.5.2,<3.6.0a0 - constrains: - - glib >2.66 - license: LGPL-2.1-or-later + - libstdcxx >=14 + - libgcc >=14 + - libogg >=1.3.5,<1.4.0a0 + license: BSD-3-Clause + license_family: BSD purls: [] - size: 4755324 - timestamp: 1785442107463 -- conda: https://prefix.dev/conda-forge/osx-arm64/libglib-2.88.3-ha08bb59_0.conda - sha256: a14417ae1f3f4a92c5766354eb280342fa6aae72a09af86bf7fcfc12a8c9225c - md5: 4a9309d9502a08a2d29b1743dcfb0e7f + size: 285894 + timestamp: 1753879378005 +- conda: https://prefix.dev/conda-forge/linux-64/libvulkan-loader-1.4.341.0-h5279c79_0.conda + sha256: a68280d57dfd29e3d53400409a39d67c4b9515097eba733aa6fe00c880620e2b + md5: 31ad065eda3c2d88f8215b1289df9c89 depends: - - __osx >=11.0 - - pcre2 >=10.47,<10.48.0a0 - - libzlib >=1.3.2,<2.0a0 - - libffi >=3.5.2,<3.6.0a0 - - libintl >=0.25.1,<1.0a0 - - libiconv >=1.18,<2.0a0 + - __glibc >=2.17,<3.0.a0 + - libstdcxx >=14 + - libgcc >=14 + - xorg-libx11 >=1.8.12,<2.0a0 + - xorg-libxrandr >=1.5.5,<2.0a0 constrains: - - glib >2.66 - license: LGPL-2.1-or-later + - libvulkan-headers 1.4.341.0.* + license: Apache-2.0 + license_family: APACHE purls: [] - size: 4448109 - timestamp: 1785442168180 -- conda: https://prefix.dev/conda-forge/linux-64/libglvnd-1.7.0-ha4b6fd6_2.conda - sha256: 1175f8a7a0c68b7f81962699751bb6574e6f07db4c9f72825f978e3016f46850 - md5: 434ca7e50e40f4918ab701e3facd59a0 + size: 199795 + timestamp: 1770077125520 +- conda: https://prefix.dev/conda-forge/linux-64/libwebp-base-1.6.0-hd42ef1d_0.conda + sha256: 3aed21ab28eddffdaf7f804f49be7a7d701e8f0e46c856d801270b470820a37b + md5: aea31d2e5b1091feca96fcfe945c3cf9 depends: - __glibc >=2.17,<3.0.a0 - license: LicenseRef-libglvnd + - libgcc >=14 + constrains: + - libwebp 1.6.0 + license: BSD-3-Clause + license_family: BSD purls: [] - size: 132463 - timestamp: 1731330968309 -- conda: https://prefix.dev/conda-forge/linux-64/libglx-1.7.0-ha4b6fd6_2.conda - sha256: 2d35a679624a93ce5b3e9dd301fff92343db609b79f0363e6d0ceb3a6478bfa7 - md5: c8013e438185f33b13814c5c488acd5c + size: 429011 + timestamp: 1752159441324 +- conda: https://prefix.dev/conda-forge/linux-64/libxcb-1.17.0-h8a09558_0.conda + sha256: 666c0c431b23c6cec6e492840b176dde533d48b7e6fb8883f5071223433776aa + md5: 92ed62436b625154323d40d5f2f11dd7 depends: - __glibc >=2.17,<3.0.a0 - - libglvnd 1.7.0 ha4b6fd6_2 - - xorg-libx11 >=1.8.10,<2.0a0 - license: LicenseRef-libglvnd + - libgcc >=13 + - pthread-stubs + - xorg-libxau >=1.0.11,<2.0a0 + - xorg-libxdmcp + license: MIT + license_family: MIT purls: [] - size: 75504 - timestamp: 1731330988898 -- conda: https://prefix.dev/conda-forge/linux-64/libglx-devel-1.7.0-ha4b6fd6_2.conda - sha256: 0a930e0148ab6e61089bbcdba25a2e17ee383e7de82e7af10cc5c12c82c580f3 - md5: 27ac5ae872a21375d980bd4a6f99edf3 + size: 395888 + timestamp: 1727278577118 +- conda: https://prefix.dev/conda-forge/linux-64/libxcrypt-4.4.36-hd590300_1.conda + sha256: 6ae68e0b86423ef188196fff6207ed0c8195dd84273cb5623b85aa08033a410c + md5: 5aa797f8787fe7a17d1b0821485b5adc depends: - - __glibc >=2.17,<3.0.a0 - - libglx 1.7.0 ha4b6fd6_2 - - xorg-libx11 >=1.8.10,<2.0a0 - - xorg-xorgproto - license: LicenseRef-libglvnd + - libgcc-ng >=12 + license: LGPL-2.1-or-later purls: [] - size: 26388 - timestamp: 1731331003255 -- conda: https://prefix.dev/conda-forge/linux-64/libgomp-15.2.0-he0feb66_19.conda - sha256: 5abe4ab9d93f6c9757d654f1969ae2267d4505315c1f2f8fe705fd60af084f1b - md5: faac990cb7aedc7f3a2224f2c9b0c26c + size: 100393 + timestamp: 1702724383534 +- conda: https://prefix.dev/conda-forge/linux-64/libxkbcommon-1.13.1-hca5e8e5_0.conda + sha256: d2195b5fbcb0af1ff7b345efdf89290c279b8d1d74f325ae0ac98148c375863c + md5: 2bca1fbb221d9c3c8e3a155784bbc2e9 depends: - __glibc >=2.17,<3.0.a0 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL - purls: [] - size: 603817 - timestamp: 1778268942614 -- conda: https://prefix.dev/conda-forge/linux-64/libharfbuzz-14.3.1-h23af247_0.conda - sha256: a4eac5a21b84e0fc753b72de01781f634fc9ab70fd32a28d6a40a19700c9188a - md5: 29709e61096dd490fff9e833e4c869f6 - depends: - - __glibc >=2.17,<3.0.a0 - - cairo >=1.18.4,<2.0a0 - - graphite2 >=1.3.15,<2.0a0 - - icu >=78.3,<79.0a0 - - libfreetype >=2.14.3 - - libfreetype6 >=2.14.3 - - libgcc >=15 - - libglib >=2.88.3,<3.0a0 - - libpng >=1.6.58,<1.7.0a0 - - libstdcxx >=15 - - libzlib >=1.3.2,<2.0a0 - license: MIT + - libgcc >=14 + - libstdcxx >=14 + - libxcb >=1.17.0,<2.0a0 + - libxml2 + - libxml2-16 >=2.14.6 + - xkeyboard-config + - xorg-libxau >=1.0.12,<2.0a0 + license: MIT/X11 Derivative license_family: MIT purls: [] - size: 1353639 - timestamp: 1786970872936 -- conda: https://prefix.dev/conda-forge/osx-arm64/libharfbuzz-14.3.1-hcda0f7c_0.conda - sha256: 67af14f8fbf9b9725890f728179d933ac35a95a6b50f37b7b568a11bfa8a4c1d - md5: 1631ca9ffe7d368850904baa1df1abf4 + size: 837922 + timestamp: 1764794163823 +- conda: https://prefix.dev/conda-forge/linux-64/libxml2-16-2.15.3-hca6bf5a_0.conda + sha256: 3d44f737c5ae52d5af32682cc1530df433f401f8e58a7533926536244127572a + md5: e79d2c2f24b027aa8d5ab1b1ba3061e7 depends: - - __osx >=11.0 - - cairo >=1.18.4,<2.0a0 - - graphite2 >=1.3.15,<2.0a0 + - __glibc >=2.17,<3.0.a0 - icu >=78.3,<79.0a0 - - libcxx >=21 - - libfreetype >=2.14.3 - - libfreetype6 >=2.14.3 - - libglib >=2.88.3,<3.0a0 - - libpng >=1.6.58,<1.7.0a0 + - libgcc >=14 + - libiconv >=1.18,<2.0a0 + - liblzma >=5.8.3,<6.0a0 - libzlib >=1.3.2,<2.0a0 + constrains: + - libxml2 2.15.3 license: MIT license_family: MIT purls: [] - size: 953252 - timestamp: 1786970947180 -- conda: https://prefix.dev/conda-forge/linux-64/libharfbuzz-devel-14.3.1-h23af247_0.conda - sha256: 9d9d620141102dcb580d8f42d1a6c9e7e691a8dfa0284783e712679723067d15 - md5: e0f17ce01589ffa7d773be573e97b36c + size: 559775 + timestamp: 1776376739004 +- conda: https://prefix.dev/conda-forge/linux-64/libxml2-2.15.3-h49c6c72_0.conda + sha256: 3bc5551720c58591f6ea1146f7d1539c734ed1c40e7b9f5cb8cb7e900c509aba + md5: 995d8c8bad2a3cc8db14675a153dec2b depends: - __glibc >=2.17,<3.0.a0 - - cairo >=1.18.4,<2.0a0 - - freetype - - graphite2 >=1.3.15,<2.0a0 - icu >=78.3,<79.0a0 - - libfreetype >=2.14.3 - - libfreetype6 >=2.14.3 - - libgcc >=15 - - libglib >=2.88.3,<3.0a0 - - libharfbuzz 14.3.1 h23af247_0 - - libpng >=1.6.58,<1.7.0a0 - - libstdcxx >=15 + - libgcc >=14 + - libiconv >=1.18,<2.0a0 + - liblzma >=5.8.3,<6.0a0 + - libxml2-16 2.15.3 hca6bf5a_0 - libzlib >=1.3.2,<2.0a0 license: MIT license_family: MIT purls: [] - size: 2114382 - timestamp: 1786970892473 -- conda: https://prefix.dev/conda-forge/osx-arm64/libharfbuzz-devel-14.3.1-hcda0f7c_0.conda - sha256: 076db9dac1b7ab31383ffd35da5f5b9ab9e56987b7751a5ec767c330f0e3c359 - md5: 911b746bffebd782ea8d53e663b0269c + size: 46810 + timestamp: 1776376751152 +- conda: https://prefix.dev/conda-forge/linux-64/libxslt-1.1.43-h711ed8c_1.conda + sha256: 0694760a3e62bdc659d90a14ae9c6e132b525a7900e59785b18a08bb52a5d7e5 + md5: 87e6096ec6d542d1c1f8b33245fe8300 depends: - - __osx >=11.0 - - cairo >=1.18.4,<2.0a0 - - freetype - - graphite2 >=1.3.15,<2.0a0 - - icu >=78.3,<79.0a0 - - libcxx >=21 - - libfreetype >=2.14.3 - - libfreetype6 >=2.14.3 - - libglib >=2.88.3,<3.0a0 - - libharfbuzz 14.3.1 hcda0f7c_0 - - libpng >=1.6.58,<1.7.0a0 - - libzlib >=1.3.2,<2.0a0 + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + - libxml2 + - libxml2-16 >=2.14.6 license: MIT license_family: MIT purls: [] - size: 1500884 - timestamp: 1786970969119 -- conda: https://prefix.dev/conda-forge/linux-64/libiconv-1.18-h3b78370_2.conda - sha256: c467851a7312765447155e071752d7bf9bf44d610a5687e32706f480aad2833f - md5: 915f5995e94f60e9a4826e0b0920ee88 + size: 245434 + timestamp: 1757963724977 +- conda: https://prefix.dev/conda-forge/linux-64/libzlib-1.3.2-h25fd6f3_2.conda + sha256: 55044c403570f0dc26e6364de4dc5368e5f3fc7ff103e867c487e2b5ab2bcda9 + md5: d87ff7921124eccd67248aa483c23fec depends: - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - license: LGPL-2.1-only + constrains: + - zlib 1.3.2 *_2 + license: Zlib + license_family: Other purls: [] - size: 790176 - timestamp: 1754908768807 -- conda: https://prefix.dev/conda-forge/osx-arm64/libiconv-1.18-h23cfdf5_2.conda - sha256: de0336e800b2af9a40bdd694b03870ac4a848161b35c8a2325704f123f185f03 - md5: 4d5a7445f0b25b6a3ddbb56e790f5251 + size: 63629 + timestamp: 1774072609062 +- conda: https://prefix.dev/conda-forge/linux-64/llvmlite-0.49.0-py311h1369f55_2.conda + sha256: bd4ddf72a6ee81991759d407d0cf8fadf9804500562839448a22c11f8e829f8e + md5: 7d4c6843f49e890b8f6fb813d7e94c1f depends: - - __osx >=11.0 - license: LGPL-2.1-only - purls: [] - size: 750379 - timestamp: 1754909073836 -- conda: https://prefix.dev/conda-forge/osx-arm64/libintl-0.25.1-h493aca8_0.conda - sha256: 99d2cebcd8f84961b86784451b010f5f0a795ed1c08f1e7c76fbb3c22abf021a - md5: 5103f6a6b210a3912faf8d7db516918c + - python + - __glibc >=2.17,<3.0.a0 + - libstdcxx >=15 + - libgcc >=15 + - zstd >=1.5.7,<1.6.0a0 + - python_abi 3.11.* *_cp311 + - libzlib >=1.3.2,<2.0a0 + license: BSD-2-Clause + license_family: BSD + purls: + - pkg:pypi/llvmlite?source=hash-mapping + size: 40845513 + timestamp: 1788013791127 +- conda: https://prefix.dev/conda-forge/linux-64/matplotlib-3.11.1-py311h968eb38_2.conda + sha256: b677501911fa682ea74a86472a003a2f8cbb046f8fb6bbc501521af6aea0744f + md5: 2cb7827f42621fe32c5161ad927ecaa7 depends: - - __osx >=11.0 - - libiconv >=1.18,<2.0a0 - license: LGPL-2.1-or-later + - matplotlib-base >=3.11.1,<3.11.2.0a0 + - pyside6 >=6.7.2 + - python >=3.11,<3.12.0a0 + - python_abi 3.11.* *_cp311 + - tornado >=5 + license: PSF-2.0 + license_family: PSF purls: [] - size: 90957 - timestamp: 1751558394144 -- conda: https://prefix.dev/conda-forge/linux-64/libjpeg-turbo-3.1.4.1-hb03c661_0.conda - sha256: 10056646c28115b174de81a44e23e3a0a3b95b5347d2e6c45cc6d49d35294256 - md5: 6178c6f2fb254558238ef4e6c56fb782 + size: 14988 + timestamp: 1785211075423 +- conda: https://prefix.dev/conda-forge/linux-64/matplotlib-base-3.11.1-py311he401cf6_2.conda + sha256: f9f48162f2553080d041b061b9f6cfec64d79d7c40df0e6379496f9ad2df738c + md5: f602c096988d0f744f4f017aa0269e30 depends: - __glibc >=2.17,<3.0.a0 + - contourpy >=1.0.1 + - cycler >=0.10 + - fonttools >=4.28.2 + - freetype + - kiwisolver >=1.3.1 + - libfreetype >=2.14.3 + - libfreetype6 >=2.14.3 - libgcc >=14 - constrains: - - jpeg <0.0.0a - license: IJG AND BSD-3-Clause AND Zlib + - libraqm >=0.11.0,<0.12.0a0 + - libstdcxx >=14 + - numpy >=1.23,<3 + - numpy >=1.25 + - packaging >=20.0 + - pillow >=9 + - pyparsing >=3 + - python >=3.11,<3.12.0a0 + - python-dateutil >=2.7 + - python_abi 3.11.* *_cp311 + - qhull >=2020.2,<2020.3.0a0 + - tk >=8.6.13,<8.7.0a0 + license: PSF-2.0 + license_family: PSF + purls: + - pkg:pypi/matplotlib?source=hash-mapping + size: 8925010 + timestamp: 1785211062689 +- conda: https://prefix.dev/conda-forge/linux-64/mpg123-1.32.9-hc50e24c_0.conda + sha256: 39c4700fb3fbe403a77d8cc27352fa72ba744db487559d5d44bf8411bb4ea200 + md5: c7f302fd11eeb0987a6a5e1f3aed6a21 + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc >=13 + - libstdcxx >=13 + license: LGPL-2.1-only + license_family: LGPL purls: [] - size: 633831 - timestamp: 1775962768273 -- conda: https://prefix.dev/conda-forge/osx-arm64/libjpeg-turbo-3.1.4.1-h84a0fba_0.conda - sha256: 17e035ae6a520ff6a6bb5dd93a4a7c3895891f4f9743bcb8c6ef607445a31cd0 - md5: b8a7544c83a67258b0e8592ec6a5d322 + size: 491140 + timestamp: 1730581373280 +- conda: https://prefix.dev/conda-forge/linux-64/ncurses-6.6-hdb14827_0.conda + sha256: fc89f74bbe362fb29fa3c037697a89bec140b346a2469a90f7936d1d7ea4d8a3 + md5: fc21868a1a5aacc937e7a18747acb8a5 depends: - - __osx >=11.0 - constrains: - - jpeg <0.0.0a - license: IJG AND BSD-3-Clause AND Zlib + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + license: X11 AND BSD-3-Clause purls: [] - size: 555681 - timestamp: 1775962975624 -- conda: https://prefix.dev/conda-forge/linux-64/liblapack-3.11.0-6_h47877c9_openblas.conda - build_number: 6 - sha256: 371f517eb7010b21c6cc882c7606daccebb943307cb9a3bf2c70456a5c024f7d - md5: 881d801569b201c2e753f03c84b85e15 + size: 918956 + timestamp: 1777422145199 +- conda: https://prefix.dev/conda-forge/linux-64/numba-0.67.0-py311hdfc3925_1.conda + sha256: 3129c290e7d02cd7fd8a44da0f1985539e7c659b18624b7298baaa267718d942 + md5: e32e21325dea34226840b71a57982ef3 depends: - - libblas 3.11.0 6_h4a7cf45_openblas + - python + - llvmlite >=0.49.0,<0.50.0a0 + - numpy >=1.22.3,<2.6 + - _openmp_mutex >=4.5 + - __glibc >=2.17,<3.0.a0 + - libgcc >=15 + - libstdcxx >=15 + - numpy >=1.23,<3 + - python_abi 3.11.* *_cp311 constrains: - - blas 2.306 openblas - - liblapacke 3.11.0 6*_openblas - - libcblas 3.11.0 6*_openblas - license: BSD-3-Clause + - tbb >=2021.6.0 + - libopenblas !=0.3.6 + - cuda-version >=11.2 + - cudatoolkit >=11.2 + - scipy >=1.0 + - cuda-python >=11.6 + license: BSD-2-Clause license_family: BSD - purls: [] - size: 18624 - timestamp: 1774503065378 -- conda: https://prefix.dev/conda-forge/osx-arm64/liblapack-3.11.0-6_hd9741b5_openblas.conda - build_number: 6 - sha256: 21606b7346810559e259807497b86f438950cf19e71838e44ebaf4bd2b35b549 - md5: ee33d2d05a7c5ea1f67653b37eb74db1 + purls: + - pkg:pypi/numba?source=hash-mapping + size: 6286682 + timestamp: 1787145506914 +- conda: https://prefix.dev/conda-forge/linux-64/numpy-2.0.2-py311h71ddf71_1.conda + sha256: a922ec6947ad6953cb011b8f1a44779f6b55d62a14c5bcd25d19a8fb1629da30 + md5: 04ce874aa54fc1d9c735a04e0c6d99c4 depends: - - libblas 3.11.0 6_h51639a9_openblas + - __glibc >=2.17,<3.0.a0 + - libblas >=3.9.0,<4.0a0 + - libcblas >=3.9.0,<4.0a0 + - libgcc >=13 + - liblapack >=3.9.0,<4.0a0 + - libstdcxx >=13 + - python >=3.11,<3.12.0a0 + - python_abi 3.11.* *_cp311 constrains: - - liblapacke 3.11.0 6*_openblas - - libcblas 3.11.0 6*_openblas - - blas 2.306 openblas + - numpy-base <0a0 license: BSD-3-Clause license_family: BSD - purls: [] - size: 18863 - timestamp: 1774504467905 -- conda: https://prefix.dev/conda-forge/linux-64/libllvm22-22.1.8-hf7376ad_1.conda - sha256: e9b5f301d6b001a9b8ce782157f56b75c92c4fbc9eba95dc6345c1139251d13b - md5: 298bb2483fc7d15396147cf1c1465359 + purls: + - pkg:pypi/numpy?source=hash-mapping + size: 9148240 + timestamp: 1732314901472 +- conda: https://prefix.dev/conda-forge/linux-64/openjpeg-2.5.4-h55fea9a_0.conda + sha256: 3900f9f2dbbf4129cf3ad6acf4e4b6f7101390b53843591c53b00f034343bc4d + md5: 11b3379b191f63139e29c0d19dee24cd depends: - __glibc >=2.17,<3.0.a0 - libgcc >=14 + - libpng >=1.6.50,<1.7.0a0 - libstdcxx >=14 - - libxml2 - - libxml2-16 >=2.14.6 - - libzlib >=1.3.2,<2.0a0 - - zstd >=1.5.7,<1.6.0a0 - license: Apache-2.0 WITH LLVM-exception - license_family: Apache + - libtiff >=4.7.1,<4.8.0a0 + - libzlib >=1.3.1,<2.0a0 + license: BSD-2-Clause + license_family: BSD purls: [] - size: 44320272 - timestamp: 1781788728739 -- conda: https://prefix.dev/conda-forge/linux-64/liblzma-5.8.3-hb03c661_0.conda - sha256: ec30e52a3c1bf7d0425380a189d209a52baa03f22fb66dd3eb587acaa765bd6d - md5: b88d90cad08e6bc8ad540cb310a761fb + size: 355400 + timestamp: 1758489294972 +- conda: https://prefix.dev/conda-forge/linux-64/openldap-2.6.13-hbde042b_0.conda + sha256: 21c4f6c7f41dc9bec2ea2f9c80440d9a4d45a6f2ac13243e658f10dcf1044146 + md5: 680608784722880fbfe1745067570b00 depends: - __glibc >=2.17,<3.0.a0 + - cyrus-sasl >=2.1.28,<3.0a0 + - krb5 >=1.22.2,<1.23.0a0 - libgcc >=14 - constrains: - - xz 5.8.3.* - license: 0BSD - purls: [] - size: 113478 - timestamp: 1775825492909 -- conda: https://prefix.dev/conda-forge/osx-arm64/liblzma-5.8.3-h8088a28_0.conda - sha256: 34878d87275c298f1a732c6806349125cebbf340d24c6c23727268184bba051e - md5: b1fd823b5ae54fbec272cea0811bd8a9 - depends: - - __osx >=11.0 - constrains: - - xz 5.8.3.* - license: 0BSD + - libstdcxx >=14 + - openssl >=3.5.6,<4.0a0 + license: OLDAP-2.8 + license_family: BSD purls: [] - size: 92472 - timestamp: 1775825802659 -- conda: https://prefix.dev/conda-forge/linux-64/liblzma-devel-5.8.3-hb03c661_0.conda - sha256: 7858f6a173206bc8a5bdc8e75690483bb66c0dcc3809ac1cb43c561a4723623a - md5: 55c20edec8e90c4703787acaade60808 + size: 786149 + timestamp: 1775741359582 +- conda: https://prefix.dev/conda-forge/linux-64/openssl-3.6.2-h35e630c_0.conda + sha256: c0ef482280e38c71a08ad6d71448194b719630345b0c9c60744a2010e8a8e0cb + md5: da1b85b6a87e141f5140bb9924cecab0 depends: - __glibc >=2.17,<3.0.a0 + - ca-certificates - libgcc >=14 - - liblzma 5.8.3 hb03c661_0 - license: 0BSD - purls: [] - size: 491429 - timestamp: 1775825511214 -- conda: https://prefix.dev/conda-forge/osx-arm64/liblzma-devel-5.8.3-h8088a28_0.conda - sha256: 3002be39c0e98ec6cd103b0dc2963dc9e0d7cab127fb2fe9a8de9707a76ed1f0 - md5: ebe1f5418d6e2d4bbc26b2c906a0a470 - depends: - - __osx >=11.0 - - liblzma 5.8.3 h8088a28_0 - license: 0BSD + license: Apache-2.0 + license_family: Apache purls: [] - size: 118482 - timestamp: 1775825828010 -- conda: https://prefix.dev/conda-forge/linux-64/libmad-0.15.1b-h0b41bf4_1001.conda - sha256: 9e94cec54c4baadaa652c761179b8d32771fe7fa55faf6c78c2e35f942367f74 - md5: dc5cc4700f02ffeecc48253c9f29025b + size: 3167099 + timestamp: 1775587756857 +- conda: https://prefix.dev/conda-forge/linux-64/opusfile-0.12-h3358134_2.conda + sha256: f4df9df880e405e5c856383f869d5b9d434f78fb7c234c9e7b099ab604fb7fc3 + md5: 5931bcae00b98f952696b6bcdd0be34b depends: - libgcc-ng >=12 - license: GPL-2.0-only - license_family: GPL - purls: [] - size: 78561 - timestamp: 1670815547616 -- conda: https://prefix.dev/conda-forge/osx-arm64/libmad-0.15.1b-h1a8c8d9_1001.conda - sha256: 8e9209acf4bf6865760e61dc0d86116ffc9efc3e13c7f559eb1ea78532a3a625 - md5: 1eb30852ed396fbe6e301fe6d715aef9 - license: GPL-2.0-only - license_family: GPL + - libogg >=1.3.4,<1.4.0a0 + - libopus >=1.3.1,<2.0a0 + - openssl >=3.0.7,<4.0a0 + license: BSD-3-Clause + license_family: BSD purls: [] - size: 77255 - timestamp: 1670815732700 -- conda: https://prefix.dev/conda-forge/linux-64/libnghttp2-1.68.1-h877daf1_0.conda - sha256: 663444d77a42f2265f54fb8b48c5450bfff4388d9c0f8253dd7855f0d993153f - md5: 2a45e7f8af083626f009645a6481f12d + size: 65901 + timestamp: 1670387479735 +- conda: https://prefix.dev/conda-forge/linux-64/pandas-3.0.1-py311h8032f78_0.conda + sha256: 3e58067de2e0b8220cf1323c1fc736028b2a117b7a7173bfe67f7da11094271f + md5: 3ac73c673df24589b5b84d43a4afd235 depends: - - __glibc >=2.17,<3.0.a0 - - c-ares >=1.34.6,<2.0a0 - - libev >=4.33,<4.34.0a0 - - libev >=4.33,<5.0a0 + - python + - numpy >=1.26.0 + - python-dateutil >=2.8.2 - libgcc >=14 + - __glibc >=2.17,<3.0.a0 - libstdcxx >=14 - - libzlib >=1.3.1,<2.0a0 - - openssl >=3.5.5,<4.0a0 - license: MIT - license_family: MIT - purls: [] - size: 663344 - timestamp: 1773854035739 -- conda: https://prefix.dev/conda-forge/osx-arm64/libnghttp2-1.68.1-h8f3e76b_0.conda - sha256: 2bc7bc3978066f2c274ebcbf711850cc9ab92e023e433b9631958a098d11e10a - md5: 6ea18834adbc3b33df9bd9fb45eaf95b - depends: - - __osx >=11.0 - - c-ares >=1.34.6,<2.0a0 - - libcxx >=19 - - libev >=4.33,<4.34.0a0 - - libev >=4.33,<5.0a0 - - libzlib >=1.3.1,<2.0a0 - - openssl >=3.5.5,<4.0a0 - license: MIT - license_family: MIT - purls: [] - size: 576526 - timestamp: 1773854624224 -- conda: https://prefix.dev/conda-forge/linux-64/libnsl-2.0.1-hb9d3cd8_1.conda - sha256: 927fe72b054277cde6cb82597d0fcf6baf127dcbce2e0a9d8925a68f1265eef5 - md5: d864d34357c3b65a4b731f78c0801dc4 + - python_abi 3.11.* *_cp311 + - numpy >=1.23,<3 + constrains: + - adbc-driver-postgresql >=1.2.0 + - adbc-driver-sqlite >=1.2.0 + - beautifulsoup4 >=4.12.3 + - blosc >=1.21.3 + - bottleneck >=1.4.2 + - fastparquet >=2024.11.0 + - fsspec >=2024.10.0 + - gcsfs >=2024.10.0 + - html5lib >=1.1 + - hypothesis >=6.116.0 + - jinja2 >=3.1.5 + - lxml >=5.3.0 + - matplotlib >=3.9.3 + - numba >=0.60.0 + - numexpr >=2.10.2 + - odfpy >=1.4.1 + - openpyxl >=3.1.5 + - psycopg2 >=2.9.10 + - pyarrow >=13.0.0 + - pyiceberg >=0.8.1 + - pymysql >=1.1.1 + - pyqt5 >=5.15.9 + - pyreadstat >=1.2.8 + - pytables >=3.10.1 + - pytest >=8.3.4 + - pytest-xdist >=3.6.1 + - python-calamine >=0.3.0 + - pytz >=2024.2 + - pyxlsb >=1.0.10 + - qtpy >=2.4.2 + - scipy >=1.14.1 + - s3fs >=2024.10.0 + - sqlalchemy >=2.0.36 + - tabulate >=0.9.0 + - xarray >=2024.10.0 + - xlrd >=2.0.1 + - xlsxwriter >=3.2.0 + - zstandard >=0.23.0 + license: BSD-3-Clause + license_family: BSD + purls: + - pkg:pypi/pandas?source=hash-mapping + size: 15143263 + timestamp: 1771408984246 +- conda: https://prefix.dev/conda-forge/linux-64/pango-1.56.4-hadf4263_0.conda + sha256: 3613774ad27e48503a3a6a9d72017087ea70f1426f6e5541dbdb59a3b626eaaf + md5: 79f71230c069a287efe3a8614069ddf1 depends: - __glibc >=2.17,<3.0.a0 + - cairo >=1.18.4,<2.0a0 + - fontconfig >=2.15.0,<3.0a0 + - fonts-conda-ecosystem + - fribidi >=1.0.10,<2.0a0 + - harfbuzz >=11.0.1 + - libexpat >=2.7.0,<3.0a0 + - libfreetype >=2.13.3 + - libfreetype6 >=2.13.3 - libgcc >=13 - license: LGPL-2.1-only - license_family: GPL + - libglib >=2.84.2,<3.0a0 + - libpng >=1.6.49,<1.7.0a0 + - libzlib >=1.3.1,<2.0a0 + license: LGPL-2.1-or-later purls: [] - size: 33731 - timestamp: 1750274110928 -- conda: https://prefix.dev/conda-forge/linux-64/libntlm-1.8-hb9d3cd8_0.conda - sha256: 3b3f19ced060013c2dd99d9d46403be6d319d4601814c772a3472fe2955612b0 - md5: 7c7927b404672409d9917d49bff5f2d6 + size: 455420 + timestamp: 1751292466873 +- conda: https://prefix.dev/conda-forge/linux-64/pcre2-10.47-haa7fec5_0.conda + sha256: 5e6f7d161356fefd981948bea5139c5aa0436767751a6930cb1ca801ebb113ff + md5: 7a3bff861a6583f1889021facefc08b1 depends: - __glibc >=2.17,<3.0.a0 - - libgcc >=13 - license: LGPL-2.1-or-later + - bzip2 >=1.0.8,<2.0a0 + - libgcc >=14 + - libzlib >=1.3.1,<2.0a0 + license: BSD-3-Clause + license_family: BSD purls: [] - size: 33418 - timestamp: 1734670021371 -- conda: https://prefix.dev/conda-forge/linux-64/libode-0.16.6-h18afd86_0.conda - sha256: 6ff25c1e497e384cc04e53ec45f0a024c8b2a85bd5afb3737cd1043869ef83a0 - md5: 49d678980383b08f99146ea8a7400806 + size: 1222481 + timestamp: 1763655398280 +- conda: https://prefix.dev/conda-forge/linux-64/pillow-12.3.0-py311hf88fc01_0.conda + sha256: fc8a6dbcf1f367cc33ae6d505370b8d9d51ca5eae9b53bf1517307f863300d27 + md5: 9782d37ef50862d2c8a9ba58c1725754 depends: - - __glibc >=2.17,<3.0.a0 - - libccd-double >=2.1,<2.2.0a0 + - python - libgcc >=14 - - libstdcxx >=14 - - pthread-stubs - - python_abi 3.10.* *_cp310 - license: LGPL-2.1-or-later OR BSD-4-Clause - purls: [] - size: 509471 - timestamp: 1760969190850 -- conda: https://prefix.dev/conda-forge/osx-arm64/libode-0.16.6-py310h46abf29_0.conda - sha256: 2f3d4fb77c4cdca3d156c196271fc4a637af8cac93573ba682c1a12c9def54d8 - md5: f23a539191cb27d18453bad21c648c2f - depends: - - __osx >=11.0 - - libccd-double >=2.1,<2.2.0a0 - - libcxx >=19 - - pthread-stubs - - python >=3.10,<3.11.0a0 *_cpython - - python_abi 3.10.* *_cp310 - license: LGPL-2.1-or-later OR BSD-4-Clause - purls: [] - size: 378594 - timestamp: 1760969550819 -- conda: https://prefix.dev/conda-forge/linux-64/libogg-1.3.5-hd0c01bc_1.conda - sha256: ffb066ddf2e76953f92e06677021c73c85536098f1c21fcd15360dbc859e22e4 - md5: 68e52064ed3897463c0e958ab5c8f91b - depends: - - libgcc >=13 - __glibc >=2.17,<3.0.a0 - license: BSD-3-Clause - license_family: BSD - purls: [] - size: 218500 - timestamp: 1745825989535 -- conda: https://prefix.dev/conda-forge/osx-arm64/libogg-1.3.5-h48c0fde_1.conda - sha256: 28bd1fe20fe43da105da41b95ac201e95a1616126f287985df8e86ddebd1c3d8 - md5: 29b8b11f6d7e6bd0e76c029dcf9dd024 - depends: - - __osx >=11.0 - license: BSD-3-Clause - license_family: BSD - purls: [] - size: 216719 - timestamp: 1745826006052 -- conda: https://prefix.dev/conda-forge/linux-64/libopenblas-0.3.32-pthreads_h94d23a6_0.conda - sha256: 6dc30b28f32737a1c52dada10c8f3a41bc9e021854215efca04a7f00487d09d9 - md5: 89d61bc91d3f39fda0ca10fcd3c68594 + - openjpeg >=2.5.4,<3.0a0 + - lcms2 >=2.19.1,<3.0a0 + - libxcb >=1.17.0,<2.0a0 + - libfreetype >=2.14.3 + - libfreetype6 >=2.14.3 + - tk >=8.6.13,<8.7.0a0 + - libjpeg-turbo >=3.1.4.1,<4.0a0 + - libwebp-base >=1.6.0,<2.0a0 + - python_abi 3.11.* *_cp311 + - libtiff >=4.7.1,<4.8.0a0 + - zlib-ng >=2.3.3,<2.4.0a0 + license: HPND + purls: + - pkg:pypi/pillow?source=hash-mapping + size: 1081155 + timestamp: 1782912080163 +- conda: https://prefix.dev/conda-forge/linux-64/pixman-0.46.4-h54a6638_1.conda + sha256: 43d37bc9ca3b257c5dd7bf76a8426addbdec381f6786ff441dc90b1a49143b6a + md5: c01af13bdc553d1a8fbfff6e8db075f0 depends: - - __glibc >=2.17,<3.0.a0 - libgcc >=14 - - libgfortran - - libgfortran5 >=14.3.0 - constrains: - - openblas >=0.3.32,<0.3.33.0a0 - license: BSD-3-Clause - license_family: BSD - purls: [] - size: 5928890 - timestamp: 1774471724897 -- conda: https://prefix.dev/conda-forge/osx-arm64/libopenblas-0.3.32-openmp_he657e61_0.conda - sha256: 713e453bde3531c22a660577e59bf91ef578dcdfd5edb1253a399fa23514949a - md5: 3a1111a4b6626abebe8b978bb5a323bf - depends: - - __osx >=11.0 - - libgfortran - - libgfortran5 >=14.3.0 - - llvm-openmp >=19.1.7 - constrains: - - openblas >=0.3.32,<0.3.33.0a0 - license: BSD-3-Clause - license_family: BSD + - libstdcxx >=14 + - libgcc >=14 + - __glibc >=2.17,<3.0.a0 + license: MIT + license_family: MIT purls: [] - size: 4308797 - timestamp: 1774472508546 -- conda: https://prefix.dev/conda-forge/linux-64/libopengl-1.7.0-ha4b6fd6_2.conda - sha256: 215086c108d80349e96051ad14131b751d17af3ed2cb5a34edd62fa89bfe8ead - md5: 7df50d44d4a14d6c31a2c54f2cd92157 + size: 450960 + timestamp: 1754665235234 +- conda: https://prefix.dev/conda-forge/linux-64/portaudio-19.7.0-hf4617a5_0.conda + sha256: 3259d2bf63d0c889c516511c8fa73214791ca30baeeee0962eee8b97d17cd1c6 + md5: 053455c094c711e9aa77cf5023cf2bc3 depends: - __glibc >=2.17,<3.0.a0 - - libglvnd 1.7.0 ha4b6fd6_2 - license: LicenseRef-libglvnd + - alsa-lib >=1.2.12,<1.3.0a0 + - libgcc >=13 + - libstdcxx >=13 + license: MIT + license_family: MIT purls: [] - size: 50757 - timestamp: 1731330993524 -- conda: https://prefix.dev/conda-forge/linux-64/libopus-1.6.1-h280c20c_0.conda - sha256: f1061a26213b9653bbb8372bfa3f291787ca091a9a3060a10df4d5297aad74fd - md5: 2446ac1fe030c2aa6141386c1f5a6aed + size: 77342 + timestamp: 1730364040048 +- conda: https://prefix.dev/conda-forge/linux-64/portmidi-2.0.8-h3cb78e3_0.conda + sha256: 13b1f300f609d386d7aec2e31c4ab2fd35c0ed6a2b28ec89605db5b4b044514b + md5: 2333d6737b6fd5c6a70977f8ec1bf110 depends: - __glibc >=2.17,<3.0.a0 + - alsa-lib >=1.2.14,<1.3.0a0 - libgcc >=14 - license: BSD-3-Clause - license_family: BSD + - libstdcxx >=14 + license: MIT + license_family: MIT purls: [] - size: 324993 - timestamp: 1768497114401 -- conda: https://prefix.dev/conda-forge/osx-arm64/libopus-1.6.1-h1a92334_0.conda - sha256: 5c95a5f7712f543c59083e62fc3a95efec8b7f3773fbf4542ad1fb87fbf51ff4 - md5: 7f414dd3fd1cb7a76e51fec074a9c49e + size: 44178 + timestamp: 1764706159843 +- conda: https://prefix.dev/conda-forge/linux-64/protobuf-3.20.2-py311ha362b79_1.conda + sha256: b5927c5e5d3d2bee29e87cfee3e45781e6f6fd663e890389726cd513ef746177 + md5: 9d64275197aab7121cd9318b593a21bd depends: - - __osx >=11.0 + - libgcc-ng >=12 + - libprotobuf 3.20.2.* + - libprotobuf >=3.20.2,<3.21.0a0 + - libstdcxx-ng >=12 + - python >=3.11,<3.12.0a0 + - python_abi 3.11.* *_cp311 + - setuptools + - six license: BSD-3-Clause license_family: BSD - purls: [] - size: 308000 - timestamp: 1768497248058 -- conda: https://prefix.dev/conda-forge/linux-64/libpciaccess-0.18-hb9d3cd8_0.conda - sha256: 0bd91de9b447a2991e666f284ae8c722ffb1d84acb594dbd0c031bd656fa32b2 - md5: 70e3400cbbfa03e96dcde7fc13e38c7b + purls: + - pkg:pypi/protobuf?source=hash-mapping + size: 368989 + timestamp: 1669119100095 +- conda: https://prefix.dev/conda-forge/linux-64/pthread-stubs-0.4-hb9d3cd8_1002.conda + sha256: 9c88f8c64590e9567c6c80823f0328e58d3b1efb0e1c539c0315ceca764e0973 + md5: b3c17d95b5a10c6e64a21fa17573e70e depends: - __glibc >=2.17,<3.0.a0 - libgcc >=13 license: MIT license_family: MIT purls: [] - size: 28424 - timestamp: 1749901812541 -- conda: https://prefix.dev/conda-forge/linux-64/libpng-1.6.58-h421ea60_0.conda - sha256: 377cfe037f3eeb3b1bf3ad333f724a64d32f315ee1958581fc671891d63d3f89 - md5: eba48a68a1a2b9d3c0d9511548db85db + size: 8252 + timestamp: 1726802366959 +- conda: https://prefix.dev/conda-forge/linux-64/pulseaudio-client-17.0-h9a6aba3_3.conda + sha256: 0a0858c59805d627d02bdceee965dd84fde0aceab03a2f984325eec08d822096 + md5: b8ea447fdf62e3597cb8d2fae4eb1a90 depends: - __glibc >=2.17,<3.0.a0 + - dbus >=1.16.2,<2.0a0 - libgcc >=14 - - libzlib >=1.3.2,<2.0a0 - license: zlib-acknowledgement - purls: [] - size: 317729 - timestamp: 1776315175087 -- conda: https://prefix.dev/conda-forge/osx-arm64/libpng-1.6.58-h132b30e_0.conda - sha256: 66eae34546df1f098a67064970c92aa14ae7a7505091889e00468294d2882c36 - md5: 2259ae0949dbe20c0665850365109b27 - depends: - - __osx >=11.0 - - libzlib >=1.3.2,<2.0a0 - license: zlib-acknowledgement + - libglib >=2.86.1,<3.0a0 + - libiconv >=1.18,<2.0a0 + - libsndfile >=1.2.2,<1.3.0a0 + - libsystemd0 >=257.10 + - libxcb >=1.17.0,<2.0a0 + constrains: + - pulseaudio 17.0 *_3 + license: LGPL-2.1-or-later + license_family: LGPL purls: [] - size: 289546 - timestamp: 1776315246750 -- conda: https://prefix.dev/conda-forge/linux-64/libpq-18.6-h9d76c99_0.conda - sha256: b1eb210c180fda9c445b11cba1286ec250ce2c2a85ccb0551a4ed5423df51e68 - md5: 72e019c04ed02a179da38c56965802d1 + size: 750785 + timestamp: 1763148198088 +- conda: https://prefix.dev/conda-forge/linux-64/pygame-2.6.1-py311h3209946_0.conda + sha256: f008b83bf960c59e2f6336b9f246e7c6c8ac5327e5a8b7574e7e152e681f1887 + md5: d79d066a1ee9b690f90c02aac432e9c7 depends: - __glibc >=2.17,<3.0.a0 - - icu >=78.3,<79.0a0 - - krb5 >=1.22.2,<1.23.0a0 - - libgcc >=15 - - openldap >=2.6.13,<2.7.0a0 - - openssl >=3.5.7,<4.0a0 - license: PostgreSQL - purls: [] - size: 2719680 - timestamp: 1786641133110 -- conda: https://prefix.dev/conda-forge/linux-64/libprotobuf-3.20.2-h6239696_0.tar.bz2 - sha256: 158899bc39d00dc79e9b3fe8e39ed413a7ae266ddf69a7ff149be16859c24149 - md5: dd9c398d02aa82219a4ea5fa69739ae7 + - fontconfig >=2.14.2,<3.0a0 + - fonts-conda-ecosystem + - freetype >=2.12.1,<3.0a0 + - libgcc >=13 + - libjpeg-turbo >=3.0.0,<4.0a0 + - libpng >=1.6.44,<1.7.0a0 + - libstdcxx >=13 + - libzlib >=1.3.1,<2.0a0 + - portmidi >=2.0.4,<3.0a0 + - python >=3.11,<3.12.0a0 + - python_abi 3.11.* *_cp311 + - sdl2 >=2.30.7,<3.0a0 + - sdl2_image >=2.8.2,<3.0a0 + - sdl2_mixer >=2.6.3,<3.0a0 + - sdl2_ttf >=2.22.0,<3.0a0 + license: LGPL-2.1-only + purls: + - pkg:pypi/pygame?source=hash-mapping + size: 3068168 + timestamp: 1727636682074 +- conda: https://prefix.dev/conda-forge/linux-64/pyside6-6.11.1-py311hf27b23e_1.conda + sha256: 3cd4963051cffa6d96972cd8e42e6b224bbf385353e9a743940b4434fba176e6 + md5: dfd3d0af46ab4c53740abe6d6dbdd403 depends: - - libgcc-ng >=12 - - libstdcxx-ng >=12 - - libzlib >=1.2.13,<2.0.0a0 - license: BSD-3-Clause - license_family: BSD - purls: [] - size: 2715070 - timestamp: 1668469845918 -- conda: https://prefix.dev/conda-forge/osx-arm64/libprotobuf-3.20.2-hb5ab8b9_0.tar.bz2 - sha256: a47188a95c95cb131f9903014e18b7868ab9b445da629f7d3a9d53d9aa8caa2c - md5: a6f25546f30d4cd56bc37b0b56ab954c + - python + - qt6-main 6.11.1.* + - libstdcxx >=14 + - libgcc >=14 + - __glibc >=2.17,<3.0.a0 + - libegl >=1.7.0,<2.0a0 + - libopengl >=1.7.0,<2.0a0 + - libvulkan-loader >=1.4.341.0,<2.0a0 + - libgl >=1.7.0,<2.0a0 + - python_abi 3.11.* *_cp311 + - libxslt >=1.1.43,<2.0a0 + - libxml2 + - libxml2-16 >=2.14.6 + - libclang13 >=22.1.5 + - qt6-main >=6.11.1,<6.12.0a0 + license: LGPL-3.0-only + license_family: LGPL + purls: + - pkg:pypi/pyside6?source=hash-mapping + - pkg:pypi/shiboken6?source=hash-mapping + size: 13815486 + timestamp: 1778933870587 +- conda: https://prefix.dev/conda-forge/linux-64/python-3.10.20-h3c07f61_0_cpython.conda + sha256: 8ff2ce308faf2588b69c65b120293f59a8f2577b772b34df4e817d220b09e081 + md5: 5d4e2b00d99feacd026859b7fa239dc0 depends: - - libcxx >=14.0.6 - - libzlib >=1.2.13,<2.0.0a0 - license: BSD-3-Clause - license_family: BSD + - __glibc >=2.17,<3.0.a0 + - bzip2 >=1.0.8,<2.0a0 + - ld_impl_linux-64 >=2.36.1 + - libexpat >=2.7.4,<3.0a0 + - libffi >=3.4,<4.0a0 + - libgcc >=14 + - liblzma >=5.8.2,<6.0a0 + - libnsl >=2.0.1,<2.1.0a0 + - libsqlite >=3.51.2,<4.0a0 + - libuuid >=2.41.3,<3.0a0 + - libxcrypt >=4.4.36 + - libzlib >=1.3.1,<2.0a0 + - ncurses >=6.5,<7.0a0 + - openssl >=3.5.5,<4.0a0 + - readline >=8.3,<9.0a0 + - tk >=8.6.13,<8.7.0a0 + - tzdata + constrains: + - python_abi 3.10.* *_cp310 + license: Python-2.0 purls: [] - size: 2281852 - timestamp: 1668470370774 -- conda: https://prefix.dev/conda-forge/linux-64/libraqm-0.11.0-h6406941_0.conda - sha256: ab3ccb9fd5816f76b18ee8974d359cd2605ca87d8ddef55369dc461b9986f95c - md5: 3ac89a48d224409739dbf6200e524373 + size: 25455342 + timestamp: 1772729810280 +- conda: https://prefix.dev/conda-forge/linux-64/python-3.11.15-hd63d673_0_cpython.conda + sha256: bf6a32c69889d38482436a786bea32276756cedf0e9805cc856ffd088e8d00f0 + md5: a5ebcefec0c12a333bcd6d7bf3bddc1f depends: + - __glibc >=2.17,<3.0.a0 + - bzip2 >=1.0.8,<2.0a0 + - ld_impl_linux-64 >=2.36.1 + - libexpat >=2.7.4,<3.0a0 + - libffi >=3.5.2,<3.6.0a0 - libgcc >=14 - - __glibc >=2.28,<3.0.a0 - - fribidi >=1.0.16,<2.0a0 - - libfreetype >=2.14.3 - - libfreetype6 >=2.14.3 - - libharfbuzz >=14.2.1 - license: MIT - license_family: MIT + - liblzma >=5.8.2,<6.0a0 + - libnsl >=2.0.1,<2.1.0a0 + - libsqlite >=3.51.2,<4.0a0 + - libuuid >=2.41.3,<3.0a0 + - libxcrypt >=4.4.36 + - libzlib >=1.3.1,<2.0a0 + - ncurses >=6.5,<7.0a0 + - openssl >=3.5.5,<4.0a0 + - readline >=8.3,<9.0a0 + - tk >=8.6.13,<8.7.0a0 + - tzdata + constrains: + - python_abi 3.11.* *_cp311 + license: Python-2.0 purls: [] - size: 33983 - timestamp: 1784850267262 -- conda: https://prefix.dev/conda-forge/osx-arm64/libraqm-0.11.0-h45af499_0.conda - sha256: b110f7f9b2cec61ea793c521950414e00cd64826e18aeb4ab40369acf05c0039 - md5: 46ea0eb4e71bffa35ab7070678bcb053 + size: 30949404 + timestamp: 1772730362552 +- conda: https://prefix.dev/conda-forge/linux-64/pyyaml-6.0.3-py311h3778330_1.conda + sha256: c9a6cd2c290d7c3d2b30ea34a0ccda30f770e8ddb2937871f2c404faf60d0050 + md5: a24add9a3bababee946f3bc1c829acfe depends: - - __osx >=11.0 - - libfreetype >=2.14.3 - - libfreetype6 >=2.14.3 - - libharfbuzz >=14.2.1 - - fribidi >=1.0.16,<2.0a0 + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + - python >=3.11,<3.12.0a0 + - python_abi 3.11.* *_cp311 + - yaml >=0.2.5,<0.3.0a0 license: MIT license_family: MIT + purls: + - pkg:pypi/pyyaml?source=hash-mapping + size: 206190 + timestamp: 1770223702917 +- conda: https://prefix.dev/conda-forge/linux-64/qhull-2020.2-h434a139_5.conda + sha256: 776363493bad83308ba30bcb88c2552632581b143e8ee25b1982c8c743e73abc + md5: 353823361b1d27eb3960efb076dfcaf6 + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc-ng >=12 + - libstdcxx-ng >=12 + license: LicenseRef-Qhull purls: [] - size: 31333 - timestamp: 1784850348342 -- conda: https://prefix.dev/conda-forge/linux-64/librsvg-2.60.2-h61e6d4b_0.conda - sha256: 38b3189cf246f7265e06917f32d046ac375117c88834d045efe73ec48ceacc59 - md5: d62da3d560992bfa2feb611d7be813b8 + size: 552937 + timestamp: 1720813982144 +- conda: https://prefix.dev/conda-forge/linux-64/qt6-main-6.11.1-pl5321h16c4a6b_0.conda + sha256: 787d9a8eb7bb993e4a543901b8edade35c1c8e75d67cadb65c56a8f9c38119a5 + md5: cdae26862f9e4c674b8443fd267f2401 depends: + - libxcb + - xcb-util + - xcb-util-wm + - xcb-util-keysyms + - xcb-util-image + - xcb-util-renderutil + - xcb-util-cursor + - libgl-devel + - libegl-devel - __glibc >=2.17,<3.0.a0 - - cairo >=1.18.4,<2.0a0 - - gdk-pixbuf >=2.44.5,<3.0a0 + - libstdcxx >=14 - libgcc >=14 - - libglib >=2.86.4,<3.0a0 + - libjpeg-turbo >=3.1.4.1,<4.0a0 + - alsa-lib >=1.2.15.3,<1.3.0a0 + - xcb-util-renderutil >=0.3.10,<0.4.0a0 + - xorg-libxcursor >=1.2.3,<2.0a0 + - double-conversion >=3.4.0,<3.5.0a0 + - dbus >=1.16.2,<2.0a0 + - libglib >=2.88.1,<3.0a0 + - libsqlite >=3.53.1,<4.0a0 + - xorg-libx11 >=1.8.13,<2.0a0 + - krb5 >=1.22.2,<1.23.0a0 + - libdrm >=2.4.125,<2.5.0a0 + - xorg-libxext >=1.3.7,<2.0a0 + - libwebp-base >=1.6.0,<2.0a0 + - harfbuzz >=14.2.0 + - xorg-libice >=1.1.2,<2.0a0 + - xorg-libxdamage >=1.1.6,<2.0a0 + - libbrotlicommon >=1.2.0,<1.3.0a0 + - libbrotlienc >=1.2.0,<1.3.0a0 + - libbrotlidec >=1.2.0,<1.3.0a0 + - xorg-libxrandr >=1.5.5,<2.0a0 + - xcb-util-image >=0.4.0,<0.5.0a0 + - libfreetype >=2.14.3 + - libfreetype6 >=2.14.3 + - xorg-libxcomposite >=0.4.7,<1.0a0 + - openssl >=3.5.6,<4.0a0 + - xcb-util-cursor >=0.1.6,<0.2.0a0 + - libvulkan-loader >=1.4.341.0,<2.0a0 + - pcre2 >=10.47,<10.48.0a0 + - xorg-libxxf86vm >=1.1.7,<2.0a0 + - icu >=78.3,<79.0a0 + - libxcb >=1.17.0,<2.0a0 + - wayland >=1.25.0,<2.0a0 + - xorg-libsm >=1.2.6,<2.0a0 + - libtiff >=4.7.1,<4.8.0a0 + - libpq >=18.3,<19.0a0 + - libegl >=1.7.0,<2.0a0 + - xcb-util-wm >=0.4.2,<0.5.0a0 + - xcb-util-keysyms >=0.4.1,<0.5.0a0 + - libxkbcommon >=1.13.1,<2.0a0 + - zstd >=1.5.7,<1.6.0a0 + - fontconfig >=2.17.1,<3.0a0 + - fonts-conda-ecosystem + - xorg-libxtst >=1.2.5,<2.0a0 + - libxml2 - libxml2-16 >=2.14.6 - - pango >=1.56.4,<2.0a0 + - libzlib >=1.3.2,<2.0a0 + - libpng >=1.6.58,<1.7.0a0 + - libcups >=2.3.3,<2.4.0a0 + - libgl >=1.7.0,<2.0a0 + - xcb-util >=0.4.1,<0.5.0a0 constrains: - - __glibc >=2.17 - license: LGPL-2.1-or-later + - qt ==6.11.1 + license: LGPL-3.0-only + license_family: LGPL purls: [] - size: 4011590 - timestamp: 1771399906142 -- conda: https://prefix.dev/conda-forge/osx-arm64/librsvg-2.60.0-h9001022_1.conda - sha256: 9ba1531b46c75313736e2ef8ba1a4d3ef7d3ffd22efe8d593bfa99da7143a1cb - md5: b6c81d5b3324b9ff9fe8f39d25d8be66 + size: 60185269 + timestamp: 1778597122245 +- conda: https://prefix.dev/conda-forge/linux-64/rav1e-0.8.1-h1fbca29_0.conda + sha256: cf550bbc8e5ebedb6dba9ccaead3e07bd1cb86b183644a4c853e06e4b3ad5ac7 + md5: d83958768626b3c8471ce032e28afcd3 depends: - - __osx >=11.0 - - cairo >=1.18.4,<2.0a0 - - gdk-pixbuf >=2.44.5,<3.0a0 - - libglib >=2.86.4,<3.0a0 - - libxml2-16 >=2.14.6 - - pango >=1.56.4,<2.0a0 + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 constrains: - - __osx >=11.0 - license: LGPL-2.1-or-later + - __glibc >=2.17 + license: BSD-2-Clause + license_family: BSD purls: [] - size: 2357137 - timestamp: 1771302195666 -- conda: https://prefix.dev/conda-forge/linux-64/libsndfile-1.2.2-hc7d488a_2.conda - sha256: 57cb5f92110324c04498b96563211a1bca6a74b2918b1e8df578bfed03cc32e4 - md5: 067590f061c9f6ea7e61e3b2112ed6b3 + size: 5595970 + timestamp: 1772540833621 +- conda: https://prefix.dev/conda-forge/linux-64/readline-8.3-h853b02a_0.conda + sha256: 12ffde5a6f958e285aa22c191ca01bbd3d6e710aa852e00618fa6ddc59149002 + md5: d7d95fc8287ea7bf33e0e7116d2b95ec depends: - __glibc >=2.17,<3.0.a0 - - lame >=3.100,<3.101.0a0 - - libflac >=1.5.0,<1.6.0a0 - libgcc >=14 - - libogg >=1.3.5,<1.4.0a0 - - libopus >=1.5.2,<2.0a0 - - libstdcxx >=14 - - libvorbis >=1.3.7,<1.4.0a0 - - mpg123 >=1.32.9,<1.33.0a0 - license: LGPL-2.1-or-later - license_family: LGPL + - ncurses >=6.5,<7.0a0 + license: GPL-3.0-only + license_family: GPL purls: [] - size: 355619 - timestamp: 1765181778282 -- conda: https://prefix.dev/conda-forge/osx-arm64/libsndfile-1.2.2-hf95f74e_2.conda - sha256: f549aafe57439ca7c362884968f24fcc35a26e4e1eb66bb6985aa9e553c25521 - md5: 27e1a5a9249833f98a739249c7d1518b + size: 345073 + timestamp: 1765813471974 +- conda: https://prefix.dev/conda-forge/linux-64/rhash-1.4.3-hd590300_2.conda + sha256: 475f68cac8981ff2b10c56e53c2f376fc3c805fbc7ec30d22f870cd88f1479ba + md5: 4cabe3858a856bff08d9a0992e413084 depends: - - __osx >=11.0 - - lame >=3.100,<3.101.0a0 - - libcxx >=19 - - libflac >=1.5.0,<1.6.0a0 - - libogg >=1.3.5,<1.4.0a0 - - libopus >=1.5.2,<2.0a0 - - libvorbis >=1.3.7,<1.4.0a0 - - mpg123 >=1.32.9,<1.33.0a0 - license: LGPL-2.1-or-later - license_family: LGPL + - libgcc-ng >=12 + license: MIT + license_family: MIT purls: [] - size: 321233 - timestamp: 1765182495193 -- conda: https://prefix.dev/conda-forge/linux-64/libsqlite-3.53.1-h0c1763c_0.conda - sha256: 54cdcd3214313b62c2a8ee277e6f42150d9b748264c1b70d958bf735e420ef8d - md5: 7dc38adcbf71e6b38748e919e16e0dce + size: 184509 + timestamp: 1693427593121 +- conda: https://prefix.dev/conda-forge/linux-64/ruff-0.15.12-h994f30f_0.conda + noarch: python + sha256: 98c771464ed93a2733bae460c39cfa9640feb20972d2e651b44e85db296942eb + md5: 3c8f229055ad244fa3a97c6c45b77099 depends: - - __glibc >=2.17,<3.0.a0 + - python - libgcc >=14 - - libzlib >=1.3.2,<2.0a0 - license: blessing - purls: [] - size: 954962 - timestamp: 1777986471789 -- conda: https://prefix.dev/conda-forge/osx-arm64/libsqlite-3.53.1-h1b79a29_0.conda - sha256: 49daec7c83e70d4efc17b813547824bc2bcf2f7256d84061d24fbfe537da9f74 - md5: 6681822ea9d362953206352371b6a904 - depends: - - __osx >=11.0 - - libzlib >=1.3.2,<2.0a0 - license: blessing - purls: [] - size: 920047 - timestamp: 1777987051643 -- conda: https://prefix.dev/conda-forge/linux-64/libssh2-1.11.1-hcf80075_0.conda - sha256: fa39bfd69228a13e553bd24601332b7cfeb30ca11a3ca50bb028108fe90a7661 - md5: eecce068c7e4eddeb169591baac20ac4 - depends: - __glibc >=2.17,<3.0.a0 - - libgcc >=13 - - libzlib >=1.3.1,<2.0a0 - - openssl >=3.5.0,<4.0a0 - license: BSD-3-Clause - license_family: BSD - purls: [] - size: 304790 - timestamp: 1745608545575 -- conda: https://prefix.dev/conda-forge/osx-arm64/libssh2-1.11.1-h1590b86_0.conda - sha256: 8bfe837221390ffc6f111ecca24fa12d4a6325da0c8d131333d63d6c37f27e0a - md5: b68e8f66b94b44aaa8de4583d3d4cc40 + constrains: + - __glibc >=2.17 + license: MIT + license_family: MIT + purls: + - pkg:pypi/ruff?source=hash-mapping + size: 9266480 + timestamp: 1778119386343 +- conda: https://prefix.dev/conda-forge/linux-64/scipy-1.17.1-py311hbe70eeb_0.conda + sha256: 0063a75e9406357ef8ecc2fb38808a2442b269bfc5a854cf2bcd368060d9a2d7 + md5: 5ae6d73ab0bebbc892c2d46dc51e90a5 depends: - - libzlib >=1.3.1,<2.0a0 - - openssl >=3.5.0,<4.0a0 + - __glibc >=2.17,<3.0.a0 + - libblas >=3.9.0,<4.0a0 + - libcblas >=3.9.0,<4.0a0 + - libgcc >=14 + - libgfortran + - libgfortran5 >=14.3.0 + - liblapack >=3.9.0,<4.0a0 + - libstdcxx >=14 + - numpy <2.7 + - numpy >=1.23,<3 + - numpy >=1.25.2 + - python >=3.11,<3.12.0a0 + - python_abi 3.11.* *_cp311 license: BSD-3-Clause license_family: BSD - purls: [] - size: 279193 - timestamp: 1745608793272 -- conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-15.2.0-h934c35e_19.conda - sha256: dff1058c76ec6b8759e41cefa2508162d00e4a5e6721aa68ec3fd10094e702dc - md5: 5794b3bdc38177caf969dabd3af08549 + purls: + - pkg:pypi/scipy?source=hash-mapping + size: 17099824 + timestamp: 1771880736635 +- conda: https://prefix.dev/conda-forge/linux-64/sdl2-2.32.56-h54a6638_0.conda + sha256: 987ad072939fdd51c92ea8d3544b286bb240aefda329f9b03a51d9b7e777f9de + md5: cdd138897d94dc07d99afe7113a07bec depends: + - libstdcxx >=14 + - libgcc >=14 - __glibc >=2.17,<3.0.a0 - - libgcc 15.2.0 he0feb66_19 - constrains: - - libstdcxx-ng ==15.2.0=*_19 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL + - libgl >=1.7.0,<2.0a0 + - sdl3 >=3.2.22,<4.0a0 + - libegl >=1.7.0,<2.0a0 + license: Zlib purls: [] - size: 5852044 - timestamp: 1778269036376 -- conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-ng-15.2.0-hdf11a46_19.conda - sha256: 0672b6b6e1791c92e8eccad58081a99d614fcf82bca5841f9dfa3c3e658f83b9 - md5: e5ce228e579726c07255dbf90dc62101 + size: 589145 + timestamp: 1757842881000 +- conda: https://prefix.dev/conda-forge/linux-64/sdl2_image-2.8.2-h06ee604_1.conda + sha256: f18184e016e2e57306d1540dea584d38f4617d7ddb6aad4af6b5f21c52fa39ea + md5: 65e113270b460dcdfc4dc0a80bb3d11c depends: - - libstdcxx 15.2.0 h934c35e_19 - license: GPL-3.0-only WITH GCC-exception-3.1 - license_family: GPL + - libavif16 >=1.0.4,<2.0a0 + - libgcc-ng >=12 + - libjpeg-turbo >=3.0.0,<4.0a0 + - libpng >=1.6.43,<1.7.0a0 + - libstdcxx-ng >=12 + - libtiff >=4.6.0,<4.8.0a0 + - libwebp-base >=1.4.0,<2.0a0 + - libzlib >=1.2.13,<2.0.0a0 + - sdl2 >=2.30.2,<3.0a0 + license: Zlib purls: [] - size: 27776 - timestamp: 1778269074600 -- conda: https://prefix.dev/conda-forge/linux-64/libsystemd0-257.13-hd0affe5_0.conda - sha256: c5008b602cb5c819f7b52d418b3ed17e1818cbbf6705b189e7ab36bb70cce3d8 - md5: 8ee3cb7f64be0e8c4787f3a4dbe024e6 + size: 152110 + timestamp: 1716857107234 +- conda: https://prefix.dev/conda-forge/linux-64/sdl2_mixer-2.6.3-hb8bcbd3_2.conda + sha256: 3a36f7d6349d132c571516514dc8cd771a705e93adef942c8eee38a09875d97a + md5: 97fbc8b1372f0000321d568c0e459e3c depends: - __glibc >=2.17,<3.0.a0 - - libcap >=2.77,<2.78.0a0 + - fluidsynth >=2.5.2,<2.6.0a0 + - libflac >=1.5.0,<1.6.0a0 - libgcc >=14 - license: LGPL-2.1-or-later + - libmad >=0.15.1b,<0.16.0a0 + - libogg >=1.3.5,<1.4.0a0 + - libstdcxx >=14 + - libvorbis >=1.3.7,<1.4.0a0 + - mpg123 >=1.32.9,<1.33.0a0 + - opusfile >=0.12,<0.13.0a0 + - sdl2 >=2.32.56,<3.0a0 + license: Zlib purls: [] - size: 492799 - timestamp: 1773797095649 -- conda: https://prefix.dev/conda-forge/linux-64/libtiff-4.7.1-h9d88235_1.conda - sha256: e5f8c38625aa6d567809733ae04bb71c161a42e44a9fa8227abe61fa5c60ebe0 - md5: cd5a90476766d53e901500df9215e927 + size: 205164 + timestamp: 1766614707552 +- conda: https://prefix.dev/conda-forge/linux-64/sdl2_ttf-2.24.0-h287479f_0.conda + sha256: 431d19b666db6e7a4f09c37c43c83f115176a006b2ac321853ca26bee888c519 + md5: bccd5b74eb55a523dfcc66b857555714 depends: - __glibc >=2.17,<3.0.a0 - - lerc >=4.0.0,<5.0a0 - - libdeflate >=1.25,<1.26.0a0 - - libgcc >=14 - - libjpeg-turbo >=3.1.0,<4.0a0 - - liblzma >=5.8.1,<6.0a0 - - libstdcxx >=14 - - libwebp-base >=1.6.0,<2.0a0 + - freetype >=2.12.1,<3.0a0 + - harfbuzz >=10.1.0 + - libgcc >=13 - libzlib >=1.3.1,<2.0a0 - - zstd >=1.5.7,<1.6.0a0 - license: HPND + - sdl2 >=2.30.10,<3.0a0 + license: Zlib purls: [] - size: 435273 - timestamp: 1762022005702 -- conda: https://prefix.dev/conda-forge/osx-arm64/libtiff-4.7.1-h4030677_1.conda - sha256: e9248077b3fa63db94caca42c8dbc6949c6f32f94d1cafad127f9005d9b1507f - md5: e2a72ab2fa54ecb6abab2b26cde93500 + size: 61954 + timestamp: 1736117956977 +- conda: https://prefix.dev/conda-forge/linux-64/sdl3-3.4.8-hdeec2a5_0.conda + sha256: bec327fffc08369afe4c1384a5b50cac9b38e7af42ebdf5f89628633bd980dbd + md5: 508bad511e617479f0ad60cc49fba903 depends: - - __osx >=11.0 - - lerc >=4.0.0,<5.0a0 - - libcxx >=19 - - libdeflate >=1.25,<1.26.0a0 - - libjpeg-turbo >=3.1.0,<4.0a0 - - liblzma >=5.8.1,<6.0a0 - - libwebp-base >=1.6.0,<2.0a0 - - libzlib >=1.3.1,<2.0a0 - - zstd >=1.5.7,<1.6.0a0 - license: HPND + - libstdcxx >=14 + - libgcc >=14 + - __glibc >=2.17,<3.0.a0 + - pulseaudio-client >=17.0,<17.1.0a0 + - libgl >=1.7.0,<2.0a0 + - libunwind >=1.8.3,<1.9.0a0 + - xorg-libxtst >=1.2.5,<2.0a0 + - xorg-libxcursor >=1.2.3,<2.0a0 + - libegl >=1.7.0,<2.0a0 + - xorg-libxfixes >=6.0.2,<7.0a0 + - libudev1 >=257.13 + - xorg-libxext >=1.3.7,<2.0a0 + - libusb >=1.0.29,<2.0a0 + - wayland >=1.25.0,<2.0a0 + - xorg-libxi >=1.8.2,<2.0a0 + - libvulkan-loader >=1.4.341.0,<2.0a0 + - liburing >=2.14,<2.15.0a0 + - xorg-libxscrnsaver >=1.2.4,<2.0a0 + - dbus >=1.16.2,<2.0a0 + - libxkbcommon >=1.13.1,<2.0a0 + - libdrm >=2.4.125,<2.5.0a0 + - xorg-libx11 >=1.8.13,<2.0a0 + license: Zlib purls: [] - size: 373892 - timestamp: 1762022345545 -- conda: https://prefix.dev/conda-forge/linux-64/libudev1-257.13-hd0affe5_0.conda - sha256: 1a1e367c04d66030aa93b4d33905f7f6fbb59cfc292e816fe3e9c1e8b3f4d1e2 - md5: 2c2270f93d6f9073cbf72d821dfc7d72 + size: 2146080 + timestamp: 1777693555942 +- conda: https://prefix.dev/conda-forge/linux-64/secretstorage-3.4.1-py311h38be061_0.conda + sha256: 47f28b12e760ae3ce8a1e616c5b56f5e874e0e4a036bdd09516ebf263c19521f + md5: ec955e67147942a68469a46d0bdf0a7b + depends: + - cryptography >=2.0 + - dbus + - jeepney >=0.6 + - python >=3.11,<3.12.0a0 + - python_abi 3.11.* *_cp311 + license: BSD-3-Clause + license_family: BSD + purls: + - pkg:pypi/secretstorage?source=hash-mapping + size: 32968 + timestamp: 1763045430433 +- conda: https://prefix.dev/conda-forge/linux-64/svt-av1-4.0.1-hecca717_0.conda + sha256: 4a1d2005153b9454fc21c9bad1b539df189905be49e851ec62a6212c2e045381 + md5: 2a2170a3e5c9a354d09e4be718c43235 depends: - __glibc >=2.17,<3.0.a0 - - libcap >=2.77,<2.78.0a0 - libgcc >=14 - license: LGPL-2.1-or-later + - libstdcxx >=14 + license: BSD-2-Clause + license_family: BSD purls: [] - size: 145087 - timestamp: 1773797108513 -- conda: https://prefix.dev/conda-forge/linux-64/libunwind-1.8.3-h65a8314_0.conda - sha256: 71c8b9d5c72473752a0bb6e91b01dd209a03916cb71f36cc6a564e3a2a132d7a - md5: e179a69edd30d75c0144d7a380b88f28 + size: 2619743 + timestamp: 1769664536467 +- conda: https://prefix.dev/conda-forge/linux-64/tk-8.6.13-noxft_h366c992_103.conda + sha256: cafeec44494f842ffeca27e9c8b0c27ed714f93ac77ddadc6aaf726b5554ebac + md5: cffd3bdd58090148f4cfcd831f4b26ab depends: - __glibc >=2.17,<3.0.a0 - libgcc >=14 - - libstdcxx >=14 - license: MIT - license_family: MIT - purls: [] - size: 75995 - timestamp: 1757032240102 -- conda: https://prefix.dev/conda-forge/linux-64/liburing-2.14-hb700be7_0.conda - sha256: 3d17b7aa90610afc65356e9e6149aeac0b2df19deda73a51f0a09cf04fd89286 - md5: 56f65185b520e016d29d01657ac02c0d + - libzlib >=1.3.1,<2.0a0 + constrains: + - xorg-libx11 >=1.8.12,<2.0a0 + license: TCL + license_family: BSD + purls: [] + size: 3301196 + timestamp: 1769460227866 +- conda: https://prefix.dev/conda-forge/linux-64/tornado-6.5.5-py311h49ec1c0_0.conda + sha256: cd8bc08ca661291cfbb05581b79f7e6a6971a072a54a335abcea5460c1230880 + md5: 73b44a114241e564deb5846e7394bf19 + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + - python >=3.11,<3.12.0a0 + - python_abi 3.11.* *_cp311 + license: Apache-2.0 + license_family: Apache + purls: + - pkg:pypi/tornado?source=hash-mapping + size: 876817 + timestamp: 1774358035290 +- conda: https://prefix.dev/conda-forge/linux-64/ukkonen-1.1.0-py311hdf67eae_0.conda + sha256: 31ad759e2d7668f1615021bca0ae2358a284939e3ca3fcb971b3f7aa83c2a6d6 + md5: 5a715cf5e3dc6cd68717c50e47dd7b6b depends: - __glibc >=2.17,<3.0.a0 + - cffi - libgcc >=14 - libstdcxx >=14 + - python >=3.11,<3.12.0a0 + - python_abi 3.11.* *_cp311 license: MIT license_family: MIT - purls: [] - size: 154203 - timestamp: 1770566529700 -- conda: https://prefix.dev/conda-forge/linux-64/libusb-1.0.29-h73b1eb8_0.conda - sha256: 89c84f5b26028a9d0f5c4014330703e7dff73ba0c98f90103e9cef6b43a5323c - md5: d17e3fb595a9f24fa9e149239a33475d + purls: + - pkg:pypi/ukkonen?source=hash-mapping + size: 14898 + timestamp: 1769438724694 +- conda: https://prefix.dev/conda-forge/linux-64/unicodedata2-17.0.1-py311h49ec1c0_0.conda + sha256: 2bd8ee058dc98e614003591eb221a8b08449768b13aebe76dad8528bf0f5f88b + md5: 2889f0c0b6a6d7a37bd64ec60f4cc210 depends: - __glibc >=2.17,<3.0.a0 - - libgcc >=13 - - libudev1 >=257.4 - license: LGPL-2.1-or-later - purls: [] - size: 89551 - timestamp: 1748856210075 -- conda: https://prefix.dev/conda-forge/osx-arm64/libusb-1.0.29-hbc156a2_0.conda - sha256: 5eee9a2bf359e474d4548874bcfc8d29ebad0d9ba015314439c256904e40aaad - md5: f6654e9e96e9d973981b3b2f898a5bfa - depends: - - __osx >=11.0 - license: LGPL-2.1-or-later - purls: [] - size: 83849 - timestamp: 1748856224950 -- conda: https://prefix.dev/conda-forge/linux-64/libuuid-2.42-h5347b49_0.conda - sha256: bc1b08c92626c91500fd9f26f2c797f3eb153b627d53e9c13cd167f1e12b2829 - md5: 38ffe67b78c9d4de527be8315e5ada2c + - libgcc >=14 + - python >=3.11,<3.12.0a0 + - python_abi 3.11.* *_cp311 + license: Apache-2.0 + license_family: Apache + purls: + - pkg:pypi/unicodedata2?source=hash-mapping + size: 409682 + timestamp: 1770909108616 +- conda: https://prefix.dev/conda-forge/linux-64/uv-0.11.12-h29f5ae7_0.conda + sha256: 4fc1481bb6ecf5a1a755661483eb99a0ec2054cd02e5893b55f9c80bac9437a8 + md5: e86a95851fd53465f0657c068cb6c403 depends: - - __glibc >=2.17,<3.0.a0 - libgcc >=14 - license: BSD-3-Clause - license_family: BSD + - __glibc >=2.17,<3.0.a0 + - libstdcxx >=14 + constrains: + - __glibc >=2.17 + license: Apache-2.0 OR MIT purls: [] - size: 40297 - timestamp: 1775052476770 -- conda: https://prefix.dev/conda-forge/linux-64/libuv-1.51.0-hb03c661_1.conda - sha256: c180f4124a889ac343fc59d15558e93667d894a966ec6fdb61da1604481be26b - md5: 0f03292cc56bf91a077a134ea8747118 + size: 19190543 + timestamp: 1778287747008 +- conda: https://prefix.dev/conda-forge/linux-64/wayland-1.25.0-hd6090a7_0.conda + sha256: ea374d57a8fcda281a0a89af0ee49a2c2e99cc4ac97cf2e2db7064e74e764bdb + md5: 996583ea9c796e5b915f7d7580b51ea6 depends: - __glibc >=2.17,<3.0.a0 + - libexpat >=2.7.4,<3.0a0 + - libffi >=3.5.2,<3.6.0a0 - libgcc >=14 + - libstdcxx >=14 license: MIT license_family: MIT purls: [] - size: 895108 - timestamp: 1753948278280 -- conda: https://prefix.dev/conda-forge/osx-arm64/libuv-1.51.0-h6caf38d_1.conda - sha256: 042c7488ad97a5629ec0a991a8b2a3345599401ecc75ad6a5af73b60e6db9689 - md5: c0d87c3c8e075daf1daf6c31b53e8083 + size: 334139 + timestamp: 1773959575393 +- conda: https://prefix.dev/conda-forge/linux-64/xcb-util-0.4.1-h4f16b4b_2.conda + sha256: ad8cab7e07e2af268449c2ce855cbb51f43f4664936eff679b1f3862e6e4b01d + md5: fdc27cb255a7a2cc73b7919a968b48f0 depends: - - __osx >=11.0 + - __glibc >=2.17,<3.0.a0 + - libgcc >=13 + - libxcb >=1.17.0,<2.0a0 license: MIT license_family: MIT purls: [] - size: 421195 - timestamp: 1753948426421 -- conda: https://prefix.dev/conda-forge/linux-64/libvorbis-1.3.7-h54a6638_2.conda - sha256: ca494c99c7e5ecc1b4cd2f72b5584cef3d4ce631d23511184411abcbb90a21a5 - md5: b4ecbefe517ed0157c37f8182768271c + size: 20772 + timestamp: 1750436796633 +- conda: https://prefix.dev/conda-forge/linux-64/xcb-util-cursor-0.1.6-hb03c661_0.conda + sha256: c2be9cae786fdb2df7c2387d2db31b285cf90ab3bfabda8fa75a596c3d20fc67 + md5: 4d1fc190b99912ed557a8236e958c559 depends: - - libogg - - libgcc >=14 - __glibc >=2.17,<3.0.a0 - - libstdcxx >=14 - libgcc >=14 - - libogg >=1.3.5,<1.4.0a0 - license: BSD-3-Clause - license_family: BSD + - libxcb >=1.13 + - libxcb >=1.17.0,<2.0a0 + - xcb-util-image >=0.4.0,<0.5.0a0 + - xcb-util-renderutil >=0.3.10,<0.4.0a0 + license: MIT + license_family: MIT purls: [] - size: 285894 - timestamp: 1753879378005 -- conda: https://prefix.dev/conda-forge/osx-arm64/libvorbis-1.3.7-h81086ad_2.conda - sha256: 95768e4eceaffb973081fd986d03da15d93aa10609ed202e6fd5ca1e490a3dce - md5: 719e7653178a09f5ca0aa05f349b41f7 + size: 20829 + timestamp: 1763366954390 +- conda: https://prefix.dev/conda-forge/linux-64/xcb-util-image-0.4.0-hb711507_2.conda + sha256: 94b12ff8b30260d9de4fd7a28cca12e028e572cbc504fd42aa2646ec4a5bded7 + md5: a0901183f08b6c7107aab109733a3c91 depends: - - libogg - - libcxx >=19 - - __osx >=11.0 - - libogg >=1.3.5,<1.4.0a0 - license: BSD-3-Clause - license_family: BSD + - libgcc-ng >=12 + - libxcb >=1.16,<2.0.0a0 + - xcb-util >=0.4.1,<0.5.0a0 + license: MIT + license_family: MIT purls: [] - size: 259122 - timestamp: 1753879389702 -- conda: https://prefix.dev/conda-forge/linux-64/libvulkan-loader-1.4.341.0-h5279c79_0.conda - sha256: a68280d57dfd29e3d53400409a39d67c4b9515097eba733aa6fe00c880620e2b - md5: 31ad065eda3c2d88f8215b1289df9c89 + size: 24551 + timestamp: 1718880534789 +- conda: https://prefix.dev/conda-forge/linux-64/xcb-util-keysyms-0.4.1-hb711507_0.conda + sha256: 546e3ee01e95a4c884b6401284bb22da449a2f4daf508d038fdfa0712fe4cc69 + md5: ad748ccca349aec3e91743e08b5e2b50 depends: - - __glibc >=2.17,<3.0.a0 - - libstdcxx >=14 - - libgcc >=14 - - xorg-libx11 >=1.8.12,<2.0a0 - - xorg-libxrandr >=1.5.5,<2.0a0 - constrains: - - libvulkan-headers 1.4.341.0.* - license: Apache-2.0 - license_family: APACHE + - libgcc-ng >=12 + - libxcb >=1.16,<2.0.0a0 + license: MIT + license_family: MIT purls: [] - size: 199795 - timestamp: 1770077125520 -- conda: https://prefix.dev/conda-forge/osx-arm64/libvulkan-loader-1.4.341.0-h3feff0a_0.conda - sha256: d2790dafc9149b1acd45b9033d02cfa3f3e9ee5af97bd61e0a5718c414a0a135 - md5: 6b4c9a5b130759136a0dde0c373cb0ea + size: 14314 + timestamp: 1718846569232 +- conda: https://prefix.dev/conda-forge/linux-64/xcb-util-renderutil-0.3.10-hb711507_0.conda + sha256: 2d401dadc43855971ce008344a4b5bd804aca9487d8ebd83328592217daca3df + md5: 0e0cbe0564d03a99afd5fd7b362feecd depends: - - __osx >=11.0 - - libcxx >=19 - constrains: - - libvulkan-headers 1.4.341.0.* - license: Apache-2.0 - license_family: APACHE + - libgcc-ng >=12 + - libxcb >=1.16,<2.0.0a0 + license: MIT + license_family: MIT purls: [] - size: 180304 - timestamp: 1770077143460 -- conda: https://prefix.dev/conda-forge/linux-64/libwebp-base-1.6.0-hd42ef1d_0.conda - sha256: 3aed21ab28eddffdaf7f804f49be7a7d701e8f0e46c856d801270b470820a37b - md5: aea31d2e5b1091feca96fcfe945c3cf9 + size: 16978 + timestamp: 1718848865819 +- conda: https://prefix.dev/conda-forge/linux-64/xcb-util-wm-0.4.2-hb711507_0.conda + sha256: 31d44f297ad87a1e6510895740325a635dd204556aa7e079194a0034cdd7e66a + md5: 608e0ef8256b81d04456e8d211eee3e8 depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - constrains: - - libwebp 1.6.0 - license: BSD-3-Clause - license_family: BSD + - libgcc-ng >=12 + - libxcb >=1.16,<2.0.0a0 + license: MIT + license_family: MIT purls: [] - size: 429011 - timestamp: 1752159441324 -- conda: https://prefix.dev/conda-forge/osx-arm64/libwebp-base-1.6.0-h07db88b_0.conda - sha256: a4de3f371bb7ada325e1f27a4ef7bcc81b2b6a330e46fac9c2f78ac0755ea3dd - md5: e5e7d467f80da752be17796b87fe6385 + size: 51689 + timestamp: 1718844051451 +- conda: https://prefix.dev/conda-forge/linux-64/xkeyboard-config-2.47-hb03c661_0.conda + sha256: 19c2bb14bec84b0e995b56b752369775c75f1589314b43733948bb5f471a6915 + md5: b56e0c8432b56decafae7e78c5f29ba5 depends: - - __osx >=11.0 - constrains: - - libwebp 1.6.0 - license: BSD-3-Clause - license_family: BSD + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + - xorg-libx11 >=1.8.13,<2.0a0 + license: MIT + license_family: MIT purls: [] - size: 294974 - timestamp: 1752159906788 -- conda: https://prefix.dev/conda-forge/linux-64/libxcb-1.17.0-h8a09558_0.conda - sha256: 666c0c431b23c6cec6e492840b176dde533d48b7e6fb8883f5071223433776aa - md5: 92ed62436b625154323d40d5f2f11dd7 + size: 399291 + timestamp: 1772021302485 +- conda: https://prefix.dev/conda-forge/linux-64/xorg-libice-1.1.2-hb9d3cd8_0.conda + sha256: c12396aabb21244c212e488bbdc4abcdef0b7404b15761d9329f5a4a39113c4b + md5: fb901ff28063514abb6046c9ec2c4a45 depends: - __glibc >=2.17,<3.0.a0 - libgcc >=13 - - pthread-stubs - - xorg-libxau >=1.0.11,<2.0a0 - - xorg-libxdmcp license: MIT license_family: MIT purls: [] - size: 395888 - timestamp: 1727278577118 -- conda: https://prefix.dev/conda-forge/osx-arm64/libxcb-1.17.0-hbffa61f_1.conda - sha256: 81f9b4fb64d977c19474d1b5616974757aaac21d55401ea105f21022b386bd28 - md5: 923bf656578743d064f352f0b56ee658 - depends: - - __osx >=11.0 - - pthread-stubs - - xorg-libxau >=1.0.12,<2.0a0 - - xorg-libxdmcp >=1.1.5,<2.0a0 + size: 58628 + timestamp: 1734227592886 +- conda: https://prefix.dev/conda-forge/linux-64/xorg-libsm-1.2.6-he73a12e_0.conda + sha256: 277841c43a39f738927145930ff963c5ce4c4dacf66637a3d95d802a64173250 + md5: 1c74ff8c35dcadf952a16f752ca5aa49 + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc >=13 + - libuuid >=2.38.1,<3.0a0 + - xorg-libice >=1.1.2,<2.0a0 license: MIT license_family: MIT purls: [] - size: 324264 - timestamp: 1787077544793 -- conda: https://prefix.dev/conda-forge/linux-64/libxcrypt-4.4.36-hd590300_1.conda - sha256: 6ae68e0b86423ef188196fff6207ed0c8195dd84273cb5623b85aa08033a410c - md5: 5aa797f8787fe7a17d1b0821485b5adc - depends: - - libgcc-ng >=12 - license: LGPL-2.1-or-later - purls: [] - size: 100393 - timestamp: 1702724383534 -- conda: https://prefix.dev/conda-forge/linux-64/libxkbcommon-1.13.1-hca5e8e5_0.conda - sha256: d2195b5fbcb0af1ff7b345efdf89290c279b8d1d74f325ae0ac98148c375863c - md5: 2bca1fbb221d9c3c8e3a155784bbc2e9 + size: 27590 + timestamp: 1741896361728 +- conda: https://prefix.dev/conda-forge/linux-64/xorg-libx11-1.8.13-he1eb515_0.conda + sha256: 516d4060139dbb4de49a4dcdc6317a9353fb39ebd47789c14e6fe52de0deee42 + md5: 861fb6ccbc677bb9a9fb2468430b9c6a depends: - __glibc >=2.17,<3.0.a0 - libgcc >=14 - - libstdcxx >=14 - libxcb >=1.17.0,<2.0a0 - - libxml2 - - libxml2-16 >=2.14.6 - - xkeyboard-config - - xorg-libxau >=1.0.12,<2.0a0 - license: MIT/X11 Derivative + license: MIT license_family: MIT purls: [] - size: 837922 - timestamp: 1764794163823 -- conda: https://prefix.dev/conda-forge/linux-64/libxml2-2.15.3-h49c6c72_0.conda - sha256: 3bc5551720c58591f6ea1146f7d1539c734ed1c40e7b9f5cb8cb7e900c509aba - md5: 995d8c8bad2a3cc8db14675a153dec2b + size: 839652 + timestamp: 1770819209719 +- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxau-1.0.12-hb03c661_1.conda + sha256: 6bc6ab7a90a5d8ac94c7e300cc10beb0500eeba4b99822768ca2f2ef356f731b + md5: b2895afaf55bf96a8c8282a2e47a5de0 depends: - __glibc >=2.17,<3.0.a0 - - icu >=78.3,<79.0a0 - libgcc >=14 - - libiconv >=1.18,<2.0a0 - - liblzma >=5.8.3,<6.0a0 - - libxml2-16 2.15.3 hca6bf5a_0 - - libzlib >=1.3.2,<2.0a0 license: MIT license_family: MIT purls: [] - size: 46810 - timestamp: 1776376751152 -- conda: https://prefix.dev/conda-forge/linux-64/libxml2-16-2.15.3-hca6bf5a_0.conda - sha256: 3d44f737c5ae52d5af32682cc1530df433f401f8e58a7533926536244127572a - md5: e79d2c2f24b027aa8d5ab1b1ba3061e7 + size: 15321 + timestamp: 1762976464266 +- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxcomposite-0.4.7-hb03c661_0.conda + sha256: 048c103000af9541c919deef03ae7c5e9c570ffb4024b42ecb58dbde402e373a + md5: f2ba4192d38b6cef2bb2c25029071d90 depends: - __glibc >=2.17,<3.0.a0 - - icu >=78.3,<79.0a0 - libgcc >=14 - - libiconv >=1.18,<2.0a0 - - liblzma >=5.8.3,<6.0a0 - - libzlib >=1.3.2,<2.0a0 - constrains: - - libxml2 2.15.3 + - xorg-libx11 >=1.8.12,<2.0a0 + - xorg-libxfixes >=6.0.2,<7.0a0 license: MIT license_family: MIT purls: [] - size: 559775 - timestamp: 1776376739004 -- conda: https://prefix.dev/conda-forge/osx-arm64/libxml2-16-2.15.3-h5ef1a60_0.conda - sha256: ff75b84cdb9e8d123db2fa694a8ac2c2059516b6cbc98ac21fb68e235d0fd354 - md5: 19edaa53885fc8205614b03da2482282 + size: 14415 + timestamp: 1770044404696 +- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxcursor-1.2.3-hb9d3cd8_0.conda + sha256: 832f538ade441b1eee863c8c91af9e69b356cd3e9e1350fff4fe36cc573fc91a + md5: 2ccd714aa2242315acaf0a67faea780b depends: - - __osx >=11.0 - - icu >=78.3,<79.0a0 - - libiconv >=1.18,<2.0a0 - - liblzma >=5.8.3,<6.0a0 - - libzlib >=1.3.2,<2.0a0 - constrains: - - libxml2 2.15.3 + - __glibc >=2.17,<3.0.a0 + - libgcc >=13 + - xorg-libx11 >=1.8.10,<2.0a0 + - xorg-libxfixes >=6.0.1,<7.0a0 + - xorg-libxrender >=0.9.11,<0.10.0a0 license: MIT license_family: MIT purls: [] - size: 466360 - timestamp: 1776377102261 -- conda: https://prefix.dev/conda-forge/linux-64/libxslt-1.1.43-h711ed8c_1.conda - sha256: 0694760a3e62bdc659d90a14ae9c6e132b525a7900e59785b18a08bb52a5d7e5 - md5: 87e6096ec6d542d1c1f8b33245fe8300 + size: 32533 + timestamp: 1730908305254 +- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxdamage-1.1.6-hb9d3cd8_0.conda + sha256: 43b9772fd6582bf401846642c4635c47a9b0e36ca08116b3ec3df36ab96e0ec0 + md5: b5fcc7172d22516e1f965490e65e33a4 depends: - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - libxml2 - - libxml2-16 >=2.14.6 + - libgcc >=13 + - xorg-libx11 >=1.8.10,<2.0a0 + - xorg-libxext >=1.3.6,<2.0a0 + - xorg-libxfixes >=6.0.1,<7.0a0 license: MIT license_family: MIT purls: [] - size: 245434 - timestamp: 1757963724977 -- conda: https://prefix.dev/conda-forge/linux-64/libzlib-1.3.2-h25fd6f3_2.conda - sha256: 55044c403570f0dc26e6364de4dc5368e5f3fc7ff103e867c487e2b5ab2bcda9 - md5: d87ff7921124eccd67248aa483c23fec + size: 13217 + timestamp: 1727891438799 +- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxdmcp-1.1.5-hb03c661_1.conda + sha256: 25d255fb2eef929d21ff660a0c687d38a6d2ccfbcbf0cc6aa738b12af6e9d142 + md5: 1dafce8548e38671bea82e3f5c6ce22f depends: - __glibc >=2.17,<3.0.a0 - constrains: - - zlib 1.3.2 *_2 - license: Zlib - license_family: Other - purls: [] - size: 63629 - timestamp: 1774072609062 -- conda: https://prefix.dev/conda-forge/osx-arm64/libzlib-1.3.2-h8088a28_2.conda - sha256: 361415a698514b19a852f5d1123c5da746d4642139904156ddfca7c922d23a05 - md5: bc5a5721b6439f2f62a84f2548136082 - depends: - - __osx >=11.0 - constrains: - - zlib 1.3.2 *_2 - license: Zlib - license_family: Other + - libgcc >=14 + license: MIT + license_family: MIT purls: [] - size: 47759 - timestamp: 1774072956767 -- conda: https://prefix.dev/conda-forge/osx-arm64/llvm-openmp-22.1.4-hc7d1edf_0.conda - sha256: a269273ccf48be6ac582bb958713ba8373262b9157a0fc76b7e5475e8a1d2a78 - md5: 46d04a647df7a4525e487d88068d19ef + size: 20591 + timestamp: 1762976546182 +- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxext-1.3.7-hb03c661_0.conda + sha256: 79c60fc6acfd3d713d6340d3b4e296836a0f8c51602327b32794625826bd052f + md5: 34e54f03dfea3e7a2dcf1453a85f1085 depends: - - __osx >=11.0 - constrains: - - openmp 22.1.4|22.1.4.* - - intel-openmp <0.0a0 - license: Apache-2.0 WITH LLVM-exception - license_family: APACHE + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + - xorg-libx11 >=1.8.12,<2.0a0 + license: MIT + license_family: MIT purls: [] - size: 286406 - timestamp: 1776846235007 -- conda: https://prefix.dev/conda-forge/linux-64/llvmlite-0.49.0-py311h1369f55_2.conda - sha256: bd4ddf72a6ee81991759d407d0cf8fadf9804500562839448a22c11f8e829f8e - md5: 7d4c6843f49e890b8f6fb813d7e94c1f + size: 50326 + timestamp: 1769445253162 +- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxfixes-6.0.2-hb03c661_0.conda + sha256: 83c4c99d60b8784a611351220452a0a85b080668188dce5dfa394b723d7b64f4 + md5: ba231da7fccf9ea1e768caf5c7099b84 depends: - - python - __glibc >=2.17,<3.0.a0 - - libstdcxx >=15 - - libgcc >=15 - - zstd >=1.5.7,<1.6.0a0 - - python_abi 3.11.* *_cp311 - - libzlib >=1.3.2,<2.0a0 - license: BSD-2-Clause - license_family: BSD - purls: - - pkg:pypi/llvmlite?source=hash-mapping - size: 40845513 - timestamp: 1788013791127 -- conda: https://prefix.dev/conda-forge/osx-arm64/llvmlite-0.49.0-py311h4a78e08_2.conda - sha256: 42f645cb34752835a9e9a39da5f383c5d5341727f37f3d96741ac035cc94d164 - md5: 16e87603b33bbbff99352220dee440a6 - depends: - - python - - __osx >=11.0 - - libcxx >=21 - - zstd >=1.5.7,<1.6.0a0 - - python_abi 3.11.* *_cp311 - - libzlib >=1.3.2,<2.0a0 - license: BSD-2-Clause - license_family: BSD - purls: - - pkg:pypi/llvmlite?source=hash-mapping - size: 30512158 - timestamp: 1788013780870 -- conda: https://prefix.dev/conda-forge/noarch/markdown-it-py-4.2.0-pyhd8ed1ab_0.conda - sha256: 0c4c35376fe920714390d46e4b8d31c876d65f18e1655899e0763ec25f2a902f - md5: 6d03368f2b2b0a5fb6839df53b2eb5e0 - depends: - - mdurl >=0.1,<1 - - python >=3.10 + - libgcc >=14 + - xorg-libx11 >=1.8.12,<2.0a0 license: MIT license_family: MIT - purls: - - pkg:pypi/markdown-it-py?source=hash-mapping - size: 69017 - timestamp: 1778169663339 -- conda: https://prefix.dev/conda-forge/linux-64/matplotlib-3.11.1-py311h968eb38_2.conda - sha256: b677501911fa682ea74a86472a003a2f8cbb046f8fb6bbc501521af6aea0744f - md5: 2cb7827f42621fe32c5161ad927ecaa7 - depends: - - matplotlib-base >=3.11.1,<3.11.2.0a0 - - pyside6 >=6.7.2 - - python >=3.11,<3.12.0a0 - - python_abi 3.11.* *_cp311 - - tornado >=5 - license: PSF-2.0 - license_family: PSF purls: [] - size: 14988 - timestamp: 1785211075423 -- conda: https://prefix.dev/conda-forge/osx-arm64/matplotlib-3.11.1-py311ha01d089_2.conda - sha256: 3e9381c800201853483185f7403d8ceb8f013d8a0dcda37c864a34e708158180 - md5: 7ce16f8bcf8a38405f1f09801e1bf832 + size: 20071 + timestamp: 1759282564045 +- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxi-1.8.2-hb9d3cd8_0.conda + sha256: 1a724b47d98d7880f26da40e45f01728e7638e6ec69f35a3e11f92acd05f9e7a + md5: 17dcc85db3c7886650b8908b183d6876 depends: - - matplotlib-base >=3.11.1,<3.11.2.0a0 - - python >=3.11,<3.12.0a0 - - python_abi 3.11.* *_cp311 - - tornado >=5 - license: PSF-2.0 - license_family: PSF + - __glibc >=2.17,<3.0.a0 + - libgcc >=13 + - xorg-libx11 >=1.8.10,<2.0a0 + - xorg-libxext >=1.3.6,<2.0a0 + - xorg-libxfixes >=6.0.1,<7.0a0 + license: MIT + license_family: MIT purls: [] - size: 14921 - timestamp: 1785211095125 -- conda: https://prefix.dev/conda-forge/linux-64/matplotlib-base-3.11.1-py311he401cf6_2.conda - sha256: f9f48162f2553080d041b061b9f6cfec64d79d7c40df0e6379496f9ad2df738c - md5: f602c096988d0f744f4f017aa0269e30 + size: 47179 + timestamp: 1727799254088 +- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxinerama-1.1.6-hecca717_0.conda + sha256: 3a9da41aac6dca9d3ff1b53ee18b9d314de88add76bafad9ca2287a494abcd86 + md5: 93f5d4b5c17c8540479ad65f206fea51 depends: - __glibc >=2.17,<3.0.a0 - - contourpy >=1.0.1 - - cycler >=0.10 - - fonttools >=4.28.2 - - freetype - - kiwisolver >=1.3.1 - - libfreetype >=2.14.3 - - libfreetype6 >=2.14.3 - libgcc >=14 - - libraqm >=0.11.0,<0.12.0a0 - libstdcxx >=14 - - numpy >=1.23,<3 - - numpy >=1.25 - - packaging >=20.0 - - pillow >=9 - - pyparsing >=3 - - python >=3.11,<3.12.0a0 - - python-dateutil >=2.7 - - python_abi 3.11.* *_cp311 - - qhull >=2020.2,<2020.3.0a0 - - tk >=8.6.13,<8.7.0a0 - license: PSF-2.0 - license_family: PSF - purls: - - pkg:pypi/matplotlib?source=hash-mapping - size: 8925010 - timestamp: 1785211062689 -- conda: https://prefix.dev/conda-forge/osx-arm64/matplotlib-base-3.11.1-py311h3c3ad35_2.conda - sha256: 09330e68ce42c7ed076a296b04ce3ea0cb10d72fb5c31b68bf1aa93ecf553a07 - md5: e0a2569461d3cc107301cce6835cf0ba + - xorg-libx11 >=1.8.12,<2.0a0 + - xorg-libxext >=1.3.6,<2.0a0 + license: MIT + license_family: MIT + purls: [] + size: 14818 + timestamp: 1769432261050 +- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxrandr-1.5.5-hb03c661_0.conda + sha256: 80ed047a5cb30632c3dc5804c7716131d767089f65877813d4ae855ee5c9d343 + md5: e192019153591938acf7322b6459d36e depends: - - __osx >=11.0 - - contourpy >=1.0.1 - - cycler >=0.10 - - fonttools >=4.28.2 - - freetype - - kiwisolver >=1.3.1 - - libcxx >=19 - - libfreetype >=2.14.3 - - libfreetype6 >=2.14.3 - - libraqm >=0.11.0,<0.12.0a0 - - numpy >=1.23,<3 - - numpy >=1.25 - - packaging >=20.0 - - pillow >=9 - - pyparsing >=3 - - python >=3.11,<3.12.0a0 - - python-dateutil >=2.7 - - python_abi 3.11.* *_cp311 - - qhull >=2020.2,<2020.3.0a0 - license: PSF-2.0 - license_family: PSF - purls: - - pkg:pypi/matplotlib?source=hash-mapping - size: 8811362 - timestamp: 1785211075697 -- conda: https://prefix.dev/conda-forge/noarch/mdurl-0.1.2-pyhd8ed1ab_1.conda - sha256: 78c1bbe1723449c52b7a9df1af2ee5f005209f67e40b6e1d3c7619127c43b1c7 - md5: 592132998493b3ff25fd7479396e8351 + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + - xorg-libx11 >=1.8.12,<2.0a0 + - xorg-libxext >=1.3.6,<2.0a0 + - xorg-libxrender >=0.9.12,<0.10.0a0 + license: MIT + license_family: MIT + purls: [] + size: 30456 + timestamp: 1769445263457 +- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxrender-0.9.12-hb9d3cd8_0.conda + sha256: 044c7b3153c224c6cedd4484dd91b389d2d7fd9c776ad0f4a34f099b3389f4a1 + md5: 96d57aba173e878a2089d5638016dc5e depends: - - python >=3.9 + - __glibc >=2.17,<3.0.a0 + - libgcc >=13 + - xorg-libx11 >=1.8.10,<2.0a0 license: MIT license_family: MIT - purls: - - pkg:pypi/mdurl?source=hash-mapping - size: 14465 - timestamp: 1733255681319 -- conda: https://prefix.dev/conda-forge/noarch/more-itertools-11.0.2-pyhcf101f3_0.conda - sha256: 74f7b461e0f0e0709a0c8abb018de9ad885258b74790ffda1e750ac5ddde0a85 - md5: b874955758a30a37c78b82ea5cf78fdb + purls: [] + size: 33005 + timestamp: 1734229037766 +- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxscrnsaver-1.2.4-hb9d3cd8_0.conda + sha256: 58e8fc1687534124832d22e102f098b5401173212ac69eb9fd96b16a3e2c8cb2 + md5: 303f7a0e9e0cd7d250bb6b952cecda90 depends: - - python >=3.10 - - python + - __glibc >=2.17,<3.0.a0 + - libgcc >=13 + - xorg-libx11 >=1.8.10,<2.0a0 + - xorg-libxext >=1.3.6,<2.0a0 license: MIT license_family: MIT - purls: - - pkg:pypi/more-itertools?source=hash-mapping - size: 71254 - timestamp: 1775762492525 -- conda: https://prefix.dev/conda-forge/linux-64/mpg123-1.32.9-hc50e24c_0.conda - sha256: 39c4700fb3fbe403a77d8cc27352fa72ba744db487559d5d44bf8411bb4ea200 - md5: c7f302fd11eeb0987a6a5e1f3aed6a21 + purls: [] + size: 14412 + timestamp: 1727899730073 +- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxtst-1.2.5-hb9d3cd8_3.conda + sha256: 752fdaac5d58ed863bbf685bb6f98092fe1a488ea8ebb7ed7b606ccfce08637a + md5: 7bbe9a0cc0df0ac5f5a8ad6d6a11af2f depends: - __glibc >=2.17,<3.0.a0 - libgcc >=13 - - libstdcxx >=13 - license: LGPL-2.1-only - license_family: LGPL + - xorg-libx11 >=1.8.10,<2.0a0 + - xorg-libxext >=1.3.6,<2.0a0 + - xorg-libxi >=1.7.10,<2.0a0 + license: MIT + license_family: MIT purls: [] - size: 491140 - timestamp: 1730581373280 -- conda: https://prefix.dev/conda-forge/osx-arm64/mpg123-1.32.9-hf642e45_0.conda - sha256: 070bbbbb96856c325c0b6637638ce535afdc49adbaff306e2238c6032d28dddf - md5: d2b4857bdc3b76c36e23236172d09840 + size: 32808 + timestamp: 1727964811275 +- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxxf86vm-1.1.7-hb03c661_0.conda + sha256: 64db17baaf36fa03ed8fae105e2e671a7383e22df4077486646f7dbf12842c9f + md5: 665d152b9c6e78da404086088077c844 depends: - - __osx >=11.0 - - libcxx >=18 - license: LGPL-2.1-only - license_family: LGPL + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + - xorg-libx11 >=1.8.12,<2.0a0 + - xorg-libxext >=1.3.6,<2.0a0 + license: MIT + license_family: MIT purls: [] - size: 360712 - timestamp: 1730581491116 -- conda: https://prefix.dev/conda-forge/noarch/munkres-1.1.4-pyhd8ed1ab_1.conda - sha256: d09c47c2cf456de5c09fa66d2c3c5035aa1fa228a1983a433c47b876aa16ce90 - md5: 37293a85a0f4f77bbd9cf7aaefc62609 + size: 18701 + timestamp: 1769434732453 +- conda: https://prefix.dev/conda-forge/linux-64/xorg-xorgproto-2025.1-hb03c661_0.conda + sha256: 7a8c64938428c2bfd016359f9cb3c44f94acc256c6167dbdade9f2a1f5ca7a36 + md5: aa8d21be4b461ce612d8f5fb791decae depends: - - python >=3.9 - license: Apache-2.0 - license_family: Apache - purls: - - pkg:pypi/munkres?source=hash-mapping - size: 15851 - timestamp: 1749895533014 -- conda: https://prefix.dev/conda-forge/linux-64/ncurses-6.6-hdb14827_0.conda - sha256: fc89f74bbe362fb29fa3c037697a89bec140b346a2469a90f7936d1d7ea4d8a3 - md5: fc21868a1a5aacc937e7a18747acb8a5 + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + license: MIT + license_family: MIT + purls: [] + size: 570010 + timestamp: 1766154256151 +- conda: https://prefix.dev/conda-forge/linux-64/xz-5.8.3-ha02ee65_0.conda + sha256: 2553fd3ec0a1020b2ca05ca10b0036a596cb0d4bf3645922fcf69dacce0e6679 + md5: 6a1b6af49a334e4e06b9f103367762bf depends: - __glibc >=2.17,<3.0.a0 - libgcc >=14 - license: X11 AND BSD-3-Clause + - liblzma 5.8.3 hb03c661_0 + - liblzma-devel 5.8.3 hb03c661_0 + - xz-gpl-tools 5.8.3 ha02ee65_0 + - xz-tools 5.8.3 hb03c661_0 + license: 0BSD AND LGPL-2.1-or-later AND GPL-2.0-or-later purls: [] - size: 918956 - timestamp: 1777422145199 -- conda: https://prefix.dev/conda-forge/osx-arm64/ncurses-6.6-h1d4f5a5_0.conda - sha256: 4ea6c620b87bd1d42bb2ccc2c87cd2483fa2d7f9e905b14c223f11ff3f4c455d - md5: 343d10ed5b44030a2f67193905aea159 + size: 24360 + timestamp: 1775825568523 +- conda: https://prefix.dev/conda-forge/linux-64/xz-gpl-tools-5.8.3-ha02ee65_0.conda + sha256: 8f139666ea18dc8340a44a54056627dd4e89e242e8cd136ab2467d6dc2c192ba + md5: 8f5e2c6726c1339287a3c76a2c138ac7 depends: - - __osx >=11.0 - license: X11 AND BSD-3-Clause + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + - liblzma 5.8.3 hb03c661_0 + constrains: + - xz 5.8.3.* + license: 0BSD AND LGPL-2.1-or-later AND GPL-2.0-or-later purls: [] - size: 805509 - timestamp: 1777423252320 -- conda: https://prefix.dev/conda-forge/noarch/nodeenv-1.10.0-pyhd8ed1ab_0.conda - sha256: 4fa40e3e13fc6ea0a93f67dfc76c96190afd7ea4ffc1bac2612d954b42cdc3ee - md5: eb52d14a901e23c39e9e7b4a1a5c015f + size: 34213 + timestamp: 1775825548743 +- conda: https://prefix.dev/conda-forge/linux-64/xz-tools-5.8.3-hb03c661_0.conda + sha256: 162ebd76803464b8c8ebc7d45df32edf0ec717b3bf369a437ae3b0254f22dc2e + md5: b62b615caa60812640f24db3a8d0fc87 depends: - - python >=3.10 - - setuptools - license: BSD-3-Clause - license_family: BSD - purls: - - pkg:pypi/nodeenv?source=hash-mapping - size: 40866 - timestamp: 1766261270149 -- conda: https://prefix.dev/conda-forge/linux-64/numba-0.67.0-py311hdfc3925_1.conda - sha256: 3129c290e7d02cd7fd8a44da0f1985539e7c659b18624b7298baaa267718d942 - md5: e32e21325dea34226840b71a57982ef3 + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + - liblzma 5.8.3 hb03c661_0 + constrains: + - xz 5.8.3.* + license: 0BSD AND LGPL-2.1-or-later + purls: [] + size: 95955 + timestamp: 1775825530484 +- conda: https://prefix.dev/conda-forge/linux-64/yaml-0.2.5-h280c20c_3.conda + sha256: 6d9ea2f731e284e9316d95fa61869fe7bbba33df7929f82693c121022810f4ad + md5: a77f85f77be52ff59391544bfe73390a + depends: + - libgcc >=14 + - __glibc >=2.17,<3.0.a0 + license: MIT + license_family: MIT + purls: [] + size: 85189 + timestamp: 1753484064210 +- conda: https://prefix.dev/conda-forge/linux-64/zlib-1.3.2-h25fd6f3_2.conda + sha256: 245c9ee8d688e23661b95e3c6dd7272ca936fabc03d423cdb3cdee1bbcf9f2f2 + md5: c2a01a08fc991620a74b32420e97868a + depends: + - __glibc >=2.17,<3.0.a0 + - libzlib 1.3.2 h25fd6f3_2 + license: Zlib + license_family: Other + purls: [] + size: 95931 + timestamp: 1774072620848 +- conda: https://prefix.dev/conda-forge/linux-64/zlib-ng-2.3.3-hce19668_1.conda + sha256: 8b786bb4380fa69a718b08a400040b865bc9207eda337e0a1955717c3c3a9403 + md5: 1726acec19beeed1c764385cd8622405 depends: - - python - - llvmlite >=0.49.0,<0.50.0a0 - - numpy >=1.22.3,<2.6 - - _openmp_mutex >=4.5 - __glibc >=2.17,<3.0.a0 - libgcc >=15 - libstdcxx >=15 - - numpy >=1.23,<3 - - python_abi 3.11.* *_cp311 - constrains: - - tbb >=2021.6.0 - - libopenblas !=0.3.6 - - cuda-version >=11.2 - - cudatoolkit >=11.2 - - scipy >=1.0 - - cuda-python >=11.6 - license: BSD-2-Clause - license_family: BSD - purls: - - pkg:pypi/numba?source=hash-mapping - size: 6286682 - timestamp: 1787145506914 -- conda: https://prefix.dev/conda-forge/osx-arm64/numba-0.67.0-py311hf682900_1.conda - sha256: fd613c23e421aa4b8700308951c90b7c4f5f3b78f85025e0c3af9366fdf5c4b0 - md5: 643ca1646acb686990d5febe0c0e5d63 - depends: - - python - - llvmlite >=0.49.0,<0.50.0a0 - - numpy >=1.22.3,<2.6 - - libcxx >=21 - - __osx >=11.0 - - llvm-openmp >=21.1.8 - - python_abi 3.11.* *_cp311 - - numpy >=1.23,<3 - constrains: - - tbb >=2021.6.0 - - libopenblas >=0.3.18,!=0.3.20 - - cuda-version >=11.2 - - cudatoolkit >=11.2 - - scipy >=1.0 - - cuda-python >=11.6 - license: BSD-2-Clause - license_family: BSD - purls: - - pkg:pypi/numba?source=hash-mapping - size: 6273051 - timestamp: 1787145526945 -- pypi: https://files.pythonhosted.org/packages/05/33/26178c7d437a87082d11019292dce6d3fe6f0e9026b7b2309cbf3e489b1d/numpy-2.0.2-cp310-cp310-macosx_11_0_arm64.whl - name: numpy - version: 2.0.2 - sha256: f15975dfec0cf2239224d80e32c3170b1d168335eaedee69da84fbe9f1f9cd04 - requires_python: '>=3.9' -- pypi: https://files.pythonhosted.org/packages/fa/66/f7177ab331876200ac7563a580140643d1179c8b4b6a6b0fc9838de2a9b8/numpy-2.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl - name: numpy - version: 2.0.2 - sha256: 496f71341824ed9f3d2fd36cf3ac57ae2e0165c143b55c3a035ee219413f3318 - requires_python: '>=3.9' -- conda: https://prefix.dev/conda-forge/linux-64/numpy-2.0.2-py311h71ddf71_1.conda - sha256: a922ec6947ad6953cb011b8f1a44779f6b55d62a14c5bcd25d19a8fb1629da30 - md5: 04ce874aa54fc1d9c735a04e0c6d99c4 + license: Zlib + license_family: Other + purls: [] + size: 123959 + timestamp: 1786736890973 +- conda: https://prefix.dev/conda-forge/linux-64/zstd-1.5.7-hb78ec9c_6.conda + sha256: 68f0206ca6e98fea941e5717cec780ed2873ffabc0e1ed34428c061e2c6268c7 + md5: 4a13eeac0b5c8e5b8ab496e6c4ddd829 depends: - __glibc >=2.17,<3.0.a0 - - libblas >=3.9.0,<4.0a0 - - libcblas >=3.9.0,<4.0a0 - - libgcc >=13 - - liblapack >=3.9.0,<4.0a0 - - libstdcxx >=13 - - python >=3.11,<3.12.0a0 - - python_abi 3.11.* *_cp311 - constrains: - - numpy-base <0a0 + - libzlib >=1.3.1,<2.0a0 license: BSD-3-Clause license_family: BSD - purls: - - pkg:pypi/numpy?source=hash-mapping - size: 9148240 - timestamp: 1732314901472 -- conda: https://prefix.dev/conda-forge/osx-arm64/numpy-2.0.2-py311h649a571_1.conda - sha256: 3d4c508041d17007a56f79b593a6d6a69d4f4e2453f1f7ee29ecb48992cc3acc - md5: 417c4c5c4a4693156f5b878cf94bf7a0 + purls: [] + size: 601375 + timestamp: 1764777111296 +- conda: https://prefix.dev/conda-forge/noarch/adwaita-icon-theme-49.0-unix_0.conda + sha256: a362b4f5c96a0bf4def96be1a77317e2730af38915eb9bec85e2a92836501ed7 + md5: b3f0179590f3c0637b7eb5309898f79e depends: - - __osx >=11.0 - - libblas >=3.9.0,<4.0a0 - - libcblas >=3.9.0,<4.0a0 - - libcxx >=18 - - liblapack >=3.9.0,<4.0a0 - - python >=3.11,<3.12.0a0 - - python >=3.11,<3.12.0a0 *_cpython - - python_abi 3.11.* *_cp311 + - __unix + - hicolor-icon-theme + - librsvg + license: LGPL-3.0-or-later OR CC-BY-SA-3.0 + license_family: LGPL + purls: [] + size: 631452 + timestamp: 1758743294412 +- conda: https://prefix.dev/conda-forge/noarch/anyio-4.13.0-pyhcf101f3_0.conda + sha256: f09aed24661cd45ba54a43772504f05c0698248734f9ae8cd289d314ac89707e + md5: af2df4b9108808da3dc76710fe50eae2 + depends: + - exceptiongroup >=1.0.2 + - idna >=2.8 + - python >=3.10 + - typing_extensions >=4.5 + - python constrains: - - numpy-base <0a0 - license: BSD-3-Clause - license_family: BSD + - trio >=0.32.0 + - uvloop >=0.22.1 + - winloop >=0.2.3 + license: MIT + license_family: MIT purls: - - pkg:pypi/numpy?source=hash-mapping - size: 6893464 - timestamp: 1732314808608 -- conda: https://prefix.dev/conda-forge/linux-64/openjpeg-2.5.4-h55fea9a_0.conda - sha256: 3900f9f2dbbf4129cf3ad6acf4e4b6f7101390b53843591c53b00f034343bc4d - md5: 11b3379b191f63139e29c0d19dee24cd + - pkg:pypi/anyio?source=hash-mapping + size: 146764 + timestamp: 1774359453364 +- conda: https://prefix.dev/conda-forge/noarch/backports-1.0-pyhd8ed1ab_5.conda + sha256: e1c3dc8b5aa6e12145423fed262b4754d70fec601339896b9ccf483178f690a6 + md5: 767d508c1a67e02ae8f50e44cacfadb2 depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - libpng >=1.6.50,<1.7.0a0 - - libstdcxx >=14 - - libtiff >=4.7.1,<4.8.0a0 - - libzlib >=1.3.1,<2.0a0 - license: BSD-2-Clause + - python >=3.9 + license: BSD-3-Clause license_family: BSD purls: [] - size: 355400 - timestamp: 1758489294972 -- conda: https://prefix.dev/conda-forge/osx-arm64/openjpeg-2.5.4-hd9e9057_0.conda - sha256: 60aca8b9f94d06b852b296c276b3cf0efba5a6eb9f25feb8708570d3a74f00e4 - md5: 4b5d3a91320976eec71678fad1e3569b + size: 7069 + timestamp: 1733218168786 +- conda: https://prefix.dev/conda-forge/noarch/backports.tarfile-1.2.0-pyhcf101f3_2.conda + sha256: 25abdb37e186f0d6ac3b774a63c81c5bc4bf554b5096b51343fa5e7c381193b1 + md5: bea46844deb274b2cc2a3a941745fa73 depends: - - __osx >=11.0 - - libcxx >=19 - - libpng >=1.6.55,<1.7.0a0 - - libtiff >=4.7.1,<4.8.0a0 - - libzlib >=1.3.1,<2.0a0 - license: BSD-2-Clause - license_family: BSD - purls: [] - size: 319697 - timestamp: 1772625397692 -- conda: https://prefix.dev/conda-forge/linux-64/openldap-2.6.13-hbde042b_0.conda - sha256: 21c4f6c7f41dc9bec2ea2f9c80440d9a4d45a6f2ac13243e658f10dcf1044146 - md5: 680608784722880fbfe1745067570b00 + - python >=3.10 + - backports + - python + license: MIT + license_family: MIT + purls: + - pkg:pypi/backports-tarfile?source=hash-mapping + size: 35739 + timestamp: 1767290467820 +- conda: https://prefix.dev/conda-forge/noarch/ca-certificates-2026.4.22-hbd8a1cb_0.conda + sha256: c9dbcc8039a52023660d6d1bbf87594a93dd69c6ac5a2a44323af2c92976728d + md5: e18ad67cf881dcadee8b8d9e2f8e5f73 depends: - - __glibc >=2.17,<3.0.a0 - - cyrus-sasl >=2.1.28,<3.0a0 - - krb5 >=1.22.2,<1.23.0a0 - - libgcc >=14 - - libstdcxx >=14 - - openssl >=3.5.6,<4.0a0 - license: OLDAP-2.8 - license_family: BSD + - __unix + license: ISC purls: [] - size: 786149 - timestamp: 1775741359582 -- conda: https://prefix.dev/conda-forge/linux-64/openssl-3.6.2-h35e630c_0.conda - sha256: c0ef482280e38c71a08ad6d71448194b719630345b0c9c60744a2010e8a8e0cb - md5: da1b85b6a87e141f5140bb9924cecab0 + size: 131039 + timestamp: 1776865545798 +- conda: https://prefix.dev/conda-forge/noarch/certifi-2026.4.22-pyhd8ed1ab_0.conda + sha256: 989db6e5957c4b44fa600c68c681ec2f36a55e48f7c7f1c073d5e91caa8cd878 + md5: 929471569c93acefb30282a22060dcd5 depends: - - __glibc >=2.17,<3.0.a0 - - ca-certificates - - libgcc >=14 - license: Apache-2.0 - license_family: Apache - purls: [] - size: 3167099 - timestamp: 1775587756857 -- conda: https://prefix.dev/conda-forge/osx-arm64/openssl-3.6.2-hd24854e_0.conda - sha256: c91bf510c130a1ea1b6ff023e28bac0ccaef869446acd805e2016f69ebdc49ea - md5: 25dcccd4f80f1638428613e0d7c9b4e1 + - python >=3.10 + license: ISC + purls: + - pkg:pypi/certifi?source=hash-mapping + size: 135656 + timestamp: 1776866680878 +- conda: https://prefix.dev/conda-forge/noarch/cfgv-3.5.0-pyhd8ed1ab_0.conda + sha256: aa589352e61bb221351a79e5946d56916e3c595783994884accdb3b97fe9d449 + md5: 381bd45fb7aa032691f3063aff47e3a1 depends: - - __osx >=11.0 - - ca-certificates - license: Apache-2.0 - license_family: Apache - purls: [] - size: 3106008 - timestamp: 1775587972483 -- conda: https://prefix.dev/conda-forge/linux-64/opusfile-0.12-h3358134_2.conda - sha256: f4df9df880e405e5c856383f869d5b9d434f78fb7c234c9e7b099ab604fb7fc3 - md5: 5931bcae00b98f952696b6bcdd0be34b + - python >=3.10 + license: MIT + license_family: MIT + purls: + - pkg:pypi/cfgv?source=hash-mapping + size: 13589 + timestamp: 1763607964133 +- conda: https://prefix.dev/conda-forge/noarch/click-8.3.3-pyhc90fa1f_0.conda + sha256: 37a5d8b10ea3516e2c42f870c9c351b9f7b31ff48c66d83490039f417e1e5228 + md5: 2266262ce8a425ecb6523d765f79b303 depends: - - libgcc-ng >=12 - - libogg >=1.3.4,<1.4.0a0 - - libopus >=1.3.1,<2.0a0 - - openssl >=3.0.7,<4.0a0 + - __unix + - python + - python >=3.10 license: BSD-3-Clause license_family: BSD - purls: [] - size: 65901 - timestamp: 1670387479735 -- conda: https://prefix.dev/conda-forge/osx-arm64/opusfile-0.12-h5643135_2.conda - sha256: 108dbee936a8e3c21d2aa5618326343844df8f1fe14067c4dc5a731d7945ecc0 - md5: e34e472ae04beeb642c5e937a2aeeebf + purls: + - pkg:pypi/click?source=hash-mapping + size: 100048 + timestamp: 1777219902525 +- conda: https://prefix.dev/conda-forge/noarch/cloudpickle-3.1.2-pyhcf101f3_1.conda + sha256: 4c287c2721d8a34c94928be8fe0e9a85754e90189dd4384a31b1806856b50a67 + md5: 61b8078a0905b12529abc622406cb62c depends: - - libogg >=1.3.4,<1.4.0a0 - - libopus >=1.3.1,<2.0a0 - - openssl >=3.0.7,<4.0a0 + - python >=3.10 + - python + license: BSD-3-Clause + license_family: BSD + purls: + - pkg:pypi/cloudpickle?source=hash-mapping + size: 27353 + timestamp: 1765303462831 +- conda: https://prefix.dev/conda-forge/noarch/colorama-0.4.6-pyhd8ed1ab_1.conda + sha256: ab29d57dc70786c1269633ba3dff20288b81664d3ff8d21af995742e2bb03287 + md5: 962b9857ee8e7018c22f2776ffa0b2d7 + depends: + - python >=3.9 + license: BSD-3-Clause + license_family: BSD + purls: + - pkg:pypi/colorama?source=hash-mapping + size: 27011 + timestamp: 1733218222191 +- conda: https://prefix.dev/conda-forge/noarch/cycler-0.12.1-pyhcf101f3_2.conda + sha256: bb47aec5338695ff8efbddbc669064a3b10fe34ad881fb8ad5d64fbfa6910ed1 + md5: 4c2a8fef270f6c69591889b93f9f55c1 + depends: + - python >=3.10 + - python + license: BSD-3-Clause + license_family: BSD + purls: + - pkg:pypi/cycler?source=hash-mapping + size: 14778 + timestamp: 1764466758386 +- conda: https://prefix.dev/conda-forge/noarch/distlib-0.4.0-pyhd8ed1ab_0.conda + sha256: 6d977f0b2fc24fee21a9554389ab83070db341af6d6f09285360b2e09ef8b26e + md5: 003b8ba0a94e2f1e117d0bd46aebc901 + depends: + - python >=3.9 + license: Apache-2.0 + license_family: APACHE + purls: + - pkg:pypi/distlib?source=hash-mapping + size: 275642 + timestamp: 1752823081585 +- conda: https://prefix.dev/conda-forge/noarch/editables-0.6-pyhcf101f3_0.conda + sha256: bb826ff403b8195467e7cd5f504bc14767b424dac27bb225508ca2c1852554b2 + md5: 86b177231eecb011fe00e2117dbc3348 + depends: + - python >=3.10 + - python + license: MIT + license_family: MIT + purls: + - pkg:pypi/editables?source=hash-mapping + size: 13160 + timestamp: 1776172429816 +- conda: https://prefix.dev/conda-forge/noarch/exceptiongroup-1.3.1-pyhd8ed1ab_0.conda + sha256: ee6cf346d017d954255bbcbdb424cddea4d14e4ed7e9813e429db1d795d01144 + md5: 8e662bd460bda79b1ea39194e3c4c9ab + depends: + - python >=3.10 + - typing_extensions >=4.6.0 + license: MIT and PSF-2.0 + purls: + - pkg:pypi/exceptiongroup?source=hash-mapping + size: 21333 + timestamp: 1763918099466 +- conda: https://prefix.dev/conda-forge/noarch/farama-notifications-0.0.4-pyhd8ed1ab_0.conda + sha256: 8df190d75bac104c6c2317b13397eed9adfa6889b12405b0288ca2ca86855c06 + md5: 61f63fcf1c2deddeae7a85a516d46c94 + depends: + - python >=3.6 + license: MIT + license_family: MIT + purls: + - pkg:pypi/farama-notifications?source=hash-mapping + size: 8406 + timestamp: 1684258265351 +- conda: https://prefix.dev/conda-forge/noarch/filelock-3.29.0-pyhd8ed1ab_0.conda + sha256: 6b471a18372bbd52bdf32fc965f71de3bc1b5219418b8e6b3875a67a7b08c483 + md5: 8fa8358d022a3a9bd101384a808044c6 + depends: + - python >=3.10 + license: Unlicense + purls: + - pkg:pypi/filelock?source=hash-mapping + size: 34211 + timestamp: 1776621506566 +- conda: https://prefix.dev/conda-forge/noarch/font-ttf-dejavu-sans-mono-2.37-hab24e00_0.tar.bz2 + sha256: 58d7f40d2940dd0a8aa28651239adbf5613254df0f75789919c4e6762054403b + md5: 0c96522c6bdaed4b1566d11387caaf45 + license: BSD-3-Clause + license_family: BSD + purls: [] + size: 397370 + timestamp: 1566932522327 +- conda: https://prefix.dev/conda-forge/noarch/font-ttf-inconsolata-3.000-h77eed37_0.tar.bz2 + sha256: c52a29fdac682c20d252facc50f01e7c2e7ceac52aa9817aaf0bb83f7559ec5c + md5: 34893075a5c9e55cdafac56607368fc6 + license: OFL-1.1 + license_family: Other + purls: [] + size: 96530 + timestamp: 1620479909603 +- conda: https://prefix.dev/conda-forge/noarch/font-ttf-source-code-pro-2.038-h77eed37_0.tar.bz2 + sha256: 00925c8c055a2275614b4d983e1df637245e19058d79fc7dd1a93b8d9fb4b139 + md5: 4d59c254e01d9cde7957100457e2d5fb + license: OFL-1.1 + license_family: Other + purls: [] + size: 700814 + timestamp: 1620479612257 +- conda: https://prefix.dev/conda-forge/noarch/font-ttf-ubuntu-0.83-h77eed37_3.conda + sha256: 2821ec1dc454bd8b9a31d0ed22a7ce22422c0aef163c59f49dfdf915d0f0ca14 + md5: 49023d73832ef61042f6a237cb2687e7 + license: LicenseRef-Ubuntu-Font-Licence-Version-1.0 + license_family: Other + purls: [] + size: 1620504 + timestamp: 1727511233259 +- conda: https://prefix.dev/conda-forge/noarch/fonts-conda-ecosystem-1-0.tar.bz2 + sha256: a997f2f1921bb9c9d76e6fa2f6b408b7fa549edd349a77639c9fe7a23ea93e61 + md5: fee5683a3f04bd15cbd8318b096a27ab + depends: + - fonts-conda-forge + license: BSD-3-Clause + license_family: BSD + purls: [] + size: 3667 + timestamp: 1566974674465 +- conda: https://prefix.dev/conda-forge/noarch/fonts-conda-forge-1-hc364b38_1.conda + sha256: 54eea8469786bc2291cc40bca5f46438d3e062a399e8f53f013b6a9f50e98333 + md5: a7970cd949a077b7cb9696379d338681 + depends: + - font-ttf-ubuntu + - font-ttf-inconsolata + - font-ttf-dejavu-sans-mono + - font-ttf-source-code-pro + license: BSD-3-Clause + license_family: BSD + purls: [] + size: 4059 + timestamp: 1762351264405 +- conda: https://prefix.dev/conda-forge/noarch/h11-0.16.0-pyhcf101f3_1.conda + sha256: 96cac6573fd35ae151f4d6979bab6fbc90cb6b1fb99054ba19eb075da9822fcb + md5: b8993c19b0c32a2f7b66cbb58ca27069 + depends: + - python >=3.10 + - typing_extensions + - python + license: MIT + license_family: MIT + purls: + - pkg:pypi/h11?source=hash-mapping + size: 39069 + timestamp: 1767729720872 +- conda: https://prefix.dev/conda-forge/noarch/h2-4.3.0-pyhcf101f3_0.conda + sha256: 84c64443368f84b600bfecc529a1194a3b14c3656ee2e832d15a20e0329b6da3 + md5: 164fc43f0b53b6e3a7bc7dce5e4f1dc9 + depends: + - python >=3.10 + - hyperframe >=6.1,<7 + - hpack >=4.1,<5 + - python + license: MIT + license_family: MIT + purls: + - pkg:pypi/h2?source=hash-mapping + size: 95967 + timestamp: 1756364871835 +- conda: https://prefix.dev/conda-forge/noarch/hatch-1.16.5-pyhcf101f3_0.conda + sha256: e298f93e25d98f5b90f231cf9cd6467773fc3fd242a9a0dce2b82fcfa1b38971 + md5: 3191c464a2222e8af63e57926da9315c + depends: + - click >=8.0.6 + - hatchling >=1.27.0 + - httpx >=0.22.0 + - hyperlink >=21.0.0 + - keyring >=23.5.0 + - packaging >=24.2 + - pexpect >=4.8,<5.dev0 + - platformdirs >=2.5.0 + - pyproject_hooks + - python >=3.10 + - rich >=11.2.0 + - shellingham >=1.4.0 + - tomli-w >=1.0 + - tomlkit >=0.11.1 + - userpath >=1.7,<2.dev0 + - uv >=0.5.23 + - virtualenv >=21 + - backports.zstd >=1.0.0 + - python-discovery >=1.1 + - python + license: MIT + license_family: MIT + purls: + - pkg:pypi/hatch?source=hash-mapping + size: 208420 + timestamp: 1772806610433 +- conda: https://prefix.dev/conda-forge/noarch/hatchling-1.29.0-pyhcf101f3_0.conda + sha256: bb86ff4ca54a2a0f63714766c7653a772c13d34c9e7cfb7be653db2fb806f961 + md5: 9d67ecd4cd5e6a9be36522be95951785 + depends: + - packaging >=24.2 + - pathspec >=0.10.1 + - pluggy >=1.0.0 + - python >=3.10 + - tomli >=1.2.2 + - trove-classifiers + - editables >=0.3 + - python + license: MIT + license_family: MIT + purls: + - pkg:pypi/hatchling?source=hash-mapping + size: 61052 + timestamp: 1773194193187 +- conda: https://prefix.dev/conda-forge/noarch/hpack-4.1.0-pyhd8ed1ab_0.conda + sha256: 6ad78a180576c706aabeb5b4c8ceb97c0cb25f1e112d76495bff23e3779948ba + md5: 0a802cb9888dd14eeefc611f05c40b6e + depends: + - python >=3.9 + license: MIT + license_family: MIT + purls: + - pkg:pypi/hpack?source=hash-mapping + size: 30731 + timestamp: 1737618390337 +- conda: https://prefix.dev/conda-forge/noarch/httpcore-1.0.9-pyh29332c3_0.conda + sha256: 04d49cb3c42714ce533a8553986e1642d0549a05dc5cc48e0d43ff5be6679a5b + md5: 4f14640d58e2cc0aa0819d9d8ba125bb + depends: + - python >=3.9 + - h11 >=0.16 + - h2 >=3,<5 + - sniffio 1.* + - anyio >=4.0,<5.0 + - certifi + - python + license: BSD-3-Clause + license_family: BSD + purls: + - pkg:pypi/httpcore?source=hash-mapping + size: 49483 + timestamp: 1745602916758 +- conda: https://prefix.dev/conda-forge/noarch/httpx-0.28.1-pyhd8ed1ab_0.conda + sha256: cd0f1de3697b252df95f98383e9edb1d00386bfdd03fdf607fa42fe5fcb09950 + md5: d6989ead454181f4f9bc987d3dc4e285 + depends: + - anyio + - certifi + - httpcore 1.* + - idna + - python >=3.9 + license: BSD-3-Clause + license_family: BSD + purls: + - pkg:pypi/httpx?source=hash-mapping + size: 63082 + timestamp: 1733663449209 +- conda: https://prefix.dev/conda-forge/noarch/hyperframe-6.1.0-pyhd8ed1ab_0.conda + sha256: 77af6f5fe8b62ca07d09ac60127a30d9069fdc3c68d6b256754d0ffb1f7779f8 + md5: 8e6923fc12f1fe8f8c4e5c9f343256ac + depends: + - python >=3.9 + license: MIT + license_family: MIT + purls: + - pkg:pypi/hyperframe?source=hash-mapping + size: 17397 + timestamp: 1737618427549 +- conda: https://prefix.dev/conda-forge/noarch/hyperlink-21.0.0-pyh29332c3_1.conda + sha256: 6fc0a91c590b3055bfb7983e6521c7b780ab8b11025058eaf898049ea827d829 + md5: c27acdecaf3c311e5781b81fe02d9641 + depends: + - python >=3.9 + - idna >=2.6 + - python + license: MIT + license_family: MIT + purls: + - pkg:pypi/hyperlink?source=hash-mapping + size: 74751 + timestamp: 1733319972207 +- conda: https://prefix.dev/conda-forge/noarch/identify-2.6.19-pyhd8ed1ab_0.conda + sha256: 381cedccf0866babfc135d65ee40b778bd20e927d2a5ec810f750c5860a7c5b8 + md5: 84a3233b709a289a4ddd7a2fd27dd988 + depends: + - python >=3.10 + - ukkonen + license: MIT + license_family: MIT + purls: + - pkg:pypi/identify?source=hash-mapping + size: 79757 + timestamp: 1776455344188 +- conda: https://prefix.dev/conda-forge/noarch/idna-3.13-pyhcf101f3_0.conda + sha256: 9ab620e6f64bb67737bd7bc1ad6f480770124e304c6710617aba7fe60b089f48 + md5: fb7130c190f9b4ec91219840a05ba3ac + depends: + - python >=3.10 + - python + license: BSD-3-Clause + license_family: BSD + purls: + - pkg:pypi/idna?source=hash-mapping + size: 59038 + timestamp: 1776947141407 +- conda: https://prefix.dev/conda-forge/noarch/importlib-metadata-8.8.0-pyhcf101f3_0.conda + sha256: 82ab2a0d91ca1e7e63ab6a4939356667ef683905dea631bc2121aa534d347b16 + md5: 080594bf4493e6bae2607e65390c520a + depends: + - python >=3.10 + - zipp >=3.20 + - python + license: Apache-2.0 + license_family: APACHE + purls: + - pkg:pypi/importlib-metadata?source=hash-mapping + size: 34387 + timestamp: 1773931568510 +- conda: https://prefix.dev/conda-forge/noarch/importlib_resources-7.1.0-pyhd8ed1ab_0.conda + sha256: a563a51aa522998172838e867e6dedcf630bc45796e8612f5a1f6d73e9c8125a + md5: 0ba6225c279baf7ea9473a62ea0ec9ae + depends: + - python >=3.10 + - zipp >=3.1.0 + constrains: + - importlib-resources >=7.1.0,<7.1.1.0a0 + license: Apache-2.0 + license_family: APACHE + purls: + - pkg:pypi/importlib-resources?source=hash-mapping + size: 34809 + timestamp: 1776068839274 +- conda: https://prefix.dev/conda-forge/noarch/iniconfig-2.3.0-pyhd8ed1ab_0.conda + sha256: e1a9e3b1c8fe62dc3932a616c284b5d8cbe3124bbfbedcf4ce5c828cb166ee19 + md5: 9614359868482abba1bd15ce465e3c42 + depends: + - python >=3.10 + license: MIT + license_family: MIT + purls: + - pkg:pypi/iniconfig?source=hash-mapping + size: 13387 + timestamp: 1760831448842 +- conda: https://prefix.dev/conda-forge/noarch/jaraco.classes-3.4.0-pyhcf101f3_3.conda + sha256: 3cc991f0f09dfd00d2626e745ba68da03e4f1dcbb7b36dd20f7a7373643cd5d5 + md5: d59568bad316413c89831456e691de29 + depends: + - python >=3.10 + - more-itertools + - python + license: MIT + license_family: MIT + purls: + - pkg:pypi/jaraco-classes?source=hash-mapping + size: 14831 + timestamp: 1767294269456 +- conda: https://prefix.dev/conda-forge/noarch/jaraco.context-6.1.2-pyhcf101f3_0.conda + sha256: 108b3919db8ef81b5585b38a3fedbe9eeccdf8fa576c250a13559a1188f597cc + md5: b9d2b1ffa307961f6bb7d83c8ba8a8be + depends: + - python >=3.10 + - backports.tarfile + - python + license: MIT + license_family: MIT + purls: + - pkg:pypi/jaraco-context?source=hash-mapping + size: 16222 + timestamp: 1776862415793 +- conda: https://prefix.dev/conda-forge/noarch/jaraco.functools-4.4.0-pyhcf101f3_1.conda + sha256: 6a91447b3bb4d7ae94cc0d77ed12617796629aee11111efe7ea43cbd0e113bda + md5: aa83cc08626bf6b613a3103942be8951 + depends: + - python >=3.10 + - more-itertools + - python + license: MIT + license_family: MIT + purls: + - pkg:pypi/jaraco-functools?source=hash-mapping + size: 18744 + timestamp: 1767294193246 +- conda: https://prefix.dev/conda-forge/noarch/jax-jumpy-1.0.0-pyhd8ed1ab_1.conda + sha256: c414b2be28e7d963e55c962caad1a25833d2e415a3d7a16e4f9da9e187dd37b3 + md5: d15bad1eca61880b5e465c4038d7c3f4 + depends: + - numpy >=1.18.0 + - python >=3.9 + license: Apache-2.0 + license_family: APACHE + purls: + - pkg:pypi/jax-jumpy?source=hash-mapping + size: 20757 + timestamp: 1734210042598 +- conda: https://prefix.dev/conda-forge/noarch/jeepney-0.9.0-pyhd8ed1ab_0.conda + sha256: 00d37d85ca856431c67c8f6e890251e7cc9e5ef3724a0302b8d4a101f22aa27f + md5: b4b91eb14fbe2f850dd2c5fc20676c0d + depends: + - python >=3.9 + license: MIT + license_family: MIT + purls: + - pkg:pypi/jeepney?source=hash-mapping + size: 40015 + timestamp: 1740828380668 +- conda: https://prefix.dev/conda-forge/noarch/keyring-25.7.0-pyh534df25_0.conda + sha256: 9def5c6fb3b3b4952a4f6b55a019b5c7065b592682b84710229de5a0b73f6364 + md5: c88f9579d08eb4031159f03640714ce3 + depends: + - __osx + - importlib-metadata >=4.11.4 + - importlib_resources + - jaraco.classes + - jaraco.context + - jaraco.functools + - python >=3.10 + license: MIT + license_family: MIT + purls: + - pkg:pypi/keyring?source=hash-mapping + size: 37924 + timestamp: 1763320995459 +- conda: https://prefix.dev/conda-forge/noarch/keyring-25.7.0-pyha804496_0.conda + sha256: 010718b1b1a35ce72782d38e6d6b9495d8d7d0dbea9a3e42901d030ff2189545 + md5: 9eeb0eaf04fa934808d3e070eebbe630 + depends: + - __linux + - importlib-metadata >=4.11.4 + - importlib_resources + - jaraco.classes + - jaraco.context + - jaraco.functools + - jeepney >=0.4.2 + - python >=3.10 + - secretstorage >=3.2 + license: MIT + license_family: MIT + purls: + - pkg:pypi/keyring?source=hash-mapping + size: 37717 + timestamp: 1763320674488 +- conda: https://prefix.dev/conda-forge/noarch/markdown-it-py-4.2.0-pyhd8ed1ab_0.conda + sha256: 0c4c35376fe920714390d46e4b8d31c876d65f18e1655899e0763ec25f2a902f + md5: 6d03368f2b2b0a5fb6839df53b2eb5e0 + depends: + - mdurl >=0.1,<1 + - python >=3.10 + license: MIT + license_family: MIT + purls: + - pkg:pypi/markdown-it-py?source=hash-mapping + size: 69017 + timestamp: 1778169663339 +- conda: https://prefix.dev/conda-forge/noarch/mdurl-0.1.2-pyhd8ed1ab_1.conda + sha256: 78c1bbe1723449c52b7a9df1af2ee5f005209f67e40b6e1d3c7619127c43b1c7 + md5: 592132998493b3ff25fd7479396e8351 + depends: + - python >=3.9 + license: MIT + license_family: MIT + purls: + - pkg:pypi/mdurl?source=hash-mapping + size: 14465 + timestamp: 1733255681319 +- conda: https://prefix.dev/conda-forge/noarch/more-itertools-11.0.2-pyhcf101f3_0.conda + sha256: 74f7b461e0f0e0709a0c8abb018de9ad885258b74790ffda1e750ac5ddde0a85 + md5: b874955758a30a37c78b82ea5cf78fdb + depends: + - python >=3.10 + - python + license: MIT + license_family: MIT + purls: + - pkg:pypi/more-itertools?source=hash-mapping + size: 71254 + timestamp: 1775762492525 +- conda: https://prefix.dev/conda-forge/noarch/munkres-1.1.4-pyhd8ed1ab_1.conda + sha256: d09c47c2cf456de5c09fa66d2c3c5035aa1fa228a1983a433c47b876aa16ce90 + md5: 37293a85a0f4f77bbd9cf7aaefc62609 + depends: + - python >=3.9 + license: Apache-2.0 + license_family: Apache + purls: + - pkg:pypi/munkres?source=hash-mapping + size: 15851 + timestamp: 1749895533014 +- conda: https://prefix.dev/conda-forge/noarch/nodeenv-1.10.0-pyhd8ed1ab_0.conda + sha256: 4fa40e3e13fc6ea0a93f67dfc76c96190afd7ea4ffc1bac2612d954b42cdc3ee + md5: eb52d14a901e23c39e9e7b4a1a5c015f + depends: + - python >=3.10 + - setuptools + license: BSD-3-Clause + license_family: BSD + purls: + - pkg:pypi/nodeenv?source=hash-mapping + size: 40866 + timestamp: 1766261270149 +- conda: https://prefix.dev/conda-forge/noarch/packaging-26.2-pyhc364b38_0.conda + sha256: 3906abfb6511a3bb309e39b9b1b7bc38f50a723971de2395489fd1f379255890 + md5: 4c06a92e74452cfa53623a81592e8934 + depends: + - python >=3.8 + - python + license: Apache-2.0 + license_family: APACHE + purls: + - pkg:pypi/packaging?source=hash-mapping + size: 91574 + timestamp: 1777103621679 +- conda: https://prefix.dev/conda-forge/noarch/pathspec-1.1.1-pyhd8ed1ab_0.conda + sha256: 6eaee417d33f298db79bc7185ab1208604c0e6cf51dade34cd513c6f9db9c6f3 + md5: 11adc78451c998c0fd162584abfa3559 + depends: + - python >=3.10 + license: MPL-2.0 + license_family: MOZILLA + purls: + - pkg:pypi/pathspec?source=hash-mapping + size: 56559 + timestamp: 1777271601895 +- conda: https://prefix.dev/conda-forge/noarch/pexpect-4.9.0-pyhd8ed1ab_1.conda + sha256: 202af1de83b585d36445dc1fda94266697341994d1a3328fabde4989e1b3d07a + md5: d0d408b1f18883a944376da5cf8101ea + depends: + - ptyprocess >=0.5 + - python >=3.9 + license: ISC + purls: + - pkg:pypi/pexpect?source=hash-mapping + size: 53561 + timestamp: 1733302019362 +- conda: https://prefix.dev/conda-forge/noarch/platformdirs-4.9.6-pyhcf101f3_0.conda + sha256: 8f29915c172f1f7f4f7c9391cd5dac3ebf5d13745c8b7c8006032615246345a5 + md5: 89c0b6d1793601a2a3a3f7d2d3d8b937 + depends: + - python >=3.10 + - python + license: MIT + license_family: MIT + purls: + - pkg:pypi/platformdirs?source=hash-mapping + size: 25862 + timestamp: 1775741140609 +- conda: https://prefix.dev/conda-forge/noarch/pluggy-1.6.0-pyhf9edf01_1.conda + sha256: e14aafa63efa0528ca99ba568eaf506eb55a0371d12e6250aaaa61718d2eb62e + md5: d7585b6550ad04c8c5e21097ada2888e + depends: + - python >=3.9 + - python + license: MIT + license_family: MIT + purls: + - pkg:pypi/pluggy?source=hash-mapping + size: 25877 + timestamp: 1764896838868 +- conda: https://prefix.dev/conda-forge/noarch/pre-commit-4.6.0-pyha770c72_0.conda + sha256: 716960bf0a9eb334458a26b3bdcb17b8d0786062138a4f48c7f335c8418c5d0b + md5: 7859736b4f8ebe6c8481bf48d91c9a1e + depends: + - cfgv >=2.0.0 + - identify >=1.0.0 + - nodeenv >=0.11.1 + - python >=3.10 + - pyyaml >=5.1 + - virtualenv >=20.10.0 + license: MIT + license_family: MIT + purls: + - pkg:pypi/pre-commit?source=hash-mapping + size: 201606 + timestamp: 1776858157327 +- conda: https://prefix.dev/conda-forge/noarch/ptyprocess-0.7.0-pyhd8ed1ab_1.conda + sha256: a7713dfe30faf17508ec359e0bc7e0983f5d94682492469bd462cdaae9c64d83 + md5: 7d9daffbb8d8e0af0f769dbbcd173a54 + depends: + - python >=3.9 + license: ISC + purls: + - pkg:pypi/ptyprocess?source=hash-mapping + size: 19457 + timestamp: 1733302371990 +- conda: https://prefix.dev/conda-forge/noarch/pycparser-2.22-pyh29332c3_1.conda + sha256: 79db7928d13fab2d892592223d7570f5061c192f27b9febd1a418427b719acc6 + md5: 12c566707c80111f9799308d9e265aef + depends: + - python >=3.9 + - python + license: BSD-3-Clause + license_family: BSD + purls: + - pkg:pypi/pycparser?source=hash-mapping + size: 110100 + timestamp: 1733195786147 +- conda: https://prefix.dev/conda-forge/noarch/pygments-2.20.0-pyhd8ed1ab_0.conda + sha256: cf70b2f5ad9ae472b71235e5c8a736c9316df3705746de419b59d442e8348e86 + md5: 16c18772b340887160c79a6acc022db0 + depends: + - python >=3.10 + license: BSD-2-Clause + license_family: BSD + purls: + - pkg:pypi/pygments?source=hash-mapping + size: 893031 + timestamp: 1774796815820 +- conda: https://prefix.dev/conda-forge/noarch/pyparsing-3.3.2-pyhcf101f3_0.conda + sha256: 417fba4783e528ee732afa82999300859b065dc59927344b4859c64aae7182de + md5: 3687cc0b82a8b4c17e1f0eb7e47163d5 + depends: + - python >=3.10 + - python + license: MIT + license_family: MIT + purls: + - pkg:pypi/pyparsing?source=hash-mapping + size: 110893 + timestamp: 1769003998136 +- conda: https://prefix.dev/conda-forge/noarch/pyproject_hooks-1.2.0-pyhd8ed1ab_1.conda + sha256: 065ac44591da9abf1ff740feb25929554b920b00d09287a551fcced2c9791092 + md5: d4582021af437c931d7d77ec39007845 + depends: + - python >=3.9 + - tomli >=1.1.0 + license: MIT + license_family: MIT + purls: + - pkg:pypi/pyproject-hooks?source=hash-mapping + size: 15528 + timestamp: 1733710122949 +- conda: https://prefix.dev/conda-forge/noarch/pyserial-3.5-pyhcf101f3_2.conda + sha256: 8c618e8ca376d73133c9971abe45463a48c9cfb529788d609fd19568764941ba + md5: b27a6cd32160c34682ce6053b04c12c6 + depends: + - python >=3.10 + - python + license: BSD-3-Clause + license_family: BSD + purls: + - pkg:pypi/pyserial?source=hash-mapping + size: 73910 + timestamp: 1767289527295 +- conda: https://prefix.dev/conda-forge/noarch/pytest-8.3.4-pyhd8ed1ab_1.conda + sha256: 75245ca9d0cbd6d38bb45ec02430189a9d4c21c055c5259739d738a2298d61b3 + md5: 799ed216dc6af62520f32aa39bc1c2bb + depends: + - colorama + - exceptiongroup >=1.0.0rc8 + - iniconfig + - packaging + - pluggy <2,>=1.5 + - python >=3.9 + - tomli >=1 + constrains: + - pytest-faulthandler >=2 + license: MIT + license_family: MIT + purls: + - pkg:pypi/pytest?source=hash-mapping + size: 259195 + timestamp: 1733217599806 +- conda: https://prefix.dev/conda-forge/noarch/python-dateutil-2.9.0.post0-pyhe01879c_2.conda + sha256: d6a17ece93bbd5139e02d2bd7dbfa80bee1a4261dced63f65f679121686bf664 + md5: 5b8d21249ff20967101ffa321cab24e8 + depends: + - python >=3.9 + - six >=1.5 + - python + license: Apache-2.0 + license_family: APACHE + purls: + - pkg:pypi/python-dateutil?source=hash-mapping + size: 233310 + timestamp: 1751104122689 +- conda: https://prefix.dev/conda-forge/noarch/python-discovery-1.3.0-pyhcf101f3_0.conda + sha256: ae70eb1c16970f2317e71dd2dee7d3a41abd26a47298ca8d9163a94b6579517b + md5: 696db6f25e56c0fafdccb0a7426fffb6 + depends: + - python >=3.10 + - filelock >=3.15.4 + - platformdirs <5,>=4.3.6 + - python + license: MIT + license_family: MIT + purls: + - pkg:pypi/python-discovery?source=hash-mapping + size: 35030 + timestamp: 1778013338579 +- conda: https://prefix.dev/conda-forge/noarch/python_abi-3.10-8_cp310.conda + build_number: 8 + sha256: 7ad76fa396e4bde336872350124c0819032a9e8a0a40590744ff9527b54351c1 + md5: 05e00f3b21e88bb3d658ac700b2ce58c + constrains: + - python 3.10.* *_cpython license: BSD-3-Clause license_family: BSD purls: [] - size: 80128 - timestamp: 1670387790769 -- conda: https://prefix.dev/conda-forge/noarch/packaging-26.2-pyhc364b38_0.conda - sha256: 3906abfb6511a3bb309e39b9b1b7bc38f50a723971de2395489fd1f379255890 - md5: 4c06a92e74452cfa53623a81592e8934 + size: 6999 + timestamp: 1752805924192 +- conda: https://prefix.dev/conda-forge/noarch/python_abi-3.11-8_cp311.conda + build_number: 8 + sha256: fddf123692aa4b1fc48f0471e346400d9852d96eeed77dbfdd746fa50a8ff894 + md5: 8fcb6b0e2161850556231336dae58358 + constrains: + - python 3.11.* *_cpython + license: BSD-3-Clause + license_family: BSD + purls: [] + size: 7003 + timestamp: 1752805919375 +- conda: https://prefix.dev/conda-forge/noarch/rich-14.3.4-pyhcf101f3_0.conda + sha256: a941b5e002504e1c9b02ea02180d40186b67d03e8e7d668bf746393c266b3951 + md5: 2e6a922d07244f514863b7e10bf5c923 + depends: + - markdown-it-py >=2.2.0 + - pygments >=2.13.0,<3.0.0 + - python >=3.10 + - typing_extensions >=4.0.0,<5.0.0 + - python + license: MIT + license_family: MIT + purls: + - pkg:pypi/rich?source=hash-mapping + size: 208480 + timestamp: 1775880677603 +- conda: https://prefix.dev/conda-forge/noarch/setuptools-82.0.1-pyh332efcf_0.conda + sha256: 82088a6e4daa33329a30bc26dc19a98c7c1d3f05c0f73ce9845d4eab4924e9e1 + md5: 8e194e7b992f99a5015edbd4ebd38efd + depends: + - python >=3.10 + license: MIT + license_family: MIT + purls: + - pkg:pypi/setuptools?source=hash-mapping + size: 639697 + timestamp: 1773074868565 +- conda: https://prefix.dev/conda-forge/noarch/shellingham-1.5.4-pyhd8ed1ab_2.conda + sha256: 1d6534df8e7924d9087bd388fbac5bd868c5bf8971c36885f9f016da0657d22b + md5: 83ea3a2ddb7a75c1b09cea582aa4f106 + depends: + - python >=3.10 + license: MIT + license_family: MIT + purls: + - pkg:pypi/shellingham?source=hash-mapping + size: 15018 + timestamp: 1762858315311 +- conda: https://prefix.dev/conda-forge/noarch/six-1.17.0-pyhe01879c_1.conda + sha256: 458227f759d5e3fcec5d9b7acce54e10c9e1f4f4b7ec978f3bfd54ce4ee9853d + md5: 3339e3b65d58accf4ca4fb8748ab16b3 + depends: + - python >=3.9 + - python + license: MIT + license_family: MIT + purls: + - pkg:pypi/six?source=hash-mapping + size: 18455 + timestamp: 1753199211006 +- conda: https://prefix.dev/conda-forge/noarch/snakeviz-2.2.2-pyhd8ed1ab_1.conda + sha256: 833326122c18887b338262c13365cb146b6702c79d72da74a1c6b8af4c50e162 + md5: 421b7a950e384949ca1b0f04f0751ce0 + depends: + - python >=3.9 + - tornado >=2.0 + license: BSD-3-Clause + license_family: BSD + purls: + - pkg:pypi/snakeviz?source=hash-mapping + size: 171545 + timestamp: 1735289409501 +- conda: https://prefix.dev/conda-forge/noarch/sniffio-1.3.1-pyhd8ed1ab_2.conda + sha256: dce518f45e24cd03f401cb0616917773159a210c19d601c5f2d4e0e5879d30ad + md5: 03fe290994c5e4ec17293cfb6bdce520 + depends: + - python >=3.10 + license: Apache-2.0 + license_family: Apache + purls: + - pkg:pypi/sniffio?source=hash-mapping + size: 15698 + timestamp: 1762941572482 +- conda: https://prefix.dev/conda-forge/noarch/tomli-2.4.1-pyhcf101f3_0.conda + sha256: 91cafdb64268e43e0e10d30bd1bef5af392e69f00edd34dfaf909f69ab2da6bd + md5: b5325cf06a000c5b14970462ff5e4d58 depends: - - python >=3.8 + - python >=3.10 - python + license: MIT + license_family: MIT + purls: + - pkg:pypi/tomli?source=hash-mapping + size: 21561 + timestamp: 1774492402955 +- conda: https://prefix.dev/conda-forge/noarch/tomli-w-1.2.0-pyhd8ed1ab_0.conda + sha256: 304834f2438017921d69f05b3f5a6394b42dc89a90a6128a46acbf8160d377f6 + md5: 32e37e8fe9ef45c637ee38ad51377769 + depends: + - python >=3.9 + license: MIT + license_family: MIT + purls: + - pkg:pypi/tomli-w?source=hash-mapping + size: 12680 + timestamp: 1736962345843 +- conda: https://prefix.dev/conda-forge/noarch/tomlkit-0.15.0-pyha770c72_0.conda + sha256: 1cd52f9ccb4854c4d731438afe0e833b6b71edaf5ede661152aa98efb3a7cc70 + md5: 42ef10a8f7f5d55a2e267c0d5daa6387 + depends: + - python >=3.10 + license: MIT + license_family: MIT + purls: + - pkg:pypi/tomlkit?source=hash-mapping + size: 41169 + timestamp: 1778423744478 +- conda: https://prefix.dev/conda-forge/noarch/trove-classifiers-2026.5.7.17-pyhd8ed1ab_0.conda + sha256: b06931edfab2f6bde64fae1e7323216b74389b5a27242bf2b54b401246efb04d + md5: 58ad6f35e45eca7db0fd5da95aafc693 + depends: + - python >=3.10 license: Apache-2.0 - license_family: APACHE + license_family: Apache purls: - - pkg:pypi/packaging?source=hash-mapping - size: 91574 - timestamp: 1777103621679 -- conda: https://prefix.dev/conda-forge/linux-64/pandas-3.0.1-py311h8032f78_0.conda - sha256: 3e58067de2e0b8220cf1323c1fc736028b2a117b7a7173bfe67f7da11094271f - md5: 3ac73c673df24589b5b84d43a4afd235 + - pkg:pypi/trove-classifiers?source=hash-mapping + size: 20076 + timestamp: 1778229720640 +- conda: https://prefix.dev/conda-forge/noarch/typing_extensions-4.15.0-pyhcf101f3_0.conda + sha256: 032271135bca55aeb156cee361c81350c6f3fb203f57d024d7e5a1fc9ef18731 + md5: 0caa1af407ecff61170c9437a808404d depends: + - python >=3.10 - python - - numpy >=1.26.0 - - python-dateutil >=2.8.2 - - libgcc >=14 - - __glibc >=2.17,<3.0.a0 - - libstdcxx >=14 - - python_abi 3.11.* *_cp311 - - numpy >=1.23,<3 + license: PSF-2.0 + license_family: PSF + purls: + - pkg:pypi/typing-extensions?source=hash-mapping + size: 51692 + timestamp: 1756220668932 +- conda: https://prefix.dev/conda-forge/noarch/tzdata-2025c-hc9c84f9_1.conda + sha256: 1d30098909076af33a35017eed6f2953af1c769e273a0626a04722ac4acaba3c + md5: ad659d0a2b3e47e38d829aa8cad2d610 + license: LicenseRef-Public-Domain + purls: [] + size: 119135 + timestamp: 1767016325805 +- conda: https://prefix.dev/conda-forge/noarch/userpath-1.9.2-pyhd8ed1ab_0.conda + sha256: 26e53b42f7fa1127e6115a35b91c20e15f75984648b88f115136f27715d4a440 + md5: 946e3571aaa55e0870fec0dea13de3bf + depends: + - click + - python >=3.9 + license: MIT + license_family: MIT + purls: + - pkg:pypi/userpath?source=hash-mapping + size: 14292 + timestamp: 1735925027874 +- conda: https://prefix.dev/conda-forge/noarch/virtualenv-21.3.1-pyhcf101f3_0.conda + sha256: 8888b4725d4166ab54435ba4b6a24e9f089578301a88f8157d012dd38a88ac43 + md5: dd6a1f3ce9d1cfa8b5b1b32953a80a55 + depends: + - python >=3.10 + - distlib >=0.3.7,<1 + - filelock <4,>=3.24.2 + - importlib-metadata >=6.6 + - platformdirs >=3.9.1,<5 + - python-discovery >=1 + - typing_extensions >=4.13.2 + - python + license: MIT + license_family: MIT + purls: + - pkg:pypi/virtualenv?source=hash-mapping + size: 5154970 + timestamp: 1777964652524 +- conda: https://prefix.dev/conda-forge/noarch/zipp-3.23.1-pyhcf101f3_0.conda + sha256: 523616c0530d305d2216c2b4a8dfd3872628b60083255b89c5e0d8c42e738cca + md5: e1c36c6121a7c9c76f2f148f1e83b983 + depends: + - python >=3.10 + - python + license: MIT + license_family: MIT + purls: + - pkg:pypi/zipp?source=hash-mapping + size: 24461 + timestamp: 1776131454755 +- conda: https://prefix.dev/conda-forge/osx-arm64/_openmp_mutex-4.5-7_kmp_llvm.conda + build_number: 7 + sha256: 7acaa2e0782cad032bdaf756b536874346ac1375745fb250e9bdd6a48a7ab3cd + md5: a44032f282e7d2acdeb1c240308052dd + depends: + - llvm-openmp >=9.0.1 + license: BSD-3-Clause + license_family: BSD + purls: [] + size: 8325 + timestamp: 1764092507920 +- conda: https://prefix.dev/conda-forge/osx-arm64/aom-3.9.1-h7bae524_0.conda + sha256: ec238f18ce8140485645252351a0eca9ef4f7a1c568a420f240a585229bc12ef + md5: 7adba36492a1bb22d98ffffe4f6fc6de + depends: + - __osx >=11.0 + - libcxx >=16 + license: BSD-2-Clause + license_family: BSD + purls: [] + size: 2235747 + timestamp: 1718551382432 +- conda: https://prefix.dev/conda-forge/osx-arm64/atk-1.0-2.38.0-hd03087b_2.conda + sha256: b0747f9b1bc03d1932b4d8c586f39a35ac97e7e72fe6e63f2b2a2472d466f3c1 + md5: 57301986d02d30d6805fdce6c99074ee + depends: + - __osx >=11.0 + - libcxx >=16 + - libglib >=2.80.0,<3.0a0 + - libintl >=0.22.5,<1.0a0 constrains: - - adbc-driver-postgresql >=1.2.0 - - adbc-driver-sqlite >=1.2.0 - - beautifulsoup4 >=4.12.3 - - blosc >=1.21.3 - - bottleneck >=1.4.2 - - fastparquet >=2024.11.0 - - fsspec >=2024.10.0 - - gcsfs >=2024.10.0 - - html5lib >=1.1 - - hypothesis >=6.116.0 - - jinja2 >=3.1.5 - - lxml >=5.3.0 - - matplotlib >=3.9.3 - - numba >=0.60.0 - - numexpr >=2.10.2 - - odfpy >=1.4.1 - - openpyxl >=3.1.5 - - psycopg2 >=2.9.10 - - pyarrow >=13.0.0 - - pyiceberg >=0.8.1 - - pymysql >=1.1.1 - - pyqt5 >=5.15.9 - - pyreadstat >=1.2.8 - - pytables >=3.10.1 - - pytest >=8.3.4 - - pytest-xdist >=3.6.1 - - python-calamine >=0.3.0 - - pytz >=2024.2 - - pyxlsb >=1.0.10 - - qtpy >=2.4.2 - - scipy >=1.14.1 - - s3fs >=2024.10.0 - - sqlalchemy >=2.0.36 - - tabulate >=0.9.0 - - xarray >=2024.10.0 - - xlrd >=2.0.1 - - xlsxwriter >=3.2.0 - - zstandard >=0.23.0 + - atk-1.0 2.38.0 + license: LGPL-2.0-or-later + license_family: LGPL + purls: [] + size: 347530 + timestamp: 1713896411580 +- conda: https://prefix.dev/conda-forge/osx-arm64/backports.zstd-1.4.0-py311h36d4fbb_0.conda + sha256: 2e6399a3663e7e20134a208cd09befc44ce1e9efe94d1d36d8911db04f186270 + md5: 3ee7e8ae532366221658b80baee36dc0 + depends: + - python + - __osx >=11.0 + - python_abi 3.11.* *_cp311 + - zstd >=1.5.7,<1.6.0a0 + license: BSD-3-Clause AND MIT AND EPL-2.0 + purls: + - pkg:pypi/backports-zstd?source=hash-mapping + size: 244743 + timestamp: 1777848723707 +- conda: https://prefix.dev/conda-forge/osx-arm64/brotli-1.2.0-hf00d406_3.conda + sha256: 7050e1b11876219bd0df375ef3d83fd00f94fb4e13c1ffb21dede0c506893079 + md5: aa7df8174ee3b34a5ad8a3160429db68 + depends: + - __osx >=11.0 + - brotli-bin 1.2.0 he4a93e4_3 + - libbrotlidec 1.2.0 h5295a6a_3 + - libbrotlienc 1.2.0 h2ddc9cb_3 + license: MIT + license_family: MIT + purls: [] + size: 20767 + timestamp: 1786622887445 +- conda: https://prefix.dev/conda-forge/osx-arm64/brotli-bin-1.2.0-he4a93e4_3.conda + sha256: 1e92cea587c2eaab169e45dae01c149b9889a8249eda296b8b6db39aee708531 + md5: d9de6c0ad7e008afdf62fb2ffd450b4a + depends: + - __osx >=11.0 + - libbrotlidec 1.2.0 h5295a6a_3 + - libbrotlienc 1.2.0 h2ddc9cb_3 + license: MIT + license_family: MIT + purls: [] + size: 18962 + timestamp: 1786622878369 +- conda: https://prefix.dev/conda-forge/osx-arm64/bzip2-1.0.8-hd037594_9.conda + sha256: 540fe54be35fac0c17feefbdc3e29725cce05d7367ffedfaaa1bdda234b019df + md5: 620b85a3f45526a8bc4d23fd78fc22f0 + depends: + - __osx >=11.0 + license: bzip2-1.0.6 + license_family: BSD + purls: [] + size: 124834 + timestamp: 1771350416561 +- conda: https://prefix.dev/conda-forge/osx-arm64/c-ares-1.34.6-hc919400_0.conda + sha256: 2995f2aed4e53725e5efbc28199b46bf311c3cab2648fc4f10c2227d6d5fa196 + md5: bcb3cba70cf1eec964a03b4ba7775f01 + depends: + - __osx >=11.0 + license: MIT + license_family: MIT + purls: [] + size: 180327 + timestamp: 1765215064054 +- conda: https://prefix.dev/conda-forge/osx-arm64/cairo-1.18.4-he0f2337_1.conda + sha256: cde9b79ee206fe3ba6ca2dc5906593fb7a1350515f85b2a1135a4ce8ec1539e3 + md5: 36200ecfbbfbcb82063c87725434161f + depends: + - __osx >=11.0 + - fontconfig >=2.15.0,<3.0a0 + - fonts-conda-ecosystem + - icu >=78.1,<79.0a0 + - libcxx >=19 + - libexpat >=2.7.3,<3.0a0 + - libfreetype >=2.14.1 + - libfreetype6 >=2.14.1 + - libglib >=2.86.3,<3.0a0 + - libpng >=1.6.53,<1.7.0a0 + - libzlib >=1.3.1,<2.0a0 + - pixman >=0.46.4,<1.0a0 + license: LGPL-2.1-only or MPL-1.1 + purls: [] + size: 900035 + timestamp: 1766416416791 +- conda: https://prefix.dev/conda-forge/osx-arm64/cffi-2.0.0-py311hd10dc20_1.conda + sha256: 1ffde698463d6e7ed571bdb85cb17bfc1d3a107c026d20047995512dcc2749ec + md5: 4d7f6780e36f18e7601811dddf3bbec5 + depends: + - __osx >=11.0 + - libffi >=3.5.2,<3.6.0a0 + - pycparser + - python >=3.11,<3.12.0a0 + - python >=3.11,<3.12.0a0 *_cpython + - python_abi 3.11.* *_cp311 + license: MIT + license_family: MIT + purls: + - pkg:pypi/cffi?source=hash-mapping + size: 294848 + timestamp: 1761203196617 +- conda: https://prefix.dev/conda-forge/osx-arm64/cmake-3.26.4-hc0af03a_0.conda + sha256: cba596b6bba58e347bd8be51fce82583f16c5707f6c98b22a7e7ba1ecdb09783 + md5: 84c170713e88c74f45fd87ce2a065cd3 + depends: + - bzip2 >=1.0.8,<2.0a0 + - expat + - libcurl >=8.1.0,<9.0a0 + - libcxx >=15.0.7 + - libexpat >=2.5.0,<3.0a0 + - libuv + - libzlib >=1.2.13,<2.0.0a0 + - ncurses >=6.3,<7.0a0 + - rhash <=1.4.3 + - xz >=5.2.6,<6.0a0 + - zlib + - zstd >=1.5.2,<1.6.0a0 license: BSD-3-Clause license_family: BSD - purls: - - pkg:pypi/pandas?source=hash-mapping - size: 15143263 - timestamp: 1771408984246 -- conda: https://prefix.dev/conda-forge/osx-arm64/pandas-3.0.1-py311h4a068b9_0.conda - sha256: 1a0f57d3c5fb08e97c8a92f560e1ce011f4ab5a1185eacb60e83c00458684dc4 - md5: e853dd807ee17d7d4f6c3c57b29456ac + purls: [] + size: 13748747 + timestamp: 1684461655168 +- conda: https://prefix.dev/conda-forge/osx-arm64/contourpy-1.3.3-py311h7d85929_4.conda + sha256: 57b2c28cbb45e7dacb565541483d802a15c6beff5ccdabba19784a526191f4d3 + md5: bd91dd35d73638e5c0f520a18850f6ba depends: + - numpy >=1.25 - python - - numpy >=1.26.0 - - python-dateutil >=2.8.2 + - python 3.11.* *_cpython - __osx >=11.0 - libcxx >=19 - - python 3.11.* *_cpython - - numpy >=1.23,<3 - python_abi 3.11.* *_cp311 - constrains: - - adbc-driver-postgresql >=1.2.0 - - adbc-driver-sqlite >=1.2.0 - - beautifulsoup4 >=4.12.3 - - blosc >=1.21.3 - - bottleneck >=1.4.2 - - fastparquet >=2024.11.0 - - fsspec >=2024.10.0 - - gcsfs >=2024.10.0 - - html5lib >=1.1 - - hypothesis >=6.116.0 - - jinja2 >=3.1.5 - - lxml >=5.3.0 - - matplotlib >=3.9.3 - - numba >=0.60.0 - - numexpr >=2.10.2 - - odfpy >=1.4.1 - - openpyxl >=3.1.5 - - psycopg2 >=2.9.10 - - pyarrow >=13.0.0 - - pyiceberg >=0.8.1 - - pymysql >=1.1.1 - - pyqt5 >=5.15.9 - - pyreadstat >=1.2.8 - - pytables >=3.10.1 - - pytest >=8.3.4 - - pytest-xdist >=3.6.1 - - python-calamine >=0.3.0 - - pytz >=2024.2 - - pyxlsb >=1.0.10 - - qtpy >=2.4.2 - - scipy >=1.14.1 - - s3fs >=2024.10.0 - - sqlalchemy >=2.0.36 - - tabulate >=0.9.0 - - xarray >=2024.10.0 - - xlrd >=2.0.1 - - xlsxwriter >=3.2.0 - - zstandard >=0.23.0 license: BSD-3-Clause license_family: BSD purls: - - pkg:pypi/pandas?source=hash-mapping - size: 14295353 - timestamp: 1771409101672 -- conda: https://prefix.dev/conda-forge/linux-64/pango-1.56.4-hadf4263_0.conda - sha256: 3613774ad27e48503a3a6a9d72017087ea70f1426f6e5541dbdb59a3b626eaaf - md5: 79f71230c069a287efe3a8614069ddf1 + - pkg:pypi/contourpy?source=hash-mapping + size: 286095 + timestamp: 1769156091585 +- conda: https://prefix.dev/conda-forge/osx-arm64/dav1d-1.2.1-hb547adb_0.conda + sha256: 93e077b880a85baec8227e8c72199220c7f87849ad32d02c14fb3807368260b8 + md5: 5a74cdee497e6b65173e10d94582fae6 + license: BSD-2-Clause + license_family: BSD + purls: [] + size: 316394 + timestamp: 1685695959391 +- conda: https://prefix.dev/conda-forge/osx-arm64/dbus-1.16.2-h3ff7a7c_1.conda + sha256: a8207751ed261764061866880da38e4d3063e167178bfe85b6db9501432462ba + md5: 5a3506971d2d53023c1c4450e908a8da depends: - - __glibc >=2.17,<3.0.a0 - - cairo >=1.18.4,<2.0a0 - - fontconfig >=2.15.0,<3.0a0 - - fonts-conda-ecosystem - - fribidi >=1.0.10,<2.0a0 - - harfbuzz >=11.0.1 - - libexpat >=2.7.0,<3.0a0 - - libfreetype >=2.13.3 - - libfreetype6 >=2.13.3 - - libgcc >=13 - - libglib >=2.84.2,<3.0a0 - - libpng >=1.6.49,<1.7.0a0 + - libcxx >=19 + - __osx >=11.0 + - libglib >=2.86.2,<3.0a0 + - libzlib >=1.3.1,<2.0a0 + - libexpat >=2.7.3,<3.0a0 + license: AFL-2.1 OR GPL-2.0-or-later + purls: [] + size: 393811 + timestamp: 1764536084131 +- conda: https://prefix.dev/conda-forge/osx-arm64/epoxy-1.5.10-hc919400_2.conda + sha256: ba685b87529c95a4bf9de140a33d703d57dc46b036e9586ed26890de65c1c0d5 + md5: 3b87dabebe54c6d66a07b97b53ac5874 + depends: + - __osx >=11.0 + license: MIT + license_family: MIT + purls: [] + size: 296347 + timestamp: 1758743805063 +- conda: https://prefix.dev/conda-forge/osx-arm64/expat-2.8.0-hf6b4638_0.conda + sha256: 9f8657c32bcff353b218b1bd7369de34c0534dc5a461630b296265e65e94e2d8 + md5: 90f3b6fa818b07e9402d5ee89f3892d5 + depends: + - __osx >=11.0 + - libexpat 2.8.0 hf6b4638_0 + license: MIT + license_family: MIT + purls: [] + size: 135334 + timestamp: 1777846191235 +- conda: https://prefix.dev/conda-forge/osx-arm64/fluidsynth-2.5.4-h985f16e_0.conda + sha256: 6fab2acb6b1c7ba0fc06c3d4cefa552c3da4c3d6a79dcdd2158eea96931c3929 + md5: 1f716f3ba6477330807ed061637048c7 + depends: + - __osx >=11.0 + - libcxx >=19 + - libglib >=2.86.4,<3.0a0 + - libsndfile >=1.2.2,<1.3.0a0 + - llvm-openmp >=19.1.7 + - portaudio >=19.7.0,<19.8.0a0 + - readline >=8.3,<9.0a0 + - sdl2 >=2.32.56,<3.0a0 + license: GPL-2.0-or-later + license_family: LGPL + purls: [] + size: 291966 + timestamp: 1776634889426 +- conda: https://prefix.dev/conda-forge/osx-arm64/fontconfig-2.17.1-h2b252f5_0.conda + sha256: 851e9c778bfc54645dcab7038c0383445cbebf16f6bb2d3f62ce422b1605385a + md5: d06ae1a11b46cc4c74177ecd28de7c7a + depends: + - __osx >=11.0 + - libexpat >=2.7.4,<3.0a0 + - libfreetype >=2.14.1 + - libfreetype6 >=2.14.1 - libzlib >=1.3.1,<2.0a0 + license: MIT + license_family: MIT + purls: [] + size: 237308 + timestamp: 1771382999247 +- conda: https://prefix.dev/conda-forge/osx-arm64/fonttools-4.63.0-py311hc290fe0_0.conda + sha256: e339446253b5aec4342526334cb2575a20beaf15478469d9baa3c5a11c7aa498 + md5: 23ee082b5c5dc73c19dc0b6451d35079 + depends: + - __osx >=11.0 + - brotli + - munkres + - python >=3.11,<3.12.0a0 + - python >=3.11,<3.12.0a0 *_cpython + - python_abi 3.11.* *_cp311 + - unicodedata2 >=15.1.0 + license: MIT + license_family: MIT + purls: + - pkg:pypi/fonttools?source=hash-mapping + size: 2948507 + timestamp: 1778771011007 +- conda: https://prefix.dev/conda-forge/osx-arm64/freetype-2.14.3-hce30654_0.conda + sha256: 5952bd9db12207a18a112e8924aa2ce8c2f9d57b62584d58a97d2f6afe1ea324 + md5: 6dcc75ba2e04c555e881b72793d3282f + depends: + - libfreetype 2.14.3 hce30654_0 + - libfreetype6 2.14.3 hdfa99f5_0 + license: GPL-2.0-only OR FTL + purls: [] + size: 173313 + timestamp: 1774298702053 +- conda: https://prefix.dev/conda-forge/osx-arm64/fribidi-1.0.16-hc919400_0.conda + sha256: d856dc6744ecfba78c5f7df3378f03a75c911aadac803fa2b41a583667b4b600 + md5: 04bdce8d93a4ed181d1d726163c2d447 + depends: + - __osx >=11.0 license: LGPL-2.1-or-later purls: [] - size: 455420 - timestamp: 1751292466873 -- conda: https://prefix.dev/conda-forge/osx-arm64/pango-1.56.4-h875632e_0.conda - sha256: 705484ad60adee86cab1aad3d2d8def03a699ece438c864e8ac995f6f66401a6 - md5: 7d57f8b4b7acfc75c777bc231f0d31be + size: 59391 + timestamp: 1757438897523 +- conda: https://prefix.dev/conda-forge/osx-arm64/gdk-pixbuf-2.44.6-h4e57454_0.conda + sha256: 07cbba4e12430de35ea608eb3006cf1f7f63832c4f89a081cd6f3872944c1aa6 + md5: e67ebd2f639f46e52af8531622fa6051 + depends: + - __osx >=11.0 + - libglib >=2.86.4,<3.0a0 + - libintl >=0.25.1,<1.0a0 + - libjpeg-turbo >=3.1.2,<4.0a0 + - liblzma >=5.8.2,<6.0a0 + - libpng >=1.6.56,<1.7.0a0 + - libtiff >=4.7.1,<4.8.0a0 + license: LGPL-2.1-or-later + license_family: LGPL + purls: [] + size: 548309 + timestamp: 1774986047281 +- conda: https://prefix.dev/conda-forge/osx-arm64/glib-tools-2.88.3-h5f197ff_0.conda + sha256: 672b06a290ae9bd4443f9315334f2dbb6d0ba239b3a1f2ea40fd66321e7a3ac6 + md5: 607824e2f42f49049c999432385832e3 depends: + - libglib ==2.88.3 ha08bb59_0 + - libffi - __osx >=11.0 - - cairo >=1.18.4,<2.0a0 - - fontconfig >=2.15.0,<3.0a0 - - fonts-conda-ecosystem - - fribidi >=1.0.10,<2.0a0 - - harfbuzz >=11.0.1 - - libexpat >=2.7.0,<3.0a0 - - libfreetype >=2.13.3 - - libfreetype6 >=2.13.3 - - libglib >=2.84.2,<3.0a0 - - libpng >=1.6.49,<1.7.0a0 - - libzlib >=1.3.1,<2.0a0 + - libintl >=0.25.1,<1.0a0 license: LGPL-2.1-or-later purls: [] - size: 426931 - timestamp: 1751292636271 -- conda: https://prefix.dev/conda-forge/noarch/pathspec-1.1.1-pyhd8ed1ab_0.conda - sha256: 6eaee417d33f298db79bc7185ab1208604c0e6cf51dade34cd513c6f9db9c6f3 - md5: 11adc78451c998c0fd162584abfa3559 + size: 205078 + timestamp: 1785442168180 +- conda: https://prefix.dev/conda-forge/osx-arm64/graphite2-1.3.15-h784d473_1.conda + sha256: 471f34a187fdb4f2df33e26f2e471b16c239a5b277903f643d9c3a8c9a9f44ec + md5: 0c7b78d9ffff4f5a6ca28d346f734d8f depends: - - python >=3.10 - license: MPL-2.0 - license_family: MOZILLA - purls: - - pkg:pypi/pathspec?source=hash-mapping - size: 56559 - timestamp: 1777271601895 -- conda: https://prefix.dev/conda-forge/linux-64/pcre2-10.47-haa7fec5_0.conda - sha256: 5e6f7d161356fefd981948bea5139c5aa0436767751a6930cb1ca801ebb113ff - md5: 7a3bff861a6583f1889021facefc08b1 + - libcxx >=19 + - __osx >=11.0 + license: LGPL-2.0-or-later + license_family: LGPL + purls: [] + size: 86493 + timestamp: 1786118637573 +- conda: https://prefix.dev/conda-forge/osx-arm64/graphviz-13.1.2-hcd33d8b_0.conda + sha256: f25e1828d02ebd78214966f483cfca5ac6a7b18824369c748d8cda99c66ff588 + md5: 81ab85a5a8481667660c7ce6e84bd681 depends: - - __glibc >=2.17,<3.0.a0 - - bzip2 >=1.0.8,<2.0a0 - - libgcc >=14 + - __osx >=11.0 + - adwaita-icon-theme + - cairo >=1.18.4,<2.0a0 + - fonts-conda-ecosystem + - gdk-pixbuf >=2.42.12,<3.0a0 + - gtk3 >=3.24.43,<4.0a0 + - gts >=0.7.6,<0.8.0a0 + - libcxx >=19 + - libexpat >=2.7.1,<3.0a0 + - libgd >=2.3.3,<2.4.0a0 + - libglib >=2.84.3,<3.0a0 + - librsvg >=2.58.4,<3.0a0 + - libwebp-base >=1.6.0,<2.0a0 - libzlib >=1.3.1,<2.0a0 - license: BSD-3-Clause - license_family: BSD + - pango >=1.56.4,<2.0a0 + license: EPL-1.0 + license_family: Other purls: [] - size: 1222481 - timestamp: 1763655398280 -- conda: https://prefix.dev/conda-forge/osx-arm64/pcre2-10.47-h30297fc_0.conda - sha256: 5e2e443f796f2fd92adf7978286a525fb768c34e12b1ee9ded4000a41b2894ba - md5: 9b4190c4055435ca3502070186eba53a + size: 2201370 + timestamp: 1754732518951 +- conda: https://prefix.dev/conda-forge/osx-arm64/gtk3-3.24.43-h5febe37_6.conda + sha256: bd66a3325bf3ce63ada3bf12eaafcfe036698741ee4bb595e83e5fdd3dba9f3d + md5: a99f96906158ebae5e3c0904bcd45145 depends: - __osx >=11.0 - - bzip2 >=1.0.8,<2.0a0 + - atk-1.0 >=2.38.0 + - cairo >=1.18.4,<2.0a0 + - epoxy >=1.5.10,<1.6.0a0 + - fribidi >=1.0.16,<2.0a0 + - gdk-pixbuf >=2.44.4,<3.0a0 + - glib-tools + - harfbuzz >=11.5.1 + - hicolor-icon-theme + - libexpat >=2.7.1,<3.0a0 + - libglib >=2.86.0,<3.0a0 + - libintl >=0.25.1,<1.0a0 + - liblzma >=5.8.1,<6.0a0 - libzlib >=1.3.1,<2.0a0 - license: BSD-3-Clause - license_family: BSD + - pango >=1.56.4,<2.0a0 + license: LGPL-2.0-or-later + license_family: LGPL purls: [] - size: 850231 - timestamp: 1763655726735 -- conda: https://prefix.dev/conda-forge/noarch/pexpect-4.9.0-pyhd8ed1ab_1.conda - sha256: 202af1de83b585d36445dc1fda94266697341994d1a3328fabde4989e1b3d07a - md5: d0d408b1f18883a944376da5cf8101ea - depends: - - ptyprocess >=0.5 - - python >=3.9 - license: ISC - purls: - - pkg:pypi/pexpect?source=hash-mapping - size: 53561 - timestamp: 1733302019362 -- conda: https://prefix.dev/conda-forge/linux-64/pillow-12.3.0-py311hf88fc01_0.conda - sha256: fc8a6dbcf1f367cc33ae6d505370b8d9d51ca5eae9b53bf1517307f863300d27 - md5: 9782d37ef50862d2c8a9ba58c1725754 + size: 4768791 + timestamp: 1761328318680 +- conda: https://prefix.dev/conda-forge/osx-arm64/gts-0.7.6-he42f4ea_4.conda + sha256: e0f8c7bc1b9ea62ded78ffa848e37771eeaaaf55b3146580513c7266862043ba + md5: 21b4dd3098f63a74cf2aa9159cbef57d depends: - - python - - libgcc >=14 - - __glibc >=2.17,<3.0.a0 - - openjpeg >=2.5.4,<3.0a0 - - lcms2 >=2.19.1,<3.0a0 - - libxcb >=1.17.0,<2.0a0 - - libfreetype >=2.14.3 - - libfreetype6 >=2.14.3 - - tk >=8.6.13,<8.7.0a0 - - libjpeg-turbo >=3.1.4.1,<4.0a0 - - libwebp-base >=1.6.0,<2.0a0 - - python_abi 3.11.* *_cp311 - - libtiff >=4.7.1,<4.8.0a0 - - zlib-ng >=2.3.3,<2.4.0a0 - license: HPND - purls: - - pkg:pypi/pillow?source=hash-mapping - size: 1081155 - timestamp: 1782912080163 -- conda: https://prefix.dev/conda-forge/osx-arm64/pillow-12.3.0-py311hd37aea2_0.conda - sha256: 3c680e002d0aadf9e21b6ee50929d8fec6ced9234b1340a027255b4518e6e49f - md5: 26ba3b773222fada6f89baf4846190e3 + - libcxx >=15.0.7 + - libglib >=2.76.3,<3.0a0 + license: LGPL-2.0-or-later + license_family: LGPL + purls: [] + size: 304331 + timestamp: 1686545503242 +- conda: https://prefix.dev/conda-forge/osx-arm64/gymnasium-1.3.0-np2py311h56d0776_0.conda + sha256: ab03d30592506e1dfe9e6fc30cddea577dd42a7eb4b6da8a80de543928e2e6fd + md5: d64237fee1a064db6f7c53090a6844da depends: - python - - python 3.11.* *_cpython - - __osx >=11.0 - - openjpeg >=2.5.4,<3.0a0 - - libfreetype >=2.14.3 - - libfreetype6 >=2.14.3 - - libjpeg-turbo >=3.1.4.1,<4.0a0 - - zlib-ng >=2.3.3,<2.4.0a0 + - cloudpickle >=1.2.0 + - farama-notifications + - jax-jumpy >=1.0.0 + - typing_extensions >=4.3.0 - python_abi 3.11.* *_cp311 - - libtiff >=4.7.1,<4.8.0a0 - - libxcb >=1.17.0,<2.0a0 - - tk >=8.6.13,<8.7.0a0 - - lcms2 >=2.19.1,<3.0a0 - - libwebp-base >=1.6.0,<2.0a0 - license: HPND + - numpy >=1.23,<3 + license: MIT + license_family: MIT purls: - - pkg:pypi/pillow?source=hash-mapping - size: 993213 - timestamp: 1782912213683 -- conda: https://prefix.dev/conda-forge/linux-64/pixman-0.46.4-h54a6638_1.conda - sha256: 43d37bc9ca3b257c5dd7bf76a8426addbdec381f6786ff441dc90b1a49143b6a - md5: c01af13bdc553d1a8fbfff6e8db075f0 + - pkg:pypi/gymnasium?source=hash-mapping + size: 1138451 + timestamp: 1777204698446 +- conda: https://prefix.dev/conda-forge/osx-arm64/harfbuzz-14.3.1-hce30654_0.conda + sha256: 1120c57b917fb0bb8fef770d56f308564c94daea0eb29a643c9f5cf73195de78 + md5: 4fb57d98ef4b5f335d96d3ab0f25d6ea depends: - - libgcc >=14 - - libstdcxx >=14 - - libgcc >=14 - - __glibc >=2.17,<3.0.a0 + - libharfbuzz-devel 14.3.1 hcda0f7c_0 license: MIT license_family: MIT purls: [] - size: 450960 - timestamp: 1754665235234 -- conda: https://prefix.dev/conda-forge/osx-arm64/pixman-0.46.4-h81086ad_1.conda - sha256: 29c9b08a9b8b7810f9d4f159aecfd205fce051633169040005c0b7efad4bc718 - md5: 17c3d745db6ea72ae2fce17e7338547f + size: 11045 + timestamp: 1786970975481 +- conda: https://prefix.dev/conda-forge/osx-arm64/hicolor-icon-theme-0.17-hce30654_3.conda + sha256: 46a4958f2f916c5938f2a6dc0709f78b175ece42f601d79a04e0276d55d25d07 + md5: cfb39109ac5fa8601eb595d66d5bf156 + license: GPL-2.0-or-later + license_family: GPL + purls: [] + size: 17616 + timestamp: 1771539622983 +- conda: https://prefix.dev/conda-forge/osx-arm64/icu-78.3-py310h579977c_2.conda + sha256: 6cdb5dee54c72e56ab189fb3ad33cb28533553d42590e7e831160248f4416a43 + md5: a5efc0b42bb8b42e97d0a29ae3e3c187 depends: - __osx >=11.0 - - libcxx >=19 license: MIT license_family: MIT purls: [] - size: 248045 - timestamp: 1754665282033 -- conda: https://prefix.dev/conda-forge/noarch/platformdirs-4.9.6-pyhcf101f3_0.conda - sha256: 8f29915c172f1f7f4f7c9391cd5dac3ebf5d13745c8b7c8006032615246345a5 - md5: 89c0b6d1793601a2a3a3f7d2d3d8b937 - depends: - - python >=3.10 - - python - license: MIT - license_family: MIT - purls: - - pkg:pypi/platformdirs?source=hash-mapping - size: 25862 - timestamp: 1775741140609 -- conda: https://prefix.dev/conda-forge/noarch/pluggy-1.6.0-pyhf9edf01_1.conda - sha256: e14aafa63efa0528ca99ba568eaf506eb55a0371d12e6250aaaa61718d2eb62e - md5: d7585b6550ad04c8c5e21097ada2888e + size: 14070242 + timestamp: 1786545847761 +- conda: https://prefix.dev/conda-forge/osx-arm64/kiwisolver-1.5.0-py311h7d85929_0.conda + sha256: bad01811dae8d727a7ff5a271c8304be495e7e594dfddb9f1d576e41ba7c1a76 + md5: 9b4b32f37ebf95463c38636ae2f2ec56 depends: - - python >=3.9 - python - license: MIT - license_family: MIT + - __osx >=11.0 + - python 3.11.* *_cpython + - libcxx >=19 + - python_abi 3.11.* *_cp311 + license: BSD-3-Clause + license_family: BSD purls: - - pkg:pypi/pluggy?source=hash-mapping - size: 25877 - timestamp: 1764896838868 -- conda: https://prefix.dev/conda-forge/linux-64/portaudio-19.7.0-hf4617a5_0.conda - sha256: 3259d2bf63d0c889c516511c8fa73214791ca30baeeee0962eee8b97d17cd1c6 - md5: 053455c094c711e9aa77cf5023cf2bc3 - depends: - - __glibc >=2.17,<3.0.a0 - - alsa-lib >=1.2.12,<1.3.0a0 - - libgcc >=13 - - libstdcxx >=13 - license: MIT - license_family: MIT - purls: [] - size: 77342 - timestamp: 1730364040048 -- conda: https://prefix.dev/conda-forge/osx-arm64/portaudio-19.7.0-h5833ebf_0.conda - sha256: 3d86803ade1ff3fd29ea1b61ce2e5ad65af0966d795ab8a7a2685fee75cf0f82 - md5: fb72bb70cfea298990d5e1a12317047c + - pkg:pypi/kiwisolver?source=hash-mapping + size: 66903 + timestamp: 1773067313219 +- conda: https://prefix.dev/conda-forge/osx-arm64/krb5-1.22.2-h385eeb1_0.conda + sha256: c0a0bf028fe7f3defcdcaa464e536cf1b202d07451e18ad83fdd169d15bef6ed + md5: e446e1822f4da8e5080a9de93474184d depends: - __osx >=11.0 - - libcxx >=17 + - libcxx >=19 + - libedit >=3.1.20250104,<3.2.0a0 + - libedit >=3.1.20250104,<4.0a0 + - openssl >=3.5.5,<4.0a0 license: MIT license_family: MIT purls: [] - size: 58138 - timestamp: 1730364270871 -- conda: https://prefix.dev/conda-forge/linux-64/portmidi-2.0.8-h3cb78e3_0.conda - sha256: 13b1f300f609d386d7aec2e31c4ab2fd35c0ed6a2b28ec89605db5b4b044514b - md5: 2333d6737b6fd5c6a70977f8ec1bf110 + size: 1160828 + timestamp: 1769770119811 +- conda: https://prefix.dev/conda-forge/osx-arm64/lame-3.100-h1a8c8d9_1003.tar.bz2 + sha256: f40ce7324b2cf5338b766d4cdb8e0453e4156a4f83c2f31bbfff750785de304c + md5: bff0e851d66725f78dc2fd8b032ddb7e + license: LGPL-2.0-only + license_family: LGPL + purls: [] + size: 528805 + timestamp: 1664996399305 +- conda: https://prefix.dev/conda-forge/osx-arm64/lcms2-2.19.1-hdfa7624_1.conda + sha256: ccb5598fad3694e79bf54f0eb812e3b3c3dd63d1497e631f5978800eadb9bcc4 + md5: d2f2c7c10e2957647d45589b7701a453 depends: - - __glibc >=2.17,<3.0.a0 - - alsa-lib >=1.2.14,<1.3.0a0 - - libgcc >=14 - - libstdcxx >=14 + - __osx >=11.0 + - libjpeg-turbo >=3.1.4.1,<4.0a0 + - libtiff >=4.7.1,<4.8.0a0 license: MIT license_family: MIT purls: [] - size: 44178 - timestamp: 1764706159843 -- conda: https://prefix.dev/conda-forge/osx-arm64/portmidi-2.0.8-haf25636_0.conda - sha256: 2a1fb2c2507a3b88ac68c4dac435a836be365446e66e995749d2188456fb4262 - md5: 2544b03efb37c9476f3ab4e993c224d1 + size: 213747 + timestamp: 1780212240694 +- conda: https://prefix.dev/conda-forge/osx-arm64/lerc-4.1.0-h1eee2c3_0.conda + sha256: 66e5ffd301a44da696f3efc2f25d6d94f42a9adc0db06c44ad753ab844148c51 + md5: 095e5749868adab9cae42d4b460e5443 depends: - __osx >=11.0 - libcxx >=19 - license: MIT - license_family: MIT + license: Apache-2.0 + license_family: Apache purls: [] - size: 41391 - timestamp: 1764706738148 -- conda: https://prefix.dev/conda-forge/noarch/pre-commit-4.6.0-pyha770c72_0.conda - sha256: 716960bf0a9eb334458a26b3bdcb17b8d0786062138a4f48c7f335c8418c5d0b - md5: 7859736b4f8ebe6c8481bf48d91c9a1e - depends: - - cfgv >=2.0.0 - - identify >=1.0.0 - - nodeenv >=0.11.1 - - python >=3.10 - - pyyaml >=5.1 - - virtualenv >=20.10.0 - license: MIT - license_family: MIT - purls: - - pkg:pypi/pre-commit?source=hash-mapping - size: 201606 - timestamp: 1776858157327 -- conda: https://prefix.dev/conda-forge/linux-64/protobuf-3.20.2-py311ha362b79_1.conda - sha256: b5927c5e5d3d2bee29e87cfee3e45781e6f6fd663e890389726cd513ef746177 - md5: 9d64275197aab7121cd9318b593a21bd + size: 164222 + timestamp: 1773114244984 +- conda: https://prefix.dev/conda-forge/osx-arm64/libavif16-1.4.1-hfce71f6_0.conda + sha256: 09e31e51026a3b74d947ba4b30a68dd99013aeef2860bcb03565bf43cad18da6 + md5: 2df04ee54a2ce2d34cf375eb02a63725 depends: - - libgcc-ng >=12 - - libprotobuf 3.20.2.* - - libprotobuf >=3.20.2,<3.21.0a0 - - libstdcxx-ng >=12 - - python >=3.11,<3.12.0a0 - - python_abi 3.11.* *_cp311 - - setuptools - - six - license: BSD-3-Clause + - __osx >=11.0 + - aom >=3.9.1,<3.10.0a0 + - dav1d >=1.2.1,<1.2.2.0a0 + - rav1e >=0.8.1,<0.9.0a0 + - svt-av1 >=4.0.1,<4.0.2.0a0 + license: BSD-2-Clause license_family: BSD - purls: - - pkg:pypi/protobuf?source=hash-mapping - size: 368989 - timestamp: 1669119100095 -- conda: https://prefix.dev/conda-forge/osx-arm64/protobuf-3.20.2-py311ha397e9f_1.conda - sha256: 38ea7c727a352ae38199c9b87b5b5636cd6bb62de13491788d803e69611776da - md5: cfa15b242f40e62b78281a3b85b07eec + purls: [] + size: 118959 + timestamp: 1774043016600 +- conda: https://prefix.dev/conda-forge/osx-arm64/libblas-3.11.0-6_h51639a9_openblas.conda + build_number: 6 + sha256: 979227fc03628925037ab2dfda008eb7b5592644d9c2c21dd285cefe8c42553d + md5: e551103471911260488a02155cef9c94 depends: - - libcxx >=14.0.6 - - libprotobuf 3.20.2.* - - libprotobuf >=3.20.2,<3.21.0a0 - - python >=3.11,<3.12.0a0 - - python >=3.11,<3.12.0a0 *_cpython - - python_abi 3.11.* *_cp311 - - setuptools - - six + - libopenblas >=0.3.32,<0.3.33.0a0 + - libopenblas >=0.3.32,<1.0a0 + constrains: + - liblapacke 3.11.0 6*_openblas + - liblapack 3.11.0 6*_openblas + - blas 2.306 openblas + - libcblas 3.11.0 6*_openblas + - mkl <2026 license: BSD-3-Clause license_family: BSD - purls: - - pkg:pypi/protobuf?source=hash-mapping - size: 348201 - timestamp: 1669119662437 -- conda: https://prefix.dev/conda-forge/linux-64/pthread-stubs-0.4-hb9d3cd8_1002.conda - sha256: 9c88f8c64590e9567c6c80823f0328e58d3b1efb0e1c539c0315ceca764e0973 - md5: b3c17d95b5a10c6e64a21fa17573e70e + purls: [] + size: 18859 + timestamp: 1774504387211 +- conda: https://prefix.dev/conda-forge/osx-arm64/libbrotlicommon-1.2.0-h1dcdb26_3.conda + sha256: 5e62b856b2e77ce98db44133bacab1281b42c1040dcbd69dbacfb80890cff5b0 + md5: b457450ba3f27c4749783c0204bd17b0 depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=13 + - __osx >=11.0 license: MIT license_family: MIT purls: [] - size: 8252 - timestamp: 1726802366959 -- conda: https://prefix.dev/conda-forge/osx-arm64/pthread-stubs-0.4-h84a0fba_1003.conda - sha256: 1c2338b9b0486af86883b9593d2f3e2845bbf216ea453dfe5d9a228e8dbe4057 - md5: d4852e6054b74645cf49ca10f6349191 + size: 80027 + timestamp: 1786622846050 +- conda: https://prefix.dev/conda-forge/osx-arm64/libbrotlidec-1.2.0-h5295a6a_3.conda + sha256: 510c9fce0d9ffcf41741dd96fc05db381672109d5665ef002c2e58f0d4ca0118 + md5: e07a99c6fdd984f4d588060f2f936bf4 depends: - __osx >=11.0 + - libbrotlicommon 1.2.0 h1dcdb26_3 license: MIT license_family: MIT purls: [] - size: 9238 - timestamp: 1786068031100 -- conda: https://prefix.dev/conda-forge/osx-arm64/pthread-stubs-0.4-hd74edd7_1002.conda - sha256: 8ed65e17fbb0ca944bfb8093b60086e3f9dd678c3448b5de212017394c247ee3 - md5: 415816daf82e0b23a736a069a75e9da7 + size: 29935 + timestamp: 1786622857695 +- conda: https://prefix.dev/conda-forge/osx-arm64/libbrotlienc-1.2.0-h2ddc9cb_3.conda + sha256: eac412417eee2e93c62e9d53559f1f9c14f40b6c41e2c432af8b517596898dd1 + md5: 954c78a9f591bfb12c79beaff7338ec8 depends: - __osx >=11.0 + - libbrotlicommon 1.2.0 h1dcdb26_3 license: MIT license_family: MIT purls: [] - size: 8381 - timestamp: 1726802424786 -- conda: https://prefix.dev/conda-forge/noarch/ptyprocess-0.7.0-pyhd8ed1ab_1.conda - sha256: a7713dfe30faf17508ec359e0bc7e0983f5d94682492469bd462cdaae9c64d83 - md5: 7d9daffbb8d8e0af0f769dbbcd173a54 - depends: - - python >=3.9 - license: ISC - purls: - - pkg:pypi/ptyprocess?source=hash-mapping - size: 19457 - timestamp: 1733302371990 -- conda: https://prefix.dev/conda-forge/linux-64/pulseaudio-client-17.0-h9a6aba3_3.conda - sha256: 0a0858c59805d627d02bdceee965dd84fde0aceab03a2f984325eec08d822096 - md5: b8ea447fdf62e3597cb8d2fae4eb1a90 + size: 295650 + timestamp: 1786622868044 +- conda: https://prefix.dev/conda-forge/osx-arm64/libcblas-3.11.0-6_hb0561ab_openblas.conda + build_number: 6 + sha256: 2e6b3e9b1ab672133b70fc6730e42290e952793f132cb5e72eee22835463eba0 + md5: 805c6d31c5621fd75e53dfcf21fb243a depends: - - __glibc >=2.17,<3.0.a0 - - dbus >=1.16.2,<2.0a0 - - libgcc >=14 - - libglib >=2.86.1,<3.0a0 - - libiconv >=1.18,<2.0a0 - - libsndfile >=1.2.2,<1.3.0a0 - - libsystemd0 >=257.10 - - libxcb >=1.17.0,<2.0a0 + - libblas 3.11.0 6_h51639a9_openblas constrains: - - pulseaudio 17.0 *_3 - license: LGPL-2.1-or-later - license_family: LGPL - purls: [] - size: 750785 - timestamp: 1763148198088 -- conda: https://prefix.dev/conda-forge/noarch/pycparser-2.22-pyh29332c3_1.conda - sha256: 79db7928d13fab2d892592223d7570f5061c192f27b9febd1a418427b719acc6 - md5: 12c566707c80111f9799308d9e265aef - depends: - - python >=3.9 - - python + - liblapacke 3.11.0 6*_openblas + - blas 2.306 openblas + - liblapack 3.11.0 6*_openblas license: BSD-3-Clause - license_family: BSD - purls: - - pkg:pypi/pycparser?source=hash-mapping - size: 110100 - timestamp: 1733195786147 -- conda: https://prefix.dev/conda-forge/linux-64/pygame-2.6.1-py311h3209946_0.conda - sha256: f008b83bf960c59e2f6336b9f246e7c6c8ac5327e5a8b7574e7e152e681f1887 - md5: d79d066a1ee9b690f90c02aac432e9c7 - depends: - - __glibc >=2.17,<3.0.a0 - - fontconfig >=2.14.2,<3.0a0 - - fonts-conda-ecosystem - - freetype >=2.12.1,<3.0a0 - - libgcc >=13 - - libjpeg-turbo >=3.0.0,<4.0a0 - - libpng >=1.6.44,<1.7.0a0 - - libstdcxx >=13 - - libzlib >=1.3.1,<2.0a0 - - portmidi >=2.0.4,<3.0a0 - - python >=3.11,<3.12.0a0 - - python_abi 3.11.* *_cp311 - - sdl2 >=2.30.7,<3.0a0 - - sdl2_image >=2.8.2,<3.0a0 - - sdl2_mixer >=2.6.3,<3.0a0 - - sdl2_ttf >=2.22.0,<3.0a0 - license: LGPL-2.1-only - purls: - - pkg:pypi/pygame?source=hash-mapping - size: 3068168 - timestamp: 1727636682074 -- conda: https://prefix.dev/conda-forge/osx-arm64/pygame-2.6.1-py311hc3e7c57_0.conda - sha256: e95e452aed4e6511b16f2650526c3e74438d5198a14e646832020d854dfa9964 - md5: db72b6d24c6c7ce1d80b8c659b4aeb2b - depends: - - __osx >=11.0 - - fontconfig >=2.14.2,<3.0a0 - - fonts-conda-ecosystem - - freetype >=2.12.1,<3.0a0 - - libcxx >=17 - - libjpeg-turbo >=3.0.0,<4.0a0 - - libpng >=1.6.44,<1.7.0a0 - - libzlib >=1.3.1,<2.0a0 - - portmidi >=2.0.4,<3.0a0 - - python >=3.11,<3.12.0a0 - - python >=3.11,<3.12.0a0 *_cpython - - python_abi 3.11.* *_cp311 - - sdl2 >=2.30.7,<3.0a0 - - sdl2_image >=2.8.2,<3.0a0 - - sdl2_mixer >=2.6.3,<3.0a0 - - sdl2_ttf >=2.22.0,<3.0a0 - license: LGPL-2.1-only - purls: - - pkg:pypi/pygame?source=hash-mapping - size: 2917534 - timestamp: 1727636756068 -- conda: https://prefix.dev/conda-forge/noarch/pygments-2.20.0-pyhd8ed1ab_0.conda - sha256: cf70b2f5ad9ae472b71235e5c8a736c9316df3705746de419b59d442e8348e86 - md5: 16c18772b340887160c79a6acc022db0 + license_family: BSD + purls: [] + size: 18863 + timestamp: 1774504433388 +- conda: https://prefix.dev/conda-forge/osx-arm64/libccd-double-2.1-h9a09cb3_2.tar.bz2 + sha256: eaba0b8153f4346229a0c52916a13fbedd689a3d3b31f4196bac65ece9050b8e + md5: 4d27a7d50c8d4bcafe33c9215e66251c depends: - - python >=3.10 - license: BSD-2-Clause + - libcxx >=13.0.1 + constrains: + - libccd <1 + license: BSD-3-Clause license_family: BSD - purls: - - pkg:pypi/pygments?source=hash-mapping - size: 893031 - timestamp: 1774796815820 -- conda: https://prefix.dev/conda-forge/noarch/pyparsing-3.3.2-pyhcf101f3_0.conda - sha256: 417fba4783e528ee732afa82999300859b065dc59927344b4859c64aae7182de - md5: 3687cc0b82a8b4c17e1f0eb7e47163d5 + purls: [] + size: 29852 + timestamp: 1654586481871 +- conda: https://prefix.dev/conda-forge/osx-arm64/libcurl-8.20.0-hd5a2499_0.conda + sha256: 38c0bc634b61e542776e97cfd15d5d41edd304d4e47c333004d2d622439b2381 + md5: 2f57b7d0c6adda88957586b7afd78438 depends: - - python >=3.10 - - python - license: MIT + - __osx >=11.0 + - krb5 >=1.22.2,<1.23.0a0 + - libnghttp2 >=1.68.1,<2.0a0 + - libssh2 >=1.11.1,<2.0a0 + - libzlib >=1.3.2,<2.0a0 + - openssl >=3.5.6,<4.0a0 + - zstd >=1.5.7,<1.6.0a0 + license: curl license_family: MIT - purls: - - pkg:pypi/pyparsing?source=hash-mapping - size: 110893 - timestamp: 1769003998136 -- conda: https://prefix.dev/conda-forge/noarch/pyproject_hooks-1.2.0-pyhd8ed1ab_1.conda - sha256: 065ac44591da9abf1ff740feb25929554b920b00d09287a551fcced2c9791092 - md5: d4582021af437c931d7d77ec39007845 + purls: [] + size: 400568 + timestamp: 1777462251987 +- conda: https://prefix.dev/conda-forge/osx-arm64/libcxx-22.1.5-h55c6f16_1.conda + sha256: dddd01bd6b338221342a89530a1caffe6051a70cc8f8b1d8bb591d5447a3c603 + md5: ff484b683fecf1e875dfc7aa01d19796 depends: - - python >=3.9 - - tomli >=1.1.0 + - __osx >=11.0 + license: Apache-2.0 WITH LLVM-exception + license_family: Apache + purls: [] + size: 569359 + timestamp: 1778191546305 +- conda: https://prefix.dev/conda-forge/osx-arm64/libdeflate-1.25-hc11a715_0.conda + sha256: 5e0b6961be3304a5f027a8c00bd0967fc46ae162cffb7553ff45c70f51b8314c + md5: a6130c709305cd9828b4e1bd9ba0000c + depends: + - __osx >=11.0 license: MIT license_family: MIT - purls: - - pkg:pypi/pyproject-hooks?source=hash-mapping - size: 15528 - timestamp: 1733710122949 -- conda: https://prefix.dev/conda-forge/noarch/pyserial-3.5-pyhcf101f3_2.conda - sha256: 8c618e8ca376d73133c9971abe45463a48c9cfb529788d609fd19568764941ba - md5: b27a6cd32160c34682ce6053b04c12c6 + purls: [] + size: 55420 + timestamp: 1761980066242 +- conda: https://prefix.dev/conda-forge/osx-arm64/libedit-3.1.20250104-pl5321hafb1f1b_0.conda + sha256: 66aa216a403de0bb0c1340a88d1a06adaff66bae2cfd196731aa24db9859d631 + md5: 44083d2d2c2025afca315c7a172eab2b depends: - - python >=3.10 - - python - license: BSD-3-Clause + - ncurses + - __osx >=11.0 + - ncurses >=6.5,<7.0a0 + license: BSD-2-Clause license_family: BSD - purls: - - pkg:pypi/pyserial?source=hash-mapping - size: 73910 - timestamp: 1767289527295 -- conda: https://prefix.dev/conda-forge/linux-64/pyside6-6.11.1-py311hf27b23e_1.conda - sha256: 3cd4963051cffa6d96972cd8e42e6b224bbf385353e9a743940b4434fba176e6 - md5: dfd3d0af46ab4c53740abe6d6dbdd403 - depends: - - python - - qt6-main 6.11.1.* - - libstdcxx >=14 - - libgcc >=14 - - __glibc >=2.17,<3.0.a0 - - libegl >=1.7.0,<2.0a0 - - libopengl >=1.7.0,<2.0a0 - - libvulkan-loader >=1.4.341.0,<2.0a0 - - libgl >=1.7.0,<2.0a0 - - python_abi 3.11.* *_cp311 - - libxslt >=1.1.43,<2.0a0 - - libxml2 - - libxml2-16 >=2.14.6 - - libclang13 >=22.1.5 - - qt6-main >=6.11.1,<6.12.0a0 - license: LGPL-3.0-only - license_family: LGPL - purls: - - pkg:pypi/pyside6?source=hash-mapping - - pkg:pypi/shiboken6?source=hash-mapping - size: 13815486 - timestamp: 1778933870587 -- conda: https://prefix.dev/conda-forge/noarch/pytest-8.3.4-pyhd8ed1ab_1.conda - sha256: 75245ca9d0cbd6d38bb45ec02430189a9d4c21c055c5259739d738a2298d61b3 - md5: 799ed216dc6af62520f32aa39bc1c2bb + purls: [] + size: 107691 + timestamp: 1738479560845 +- conda: https://prefix.dev/conda-forge/osx-arm64/libev-4.33-h93a5062_2.conda + sha256: 95cecb3902fbe0399c3a7e67a5bed1db813e5ab0e22f4023a5e0f722f2cc214f + md5: 36d33e440c31857372a72137f78bacf5 + license: BSD-2-Clause + license_family: BSD + purls: [] + size: 107458 + timestamp: 1702146414478 +- conda: https://prefix.dev/conda-forge/osx-arm64/libexpat-2.8.0-hf6b4638_0.conda + sha256: f4b1cafc59afaede8fa0a2d9cf376840f1c553001acd72f6ead18bbc8ac8c49c + md5: 65466e82c09e888ca7560c11a97d5450 depends: - - colorama - - exceptiongroup >=1.0.0rc8 - - iniconfig - - packaging - - pluggy <2,>=1.5 - - python >=3.9 - - tomli >=1 + - __osx >=11.0 constrains: - - pytest-faulthandler >=2 + - expat 2.8.0.* license: MIT license_family: MIT - purls: - - pkg:pypi/pytest?source=hash-mapping - size: 259195 - timestamp: 1733217599806 -- conda: https://prefix.dev/conda-forge/linux-64/python-3.10.20-h3c07f61_0_cpython.conda - sha256: 8ff2ce308faf2588b69c65b120293f59a8f2577b772b34df4e817d220b09e081 - md5: 5d4e2b00d99feacd026859b7fa239dc0 + purls: [] + size: 68789 + timestamp: 1777846180142 +- conda: https://prefix.dev/conda-forge/osx-arm64/libffi-3.5.2-hcf2aa1b_0.conda + sha256: 6686a26466a527585e6a75cc2a242bf4a3d97d6d6c86424a441677917f28bec7 + md5: 43c04d9cb46ef176bb2a4c77e324d599 depends: - - __glibc >=2.17,<3.0.a0 - - bzip2 >=1.0.8,<2.0a0 - - ld_impl_linux-64 >=2.36.1 - - libexpat >=2.7.4,<3.0a0 - - libffi >=3.4,<4.0a0 - - libgcc >=14 - - liblzma >=5.8.2,<6.0a0 - - libnsl >=2.0.1,<2.1.0a0 - - libsqlite >=3.51.2,<4.0a0 - - libuuid >=2.41.3,<3.0a0 - - libxcrypt >=4.4.36 - - libzlib >=1.3.1,<2.0a0 - - ncurses >=6.5,<7.0a0 - - openssl >=3.5.5,<4.0a0 - - readline >=8.3,<9.0a0 - - tk >=8.6.13,<8.7.0a0 - - tzdata - constrains: - - python_abi 3.10.* *_cp310 - license: Python-2.0 + - __osx >=11.0 + license: MIT + license_family: MIT purls: [] - size: 25455342 - timestamp: 1772729810280 -- conda: https://prefix.dev/conda-forge/linux-64/python-3.11.15-hd63d673_0_cpython.conda - sha256: bf6a32c69889d38482436a786bea32276756cedf0e9805cc856ffd088e8d00f0 - md5: a5ebcefec0c12a333bcd6d7bf3bddc1f + size: 40979 + timestamp: 1769456747661 +- conda: https://prefix.dev/conda-forge/osx-arm64/libflac-1.5.0-h6824b09_1.conda + sha256: 565e5c38e80eb5752bfa52f6b771fa2fd75c0551a1f61ea84a12a2fb4454900c + md5: b14b19359aed60c200b1ca58b53f5ca3 depends: - - __glibc >=2.17,<3.0.a0 - - bzip2 >=1.0.8,<2.0a0 - - ld_impl_linux-64 >=2.36.1 - - libexpat >=2.7.4,<3.0a0 - - libffi >=3.5.2,<3.6.0a0 - - libgcc >=14 - - liblzma >=5.8.2,<6.0a0 - - libnsl >=2.0.1,<2.1.0a0 - - libsqlite >=3.51.2,<4.0a0 - - libuuid >=2.41.3,<3.0a0 - - libxcrypt >=4.4.36 - - libzlib >=1.3.1,<2.0a0 - - ncurses >=6.5,<7.0a0 - - openssl >=3.5.5,<4.0a0 - - readline >=8.3,<9.0a0 - - tk >=8.6.13,<8.7.0a0 - - tzdata - constrains: - - python_abi 3.11.* *_cp311 - license: Python-2.0 + - __osx >=11.0 + - libcxx >=19 + - libiconv >=1.18,<2.0a0 + - libogg >=1.3.5,<1.4.0a0 + license: BSD-3-Clause + license_family: BSD purls: [] - size: 30949404 - timestamp: 1772730362552 -- conda: https://prefix.dev/conda-forge/osx-arm64/python-3.10.20-h1b19095_0_cpython.conda - sha256: f0f6fcbb6cfdee5a6b9c03b5b94d2bbe737f3b17a618006c7685cc48992ae667 - md5: 55ec25b0d09379eb11c32dbe09ee28c4 + size: 321872 + timestamp: 1764527007890 +- conda: https://prefix.dev/conda-forge/osx-arm64/libfreetype-2.14.3-hce30654_0.conda + sha256: a047a2f238362a37d484f9620e8cba29f513a933cd9eb68571ad4b270d6f8f3e + md5: f73b109d49568d5d1dda43bb147ae37f + depends: + - libfreetype6 >=2.14.3 + license: GPL-2.0-only OR FTL + purls: [] + size: 8091 + timestamp: 1774298691258 +- conda: https://prefix.dev/conda-forge/osx-arm64/libfreetype6-2.14.3-hdfa99f5_0.conda + sha256: ff764608e1f2839e95e2cf9b243681475f8778c36af7a42b3f78f476fdbb1dd3 + md5: e98ba7b5f09a5f450eca083d5a1c4649 depends: - __osx >=11.0 - - bzip2 >=1.0.8,<2.0a0 - - libexpat >=2.7.4,<3.0a0 - - libffi >=3.4,<4.0a0 - - liblzma >=5.8.2,<6.0a0 - - libsqlite >=3.51.2,<4.0a0 - - libzlib >=1.3.1,<2.0a0 - - ncurses >=6.5,<7.0a0 - - openssl >=3.5.5,<4.0a0 - - readline >=8.3,<9.0a0 - - tk >=8.6.13,<8.7.0a0 - - tzdata + - libpng >=1.6.55,<1.7.0a0 + - libzlib >=1.3.2,<2.0a0 constrains: - - python_abi 3.10.* *_cp310 - license: Python-2.0 + - freetype >=2.14.3 + license: GPL-2.0-only OR FTL + purls: [] + size: 338085 + timestamp: 1774298689297 +- conda: https://prefix.dev/conda-forge/osx-arm64/libgcc-15.2.0-hcbb3090_19.conda + sha256: 06644fa4d34d57c9e48f4d84b1256f9e5f654fdb37f43acc8a58a396952d42b7 + md5: 644058123986582db33aebd4ae2ca184 + depends: + - _openmp_mutex + constrains: + - libgcc-ng ==15.2.0=*_19 + - libgomp 15.2.0 19 + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL purls: [] - size: 12468674 - timestamp: 1772730636766 -- conda: https://prefix.dev/conda-forge/osx-arm64/python-3.11.15-h8561d8f_0_cpython.conda - sha256: 9a846065863925b2562126a5c6fecd7a972e84aaa4de9e686ad3715ca506acfa - md5: 49c7d96c58b969585cf09fb01d74e08e + size: 404080 + timestamp: 1778273064154 +- conda: https://prefix.dev/conda-forge/osx-arm64/libgd-2.3.3-h05bcc79_12.conda + sha256: 269edce527e204a80d3d05673301e0207efcd0dbeebc036a118ceb52690d6341 + md5: fa4a92cfaae9570d89700a292a9ca714 depends: - __osx >=11.0 - - bzip2 >=1.0.8,<2.0a0 - - libexpat >=2.7.4,<3.0a0 - - libffi >=3.5.2,<3.6.0a0 - - liblzma >=5.8.2,<6.0a0 - - libsqlite >=3.51.2,<4.0a0 + - fontconfig >=2.15.0,<3.0a0 + - fonts-conda-ecosystem + - icu >=78.1,<79.0a0 + - libexpat >=2.7.3,<3.0a0 + - libfreetype >=2.14.1 + - libfreetype6 >=2.14.1 + - libiconv >=1.18,<2.0a0 + - libjpeg-turbo >=3.1.2,<4.0a0 + - libpng >=1.6.53,<1.7.0a0 + - libtiff >=4.7.1,<4.8.0a0 + - libwebp-base >=1.6.0,<2.0a0 - libzlib >=1.3.1,<2.0a0 - - ncurses >=6.5,<7.0a0 - - openssl >=3.5.5,<4.0a0 - - readline >=8.3,<9.0a0 - - tk >=8.6.13,<8.7.0a0 - - tzdata - constrains: - - python_abi 3.11.* *_cp311 - license: Python-2.0 + license: GD + license_family: BSD purls: [] - size: 14753109 - timestamp: 1772730203101 -- conda: https://prefix.dev/conda-forge/noarch/python-dateutil-2.9.0.post0-pyhe01879c_2.conda - sha256: d6a17ece93bbd5139e02d2bd7dbfa80bee1a4261dced63f65f679121686bf664 - md5: 5b8d21249ff20967101ffa321cab24e8 - depends: - - python >=3.9 - - six >=1.5 - - python - license: Apache-2.0 - license_family: APACHE - purls: - - pkg:pypi/python-dateutil?source=hash-mapping - size: 233310 - timestamp: 1751104122689 -- conda: https://prefix.dev/conda-forge/noarch/python-discovery-1.3.0-pyhcf101f3_0.conda - sha256: ae70eb1c16970f2317e71dd2dee7d3a41abd26a47298ca8d9163a94b6579517b - md5: 696db6f25e56c0fafdccb0a7426fffb6 + size: 159247 + timestamp: 1766331953491 +- conda: https://prefix.dev/conda-forge/osx-arm64/libgfortran-15.2.0-h07b0088_19.conda + sha256: d4837b3b9b30af3132d260225e91ab9dde83be04c59513f500cc81050fb37486 + md5: 1ea03f87cdb1078fbc0e2b2deb63752c depends: - - python >=3.10 - - filelock >=3.15.4 - - platformdirs <5,>=4.3.6 - - python - license: MIT - license_family: MIT - purls: - - pkg:pypi/python-discovery?source=hash-mapping - size: 35030 - timestamp: 1778013338579 -- conda: https://prefix.dev/conda-forge/noarch/python_abi-3.10-8_cp310.conda - build_number: 8 - sha256: 7ad76fa396e4bde336872350124c0819032a9e8a0a40590744ff9527b54351c1 - md5: 05e00f3b21e88bb3d658ac700b2ce58c + - libgfortran5 15.2.0 hdae7583_19 constrains: - - python 3.10.* *_cpython - license: BSD-3-Clause - license_family: BSD + - libgfortran-ng ==15.2.0=*_19 + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL purls: [] - size: 6999 - timestamp: 1752805924192 -- conda: https://prefix.dev/conda-forge/noarch/python_abi-3.11-8_cp311.conda - build_number: 8 - sha256: fddf123692aa4b1fc48f0471e346400d9852d96eeed77dbfdd746fa50a8ff894 - md5: 8fcb6b0e2161850556231336dae58358 + size: 139675 + timestamp: 1778273280875 +- conda: https://prefix.dev/conda-forge/osx-arm64/libgfortran5-15.2.0-hdae7583_19.conda + sha256: d0a68b7a121d115b80c169e24d1265dcc25a3fe58d107df1bbc430797e226d88 + md5: ba36d8c606a6a53fe0b8c12d47267b3d + depends: + - libgcc >=15.2.0 constrains: - - python 3.11.* *_cpython - license: BSD-3-Clause - license_family: BSD + - libgfortran 15.2.0 + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL purls: [] - size: 7003 - timestamp: 1752805919375 -- conda: https://prefix.dev/conda-forge/linux-64/pyyaml-6.0.3-py311h3778330_1.conda - sha256: c9a6cd2c290d7c3d2b30ea34a0ccda30f770e8ddb2937871f2c404faf60d0050 - md5: a24add9a3bababee946f3bc1c829acfe + size: 599691 + timestamp: 1778273075448 +- conda: https://prefix.dev/conda-forge/osx-arm64/libglib-2.88.3-ha08bb59_0.conda + sha256: a14417ae1f3f4a92c5766354eb280342fa6aae72a09af86bf7fcfc12a8c9225c + md5: 4a9309d9502a08a2d29b1743dcfb0e7f depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - python >=3.11,<3.12.0a0 - - python_abi 3.11.* *_cp311 - - yaml >=0.2.5,<0.3.0a0 - license: MIT - license_family: MIT - purls: - - pkg:pypi/pyyaml?source=hash-mapping - size: 206190 - timestamp: 1770223702917 -- conda: https://prefix.dev/conda-forge/osx-arm64/pyyaml-6.0.3-py311hc290fe0_1.conda - sha256: 984e73d7957460689e10533059de8adb38a308853d298900a37acc58edd84cec - md5: e4b908da7cd496b3fa6798c0f60a2a19 + - __osx >=11.0 + - pcre2 >=10.47,<10.48.0a0 + - libzlib >=1.3.2,<2.0a0 + - libffi >=3.5.2,<3.6.0a0 + - libintl >=0.25.1,<1.0a0 + - libiconv >=1.18,<2.0a0 + constrains: + - glib >2.66 + license: LGPL-2.1-or-later + purls: [] + size: 4448109 + timestamp: 1785442168180 +- conda: https://prefix.dev/conda-forge/osx-arm64/libharfbuzz-14.3.1-hcda0f7c_0.conda + sha256: 67af14f8fbf9b9725890f728179d933ac35a95a6b50f37b7b568a11bfa8a4c1d + md5: 1631ca9ffe7d368850904baa1df1abf4 depends: - __osx >=11.0 - - python >=3.11,<3.12.0a0 - - python >=3.11,<3.12.0a0 *_cpython - - python_abi 3.11.* *_cp311 - - yaml >=0.2.5,<0.3.0a0 + - cairo >=1.18.4,<2.0a0 + - graphite2 >=1.3.15,<2.0a0 + - icu >=78.3,<79.0a0 + - libcxx >=21 + - libfreetype >=2.14.3 + - libfreetype6 >=2.14.3 + - libglib >=2.88.3,<3.0a0 + - libpng >=1.6.58,<1.7.0a0 + - libzlib >=1.3.2,<2.0a0 license: MIT license_family: MIT - purls: - - pkg:pypi/pyyaml?source=hash-mapping - size: 192948 - timestamp: 1770223655988 -- conda: https://prefix.dev/conda-forge/linux-64/qhull-2020.2-h434a139_5.conda - sha256: 776363493bad83308ba30bcb88c2552632581b143e8ee25b1982c8c743e73abc - md5: 353823361b1d27eb3960efb076dfcaf6 - depends: - - __glibc >=2.17,<3.0.a0 - - libgcc-ng >=12 - - libstdcxx-ng >=12 - license: LicenseRef-Qhull purls: [] - size: 552937 - timestamp: 1720813982144 -- conda: https://prefix.dev/conda-forge/osx-arm64/qhull-2020.2-h420ef59_5.conda - sha256: 873ac689484262a51fd79bc6103c1a1bedbf524924d7f0088fb80703042805e4 - md5: 6483b1f59526e05d7d894e466b5b6924 + size: 953252 + timestamp: 1786970947180 +- conda: https://prefix.dev/conda-forge/osx-arm64/libharfbuzz-devel-14.3.1-hcda0f7c_0.conda + sha256: 076db9dac1b7ab31383ffd35da5f5b9ab9e56987b7751a5ec767c330f0e3c359 + md5: 911b746bffebd782ea8d53e663b0269c depends: - __osx >=11.0 - - libcxx >=16 - license: LicenseRef-Qhull - purls: [] - size: 516376 - timestamp: 1720814307311 -- conda: https://prefix.dev/conda-forge/linux-64/qt6-main-6.11.1-pl5321h16c4a6b_0.conda - sha256: 787d9a8eb7bb993e4a543901b8edade35c1c8e75d67cadb65c56a8f9c38119a5 - md5: cdae26862f9e4c674b8443fd267f2401 - depends: - - libxcb - - xcb-util - - xcb-util-wm - - xcb-util-keysyms - - xcb-util-image - - xcb-util-renderutil - - xcb-util-cursor - - libgl-devel - - libegl-devel - - __glibc >=2.17,<3.0.a0 - - libstdcxx >=14 - - libgcc >=14 - - libjpeg-turbo >=3.1.4.1,<4.0a0 - - alsa-lib >=1.2.15.3,<1.3.0a0 - - xcb-util-renderutil >=0.3.10,<0.4.0a0 - - xorg-libxcursor >=1.2.3,<2.0a0 - - double-conversion >=3.4.0,<3.5.0a0 - - dbus >=1.16.2,<2.0a0 - - libglib >=2.88.1,<3.0a0 - - libsqlite >=3.53.1,<4.0a0 - - xorg-libx11 >=1.8.13,<2.0a0 - - krb5 >=1.22.2,<1.23.0a0 - - libdrm >=2.4.125,<2.5.0a0 - - xorg-libxext >=1.3.7,<2.0a0 - - libwebp-base >=1.6.0,<2.0a0 - - harfbuzz >=14.2.0 - - xorg-libice >=1.1.2,<2.0a0 - - xorg-libxdamage >=1.1.6,<2.0a0 - - libbrotlicommon >=1.2.0,<1.3.0a0 - - libbrotlienc >=1.2.0,<1.3.0a0 - - libbrotlidec >=1.2.0,<1.3.0a0 - - xorg-libxrandr >=1.5.5,<2.0a0 - - xcb-util-image >=0.4.0,<0.5.0a0 + - cairo >=1.18.4,<2.0a0 + - freetype + - graphite2 >=1.3.15,<2.0a0 + - icu >=78.3,<79.0a0 + - libcxx >=21 - libfreetype >=2.14.3 - libfreetype6 >=2.14.3 - - xorg-libxcomposite >=0.4.7,<1.0a0 - - openssl >=3.5.6,<4.0a0 - - xcb-util-cursor >=0.1.6,<0.2.0a0 - - libvulkan-loader >=1.4.341.0,<2.0a0 - - pcre2 >=10.47,<10.48.0a0 - - xorg-libxxf86vm >=1.1.7,<2.0a0 - - icu >=78.3,<79.0a0 - - libxcb >=1.17.0,<2.0a0 - - wayland >=1.25.0,<2.0a0 - - xorg-libsm >=1.2.6,<2.0a0 - - libtiff >=4.7.1,<4.8.0a0 - - libpq >=18.3,<19.0a0 - - libegl >=1.7.0,<2.0a0 - - xcb-util-wm >=0.4.2,<0.5.0a0 - - xcb-util-keysyms >=0.4.1,<0.5.0a0 - - libxkbcommon >=1.13.1,<2.0a0 - - zstd >=1.5.7,<1.6.0a0 - - fontconfig >=2.17.1,<3.0a0 - - fonts-conda-ecosystem - - xorg-libxtst >=1.2.5,<2.0a0 - - libxml2 - - libxml2-16 >=2.14.6 - - libzlib >=1.3.2,<2.0a0 - - libpng >=1.6.58,<1.7.0a0 - - libcups >=2.3.3,<2.4.0a0 - - libgl >=1.7.0,<2.0a0 - - xcb-util >=0.4.1,<0.5.0a0 - constrains: - - qt ==6.11.1 - license: LGPL-3.0-only - license_family: LGPL + - libglib >=2.88.3,<3.0a0 + - libharfbuzz 14.3.1 hcda0f7c_0 + - libpng >=1.6.58,<1.7.0a0 + - libzlib >=1.3.2,<2.0a0 + license: MIT + license_family: MIT purls: [] - size: 60185269 - timestamp: 1778597122245 -- conda: https://prefix.dev/conda-forge/linux-64/rav1e-0.8.1-h1fbca29_0.conda - sha256: cf550bbc8e5ebedb6dba9ccaead3e07bd1cb86b183644a4c853e06e4b3ad5ac7 - md5: d83958768626b3c8471ce032e28afcd3 + size: 1500884 + timestamp: 1786970969119 +- conda: https://prefix.dev/conda-forge/osx-arm64/libiconv-1.18-h23cfdf5_2.conda + sha256: de0336e800b2af9a40bdd694b03870ac4a848161b35c8a2325704f123f185f03 + md5: 4d5a7445f0b25b6a3ddbb56e790f5251 depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - constrains: - - __glibc >=2.17 - license: BSD-2-Clause - license_family: BSD + - __osx >=11.0 + license: LGPL-2.1-only purls: [] - size: 5595970 - timestamp: 1772540833621 -- conda: https://prefix.dev/conda-forge/osx-arm64/rav1e-0.8.1-h8246384_0.conda - sha256: 925e35b71fe513e0380ecd2fe137e3f4f248bf7ce4bad96946c7c704b7a50d26 - md5: 4706a8a71474c692482c3f86c2175454 + size: 750379 + timestamp: 1754909073836 +- conda: https://prefix.dev/conda-forge/osx-arm64/libintl-0.25.1-h493aca8_0.conda + sha256: 99d2cebcd8f84961b86784451b010f5f0a795ed1c08f1e7c76fbb3c22abf021a + md5: 5103f6a6b210a3912faf8d7db516918c depends: - __osx >=11.0 - constrains: + - libiconv >=1.18,<2.0a0 + license: LGPL-2.1-or-later + purls: [] + size: 90957 + timestamp: 1751558394144 +- conda: https://prefix.dev/conda-forge/osx-arm64/libjpeg-turbo-3.1.4.1-h84a0fba_0.conda + sha256: 17e035ae6a520ff6a6bb5dd93a4a7c3895891f4f9743bcb8c6ef607445a31cd0 + md5: b8a7544c83a67258b0e8592ec6a5d322 + depends: - __osx >=11.0 - license: BSD-2-Clause - license_family: BSD + constrains: + - jpeg <0.0.0a + license: IJG AND BSD-3-Clause AND Zlib purls: [] - size: 886953 - timestamp: 1772541394570 -- pypi: ./vendor/rSim - name: rc-robosim - version: 1.2.0+utama - sha256: 3ee70be6ae49588d10349b223ee29716b1694b243a04c7523b8a78f667820579 -- conda: https://prefix.dev/conda-forge/linux-64/readline-8.3-h853b02a_0.conda - sha256: 12ffde5a6f958e285aa22c191ca01bbd3d6e710aa852e00618fa6ddc59149002 - md5: d7d95fc8287ea7bf33e0e7116d2b95ec + size: 555681 + timestamp: 1775962975624 +- conda: https://prefix.dev/conda-forge/osx-arm64/liblapack-3.11.0-6_hd9741b5_openblas.conda + build_number: 6 + sha256: 21606b7346810559e259807497b86f438950cf19e71838e44ebaf4bd2b35b549 + md5: ee33d2d05a7c5ea1f67653b37eb74db1 depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - ncurses >=6.5,<7.0a0 - license: GPL-3.0-only - license_family: GPL + - libblas 3.11.0 6_h51639a9_openblas + constrains: + - liblapacke 3.11.0 6*_openblas + - libcblas 3.11.0 6*_openblas + - blas 2.306 openblas + license: BSD-3-Clause + license_family: BSD purls: [] - size: 345073 - timestamp: 1765813471974 -- conda: https://prefix.dev/conda-forge/osx-arm64/readline-8.3-h46df422_0.conda - sha256: a77010528efb4b548ac2a4484eaf7e1c3907f2aec86123ed9c5212ae44502477 - md5: f8381319127120ce51e081dce4865cf4 + size: 18863 + timestamp: 1774504467905 +- conda: https://prefix.dev/conda-forge/osx-arm64/liblzma-5.8.3-h8088a28_0.conda + sha256: 34878d87275c298f1a732c6806349125cebbf340d24c6c23727268184bba051e + md5: b1fd823b5ae54fbec272cea0811bd8a9 depends: - __osx >=11.0 - - ncurses >=6.5,<7.0a0 - license: GPL-3.0-only - license_family: GPL + constrains: + - xz 5.8.3.* + license: 0BSD purls: [] - size: 313930 - timestamp: 1765813902568 -- conda: https://prefix.dev/conda-forge/linux-64/rhash-1.4.3-hd590300_2.conda - sha256: 475f68cac8981ff2b10c56e53c2f376fc3c805fbc7ec30d22f870cd88f1479ba - md5: 4cabe3858a856bff08d9a0992e413084 + size: 92472 + timestamp: 1775825802659 +- conda: https://prefix.dev/conda-forge/osx-arm64/liblzma-devel-5.8.3-h8088a28_0.conda + sha256: 3002be39c0e98ec6cd103b0dc2963dc9e0d7cab127fb2fe9a8de9707a76ed1f0 + md5: ebe1f5418d6e2d4bbc26b2c906a0a470 depends: - - libgcc-ng >=12 - license: MIT - license_family: MIT + - __osx >=11.0 + - liblzma 5.8.3 h8088a28_0 + license: 0BSD purls: [] - size: 184509 - timestamp: 1693427593121 -- conda: https://prefix.dev/conda-forge/osx-arm64/rhash-1.4.3-hb547adb_2.conda - sha256: f20c9765768d0c61bbbb462dc83b55372328498a746f60e1e93c985e3436ef73 - md5: 24308c7e0949c572688900b8b2f2a3ba - license: MIT - license_family: MIT + size: 118482 + timestamp: 1775825828010 +- conda: https://prefix.dev/conda-forge/osx-arm64/libmad-0.15.1b-h1a8c8d9_1001.conda + sha256: 8e9209acf4bf6865760e61dc0d86116ffc9efc3e13c7f559eb1ea78532a3a625 + md5: 1eb30852ed396fbe6e301fe6d715aef9 + license: GPL-2.0-only + license_family: GPL purls: [] - size: 176444 - timestamp: 1693427792263 -- conda: https://prefix.dev/conda-forge/noarch/rich-14.3.4-pyhcf101f3_0.conda - sha256: a941b5e002504e1c9b02ea02180d40186b67d03e8e7d668bf746393c266b3951 - md5: 2e6a922d07244f514863b7e10bf5c923 - depends: - - markdown-it-py >=2.2.0 - - pygments >=2.13.0,<3.0.0 - - python >=3.10 - - typing_extensions >=4.0.0,<5.0.0 - - python - license: MIT - license_family: MIT - purls: - - pkg:pypi/rich?source=hash-mapping - size: 208480 - timestamp: 1775880677603 -- conda: https://prefix.dev/conda-forge/linux-64/ruff-0.15.12-h994f30f_0.conda - noarch: python - sha256: 98c771464ed93a2733bae460c39cfa9640feb20972d2e651b44e85db296942eb - md5: 3c8f229055ad244fa3a97c6c45b77099 + size: 77255 + timestamp: 1670815732700 +- conda: https://prefix.dev/conda-forge/osx-arm64/libnghttp2-1.68.1-h8f3e76b_0.conda + sha256: 2bc7bc3978066f2c274ebcbf711850cc9ab92e023e433b9631958a098d11e10a + md5: 6ea18834adbc3b33df9bd9fb45eaf95b depends: - - python - - libgcc >=14 - - __glibc >=2.17,<3.0.a0 - constrains: - - __glibc >=2.17 + - __osx >=11.0 + - c-ares >=1.34.6,<2.0a0 + - libcxx >=19 + - libev >=4.33,<4.34.0a0 + - libev >=4.33,<5.0a0 + - libzlib >=1.3.1,<2.0a0 + - openssl >=3.5.5,<4.0a0 license: MIT license_family: MIT - purls: - - pkg:pypi/ruff?source=hash-mapping - size: 9266480 - timestamp: 1778119386343 -- conda: https://prefix.dev/conda-forge/osx-arm64/ruff-0.15.12-hbd3f8a3_0.conda - noarch: python - sha256: 91992a557456cbe9980e8ffb0f0d1200f65f741adeefc7ecf568d1935690a7bc - md5: 7151a0851207b88c0031f388a7825e9b + purls: [] + size: 576526 + timestamp: 1773854624224 +- conda: https://prefix.dev/conda-forge/osx-arm64/libode-0.16.6-py310h46abf29_0.conda + sha256: 2f3d4fb77c4cdca3d156c196271fc4a637af8cac93573ba682c1a12c9def54d8 + md5: f23a539191cb27d18453bad21c648c2f depends: - - python - - __osx >=11.0 - constrains: - __osx >=11.0 - license: MIT - license_family: MIT - purls: - - pkg:pypi/ruff?source=hash-mapping - size: 8485007 - timestamp: 1778119519471 -- conda: https://prefix.dev/conda-forge/linux-64/scipy-1.17.1-py311hbe70eeb_0.conda - sha256: 0063a75e9406357ef8ecc2fb38808a2442b269bfc5a854cf2bcd368060d9a2d7 - md5: 5ae6d73ab0bebbc892c2d46dc51e90a5 + - libccd-double >=2.1,<2.2.0a0 + - libcxx >=19 + - pthread-stubs + - python >=3.10,<3.11.0a0 *_cpython + - python_abi 3.10.* *_cp310 + license: LGPL-2.1-or-later OR BSD-4-Clause + purls: [] + size: 378594 + timestamp: 1760969550819 +- conda: https://prefix.dev/conda-forge/osx-arm64/libogg-1.3.5-h48c0fde_1.conda + sha256: 28bd1fe20fe43da105da41b95ac201e95a1616126f287985df8e86ddebd1c3d8 + md5: 29b8b11f6d7e6bd0e76c029dcf9dd024 depends: - - __glibc >=2.17,<3.0.a0 - - libblas >=3.9.0,<4.0a0 - - libcblas >=3.9.0,<4.0a0 - - libgcc >=14 - - libgfortran - - libgfortran5 >=14.3.0 - - liblapack >=3.9.0,<4.0a0 - - libstdcxx >=14 - - numpy <2.7 - - numpy >=1.23,<3 - - numpy >=1.25.2 - - python >=3.11,<3.12.0a0 - - python_abi 3.11.* *_cp311 + - __osx >=11.0 license: BSD-3-Clause license_family: BSD - purls: - - pkg:pypi/scipy?source=hash-mapping - size: 17099824 - timestamp: 1771880736635 -- conda: https://prefix.dev/conda-forge/osx-arm64/scipy-1.17.1-py311he9931d0_0.conda - sha256: f212138a7eb86cf8bcdb46f003ae552967cd7e48d2c539f7f8dd6e800c74b70d - md5: 40606bef4834281d5f746626338829dc + purls: [] + size: 216719 + timestamp: 1745826006052 +- conda: https://prefix.dev/conda-forge/osx-arm64/libopenblas-0.3.32-openmp_he657e61_0.conda + sha256: 713e453bde3531c22a660577e59bf91ef578dcdfd5edb1253a399fa23514949a + md5: 3a1111a4b6626abebe8b978bb5a323bf depends: - __osx >=11.0 - - libblas >=3.9.0,<4.0a0 - - libcblas >=3.9.0,<4.0a0 - - libcxx >=19 - libgfortran - libgfortran5 >=14.3.0 - - liblapack >=3.9.0,<4.0a0 - - numpy <2.7 - - numpy >=1.23,<3 - - numpy >=1.25.2 - - python >=3.11,<3.12.0a0 - - python >=3.11,<3.12.0a0 *_cpython - - python_abi 3.11.* *_cp311 + - llvm-openmp >=19.1.7 + constrains: + - openblas >=0.3.32,<0.3.33.0a0 + license: BSD-3-Clause + license_family: BSD + purls: [] + size: 4308797 + timestamp: 1774472508546 +- conda: https://prefix.dev/conda-forge/osx-arm64/libopus-1.6.1-h1a92334_0.conda + sha256: 5c95a5f7712f543c59083e62fc3a95efec8b7f3773fbf4542ad1fb87fbf51ff4 + md5: 7f414dd3fd1cb7a76e51fec074a9c49e + depends: + - __osx >=11.0 license: BSD-3-Clause license_family: BSD - purls: - - pkg:pypi/scipy?source=hash-mapping - size: 14107248 - timestamp: 1771880859933 -- conda: https://prefix.dev/conda-forge/linux-64/sdl2-2.32.56-h54a6638_0.conda - sha256: 987ad072939fdd51c92ea8d3544b286bb240aefda329f9b03a51d9b7e777f9de - md5: cdd138897d94dc07d99afe7113a07bec - depends: - - libstdcxx >=14 - - libgcc >=14 - - __glibc >=2.17,<3.0.a0 - - libgl >=1.7.0,<2.0a0 - - sdl3 >=3.2.22,<4.0a0 - - libegl >=1.7.0,<2.0a0 - license: Zlib purls: [] - size: 589145 - timestamp: 1757842881 -- conda: https://prefix.dev/conda-forge/osx-arm64/sdl2-2.32.56-h248ca61_0.conda - sha256: 704c5cae4bc839a18c70cbf3387d7789f1902828c79c6ddabcd34daf594f4103 - md5: 092c5b693dc6adf5f409d12f33295a2a + size: 308000 + timestamp: 1768497248058 +- conda: https://prefix.dev/conda-forge/osx-arm64/libpng-1.6.58-h132b30e_0.conda + sha256: 66eae34546df1f098a67064970c92aa14ae7a7505091889e00468294d2882c36 + md5: 2259ae0949dbe20c0665850365109b27 depends: - - libcxx >=19 - __osx >=11.0 - - sdl3 >=3.2.22,<4.0a0 - license: Zlib + - libzlib >=1.3.2,<2.0a0 + license: zlib-acknowledgement purls: [] - size: 542508 - timestamp: 1757842919681 -- conda: https://prefix.dev/conda-forge/linux-64/sdl2_image-2.8.2-h06ee604_1.conda - sha256: f18184e016e2e57306d1540dea584d38f4617d7ddb6aad4af6b5f21c52fa39ea - md5: 65e113270b460dcdfc4dc0a80bb3d11c + size: 289546 + timestamp: 1776315246750 +- conda: https://prefix.dev/conda-forge/osx-arm64/libprotobuf-3.20.2-hb5ab8b9_0.tar.bz2 + sha256: a47188a95c95cb131f9903014e18b7868ab9b445da629f7d3a9d53d9aa8caa2c + md5: a6f25546f30d4cd56bc37b0b56ab954c depends: - - libavif16 >=1.0.4,<2.0a0 - - libgcc-ng >=12 - - libjpeg-turbo >=3.0.0,<4.0a0 - - libpng >=1.6.43,<1.7.0a0 - - libstdcxx-ng >=12 - - libtiff >=4.6.0,<4.8.0a0 - - libwebp-base >=1.4.0,<2.0a0 + - libcxx >=14.0.6 - libzlib >=1.2.13,<2.0.0a0 - - sdl2 >=2.30.2,<3.0a0 - license: Zlib + license: BSD-3-Clause + license_family: BSD purls: [] - size: 152110 - timestamp: 1716857107234 -- conda: https://prefix.dev/conda-forge/osx-arm64/sdl2_image-2.8.2-h376e2e1_1.conda - sha256: 8c385478a7b6a6e34b3b3f3d48ed48f504698544987ad331f03a7b43b11d689a - md5: 247d2c5a873901ef51f378c69a2c708e + size: 2281852 + timestamp: 1668470370774 +- conda: https://prefix.dev/conda-forge/osx-arm64/libraqm-0.11.0-h45af499_0.conda + sha256: b110f7f9b2cec61ea793c521950414e00cd64826e18aeb4ab40369acf05c0039 + md5: 46ea0eb4e71bffa35ab7070678bcb053 depends: - __osx >=11.0 - - libavif16 >=1.0.4,<2.0a0 - - libcxx >=16 - - libjpeg-turbo >=3.0.0,<4.0a0 - - libpng >=1.6.43,<1.7.0a0 - - libtiff >=4.6.0,<4.8.0a0 - - libwebp-base >=1.4.0,<2.0a0 - - libzlib >=1.2.13,<2.0.0a0 - - sdl2 >=2.30.2,<3.0a0 - license: Zlib + - libfreetype >=2.14.3 + - libfreetype6 >=2.14.3 + - libharfbuzz >=14.2.1 + - fribidi >=1.0.16,<2.0a0 + license: MIT + license_family: MIT purls: [] - size: 118041 - timestamp: 1716857215118 -- conda: https://prefix.dev/conda-forge/linux-64/sdl2_mixer-2.6.3-hb8bcbd3_2.conda - sha256: 3a36f7d6349d132c571516514dc8cd771a705e93adef942c8eee38a09875d97a - md5: 97fbc8b1372f0000321d568c0e459e3c + size: 31333 + timestamp: 1784850348342 +- conda: https://prefix.dev/conda-forge/osx-arm64/librsvg-2.60.0-h9001022_1.conda + sha256: 9ba1531b46c75313736e2ef8ba1a4d3ef7d3ffd22efe8d593bfa99da7143a1cb + md5: b6c81d5b3324b9ff9fe8f39d25d8be66 depends: - - __glibc >=2.17,<3.0.a0 - - fluidsynth >=2.5.2,<2.6.0a0 - - libflac >=1.5.0,<1.6.0a0 - - libgcc >=14 - - libmad >=0.15.1b,<0.16.0a0 - - libogg >=1.3.5,<1.4.0a0 - - libstdcxx >=14 - - libvorbis >=1.3.7,<1.4.0a0 - - mpg123 >=1.32.9,<1.33.0a0 - - opusfile >=0.12,<0.13.0a0 - - sdl2 >=2.32.56,<3.0a0 - license: Zlib + - __osx >=11.0 + - cairo >=1.18.4,<2.0a0 + - gdk-pixbuf >=2.44.5,<3.0a0 + - libglib >=2.86.4,<3.0a0 + - libxml2-16 >=2.14.6 + - pango >=1.56.4,<2.0a0 + constrains: + - __osx >=11.0 + license: LGPL-2.1-or-later purls: [] - size: 205164 - timestamp: 1766614707552 -- conda: https://prefix.dev/conda-forge/osx-arm64/sdl2_mixer-2.6.3-h45fadf6_2.conda - sha256: b826d7fa6738d9fcc36bdcb299744246fe82d0f9d9d0d0f999f3111cb7b4d373 - md5: 890924faa4965ba3edb0cc5cc94db572 + size: 2357137 + timestamp: 1771302195666 +- conda: https://prefix.dev/conda-forge/osx-arm64/libsndfile-1.2.2-hf95f74e_2.conda + sha256: f549aafe57439ca7c362884968f24fcc35a26e4e1eb66bb6985aa9e553c25521 + md5: 27e1a5a9249833f98a739249c7d1518b depends: - __osx >=11.0 - - fluidsynth >=2.5.2,<2.6.0a0 + - lame >=3.100,<3.101.0a0 - libcxx >=19 - libflac >=1.5.0,<1.6.0a0 - - libmad >=0.15.1b,<0.16.0a0 - libogg >=1.3.5,<1.4.0a0 + - libopus >=1.5.2,<2.0a0 - libvorbis >=1.3.7,<1.4.0a0 - mpg123 >=1.32.9,<1.33.0a0 - - opusfile >=0.12,<0.13.0a0 - - sdl2 >=2.32.56,<3.0a0 - license: Zlib - purls: [] - size: 187456 - timestamp: 1766614943278 -- conda: https://prefix.dev/conda-forge/linux-64/sdl2_ttf-2.24.0-h287479f_0.conda - sha256: 431d19b666db6e7a4f09c37c43c83f115176a006b2ac321853ca26bee888c519 - md5: bccd5b74eb55a523dfcc66b857555714 - depends: - - __glibc >=2.17,<3.0.a0 - - freetype >=2.12.1,<3.0a0 - - harfbuzz >=10.1.0 - - libgcc >=13 - - libzlib >=1.3.1,<2.0a0 - - sdl2 >=2.30.10,<3.0a0 - license: Zlib + license: LGPL-2.1-or-later + license_family: LGPL purls: [] - size: 61954 - timestamp: 1736117956977 -- conda: https://prefix.dev/conda-forge/osx-arm64/sdl2_ttf-2.24.0-h443c5de_0.conda - sha256: 5dc56fd1de51dec2f7b63b1a9069ab35ab0494d9cd5af164ab0019cbd9564cf6 - md5: 3cf5cf83deccb663b4e932d3d4b28f57 + size: 321233 + timestamp: 1765182495193 +- conda: https://prefix.dev/conda-forge/osx-arm64/libsqlite-3.53.1-h1b79a29_0.conda + sha256: 49daec7c83e70d4efc17b813547824bc2bcf2f7256d84061d24fbfe537da9f74 + md5: 6681822ea9d362953206352371b6a904 depends: - __osx >=11.0 - - freetype >=2.12.1,<3.0a0 - - harfbuzz >=10.1.0 - - sdl2 >=2.30.10,<3.0a0 - license: Zlib + - libzlib >=1.3.2,<2.0a0 + license: blessing purls: [] - size: 45429 - timestamp: 1736118165229 -- conda: https://prefix.dev/conda-forge/linux-64/sdl3-3.4.8-hdeec2a5_0.conda - sha256: bec327fffc08369afe4c1384a5b50cac9b38e7af42ebdf5f89628633bd980dbd - md5: 508bad511e617479f0ad60cc49fba903 + size: 920047 + timestamp: 1777987051643 +- conda: https://prefix.dev/conda-forge/osx-arm64/libssh2-1.11.1-h1590b86_0.conda + sha256: 8bfe837221390ffc6f111ecca24fa12d4a6325da0c8d131333d63d6c37f27e0a + md5: b68e8f66b94b44aaa8de4583d3d4cc40 depends: - - libstdcxx >=14 - - libgcc >=14 - - __glibc >=2.17,<3.0.a0 - - pulseaudio-client >=17.0,<17.1.0a0 - - libgl >=1.7.0,<2.0a0 - - libunwind >=1.8.3,<1.9.0a0 - - xorg-libxtst >=1.2.5,<2.0a0 - - xorg-libxcursor >=1.2.3,<2.0a0 - - libegl >=1.7.0,<2.0a0 - - xorg-libxfixes >=6.0.2,<7.0a0 - - libudev1 >=257.13 - - xorg-libxext >=1.3.7,<2.0a0 - - libusb >=1.0.29,<2.0a0 - - wayland >=1.25.0,<2.0a0 - - xorg-libxi >=1.8.2,<2.0a0 - - libvulkan-loader >=1.4.341.0,<2.0a0 - - liburing >=2.14,<2.15.0a0 - - xorg-libxscrnsaver >=1.2.4,<2.0a0 - - dbus >=1.16.2,<2.0a0 - - libxkbcommon >=1.13.1,<2.0a0 - - libdrm >=2.4.125,<2.5.0a0 - - xorg-libx11 >=1.8.13,<2.0a0 - license: Zlib + - libzlib >=1.3.1,<2.0a0 + - openssl >=3.5.0,<4.0a0 + license: BSD-3-Clause + license_family: BSD purls: [] - size: 2146080 - timestamp: 1777693555942 -- conda: https://prefix.dev/conda-forge/osx-arm64/sdl3-3.4.8-h6fa9c73_0.conda - sha256: 0c15a7f3f46d175c70ca7b032cee3eee9ef602492688a79a6e734f2efc466dad - md5: 53311362c6da21e58442bfb959991455 + size: 279193 + timestamp: 1745608793272 +- conda: https://prefix.dev/conda-forge/osx-arm64/libtiff-4.7.1-h4030677_1.conda + sha256: e9248077b3fa63db94caca42c8dbc6949c6f32f94d1cafad127f9005d9b1507f + md5: e2a72ab2fa54ecb6abab2b26cde93500 depends: - __osx >=11.0 + - lerc >=4.0.0,<5.0a0 - libcxx >=19 - - libvulkan-loader >=1.4.341.0,<2.0a0 - - libusb >=1.0.29,<2.0a0 - - dbus >=1.16.2,<2.0a0 - license: Zlib + - libdeflate >=1.25,<1.26.0a0 + - libjpeg-turbo >=3.1.0,<4.0a0 + - liblzma >=5.8.1,<6.0a0 + - libwebp-base >=1.6.0,<2.0a0 + - libzlib >=1.3.1,<2.0a0 + - zstd >=1.5.7,<1.6.0a0 + license: HPND purls: [] - size: 1561566 - timestamp: 1777693640800 -- conda: https://prefix.dev/conda-forge/linux-64/secretstorage-3.4.1-py311h38be061_0.conda - sha256: 47f28b12e760ae3ce8a1e616c5b56f5e874e0e4a036bdd09516ebf263c19521f - md5: ec955e67147942a68469a46d0bdf0a7b - depends: - - cryptography >=2.0 - - dbus - - jeepney >=0.6 - - python >=3.11,<3.12.0a0 - - python_abi 3.11.* *_cp311 - license: BSD-3-Clause - license_family: BSD - purls: - - pkg:pypi/secretstorage?source=hash-mapping - size: 32968 - timestamp: 1763045430433 -- conda: https://prefix.dev/conda-forge/noarch/setuptools-82.0.1-pyh332efcf_0.conda - sha256: 82088a6e4daa33329a30bc26dc19a98c7c1d3f05c0f73ce9845d4eab4924e9e1 - md5: 8e194e7b992f99a5015edbd4ebd38efd - depends: - - python >=3.10 - license: MIT - license_family: MIT - purls: - - pkg:pypi/setuptools?source=hash-mapping - size: 639697 - timestamp: 1773074868565 -- conda: https://prefix.dev/conda-forge/noarch/shellingham-1.5.4-pyhd8ed1ab_2.conda - sha256: 1d6534df8e7924d9087bd388fbac5bd868c5bf8971c36885f9f016da0657d22b - md5: 83ea3a2ddb7a75c1b09cea582aa4f106 + size: 373892 + timestamp: 1762022345545 +- conda: https://prefix.dev/conda-forge/osx-arm64/libusb-1.0.29-hbc156a2_0.conda + sha256: 5eee9a2bf359e474d4548874bcfc8d29ebad0d9ba015314439c256904e40aaad + md5: f6654e9e96e9d973981b3b2f898a5bfa depends: - - python >=3.10 - license: MIT - license_family: MIT - purls: - - pkg:pypi/shellingham?source=hash-mapping - size: 15018 - timestamp: 1762858315311 -- conda: https://prefix.dev/conda-forge/noarch/six-1.17.0-pyhe01879c_1.conda - sha256: 458227f759d5e3fcec5d9b7acce54e10c9e1f4f4b7ec978f3bfd54ce4ee9853d - md5: 3339e3b65d58accf4ca4fb8748ab16b3 + - __osx >=11.0 + license: LGPL-2.1-or-later + purls: [] + size: 83849 + timestamp: 1748856224950 +- conda: https://prefix.dev/conda-forge/osx-arm64/libuv-1.51.0-h6caf38d_1.conda + sha256: 042c7488ad97a5629ec0a991a8b2a3345599401ecc75ad6a5af73b60e6db9689 + md5: c0d87c3c8e075daf1daf6c31b53e8083 depends: - - python >=3.9 - - python + - __osx >=11.0 license: MIT license_family: MIT - purls: - - pkg:pypi/six?source=hash-mapping - size: 18455 - timestamp: 1753199211006 -- conda: https://prefix.dev/conda-forge/noarch/snakeviz-2.2.2-pyhd8ed1ab_1.conda - sha256: 833326122c18887b338262c13365cb146b6702c79d72da74a1c6b8af4c50e162 - md5: 421b7a950e384949ca1b0f04f0751ce0 + purls: [] + size: 421195 + timestamp: 1753948426421 +- conda: https://prefix.dev/conda-forge/osx-arm64/libvorbis-1.3.7-h81086ad_2.conda + sha256: 95768e4eceaffb973081fd986d03da15d93aa10609ed202e6fd5ca1e490a3dce + md5: 719e7653178a09f5ca0aa05f349b41f7 depends: - - python >=3.9 - - tornado >=2.0 + - libogg + - libcxx >=19 + - __osx >=11.0 + - libogg >=1.3.5,<1.4.0a0 license: BSD-3-Clause license_family: BSD - purls: - - pkg:pypi/snakeviz?source=hash-mapping - size: 171545 - timestamp: 1735289409501 -- conda: https://prefix.dev/conda-forge/noarch/sniffio-1.3.1-pyhd8ed1ab_2.conda - sha256: dce518f45e24cd03f401cb0616917773159a210c19d601c5f2d4e0e5879d30ad - md5: 03fe290994c5e4ec17293cfb6bdce520 - depends: - - python >=3.10 - license: Apache-2.0 - license_family: Apache - purls: - - pkg:pypi/sniffio?source=hash-mapping - size: 15698 - timestamp: 1762941572482 -- conda: https://prefix.dev/conda-forge/linux-64/svt-av1-4.0.1-hecca717_0.conda - sha256: 4a1d2005153b9454fc21c9bad1b539df189905be49e851ec62a6212c2e045381 - md5: 2a2170a3e5c9a354d09e4be718c43235 - depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - libstdcxx >=14 - license: BSD-2-Clause - license_family: BSD purls: [] - size: 2619743 - timestamp: 1769664536467 -- conda: https://prefix.dev/conda-forge/osx-arm64/svt-av1-4.0.1-h0cb729a_0.conda - sha256: bdef3c1c4d2a396ad4f7dc64c5e9a02d4c5a21ff93ed07a33e49574de5d2d18d - md5: 8badc3bf16b62272aa2458f138223821 + size: 259122 + timestamp: 1753879389702 +- conda: https://prefix.dev/conda-forge/osx-arm64/libvulkan-loader-1.4.341.0-h3feff0a_0.conda + sha256: d2790dafc9149b1acd45b9033d02cfa3f3e9ee5af97bd61e0a5718c414a0a135 + md5: 6b4c9a5b130759136a0dde0c373cb0ea depends: - __osx >=11.0 - libcxx >=19 - license: BSD-2-Clause - license_family: BSD - purls: [] - size: 1456245 - timestamp: 1769664727051 -- conda: https://prefix.dev/conda-forge/linux-64/tk-8.6.13-noxft_h366c992_103.conda - sha256: cafeec44494f842ffeca27e9c8b0c27ed714f93ac77ddadc6aaf726b5554ebac - md5: cffd3bdd58090148f4cfcd831f4b26ab - depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - libzlib >=1.3.1,<2.0a0 constrains: - - xorg-libx11 >=1.8.12,<2.0a0 - license: TCL - license_family: BSD + - libvulkan-headers 1.4.341.0.* + license: Apache-2.0 + license_family: APACHE purls: [] - size: 3301196 - timestamp: 1769460227866 -- conda: https://prefix.dev/conda-forge/osx-arm64/tk-8.6.13-h010d191_3.conda - sha256: 799cab4b6cde62f91f750149995d149bc9db525ec12595e8a1d91b9317f038b3 - md5: a9d86bc62f39b94c4661716624eb21b0 + size: 180304 + timestamp: 1770077143460 +- conda: https://prefix.dev/conda-forge/osx-arm64/libwebp-base-1.6.0-h07db88b_0.conda + sha256: a4de3f371bb7ada325e1f27a4ef7bcc81b2b6a330e46fac9c2f78ac0755ea3dd + md5: e5e7d467f80da752be17796b87fe6385 depends: - __osx >=11.0 - - libzlib >=1.3.1,<2.0a0 - license: TCL + constrains: + - libwebp 1.6.0 + license: BSD-3-Clause license_family: BSD purls: [] - size: 3127137 - timestamp: 1769460817696 -- conda: https://prefix.dev/conda-forge/noarch/tomli-2.4.1-pyhcf101f3_0.conda - sha256: 91cafdb64268e43e0e10d30bd1bef5af392e69f00edd34dfaf909f69ab2da6bd - md5: b5325cf06a000c5b14970462ff5e4d58 - depends: - - python >=3.10 - - python - license: MIT - license_family: MIT - purls: - - pkg:pypi/tomli?source=hash-mapping - size: 21561 - timestamp: 1774492402955 -- conda: https://prefix.dev/conda-forge/noarch/tomli-w-1.2.0-pyhd8ed1ab_0.conda - sha256: 304834f2438017921d69f05b3f5a6394b42dc89a90a6128a46acbf8160d377f6 - md5: 32e37e8fe9ef45c637ee38ad51377769 + size: 294974 + timestamp: 1752159906788 +- conda: https://prefix.dev/conda-forge/osx-arm64/libxcb-1.17.0-hbffa61f_1.conda + sha256: 81f9b4fb64d977c19474d1b5616974757aaac21d55401ea105f21022b386bd28 + md5: 923bf656578743d064f352f0b56ee658 depends: - - python >=3.9 + - __osx >=11.0 + - pthread-stubs + - xorg-libxau >=1.0.12,<2.0a0 + - xorg-libxdmcp >=1.1.5,<2.0a0 license: MIT license_family: MIT - purls: - - pkg:pypi/tomli-w?source=hash-mapping - size: 12680 - timestamp: 1736962345843 -- conda: https://prefix.dev/conda-forge/noarch/tomlkit-0.15.0-pyha770c72_0.conda - sha256: 1cd52f9ccb4854c4d731438afe0e833b6b71edaf5ede661152aa98efb3a7cc70 - md5: 42ef10a8f7f5d55a2e267c0d5daa6387 + purls: [] + size: 324264 + timestamp: 1787077544793 +- conda: https://prefix.dev/conda-forge/osx-arm64/libxml2-16-2.15.3-h5ef1a60_0.conda + sha256: ff75b84cdb9e8d123db2fa694a8ac2c2059516b6cbc98ac21fb68e235d0fd354 + md5: 19edaa53885fc8205614b03da2482282 depends: - - python >=3.10 + - __osx >=11.0 + - icu >=78.3,<79.0a0 + - libiconv >=1.18,<2.0a0 + - liblzma >=5.8.3,<6.0a0 + - libzlib >=1.3.2,<2.0a0 + constrains: + - libxml2 2.15.3 license: MIT license_family: MIT - purls: - - pkg:pypi/tomlkit?source=compressed-mapping - size: 41169 - timestamp: 1778423744478 -- conda: https://prefix.dev/conda-forge/linux-64/tornado-6.5.5-py311h49ec1c0_0.conda - sha256: cd8bc08ca661291cfbb05581b79f7e6a6971a072a54a335abcea5460c1230880 - md5: 73b44a114241e564deb5846e7394bf19 - depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - python >=3.11,<3.12.0a0 - - python_abi 3.11.* *_cp311 - license: Apache-2.0 - license_family: Apache - purls: - - pkg:pypi/tornado?source=hash-mapping - size: 876817 - timestamp: 1774358035290 -- conda: https://prefix.dev/conda-forge/osx-arm64/tornado-6.5.5-py311hc949640_0.conda - sha256: 572923958ec987f3f68e228dfec243c89ab94b50398731215d36e2e040db8703 - md5: 6f12d9ff025ab1875dff67ad779ca29d + purls: [] + size: 466360 + timestamp: 1776377102261 +- conda: https://prefix.dev/conda-forge/osx-arm64/libzlib-1.3.2-h8088a28_2.conda + sha256: 361415a698514b19a852f5d1123c5da746d4642139904156ddfca7c922d23a05 + md5: bc5a5721b6439f2f62a84f2548136082 depends: - __osx >=11.0 - - python >=3.11,<3.12.0a0 - - python >=3.11,<3.12.0a0 *_cpython - - python_abi 3.11.* *_cp311 - license: Apache-2.0 - license_family: Apache - purls: - - pkg:pypi/tornado?source=hash-mapping - size: 875022 - timestamp: 1774358570256 -- conda: https://prefix.dev/conda-forge/noarch/trove-classifiers-2026.5.7.17-pyhd8ed1ab_0.conda - sha256: b06931edfab2f6bde64fae1e7323216b74389b5a27242bf2b54b401246efb04d - md5: 58ad6f35e45eca7db0fd5da95aafc693 + constrains: + - zlib 1.3.2 *_2 + license: Zlib + license_family: Other + purls: [] + size: 47759 + timestamp: 1774072956767 +- conda: https://prefix.dev/conda-forge/osx-arm64/llvm-openmp-22.1.4-hc7d1edf_0.conda + sha256: a269273ccf48be6ac582bb958713ba8373262b9157a0fc76b7e5475e8a1d2a78 + md5: 46d04a647df7a4525e487d88068d19ef depends: - - python >=3.10 - license: Apache-2.0 - license_family: Apache - purls: - - pkg:pypi/trove-classifiers?source=hash-mapping - size: 20076 - timestamp: 1778229720640 -- conda: https://prefix.dev/conda-forge/noarch/typing_extensions-4.15.0-pyhcf101f3_0.conda - sha256: 032271135bca55aeb156cee361c81350c6f3fb203f57d024d7e5a1fc9ef18731 - md5: 0caa1af407ecff61170c9437a808404d + - __osx >=11.0 + constrains: + - openmp 22.1.4|22.1.4.* + - intel-openmp <0.0a0 + license: Apache-2.0 WITH LLVM-exception + license_family: APACHE + purls: [] + size: 286406 + timestamp: 1776846235007 +- conda: https://prefix.dev/conda-forge/osx-arm64/llvmlite-0.49.0-py311h4a78e08_2.conda + sha256: 42f645cb34752835a9e9a39da5f383c5d5341727f37f3d96741ac035cc94d164 + md5: 16e87603b33bbbff99352220dee440a6 depends: - - python >=3.10 - python - license: PSF-2.0 - license_family: PSF + - __osx >=11.0 + - libcxx >=21 + - zstd >=1.5.7,<1.6.0a0 + - python_abi 3.11.* *_cp311 + - libzlib >=1.3.2,<2.0a0 + license: BSD-2-Clause + license_family: BSD purls: - - pkg:pypi/typing-extensions?source=hash-mapping - size: 51692 - timestamp: 1756220668932 -- conda: https://prefix.dev/conda-forge/noarch/tzdata-2025c-hc9c84f9_1.conda - sha256: 1d30098909076af33a35017eed6f2953af1c769e273a0626a04722ac4acaba3c - md5: ad659d0a2b3e47e38d829aa8cad2d610 - license: LicenseRef-Public-Domain - purls: [] - size: 119135 - timestamp: 1767016325805 -- conda: https://prefix.dev/conda-forge/linux-64/ukkonen-1.1.0-py311hdf67eae_0.conda - sha256: 31ad759e2d7668f1615021bca0ae2358a284939e3ca3fcb971b3f7aa83c2a6d6 - md5: 5a715cf5e3dc6cd68717c50e47dd7b6b + - pkg:pypi/llvmlite?source=hash-mapping + size: 30512158 + timestamp: 1788013780870 +- conda: https://prefix.dev/conda-forge/osx-arm64/matplotlib-3.11.1-py311ha01d089_2.conda + sha256: 3e9381c800201853483185f7403d8ceb8f013d8a0dcda37c864a34e708158180 + md5: 7ce16f8bcf8a38405f1f09801e1bf832 depends: - - __glibc >=2.17,<3.0.a0 - - cffi - - libgcc >=14 - - libstdcxx >=14 + - matplotlib-base >=3.11.1,<3.11.2.0a0 - python >=3.11,<3.12.0a0 - python_abi 3.11.* *_cp311 - license: MIT - license_family: MIT - purls: - - pkg:pypi/ukkonen?source=hash-mapping - size: 14898 - timestamp: 1769438724694 -- conda: https://prefix.dev/conda-forge/osx-arm64/ukkonen-1.1.0-py311h572238d_0.conda - sha256: 1bf370d4d4698b339d54342b2d653d9ed26f5004af2da3e5556b641fb5e56e1b - md5: 2855259ce88c41c1b2297041ec75f540 + - tornado >=5 + license: PSF-2.0 + license_family: PSF + purls: [] + size: 14921 + timestamp: 1785211095125 +- conda: https://prefix.dev/conda-forge/osx-arm64/matplotlib-base-3.11.1-py311h3c3ad35_2.conda + sha256: 09330e68ce42c7ed076a296b04ce3ea0cb10d72fb5c31b68bf1aa93ecf553a07 + md5: e0a2569461d3cc107301cce6835cf0ba depends: - __osx >=11.0 - - cffi + - contourpy >=1.0.1 + - cycler >=0.10 + - fonttools >=4.28.2 + - freetype + - kiwisolver >=1.3.1 - libcxx >=19 + - libfreetype >=2.14.3 + - libfreetype6 >=2.14.3 + - libraqm >=0.11.0,<0.12.0a0 + - numpy >=1.23,<3 + - numpy >=1.25 + - packaging >=20.0 + - pillow >=9 + - pyparsing >=3 - python >=3.11,<3.12.0a0 - - python >=3.11,<3.12.0a0 *_cpython + - python-dateutil >=2.7 - python_abi 3.11.* *_cp311 - license: MIT - license_family: MIT + - qhull >=2020.2,<2020.3.0a0 + license: PSF-2.0 + license_family: PSF purls: - - pkg:pypi/ukkonen?source=hash-mapping - size: 14760 - timestamp: 1769438970347 -- conda: https://prefix.dev/conda-forge/linux-64/unicodedata2-17.0.1-py311h49ec1c0_0.conda - sha256: 2bd8ee058dc98e614003591eb221a8b08449768b13aebe76dad8528bf0f5f88b - md5: 2889f0c0b6a6d7a37bd64ec60f4cc210 + - pkg:pypi/matplotlib?source=hash-mapping + size: 8811362 + timestamp: 1785211075697 +- conda: https://prefix.dev/conda-forge/osx-arm64/mpg123-1.32.9-hf642e45_0.conda + sha256: 070bbbbb96856c325c0b6637638ce535afdc49adbaff306e2238c6032d28dddf + md5: d2b4857bdc3b76c36e23236172d09840 depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - python >=3.11,<3.12.0a0 + - __osx >=11.0 + - libcxx >=18 + license: LGPL-2.1-only + license_family: LGPL + purls: [] + size: 360712 + timestamp: 1730581491116 +- conda: https://prefix.dev/conda-forge/osx-arm64/ncurses-6.6-h1d4f5a5_0.conda + sha256: 4ea6c620b87bd1d42bb2ccc2c87cd2483fa2d7f9e905b14c223f11ff3f4c455d + md5: 343d10ed5b44030a2f67193905aea159 + depends: + - __osx >=11.0 + license: X11 AND BSD-3-Clause + purls: [] + size: 805509 + timestamp: 1777423252320 +- conda: https://prefix.dev/conda-forge/osx-arm64/numba-0.67.0-py311hf682900_1.conda + sha256: fd613c23e421aa4b8700308951c90b7c4f5f3b78f85025e0c3af9366fdf5c4b0 + md5: 643ca1646acb686990d5febe0c0e5d63 + depends: + - python + - llvmlite >=0.49.0,<0.50.0a0 + - numpy >=1.22.3,<2.6 + - libcxx >=21 + - __osx >=11.0 + - llvm-openmp >=21.1.8 - python_abi 3.11.* *_cp311 - license: Apache-2.0 - license_family: Apache + - numpy >=1.23,<3 + constrains: + - tbb >=2021.6.0 + - libopenblas >=0.3.18,!=0.3.20 + - cuda-version >=11.2 + - cudatoolkit >=11.2 + - scipy >=1.0 + - cuda-python >=11.6 + license: BSD-2-Clause + license_family: BSD purls: - - pkg:pypi/unicodedata2?source=hash-mapping - size: 409682 - timestamp: 1770909108616 -- conda: https://prefix.dev/conda-forge/osx-arm64/unicodedata2-17.0.1-py311hc949640_0.conda - sha256: 984d3b0ddb0802c228c520db31d906b5b546b13da3eca1ce35c754d97c012497 - md5: a9d9010d246205c63f824b0bcf050acd + - pkg:pypi/numba?source=hash-mapping + size: 6273051 + timestamp: 1787145526945 +- conda: https://prefix.dev/conda-forge/osx-arm64/numpy-2.0.2-py311h649a571_1.conda + sha256: 3d4c508041d17007a56f79b593a6d6a69d4f4e2453f1f7ee29ecb48992cc3acc + md5: 417c4c5c4a4693156f5b878cf94bf7a0 depends: - __osx >=11.0 + - libblas >=3.9.0,<4.0a0 + - libcblas >=3.9.0,<4.0a0 + - libcxx >=18 + - liblapack >=3.9.0,<4.0a0 - python >=3.11,<3.12.0a0 - python >=3.11,<3.12.0a0 *_cpython - python_abi 3.11.* *_cp311 - license: Apache-2.0 - license_family: Apache - purls: - - pkg:pypi/unicodedata2?source=hash-mapping - size: 416024 - timestamp: 1770909604661 -- conda: https://prefix.dev/conda-forge/noarch/userpath-1.9.2-pyhd8ed1ab_0.conda - sha256: 26e53b42f7fa1127e6115a35b91c20e15f75984648b88f115136f27715d4a440 - md5: 946e3571aaa55e0870fec0dea13de3bf - depends: - - click - - python >=3.9 - license: MIT - license_family: MIT - purls: - - pkg:pypi/userpath?source=hash-mapping - size: 14292 - timestamp: 1735925027874 -- conda: https://prefix.dev/conda-forge/linux-64/uv-0.11.12-h29f5ae7_0.conda - sha256: 4fc1481bb6ecf5a1a755661483eb99a0ec2054cd02e5893b55f9c80bac9437a8 - md5: e86a95851fd53465f0657c068cb6c403 - depends: - - libgcc >=14 - - __glibc >=2.17,<3.0.a0 - - libstdcxx >=14 constrains: - - __glibc >=2.17 - license: Apache-2.0 OR MIT - purls: [] - size: 19190543 - timestamp: 1778287747008 -- conda: https://prefix.dev/conda-forge/osx-arm64/uv-0.11.12-h2c65d96_0.conda - sha256: e8050d5259b4f77b838ecc573643451593b39970f1b25412267db10919de2ca3 - md5: a5b3c646ec7fe96f192bb4f5fa8442f3 + - numpy-base <0a0 + license: BSD-3-Clause + license_family: BSD + purls: + - pkg:pypi/numpy?source=hash-mapping + size: 6893464 + timestamp: 1732314808608 +- conda: https://prefix.dev/conda-forge/osx-arm64/openjpeg-2.5.4-hd9e9057_0.conda + sha256: 60aca8b9f94d06b852b296c276b3cf0efba5a6eb9f25feb8708570d3a74f00e4 + md5: 4b5d3a91320976eec71678fad1e3569b depends: - __osx >=11.0 - libcxx >=19 - constrains: + - libpng >=1.6.55,<1.7.0a0 + - libtiff >=4.7.1,<4.8.0a0 + - libzlib >=1.3.1,<2.0a0 + license: BSD-2-Clause + license_family: BSD + purls: [] + size: 319697 + timestamp: 1772625397692 +- conda: https://prefix.dev/conda-forge/osx-arm64/openssl-3.6.2-hd24854e_0.conda + sha256: c91bf510c130a1ea1b6ff023e28bac0ccaef869446acd805e2016f69ebdc49ea + md5: 25dcccd4f80f1638428613e0d7c9b4e1 + depends: - __osx >=11.0 - license: Apache-2.0 OR MIT + - ca-certificates + license: Apache-2.0 + license_family: Apache purls: [] - size: 16562936 - timestamp: 1778287818707 -- conda: https://prefix.dev/conda-forge/noarch/virtualenv-21.3.1-pyhcf101f3_0.conda - sha256: 8888b4725d4166ab54435ba4b6a24e9f089578301a88f8157d012dd38a88ac43 - md5: dd6a1f3ce9d1cfa8b5b1b32953a80a55 + size: 3106008 + timestamp: 1775587972483 +- conda: https://prefix.dev/conda-forge/osx-arm64/opusfile-0.12-h5643135_2.conda + sha256: 108dbee936a8e3c21d2aa5618326343844df8f1fe14067c4dc5a731d7945ecc0 + md5: e34e472ae04beeb642c5e937a2aeeebf + depends: + - libogg >=1.3.4,<1.4.0a0 + - libopus >=1.3.1,<2.0a0 + - openssl >=3.0.7,<4.0a0 + license: BSD-3-Clause + license_family: BSD + purls: [] + size: 80128 + timestamp: 1670387790769 +- conda: https://prefix.dev/conda-forge/osx-arm64/pandas-3.0.1-py311h4a068b9_0.conda + sha256: 1a0f57d3c5fb08e97c8a92f560e1ce011f4ab5a1185eacb60e83c00458684dc4 + md5: e853dd807ee17d7d4f6c3c57b29456ac depends: - - python >=3.10 - - distlib >=0.3.7,<1 - - filelock <4,>=3.24.2 - - importlib-metadata >=6.6 - - platformdirs >=3.9.1,<5 - - python-discovery >=1 - - typing_extensions >=4.13.2 - python - license: MIT - license_family: MIT + - numpy >=1.26.0 + - python-dateutil >=2.8.2 + - __osx >=11.0 + - libcxx >=19 + - python 3.11.* *_cpython + - numpy >=1.23,<3 + - python_abi 3.11.* *_cp311 + constrains: + - adbc-driver-postgresql >=1.2.0 + - adbc-driver-sqlite >=1.2.0 + - beautifulsoup4 >=4.12.3 + - blosc >=1.21.3 + - bottleneck >=1.4.2 + - fastparquet >=2024.11.0 + - fsspec >=2024.10.0 + - gcsfs >=2024.10.0 + - html5lib >=1.1 + - hypothesis >=6.116.0 + - jinja2 >=3.1.5 + - lxml >=5.3.0 + - matplotlib >=3.9.3 + - numba >=0.60.0 + - numexpr >=2.10.2 + - odfpy >=1.4.1 + - openpyxl >=3.1.5 + - psycopg2 >=2.9.10 + - pyarrow >=13.0.0 + - pyiceberg >=0.8.1 + - pymysql >=1.1.1 + - pyqt5 >=5.15.9 + - pyreadstat >=1.2.8 + - pytables >=3.10.1 + - pytest >=8.3.4 + - pytest-xdist >=3.6.1 + - python-calamine >=0.3.0 + - pytz >=2024.2 + - pyxlsb >=1.0.10 + - qtpy >=2.4.2 + - scipy >=1.14.1 + - s3fs >=2024.10.0 + - sqlalchemy >=2.0.36 + - tabulate >=0.9.0 + - xarray >=2024.10.0 + - xlrd >=2.0.1 + - xlsxwriter >=3.2.0 + - zstandard >=0.23.0 + license: BSD-3-Clause + license_family: BSD purls: - - pkg:pypi/virtualenv?source=hash-mapping - size: 5154970 - timestamp: 1777964652524 -- conda: https://prefix.dev/conda-forge/linux-64/wayland-1.25.0-hd6090a7_0.conda - sha256: ea374d57a8fcda281a0a89af0ee49a2c2e99cc4ac97cf2e2db7064e74e764bdb - md5: 996583ea9c796e5b915f7d7580b51ea6 + - pkg:pypi/pandas?source=hash-mapping + size: 14295353 + timestamp: 1771409101672 +- conda: https://prefix.dev/conda-forge/osx-arm64/pango-1.56.4-h875632e_0.conda + sha256: 705484ad60adee86cab1aad3d2d8def03a699ece438c864e8ac995f6f66401a6 + md5: 7d57f8b4b7acfc75c777bc231f0d31be depends: - - __glibc >=2.17,<3.0.a0 - - libexpat >=2.7.4,<3.0a0 - - libffi >=3.5.2,<3.6.0a0 - - libgcc >=14 - - libstdcxx >=14 - license: MIT - license_family: MIT + - __osx >=11.0 + - cairo >=1.18.4,<2.0a0 + - fontconfig >=2.15.0,<3.0a0 + - fonts-conda-ecosystem + - fribidi >=1.0.10,<2.0a0 + - harfbuzz >=11.0.1 + - libexpat >=2.7.0,<3.0a0 + - libfreetype >=2.13.3 + - libfreetype6 >=2.13.3 + - libglib >=2.84.2,<3.0a0 + - libpng >=1.6.49,<1.7.0a0 + - libzlib >=1.3.1,<2.0a0 + license: LGPL-2.1-or-later purls: [] - size: 334139 - timestamp: 1773959575393 -- conda: https://prefix.dev/conda-forge/linux-64/xcb-util-0.4.1-h4f16b4b_2.conda - sha256: ad8cab7e07e2af268449c2ce855cbb51f43f4664936eff679b1f3862e6e4b01d - md5: fdc27cb255a7a2cc73b7919a968b48f0 + size: 426931 + timestamp: 1751292636271 +- conda: https://prefix.dev/conda-forge/osx-arm64/pcre2-10.47-h30297fc_0.conda + sha256: 5e2e443f796f2fd92adf7978286a525fb768c34e12b1ee9ded4000a41b2894ba + md5: 9b4190c4055435ca3502070186eba53a depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=13 - - libxcb >=1.17.0,<2.0a0 - license: MIT - license_family: MIT + - __osx >=11.0 + - bzip2 >=1.0.8,<2.0a0 + - libzlib >=1.3.1,<2.0a0 + license: BSD-3-Clause + license_family: BSD purls: [] - size: 20772 - timestamp: 1750436796633 -- conda: https://prefix.dev/conda-forge/linux-64/xcb-util-cursor-0.1.6-hb03c661_0.conda - sha256: c2be9cae786fdb2df7c2387d2db31b285cf90ab3bfabda8fa75a596c3d20fc67 - md5: 4d1fc190b99912ed557a8236e958c559 + size: 850231 + timestamp: 1763655726735 +- conda: https://prefix.dev/conda-forge/osx-arm64/pillow-12.3.0-py311hd37aea2_0.conda + sha256: 3c680e002d0aadf9e21b6ee50929d8fec6ced9234b1340a027255b4518e6e49f + md5: 26ba3b773222fada6f89baf4846190e3 depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - libxcb >=1.13 + - python + - python 3.11.* *_cpython + - __osx >=11.0 + - openjpeg >=2.5.4,<3.0a0 + - libfreetype >=2.14.3 + - libfreetype6 >=2.14.3 + - libjpeg-turbo >=3.1.4.1,<4.0a0 + - zlib-ng >=2.3.3,<2.4.0a0 + - python_abi 3.11.* *_cp311 + - libtiff >=4.7.1,<4.8.0a0 - libxcb >=1.17.0,<2.0a0 - - xcb-util-image >=0.4.0,<0.5.0a0 - - xcb-util-renderutil >=0.3.10,<0.4.0a0 - license: MIT - license_family: MIT - purls: [] - size: 20829 - timestamp: 1763366954390 -- conda: https://prefix.dev/conda-forge/linux-64/xcb-util-image-0.4.0-hb711507_2.conda - sha256: 94b12ff8b30260d9de4fd7a28cca12e028e572cbc504fd42aa2646ec4a5bded7 - md5: a0901183f08b6c7107aab109733a3c91 + - tk >=8.6.13,<8.7.0a0 + - lcms2 >=2.19.1,<3.0a0 + - libwebp-base >=1.6.0,<2.0a0 + license: HPND + purls: + - pkg:pypi/pillow?source=hash-mapping + size: 993213 + timestamp: 1782912213683 +- conda: https://prefix.dev/conda-forge/osx-arm64/pixman-0.46.4-h81086ad_1.conda + sha256: 29c9b08a9b8b7810f9d4f159aecfd205fce051633169040005c0b7efad4bc718 + md5: 17c3d745db6ea72ae2fce17e7338547f depends: - - libgcc-ng >=12 - - libxcb >=1.16,<2.0.0a0 - - xcb-util >=0.4.1,<0.5.0a0 + - __osx >=11.0 + - libcxx >=19 license: MIT license_family: MIT purls: [] - size: 24551 - timestamp: 1718880534789 -- conda: https://prefix.dev/conda-forge/linux-64/xcb-util-keysyms-0.4.1-hb711507_0.conda - sha256: 546e3ee01e95a4c884b6401284bb22da449a2f4daf508d038fdfa0712fe4cc69 - md5: ad748ccca349aec3e91743e08b5e2b50 + size: 248045 + timestamp: 1754665282033 +- conda: https://prefix.dev/conda-forge/osx-arm64/portaudio-19.7.0-h5833ebf_0.conda + sha256: 3d86803ade1ff3fd29ea1b61ce2e5ad65af0966d795ab8a7a2685fee75cf0f82 + md5: fb72bb70cfea298990d5e1a12317047c depends: - - libgcc-ng >=12 - - libxcb >=1.16,<2.0.0a0 + - __osx >=11.0 + - libcxx >=17 license: MIT license_family: MIT purls: [] - size: 14314 - timestamp: 1718846569232 -- conda: https://prefix.dev/conda-forge/linux-64/xcb-util-renderutil-0.3.10-hb711507_0.conda - sha256: 2d401dadc43855971ce008344a4b5bd804aca9487d8ebd83328592217daca3df - md5: 0e0cbe0564d03a99afd5fd7b362feecd + size: 58138 + timestamp: 1730364270871 +- conda: https://prefix.dev/conda-forge/osx-arm64/portmidi-2.0.8-haf25636_0.conda + sha256: 2a1fb2c2507a3b88ac68c4dac435a836be365446e66e995749d2188456fb4262 + md5: 2544b03efb37c9476f3ab4e993c224d1 depends: - - libgcc-ng >=12 - - libxcb >=1.16,<2.0.0a0 + - __osx >=11.0 + - libcxx >=19 license: MIT license_family: MIT purls: [] - size: 16978 - timestamp: 1718848865819 -- conda: https://prefix.dev/conda-forge/linux-64/xcb-util-wm-0.4.2-hb711507_0.conda - sha256: 31d44f297ad87a1e6510895740325a635dd204556aa7e079194a0034cdd7e66a - md5: 608e0ef8256b81d04456e8d211eee3e8 + size: 41391 + timestamp: 1764706738148 +- conda: https://prefix.dev/conda-forge/osx-arm64/protobuf-3.20.2-py311ha397e9f_1.conda + sha256: 38ea7c727a352ae38199c9b87b5b5636cd6bb62de13491788d803e69611776da + md5: cfa15b242f40e62b78281a3b85b07eec depends: - - libgcc-ng >=12 - - libxcb >=1.16,<2.0.0a0 - license: MIT - license_family: MIT - purls: [] - size: 51689 - timestamp: 1718844051451 -- conda: https://prefix.dev/conda-forge/linux-64/xkeyboard-config-2.47-hb03c661_0.conda - sha256: 19c2bb14bec84b0e995b56b752369775c75f1589314b43733948bb5f471a6915 - md5: b56e0c8432b56decafae7e78c5f29ba5 + - libcxx >=14.0.6 + - libprotobuf 3.20.2.* + - libprotobuf >=3.20.2,<3.21.0a0 + - python >=3.11,<3.12.0a0 + - python >=3.11,<3.12.0a0 *_cpython + - python_abi 3.11.* *_cp311 + - setuptools + - six + license: BSD-3-Clause + license_family: BSD + purls: + - pkg:pypi/protobuf?source=hash-mapping + size: 348201 + timestamp: 1669119662437 +- conda: https://prefix.dev/conda-forge/osx-arm64/pthread-stubs-0.4-h84a0fba_1003.conda + sha256: 1c2338b9b0486af86883b9593d2f3e2845bbf216ea453dfe5d9a228e8dbe4057 + md5: d4852e6054b74645cf49ca10f6349191 depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - xorg-libx11 >=1.8.13,<2.0a0 + - __osx >=11.0 license: MIT license_family: MIT purls: [] - size: 399291 - timestamp: 1772021302485 -- conda: https://prefix.dev/conda-forge/linux-64/xorg-libice-1.1.2-hb9d3cd8_0.conda - sha256: c12396aabb21244c212e488bbdc4abcdef0b7404b15761d9329f5a4a39113c4b - md5: fb901ff28063514abb6046c9ec2c4a45 + size: 9238 + timestamp: 1786068031100 +- conda: https://prefix.dev/conda-forge/osx-arm64/pthread-stubs-0.4-hd74edd7_1002.conda + sha256: 8ed65e17fbb0ca944bfb8093b60086e3f9dd678c3448b5de212017394c247ee3 + md5: 415816daf82e0b23a736a069a75e9da7 depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=13 + - __osx >=11.0 license: MIT license_family: MIT purls: [] - size: 58628 - timestamp: 1734227592886 -- conda: https://prefix.dev/conda-forge/linux-64/xorg-libsm-1.2.6-he73a12e_0.conda - sha256: 277841c43a39f738927145930ff963c5ce4c4dacf66637a3d95d802a64173250 - md5: 1c74ff8c35dcadf952a16f752ca5aa49 + size: 8381 + timestamp: 1726802424786 +- conda: https://prefix.dev/conda-forge/osx-arm64/pygame-2.6.1-py311hc3e7c57_0.conda + sha256: e95e452aed4e6511b16f2650526c3e74438d5198a14e646832020d854dfa9964 + md5: db72b6d24c6c7ce1d80b8c659b4aeb2b depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=13 - - libuuid >=2.38.1,<3.0a0 - - xorg-libice >=1.1.2,<2.0a0 - license: MIT - license_family: MIT - purls: [] - size: 27590 - timestamp: 1741896361728 -- conda: https://prefix.dev/conda-forge/linux-64/xorg-libx11-1.8.13-he1eb515_0.conda - sha256: 516d4060139dbb4de49a4dcdc6317a9353fb39ebd47789c14e6fe52de0deee42 - md5: 861fb6ccbc677bb9a9fb2468430b9c6a + - __osx >=11.0 + - fontconfig >=2.14.2,<3.0a0 + - fonts-conda-ecosystem + - freetype >=2.12.1,<3.0a0 + - libcxx >=17 + - libjpeg-turbo >=3.0.0,<4.0a0 + - libpng >=1.6.44,<1.7.0a0 + - libzlib >=1.3.1,<2.0a0 + - portmidi >=2.0.4,<3.0a0 + - python >=3.11,<3.12.0a0 + - python >=3.11,<3.12.0a0 *_cpython + - python_abi 3.11.* *_cp311 + - sdl2 >=2.30.7,<3.0a0 + - sdl2_image >=2.8.2,<3.0a0 + - sdl2_mixer >=2.6.3,<3.0a0 + - sdl2_ttf >=2.22.0,<3.0a0 + license: LGPL-2.1-only + purls: + - pkg:pypi/pygame?source=hash-mapping + size: 2917534 + timestamp: 1727636756068 +- conda: https://prefix.dev/conda-forge/osx-arm64/python-3.10.20-h1b19095_0_cpython.conda + sha256: f0f6fcbb6cfdee5a6b9c03b5b94d2bbe737f3b17a618006c7685cc48992ae667 + md5: 55ec25b0d09379eb11c32dbe09ee28c4 depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - libxcb >=1.17.0,<2.0a0 - license: MIT - license_family: MIT + - __osx >=11.0 + - bzip2 >=1.0.8,<2.0a0 + - libexpat >=2.7.4,<3.0a0 + - libffi >=3.4,<4.0a0 + - liblzma >=5.8.2,<6.0a0 + - libsqlite >=3.51.2,<4.0a0 + - libzlib >=1.3.1,<2.0a0 + - ncurses >=6.5,<7.0a0 + - openssl >=3.5.5,<4.0a0 + - readline >=8.3,<9.0a0 + - tk >=8.6.13,<8.7.0a0 + - tzdata + constrains: + - python_abi 3.10.* *_cp310 + license: Python-2.0 purls: [] - size: 839652 - timestamp: 1770819209719 -- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxau-1.0.12-hb03c661_1.conda - sha256: 6bc6ab7a90a5d8ac94c7e300cc10beb0500eeba4b99822768ca2f2ef356f731b - md5: b2895afaf55bf96a8c8282a2e47a5de0 + size: 12468674 + timestamp: 1772730636766 +- conda: https://prefix.dev/conda-forge/osx-arm64/python-3.11.15-h8561d8f_0_cpython.conda + sha256: 9a846065863925b2562126a5c6fecd7a972e84aaa4de9e686ad3715ca506acfa + md5: 49c7d96c58b969585cf09fb01d74e08e depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - license: MIT - license_family: MIT + - __osx >=11.0 + - bzip2 >=1.0.8,<2.0a0 + - libexpat >=2.7.4,<3.0a0 + - libffi >=3.5.2,<3.6.0a0 + - liblzma >=5.8.2,<6.0a0 + - libsqlite >=3.51.2,<4.0a0 + - libzlib >=1.3.1,<2.0a0 + - ncurses >=6.5,<7.0a0 + - openssl >=3.5.5,<4.0a0 + - readline >=8.3,<9.0a0 + - tk >=8.6.13,<8.7.0a0 + - tzdata + constrains: + - python_abi 3.11.* *_cp311 + license: Python-2.0 purls: [] - size: 15321 - timestamp: 1762976464266 -- conda: https://prefix.dev/conda-forge/osx-arm64/xorg-libxau-1.0.12-h84a0fba_2.conda - sha256: 5c5ea38ceec008e4ff40111fc166b04086fca310b0aa9e5bd46f65e6b0dcb71d - md5: 31d71ce1b056f69b6ec67ee0712bdf97 + size: 14753109 + timestamp: 1772730203101 +- conda: https://prefix.dev/conda-forge/osx-arm64/pyyaml-6.0.3-py311hc290fe0_1.conda + sha256: 984e73d7957460689e10533059de8adb38a308853d298900a37acc58edd84cec + md5: e4b908da7cd496b3fa6798c0f60a2a19 depends: - __osx >=11.0 + - python >=3.11,<3.12.0a0 + - python >=3.11,<3.12.0a0 *_cpython + - python_abi 3.11.* *_cp311 + - yaml >=0.2.5,<0.3.0a0 license: MIT license_family: MIT - purls: [] - size: 15124 - timestamp: 1786381585975 -- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxcomposite-0.4.7-hb03c661_0.conda - sha256: 048c103000af9541c919deef03ae7c5e9c570ffb4024b42ecb58dbde402e373a - md5: f2ba4192d38b6cef2bb2c25029071d90 + purls: + - pkg:pypi/pyyaml?source=hash-mapping + size: 192948 + timestamp: 1770223655988 +- conda: https://prefix.dev/conda-forge/osx-arm64/qhull-2020.2-h420ef59_5.conda + sha256: 873ac689484262a51fd79bc6103c1a1bedbf524924d7f0088fb80703042805e4 + md5: 6483b1f59526e05d7d894e466b5b6924 depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - xorg-libx11 >=1.8.12,<2.0a0 - - xorg-libxfixes >=6.0.2,<7.0a0 - license: MIT - license_family: MIT + - __osx >=11.0 + - libcxx >=16 + license: LicenseRef-Qhull purls: [] - size: 14415 - timestamp: 1770044404696 -- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxcursor-1.2.3-hb9d3cd8_0.conda - sha256: 832f538ade441b1eee863c8c91af9e69b356cd3e9e1350fff4fe36cc573fc91a - md5: 2ccd714aa2242315acaf0a67faea780b + size: 516376 + timestamp: 1720814307311 +- conda: https://prefix.dev/conda-forge/osx-arm64/rav1e-0.8.1-h8246384_0.conda + sha256: 925e35b71fe513e0380ecd2fe137e3f4f248bf7ce4bad96946c7c704b7a50d26 + md5: 4706a8a71474c692482c3f86c2175454 depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=13 - - xorg-libx11 >=1.8.10,<2.0a0 - - xorg-libxfixes >=6.0.1,<7.0a0 - - xorg-libxrender >=0.9.11,<0.10.0a0 - license: MIT - license_family: MIT + - __osx >=11.0 + constrains: + - __osx >=11.0 + license: BSD-2-Clause + license_family: BSD purls: [] - size: 32533 - timestamp: 1730908305254 -- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxdamage-1.1.6-hb9d3cd8_0.conda - sha256: 43b9772fd6582bf401846642c4635c47a9b0e36ca08116b3ec3df36ab96e0ec0 - md5: b5fcc7172d22516e1f965490e65e33a4 + size: 886953 + timestamp: 1772541394570 +- conda: https://prefix.dev/conda-forge/osx-arm64/readline-8.3-h46df422_0.conda + sha256: a77010528efb4b548ac2a4484eaf7e1c3907f2aec86123ed9c5212ae44502477 + md5: f8381319127120ce51e081dce4865cf4 depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=13 - - xorg-libx11 >=1.8.10,<2.0a0 - - xorg-libxext >=1.3.6,<2.0a0 - - xorg-libxfixes >=6.0.1,<7.0a0 - license: MIT - license_family: MIT + - __osx >=11.0 + - ncurses >=6.5,<7.0a0 + license: GPL-3.0-only + license_family: GPL purls: [] - size: 13217 - timestamp: 1727891438799 -- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxdmcp-1.1.5-hb03c661_1.conda - sha256: 25d255fb2eef929d21ff660a0c687d38a6d2ccfbcbf0cc6aa738b12af6e9d142 - md5: 1dafce8548e38671bea82e3f5c6ce22f - depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 + size: 313930 + timestamp: 1765813902568 +- conda: https://prefix.dev/conda-forge/osx-arm64/rhash-1.4.3-hb547adb_2.conda + sha256: f20c9765768d0c61bbbb462dc83b55372328498a746f60e1e93c985e3436ef73 + md5: 24308c7e0949c572688900b8b2f2a3ba license: MIT license_family: MIT purls: [] - size: 20591 - timestamp: 1762976546182 -- conda: https://prefix.dev/conda-forge/osx-arm64/xorg-libxdmcp-1.1.5-h84a0fba_2.conda - sha256: 2f6915f0897ace4a1b5d66d0463079f7bc9819b0048c03677e47764f0a743499 - md5: f51e9414bf1b7bb556aac1a0b74a75fe + size: 176444 + timestamp: 1693427792263 +- conda: https://prefix.dev/conda-forge/osx-arm64/ruff-0.15.12-hbd3f8a3_0.conda + noarch: python + sha256: 91992a557456cbe9980e8ffb0f0d1200f65f741adeefc7ecf568d1935690a7bc + md5: 7151a0851207b88c0031f388a7825e9b depends: + - python + - __osx >=11.0 + constrains: - __osx >=11.0 license: MIT license_family: MIT - purls: [] - size: 19486 - timestamp: 1786381546642 -- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxext-1.3.7-hb03c661_0.conda - sha256: 79c60fc6acfd3d713d6340d3b4e296836a0f8c51602327b32794625826bd052f - md5: 34e54f03dfea3e7a2dcf1453a85f1085 + purls: + - pkg:pypi/ruff?source=hash-mapping + size: 8485007 + timestamp: 1778119519471 +- conda: https://prefix.dev/conda-forge/osx-arm64/scipy-1.17.1-py311he9931d0_0.conda + sha256: f212138a7eb86cf8bcdb46f003ae552967cd7e48d2c539f7f8dd6e800c74b70d + md5: 40606bef4834281d5f746626338829dc depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - xorg-libx11 >=1.8.12,<2.0a0 - license: MIT - license_family: MIT - purls: [] - size: 50326 - timestamp: 1769445253162 -- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxfixes-6.0.2-hb03c661_0.conda - sha256: 83c4c99d60b8784a611351220452a0a85b080668188dce5dfa394b723d7b64f4 - md5: ba231da7fccf9ea1e768caf5c7099b84 + - __osx >=11.0 + - libblas >=3.9.0,<4.0a0 + - libcblas >=3.9.0,<4.0a0 + - libcxx >=19 + - libgfortran + - libgfortran5 >=14.3.0 + - liblapack >=3.9.0,<4.0a0 + - numpy <2.7 + - numpy >=1.23,<3 + - numpy >=1.25.2 + - python >=3.11,<3.12.0a0 + - python >=3.11,<3.12.0a0 *_cpython + - python_abi 3.11.* *_cp311 + license: BSD-3-Clause + license_family: BSD + purls: + - pkg:pypi/scipy?source=hash-mapping + size: 14107248 + timestamp: 1771880859933 +- conda: https://prefix.dev/conda-forge/osx-arm64/sdl2-2.32.56-h248ca61_0.conda + sha256: 704c5cae4bc839a18c70cbf3387d7789f1902828c79c6ddabcd34daf594f4103 + md5: 092c5b693dc6adf5f409d12f33295a2a depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - xorg-libx11 >=1.8.12,<2.0a0 - license: MIT - license_family: MIT + - libcxx >=19 + - __osx >=11.0 + - sdl3 >=3.2.22,<4.0a0 + license: Zlib purls: [] - size: 20071 - timestamp: 1759282564045 -- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxi-1.8.2-hb9d3cd8_0.conda - sha256: 1a724b47d98d7880f26da40e45f01728e7638e6ec69f35a3e11f92acd05f9e7a - md5: 17dcc85db3c7886650b8908b183d6876 + size: 542508 + timestamp: 1757842919681 +- conda: https://prefix.dev/conda-forge/osx-arm64/sdl2_image-2.8.2-h376e2e1_1.conda + sha256: 8c385478a7b6a6e34b3b3f3d48ed48f504698544987ad331f03a7b43b11d689a + md5: 247d2c5a873901ef51f378c69a2c708e depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=13 - - xorg-libx11 >=1.8.10,<2.0a0 - - xorg-libxext >=1.3.6,<2.0a0 - - xorg-libxfixes >=6.0.1,<7.0a0 - license: MIT - license_family: MIT + - __osx >=11.0 + - libavif16 >=1.0.4,<2.0a0 + - libcxx >=16 + - libjpeg-turbo >=3.0.0,<4.0a0 + - libpng >=1.6.43,<1.7.0a0 + - libtiff >=4.6.0,<4.8.0a0 + - libwebp-base >=1.4.0,<2.0a0 + - libzlib >=1.2.13,<2.0.0a0 + - sdl2 >=2.30.2,<3.0a0 + license: Zlib purls: [] - size: 47179 - timestamp: 1727799254088 -- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxinerama-1.1.6-hecca717_0.conda - sha256: 3a9da41aac6dca9d3ff1b53ee18b9d314de88add76bafad9ca2287a494abcd86 - md5: 93f5d4b5c17c8540479ad65f206fea51 + size: 118041 + timestamp: 1716857215118 +- conda: https://prefix.dev/conda-forge/osx-arm64/sdl2_mixer-2.6.3-h45fadf6_2.conda + sha256: b826d7fa6738d9fcc36bdcb299744246fe82d0f9d9d0d0f999f3111cb7b4d373 + md5: 890924faa4965ba3edb0cc5cc94db572 depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - libstdcxx >=14 - - xorg-libx11 >=1.8.12,<2.0a0 - - xorg-libxext >=1.3.6,<2.0a0 - license: MIT - license_family: MIT + - __osx >=11.0 + - fluidsynth >=2.5.2,<2.6.0a0 + - libcxx >=19 + - libflac >=1.5.0,<1.6.0a0 + - libmad >=0.15.1b,<0.16.0a0 + - libogg >=1.3.5,<1.4.0a0 + - libvorbis >=1.3.7,<1.4.0a0 + - mpg123 >=1.32.9,<1.33.0a0 + - opusfile >=0.12,<0.13.0a0 + - sdl2 >=2.32.56,<3.0a0 + license: Zlib purls: [] - size: 14818 - timestamp: 1769432261050 -- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxrandr-1.5.5-hb03c661_0.conda - sha256: 80ed047a5cb30632c3dc5804c7716131d767089f65877813d4ae855ee5c9d343 - md5: e192019153591938acf7322b6459d36e + size: 187456 + timestamp: 1766614943278 +- conda: https://prefix.dev/conda-forge/osx-arm64/sdl2_ttf-2.24.0-h443c5de_0.conda + sha256: 5dc56fd1de51dec2f7b63b1a9069ab35ab0494d9cd5af164ab0019cbd9564cf6 + md5: 3cf5cf83deccb663b4e932d3d4b28f57 depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - xorg-libx11 >=1.8.12,<2.0a0 - - xorg-libxext >=1.3.6,<2.0a0 - - xorg-libxrender >=0.9.12,<0.10.0a0 - license: MIT - license_family: MIT + - __osx >=11.0 + - freetype >=2.12.1,<3.0a0 + - harfbuzz >=10.1.0 + - sdl2 >=2.30.10,<3.0a0 + license: Zlib purls: [] - size: 30456 - timestamp: 1769445263457 -- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxrender-0.9.12-hb9d3cd8_0.conda - sha256: 044c7b3153c224c6cedd4484dd91b389d2d7fd9c776ad0f4a34f099b3389f4a1 - md5: 96d57aba173e878a2089d5638016dc5e + size: 45429 + timestamp: 1736118165229 +- conda: https://prefix.dev/conda-forge/osx-arm64/sdl3-3.4.8-h6fa9c73_0.conda + sha256: 0c15a7f3f46d175c70ca7b032cee3eee9ef602492688a79a6e734f2efc466dad + md5: 53311362c6da21e58442bfb959991455 + depends: + - __osx >=11.0 + - libcxx >=19 + - libvulkan-loader >=1.4.341.0,<2.0a0 + - libusb >=1.0.29,<2.0a0 + - dbus >=1.16.2,<2.0a0 + license: Zlib + purls: [] + size: 1561566 + timestamp: 1777693640800 +- conda: https://prefix.dev/conda-forge/osx-arm64/svt-av1-4.0.1-h0cb729a_0.conda + sha256: bdef3c1c4d2a396ad4f7dc64c5e9a02d4c5a21ff93ed07a33e49574de5d2d18d + md5: 8badc3bf16b62272aa2458f138223821 depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=13 - - xorg-libx11 >=1.8.10,<2.0a0 - license: MIT - license_family: MIT + - __osx >=11.0 + - libcxx >=19 + license: BSD-2-Clause + license_family: BSD purls: [] - size: 33005 - timestamp: 1734229037766 -- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxscrnsaver-1.2.4-hb9d3cd8_0.conda - sha256: 58e8fc1687534124832d22e102f098b5401173212ac69eb9fd96b16a3e2c8cb2 - md5: 303f7a0e9e0cd7d250bb6b952cecda90 + size: 1456245 + timestamp: 1769664727051 +- conda: https://prefix.dev/conda-forge/osx-arm64/tk-8.6.13-h010d191_3.conda + sha256: 799cab4b6cde62f91f750149995d149bc9db525ec12595e8a1d91b9317f038b3 + md5: a9d86bc62f39b94c4661716624eb21b0 depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=13 - - xorg-libx11 >=1.8.10,<2.0a0 - - xorg-libxext >=1.3.6,<2.0a0 - license: MIT - license_family: MIT + - __osx >=11.0 + - libzlib >=1.3.1,<2.0a0 + license: TCL + license_family: BSD purls: [] - size: 14412 - timestamp: 1727899730073 -- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxtst-1.2.5-hb9d3cd8_3.conda - sha256: 752fdaac5d58ed863bbf685bb6f98092fe1a488ea8ebb7ed7b606ccfce08637a - md5: 7bbe9a0cc0df0ac5f5a8ad6d6a11af2f + size: 3127137 + timestamp: 1769460817696 +- conda: https://prefix.dev/conda-forge/osx-arm64/tornado-6.5.5-py311hc949640_0.conda + sha256: 572923958ec987f3f68e228dfec243c89ab94b50398731215d36e2e040db8703 + md5: 6f12d9ff025ab1875dff67ad779ca29d depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=13 - - xorg-libx11 >=1.8.10,<2.0a0 - - xorg-libxext >=1.3.6,<2.0a0 - - xorg-libxi >=1.7.10,<2.0a0 + - __osx >=11.0 + - python >=3.11,<3.12.0a0 + - python >=3.11,<3.12.0a0 *_cpython + - python_abi 3.11.* *_cp311 + license: Apache-2.0 + license_family: Apache + purls: + - pkg:pypi/tornado?source=hash-mapping + size: 875022 + timestamp: 1774358570256 +- conda: https://prefix.dev/conda-forge/osx-arm64/ukkonen-1.1.0-py311h572238d_0.conda + sha256: 1bf370d4d4698b339d54342b2d653d9ed26f5004af2da3e5556b641fb5e56e1b + md5: 2855259ce88c41c1b2297041ec75f540 + depends: + - __osx >=11.0 + - cffi + - libcxx >=19 + - python >=3.11,<3.12.0a0 + - python >=3.11,<3.12.0a0 *_cpython + - python_abi 3.11.* *_cp311 license: MIT license_family: MIT + purls: + - pkg:pypi/ukkonen?source=hash-mapping + size: 14760 + timestamp: 1769438970347 +- conda: https://prefix.dev/conda-forge/osx-arm64/unicodedata2-17.0.1-py311hc949640_0.conda + sha256: 984d3b0ddb0802c228c520db31d906b5b546b13da3eca1ce35c754d97c012497 + md5: a9d9010d246205c63f824b0bcf050acd + depends: + - __osx >=11.0 + - python >=3.11,<3.12.0a0 + - python >=3.11,<3.12.0a0 *_cpython + - python_abi 3.11.* *_cp311 + license: Apache-2.0 + license_family: Apache + purls: + - pkg:pypi/unicodedata2?source=hash-mapping + size: 416024 + timestamp: 1770909604661 +- conda: https://prefix.dev/conda-forge/osx-arm64/uv-0.11.12-h2c65d96_0.conda + sha256: e8050d5259b4f77b838ecc573643451593b39970f1b25412267db10919de2ca3 + md5: a5b3c646ec7fe96f192bb4f5fa8442f3 + depends: + - __osx >=11.0 + - libcxx >=19 + constrains: + - __osx >=11.0 + license: Apache-2.0 OR MIT purls: [] - size: 32808 - timestamp: 1727964811275 -- conda: https://prefix.dev/conda-forge/linux-64/xorg-libxxf86vm-1.1.7-hb03c661_0.conda - sha256: 64db17baaf36fa03ed8fae105e2e671a7383e22df4077486646f7dbf12842c9f - md5: 665d152b9c6e78da404086088077c844 + size: 16562936 + timestamp: 1778287818707 +- conda: https://prefix.dev/conda-forge/osx-arm64/xorg-libxau-1.0.12-h84a0fba_2.conda + sha256: 5c5ea38ceec008e4ff40111fc166b04086fca310b0aa9e5bd46f65e6b0dcb71d + md5: 31d71ce1b056f69b6ec67ee0712bdf97 depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - xorg-libx11 >=1.8.12,<2.0a0 - - xorg-libxext >=1.3.6,<2.0a0 + - __osx >=11.0 license: MIT license_family: MIT purls: [] - size: 18701 - timestamp: 1769434732453 -- conda: https://prefix.dev/conda-forge/linux-64/xorg-xorgproto-2025.1-hb03c661_0.conda - sha256: 7a8c64938428c2bfd016359f9cb3c44f94acc256c6167dbdade9f2a1f5ca7a36 - md5: aa8d21be4b461ce612d8f5fb791decae + size: 15124 + timestamp: 1786381585975 +- conda: https://prefix.dev/conda-forge/osx-arm64/xorg-libxdmcp-1.1.5-h84a0fba_2.conda + sha256: 2f6915f0897ace4a1b5d66d0463079f7bc9819b0048c03677e47764f0a743499 + md5: f51e9414bf1b7bb556aac1a0b74a75fe depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 + - __osx >=11.0 license: MIT license_family: MIT purls: [] - size: 570010 - timestamp: 1766154256151 -- conda: https://prefix.dev/conda-forge/linux-64/xz-5.8.3-ha02ee65_0.conda - sha256: 2553fd3ec0a1020b2ca05ca10b0036a596cb0d4bf3645922fcf69dacce0e6679 - md5: 6a1b6af49a334e4e06b9f103367762bf - depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - liblzma 5.8.3 hb03c661_0 - - liblzma-devel 5.8.3 hb03c661_0 - - xz-gpl-tools 5.8.3 ha02ee65_0 - - xz-tools 5.8.3 hb03c661_0 - license: 0BSD AND LGPL-2.1-or-later AND GPL-2.0-or-later - purls: [] - size: 24360 - timestamp: 1775825568523 + size: 19486 + timestamp: 1786381546642 - conda: https://prefix.dev/conda-forge/osx-arm64/xz-5.8.3-hd0f0c4f_0.conda sha256: d5bb880876336f625523c022aa9bdc6be76a85df721d9e7b33c352f528619185 md5: 4df12be699991b97b66a85cc46ea75b5 @@ -6349,19 +6412,6 @@ packages: purls: [] size: 24348 timestamp: 1775825911109 -- conda: https://prefix.dev/conda-forge/linux-64/xz-gpl-tools-5.8.3-ha02ee65_0.conda - sha256: 8f139666ea18dc8340a44a54056627dd4e89e242e8cd136ab2467d6dc2c192ba - md5: 8f5e2c6726c1339287a3c76a2c138ac7 - depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - liblzma 5.8.3 hb03c661_0 - constrains: - - xz 5.8.3.* - license: 0BSD AND LGPL-2.1-or-later AND GPL-2.0-or-later - purls: [] - size: 34213 - timestamp: 1775825548743 - conda: https://prefix.dev/conda-forge/osx-arm64/xz-gpl-tools-5.8.3-hd0f0c4f_0.conda sha256: 0864d53202f618b4c8a5f2c38b7029f14b900b852e99b6248813303f69ccfdee md5: 43d168a8c95a8fcdcc44c2a0a7887653 @@ -6374,19 +6424,6 @@ packages: purls: [] size: 34224 timestamp: 1775825884830 -- conda: https://prefix.dev/conda-forge/linux-64/xz-tools-5.8.3-hb03c661_0.conda - sha256: 162ebd76803464b8c8ebc7d45df32edf0ec717b3bf369a437ae3b0254f22dc2e - md5: b62b615caa60812640f24db3a8d0fc87 - depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=14 - - liblzma 5.8.3 hb03c661_0 - constrains: - - xz 5.8.3.* - license: 0BSD AND LGPL-2.1-or-later - purls: [] - size: 95955 - timestamp: 1775825530484 - conda: https://prefix.dev/conda-forge/osx-arm64/xz-tools-5.8.3-h8088a28_0.conda sha256: beb7fb34d5517cce06f5f89710de7108a8ca65ed9c0324269fc0446807bcbd91 md5: b8c47eab4e58fe7015a12ceb9d5b114c @@ -6399,17 +6436,6 @@ packages: purls: [] size: 85931 timestamp: 1775825857949 -- conda: https://prefix.dev/conda-forge/linux-64/yaml-0.2.5-h280c20c_3.conda - sha256: 6d9ea2f731e284e9316d95fa61869fe7bbba33df7929f82693c121022810f4ad - md5: a77f85f77be52ff59391544bfe73390a - depends: - - libgcc >=14 - - __glibc >=2.17,<3.0.a0 - license: MIT - license_family: MIT - purls: [] - size: 85189 - timestamp: 1753484064210 - conda: https://prefix.dev/conda-forge/osx-arm64/yaml-0.2.5-h925e9cb_3.conda sha256: b03433b13d89f5567e828ea9f1a7d5c5d697bf374c28a4168d71e9464f5dafac md5: 78a0fe9e9c50d2c381e8ee47e3ea437d @@ -6420,29 +6446,6 @@ packages: purls: [] size: 83386 timestamp: 1753484079473 -- conda: https://prefix.dev/conda-forge/noarch/zipp-3.23.1-pyhcf101f3_0.conda - sha256: 523616c0530d305d2216c2b4a8dfd3872628b60083255b89c5e0d8c42e738cca - md5: e1c36c6121a7c9c76f2f148f1e83b983 - depends: - - python >=3.10 - - python - license: MIT - license_family: MIT - purls: - - pkg:pypi/zipp?source=hash-mapping - size: 24461 - timestamp: 1776131454755 -- conda: https://prefix.dev/conda-forge/linux-64/zlib-1.3.2-h25fd6f3_2.conda - sha256: 245c9ee8d688e23661b95e3c6dd7272ca936fabc03d423cdb3cdee1bbcf9f2f2 - md5: c2a01a08fc991620a74b32420e97868a - depends: - - __glibc >=2.17,<3.0.a0 - - libzlib 1.3.2 h25fd6f3_2 - license: Zlib - license_family: Other - purls: [] - size: 95931 - timestamp: 1774072620848 - conda: https://prefix.dev/conda-forge/osx-arm64/zlib-1.3.2-h8088a28_2.conda sha256: 8dd2ac25f0ba714263aac5832d46985648f4bfb9b305b5021d702079badc08d2 md5: f1c0bce276210bed45a04949cfe8dc20 @@ -6454,18 +6457,6 @@ packages: purls: [] size: 81123 timestamp: 1774072974535 -- conda: https://prefix.dev/conda-forge/linux-64/zlib-ng-2.3.3-hce19668_1.conda - sha256: 8b786bb4380fa69a718b08a400040b865bc9207eda337e0a1955717c3c3a9403 - md5: 1726acec19beeed1c764385cd8622405 - depends: - - __glibc >=2.17,<3.0.a0 - - libgcc >=15 - - libstdcxx >=15 - license: Zlib - license_family: Other - purls: [] - size: 123959 - timestamp: 1786736890973 - conda: https://prefix.dev/conda-forge/osx-arm64/zlib-ng-2.3.3-h31dac16_1.conda sha256: 489a29915a3e1b425cff4df10a448f55bbaaf29d777a0f8a9e381444e6a284f1 md5: 4621ded2fd5b36f51454d5f81bff4ec1 @@ -6477,17 +6468,6 @@ packages: purls: [] size: 95857 timestamp: 1786737243497 -- conda: https://prefix.dev/conda-forge/linux-64/zstd-1.5.7-hb78ec9c_6.conda - sha256: 68f0206ca6e98fea941e5717cec780ed2873ffabc0e1ed34428c061e2c6268c7 - md5: 4a13eeac0b5c8e5b8ab496e6c4ddd829 - depends: - - __glibc >=2.17,<3.0.a0 - - libzlib >=1.3.1,<2.0a0 - license: BSD-3-Clause - license_family: BSD - purls: [] - size: 601375 - timestamp: 1764777111296 - conda: https://prefix.dev/conda-forge/osx-arm64/zstd-1.5.7-hbf9d68e_6.conda sha256: 9485ba49e8f47d2b597dd399e88f4802e100851b27c21d7525625b0b4025a5d9 md5: ab136e4c34e97f34fb621d2592a393d8 @@ -6499,3 +6479,33 @@ packages: purls: [] size: 433413 timestamp: 1764777166076 +- pypi: ./vendor/rSim + name: rc-robosim +- pypi: https://files.pythonhosted.org/packages/05/33/26178c7d437a87082d11019292dce6d3fe6f0e9026b7b2309cbf3e489b1d/numpy-2.0.2-cp310-cp310-macosx_11_0_arm64.whl + name: numpy + version: 2.0.2 + sha256: f15975dfec0cf2239224d80e32c3170b1d168335eaedee69da84fbe9f1f9cd04 + requires_python: '>=3.9' +- pypi: https://files.pythonhosted.org/packages/fa/66/f7177ab331876200ac7563a580140643d1179c8b4b6a6b0fc9838de2a9b8/numpy-2.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl + name: numpy + version: 2.0.2 + sha256: 496f71341824ed9f3d2fd36cf3ac57ae2e0165c143b55c3a035ee219413f3318 + requires_python: '>=3.9' +- pypi: https://files.pythonhosted.org/packages/fb/06/6a7c30c3519181263e1bbf0cbea67ef4a43a64443ee16717c7d760214943/lenses-1.2.0-py3-none-any.whl + name: lenses + version: 1.2.0 + sha256: e03c81e35500e12e1d35504f76c26489c0a4e08b0881e96fc4e8a1b707c53f16 + requires_dist: + - sphinx ; extra == 'docs' + - pyrsistent ; extra == 'lints' + - ufmt ; extra == 'lints' + - flake8 ; extra == 'lints' + - mypy ; implementation_name == 'cpython' and extra == 'lints' + - pyrsistent ; extra == 'optional' + - pyrsistent ; extra == 'tests' + - pytest ; extra == 'tests' + - pytest-sugar ; extra == 'tests' + - coverage ; extra == 'tests' + - pytest-coverage ; extra == 'tests' + - hypothesis ; extra == 'tests' + requires_python: '>=3.7,<4' diff --git a/pixi.toml b/pixi.toml index 94d07ab5e..a2beb7a8c 100644 --- a/pixi.toml +++ b/pixi.toml @@ -55,18 +55,20 @@ numpy = "<=2.0.2" [tasks] lint = "pre-commit run --all-files" test = "pytest utama_core/tests/" -build-planner = "cmake -B build/fpp utama_core/motion_planning/src/fastpathplanning/cpp && cmake --build build/fpp -j" +build-planner = "cmake -B build/fpp utama_core/motion_planning/fastpathplanning/cpp && cmake --build build/fpp -j" main = "python -m main" +evaluate = "python tools/evaluation/evaluate.py" +dashboard = "python -m utama_core.dashboard" replay = "python -m utama_core.replay.replay_player" runs = "python -m utama_core.analysis.list_runs" -debug-robots = "python -m utama_core.team_controller.src.debug_utils.telop_gui" -calibrate = "python examples/calibrate_robot.py" -find-robots = "python -m utama_core.team_controller.src.controllers.real.find_robots" -field-check = "python tools/field_check.py" +debug-robots = "python -m utama_core.team_controller.debug_utils.telop_gui" +calibrate = "python tools/field/calibrate_robot.py" +find-robots = "python -m utama_core.team_controller.controllers.real.find_robots" +field-check = "python tools/field/field_check.py" demos = "python examples/demos.py" -package-results = "python tools/package_logs.py tournament" -package-field = "python tools/package_logs.py field" -trim-field = "python tools/trim_idle_log.py replays/field/*.log.gz" +package-results = "python tools/field/package_logs.py tournament" +package-field = "python tools/field/package_logs.py field" +trim-field = "python tools/field/trim_idle_log.py replays/field/*.log.gz" precommit-install = "pre-commit install && pixi run pre-commit install --hook-type pre-commit" precommit-uninstall = "pre-commit uninstall" diff --git a/utama_core/motion_planning/src/trajsampling/__init__.py b/tools/__init__.py similarity index 100% rename from utama_core/motion_planning/src/trajsampling/__init__.py rename to tools/__init__.py diff --git a/utama_core/rsoccer_simulator/src/Simulators/__init__.py b/tools/debug/__init__.py similarity index 100% rename from utama_core/rsoccer_simulator/src/Simulators/__init__.py rename to tools/debug/__init__.py diff --git a/tools/debug_match.py b/tools/debug/debug_match.py similarity index 83% rename from tools/debug_match.py rename to tools/debug/debug_match.py index 8aaa45a5e..e88a3c8ca 100644 --- a/tools/debug_match.py +++ b/tools/debug/debug_match.py @@ -1,8 +1,8 @@ -"""debug_match.py — one-off ad hoc match runner for tactic debugging. +"""tools/debug/debug_match.py — one-off ad hoc match runner for tactic debugging. Run: - pixi run python tools/debug_match.py --strategy build_counter_flow_kernel_strategy \\ - --opponent build_high_press_kernel_strategy --duration 90 --headless + pixi run python tools/debug/debug_match.py --strategy riptide \\ + --opponent wolfpack --duration 90 --headless Replaces the pattern of hand-writing a fresh `StrategyRunner(...)` block per bug (`trace_relay_stall.py`, `trace_finish_detail.py`, `check_keeper.py`, @@ -38,22 +38,14 @@ import sys from pathlib import Path -REPO_ROOT = Path(__file__).resolve().parents[1] +REPO_ROOT = Path(__file__).resolve().parents[2] if str(REPO_ROOT) not in sys.path: sys.path.insert(0, str(REPO_ROOT)) -from tools.evaluation.match import ( - _CONFIG_NAMES, - N_OUTFIELD, - OUTFIELD_ROBOT_IDS, - TICKS_PER_SECOND, -) -from utama_core.custom_referee import CustomReferee -from utama_core.engine.abstract_strategy import AbstractStrategy +from tools.evaluation.match import TICKS_PER_SECOND from utama_core.engine.match_log import load_jsonl -from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.run import StrategyRunner -from utama_core.strategy import kernel_strategy +from utama_core.run.sim_setup import UnknownStrategy, load_side, sim_runner class _TargetRecorder: @@ -114,8 +106,8 @@ def poses(robots): def main() -> None: parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) - parser.add_argument("--strategy", required=True, choices=sorted(_CONFIG_NAMES)) - parser.add_argument("--opponent", required=True, choices=sorted(_CONFIG_NAMES)) + parser.add_argument("--strategy", required=True, help="a strategy name, a .strategy file or PATH.py:FUNCTION") + parser.add_argument("--opponent", required=True, help="the same kinds as --strategy") parser.add_argument("--duration", type=float, default=90.0, help="sim seconds (default 90)") parser.add_argument("--stop-on-goal", action="store_true", help="end the match as soon as either side scores") parser.add_argument( @@ -139,34 +131,21 @@ def main() -> None: default=None, help=( "If set, also accumulate and write the same possession/shots/ball-travel " - "summary round_robin.py records (utama_core.engine.match_stats.MatchStats) to " + "summary evaluate.py records (utama_core.engine.match_stats.MatchStats) to " "this path. Off by default since most debugging sessions only care about the " "match_log/trace output, not aggregate stats." ), ) args = parser.parse_args() - build_a = getattr(kernel_strategy, args.strategy) - build_b = getattr(kernel_strategy, args.opponent) - strategy_a = AbstractStrategy(build_kernel_strategy=build_a(OUTFIELD_ROBOT_IDS)) - strategy_b = AbstractStrategy(build_kernel_strategy=build_b(OUTFIELD_ROBOT_IDS)) - - referee = CustomReferee.from_profile_name( - "simulation", n_robots_yellow=N_OUTFIELD + 1, n_robots_blue=N_OUTFIELD + 1 - ) + try: + strategy_a, strategy_b = load_side(args.strategy), load_side(args.opponent) + except UnknownStrategy as e: + parser.error(str(e)) - runner = StrategyRunner( - strategy=strategy_a, - opp_strategy=strategy_b, - my_team_is_yellow=True, - my_team_is_right=True, - mode="rsim", - exp_friendly=N_OUTFIELD + 1, - exp_enemy=N_OUTFIELD + 1, - exp_ball=True, - referee=referee, - enable_vision_stream=False, - referee_initial_command=RefereeCommand.PREPARE_KICKOFF_YELLOW, + runner, _ = sim_runner( + strategy_a, + strategy_b, match_log_path=args.match_log, stats_path=args.stats_path, control_scheme=args.control_scheme, diff --git a/tools/debug/figure_style.py b/tools/debug/figure_style.py new file mode 100644 index 000000000..f259cef4e --- /dev/null +++ b/tools/debug/figure_style.py @@ -0,0 +1,25 @@ +"""The colours and matplotlib style every figure tool shares (pitch_maps, explain, match_timeline), +so the figures read as one set. Importing it sets the style.""" + +import matplotlib.pyplot as plt + +INK, INK_2, INK_3, SURFACE, GRID = "#0b0b0b", "#52514e", "#8a8984", "#fcfcfb", "#e4e3df" +FOR, AGAINST = "#2a78d6", "#eb6834" # categorical slots 1 and 2 +# Categorical slots in fixed order (validated adjacent-pair for stacks); never cycled. +SLOTS = ["#2a78d6", "#eb6834", "#1baf7a", "#eda100", "#e87ba4", "#008300", "#6250d6"] + +plt.rcParams.update( + { + "figure.facecolor": SURFACE, + "axes.facecolor": SURFACE, + "axes.edgecolor": INK_3, + "axes.labelcolor": INK_2, + "axes.titlesize": 10, + "axes.titlecolor": INK, + "axes.spines.top": False, + "axes.spines.right": False, + "xtick.color": INK_2, + "ytick.color": INK, + "font.size": 9, + } +) diff --git a/tools/triage.py b/tools/debug/find_bugs.py similarity index 80% rename from tools/triage.py rename to tools/debug/find_bugs.py index 2556f68f3..4885f2d36 100644 --- a/tools/triage.py +++ b/tools/debug/find_bugs.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 # ruff: noqa: E402 -"""Triage a run dir: which problems happened in which matches, with the numbers, and a picture for the worst. +"""Find the bugs in a run dir: which problems happened in which matches, with the numbers, and a picture for the worst. - pixi run python tools/triage.py REPLAYS_OR_RUN_DIR [--strategy NAME ...] [--matches 3] [--out DIR] + pixi run python tools/debug/find_bugs.py REPLAYS_OR_RUN_DIR [--strategy NAME ...] [--matches 3] [--out DIR] [--max-pictures 8] [--workers 2] [--restarts] Start here when a strategy plays badly. For each strategy the friendly side (config_a, the only side the @@ -12,7 +12,7 @@ - `stall` (`stuck_detector.find_stuck_windows`): a window with the ball frozen while a friendly robot oscillates, or a restart held far too long (`restart_stall`). No `plan_trace` here: it needs the robot's target, which the replay does not record, and a guessed target draws carrots that mean nothing; trace a stalled robot by hand - with `tools/plan_trace.py --target X Y` once you know where it was going; + with `tools/debug/plan_trace.py --target X Y` once you know where it was going; - `target_in_keep_out`, `keep_out_short`, `target_in_defense_area` (`restart_picture.restart_findings`): only with `--restarts`, which is slow (about 45 s a match). @@ -23,7 +23,16 @@ restart_stall) `restart_picture` at its restart. `OUT/index.md` is the report to read first: per strategy, its matches with their scores, the finding counts by kind, then each pictured finding with its message and picture path. -`OUT` defaults to `RUN_DIR/triage/`. Read-only: nothing is played or changed. +`OUT` defaults to `RUN_DIR/find_bugs/`. Read-only: nothing is played or changed. + +`--fouls` instead lists our side's (config_a's) fouls in a round-robin run, each with the referee command +active then and whether that restart was ours or theirs: the starting points for a regression moment +(`tools/debug/moments.py capture`). `--rule NAME` keeps one rule, `--skip-own-restart` leaves out fouls during our +own restarts, `--by strategy,rule` counts per combination instead (columns: strategy, rule, tactic, +restart), `--json` writes JSON. `out_of_bounds`, the ball leaving the field, is a stoppage and is left out +unless `--include-stoppages` (`utama_core/analysis/fouls.py`; until 2026-11-11 `tools/debug/moments.py fouls`). + + pixi run python tools/debug/find_bugs.py replays/eval_/round_1 --fouls [--rule keep_out] [--by strategy,rule] """ from __future__ import annotations @@ -42,13 +51,14 @@ os.environ.setdefault("PYGAME_HIDE_SUPPORT_PROMPT", "1") -REPO_ROOT = Path(__file__).resolve().parents[1] +REPO_ROOT = Path(__file__).resolve().parents[2] if str(REPO_ROOT) not in sys.path: sys.path.insert(0, str(REPO_ROOT)) -from tools import match_timeline +from tools.debug import match_timeline +from tools.debug.plan_trace import replay_game_at from tools.evaluation.match import _short_name -from tools.plan_trace import replay_game_at +from utama_core.analysis import fouls as fouls_lib from utama_core.analysis.findings import Finding, write_jsonl from utama_core.analysis.matches import STEM, Match, load_match from utama_core.analysis.plan_trace import plan_findings, plan_trace @@ -302,7 +312,7 @@ def write_index( restarts: bool, ) -> Path: lines = [ - f"# Triage: {run_dir.name}", + f"# Find bugs: {run_dir.name}", "", f"Friendly side (config_a) of each strategy's worst matches by goal difference. " f"Pictures: the top {max_pictures} findings with a picture source. Restart findings: " @@ -347,7 +357,7 @@ def write_index( return path -def triage( +def find_bugs( run_dir: Union[str, Path], *, strategies: Optional[set[str]] = None, @@ -360,7 +370,7 @@ def triage( """Analyse the selected matches, draw the top pictures and write `out/index.md` and `out/findings.jsonl`. Returns the index path.""" run_dir = Path(run_dir) - out = Path(out) if out is not None else run_dir / "triage" + out = Path(out) if out is not None else run_dir / "find_bugs" pictures = out / "pictures" pictures.mkdir(parents=True, exist_ok=True) selected = select_matches(run_dir, strategies, matches) @@ -379,23 +389,51 @@ def triage( return write_index(out, run_dir, reports, max_pictures, restarts) +def fouls_report( + run_dir: Path, + rule: Optional[str] = None, + skip_own_restart: bool = False, + include_stoppages: bool = False, + by: Optional[str] = None, + as_json: bool = False, +) -> list[str]: + """`--fouls`: our side's fouls in `run_dir` as lines to print (see the module docstring).""" + found = fouls_lib.our_fouls(run_dir, rule) + if skip_own_restart: + found = fouls_lib.without_own_restarts(found) + if not include_stoppages: + found = fouls_lib.without_stoppages(found) + columns = [c.strip() for c in by.split(",")] if by else None + if columns: + unknown = [c for c in columns if c not in fouls_lib.FOUL_COLUMNS] + if unknown: + raise ValueError(f"--by: unknown column(s) {unknown}; choose from {', '.join(fouls_lib.FOUL_COLUMNS)}") + if as_json: + return [fouls_lib.fouls_json(found, columns)] + if columns: + return fouls_lib.fouls_by_table(found, columns) + return [fouls_lib.foul_line(f) for f in found] + + def main() -> None: parser = argparse.ArgumentParser( description=__doc__.split("\n\n")[0], formatter_class=argparse.RawDescriptionHelpFormatter ) parser.add_argument( - "run_dir", type=Path, help="a round-robin dir (replays/tournament_) or any dir of match .npz files" + "run_dir", + type=Path, + help="a round folder (replays/eval_/round_), an old replays/tournament_, or any dir of match .npz files", ) parser.add_argument( "--strategy", action="append", metavar="NAME", - help="only matches where this strategy is config_a (repeatable; short or build_*_kernel_strategy names)", + help="only matches where this strategy is config_a (repeatable; plain names, or the build__kernel_strategy names of old runs)", ) parser.add_argument( "--matches", type=int, default=3, help="each strategy's N worst matches by goal difference (default 3)" ) - parser.add_argument("--out", type=Path, default=None, help="output dir (default RUN_DIR/triage/)") + parser.add_argument("--out", type=Path, default=None, help="output dir (default RUN_DIR/find_bugs/)") parser.add_argument("--max-pictures", type=int, default=8, help="pictures to draw (default 8)") parser.add_argument("--workers", type=int, default=2, help="worker processes, one match each (default 2)") parser.add_argument( @@ -403,8 +441,24 @@ def main() -> None: action="store_true", help="also check every restart's referee override (restart_picture findings). SLOW: about 45 s a match", ) + fouls = parser.add_argument_group("--fouls: list our side's fouls instead (see the module docstring)") + fouls.add_argument("--fouls", action="store_true", help="list our side's fouls in the run; nothing else") + fouls.add_argument("--rule", default=None, help="only this rule") + fouls.add_argument("--skip-own-restart", action="store_true", help="leave out fouls during our own restarts") + fouls.add_argument("--include-stoppages", action="store_true", help="also list out_of_bounds") + fouls.add_argument( + "--by", default=None, metavar="COLUMNS", help=f"counts per combination of {', '.join(fouls_lib.FOUL_COLUMNS)}" + ) + fouls.add_argument("--json", action="store_true", help="JSON to stdout instead of text") args = parser.parse_args() - index = triage( + if args.fouls: + try: + print("\n".join(fouls_report(args.run_dir, args.rule, args.skip_own_restart, args.include_stoppages, + args.by, args.json))) # fmt: skip + except ValueError as e: + parser.error(str(e)) + return + index = find_bugs( args.run_dir, strategies=set(args.strategy) if args.strategy else None, matches=args.matches, diff --git a/tools/match_timeline.py b/tools/debug/match_timeline.py similarity index 97% rename from tools/match_timeline.py rename to tools/debug/match_timeline.py index 332d63003..9305c04b6 100644 --- a/tools/match_timeline.py +++ b/tools/debug/match_timeline.py @@ -2,7 +2,7 @@ # ruff: noqa: E402 """One match window as swimlanes: referee command, each robot's tactic, distance to the ball, events. - pixi run python tools/match_timeline.py replays/tournament_/_vs_.npz 100 160 --side friendly + pixi run python tools/debug/match_timeline.py replays/eval_/round_1/_vs_.npz 100 160 --side friendly Stacked panels on one time axis (Gantt-style, no dual axes): 1. the referee command band: live play, STOP, kickoff, free kick, penalty, placement, HALT (goal and @@ -19,7 +19,7 @@ Prints, for the side: tactic switches per minute and the longest single tactic span, per robot. `--out` defaults to a `.timeline__-.png` beside the replay. -Reuses `tools/replay_trace.py` for the event list (kicks, possession, referee changes, fouls, goals) and +Reuses `tools/debug/replay_trace.py` for the event list (kicks, possession, referee changes, fouls, goals) and the status messages, and `analysis/turnover_breakdown.analyse_match` for shots. """ @@ -42,11 +42,11 @@ import numpy as np # noqa: E402 from matplotlib.patches import Patch # noqa: E402 -REPO_ROOT = Path(__file__).resolve().parents[1] +REPO_ROOT = Path(__file__).resolve().parents[2] if str(REPO_ROOT) not in sys.path: sys.path.insert(0, str(REPO_ROOT)) -from tools import replay_trace # noqa: E402 +from tools.debug import replay_trace # noqa: E402 from utama_core.analysis import turnover_breakdown # noqa: E402 from utama_core.analysis.findings import Finding, write_jsonl # noqa: E402 from utama_core.entities.referee.referee_command import RefereeCommand # noqa: E402 @@ -55,16 +55,16 @@ # the robot reverted before B could do anything. A robot with at least FLIP_BACKS_PER_MIN of them per minute # of live play gets a `tactic_thrash` finding. Raw switch rate is not the signal: most strategies switch # 10-25 times per live minute by design (attack/defence on possession). Measured on tournament_20261017_151052 -# (66 matches, friendly robots, median flip-backs under 1 s per live min): give_and_go_solo 0.0, decoy_and_overload -# 0.1, high_press 0.3, overload_press 0.5; counter_flow, clear_danger, clear_press_plus, split_shape, -# press_trigger_flow, score_aware_counter_flow 4.6-5.6; press_and_pass 13.4. 2 per min (one every 30 s of live +# (66 matches, friendly robots, median flip-backs under 1 s per live min): ricochet 0.0, mirage +# 0.1, wolfpack 0.3, avalanche 0.5; riptide, firebreak, breakwater, pendulum, +# tripwire, chameleon 4.6-5.6; terrier 13.4. 2 per min (one every 30 s of live # play) sits between the steady and the flipping strategies. FLIP_S = 1.0 FLIP_BACKS_PER_MIN = 2.0 # Under this much live play a rate is noise (one switch in 10 s reads as 6 per minute): no thrash finding. MIN_LIVE_S = 30.0 -# Styling copied from tools/signal_report.py so the figures read as one set. +# Styling shared with tools/debug/figure_style.py so the figures read as one set. INK, INK_2, INK_3, SURFACE, GRID = "#0b0b0b", "#52514e", "#8a8984", "#fcfcfb", "#e4e3df" FOR, AGAINST = "#2a78d6", "#eb6834" # categorical slots 1 and 2 SLOTS = ["#2a78d6", "#eb6834", "#1baf7a", "#eda100", "#e87ba4", "#008300", "#6250d6"] diff --git a/tools/moments.py b/tools/debug/moments.py similarity index 71% rename from tools/moments.py rename to tools/debug/moments.py index 408920e78..69053374b 100644 --- a/tools/moments.py +++ b/tools/debug/moments.py @@ -1,16 +1,16 @@ """Regression moments: one field state that reproduced a bug, replayed for a few seconds against every strategy it concerns, with a check of what our robots must do instead. The workflow (find, -reproduce, fix the cause with a unit test, keep the moment) is in docs/STRATEGY_DEVELOPMENT.md, +reproduce, fix the cause with a unit test, keep the moment) is in docs/strategy.md, "Debugging a foul or failure". A moment is a JSON file in `utama_core/tests/moments/` (`test_moments.py` plays each one): {"name": ..., "note": what went wrong and why it must not happen again, "source": {"replay": ..., "t": ...} or null for a hand-made one, - "strategy": "all" or one strategy, "opponent": the other side (default split_shape), + "strategy": "all" or one strategy, "opponent": the other side (default pendulum), "seconds": how long to play (default 3), "checks": names from `CHECKS` below, or referee rule names our side must not break - (`custom_referee/rules/`, "*" for any), + (`referee/rules/`, "*" for any), "requires": names from `REQUIRES` below: conditions that must hold during the play, so a moment whose situation never arose fails ("did not arise: ...") instead of passing, "known_failure": null, or why it still fails (the test is then a strict xfail), @@ -32,30 +32,21 @@ a robot came near the ball. Without them a moment passes when the opponent does something else, the ball goes elsewhere, or our robot never gets there. -Hand-made moments: `new` writes a template (both teams in a fixed formation, ours on the right, -the pool's noise with seed 1, source null) to edit by hand; `save` and `load` refuse an -invalid one, naming each problem (ids, field lines, check and strategy names). - -List our side's fouls in a round-robin run, as starting points, each with the referee command -active then and whether that restart is ours or theirs (`--skip-own-restart` leaves out ours): - pixi run python tools/moments.py fouls replays/tournament_ [--rule keep_out] [--skip-own-restart] -(`--by strategy,rule` counts them per combination instead; `out_of_bounds`, the ball leaving the -field, is a stoppage and is left out unless `--include-stoppages`.) +A moment comes from a replay (`capture`); `save` and `load` refuse an invalid one, naming each +problem (ids, field lines, check and strategy names). Starting points: our side's fouls in a run, +`pixi run python tools/debug/find_bugs.py replays/eval_/round_1 --fouls` (until 2026-11-11 `tools/debug/moments.py fouls`). Capture one from a replay (its noise and designated position come with it; `--out` writes elsewhere than utama_core/tests/moments/): - pixi run python tools/moments.py capture replays/tournament_/_vs_.npz --t 254.65 \\ + pixi run python tools/debug/moments.py capture replays/eval_/round_1/_vs_.npz --t 254.65 \\ --name free_kick_defender_drives_in --check keeps_clear --strategy --opponent \\ --note "..." [--out PATH] -Write a hand-made one, then edit its positions in the JSON: - pixi run python tools/moments.py new --command NORMAL_START [--ball X Y] \\ - [--strategy NAME] [--seconds N] --check --note "..." Play one (`--seed N` replays its noise with another seed, the JSON untouched): - pixi run python tools/moments.py play utama_core/tests/moments/.json [--strategy NAME] [--seed N] + pixi run python tools/debug/moments.py play utama_core/tests/moments/.json [--strategy NAME] [--seed N] Play it under several seeds as one table, compare with the code at a git ref (a worktree under `AGAINST_DIR`, to remove with `git worktree remove --force`), look at its events (referee changes, fouls, keep-out entries, kicks, closest approaches), or try a scratch strategy file's factory: - pixi run python tools/moments.py play --seeds 0-4 [--against HEAD~3] [--events] - pixi run python tools/moments.py play --strategy path/to/scratch.py:build_my_kernel_strategy + pixi run python tools/debug/moments.py play --seeds 0-4 [--against HEAD~3] [--events] + pixi run python tools/debug/moments.py play --strategy path/to/scratch.py:my """ from __future__ import annotations @@ -65,7 +56,6 @@ os.environ.setdefault("PYGAME_HIDE_SUPPORT_PROMPT", "1") # before any import: hides pygame's banner import argparse import dataclasses -import importlib.util import json import math import os @@ -74,11 +64,10 @@ import subprocess import sys import tempfile -from collections import Counter from pathlib import Path from typing import Callable, Optional -REPO_ROOT = Path(__file__).resolve().parents[1] +REPO_ROOT = Path(__file__).resolve().parents[2] if str(REPO_ROOT) not in sys.path: sys.path.insert(0, str(REPO_ROOT)) @@ -87,19 +76,21 @@ OUTFIELD_ROBOT_IDS, TICKS_PER_SECOND, ) +from utama_core.analysis.fouls import restart_side # noqa: E402 from utama_core.entities.referee.referee_command import RefereeCommand # noqa: E402 from utama_core.replay.scenario import ( # noqa: E402 RobotState, Scenario, - _referee_command_at, scenario_from_replay, ) +from utama_core.run import sim_setup # noqa: E402 +from utama_core.strategy.catalog import plain_name # noqa: E402 MOMENTS_DIR = REPO_ROOT / "utama_core" / "tests" / "moments" -DEFAULT_OPPONENT = "build_split_shape_kernel_strategy" +DEFAULT_OPPONENT = "pendulum" DEFAULT_SECONDS = 3.0 -# Rulebook distances (`custom_referee/rules/keep_out_rule.py`, `robot_stop_speed_rule.py`). +# Rulebook distances (`referee/rules/keep_out_rule.py`, `robot_stop_speed_rule.py`). KEEP_OUT_M = 0.5 STOP_SPEED_MPS = 1.5 # A robot inside the keep-out circle may drift with noise, never drive in: closer by more than @@ -115,10 +106,10 @@ # `play --against`: worktrees live beside the repo (not in it), each with the compiled extensions # below copied in (gitignored, so a new worktree lacks them; without them the planner falls back to # Python and results differ). -AGAINST_DIR = REPO_ROOT.parent / "moments-work-20261017" / "against" +AGAINST_DIR = REPO_ROOT.parent / f"{REPO_ROOT.name}-moments-against" BUILD_ARTIFACTS = ( - "utama_core/motion_planning/src/fastpathplanning/_fastpathplanner.cpython-*.so", - "utama_core/rsoccer_simulator/src/Simulators/robosim/_robosim.cpython-*.so", + "utama_core/motion_planning/fastpathplanning/_fastpathplanner.cpython-*.so", + "utama_core/simulator/simulators/robosim/_robosim.cpython-*.so", ) @@ -139,18 +130,16 @@ class Moment: def short_name(name: str) -> str: - return name.removeprefix("build_").removesuffix("_kernel_strategy") + return plain_name(name) def _full_name(name: str) -> str: - if name == "all" or name.startswith("build_") or _is_file_spec(name): - return name - return f"build_{name}_kernel_strategy" + return name if name == "all" or _is_file_spec(name) else plain_name(name) def _is_file_spec(name: str) -> bool: """`PATH.py:FACTORY`: a factory in a scratch file, not a catalog name.""" - return name.rpartition(":")[0].endswith(".py") + return sim_setup.is_file_spec(name) def to_dict(m: Moment) -> dict: @@ -222,19 +211,18 @@ def save(m: Moment, path: Optional[Path] = None) -> Path: def catalog() -> list[str]: - """The round-robin's strategies: every factory `kernel_strategy.py` re-exports, minus the - retired ones.""" - from tools.evaluation.round_robin import _CONFIG_NAMES, RETIRED + """The round-robin's strategies: every strategy in the catalog.""" + from tools.evaluation.match import _CONFIG_NAMES - return [n for n in _CONFIG_NAMES if n not in RETIRED] + return list(_CONFIG_NAMES) def _referee_behaviour(name: str) -> tuple: """What decides a strategy's robots during a restart: its referee overrides and its goalkeeper tactic. Strategies equal here move identically while the override holds.""" - from utama_core.strategy import kernel_strategy + from utama_core.strategy.catalog import builder - strategy = getattr(kernel_strategy, name)(OUTFIELD_ROBOT_IDS)(None) + strategy = builder(name, OUTFIELD_ROBOT_IDS)(None) overrides = tuple( sorted((c.name, getattr(f, "__qualname__", repr(f))) for c, f in strategy.referee_overrides.items()) ) @@ -265,11 +253,11 @@ class MomentError(ValueError): def referee_rule_names() -> set[str]: - """The `rule_name=` literals of the referee's rules, read from `custom_referee/` (rules and state machine).""" + """The `rule_name=` literals of the referee's rules, read from `referee/` (rules and state machine).""" import ast names = set() - for path in (REPO_ROOT / "utama_core" / "custom_referee").rglob("*.py"): + for path in (REPO_ROOT / "utama_core" / "referee").rglob("*.py"): for node in ast.walk(ast.parse(path.read_text())): if isinstance(node, ast.Call): for kw in node.keywords: @@ -313,49 +301,6 @@ def validate(m: Moment) -> None: raise MomentError(f"{m.name}:\n " + "\n ".join(problems)) -def template( - name: str, - note: str, - command: str, - checks: list[str], - ball: tuple[float, float] = (0.0, 0.0), - strategy: str = "all", - seconds: float = DEFAULT_SECONDS, -) -> Moment: - """A hand-made moment: both teams in a fixed formation (ours yellow on the right, facing left), - the given ball and referee command, the reference pool's noise with seed 1, source null.""" - from utama_core.replay.scenario import RobotState - - ours = [(4.0, 0.0), (2.2, 1.2), (2.2, -1.2), (1.0, 2.0), (1.0, -2.0), (0.6, 0.0)] - - def robots(positions, facing): - return tuple( - RobotState(id=i, x=x, y=y, orientation=facing, vx=0.0, vy=0.0) for i, (x, y) in enumerate(positions) - ) - - pool = json.loads((REPO_ROOT / "tools" / "evaluation" / "pools" / "pool_v1.json").read_text()) - scenario = Scenario( - sim_time=0.0, - ball_x=ball[0], - ball_y=ball[1], - ball_vx=0.0, - ball_vy=0.0, - friendly_robots=robots(ours, math.pi), - enemy_robots=robots([(-x, y) for x, y in ours], 0.0), - referee_command=RefereeCommand[command], - source_replay=Path("hand-made"), - ) - return Moment( - name=name, - note=note, - scenario=scenario, - checks=list(checks), - strategy=_full_name(strategy), - seconds=seconds, - sim_noise={**pool["sim_noise"], "seed": 1}, - ) - - def with_seed(m: Moment, seed: int) -> Moment: """`m` played with its sim noise's seed replaced (`play --seed`), the JSON untouched.""" if m.sim_noise is None: @@ -376,18 +321,6 @@ class Tick: ball_speed: Optional[float] = None # m/s, for `events`' kicks -def restart_side(command: Optional[RefereeCommand], we_are_yellow: bool = True) -> Optional[str]: - """ "ours" for a restart our team takes, "theirs" for one the other team takes, None for - STOP, live play and timeouts.""" - if command is None or command.name.startswith("TIMEOUT"): - return None - if command.name.endswith("YELLOW" if we_are_yellow else "BLUE"): - return "ours" - if command.name.endswith("BLUE" if we_are_yellow else "YELLOW"): - return "theirs" - return None - - def _restart_against_us(command: Optional[RefereeCommand], we_are_yellow: bool) -> bool: """STOP, or a restart the other team takes: when every robot of ours keeps out.""" return command is RefereeCommand.STOP or restart_side(command, we_are_yellow) == "theirs" @@ -574,25 +507,11 @@ def events(ticks: list[Tick], we_are_yellow: bool = True) -> list[str]: def factory_for(name: str) -> Callable: - """The strategy factory a name means: a catalog `build_*_kernel_strategy`, or `PATH.py:FACTORY`, - a factory in a scratch file imported as it is (so a tactic can be tried without a repo change).""" - from utama_core.strategy import kernel_strategy - - if not _is_file_spec(name): - try: - return getattr(kernel_strategy, name) - except AttributeError: - raise MomentError(f"unknown strategy {short_name(name)!r}") from None - path, _, func = name.rpartition(":") - if not Path(path).is_file(): - raise MomentError(f"{name}: no such file {path}") - spec = importlib.util.spec_from_file_location(f"scratch_{Path(path).stem}", path) - module = importlib.util.module_from_spec(spec) - spec.loader.exec_module(module) - factory = getattr(module, func, None) - if not callable(factory): - raise MomentError(f"{name}: {path} has no factory {func!r}") - return factory + """`sim_setup.factory_for`, its errors as `MomentError`.""" + try: + return sim_setup.factory_for(name) + except sim_setup.UnknownStrategy as e: + raise MomentError(str(e)) from None def label(name: str) -> str: @@ -605,30 +524,20 @@ def label(name: str) -> str: def play(m: Moment, strategy: str) -> list[Tick]: """Play `m` with `strategy` on our side (yellow) for `m.seconds`.""" - from utama_core.custom_referee import CustomReferee - from utama_core.engine.abstract_strategy import AbstractStrategy from utama_core.replay.scenario import apply_scenario - from utama_core.rsoccer_simulator.src.Utils.sim_noise import SimNoise - from utama_core.run import StrategyRunner + from utama_core.simulator.utils.sim_noise import SimNoise - def side(name: str) -> AbstractStrategy: - return AbstractStrategy(build_kernel_strategy=factory_for(name)(OUTFIELD_ROBOT_IDS)) + def side(name: str): + try: + return sim_setup.load_side(name) + except sim_setup.UnknownStrategy as e: + raise MomentError(str(e)) from None - referee = CustomReferee.from_profile_name( - "simulation", n_robots_yellow=N_OUTFIELD + 1, n_robots_blue=N_OUTFIELD + 1 - ) - runner = StrategyRunner( - strategy=side(strategy), - opp_strategy=side(m.opponent), - my_team_is_yellow=True, - my_team_is_right=True, - mode="rsim", - exp_friendly=N_OUTFIELD + 1, - exp_enemy=N_OUTFIELD + 1, - exp_ball=True, - referee=referee, - enable_vision_stream=False, + runner, referee = sim_setup.sim_runner( + side(strategy), + side(m.opponent), sim_noise=SimNoise.from_dict(m.sim_noise) if m.sim_noise else None, + initial_command=None, ) ticks = [] try: @@ -726,92 +635,6 @@ def _designated_position(replay: Path, t: float) -> Optional[tuple[float, float] return tuple(designated) if designated else None -def without_own_restarts(fouls: list[dict]) -> list[dict]: - """`fouls` minus those during a restart our team takes: `keeps_clear` does not apply there.""" - return [f for f in fouls if f.get("restart") != "ours"] - - -# Rules that stop play without being a rules foul: the ball leaving the field. -STOPPAGE_RULES = frozenset({"out_of_bounds"}) -FOUL_COLUMNS = ("strategy", "rule", "tactic", "restart") - - -def without_stoppages(fouls: list[dict]) -> list[dict]: - return [f for f in fouls if f["rule"] not in STOPPAGE_RULES] - - -def _foul_column(f: dict, column: str) -> str: - if column == "strategy": - return short_name(f["config_a"]) - if column == "restart": - return f.get("restart") or "live" - return str(f.get(column) or "-") - - -def count_fouls(fouls: list[dict], columns: list[str]) -> list[tuple[tuple[str, ...], int]]: - """How many of `fouls` fall in each combination of `columns` (names from `FOUL_COLUMNS`), - most common first; ties in name order.""" - counts = Counter(tuple(_foul_column(f, c) for c in columns) for f in fouls) - return sorted(counts.items(), key=lambda item: (-item[1], item[0])) - - -def fouls_json(fouls: list[dict], columns: Optional[list[str]] = None) -> str: - """`fouls` as JSON: the foul dicts as they are, or with `columns` the `count_fouls` rows as - {column: value, ..., "count": n} objects, most common first.""" - if columns is None: - data = fouls - else: - data = [{**dict(zip(columns, key)), "count": n} for key, n in count_fouls(fouls, columns)] - return json.dumps(data, indent=1, sort_keys=True) - - -def print_fouls_by(fouls: list[dict], columns: list[str]) -> None: - """`count_fouls` as a table: a count column, then one column per name, then the total.""" - rows = count_fouls(fouls, columns) - widths = [max([len(c)] + [len(key[i]) for key, _ in rows]) for i, c in enumerate(columns)] - print(f"{'count':>5} " + " ".join(f"{c:<{w}}" for c, w in zip(columns, widths))) - for key, n in rows: - print(f"{n:>5} " + " ".join(f"{v:<{w}}" for v, w in zip(key, widths))) - print(f"{sum(n for _, n in rows):>5} total") - - -def our_fouls(run_dir: Path, rule: Optional[str] = None) -> list[dict]: - """Every foul config_a (our side in the replay) committed in a round-robin run, from its - summary.json: the starting points for new moments. Each carries the referee `command` active - at its time (from the match's `.intentions.jsonl`, None if absent), its `restart` side - ("ours", "theirs", or None for live play and STOP) and its match's `replay` (the .npz, else the - .pkl, relative to the repo root; None if neither is there), for replay_trace and repro.""" - run_dir = Path(run_dir) - summary = json.loads((run_dir / "summary.json").read_text()) - out = [] - for r in summary["results"]: - stem = run_dir / f"{short_name(r['config_a'])}_vs_{short_name(r['config_b'])}" - sidecar = Path(f"{stem}.intentions.jsonl") - replay = next((p for p in (Path(f"{stem}.npz"), Path(f"{stem}.pkl")) if p.exists()), None) - for f in (r.get("stats") or {}).get("fouls") or []: - if f.get("side") == "friendly" and (rule is None or f["rule"] == rule): - command = _referee_command_at(sidecar, f["sim_time"]) - out.append( - { - "config_a": r["config_a"], - "config_b": r["config_b"], - **f, - "command": command.name if command else None, - "restart": restart_side(command), - "replay": _repo_relative(replay) if replay is not None else None, - } - ) - return out - - -def _repo_relative(path: Path) -> str: - """`path` relative to the repo root (as a string), or as given if it is outside the repo.""" - try: - return str(Path(path).resolve().relative_to(REPO_ROOT)) - except ValueError: - return str(path) - - def parse_seeds(spec: str) -> list[int]: """`0-4` or `0,2,3` (or both, `0-1,3`): the seeds in order, each once.""" seeds = [] @@ -848,7 +671,7 @@ def _git(*args: str, cwd: Path = REPO_ROOT) -> str: def ref_worktree(ref: str) -> Path: """A worktree of the tree at `ref` under `AGAINST_DIR` (reused if it is there at that commit), - with the main tree's `.pixi` and compiled extensions, and this `tools/moments.py` in place of + with the main tree's `.pixi` and compiled extensions, and this `tools/debug/moments.py` in place of its own: the same judge plays the moment, only the code under test differs, so any commit can be compared, including ones from before `--seeds`. Not removed afterwards.""" sha = _git("rev-parse", "--verify", f"{ref}^{{commit}}") @@ -866,12 +689,16 @@ def ref_worktree(ref: str) -> Path: for pattern in BUILD_ARTIFACTS: for src in REPO_ROOT.glob(pattern): shutil.copy2(src, path / src.relative_to(REPO_ROOT)) - shutil.copy2(Path(__file__).resolve(), path / "tools" / "moments.py") + (path / "tools" / "debug").mkdir(parents=True, exist_ok=True) + shutil.copy2(Path(__file__).resolve(), path / "tools" / "debug" / "moments.py") + sim = path / "utama_core" / "run" / "sim_setup.py" + if not sim.exists(): # a commit from before sim_setup moved into utama_core: the judge needs it + shutil.copy2(sim_setup.__file__, sim) return path def ref_cells(json_path: Path, name: str, seeds: list[int], tree: Path) -> dict[int, list[str]]: - """{seed: failures} for one strategy, played in `tree` by this `tools/moments.py` (copied there by + """{seed: failures} for one strategy, played in `tree` by this `tools/debug/moments.py` (copied there by `ref_worktree`; its env's python, run directly so pixi cannot re-solve the shared env).""" fd, out = tempfile.mkstemp(dir=AGAINST_DIR, suffix=".json") os.close(fd) @@ -879,7 +706,7 @@ def ref_cells(json_path: Path, name: str, seeds: list[int], tree: Path) -> dict[ env = {**os.environ, "PATH": f"{python.parent}{os.pathsep}{os.environ.get('PATH', '')}"} cmd = [ str(python), - "tools/moments.py", + "tools/debug/moments.py", "play", str(json_path), "--strategy", @@ -942,42 +769,6 @@ def main() -> None: p.add_argument("--designated-position", type=float, nargs=2, default=None) p.add_argument("--out", type=Path, default=None, help=f"where to write it (default {MOMENTS_DIR}/.json)") - p = sub.add_parser("fouls", help="list our side's fouls in a round-robin run") - p.add_argument("run_dir", type=Path) - p.add_argument("--rule", default=None) - p.add_argument( - "--skip-own-restart", - action="store_true", - help="leave out fouls during our own restarts (keeps_clear does not apply there)", - ) - p.add_argument( - "--include-stoppages", - action="store_true", - help="also list out_of_bounds (the ball leaving the field: a stoppage, not a rules foul)", - ) - p.add_argument( - "--by", - default=None, - metavar="COLUMNS", - help=f"print counts per combination of these columns, comma-separated, of {', '.join(FOUL_COLUMNS)} " - "(e.g. strategy,rule), instead of one line per foul", - ) - p.add_argument( - "--json", - action="store_true", - help="write JSON to stdout instead of text: the foul dicts, or with --by a list of {column: value, ..., " - "count} rows", - ) - - p = sub.add_parser("new", help="write a hand-made moment template to edit by hand") - p.add_argument("name", help="lowercase letters, digits and underscores") - p.add_argument("--command", required=True, choices=[c.name for c in RefereeCommand]) - p.add_argument("--ball", type=float, nargs=2, default=(0.0, 0.0), metavar=("X", "Y")) - p.add_argument("--strategy", default="all") - p.add_argument("--seconds", type=float, default=DEFAULT_SECONDS) - p.add_argument("--check", nargs="+", required=True, help=f"checks ({', '.join(CHECKS)}), rule names or '*'") - p.add_argument("--note", required=True, help="what went wrong, and why it must not happen again") - p = sub.add_parser("play", help="play a moment and print what broke its checks") p.add_argument("moment", type=Path) p.add_argument( @@ -996,26 +787,7 @@ def main() -> None: p.add_argument("--json", type=Path, help=argparse.SUPPRESS) # --against reads the other tree's results args = parser.parse_args() - if args.cmd == "new": - if not re.fullmatch(r"[a-z0-9_]+", args.name): - parser.error("the name must be lowercase letters, digits and underscores") - path = MOMENTS_DIR / f"{args.name}.json" - if path.exists(): - parser.error(f"{path} exists") - try: - m = template( - args.name, - args.note, - args.command, - args.check, - ball=tuple(args.ball), - strategy=args.strategy, - seconds=args.seconds, - ) - print(f"Wrote {save(m)}: edit its positions by hand, then `play` it") - except MomentError as e: - parser.error(str(e)) - elif args.cmd == "capture": + if args.cmd == "capture": m = capture( args.replay, args.t, @@ -1030,30 +802,6 @@ def main() -> None: print( f"Wrote {save(m, args.out)} ({m.scenario.referee_command.name if m.scenario.referee_command else 'no command'})" ) - elif args.cmd == "fouls": - fouls = our_fouls(args.run_dir, args.rule) - if args.skip_own_restart: - fouls = without_own_restarts(fouls) - if not args.include_stoppages: - fouls = without_stoppages(fouls) - if args.by: - columns = [c.strip() for c in args.by.split(",")] - unknown = [c for c in columns if c not in FOUL_COLUMNS] - if unknown: - parser.error(f"--by: unknown column(s) {unknown}; choose from {', '.join(FOUL_COLUMNS)}") - if args.json: - print(fouls_json(fouls, columns)) - else: - print_fouls_by(fouls, columns) - elif args.json: - print(fouls_json(fouls)) - else: - for f in fouls: - print( - f"{f['rule']:<28} t={f['sim_time']:>7.2f} robot {f.get('robot_id')} {f.get('tactic') or '':<24} " - f"{(f['command'] or '?'):<22} {f['restart'] or 'live':<7} " - f"{short_name(f['config_a'])} vs {short_name(f['config_b'])}" - ) else: m = load(args.moment) if args.seed is not None and args.seeds: diff --git a/tools/pitch_maps.py b/tools/debug/pitch_maps.py similarity index 88% rename from tools/pitch_maps.py rename to tools/debug/pitch_maps.py index 683cfd4ef..df2c54dca 100644 --- a/tools/pitch_maps.py +++ b/tools/debug/pitch_maps.py @@ -1,8 +1,8 @@ """On-pitch pictures of how each strategy plays, from one round-robin run. - pixi run python tools/pitch_maps.py replays/tournament_ [--out docs/img/signals] + pixi run python tools/debug/pitch_maps.py replays/eval_/round_1 [--out docs/img/signals] -Every strategy gets one panel per figure, in `signal_report`'s order (points per match). All +Every strategy gets one panel per figure, in name order (never a ranking). All panels use one frame: the strategy attacks toward +x, its own goal is on the left (-x), and the pitch is rotated 180 degrees for a team that attacks toward -x, so its left wing is +y in every panel. Writes: @@ -15,6 +15,9 @@ - `fouls_map.png`: where the strategy committed its fouls, coloured by rule: the four most common rules in the run, then all other rules. +With `--data PATH` it writes the numbers behind the position and shot maps as JSON instead (the +dashboard's Strategies tab draws them; `map_data`), and no figures. + Possession is `MatchStatsAccumulator`'s notion without its hysteresis: the nearest robot to the ball, within `_POSSESSION_RADIUS_M`, while the ball is slower than `_PASS_RELEASE_MPS`. Positions are sampled every `STEP` ticks in live play (NORMAL_START, FORCE_START); the goalkeeper is the @@ -41,11 +44,11 @@ from matplotlib.colors import LinearSegmentedColormap # noqa: E402 from matplotlib.patches import Circle, Rectangle # noqa: E402 -REPO_ROOT = Path(__file__).resolve().parents[1] +REPO_ROOT = Path(__file__).resolve().parents[2] if str(REPO_ROOT) not in sys.path: sys.path.insert(0, str(REPO_ROOT)) -from tools import signal_report as sr # noqa: E402 +from tools.debug import figure_style as sr # noqa: E402 from utama_core.analysis import turnover_breakdown # noqa: E402 from utama_core.analysis.findings import Finding, write_jsonl # noqa: E402 from utama_core.config.field_params import STANDARD_FIELD_DIMS as F # noqa: E402 @@ -58,6 +61,7 @@ ColumnarReplay, load_columnar_replay, ) +from utama_core.strategy.catalog import plain_name # noqa: E402 L, W = F.full_field_half_length, F.full_field_half_width BOX_D, BOX_W = 2 * F.half_defense_area_depth, F.half_defense_area_width # the 2 m x 1 m box, from the goal line @@ -218,6 +222,43 @@ def shot_marks(views: list[MatchView], strategy: str) -> dict: } +def map_data(views: list[MatchView], order: list[str]) -> dict: + """The position and shot maps' numbers, for the dashboard: per strategy, both position grids + (shares per cell, rows y and columns x, with each robot's mean) and its shots for and against as + (x, y, scored). `vmax` is one colour scale per grid kind across all strategies, as in the figures.""" + out: dict = { + "pitch": { + "half_length": L, + "half_width": W, + "box_depth": BOX_D, + "box_half_width": BOX_W, + "goal_half_width": F.half_goal_width, + "goal_depth": GOAL_D, + "centre_radius": F.center_circle_radius, + }, + "bin_m": BIN_M, + "vmax": {}, + "strategies": {n: {} for n in order}, + } + for key, in_possession in (("attack", True), ("defence", False)): + grids = {n: position_grid(views, n, in_possession) for n in order} + nonzero = [g["share"][g["share"] > 0] for g in grids.values()] + nonzero = np.concatenate(nonzero) if nonzero else np.empty(0) + out["vmax"][key] = float(np.percentile(nonzero, 99)) if nonzero.size else 1.0 + for n, g in grids.items(): + out["strategies"][n][key] = { + "share": np.round(g["share"], 5).tolist(), + "means": [[round(x, 3), round(y, 3)] for x, y in g["means"]], + } + for n in order: + marks = shot_marks(views, n) + out["strategies"][n]["shots"] = { + side: [[round(float(x), 3), round(float(y), 3), bool(scored)] for x, y, scored in marks[side]] + for side in ("own", "faced") + } + return out + + def top_rules(views: list[MatchView], k: int = TOP_RULES) -> list[str]: counts = Counter(f["rule"] for v in views for f in v.fouls) return [rule for rule, _ in counts.most_common(k)] @@ -386,7 +427,7 @@ def plot_fouls(views, order, labels, path: Path) -> None: def zone_findings(views: list[MatchView], order: list[str], images: Optional[dict[str, str]] = None) -> list[Finding]: """Six descriptive `zone_share` findings per strategy: the share of its in-possession and of its - out-of-possession outfield samples in each third (docs/pitch_zones.md). No threshold: they describe.""" + out-of-possession outfield samples in each third (docs/signals.md ("Pitch zones")). No threshold: they describe.""" third = L / 3 # the thirds' boundaries in the common frame, at x = +-1.5 m out: list[Finding] = [] for name in order: @@ -416,7 +457,7 @@ def zone_findings(views: list[MatchView], order: list[str], images: Optional[dic threshold=None, unit="share of samples", message=( - f"{sr.short(name)} had {share:.0%} of its {label} samples in the {zone} " + f"{plain_name(name)} had {share:.0%} of its {label} samples in the {zone} " f"({xs.size} samples)." ), image=(images or {}).get(label), @@ -438,7 +479,7 @@ def summary_rows(views: list[MatchView], order: list[str]) -> list[dict]: fouls = [f for v in views if v.strategy == name for f in v.fouls] rows.append( { - "strategy": sr.short(name), + "strategy": plain_name(name), "in_possession_attacking_half": float(np.mean(x[inp] > 0)) if inp.any() else None, "in_possession_mean_abs_y": float(np.mean(np.abs(y[inp]))) if inp.any() else None, "out_possession_own_half": float(np.mean(x[~inp] < 0)) if (~inp).any() else None, @@ -470,7 +511,7 @@ def run_views(run_dir: Path, workers: int) -> list[MatchView]: summary = json.loads((run_dir / "summary.json").read_text()) jobs = [] for r in summary["results"]: - stem = f"{sr.short(r['config_a'])}_vs_{sr.short(r['config_b'])}" + stem = f"{plain_name(r['config_a'])}_vs_{plain_name(r['config_b'])}" npz = run_dir / f"{stem}.npz" if npz.exists(): jobs.append((str(npz), r["config_a"], r["config_b"], (r.get("stats") or {}).get("fouls") or [])) @@ -485,11 +526,18 @@ def main() -> None: parser.add_argument( "--findings", metavar="PATH", help="also write the zone shares per strategy as JSON lines (- for stdout)" ) + parser.add_argument("--data", type=Path, metavar="PATH", help="write the maps' numbers as JSON here, no figures") args = parser.parse_args() summary = json.loads((args.run_dir / "summary.json").read_text()) - order = sr._order(summary["strategies"]) - labels = {n: f"{sr.short(n)} {sr.points(summary['strategies'][n]):.2f}" for n in order} + order = sorted(summary["strategies"], key=plain_name) + labels = {n: plain_name(n) for n in order} views = run_views(args.run_dir, args.workers) + if args.data is not None: + played = [n for n in order if any(v.strategy == n for v in views)] + tmp = args.data.with_suffix(".tmp") + tmp.write_text(json.dumps(map_data(views, played))) + tmp.replace(args.data) # whole or not at all: the dashboard may be reading it + return args.out.mkdir(parents=True, exist_ok=True) attack_png = args.out / "positions_attack.png" defence_png = args.out / "positions_defence.png" diff --git a/tools/plan_snapshot.py b/tools/debug/plan_snapshot.py similarity index 93% rename from tools/plan_snapshot.py rename to tools/debug/plan_snapshot.py index 5efcf5d1e..81cfbbdf5 100644 --- a/tools/plan_snapshot.py +++ b/tools/debug/plan_snapshot.py @@ -1,6 +1,6 @@ """Picture of what the fast-path planner decided for one robot on one tick. - pixi run python tools/plan_snapshot.py REPLAY.npz --t 260 --robot 4 --target -1.0 -0.3 --side enemy + pixi run python tools/debug/plan_snapshot.py REPLAY.npz --t 260 --robot 4 --target -1.0 -0.3 --side enemy Rebuilds the field state at `--t` from the replay (`utama_core.replay.scenario`), runs the planner's `_path_to` for the robot toward `--target`, and writes a PNG: the pitch around the robot, every robot @@ -11,8 +11,8 @@ no `--target`, the robot's own position 0.5 s later stands in for it, and the text box says so. Use it when a robot does something odd near an obstacle or a keep-out zone (see -docs/STRATEGY_DEVELOPMENT.md, "Debugging a foul or failure"). The picture is one tick: pair it with -`tools/replay_trace.py` for the timeline. +docs/strategy.md, "Debugging a foul or failure"). The picture is one tick: pair it with +`tools/debug/replay_trace.py` for the timeline. """ from __future__ import annotations @@ -21,7 +21,7 @@ import sys from pathlib import Path -REPO_ROOT = Path(__file__).resolve().parents[1] +REPO_ROOT = Path(__file__).resolve().parents[2] if str(REPO_ROOT) not in sys.path: sys.path.insert(0, str(REPO_ROOT)) diff --git a/tools/plan_trace.py b/tools/debug/plan_trace.py similarity index 92% rename from tools/plan_trace.py rename to tools/debug/plan_trace.py index 135406692..e278c50b6 100644 --- a/tools/plan_trace.py +++ b/tools/debug/plan_trace.py @@ -1,6 +1,6 @@ """The fast-path planner over a time window: one robot's plan, tick by tick. - pixi run python tools/plan_trace.py REPLAY.npz --t0 250 --t1 262 --robot 4 --side enemy --target -1.0 -0.3 + pixi run python tools/debug/plan_trace.py REPLAY.npz --t0 250 --t1 262 --robot 4 --side enemy --target -1.0 -0.3 For each sampled time in [t0, t1] (every `--step` s) it rebuilds the field state from the replay (`utama_core.replay.scenario`), runs the planner's `_path_to` for the robot, and records the robot's @@ -9,10 +9,10 @@ carrot joined to the robot, above time panels for robot-to-ball distance (with the keep-out distance), robot-to-carrot length, speed and the referee command. Read-only; the planner is not changed. Without `--target` each tick's target is the robot's position `--lookahead` s later, the -stand-in `tools/plan_snapshot.py` uses; the figure says so. `--json` prints the per-sample rows. +stand-in `tools/debug/plan_snapshot.py` uses; the figure says so. `--json` prints the per-sample rows. Use it when a robot's behaviour near an obstacle or keep-out zone unfolds over time, where one -`plan_snapshot` tick cannot show it (see docs/STRATEGY_DEVELOPMENT.md, "Debugging a foul or failure"). +`plan_snapshot` tick cannot show it (see docs/strategy.md, "Debugging a foul or failure"). """ from __future__ import annotations @@ -26,7 +26,7 @@ os.environ.setdefault("PYGAME_HIDE_SUPPORT_PROMPT", "1") # keep pygame's banner off stdout (--findings -) -REPO_ROOT = Path(__file__).resolve().parents[1] +REPO_ROOT = Path(__file__).resolve().parents[2] if str(REPO_ROOT) not in sys.path: sys.path.insert(0, str(REPO_ROOT)) @@ -34,6 +34,7 @@ from utama_core.analysis.plan_snapshot import game_from_scenario # noqa: E402 from utama_core.analysis.plan_trace import plan_findings, plan_trace # noqa: E402 from utama_core.replay.scenario import scenario_from_replay # noqa: E402 +from utama_core.strategy.catalog import plain_name def replay_game_at(replay: Path, side: str): @@ -91,7 +92,7 @@ def main() -> None: REPO_ROOT / "replays" / "plan_trace" / f"{args.replay.stem}_{args.t0:g}-{args.t1:g}_{args.side}{args.robot}.png" ) config = first.config_a_name if args.side == "friendly" else first.config_b_name - short = (config or "?").removeprefix("build_").removesuffix("_kernel_strategy") + short = plain_name((config or "?")) title = f"planned {args.side} {short}, robot {args.robot}, t = {args.t0:g} to {args.t1:g} s" trace = plan_trace( diff --git a/tools/replay_trace.py b/tools/debug/replay_trace.py similarity index 98% rename from tools/replay_trace.py rename to tools/debug/replay_trace.py index a7da13d41..784c4bdb6 100644 --- a/tools/replay_trace.py +++ b/tools/debug/replay_trace.py @@ -5,7 +5,7 @@ The first thing to run on a stalled match or a voided restart, before rendering it: - pixi run python tools/replay_trace.py replays/tournament_/_vs_.npz 20 40 + pixi run python tools/debug/replay_trace.py replays/tournament_/_vs_.npz 20 40 `--events` prints the events in the window instead of the periodic rows, one line each: KICK the ball's speed rises by >= 0.5 m/s in one tick, or leaves rest (< 0.5 to >= 1.0 m/s); @@ -40,7 +40,7 @@ import numpy as np -REPO_ROOT = Path(__file__).resolve().parents[1] +REPO_ROOT = Path(__file__).resolve().parents[2] if str(REPO_ROOT) not in sys.path: sys.path.insert(0, str(REPO_ROOT)) diff --git a/tools/repro_from_replay.py b/tools/debug/repro_from_replay.py similarity index 89% rename from tools/repro_from_replay.py rename to tools/debug/repro_from_replay.py index 71b80fb58..048b64a90 100644 --- a/tools/repro_from_replay.py +++ b/tools/debug/repro_from_replay.py @@ -1,8 +1,8 @@ -"""repro_from_replay.py — reload a replay's field state at a given timestamp +"""tools/debug/repro_from_replay.py — reload a replay's field state at a given timestamp into a fresh headless rsim match, and tick forward with match_log tracing on. -Why this exists: finding a stall today means running a 231-match round-robin -(`round_robin.py`), spotting a suspicious match, then tracing its replay +Why this exists: finding a stall today means running an evaluation +(`evaluate.py`), spotting a suspicious match, then tracing its replay (`render_window`/`load_frames_in_range`) to find the stall window. Once the window is known (e.g. "ball frozen from t=264s"), reproducing it previously meant replaying the *whole* match from t=0 in a fresh run just to get back @@ -41,12 +41,12 @@ starts with whatever the freshly-seeded `CustomReferee` defaults to. Usage: - pixi run python tools/repro_from_replay.py replays/tournament_.../match.npz \\ + pixi run python tools/debug/repro_from_replay.py replays/tournament_.../match.npz \\ --t 260 --duration 15 --control-scheme trajsample \\ --trace-out /tmp/repro_trace.jsonl -`--strategy` / `--opponent` take the short name of a `build_*_kernel_strategy` factory in -`utama_core/strategy/` (e.g. `clear_press_plus`, `counter_flow`), the same names as the +`--strategy` / `--opponent` take the name of a strategy in +`utama_core/strategy/` (e.g. `breakwater`, `riptide`), the same names as the replay's `summary.json` config names. The trace shows the tactics those strategies use, not the strategy names (e.g. `decoy_and_overload.*` keys come from a strategy's DecoyOverloadTactic). @@ -87,20 +87,19 @@ class name (e.g. "DecoyOverloadTactic"), on a release why, else null. Written wh from pathlib import Path from typing import Optional -REPO_ROOT = Path(__file__).resolve().parents[1] +REPO_ROOT = Path(__file__).resolve().parents[2] if str(REPO_ROOT) not in sys.path: sys.path.insert(0, str(REPO_ROOT)) from tools.evaluation.match import N_OUTFIELD, OUTFIELD_ROBOT_IDS, TICKS_PER_SECOND -from utama_core.custom_referee import CustomReferee -from utama_core.engine.abstract_strategy import AbstractStrategy +from utama_core.bundle.strategy_file import SUFFIX from utama_core.engine.match_log import load_jsonl from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.replay.columnar_reader import load_sim_noise from utama_core.replay.scenario import Scenario, apply_scenario, scenario_from_replay -from utama_core.rsoccer_simulator.src.Utils.sim_noise import SimNoise -from utama_core.run import StrategyRunner -from utama_core.strategy import kernel_strategy +from utama_core.run.sim_setup import load_side, sim_runner +from utama_core.simulator.utils.sim_noise import SimNoise +from utama_core.strategy import catalog _STILL_STALLED_WINDOW_S = 10.0 _STILL_STALLED_THRESHOLD_M = 0.05 # 5 cm @@ -114,11 +113,10 @@ def _resolve_config_name(explicit: Optional[str], from_scenario: Optional[str], f"given and the replay's directory has no summary.json (or no matching entry) to derive it from. " f"Pass --strategy/--opponent explicitly." ) - if not name.startswith("build_"): - name = f"build_{name}" - if not name.endswith("_kernel_strategy"): - name = f"{name}_kernel_strategy" - if not hasattr(kernel_strategy, name): + if name.endswith(SUFFIX): + return name + name = catalog.current_name(name) + if name not in catalog.names(): raise SystemExit( f"Unknown strategy config {name!r} (from {'CLI override' if explicit else 'replay metadata'})." ) @@ -250,13 +248,13 @@ def main() -> None: parser.add_argument( "--strategy", default=None, - help="override the friendly (config_a) strategy: the short name (e.g. clear_press_plus) or the factory " - "name (e.g. build_clear_press_plus_kernel_strategy); default: the replay's summary.json", + help="override the friendly (config_a) strategy: the short name (e.g. breakwater) or the factory " + "name (e.g. breakwater); default: the replay's summary.json", ) parser.add_argument( "--opponent", default=None, - help="override the enemy (config_b) strategy, same two name forms (e.g. counter_flow); default: the " + help="override the enemy (config_b) strategy, same two name forms (e.g. riptide); default: the " "replay's summary.json", ) parser.add_argument( @@ -286,30 +284,12 @@ def main() -> None: strategy_a_name = _resolve_config_name(args.strategy, scenario.config_a_name, "friendly") strategy_b_name = _resolve_config_name(args.opponent, scenario.config_b_name, "enemy") - build_a = getattr(kernel_strategy, strategy_a_name) - build_b = getattr(kernel_strategy, strategy_b_name) - strategy_a = AbstractStrategy(build_kernel_strategy=build_a(OUTFIELD_ROBOT_IDS)) - strategy_b = AbstractStrategy(build_kernel_strategy=build_b(OUTFIELD_ROBOT_IDS)) - - referee = CustomReferee.from_profile_name( - "simulation", n_robots_yellow=N_OUTFIELD + 1, n_robots_blue=N_OUTFIELD + 1 - ) - - runner = StrategyRunner( - strategy=strategy_a, - opp_strategy=strategy_b, - my_team_is_yellow=True, - my_team_is_right=True, - mode="rsim", - exp_friendly=N_OUTFIELD + 1, - exp_enemy=N_OUTFIELD + 1, - exp_ball=True, - referee=referee, - enable_vision_stream=False, - referee_initial_command=RefereeCommand.PREPARE_KICKOFF_YELLOW, + runner, referee = sim_runner( + load_side(strategy_a_name), + load_side(strategy_b_name), + sim_noise=sim_noise, control_scheme=args.control_scheme, match_log_path=args.trace_out, - sim_noise=sim_noise, ) print(noise_line) diff --git a/tools/restart_picture.py b/tools/debug/restart_picture.py similarity index 94% rename from tools/restart_picture.py rename to tools/debug/restart_picture.py index 46693d254..ba4fcb447 100644 --- a/tools/restart_picture.py +++ b/tools/debug/restart_picture.py @@ -1,8 +1,8 @@ """Picture of where the referee override sends every robot for one restart. - pixi run python tools/restart_picture.py REPLAY.npz --t 260 [--side enemy] [--out PATH] - pixi run python tools/restart_picture.py REPLAY.npz --all-restarts [--side enemy] [--out PATH] - pixi run python tools/restart_picture.py REPLAY.npz --findings - [--side enemy] + pixi run python tools/debug/restart_picture.py REPLAY.npz --t 260 [--side enemy] [--out PATH] + pixi run python tools/debug/restart_picture.py REPLAY.npz --all-restarts [--side enemy] [--out PATH] + pixi run python tools/debug/restart_picture.py REPLAY.npz --findings - [--side enemy] Rebuilds the field state at `--t` from the replay (`utama_core.replay.scenario`), runs `RefereeOverride.tick` for the replay's referee command there, exactly as the strategy does, and draws @@ -20,7 +20,7 @@ Use it when a restart goes wrong: robots inside the keep-out, a kicker that never reaches the ball, a placer or defender parked in the wrong place. Filter on the findings first, open the picture to understand -them. See docs/STRATEGY_DEVELOPMENT.md, "Referee handling". +them. See docs/strategy.md, "Referee handling". """ from __future__ import annotations @@ -34,7 +34,7 @@ os.environ.setdefault("PYGAME_HIDE_SUPPORT_PROMPT", "1") # keep pygame's banner off stdout (--findings -) -REPO_ROOT = Path(__file__).resolve().parents[1] +REPO_ROOT = Path(__file__).resolve().parents[2] if str(REPO_ROOT) not in sys.path: sys.path.insert(0, str(REPO_ROOT)) diff --git a/utama_core/rsoccer_simulator/src/ssl/__init__.py b/tools/dev/__init__.py similarity index 100% rename from utama_core/rsoccer_simulator/src/ssl/__init__.py rename to tools/dev/__init__.py diff --git a/tools/dev/build_strategy.py b/tools/dev/build_strategy.py new file mode 100644 index 000000000..0ab97b0cd --- /dev/null +++ b/tools/dev/build_strategy.py @@ -0,0 +1,31 @@ +"""Pack one strategy and the code it runs on into a `.strategy` file. + + pixi run python tools/dev/build_strategy.py pendulum pendulum.strategy + pixi run python tools/dev/build_strategy.py pendulum frozen.strategy --ref v2.5.0 + +Without `--ref` it takes the working tree as it stands, uncommitted changes included. +""" + +import argparse +import sys +from pathlib import Path + +REPO_ROOT = Path(__file__).resolve().parents[2] +if str(REPO_ROOT) not in sys.path: + sys.path.insert(0, str(REPO_ROOT)) + +from utama_core.bundle.strategy_file import build # noqa: E402 + + +def main() -> None: + parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + parser.add_argument("strategy", help="strategy name, e.g. pendulum") + parser.add_argument("output", type=Path) + parser.add_argument("--ref", help="git commit to pack (default: the working tree)") + args = parser.parse_args() + path = build(args.strategy, args.output, args.ref) + print(f"{path}: {path.stat().st_size / 1e6:.2f} MB") + + +if __name__ == "__main__": + main() diff --git a/tools/check_strategy_branch.py b/tools/dev/check_strategy_branch.py similarity index 84% rename from tools/check_strategy_branch.py rename to tools/dev/check_strategy_branch.py index 22a4f382c..e2501c386 100644 --- a/tools/check_strategy_branch.py +++ b/tools/dev/check_strategy_branch.py @@ -1,7 +1,7 @@ -"""check_strategy_branch.py — fail if a strategy branch could score better without playing better. +"""tools/dev/check_strategy_branch.py — fail if a strategy branch could score better without playing better. Run: - python tools/check_strategy_branch.py --base origin/main + python tools/dev/check_strategy_branch.py --base origin/main A strategy is scored by the round-robin and the evaluation. If the branch that changes it, often written by an agent, could also change the evaluation or its opponents, it could raise its score @@ -13,8 +13,8 @@ 2. **Opponents.** Every other strategy must run the base branch's code, so the round-robin plays the same opponents as on `main`. A branch either adds new strategy modules or changes exactly one existing one, never both; it never changes or deletes `pickers.py` (shared by most - strategies) or deletes a strategy; in `kernel_strategy.py` it only adds imports from the - modules it adds; and in `tactics/` it only adds new modules, since the existing tactics are + strategies) or `catalog.py` (which finds them) or deletes a strategy; and in `tactics/` it only + adds new modules, since the existing tactics are what the opponents run (to improve one, copy it into a new module). 3. **Reach.** A new or changed strategy or tactic module can't affect anything outside itself: no import-time effects or hazards (`utama_core/replay/fingerprint.py`'s `_import_time_effects` and `_hazards`: @@ -42,12 +42,11 @@ "utama_core/strategy/", "utama_core/tactics/", # new modules only (check 2) "utama_core/tests/strategy/", - "docs/strategies.md", ) STRATEGY_DIR = "utama_core/strategy/" TACTICS_DIR = "utama_core/tactics/" -REGISTRY = STRATEGY_DIR + "kernel_strategy.py" +CATALOG = STRATEGY_DIR + "catalog.py" PICKERS = STRATEGY_DIR + "pickers.py" PACKAGE_INIT = STRATEGY_DIR + "__init__.py" _FINGERPRINT = Path("utama_core/replay/fingerprint.py") @@ -83,7 +82,7 @@ def _module_name(path: str) -> str: def opponent_problems(changes: dict[str, str]) -> list[str]: """Check 2's file rules, from `changed_files`.""" - strategy = {p: s for p, s in changes.items() if p.startswith(STRATEGY_DIR) and p.endswith(".py") and p != REGISTRY} + strategy = {p: s for p, s in changes.items() if p.startswith(STRATEGY_DIR) and p.endswith(".py")} problems = [f"{p}: deletes a strategy module" for p, s in strategy.items() if s == "D"] problems += [ f"{p}: changes an existing tactic, which the opponents run; copy it into a new module instead" @@ -92,6 +91,8 @@ def opponent_problems(changes: dict[str, str]) -> list[str]: ] if PICKERS in strategy: problems.append(f"{PICKERS}: shared by most strategies, so changing it changes the opponents") + if CATALOG in strategy: + problems.append(f"{CATALOG}: every strategy is found through it, so changing it changes the opponents") if PACKAGE_INIT in strategy: problems.append(f"{PACKAGE_INIT}: every strategy runs it, so changing it changes the opponents") problems += [ @@ -99,7 +100,9 @@ def opponent_problems(changes: dict[str, str]) -> list[str]: ] added = sorted(p for p, s in strategy.items() if s == "A") # anything but an addition or a deletion changes an existing strategy, a type change included - modified = sorted(p for p, s in strategy.items() if s not in ("A", "D") and p not in (PICKERS, PACKAGE_INIT)) + modified = sorted( + p for p, s in strategy.items() if s not in ("A", "D") and p not in (PICKERS, CATALOG, PACKAGE_INIT) + ) if added and modified: problems.append(f"adds {', '.join(added)} and also changes {', '.join(modified)}: do one or the other") elif len(modified) > 1: @@ -107,38 +110,6 @@ def opponent_problems(changes: dict[str, str]) -> list[str]: return problems -def registry_problems(old_source: str, new_source: str, added_modules: set[str]) -> list[str]: - """Check 2's `kernel_strategy.py` rule: the old statements unchanged and in order, plus only - `from import ...` statements, which may not rebind a name the registry - already has (that would replace an opponent's factory) or rename what they import.""" - old_tree = ast.parse(old_source) - old = [ast.dump(s) for s in old_tree.body] - bound = {n.id for n in ast.walk(old_tree) if isinstance(n, ast.Name) and isinstance(n.ctx, ast.Store)} - bound |= { - a.asname or a.name for n in ast.walk(old_tree) if isinstance(n, (ast.Import, ast.ImportFrom)) for a in n.names - } - new = ast.parse(new_source).body - problems, i = [], 0 - for stmt in new: - if i < len(old) and ast.dump(stmt) == old[i]: - i += 1 - elif not (isinstance(stmt, ast.ImportFrom) and stmt.module in added_modules): - problems.append( - f"{REGISTRY} line {stmt.lineno}: only imports from the modules this branch adds may be added" - ) - else: - for a in stmt.names: - if a.asname or a.name in bound: - problems.append( - f"{REGISTRY} line {stmt.lineno}: imports {a.name}" - + (f" as {a.asname}" if a.asname else "") - + ", which would rebind or rename a name the registry has" - ) - if i < len(old): - problems.append(f"{REGISTRY}: changes or removes an existing statement") - return problems - - def _load_fingerprint(path: Path = _FINGERPRINT): # By path, not as `utama_core.replay.fingerprint`: the package's __init__ needs numpy, which # CI's plain python3 lacks. Check 1 has passed by now, so this is the base branch's file. @@ -322,13 +293,10 @@ def main(argv: list[str] | None = None) -> int: return 1 problems = opponent_problems(changes) - added = {_module_name(p) for p, s in changes.items() if s == "A" and p.startswith(STRATEGY_DIR)} - if REGISTRY in changes: - problems += registry_problems(_git("show", f"{args.base}:{REGISTRY}"), Path(REGISTRY).read_text(), added) fingerprint = _load_fingerprint() for path, status in sorted(changes.items()): code = path.startswith((STRATEGY_DIR, TACTICS_DIR)) and path.endswith(".py") - if status != "D" and code and path != REGISTRY: + if status != "D" and code: problems += reach_problems(path, Path(path).read_text(), fingerprint) if problems: print("This strategy branch could change its opponents or the evaluation:") diff --git a/tools/package_graph.py b/tools/dev/package_graph.py similarity index 98% rename from tools/package_graph.py rename to tools/dev/package_graph.py index 15e519b76..f805f96c5 100644 --- a/tools/package_graph.py +++ b/tools/dev/package_graph.py @@ -1,6 +1,6 @@ """Package dependency graph of `utama_core/`, as a Mermaid flowchart, and the stated import rules it breaks. - pixi run python tools/package_graph.py + pixi run python tools/dev/package_graph.py Parses every `.py` under `utama_core/` with `ast` (nothing is imported) and counts imports between first-level packages (`engine`, `replay`, ...). Test code is not scanned as a source, but an import @@ -21,7 +21,7 @@ from dataclasses import dataclass from pathlib import Path -ROOT = Path(__file__).resolve().parent.parent +ROOT = Path(__file__).resolve().parents[2] PACKAGE = "utama_core" TESTS = "tests" diff --git a/tools/setup_worktree.sh b/tools/dev/setup_worktree.sh similarity index 86% rename from tools/setup_worktree.sh rename to tools/dev/setup_worktree.sh index 3f086783b..7d42bf6cc 100755 --- a/tools/setup_worktree.sh +++ b/tools/dev/setup_worktree.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# setup_worktree.sh — prepare a git worktree of this repo to run tests and tools. +# tools/dev/setup_worktree.sh — prepare a git worktree of this repo to run tests and tools. # # Run inside the worktree (not the main checkout). It makes the worktree usable without a # fresh `pixi install` or planner build: @@ -8,7 +8,7 @@ # the main checkout. Without them the planner falls back to Python and results differ. # Idempotent: re-running changes nothing that is already in place. Prints one line per action. # -# Usage: tools/setup_worktree.sh +# Usage: tools/dev/setup_worktree.sh set -euo pipefail wt_root="$(git rev-parse --show-toplevel)" @@ -31,8 +31,8 @@ else fi for rel in \ - utama_core/motion_planning/src/fastpathplanning \ - utama_core/rsoccer_simulator/src/Simulators/robosim; do + utama_core/motion_planning/fastpathplanning \ + utama_core/simulator/simulators/robosim; do for src in "$main_root/$rel"/_*.cpython-*.so; do [ -e "$src" ] || continue name="$(basename "$src")" diff --git a/tools/evaluation/evaluate.py b/tools/evaluation/evaluate.py index ee6f775f6..ca820d091 100644 --- a/tools/evaluation/evaluate.py +++ b/tools/evaluation/evaluate.py @@ -1,252 +1,435 @@ -"""evaluate.py — is a candidate strategy better than the champion? As few matches as that takes. +"""evaluate.py — how the strategies play, and whether a candidate beats the champion at the last release. Run: - pixi run python tools/evaluation/evaluate.py CANDIDATE [CANDIDATE ...] [flags] - - --pool PATH the reference pool (default tools/evaluation/pools/pool_v1.json): the - champion, the opponents, the held-out opponents and the sim noise - --held-out play the pool's held-out opponents instead (the check before promoting) - --baseline NAME compare against this strategy instead of the champion: a new version - against the one it changes. The baseline takes the champion's role, the - champion joins the opponents, and a baseline from the pool leaves them - --max-rounds N rounds before a candidate is called undecided (default 6) - --max-workers N matches at once (default 8) - --explain also write on-pitch pictures of each candidate against the champion to - replays/eval/explain/_/ (positions, shots, fouls and a - summary; see tools/evaluation/explain.py). Explains the verdict, never - changes it. Off by default; the matches are kept until it has run. - -How it decides --------------- -Matches are played in rounds. In round k each candidate plays every opponent and the champion -once, and the champion plays every opponent, all with sim-noise seed k, so the candidate and the -champion meet the same opponents under the same noise. The candidate is config_a in odd rounds -and config_b in even ones. - -After each round the candidate is compared with the champion on paired matches -(`ratings.paired_difference`): its goal difference minus the champion's against the same -opponent with the same seed and colour, from every match in the ledger (`replay/eval_ledger.py`: -this run's, earlier runs', round-robins'), plus their head-to-head matches. Paired results share -the opponent and the noise, so their difference cancels much of it: all of it for identical -code, little for unrelated strategies; the spread is estimated from the differences themselves. -P(candidate stronger than champion) decides: - -- **better** once P >= PROMOTE (0.99), -- **worse** once P <= DROP (0.2), -- **undecided** after `--max-rounds`: not clearly better, which for a search means drop it. - -Thresholds come from simulating the rule (match noise SD 1.9 goals, six opponents, 6 rounds, -paired results correlated 0 to 1): two equal strategies are called "better" at most 3% of the -time. Unrelated strategies (correlation 0): one goal per match worse is dropped after ~2 rounds, -one goal better found 61% of the time, half a goal better 20%. A small change to a strategy -(correlation ~0.9): one goal better found every time in ~3 rounds, half a goal better 55%. -Strengths printed at the end come from the ratings over all matches (`analysis/ratings.py`). - -A fixture already in the ledger is never played again, so the champion's matches are played -once per seed and reused by every candidate. Replays are not kept: a match is a pure function -of its fixture, so `round_robin.py --pair A B --sim-noise` with the pool's noise and the seed -plays it again. - -Promoting is a decision, not a side effect: a candidate called better should pass `--held-out` -(it must not lose clearly to opponents never used for selection) before you set it as the -pool's champion by hand. + pixi run python tools/evaluation/evaluate.py [CANDIDATE ...] [--at REF] [--all] + +No candidate: one round robin of the core strategies (the health check: stalls, fouls, signals). +With candidates (strategy names or `.strategy` files): rounds until each is better, dropped or undecided. + + --at REF the reference is the champion as it was at git commit REF (default: the latest release tag) + --all every strategy in the catalog plays, not only the core + +How it works (players, rounds, the verdict, the match results store, the output folder): +docs/strategy.md, "Evaluating a strategy". For a beginner: tutorials/first_strategy.md, step 8. + +Matches play in parallel (CPUs minus one, at most 12). A match the store (replays/match_results/) holds +is never played again. A match that crashes is reported (`failed` in summary.json and report.json) and +left out of the verdict; the next run plays it again. Writes replays/eval_/. """ from __future__ import annotations +import os + +# One thread per match process: several matches run at once. +for _var in ("OMP_NUM_THREADS", "OPENBLAS_NUM_THREADS", "MKL_NUM_THREADS", "NUMEXPR_NUM_THREADS"): + os.environ.setdefault(_var, "1") + import argparse +import dataclasses +import itertools import json -import os -import shutil +import subprocess import sys from concurrent.futures import FIRST_COMPLETED, ProcessPoolExecutor, wait from datetime import datetime, timezone from pathlib import Path +from typing import Optional REPO_ROOT = Path(__file__).resolve().parents[2] if str(REPO_ROOT) not in sys.path: sys.path.insert(0, str(REPO_ROOT)) -from tools.evaluation.match import _short_name, run_match # noqa: E402 -from tools.evaluation.round_robin import ( # noqa: E402 - MAX_MATCH_SECONDS, - _resolve_config_names, - _run_metadata, +from tools.evaluation.match import ( # noqa: E402 + _CONFIG_NAMES, + TICKS_PER_SECOND, + _short_name, + run_match, +) +from tools.evaluation.sim_settings import load_players, reference_noise # noqa: E402 +from utama_core.analysis import ( # noqa: E402 + ratings, + restart_outcomes, + turnover_breakdown, ) -from utama_core.analysis import ratings # noqa: E402 +from utama_core.analysis.strategy_table import strategy_table # noqa: E402 +from utama_core.bundle.strategy_file import SUFFIX, frozen # noqa: E402 from utama_core.config.settings import REPLAY_BASE_PATH # noqa: E402 -from utama_core.replay import eval_ledger # noqa: E402 +from utama_core.replay import match_results # noqa: E402 from utama_core.replay.fingerprint import CodeGraph # noqa: E402 -from utama_core.rsoccer_simulator.src.Utils.sim_noise import SimNoise # noqa: E402 - -DEFAULT_POOL = Path(__file__).with_name("pools") / "pool_v1.json" -PROMOTE = 0.99 -DROP = 0.2 -MAX_ROUNDS = 6 - - -def round_fixtures(candidates: list[str], champion: str, opponents: list[str], k: int) -> list[tuple[str, str, int]]: - """Round `k`'s (config_a, config_b, seed): each candidate against every opponent and the - champion, and the champion against every opponent; the side under test is config_a in odd - rounds.""" - out = [] - for side in [*candidates, champion]: - rivals = opponents if side == champion else [*opponents, champion] - for o in rivals: - out.append((side, o, k) if k % 2 else (o, side, k)) - return list(dict.fromkeys(out)) - - -def verdict(p_better: float, rounds: int, max_rounds: int) -> str | None: - """The candidate's verdict after `rounds` rounds, or None to play another.""" - if p_better >= PROMOTE: - return "better" - if p_better <= DROP: - return "worse" - return "undecided" if rounds >= max_rounds else None - - -def play(a: str, b: str, seed: int, noise: dict, run_dir: Path, keep: bool = False) -> dict: - """One fixture's `MatchResult` as a dict. The match is recorded like a round-robin's (same - play), then its files are deleted unless `keep` (`--explain` reads them): only the result is kept.""" - tag = f"{_short_name(a)}_vs_{_short_name(b)}_s{seed}" - result = run_match( - a, - b, - duration_seconds=MAX_MATCH_SECONDS, - run_dir=run_dir, - match_tag_suffix=f"_s{seed}", - sim_noise=SimNoise.from_dict({**noise, "seed": seed}), - ) - if not keep: - for f in run_dir.glob(f"{tag}.*"): - f.unlink() +from utama_core.simulator.utils.sim_noise import SimNoise # noqa: E402 +from utama_core.strategy import catalog # noqa: E402 + +CONFIRM_SEED = 101 # the confirm stage's first seed: never one the screen plays +WORKERS = min(12, max(1, (os.cpu_count() or 1) - 1)) # 1 plays in this process (tests) +FROZEN_DIR = Path("replays/eval/frozen") # relative: a file's path is its name in the match results +# A full match: two halves of 300 s of playing time, the clock stopped whenever no team may play the +# ball, about 710-870 s of sim time. This only caps a match that can't reach full time. +MAX_MATCH_SECONDS = 1200.0 + + +# --- who plays what --------------------------------------------------------------------------- + + +def round_fixtures( + k: int, candidates: list[str], reference: str, opponents: list[str], seed: Optional[int] = None +) -> list[tuple[str, str, int]]: + """Round `k`'s (config_a, config_b, seed): every pair of candidates, reference and opponents once, + under `seed` (k by default). + The store holds every match whose code is unchanged, so only the matches of edited strategies, or + of a seed not played before, are actually played. The earlier of the two in (candidates, + reference, opponents) order is config_a under an odd seed, so candidates and reference face each + opponent with the same colour, and a seed always has the same colours whichever round plays it + (a confirm seed's round depends on `ratings.ROUNDS`).""" + seed = k if seed is None else seed + order = list(dict.fromkeys([*candidates, reference, *opponents])) + pairs = itertools.combinations(order, 2) + return [(x, y, seed) if seed % 2 else (y, x, seed) for x, y in pairs] + + +def seed_of(k: int) -> int: + """Round k's noise seed: k in the screen (rounds 1..ROUNDS), CONFIRM_SEED on in the confirm stage.""" + n = ratings.ROUNDS + return k if k <= n else CONFIRM_SEED + k - n - 1 + + +def stage_seeds(k: int) -> set[int]: + """The seeds of round k's stage played so far: the stage's diffs, and only those, decide.""" + first = 1 if k <= ratings.ROUNDS else ratings.ROUNDS + 1 + return {seed_of(j) for j in range(first, k + 1)} + + +def resolve_names(requested: list[str]) -> list[str]: + """Strategy names (today's or old ones) in catalog order, then `.strategy` files as given.""" + files = [n for n in requested if n.endswith(SUFFIX)] + wanted = {catalog.current_name(n) for n in requested if n not in files} + names = [n for n in _CONFIG_NAMES if n in wanted] + if unknown := wanted - set(names): + raise SystemExit(f"Unknown strategy name(s): {sorted(unknown)}. Available: {sorted(_CONFIG_NAMES)}") + return names + files + + +def latest_release() -> str: + """The latest release tag reachable from HEAD. Without one there is no reference: stop rather + than quietly compare against today's code.""" + tag = _git("describe", "--tags", "--abbrev=0") + if not tag: + raise SystemExit("No release tag reachable from HEAD (a shallow clone?): fetch the tags or pass --at REF.") + return tag + + +def champion_at(ref: str, today: str) -> str: + """The champion that `reference/players.json` named at `ref`, or `today`'s if that commit has + none. The reference is the champion of the last release: a strategy promoted since (perhaps + one that didn't exist then) becomes the reference only at the next release.""" + text = _git("show", f"{ref}:tools/evaluation/reference/players.json") + try: + return json.loads(text)["champion"] if text else today + except (ValueError, KeyError, TypeError): + return today + + +def same_code(players: list[str], fps: dict[str, str]) -> dict[str, str]: + """Each player whose code is the same as an earlier player's in `players`, mapped to that + player. Right after a release the frozen champion is the working-tree champion's code: the two + would be one player under two names, so the later one is left out.""" + first: dict[str, str] = {} + out = {} + for n in players: + out.update({n: first[fps[n]]} if fps[n] in first else {}) + first.setdefault(fps[n], n) + return out + + +def at_ref(name: str, ref: str) -> str: + """Strategy `name` as it was at `ref`, as a `.strategy` file's path (built once, then kept). An + older commit may know the strategy by its old name (`catalog.RENAMED`).""" + for n in [name, *(old for old, new in catalog.RENAMED.items() if new == name)]: + try: + return frozen(n, ref, FROZEN_DIR).as_posix() + except ValueError: + continue + raise SystemExit(f"no strategy {name} (or an old name of it) at {ref}") + + +# --- playing ---------------------------------------------------------------------------------- + + +def analyse_replay(npz: Path) -> tuple[list[dict], dict]: + """A played match's restart episodes and ball-loss record, from its replay. Kept out of `match.py` + (the environment's entry point), so changing an analysis replays no match.""" + return restart_outcomes.analyse_match(npz), turnover_breakdown.analyse_match(str(npz)) + + +def tag(a: str, b: str) -> str: + """A match's file stem in a round directory.""" + return f"{_short_name(a)}_vs_{_short_name(b)}" + + +def play_and_record( + config_a: str, config_b: str, *, a_fp: str, b_fp: str, env: str, seed: Optional[int], source: str, + run_dir: Path, **run_kwargs, +) -> dict: # fmt: skip + """Play one match into `run_dir` and return its stored record (`match_results.record`), with its + replay analysed. `run_kwargs` go to `match.run_match`.""" + result = run_match(config_a, config_b, run_dir=run_dir, **run_kwargs) + restarts = losses = replay = None + npz = Path(run_dir) / f"{tag(config_a, config_b)}.npz" + if npz.exists(): # no replay: crashed before it was written + restarts, losses = analyse_replay(npz) + replay = Path(os.path.relpath(npz.with_suffix(""), REPLAY_BASE_PATH)).as_posix() + return match_results.record( + env, a_fp, b_fp, dataclasses.asdict(result), seed=seed, source=source, restarts=restarts, losses=losses, + replay=replay, + ) # fmt: skip + + +def link_replay(rec: dict, round_dir: Path, a: str, b: str) -> bool: + """Link a reused match's files (replay, stats, intentions) into this round's folder under this + run's names, so every reader of a round folder sees all of its matches. False if the record has + no replay or its files were deleted.""" + if not rec.get("replay"): + return False + stem = Path(REPLAY_BASE_PATH) / rec["replay"] + files = sorted(stem.parent.glob(f"{stem.name}.*")) + if not any(f.suffix == ".npz" for f in files): + return False + for f in files: + link = round_dir / f"{tag(a, b)}{f.name[len(stem.name):]}" + if not link.exists(): + link.symlink_to(os.path.relpath(f, round_dir)) + return True + + +def result_row(rec: dict, a: str, b: str, reused: bool) -> dict: + """A record as a `summary.json` result, under this run's names for the two players.""" + winner = a if rec["score_a"] > rec["score_b"] else b if rec["score_b"] > rec["score_a"] else "draw" return { - "config_a": result.config_a, - "config_b": result.config_b, - "score_a": result.score_a, - "score_b": result.score_b, - "stats": {"shots": (result.stats or {}).get("shots")}, + "config_a": a, + "config_b": b, + "score_a": rec["score_a"], + "score_b": rec["score_b"], + "winner": winner, + "seed": rec["seed"], + "stats": rec["stats"], + "possession_backstop": possession_backstop(rec["stats"]), + "reused": reused, } +def possession_backstop(stats: Optional[dict]) -> bool: + """A stall the watchdog missed: possession pinned at 100/0 with the ball barely moving.""" + if not stats: + return False + poss = stats.get("possession_pct") or {} + pinned = {poss.get("friendly"), poss.get("enemy")} == {0.0, 1.0} + return pinned and (stats.get("ball_travel_m") or 0.0) < 1.0 + + +# --- the run ---------------------------------------------------------------------------------- + + def build_parser() -> argparse.ArgumentParser: parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) - parser.add_argument("candidates", nargs="+") - parser.add_argument("--pool", type=Path, default=DEFAULT_POOL) - parser.add_argument("--held-out", action="store_true") - parser.add_argument("--baseline") - parser.add_argument("--max-rounds", type=int, default=MAX_ROUNDS) - parser.add_argument("--max-workers", type=int, default=min(8, max(1, (os.cpu_count() or 1) - 1))) - parser.add_argument("--explain", action="store_true", help="also write on-pitch pictures per candidate (see above)") + parser.add_argument("candidates", nargs="*") + parser.add_argument("--at", metavar="REF") + parser.add_argument("--all", action="store_true") + parser.add_argument("--players", type=Path, help=argparse.SUPPRESS) # tests: another players.json return parser -def main() -> None: - args = build_parser().parse_args() +def main(argv: Optional[list[str]] = None) -> None: + args = build_parser().parse_args(argv) + setup = load_players(args.players) if args.players else load_players() + core = resolve_names(setup["core"]) + reserve = [n for n in _CONFIG_NAMES if n not in core] if args.all else [] + ref = args.at or latest_release() + reference = at_ref(resolve_names([champion_at(ref, setup["champion"])])[0], ref) + today = resolve_names([setup["champion"]])[0] # today's champion, on today's shared code + candidates = [c for c in resolve_names(args.candidates) if c != reference] - pool = json.loads(args.pool.read_text()) - champion = _resolve_config_names([args.baseline or pool["champion"]])[0] - opponents = _resolve_config_names(pool["held_out"] if args.held_out else pool["opponents"]) - pool_champion = _resolve_config_names([pool["champion"]])[0] - if champion != pool_champion: - opponents.append(pool_champion) # against a baseline, the champion is one more opponent - opponents = [o for o in opponents if o != champion] # a baseline from the pool leaves its seat - candidates = [c for c in _resolve_config_names(args.candidates) if c != champion] - noise = SimNoise.from_dict(pool["sim_noise"]).to_dict() + noise = SimNoise.from_dict(reference_noise()).to_dict() noise.pop("seed", None) - + env_args = { + "duration_seconds": MAX_MATCH_SECONDS, + "sim_noise": noise, + } graph = CodeGraph() - env = eval_ledger.environment(graph, duration_seconds=MAX_MATCH_SECONDS, sim_noise=noise) - fps = {n: graph.strategy_fingerprint(n)[:16] for n in {*candidates, champion, *opponents}} - - def fixture_id(f: tuple[str, str, int]) -> str: - a, b, seed = f - return eval_ledger.fixture_id(env, a, fps[a], b, fps[b], seed) + env = match_results.environment(graph, **env_args) + store = match_results.open_store(REPLAY_BASE_PATH) + everyone = list(dict.fromkeys([reference, *candidates, *core, *reserve])) + fps = {n: graph.strategy_fingerprint(n)[:16] for n in everyone} + for n, first in (dupes := same_code(everyone, fps)).items(): + print(f"{_short_name(n)} is left out: it is the same code as {_short_name(first)}") + candidates, core, reserve = ([n for n in group if n not in dupes] for group in (candidates, core, reserve)) + fps = {n: fp for n, fp in fps.items() if n not in dupes} run_id = datetime.now(timezone.utc).strftime("eval_%Y%m%d_%H%M%S") - run_dir = Path(REPLAY_BASE_PATH) / run_id # replay files must sit directly under replays/ - run_dir.mkdir(parents=True, exist_ok=True) - print( - f"Pool v{pool['version']}{' (held out)' if args.held_out else ''}: " - f"{'baseline' if args.baseline else 'champion'} {_short_name(champion)}; " - f"opponents {', '.join(_short_name(o) for o in opponents)}; environment {env}\n" - ) + while True: # claim the folder: two runs (two worktrees) may start in the same second + try: + (Path(REPLAY_BASE_PATH) / run_id).mkdir(parents=True) + break + except FileExistsError: + run_id += "b" + run_dir = Path(REPLAY_BASE_PATH) / run_id + print(f"Reference {_short_name(reference)}; core {', '.join(_short_name(n) for n in core)}; environment {env}") + + def still_current(a: str, b: str) -> bool: + """Store a played match only if the code it ran is still the code on disk.""" + now = CodeGraph() + return match_results.environment(now, **env_args) == env and all( + now.strategy_fingerprint(n)[:16] == fps[n] for n in (a, b) + ) + run_kwargs = {k: v for k, v in env_args.items() if k != "sim_noise"} open_ = list(candidates) report: dict[str, dict] = {} + rounds: list[dict] = [] + opponents_so_far: set[str] = set() played = reused = 0 - with ProcessPoolExecutor(max_workers=args.max_workers) as executor: - for k in range(1, args.max_rounds + 1): - if not open_: + failed: list[dict] = [] + executor = ProcessPoolExecutor(max_workers=WORKERS) if WORKERS > 1 else None + try: + for k in range(1, 2 * ratings.ROUNDS + 1): + if k > 1 and not open_: break - ledger = eval_ledger.load(env) - todo = [f for f in round_fixtures(open_, champion, opponents, k) if fixture_id(f) not in ledger] - reused += len(round_fixtures(open_, champion, opponents, k)) - len(todo) - futures = {executor.submit(play, *f, noise, run_dir, args.explain): f for f in todo} - while futures: - done, _ = wait(futures, return_when=FIRST_COMPLETED) - for future in done: - a, b, seed = futures.pop(future) - result = future.result() - eval_ledger.append([eval_ledger.entry(env, graph, result, seed, source=run_id)]) - played += 1 - print( - f" round {k}: {_short_name(a):<24} {result['score_a']} - {result['score_b']} {_short_name(b)}", - flush=True, - ) - - fit = _fit(env, fps, {*open_, champion, *opponents}) - ledger = _up_to_round(eval_ledger.load(env), k) - for c in list(open_): - margin, sd = ratings.paired_difference(*paired(ledger, fps, c, champion, opponents), fit.noise_sd) - p = ratings.p_positive(margin, sd) - v = verdict(p, k, args.max_rounds) - print(f"after round {k}: {_short_name(c):<28} P(better) {p:.2f} margin {margin:+.2f} ± {sd:.2f}") - if v is not None: - open_.remove(c) - report[c] = {"verdict": v, "rounds": k, "p_better": round(p, 3), "margin": round(margin, 2)} - report[c]["margin_sd"] = round(sd, 2) - print() - if args.explain: - _explain(run_dir, run_id, candidates, champion) - shutil.rmtree(run_dir, ignore_errors=True) # this run's own scratch dir; results are in the ledger - - final = _fit(env, fps, {*candidates, champion, *opponents}) - ledger = eval_ledger.load(env) - print(f"Verdicts ({played} matches played, {reused} reused from the ledger):") + opponents = [p for p in [*core, *reserve] if p not in candidates and p != reference] + # today's champion first: it then meets every other opponent in the candidates' colour + opponents.sort(key=lambda p: p != today) + opponents_so_far |= set(opponents) + seed = seed_of(k) + fixtures = round_fixtures(k, open_ if k > 1 else candidates, reference, opponents, seed) + round_dir = run_dir / f"round_{k}" + round_dir.mkdir(parents=True, exist_ok=True) + recs: dict[tuple[str, str], tuple[dict, bool]] = {} + todo = [] + for a, b, seed in fixtures: + rec = store.get(env, match_results.fixture_id(env, fps[a], fps[b], seed)) + if rec is None: + todo.append((a, b, seed)) + else: + recs[(a, b)] = (rec, True) + link_replay(rec, round_dir, a, b) + reused += len(recs) + print( + f"\nRound {k}: {len(fixtures)} matches, {len(recs)} from the match results store, {len(todo)} to play" + ) + + def finish(a: str, b: str, rec: dict) -> None: + nonlocal played + played += 1 + recs[(a, b)] = (rec, False) + if still_current(a, b): + store.put(rec) + else: + print(f" {tag(a, b)} not stored: its code changed while the run played", flush=True) + print( + f" round {k}: {_short_name(a):<24} {rec['score_a']} - {rec['score_b']} {_short_name(b)}", + flush=True, + ) + + def fail(a: str, b: str, err: BaseException) -> None: + """A match that crashed: reported, not stored, missing from the verdict's pairs.""" + print(f" round {k}: {tag(a, b)} CRASHED: {err!r}", flush=True) + failed.append({"round": k, "config_a": a, "config_b": b, "error": repr(err)}) + + def submit(a: str, b: str, seed: int) -> tuple: + kw = dict(a_fp=fps[a], b_fp=fps[b], env=env, seed=seed, source=run_id, run_dir=round_dir) + kw.update(run_kwargs, sim_noise=SimNoise.from_dict({**noise, "seed": seed})) + return a, b, kw + + if executor is None: + for a, b, kw in (submit(*f) for f in todo): + try: + rec = play_and_record(a, b, **kw) + except Exception as err: # noqa: BLE001 -- one bad match must not lose the run + fail(a, b, err) + else: + finish(a, b, rec) + else: + futures = { + executor.submit(play_and_record, a, b, **kw): (a, b) for a, b, kw in (submit(*f) for f in todo) + } + while futures: + done, _ = wait(futures, return_when=FIRST_COMPLETED) + for future in done: + a, b = futures.pop(future) + try: + rec = future.result() + except Exception as err: # noqa: BLE001 -- one bad match must not lose the run + fail(a, b, err) + else: + finish(a, b, rec) + + rows = [result_row(rec, a, b, was_reused) for (a, b), (rec, was_reused) in recs.items()] + names = sorted({n for pair in recs for n in pair}) + summary = {"run_id": f"{run_id}/round_{k}", "round": k, "seed": seed, "config_names": names} + summary["results"] = sorted(rows, key=lambda r: (r["config_a"], r["config_b"])) + summary["failed"] = [f for f in failed if f["round"] == k] + summary.update(signals(summary, {pair: rec for pair, (rec, _) in recs.items()}, round_dir)) + (round_dir / "summary.json").write_text(json.dumps(summary, indent=2)) + rounds.append(summary) + + if candidates: + confirming = k > ratings.ROUNDS + ledger = _with_seeds(store.load(env, fps=fps), stage_seeds(k)) + for c in list(open_): + test = ratings.paired_test(paired(ledger, fps, c, reference, sorted(opponents_so_far))[0]) + stage = "confirm" if confirming else "screen" + print(f"after round {k} ({stage}): {_short_name(c):<28} {_test_line(test)}") + v = ratings.decide(test, k - ratings.ROUNDS if confirming else k, confirming) + if v is None: + continue + report.setdefault(c, {})[stage] = _test_dict(test) + if v != "confirm": + open_.remove(c) + report[c].update(verdict=v, rounds=k, decided_in=stage) + finally: + if executor is not None: + executor.shutdown(cancel_futures=True) + + health = rounds[0] + print_signals(health, f"{run_id}/round_1") + ledger = store.load(env, fps=fps) + if candidates: + print(f"\nVerdicts against {_short_name(reference)} ({played} matches played, {reused} from the store):") for c in candidates: r = report[c] + decided = r[r["decided_in"]] print( - f" {_short_name(c):<28} {r['verdict'].upper():<10} P(better) {r['p_better']:.2f} " - f"margin {r['margin']:+.2f} ± {r['margin_sd']:.2f} goals/match after {r['rounds']} round(s)" + f" {_short_name(c):<28} {r['verdict'].upper():<10} in the {r['decided_in']} after {r['rounds']} " + f"round(s): {_test_line(ratings.PairedTest(**decided))}" ) - r["per_opponent"] = _per_opponent(_up_to_round(ledger, r["rounds"]), fps, c, champion, opponents) - print(f" {'opponent':<26} {'candidate GD':>12} {'champion GD':>12} {'matches':>8} (same seed and colour)") + upto = _with_seeds(ledger, {seed_of(j) for j in range(1, r["rounds"] + 1)}) + r["per_opponent"] = _per_opponent(upto, fps, c, reference, sorted(opponents_so_far)) + if today in fps and today not in (c, reference): # not the same code as the reference + test = ratings.paired_test(paired(upto, fps, c, today, sorted(opponents_so_far - {today}))[0]) + r["vs_todays_champion"] = {"name": today, **_test_dict(test)} + print(f" against today's {_short_name(today)} (same shared code): {_test_line(test)}") + r["stalls"] = stall_coverage(upto, fps, c) + print(f" {'opponent':<26} {'candidate GD':>12} {'reference GD':>12} {'matches':>8} (same seed and colour)") for o, row in r["per_opponent"].items(): name = o if o == "head-to-head" else _short_name(o) print(f" {name:<26} {row['candidate']:>+12} {row['champion']:>+12} {row['matches']:>8}") - if r["verdict"] == "better" and not args.held_out: - print(f" -> next: evaluate.py {_short_name(c)} --held-out, then set it as the pool's champion") - print("\nStrengths (goals per match, ± SD):") - for n in sorted(final.names, key=lambda n: -final.strength(n)[0]): - m, sd = final.strength(n) - print(f" {_short_name(n):<28} {m:+.2f} ± {sd:.2f}") - - out = Path(REPLAY_BASE_PATH) / "eval" / "reports" / f"{run_id}.json" - out.parent.mkdir(parents=True, exist_ok=True) + for line in stall_lines(r["stalls"], "candidate"): + print(f" {line}") + + if failed: + print(f"\n{len(failed)} match(es) crashed (summary.json 'failed'); their pairs are missing from the verdicts.") + out = run_dir / "report.json" out.write_text( json.dumps( { "run_id": run_id, "run": _run_metadata(), - "pool": str(args.pool), - "held_out": args.held_out, + "reference": reference, + "core": core, "environment": env, - "rule": {"promote": PROMOTE, "drop": DROP, "max_rounds": args.max_rounds}, + "rule": {"rounds": ratings.ROUNDS, "alpha": ratings.ALPHA, "confirm_seed": CONFIRM_SEED}, "candidates": report, - "strengths": {n: final.strength(n) for n in final.names}, - "noise_sd": final.noise_sd, + "failed": failed, + "rounds": [{"round": s["round"], "seed": s["seed"], "matches": len(s["results"])} for s in rounds], + "signals": {k: v for k, v in health.items() if k not in ("results",)}, }, indent=2, ) @@ -254,34 +437,21 @@ def fixture_id(f: tuple[str, str, int]) -> str: print(f"\nReport: {out.relative_to(REPO_ROOT) if out.is_relative_to(REPO_ROOT) else out}") -def _explain(run_dir: Path, run_id: str, candidates: list[str], champion: str) -> None: - """`--explain`: pictures of each candidate against the champion, from this run's kept matches. - Runs before the scratch dir is removed; a failure is printed and never loses the verdicts.""" - from tools.evaluation import explain # matplotlib: imported only when asked for +# --- the verdict's arithmetic ----------------------------------------------------------------- - for c in candidates: - out = Path(REPLAY_BASE_PATH) / "eval" / "explain" / f"{_short_name(c)}_{run_id}" - try: - explain.explain(run_dir, c, champion, out) - print(f"explain: {_short_name(c)} vs {_short_name(champion)} written to {out}") - except Exception as exc: # noqa: BLE001 - the pictures are optional; the verdicts are not - print(f"explain: {_short_name(c)} failed ({type(exc).__name__}: {exc}); verdicts are unaffected") + +def _with_seeds(ledger: dict, seeds: set[int]) -> dict: + """The stored matches with one of `seeds`: a decision uses its own stage's rounds only, whatever + other seeds the store already holds, so it doesn't depend on earlier runs.""" + return {f: e for f, e in ledger.items() if e["seed"] in seeds} -def _fit(env: str, fps: dict[str, str], players: set[str]) -> ratings.Ratings: - """Ratings over every ledger match in `env` between `players` at their current code.""" - matches = [ - (e["a"], e["b"], e["score_a"] - e["score_b"]) - for e in eval_ledger.load(env).values() - if e["a"] in players and e["b"] in players and fps.get(e["a"]) == e["a_fp"] and fps.get(e["b"]) == e["b_fp"] - ] - return ratings.fit(matches, names=sorted(players)) +def _test_dict(test: ratings.PairedTest) -> dict: + return {"n": test.n, "mean": round(test.mean, 3), "se": round(test.se, 3), "p": round(test.p, 4)} -def _up_to_round(ledger: dict, k: int) -> dict: - """The ledger's matches of rounds 1..k (seeds 1..k): a verdict after round k uses those only, - whatever later rounds the ledger already holds, so it doesn't depend on earlier runs.""" - return {f: e for f, e in ledger.items() if e["seed"] is not None and e["seed"] <= k} +def _test_line(test: ratings.PairedTest) -> str: + return f"mean diff {test.mean:+.2f} ± {test.se:.2f} goals/match over {test.n} diffs, p {test.p:.3f}" def _margins(ledger: dict, fps: dict, side: str, o: str) -> dict[tuple, int]: @@ -297,33 +467,338 @@ def _margins(ledger: dict, fps: dict, side: str, o: str) -> dict[tuple, int]: return out -def paired(ledger: dict, fps: dict, candidate: str, champion: str, opponents: list[str]) -> tuple[list, list]: - """The candidate's goal difference minus the champion's against each opponent, over the - matches both played with the same seed and colour, and the candidate's margins against the - champion: `ratings.paired_difference`'s inputs.""" +def paired(ledger: dict, fps: dict, candidate: str, reference: str, opponents: list[str]) -> tuple[list, list]: + """The candidate's goal difference minus the reference's against each opponent, over the matches + both played with the same seed and colour (the verdict's diffs), and the candidate's margins + against the reference (head-to-head, reported only).""" diffs = [] for o in opponents: - c, ch = _margins(ledger, fps, candidate, o), _margins(ledger, fps, champion, o) - diffs += [c[k] - ch[k] for k in sorted(set(c) & set(ch))] - return diffs, list(_margins(ledger, fps, candidate, champion).values()) + c, ref = _margins(ledger, fps, candidate, o), _margins(ledger, fps, reference, o) + diffs += [c[k] - ref[k] for k in sorted(set(c) & set(ref))] + return diffs, list(_margins(ledger, fps, candidate, reference).values()) -def _per_opponent(ledger: dict, fps: dict, candidate: str, champion: str, opponents: list[str]) -> dict: - """Goal difference against each opponent, the candidate's and the champion's, over the - matches both played with the same seed and colour (so the two columns face the same noise).""" +def _per_opponent(ledger: dict, fps: dict, candidate: str, reference: str, opponents: list[str]) -> dict: + """Goal difference against each opponent, the candidate's and the reference's, over the matches + both played with the same seed and colour (so the two columns face the same noise).""" rows = {} for o in opponents: - c, ch = _margins(ledger, fps, candidate, o), _margins(ledger, fps, champion, o) - common = sorted(set(c) & set(ch)) + c, ref = _margins(ledger, fps, candidate, o), _margins(ledger, fps, reference, o) + common = sorted(set(c) & set(ref)) rows[o] = { "candidate": sum(c[k] for k in common), - "champion": sum(ch[k] for k in common), + "champion": sum(ref[k] for k in common), "matches": len(common), } - h2h = _margins(ledger, fps, candidate, champion) + h2h = _margins(ledger, fps, candidate, reference) rows["head-to-head"] = {"candidate": sum(h2h.values()), "champion": -sum(h2h.values()), "matches": len(h2h)} return rows +def stall_coverage(ledger: dict, fps: dict, side: str) -> dict: + """Stalls `side` was checked for over the stored matches at current code: the watchdog only + watches config_a, so a match counts as checked when `side` was config_a and its record + has a stall record (None, an older line, is unknown). `total` counts every match of `side`.""" + checked, total, stalls = 0, 0, [] + for e in ledger.values(): + if side not in (e["a"], e["b"]): + continue + if e["a_fp"] != fps.get(e["a"]) or e["b_fp"] != fps.get(e["b"]): + continue + total += 1 + if e["a"] != side or e.get("stalls") is None: + continue + checked += 1 + stalls += [{"a": e["a"], "b": e["b"], "seed": e["seed"], **s} for s in e["stalls"]] + return {"checked": checked, "total": total, "stalls": stalls} + + +def stall_lines(cov: dict, name: str) -> list[str]: + """The printed stall report for one side's `stall_coverage`.""" + head = f"stalls checked in {cov['checked']} of {cov['total']} {name} matches (watchdog covers config_a only): " + if not cov["checked"]: + return [head + "unknown"] + if not cov["stalls"]: + return [head + "none"] + lines = [head + str(len(cov["stalls"]))] + for s in cov["stalls"]: + diagnosis = f" -- {s['diagnosis']}" if s.get("diagnosis") else "" + lines.append( + f" {_short_name(s['a'])} vs {_short_name(s['b'])} seed {s['seed']}: " + f"{s['kind']} at t={s['sim_time']:.1f}s{diagnosis}" + ) + return lines + + +# --- signals ---------------------------------------------------------------------------------- + + +def signals(summary: dict, by_tag: dict[tuple[str, str], dict], round_dir: Optional[Path]) -> dict: + """A round's signals (docs/signals.md) from its `summary["results"]` and their stored records + (by (config_a, config_b) under this run's names): restarts, ball losses, the per-strategy table, + fouls, stalls and how many matches checked them.""" + rows = summary["results"] + out: dict = {} + restarts = [e for r in rows for e in (by_tag.get((r["config_a"], r["config_b"]), {}).get("restarts") or [])] + out["restarts"] = restart_outcomes.summarise(restarts) + losses = { + tag(r["config_a"], r["config_b"]): {**rec["losses"], "match": tag(r["config_a"], r["config_b"])} + for r in rows + if (rec := by_tag.get((r["config_a"], r["config_b"]))) and rec.get("losses") is not None + } + real_losses = chances = None + if losses: + ordered = [losses[t] for t in sorted(losses)] + out["ball_losses"] = turnover_breakdown.breakdown(ordered) + if round_dir is not None: + report = turnover_breakdown.report(summary["run_id"], ordered, summary) + (round_dir / "ball_losses.md").write_text(report) + real_losses = {t: turnover_breakdown.real_loss_kinds(r) for t, r in losses.items()} + chances = {t: r["chances"] for t, r in losses.items() if "chances" in r} + out["strategies"] = strategy_table(rows, real_losses, chances or {}) + out["fouls"] = foul_table(rows) + out["stall_incidents"] = stall_incidents(rows) + out["stalls_checked"] = { + n: { + "checked": sum(1 for r in rows if r["config_a"] == n and r["stats"] is not None), + "matches": sum(1 for r in rows if n in (r["config_a"], r["config_b"])), + } + for n in summary["config_names"] + } + return out + + +def stall_incidents(results: list[dict]) -> list[dict]: + """Stall events over `summary.json`-shaped `results`, with deterministic duplicates merged: the + same kind, onset tick and duration tick in matches that share a strategy is one freeze seen + against two opponents that hadn't diverged yet (rsim is deterministic), not two separate + problems. In order of first appearance.""" + incidents: list[dict] = [] + by_key: dict[tuple, dict] = {} + for r in results: + t = tag(r["config_a"], r["config_b"]) + for e in (r.get("stats") or {}).get("stall_events") or []: + ticks = (e["kind"], round(e["sim_time"] * TICKS_PER_SECOND), round(e["duration_s"] * TICKS_PER_SECOND)) + keys = [(name, *ticks) for name in (r["config_a"], r["config_b"])] + incident = next((by_key[k] for k in keys if k in by_key), None) + if incident is None: + incident = {"kind": e["kind"], "sim_time": e["sim_time"], "duration_s": e["duration_s"], "matches": []} + incidents.append(incident) + if t not in incident["matches"]: + incident["matches"].append(t) + for k in keys: + by_key.setdefault(k, incident) + return incidents + + +def foul_table(results: list[dict]) -> dict[str, dict]: + """Every logged foul (`MatchStats.fouls`, both sides) by rule, then by "strategy/tactic" of the + offending robot. `inferred` counts fouls whose rule only named a team, attributed to that side's + robot nearest the ball.""" + table: dict[str, dict] = {} + for r in results: + for foul in (r.get("stats") or {}).get("fouls") or []: + strategy = _short_name(r["config_a"] if foul["side"] == "friendly" else r["config_b"]) + row = table.setdefault(foul["rule"], {"total": 0, "inferred": 0, "by_tactic": {}}) + row["total"] += 1 + row["inferred"] += bool(foul["inferred"]) + key = f"{strategy}/{foul['tactic'] or 'unknown'}" + row["by_tactic"][key] = row["by_tactic"].get(key, 0) + 1 + for row in table.values(): + row["by_tactic"] = dict(sorted(row["by_tactic"].items(), key=lambda kv: -kv[1])) + return dict(sorted(table.items(), key=lambda kv: -kv[1]["total"])) + + +def print_signals(summary: dict, run_label: str) -> None: + """The printed health check: stalls with their coverage, then every signal table.""" + rows = summary["results"] + stalled = [r for r in rows if (r["stats"] or {}).get("stall_events")] + backstop = [r for r in rows if r["possession_backstop"] and r not in stalled] + checked = summary["stalls_checked"] + print(f"\nSTALLS in round 1: {len(stalled)} match(es), {len(summary['stall_incidents'])} distinct incident(s)") + print( + " checked as config_a (the watchdog watches config_a only): " + + ", ".join(f"{_short_name(n)} {c['checked']}/{c['matches']}" for n, c in checked.items()) + ) + for r in stalled: + for e in r["stats"]["stall_events"]: + tactics = f" tactics={e['tactic_ids']}" if e.get("tactic_ids") else "" + diagnosis = f" -- {e['diagnosis']}" if e.get("diagnosis") else "" + print( + f" {tag(r['config_a'], r['config_b']):<50} {e['kind']:<17} onset t={e['sim_time']:.1f}s " + f"referee={e.get('referee_command')}{tactics}{diagnosis}" + ) + for r in backstop: + poss = r["stats"]["possession_pct"] + print( + f" {tag(r['config_a'], r['config_b']):<50} {'POSSESSION_BACKSTOP':<17} " + f"possession {poss['friendly']:.0%}/{poss['enemy']:.0%} ball_travel {r['stats']['ball_travel_m']:.2f}m" + ) + _print_restarts(summary["restarts"]) + if "ball_losses" in summary: + _print_ball_losses(summary["ball_losses"], run_label) + _print_strategy_table(summary["strategies"]) + _print_loss_kinds(summary["strategies"]) + _print_chances(summary["strategies"]) + _print_foul_table(summary["fouls"]) + _print_motion_planning_table(summary["strategies"]) + + +def _print_restarts(restarts: dict) -> None: + if not restarts["restarts"]: + return + print( + f"\nRESTARTS: {restarts['restarts']}, {restarts['reached_normal_start'] / restarts['restarts']:.0%} " + "reached NORMAL_START" + ) + for kind, row in restarts["by_kind"].items(): + outcomes = ", ".join(f"{k} {n}" for k, n in row["outcomes"].items()) + print(f" {kind:<16} {row['n']:>4} reached {row['reached_normal_start'] / row['n']:>4.0%} {outcomes}") + + +def _print_foul_table(table: dict[str, dict]) -> None: + if not table: + return + print("\nFOULS (both sides; top strategy/tactic of the offending robot; * = rule named only a team):") + for rule, row in table.items(): + top = ", ".join(f"{k} {c}" for k, c in list(row["by_tactic"].items())[:4]) + star = "*" if row["inferred"] else "" + print(f" {rule + star:<30} {row['total']:>5} {top}") + + +def _print_strategy_table(table: dict[str, dict]) -> None: + print("\nSTRATEGIES (per match; losses = real ball losses, as config_a only):") + print( + f" {'strategy':<32} {'W-D-L':>9} {'GF':>5} {'GA':>5} {'shots':>6} {'passes':>7} {'entries':>8} {'fouls':>6} {'losses':>7} {'stalled':>8}" + ) + for name, t in sorted(table.items()): + n = max(1, t["matches"]) + losses = f"{t['real_losses_as_a'] / t['matches_as_a']:.1f}" if t["matches_as_a"] else "-" + print( + f" {_short_name(name):<32} {t['wins']:>3}-{t['draws']}-{t['losses']:<3} {t['goals_for'] / n:>5.2f} " + f"{t['goals_against'] / n:>5.2f} {t['shots'] / n:>6.2f} {t['completed_passes'] / n:>7.1f} " + f"{t['attacking_third_entries'] / n:>8.1f} {t['fouls'] / n:>6.1f} {losses:>7} {t['stalled']:>8}" + ) + + +def _print_loss_kinds(table: dict[str, dict]) -> None: + """Real ball losses per match as config_a, by kind: where each strategy gives the ball away.""" + rows = {name: t for name, t in table.items() if t["matches_as_a"]} + if not rows: + return + totals: dict[str, int] = {} + for t in rows.values(): + for kind, n in t["real_loss_kinds_as_a"].items(): + totals[kind] = totals.get(kind, 0) + n + kinds = sorted(totals, key=lambda k: -totals[k]) + short = { + "shot_saved_or_blocked": "shot_saved", + "ball_out_after_kick": "out_kick", + "ball_out_other": "out_other", + "pass_intercepted": "intercepted", + "loose_ball_lost": "loose_lost", + } + print("\nLOSS KINDS (real ball losses per match as config_a, by kind; see ball_losses.md):") + print(f" {'strategy':<32} " + " ".join(f"{short.get(k, k)[:11]:>11}" for k in kinds)) + for name, t in sorted(rows.items(), key=lambda kv: -kv[1]["real_losses_as_a"] / kv[1]["matches_as_a"]): + n = t["matches_as_a"] + print( + f" {_short_name(name):<32} " + " ".join(f"{t['real_loss_kinds_as_a'].get(k, 0) / n:>11.2f}" for k in kinds) + ) + + +def _print_chances(table: dict[str, dict]) -> None: + """Chances created and conceded per strategy, both sides (`analysis.chances`).""" + rows = {name: t for name, t in table.items() if t["chances"]["matches"]} + if not rows: + return + + def pct(v: Optional[float]) -> str: + return f"{v:.0%}" if v is not None else "-" + + def num(v: Optional[float]) -> str: + return f"{v:.1f}" if v is not None else "-" + + print( + "\nCHANCES (both sides; conv = goals per shot, open = goal mouth unblocked at the shot, " + "regain>shot = open-play regains shot from within 10 s, danger = s/match the enemy held " + "the ball in our defensive third, fk>shot = free kicks shot from within 10 s, " + "progress = m gained per completed pass):" + ) + print( + f" {'strategy':<28} {'shots':>6} {'conv':>5} {'dist':>5} {'open':>5} {'save':>5} {'open vs':>7} " + f"{'regain>shot':>11} {'secs':>5} {'danger':>6} {'fk>shot':>7} {'progress':>8} {'fwd':>4}" + ) + for name, t in sorted(rows.items()): + c = t["chances"] + print( + f" {_short_name(name):<28} {c['shots'] / c['matches']:>6.1f} {pct(c['conversion']):>5} " + f"{num(c['shot_distance_m']):>5} {pct(c['shot_open_goal']):>5} {pct(c['save_rate']):>5} " + f"{pct(c['faced_open_goal']):>7} {pct(c['regain_to_shot']):>11} {num(c['regain_to_shot_s']):>5} " + f"{num(c['danger_s_per_match']):>6} {pct(c['free_kick_to_shot']):>7} " + f"{num(t['pass_progress_m']):>8} {pct(t['forward_pass_share']):>4}" + ) + + +def _print_motion_planning_table(table: dict[str, dict]) -> None: + if not any(t.get("worst_clearance_m") is not None or t.get("robot_overlap_ticks", 0) > 0 for t in table.values()): + return + print( + "\nMOTION PLANNING (per match averages; tm_coll = teammate overlap s (incidents), " + "total_coll = all overlap s (incidents), near_miss = near miss s <5cm, min_clr = worst clearance):" + ) + print(f" {'strategy':<32} {'tm_coll':>18} {'total_coll':>20} {'near_miss':>11} {'min_clr':>10}") + for name, t in sorted(table.items()): + n = max(1, t["matches"]) + tm = f"{t.get('teammate_overlap_ticks', 0) / n / TICKS_PER_SECOND:.2f}s ({t.get('teammate_overlap_incidents', 0) / n:.1f})" + tot = f"{t.get('robot_overlap_ticks', 0) / n / TICKS_PER_SECOND:.2f}s ({t.get('robot_overlap_incidents', 0) / n:.1f})" + near = t.get("near_miss_ticks", 0) / n / TICKS_PER_SECOND + wc = t.get("worst_clearance_m") + clr = f"{wc * 100:.1f} cm" if wc is not None else "-" + print(f" {_short_name(name):<32} {tm:>18} {tot:>20} {near:>10.2f}s {clr:>10}") + + +def _print_ball_losses(b: dict, run_label: str) -> None: + def top(counts: dict[str, int], k: int = 5) -> str: + return ", ".join(f"{name} {c}" for name, c in list(counts.items())[:k]) or "none" + + print( + f"\nBALL LOSSES (config_a side): {b['real_losses']} real ({b['real_losses_per_match']}/match; " + f"{b['raw_turnovers']} raw MatchStats turnovers)" + ) + print(f" by kind: {top(b['by_kind'])}") + print(f" fouls: {top(b['fouls_by_rule'])}") + print(f" by tactic: {top(b['by_tactic'])}") + rec = b.get("receptions") + if rec and rec["passes"]: + print( + f" passes: {top(rec['by_outcome'])}; {rec['catch_rate'] or 0:.0%} of reachable caught, " + f"missed median facing off {rec['missed']['median_facing_off_deg']} deg" + ) + print(f" full breakdown: replays/{run_label}/ball_losses.md") + + +# --- run metadata ----------------------------------------------------------------------------- + + +def _git(*args: str) -> Optional[str]: + try: + out = subprocess.run(["git", *args], capture_output=True, text=True, check=True, cwd=REPO_ROOT) + except (OSError, subprocess.CalledProcessError): + return None + return out.stdout.strip() + + +def _run_metadata() -> dict: + """What produced this run: enough to reproduce it or line it up against another.""" + status = _git("status", "--porcelain", "--untracked-files=no") + return { + "git_commit": _git("rev-parse", "HEAD"), + "git_dirty": bool(status) if status is not None else None, + "argv": sys.argv[1:], + "started_utc": datetime.now(timezone.utc).isoformat(timespec="seconds"), + } + + if __name__ == "__main__": main() diff --git a/tools/evaluation/explain.py b/tools/evaluation/explain.py index e8ffa6c65..58c5cc9ad 100644 --- a/tools/evaluation/explain.py +++ b/tools/evaluation/explain.py @@ -5,8 +5,8 @@ Explains a verdict; it never makes one. Goals (`evaluate.py`'s verdict) are the only ranking; these pictures and numbers show how the two strategies played, so a search agent can see WHY a candidate won or lost. Each strategy's view is every match it played in the run dir, against any -opponent (`find_matches`): a match file's stem is `_vs_` (round-robin) or -`_vs__s` (an evaluate.py run), and config_a is the friendly side. +opponent (`find_matches`): a match file's stem is `_vs_` (an evaluate.py round folder or an old round-robin; evaluate.py runs before +2026-11-12 added `_s`), and config_a is the friendly side. Writes to DIR: @@ -15,9 +15,9 @@ - `fouls.png`: each strategy's fouls by rule, one fixed colour per rule (`pitch_maps.plot_fouls`); - `summary.json`: the numbers behind the pictures per side, and the paired goal difference per opponent (same opponent, seed and colour, as `evaluate.py` pairs them), where the run has them. -- `triage/`: `tools/triage.py` on the candidate's two worst matches as config_a (`index.md` first). +- `find_bugs/`: `tools/debug/find_bugs.py` on the candidate's two worst matches as config_a (`index.md` first). -Everything is in the attacking frame of `pitch_maps.py` (attacking right). Goals come from the +Everything is in the attacking frame of `tools/debug/pitch_maps.py` (attacking right). Goals come from the replay's final referee state (the score), fouls from the match's `.stats.json`. """ @@ -40,9 +40,9 @@ if str(REPO_ROOT) not in sys.path: sys.path.insert(0, str(REPO_ROOT)) -from tools import pitch_maps as pm # noqa: E402 -from tools import signal_report as sr # noqa: E402 -from tools import triage # noqa: E402 +from tools.debug import figure_style as sr # noqa: E402 +from tools.debug import find_bugs # noqa: E402 +from tools.debug import pitch_maps as pm # noqa: E402 from tools.evaluation.match import _short_name # noqa: E402 from utama_core.analysis.matches import Match, find_matches # noqa: E402 @@ -193,14 +193,14 @@ def explain(run_dir, candidate: str, champion: str, out_dir, workers: int = 2) - "paired": paired_rows(matches, cand, champ), "fouls_rules_shown": pm.top_rules(views), "notes": ( - "Matches are those in the run dir; fixtures reused from the ledger have no replay here. " - "Positions and fouls exclude the goalkeeper and out-of-bounds (as pitch_maps.py)." + "Matches are those in the run dir; a match reused from the store is a link to the run that played it. " + "Positions and fouls exclude the goalkeeper and out-of-bounds (as tools/debug/pitch_maps.py)." ), } (out_dir / "summary.json").write_text(json.dumps(summary, indent=2)) # The candidate's two worst matches as config_a (the friendly side the intentions log covers), for an agent to # start from; evaluate.py's failure guard covers this call too. - triage.triage(run_dir, strategies={cand}, matches=2, out=out_dir / "triage", workers=workers) + find_bugs.find_bugs(run_dir, strategies={cand}, matches=2, out=out_dir / "find_bugs", workers=workers) return summary diff --git a/tools/evaluation/match.py b/tools/evaluation/match.py index fc43998d2..01921a776 100644 --- a/tools/evaluation/match.py +++ b/tools/evaluation/match.py @@ -1,65 +1,67 @@ """match.py — shared match-construction/running mechanics for the -evaluation drivers (`round_robin.py`, `evaluate.py`). +evaluation driver (`evaluate.py`). -Why this exists: `round_robin.py`'s `run_match` and the since-retired +Why this exists: `evaluate.py`'s `run_match` and the since-retired `full_match_tournament.py`'s `run_match_cell` were ~80% identical code (build -two strategies from kernel_strategy factory names, construct a referee with +two strategies from their names, construct a referee with the right kickoff-team/initial-command, wire up match_log/stats/replay paths, build and step a `StrategyRunner`, read back the score) that had drifted into two independent copies differing only in a few real parameters (duration, -whether side/kickoff are fixed or swept, fuzzing). Correctness fixes found in +whether side/kickoff are fixed or swept). Correctness fixes found in one copy (the `PREPARE_KICKOFF_*` vs `FORCE_START` kickoff-ceremony fix; the `_stats_to_dict` StallEvent-serialization fix) had to be manually ported to the other and could easily have been missed. This module is the single place that logic lives now; each script above is a thin CLI over it, differing only in which strategies it selects, what duration it uses, and whether it sweeps -side/kickoff as independent axes. +side/kickoff as independent axes. The strategies, referee and rsim runner of a +match come from `utama_core/run/sim_setup.py`, the one set-up the debugging tools share. """ from __future__ import annotations -import dataclasses import os from dataclasses import dataclass, field from pathlib import Path from typing import Optional -from utama_core.custom_referee import CustomReferee -from utama_core.custom_referee.profiles.profile_loader import load_profile -from utama_core.custom_referee.restart_fuzzer import RestartFuzzingReferee -from utama_core.engine.abstract_strategy import AbstractStrategy +from utama_core.bundle.strategy_file import SUFFIX, BundledStrategy +from utama_core.config.settings import REPLAY_BASE_PATH from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.entities.referee.stage import Stage from utama_core.replay.columnar_writer import ColumnarReplayWriterConfig -from utama_core.rsoccer_simulator.src.Simulators.robosim.robosim_wrapper import ( - enable_sim_reuse, +from utama_core.run.sim_setup import ( # noqa: F401 -- re-exported + N_OUTFIELD, + OUTFIELD_ROBOT_IDS, + load_side, + sim_referee, + sim_runner, ) -from utama_core.rsoccer_simulator.src.Utils.sim_noise import SimNoise -from utama_core.run import StrategyRunner -from utama_core.strategy import kernel_strategy +from utama_core.simulator.simulators.robosim.robosim_wrapper import enable_sim_reuse +from utama_core.simulator.utils.sim_noise import SimNoise +from utama_core.strategy import catalog +from utama_core.strategy.catalog import plain_name -N_OUTFIELD = 5 # + 1 goalkeeper per side -OUTFIELD_ROBOT_IDS = tuple(range(1, N_OUTFIELD + 1)) TICKS_PER_SECOND = 60 # matches rsim's default step rate -# build_default_kernel_strategy is excluded from the auto-discovered catalog: + +def replay_name(run_dir: Path, match_tag: str) -> str: + """A match's replay name: its path under REPLAY_BASE_PATH, no suffix, so the replay lands in + `run_dir` as `.npz`.""" + return Path(os.path.relpath(Path(run_dir) / match_tag, REPLAY_BASE_PATH)).as_posix() + + +# default is excluded from the auto-discovered catalog: # despite the name, it isn't a competitive team — it's the kernel's minimal # single-tactic smoke-test scaffold (see its docstring), used across the test # suite with as few as zero outfield robots, and plays a real match with 3 of 5 -# outfield robots never issued a command. Every other factory is playable here; -# which ones a round-robin plays by default is round_robin.RETIRED's business. -_CONFIG_NAMES = [ - name - for name in dir(kernel_strategy) - if name.startswith("build_") - and name.endswith("_kernel_strategy") - and callable(getattr(kernel_strategy, name)) - and name != "build_default_kernel_strategy" -] +# outfield robots never issued a command. Every other strategy is playable here. +_CONFIG_NAMES = catalog.player_names() def _short_name(config_name: str) -> str: - return config_name.removeprefix("build_").removesuffix("_kernel_strategy") + if config_name.endswith(SUFFIX): + return Path(config_name).stem + return plain_name(config_name) def _stats_to_dict(stats) -> dict: @@ -97,7 +99,7 @@ def _stats_to_dict(stats) -> dict: @dataclass class MatchResult: """One match's outcome. `a_is_right`/`a_kicks_off` default to the - `round_robin.py`'s fixed convention (config_a starts on the right and + `evaluate.py`'s fixed convention (config_a starts on the right and kicks off the first half; with halves the teams change ends at half-time). """ @@ -127,12 +129,9 @@ def run_match( a_kicks_off: bool = True, run_dir: Optional[Path] = None, match_tag_suffix: str = "", - control_scheme: str = "fpp", - fuzz_seed: Optional[int] = None, - fuzz_interval_s: tuple[float, float] = (25.0, 45.0), sim_noise: Optional[SimNoise] = None, ) -> MatchResult: - """Play one match between two kernel-strategy factories, until the referee calls full + """Play one match between two strategies, until the referee calls full time (two halves of the profile's `half_duration_seconds` of playing time, the clock stopped whenever no team may play the ball) or `duration_seconds` of sim time pass, whichever is first. The cap only ends a match that can't finish: two 300 s halves took @@ -161,47 +160,19 @@ def run_match( `match_tag_suffix` is appended to the per-match file tag (e.g. a side/ kickoff cell tag like `_Rk`) so cells for the same pair don't collide. - `control_scheme` is used for both sides (matching StrategyRunner's - default of falling back to `control_scheme` when `opp_control_scheme` is - unset) — these tournament drivers compare strategies against each other, - not motion planners against each other (see - `tools/motion_planning_benchmark.py` for that). - - `fuzz_seed`, if set, swaps in `RestartFuzzingReferee` (see - `utama_core/custom_referee/restart_fuzzer.py`) instead of plain - `CustomReferee`, so this match's referee injects extra seeded-random - legal restarts during live play. + Both sides use the fpp planner (`tools/motion_planning_benchmark.py` compares planners). `sim_noise`, if set, plays the match with seeded latency, kick speed noise and vision noise - (`utama_core/rsoccer_simulator/src/Utils/sim_noise.py`, `docs/sim_realism.md`). The draws + (`utama_core/simulator/utils/sim_noise.py`, `docs/sim_realism.md`). The draws depend on the seed, team colour and robot id only, so the same `sim_noise` gives every pairing the same physics. """ enable_sim_reuse() - build_a = getattr(kernel_strategy, config_a_name) - build_b = getattr(kernel_strategy, config_b_name) - - strategy_a = AbstractStrategy(build_kernel_strategy=build_a(OUTFIELD_ROBOT_IDS)) - strategy_b = AbstractStrategy(build_kernel_strategy=build_b(OUTFIELD_ROBOT_IDS)) - - # "simulation" profile's kickoff_team defaults to "yellow"; override it to - # "blue" when B kicks off. Neither CustomReferee.from_profile_name nor - # RestartFuzzingReferee.from_profile_name takes a kickoff_team override, - # so build the profile by hand, then construct the referee from it directly. - profile = load_profile("simulation") - if not a_kicks_off: - profile = dataclasses.replace(profile, game=dataclasses.replace(profile.game, kickoff_team="blue")) - if fuzz_seed is not None: - referee = RestartFuzzingReferee( - profile, - seed=fuzz_seed, - interval_s=fuzz_interval_s, - n_robots_yellow=N_OUTFIELD + 1, - n_robots_blue=N_OUTFIELD + 1, - ) - else: - referee = CustomReferee(profile, n_robots_yellow=N_OUTFIELD + 1, n_robots_blue=N_OUTFIELD + 1) + strategy_a = load_side(config_a_name) + strategy_b = load_side(config_b_name) + # config_a kicks off unless told otherwise; the referee's kickoff team and the ceremony follow it. + referee = sim_referee(kickoff_team="yellow" if a_kicks_off else "blue") initial_command = RefereeCommand.PREPARE_KICKOFF_YELLOW if a_kicks_off else RefereeCommand.PREPARE_KICKOFF_BLUE match_tag = f"{_short_name(config_a_name)}_vs_{_short_name(config_b_name)}{match_tag_suffix}" @@ -209,39 +180,20 @@ def run_match( if run_dir is not None: extra_kwargs["match_log_path"] = str(run_dir / f"{match_tag}.intentions.jsonl") extra_kwargs["stats_path"] = str(run_dir / f"{match_tag}.stats.json") - # replay_name is relative to REPLAY_BASE_PATH, not run_dir, since replays - # live under a fixed replays/ root — nest it under the same tournament - # subdirectory so the two stay next to each other on disk. - # - # Columnar (.npz) rather than pickle (.pkl): ~13 MB/match in the old - # format vs. a fraction of that here, and every reader a tournament - # run's replays are actually fed through — `load_frames_in_range` - # (`replay_player.py`, used by `render_window`) and - # `find_stuck_windows` (`analysis/stuck_detector.py`) — already dispatches on - # `.npz` vs `.pkl` by extension, so nothing downstream of a - # tournament run breaks. Only the interactive `play_replay`/ - # `get_latest_replay_name` CLI helpers in `replay_player.py` still - # hardcode `.pkl`. + # The writer puts a replay at REPLAY_BASE_PATH / replay_name: name it so the .npz lands in + # run_dir beside the match's other files, however deep run_dir is (eval_/round_/). extra_kwargs["replay_writer_config"] = ColumnarReplayWriterConfig( - replay_name=f"{run_dir.name}/{match_tag}", overwrite_existing=True + replay_name=replay_name(run_dir, match_tag), overwrite_existing=True ) - resolved_scheme = None if control_scheme in (None, "auto") else control_scheme - - runner = StrategyRunner( - strategy=strategy_a, - opp_strategy=strategy_b, - my_team_is_yellow=True, - my_team_is_right=a_is_right, - mode="rsim", - exp_friendly=N_OUTFIELD + 1, - exp_enemy=N_OUTFIELD + 1, - exp_ball=True, - referee=referee, - enable_vision_stream=False, - referee_initial_command=initial_command, - control_scheme=resolved_scheme, + runner, _ = sim_runner( + strategy_a, + strategy_b, sim_noise=sim_noise, + initial_command=initial_command, + referee=referee, + my_team_is_right=a_is_right, + control_scheme="fpp", **extra_kwargs, ) @@ -256,6 +208,9 @@ def run_match( stats = runner.match_stats.finalize() if runner.match_stats is not None else None finally: runner.close() + for strategy in (strategy_a, strategy_b): + if isinstance(strategy, BundledStrategy): + strategy.close() return MatchResult( config_a=config_a_name, diff --git a/tools/evaluation/pools/pool_v1.json b/tools/evaluation/pools/pool_v1.json deleted file mode 100644 index febf88590..000000000 --- a/tools/evaluation/pools/pool_v1.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "version": 1, - "note": "Chosen 2026-10-17 from the 12 strategies of tournament_20261016_201213 for spread of styles, not standings. Change it only on purpose, as pool_v2.json: ratings are comparable within one pool version.", - "champion": "split_shape", - "opponents": [ - "clear_danger", - "decoy_and_overload", - "counter_flow", - "high_press", - "tiki_taka_plus", - "press_and_pass" - ], - "held_out": [ - "overload_press", - "score_aware_counter_flow", - "give_and_go_solo" - ], - "sim_noise": { - "latency_s": [0.03, 0.15], - "kick_speed_offset_sd": 0.2, - "kick_speed_sd": 0.45, - "vision": {"x_stddev": 0.0007, "y_stddev": 0.0007, "th_stddev_deg": 0.3}, - "vanishing": 0.005, - "ball_roll_decel": [0.27, 0.33], - "ball_slide_decel": [2.5, 4.0], - "kick_angle_offset_sd_deg": 1.5, - "kick_angle_sd_deg": 3.0, - "max_accel": [1.5, 3.5] - } -} diff --git a/tools/evaluation/reference/players.json b/tools/evaluation/reference/players.json new file mode 100644 index 000000000..aa4d4bf3e --- /dev/null +++ b/tools/evaluation/reference/players.json @@ -0,0 +1,5 @@ +{ + "note": "evaluate.py's players. The champion is the reference at the last release: promote a strategy by changing this line in a PR. The core plays every round; every other strategy in the catalog is reserve, played only with --all. Core chosen 2026-11-12 to cover every tactic the strategies use.", + "champion": "pendulum", + "core": ["pendulum", "breakwater", "avalanche", "mirage", "wolfpack"] +} diff --git a/tools/evaluation/reference/robots.json b/tools/evaluation/reference/robots.json new file mode 100644 index 000000000..7d2550148 --- /dev/null +++ b/tools/evaluation/reference/robots.json @@ -0,0 +1,15 @@ +{ + "note": "What the simulated robots can do: assumed good, at league level, not noise-free. Never our current robots' measurements: their shortfalls are the control layer's job. Top speed and the 4 m/s^2 acceleration cap are RSIM_PARAMS. A change here starts a new evaluation environment and replays the ledger.", + "values": { + "kick_speed_offset_sd": 0.2, + "kick_speed_sd": 0.45, + "kick_angle_offset_sd_deg": 1.5, + "kick_angle_sd_deg": 3.0 + }, + "sources": { + "kick_speed_offset_sd": "League logs, docs/sim_realism.md: team median kick speeds 4.1 to 6.3 m/s.", + "kick_speed_sd": "League logs, docs/sim_realism.md: within-team SD about 0.45 m/s.", + "kick_angle_offset_sd_deg": "Chosen with kick_angle_sd_deg to match real pass completion, docs/sim_realism.md: 0.80 at 1 degree, 0.39 at 6, real 0.50.", + "kick_angle_sd_deg": "As kick_angle_offset_sd_deg." + } +} diff --git a/tools/evaluation/reference/world.json b/tools/evaluation/reference/world.json new file mode 100644 index 000000000..4382ddd7a --- /dev/null +++ b/tools/evaluation/reference/world.json @@ -0,0 +1,17 @@ +{ + "note": "What the simulated world does, whichever robots play in it: measured, each number with its source. Would better robots change it? If so it belongs in robots.json. A change here starts a new evaluation environment and replays the ledger.", + "values": { + "latency_s": [0.05, 0.09], + "vision": {"x_stddev": 0.0007, "y_stddev": 0.0007, "th_stddev_deg": 0.3}, + "vanishing": 0.005, + "ball_roll_decel": [0.20, 0.33], + "ball_slide_decel": [2.5, 4.0] + }, + "sources": { + "latency_s": "Field logs (tools/field/field_physics.py, tools/field/field_sessions.json): command to vision about 50 to 60 ms on 2026-10-28 (2 radios, wired vision), 80 to 88 ms on 2026-10-27 (one calibration run). The range spans both.", + "vision": "League logs, docs/sim_realism.md: robot noise 0.4 to 1 mm, heading 0.2 to 0.3 degrees. Our lab's ball at rest measures 0.3 to 0.7 mm.", + "vanishing": "League logs, docs/sim_realism.md: 0.1 to 0.9% of detections missing.", + "ball_roll_decel": "Spans our carpet, about 0.20 m/s^2 (2026-10-28, 43 kicks, tools/field/field_physics.py), to the league's, about 0.29 (docs/sim_realism.md) and a little above.", + "ball_slide_decel": "docs/sim_realism.md, unchanged from the 2026-10-17 settings." + } +} diff --git a/tools/evaluation/round_robin.py b/tools/evaluation/round_robin.py deleted file mode 100644 index 5d6138941..000000000 --- a/tools/evaluation/round_robin.py +++ /dev/null @@ -1,986 +0,0 @@ -"""round_robin.py (formerly smoke_tournament.py, before that tournament.py) — Round-robin every -`build_*_kernel_strategy` config against every other, one full match per pair -(two halves, see `MAX_MATCH_SECONDS` below). This is the whole-catalog health and stall check; -a single strategy is judged with `evaluate.py`. - -Match construction (build strategies, referee, StrategyRunner, kickoff -ceremony, run_dir file layout) lives in `match.py`. - -Run: - pixi run python tools/evaluation/round_robin.py [config ...] [flags] - -Configs are short names (`tiki_taka`); none means every config not in RETIRED. Flags: - --pair A B one match, A as config_a - --reuse take unchanged matches from replays/match_cache/; check the - "N reused ... M to play" line it prints before waiting on M - --spot-check F with --reuse, replay this fraction of reused matches to verify - --strict fail on any stall - --stop-at-first-stall stop the run at the first stall - --both-sides play each pair twice, sides swapped - --control-scheme NAME planner (fpp, trajsample, ...) - --fuzz-restarts SEED inject random legal restarts; --fuzz-interval LO HI sets the gap - --sim-noise JSON seeded sim noise for every match: a SimNoise as inline JSON or a file - --match-seconds S match length in sim seconds (default 1200) - --max-workers N, --sequential, --no-save, -v/--verbose, -h/--help - -What this does --------------- -Headless rsim, no external process required. For each distinct pair of the -`build_*_kernel_strategy` factories in `utama_core.strategy.kernel_strategy`, -runs one `StrategyRunner` match (6v6: 1 goalkeeper + 5 outfield robots per -side — enough for every factory's minimum, including the `min_attack=2` -configs and `build_three_slot_kernel_strategy`'s three concurrent slots), -steps it until `CustomReferee` calls full time, and records the final -score from its scoreboard. - -Deliberately the smallest mechanism that answers "how do these configs do -against each other": a for-loop over `StrategyRunner` matches and a plain -tally, not a new `Tournament`/`Runner` class, no bracketing/seeding. Round- -robin (every pair once) rather than anything more elaborate — there are only -`C(n, 2)` pairs for the current catalog size, all of which comfortably fit -in one run. See `docs/roadmap.md`'s "Multi-strategy / tournament evaluation -infra" section for why this stays this small: the kernel's -`Strategy`/`Tactic`/`Partitioner` primitives already solve the "many things -owning dynamic robot subsets" problem this would otherwise need to -reinvent — a tournament script is purely a driver on top of -`StrategyRunner`'s existing `opp_strategy` support, not a new mechanism. - -Every run records the full observability stack (structured intention log, -aggregate stats, replay trail — see `utama_core.engine.match_log`/ -`match_stats`, `utama_core.replay`) per match under -`replays/tournament_/`, plus one `summary.json` for the whole -run — on by default, since it's cheap and is what a tournament run is -usually for. Pass `--no-save` for a quick throwaway run (e.g. a smoke test -of a code change) that doesn't need the trace kept afterward — replays in -particular can be tens to hundreds of MB per match, and a `--no-save` run -that's forgotten about is exactly how `replays/` silently filled up with -unreferenced gigabytes before (cleaned up 2026-08-26; see -`docs/STRATEGY_DEVELOPMENT.md`'s Observability section). `--verbose`/`-v` -also prints a possession/shots/ball-travel line per match as it completes, -independent of `--no-save`. - -`--both-sides` plays each pair twice — once with each config as -`config_a` (yellow, defending the right goal in the first half per `run_match`'s -hardcoded `my_team_is_yellow=True, my_team_is_right=True`; the teams change ends at -half-time) — instead of -once. This isn't a repeat: the sim's initial formation and every -`my_team_is_right`-relative geometry call (`enemy_goal_line`, defense-area -clamps, etc.) genuinely differ by side, so re-running the exact same pair -gives a byte-identical result (fixed initial formation, no RNG source that -varies run to run) while swapping which config plays which side gives a -real second data point per pair — the smallest available source of -variance reduction without inventing a noise model. Off by default since it -doubles match count. -""" - -from __future__ import annotations - -import os - -# Prevent multi-process thread oversubscription across OpenBLAS, MKL, OpenMP, NumExpr -os.environ.setdefault("OMP_NUM_THREADS", "1") -os.environ.setdefault("OPENBLAS_NUM_THREADS", "1") -os.environ.setdefault("MKL_NUM_THREADS", "1") -os.environ.setdefault("NUMEXPR_NUM_THREADS", "1") - -import dataclasses -import itertools -import json -import subprocess -import sys -from concurrent.futures import ProcessPoolExecutor, as_completed -from datetime import datetime, timezone -from pathlib import Path -from typing import Optional - -REPO_ROOT = Path(__file__).resolve().parents[2] -if str(REPO_ROOT) not in sys.path: - sys.path.insert(0, str(REPO_ROOT)) - -from tools.evaluation.match import ( # noqa: F401 -- re-exported for callers importing this module - _CONFIG_NAMES, - N_OUTFIELD, - OUTFIELD_ROBOT_IDS, - TICKS_PER_SECOND, - MatchResult, - _short_name, - _stats_to_dict, -) -from tools.evaluation.match import run_match as _lib_run_match -from utama_core.analysis import ratings, restart_outcomes, turnover_breakdown -from utama_core.analysis.strategy_table import strategy_table -from utama_core.config.settings import REPLAY_BASE_PATH -from utama_core.replay import eval_ledger, match_cache -from utama_core.replay.fingerprint import CodeGraph, match_key -from utama_core.rsoccer_simulator.src.Utils.sim_noise import SimNoise - -# Left out of a round-robin unless named: the bottom ten of the 2026-10-05 full round-robin -# (docs/strategies.md). Their code stays, since kept strategies and tests build on some of them. -# Named here, outside the match cache key, so retiring one reruns nothing. -RETIRED = { - "build_tiki_taka_kernel_strategy", - "build_counter_press_kernel_strategy", - "build_high_line_zone_kernel_strategy", - "build_three_slot_kernel_strategy", - "build_switch_of_play_kernel_strategy", - "build_low_block_kernel_strategy", - "build_zone_fluid_kernel_strategy", - "build_score_aware_zone_flow_kernel_strategy", - "build_overload_flow_kernel_strategy", - "build_shadow_switch_kernel_strategy", -} - -# A full match, as the rulebook has it: two halves of 300 s of playing time, the clock stopped -# whenever no team may play the ball (`custom_referee/state_machine.py`), so about 710 s of -# sim time (785 s in two measured matches, tournament_20261006_111922). config_a starts on the -# right and kicks off the first half; at half-time the teams change ends and config_b kicks -# off the second. Without `--both-sides` each pair plays once. Shorter matches rank differently: 65s matches were -# 55% draws, and 16 of 40 full matches (replays/tournament_20261003_102921) changed -# result after 180s, enough to reorder the top of the table. rsim is deterministic, so -# a short match is exactly the start of the full one; it just stops before it's decided. -# This only caps a match that can't reach full time (most took under 870 s of sim time). -MAX_MATCH_SECONDS = 1200.0 - - -def run_match( - config_a_name: str, - config_b_name: str, - run_dir: Optional[Path] = None, - control_scheme: str = "fpp", - fuzz_seed: Optional[int] = None, - fuzz_interval_s: tuple[float, float] = (25.0, 45.0), - max_match_seconds: float = MAX_MATCH_SECONDS, - sim_noise: Optional[SimNoise] = None, -) -> MatchResult: - """Play one full match (capped at `max_match_seconds`), config_a - fixed to the right side and kickoff (this module's historical, un-swept - convention). Thin wrapper over `match.run_match`; see its - docstring for what each parameter does. - """ - return _lib_run_match( - config_a_name, - config_b_name, - duration_seconds=max_match_seconds, - run_dir=run_dir, - control_scheme=control_scheme, - fuzz_seed=fuzz_seed, - fuzz_interval_s=fuzz_interval_s, - sim_noise=sim_noise, - ) - - -def main() -> None: - # Optional CLI args: config names (with or without the `build_`/ - # `_kernel_strategy` wrapping) to run instead of the full auto-discovered - # catalog — useful for a quick check of one or two configs without - # waiting on every pair, e.g. `python tools/evaluation/round_robin.py default - # low_block`. `--sequential` forces the old one-process-at-a-time loop - # (useful for debugging a specific match without pool noise); otherwise - # matches run in a process pool since each `run_match` call is fully - # self-contained (its own StrategyRunner, its own rSim subprocess, no - # shared state with any other match) — this is the "many independent - # matches" case, not the harder "parallelize robots within one match" - # case (shared per-tick obstacle state, GIL-bound Python, would need its - # own design). No args keeps today's behaviour: every config, once each. - # `--max-workers N` caps the pool size, e.g. to leave headroom on a shared - # machine — os.cpu_count() ignores CPU affinity/cgroup limits, so a - # `taskset`-restricted run would otherwise still size the pool for all - # cores and oversubscribe. - # `--pair A B` plays just that one fixture, A as config_a. - # `--both-sides` plays every pair twice, once with each config on each - # side — see the module docstring for why this is real variance - # reduction rather than a duplicate match. - # `--control-scheme NAME` runs every match with that motion-control scheme - # (e.g. `fpp`, `dwa`, `trajsample` — see - # utama_core.motion_planning.src.common.control_schemes) on both sides - # instead of StrategyRunner's default `fpp`. This script compares - # strategies against each other, not planners against each other, so - # there's a single scheme per run rather than a per-side override. - # `--verbose`/`-v` prints each match's possession/shots/ball-travel line - # alongside the score. The full observability stack (intention log, full - # stats JSON, replay trail — see `utama_core.engine.match_log`/ - # `match_stats`, `utama_core.replay`) is recorded by default, under - # `replays/tournament_/`: it's cheap per match and is the - # point of running a tournament at all — a bare win/loss tally without - # the trace behind it was exactly what made the earlier scoreless-match - # investigations start from zero every time. `--no-save` skips all of - # it (no run_dir created, no summary.json) for a throwaway smoke-test - # run that doesn't need to be analyzed afterward. - # `--fuzz-restarts SEED` swaps in `RestartFuzzingReferee` for every match - # in this run (see docs/custom_referee.md's "Restart fuzzing" section / - # `utama_core/custom_referee/restart_fuzzer.py`), injecting extra - # seeded-random legal restarts during live play so referee auto-advance - # paths get exercised far more often than natural play alone triggers - # them. `--fuzz-interval LO HI` sets the sim-second gap range between - # injections (default 25-45s); both are recorded in summary.json - # (`fuzz_seed`/`fuzz_interval_s`, null when off) so a fuzzed run is - # reproducible from the summary alone. - # `--stop-at-first-stall` exits as soon as any match records a - # `StallEvent`, instead of finishing all `C(n, 2)` pairs — for iterating - # on a stall fix without waiting ~40 minutes for the full round-robin; - # rsim is deterministic, so the first stall found for a given - # catalog/seed/control-scheme reproduces the same way every run. Implies - # `--strict`. In pool mode, in-flight matches still finish (their cost is - # already sunk) but no further matches are submitted. - # `--reuse` takes a match's result from `replays/match_cache/` instead of - # playing it when nothing that match runs has changed since it was stored - # (`utama_core.replay.fingerprint.match_key`; rsim is deterministic, so the - # stored result is what the match would play). After a change to one - # strategy only its matches play. `--spot-check F` (default 0.05) also - # replays that fraction of the reusable matches, at least one, and compares - # them with their stored records: a difference means the fingerprint missed - # a dependency, is printed loudly, evicts those records, and fails `--strict`. - args = sys.argv[1:] - if "-h" in args or "--help" in args: - print(__doc__) - return - sequential = "--sequential" in args - args = [a for a in args if a != "--sequential"] - verbose = "--verbose" in args or "-v" in args - args = [a for a in args if a not in ("--verbose", "-v")] - both_sides = "--both-sides" in args - args = [a for a in args if a != "--both-sides"] - max_workers_override: int | None = None - if "--max-workers" in args: - idx = args.index("--max-workers") - max_workers_override = int(args[idx + 1]) - args = args[:idx] + args[idx + 2 :] - no_save = "--no-save" in args - args = [a for a in args if a != "--no-save"] - reuse = "--reuse" in args - args = [a for a in args if a != "--reuse"] - spot_check = 0.05 - if "--spot-check" in args: - idx = args.index("--spot-check") - spot_check = float(args[idx + 1]) - args = args[:idx] + args[idx + 2 :] - if reuse and no_save: - # A stored record is a recorded match's (the match log and stats recorder - # live), and the post-run analyses it carries are read from saved replays. - raise SystemExit("--reuse stores and reads recorded matches; drop --no-save") - # `--strict` exits non-zero when any match in this run recorded a stall - # event (see the STALLS section below) — for CI/pre-merge gating, so a - # stall regression fails the run instead of only showing up if someone - # reads the printed section or summary.json by hand. - strict = "--strict" in args - args = [a for a in args if a != "--strict"] - # `--stop-at-first-stall` exits the round-robin as soon as any match - # records a `StallEvent`, instead of running all `C(n, 2)` pairs — for - # iterating on a stall fix, where the other ~230 matches add nothing - # once one reproduction is in hand (rsim is deterministic, so the first - # stall found for a given catalog/seed/control-scheme is stable across - # runs). Implies `--strict`, since the point of stopping early is to - # fail fast, not to keep going and report success. Standings/STALLS - # output below still reflects however many matches actually ran. - stop_at_first_stall = "--stop-at-first-stall" in args - args = [a for a in args if a != "--stop-at-first-stall"] - strict = strict or stop_at_first_stall - if stop_at_first_stall and no_save: - # Stall detection reads `MatchResult.stats`, which is only populated - # when `run_match` gets a `stats_path` — i.e. never under `--no-save` - # (see `run_match`'s `extra_kwargs` construction). Combined with - # `--no-save`, `_stalled()` would be unconditionally False for every - # match, so this run-forever's fast-exit would silently never fire — - # worse than a no-op, since it would look like a clean run. `--strict` - # alone has this same gap but degrades to "did nothing", which is - # already documented above; `--stop-at-first-stall`'s entire point is - # to fire, so make the misuse loud instead. - raise SystemExit("--stop-at-first-stall requires stats collection; drop --no-save") - control_scheme = "fpp" - if "--control-scheme" in args: - idx = args.index("--control-scheme") - control_scheme = args[idx + 1] - args = args[:idx] + args[idx + 2 :] - # `--fuzz-restarts SEED` runs every match with `RestartFuzzingReferee` - # instead of plain `CustomReferee`, injecting extra seeded-random legal - # restarts during live play (see docs/custom_referee.md's "Restart - # fuzzing" section / restart_fuzzer.py). Same seed -> identical injection - # schedule (kind, team, sim time), so a run is reproducible. - fuzz_seed: Optional[int] = None - if "--fuzz-restarts" in args: - idx = args.index("--fuzz-restarts") - fuzz_seed = int(args[idx + 1]) - args = args[:idx] + args[idx + 2 :] - # `--fuzz-interval LO HI` sets the (sim-second) gap range between - # injections when `--fuzz-restarts` is on. Default 25-45s: about 17 - # injections over a full match, not the 8-20s range in - # RestartFuzzingReferee's own docstring, which is a stress-test example, - # not a sane default for a normal round-robin. - fuzz_interval_s: tuple[float, float] = (25.0, 45.0) - if "--fuzz-interval" in args: - idx = args.index("--fuzz-interval") - fuzz_interval_s = (float(args[idx + 1]), float(args[idx + 2])) - args = args[:idx] + args[idx + 3 :] - - # `--sim-noise JSON` plays every match with the same seeded latency, kick speed and direction - # noise, ball friction, per-robot motion limits and vision noise: a `SimNoise` as inline JSON or - # a path to a JSON file, e.g. '{"seed": 1, "latency_s": [0.05, 0.1], "kick_speed_sd": 0.3}' - # (field list in `SimNoise`'s docstring). Every pairing gets the same - # draws (they depend on colour and robot id, not strategy), so standings stay paired. - sim_noise: Optional[SimNoise] = None - if "--sim-noise" in args: - idx = args.index("--sim-noise") - spec = args[idx + 1] - sim_noise = SimNoise.from_dict(json.loads(Path(spec).read_text() if Path(spec).is_file() else spec)) - args = args[:idx] + args[idx + 2 :] - sim_noise_dict = sim_noise.to_dict() if sim_noise is not None else None - - match_seconds = MAX_MATCH_SECONDS - if "--match-seconds" in args: - idx = args.index("--match-seconds") - match_seconds = float(args[idx + 1]) - args = args[:idx] + args[idx + 2 :] - - # `--pair A B` plays exactly one fixture, A as config_a (yellow, right side - # and kickoff in the first half) -- e.g. to rerun one stalled match from a round-robin, which - # reproduces exactly since rsim is deterministic. - pair: Optional[tuple[str, str]] = None - if "--pair" in args: - idx = args.index("--pair") - pair = (args[idx + 1], args[idx + 2]) - args = args[:idx] + args[idx + 3 :] - if args: - raise SystemExit(f"--pair takes no other config names: {args}") - - if pair is not None: - config_names = _resolve_config_names(list(pair)) - pairs = [tuple(_resolve_config_names([name])[0] for name in pair)] - else: - if args: - config_names = _resolve_config_names(args) - if len(config_names) < 2: - raise SystemExit("Need at least 2 configs to play a round-robin.") - else: - config_names = [name for name in _CONFIG_NAMES if name not in RETIRED] - - base_pairs = list(itertools.combinations(sorted(config_names), 2)) - # --both-sides plays (a, b) and (b, a) as distinct fixtures — see the - # module docstring for why this is a real second data point (side- - # dependent geometry) rather than a duplicate, unlike naively re-running - # the same pair (which is byte-identical: fixed initial formation, no - # varying RNG source). - pairs = [(a, b) for a, b in base_pairs] + ([(b, a) for a, b in base_pairs] if both_sides else []) - - run_id = datetime.now(timezone.utc).strftime("tournament_%Y%m%d_%H%M%S") - run_dir: Optional[Path] = None - if not no_save: - run_dir = REPLAY_BASE_PATH / run_id - run_dir.mkdir(parents=True, exist_ok=True) - - all_pairs = pairs - - def _keys() -> dict[tuple[str, str], str]: - graph = CodeGraph() - return { - (a, b): match_key( - graph, - a, - b, - duration_seconds=match_seconds, - control_scheme=control_scheme, - fuzz_seed=fuzz_seed, - fuzz_interval_s=fuzz_interval_s, - sim_noise=sim_noise_dict, - ) - for a, b in all_pairs - } - - cache = match_cache.MatchCache() - keys: dict[tuple[str, str], str] = _keys() if reuse else {} - stored = {p: rec for p in pairs if reuse and (rec := cache.get(keys[p])) is not None} - spot_checked = { - p for p in stored if keys[p] in match_cache.spot_check_sample([keys[q] for q in stored], spot_check) - } - reused = {p: rec for p, rec in stored.items() if p not in spot_checked} - pairs = [p for p in pairs if p not in reused] - - print( - f"Round-robin: {len(config_names)} configs, {len(all_pairs)} matches" + (" (both sides)" if both_sides else "") - ) - if reuse: - print( - f"--reuse: {len(reused)} stored result(s) reused, {len(spot_checked)} replayed as a spot-check, " - f"{len(pairs) - len(spot_checked)} to play" - ) - print(f"{N_OUTFIELD + 1}v{N_OUTFIELD + 1}, two 300 s halves of playing time per match, headless rsim") - if no_save: - print("--no-save: not recording replay/intention-log/stats for this run") - else: - print(f"Recording to replays/{run_id}/ (per-match replay, intention log, stats)") - if not sequential: - default_workers = min(12, max(1, (os.cpu_count() or 1) - 1)) - n_workers = max(1, min(len(pairs), max_workers_override or default_workers)) - print(f"Running {n_workers} matches concurrently (--sequential to disable)\n") - else: - print("Running sequentially\n") - - results: list[MatchResult] = [] - wins: dict[str, int] = {name: 0 for name in config_names} - draws: dict[str, int] = {name: 0 for name in config_names} - - def _stats_line(result: MatchResult) -> str: - if not result.stats: - return "" - s = result.stats - poss = s["possession_pct"] - shots = s["shots"] - return ( - f" possession {poss['friendly']:.0%}/{poss['enemy']:.0%} " - f"shots {shots['friendly']}-{shots['enemy']} " - f"ball_travel {s['ball_travel_m']:.1f}m " - f"turnovers {s['turnovers']} completed_passes {s['completed_passes']} " - f"attacking_third_entries {s['attacking_third_entries']}" - ) - - def _stalled(result: MatchResult) -> bool: - return bool(result.stats and result.stats.get("stall_events")) - - def _record(result: MatchResult) -> None: - results.append(result) - if result.winner == "draw": - draws[result.config_a] += 1 - draws[result.config_b] += 1 - else: - wins[result.winner] += 1 - print( - f"{result.config_a:<40} {result.score_a} - {result.score_b} " - f"{result.config_b:<40} winner={result.winner}", - flush=True, - ) - if verbose: - line = _stats_line(result) - if line: - print(line, flush=True) - - # Each played match's restart and ball-loss analyses, made as it finishes: the end of the run - # reads them from here rather than replaying every saved match again. - analysed: dict[str, tuple[list[dict], dict]] = {} - - def _analyse(result: MatchResult) -> None: - # Stored in the match cache straight away too, not only once the whole run ends, so a crash - # (WSL running out of memory killed two runs on 2026-10-09) loses only the matches still - # playing. A spot-checked match is left to `_store_played`, which compares it with its - # stored record; so is any match whose key changed since the run started (code edited mid-run). - pair = (result.config_a, result.config_b) - npz = run_dir / f"{_tag(pair)}.npz" if run_dir is not None else None - if npz is None or not npz.exists(): # no run dir, or crashed without a replay - return - restarts = restart_outcomes.analyse_match(npz) - losses = turnover_breakdown.analyse_match(str(npz)) - analysed[_tag(pair)] = (restarts, losses) - if reuse and pair not in spot_checked and _keys()[pair] == keys[pair]: - cache.put(keys[pair], {"result": dataclasses.asdict(result), "restarts": restarts, "losses": losses}) - - for (a, b), rec in reused.items(): - _record(MatchResult(**rec["result"])) - - if sequential: - for config_a_name, config_b_name in pairs: - match_kwargs = { - "run_dir": run_dir, - "control_scheme": control_scheme, - "fuzz_seed": fuzz_seed, - "fuzz_interval_s": fuzz_interval_s, - } - if match_seconds != MAX_MATCH_SECONDS: - match_kwargs["max_match_seconds"] = match_seconds - if sim_noise is not None: - match_kwargs["sim_noise"] = sim_noise - result = run_match( - config_a_name, - config_b_name, - **match_kwargs, - ) - _record(result) - _analyse(result) - if stop_at_first_stall and _stalled(result): - tag = f"{_short_name(result.config_a)}_vs_{_short_name(result.config_b)}" - print(f"\n--stop-at-first-stall: stopping after {tag}", flush=True) - break - else: - # Matches complete out of submission order under a process pool — - # printed as they finish rather than buffered back into pair order, - # since waiting to preserve order would throttle everything to the - # slowest in-flight match. Final standings are still sorted, so the - # only user-visible reordering is the interleaved progress log. - with ProcessPoolExecutor(max_workers=n_workers) as pool: - futures = [ - pool.submit( - run_match, a, b, run_dir, control_scheme, fuzz_seed, fuzz_interval_s, match_seconds, sim_noise - ) - for a, b in pairs - ] - for future in as_completed(futures): - result = future.result() - _record(result) - _analyse(result) - if stop_at_first_stall and _stalled(result): - tag = f"{_short_name(result.config_a)}_vs_{_short_name(result.config_b)}" - print( - f"\n--stop-at-first-stall: stopping after {tag} " - "(in-flight matches still finish; not resubmitted)", - flush=True, - ) - for fut in futures: - fut.cancel() - break - - print("\nStandings (wins, draws):") - for name in sorted(config_names, key=lambda n: (-wins[n], -draws[n])): - print(f" {name:<40} {wins[name]}W {draws[name]}D") - - # STALLS: every match that recorded a `StallEvent` (see - # `utama_core.engine.match_stats`'s RESTART_STALL/COMMITTED_FROZEN - # watchdogs), plus a heuristic backstop for anything the watchdog itself - # missed — possession pinned at 100%/0% with almost no ball movement is - # exactly the signature a stalled match showed before this watchdog - # existed (see this module's/`match_stats.py`'s docs). Both are printed - # together since they answer the same question ("did this run stall - # anywhere") and both go into summary.json per match either way. - def _match_tag_of(r: MatchResult) -> str: - return f"{_short_name(r.config_a)}_vs_{_short_name(r.config_b)}" - - stalled_matches: list[tuple[MatchResult, list[dict]]] = [] - backstop_matches: list[MatchResult] = [] - for r in results: - if not r.stats: - continue - events = r.stats.get("stall_events") or [] - if events: - stalled_matches.append((r, events)) - poss = r.stats.get("possession_pct") or {} - pinned = (poss.get("friendly") == 1.0 and poss.get("enemy") == 0.0) or ( - poss.get("friendly") == 0.0 and poss.get("enemy") == 1.0 - ) - if pinned and (r.stats.get("ball_travel_m") or 0.0) < 1.0: - backstop_matches.append(r) - - stalled_match_ids = {id(r) for r, _ in stalled_matches} - incidents = stall_incidents([{"config_a": r.config_a, "config_b": r.config_b, "stats": r.stats} for r in results]) - if stalled_matches or backstop_matches: - print(f"\nSTALLS: {len(stalled_matches)} match(es), {len(incidents)} distinct incident(s)") - for r, events in stalled_matches: - for e in events: - tactic_str = f" tactics={e['tactic_ids']}" if e["tactic_ids"] else "" - diagnosis = f" -- {e['diagnosis']}" if e.get("diagnosis") else "" - print( - f" {_match_tag_of(r):<50} {e['kind']:<17} onset t={e['sim_time']:.1f}s " - f"referee={e['referee_command']}{tactic_str}{diagnosis}" - ) - for r in backstop_matches: - if id(r) in stalled_match_ids: - continue - poss = r.stats["possession_pct"] - print( - f" {_match_tag_of(r):<50} {'POSSESSION_BACKSTOP':<17} " - f"possession {poss['friendly']:.0%}/{poss['enemy']:.0%} " - f"ball_travel {r.stats['ball_travel_m']:.2f}m" - ) - else: - print("\nSTALLS: none") - - backstop_match_ids = {id(r) for r in backstop_matches} - summary = { - "run_id": run_id, - "run": _run_metadata(), - "config_names": sorted(config_names), - "control_scheme": control_scheme, - "max_match_seconds": match_seconds, - "fuzz_seed": fuzz_seed, - "fuzz_interval_s": list(fuzz_interval_s) if fuzz_seed is not None else None, - "sim_noise": sim_noise_dict, - "results": [ - { - "config_a": r.config_a, - "config_b": r.config_b, - "score_a": r.score_a, - "score_b": r.score_b, - "winner": r.winner, - "stats": r.stats, - "possession_backstop": id(r) in backstop_match_ids, - "reused": (r.config_a, r.config_b) in reused, - } - for r in results - ], - "standings": {name: {"wins": wins[name], "draws": draws[name]} for name in config_names}, - "stalled_match_count": len(stalled_matches), - "stall_incidents": incidents, - "possession_backstop_match_count": len(backstop_matches), - "reuse": ( - {"reused": len(reused), "spot_checked": len(spot_checked), "played": len(pairs) - len(spot_checked)} - if reuse - else None - ), - } - real_losses_by_match: Optional[dict[str, dict[str, int]]] = None - chances_by_match: dict[str, dict] = {} - mismatches: list[tuple[str, str]] = [] - if run_dir is not None: - summary_path = run_dir / "summary.json" - with open(summary_path, "w") as f: - json.dump(summary, f, indent=2) - # RESTARTS: what became of every restart -- taken, or voided/stopped/timed out. - restarts_by_match = {tag: restarts for tag, (restarts, _) in analysed.items()} - restarts_by_match.update({_tag(p): rec["restarts"] for p, rec in reused.items()}) - summary["restarts"] = restart_outcomes.summarise( - [e for m in sorted(restarts_by_match) for e in restarts_by_match[m]] - ) - _print_restarts(summary["restarts"]) - # BALL LOSSES: how the friendly side (config_a) gave the ball away, by kind, foul rule - # and tactic — `MatchStats.turnovers` alone is mostly two robots on one ball flipping - # "nearest robot". Analysed as each match finished (`_analyse`). - losses = [loss for _, loss in analysed.values()] - losses = sorted(losses + [rec["losses"] for rec in reused.values()], key=lambda r: r["match"]) - if reuse: - mismatches = _store_played( - cache, keys, _keys(), results, reused, spot_checked, stored, restarts_by_match, losses - ) - # Kept in the summary, not only printed: a spot-check is also the run's check that - # rsim replays a match exactly. Mismatches were seen once (2026-09-23, under load - # ~30) and not reproduced since; a non-empty list is the evidence to chase. - summary["reuse"]["mismatches"] = sorted(_tag(p) for p in mismatches) - if losses: # no replays saved (e.g. every match crashed): nothing to break down - summary["ball_losses"] = turnover_breakdown.breakdown(losses) - (run_dir / "ball_losses.md").write_text(turnover_breakdown.report(run_id, losses, summary)) - _print_ball_losses(summary["ball_losses"], run_id) - real_losses_by_match = {r["match"]: turnover_breakdown.real_loss_kinds(r) for r in losses} - # Records stored before chances were measured have none: their matches are left out. - chances_by_match = {r["match"]: r["chances"] for r in losses if "chances" in r} - - summary["strategies"] = strategy_table(summary["results"], real_losses_by_match, chances_by_match) - _print_strategy_table(summary["strategies"]) - summary["ratings"] = _ratings(summary["results"]) - _print_loss_kinds(summary["strategies"]) - _print_chances(summary["strategies"]) - summary["fouls"] = foul_table(summary["results"]) - _print_foul_table(summary["fouls"]) - _print_motion_planning_table(summary["strategies"]) - if run_dir is not None: - with open(summary_path, "w") as f: - json.dump(summary, f, indent=2) - print(f"\nFull results + stats: replays/{run_id}/summary.json") - _append_to_ledger(results, run_id, match_seconds, control_scheme, fuzz_seed, sim_noise_dict) - - if strict and reuse and mismatches: - raise SystemExit(f"--strict: {len(mismatches)} spot-checked match(es) differ from their stored records") - if strict and (stalled_matches or backstop_matches): - raise SystemExit( - f"--strict: {len(stalled_matches)} match(es) with stall events, " - f"{len(backstop_matches)} match(es) flagged by the possession backstop" - ) - - -def _append_to_ledger( - results: list[MatchResult], - run_id: str, - match_seconds: float, - control_scheme: str, - fuzz_seed: Optional[int], - sim_noise_dict: Optional[dict], -) -> None: - """Add the run's matches to the evaluation ledger (`replay/eval_ledger.py`), so - `evaluate.py`'s ratings count them. Only matches in `evaluate.py`'s setting: config_a on - the right kicking off, no restart fuzzing.""" - if fuzz_seed is not None: - return - graph = CodeGraph() - env = eval_ledger.environment( - graph, duration_seconds=match_seconds, sim_noise=sim_noise_dict, control_scheme=control_scheme - ) - seed = sim_noise_dict.get("seed") if sim_noise_dict else None - eval_ledger.append( - ( - eval_ledger.entry(env, graph, dataclasses.asdict(r), seed, source=run_id) - for r in results - if r.a_is_right and r.a_kicks_off - ), - Path(REPLAY_BASE_PATH) / "eval" / "ledger.jsonl", # this module's, so tests can redirect it - ) - - -def _tag(pair: tuple[str, str]) -> str: - """A match's file stem in a run directory (`match.run_match`'s `match_tag`).""" - return f"{_short_name(pair[0])}_vs_{_short_name(pair[1])}" - - -def _store_played( - cache: match_cache.MatchCache, - keys: dict[tuple[str, str], str], - keys_now: dict[tuple[str, str], str], - results: list[MatchResult], - reused: dict, - spot_checked: set, - stored: dict, - restarts_by_match: dict[str, list[dict]], - losses: list[dict], -) -> list[tuple[str, str]]: - """Store every match this run played, and compare each spot-checked one with its stored - record. Returns the spot-checked pairs that differ; their records are evicted, not - replaced, since their key no longer names one result, and so is every record this run - reused. Stores nothing if any key changed while the run played (code edited mid-run).""" - if keys_now != keys: - print("\n--reuse: the code changed while this run played; storing nothing", flush=True) - return [] - losses_by_match = {r["match"]: r for r in losses} - mismatches: list[tuple[str, str]] = [] - for r in results: - pair = (r.config_a, r.config_b) - if pair in reused or _tag(pair) not in losses_by_match: # reused, or crashed without a replay - continue - record = { - "result": dataclasses.asdict(r), - "restarts": restarts_by_match.get(_tag(pair), []), - "losses": losses_by_match[_tag(pair)], - } - if pair in spot_checked: - parts = match_cache.differences(stored[pair], record) - if parts: - mismatches.append(pair) - cache.evict(keys[pair]) - print( - f"\n*** --reuse SPOT-CHECK MISMATCH: {_tag(pair)} differs from its stored record in {parts}. " - "The fingerprint missed something this match depends on; its record is evicted. ***", - flush=True, - ) - continue - cache.put(keys[pair], record) - if spot_checked: - print(f"\n--reuse: spot-check {len(spot_checked) - len(mismatches)}/{len(spot_checked)} identical", flush=True) - if mismatches: - # The records this run reused were trusted on the same fingerprints that just failed. - for pair in reused: - cache.evict(keys[pair]) - print( - f"*** --reuse: this run's {len(reused)} reused result(s) are evicted too and its standings can't be " - "trusted; rerun without --reuse. ***", - flush=True, - ) - return mismatches - - -def _resolve_config_names(requested_names: list[str]) -> list[str]: - """Factory names for `requested_names`, each given with or without the - `build_`/`_kernel_strategy` wrapping, in catalog order.""" - requested = set(requested_names) - config_names = [ - name - for name in _CONFIG_NAMES - if name in requested or name.removeprefix("build_").removesuffix("_kernel_strategy") in requested - ] - unmatched = requested - { - n for name in config_names for n in (name, name.removeprefix("build_").removesuffix("_kernel_strategy")) - } - if unmatched: - raise SystemExit(f"Unknown config name(s): {sorted(unmatched)}. Available: {sorted(_CONFIG_NAMES)}") - return config_names - - -def _run_metadata() -> dict: - """What produced this run: enough to reproduce it or line it up against another.""" - - def git(*args: str) -> Optional[str]: - try: - out = subprocess.run(["git", *args], capture_output=True, text=True, check=True, cwd=Path(__file__).parent) - except (OSError, subprocess.CalledProcessError): - return None - return out.stdout.strip() - - status = git("status", "--porcelain", "--untracked-files=no") - return { - "git_commit": git("rev-parse", "HEAD"), - "git_dirty": bool(status) if status is not None else None, - "argv": sys.argv[1:], - "started_utc": datetime.now(timezone.utc).isoformat(timespec="seconds"), - } - - -def stall_incidents(results: list[dict]) -> list[dict]: - """Stall events over `summary.json`-shaped `results`, with deterministic duplicates - merged: the same kind, onset tick and duration tick in matches that share a strategy - is one freeze seen against two opponents that hadn't diverged yet (rsim is - deterministic), not two separate problems. In order of first appearance.""" - incidents: list[dict] = [] - by_key: dict[tuple, dict] = {} - for r in results: - tag = f"{_short_name(r['config_a'])}_vs_{_short_name(r['config_b'])}" - for e in (r.get("stats") or {}).get("stall_events") or []: - ticks = (e["kind"], round(e["sim_time"] * TICKS_PER_SECOND), round(e["duration_s"] * TICKS_PER_SECOND)) - keys = [(name, *ticks) for name in (r["config_a"], r["config_b"])] - incident = next((by_key[k] for k in keys if k in by_key), None) - if incident is None: - incident = {"kind": e["kind"], "sim_time": e["sim_time"], "duration_s": e["duration_s"], "matches": []} - incidents.append(incident) - if tag not in incident["matches"]: - incident["matches"].append(tag) - for k in keys: - by_key.setdefault(k, incident) - return incidents - - -def _print_restarts(restarts: dict) -> None: - if not restarts["restarts"]: - return - print( - f"\nRESTARTS: {restarts['restarts']}, {restarts['reached_normal_start'] / restarts['restarts']:.0%} " - "reached NORMAL_START" - ) - for kind, row in restarts["by_kind"].items(): - outcomes = ", ".join(f"{k} {n}" for k, n in row["outcomes"].items()) - print(f" {kind:<16} {row['n']:>4} reached {row['reached_normal_start'] / row['n']:>4.0%} {outcomes}") - - -def foul_table(results: list[dict]) -> dict[str, dict]: - """Every logged foul (`MatchStats.fouls`, both sides) by rule, then by - "strategy/tactic" of the offending robot. `inferred` counts fouls whose rule only - named a team, attributed to that side's robot nearest the ball.""" - table: dict[str, dict] = {} - for r in results: - for foul in (r.get("stats") or {}).get("fouls") or []: - strategy = _short_name(r["config_a"] if foul["side"] == "friendly" else r["config_b"]) - row = table.setdefault(foul["rule"], {"total": 0, "inferred": 0, "by_tactic": {}}) - row["total"] += 1 - row["inferred"] += bool(foul["inferred"]) - key = f"{strategy}/{foul['tactic'] or 'unknown'}" - row["by_tactic"][key] = row["by_tactic"].get(key, 0) + 1 - for row in table.values(): - row["by_tactic"] = dict(sorted(row["by_tactic"].items(), key=lambda kv: -kv[1])) - return dict(sorted(table.items(), key=lambda kv: -kv[1]["total"])) - - -def _print_foul_table(table: dict[str, dict]) -> None: - if not table: - return - print("\nFOULS (both sides; top strategy/tactic of the offending robot; * = rule named only a team):") - for rule, row in table.items(): - top = ", ".join(f"{k} {c}" for k, c in list(row["by_tactic"].items())[:4]) - star = "*" if row["inferred"] else "" - print(f" {rule + star:<30} {row['total']:>5} {top}") - - -def _print_strategy_table(table: dict[str, dict]) -> None: - print("\nSTRATEGIES (per match; losses = real ball losses, as config_a only):") - print( - f" {'strategy':<32} {'W-D-L':>9} {'GF':>5} {'GA':>5} {'shots':>6} {'passes':>7} {'entries':>8} {'fouls':>6} {'losses':>7} {'stalled':>8}" - ) - for name, t in sorted(table.items(), key=lambda kv: (-kv[1]["wins"], -kv[1]["draws"])): - n = max(1, t["matches"]) - losses = f"{t['real_losses_as_a'] / t['matches_as_a']:.1f}" if t["matches_as_a"] else "-" - print( - f" {_short_name(name):<32} {t['wins']:>3}-{t['draws']}-{t['losses']:<3} {t['goals_for'] / n:>5.2f} " - f"{t['goals_against'] / n:>5.2f} {t['shots'] / n:>6.2f} {t['completed_passes'] / n:>7.1f} " - f"{t['attacking_third_entries'] / n:>8.1f} {t['fouls'] / n:>6.1f} {losses:>7} {t['stalled']:>8}" - ) - - -def _ratings(results: list[dict]) -> dict[str, dict[str, float]]: - """Each config's strength from goal margins, with its SD (`analysis.ratings`).""" - fit = ratings.fit([(r["config_a"], r["config_b"], r["score_a"] - r["score_b"]) for r in results]) - return {n: dict(zip(("strength", "sd"), (round(v, 2) for v in fit.strength(n)))) for n in fit.names} - - -def _print_loss_kinds(table: dict[str, dict]) -> None: - """Real ball losses per match as config_a, by kind: where each strategy gives the ball away.""" - rows = {name: t for name, t in table.items() if t["matches_as_a"]} - if not rows: - return - totals: dict[str, int] = {} - for t in rows.values(): - for kind, n in t["real_loss_kinds_as_a"].items(): - totals[kind] = totals.get(kind, 0) + n - kinds = sorted(totals, key=lambda k: -totals[k]) - short = { - "shot_saved_or_blocked": "shot_saved", - "ball_out_after_kick": "out_kick", - "ball_out_other": "out_other", - "pass_intercepted": "intercepted", - "loose_ball_lost": "loose_lost", - } - print("\nLOSS KINDS (real ball losses per match as config_a, by kind; see ball_losses.md):") - print(f" {'strategy':<32} " + " ".join(f"{short.get(k, k)[:11]:>11}" for k in kinds)) - for name, t in sorted(rows.items(), key=lambda kv: -kv[1]["real_losses_as_a"] / kv[1]["matches_as_a"]): - n = t["matches_as_a"] - print( - f" {_short_name(name):<32} " + " ".join(f"{t['real_loss_kinds_as_a'].get(k, 0) / n:>11.2f}" for k in kinds) - ) - - -def _print_chances(table: dict[str, dict]) -> None: - """Chances created and conceded per strategy, both sides (`analysis.chances`).""" - rows = {name: t for name, t in table.items() if t["chances"]["matches"]} - if not rows: - return - - def pct(v: Optional[float]) -> str: - return f"{v:.0%}" if v is not None else "-" - - def num(v: Optional[float]) -> str: - return f"{v:.1f}" if v is not None else "-" - - print( - "\nCHANCES (both sides; conv = goals per shot, open = goal mouth unblocked at the shot, " - "regain>shot = open-play regains shot from within 10 s, danger = s/match the enemy held " - "the ball in our defensive third, fk>shot = free kicks shot from within 10 s, " - "progress = m gained per completed pass):" - ) - print( - f" {'strategy':<28} {'shots':>6} {'conv':>5} {'dist':>5} {'open':>5} {'save':>5} {'open vs':>7} " - f"{'regain>shot':>11} {'secs':>5} {'danger':>6} {'fk>shot':>7} {'progress':>8} {'fwd':>4}" - ) - for name, t in sorted(rows.items(), key=lambda kv: (-kv[1]["wins"], -kv[1]["draws"])): - c = t["chances"] - print( - f" {_short_name(name):<28} {c['shots'] / c['matches']:>6.1f} {pct(c['conversion']):>5} " - f"{num(c['shot_distance_m']):>5} {pct(c['shot_open_goal']):>5} {pct(c['save_rate']):>5} " - f"{pct(c['faced_open_goal']):>7} {pct(c['regain_to_shot']):>11} {num(c['regain_to_shot_s']):>5} " - f"{num(c['danger_s_per_match']):>6} {pct(c['free_kick_to_shot']):>7} " - f"{num(t['pass_progress_m']):>8} {pct(t['forward_pass_share']):>4}" - ) - - -def _print_motion_planning_table(table: dict[str, dict]) -> None: - has_motion = any( - t.get("worst_clearance_m") is not None or t.get("robot_overlap_ticks", 0) > 0 for t in table.values() - ) - if not has_motion: - return - print( - "\nMOTION PLANNING (per match averages; tm_coll = teammate overlap s (incidents), " - "total_coll = all overlap s (incidents), near_miss = near miss s <5cm, min_clr = worst clearance):" - ) - print(f" {'strategy':<32} {'tm_coll':>18} {'total_coll':>20} {'near_miss':>11} {'min_clr':>10}") - for name, t in sorted(table.items(), key=lambda kv: (-kv[1]["wins"], -kv[1]["draws"])): - n = max(1, t["matches"]) - tm_coll_s = (t.get("teammate_overlap_ticks", 0) / n) / TICKS_PER_SECOND - tm_inc = t.get("teammate_overlap_incidents", 0) / n - total_coll_s = (t.get("robot_overlap_ticks", 0) / n) / TICKS_PER_SECOND - tot_inc = t.get("robot_overlap_incidents", 0) / n - near_miss_s = (t.get("near_miss_ticks", 0) / n) / TICKS_PER_SECOND - wc = t.get("worst_clearance_m") - min_clr_str = f"{wc * 100:.1f} cm" if wc is not None else "-" - tm_str = f"{tm_coll_s:.2f}s ({tm_inc:.1f})" - tot_str = f"{total_coll_s:.2f}s ({tot_inc:.1f})" - print(f" {_short_name(name):<32} {tm_str:>18} {tot_str:>20} {near_miss_s:>10.2f}s {min_clr_str:>10}") - - -def _print_ball_losses(b: dict, run_id: str) -> None: - def top(counts: dict[str, int], k: int = 5) -> str: - return ", ".join(f"{name} {c}" for name, c in list(counts.items())[:k]) or "none" - - print( - f"\nBALL LOSSES (config_a side): {b['real_losses']} real ({b['real_losses_per_match']}/match; " - f"{b['raw_turnovers']} raw MatchStats turnovers)" - ) - print(f" by kind: {top(b['by_kind'])}") - print(f" fouls: {top(b['fouls_by_rule'])}") - print(f" by tactic: {top(b['by_tactic'])}") - rec = b.get("receptions") - if rec and rec["passes"]: - print( - f" passes: {top(rec['by_outcome'])}; {rec['catch_rate'] or 0:.0%} of reachable caught, " - f"missed median facing off {rec['missed']['median_facing_off_deg']} deg" - ) - print(f" full breakdown: replays/{run_id}/ball_losses.md") - - -if __name__ == "__main__": - main() diff --git a/tools/evaluation/sim_settings.py b/tools/evaluation/sim_settings.py new file mode 100644 index 000000000..fc4bde8a6 --- /dev/null +++ b/tools/evaluation/sim_settings.py @@ -0,0 +1,33 @@ +"""What the reference evaluation plays: the players, and the simulated world and robots. + +`reference/players.json` names the champion and the core strategies (`evaluate.py`). `reference/world.json` is the +measured world, `reference/robots.json` the robots, assumed good. They live in a subdirectory +because `replay/fingerprint.py` hashes data files beside `match.py`: choosing a new champion must +not rerun every cached match. World and robots enter the matches together as one `SimNoise`. +""" + +from __future__ import annotations + +import json +from pathlib import Path + +from utama_core.simulator.utils.sim_noise import SimNoise + +REFERENCE_DIR = Path(__file__).with_name("reference") +DEFAULT_PLAYERS = REFERENCE_DIR / "players.json" + + +def _values(name: str) -> dict: + return json.loads((REFERENCE_DIR / f"{name}.json").read_text())["values"] + + +def load_players(path: Path = DEFAULT_PLAYERS) -> dict: + return json.loads(Path(path).read_text()) + + +def reference_noise(seed: int = 0) -> dict: + """The reference world and robots as a `SimNoise` dict, played with `seed`.""" + world, robots = _values("world"), _values("robots") + both = set(world) & set(robots) + assert not both, f"set in both world.json and robots.json: {sorted(both)}" + return {**world, **robots, "seed": seed} diff --git a/tools/evaluation/verdict_sim.py b/tools/evaluation/verdict_sim.py new file mode 100644 index 000000000..7d998263f --- /dev/null +++ b/tools/evaluation/verdict_sim.py @@ -0,0 +1,75 @@ +"""How often evaluate.py's rule gets it right: the rule played on simulated match results. + + pixi run python tools/evaluation/verdict_sim.py [--trials 4000] [--opponents 4 5] [--sd 1.6] + +No matches are played. A candidate and the reference meet each opponent once per round (same seed and +colour, so their results are correlated `rho`: ~0.9 for a small edit of one strategy, ~0 for +unrelated strategies); every match's goal difference has SD `sd`. The rule is `ratings.decide`, the +one evaluate.py runs: a screen of ROUNDS rounds that only drops, then ROUNDS fresh rounds that accept +at p <= ALPHA. Prints, per true effect (goals per match) and correlation, the share of candidates +called better, dropped and undecided, and the mean number of rounds played. + +What it leaves out: a candidate's effect is the same against every opponent (no matchups), and diffs +are normal (real ones are whole goals, maybe heavy-tailed). The test (`tests/tools/test_verdict_sim.py`) +pins the claim the docs make: an equal strategy is called better at most ALPHA of the time. +""" + +from __future__ import annotations + +import argparse +import sys +from pathlib import Path + +import numpy as np + +REPO_ROOT = Path(__file__).resolve().parents[2] +if str(REPO_ROOT) not in sys.path: + sys.path.insert(0, str(REPO_ROOT)) + +from utama_core.analysis import ratings # noqa: E402 + + +def simulate( + effect: float, rho: float, n_opponents: int, trials: int, seed: int = 0, sd: float = ratings.NOISE_SD +) -> dict: + """Share of `trials` candidates called better / dropped / undecided, and their mean rounds.""" + rng = np.random.default_rng(seed) + sd_diff = sd * np.sqrt(2 * (1 - rho)) # SD of one diff: candidate's margin minus the reference's + out = {"better": 0, "dropped": 0, "undecided": 0, "rounds": 0} + for _ in range(trials): + verdict, k = None, 0 + for confirming in (False, True): + diffs: list[float] = [] # each stage decides on its own seeds' diffs only + for j in range(1, ratings.ROUNDS + 1): + k += 1 + diffs += list(rng.normal(effect, sd_diff, size=n_opponents)) + verdict = ratings.decide(ratings.paired_test(diffs), j, confirming) + if verdict is not None: + break + if verdict != "confirm": + break + out[verdict] += 1 + out["rounds"] += k + return {key: value / trials for key, value in out.items()} + + +def main(argv: list[str] | None = None) -> None: + parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + parser.add_argument("--trials", type=int, default=4000) + parser.add_argument("--opponents", type=int, nargs="+", default=[4, 5]) + parser.add_argument("--sd", type=float, default=ratings.NOISE_SD) + args = parser.parse_args(argv) + print(f"ROUNDS {ratings.ROUNDS}, ALPHA {ratings.ALPHA}, match SD {args.sd}") + print(f"{'opponents':>9} {'rho':>4} {'effect':>6} {'better':>7} {'dropped':>8} {'undecided':>9} {'rounds':>6}") + for n in args.opponents: + for rho in (0.0, 0.5, 0.9): + for effect in (-0.5, 0.0, 0.3, 0.5, 1.0): + r = simulate(effect, rho, n, args.trials, sd=args.sd) + print( + f"{n:>9} {rho:>4.1f} {effect:>+6.1f} {r['better']:>7.1%} {r['dropped']:>8.1%} " + f"{r['undecided']:>9.1%} {r['rounds']:>6.1f}" + ) + + +if __name__ == "__main__": + main() diff --git a/utama_core/shared/__init__.py b/tools/field/__init__.py similarity index 100% rename from utama_core/shared/__init__.py rename to tools/field/__init__.py diff --git a/examples/ball_trials.py b/tools/field/ball_trials.py similarity index 98% rename from examples/ball_trials.py rename to tools/field/ball_trials.py index fc33a8f7c..4ff65c563 100644 --- a/examples/ball_trials.py +++ b/tools/field/ball_trials.py @@ -1,5 +1,5 @@ # ruff: noqa: E402 -"""examples/ball_trials.py — the ball part of `pixi run calibrate`: the robot fetches the ball itself. +"""tools/field/ball_trials.py — the ball part of `pixi run calibrate`: the robot fetches the ball itself. `BallTrialsTactic` measures how fast one robot can carry the ball and how its kicks leave, with no one placing the ball on its dribbler: @@ -27,21 +27,20 @@ import sys from pathlib import Path -sys.path.insert(0, str(Path(__file__).resolve().parents[1])) +sys.path.insert(0, str(Path(__file__).resolve().parents[2])) import math from typing import NamedTuple, Optional -from pass_receive import take_ball_facing - +from examples.pass_receive import take_ball_facing from utama_core.config.robot_params import REAL_PARAMS from utama_core.engine.context import TickContext from utama_core.engine.tactic import BaseTactic, RobotId, TacticTag from utama_core.entities.data.command import RobotCommand from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import FieldBounds, Game -from utama_core.shared.pass_and_score_geometry import kick_bend -from utama_core.skills.src.utils.move_utils import turn_on_spot +from utama_core.geometry.pass_and_score_geometry import kick_bend +from utama_core.skills.utils.move_utils import turn_on_spot CARRY_M = 0.5 # how far a carry goes TURN_RAD = math.pi # how far a turn goes diff --git a/examples/calibrate_robot.py b/tools/field/calibrate_robot.py similarity index 97% rename from examples/calibrate_robot.py rename to tools/field/calibrate_robot.py index 86d9e4521..65c745ad4 100644 --- a/examples/calibrate_robot.py +++ b/tools/field/calibrate_robot.py @@ -1,5 +1,5 @@ # ruff: noqa: E402 -"""examples/calibrate_robot.py — measure one real robot and write its profile: no dashboard. +"""tools/field/calibrate_robot.py — measure one real robot and write its profile: no dashboard. Run: pixi run calibrate # finds the robots on the field; asks which if several @@ -15,7 +15,7 @@ camera's view facing +x (0.8 m clear ahead, 0.6 m to its left) with a ball at rest in view. It plays fixed moves first (`tactics/scripted_moves.py`, `CALIBRATION_SCRIPT`): about 65 s of driving and turning, its turns on the spot also showing where its tag sits. Then the ball part -(`ball_trials.py`), where it fetches the ball itself: +(`tools/field/ball_trials.py`), where it fetches the ball itself: - a carry ladder: forward, backward, sideways and turning with the ball at rising speeds, `--repeats` times each, a direction ending at the first speed that loses the ball; - `--kicks` kicks along the field, each with the kicker charged. @@ -42,7 +42,7 @@ import sys from pathlib import Path -sys.path.insert(0, str(Path(__file__).resolve().parents[1])) +sys.path.insert(0, str(Path(__file__).resolve().parents[2])) import argparse import json @@ -53,8 +53,8 @@ from dataclasses import replace from typing import Optional -from ball_trials import BallTrialsTactic, at_caps -from shooting_drill import ( +from tools.field.ball_trials import BallTrialsTactic, at_caps +from tools.field.shooting_drill import ( CAMERA_HALF, FIELD, KEEP_OUT, @@ -63,7 +63,6 @@ _one_robot_strategy, no_rules_referee, ) - from utama_core.analysis.robot_calibration import ( FieldLog, ball_noise, @@ -80,13 +79,13 @@ Move, ScriptedMovesTactic, ) -from utama_core.team_controller.src.controllers.common.robot_profile import ( +from utama_core.team_controller.controllers.common.robot_profile import ( RobotProfile, load_profile, profile_path, save_profile, ) -from utama_core.team_controller.src.controllers.real import find_robots +from utama_core.team_controller.controllers.real import find_robots _START = ( "Robot near the middle of the camera's view facing +x, 0.8 m clear ahead and 0.6 m to its left, " @@ -373,7 +372,7 @@ def _analyse(log_path: str, robot: tuple[str, int], radio: int, old: RobotProfil def committed_profile(radio: int) -> Optional[RobotProfile]: """The robot's profile as last committed (`git show HEAD:...`); None if it has none.""" path = profile_path(radio) - rel = path.relative_to(Path(__file__).resolve().parents[1]).as_posix() + rel = path.relative_to(Path(__file__).resolve().parents[2]).as_posix() shown = subprocess.run(["git", "show", f"HEAD:{rel}"], capture_output=True, text=True) return RobotProfile(**json.loads(shown.stdout)["profile"]) if shown.returncode == 0 else None diff --git a/tools/field_check.py b/tools/field/field_check.py similarity index 90% rename from tools/field_check.py rename to tools/field/field_check.py index 84cc043a1..43ab8a977 100644 --- a/tools/field_check.py +++ b/tools/field/field_check.py @@ -6,7 +6,7 @@ pixi run field-check # radios 0 to 7 pixi run field-check --radios 0 1 -1. Vision (`vision_check.py`, 2 s): cameras and their packets per second, the field size, the ball +1. Vision (`tools/field/vision_check.py`, 2 s): cameras and their packets per second, the field size, the ball and the lids in view. Nothing heard: it stops there. 2. Robots (`find-robots`): each radio that answers turns about 70 degrees on the spot and back; the lid that turned is its; the share of its commands it answered; its profile. The pairing is @@ -21,15 +21,15 @@ import sys from pathlib import Path -REPO_ROOT = Path(__file__).resolve().parents[1] -for p in (REPO_ROOT, REPO_ROOT / "tools"): +REPO_ROOT = Path(__file__).resolve().parents[2] +for p in (REPO_ROOT, REPO_ROOT / "tools" / "field"): if str(p) not in sys.path: sys.path.insert(0, str(p)) from vision_check import _socket, listen from utama_core.config.settings import MULTICAST_GROUP, PORT, VISION_PORT -from utama_core.team_controller.src.controllers.real import find_robots +from utama_core.team_controller.controllers.real import find_robots VISION_S = 2.0 MIN_CAMERA_HZ = 30 # a camera sending fewer packets per second than this is struggling @@ -38,7 +38,7 @@ def vision_lines(heard: dict, seconds: float) -> list[str]: """`listen`'s result as checklist lines.""" if not heard["senders"]: - return [f"!! vision: nothing on {MULTICAST_GROUP}:{VISION_PORT} (docs/real_robot_setup.md, 'Vision')"] + return [f"!! vision: nothing on {MULTICAST_GROUP}:{VISION_PORT} (tutorials/field_day.md, 'Vision')"] lines = [] for camera, n in sorted(heard["per_camera"].items()): hz = n / seconds diff --git a/tools/field/field_physics.py b/tools/field/field_physics.py new file mode 100644 index 000000000..586b5e298 --- /dev/null +++ b/tools/field/field_physics.py @@ -0,0 +1,267 @@ +"""World physics measured from field logs, for the sim's settings: loop delay, ball rolling +deceleration, and detection noise at rest for the ball and the robots. + +Only the sessions and measurements allowed in `tools/field/field_sessions.json` are read. Each log's +values are grouped by (day, radio) and printed as a median with its middle half and count, then +checked for agreement across the groups: a setting is only trusted if the days repeat it. + + pixi run python tools/field/field_physics.py [--logs replays/field] [--workers 2] [--json OUT] +""" + +from __future__ import annotations + +import argparse +import glob +import json +import os +import sys +from multiprocessing import Pool +from pathlib import Path +from typing import Optional + +import numpy as np + +REPO_ROOT = Path(__file__).resolve().parents[2] +if str(REPO_ROOT) not in sys.path: + sys.path.insert(0, str(REPO_ROOT)) + +from utama_core.analysis import robot_calibration as rc # noqa: E402 + +REGISTER = Path(__file__).with_name("field_sessions.json") +MEASUREMENTS = ("loop_delay", "ball_roll", "ball_noise", "robot_noise") +UNITS = {"loop_delay": "ms", "ball_roll": "m/s^2", "ball_noise": "mm", "robot_noise": "mm"} +ROLL_MAX_RMS_MM = 12.0 # a roll fit this noisy is not a clean roll +ROLL_MIN_DECEL = 0.0 +ROLL_MIN_SECS = 0.6 +STEP_MIN_CMD = 0.3 # commanded speed (m/s or rad/s) for a step to count as a delay measurement +STEP_AXES = ("forward", "left") +FIELD_BOUNDS = {"top_left": [-1.5, 1.125], "bottom_right": [1.5, -1.125]} +ROLL_MIN_SPEED = 0.8 # m/s, ball speed of a kick +ROLL_EDGE_M = 0.1 # the fit stops this far from the field edge +ROLL_ROBOT_M = 0.25 # and this far from any robot + + +def load_register(path: Path = REGISTER) -> dict: + """The field sessions register: which days may be used for which measurements.""" + with open(path) as f: + return json.load(f) + + +def session_of(log_name: str) -> str: + """The day (first 8 characters of the file name), e.g. '20261028' for '20261028_...log.gz'.""" + return Path(log_name).name[:8] + + +def allowed(register: dict, day: str, measurement: str) -> bool: + """True only if the day is registered and lists the measurement in its `use`.""" + session = register.get("sessions", {}).get(day) + if session is None: + return False + return measurement in session.get("use", []) + + +def ball_rolls(log, robot_kicks: list[dict], bounds) -> list[dict]: + """Rolling deceleration after clean kicks, single camera, away from robots and field edge. + + Each kick's ball path is fitted with a quadratic in distance travelled; the fit is kept only + if it is clean (rms < ROLL_MAX_RMS_MM), decelerating and at least ROLL_MIN_SECS long.""" + if len(log.balls) < 30: + return [] + b = rc._main_camera(np.column_stack([log.balls[:, :2], log.balls[:, 2:], np.zeros(len(log.balls))])).astype(float) + out = [] + (xl, yt), (xr, yb) = bounds + for k in robot_kicks: + if k["ball_speed"] < ROLL_MIN_SPEED or k.get("chip"): + continue + t0 = k["t"] + w = (b[:, 0] > t0 + 0.3) & (b[:, 0] < t0 + 5) + if w.sum() < 25: + continue + r = b[w] + dt = np.diff(r[:, 0]) + cut = np.flatnonzero(dt > 0.1) + if len(cut): + r = r[: cut[0] + 1] + inside = ( + (r[:, 2] > xl + ROLL_EDGE_M) + & (r[:, 2] < xr - ROLL_EDGE_M) + & (r[:, 3] > yb + ROLL_EDGE_M) + & (r[:, 3] < yt - ROLL_EDGE_M) + ) + # distance from the ball to the nearest robot at each sample + d = np.full(len(r), np.inf) + for rows in log.robots.values(): + q = rows[np.argsort(rows[:, 0].astype(float))].astype(float) + d = np.minimum( + d, + np.hypot( + np.interp(r[:, 0], q[:, 0], q[:, 2]) - r[:, 2], np.interp(r[:, 0], q[:, 0], q[:, 3]) - r[:, 3] + ), + ) + ok = inside & (d > ROLL_ROBOT_M) + n = int(np.argmin(ok)) if not ok.all() else len(r) + r = r[:n] + if len(r) < 25: + continue + t = r[:, 0] - r[0, 0] + s = np.r_[0, np.cumsum(np.hypot(np.diff(r[:, 2]), np.diff(r[:, 3])))] + moving = np.flatnonzero(np.gradient(s, t) > 0.15) + if len(moving) < 25: + continue + e = moving[-1] + 1 + t, s = t[:e], s[:e] + if t[-1] < 0.4: + continue + c = np.polyfit(t, s, 2) + row = dict( + decel=round(float(-2 * c[0]), 3), + v0=round(float(c[1]), 3), + secs=round(float(t[-1]), 2), + rms_mm=round(1000 * float(np.std(s - np.polyval(c, t))), 2), + ) + if row["rms_mm"] < ROLL_MAX_RMS_MM and row["decel"] > ROLL_MIN_DECEL and row["secs"] >= ROLL_MIN_SECS: + out.append(row) + return out + + +def step_delays_ms(steps: list[dict]) -> list[float]: + """Each fitted step's delay in ms, for steps moving forward or left at >= STEP_MIN_CMD.""" + out = [] + for s in steps: + delay = s.get("delay_s") + if not delay or delay <= 0: + continue + if s.get("axis") not in STEP_AXES or abs(s.get("commanded", 0.0)) < STEP_MIN_CMD: + continue + out.append(delay * 1000) + return out + + +def measure_log(path) -> Optional[dict]: + """The allowed measurements of one field log, or None if its mode is not real or its day + allows nothing. Each value is (measurement, radio or None, value).""" + name = os.path.basename(str(path)) + day = session_of(name) + register = load_register() + if not any(allowed(register, day, m) for m in MEASUREMENTS): + return None + try: + log = rc.FieldLog(path) + if log.info.get("mode") != "real": + return None + fb = log.info.get("field_bounds", FIELD_BOUNDS) + bounds = (fb["top_left"], fb["bottom_right"]) + values: list[tuple] = [] + for r in rc.calibrate(log): + if "error" in r: + continue + fw = r["firmware_id"] + if allowed(register, day, "loop_delay"): + values += [("loop_delay", fw, ms) for ms in step_delays_ms(r["steps"])] + if allowed(register, day, "ball_roll"): + values += [("ball_roll", fw, roll["decel"]) for roll in ball_rolls(log, r["kicks"], bounds)] + if allowed(register, day, "robot_noise") and r["vision"].get("position_mm") is not None: + values.append(("robot_noise", fw, r["vision"]["position_mm"])) + if allowed(register, day, "ball_noise"): + pos = rc.ball_noise(log.balls).get("position_mm") + if pos is not None: + values.append(("ball_noise", None, pos)) + return {"log": name, "day": day, "values": values} + except Exception as e: # one bad log must not lose the run + return {"log": name, "day": day, "error": str(e), "values": []} + + +def summarise(rows: list[dict]) -> dict: + """{measurement: {(day, radio): {median, lo, hi, n}}}: lo and hi are the 25th and 75th percentiles.""" + grouped: dict[str, dict[tuple, list[float]]] = {} + for row in rows: + if not row: + continue + for measurement, radio, value in row["values"]: + grouped.setdefault(measurement, {}).setdefault((row["day"], radio), []).append(float(value)) + out: dict = {} + for measurement, groups in grouped.items(): + out[measurement] = {} + for key, vals in sorted(groups.items(), key=lambda kv: (kv[0][0], -1 if kv[0][1] is None else kv[0][1])): + a = np.array(vals, float) + out[measurement][key] = { + "median": round(float(np.median(a)), 3), + "lo": round(float(np.percentile(a, 25)), 3), + "hi": round(float(np.percentile(a, 75)), 3), + "n": len(a), + } + return out + + +def agreement(groups: dict, tolerance: float = 0.25, min_n: int = 5) -> dict: + """Whether the groups' medians agree: highest - lowest <= tolerance * median of the medians. + Only groups with at least `min_n` values count. Fewer than two usable groups gives agree None.""" + medians = [g["median"] for g in groups.values() if g["n"] >= min_n] + if len(medians) < 2: + return {"medians": [min(medians), max(medians)] if medians else [], "agree": None, "groups_used": len(medians)} + lowest, highest = min(medians), max(medians) + return { + "medians": [lowest, highest], + "agree": bool(highest - lowest <= tolerance * float(np.median(medians))), + "groups_used": len(medians), + } + + +def _key(day: str, radio) -> str: + return f"{day}|{'all' if radio is None else radio}" + + +def main(argv: Optional[list[str]] = None) -> int: + parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + parser.add_argument("--logs", default="replays/field", help="folder of *.log.gz files") + parser.add_argument("--workers", type=int, default=2) + parser.add_argument("--json", type=Path, help="write the summary, agreement and errors here") + args = parser.parse_args(argv) + + files = sorted(glob.glob(os.path.join(args.logs, "*.log.gz"))) + print(f"{len(files)} logs in {args.logs}") + with Pool(args.workers) as pool: + rows = [r for r in pool.imap(measure_log, files, chunksize=1) if r is not None] + errors = [r for r in rows if "error" in r] + for r in errors: + print(f"ERROR {r['log']}: {r['error']}") + print(f"{len(rows)} logs used, {len(errors)} errored") + + summary = summarise(rows) + agree_all: dict = {} + for measurement in MEASUREMENTS: + groups = summary.get(measurement, {}) + unit = UNITS[measurement] + print(f"\n{measurement} ({unit})") + if not groups: + print(" no values") + agree_all[measurement] = agreement({}) + continue + print(f" {'day':<10}{'radio':<7}{'median':>10}{'middle half':>24}{'n':>7}") + for (day, radio), g in groups.items(): + radio_s = "all" if radio is None else str(radio) + middle = "%s to %s" % (g["lo"], g["hi"]) + print(f" {day:<10}{radio_s:<7}{g['median']:>10}{middle:>24}{g['n']:>7}") + ag = agreement(groups) + agree_all[measurement] = ag + if ag["agree"] is None: + verdict = f"too few groups to compare ({ag['groups_used']} with n >= 5)" + elif ag["agree"]: + verdict = "agree" + else: + verdict = "disagree: find the setup difference or use the spread as the range" + print(f" agreement: {verdict}") + + if args.json: + payload = { + "summary": {m: {_key(d, r): g for (d, r), g in groups.items()} for m, groups in summary.items()}, + "agreement": agree_all, + "errors": [{"log": r["log"], "error": r["error"]} for r in errors], + } + args.json.write_text(json.dumps(payload, indent=1)) + print(f"\nwritten {args.json}") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/field/field_sessions.json b/tools/field/field_sessions.json new file mode 100644 index 000000000..0e9fa9768 --- /dev/null +++ b/tools/field/field_sessions.json @@ -0,0 +1,32 @@ +{ + "note": "Every field session, and which measurements it may be used for. tools/field/field_physics.py reads only what is allowed here. Stop rule: a number enters the sim only if it repeats across runs, or its spread is deliberately used as the range.", + "source_archive": "replays/field_logs_20261102_211613.tar.gz (untrimmed, local only; do not delete). Trimmed logs: release v2.5.0, field_logs_20261102_233700.tar.gz.", + "measurements": ["loop_delay", "ball_roll", "ball_noise", "robot_noise"], + "sessions": { + "20261021": { + "setup": "Logged as mode=real but synthetic: zero noise, 4 cameras.", + "use": [], + "why": "Not real data." + }, + "20261022": { + "setup": "Real logs mixed with 7 grSim logs. Cameras disagree by about 71 mm.", + "use": ["ball_noise"], + "why": "Camera disagreement rules out anything from motion." + }, + "20261027": { + "setup": "One calibration run, vision about 44 Hz with about 20 ms processing.", + "use": ["loop_delay", "ball_roll", "ball_noise", "robot_noise"], + "why": "Usable as a second day to check agreement, but thin: 79 ms and 1.8 m/s^2 sideways came from this one run." + }, + "20261028": { + "setup": "2 radios, 7 usable calibration runs, wired vision, cameras within about 11 mm.", + "use": ["loop_delay", "ball_roll", "ball_noise", "robot_noise"], + "why": "The main reference." + }, + "20261029": { + "setup": "Vision over a 2.4 GHz phone hotspot: frames bunched, delays up to about 145 ms.", + "use": ["ball_noise", "robot_noise"], + "why": "Timing and anything fitted from motion are corrupted by the link." + } + } +} diff --git a/tools/package_logs.py b/tools/field/package_logs.py similarity index 93% rename from tools/package_logs.py rename to tools/field/package_logs.py index 099c02b70..17fd3584a 100644 --- a/tools/package_logs.py +++ b/tools/field/package_logs.py @@ -2,20 +2,21 @@ Modes: 1. Tournament Results (Tier 1): packages summary.json, *.stats.json, *.timeline.json, - ledger entries, and reports while stripping large columnar *.npz arrays (reducing + and reports while stripping large columnar *.npz arrays (reducing ~1 GB to ~3 MB). 2. Real Field Logs (Tier 2): compresses raw .log files to .log.gz and bundles them with calibration files and hardware configurations for sharing. Usage: - pixi run python tools/package_logs.py tournament [DIR_OR_ID] [--out OUT] [--with-intentions] [--dry-run] - pixi run python tools/package_logs.py field [DIR] [--out OUT] [--compress-in-place] [--dry-run] + pixi run python tools/field/package_logs.py tournament [DIR_OR_ID] [--out OUT] [--with-intentions] [--dry-run] + pixi run python tools/field/package_logs.py field [DIR] [--out OUT] [--compress-in-place] [--dry-run] """ from __future__ import annotations import argparse import gzip +import re import shutil import sys import tarfile @@ -23,12 +24,15 @@ from pathlib import Path from typing import Optional, Sequence -REPO_ROOT = Path(__file__).resolve().parents[1] +REPO_ROOT = Path(__file__).resolve().parents[2] def find_latest_tournament(replays_dir: Path) -> Optional[Path]: - """Find the most recent tournament_* directory in replays_dir.""" - runs = sorted(replays_dir.glob("tournament_*")) + """The most recent run directory in replays_dir: an evaluate.py round or an older round-robin.""" + runs = sorted( + [*replays_dir.glob("tournament_*"), *replays_dir.glob("eval_*/round_*")], + key=lambda p: re.sub(r"^\D*", "", p.relative_to(replays_dir).as_posix()), + ) return runs[-1] if runs else None @@ -40,7 +44,7 @@ def collect_tournament_files(run_dir: Path, with_intentions: bool = False) -> li files: list[Path] = [] # Core summaries and stats - for pattern in ("summary.json", "*.stats.json", "*.timeline.json", "*.md", "ledger.jsonl"): + for pattern in ("summary.json", "*.stats.json", "*.timeline.json", "*.md"): files.extend(sorted(run_dir.glob(pattern))) if with_intentions: diff --git a/tools/robot_calibration.py b/tools/field/robot_calibration.py similarity index 74% rename from tools/robot_calibration.py rename to tools/field/robot_calibration.py index 6e7b733ea..c799f9924 100644 --- a/tools/robot_calibration.py +++ b/tools/field/robot_calibration.py @@ -2,13 +2,13 @@ """A robot's numbers (loop delay, speed and turn tracking, acceleration, vision noise, kick speed) from a recorded field test. See `utama_core/analysis/robot_calibration.py`. - pixi run python tools/robot_calibration.py replays/field/.log [--json OUT] + pixi run python tools/field/robot_calibration.py replays/field/.log [--json OUT] """ import sys from pathlib import Path -REPO_ROOT = Path(__file__).resolve().parents[1] +REPO_ROOT = Path(__file__).resolve().parents[2] if str(REPO_ROOT) not in sys.path: sys.path.insert(0, str(REPO_ROOT)) diff --git a/examples/shooting_drill.py b/tools/field/shooting_drill.py similarity index 93% rename from examples/shooting_drill.py rename to tools/field/shooting_drill.py index b7e9f402e..35cc79511 100644 --- a/examples/shooting_drill.py +++ b/tools/field/shooting_drill.py @@ -1,15 +1,15 @@ # ruff: noqa: E402 -"""examples/shooting_drill.py — one robot shoots at a goal the other defends, on a small field. +"""tools/field/shooting_drill.py — one robot shoots at a goal the other defends, on a small field. The keeper feeds a ball it holds back to the attacker, so the drill loops; it is also where a test day's field, camera half and robot hardware are set (the other examples import them). Run: - pixi run python examples/shooting_drill.py # real robots (MODE below) - pixi run python examples/shooting_drill.py --mode rsim - pixi run python examples/shooting_drill.py --mode grsim # grSim must be running + pixi run python tools/field/shooting_drill.py # real robots (MODE below) + pixi run python tools/field/shooting_drill.py --mode rsim + pixi run python tools/field/shooting_drill.py --mode grsim # grSim must be running # the dashboard is at http://localhost:8080: press Force Start to play, Halt to freeze - pixi run python examples/shooting_drill.py --calibrate attacker # or defender + pixi run python tools/field/shooting_drill.py --calibrate attacker # or defender What it does: - Two robots, one per team, both ours on one radio: the attacker attacks the goal in @@ -24,14 +24,14 @@ On the dashboard's Live tab, the field check must be all green or amber before Force Start: a red row (robot not seen, outside the camera half, radio lost, wrong field size) halts the -robots at once. See docs/custom_referee_gui.md, "Field check". +robots at once. See docs/referee.md ("Operator panel"), "Field check". Measuring a robot (`--calibrate attacker|defender`): that robot plays fixed moves instead (`tactics/scripted_moves.py`, about 70 s: 10 s still, steps forward and back at 0.3, 0.6 and 1 m/s, sideways, turns) while the other stands still. Put it 1 m inside the area, facing along the field's long side, and a ball at rest in view; Force Start. Halting (to put it back) restarts the interrupted move. Then measure it from the recorded log: - pixi run python tools/robot_calibration.py replays/field/.log + pixi run python tools/field/robot_calibration.py replays/field/.log Calibrate near the middle of the camera's view: its noise grows towards the image edges. Run it twice per robot (early and late): how far the two runs disagree is how far to trust them. Gain and loop delay should agree closely; acceleration, turning above all, is only rough. @@ -39,7 +39,7 @@ The rest of a test day's measurements, any run (every real run records a log): - Floor friction: roll the ball by hand across open floor 8-10 times at different speeds, away from robots. Then convert the log and fit its free-rolling segments: - pixi run python tools/convert_ssl_log.py replays/field/.log --out replays/field/converted + pixi run python tools/realism/convert_ssl_log.py replays/field/.log --out replays/field/converted pixi run python -m utama_core.analysis.physics_ranges --real replays/field/converted The result replaces BALL_ROLL_DECEL (`config/settings.py`, the league's 0.29 m/s^2). - Kick speed: 5+ kicks per robot with the ball placed at its kicker (the attacker kicks in @@ -58,7 +58,7 @@ from pathlib import Path # Run as `pixi run python examples/.py`: utama_core is not installed, so put the repo on the path. -sys.path.insert(0, str(Path(__file__).resolve().parents[1])) +sys.path.insert(0, str(Path(__file__).resolve().parents[2])) import argparse import dataclasses @@ -66,14 +66,6 @@ from typing import NamedTuple, Optional from utama_core.config.field_params import FieldBounds, FieldDimensions -from utama_core.custom_referee import CustomReferee -from utama_core.custom_referee.profiles.profile_loader import ( - AutoAdvanceConfig, - GameConfig, - RefereeProfile, - RulesConfig, - load_profile, -) from utama_core.dashboard import DashboardServer, attach_dashboard from utama_core.dashboard.views import referee as referee_view from utama_core.dashboard.views import strategy as strategy_view @@ -82,20 +74,28 @@ from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy from utama_core.engine.tactic import BaseTactic, TacticTag from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.geometry.pass_and_score_geometry import has_ball, oriented_towards +from utama_core.referee import CustomReferee +from utama_core.referee.profiles.profile_loader import ( + AutoAdvanceConfig, + GameConfig, + RefereeProfile, + RulesConfig, + load_profile, +) from utama_core.run import StrategyRunner -from utama_core.shared.pass_and_score_geometry import has_ball, oriented_towards -from utama_core.skills.src.utils.move_utils import kick, turn_on_spot +from utama_core.skills.utils.move_utils import kick, turn_on_spot from utama_core.tactics.defense import DefenseTactic from utama_core.tactics.give_and_go import GiveAndGoTactic from utama_core.tactics.goalkeeper import GoalkeeperTactic from utama_core.tactics.lead_and_support import LeadAndSupportTactic from utama_core.tactics.press_and_contain import PressAndContainTactic from utama_core.tactics.scripted_moves import ScriptedMovesTactic -from utama_core.team_controller.src.controllers.common.robot_profile import RobotProfile -from utama_core.team_controller.src.controllers.common.robot_profile import ( +from utama_core.team_controller.controllers.common.robot_profile import RobotProfile +from utama_core.team_controller.controllers.common.robot_profile import ( load_profile as robot_profile, ) -from utama_core.team_controller.src.controllers.real.find_robots import ( +from utama_core.team_controller.controllers.real.find_robots import ( confirm as confirm_lids, ) @@ -269,7 +269,7 @@ def _build(motion_controller) -> KernelSchedulerStrategy: ) return AbstractStrategy( - build_kernel_strategy=_build, + build=_build, goalkeeper_id=robot_id if tactic_cls is None else _NO_ROBOT, ) diff --git a/tools/ssl-vision-lab-field.patch b/tools/field/ssl-vision-lab-field.patch similarity index 100% rename from tools/ssl-vision-lab-field.patch rename to tools/field/ssl-vision-lab-field.patch diff --git a/tools/trim_idle_log.py b/tools/field/trim_idle_log.py similarity index 96% rename from tools/trim_idle_log.py rename to tools/field/trim_idle_log.py index 2f1e9a4de..10b7e914c 100644 --- a/tools/trim_idle_log.py +++ b/tools/field/trim_idle_log.py @@ -7,8 +7,8 @@ transitions. Usage: - pixi run python tools/trim_idle_log.py replays/field/.log.gz [--out OUT] [--dry-run] - pixi run python tools/trim_idle_log.py replays/field/*.log.gz --in-place + pixi run python tools/field/trim_idle_log.py replays/field/.log.gz [--out OUT] [--dry-run] + pixi run python tools/field/trim_idle_log.py replays/field/*.log.gz --in-place """ from __future__ import annotations @@ -21,7 +21,7 @@ from pathlib import Path from typing import Iterator, Optional, Sequence -REPO_ROOT = Path(__file__).resolve().parents[1] +REPO_ROOT = Path(__file__).resolve().parents[2] if str(REPO_ROOT) not in sys.path: sys.path.insert(0, str(REPO_ROOT)) @@ -36,7 +36,7 @@ VISION_2014, ) from utama_core.replay.ssl_log import read_records # noqa: E402 -from utama_core.team_controller.src.generated_code.ssl_gc_referee_message_pb2 import ( # noqa: E402 +from utama_core.team_controller.generated_code.ssl_gc_referee_message_pb2 import ( # noqa: E402 Referee, ) diff --git a/tools/vision_check.py b/tools/field/vision_check.py similarity index 96% rename from tools/vision_check.py rename to tools/field/vision_check.py index cfd942f42..8114cef4a 100644 --- a/tools/vision_check.py +++ b/tools/field/vision_check.py @@ -1,7 +1,7 @@ # ruff: noqa: E402 """Does ssl-vision's multicast reach this machine? Listens for a few seconds, with no radio or runner, and prints who sent it, packets per second per camera, what was detected and the field -size ssl-vision announces. The first check on a test day (`docs/real_robot_setup.md`). +size ssl-vision announces. The first check on a test day (`tutorials/field_day.md`). Each robot and ball is also listed where each camera puts it (mean over the run) and, when several cameras see it, the largest gap between them: cameras whose calibrations agree are a few @@ -13,8 +13,8 @@ each camera's error at each point. Cameras that agree with each other can both be wrong; this says by how much. The results are saved to `replays/field/` as the baseline for the next setup. - pixi run python tools/vision_check.py [--seconds 5] - pixi run python tools/vision_check.py --guided ball [--seconds 2] + pixi run python tools/field/vision_check.py [--seconds 5] + pixi run python tools/field/vision_check.py --guided ball [--seconds 2] """ import argparse @@ -28,12 +28,12 @@ from itertools import combinations from pathlib import Path -REPO_ROOT = Path(__file__).resolve().parents[1] +REPO_ROOT = Path(__file__).resolve().parents[2] if str(REPO_ROOT) not in sys.path: sys.path.insert(0, str(REPO_ROOT)) from utama_core.config.settings import MULTICAST_GROUP, VISION_PORT -from utama_core.team_controller.src.generated_code.ssl_vision_wrapper_pb2 import ( +from utama_core.team_controller.generated_code.ssl_vision_wrapper_pb2 import ( SSL_WrapperPacket, ) @@ -135,7 +135,7 @@ def check(seconds: float) -> None: sock = _socket() heard = listen(sock, seconds) if not heard["senders"]: - print(f"Nothing on {MULTICAST_GROUP}:{VISION_PORT} in {seconds:.0f} s: see docs/real_robot_setup.md, 'Vision'.") + print(f"Nothing on {MULTICAST_GROUP}:{VISION_PORT} in {seconds:.0f} s: see tutorials/field_day.md, 'Vision'.") sys.exit(1) print(f"From: {', '.join(sorted(heard['senders']))}") per_camera = heard["per_camera"] diff --git a/tools/metric_correlation.py b/tools/metric_correlation.py deleted file mode 100644 index 80debc3b7..000000000 --- a/tools/metric_correlation.py +++ /dev/null @@ -1,1535 +0,0 @@ -#!/usr/bin/env python3 -# ruff: noqa: E402 -"""Offline study: which cheap per-match proxy metrics predict match outcome. - -Run from the repository root, for example: - - pixi run python tools/metric_correlation.py \\ - replays/tournament_20260903_101521 \\ - replays/tournament_20260903_112025 \\ - replays/tournament_20260903_115838 \\ - --out benchmark_results/metric_correlation.md - -Purpose -------- -`docs/strategies.md` and `round_robin.py` already tell us who won each match, but a -full 65s round-robin match is expensive to run inside an agent loop that's iterating -on a single strategy change. If some cheap per-match "proxy" metric (possession, -territory, shots, ...) reliably predicts match outcome, a much shorter scenario -benchmark reporting just that metric could stand in for a full win-rate sweep. This -script is the offline study that answers "which metrics, if any" using replay data we -already have on disk, before spending any effort wiring new metrics into the live -`MatchStats` accumulator (`utama_core/engine/match_stats.py`). - -It does not run the simulator, a tactic, or a strategy — it only reads -`summary.json`/`_vs_.stats.json` (already-computed `MatchStats`) and replays -`_vs_.pkl` frame-by-frame at a 10 Hz sample (`_SAMPLE_HZ`) to compute a second -family of metrics `MatchStats` does not currently report. - -Side convention (see `match.run_match`): `config_a` is always yellow AND -starts on the right (`my_team_is_right=True`), `config_b` is always blue/left; the teams -change ends at half-time, so each frame's own `my_team_is_right` gives its side. Every replay -frame's `friendly_robots`/`ball` are recorded from `config_a`'s perspective -(`ReplayMetadata.my_team_is_yellow=True` in every file checked), so "friendly" in a -frame or in `.stats.json` always means `config_a`. Side is a real effect in -this sim (see `round_robin.py`'s `--both-sides` docstring), so every metric below is -reported both as a per-side value and as an a-minus-b differential, and side is kept -as an explicit covariate in the logistic fit (part A) rather than assumed away. - -Frame-derived metric definitions (see also each metric function's own docstring for -the precise threshold/tie-break used — this is the summary): - -1. `shots_on_target` — a ball-speed spike (>= `_SHOT_SPEED_MPS`, matching - `match_stats.py`'s existing shot heuristic for consistency) launched from within - `_SHOT_LAUNCH_RADIUS_M` of an attacking-side robot, moving toward the opponent - goal, whose straight-line velocity ray crosses the opponent goal line inside the - goal mouth. Edge-detected with the same "locked until ball slows" debounce - `match_stats.py` uses, so one continuous fast, on-target ball counts once. This is - a slightly stricter version of `MatchStats.shots` (also requires launch proximity - to a robot, not just "ball already fast in the attacking third") — kept as its own - metric rather than replacing `shots` since the two disagree occasionally (a - deflection re-accelerating the ball with no robot nearby) and that disagreement is - itself informative for part D's "which to instrument" call. -2. `attacking_third_entries` — count of ball crossings from at/behind the midline - into a side's attacking third (`x` beyond +/-1.5 m from centre on that side's - attack axis, matching `match_stats.py`'s zone boundary), hysteresis band - `_ENTRY_HYSTERESIS_M` wide so oscillation on the 1.5 m line doesn't double-count. -3. `completed_passes` / `turnovers` — a "possession" event starts when the ball - enters a robot's `_POSSESSION_RADIUS_M` while moving slower than - `_PASS_RELEASE_MPS ` (i.e. controlled, not a shot flying past) and ends when it - leaves that radius at >= `_PASS_RELEASE_MPS`. A **completed pass** is a - possession-end-by-a-side-A-robot immediately (no intervening possession event by - the opposing side) followed by a possession-start by a *different* side-A robot. A - **turnover** is the same shape but the next possessor is an opposing-side robot. - Ball-out-of-bounds/no-further-possession before the match ends counts as neither. -4. `possession_under_pressure_s` — seconds a side's nearest-robot-to-ball (the same - possession attribution `MatchStats.possession_pct` uses) also has an opponent - robot within `_PRESSURE_RADIUS_M`, at the 10 Hz sample rate. -5. `restart_to_first_entry_s` / `n_restarts` — from the intentions.jsonl referee - trace: each transition *into* a live command (`NORMAL_START`/`FORCE_START`) from a - non-live command starts a restart clock, attributed to whichever side is - possessing the ball (nearest-robot-to-ball) at that live-start frame; it stops - at the first frame afterward where that same side's ball position enters its - attacking third. Restarts with no qualifying entry before the next stoppage or - match end are excluded from the mean (and counted separately, `n_restarts` vs. - `n_restarts_with_entry`) rather than imputing an arbitrary ceiling. Reported - both per-side (`restart_to_first_entry_s_friendly`/`_enemy`, feeding the same - `a-b` differential every other metric uses) and as a single match-level mean - pooling both sides. *Lower is better* for the possessing side (faster tempo - off a restart) -- see `_LOWER_IS_BETTER`. -6. `mean_ball_x_towards_opponent_goal` (territory) and `defensive_third_time_pct` — - mean of `ball.p.x` projected onto each side's attack axis (matching - `match_stats.py`'s `own_goal_sign` convention) across sampled frames, and the - fraction of sampled frames the ball spends in a side's own defensive third. -7. Two more, chosen for a plausible causal link to scoring rather than just - correlation-mining: - - `shot_backed_up_rate` — of `shots_on_target` events, the fraction where a - teammate of the shooting side is within `_SUPPORT_RADIUS_M` of the ball at the - moment of the shot (rebound/follow-up support). Motivated by: an unsupported shot - that's saved or deflected usually just turns over possession, while a backed-up - shot can be converted on the second ball — plausibly causal for *actually* - converting territory into goals, not just reaching the box. - - `defensive_third_time_pct` (see 6) doubles as a plausible direct predictor of - *conceding*: time spent defending your own third is time the opponent could - be shooting, independent of any single shot metric firing. - -All frame-derived metrics are computed once per match from a single pass over -10 Hz-sampled frames (`_iter_sampled_frames`) and cached to -`/frame_metrics//.json` so a re-run (e.g. after a code -tweak to this script) never re-reads a `.pkl`. Per-match rows (frame metrics + -stats.json + summary.json result) are also cached per run to -`/rows/.json`. -""" - -from __future__ import annotations - -import argparse -import json -import math -import multiprocessing as mp -import os -import sys -import tempfile -import time -from dataclasses import dataclass -from pathlib import Path -from typing import Optional - -import numpy as np - -try: - from scipy import stats as scipy_stats - - _HAVE_SCIPY = True -except ImportError: # pragma: no cover - scipy is present in the pixi env - _HAVE_SCIPY = False - -REPO_ROOT = Path(__file__).resolve().parents[1] -if str(REPO_ROOT) not in sys.path: - sys.path.insert(0, str(REPO_ROOT)) - -from utama_core.config.field_params import STANDARD_FIELD_DIMS # noqa: E402 -from utama_core.config.physical_constants import ROBOT_RADIUS # noqa: E402 -from utama_core.replay.columnar_reader import load_columnar_replay # noqa: E402 -from utama_core.replay.entities import ReplayMetadata # noqa: E402 -from utama_core.replay.replay_player import _load_replay # noqa: E402 - -# --- Sampling --------------------------------------------------------------- -_SAMPLE_HZ = 10.0 -_TICK_HZ = 60.0 # rsim's fixed step rate (match.TICKS_PER_SECOND) -_SAMPLE_STRIDE = max(1, round(_TICK_HZ / _SAMPLE_HZ)) -_DT = _SAMPLE_STRIDE / _TICK_HZ - -# --- Field geometry (matches utama_core/engine/match_stats.py's conventions) --- -_HALF_LENGTH = STANDARD_FIELD_DIMS.full_field_half_length # 4.5 -_HALF_GOAL_WIDTH = STANDARD_FIELD_DIMS.half_goal_width # 0.5 -_ATTACKING_THIRD_M = 1.5 # matches match_stats.py's zone boundary - -# --- Metric thresholds (each used in exactly one metric function below; see the -# module docstring's numbered list for the "why") --- -_SHOT_SPEED_MPS = 3.5 # matches match_stats.py's _SHOT_SPEED_MPS -_SHOT_LAUNCH_RADIUS_M = 0.5 # "from within N m of a robot" per the task's metric 1 -_ENTRY_HYSTERESIS_M = 0.3 # metric 2: band around the 1.5 m third boundary -_POSSESSION_RADIUS_M = 2 * ROBOT_RADIUS + 0.05 # ~0.23 m: robot footprint + dribble slack -_PASS_RELEASE_MPS = 1.0 # matches match_stats.py's _SHOT_LOCK_RELEASE_MPS release speed -_PRESSURE_RADIUS_M = 0.5 # metric 4, per the task spec -_SUPPORT_RADIUS_M = 1.0 # metric 7: "teammate near the ball at shot time" -_RESTART_LIVE_COMMANDS = {"NORMAL_START", "FORCE_START"} - -# --- Metrics 8-12 (2026-09-04 debugging-signal expansion): each mined from a -# real, already-traced bug mechanism in docs/roadmap.md's "trajsample liveness fixes", rather than -# invented speculatively -- the point is a cheap counter that would have -# flagged that exact mechanism automatically instead of needing a human to -# live-trace a match. See each metric's own comment below for which bug it -# targets. -_NEAR_STALL_RADIUS_M = 0.5 # metric 8: same order as match_stats.py's NO_PROGRESS_POSSESSION radius (0.35), a -# little looser here since this is meant to catch pre-watchdog *risk*, not confirmed stalls -_NEAR_STALL_SECONDS = 2.0 # metric 8: much shorter than the live watchdog's 8s -- an early-warning signal, -# not a replacement for it -_THRASH_WINDOW_S = 5.0 # metric 9: matches the ~5-9s windows item 15's kicker-thrash traces were measured over -_OSCILLATION_WINDOW_S = 3.0 # metric 10: window over which a distance-derivative sign-flip run is counted -_OSCILLATION_MIN_AMPLITUDE_M = 0.3 # metric 10: ignore sub-30cm position noise, only count a real retreat/re-approach - - -def _iter_sampled_frames(replay_path: Path): - """Yield every `_SAMPLE_STRIDE`-th `GameFrame` from a replay file, plus the - replay metadata first. A generator, not a list, so a caller that only needs - a running accumulation (the common case here) never holds the sampled frames - in memory at once. - - Dispatches on extension like `replay_player.load_frames_in_range` does: - `.npz` is the columnar format current tournament runs actually write - (`ColumnarReplayWriter`) — `_load_replay` only understands the older - one-pickle-per-frame `.pkl` format, so it can't read current runs at all. - `ColumnarReplay` has no separate `ReplayMetadata` object; `my_team_is_yellow` - is a field on it directly, which is the only piece of metadata this module - reads, so it's wrapped in a `ReplayMetadata` to keep `compute_frame_metrics` - unchanged. - """ - if replay_path.suffix == ".npz": - replay = load_columnar_replay(replay_path) - yield ReplayMetadata( - my_team_is_yellow=replay.my_team_is_yellow, - exp_friendly=len(replay.friendly_ids), - exp_enemy=len(replay.enemy_ids), - ) - for i in range(0, replay.n_ticks, _SAMPLE_STRIDE): - yield replay.frame_at(i) - return - - gen = _load_replay(replay_path) - metadata = next(gen) - yield metadata - for i, frame in enumerate(gen): - if i % _SAMPLE_STRIDE == 0: - yield frame - - -def _attack_sign(my_team_is_right: bool, side: str) -> float: - """+1/-1 multiplier s.t. `x * attack_sign` grows as `side`'s ball/robot moves - toward the *opponent's* goal. Matches `match_stats.py`'s `own_goal_sign` - convention exactly (friendly's own goal sits at `+own_goal_sign * half_length`). - """ - own_goal_sign = 1.0 if my_team_is_right else -1.0 - return -own_goal_sign if side == "friendly" else own_goal_sign - - -def _own_goal_x(my_team_is_right: bool, side: str) -> float: - own_goal_sign = 1.0 if my_team_is_right else -1.0 - ref_sign = own_goal_sign if side == "friendly" else -own_goal_sign - return ref_sign * _HALF_LENGTH - - -@dataclass -class _PossessionState: - side: Optional[str] = None - robot_id: Optional[int] = None - - -def compute_frame_metrics(replay_path: Path, referee_events: list[dict]) -> dict: - """Single pass over 10 Hz-sampled frames computing every frame-derived metric - (see module docstring, items 1-7) for both `friendly` (config_a) and `enemy` - (config_b). Returns a flat dict of `{metric}_{side}` -> value plus a couple of - match-level counts (`n_restarts`, `n_restarts_with_entry`). - """ - frames_iter = _iter_sampled_frames(replay_path) - next(frames_iter) # metadata - - sides = ("friendly", "enemy") - shots_on_target = {s: 0 for s in sides} - shots_backed_up = {s: 0 for s in sides} - shot_lock = {s: False for s in sides} - entries = {s: 0 for s in sides} - in_attacking_third = {s: False for s in sides} # hysteresis state - ball_x_sum = {s: 0.0 for s in sides} - defensive_third_ticks = {s: 0 for s in sides} - pressure_ticks = {s: 0 for s in sides} - n_ticks = 0 - - possession = _PossessionState() # current controlling (side, robot_id) or None - completed_passes = {s: 0 for s in sides} - turnovers = {s: 0 for s in sides} - - # --- metric 8: near-stall risk (pre-watchdog early warning) --- - # Same shape as match_stats.py's NO_PROGRESS_POSSESSION watchdog (a robot - # stuck near the ball without ever gaining possession), but a much shorter - # threshold and a looser radius -- meant to fire well before the live 8s - # watchdog would, so it can serve as a leading risk indicator rather than a - # confirmed-stall count. Tracked per side (whichever side's nearest robot is - # the one stuck). - near_stall_since: dict[str, Optional[float]] = {s: None for s in sides} - near_stall_holder: dict[str, Optional[int]] = {s: None for s in sides} - near_stall_events = {s: 0 for s in sides} - - # --- metric 9: kicker/nearest-robot identity thrash during a restart --- - # Mined directly from item 15's traced DIRECT_FREE bug: the "closest robot - # to the ball" identity flipped ~9x/second on ordinary position noise - # before the Sticky[int] fix (243 switches/27s -> 4). This counts identity - # switches of the nearest-to-ball robot *within a side*, while a restart - # command is in effect -- a regression of that exact bug class would show - # up here even if nothing else changes. - restart_active = False - thrash_prev_id: dict[str, Optional[int]] = {s: None for s in sides} - thrash_switches = {s: 0 for s in sides} - - # --- metric 10: retreat/re-approach oscillation --- - # The "congestion/local-minimum" signature item 15 traced repeatedly: a - # side's nearest-robot-to-ball distance oscillates (approach, retreat, - # re-approach) instead of monotonically closing, for seconds at a time, - # while the planner reports no collision. Counts local direction reversals - # in each side's nearest-to-ball distance time series, ignoring reversals - # smaller than _OSCILLATION_MIN_AMPLITUDE_M (position noise). - osc_last_dist: dict[str, Optional[float]] = {s: None for s in sides} - osc_last_extremum: dict[str, Optional[float]] = {s: None for s in sides} - osc_direction: dict[str, int] = {s: 0 for s in sides} # +1 closing, -1 opening, 0 unknown - osc_reversals = {s: 0 for s in sides} - - # --- metric 11: ball-carrier hold duration (COMMITTED_FROZEN precursor) --- - # Targets the DefenseTactic ball-drag bug class: one robot keeps has_ball - # continuously for an abnormally long stretch. Tracks the longest - # continuous has_ball run per side across the match (p95 needs many - # matches pooled, so this reports the single max per match; part B pools - # across a strategy's matches for a percentile). - carrier_hold_since: dict[str, Optional[float]] = {s: None for s in sides} - carrier_hold_id: dict[str, Optional[int]] = {s: None for s in sides} - carrier_hold_max_s = {s: 0.0 for s in sides} - - # Restart-to-entry bookkeeping, split by which side was possessing at the - # restart (so it folds into the same per-side differential framework every - # other metric uses -- a side reaching the attacking third faster off its - # own restarts is a directly plausible predictor of scoring more). - restarts_resolved: dict[str, list[float]] = {s: [] for s in sides} - n_restarts = 0 - n_restarts_with_entry = 0 - pending_restart: Optional[dict] = None # {"t0": float, "side": Optional[str]} - - # Referee events are timestamped independently (intentions.jsonl); merge by - # sim_time against the sampled frame stream below rather than a second pass. - ref_events = sorted(referee_events, key=lambda e: e["sim_time"]) - ref_idx = 0 - prev_command: Optional[str] = None - - for frame in frames_iter: - my_team_is_right = frame.my_team_is_right # config_a's side; the teams change ends at half-time - ball = frame.ball - if ball is None: - continue - n_ticks += 1 - t = frame.ts - - # Advance the referee-event cursor to the latest event at or before this - # sampled frame, tracking live-command transitions as we pass them. - while ref_idx < len(ref_events) and ref_events[ref_idx]["sim_time"] <= t: - cmd = ref_events[ref_idx]["command"] - if cmd in _RESTART_LIVE_COMMANDS and prev_command not in _RESTART_LIVE_COMMANDS: - # A live-play command just started a restart clock. Whoever is - # nearest the ball *now* (this frame) is "the possessing side" for - # the purpose of measuring how fast they reach the attacking third. - all_robots = [(rid, r, "friendly") for rid, r in frame.friendly_robots.items()] + [ - (rid, r, "enemy") for rid, r in frame.enemy_robots.items() - ] - nearest_side = min(all_robots, key=lambda e: e[1].p.distance_to(ball.p))[2] if all_robots else None - pending_restart = {"t0": t, "side": nearest_side} - n_restarts += 1 - # metric 9: "restart active" = any non-HALT/STOP referee command that - # isn't yet live play (the mass-replan ceremony window item 15's - # kicker-thrash bug was traced during -- PREPARE_*/DIRECT_FREE_*/ - # BALL_PLACEMENT_* etc., not the live-play commands themselves, since - # once play is live the "nearest robot" is expected to change hands - # normally as the ball moves). - restart_active = cmd not in ("HALT", "STOP") and cmd not in _RESTART_LIVE_COMMANDS - prev_command = cmd - ref_idx += 1 - - all_robots = [(rid, r, "friendly") for rid, r in frame.friendly_robots.items()] + [ - (rid, r, "enemy") for rid, r in frame.enemy_robots.items() - ] - - # --- possession (nearest robot to ball; matches match_stats.py) --- - nearest_id, nearest_robot, nearest_side = min(all_robots, key=lambda e: e[1].p.distance_to(ball.p)) - dist_to_nearest = nearest_robot.p.distance_to(ball.p) - - # --- metric 4: possession under pressure --- - opp_prefix = "enemy" if nearest_side == "friendly" else "friendly" - opponents = [r for rid, r, s in all_robots if s == opp_prefix] - if dist_to_nearest <= _POSSESSION_RADIUS_M and opponents: - min_opp_dist = min(r.p.distance_to(ball.p) for r in opponents) - if min_opp_dist <= _PRESSURE_RADIUS_M: - pressure_ticks[nearest_side] += 1 - - # --- metric 8: near-stall risk --- - # A side's nearest robot sits within _NEAR_STALL_RADIUS_M of the ball, - # same identity, for more than _NEAR_STALL_SECONDS, without possession - # ever latching to it (possession.side/robot_id != this holder) -- an - # early-warning version of match_stats.py's NO_PROGRESS_POSSESSION - # watchdog (which uses a tighter radius and an 8s threshold). One event - # is logged per qualifying stretch (not re-logged every tick it - # continues), mirroring that watchdog's own "log once per stretch" shape. - for side in sides: - side_robots = [(rid, r) for rid, r, s in all_robots if s == side] - if not side_robots: - near_stall_since[side] = None - near_stall_holder[side] = None - continue - s_id, s_robot = min(side_robots, key=lambda e: e[1].p.distance_to(ball.p)) - s_dist = s_robot.p.distance_to(ball.p) - has_control = possession.side == side and possession.robot_id == s_id - if s_dist <= _NEAR_STALL_RADIUS_M and not has_control: - if near_stall_holder[side] != s_id: - near_stall_since[side] = t - near_stall_holder[side] = s_id - elif near_stall_since[side] is not None and (t - near_stall_since[side]) > _NEAR_STALL_SECONDS: - near_stall_events[side] += 1 - near_stall_since[side] = None # reset so a longer stretch doesn't multi-count - else: - near_stall_since[side] = None - near_stall_holder[side] = None - - # --- metric 9: nearest-robot identity thrash during a restart ceremony --- - if restart_active: - for side in sides: - side_robots = [(rid, r) for rid, r, s in all_robots if s == side] - if not side_robots: - continue - s_id, _ = min(side_robots, key=lambda e: e[1].p.distance_to(ball.p)) - if thrash_prev_id[side] is not None and thrash_prev_id[side] != s_id: - thrash_switches[side] += 1 - thrash_prev_id[side] = s_id - else: - thrash_prev_id = {s: None for s in sides} - - # --- metric 10: retreat/re-approach oscillation --- - # A local direction reversal in a side's nearest-to-ball distance, - # ignoring reversals smaller than _OSCILLATION_MIN_AMPLITUDE_M so - # ordinary position noise (and a robot legitimately arriving and - # settling) doesn't count. This is a running peak/trough detector, not - # a windowed FFT -- cheap and matches how the bug was actually spotted - # in live traces (distance visibly sawtoothing instead of monotonically - # closing). - for side in sides: - side_robots = [(rid, r) for rid, r, s in all_robots if s == side] - if not side_robots: - continue - s_dist = min(r.p.distance_to(ball.p) for _, r in side_robots) - if osc_last_dist[side] is None: - osc_last_dist[side] = s_dist - osc_last_extremum[side] = s_dist - else: - delta = s_dist - osc_last_dist[side] - new_direction = 1 if delta > 0 else (-1 if delta < 0 else osc_direction[side]) - if ( - osc_direction[side] != 0 - and new_direction != osc_direction[side] - and osc_last_extremum[side] is not None - and abs(s_dist - osc_last_extremum[side]) >= _OSCILLATION_MIN_AMPLITUDE_M - ): - osc_reversals[side] += 1 - osc_last_extremum[side] = s_dist - elif osc_last_extremum[side] is None or ( - new_direction == osc_direction[side] - and ( - (new_direction > 0 and s_dist > osc_last_extremum[side]) - or (new_direction < 0 and s_dist < osc_last_extremum[side]) - ) - ): - osc_last_extremum[side] = s_dist - osc_direction[side] = new_direction - osc_last_dist[side] = s_dist - - # --- metric 11: ball-carrier hold duration (COMMITTED_FROZEN precursor) --- - for side in sides: - side_robots = [(rid, r) for rid, r, s in all_robots if s == side] - holder = next((rid for rid, r in side_robots if r.has_ball), None) - if holder is not None and carrier_hold_id[side] == holder: - held_for = t - carrier_hold_since[side] - if held_for > carrier_hold_max_s[side]: - carrier_hold_max_s[side] = held_for - elif holder is not None: - carrier_hold_id[side] = holder - carrier_hold_since[side] = t - else: - carrier_hold_id[side] = None - carrier_hold_since[side] = None - - # --- metric 3: completed passes / turnovers (possession-radius state machine) --- - ball_speed = math.hypot(ball.v.x, ball.v.y) - controlled = dist_to_nearest <= _POSSESSION_RADIUS_M and ball_speed < _PASS_RELEASE_MPS - if controlled: - new_holder = (nearest_side, nearest_id) - if possession.side is None: - possession = _PossessionState(*new_holder) - elif (possession.side, possession.robot_id) != new_holder: - # Possession changed hands without an intervening "released at - # speed" event (e.g. a slow dribble handoff/tackle) -- attribute - # as a same-side completed pass or a turnover exactly like a - # released pass would be, then adopt the new holder. - if possession.side == nearest_side: - completed_passes[possession.side] += 1 - else: - turnovers[possession.side] += 1 - possession = _PossessionState(*new_holder) - elif possession.side is not None and ball_speed >= _PASS_RELEASE_MPS and dist_to_nearest > _POSSESSION_RADIUS_M: - # Ball just left a controlled possession at speed: released. The - # eventual outcome (pass vs turnover vs neither) is resolved the next - # time the ball is controlled again, or never if it isn't. Mark as - # "released" by clearing robot_id but remembering the releasing side. - if possession.robot_id is not None: - possession = _PossessionState(side=possession.side, robot_id=None) - - # --- metric 1: shots on target --- - for side in sides: - attack_sign = _attack_sign(my_team_is_right, side) - if ball_speed < 1.0: - shot_lock[side] = False - if shot_lock[side]: - continue - toward_goal = ball.v.x * attack_sign > 0.0 - own_goal_x = _own_goal_x(my_team_is_right, side) - progress_from_own_goal = (ball.p.x - own_goal_x) * attack_sign - if not ( - ball_speed >= _SHOT_SPEED_MPS - and toward_goal - and progress_from_own_goal > _HALF_LENGTH + _ATTACKING_THIRD_M - ): - continue - launcher_side_robots = [r for rid, r, s in all_robots if s == side] - if not launcher_side_robots: - continue - near_launcher = min(r.p.distance_to(ball.p) for r in launcher_side_robots) <= _SHOT_LAUNCH_RADIUS_M - if not near_launcher: - continue - attacking_goal_x = attack_sign * _HALF_LENGTH - if ball.v.x == 0: - continue - ticks_to_goal_line = (attacking_goal_x - ball.p.x) / ball.v.x - predicted_y = ball.p.y + ball.v.y * ticks_to_goal_line - if abs(predicted_y) <= _HALF_GOAL_WIDTH: - shots_on_target[side] += 1 - shot_lock[side] = True - # metric 7a: is a teammate (excluding the shooter itself, hence - # the `0 <` lower bound) backing up the shot within support range? - teammates = [r for rid, r, s in all_robots if s == side] - if any(0 < r.p.distance_to(ball.p) <= _SUPPORT_RADIUS_M for r in teammates): - shots_backed_up[side] += 1 - - # --- metric 2: attacking-third entries (hysteresis) --- - for side in sides: - attack_sign = _attack_sign(my_team_is_right, side) - own_goal_x = _own_goal_x(my_team_is_right, side) - progress = (ball.p.x - own_goal_x) * attack_sign - enter_th = _HALF_LENGTH + _ATTACKING_THIRD_M - exit_th = enter_th - _ENTRY_HYSTERESIS_M - if not in_attacking_third[side] and progress > enter_th: - in_attacking_third[side] = True - entries[side] += 1 - elif in_attacking_third[side] and progress < exit_th: - in_attacking_third[side] = False - - # --- metric 6: territory / defensive-third time --- - # `progress` here is the ball's position measured from `side`'s own goal - # along its attack axis: large positive = deep in the opponent's end - # (territory), small/negative = deep in `side`'s own end. The same - # `< _ATTACKING_THIRD_M` cut `match_stats.py` uses for "defensive zone" - # (mirrored: that file measures from each *robot's* own goal too) gives - # the fraction of time the ball spends in `side`'s own defensive third. - for side in sides: - attack_sign = _attack_sign(my_team_is_right, side) - own_goal_x = _own_goal_x(my_team_is_right, side) - progress = (ball.p.x - own_goal_x) * attack_sign - ball_x_sum[side] += progress - if progress < _ATTACKING_THIRD_M: - defensive_third_ticks[side] += 1 - - # --- restart-to-entry resolution --- - if pending_restart is not None: - side = pending_restart["side"] - if side is not None and in_attacking_third[side]: - restarts_resolved[side].append(t - pending_restart["t0"]) - n_restarts_with_entry += 1 - pending_restart = None - - n_ticks = max(n_ticks, 1) - all_resolved = restarts_resolved["friendly"] + restarts_resolved["enemy"] - out = { - "n_sampled_ticks": n_ticks, - "n_restarts": n_restarts, - "n_restarts_with_entry": n_restarts_with_entry, - "restart_to_first_entry_s_mean": (float(np.mean(all_resolved)) if all_resolved else None), - } - for side in sides: - out[f"shots_on_target_{side}"] = shots_on_target[side] - out[f"restart_to_first_entry_s_{side}"] = ( - float(np.mean(restarts_resolved[side])) if restarts_resolved[side] else None - ) - out[f"shot_backed_up_rate_{side}"] = ( - shots_backed_up[side] / shots_on_target[side] if shots_on_target[side] > 0 else None - ) - out[f"attacking_third_entries_{side}"] = entries[side] - out[f"completed_passes_{side}"] = completed_passes[side] - out[f"turnovers_{side}"] = turnovers[side] - out[f"possession_under_pressure_s_{side}"] = pressure_ticks[side] * _DT - out[f"mean_ball_x_towards_opponent_goal_{side}"] = ball_x_sum[side] / n_ticks - out[f"defensive_third_time_pct_{side}"] = defensive_third_ticks[side] / n_ticks - out[f"near_stall_events_{side}"] = near_stall_events[side] - out[f"kicker_identity_thrash_{side}"] = thrash_switches[side] - out[f"retreat_reapproach_oscillations_{side}"] = osc_reversals[side] - out[f"ball_carrier_hold_max_s_{side}"] = carrier_hold_max_s[side] - return out - - -def _match_tag(config_a: str, config_b: str) -> str: - def short(name: str) -> str: - return name.removeprefix("build_").removesuffix("_kernel_strategy") - - return f"{short(config_a)}_vs_{short(config_b)}" - - -def _load_referee_events(intentions_path: Path) -> list[dict]: - events = [] - if not intentions_path.exists(): - return events - with open(intentions_path) as f: - for line in f: - line = line.strip() - if not line: - continue - d = json.loads(line) - if d.get("event") == "referee": - events.append({"sim_time": d["sim_time"], "command": d["command"]}) - return events - - -def _cache_path(scratch_dir: Path, run_name: str, match_tag: str) -> Path: - d = scratch_dir / "frame_metrics" / run_name - d.mkdir(parents=True, exist_ok=True) - return d / f"{match_tag}.json" - - -def _worker(args: tuple) -> tuple[str, dict]: - run_dir_str, match_tag, scratch_dir_str = args - run_dir = Path(run_dir_str) - scratch_dir = Path(scratch_dir_str) - cache_path = _cache_path(scratch_dir, run_dir.name, match_tag) - if cache_path.exists(): - with open(cache_path) as f: - return match_tag, json.load(f) - # Current tournament runs write `.npz` (ColumnarReplayWriter); older run - # directories on disk still have `.pkl` (see `_iter_sampled_frames`'s - # dispatch on extension) — prefer `.npz`, fall back for old runs. - npz_path = run_dir / f"{match_tag}.npz" - replay_path = npz_path if npz_path.exists() else run_dir / f"{match_tag}.pkl" - intentions_path = run_dir / f"{match_tag}.intentions.jsonl" - ref_events = _load_referee_events(intentions_path) - try: - metrics = compute_frame_metrics(replay_path, ref_events) - except Exception as exc: # pragma: no cover - defensive: one bad match shouldn't kill the run - metrics = {"_error": str(exc)} - with open(cache_path, "w") as f: - json.dump(metrics, f) - return match_tag, metrics - - -def build_rows(run_dir: Path, scratch_dir: Path, n_workers: int) -> list[dict]: - """One row per match in `run_dir`: summary.json result + stats.json + frame - metrics, cached whole to `/rows/.json`. - """ - rows_cache = scratch_dir / "rows" / f"{run_dir.name}.json" - rows_cache.parent.mkdir(parents=True, exist_ok=True) - if rows_cache.exists(): - with open(rows_cache) as f: - return json.load(f) - - with open(run_dir / "summary.json") as f: - summary = json.load(f) - - tasks = [] - for r in summary["results"]: - match_tag = _match_tag(r["config_a"], r["config_b"]) - tasks.append((str(run_dir), match_tag, str(scratch_dir))) - - frame_results: dict[str, dict] = {} - if n_workers > 1: - with mp.Pool(n_workers) as pool: - for match_tag, metrics in pool.imap_unordered(_worker, tasks, chunksize=1): - frame_results[match_tag] = metrics - else: - for t in tasks: - match_tag, metrics = _worker(t) - frame_results[match_tag] = metrics - - rows = [] - for r in summary["results"]: - match_tag = _match_tag(r["config_a"], r["config_b"]) - stats = r.get("stats") or {} - frame_metrics = frame_results.get(match_tag, {}) - row = { - "run": run_dir.name, - "match_tag": match_tag, - "config_a": r["config_a"], - "config_b": r["config_b"], - "score_a": r["score_a"], - "score_b": r["score_b"], - "winner": r["winner"], - "stats": stats, - "frame_metrics": frame_metrics, - } - rows.append(row) - - with open(rows_cache, "w") as f: - json.dump(rows, f) - return rows - - -# --- Metric differential extraction ----------------------------------------- - -# (metric_name, stats.json path template or frame_metrics key template). -# "stats:" prefix -> read from row["stats"], "frame:" prefix -> row["frame_metrics"]. -# -# `ball_travel_m` (from stats.json) is deliberately NOT in this list: `MatchStats` -# records it as one match-level total, not split by side, so it has no `a-b` -# differential to compute -- see `part_a`/report generation below for how it's -# reported instead (against |goal diff|, not signed goal diff). -# -# `shot_backed_up_rate` is also excluded from `ALL_METRICS`'s per-match -# differential framework (part A): it's only defined for a side that took >=1 -# shot on target in that match, and with only ~13 shots_on_target events across -# 231 matches in a run, both sides taking a shot in the *same* match essentially -# never happens -- the per-match differential would be `None` almost everywhere. -# It's still analysed in parts B/C, pooled per-strategy (total backed-up shots / -# total shots across all of a strategy's matches, not a mean of per-match -# differences) -- see `_shot_backed_up_pooled_rate`. -_STATS_METRICS = [ - "possession_pct", - "shots", - "zone_time_pct_attacking", - "robot_motion_pct", -] -_FRAME_METRICS = [ - "shots_on_target", - "attacking_third_entries", - "completed_passes", - "turnovers", - "possession_under_pressure_s", - "mean_ball_x_towards_opponent_goal", - "defensive_third_time_pct", - "restart_to_first_entry_s", - # Metrics 8-11 (2026-09-04 debugging-signal expansion, see compute_frame_metrics): - # each is a cheap proxy mined from a real, already-traced bug mechanism, tested - # here for whether it *also* carries any outcome signal, not just bug-detection value. - "near_stall_events", - "kicker_identity_thrash", - "retreat_reapproach_oscillations", - "ball_carrier_hold_max_s", -] -# Metrics where a *lower* value is better for that side -- `turnovers`, -# `defensive_third_time_pct`, and `restart_to_first_entry_s` (faster = better -# attacking tempo off a restart). Their differentials are still computed the -# same `own - opponent` way as every other metric; a *negative* correlation -# with points/goal-diff is the expected "good" sign for these, same as -# `defensive_third_time_pct` already reads in part B's table. The 4 new -# debugging-signal metrics are all "lower is better" too -- each one counts an -# occurrence of a known-bad mechanism (near-stall risk, identity thrash, -# retreat/re-approach oscillation, an abnormally long ball hold). -_LOWER_IS_BETTER = frozenset( - { - "turnovers", - "defensive_third_time_pct", - "restart_to_first_entry_s", - "near_stall_events", - "kicker_identity_thrash", - "retreat_reapproach_oscillations", - "ball_carrier_hold_max_s", - } -) - -ALL_METRICS = _STATS_METRICS + _FRAME_METRICS - - -def _team_zone_attacking_mean(zone_time_pct: dict, side: str) -> Optional[float]: - vals = [v["attacking"] for k, v in zone_time_pct.items() if k.startswith(f"{side}_") and "attacking" in v] - return float(np.mean(vals)) if vals else None - - -def _team_robot_motion_mean(robot_motion_pct: dict, side: str) -> Optional[float]: - vals = [v for k, v in robot_motion_pct.items() if k.startswith(f"{side}_")] - return float(np.mean(vals)) if vals else None - - -def extract_side_value(row: dict, metric: str, side: str) -> Optional[float]: - """`side` is "friendly" (=config_a) or "enemy" (=config_b) — matches the - replay/stats.json convention throughout this file. - """ - stats = row["stats"] - fm = row["frame_metrics"] - if metric == "possession_pct": - return stats.get("possession_pct", {}).get(side) - if metric == "shots": - return stats.get("shots", {}).get(side) - if metric == "zone_time_pct_attacking": - return _team_zone_attacking_mean(stats.get("zone_time_pct", {}), side) - if metric == "robot_motion_pct": - return _team_robot_motion_mean(stats.get("robot_motion_pct", {}), side) - if metric in _FRAME_METRICS: - return fm.get(f"{metric}_{side}") - raise ValueError(metric) - - -def compute_differential(row: dict, metric: str) -> Optional[float]: - """a (friendly/config_a) minus b (enemy/config_b), None if either side's value - is missing (e.g. shot_backed_up_rate when a side took zero shots on target). - """ - a = extract_side_value(row, metric, "friendly") - b = extract_side_value(row, metric, "enemy") - if a is None or b is None: - return None - return a - b - - -def goal_diff(row: dict) -> int: - return row["score_a"] - row["score_b"] - - -def winner_label(row: dict) -> Optional[int]: - """1 if config_a won, 0 if config_b won, None if draw (decisive-only metrics).""" - if row["winner"] == "draw": - return None - return 1 if row["winner"] == row["config_a"] else 0 - - -# --- Statistics --------------------------------------------------------------- - - -def spearman(x: np.ndarray, y: np.ndarray) -> tuple[float, float, int]: - mask = ~(np.isnan(x) | np.isnan(y)) - x, y = x[mask], y[mask] - n = len(x) - if n < 3: - return float("nan"), float("nan"), n - if _HAVE_SCIPY: - rho, p = scipy_stats.spearmanr(x, y) - return float(rho), float(p), n - # Fallback: rank + Pearson. - rx = _rankdata(x) - ry = _rankdata(y) - rho = _pearson(rx, ry) - return rho, float("nan"), n - - -def _rankdata(a: np.ndarray) -> np.ndarray: - order = np.argsort(a, kind="mergesort") - ranks = np.empty(len(a), dtype=float) - sorted_a = a[order] - i = 0 - while i < len(a): - j = i - while j + 1 < len(a) and sorted_a[j + 1] == sorted_a[i]: - j += 1 - avg_rank = (i + j) / 2.0 + 1 - ranks[order[i : j + 1]] = avg_rank - i = j + 1 - return ranks - - -def _pearson(x: np.ndarray, y: np.ndarray) -> float: - xm, ym = x - x.mean(), y - y.mean() - denom = math.sqrt(float(np.sum(xm**2)) * float(np.sum(ym**2))) - if denom == 0: - return float("nan") - return float(np.sum(xm * ym) / denom) - - -def auc_score(values: np.ndarray, labels: np.ndarray) -> tuple[float, int]: - """AUC of `values` predicting `labels==1`, via Mann-Whitney U (ties split).""" - mask = ~np.isnan(values) - values, labels = values[mask], labels[mask] - pos = values[labels == 1] - neg = values[labels == 0] - n = len(pos) + len(neg) - if len(pos) == 0 or len(neg) == 0: - return float("nan"), n - if _HAVE_SCIPY: - u, _ = scipy_stats.mannwhitneyu(pos, neg, alternative="two-sided") - auc = u / (len(pos) * len(neg)) - return float(auc), n - # Fallback: direct rank-sum AUC. - combined = np.concatenate([pos, neg]) - ranks = _rankdata(combined) - r_pos = ranks[: len(pos)].sum() - auc = (r_pos - len(pos) * (len(pos) + 1) / 2.0) / (len(pos) * len(neg)) - return float(auc), n - - -def fit_logistic_with_side(x: np.ndarray, side_is_a_right: np.ndarray, y: np.ndarray) -> Optional[dict]: - """Logistic regression of `y` (1=config_a win) on [intercept, x, side_covariate]. - - In this dataset config_a is *always* right (see module docstring), so a - literal "which physical side" covariate would be a constant column and - useless. What genuinely varies match-to-match is a fixed all-True/False - only across the whole corpus, so instead we use, as the requested "side - intercept", a coin-flip-free proxy that is still a real per-match binary - covariate: none exists in this dataset since config_a=yellow=right on - every single match (see match.run_match's hardcoded - my_team_is_yellow=True/my_team_is_right=True). We therefore fit x alone - (intercept + slope) and report that the side covariate is degenerate - (constant) rather than silently fitting a coefficient to an all-ones - column, which statsmodels/sklearn would either drop or blow up on. - """ - mask = ~np.isnan(x) - x, y = x[mask], y[mask] - if len(np.unique(y)) < 2 or len(x) < 5: - return None - # Standardize x for numerically stable IRLS. - mu, sigma = x.mean(), x.std() - if sigma == 0: - return None - xs = (x - mu) / sigma - X = np.column_stack([np.ones_like(xs), xs]) - beta = np.zeros(2) - for _ in range(100): - z = X @ beta - p = 1.0 / (1.0 + np.exp(-z)) - w = p * (1 - p) - w = np.clip(w, 1e-6, None) - W = np.diag(w) - try: - hessian = X.T @ W @ X - grad = X.T @ (y - p) - delta = np.linalg.solve(hessian, grad) - except np.linalg.LinAlgError: - return None - beta = beta + delta - if np.max(np.abs(delta)) < 1e-8: - break - slope_per_unit = beta[1] / sigma - return { - "intercept": float(beta[0]), - "slope_std": float(beta[1]), - "slope_per_unit": float(slope_per_unit), - "n": int(len(x)), - "side_covariate": "degenerate (config_a is right on every match in this dataset)", - } - - -def fit_weighted_proxy(metric_names: list[str], X: np.ndarray, y_goal_diff: np.ndarray) -> Optional[dict]: - """OLS: goal_diff ~ intercept + sum(w_i * standardized_metric_i), reported - back in original (per-metric-unit) goals-per-match terms. Used only for - part D's proposed weighted proxy score, over per-strategy aggregates. - """ - mask = ~np.isnan(X).any(axis=1) & ~np.isnan(y_goal_diff) - X, y = X[mask], y_goal_diff[mask] - n = len(y) - if n < len(metric_names) + 2: - return None - mu = X.mean(axis=0) - sigma = X.std(axis=0) - sigma[sigma == 0] = 1.0 - Xs = (X - mu) / sigma - design = np.column_stack([np.ones(n), Xs]) - beta, *_ = np.linalg.lstsq(design, y, rcond=None) - weights_per_unit = beta[1:] / sigma - residuals = y - design @ beta - r2 = 1 - np.sum(residuals**2) / np.sum((y - y.mean()) ** 2) if np.sum((y - y.mean()) ** 2) > 0 else float("nan") - return { - "intercept": float(beta[0]), - "weights_per_unit": {name: float(w) for name, w in zip(metric_names, weights_per_unit)}, - "weights_standardized": {name: float(w) for name, w in zip(metric_names, beta[1:])}, - "n": n, - "r2": float(r2), - } - - -# --- Per-strategy aggregation -------------------------------------------------- - - -def per_strategy_aggregates(all_rows: list[dict], metrics: list[str]) -> dict[str, dict]: - """For each strategy, mean differential (as that strategy's side minus - opponent, regardless of whether it played a or b) per metric across every - match it played, plus points-per-match and goal-diff-per-match. - """ - strategies: dict[str, dict] = {} - for row in all_rows: - for role, config, opp_config in ( - ("a", row["config_a"], row["config_b"]), - ("b", row["config_b"], row["config_a"]), - ): - s = strategies.setdefault( - config, - {"matches": 0, "points": 0.0, "goal_diff_sum": 0, "metric_sums": {m: [] for m in metrics}}, - ) - s["matches"] += 1 - if row["winner"] == "draw": - s["points"] += 1.0 - elif row["winner"] == config: - s["points"] += 3.0 - gd = (row["score_a"] - row["score_b"]) if role == "a" else (row["score_b"] - row["score_a"]) - s["goal_diff_sum"] += gd - own_side = "friendly" if role == "a" else "enemy" - opp_side = "enemy" if role == "a" else "friendly" - for m in metrics: - own_val = extract_side_value(row, m, own_side) - opp_val = extract_side_value(row, m, opp_side) - if own_val is not None and opp_val is not None: - s["metric_sums"][m].append(own_val - opp_val) - - out = {} - for name, s in strategies.items(): - entry = { - "matches": s["matches"], - "points_per_match": s["points"] / s["matches"] if s["matches"] else float("nan"), - "goal_diff_per_match": s["goal_diff_sum"] / s["matches"] if s["matches"] else float("nan"), - } - for m in metrics: - vals = s["metric_sums"][m] - entry[f"mean_diff_{m}"] = float(np.mean(vals)) if vals else float("nan") - out[name] = entry - return out - - -def pooled_shot_backed_up_rate_diff(all_rows: list[dict]) -> dict[str, float]: - """Per-strategy `own_pooled_rate - opp_pooled_rate` for `shot_backed_up_rate`, - where each pooled rate is `sum(backed-up shots) / sum(shots on target)` across - every match the strategy played -- NOT a mean of per-match differentials (see - `ALL_METRICS`'s docstring note on why the per-match differential is too sparse - to use directly here: ~13 shots_on_target events across 231 matches). - """ - own_backed: dict[str, int] = {} - own_shots: dict[str, int] = {} - opp_backed: dict[str, int] = {} - opp_shots: dict[str, int] = {} - for row in all_rows: - fm = row["frame_metrics"] - for role, config, opp_config in ( - ("a", row["config_a"], row["config_b"]), - ("b", row["config_b"], row["config_a"]), - ): - own_side = "friendly" if role == "a" else "enemy" - opp_side = "enemy" if role == "a" else "friendly" - shots_n = fm.get(f"shots_on_target_{own_side}", 0) or 0 - rate = fm.get(f"shot_backed_up_rate_{own_side}") - own_shots[config] = own_shots.get(config, 0) + shots_n - if rate is not None: - own_backed[config] = own_backed.get(config, 0) + round(rate * shots_n) - opp_shots_n = fm.get(f"shots_on_target_{opp_side}", 0) or 0 - opp_rate = fm.get(f"shot_backed_up_rate_{opp_side}") - opp_shots[config] = opp_shots.get(config, 0) + opp_shots_n - if opp_rate is not None: - opp_backed[config] = opp_backed.get(config, 0) + round(opp_rate * opp_shots_n) - - out = {} - for config in own_shots: - own_rate = own_backed.get(config, 0) / own_shots[config] if own_shots.get(config, 0) > 0 else float("nan") - opp_rate = opp_backed.get(config, 0) / opp_shots[config] if opp_shots.get(config, 0) > 0 else float("nan") - out[config] = own_rate - opp_rate - return out - - -# --- Report generation ---------------------------------------------------- - - -def _fmt(v, nd=3) -> str: - if v is None or (isinstance(v, float) and math.isnan(v)): - return "n/a" - if isinstance(v, float): - return f"{v:.{nd}f}" - return str(v) - - -def _mlabel(name: str) -> str: - """Metric name for table display, flagged with `†` when a *lower* raw - `a-b` differential is the "good" direction for side a (see `_LOWER_IS_BETTER`) - -- otherwise a reader sees e.g. `restart_to_first_entry_s`'s negative - correlation with winning and might misread it as "this metric doesn't matter" - rather than "lower is better and the sign is exactly as expected". - """ - base = name.split(" ")[0] - return f"{name} †" if base in _LOWER_IS_BETTER else name - - -def main() -> None: - parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) - parser.add_argument("run_dirs", nargs="+", type=Path, help="tournament run directories") - parser.add_argument("--out", type=Path, required=True, help="output markdown report path") - parser.add_argument( - "--reliability-runs", - nargs=2, - default=["tournament_20260903_101521", "tournament_20260903_115838"], - help="two run names (by dir basename) to correlate per-strategy metrics across, for part C", - ) - parser.add_argument("--workers", type=int, default=max(1, (os.cpu_count() or 2) - 1)) - parser.add_argument( - "--scratch-dir", - type=Path, - default=Path( - os.environ.get( - "METRIC_CORRELATION_SCRATCH", - str(Path(tempfile.gettempdir()) / "metric_correlation_scratch"), - ) - ), - ) - args = parser.parse_args() - - t_start = time.time() - args.scratch_dir.mkdir(parents=True, exist_ok=True) - - all_rows: list[dict] = [] - for run_dir in args.run_dirs: - rows = build_rows(run_dir, args.scratch_dir, args.workers) - all_rows.extend(rows) - - print(f"Loaded {len(all_rows)} match rows across {len(args.run_dirs)} runs in {time.time() - t_start:.1f}s") - - report_lines: list[str] = [] - report_lines.append("# Metric-correlation study: proxy metrics vs. match outcome") - report_lines.append("") - report_lines.append( - f"Generated {time.strftime('%Y-%m-%d %H:%M UTC', time.gmtime())} by `tools/metric_correlation.py`." - ) - report_lines.append("") - report_lines.append( - "Runs analysed: " + ", ".join(r.name for r in args.run_dirs) + f" ({len(all_rows)} matches total)." - ) - report_lines.append("") - report_lines.append( - "Side convention: `config_a` is always yellow and starts on the right " - "(`match.run_match` hardcodes `my_team_is_yellow=True, my_team_is_right=True`; " - "in runs with halves the teams change ends at half-time); " - "`friendly` in stats/frame metrics always means `config_a`. All metrics below are reported " - "as `a - b` differentials. Because config_a is right on literally every match in this corpus, " - "side cannot be fit as a genuine covariate (it is a constant column) -- see part A." - ) - report_lines.append("") - - # ---- Part A: per-match ---- - report_lines.append("## A. Per-match: Spearman correlation with goal diff, AUC for decisive matches") - report_lines.append("") - report_lines.append( - "Spearman correlates each metric's `a-b` differential with `score_a - score_b` over ALL matches " - "(including draws, since goal diff is still informative at 0-0 for many metrics). AUC is computed only " - "over the 22-26 decisive matches per run (config_a win=1 vs config_b win=0), predicting winner from the " - "raw differential's rank. A logistic fit (intercept + standardized slope) is also reported per metric; " - "a genuine side covariate could not be added (see note above), so this is intercept+slope only, not the " - "originally intended 3-parameter model." - ) - report_lines.append("") - report_lines.append("| metric | n (corr) | spearman rho | p | n (AUC) | AUC | logistic slope/unit |") - report_lines.append("|---|---:|---:|---:|---:|---:|---:|") - - gd = np.array([goal_diff(r) for r in all_rows], dtype=float) - win_labels = np.array([w if w is not None else np.nan for w in (winner_label(r) for r in all_rows)]) - - part_a_results = {} - for m in ALL_METRICS: - diffs = np.array( - [compute_differential(r, m) if compute_differential(r, m) is not None else np.nan for r in all_rows] - ) - rho, p, n_corr = spearman(diffs, gd) - auc, n_auc = auc_score(diffs, win_labels) - dec_mask = ~np.isnan(win_labels) - logit = fit_logistic_with_side(diffs[dec_mask], None, win_labels[dec_mask]) - slope = logit["slope_per_unit"] if logit else None - part_a_results[m] = {"rho": rho, "p": p, "n_corr": n_corr, "auc": auc, "n_auc": n_auc, "slope": slope} - report_lines.append( - f"| {_mlabel(m)} | {n_corr} | {_fmt(rho)} | {_fmt(p)} | {n_auc} | {_fmt(auc)} | {_fmt(slope, 4)} |" - ) - report_lines.append("") - report_lines.append( - "`ball_travel_m` (from `stats.json`) and `shot_backed_up_rate` are not in the table above: " - "`MatchStats` records `ball_travel_m` as one match-level total with no side split, so it has no " - "`a-b` differential -- see below for a match-level check against `|goal diff|` instead. " - "`shot_backed_up_rate` requires a side to have taken >=1 shot on target, and with only a handful of " - "`shots_on_target` events per run, both sides rarely take one in the *same* match -- its per-match " - "differential is `None` almost everywhere, so it's analysed only in parts B/C as a pooled per-strategy " - "rate instead (`pooled_shot_backed_up_rate_diff`)." - ) - report_lines.append("") - - ball_travel = np.array( - [r["stats"].get("ball_travel_m", float("nan")) if r["stats"] else float("nan") for r in all_rows] - ) - abs_gd = np.abs(gd) - rho_bt, p_bt, n_bt = spearman(ball_travel, abs_gd) - part_a_results["ball_travel_m (match-level, vs |goal diff|)"] = {"rho": rho_bt, "p": p_bt, "n_corr": n_bt} - report_lines.append( - f"`ball_travel_m` (match total) vs. `|goal diff|`: spearman rho={_fmt(rho_bt)}, p={_fmt(p_bt)}, n={n_bt}. " - "A more-decisive match plausibly involves more end-to-end ball movement (attacks that go somewhere) " - "rather than a stalemate, hence testing against |goal diff| rather than the signed value." - ) - report_lines.append("") - - # Metric 12 (2026-09-04 expansion) plus a follow-up split (2026-09-04, - # same day): total fouls per match, and its two largest components - # broken out individually, from `rule_event_counts` (already computed by - # MatchStats, previously unused by this study). No side split in - # stats.json (same limitation as ball_travel_m), so all three are tested - # match-level against |goal diff| rather than as an a-b differential. - # Two plausible, opposite-sign hypotheses for total_fouls: more fouls - # could mean a more contested, competitive match (positive with - # |goal diff| is NOT expected -- closer contests are lower |goal diff|), - # or could mean more congestion/crashing typical of a stalling match - # (which would show low |goal diff| too). Reported without a strong - # prior on sign; the data decides. - # - # crashing_rate and out_of_bounds_rate are broken out individually - # because they dominate total_fouls by a wide margin (roughly 60% and - # 20% of it respectively in a same-day 462-match spot check) and are - # architecturally distinct: crashing_rule.py fires on §8.4.2's own - # closing-speed fault thresholds with a built-in 2s retrigger cooldown - # (so this is a genuine per-collision-event count, not tick-spam), while - # out_of_bounds is a pure ball-position check with no cooldown of its - # own (each firing ends the active-play window until the next restart, - # so it also can't tick-spam in practice). A user-observed spot check - # (2026-09-04) found out_of_bounds heavily right-skewed rather than - # uniform: 46% of matches in that check had zero out_of_bounds events, - # but a few pathological matches hit 40-58 in a single 65s window, and - # the per-strategy rate spanned an 8-10x range (switch_of_play/ - # counter_press/high_line_zone/clear_press_plus far above tiki_taka/ - # three_slot/decoy_and_overload) -- worth its own metric to track - # whether that skew is a specific strategy's aim/geometry issue (e.g. a - # cross-field switch-of-play pass overshooting the sideline) rather than - # a uniform baseline, which a single pooled total_fouls number would - # hide entirely. - total_fouls = np.array( - [sum(r["stats"].get("rule_event_counts", {}).values()) if r["stats"] else float("nan") for r in all_rows] - ) - crashing_rate = np.array( - [r["stats"].get("rule_event_counts", {}).get("crashing", 0) if r["stats"] else float("nan") for r in all_rows] - ) - out_of_bounds_rate = np.array( - [ - r["stats"].get("rule_event_counts", {}).get("out_of_bounds", 0) if r["stats"] else float("nan") - for r in all_rows - ] - ) - for name, values in ( - ("total_fouls", total_fouls), - ("crashing_rate", crashing_rate), - ("out_of_bounds_rate", out_of_bounds_rate), - ): - rho_v, p_v, n_v = spearman(values, abs_gd) - part_a_results[f"{name} (match-level, vs |goal diff|)"] = {"rho": rho_v, "p": p_v, "n_corr": n_v} - report_lines.append( - f"`{name}` (match total) vs. `|goal diff|`: spearman rho={_fmt(rho_v)}, p={_fmt(p_v)}, n={n_v}. " - f"Mean {float(np.nanmean(values)):.2f}/match, max {int(np.nanmax(values))}, " - f"{int(np.sum(values == 0))} matches ({np.sum(values == 0) / len(values) * 100:.1f}%) with zero." - ) - report_lines.append("") - - # ---- Part B: per-strategy ---- - report_lines.append("## B. Per-strategy: mean differential vs. points/goal-diff per match") - report_lines.append("") - report_lines.append( - "Each strategy's mean `own - opponent` differential per metric, aggregated across every match it played " - "in the three 101521/112025/115838 runs (63 matches per strategy, 21 per run x 3 runs), correlated " - "(Spearman) against that strategy's points-per-match (3/1/0) and goal-diff-per-match across the 22 strategies." - ) - report_lines.append("") - - main_run_names = {r.name for r in args.run_dirs if "20260902" not in r.name} - main_rows = [r for r in all_rows if r["run"] in main_run_names] - agg = per_strategy_aggregates(main_rows, ALL_METRICS) - strategy_names = sorted(agg.keys()) - points = np.array([agg[s]["points_per_match"] for s in strategy_names]) - gd_per_match = np.array([agg[s]["goal_diff_per_match"] for s in strategy_names]) - - part_b_results = {} - for m in ALL_METRICS: - vals = np.array([agg[s][f"mean_diff_{m}"] for s in strategy_names]) - rho_pts, p_pts, n_pts = spearman(vals, points) - rho_gd, p_gd, n_gd = spearman(vals, gd_per_match) - part_b_results[m] = {"rho_points": rho_pts, "p_points": p_pts, "rho_gd": rho_gd, "p_gd": p_gd, "n": n_pts} - - # shot_backed_up_rate: pooled per-strategy rate (see - # pooled_shot_backed_up_rate_diff's docstring for why this can't use the - # mean-of-per-match-differentials framework the other metrics use above). - sbr_diff = pooled_shot_backed_up_rate_diff(main_rows) - sbr_vals = np.array([sbr_diff.get(s, float("nan")) for s in strategy_names]) - rho_pts, p_pts, n_pts = spearman(sbr_vals, points) - rho_gd, p_gd, n_gd = spearman(sbr_vals, gd_per_match) - part_b_results["shot_backed_up_rate (pooled)"] = { - "rho_points": rho_pts, - "p_points": p_pts, - "rho_gd": rho_gd, - "p_gd": p_gd, - "n": n_pts, - } - - ranked = sorted( - part_b_results.items(), key=lambda kv: -abs(kv[1]["rho_points"]) if not math.isnan(kv[1]["rho_points"]) else 0 - ) - - report_lines.append("Full ranking (by |rho vs points-per-match|):") - report_lines.append("") - report_lines.append("| metric | n strategies | rho vs points/match | p | rho vs goal-diff/match | p |") - report_lines.append("|---|---:|---:|---:|---:|---:|") - for m, res in ranked: - report_lines.append( - f"| {_mlabel(m)} | {res['n']} | {_fmt(res['rho_points'])} | {_fmt(res['p_points'])} | " - f"{_fmt(res['rho_gd'])} | {_fmt(res['p_gd'])} |" - ) - report_lines.append("") - - report_lines.append("### Top five metrics by |rho vs points-per-match|") - report_lines.append("") - report_lines.append("| rank | metric | rho vs points/match | p | rho vs goal-diff/match | p |") - report_lines.append("|---:|---|---:|---:|---:|---:|") - top5 = ranked[:5] - for i, (m, res) in enumerate(top5, 1): - report_lines.append( - f"| {i} | {m} | {_fmt(res['rho_points'])} | {_fmt(res['p_points'])} | " - f"{_fmt(res['rho_gd'])} | {_fmt(res['p_gd'])} |" - ) - report_lines.append("") - - # ---- Part B.5: per-strategy crashing_rate / out_of_bounds_rate ---- - # Not folded into per_strategy_aggregates()'s differential framework - # (crashing_rate/out_of_bounds_rate have no side split -- see the Part A - # comment above), so computed directly here: for each strategy, its own - # rate summed across every match it played (either side), same "own + - # opponent, summed over role" shape a-differential metrics don't need but - # a match-level total does, since a match-level count isn't attributable - # to one side. - report_lines.append("### B.5 Per-strategy crashing_rate / out_of_bounds_rate") - report_lines.append("") - report_lines.append( - "Match-level counts (no side split available) summed across every match a strategy played, either side, " - "then divided by matches played. Sorted by `out_of_bounds_rate` descending -- flagged for investigation " - "2026-09-04 after a user spot check found a 8-10x spread across strategies (not a uniform baseline) with " - "some individual matches hitting 40-58 events in 65s." - ) - report_lines.append("") - strategy_foul_totals: dict[str, dict] = {} - for row in all_rows: - rec = row["stats"].get("rule_event_counts", {}) if row["stats"] else {} - crashing_n = rec.get("crashing", 0) - oob_n = rec.get("out_of_bounds", 0) - for config in (row["config_a"], row["config_b"]): - s = strategy_foul_totals.setdefault(config, {"matches": 0, "crashing": 0, "out_of_bounds": 0}) - s["matches"] += 1 - s["crashing"] += crashing_n - s["out_of_bounds"] += oob_n - ranked_fouls = sorted( - strategy_foul_totals.items(), - key=lambda kv: -(kv[1]["out_of_bounds"] / kv[1]["matches"] if kv[1]["matches"] else 0), - ) - report_lines.append("| strategy | matches | crashing/match | out_of_bounds/match |") - report_lines.append("|---|---:|---:|---:|") - for name, s in ranked_fouls: - report_lines.append( - f"| {name} | {s['matches']} | {_fmt(s['crashing'] / s['matches'])} | {_fmt(s['out_of_bounds'] / s['matches'])} |" - ) - report_lines.append("") - - strat_points = {name: agg["points_per_match"] for name, agg in per_strategy_aggregates(all_rows, []).items()} - oob_rates = np.array([s["out_of_bounds"] / s["matches"] for _, s in ranked_fouls]) - points_arr = np.array([strat_points.get(name, float("nan")) for name, _ in ranked_fouls]) - rho_oob_pts, p_oob_pts, n_oob_pts = spearman(oob_rates, points_arr) - report_lines.append( - f"`out_of_bounds_rate` vs. points-per-match across the {len(ranked_fouls)} strategies: " - f"spearman rho={_fmt(rho_oob_pts)}, p={_fmt(p_oob_pts)}, n={n_oob_pts} -- does going out of bounds more " - "actually predict worse results for that strategy, or is it orthogonal to winning (e.g. a deliberate " - "relief-clearance pattern that costs nothing)." - ) - report_lines.append("") - - # ---- Part C: reliability ---- - report_lines.append("## C. Reliability: per-strategy metric value, run 101521 vs run 115838") - report_lines.append("") - report_lines.append( - "**Caveat: code changed between these runs** (stall/deadlock fixes landed on this branch between " - "101521, 112025, and 115838 -- see the git log). Any reliability number below is therefore a *lower " - "bound* on true metric reliability: some run-to-run disagreement here is genuine strategy-vs-strategy " - "noise, but some is the runner behaving differently, not the metric being noisy." - ) - report_lines.append("") - - run_a_name, run_b_name = args.reliability_runs - rows_a = [r for r in all_rows if r["run"] == run_a_name] - rows_b = [r for r in all_rows if r["run"] == run_b_name] - reliability = {} - if rows_a and rows_b: - agg_a = per_strategy_aggregates(rows_a, ALL_METRICS) - agg_b = per_strategy_aggregates(rows_b, ALL_METRICS) - common = sorted(set(agg_a) & set(agg_b)) - report_lines.append(f"Comparing {len(common)} strategies present in both `{run_a_name}` and `{run_b_name}`.") - report_lines.append("") - report_lines.append("| metric | n strategies | spearman rho (run-to-run) | p |") - report_lines.append("|---|---:|---:|---:|") - for m in ALL_METRICS: - va = np.array([agg_a[s][f"mean_diff_{m}"] for s in common]) - vb = np.array([agg_b[s][f"mean_diff_{m}"] for s in common]) - rho, p, n = spearman(va, vb) - reliability[m] = {"rho": rho, "p": p, "n": n} - report_lines.append(f"| {_mlabel(m)} | {n} | {_fmt(rho)} | {_fmt(p)} |") - - sbr_a = pooled_shot_backed_up_rate_diff(rows_a) - sbr_b = pooled_shot_backed_up_rate_diff(rows_b) - va = np.array([sbr_a.get(s, float("nan")) for s in common]) - vb = np.array([sbr_b.get(s, float("nan")) for s in common]) - rho, p, n = spearman(va, vb) - reliability["shot_backed_up_rate (pooled)"] = {"rho": rho, "p": p, "n": n} - report_lines.append(f"| shot_backed_up_rate (pooled) | {n} | {_fmt(rho)} | {_fmt(p)} |") - report_lines.append("") - - report_lines.append("### Reliability of the top-five B metrics") - report_lines.append("") - report_lines.append("| metric | validity rho (points/match) | reliability rho (run-to-run) | verdict |") - report_lines.append("|---|---:|---:|---|") - for m, res in top5: - rel = reliability.get(m, {"rho": float("nan")}) - v_rho = res["rho_points"] - r_rho = rel["rho"] - if not math.isnan(v_rho) and not math.isnan(r_rho): - if abs(v_rho) >= 0.3 and abs(r_rho) >= 0.5: - verdict = "valid & reliable -- good instrumentation candidate" - elif abs(v_rho) >= 0.3 and abs(r_rho) < 0.5: - verdict = "valid but unreliable -- likely noise, deprioritize" - elif abs(v_rho) < 0.3 and abs(r_rho) >= 0.5: - verdict = "reliable but not valid -- measures something other than winning" - else: - verdict = "neither valid nor reliable" - else: - verdict = "insufficient data" - report_lines.append(f"| {_mlabel(m)} | {_fmt(v_rho)} | {_fmt(r_rho)} | {verdict} |") - report_lines.append("") - else: - report_lines.append("*(one or both reliability runs not present in the provided `run_dirs`; skipped.)*") - report_lines.append("") - - old_draw_runs = [r for r in args.run_dirs if "20260902_2209" in r.name or "20260902_2223" in r.name] - if old_draw_runs: - report_lines.append( - "Two older 36-match, 9-strategy runs (`tournament_20260902_220936`, `tournament_20260902_222351`) " - "were all draws and cover fewer than half the strategy catalog -- not used quantitatively above " - "(too few decisive matches and too small a strategy set for a meaningful correlation), consistent " - "with the task's guidance to use them only for reliability spot-checks." - ) - report_lines.append("") - - # ---- Part D: recommendation ---- - report_lines.append("## D. Recommendation") - report_lines.append("") - - # Combined validity-x-reliability ranking, computed here (ahead of the "which - # metrics to instrument" subsection below) so the weighted proxy score and the - # instrument/drop lists are built from the same selection instead of two - # different top-N cuts. - combined = [] - for m, res in part_b_results.items(): - rel = reliability.get(m, {"rho": float("nan")}) - v_rho, r_rho = res["rho_points"], rel["rho"] - score = abs(v_rho) * abs(r_rho) if not (math.isnan(v_rho) or math.isnan(r_rho)) else float("-inf") - combined.append((m, v_rho, r_rho, score)) - combined.sort(key=lambda t: t[3], reverse=True) - n_strong = sum(1 for *_, s in combined if s >= 0.3) - n_keep = min(6, max(4, n_strong)) if n_strong >= 4 else min(6, len(combined)) - top_n = combined[:n_keep] - recommend_keep = [m for m, _v, _r, s in top_n if s != float("-inf")] - recommend_drop = [m for m, _v, _r, _s in combined if m not in recommend_keep] - - # shot_backed_up_rate (pooled) has no per-match `mean_diff_` entry in `agg` - # (it's computed separately -- see pooled_shot_backed_up_rate_diff), so the - # weighted-proxy fit below only includes metrics with a real `agg` column. - candidate_metrics = [m for m in recommend_keep if f"mean_diff_{m}" in next(iter(agg.values()), {})] - X_cols = [] - valid_metric_names = [] - for m in candidate_metrics: - vals = np.array([agg[s][f"mean_diff_{m}"] for s in strategy_names]) - if not np.all(np.isnan(vals)): - X_cols.append(vals) - valid_metric_names.append(m) - weighted = None - if X_cols: - X = np.column_stack(X_cols) - weighted = fit_weighted_proxy(valid_metric_names, X, gd_per_match) - - n_decisive = int(np.sum(~np.isnan(win_labels))) - report_lines.append( - f"**Honesty check first:** matches are 65 s and only {n_decisive}/{len(all_rows)} " - f"({100*n_decisive/max(1,len(all_rows)):.0f}%) are decisive across the analysed runs. Per-match AUCs in " - "part A are computed on ~22-26 matches per run; per-strategy correlations in part B have n=22 (one point " - "per strategy) and n=9 for the tiny reliability spot-check runs. None of these sample sizes support " - 'strong causal claims -- treat every number here as "consistent with" rather than "proves". The ' - "cleanest signal is the per-strategy aggregate (63 matches/strategy pools out a lot of single-match " - "noise), which is why part D's weights are fit there, not on individual matches." - ) - report_lines.append("") - - if weighted: - report_lines.append( - f"Weighted proxy score (OLS, goal-diff-per-match ~ intercept + weighted metrics; " - f"n={weighted['n']} strategies, R^2={_fmt(weighted['r2'])}):" - ) - report_lines.append("") - report_lines.append(f"`proxy_score = {_fmt(weighted['intercept'])}`") - for name, w in weighted["weights_per_unit"].items(): - report_lines.append(f" `+ ({_fmt(w, 5)}) * mean_diff_{name}`") - report_lines.append("") - report_lines.append( - "Units: `proxy_score` is in goals per match; each weight is per one raw unit of that metric's " - "`a-b` differential (e.g. per 1.0 of possession_pct differential, or per 1 extra shot_on_target). " - f"R^2={_fmt(weighted['r2'])} on n={weighted['n']} strategies -- with this few points, treat the " - "specific weight values as directionally suggestive, not a tuned production model." - ) - report_lines.append("") - - report_lines.append("### Which metrics to instrument live in MatchStats") - report_lines.append("") - report_lines.append( - "Combined score = `|validity rho (B, vs points/match)| x |reliability rho (C, run-to-run)|`, over every " - "metric analysed in B (including the pooled `shot_backed_up_rate`) -- rewards metrics that are both " - "predictive of winning and stable run-to-run, rather than gating on a hard top-five-only cutoff:" - ) - report_lines.append("") - report_lines.append("| metric | validity rho | reliability rho | combined score |") - report_lines.append("|---|---:|---:|---:|") - for m, v_rho, r_rho, score in combined: - report_lines.append( - f"| {_mlabel(m)} | {_fmt(v_rho)} | {_fmt(r_rho)} | {_fmt(score) if score != float('-inf') else 'n/a'} |" - ) - report_lines.append("") - report_lines.append(f"**Instrument these {len(recommend_keep)} live in `MatchStats`:**") - report_lines.append("") - for m in recommend_keep: - report_lines.append(f"- `{m}`") - report_lines.append("") - report_lines.append("**Drop or deprioritize:**") - report_lines.append("") - for m in recommend_drop: - report_lines.append(f"- `{m}`") - report_lines.append("") - report_lines.append( - "Note `possession_pct`, `robot_motion_pct`, and `possession_under_pressure_s` land in the drop list " - "despite `possession_pct`/`robot_motion_pct` already being free (already computed by `MatchStats` today) " - '-- "drop" here means "don\'t treat as a proxy for winning / don\'t weight in the proxy score", not ' - '"remove from `MatchStats`"; they may still be useful for other diagnostic purposes.' - ) - report_lines.append("") - report_lines.append(f"**Runtime:** full analysis over {len(all_rows)} matches took {time.time() - t_start:.1f}s.") - report_lines.append("") - - args.out.parent.mkdir(parents=True, exist_ok=True) - with open(args.out, "w") as f: - f.write("\n".join(report_lines)) - - json_out = args.out.with_suffix(".json") - with open(json_out, "w") as f: - json.dump( - { - "part_a": part_a_results, - "part_b": {m: res for m, res in part_b_results.items()}, - "part_b_top5": [m for m, _ in top5], - "reliability": reliability, - "weighted_proxy": weighted, - "n_matches": len(all_rows), - "n_decisive": n_decisive, - "runtime_s": time.time() - t_start, - }, - f, - indent=2, - ) - - print(f"Wrote {args.out} and {json_out} in {time.time() - t_start:.1f}s total") - - -if __name__ == "__main__": - main() diff --git a/tools/motion_planning_benchmark.py b/tools/motion_planning_benchmark.py index dd06e2a32..d4fec373a 100644 --- a/tools/motion_planning_benchmark.py +++ b/tools/motion_planning_benchmark.py @@ -46,11 +46,11 @@ from utama_core.entities.data.command import RobotCommand from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.global_utils.git_utils import git_revision -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.replay.git_utils import git_revision from utama_core.run import StrategyRunner -from utama_core.skills.src.utils.move_utils import move -from utama_core.team_controller.src.controllers import AbstractSimController +from utama_core.skills.utils.move_utils import move +from utama_core.team_controller.controllers import AbstractSimController from utama_core.tests.common.abstract_test_manager import ( AbstractTestManager, TestingStatus, @@ -666,7 +666,7 @@ def build(motion_controller: MotionController) -> KernelStrategy: ctx=TickContext(motion_controller=motion_controller), ) - return AbstractStrategy(build_kernel_strategy=build, exp_ball=False) + return AbstractStrategy(build=build, exp_ball=False) class _ControllerTimer: @@ -782,7 +782,7 @@ def __init__(self, scenario: Scenario, record_trace: bool = False): # controller commanded. Suppress `max_speed_mps`/ # `max_observed_acceleration_mps2` (and therefore `speed_limit_exceeded`) # for a short settling window per teleported robot -- the same - # estimator-transient caveat docs/motion_planning_comparison.md + # estimator-transient caveat docs/motion_planning.md # already documents for acceleration applies here too. self._settling_until_tick: dict[RobotKey, int] = {} # Measured directly (see the comment above): the simulator's @@ -961,7 +961,7 @@ def result(self) -> dict: # A real physical limit (RSIM_PARAMS.MAX_VEL, plus measurement # tolerance) is a hard pass/fail gate, unlike acceleration: observed # acceleration is reconstructed from filtered simulator velocity and - # can include estimator transients (see docs/motion_planning_comparison.md), + # can include estimator transients (see docs/motion_planning.md), # so it stays diagnostic-only rather than gating `passed`. speed_limit_exceeded = self.max_speed_mps > RSIM_PARAMS.MAX_VEL + SPEED_LIMIT_TOLERANCE return { @@ -1198,7 +1198,7 @@ def markdown_report(payload: dict) -> str: # --- Figures (`--figures DIR`) ------------------------------------------------------------- -# Style copied from tools/signal_report.py. matplotlib is imported only when figures are written, +# Style copied from tools/debug/figure_style.py. matplotlib is imported only when figures are written, # so a default run neither loads it nor changes its output. INK, INK_2, INK_3, SURFACE, GRID = "#0b0b0b", "#52514e", "#8a8984", "#fcfcfb", "#e4e3df" # Categorical slots in fixed order. A scheme keeps the same slot in every figure; slots are never cycled. diff --git a/utama_core/team_controller/src/__init__.py b/tools/realism/__init__.py similarity index 100% rename from utama_core/team_controller/src/__init__.py rename to tools/realism/__init__.py diff --git a/tools/convert_ssl_log.py b/tools/realism/convert_ssl_log.py similarity index 97% rename from tools/convert_ssl_log.py rename to tools/realism/convert_ssl_log.py index 37df43cdf..481c73c6b 100644 --- a/tools/convert_ssl_log.py +++ b/tools/realism/convert_ssl_log.py @@ -1,7 +1,7 @@ """Official RoboCup SSL game logs as replays in our format (`utama_core/replay/ssl_log.py`). - pixi run python tools/convert_ssl_log.py LOG_OR_DIR ... --out DIR [--raw-vision] - pixi run python tools/convert_ssl_log.py --corpus 2022-2026 --out DIR [--division div-b] [--jobs 4] + pixi run python tools/realism/convert_ssl_log.py LOG_OR_DIR ... --out DIR [--raw-vision] + pixi run python tools/realism/convert_ssl_log.py --corpus 2022-2026 --out DIR [--division div-b] [--jobs 4] [--raw-vision] [--backfill-extras] The first form converts game logs (`*.log.gz`; a directory: every log under it). The second @@ -44,7 +44,7 @@ from concurrent.futures import ProcessPoolExecutor from pathlib import Path -REPO_ROOT = Path(__file__).resolve().parents[1] +REPO_ROOT = Path(__file__).resolve().parents[2] if str(REPO_ROOT) not in sys.path: sys.path.insert(0, str(REPO_ROOT)) diff --git a/tools/realism_scorecard.py b/tools/realism/realism_scorecard.py similarity index 91% rename from tools/realism_scorecard.py rename to tools/realism/realism_scorecard.py index 83f22abcc..318ad686c 100644 --- a/tools/realism_scorecard.py +++ b/tools/realism/realism_scorecard.py @@ -3,12 +3,12 @@ """Realism scorecard: a round-robin's matches against real Division B matches, component by component (attempts, chance quality, keeper saves, misses, ball slow-down, kick speed ...). - # the real side, from converted official logs (`tools/convert_ssl_log.py`); rewrites the + # the real side, from converted official logs (`tools/realism/convert_ssl_log.py`); rewrites the # committed reference (xG model + real rows) - pixi run python tools/realism_scorecard.py --real ~/dev/ssl/official-logs/2025 ~/dev/ssl/official-logs/2026 + pixi run python tools/realism/realism_scorecard.py --real ~/dev/ssl/official-logs/2025 ~/dev/ssl/official-logs/2026 # a round-robin against the reference - pixi run python tools/realism_scorecard.py --sim replays/tournament_ + pixi run python tools/realism/realism_scorecard.py --sim replays/tournament_ Per-match shot records are cached: the real ones in `--real-cache`, the sim ones in `/realism_shots.jsonl`; a cache is reused unless `--refresh`. What each row means and @@ -23,7 +23,7 @@ from concurrent.futures import ProcessPoolExecutor from pathlib import Path -REPO_ROOT = Path(__file__).resolve().parent.parent +REPO_ROOT = Path(__file__).resolve().parents[2] if str(REPO_ROOT) not in sys.path: sys.path.insert(0, str(REPO_ROOT)) diff --git a/tools/signal_report.py b/tools/signal_report.py deleted file mode 100644 index 15249ba5a..000000000 --- a/tools/signal_report.py +++ /dev/null @@ -1,412 +0,0 @@ -"""Figures of a round-robin's strategy signals (`docs/signals.md`) for `docs/signal_report.md`. - - pixi run python tools/signal_report.py replays/tournament_ [--out docs/img/signals] - -Replays the run's saved matches through `turnover_breakdown.analyse_match` (which carries -`chances`), so it works on runs recorded before chances were measured; it covers the matches -whose replay is in the run directory. Every figure lists the strategies in one order, by points -per match, top first. Writes: - -- `results.png`: goals, shots and goals per shot, each for and against: goals per match is shots - times goals per shot, so it shows whether a strategy wins on volume or on quality; -- `signals.png`: one panel per main signal, every strategy a dot on the signal's own scale, the - median dashed; -- `shot_quality.png`: goals per shot by distance and open goal mouth, over the whole run; -- `fouls.png`: fouls per match by rule (the ball going out is not a foul: its own panel), with - the stalled matches; -- `ball_losses.png`: real ball losses per match by kind, for strategies with at least - `MIN_LOSS_MATCHES` matches as config_a (losses are measured for config_a only). - -It also prints the figures' numbers as a markdown table, for the report and for reading without -the images. -""" - -from __future__ import annotations - -import argparse -import json -import sys -from pathlib import Path -from typing import Callable, Optional - -import matplotlib - -matplotlib.use("Agg") -import matplotlib.pyplot as plt # noqa: E402 -import numpy as np # noqa: E402 - -REPO_ROOT = Path(__file__).resolve().parents[1] -if str(REPO_ROOT) not in sys.path: - sys.path.insert(0, str(REPO_ROOT)) - -from utama_core.analysis import turnover_breakdown # noqa: E402 -from utama_core.analysis.strategy_table import strategy_table # noqa: E402 - -INK, INK_2, INK_3, SURFACE, GRID = "#0b0b0b", "#52514e", "#8a8984", "#fcfcfb", "#e4e3df" -FOR, AGAINST = "#2a78d6", "#eb6834" # categorical slots 1 and 2 -# Categorical slots in fixed order (validated adjacent-pair for stacks); never cycled. -SLOTS = ["#2a78d6", "#eb6834", "#1baf7a", "#eda100", "#e87ba4", "#008300", "#6250d6"] -MIN_LOSS_MATCHES = 5 - -plt.rcParams.update( - { - "figure.facecolor": SURFACE, - "axes.facecolor": SURFACE, - "axes.edgecolor": INK_3, - "axes.labelcolor": INK_2, - "axes.titlesize": 10, - "axes.titlecolor": INK, - "axes.spines.top": False, - "axes.spines.right": False, - "xtick.color": INK_2, - "ytick.color": INK, - "font.size": 9, - } -) - - -def short(name: str) -> str: - return name.removeprefix("build_").removesuffix("_kernel_strategy") - - -def points(row: dict) -> float: - return (3 * row["wins"] + row["draws"]) / max(1, row["matches"]) - - -def _order(table: dict) -> list[str]: - return sorted(table, key=lambda n: -points(table[n])) - - -def _per_match(key: str) -> Callable[[dict], Optional[float]]: - return lambda r: r[key] / r["matches"] if r["matches"] else None - - -def _chance(key: str) -> Callable[[dict], Optional[float]]: - return lambda r: r["chances"].get(key) - - -def _ratio(num: str, den: str) -> Callable[[dict], Optional[float]]: - return lambda r: r[num] / r[den] if r[den] else None - - -# (label, value, which way usually helps: "higher" / "lower" / "", format) -SIGNALS = [ - ("attacking-third entries / match", _per_match("attacking_third_entries"), "higher", "{:.1f}"), - ("regains followed by a shot", _chance("regain_to_shot"), "higher", "{:.0%}"), - ("free kicks followed by a shot", _chance("free_kick_to_shot"), "higher", "{:.0%}"), - ("shot distance (m)", _chance("shot_distance_m"), "lower", "{:.1f}"), - ("goal mouth open, own shots", _chance("shot_open_goal"), "higher", "{:.0%}"), - ("completed passes / match", _per_match("completed_passes"), "", "{:.0f}"), - ("metres gained per pass", lambda r: r["pass_progress_m"], "higher", "{:.2f}"), - ("danger conceded (s / match)", _chance("danger_s_per_match"), "lower", "{:.0f}"), - ("goal mouth open, shots faced", _chance("faced_open_goal"), "lower", "{:.0%}"), - ("save rate", _chance("save_rate"), "higher", "{:.0%}"), -] - - -def _ylabels(ax, names: list[str], table: dict, show: bool = True) -> None: - ax.set_yticks(range(len(names))) - if show: # shared y: clearing one panel's labels would clear them all, so hide them instead - ax.set_yticklabels([f"{short(n)} {points(table[n]):.2f}" for n in names]) - ax.set_ylim(len(names) - 0.5, -0.5) - ax.tick_params(axis="y", length=0, labelleft=show) - ax.spines["left"].set_visible(False) - ax.grid(axis="x", color=GRID, lw=0.8) - ax.set_axisbelow(True) - - -def _dumbbell(ax, names, table, value_for, value_against, fmt) -> None: - for i, n in enumerate(names): - a, b = value_for(table[n]), value_against(table[n]) - if a is None or b is None: - continue - ax.plot([a, b], [i, i], color=INK_3, lw=2, solid_capstyle="round", zorder=1) - ax.scatter([b], [i], s=64, color=AGAINST, edgecolors=SURFACE, linewidths=2, zorder=2) - ax.scatter([a], [i], s=64, color=FOR, edgecolors=SURFACE, linewidths=2, zorder=3) - ax.xaxis.set_major_formatter(plt.FuncFormatter(lambda v, _: fmt.format(v))) - - -def results(table: dict, path: Path) -> None: - names = _order(table) - fig, axes = plt.subplots(1, 3, figsize=(13, 0.36 * len(names) + 1.9), sharey=True) - panels = [ - ("goals per match", _per_match("goals_for"), _per_match("goals_against"), "{:.0f}"), - ("shots per match", _per_match("shots"), _per_match("shots_faced"), "{:.0f}"), - ("goals per shot", _ratio("goals_for", "shots"), _ratio("goals_against", "shots_faced"), "{:.0%}"), - ] - for k, (ax, (title, f, a, fmt)) in enumerate(zip(axes, panels)): - _dumbbell(ax, names, table, f, a, fmt) - _ylabels(ax, names, table, show=k == 0) - ax.set_title(title, loc="left") - axes[0].set_xlim(left=0) - axes[1].set_xlim(left=0) - axes[2].set_xlim(left=0) - handles = [ - plt.Line2D([], [], marker="o", ls="", color=FOR, markersize=8, label="for (scored, shots made)"), - plt.Line2D([], [], marker="o", ls="", color=AGAINST, markersize=8, label="against (conceded, shots faced)"), - ] - fig.legend(handles=handles, loc="upper left", ncol=2, frameon=False, bbox_to_anchor=(0.0, 1.0)) - fig.suptitle( - "Why each strategy gets its results: goals per match = shots x goals per shot " - "(strategies by points per match, the number after the name)", - x=0.0, - ha="left", - y=1.07, - fontsize=10, - color=INK, - ) - fig.tight_layout() - fig.savefig(path, dpi=130, bbox_inches="tight") - plt.close(fig) - - -def signals(table: dict, path: Path, cols: int = 5) -> None: - names = _order(table) - rows = -(-len(SIGNALS) // cols) - fig, axes = plt.subplots(rows, cols, figsize=(3.0 * cols + 2.2, (0.3 * len(names) + 1.1) * rows), sharey=True) - for k, (ax, (label, value, helps, fmt)) in enumerate(zip(axes.flat, SIGNALS)): - vals = [value(table[n]) for n in names] - present = [(i, v) for i, v in enumerate(vals) if v is not None] - ax.scatter( - [v for _, v in present], [i for i, _ in present], s=56, color=FOR, edgecolors=SURFACE, lw=2, zorder=3 - ) - if present: - ax.axvline(float(np.median([v for _, v in present])), color=INK_3, lw=1, ls="--", zorder=1) - lo = min(present, key=lambda p: p[1]) - hi = max(present, key=lambda p: p[1]) - for i, v in (lo, hi): # label only the extremes; the table has every value - ax.annotate( - fmt.format(v), - (v, i), - xytext=(0, 7), - textcoords="offset points", - ha="center", - fontsize=8, - color=INK_2, - ) - ax.xaxis.set_major_formatter(plt.FuncFormatter(lambda v, _, f=fmt: f.format(v))) - ax.xaxis.set_major_locator(plt.MaxNLocator(4)) - _ylabels(ax, names, table, show=k % cols == 0) - ax.set_title(label + (f" ({helps} helps)" if helps else ""), loc="left", fontsize=9) - for ax in list(axes.flat)[len(SIGNALS) :]: - ax.set_visible(False) - fig.suptitle( - "Signals per strategy, each on its own scale (dashed: median of the 12; labels: lowest and highest)", - x=0.0, - ha="left", - fontsize=10, - color=INK, - ) - fig.tight_layout() - fig.savefig(path, dpi=130, bbox_inches="tight") - plt.close(fig) - - -DIST_BINS = [0.0, 1.5, 2.0, 2.5, 3.0, 3.5, 10.0] -OPEN_BINS = [0.0, 0.25, 0.5, 0.75, 1.01] -MIN_CELL_SHOTS = 15 - - -def shot_quality(shots: list[dict], path: Path) -> None: - goals = np.zeros((len(OPEN_BINS) - 1, len(DIST_BINS) - 1)) - count = np.zeros_like(goals) - for s in shots: - i = np.searchsorted(OPEN_BINS, s["open_goal"], side="right") - 1 - j = np.searchsorted(DIST_BINS, s["distance_m"], side="right") - 1 - count[i, j] += 1 - goals[i, j] += s["scored"] - rate = np.divide(goals, count, out=np.full_like(goals, np.nan), where=count >= MIN_CELL_SHOTS) - fig, ax = plt.subplots(figsize=(8, 4.2)) - cmap = matplotlib.colors.LinearSegmentedColormap.from_list("blue", ["#cde2fb", "#6da7ec", "#256abf", "#0d366b"]) - cmap.set_bad(GRID) - im = ax.imshow(np.ma.masked_invalid(rate), cmap=cmap, vmin=0, vmax=1, origin="lower", aspect="auto") - for i in range(rate.shape[0]): - for j in range(rate.shape[1]): - n = int(count[i, j]) - if n >= MIN_CELL_SHOTS: - ax.text( - j, - i, - f"{rate[i, j]:.0%}\n{n} shots", - ha="center", - va="center", - fontsize=8, - color=SURFACE if rate[i, j] > 0.45 else INK, - ) - elif n: - ax.text(j, i, f"{n} shots", ha="center", va="center", fontsize=7, color=INK_2) - ax.set_xticks(range(len(DIST_BINS) - 1)) - ax.set_xticklabels([f"{a:g}-{b:g}" if b < 10 else f">{a:g}" for a, b in zip(DIST_BINS, DIST_BINS[1:])]) - ax.set_yticks(range(len(OPEN_BINS) - 1)) - ax.set_yticklabels([f"{a:.0%}-{min(b, 1):.0%}" for a, b in zip(OPEN_BINS, OPEN_BINS[1:])]) - ax.set_xlabel("shot distance to goal centre (m)") - ax.set_ylabel("goal mouth open at the shot") - ax.tick_params(length=0) - for sp in ax.spines.values(): - sp.set_visible(False) - ax.set_title( - f"Goals per shot, all {len(shots)} shots of the run (grey: under {MIN_CELL_SHOTS} shots, no rate)", loc="left" - ) - fig.colorbar(im, ax=ax, label="goals per shot", format=plt.FuncFormatter(lambda v, _: f"{v:.0%}")) - fig.tight_layout() - fig.savefig(path, dpi=130) - plt.close(fig) - - -def _stacked(ax, names, parts: list[tuple[str, list[float]]]) -> None: - left = np.zeros(len(names)) - for k, (label, vals) in enumerate(parts): - v = np.array(vals, dtype=float) - ax.barh( - range(len(names)), v, left=left, height=0.62, color=SLOTS[k], label=label, edgecolor=SURFACE, linewidth=2 - ) - left += v - - -LOSS_KINDS = [ - "tackled", - "ball_out_after_kick", - "shot_saved_or_blocked", - "pass_intercepted", - "loose_ball_lost", - "foul", - "ball_out_other", -] - - -def ball_losses(table: dict, path: Path) -> None: - names = [n for n in _order(table) if table[n]["matches_as_a"] >= MIN_LOSS_MATCHES] - fig, ax = plt.subplots(figsize=(10, 0.36 * len(names) + 1.8)) - parts = [ - ( - kind.replace("_", " "), - [table[n]["real_loss_kinds_as_a"].get(kind, 0) / table[n]["matches_as_a"] for n in names], - ) - for kind in LOSS_KINDS - ] - _stacked(ax, names, parts) - ax.set_yticks(range(len(names))) - ax.set_yticklabels([f"{short(n)} ({table[n]['matches_as_a']} matches)" for n in names]) - ax.set_ylim(len(names) - 0.5, -0.5) - ax.tick_params(axis="y", length=0) - ax.spines["left"].set_visible(False) - ax.grid(axis="x", color=GRID, lw=0.8) - ax.set_axisbelow(True) - ax.set_xlabel("real ball losses per match (not won back within 1 s)") - ax.set_title( - f"How each strategy loses the ball (as config_a only; strategies with {MIN_LOSS_MATCHES}+ such matches)", - loc="left", - ) - ax.legend(ncol=4, frameon=False, loc="upper left", bbox_to_anchor=(0, -0.12 - 0.3 / max(1, len(names)))) - fig.tight_layout() - fig.savefig(path, dpi=130, bbox_inches="tight") - plt.close(fig) - - -BALL_OUT = "out_of_bounds" - - -def _fouls_per_match(summary: dict, table: dict) -> dict[str, dict[str, float]]: - out: dict[str, dict[str, float]] = {n: {} for n in table} - for rule, info in summary["fouls"].items(): - for key, count in info["by_tactic"].items(): - strategy = f"build_{key.split('/')[0]}_kernel_strategy" - if strategy in table: - out[strategy][rule] = out[strategy].get(rule, 0.0) + count / table[strategy]["matches"] - return out - - -def fouls(summary: dict, table: dict, path: Path, top: int = 5) -> None: - names = _order(table) - per = _fouls_per_match(summary, table) - rules = [r for r in summary["fouls"] if r != BALL_OUT] - shown = sorted(rules, key=lambda r: -summary["fouls"][r]["total"])[:top] - parts = [(r.replace("_", " "), [per[n].get(r, 0.0) for n in names]) for r in shown] - parts.append(("other", [sum(v for r, v in per[n].items() if r not in shown and r != BALL_OUT) for n in names])) - fig, (a, b) = plt.subplots( - 1, 2, figsize=(13, 0.36 * len(names) + 2.0), sharey=True, gridspec_kw={"width_ratios": [3, 1]} - ) - _stacked(a, names, parts) - for i, n in enumerate(names): - total = sum(v for _, vals in parts for v in [vals[i]]) - stalled = table[n]["stalled"] - if stalled: - a.text(total + 0.1, i, f"{stalled} stalled", va="center", fontsize=8, color=INK_2) - _ylabels(a, names, table) - a.set_title("fouls per match, by rule", loc="left") - a.legend(ncol=6, frameon=False, loc="upper left", bbox_to_anchor=(0, -0.08 - 0.3 / len(names))) - b.barh(range(len(names)), [per[n].get(BALL_OUT, 0.0) for n in names], height=0.62, color=INK_3) - _ylabels(b, names, table, show=False) - b.set_title("ball out of play per match (not a foul)", loc="left") - fig.suptitle( - "Fouls by the offending strategy, and the matches it stalled in (each stall counts for both teams)", - x=0.0, - ha="left", - fontsize=10, - color=INK, - ) - fig.tight_layout() - fig.savefig(path, dpi=130, bbox_inches="tight") - plt.close(fig) - - -def markdown(table: dict) -> str: - """The figures' numbers, one row per strategy in the figures' order.""" - cols = [ - ("points / match", points, "{:.2f}"), - ("GF", _per_match("goals_for"), "{:.1f}"), - ("GA", _per_match("goals_against"), "{:.1f}"), - ("shots", _per_match("shots"), "{:.1f}"), - ("shots faced", _per_match("shots_faced"), "{:.1f}"), - ("goals / shot", _ratio("goals_for", "shots"), "{:.0%}"), - ("conceded / shot faced", _ratio("goals_against", "shots_faced"), "{:.0%}"), - ] + [(label, value, fmt) for label, value, _, fmt in SIGNALS] - lines = ["| strategy | " + " | ".join(c[0] for c in cols) + " |", "|---" * (len(cols) + 1) + "|"] - for n in _order(table): - cells = [] - for _, value, fmt in cols: - v = value(table[n]) - cells.append("-" if v is None else fmt.format(v)) - lines.append(f"| `{short(n)}` | " + " | ".join(cells) + " |") - return "\n".join(lines) - - -def build(summary: dict, losses: list[dict], out: Path) -> dict: - """Write every figure for `summary` (a round-robin's summary.json) and its replays' - `turnover_breakdown.analyse_match` records. Returns the strategy table plotted, each row - with `shots_faced` added.""" - out.mkdir(parents=True, exist_ok=True) - real = {r["match"]: turnover_breakdown.real_loss_kinds(r) for r in losses} - chances_by_match = {r["match"]: r["chances"] for r in losses if "chances" in r} - table = strategy_table(summary["results"], real, chances_by_match) - for row in table.values(): - row["shots_faced"] = 0 - for r in summary["results"]: - shots = (r.get("stats") or {}).get("shots") or {} - for name, theirs in ((r["config_a"], "enemy"), (r["config_b"], "friendly")): - if name in table: - table[name]["shots_faced"] += shots.get(theirs, 0) - shots = [s for c in chances_by_match.values() for s in c["shots"]] - results(table, out / "results.png") - signals(table, out / "signals.png") - shot_quality(shots, out / "shot_quality.png") - ball_losses(table, out / "ball_losses.png") - fouls(summary, table, out / "fouls.png") - return table - - -def main() -> None: - parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0]) - parser.add_argument("run_dir", type=Path) - parser.add_argument("--out", type=Path, default=REPO_ROOT / "docs" / "img" / "signals") - parser.add_argument("--workers", type=int, default=8) - args = parser.parse_args() - summary = json.loads((args.run_dir / "summary.json").read_text()) - losses = turnover_breakdown.analyse_run(args.run_dir, args.workers) - table = build(summary, losses, args.out) - print(f"{len(losses)} of {len(summary['results'])} matches had a replay; figures in {args.out}\n") - print(markdown(table)) - - -if __name__ == "__main__": - main() diff --git a/docs/real_robot_setup.md b/tutorials/field_day.md similarity index 90% rename from docs/real_robot_setup.md rename to tutorials/field_day.md index 0de60f5ef..75e59fe3b 100644 --- a/docs/real_robot_setup.md +++ b/tutorials/field_day.md @@ -1,13 +1,13 @@ -# Real robots: setting up and checking vision and radio +# A field day with real robots The procedure for a test day with real robots: ssl-vision on its own Linux laptop sending vision over the network, and our stack on a Windows laptop in WSL with the radio dongle. Each part is -checked on its own before anything drives a robot: vision with `tools/vision_check.py`, the radio -with teleop, then both together in the field check of `examples/shooting_drill.py`. +checked on its own before anything drives a robot: vision with `tools/field/vision_check.py`, the radio +with teleop, then both together in the field check of `tools/field/shooting_drill.py`. ``` vision laptop (Linux) robot laptop (Windows + WSL) - cameras -> ssl-vision --multicast--> tools/vision_check.py, then the runner + cameras -> ssl-vision --multicast--> tools/field/vision_check.py, then the runner 224.5.23.2:10006 radio dongle (USB, passed into WSL) -> robots ``` @@ -22,7 +22,7 @@ vision laptop (Linux) robot laptop (Windows + WSL) README lists, then `sudo sh install_spinnaker.sh`: yes to the udev entry (add your user to `flirimaging`) and to USB-FS 1000 MB. Build ssl-vision with `cmake -B build -DUSE_SPINNAKER=true -DUSE_V4L=true && make -C build`. -2. Add our field as a preset: `git apply tools/ssl-vision-lab-field.patch` in the ssl-vision +2. Add our field as a preset: `git apply tools/field/ssl-vision-lab-field.patch` in the ssl-vision checkout (copy the file over), then rebuild. Field Configuration gets a **Lab Field** button (3 m x 2.25 m, goal 0.8 m, defense area 1 m x 0.5 m, two cameras). Do not use the Division B button with two cameras: it sets the camera count to 1. @@ -91,14 +91,14 @@ with **Save Settings**, not on a crash. On the robot laptop, in WSL: ``` -pixi run python tools/vision_check.py +pixi run python tools/field/vision_check.py ``` Expect each camera at about its frame rate and the field at 3000 x 2250 mm. Nothing at all means the network or the firewall (steps 3-4 above, step 1 here); one camera missing means its capture is not running. -After a calibration, check it against known spots: `tools/vision_check.py --guided ball`, then +After a calibration, check it against known spots: `tools/field/vision_check.py --guided ball`, then `--guided "blue 2"` (any robot, facing +x). It asks for the ball or robot on the 9 points (corners, edge midpoints, centre) and prints each camera's error there; the results land in `replays/field/*_vision_truth_*.json` to compare with the next setup. The pattern points at the @@ -131,11 +131,11 @@ radio IDs must differ across all robots on it. ### 4. Both together -Set the "Test-day configuration" block of `examples/shooting_drill.py`: `FIELD`, +Set the "Test-day configuration" block of `tools/field/shooting_drill.py`: `FIELD`, `CAMERA_HALF` (`"full"` when the cameras cover the whole field), each robot's vision and radio -ID and working hardware. Then `pixi run python examples/shooting_drill.py`, open +ID and working hardware. Then `pixi run python tools/field/shooting_drill.py`, open http://localhost:8080 and go through the Live tab's field check -([custom_referee_gui.md](custom_referee_gui.md#field-check-camera-runs)): every row green or +([referee.md, "Operator panel"](../docs/referee.md#operator-panel)): every row green or amber, each robot under its own ID and colour, a ball in each corner inside the area in play, and a robot pushed by hand across the cameras' overlap moving smoothly (a jump there means the two calibrations disagree). Only then Force Start. @@ -187,7 +187,7 @@ robots), and the pattern that turned with it is its lid. It prints radio, lid an profile was calibrated on that lid (a profile's tag offset is its lid's: calibrate again after a swap), and the radios that did not answer and patterns no radio turned. The pairing is saved on this machine (`replays/field/robots_found.json`). The robots an example uses are chosen by radio -(`RADIO_0`, `RADIO_1` in `shooting_drill.py`), one per colour, and no vision ID or colour is +(`RADIO_0`, `RADIO_1` in `tools/field/shooting_drill.py`), one per colour, and no vision ID or colour is written by hand: on real robots an example starts by watching vision for 0.5 s (nothing moves). With each robot's saved lid in view it uses them; otherwise (never run here, a lid missing) it finds those robots again first (`find_robots.confirm`). It cannot tell two robots in use that @@ -205,10 +205,10 @@ pixi run calibrate --radio 0 --check # the new profile against the committ Without both `--robot colour:id` and `--radio` it looks the robot up: with `--radio`, as the examples do; with neither, by `find-robots`. -No dashboard: it runs in the terminal (`examples/calibrate_robot.py`). Once vision sees the robot +No dashboard: it runs in the terminal (`tools/field/calibrate_robot.py`). Once vision sees the robot it asks you to put it near the middle of the camera's view facing +x, with 0.8 m clear ahead, 0.6 m to its left and a ball at rest in view; press Enter. It drives and turns for about 65 s. -Then the ball part (`examples/ball_trials.py`), where **the robot fetches the ball itself**: +Then the ball part (`tools/field/ball_trials.py`), where **the robot fetches the ball itself**: - **Carry ladder**: it carries the ball 0.5 m forward, backward, left and right, and half a turn each way, at rising speeds (0.2 to 1 m/s, 0.5 to 4 rad/s), twice each (`--repeats`), from @@ -236,10 +236,8 @@ which every example reads (`load_profile`). Nothing to copy by hand: - `carry_speed`, `carry_turn`: the carry ladder's slowest direction, the fastest speed it kept the ball every time; `move()` holds this robot to them (`RobotParams.CARRY_*` otherwise). -rsim kicks a robot given its profile as it measured (`real_kick.py`): at its kick speed, off its -heading by its bias and bend, scattered by its spread, and passes and shots aim against bend and -bias there too. So an example rehearsed in rsim (`--mode rsim`) kicks like the robot on the field. -Matches without profiles (the strategy evaluation) keep the sim's own kick. +rsim keeps its own kick, and kick bend and bias are applied on real robots only, so a rehearsal in +rsim (`--mode rsim`) does not kick like the robot on the field. **Kicker charge in play.** On real robots a robot that has not kicked for 25 s fires an empty kick, when the ball is neither on it (ball sensor) nor within 30 cm (vision), and never in a HALT @@ -263,7 +261,7 @@ the new profile is no worse. Ten kicks a side tell apart only differences of a f Calibrate every robot, twice per session (early and late): how far the two runs disagree is how far to trust them. An older log is measured again with -`pixi run python tools/robot_calibration.py replays/field/.log --tag yellow:0 0 -0.002` +`pixi run python tools/field/robot_calibration.py replays/field/.log --tag yellow:0 0 -0.002` (`--tag` per robot: its `tag_forward_m`, `tag_left_m`). @@ -277,4 +275,6 @@ far to trust them. An older log is measured again with | `tee: .../usbfs_memory_mb: No such file` | WSL loads USB support only once a device is attached; `/etc/modprobe.d/usbfs.conf` with `options usbcore usbfs_memory_mb=1000` sets it then | | Whole image tinted one colour | White balance stuck at an extreme (2800 K): auto, then lock | | `vision_check` sees nothing | Different networks, Wi-Fi multicast, `.wslconfig` not mirrored, or the firewall rule missing | -| Dashboard: "Address already in use" | Another dashboard (`dashboard_server.py`) holds 8080: stop it | +| Dashboard: "Address already in use" | Another dashboard (`pixi run dashboard`) holds 8080: stop it | + +What the field logs hold and the external tools (grSim, GameController, ssl-vision): [docs/real_robots.md](../docs/real_robots.md). diff --git a/tutorials/first_strategy.md b/tutorials/first_strategy.md new file mode 100644 index 000000000..5133da1ef --- /dev/null +++ b/tutorials/first_strategy.md @@ -0,0 +1,219 @@ +# Your first strategy + +This page takes you from zero to a strategy of your own, playing in the simulator. +You need no knowledge of the codebase. Allow about an hour and a half. + +First, install everything: follow steps 1 to 3 of the [README](../README.md#quick-start). + +## 1. Watch a match + +``` +pixi run main +``` + +A window opens and two strategies play football. Yellow plays `pendulum`. Blue plays `wolfpack`. +Press Ctrl+C to stop. + +You can pick any two strategies: + +``` +pixi run main riptide terrier +``` + +Step 2 shows every strategy on the dashboard. + +## 2. Look around our strategies + +The dashboard shows every strategy, how it plays and replays of its matches. To fill it, download +[`replays-v2.6.0.zip`](https://github.com/First-Order-RoboCup-SSL/Utama-Core/releases/download/v2.6.0/replays-v2.6.0.zip) +(160 MB: the core strategies playing each other once) and unpack it: + +``` +pixi run python -m zipfile -e replays-v2.6.0.zip replays/ +pixi run dashboard +``` + +Open http://localhost:8080 and click **Strategies**. + +![A strategy's page](img/dashboard/strategy_page.png) + +- **On the pitch**: where its robots stand with the ball and without it (darker is more time), and + where its shots came from. Every picture attacks to the right. +- **How it plays**: each number beside the other strategies' average. These explain a style; more is + not always better. +- **Matches**: click ▶ to watch one. + +![A replay](img/dashboard/replay.png) + +The replay shows the robots, the referee's decisions and which tactic each robot ran, on a timeline +under the pitch. The list on the right has one row per restart or ball won; click a row to jump to it. + +Pick two strategies with different maps and watch a match of each. What do they do differently? + +## 3. Three words you need + +- **Strategy**: decides what the whole team does. One file in `utama_core/strategy/`. + The file's name is the strategy's name. +- **Tactic**: tells a group of robots what to do, every tick (60 times a second). + A strategy is made of one or more tactics. +- **Skill**: one robot action, like "go to the ball" or "go to this point". + Tactics use skills. + +The goalkeeper is handled for you. Your strategy controls the other five robots. +Restarts (kickoffs, free kicks, stops) are also handled for you. + +## 4. Make a branch + +``` +git switch main +git pull +git switch -c strategy/rookie +``` + +## 5. Write the strategy + +Create the file `utama_core/strategy/rookie.py` and paste this in: + +```python +# utama_core/strategy/rookie.py +"""`rookie`: the robot nearest the ball chases it and kicks it forward. The others follow the play.""" + +from utama_core.engine.context import TickContext +from utama_core.engine.strategy import Strategy +from utama_core.engine.tactic import BaseTactic, TacticTag +from utama_core.entities.data.vector import Vector2D +from utama_core.skills.go_to_ball import go_to_ball +from utama_core.skills.go_to_point import go_to_point +from utama_core.skills.kick_upfield import kick_upfield + +LANES = [-2.0, -0.7, 0.7, 2.0] # where the helpers stand across the pitch (y, metres) + + +class ChaseAndKick(BaseTactic[None]): + tag = TacticTag.ATTACK + + def initial_mem(self): + return None # this tactic remembers nothing between ticks + + def tick(self, game, ctx, robot_ids, mem): + if not robot_ids or game.ball is None: + return {}, mem + ball = game.ball.p + robots = game.friendly_robots + + # The robot nearest the ball is the chaser. + chaser = min(robot_ids, key=lambda i: robots[i].p.distance_to(ball)) + # +1 if our goal is on the right, -1 if it is on the left. + back = 1 if game.field.my_goal_line[0][0] > 0 else -1 + + commands = {} + if robots[chaser].has_ball: + commands[chaser] = kick_upfield(game, ctx.motion_controller, chaser) + else: + commands[chaser] = go_to_ball(game, ctx.motion_controller, chaser) + + # The helpers stand 1 m behind the ball, spread across the pitch. + helpers = [i for i in robot_ids if i != chaser] + x = ball.x + back * 1.0 + x = max(-3.3, min(3.3, x)) # stay out of the goal areas + for i, y in zip(helpers, LANES): + commands[i] = go_to_point(game, ctx.motion_controller, i, Vector2D(x, y)) + return commands, mem + + +def build(outfield_robot_ids, motion_controller): + return Strategy( + tactics={"chase": ChaseAndKick()}, + partitioner=Strategy.single_tactic_picker(lambda game, active: "chase"), + outfield_robot_ids=outfield_robot_ids, + ctx=TickContext(motion_controller=motion_controller), + ) +``` + +What it does: + +- `tick` runs 60 times a second. It gets the game (`game`) and the robots it controls (`robot_ids`). +- It returns one command per robot. +- `build` puts the tactic into a strategy. Every strategy file needs a `build` function. + +## 6. Watch it play + +``` +pixi run main rookie wolfpack +``` + +Your team is yellow. Does the chaser reach the ball? Do the helpers follow the play? + +## 7. Change something + +Try one small change, then watch again: + +- Move the helpers closer to the ball: change `1.0` to `0.5`. +- Put the helpers in front of the ball instead: change `back * 1.0` to `-back * 1.0`. +- Use fewer lanes, so one robot stays near your goal. + +Change one thing at a time, so you know what made the difference. + +## 8. Test it + +``` +pixi run pytest utama_core/tests/engine/test_all_strategy_configs.py --headless +pixi run test +pixi run lint +``` + +All three must pass before you open a pull request. + +## 9. Is it better? Run an evaluation + +Watching one match is not enough. Football is full of luck. +The evaluation plays many matches and tells you if your strategy beats the champion (our best strategy). + +``` +pixi run evaluate rookie +``` + +This takes a while: matches play in the background, several at a time. +Matches that were already played are reused, so a second run is faster. + +At the end, look at the **verdict** line: + +``` +rookie DROPPED in the screen after 2 round(s): mean diff -1.20 ± 0.40 goals/match ... +``` + +Read two things: + +1. **The verdict.** + - `BETTER`: it beats the champion. Well done. + - `DROPPED`: it is not better. Most new strategies end here. That is normal. + - `UNDECIDED`: maybe a little better, but not clearly. Treat it as not better. +2. **The mean diff.** How many more goals per match your strategy scores than the champion, + against the same opponents. +0.5 means half a goal per match better. Negative means worse. + +Ignore everything else in the output for now. + +Then open the dashboard again: `rookie` is on the **Strategies** tab with its verdict, its maps +and its matches, beside the strategies you looked at in step 2. + +## 10. Now let an agent write one + +You know how a strategy works now. A coding agent (Claude Code, Codex, Cursor or another) can write and +test new ones much faster. This repo has step-by-step guides for agents in `.agents/skills/`; the one +for strategies is `change-strategy`. + +Open your agent in the repo and ask, for example: + +> Follow the change-strategy skill (.agents/skills/change-strategy/SKILL.md). Make a new strategy where two robots always defend near our goal +> and three attack. + +The agent makes the branch, writes the strategy, runs the tests and asks you before it runs +an evaluation. Read what it wrote. Watch the strategy with `pixi run main wolfpack`. +You decide what to keep. + +## Where to go next + +- [strategy.md](../docs/strategy.md): how strategies and tactics really work. + Read it when you want to write a proper tactic. +- `utama_core/tactics/`: real tactics to copy from. +- `utama_core/skills/`: every skill a robot can use. diff --git a/tutorials/img/dashboard/replay.png b/tutorials/img/dashboard/replay.png new file mode 100644 index 000000000..d2a176d71 Binary files /dev/null and b/tutorials/img/dashboard/replay.png differ diff --git a/tutorials/img/dashboard/strategy_page.png b/tutorials/img/dashboard/strategy_page.png new file mode 100644 index 000000000..d52e69c1c Binary files /dev/null and b/tutorials/img/dashboard/strategy_page.png differ diff --git a/utama_core/analysis/chances.py b/utama_core/analysis/chances.py index c6c1fcd0d..f2d0855cb 100644 --- a/utama_core/analysis/chances.py +++ b/utama_core/analysis/chances.py @@ -2,7 +2,7 @@ `turnover_breakdown.analyse_match` feeds every replay frame to a `ChanceTracker`, so this costs no extra pass over the replay. Its record is under `chances` in each match's ball-loss -record; `round_robin.py` totals it per strategy (`side_totals`, `rates`) into +record; `evaluate.py` totals it per strategy (`side_totals`, `rates`) into `summary.json`'s `strategies[*].chances`. Unlike the ball-loss breakdown, everything here is measured for both sides: it needs positions and possession, not the intentions log. diff --git a/utama_core/analysis/close_calls.py b/utama_core/analysis/close_calls.py index f273abf6b..76c845b7c 100644 --- a/utama_core/analysis/close_calls.py +++ b/utama_core/analysis/close_calls.py @@ -4,7 +4,7 @@ Reads SSL game logs written on real robots (`StrategyRunner(game_log_path=...)`): the camera's raw detections (one camera per robot, `robot_calibration._main_camera`) and the referee's commands. Each robot's track is the camera's view of its tag; pass a robot's tag offset -(`--tag`, as `tools/robot_calibration.py` takes it) to measure from the robot's centre. +(`--tag`, as `tools/field/robot_calibration.py` takes it) to measure from the robot's centre. Only the robots a run drove count (its run info's `vision_to_cmd`): ssl-vision misreads a tag as another pattern now and then. A close call is one stretch with the two centres nearer than @@ -32,9 +32,7 @@ from utama_core.analysis.robot_calibration import FieldLog, _main_camera, tag_offsets from utama_core.config.physical_constants import ROBOT_RADIUS from utama_core.replay.ssl_log import REFEREE, read_records -from utama_core.team_controller.src.generated_code.ssl_gc_referee_message_pb2 import ( - Referee, -) +from utama_core.team_controller.generated_code.ssl_gc_referee_message_pb2 import Referee CLOSE_M = 0.25 CONTACT_M = 2 * ROBOT_RADIUS diff --git a/utama_core/analysis/findings.py b/utama_core/analysis/findings.py index 547d25a7c..2e47ee20a 100644 --- a/utama_core/analysis/findings.py +++ b/utama_core/analysis/findings.py @@ -1,7 +1,7 @@ """One shared format for the problems the picture tools flag (`--findings PATH` on each tool). A picture is for understanding a flagged problem, never the only evidence for it: each tool also emits -its flags as JSON lines, one `Finding` per line, so an agent (or `tools/triage.py`) can filter on the +its flags as JSON lines, one `Finding` per line, so an agent (or `tools/debug/find_bugs.py`) can filter on the JSON and open the picture only to see what it means. {"tool": "match_timeline", "kind": "tactic_thrash", "replay": "replays/.../a_vs_b.npz", "side": "friendly", diff --git a/utama_core/analysis/fouls.py b/utama_core/analysis/fouls.py new file mode 100644 index 000000000..ccc4f3f10 --- /dev/null +++ b/utama_core/analysis/fouls.py @@ -0,0 +1,126 @@ +"""Our side's fouls in a round-robin run, with the referee command active at each: the starting points for +new regression moments. `tools/debug/find_bugs.py --fouls` prints them; `tools/debug/moments.py` uses `restart_side` in +its checks. (Until 2026-11-11 this was `tools/debug/moments.py fouls`.) + +`out_of_bounds`, the ball leaving the field, is a stoppage rather than a rules foul (`STOPPAGE_RULES`). +""" + +from __future__ import annotations + +import json +from collections import Counter +from pathlib import Path +from typing import Optional + +from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.replay.scenario import _referee_command_at +from utama_core.strategy.catalog import plain_name + +REPO_ROOT = Path(__file__).resolve().parents[2] + +# Rules that stop play without being a rules foul: the ball leaving the field. +STOPPAGE_RULES = frozenset({"out_of_bounds"}) +FOUL_COLUMNS = ("strategy", "rule", "tactic", "restart") + + +def restart_side(command: Optional[RefereeCommand], we_are_yellow: bool = True) -> Optional[str]: + """ "ours" for a restart our team takes, "theirs" for one the other team takes, None for + STOP, live play and timeouts.""" + if command is None or command.name.startswith("TIMEOUT"): + return None + if command.name.endswith("YELLOW" if we_are_yellow else "BLUE"): + return "ours" + if command.name.endswith("BLUE" if we_are_yellow else "YELLOW"): + return "theirs" + return None + + +def without_own_restarts(fouls: list[dict]) -> list[dict]: + """`fouls` minus those during a restart our team takes: `keeps_clear` does not apply there.""" + return [f for f in fouls if f.get("restart") != "ours"] + + +def without_stoppages(fouls: list[dict]) -> list[dict]: + return [f for f in fouls if f["rule"] not in STOPPAGE_RULES] + + +def _foul_column(f: dict, column: str) -> str: + if column == "strategy": + return plain_name(f["config_a"]) + if column == "restart": + return f.get("restart") or "live" + return str(f.get(column) or "-") + + +def count_fouls(fouls: list[dict], columns: list[str]) -> list[tuple[tuple[str, ...], int]]: + """How many of `fouls` fall in each combination of `columns` (names from `FOUL_COLUMNS`), + most common first; ties in name order.""" + counts = Counter(tuple(_foul_column(f, c) for c in columns) for f in fouls) + return sorted(counts.items(), key=lambda item: (-item[1], item[0])) + + +def fouls_json(fouls: list[dict], columns: Optional[list[str]] = None) -> str: + """`fouls` as JSON: the foul dicts as they are, or with `columns` the `count_fouls` rows as + {column: value, ..., "count": n} objects, most common first.""" + if columns is None: + data = fouls + else: + data = [{**dict(zip(columns, key)), "count": n} for key, n in count_fouls(fouls, columns)] + return json.dumps(data, indent=1, sort_keys=True) + + +def fouls_by_table(fouls: list[dict], columns: list[str]) -> list[str]: + """`count_fouls` as table lines: a count column, then one column per name, then the total.""" + rows = count_fouls(fouls, columns) + widths = [max([len(c)] + [len(key[i]) for key, _ in rows]) for i, c in enumerate(columns)] + lines = [f"{'count':>5} " + " ".join(f"{c:<{w}}" for c, w in zip(columns, widths))] + for key, n in rows: + lines.append(f"{n:>5} " + " ".join(f"{v:<{w}}" for v, w in zip(key, widths))) + lines.append(f"{sum(n for _, n in rows):>5} total") + return lines + + +def foul_line(f: dict) -> str: + """One foul as a line: rule, time, robot, tactic, referee command, restart side, match.""" + return ( + f"{f['rule']:<28} t={f['sim_time']:>7.2f} robot {f.get('robot_id')} {f.get('tactic') or '':<24} " + f"{(f['command'] or '?'):<22} {f['restart'] or 'live':<7} " + f"{plain_name(f['config_a'])} vs {plain_name(f['config_b'])}" + ) + + +def _repo_relative(path: Path) -> str: + """`path` relative to the repo root (as a string), or as given if it is outside the repo.""" + try: + return str(Path(path).resolve().relative_to(REPO_ROOT)) + except ValueError: + return str(path) + + +def our_fouls(run_dir: Path, rule: Optional[str] = None) -> list[dict]: + """Every foul config_a (our side in the replay) committed in a round-robin run, from its + summary.json. Each carries the referee `command` active at its time (from the match's + `.intentions.jsonl`, None if absent), its `restart` side ("ours", "theirs", or None for live play + and STOP) and its match's `replay` (the .npz, else the .pkl, relative to the repo root; None if + neither is there), for replay_trace and repro.""" + run_dir = Path(run_dir) + summary = json.loads((run_dir / "summary.json").read_text()) + out = [] + for r in summary["results"]: + stem = run_dir / f"{plain_name(r['config_a'])}_vs_{plain_name(r['config_b'])}" + sidecar = Path(f"{stem}.intentions.jsonl") + replay = next((p for p in (Path(f"{stem}.npz"), Path(f"{stem}.pkl")) if p.exists()), None) + for f in (r.get("stats") or {}).get("fouls") or []: + if f.get("side") == "friendly" and (rule is None or f["rule"] == rule): + command = _referee_command_at(sidecar, f["sim_time"]) + out.append( + { + "config_a": r["config_a"], + "config_b": r["config_b"], + **f, + "command": command.name if command else None, + "restart": restart_side(command), + "replay": _repo_relative(replay) if replay is not None else None, + } + ) + return out diff --git a/utama_core/analysis/goal_ledger.py b/utama_core/analysis/goal_sources.py similarity index 98% rename from utama_core/analysis/goal_ledger.py rename to utama_core/analysis/goal_sources.py index d2ac23b1c..ec1f90a9c 100644 --- a/utama_core/analysis/goal_ledger.py +++ b/utama_core/analysis/goal_sources.py @@ -1,6 +1,6 @@ """Where goals come from: every goal attributed to the situation that started the play it ended. - pixi run python -m utama_core.analysis.goal_ledger replays/tournament_ --out ledger.json + pixi run python -m utama_core.analysis.goal_sources replays/tournament_ --out ledger.json A strategy's goals per match is exactly a sum over situation types of how often the situation happens per match times how often it ends in a goal (P). That splits a result into what a @@ -61,6 +61,7 @@ from utama_core.config.field_params import STANDARD_FIELD_DIMS from utama_core.entities.referee.referee_command import RefereeCommand as C from utama_core.replay.columnar_reader import load_columnar_replay +from utama_core.strategy.catalog import plain_name WINDOW_S = 10.0 FOLD_S = 1.5 @@ -268,7 +269,7 @@ def run_labels(run_dir: Path) -> dict[str, tuple[str, str]]: def _short(config: str) -> str: """A config's name in replay file names (`match._short_name`).""" - return config.removeprefix("build_").removesuffix("_kernel_strategy") + return plain_name(config) def situation_type(situation: Optional[dict], side: str) -> str: @@ -399,7 +400,7 @@ def main() -> None: parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0]) parser.add_argument("paths", nargs="+", type=Path, help="run directories and/or replay .npz files") parser.add_argument("--labels", type=Path, help='JSON {"": ["", ""]}: who played') - parser.add_argument("--out", type=Path, help="JSON output (default: goal_ledger.json beside the first input)") + parser.add_argument("--out", type=Path, help="JSON output (default: goal_sources.json beside the first input)") parser.add_argument("--rates", type=Path, help="also write the corpus's situation rates here (situation_rates)") parser.add_argument("--workers", type=int, default=8) args = parser.parse_args() @@ -409,13 +410,13 @@ def main() -> None: strategies = tables(matches) print(report(strategies)) first = args.paths[0] - out = args.out or (first if first.is_dir() else first.parent) / "goal_ledger.json" + out = args.out or (first if first.is_dir() else first.parent) / "goal_sources.json" out.write_text(json.dumps({"strategies": strategies, "matches": matches}, indent=1)) print(f"wrote {out}: {len(matches)} matches, {sum(len(m['goals']) for m in matches)} goals") if args.rates: rates = situation_rates(matches) rates["inputs"] = [p.name for p in args.paths] - rates["command"] = " ".join(["python -m utama_core.analysis.goal_ledger", *sys.argv[1:]]) + rates["command"] = " ".join(["python -m utama_core.analysis.goal_sources", *sys.argv[1:]]) args.rates.write_text(json.dumps(rates, indent=1) + "\n") print(f"wrote {args.rates}: {rates['live_min_per_match']:.2f} live minutes per match") diff --git a/utama_core/analysis/list_runs.py b/utama_core/analysis/list_runs.py index d1a1c8ece..68e570ca1 100644 --- a/utama_core/analysis/list_runs.py +++ b/utama_core/analysis/list_runs.py @@ -1,6 +1,6 @@ """List the tournament runs under ./replays (`pixi run runs`). -One line per `replays/tournament_*` directory, oldest first: when it started, the +One line per run directory (`replays/tournament_*`, and `replays/eval_*/round_*` from evaluate.py), oldest first: when it started, the git commit it ran on (`*` if the tree was dirty), how many matches finished, how many stalled, and its command-line arguments -- all read from the run's `summary.json`. A run still in progress, or from before a field existed, shows `-` @@ -8,14 +8,21 @@ """ import json +import re from pathlib import Path from utama_core.config.settings import REPLAY_BASE_PATH +def _started(run: str) -> str: + """A run's name from its timestamp on, so both kinds of run sort oldest first.""" + return re.sub(r"^\D*", "", run) + + def run_rows(replays_dir: Path) -> list[dict]: rows = [] - for run_dir in sorted(replays_dir.glob("tournament_*")): + runs = [*replays_dir.glob("tournament_*"), *replays_dir.glob("eval_*/round_*")] + for run_dir in sorted(runs, key=lambda p: _started(p.relative_to(replays_dir).as_posix())): if not run_dir.is_dir(): continue try: @@ -28,7 +35,7 @@ def run_rows(replays_dir: Path) -> list[dict]: argv = run.get("argv") rows.append( { - "run": run_dir.name, + "run": run_dir.relative_to(replays_dir).as_posix(), "started": run.get("started_utc", "-"), "commit": (commit[:8] + ("*" if run.get("git_dirty") else "")) if commit else "-", "matches": len(results) if isinstance(results, list) else "-", diff --git a/utama_core/analysis/matches.py b/utama_core/analysis/matches.py index 0da6c6b95..374665e12 100644 --- a/utama_core/analysis/matches.py +++ b/utama_core/analysis/matches.py @@ -1,8 +1,8 @@ """The matches in a run dir: which two strategies a replay is between, and the score it ended on. -A match file's stem is `_vs_` (round-robin) or `_vs__s` (an -evaluate.py run). config_a is the friendly side (yellow) in every run. Shared by `tools/evaluation/explain.py` -and `tools/triage.py`. +A match file's stem is `_vs_` (an evaluate.py round folder, or an old round-robin); +evaluate.py runs before 2026-11-12 added `_s`, still read. config_a is the friendly side (yellow) in every run. Shared by `tools/evaluation/explain.py` +and `tools/debug/find_bugs.py`. """ from __future__ import annotations diff --git a/utama_core/analysis/motion_stats.py b/utama_core/analysis/motion_stats.py index 8d068d417..651a5839f 100644 --- a/utama_core/analysis/motion_stats.py +++ b/utama_core/analysis/motion_stats.py @@ -13,6 +13,7 @@ import numpy as np from utama_core.config.physical_constants import ROBOT_RADIUS +from utama_core.strategy.catalog import plain_name def _count_incidents(d_pairs: np.ndarray) -> int: @@ -196,8 +197,8 @@ def enrich_tournament_directory(tournament_dir: Union[str, Path]) -> None: summary = json.load(f) for result in summary.get("results", []): - cfg_a = result["config_a"].removeprefix("build_").removesuffix("_kernel_strategy") - cfg_b = result["config_b"].removeprefix("build_").removesuffix("_kernel_strategy") + cfg_a = plain_name(result["config_a"]) + cfg_b = plain_name(result["config_b"]) tag = f"{cfg_a}_vs_{cfg_b}" if tag in stats_updates: m = stats_updates[tag] diff --git a/utama_core/analysis/plan_snapshot.py b/utama_core/analysis/plan_snapshot.py index 8726b7bf0..3c487cc47 100644 --- a/utama_core/analysis/plan_snapshot.py +++ b/utama_core/analysis/plan_snapshot.py @@ -1,4 +1,4 @@ -"""A picture of what `FastPathPlanner` decided for one robot on one tick (`tools/plan_snapshot.py`). +"""A picture of what `FastPathPlanner` decided for one robot on one tick (`tools/debug/plan_snapshot.py`). Builds the `Game` the planner saw (from a replay frame via `replay.scenario`, or from a hand-made state via `build_game`), runs the planner's own `_path_to`, and draws the pitch around the robot: @@ -33,13 +33,14 @@ from utama_core.entities.game.team_info import TeamInfo from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.entities.referee.stage import Stage -from utama_core.motion_planning.src.fastpathplanning.planner import ( +from utama_core.motion_planning.fastpathplanning.planner import ( FastPathPlanner, _keeps_off_ball, ) from utama_core.replay.scenario import Scenario, scenario_from_replay +from utama_core.strategy.catalog import plain_name -# Same ink and palette as tools/signal_report.py (FOR = friendly, AGAINST = enemy). +# Same ink and palette as tools/debug/figure_style.py (FOR = friendly, AGAINST = enemy). INK, INK_2, INK_3, SURFACE, GRID = "#0b0b0b", "#52514e", "#8a8984", "#fcfcfb", "#e4e3df" FOR, AGAINST = "#2a78d6", "#eb6834" CARROT = "#1baf7a" # categorical slot 3: the planner's output, distinct from the team colours @@ -179,7 +180,7 @@ def _stadium(a: np.ndarray, b: np.ndarray, r: float, n: int = 24) -> np.ndarray: def _short(config_name: Optional[str]) -> str: if not config_name: return "?" - return config_name.removeprefix("build_").removesuffix("_kernel_strategy") + return plain_name(config_name) def style_axes(ax): diff --git a/utama_core/analysis/plan_trace.py b/utama_core/analysis/plan_trace.py index dfb2a6698..4694fcd82 100644 --- a/utama_core/analysis/plan_trace.py +++ b/utama_core/analysis/plan_trace.py @@ -1,4 +1,4 @@ -"""The fast-path planner over a time window: how one robot's plan unfolded (`tools/plan_trace.py`). +"""The fast-path planner over a time window: how one robot's plan unfolded (`tools/debug/plan_trace.py`). `plan_snapshot` shows one tick. This runs the same `FastPathPlanner._path_to` on every sampled tick of a window, builds the `Game` each tick saw from a callback (so tests can feed synthetic @@ -51,7 +51,7 @@ from utama_core.config.field_params import STANDARD_FIELD_DIMS, FieldDimensions from utama_core.config.referee_constants import BALL_KEEP_OUT_DISTANCE from utama_core.entities.game import Game -from utama_core.motion_planning.src.fastpathplanning.planner import ( +from utama_core.motion_planning.fastpathplanning.planner import ( FastPathPlanner, _keeps_off_ball, ) @@ -60,7 +60,7 @@ # Single-hue ramp (light to dark FOR blue) for time; the carrot dots keep the carrot colour. TIME_CMAP = mcolors.LinearSegmentedColormap.from_list("time", ["#d6e6fa", FOR, "#0f3d7a"]) -# Referee bands: categorical slots from tools/signal_report.py, STOP grey, BALL_PLACEMENT ink. +# Referee bands: categorical slots from tools/debug/figure_style.py, STOP grey, BALL_PLACEMENT ink. REFEREE_COLOURS = { "HALT": "#e4e3df", "STOP": "#e4e3df", diff --git a/utama_core/analysis/ratings.py b/utama_core/analysis/ratings.py index c854751dc..a785ef5b5 100644 --- a/utama_core/analysis/ratings.py +++ b/utama_core/analysis/ratings.py @@ -1,118 +1,66 @@ -"""Strategy ratings with uncertainty, from match margins. +"""The verdict's test: is the candidate's mean paired difference above zero? -Model: a match's margin (goal difference, config_a minus config_b) is strength(a) - strength(b) -plus noise, normal with SD `noise_sd`; every strength has a normal prior, mean 0 and SD -`PRIOR_SD`. The posterior is normal and closed-form (Bayesian ridge regression), so a strength -comes with its SD, and two strengths with the probability one is the larger. +A paired difference ("diff") is the candidate's goal difference minus the reference's against the +same opponent, with the same seed and colour (`tools/evaluation/evaluate.py`'s `paired`). The same +opponent cancels its strength, and the same noise cancels part of the luck: much of it for a small +edit, little for an unrelated strategy. The test is a one-sided paired t-test on the diffs: it +estimates their spread from the diffs themselves, so it needs no assumed noise level, and a small +sample is paid for by the t distribution's wider tails, not by a hand-set prior. -A strength is in goals per match against an opponent of strength 0. The prior centres the -ratings of whoever has played on 0, so compare strengths within one fit (`p_better`), not -across fits. +The rule built on it (`decide`): a screen on seeds 1..ROUNDS that only drops (mean diff <= 0), then +a confirm stage on fresh seeds that accepts at p <= ALPHA. `tools/evaluation/verdict_sim.py` plays it +on simulated results. -`noise_sd` is fitted from the residuals, shrunk toward `NOISE_SD` (the per-match spread of -goal difference left after strengths in `tournament_20261016_201213`, 66 matches) with the -weight of `NOISE_PRIOR_N` matches, so a few matches cannot make it tiny. +Until 2026-11-12 this module held a Bayesian rating model with a prior on the diffs' spread +(weight 6) and head-to-head matches in the verdict; it was replaced by this test (git history). """ from __future__ import annotations import math from dataclasses import dataclass - -import numpy as np - -PRIOR_SD = 1.0 # goals per match; strengths in the 2026-10-16 baseline spread with SD ~0.7 -NOISE_SD = 1.6 -NOISE_PRIOR_N = 10 - - -@dataclass -class Ratings: - names: list[str] - mean: np.ndarray - cov: np.ndarray - noise_sd: float - n_matches: int - - def _i(self, name: str) -> int: - return self.names.index(name) - - def strength(self, name: str) -> tuple[float, float]: - """(mean, SD) of `name`'s strength.""" - i = self._i(name) - return float(self.mean[i]), math.sqrt(self.cov[i, i]) - - def diff(self, x: str, y: str) -> tuple[float, float]: - """(mean, SD) of strength(x) - strength(y): x's expected margin over y.""" - i, j = self._i(x), self._i(y) - var = self.cov[i, i] + self.cov[j, j] - 2 * self.cov[i, j] - return float(self.mean[i] - self.mean[j]), math.sqrt(max(var, 0.0)) - - def p_better(self, x: str, y: str) -> float: - """Posterior probability that x is stronger than y.""" - m, s = self.diff(x, y) - return 0.5 * (1 + math.erf(m / (s * math.sqrt(2)))) if s > 0 else float(m > 0) - - -def fit( - matches: list[tuple[str, str, float]], - names: list[str] | None = None, - prior_sd: float = PRIOR_SD, - noise_sd: float | None = None, -) -> Ratings: - """Ratings from `(config_a, config_b, margin)` triples. `names` adds strategies with no - matches yet (they keep the prior). `noise_sd`, if given, is used as is instead of fitted.""" - names = sorted(set(names or []) | {a for a, _, _ in matches} | {b for _, b, _ in matches}) - ix = {n: i for i, n in enumerate(names)} - A = np.zeros((len(matches), len(names))) - y = np.array([m for _, _, m in matches], float) - for row, (a, b, _) in enumerate(matches): - A[row, ix[a]] += 1.0 - A[row, ix[b]] -= 1.0 - prior_precision = np.eye(len(names)) / prior_sd**2 - - def posterior(sd: float) -> tuple[np.ndarray, np.ndarray]: - cov = np.linalg.inv(A.T @ A / sd**2 + prior_precision) - return cov @ A.T @ y / sd**2, cov - - sd = noise_sd - if sd is None: - sd = NOISE_SD - for _ in range(5): # a few fixed-point steps: the residuals depend on the fit - mean, _ = posterior(sd) - rss = float(np.sum((y - A @ mean) ** 2)) - dof = max(len(matches) - len(names) + 1, 0) - sd = math.sqrt((NOISE_PRIOR_N * NOISE_SD**2 + rss) / (NOISE_PRIOR_N + dof)) - mean, cov = posterior(sd) - return Ratings(names, mean, cov, sd, len(matches)) - - -PAIRED_PRIOR_N = 6 # weight, in paired differences, of the prior that pairing removes no noise - - -def paired_difference(diffs: list[float], head_to_head: list[float], noise_sd: float) -> tuple[float, float]: - """(mean, SD) of strength(candidate) - strength(baseline) from paired matches. - - `diffs`: for each opponent, seed and colour both played, the candidate's goal difference minus - the baseline's. Same opponent and same noise, so much of the noise cancels: all of it for - identical code, little for unrelated strategies. Their variance is estimated from the diffs - themselves, shrunk toward 2 * noise_sd^2 (no cancelling) with the weight of - `PAIRED_PRIOR_N` diffs, so a few equal results cannot make it tiny. - `head_to_head`: the candidate's margins against the baseline, each with variance noise_sd^2. - The prior on the difference is normal, mean 0, SD sqrt(2) * PRIOR_SD (two strengths).""" - precision = 1 / (2 * PRIOR_SD**2) - weighted = 0.0 - if diffs: - d = np.asarray(diffs, float) - ss = float(np.sum((d - d.mean()) ** 2)) - var_d = (PAIRED_PRIOR_N * 2 * noise_sd**2 + ss) / (PAIRED_PRIOR_N + len(d) - 1) - precision += len(d) / var_d - weighted += d.sum() / var_d - if head_to_head: - precision += len(head_to_head) / noise_sd**2 - weighted += float(np.sum(head_to_head)) / noise_sd**2 - return weighted / precision, math.sqrt(1 / precision) - - -def p_positive(mean: float, sd: float) -> float: - return 0.5 * (1 + math.erf(mean / (sd * math.sqrt(2)))) +from typing import Optional + +from scipy import stats + +# Rounds per stage (screen, then confirm). Provisional: set it from the measured spread s of real +# diffs so a 0.3-goal improvement is found 80% of the time (rough: s 0.5 -> 3, 0.7 -> 7, 1.0 -> 14). +ROUNDS = 6 +# One-sided error bar of the confirm stage: the share of equal candidates called better. Provisional: +# set it from how often edits turn out better (the rarer, the smaller ALPHA must be). +ALPHA = 0.05 +NOISE_SD = 1.6 # per-match spread of goal difference (tournament_20261016_201213); verdict_sim's default + + +@dataclass(frozen=True) +class PairedTest: + n: int # number of diffs + mean: float # mean diff, goals per match + se: float # its standard error + p: float # one-sided p-value for "mean > 0": how often an equal candidate would look this good + + +def paired_test(diffs: list[float]) -> PairedTest: + """The one-sided paired t-test of `diffs`. Fewer than two diffs, or none above zero, give p = 1.""" + n = len(diffs) + mean = sum(diffs) / n if n else 0.0 + if n < 2: + return PairedTest(n, mean, math.inf, 1.0) + sd = math.sqrt(sum((d - mean) ** 2 for d in diffs) / (n - 1)) + se = sd / math.sqrt(n) + if se == 0: # every diff the same: identical code (all zero), or an exact, repeated margin + return PairedTest(n, mean, 0.0, 0.0 if mean > 0 else 1.0) + return PairedTest(n, mean, se, float(stats.t.sf(mean / se, n - 1))) + + +def decide(test: PairedTest, rounds_in_stage: int, confirming: bool) -> Optional[str]: + """evaluate.py's rule after a round of a stage: "dropped" (mean diff <= 0, from the stage's second + round), "confirm" (the screen survived), "better" (confirm stage, p <= ALPHA), "undecided" + (confirm stage, p > ALPHA), or None to play another round. The screen never accepts.""" + if rounds_in_stage >= 2 and test.n and test.mean <= 0: + return "dropped" + if rounds_in_stage < ROUNDS: + return None + if not confirming: + return "confirm" + return "better" if test.p <= ALPHA else "undecided" diff --git a/utama_core/analysis/render_window.py b/utama_core/analysis/render_window.py index 9045c0f4c..b7452a95c 100644 --- a/utama_core/analysis/render_window.py +++ b/utama_core/analysis/render_window.py @@ -32,7 +32,7 @@ from utama_core.engine.match_log import load_jsonl from utama_core.entities.game import GameFrame from utama_core.replay.replay_player import load_frames_in_range -from utama_core.rsoccer_simulator.src.Render.utils import COLORS +from utama_core.simulator.render.utils import COLORS _FRIENDLY_COLOR = tuple(c / 255 for c in COLORS["YELLOW"]) _ENEMY_COLOR = tuple(c / 255 for c in COLORS["BLUE"]) diff --git a/utama_core/analysis/restart_outcomes.py b/utama_core/analysis/restart_outcomes.py index b094438b4..09bb20e4b 100644 --- a/utama_core/analysis/restart_outcomes.py +++ b/utama_core/analysis/restart_outcomes.py @@ -1,6 +1,6 @@ """What became of every restart in a tournament run: taken, or why not. -`round_robin.py` runs this after every saved run and writes `summary()` into +`evaluate.py` runs this after every saved run and writes `summary()` into `summary.json` under `restarts`. Found necessary 2026-09-28: 8 of 19 penalties in a full round-robin were never taken (the ball was never placed, then keep-out voided them) and no existing signal showed it. diff --git a/utama_core/analysis/restart_picture.py b/utama_core/analysis/restart_picture.py index 178230c4a..063185b81 100644 --- a/utama_core/analysis/restart_picture.py +++ b/utama_core/analysis/restart_picture.py @@ -1,9 +1,9 @@ -"""Picture of where the referee override sends every friendly robot for one restart (`tools/restart_picture.py`). +"""Picture of where the referee override sends every friendly robot for one restart (`tools/debug/restart_picture.py`). For a replay state whose referee command is a restart (STOP, timeouts, kick-offs, penalties, free kicks, ball placement), this runs `RefereeOverride.tick` exactly as the strategy does and records the target each robot is commanded to. The `*Step` classes only produce velocity commands through `move` and -`turn_on_spot`, so `_recording_steps` swaps those two names in `custom_referee.actions` for recorders for +`turn_on_spot`, so `_recording_steps` swaps those two names in `referee.actions` for recorders for the duration of the call (and restores them): the commanded target is what is captured, and no engine or planner code changes. A detour waypoint is captured as the target, as commanded. @@ -54,7 +54,6 @@ BALL_KEEP_OUT_DISTANCE, OPPONENT_DEFENSE_AREA_KEEP_DISTANCE, ) -from utama_core.custom_referee import actions as _actions from utama_core.engine.referee_override import RefereeOverride, is_override_command from utama_core.entities.data.referee import RefereeData from utama_core.entities.data.vector import Vector2D @@ -62,6 +61,7 @@ from utama_core.entities.game.team_info import TeamInfo from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.entities.referee.stage import Stage +from utama_core.referee import actions as _actions from utama_core.replay.columnar_reader import load_columnar_replay from utama_core.replay.scenario import Scenario, scenario_from_replay @@ -112,7 +112,7 @@ def flagged(self) -> tuple[RobotPlan, ...]: @contextmanager def _recording_steps() -> Iterator[dict[int, CommandedTarget]]: - """Swap `move` and `turn_on_spot` in `custom_referee.actions` for recorders, then restore them.""" + """Swap `move` and `turn_on_spot` in `referee.actions` for recorders, then restore them.""" recorded: dict[int, CommandedTarget] = {} real_move, real_turn = _actions.move, _actions.turn_on_spot diff --git a/utama_core/analysis/robot_calibration.py b/utama_core/analysis/robot_calibration.py index 41f568b95..3b1a88860 100644 --- a/utama_core/analysis/robot_calibration.py +++ b/utama_core/analysis/robot_calibration.py @@ -2,7 +2,7 @@ Reads an SSL game log written by `GameLogWriter` (`StrategyRunner(game_log_path=...)`) on real robots: the radio packets as sent and the camera's raw detections, on one clock. Best from a -`--calibrate` run of `examples/shooting_drill.py` (fixed moves, `ScriptedMovesTactic`); +`--calibrate` run of `tools/field/shooting_drill.py` (fixed moves, `ScriptedMovesTactic`); any run works, with fewer clean steps. Per robot that was sent commands: @@ -25,9 +25,9 @@ - **Dribbling**: per constant command held at least `DRIBBLE_MIN_S` with the dribbler on, where the ball sat in the robot's frame (forward of its centre, to its left), how much of the time the ball sensor read on, and whether the ball was still on at the end (`BALL_LOST_M`). A - `examples/calibrate_robot.py` run holds, turns and drives with the ball, then kicks it 3 times. + `tools/field/calibrate_robot.py` run holds, turns and drives with the ball, then kicks it 3 times. - pixi run python tools/robot_calibration.py replays/field/.log [--json OUT] + pixi run python tools/field/robot_calibration.py replays/field/.log [--json OUT] """ from __future__ import annotations @@ -42,7 +42,7 @@ from utama_core.replay.game_log_writer import RADIO_IN, RADIO_OUT, RUN_INFO from utama_core.replay.ssl_log import VISION_2014, read_records -from utama_core.team_controller.src.generated_code.ssl_vision_wrapper_pb2 import ( +from utama_core.team_controller.generated_code.ssl_vision_wrapper_pb2 import ( SSL_WrapperPacket, ) diff --git a/utama_core/analysis/strategy_table.py b/utama_core/analysis/strategy_table.py index 9ee2ded93..dd124f99d 100644 --- a/utama_core/analysis/strategy_table.py +++ b/utama_core/analysis/strategy_table.py @@ -2,7 +2,7 @@ Lives in `utama_core` so the analysis code can rebuild a `summary.json`'s `strategies` table without importing the `tools/` scripts (which are not part of the installed package). -`tools/evaluation/round_robin.py` re-exports it. +`tools/evaluation/evaluate.py` prints it. """ from __future__ import annotations @@ -10,11 +10,12 @@ from typing import Optional from utama_core.analysis import chances +from utama_core.strategy.catalog import plain_name def _short_name(config_name: str) -> str: """A config's name in replay file names (mirrors `tools/evaluation/match._short_name`).""" - return config_name.removeprefix("build_").removesuffix("_kernel_strategy") + return plain_name(config_name) def strategy_table( diff --git a/utama_core/analysis/stuck_detector.py b/utama_core/analysis/stuck_detector.py index 6febe453c..8fecd9ac0 100644 --- a/utama_core/analysis/stuck_detector.py +++ b/utama_core/analysis/stuck_detector.py @@ -2,7 +2,7 @@ robot oscillates instead of making progress, or a restart command stuck in effect far longer than any legal restart ceremony takes. -This is a prototype analysis tool, not a live `custom_referee` rule (see +This is a prototype analysis tool, not a live `referee` rule (see `docs/testing_gaps.md` gap #11) — it runs after a match, over a recorded `.pkl`/`.npz` replay, and reports candidate windows for a human/agent to look at with `render_window()`. It intentionally does not (and should not, @@ -468,7 +468,7 @@ def find_stuck_windows( `RefereeSidecar`) to reconstruct the command per frame; only if *that* is also unavailable does this check skip entirely, exactly as before — not every replay (a unit-test fixture, a non-refereed - `debug_match.py` run) carries referee state or a sidecar. + `tools/debug/debug_match.py` run) carries referee state or a sidecar. - **Ball possessed.** A window where some robot (either team) has `has_ball=True` for at least `possession_fraction` of its frames is a robot legitimately holding/shielding the ball, not a stall — this is diff --git a/utama_core/analysis/tag_calibration.py b/utama_core/analysis/tag_calibration.py index 10fa97788..e52f83b83 100644 --- a/utama_core/analysis/tag_calibration.py +++ b/utama_core/analysis/tag_calibration.py @@ -2,7 +2,7 @@ centre and how far its heading is off the robot's forward direction. Reads an SSL game log written on real robots (`StrategyRunner(game_log_path=...)`): the turns -and straight drives of an `examples/calibrate_robot.py` run, which writes the offset into the +and straight drives of an `tools/field/calibrate_robot.py` run, which writes the offset into the robot's profile. - **Tag offset**: a robot turning on the spot turns about its own centre, so its tag traces a diff --git a/utama_core/analysis/turnover_breakdown.py b/utama_core/analysis/turnover_breakdown.py index 82845b3d4..18376c541 100644 --- a/utama_core/analysis/turnover_breakdown.py +++ b/utama_core/analysis/turnover_breakdown.py @@ -1,6 +1,6 @@ """Breakdown of *how* the friendly team loses the ball, over a tournament run's replays. -`round_robin.py` runs this after every saved run: headline numbers go into +`evaluate.py` runs this after every saved run: headline numbers go into `summary.json` under `ball_losses`, the full report into `ball_losses.md` beside it. For an existing run: @@ -50,6 +50,7 @@ from utama_core.engine.match_stats import _POSSESSION_RADIUS_M, MatchStatsAccumulator from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.replay.replay_player import load_frames_in_range +from utama_core.strategy.catalog import plain_name LIVE = {RefereeCommand.NORMAL_START, RefereeCommand.FORCE_START} # Restarts that hand the ball to blue (the enemy). Kickoffs are excluded: blue kicks off @@ -431,7 +432,7 @@ def report(run_name: str, results: list[dict], summary: dict) -> str: recorded = {f"{r['config_a']}_vs_{r['config_b']}": (r["stats"] or {}).get("turnovers") for r in summary["results"]} def short(name: str) -> str: - return name.removeprefix("build_").removesuffix("_kernel_strategy") + return plain_name(name) recorded = {"_vs_".join(short(p) for p in k.split("_vs_")): v for k, v in recorded.items()} mismatches = [ diff --git a/utama_core/bundle/__init__.py b/utama_core/bundle/__init__.py new file mode 100644 index 000000000..3dd1b18ba --- /dev/null +++ b/utama_core/bundle/__init__.py @@ -0,0 +1 @@ +"""`.strategy` files: one strategy and the exact code it runs on, played in its own process.""" diff --git a/utama_core/bundle/archive.py b/utama_core/bundle/archive.py new file mode 100644 index 000000000..f889cad3a --- /dev/null +++ b/utama_core/bundle/archive.py @@ -0,0 +1,34 @@ +"""A `.strategy` file on disk: standard library only, so fingerprinting doesn't import a strategy.""" + +from __future__ import annotations + +import hashlib +import json +import os +import shutil +import tempfile +import zipfile +from pathlib import Path + +SUFFIX = ".strategy" +_CACHE = Path(os.environ.get("XDG_CACHE_HOME", Path.home() / ".cache")) / "utama" / "strategies" + + +def unpack(path: Path) -> Path: + """The file's unpacked directory, shared by every process that plays the same bytes.""" + root = _CACHE / hashlib.sha256(path.read_bytes()).hexdigest()[:16] + if root.exists(): + return root + _CACHE.mkdir(parents=True, exist_ok=True) + partial = Path(tempfile.mkdtemp(dir=_CACHE)) + with zipfile.ZipFile(path) as archive: + archive.extractall(partial) + try: + partial.rename(root) + except OSError: # another match unpacked it first + shutil.rmtree(partial) + return root + + +def read_manifest(root: Path) -> dict: + return json.loads((root / "manifest.json").read_text()) diff --git a/utama_core/bundle/host.py b/utama_core/bundle/host.py new file mode 100644 index 000000000..865a966f6 --- /dev/null +++ b/utama_core/bundle/host.py @@ -0,0 +1,192 @@ +"""The process a `.strategy` file runs in: game frames in on stdin, robot commands out on stdout. + +Run as `python -m utama_core.bundle.host` from an unpacked bundle, so `utama_core` is the bundle's own +copy. This file and `wire.py` are the current ones even in a bundle of an older commit; the rest is +that commit's code. +""" + +from __future__ import annotations + +import dataclasses +import json +import os +import sys + +from utama_core.bundle import wire +from utama_core.config.enums import Mode +from utama_core.config.field_params import FieldBounds, FieldDimensions +from utama_core.config.settings import MAX_GAME_HISTORY +from utama_core.engine.abstract_strategy import AbstractStrategy +from utama_core.engine.match_log import MatchLog +from utama_core.entities.data.referee import RefereeData +from utama_core.entities.data.vector import Vector2D, Vector3D +from utama_core.entities.game import Ball, Field, Game, GameFrame, GameHistory, Robot +from utama_core.entities.game.team_info import TeamInfo +from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.entities.referee.stage import Stage +from utama_core.motion_planning.common.control_schemes import CONTROL_SCHEME_MAP + + +class _CommandRecorder: + """Stands in for the robot controller: `AbstractStrategy.step` fills it, the host sends it.""" + + keeps_kickers_charged = False + + def __init__(self) -> None: + self.commands: dict[str, list] = {} + + def add_robot_commands(self, command, robot_id: int) -> None: + self.commands[str(robot_id)] = [ + float(command.local_forward_vel), + float(command.local_left_vel), + float(command.angular_vel), + bool(command.kick), + bool(command.chip), + bool(command.dribble), + ] + + def send_robot_commands(self) -> None: + pass + + +def _robot(values: list) -> Robot: + rid, is_friendly, has_ball, p, v, a, orientation = values + return Robot(rid, is_friendly, has_ball, Vector2D(*p), Vector2D(*v), Vector2D(*a), orientation) + + +def _referee(data: dict | None) -> RefereeData | None: + if data is None: + return None + next_command = data.pop("next_command") + return RefereeData( + **{ + **data, + "referee_command": RefereeCommand[data["referee_command"]], + "stage": Stage[data["stage"]], + "blue_team": TeamInfo(**data["blue_team"]), + "yellow_team": TeamInfo(**data["yellow_team"]), + "designated_position": None if data["designated_position"] is None else tuple(data["designated_position"]), + "next_command": None if next_command is None else RefereeCommand[next_command], + } + ) + + +def decode_frame(data: dict) -> GameFrame: + ball = data["ball"] + return GameFrame( + ts=data["ts"], + my_team_is_yellow=data["my_team_is_yellow"], + my_team_is_right=data["my_team_is_right"], + friendly_robots={values[0]: _robot(values) for values in data["friendly_robots"]}, + enemy_robots={values[0]: _robot(values) for values in data["enemy_robots"]}, + ball=None if ball is None else Ball(Vector3D(*ball[0]), Vector3D(*ball[1]), Vector3D(*ball[2])), + referee=_referee(data["referee"]), + ) + + +def decode_field(data: dict) -> Field: + return Field( + data["my_team_is_right"], + FieldDimensions(**data["dims"]), + FieldBounds(tuple(data["top_left"]), tuple(data["bottom_right"])), + data["defense_area_rules"], + ) + + +def _drain(log) -> list: + """What the strategy logged since the last call, as `[event class name, fields]`.""" + if log is None: + return [] + out = [] + for event in log._events: + fields = dataclasses.asdict(event) + if "tag" in fields: + fields["tag"] = fields["tag"].value + out.append([type(event).__name__, fields]) + log._events.clear() + return out + + +def _slot_status(strategy) -> dict: + return { + tactic_id: {"robots": list(info["robots"]), "committed": bool(info["committed"]), "tag": info["tag"].value} + for tactic_id, info in strategy._kernel_strategy.slot_status(strategy.game).items() + } + + +def _partition(strategy) -> dict: + kernel = strategy._kernel_strategy + return { + "partition": {tactic_id: list(robots) for tactic_id, robots in kernel.active_partition.items()}, + "names": {tactic_id: type(kernel._tactics[tactic_id]).__name__ for tactic_id in kernel.active_partition}, + } + + +_QUERIES = { + "slot_status": _slot_status, + "partition": _partition, + "debug_status": lambda strategy: {str(rid): row for rid, row in strategy.debug_status().items()}, +} + + +def _controller(setup: dict): + """The motion controller as the runner configured its own.""" + scheme = next(c for c in CONTROL_SCHEME_MAP.values() if c.__name__ == setup["controller"]) + controller = scheme(Mode(setup["mode"]), None) + controller.pose_ahead.latency_s = setup["latency_s"] + controller.robot_carry = {int(rid): tuple(carry) for rid, carry in setup["robot_carry"].items()} + controller.kick_bend = {int(rid): bend for rid, bend in setup["kick_bend"].items()} + controller.kick_bias = {int(rid): bias for rid, bias in setup["kick_bias"].items()} + return controller + + +def _builder(manifest: dict): + """`AbstractStrategy`'s first argument. The file's own code decides how: files of commits from + before `strategy/catalog.py` have `kernel_strategy.build__kernel_strategy` instead.""" + ids = tuple(map(int, sys.argv[1:])) or tuple(manifest["outfield_ids"]) # the run's robots, if it named them + name = manifest["strategy"] + try: + from utama_core.strategy.catalog import builder + except ModuleNotFoundError: + from utama_core.strategy import kernel_strategy + + return getattr(kernel_strategy, f"build_{name}_kernel_strategy")(ids) + return builder(name, ids) + + +def main() -> None: + # Strategy code that prints must not corrupt the channel. + replies = os.fdopen(os.dup(1), "wb") + os.dup2(2, 1) + requests = sys.stdin.buffer + + with open("manifest.json") as f: + manifest = json.load(f) + strategy = AbstractStrategy(_builder(manifest)) + recorder = _CommandRecorder() + strategy.load_robot_controller(recorder) + wire.send(replies, {"control_scheme": strategy.control_scheme}) + + log = None + while (message := wire.receive(requests)) is not None: + kind = message["type"] + if kind == "setup": + strategy.load_motion_controller(_controller(message)) + elif kind == "game": + history = GameHistory(MAX_GAME_HISTORY) + strategy.load_game(Game(history, decode_frame(message["frame"]), field=decode_field(message["field"]))) + elif kind == "match_log": + log = MatchLog() + strategy._kernel_strategy.match_log = log + elif kind == "frame": + strategy.game.add_game_frame(decode_frame(message["frame"])) + elif kind == "tick": + recorder.commands = {} + strategy.step() + wire.send(replies, {"commands": recorder.commands, "events": _drain(log)}) + elif kind == "query": + wire.send(replies, _QUERIES[message["name"]](strategy)) + + +if __name__ == "__main__": + main() diff --git a/utama_core/bundle/strategy_file.py b/utama_core/bundle/strategy_file.py new file mode 100644 index 000000000..1573229d6 --- /dev/null +++ b/utama_core/bundle/strategy_file.py @@ -0,0 +1,249 @@ +"""Building, unpacking and playing `.strategy` files. + +A `.strategy` file is a zip of the `utama_core` package at one commit plus a manifest naming the +strategy. It plays in its own process (`host.py`), so it keeps its own skills, tactics and motion code +while the runner around it changes: a frozen opponent, or one somebody else wrote. + +It is plain Python and runs with this machine's rights. Isolate a file you did not build before +playing it. +""" + +from __future__ import annotations + +import json +import os +import platform +import subprocess +import sys +import tarfile +import weakref +import zipfile +from io import BytesIO +from pathlib import Path +from typing import Optional + +from utama_core.bundle import wire +from utama_core.bundle.archive import SUFFIX, read_manifest, unpack +from utama_core.engine.abstract_strategy import AbstractStrategy +from utama_core.engine.match_log import IntentionEvent, TraceEvent +from utama_core.engine.tactic import TacticTag +from utama_core.entities.data.command import RobotCommand + +FORMAT_VERSION = 1 +_REPO = Path(__file__).resolve().parents[2] +_OWN_CODE = Path(__file__).resolve().parent + + +def _wanted(path: str) -> bool: + return path.startswith("utama_core/") and not path.startswith("utama_core/tests/") and "__pycache__" not in path + + +def _worktree_files() -> dict[str, bytes]: + listed = subprocess.run( + ["git", "ls-files", "-co", "--exclude-standard", "utama_core"], + cwd=_REPO, + capture_output=True, + text=True, + check=True, + ).stdout.splitlines() + return {p: (_REPO / p).read_bytes() for p in listed if _wanted(p) and (_REPO / p).is_file()} + + +def _commit_files(ref: str) -> dict[str, bytes]: + archive = subprocess.run(["git", "archive", ref, "utama_core"], cwd=_REPO, capture_output=True, check=True).stdout + with tarfile.open(fileobj=BytesIO(archive)) as tar: + return {m.name: tar.extractfile(m).read() for m in tar if m.isfile() and _wanted(m.name)} + + +def _commit_of(ref: str) -> str: + # `^{commit}`: on its own an annotated tag resolves to the tag object, which is no commit. + return subprocess.run( + ["git", "rev-parse", f"{ref}^{{commit}}"], cwd=_REPO, capture_output=True, text=True, check=True + ).stdout.strip() + + +def build(strategy: str, output: Path, ref: Optional[str] = None, outfield_ids: tuple = (1, 2, 3, 4, 5)) -> Path: + """Write `output`. `ref` is a git commit; None takes the working tree as it stands. + + Same inputs, same bytes, so a file's hash identifies what it plays.""" + files = _commit_files(ref) if ref else _worktree_files() + if f"utama_core/strategy/{strategy}.py" not in files: + raise ValueError(f"no strategy {strategy} in utama_core/strategy/ at {ref or 'the working tree'}") + + # Git has no compiled planner or simulator, at any commit: take this machine's. + for path in sorted((_REPO / "utama_core").rglob("*.so")): + relative = path.relative_to(_REPO).as_posix() + if _wanted(relative): + files[relative] = path.read_bytes() + # Always this version: an older commit has none. + for path in sorted(_OWN_CODE.glob("*.py")): + files[path.relative_to(_REPO).as_posix()] = path.read_bytes() + + manifest = { + "format": FORMAT_VERSION, + "strategy": strategy, + "outfield_ids": list(outfield_ids), + "commit": _commit_of(ref or "HEAD"), + "working_tree": ref is None, + "python": f"{sys.version_info.major}.{sys.version_info.minor}", + "platform": f"{sys.platform}-{platform.machine()}", + } + files["manifest.json"] = json.dumps(manifest, indent=2, sort_keys=True).encode() + + output.parent.mkdir(parents=True, exist_ok=True) + with zipfile.ZipFile(output, "w", zipfile.ZIP_DEFLATED, compresslevel=9) as archive: + for name in sorted(files): + info = zipfile.ZipInfo(name, date_time=(1980, 1, 1, 0, 0, 0)) + info.compress_type = zipfile.ZIP_DEFLATED + info.external_attr = 0o644 << 16 + archive.writestr(info, files[name]) + return output + + +def frozen(strategy: str, ref: str, directory: Path) -> Path: + """`strategy` as it was at `ref`, built the first time and kept: a file that is never rebuilt is + a fixed baseline, whatever happens to the planner binary or this package later.""" + path = directory / f"{strategy}@{_commit_of(ref)[:8]}{SUFFIX}" + if not path.exists(): + partial = build(strategy, path.with_suffix(".partial"), ref) + partial.rename(path) + return path + + +def _stop(process: subprocess.Popen) -> None: + try: + process.stdin.close() + except BrokenPipeError: # it has already gone + pass + try: + process.wait(timeout=10) + except subprocess.TimeoutExpired: + process.kill() + process.wait() + process.stdout.close() + + +class _RemoteKernel: + """What `StrategyRunner` reads off a kernel `Strategy` (match log, slots, partition, keeper), answered + by the file's process, so stats, fouls, intentions and the dashboard work as for any strategy.""" + + def __init__(self, owner: "BundledStrategy"): + self._owner = owner + self._match_log = None + self._tactics: dict = {} + + @property + def match_log(self): + return self._match_log + + @match_log.setter + def match_log(self, log) -> None: + self._match_log = log + if log is not None: + self._owner._send({"type": "match_log"}) + + def record(self, events: list) -> None: + for name, fields in events: + if name == "IntentionEvent": + fields = {**fields, "tag": TacticTag(fields["tag"]), "robot_ids": tuple(fields["robot_ids"])} + self._match_log._events.append(IntentionEvent(**fields)) + else: + self._match_log._events.append(TraceEvent(**fields)) + + def slot_status(self, game) -> dict: + return self._owner._query("slot_status") + + @property + def active_partition(self) -> dict: + reply = self._owner._query("partition") + # The runner names a tactic by `type(kernel._tactics[id]).__name__`. + self._tactics = {tactic_id: type(name, (), {})() for tactic_id, name in reply["names"].items()} + return reply["partition"] + + @property + def _pinned_robot_id(self) -> int: + return self._owner._goalkeeper_id + + +class BundledStrategy(AbstractStrategy): + """A `.strategy` file, as `StrategyRunner` drives any strategy.""" + + def __init__(self, path: str | Path, outfield_robot_ids: Optional[tuple[int, ...]] = None): + """`outfield_robot_ids`: the robots this run has, if not the ones the file was built for + (a field day rarely has five).""" + super().__init__(build=None) + self.path = Path(path) + root = unpack(self.path) + self.manifest = read_manifest(root) + if self.manifest["format"] != FORMAT_VERSION: + raise ValueError(f"{path}: format {self.manifest['format']}, this code reads {FORMAT_VERSION}") + self._process = subprocess.Popen( + [sys.executable, "-m", "utama_core.bundle.host", *map(str, outfield_robot_ids or ())], + cwd=root, + env={**os.environ, "PYTHONPATH": str(root)}, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + ) + self.close = weakref.finalize(self, _stop, self._process) + self.control_scheme = self._reply()["control_scheme"] + self._kernel_strategy = _RemoteKernel(self) + self._sent_frame = None + + def _send(self, message: dict) -> None: + wire.send(self._process.stdin, message) + + def _reply(self): + reply = wire.receive(self._process.stdout) + if reply is None: + raise RuntimeError(f"{self.path}: its process stopped (exit code {self._process.wait()})") + return reply + + def load_motion_controller(self, motion_controller) -> None: + self.motion_controller = motion_controller + self._send( + { + "type": "setup", + "controller": type(motion_controller).__name__, + "mode": motion_controller.mode.value, + "latency_s": motion_controller.pose_ahead.latency_s, + "robot_carry": {str(rid): list(carry) for rid, carry in motion_controller.robot_carry.items()}, + "kick_bend": {str(rid): bend for rid, bend in motion_controller.kick_bend.items()}, + "kick_bias": {str(rid): bias for rid, bias in motion_controller.kick_bias.items()}, + } + ) + + def load_game(self, game) -> None: + super().load_game(game) + self._sent_frame = game._current_game_standard_frame + self._send( + {"type": "game", "frame": wire.encode_frame(self._sent_frame), "field": wire.encode_field(game.field)} + ) + + def _sync(self) -> None: + """The file's process sees the frame this side sees now, before it is asked anything: the + runner reads which tactics are committed after a new frame and before stepping.""" + frame = self.game._current_game_standard_frame + if frame is not self._sent_frame: + self._send({"type": "frame", "frame": wire.encode_frame(frame)}) + self._sent_frame = frame + + def _query(self, name: str): + self._sync() + self._send({"type": "query", "name": name}) + return self._reply() + + def step(self) -> None: + self._sync() + self._send({"type": "tick"}) + reply = self._reply() + self._kernel_strategy.record(reply["events"]) + commands = {int(robot_id): RobotCommand(*values) for robot_id, values in reply["commands"].items()} + if self._kicker_charge is not None: # needs the robot controller, which stays on this side + commands = self._kicker_charge.apply(self.game, commands) + for robot_id in self.game.friendly_robots: + if robot_id in commands: + self.robot_controller.add_robot_commands(commands[robot_id], robot_id) + self.robot_controller.send_robot_commands() + + def debug_status(self) -> dict[int, list[str]]: + return {int(robot_id): row for robot_id, row in self._query("debug_status").items()} diff --git a/utama_core/bundle/wire.py b/utama_core/bundle/wire.py new file mode 100644 index 000000000..2f3fe292f --- /dev/null +++ b/utama_core/bundle/wire.py @@ -0,0 +1,101 @@ +"""What crosses the process boundary of a `.strategy` file: length-prefixed JSON. + +Standard library only, and it reads frames by attribute: this file ships inside every bundle and +must work with the entity classes of whichever commit the bundle holds. JSON and not pickle because +the runner must be able to read what a bundle sends without running anything it says. A Python float +survives JSON exactly, so a bundled match can equal the same match run in one process. +""" + +from __future__ import annotations + +import json +import struct +from typing import Any, BinaryIO, Optional + +_HEADER = struct.Struct(" None: + data = json.dumps(message, separators=(",", ":")).encode() + stream.write(_HEADER.pack(len(data)) + data) + stream.flush() + + +def receive(stream: BinaryIO) -> Optional[Any]: + """The next message, or None when the other side has gone.""" + header = stream.read(_HEADER.size) + if len(header) < _HEADER.size: + return None + (length,) = _HEADER.unpack(header) + data = stream.read(length) + if len(data) < length: + return None + return json.loads(data) + + +def _vector(vector) -> list[float]: + return [float(vector.x), float(vector.y)] + ([float(vector.z)] if hasattr(vector, "z") else []) + + +def _robot(robot) -> list: + return [ + int(robot.id), + bool(robot.is_friendly), + bool(robot.has_ball), + _vector(robot.p), + _vector(robot.v), + _vector(robot.a), + float(robot.orientation), + ] + + +def _team(team) -> dict: + return dict(vars(team)) + + +def _referee(referee) -> Optional[dict]: + if referee is None: + return None + return { + "source_identifier": referee.source_identifier, + "time_sent": referee.time_sent, + "time_received": referee.time_received, + "referee_command": referee.referee_command.name, + "referee_command_timestamp": referee.referee_command_timestamp, + "stage": referee.stage.name, + "stage_time_left": referee.stage_time_left, + "blue_team": _team(referee.blue_team), + "yellow_team": _team(referee.yellow_team), + "designated_position": referee.designated_position, + "blue_team_on_positive_half": referee.blue_team_on_positive_half, + "next_command": None if referee.next_command is None else referee.next_command.name, + "current_action_time_remaining": referee.current_action_time_remaining, + "match_type": referee.match_type, + "status_message": referee.status_message, + } + + +def encode_frame(frame) -> dict: + """A `GameFrame`, without the referee's raw `game_events`: no strategy reads them.""" + ball = frame.ball + return { + "ts": float(frame.ts), + "my_team_is_yellow": bool(frame.my_team_is_yellow), + "my_team_is_right": bool(frame.my_team_is_right), + "friendly_robots": [_robot(robot) for robot in frame.friendly_robots.values()], + "enemy_robots": [_robot(robot) for robot in frame.enemy_robots.values()], + "ball": None if ball is None else [_vector(ball.p), _vector(ball.v), _vector(ball.a)], + "referee": _referee(frame.referee), + } + + +def encode_field(field) -> dict: + dims = field._field_dims + bounds = field._field_bounds + return { + "my_team_is_right": field.my_team_is_right, + "dims": {name: getattr(dims, name) for name in dims.__dataclass_fields__}, + "top_left": list(bounds.top_left), + "bottom_right": list(bounds.bottom_right), + "defense_area_rules": field._defense_area_rules, + } diff --git a/utama_core/config/formations.py b/utama_core/config/formations.py index a53855b2f..a8fbdf1f9 100644 --- a/utama_core/config/formations.py +++ b/utama_core/config/formations.py @@ -6,7 +6,7 @@ from utama_core.config.field_params import FieldBounds from utama_core.config.physical_constants import MAX_ROBOTS, ROBOT_RADIUS -from utama_core.global_utils.math_utils import normalise_heading +from utama_core.geometry.math_utils import normalise_heading class FormationEntry(NamedTuple): diff --git a/utama_core/custom_referee/__init__.py b/utama_core/custom_referee/__init__.py deleted file mode 100644 index 6b08039e9..000000000 --- a/utama_core/custom_referee/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from utama_core.custom_referee.custom_referee import CustomReferee -from utama_core.custom_referee.geometry import RefereeGeometry - -__all__ = ["CustomReferee", "RefereeGeometry"] diff --git a/utama_core/custom_referee/profiles/__init__.py b/utama_core/custom_referee/profiles/__init__.py deleted file mode 100644 index 5b9edc28f..000000000 --- a/utama_core/custom_referee/profiles/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from utama_core.custom_referee.profiles.profile_loader import load_profile - -__all__ = ["load_profile"] diff --git a/utama_core/custom_referee/restart_fuzzer.py b/utama_core/custom_referee/restart_fuzzer.py deleted file mode 100644 index 6969b3f91..000000000 --- a/utama_core/custom_referee/restart_fuzzer.py +++ /dev/null @@ -1,432 +0,0 @@ -"""RestartFuzzingReferee: opt-in referee subclass that injects scripted restarts. - -Motivation (see `docs/STRATEGY_DEVELOPMENT.md` / `docs/custom_referee.md`): -rsim is deterministic, and the 231-pairing round-robin tournament always -starts from the same kickoff and only ever *reacts* to whatever restarts -naturally occur during a match — most of which never happen at all in a -given pairing/formation. Most stalls found in practice have been in referee -restart auto-advance paths (`GameStateMachine.step()`'s five `Auto-advance` -blocks in `state_machine.py`) that only get exercised when a real foul/goal -happens to occur. `RestartFuzzingReferee` exercises those code paths far -more often, in many more ball/robot geometries, by injecting additional -*legal* restarts at seeded-random sim times during otherwise-normal live -play. - -This is deliberately a thin subclass, not a new referee: `CustomReferee` -already owns rule-checking, state transitions, and auto-advance; this class -only decides *when* and *what* to inject, then calls the same public -`set_command` API a human operator or scenario script would use (see -`utama_core/tests/strategy_runner/test_scenario_hooks.py`'s -`test_custom_referee_set_command_accepts_scripted_metadata`). Because -`set_command` inserts a real `STOP` before any set-piece command (see -`GameStateMachine.set_command`), an injected restart goes through exactly -the same `STOP -> queued restart -> NORMAL_START` auto-advance sequence a -naturally-detected foul/goal would, so a stall it exposes is indistinguishable -from — and just as real as — a naturally occurring one. - -`StrategyRunner` never needs to know about this class: it only checks -`isinstance(self.referee, CustomReferee)` (see `strategy_runner.py`) before -calling `referee.step(...)`, `referee.attach_match_log(...)`, etc. — all of -which this subclass inherits or overrides compatibly. -""" - -from __future__ import annotations - -import random -from dataclasses import dataclass -from typing import Optional - -from utama_core.custom_referee.custom_referee import CustomReferee -from utama_core.custom_referee.profiles.profile_loader import load_profile -from utama_core.entities.data.referee import RefereeData -from utama_core.entities.game.game_frame import GameFrame -from utama_core.entities.referee.referee_command import RefereeCommand - -# Commands that count as "live play" — the only state an injection may -# start from (mirrors OutOfBoundsRule/BallSpeedRule/DefenseAreaRule's own -# `_ACTIVE_PLAY_COMMANDS` gating, kept independently here since we do not own -# any of those rule files). -_LIVE_PLAY_COMMANDS = frozenset({RefereeCommand.NORMAL_START, RefereeCommand.FORCE_START}) - -# Rulebook margin (SSL §8.4.1: "keep at least 0.2 meters distance to the -# opponent defense area") reused from defense_area_stoppage_rule.py's -# `_MIN_DISTANCE` — not imported directly since that name is a private -# module constant of a file we don't own; duplicated as a literal with the -# same provenance noted here rather than reimplementing the geometry. -_DEFENSE_AREA_MARGIN = 0.2 - -# Delay (sim seconds) between the injected STOP and its FORCE_START -# follow-up for KIND_FORCE_START — long enough for `_all_robots_clear()`'s -# 0.5 m keep-out check (state_machine.py's `_BALL_CLEAR_DIST`) to plausibly -# be satisfied by the time FORCE_START lands, short enough to stay well -# under `_STOP_CLEAR_TIMEOUT_SECONDS` (15 s) so this follow-up is never -# mistaken for — or masks — the auto-advance stall detector it's meant to -# exercise coverage of. -_FORCE_START_STOP_DELAY_S = 2.0 - -# Field-line margin for a playable placement spot — mirrors -# OutOfBoundsRule._INFIELD_OFFSET (0.25 m), which OutOfBoundsRule itself -# picked "for a playable free-kick placement" against the same field-line -# geometry a fuzzed ball-placement target needs to respect. -_FIELD_LINE_MARGIN = 0.25 - -# Kinds of restart this fuzzer knows how to inject. Each is a self-contained -# scripted sequence built entirely from the public `set_command` API. -KIND_BALL_PLACEMENT_DIRECT_FREE = "ball_placement_direct_free" -KIND_FORCE_START = "force_start" -KIND_PREPARE_KICKOFF = "prepare_kickoff" - -ALL_KINDS = ( - KIND_BALL_PLACEMENT_DIRECT_FREE, - KIND_FORCE_START, - KIND_PREPARE_KICKOFF, -) - - -@dataclass(frozen=True) -class Injection: - """One record of a fuzzer-injected restart, kept on `injections` so a - caller (validation script, test) can log/inspect what was injected.""" - - sim_time: float - kind: str - team_is_yellow: Optional[bool] # None for kinds with no team (none currently, kept for forward-compat) - position: Optional[tuple[float, float]] # designated_position, when the kind sets one - - -class RestartFuzzingReferee(CustomReferee): - """`CustomReferee` subclass that periodically injects a scripted, legal - restart during live play, on top of whatever the rule checkers detect - naturally. - - Usage:: - - referee = RestartFuzzingReferee.from_profile_name( - "simulation", seed=1, interval_s=(8, 20), n_robots_yellow=6, n_robots_blue=6 - ) - runner = StrategyRunner(..., referee=referee) - runner.run() - for inj in referee.injections: - print(inj) - - Args: - profile: Same `RefereeProfile` `CustomReferee.__init__` takes. - seed: RNG seed. Same seed (and same sequence of `step()` sim times) - always produces the same injection schedule, kinds, teams, and - positions — see `test_seed_determinism`. - interval_s: `(min, max)` sim-seconds range between injections; - each gap is drawn uniformly from this range using `seed`. - kinds: Which injection kinds are enabled (subset of `ALL_KINDS`). - Defaults to all three. - n_robots_yellow, n_robots_blue: Passed through to `CustomReferee`. - """ - - def __init__( - self, - profile, - seed: int, - interval_s: tuple[float, float] = (8.0, 20.0), - kinds: tuple[str, ...] = ALL_KINDS, - n_robots_yellow: int = 3, - n_robots_blue: int = 3, - ) -> None: - super().__init__(profile, n_robots_yellow=n_robots_yellow, n_robots_blue=n_robots_blue) - if interval_s[0] <= 0 or interval_s[1] < interval_s[0]: - raise ValueError(f"interval_s must be a positive, non-decreasing (min, max) pair, got {interval_s}") - if not kinds: - raise ValueError("kinds must be non-empty") - unknown = set(kinds) - set(ALL_KINDS) - if unknown: - raise ValueError(f"unknown injection kind(s): {sorted(unknown)}") - - self._seed = seed - self._interval_s = interval_s - self._kinds = tuple(kinds) - self._rng = random.Random(seed) - - # Scheduled sim-time of the next injection. Set lazily on the first - # `step()` call once we know the clock's starting sim time (mirrors - # how `CustomReferee.seed_clock()` defers timer alignment until the - # first real game frame — we do the same here for the same reason: - # rsim time and grsim/real wall-clock time start from very different - # bases). - self._next_injection_time: Optional[float] = None - - # Pending follow-up for the two-step STOP-then-FORCE_START sequence - # (KIND_FORCE_START): the sim time at which to issue the follow-up - # `set_command`, or None when no follow-up is pending. Deferred to a - # later tick (rather than issued in the same `step()` call as the - # STOP) so the STOP is a real, observable tick on its own — the same - # shape a human GC operator or `strategy_runner.py`'s own - # STOP-after-goal fast path uses — and so a stalled STOP->FORCE_START - # transition is genuinely detectable rather than being collapsed - # into a single atomic call. - self._pending_force_start_at: Optional[float] = None - - # Pending follow-up for the KIND_BALL_PLACEMENT_DIRECT_FREE sequence: - # `(placement_cmd, direct_free_cmd)` once the initial `set_command` - # (queuing STOP -> placement_cmd) has been issued, or `None`. Consumed - # the moment `step()` observes `referee_command == placement_cmd` - # (i.e. GameStateMachine's own STOP auto-advance has actually flipped - # into it), at which point `next_command` is overwritten to - # `direct_free_cmd` so ball placement resumes into a real free kick - # instead of straight to NORMAL_START. See `_inject`'s - # KIND_BALL_PLACEMENT_DIRECT_FREE branch for why this two-step dance - # is necessary rather than a single `set_command(..., next_command=)` - # call. - self._pending_direct_free: Optional[tuple[RefereeCommand, RefereeCommand]] = None - - self.injections: list[Injection] = [] - - @classmethod - def from_profile_name( - cls, - name: str, - seed: int, - interval_s: tuple[float, float] = (8.0, 20.0), - kinds: tuple[str, ...] = ALL_KINDS, - n_robots_yellow: int = 3, - n_robots_blue: int = 3, - ) -> "RestartFuzzingReferee": - """Convenience constructor mirroring `CustomReferee.from_profile_name`.""" - profile = load_profile(name) - return cls( - profile, - seed=seed, - interval_s=interval_s, - kinds=kinds, - n_robots_yellow=n_robots_yellow, - n_robots_blue=n_robots_blue, - ) - - # ------------------------------------------------------------------ - # Main loop interface - # ------------------------------------------------------------------ - - def step(self, game_frame: GameFrame, current_time: float) -> RefereeData: - """Delegate to `CustomReferee.step()`, then decide whether to inject.""" - result = super().step(game_frame, current_time) - - # Fire any pending BALL_PLACEMENT_* -> DIRECT_FREE_* follow-up (see - # `_pending_direct_free`) once the state machine has actually - # transitioned into the queued placement command. - if self._pending_direct_free is not None: - placement_cmd, direct_free_cmd = self._pending_direct_free - if result.referee_command == placement_cmd: - self._pending_direct_free = None - self._state.next_command = direct_free_cmd - result = self._state._generate_referee_data(current_time) - - # Fire any pending STOP -> FORCE_START follow-up (see - # `_pending_force_start_at`) before considering a brand new - # injection, so the two never race within the same tick. - if self._pending_force_start_at is not None and current_time >= self._pending_force_start_at: - self._pending_force_start_at = None - self.set_command( - RefereeCommand.FORCE_START, - timestamp=current_time, - status_message="restart_fuzzer: injected FORCE_START", - ) - # `set_command` mutates `self._state` directly but (unlike - # `step()`) doesn't return a fresh `RefereeData` snapshot — ask - # the state machine to regenerate one so this method's return - # value reflects the FORCE_START we just issued, same as every - # other caller of `CustomReferee.step()` expects a same-tick - # snapshot. `_generate_referee_data` is a private read-only - # accessor (no state mutation) on `GameStateMachine`, which we - # don't own — used here rather than duplicating its trivial - # dataclass-construction logic. - result = self._state._generate_referee_data(current_time) - - if self._next_injection_time is None: - self._schedule_next(current_time) - return result - - if current_time < self._next_injection_time: - return result - - if ( - not self._is_live_play(result) - or self._pending_force_start_at is not None - or self._pending_direct_free is not None - ): - # Not currently eligible (mid-restart, just after a goal / ball - # not yet back in play, or a FORCE_START follow-up is already - # pending) — don't burn the schedule; just wait for the next - # tick and re-check. This means an injection can fire slightly - # later than `_next_injection_time` if the game happens to be - # mid-restart exactly then, but it will never fire *during* one. - return result - - self._inject(game_frame, current_time) - self._schedule_next(current_time) - return result - - # ------------------------------------------------------------------ - # Scheduling - # ------------------------------------------------------------------ - - def _schedule_next(self, current_time: float) -> None: - gap = self._rng.uniform(*self._interval_s) - self._next_injection_time = current_time + gap - - def _is_live_play(self, ref_data: RefereeData) -> bool: - """True iff the game is in ordinary live play right now: command is - NORMAL_START/FORCE_START (not mid-restart), and there is no - just-scored-goal ball-placement queued (a goal always routes through - `designated_position=(0.0, 0.0)` + a queued `BALL_PLACEMENT_*`/ - `PREPARE_KICKOFF_*` `next_command` per `GameStateMachine._handle_goal` - — `next_command is None` during genuine live play, since it's only - ever populated while a restart is queued/in-flight). - """ - return ref_data.referee_command in _LIVE_PLAY_COMMANDS and ref_data.next_command is None - - # ------------------------------------------------------------------ - # Injection - # ------------------------------------------------------------------ - - def _inject(self, game_frame: GameFrame, current_time: float) -> None: - kind = self._rng.choice(self._kinds) - team_is_yellow = self._rng.choice([True, False]) - - if kind == KIND_BALL_PLACEMENT_DIRECT_FREE: - position = self._random_legal_position() - placement_cmd = ( - RefereeCommand.BALL_PLACEMENT_YELLOW if team_is_yellow else RefereeCommand.BALL_PLACEMENT_BLUE - ) - direct_free_cmd = RefereeCommand.DIRECT_FREE_YELLOW if team_is_yellow else RefereeCommand.DIRECT_FREE_BLUE - # Chain BALL_PLACEMENT_* -> DIRECT_FREE_* -> NORMAL_START the same - # way a real foul does (GameStateMachine._handle_foul routes a - # foul's designated_position through ball placement first, then - # `_post_ball_placement_command` resumes into the real restart - # command once placement completes — see auto-advance 1 and 4 in - # state_machine.py). `_post_ball_placement_command` has no public - # setter, so it can't be reached through `set_command()` alone: - # passing `next_command=direct_free_cmd` to `set_command()` would - # silently overwrite the STOP-insertion's own `next_command = - # placement_cmd` and skip ball placement entirely (verified via a - # scratch rsim run: BALL_PLACEMENT_BLUE never appeared in the - # observed command history when this was tried). Two separate - # `set_command()` calls avoid that clobber: the first queues - # BALL_PLACEMENT_* behind a STOP exactly like a real foul would; - # once GameStateMachine's own auto-advance 1 flips STOP -> - # BALL_PLACEMENT_* (next_command defaults to NORMAL_START at that - # point per auto-advance 1's `self.next_command = - # self._post_ball_placement_command or RefereeCommand.NORMAL_START`), - # the second call (scheduled via `_pending_direct_free`, fired - # from `step()` once BALL_PLACEMENT_* is actually observed) - # overwrites `next_command` to the real DIRECT_FREE_* so auto- - # advance 4 resumes into it instead of straight to NORMAL_START. - self.set_command( - placement_cmd, - timestamp=current_time, - designated_position=position, - status_message="restart_fuzzer: injected ball placement", - ) - self._pending_direct_free = (placement_cmd, direct_free_cmd) - elif kind == KIND_FORCE_START: - position = None - # FORCE_START is not itself a member of `_NEEDS_STOP_FIRST`, so - # `set_command` has no built-in way to queue it as a `next_command` - # the way it does for BALL_PLACEMENT_*/PREPARE_KICKOFF_*/ - # DIRECT_FREE_*. Script the same two-step shape a human GC - # operator (or `strategy_runner.py`'s own STOP-after-goal fast - # path) uses instead: issue STOP now, then a genuine follow-up - # `set_command(FORCE_START)` a few seconds later once robots have - # had a chance to react to the STOP — scheduled via - # `_pending_force_start_at` and fired from a later `step()` call - # (see there) rather than in this same tick, so the STOP is a - # real, independently observable transition and a stall in - # either half of the sequence is genuinely detectable. - self.set_command( - RefereeCommand.STOP, - timestamp=current_time, - status_message="restart_fuzzer: injected STOP before FORCE_START", - ) - self._pending_force_start_at = current_time + _FORCE_START_STOP_DELAY_S - elif kind == KIND_PREPARE_KICKOFF: - position = None - kickoff_cmd = ( - RefereeCommand.PREPARE_KICKOFF_YELLOW if team_is_yellow else RefereeCommand.PREPARE_KICKOFF_BLUE - ) - # Same metadata shape a real kickoff restart uses (no - # designated_position — kickoff readiness is centre-circle - # presence, not a placement target; see - # GameStateMachine._kicker_in_centre_circle). set_command() - # inserts STOP first since PREPARE_KICKOFF_* is in - # `_NEEDS_STOP_FIRST`. - self.set_command( - kickoff_cmd, - timestamp=current_time, - status_message="restart_fuzzer: injected kickoff", - ) - else: # pragma: no cover - guarded by __init__'s kinds validation - raise AssertionError(f"unhandled kind: {kind}") - - injection = Injection( - sim_time=current_time, - kind=kind, - team_is_yellow=team_is_yellow, - position=position, - ) - self.injections.append(injection) - - if self._match_log is not None: - self._match_log.trace( - tick=self._match_log_tick, - sim_time=current_time, - key="restart_fuzzer_injection", - value={ - "kind": kind, - "team_is_yellow": team_is_yellow, - "position": list(position) if position is not None else None, - }, - ) - - def _random_legal_position(self) -> tuple[float, float]: - """Draw a designated-placement position that is legal per the SSL - rulebook: inside the field, outside both defense areas, and at - least the rulebook margin from the field boundary lines. - - Reuses `RefereeGeometry`'s own inside-field/defense-area helpers - (`is_in_field` is not used directly — sampling is done within a - margin-shrunk field rectangle from the start, so every draw is - legal by construction rather than rejection-sampled against - `is_in_field`) plus `is_in_left/right_defense_area` to reject draws - that land inside a defense area (rare, since defense areas sit at - the ends of the field, but not impossible for a draw near the - margin-shrunk rectangle's x-extremes). - """ - geometry = self.geometry - x_bound = geometry.half_length - _FIELD_LINE_MARGIN - y_bound = geometry.half_width - _FIELD_LINE_MARGIN - - for _ in range(1000): - x = self._rng.uniform(-x_bound, x_bound) - y = self._rng.uniform(-y_bound, y_bound) - if self._position_is_legal(x, y): - return (x, y) - # Practically unreachable (the margin-shrunk rectangle minus two - # defense-area rectangles at its ends still covers most of the - # field) — fall back to the centre spot, which is always legal on - # any standard or shrunk field geometry. - return (0.0, 0.0) - - def _position_is_legal(self, x: float, y: float) -> bool: - """True iff (x, y) is inside the field with the field-line margin - already baked into the caller's sampling rectangle, and at least - `_DEFENSE_AREA_MARGIN` from both defense areas (rulebook §8.4.1's - "0.2 meters distance to the opponent defense area", reused for - *either* defense area — an own-defense-area placement is illegal - for the same reason DefenseAreaRule keeps friendly robots out - during live play). Uses `RefereeGeometry.distance_to_left/right_ - defense_area`, which is already 0.0 for a point inside the - rectangle, so this rejects both "inside" and "too close" in one - check per side. - """ - geometry = self.geometry - if geometry.distance_to_left_defense_area(x, y) < _DEFENSE_AREA_MARGIN: - return False - if geometry.distance_to_right_defense_area(x, y) < _DEFENSE_AREA_MARGIN: - return False - return True diff --git a/utama_core/custom_referee/rules/__init__.py b/utama_core/custom_referee/rules/__init__.py deleted file mode 100644 index 7a6548f0a..000000000 --- a/utama_core/custom_referee/rules/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -from utama_core.custom_referee.rules.base_rule import BaseRule, RuleViolation -from utama_core.custom_referee.rules.defense_area_rule import DefenseAreaRule -from utama_core.custom_referee.rules.goal_rule import GoalRule -from utama_core.custom_referee.rules.keep_out_rule import KeepOutRule -from utama_core.custom_referee.rules.out_of_bounds_rule import OutOfBoundsRule - -__all__ = [ - "BaseRule", - "RuleViolation", - "GoalRule", - "OutOfBoundsRule", - "DefenseAreaRule", - "KeepOutRule", -] diff --git a/dashboard_server.py b/utama_core/dashboard/__main__.py similarity index 71% rename from dashboard_server.py rename to utama_core/dashboard/__main__.py index fb42deb40..306a62b43 100644 --- a/dashboard_server.py +++ b/utama_core/dashboard/__main__.py @@ -1,17 +1,17 @@ -"""dashboard_server.py — standalone dashboard (Replay + Tournament only). +"""utama_core/dashboard/__main__.py — standalone dashboard (Replay + Strategies only). Run: - pixi run python dashboard_server.py + pixi run dashboard (or: python -m utama_core.dashboard) # open http://localhost:8080 in a browser No live match, no CustomReferee, no StrategyRunner — `attach_dashboard()` -already wires up Replay and Tournament unconditionally (both are stateless +already wires up Replay and Strategies unconditionally (both are stateless readers of `replays/*/summary.json` and `*.pkl` files on disk), so this script's only job is to start the HTTP server and keep the process alive. Live/Referee views need a running match to attach to and so are still opt-in — see `examples/demo_referee_gui_rsim.py` for a script that starts one. -Use this when you just want to browse recorded replays or tournament +Use this when you just want to browse recorded replays or evaluation standings without also starting a live rsim match. """ diff --git a/utama_core/dashboard/page.py b/utama_core/dashboard/page.py index 7e4da9402..d6d1c68fc 100644 --- a/utama_core/dashboard/page.py +++ b/utama_core/dashboard/page.py @@ -1,7 +1,7 @@ """Assembles the dashboard's single-page shell by inlining `static/*` files. Kept dependency-free and build-step-free on purpose (same constraint -`custom_referee/gui.py` operated under): one HTML string, served by the +`referee/gui.py` operated under): one HTML string, served by the stdlib HTTP server, no bundler, no separate static file route. """ @@ -22,5 +22,5 @@ def build_page() -> str: .replace("__LIVE_JS__", (_STATIC_DIR / "live.js").read_text()) .replace("__TIMELINE_JS__", (_STATIC_DIR / "timeline.js").read_text()) .replace("__REPLAY_JS__", (_STATIC_DIR / "replay.js").read_text()) - .replace("__TOURNAMENT_JS__", (_STATIC_DIR / "tournament.js").read_text()) + .replace("__STRATEGIES_JS__", (_STATIC_DIR / "strategies.js").read_text()) ) diff --git a/utama_core/dashboard/server.py b/utama_core/dashboard/server.py index bf2c6252f..e5f5e63d4 100644 --- a/utama_core/dashboard/server.py +++ b/utama_core/dashboard/server.py @@ -7,7 +7,7 @@ handler for the path. Each `views/*.py` module owns its own state shape and registers itself against a running server — this module just moves bytes. -Extracted from `custom_referee/gui.py`'s `_RefereeGUIServer`, which used to +Extracted from `referee/gui.py`'s `_RefereeGUIServer`, which used to run one server per referee instance with a single hardcoded SSE channel and a single hardcoded `/command` handler. Multiple views sharing one server means one browser tab, one port, one process — not a GUI per concern. @@ -56,7 +56,7 @@ def send(self, data: bytes) -> bool: def attach_dashboard(port: int = 8080) -> "DashboardServer": """Start the dashboard's HTTP server in a background daemon thread. - Tournament and Replay views are attached automatically — both are + Strategies and Replay views are attached automatically — both are stateless readers of files on disk (`replays/*/summary.json`, `*.pkl`), so every dashboard instance gets them working with no per-script wiring. The Referee and Live views depend on a specific running match/referee @@ -65,11 +65,11 @@ def attach_dashboard(port: int = 8080) -> "DashboardServer": """ from utama_core.dashboard.page import build_page from utama_core.dashboard.views import replay as replay_view - from utama_core.dashboard.views import tournament as tournament_view + from utama_core.dashboard.views import strategies as strategies_view server = DashboardServer(port) server.set_page(build_page()) - tournament_view.attach(server) + strategies_view.attach(server) replay_view.attach(server) server.start() print(f"Dashboard → http://localhost:{port}") @@ -83,7 +83,7 @@ class DashboardServer(threading.Thread): that channel receives it as one `data:` frame. Views register POST handlers with `add_command_handler(path, handler)` and static payload getters with `add_route(path, getter)` for simple `GET -> JSON` endpoints - (e.g. tournament summaries, replay frame lists). + (e.g. evaluation summaries, replay frame lists). """ def __init__(self, port: int) -> None: diff --git a/utama_core/dashboard/static/app.css b/utama_core/dashboard/static/app.css index f79759c3b..c8676209c 100644 --- a/utama_core/dashboard/static/app.css +++ b/utama_core/dashboard/static/app.css @@ -4,15 +4,19 @@ safety-relevant, not decorative. */ :root { - --bg: #17191d; - --surface: #1e2126; - --surface-2: #262a31; - --border: #33373f; - --text: #dfe2e8; - --muted: #8b909b; - --accent: #7ea6c9; - --halt: #b8615a; - --radius: 5px; + --bg: #f5f6f8; + --surface: #ffffff; + --surface-2: #f0f2f5; + --border: #e2e5ea; + --text: #1c2230; + --muted: #6b7280; + --accent: #2563eb; + --halt: #c53030; + --ok: #15803d; + --warn: #b45309; + --fail: #b91c1c; + --radius: 8px; + --mono: ui-monospace, "SF Mono", "Cascadia Code", monospace; } * , *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; } @@ -22,40 +26,40 @@ html, body { height: 100%; } body { background: var(--bg); color: var(--text); - font-family: ui-monospace, "SF Mono", "Cascadia Code", monospace; + font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; + font-size: 14px; + line-height: 1.45; height: 100vh; display: flex; flex-direction: column; overflow: hidden; } +code, pre { font-family: var(--mono); font-size: .85em; } + #tabs { display: flex; - gap: 2px; - padding: 6px 8px 0; + gap: 4px; + padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; } .tab { - padding: 7px 16px; - font-size: .72rem; - letter-spacing: .04em; - text-transform: uppercase; + padding: 12px 14px 10px; + font-size: .9rem; + font-weight: 500; color: var(--muted); background: transparent; - border: 1px solid transparent; - border-bottom: none; - border-radius: var(--radius) var(--radius) 0 0; + border: none; + border-bottom: 2px solid transparent; + border-radius: 0; cursor: pointer; } -.tab.active { - color: var(--text); - background: var(--bg); - border-color: var(--border); -} +.tab:hover { color: var(--text); border-color: transparent; border-bottom-color: var(--border); } +.tab.active { color: var(--text); border-bottom-color: var(--accent); } .view { flex: 1; @@ -77,11 +81,10 @@ body { } .panel-title { - padding: 7px 14px; - font-size: .62rem; - letter-spacing: .1em; - text-transform: uppercase; - color: var(--muted); + padding: 10px 14px; + font-size: .85rem; + font-weight: 600; + color: var(--text); border-bottom: 1px solid var(--border); flex-shrink: 0; } @@ -107,38 +110,36 @@ body { justify-content: center; background: color-mix(in srgb, var(--bg) 80%, transparent); color: var(--muted); - font-size: .78rem; - letter-spacing: .04em; - text-transform: uppercase; + font-size: .9rem; } button { padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius); - background: var(--surface-2); + background: var(--surface); color: var(--text); font-family: inherit; - font-size: .72rem; - letter-spacing: .03em; + font-size: .82rem; cursor: pointer; } button:hover { border-color: var(--accent); } button:active { transform: translateY(1px); } button.btn-halt { color: var(--halt); border-color: var(--halt); } -button.btn-accent { color: var(--accent); border-color: var(--accent); } +button.btn-accent { color: #fff; background: var(--accent); border-color: var(--accent); } +button.btn-accent:hover { filter: brightness(1.08); } select, input[type="range"] { font-family: inherit; - font-size: .72rem; + font-size: .82rem; color: var(--text); } select { padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); - background: var(--surface-2); + background: var(--surface); } input[type="range"] { accent-color: var(--accent); @@ -148,20 +149,19 @@ input[type="range"] { .row { display: flex; gap: 6px; flex-wrap: wrap; } .stack { display: flex; flex-direction: column; gap: 8px; } -table { border-collapse: collapse; width: 100%; font-size: .78rem; } -th, td { padding: 5px 10px; text-align: left; border-bottom: 1px solid var(--border); } -th { color: var(--muted); font-weight: 600; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; } +table { border-collapse: collapse; width: 100%; font-size: .88rem; } +th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border); } +th { color: var(--muted); font-weight: 500; font-size: .8rem; } td.num { text-align: right; font-variant-numeric: tabular-nums; } .muted { color: var(--muted); } .accent { color: var(--accent); } .ref-section-title { - font-size: .62rem; - letter-spacing: .08em; - text-transform: uppercase; + font-size: .8rem; + font-weight: 600; color: var(--muted); - padding-top: 6px; + padding-top: 8px; border-top: 1px solid var(--border); } .ref-row { @@ -182,11 +182,11 @@ td.num { text-align: right; font-variant-numeric: tabular-nums; } .conn-dot.live { background: var(--accent); } /* Field check (live view): one row per check, coloured by status; the auto-HALT banner. */ -.check-ok { color: #5fb87a; } -.check-warn { color: #e0a14a; } -.check-fail { color: #e06a60; font-weight: 600; } +.check-ok { color: var(--ok); } +.check-warn { color: var(--warn); } +.check-fail { color: var(--fail); font-weight: 600; } /* A robot's ball sensor on (live view's robot panel), in the field's ball colour. */ -.ball-on { background: #c98a3f; color: #1a1d24; font-weight: 600; padding: 0 6px; border-radius: 3px; } +.ball-on { background: #e8892b; color: #fff; font-weight: 600; padding: 0 6px; border-radius: 3px; } .auto-halt { background: var(--halt); color: #fff; padding: 6px 8px; border-radius: var(--radius); font-size: .75rem; } /* Replay timeline (timeline.js): swimlanes under the transport controls. */ @@ -198,7 +198,7 @@ td.num { text-align: right; font-variant-numeric: tabular-nums; } .play-row { display: flex; gap: 8px; padding: 3px 4px 3px 6px; border-left: 3px solid var(--border); cursor: pointer; } .play-row:hover { background: var(--surface-2); } .play-row.current { background: var(--surface-2); } -.play-row.goal .play-ended { color: #e0c14f; font-weight: bold; } +.play-row.goal .play-ended { color: #a16207; font-weight: bold; } .play-time { min-width: 38px; color: var(--muted); font-variant-numeric: tabular-nums; } .play-detail { color: var(--muted); } .raw-log summary { cursor: pointer; font-size: .68rem; margin-top: 8px; } @@ -209,13 +209,13 @@ td.num { text-align: right; font-variant-numeric: tabular-nums; } /* Replay timeline markers: one tick per goal / foul / stall / ball loss. */ .marker-strip { position: relative; height: 10px; margin: 0 7px; } .marker { position: absolute; top: 0; width: 3px; height: 10px; margin-left: -1px; border-radius: 1px; cursor: pointer; } -.marker-goal { background: #e0c14f; } -.marker-foul { background: #d08a4a; } +.marker-goal { background: #ca8a04; } +.marker-foul { background: #ea7a2e; } .marker-stall { background: var(--halt); } .marker-loss { background: var(--muted); } -.marker-kind { display: inline-block; min-width: 38px; font-size: .62rem; text-transform: uppercase; letter-spacing: .04em; } +.marker-kind { display: inline-block; min-width: 38px; font-size: .72rem; border-radius: 4px; } .marker-kind.marker-goal, .marker-kind.marker-foul, .marker-kind.marker-stall, .marker-kind.marker-loss { - position: static; width: auto; height: auto; margin: 0 6px 0 0; padding: 0 4px; color: #17191d; + position: static; width: auto; height: auto; margin: 0 6px 0 0; padding: 0 5px; color: #fff; } /* Live: right-click / long-press menu on the field (live.js, ball placement). */ @@ -239,3 +239,61 @@ td.num { text-align: right; font-variant-numeric: tabular-nums; } padding: 16px 24px; font-size: 1rem; background: var(--halt); color: #fff; } } + +/* Strategies tab (strategies.js) */ +#view-strategies { background: var(--bg); } +.subtabs { display: flex; gap: 4px; margin-bottom: 12px; } +.subtab { border: none; background: transparent; color: var(--muted); font-weight: 500; padding: 6px 12px; border-radius: 999px; } +.subtab:hover { color: var(--text); } +.subtab.active { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); } +.strategies-layout { display: flex; gap: 16px; width: 100%; min-height: 0; align-items: flex-start; } +.strategy-list { width: 250px; flex-shrink: 0; max-height: calc(100vh - 120px); overflow-y: auto; padding: 4px; } +.strategy-group { font-size: .75rem; color: var(--muted); padding: 10px 10px 4px; } +.strategy-item { padding: 7px 10px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; } +.strategy-item:hover { background: var(--surface-2); } +.strategy-item.active { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); font-weight: 600; } +.strategy-page { flex: 1; padding: 20px 24px; gap: 22px; overflow-y: auto; max-height: calc(100vh - 120px); } +.strategy-page h1 { font-size: 1.5rem; font-weight: 650; } +.strategy-page h2 { font-size: .95rem; font-weight: 600; margin-bottom: 8px; } +.strategy-page .lead { color: var(--muted); margin-top: 2px; } +.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .75rem; font-weight: 500; background: var(--surface-2); color: var(--muted); } +.pill.champion { background: #fef3c7; color: #92400e; } +.pill.core { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); } +.pill.better { background: #dcfce7; color: var(--ok); } +.pill.dropped { background: #fee2e2; color: var(--fail); } +.pill.undecided { background: #fef3c7; color: var(--warn); } +.tactic-chip { display: inline-block; padding: 1px 9px; border: 1px solid var(--border); border-radius: 999px; font-size: .78rem; cursor: help; } +.meta-row { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; font-size: .85rem; margin-top: 10px; } +.maps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; } +.map figcaption { font-size: .8rem; color: var(--muted); margin-bottom: 4px; } +.map svg { width: 100%; height: auto; display: block; } +.signals { display: grid; grid-template-columns: 190px 1fr 52px 52px; gap: 6px 12px; align-items: center; font-size: .85rem; max-width: 760px; } +.signals .head { font-size: .75rem; color: var(--muted); } +.signals .num { text-align: right; font-variant-numeric: tabular-nums; } +.dumbbell { position: relative; height: 14px; } +.dumbbell .track { position: absolute; left: 0; right: 0; top: 6px; height: 2px; background: var(--surface-2); } +.dumbbell .link { position: absolute; top: 6px; height: 2px; background: color-mix(in srgb, var(--accent) 35%, transparent); } +.dumbbell .dot { position: absolute; top: 2px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; } +.dumbbell .dot.this { background: var(--accent); } +.dumbbell .dot.others { background: #fff; border: 2px solid #9ca3af; } +.matches { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; } +.match > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.match .score { white-space: nowrap; } +.match > .row { flex-wrap: nowrap; flex-shrink: 0; } +.match { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: .88rem; } +.match .score { font-weight: 600; font-variant-numeric: tabular-nums; } +.match .win { color: var(--ok); } .match .loss { color: var(--fail); } .match .draw { color: var(--muted); } +.icon-btn { padding: 2px 9px; border-radius: 999px; font-size: .75rem; } +.run-card { margin-bottom: 10px; } +.run-header { cursor: pointer; display: flex; gap: 10px; align-items: baseline; } +.run-body { padding: 10px 16px 14px; gap: 12px; font-size: .88rem; } +.round-header { cursor: pointer; color: var(--muted); margin-top: 4px; } +.verdict-card { padding: 10px 12px; margin-bottom: 6px; border: 1px solid var(--border); border-radius: 6px; } +.archive-header { cursor: pointer; color: var(--muted); padding: 8px 2px; } +@media (max-width: 900px) { + .strategies-layout { flex-direction: column; } + .strategy-list { width: 100%; max-height: 30vh; } + .strategy-page { max-height: none; padding: 16px; } + .maps { grid-template-columns: 1fr; } + .signals { grid-template-columns: 130px 1fr 44px 44px; } +} diff --git a/utama_core/dashboard/static/app.js b/utama_core/dashboard/static/app.js index ad1ae52a8..d5fa69eb4 100644 --- a/utama_core/dashboard/static/app.js +++ b/utama_core/dashboard/static/app.js @@ -1,4 +1,4 @@ -// Tab shell. Each view module (referee.js, live.js, replay.js, tournament.js) +// Tab shell. Each view module (referee.js, live.js, replay.js, strategies.js) // registers itself via `Dashboard.registerView(name, { mount, onShow })`. // `mount` runs once; `onShow` runs each time the tab becomes active (views // that poll on an interval only should start when visible). @@ -30,7 +30,7 @@ const Dashboard = (() => { } // Cross-view command: switch to the Replay tab and preload a specific - // path (used by the Tournament tab's "view replay" links). `replay.js` + // path (used by the Strategies tab's "view replay" links). `replay.js` // registers this itself, since only it knows how to load a replay — this // is just the addressable hook other views call into. let _showReplay = null; diff --git a/utama_core/dashboard/static/field_canvas.js b/utama_core/dashboard/static/field_canvas.js index 8798ad6ae..3e95c36b2 100644 --- a/utama_core/dashboard/static/field_canvas.js +++ b/utama_core/dashboard/static/field_canvas.js @@ -9,15 +9,16 @@ // tactic_tags: {robotId: "attack" | "defense" | "mixed"} }); const FIELD_COLORS = { - pitch: "#242832", - line: "#4b5162", - yellow: "#e0a527", - blue: "#3d7fd1", - ball: "#c98a3f", - marker: "#e8eaf0", - laneOpen: "#5fb87a", - laneBlocked: "#c0524a", - committed: "#e0a14a", + pitch: "#e9f0e8", + line: "#a5b3a7", + yellow: "#eab308", + blue: "#2563eb", + ball: "#ea580c", + marker: "#1c2230", + heading: "#1c2230", + laneOpen: "#16a34a", + laneBlocked: "#dc2626", + committed: "#d97706", }; // Ring colour per `TacticTag` value (utama_core/engine/tactic.py) around a @@ -25,10 +26,10 @@ const FIELD_COLORS = { // the body keeps its jersey colour. Purely a display of the tag the robot's // current tactic declares; nothing in the scheduler reads it. const TACTIC_TAG_COLORS = { - attack: "#d9694f", - defense: "#4fb3a9", - mixed: "#a68fd6", - referee: "#c8c8c8", // a restart or HALT drives the robot, not its tactic + attack: "#e11d48", + defense: "#0d9488", + mixed: "#7c3aed", + referee: "#9ca3af", // a restart or HALT drives the robot, not its tactic }; // Robot body radius, world meters -> px is ROBOT_RADIUS * scale so the drawn @@ -220,7 +221,7 @@ class FieldCanvas { } // Heading dash extends past the body edge so it reads as a // direction pointer rather than disappearing into the fill. - ctx.strokeStyle = FIELD_COLORS.pitch; + ctx.strokeStyle = FIELD_COLORS.heading; ctx.lineWidth = Math.max(1, r * 0.28); // Through toX/toY, so a mirrored view (our goal on the right) mirrors it too. const headingM = (r * 1.6) / scale; @@ -231,7 +232,8 @@ class FieldCanvas { toY(bot.y + headingM * Math.sin(bot.orientation)) ); ctx.stroke(); - this._label(ctx, bot.id, cx, cy - r - 2, "bottom", "bold " + textPx, fill); + // yellow text is unreadable on the light pitch: the id takes a darker yellow + this._label(ctx, bot.id, cx, cy - r - 2, "bottom", "bold " + textPx, fill === FIELD_COLORS.yellow ? "#a16207" : fill); if (label && tactics[String(bot.id)]) { this._label(ctx, tactics[String(bot.id)], cx, cy + r + 2, "top", textPx, FIELD_COLORS.marker); } @@ -260,7 +262,7 @@ class FieldCanvas { // A robot past the area in play by more than the margin has forced HALT on real robots. const [x1, y1, x2, y2] = state.field_check.bounds; const m = state.field_check.margin; - ctx.strokeStyle = "#e06a60"; + ctx.strokeStyle = "#dc2626"; ctx.lineWidth = 2; for (const bot of [...(robots.friendly || []), ...(robots.enemy || [])]) { if (bot.x < x1 - m || bot.x > x2 + m || bot.y < y1 - m || bot.y > y2 + m) { @@ -314,7 +316,7 @@ class FieldCanvas { const [x1, y1, x2, y2] = fieldCheck.bounds; const r = rectBounds(x1, y1, x2, y2); ctx.save(); - ctx.fillStyle = "rgba(0, 0, 0, 0.45)"; + ctx.fillStyle = "rgba(28, 34, 48, 0.18)"; ctx.beginPath(); ctx.rect(0, 0, CW, CH); ctx.rect(r.x + r.w, r.y, -r.w, r.h); // opposite winding cuts the area in play out @@ -324,8 +326,8 @@ class FieldCanvas { ctx.lineWidth = 1.5; ctx.strokeRect(r.x, r.y, r.w, r.h); // Keep-out zones (StrategyRunner's keep_out): no robot may enter; one inside forces HALT. - ctx.fillStyle = "rgba(224, 106, 96, 0.25)"; - ctx.strokeStyle = "#e06a60"; + ctx.fillStyle = "rgba(220, 38, 38, 0.15)"; + ctx.strokeStyle = "#dc2626"; for (const [kx1, ky1, kx2, ky2] of fieldCheck.keep_out || []) { const k = rectBounds(kx1, ky1, kx2, ky2); ctx.fillRect(k.x, k.y, k.w, k.h); @@ -511,7 +513,7 @@ class FieldCanvas { } // The intended receive point itself, whether or not the receiver has // reached it yet — the whole point of tracing this is to see when the - // two diverge (the exact silent-aim bug class STRATEGY_DEVELOPMENT.md + // two diverge (the exact silent-aim bug class strategy.md // warns intercept_point() can produce). const tx = toX(passTarget.x), ty = toY(passTarget.y); ctx.strokeStyle = FIELD_COLORS.ball; diff --git a/utama_core/dashboard/static/index.html b/utama_core/dashboard/static/index.html index f091d7fef..066f107d2 100644 --- a/utama_core/dashboard/static/index.html +++ b/utama_core/dashboard/static/index.html @@ -11,7 +11,7 @@
- +
@@ -162,8 +162,8 @@
-
-
+
+
@@ -172,7 +172,7 @@ - + diff --git a/utama_core/dashboard/static/live.js b/utama_core/dashboard/static/live.js index 5c15518b1..bfe8db17c 100644 --- a/utama_core/dashboard/static/live.js +++ b/utama_core/dashboard/static/live.js @@ -1,5 +1,5 @@ // Live view: field canvas + referee command buttons + profile config readout. -// Successor to custom_referee/gui.py's single-page HTML/JS — same behavior, +// Successor to referee/gui.py's single-page HTML/JS — same behavior, // registered as one tab against the shared dashboard server. Named "Live" // (not "Referee") because it's the one view for watching+controlling a // running match — a tactic-assignment panel lives here too, not in a @@ -432,7 +432,7 @@ .then((r) => (r.ok ? r.json() : null)) .then((c) => { if (!c) { - // dashboard_server.py alone serves Replay and Tournament; a live match attaches this view + // `pixi run dashboard` alone serves Replay and Tournament; a live match attaches this view document.getElementById("ref-profile-name").textContent = "No live match attached"; return; } diff --git a/utama_core/dashboard/static/replay.js b/utama_core/dashboard/static/replay.js index 4d8bce3fd..c9a7481bc 100644 --- a/utama_core/dashboard/static/replay.js +++ b/utama_core/dashboard/static/replay.js @@ -208,7 +208,7 @@ function framesFromColumns(c) { return; } const t0 = frameTs(0); - const colour = { Yellow: "#e0a527", Blue: "#3d7fd1" }; + const colour = { Yellow: "#eab308", Blue: "#2563eb" }; list.innerHTML = play .map((r, i) => { const goal = r.ended && r.ended.startsWith("Goal") ? " goal" : ""; @@ -307,7 +307,7 @@ function framesFromColumns(c) { if (fieldView) fieldView.draw(frame); if (timeline) timeline.draw(frame.ts); markPlay(frame.ts); - renderRobotStatusInto("replay-status-entries", frame, { hideFeedback: true }); + renderRobotStatusInto("replay-status-entries", frame, { hideFeedback: true, hideFriendly: true }); renderTacticStatusInto("replay-tactic-entries", tacticStatus, { emptyLabel: "no tactic data at this frame", }); @@ -481,7 +481,7 @@ function framesFromColumns(c) { } function loadReplayByPath(path, atTime) { - // Entry point for other views (Tournament's "view replay" links) via + // Entry point for other views (the Strategies tab's "view replay" links) via // Dashboard.showReplay(path) — same load, but also syncs the dropdown. // The dropdown's options are only populated once loadList()'s fetch // resolves, so the value must be set inside that callback, not after diff --git a/utama_core/dashboard/static/status_panel.js b/utama_core/dashboard/static/status_panel.js index a6abb89ae..ad173eff3 100644 --- a/utama_core/dashboard/static/status_panel.js +++ b/utama_core/dashboard/static/status_panel.js @@ -93,7 +93,7 @@ function renderTacticStatusInto(containerId, tacticStatus, options) { robotId + "" + label.replace(/\s*\(committed\)/, "") + - (tagColor ? ' ' + tag + "" : "") + + (tagColor && tag !== label ? ' ' + tag + "" : "") + "" + (committed ? 'committed' : "") + "
" + diff --git a/utama_core/dashboard/static/strategies.js b/utama_core/dashboard/static/strategies.js new file mode 100644 index 000000000..6d46e9724 --- /dev/null +++ b/utama_core/dashboard/static/strategies.js @@ -0,0 +1,412 @@ +// Strategies tab: every strategy in the catalog (what it is, its tactics, its verdict, where it +// stands and shoots on the pitch, how it plays, its newest matches) and every evaluation run. +// Data: GET /strategies, /strategies/runs and /strategies/maps (dashboard/views/strategies.py). +// There are no standings: the verdict (goals, paired against the champion) is the only ranking; +// signals sit beside the other strategies' average to explain how a strategy plays (docs/signals.md). + +(function () { + let data = null; // /strategies + let runs = null; // /strategies/runs, loaded when the Runs page is first opened + let page = "strategies"; // "strategies" | "runs" + let selected = null; // strategy name + let showArchive = false; + const maps = {}; // round run_id -> /strategies/maps answer + const expandedRun = {}; // run_id -> bool; the newest starts open + const expandedRound = {}; // "run_id:k" -> bool + + const esc = (s) => + String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]); + const pct = (x) => Math.round((x || 0) * 100) + "%"; + const num = (x, d = 2) => (x == null ? "—" : Number(x).toFixed(d)); + const signed = (x, d = 2) => (x == null ? "—" : (x > 0 ? "+" : "") + Number(x).toFixed(d)); + + const pill = (text, cls, title) => `${esc(text)}`; + function replayButton(path, atTime, label) { + if (!path) return ""; + const at = atTime != null ? ` data-at="${atTime}"` : ""; + return ``; + } + + // --- the strategy list -------------------------------------------------------------------------- + + function renderList() { + const groups = [ + ["Champion", (s) => s.role === "champion"], + ["Core", (s) => s.role === "core"], + ["Reserve", (s) => s.role === "reserve"], + ]; + return groups + .map(([title, keep]) => { + const rows = data.strategies.filter(keep).sort((a, b) => a.name.localeCompare(b.name)); + if (!rows.length) return ""; + return ( + `
${title}
` + + rows + .map((s) => { + const v = s.verdicts[0]; + return ( + `
` + + `${esc(s.name)}${v ? pill(v.verdict, v.verdict) : ""}
` + ); + }) + .join("") + ); + }) + .join(""); + } + + // --- one strategy ------------------------------------------------------------------------------- + + function renderTactics(s) { + return s.tactics + .map((t) => `${esc(t.name.replace(/Tactic$/, ""))}`) + .join(" "); + } + + function renderVerdict(s) { + const v = s.verdicts[0]; + if (!v) return pill("not evaluated", "", `pixi run evaluate ${s.name}`); + const detail = `decided in the ${v.decided_in} after ${v.rounds} round(s), n ${v.n}, p ${num(v.p, 3)}, ${v.date || v.run_id}`; + return `${pill(v.verdict, v.verdict, detail)} ${signed(v.mean)} ± ${num(v.se)} goals/match vs ${esc(v.reference)}`; + } + + // An SVG pitch in the maps' frame (metres, attacking right), with `inner` drawn under the lines. + function pitchSvg(p, inner) { + const L = p.half_length, W = p.half_width, gd = p.goal_depth, pad = 0.12; + const vb = `${-L - gd - pad} ${-W - pad} ${2 * (L + gd + pad)} ${2 * (W + pad)}`; + const line = 'fill="none" stroke="#a5b3a7" stroke-width="1" vector-effect="non-scaling-stroke"'; + const lines = + `` + + `` + + `` + + `` + + `` + + `` + + ``; + return ( + `` + + `` + + `${inner}${lines}` + ); + } + + function heatmap(m, grid, vmax) { + const L = m.pitch.half_length, W = m.pitch.half_width, b = m.bin_m; + let out = ""; + grid.share.forEach((row, i) => + row.forEach((v, j) => { + if (v > 0) { + const a = Math.min(1, v / vmax).toFixed(2); + out += ``; + } + }) + ); + for (const [x, y] of grid.means) out += ``; + return out; + } + + function shotMarks(shots) { + const mark = ([x, y, scored], colour) => + ``; + return (shots.faced || []).map((s) => mark(s, "#dc2626")).join("") + (shots.own || []).map((s) => mark(s, "#2563eb")).join(""); + } + + function renderMaps(s) { + if (!s.signals) return ""; + const m = maps[s.signals.run_id]; + let body; + if (!m || m.status === "computing") body = '
Drawing the maps from the replays… (about a minute, once per run)
'; + else if (m.status !== "ready") body = '
No maps: this round has no replays.
'; + else if (!m.strategies[s.name]) body = '
No replays of this strategy in this round.
'; + else { + const d = m.strategies[s.name]; + const fig = (title, svg) => `
${title}
${svg}
`; + body = + `
` + + fig("With the ball", pitchSvg(m.pitch, heatmap(m, d.attack, m.vmax.attack))) + + fig("Without the ball", pitchSvg(m.pitch, heatmap(m, d.defence, m.vmax.defence))) + + fig( + `Shots ● ours ● against, hollow missed`, + pitchSvg(m.pitch, shotMarks(d.shots)) + ) + + `
`; + } + return `

On the pitch attacking →, dots are each robot's average spot

${body}
`; + } + + function renderSignals(s) { + const sig = s.signals; + if (!sig) return ""; + const fmt = (r, x) => (x == null ? "—" : r.key.endsWith("_share") || r.key === "stalled" ? pct(x) : num(x, r.key === "pass_progress_m" ? 2 : 1)); + const rows = sig.rows + .filter((r) => r.value != null || r.field != null) + .map((r) => { + const max = Math.max(Math.abs(r.value || 0), Math.abs(r.field || 0)) * 1.15 || 1; + const at = (x) => (Math.abs(x || 0) / max) * 100; + const a = at(r.value), b = at(r.field); + const bar = + `
` + + (r.value != null && r.field != null ? `` : "") + + (r.field != null ? `
` : "") + + (r.value != null ? `
` : "") + + `
`; + return `${esc(r.label)}${bar}${fmt(r, r.value)}${fmt(r, r.field)}`; + }) + .join(""); + const title = `${sig.matches} matches in ${sig.run_id}. More is not always better: these explain how it plays (docs/signals.md).`; + return ( + `

How it plays per match

` + + `
thisothers${rows}
` + ); + } + + function renderMatches(s) { + if (!s.matches.length) return ""; + const newest = s.matches[0].run_id; // older runs played older code: not shown here + const cards = s.matches + .filter((m) => m.run_id === newest) + .map((m) => { + const [f, a] = m.score; + const res = f > a ? "win" : f < a ? "loss" : "draw"; + return ( + `
${esc(m.opponent)}` + + `${f}–${a}` + + `${m.stalled ? pill("stalled", "dropped") : ""}${replayButton(m.replay)}
` + ); + }) + .join(""); + return `

Matches ${esc(s.matches[0].date || "")}

${cards}
`; + } + + function renderStrategy(s) { + const old = s.old_names.length ? ` was ${s.old_names.map(esc).join(", ")}` : ""; + const role = s.role === "champion" ? pill("champion", "champion") : s.role === "core" ? pill("core", "core") : pill("reserve"); + return ` +
+
+

${esc(s.name)}

${role}${old}
+
${esc(s.summary)}
+
${renderTactics(s)}${renderVerdict(s)} + ${esc(s.file)}
+
+ ${s.signals || s.matches.length ? "" : `
No matches yet. Reserve strategies play in pixi run evaluate --all.
`} + ${renderMaps(s)} + ${renderSignals(s)} + ${renderMatches(s)} +
`; + } + + function renderStrategiesPage() { + if (!data) return '
Loading…
'; + if (!selected || !data.strategies.find((s) => s.name === selected)) selected = data.champion || data.strategies[0]?.name; + const s = data.strategies.find((x) => x.name === selected); + if (s) loadMaps(s); + return ` +
+
${renderList()}
+ ${s ? renderStrategy(s) : ""} +
`; + } + + // --- runs --------------------------------------------------------------------------------------- + + function renderVerdictCards(run) { + if (!run.report) return '
Did not finish.
'; + const cands = Object.entries(run.report.candidates || {}); + if (!cands.length) return '
No candidate: a health check only.
'; + return cands + .map(([name, r]) => { + const t = r[r.decided_in] || {}; + const h2h = r.vs_todays_champion; + const detail = `in the ${r.decided_in} after ${r.rounds} round(s), n ${t.n ?? "—"}, p ${num(t.p, 3)}`; + return ( + `
${esc(name)}${pill(r.verdict, r.verdict, detail)}
` + + `
${signed(t.mean)} ± ${num(t.se)} goals/match vs ${esc(run.reference)} at the last release` + + (h2h ? ` · vs today's ${esc(h2h.name)} ${signed(h2h.mean)} ± ${num(h2h.se)}` : "") + + `
` + ); + }) + .join(""); + } + + // Find the replay of the match named "
_vs_" (how stall incidents name matches). + function replayOfMatch(round, stem) { + const r = (round.results || []).find((x) => x.replay && x.replay.split("/").pop().startsWith(stem + ".")); + return r ? r.replay : null; + } + + function renderHealth(round) { + const parts = []; + const incidents = round.stall_incidents || []; + if (round.stall_incidents) { + const rows = incidents + .map( + (inc) => + `
${esc(inc.kind)} at ${inc.sim_time.toFixed(1)}s for ${inc.duration_s.toFixed(0)}s` + + inc.matches.map((m) => replayButton(replayOfMatch(round, m), inc.sim_time, "▶ " + m)).join("") + + `
` + ) + .join(""); + parts.push(`
Stalls ${incidents.length}${rows}
`); + } + const rs = round.restarts; + if (rs && rs.restarts) parts.push(`
Restarts ${pct(rs.reached_normal_start / rs.restarts)} went live
`); + if (round.fouls) { + const byRule = Object.entries(round.fouls) + .map(([rule, f]) => [rule, f.total]) + .sort((a, b) => b[1] - a[1]) + .map(([rule, n]) => `${n} ${rule.replace(/_/g, " ")}`) + .join(", "); + parts.push(`
Fouls ${byRule || "none"}
`); + } + if ((round.failed || []).length) parts.push(`
${round.failed.length} match(es) crashed
`); + return parts.join(""); + } + + function renderRoundMatches(round) { + const rows = (round.results || []) + .map( + (r) => + `${esc(r.display_a)} vs ${esc(r.display_b)}${r.score_a}–${r.score_b}` + + `${r.stalled ? pill("stalled", "dropped") : ""}${replayButton(r.replay)}` + ) + .join(""); + return `${rows}
`; + } + + function renderRun(run) { + const nMatches = run.rounds.reduce((n, s) => n + (s.results || []).length, 0); + const open = expandedRun[run.run_id]; + const header = + `
${open ? "▾" : "▸"}` + + `${esc(run.date || run.run_id)}${run.rounds.length} round(s), ${nMatches} matches
`; + if (!open) return `
${header}
`; + const rounds = run.rounds + .map((round) => { + const key = `${run.run_id}:${round.round ?? 1}`; + const o = expandedRound[key]; + return ( + `
${o ? "▾" : "▸"} Round ${round.round ?? 1}` + + `${round.seed != null ? ` · seed ${round.seed}` : ""} · ${(round.results || []).length} matches
` + + (o ? renderRoundMatches(round) : "") + ); + }) + .join(""); + return ` +
+ ${header} +
+ ${run.run_id.startsWith("eval_") ? `
${renderVerdictCards(run)}
` : ""} + ${run.rounds[0] ? renderHealth(run.rounds[0]) : ""} +
${rounds}
+
+
`; + } + + function renderRunsPage() { + if (!runs) return '
Loading…
'; + const current = runs.filter((r) => r.run_id.startsWith("eval_")); + const archive = runs.filter((r) => !r.run_id.startsWith("eval_")); + const empty = current.length ? "" : '
No runs yet: pixi run evaluate NAME
'; + const older = archive.length + ? `
${showArchive ? "▾" : "▸"} Older round robins (${archive.length}): older code, not comparable
` + + (showArchive ? archive.map(renderRun).join("") : "") + : ""; + return `
${empty}${current.map(renderRun).join("")}${older}
`; + } + + // --- shell -------------------------------------------------------------------------------------- + + function render() { + const root = document.getElementById("strategies-root"); + if (!root) return; + const tab = (p, label) => ``; + root.innerHTML = + `
${tab("strategies", "Strategies")}${tab("runs", "Evaluation runs")}
` + + (page === "strategies" ? renderStrategiesPage() : renderRunsPage()); + + for (const b of root.querySelectorAll(".subtab")) { + b.addEventListener("click", () => { + page = b.dataset.page; + if (page === "runs" && !runs) loadRuns(); + render(); + }); + } + for (const el of root.querySelectorAll(".strategy-item")) { + el.addEventListener("click", () => { + selected = el.dataset.name; + render(); + }); + } + for (const h of root.querySelectorAll(".archive-header")) { + h.addEventListener("click", () => { + showArchive = !showArchive; + render(); + }); + } + for (const h of root.querySelectorAll(".run-header")) { + h.addEventListener("click", () => { + expandedRun[h.dataset.runId] = !expandedRun[h.dataset.runId]; + render(); + }); + } + for (const h of root.querySelectorAll(".round-header")) { + h.addEventListener("click", () => { + expandedRound[h.dataset.key] = !expandedRound[h.dataset.key]; + render(); + }); + } + for (const btn of root.querySelectorAll(".view-replay-btn")) { + btn.addEventListener("click", (e) => { + e.stopPropagation(); + const at = btn.dataset.at != null ? Number(btn.dataset.at) : undefined; + Dashboard.showReplay(btn.dataset.path, at); + }); + } + } + + // The maps of the round a strategy's signals come from: asked once, polled while computing. + function loadMaps(s) { + const round = s.signals && s.signals.run_id; + const known = round && maps[round]; + if (!round || (known && (known.status !== "computing" || known.pending || known.retryAt > Date.now()))) return; + maps[round] = { status: "computing", pending: true }; + fetch("/strategies/maps?round=" + encodeURIComponent(round)) + .then((r) => r.json()) + .then((m) => { + const computing = m.status === "computing"; + maps[round] = computing ? { ...m, retryAt: Date.now() + 3000 } : m; + if (computing) setTimeout(() => page === "strategies" && render(), 3100); + render(); + }) + .catch((err) => { + maps[round] = { status: "failed" }; + console.error("maps fetch error:", err); + }); + } + + function load() { + fetch("/strategies") + .then((r) => r.json()) + .then((d) => { + data = d; + render(); + }) + .catch((err) => console.error("strategies fetch error:", err)); + if (page === "runs") loadRuns(); + } + + function loadRuns() { + fetch("/strategies/runs") + .then((r) => r.json()) + .then((d) => { + runs = d; + const first = runs.find((r) => r.run_id.startsWith("eval_")) || runs[0]; + if (first && !Object.keys(expandedRun).length) expandedRun[first.run_id] = true; + render(); + }) + .catch((err) => console.error("runs fetch error:", err)); + } + + Dashboard.registerView("strategies", { mount: render, onShow: load }); +})(); diff --git a/utama_core/dashboard/static/timeline.js b/utama_core/dashboard/static/timeline.js index 22cbd4fec..f1ba51d3f 100644 --- a/utama_core/dashboard/static/timeline.js +++ b/utama_core/dashboard/static/timeline.js @@ -1,9 +1,9 @@ // Match timeline: a window of the match as swimlanes, the dashboard's version of -// tools/match_timeline.py's figure, in the Replay tab around the viewed frame and in the +// tools/debug/match_timeline.py's figure, in the Replay tab around the viewed frame and in the // Live tab up to now. Top to bottom, on one time axis: // - the referee command band (live play, STOP, kickoff, free kick, penalty, placement, HALT); // - possession: whose ball it is, in the team's colour. In a replay, one span per situation -// (a restart going live or a side winning the ball, as goal_ledger counts them); live, +// (a restart going live or a side winning the ball, as goal_sources counts them); live, // the side with a robot on the ball; // - one lane per friendly robot: a span per tactic it was in (the Tactic class from the // intention log), a dark tick where it switched, and a light strip where it had the ball; @@ -17,19 +17,19 @@ (function () { const SLOTS = ["#2a78d6", "#eb6834", "#1baf7a", "#eda100", "#e87ba4", "#008300", "#6250d6"]; - const OTHER = "#5f636c"; // tactics beyond the seven slots - const TEAM = { yellow: "#e0a527", blue: "#3d7fd1" }; // field_canvas.js's robot colours + const OTHER = "#9ca3af"; // tactics beyond the seven slots + const TEAM = { yellow: "#eab308", blue: "#2563eb" }; // field_canvas.js's robot colours const REF_FILL = { - "live play": "#2b3a30", - STOP: "#5b5f68", - HALT: "#b8615a", - kickoff: "#3d5a80", - "free kick": "#7a5236", - penalty: "#6d4560", - placement: "#6e6436", - other: "#33373f", + "live play": "#d7eedd", + STOP: "#dde0e5", + HALT: "#f6c9c4", + kickoff: "#d3e3f8", + "free kick": "#f5dfc8", + penalty: "#ecd6ea", + placement: "#efe7c2", + other: "#e7e9ed", }; - const MARKER_FILL = { goal: "#e0c14f", foul: "#d08a4a", stall: "#b8615a", loss: "#8b909b" }; + const MARKER_FILL = { goal: "#ca8a04", foul: "#ea7a2e", stall: "#c53030", loss: "#9ca3af" }; const KEEPER = "goalkeeper"; // the label the Live view's tactic status gives the keeper const LIVE_KEEP_S = 300; const MAX_DIST_M = 3; @@ -372,7 +372,7 @@ const group = refGroup(state.command); extend(d.referee, group, (state.command || "").replace(/_/g, " ").toLowerCase()); - // possession as goal_ledger reads it: the side with a robot on the ball while the other + // possession as goal_sources reads it: the side with a robot on the ball while the other // has none keeps it until the other side touches it; nobody holds it outside live play const last = d.possession[d.possession.length - 1]; const ours = friendly.some((r) => r.has_ball); @@ -486,7 +486,7 @@ this._view = [t0, t1]; const w = cssW - GUTTER; const x = (t) => GUTTER + ((t - t0) / span) * w; - ctx.font = "10px ui-monospace, monospace"; + ctx.font = "10px system-ui, sans-serif"; ctx.textBaseline = "middle"; const band = (spans, y, h, fill, label) => { @@ -498,14 +498,14 @@ ctx.fillRect(a, y, Math.max(1, b - a - 1), h); const text = label && label(s); if (text && ctx.measureText(text).width + 6 < b - a) { - ctx.fillStyle = "#dfe2e8"; + ctx.fillStyle = "#1c2230"; ctx.fillText(text, a + 3, y + h / 2); } } }; const row = (kind, text, y, h, lane) => { this._rows.push({ kind, y0: y, y1: y + h, lane }); - ctx.fillStyle = "#8b909b"; + ctx.fillStyle = "#6b7280"; ctx.fillText(text, 2, y + h / 2); }; @@ -534,20 +534,20 @@ (s) => short(s.label) ); // a tick where the robot switched from one tactic to another - ctx.fillStyle = "#101114"; + ctx.fillStyle = "#ffffff"; let prev = null; for (const s of lane.tactics) { if (!s.label) continue; if (prev && prev !== s.label && s.t0 >= t0 && s.t0 <= t1) ctx.fillRect(x(s.t0) - 1, y, 2, LANE_H - 2); prev = s.label; } - band(lane.ball, y + LANE_H - 5, 3, () => "#f2f2f2"); + band(lane.ball, y + LANE_H - 5, 3, () => "#1c2230"); y += LANE_H; } y += GAP; row("dist", "ball m", y, DIST_H); - ctx.strokeStyle = "#33373f"; + ctx.strokeStyle = "#e5e7eb"; ctx.beginPath(); for (const m of [1, 2]) { const gy = y + DIST_H * (1 - m / MAX_DIST_M); @@ -582,10 +582,10 @@ row("events", "events", y, EVENT_H); for (const m of d.markers) { if (m.sim_time < t0 || m.sim_time > t1) continue; - ctx.fillStyle = MARKER_FILL[m.kind] || "#8b909b"; + ctx.fillStyle = MARKER_FILL[m.kind] || "#9ca3af"; ctx.fillRect(x(m.sim_time) - 1.5, y, 3, EVENT_H); } - ctx.strokeStyle = "#101114"; + ctx.strokeStyle = "#ffffff"; for (const s of d.shots) { if (s.t < t0 || s.t > t1) continue; ctx.fillStyle = d.team[s.side] || OTHER; @@ -598,7 +598,7 @@ // axis: a tick every 5 s or 10 s or 30 s, labelled as match time (m:ss) const step = span > 180 ? 30 : span > 60 ? 10 : 5; - ctx.fillStyle = "#8b909b"; + ctx.fillStyle = "#6b7280"; ctx.textAlign = "center"; for (let s = Math.ceil((t0 - d.origin) / step) * step; d.origin + s <= t1; s += step) { const px = x(d.origin + s); @@ -608,7 +608,7 @@ ctx.textAlign = "start"; const cx = x(ts); - ctx.fillStyle = "#dfe2e8"; + ctx.fillStyle = "#1c2230"; ctx.fillRect(cx - 0.5, 0, 1.5, y); } } diff --git a/utama_core/dashboard/static/tournament.js b/utama_core/dashboard/static/tournament.js deleted file mode 100644 index 05d22a6a6..000000000 --- a/utama_core/dashboard/static/tournament.js +++ /dev/null @@ -1,397 +0,0 @@ -// Tournament view: standings + per-match results, sortable/expandable. -// Successor concern to hand-reading round-robin log output — -// reads replays//summary.json via the tournament view's Python side. -// A round_robin.py summary also carries a per-strategy table, stall -// incidents, restart outcomes and fouls (docs/STRATEGY_DEVELOPMENT.md -// "Reading a tournament run"); those are shown when present. Each result's -// `replay` is the path of its replay file, or null (added server-side). -// `round_robin.py` writes `winner` as the literal string "draw" on -// a tie (never null), and `standings` only carries wins/draws per config — -// losses/GF/GA/win% are derived here from `results`, not shipped precomputed. - -(function () { - let runs = []; - let sortKey = { column: "wins", dir: -1 }; - let expandedMatch = {}; // "runIndex:matchIndex" -> bool - let expandedRun = {}; // run_id -> bool; only the newest run starts open - - function short(name) { - return name.replace(/^build_/, "").replace(/_kernel_strategy$/, ""); - } - - function pct(x) { - return Math.round((x || 0) * 1000) / 10 + "%"; - } - - // Derive losses/games/GF/GA/win% per config from `results`, since - // `standings` in summary.json only ever carries wins/draws. - function standingsRows(run) { - if (run.strategies) return sortRows(strategyRows(run)); - const base = {}; - for (const name of run.config_names || []) { - base[name] = { name, wins: 0, draws: 0, losses: 0, games: 0, gf: 0, ga: 0 }; - } - for (const r of run.results || []) { - const a = base[r.config_a] || (base[r.config_a] = { name: r.config_a, wins: 0, draws: 0, losses: 0, games: 0, gf: 0, ga: 0 }); - const b = base[r.config_b] || (base[r.config_b] = { name: r.config_b, wins: 0, draws: 0, losses: 0, games: 0, gf: 0, ga: 0 }); - a.games++; - b.games++; - a.gf += r.score_a; - a.ga += r.score_b; - b.gf += r.score_b; - b.ga += r.score_a; - if (r.winner === "draw") { - a.draws++; - b.draws++; - } else if (r.winner === r.config_a) { - a.wins++; - b.losses++; - } else if (r.winner === r.config_b) { - b.wins++; - a.losses++; - } - } - const rows = Object.values(base).map((s) => ({ - ...s, - gd: s.gf - s.ga, - winPct: s.games ? s.wins / s.games : 0, - })); - return sortRows(rows); - } - - function sortRows(rows) { - const { column, dir } = sortKey; - rows.sort((x, y) => ((x[column] ?? 0) - (y[column] ?? 0)) * dir); - return rows; - } - - // round_robin.py's per-strategy table (summary.json `strategies`). - function strategyRows(run) { - return Object.entries(run.strategies).map(([name, s]) => ({ - name, - wins: s.wins, - draws: s.draws, - losses: s.losses, - games: s.matches, - gf: s.goals_for, - ga: s.goals_against, - gd: s.goals_for - s.goals_against, - winPct: s.matches ? s.wins / s.matches : 0, - shots: s.shots, - passes: s.completed_passes, - entries: s.attacking_third_entries, - fouls: s.fouls, - realLosses: s.real_losses_as_a, - stalled: s.stalled, - })); - } - - function renderStandings(run, runIndex) { - const rows = standingsRows(run); - const arrow = (col) => (sortKey.column === col ? (sortKey.dir === -1 ? " ▼" : " ▲") : ""); - const cols = [ - ["wins", "W"], - ["draws", "D"], - ["losses", "L"], - ["games", "Games"], - ["gf", "GF"], - ["ga", "GA"], - ["gd", "GD"], - ["winPct", "Win%"], - ]; - if (run.strategies) { - cols.push( - ["shots", "Shots"], - ["passes", "Passes"], - ["entries", "Entries"], - ["fouls", "Fouls"], - ["realLosses", "Losses as A"], - ["stalled", "Stalled"] - ); - } - const cell = (r, col) => { - if (col === "gd") return `${r.gd > 0 ? "+" : ""}${r.gd}`; - if (col === "winPct") return pct(r.winPct); - return r[col] ?? "—"; - }; - const trs = rows - .map((r) => `${short(r.name)}` + cols.map(([col]) => `${cell(r, col)}`).join("") + ``) - .join(""); - const ths = cols - .map(([col, label]) => `${label}${arrow(col)}`) - .join(""); - return ` - - ${ths} - ${trs} -
Config
`; - } - - function replayButton(path, atTime, label) { - if (!path) return `no replay file`; - const at = atTime != null ? ` data-at="${atTime}"` : ""; - return ``; - } - - function teamAvg(perRobot, prefix) { - const vals = Object.entries(perRobot || {}) - .filter(([k]) => k.startsWith(prefix)) - .map(([, v]) => v); - if (!vals.length) return null; - return vals.reduce((a, b) => a + b, 0) / vals.length; - } - - function renderMatchDetail(r) { - const stats = r.stats || {}; - const rec = stats.rule_event_counts || {}; - const recParts = Object.entries(rec).map(([k, v]) => `${v} ${k.replace(/_/g, " ")}`); - const shots = stats.shots || {}; - const friendlyMotion = teamAvg(stats.robot_motion_pct, "friendly_"); - const enemyMotion = teamAvg(stats.robot_motion_pct, "enemy_"); - - return ` -
-
Rule events${recParts.length ? recParts.join(", ") : "none"}
-
Shots${shots.friendly ?? 0} - ${shots.enemy ?? 0}
-
Ball travel${stats.ball_travel_m != null ? stats.ball_travel_m.toFixed(1) + " m" : "—"}
-
Avg motion${friendlyMotion != null ? pct(friendlyMotion) : "—"} - ${enemyMotion != null ? pct(enemyMotion) : "—"}
-
${replayButton(r.replay)}
-
`; - } - - // Fixed, predictable ordering for the 4 side x kickoff cells within a - // pair's group — (a_is_right, a_kicks_off) in this order — rather than - // whatever order concurrent workers happened to finish in. - const CELL_ORDER = [ - [true, true], - [true, false], - [false, true], - [false, false], - ]; - - function cellLabel(r, pairA) { - // round_robin.py plays each pair once, config_a as yellow - if (r.a_is_right === undefined) return `${short(r.config_a)} (yellow) vs ${short(r.config_b)}`; - // r.config_a may be either physical config depending on which side of - // the 4-cell product ran; re-express relative to pairA (the group's - // canonical/alphabetically-first config) so labels read consistently - // within a group regardless of which config was "a" for this row. - const aIsPairA = r.config_a === pairA; - const isRight = aIsPairA ? r.a_is_right : !r.a_is_right; - const kicksOff = aIsPairA ? r.a_kicks_off : !r.a_kicks_off; - return `${short(pairA)} ${isRight ? "right" : "left"}, ${kicksOff ? short(pairA) : "opponent"} kicks off`; - } - - // Group flat `results` into one entry per unordered {config_a, config_b} - // pair, each holding up to 4 cell rows ordered by CELL_ORDER. Groups are - // ordered alphabetically by the pair's sorted names for a stable render - // independent of match-completion order. - function groupedMatches(run) { - const groups = {}; // "confA|confB" (sorted) -> { pairA, pairB, rows: [] } - (run.results || []).forEach((r, i) => { - const [pairA, pairB] = [r.config_a, r.config_b].sort(); - const key = pairA + "|" + pairB; - if (!groups[key]) groups[key] = { pairA, pairB, rows: [] }; - groups[key].rows.push({ r, resultIndex: i }); - }); - - return Object.keys(groups) - .sort() - .map((key) => { - const g = groups[key]; - g.rows.sort((x, y) => { - const cellOf = (row) => { - const aIsPairA = row.r.config_a === g.pairA; - const isRight = aIsPairA ? row.r.a_is_right : !row.r.a_is_right; - const kicksOff = aIsPairA ? row.r.a_kicks_off : !row.r.a_kicks_off; - return CELL_ORDER.findIndex(([r_, k_]) => r_ === isRight && k_ === kicksOff); - }; - return cellOf(x) - cellOf(y); - }); - return g; - }); - } - - function renderMatches(run, runIndex) { - const groups = groupedMatches(run); - const rows = groups - .map((g) => { - const groupHeader = - `` + - `${short(g.pairA)} vs ${short(g.pairB)}`; - const matchRows = g.rows - .map(({ r, resultIndex }) => { - const key = runIndex + ":" + resultIndex; - const isDraw = r.winner === "draw"; - const winnerLabel = isDraw ? "draw" : short(r.winner); - const poss = (r.stats || {}).possession_pct; - const possLabel = poss ? `${pct(poss.friendly)} - ${pct(poss.enemy)}` : "—"; - const expanded = !!expandedMatch[key]; - const detailRow = expanded - ? `${renderMatchDetail(r)}` - : ""; - return ( - `` + - `${cellLabel(r, g.pairA)}` + - `${r.score_a} - ${r.score_b}` + - `${winnerLabel}${((r.stats || {}).stall_events || []).length ? ' stalled' : ""}` + - `${possLabel}` + - `${expanded ? "▲" : "▼"}` + - `${detailRow}` - ); - }) - .join(""); - return groupHeader + matchRows; - }) - .join(""); - - return ` -
- - - - - ${rows} -
CellScoreWinnerPossession
-
`; - } - - // Find the replay of the match named "
_vs_" (how stall incidents name matches). - function replayOfMatch(run, stem) { - const r = (run.results || []).find((x) => x.replay && x.replay.split("/").pop().startsWith(stem + ".")); - return r ? r.replay : null; - } - - function renderDiagnostics(run) { - const parts = []; - const incidents = run.stall_incidents || []; - if (run.stall_incidents) { - const rows = incidents - .map( - (inc) => - `
stall${inc.kind} at ${inc.sim_time.toFixed(1)}s ` + - `for ${inc.duration_s.toFixed(0)}s` + - inc.matches.map((m) => replayButton(replayOfMatch(run, m), inc.sim_time, m)).join("") + - `
` - ) - .join(""); - parts.push( - `
Stalls: ${run.stalled_match_count ?? incidents.length} matches, ${incidents.length} incidents
` + - (rows || '
none
') - ); - } - const rs = run.restarts; - if (rs && rs.restarts) { - const kinds = Object.entries(rs.by_kind || {}) - .map(([kind, k]) => { - const bad = Object.entries(k.outcomes || {}) - .filter(([o]) => o !== "taken") - .map(([o, n]) => `${n} ${o.replace(/_/g, " ")}`) - .join(", "); - return `
${kind.replace(/_/g, " ").toLowerCase()}` + - `${k.reached_normal_start}/${k.n} reached NORMAL_START${bad ? " (" + bad + ")" : ""}
`; - }) - .join(""); - parts.push( - `
Restarts: ${rs.reached_normal_start}/${rs.restarts} reached NORMAL_START (${pct(rs.reached_normal_start / rs.restarts)})
` + - kinds - ); - } - if (run.fouls) { - const byRule = Object.entries(run.fouls) - .map(([rule, f]) => [rule, f.total]) - .sort((a, b) => b[1] - a[1]) - .map(([rule, n]) => `${n} ${rule.replace(/_/g, " ")}`) - .join(", "); - parts.push(`
Fouls
${byRule || "none"}
`); - } - return parts.length ? `
${parts.join("")}
` : ""; - } - - function renderRunHeader(run) { - const meta = run.run || {}; - const commit = meta.git_commit ? ` · ${meta.git_commit.slice(0, 8)}${meta.git_dirty ? " (dirty)" : ""}` : ""; - const argv = meta.argv && meta.argv.length ? ` · ${meta.argv.join(" ")}` : ""; - const open = expandedRun[run.run_id]; - return `
${open ? "▼" : "▶"} ${run.run_id} · ` + - `${(run.config_names || []).length} configs · ${(run.results || []).length} matches${commit}${argv}
`; - } - - function renderRun(run, index) { - if (!expandedRun[run.run_id]) return `
${renderRunHeader(run)}
`; - return ` -
- ${renderRunHeader(run)} -
${renderStandings(run, index)}
- ${renderDiagnostics(run)} -
Matches
- ${renderMatches(run, index)} -
`; - } - - function render() { - const container = document.getElementById("tournament-runs"); - if (!container) return; - if (!runs.length) { - container.innerHTML = '
No tournament runs found.
'; - return; - } - container.innerHTML = runs.map(renderRun).join(""); - - for (const th of container.querySelectorAll("th.sortable")) { - th.addEventListener("click", () => { - const col = th.dataset.col; - if (sortKey.column === col) { - sortKey.dir *= -1; - } else { - sortKey = { column: col, dir: -1 }; - } - render(); - }); - } - for (const header of container.querySelectorAll(".run-header")) { - header.addEventListener("click", () => { - const id = header.dataset.runId; - expandedRun[id] = !expandedRun[id]; - render(); - }); - } - for (const row of container.querySelectorAll("tr.match-row")) { - row.addEventListener("click", (e) => { - if (e.target.closest(".view-replay-btn")) return; - const key = row.dataset.key; - expandedMatch[key] = !expandedMatch[key]; - render(); - }); - } - for (const btn of container.querySelectorAll(".view-replay-btn")) { - btn.addEventListener("click", (e) => { - e.stopPropagation(); - const path = btn.dataset.path; - const at = btn.dataset.at != null ? Number(btn.dataset.at) : undefined; - Dashboard.showReplay(path, at); - }); - } - } - - function load() { - fetch("/tournament/runs") - .then((r) => r.json()) - .then((data) => { - runs = data; - if (runs.length && !Object.keys(expandedRun).length) expandedRun[runs[0].run_id] = true; - render(); - }) - .catch((err) => console.error("tournament fetch error:", err)); - } - - function mount() { - load(); - } - - function onShow() { - load(); - } - - Dashboard.registerView("tournament", { mount, onShow }); -})(); diff --git a/utama_core/dashboard/views/demo.py b/utama_core/dashboard/views/demo.py index bcd3e02eb..6403c3a23 100644 --- a/utama_core/dashboard/views/demo.py +++ b/utama_core/dashboard/views/demo.py @@ -11,7 +11,7 @@ - settings (`settings`: name -> the values it takes): sent with Run, they apply from the demo it starts (the script sets the examples' config block from them); - the field check (`checks`: real robots only): stops the demo as a switch does, the script runs - `tools/field_check.py`'s check with the radio free (each robot turns on the spot), its lines + `tools/field/field_check.py`'s check with the radio free (each robot turns on the spot), its lines shown under the panel, then starts the same demo again. """ diff --git a/utama_core/dashboard/views/referee.py b/utama_core/dashboard/views/referee.py index dfe746490..403670822 100644 --- a/utama_core/dashboard/views/referee.py +++ b/utama_core/dashboard/views/referee.py @@ -1,6 +1,6 @@ """Referee view — attaches `CustomReferee` state/commands to a `DashboardServer`. -This is the direct successor to `custom_referee/gui.py`'s `_RefereeGUIServer`: +This is the direct successor to `referee/gui.py`'s `_RefereeGUIServer`: same state shape pushed over SSE, same `/command` semantics, but registered as one channel/route pair on a shared server instead of owning a private HTTP server. `CustomReferee.step()` still calls `notify()` on every tick — @@ -18,8 +18,8 @@ from utama_core.entities.referee.referee_command import RefereeCommand if TYPE_CHECKING: - from utama_core.custom_referee import CustomReferee - from utama_core.custom_referee.profiles.profile_loader import RefereeProfile + from utama_core.referee import CustomReferee + from utama_core.referee.profiles.profile_loader import RefereeProfile CHANNEL = "referee" diff --git a/utama_core/dashboard/views/replay.py b/utama_core/dashboard/views/replay.py index d93deae45..ab6f8729c 100644 --- a/utama_core/dashboard/views/replay.py +++ b/utama_core/dashboard/views/replay.py @@ -31,7 +31,7 @@ replay frame by frame, several seconds; its result is kept beside the replay in `.timeline.json`, redone when the replay or `ANALYSIS_VERSION` changes. -`play` is the match told as its situations (`goal_ledger`: a restart going live +`play` is the match told as its situations (`goal_sources`: a restart going live or a side winning the ball), one row each with how it ended: a goal, a stoppage and its reason, or the other side winning the ball (with how we lost it). @@ -51,11 +51,10 @@ import numpy as np -from utama_core.analysis import goal_ledger +from utama_core.analysis import goal_sources from utama_core.analysis.turnover_breakdown import analyse_match, is_real from utama_core.config.field_params import STANDARD_FIELD_DIMS from utama_core.config.settings import REPLAY_BASE_PATH -from utama_core.custom_referee.geometry import RefereeGeometry from utama_core.dashboard.server import DashboardServer from utama_core.dashboard.views.referee import _serialise_ball, _serialise_robots from utama_core.engine.match_log import ( @@ -65,6 +64,7 @@ load_jsonl, ) from utama_core.entities.game.game_frame import GameFrame +from utama_core.referee.geometry import RefereeGeometry from utama_core.replay.columnar_reader import load_columnar_replay from utama_core.replay.replay_player import _load_replay @@ -293,10 +293,10 @@ def _play(replay_path: Path, referee_events: list, losses: list[dict], end_t: fl if replay_path.suffix != ".npz": return [] try: - match = goal_ledger.match_ledger(replay_path) + match = goal_sources.match_ledger(replay_path) except Exception: # noqa: BLE001 - optional, like the markers return [] - return play_rows(goal_ledger.situations(match), referee_events, losses, end_t) + return play_rows(goal_sources.situations(match), referee_events, losses, end_t) def play_rows(starts: list[dict], referee_events: list, losses: list[dict], end_t: float) -> list[dict]: diff --git a/utama_core/dashboard/views/strategies.py b/utama_core/dashboard/views/strategies.py new file mode 100644 index 000000000..bd9606fc2 --- /dev/null +++ b/utama_core/dashboard/views/strategies.py @@ -0,0 +1,413 @@ +"""Strategies view: every strategy in the catalog, with what it is and what we know about it, and +every evaluation run, verdicts first. Reads only what is already on disk; records nothing. + + GET /strategies {"champion", "core", "strategies": [...]} one entry per catalog strategy + GET /strategies/runs every run under `replays/`, newest first + GET /strategies/maps?round= the round's position and shot maps per strategy + +A strategy's entry: its description (the module docstring), file, role (champion / core / reserve, +`tools/evaluation/reference/players.json`), the tactics it imports, its verdicts (from each +`eval_*/report.json` it was a candidate in), how it plays (per-match signals in the newest round it +played, beside the average of the other strategies in that round) and its matches, each with its +replay. Names are shown as the catalog calls them today: a `.strategy` file (`name@commit.strategy`) +and a pre-rename name both show as the strategy's name, so frozen files never appear as strategies of +their own. Matches played under an older name or older code keep their date, which is how to tell. + +The maps are `tools/debug/pitch_maps.py --data`, run in the background the first time a round's maps +are asked for and kept beside its summary (`pitch_maps.json`); until then the answer is "computing". +""" + +from __future__ import annotations + +import ast +import json +import re +import subprocess +import sys +import threading +from pathlib import Path +from typing import Iterable, Optional + +from utama_core.config.settings import REPLAY_BASE_PATH +from utama_core.dashboard.server import DashboardServer +from utama_core.strategy import catalog + +REPO = Path(__file__).resolve().parents[3] +PLAYERS = REPO / "tools" / "evaluation" / "reference" / "players.json" +STRATEGY_DIR = REPO / "utama_core" / "strategy" +TACTICS_PACKAGE = "utama_core.tactics" + +# The signals shown per strategy, as (key, label, per): `per` is "match" (divide the round total by +# matches), "match_as_a" (real losses are measured on config_a's side only) or None (already a rate). +SIGNALS = [ + ("goals_for", "goals scored", "match"), + ("goals_against", "goals conceded", "match"), + ("shots", "shots", "match"), + ("attacking_third_entries", "attacking-third entries", "match"), + ("completed_passes", "completed passes", "match"), + ("forward_pass_share", "forward pass share", None), + ("pass_progress_m", "metres gained per pass", None), + ("real_losses_as_a", "real ball losses", "match_as_a"), + ("fouls", "fouls", "match"), + ("stalled", "stalled matches (share)", "match"), +] + + +def attach(server: DashboardServer) -> None: + server.add_route("/strategies", lambda: json.dumps(load_strategies()).encode()) + server.add_route("/strategies/runs", lambda: json.dumps(load_runs()).encode()) + server.add_route("/strategies/maps", lambda q=None: json.dumps(maps_of((q or {}).get("round", ""))).encode()) + + +# --- names ------------------------------------------------------------------------------------ + + +def is_frozen(config: str) -> bool: + """A player from a `.strategy` file: recorded as its path or as `name@commit`.""" + return config.endswith(".strategy") or "@" in config + + +def display_name(config: str) -> str: + """`config` as the catalog calls it today: `replays/eval/frozen/pendulum@ab12.strategy`, + `split_shape@ab12` and `build_split_shape_kernel_strategy` all become a plain catalog name.""" + if is_frozen(config): + config = Path(config).name.removesuffix(".strategy").split("@")[0] + return catalog.current_name(config) + + +def _label(config: str) -> str: + """How a player is shown in a match: its catalog name, marked when it is the last release's file.""" + return display_name(config) + (" (last release)" if is_frozen(config) else "") + + +def _newest_first(run_id: str) -> tuple: + """A sort key: by the run's date and time (`eval_` and `tournament_` alike), then its id.""" + m = re.search(r"\d{8}_\d{6}", run_id) + return (m[0] if m else "", run_id) + + +def run_date(run_id: str) -> Optional[str]: + m = re.search(r"(\d{4})(\d{2})(\d{2})", run_id) + return f"{m[1]}-{m[2]}-{m[3]}" if m else None + + +# --- reading the disk ------------------------------------------------------------------------- + + +def _read_json(path: Path) -> Optional[dict]: + try: + return json.loads(path.read_text()) + except (OSError, json.JSONDecodeError): + return None + + +def _summary_paths(base: Path) -> list[Path]: + # older round robins: /summary.json; evaluate.py: eval_/round_/summary.json + return [*base.glob("*/summary.json"), *base.glob("eval_*/round_*/summary.json")] + + +def _summaries(base: Path) -> list[tuple[Path, dict]]: + out = [] + for path in _summary_paths(base): + summary = _read_json(path) + if summary is not None: + for result in summary.get("results", []): + result["replay"] = _replay_path(base, path.parent, result) + out.append((path, summary)) + out.sort(key=lambda ps: _newest_first(ps[1].get("run_id", "")), reverse=True) + return out + + +def _file_name(config: str) -> str: + """A player's name in replay file names, as `tools/evaluation/match._short_name` writes it: a + `.strategy` file by its file name (`split_shape@cffe3a28`), anything else by its plain name.""" + return Path(config).stem if config.endswith(".strategy") else catalog.plain_name(config) + + +def _replay_path(base: Path, run_dir: Path, result: dict) -> Optional[str]: + """The result's replay, relative to `base`: `evaluate.py` writes `
_vs_.npz`. Older runs + (the retired `ladder.py`, `full_match_tournament.py`) wrote side and kickoff tags, + `_vs__` (as `.pkl` for the latter).""" + stem = f"{_file_name(result['config_a'])}_vs_{_file_name(result['config_b'])}" + names = [f"{stem}.npz", f"{stem}.pkl"] + if "a_is_right" in result: + names.insert(0, f"{stem}_{'R' if result['a_is_right'] else 'L'}{'K' if result.get('a_kicks_off') else 'k'}.pkl") + for name in names: + if (run_dir / name).exists(): + return str((run_dir / name).relative_to(base)) + return None + + +def _reports(base: Path) -> list[dict]: + reports = [r for p in base.glob("eval_*/report.json") if (r := _read_json(p)) is not None] + return sorted(reports, key=lambda r: r.get("run_id", ""), reverse=True) + + +# --- one strategy ----------------------------------------------------------------------------- + + +def _docstring(path: Path) -> str: + try: + return ast.get_docstring(ast.parse(path.read_text())) or "" + except (OSError, SyntaxError): + return "" + + +def _first_line(text: str) -> str: + return text.strip().split("\n\n")[0].replace("\n", " ") if text else "" + + +# a strategy docstring opens "`name` (until `old`): what it does. The pickers only it uses are +# here."; the page already shows the name and old names +_NAME_PREFIX = re.compile(r"^`[^`]+`(\s*\(until [^)]*\))?:\s*") +_BOILERPLATE = re.compile(r"\s*[^.]*\bpickers only it uses\b[^.]*\.?") + + +def summary_of(doc: str) -> str: + """What the strategy does, in one line, without its name or the docstring's boilerplate.""" + line = _BOILERPLATE.sub("", _NAME_PREFIX.sub("", _first_line(doc))).strip() + if not line.startswith("`"): # a strategy's name stays lower case + line = line[:1].upper() + line[1:] + return line.replace("`", "") + + +def tactics_of(path: Path) -> list[dict]: + """The tactics a strategy file imports from `utama_core.tactics`, each with its module's first + docstring paragraph. Read from source: importing would run the module.""" + try: + tree = ast.parse(path.read_text()) + except (OSError, SyntaxError): + return [] + found: dict[str, dict] = {} + for node in ast.walk(tree): + if isinstance(node, ast.ImportFrom) and node.module and node.module.startswith(TACTICS_PACKAGE): + module = REPO / Path(*node.module.split(".")) + file = module.with_suffix(".py") if module.with_suffix(".py").exists() else module / "__init__.py" + for alias in node.names: + if alias.name[:1].isupper() and alias.name not in found: + found[alias.name] = { + "name": alias.name, + "file": str(file.relative_to(REPO)), + "description": _first_line(_docstring(file)), + } + return list(found.values()) + + +def _stalled(result: dict) -> bool: + return bool((result.get("stats") or {}).get("stall_events") or result.get("possession_backstop")) + + +def _matches_of(name: str, summaries: Iterable[tuple[Path, dict]]) -> list[dict]: + out = [] + for _, summary in summaries: + run_id = summary.get("run_id", "") + for r in summary.get("results", []): + if r.get("reused"): # listed under the run that played it + continue + sides = ( + (r["config_a"], r["config_b"], r["score_a"], r["score_b"]), + (r["config_b"], r["config_a"], r["score_b"], r["score_a"]), + ) + # today's strategy only (not the last release's file of it), and never against itself + mine = [ + side + for side in sides + if display_name(side[0]) == name and not is_frozen(side[0]) and _label(side[1]) != name + ] + if not mine: + continue + _, them, score_me, score_them = mine[0] + out.append( + { + "opponent": _label(them), + "score": [score_me, score_them], + "seed": r.get("seed"), + "run_id": run_id, + "date": run_date(run_id), + "stalled": _stalled(r), + "replay": r.get("replay"), + } + ) + return out + + +def _rate(row: dict, key: str, per: Optional[str]) -> Optional[float]: + value = row.get(key) + if value is None: + return None + if per == "match": + n = row.get("matches") or 0 + elif per == "match_as_a": + n = row.get("matches_as_a") or 0 + else: + return float(value) + return value / n if n else None + + +MIN_SIGNAL_MATCHES = 3 # fewer is an exhibition match, not a round: its averages say little + + +def signals_of(name: str, summaries: Iterable[tuple[Path, dict]]) -> Optional[dict]: + """Per-match signals in the newest round with a strategy table that `name` played at least + `MIN_SIGNAL_MATCHES` in (else the newest it played in at all), beside the mean of the other + strategies there. A comparison with the field, not a ranking.""" + # a frozen file is not one of today's strategies: left out of both sides of the comparison + tables = [ + (summary, {display_name(k): v for k, v in (summary.get("strategies") or {}).items() if not is_frozen(k)}) + for _, summary in summaries + ] + tables = [(summary, t) for summary, t in tables if name in t] + full = [(summary, t) for summary, t in tables if (t[name].get("matches") or 0) >= MIN_SIGNAL_MATCHES] + for summary, table in (full or tables)[:1]: + others = [row for n, row in table.items() if n != name] + rows = [] + for key, label, per in SIGNALS: + value = _rate(table[name], key, per) + field = [v for row in others if (v := _rate(row, key, per)) is not None] + rows.append( + { + "key": key, + "label": label, + "value": value, + "field": sum(field) / len(field) if field else None, + } + ) + run_id = summary.get("run_id", "") + return { + "run_id": run_id, + "date": run_date(run_id), + "matches": table[name].get("matches"), + "rows": rows, + } + return None + + +def _verdicts_of(name: str, reports: Iterable[dict]) -> list[dict]: + out = [] + for report in reports: + for candidate, r in (report.get("candidates") or {}).items(): + if display_name(candidate) != name or "verdict" not in r: + continue + decided = r.get(r.get("decided_in", ""), {}) + out.append( + { + "run_id": report.get("run_id"), + "date": run_date(report.get("run_id", "")), + "verdict": r["verdict"], + "decided_in": r.get("decided_in"), + "rounds": r.get("rounds"), + "mean": decided.get("mean"), + "se": decided.get("se"), + "p": decided.get("p"), + "n": decided.get("n"), + "reference": display_name(report.get("reference", "")), + } + ) + return out + + +def load_strategies(base: Optional[Path] = None) -> dict: + base = Path(base or REPLAY_BASE_PATH) + players = _read_json(PLAYERS) or {} + champion, core = players.get("champion"), players.get("core", []) + summaries = _summaries(base) if base.exists() else [] + reports = _reports(base) if base.exists() else [] + strategies = [] + for name in catalog.player_names(): + path = STRATEGY_DIR / f"{name}.py" + doc = _docstring(path) + strategies.append( + { + "name": name, + "role": "champion" if name == champion else "core" if name in core else "reserve", + "summary": summary_of(doc), + "description": doc, + "file": str(path.relative_to(REPO)), + "old_names": sorted(old for old, new in catalog.RENAMED.items() if new == name), + "tactics": tactics_of(path), + "verdicts": _verdicts_of(name, reports), + "signals": signals_of(name, summaries), + "matches": _matches_of(name, summaries), + } + ) + return {"champion": champion, "core": core, "strategies": strategies} + + +# --- runs ------------------------------------------------------------------------------------- + + +def load_runs(base: Optional[Path] = None) -> list[dict]: + """Every run, newest first: an `evaluate.py` run is its report (if it finished) and its rounds; + an older round robin is one round. Names in results stay as recorded, with `display_a`/`display_b` + the catalog names; each result's `stats` is replaced by `stalled`.""" + base = Path(base or REPLAY_BASE_PATH) + if not base.exists(): + return [] + runs: dict[str, dict] = {} + for path, summary in _summaries(base): + for r in summary.get("results", []): + r["display_a"], r["display_b"] = _label(r["config_a"]), _label(r["config_b"]) + # the page needs only whether it stalled; the full stats are ~95% of the payload + r["stalled"] = _stalled(r) + r.pop("stats", None) + run_dir = path.parent.parent if path.parent.name.startswith("round_") else path.parent + run = runs.setdefault( + run_dir.name, {"run_id": run_dir.name, "date": run_date(run_dir.name), "report": None, "rounds": []} + ) + run["rounds"].append(summary) + for report in _reports(base): + run = runs.get(report.get("run_id")) + if run is None: + continue + run["reference"] = display_name(report.get("reference", "")) + run["report"] = { + "run": report.get("run"), + "rule": report.get("rule"), + "failed": report.get("failed", []), + "candidates": { + display_name(c): {k: v for k, v in r.items() if k != "stalls"} + for c, r in (report.get("candidates") or {}).items() + }, + } + for run in runs.values(): + run["rounds"].sort(key=lambda s: s.get("round", 0)) + return sorted(runs.values(), key=lambda r: _newest_first(r["run_id"]), reverse=True) + + +# --- maps ------------------------------------------------------------------------------------- + +MAPS_FILE = "pitch_maps.json" +PITCH_MAPS = REPO / "tools" / "debug" / "pitch_maps.py" +_jobs: dict[Path, subprocess.Popen] = {} +_jobs_lock = threading.Lock() + + +def maps_of(round_id: str, base: Optional[Path] = None, start=subprocess.Popen) -> dict: + """A round's maps by catalog name (frozen files left out), or its status: "computing" while + `pitch_maps.py` runs, "failed" if it ended without writing them (asking again retries), "missing" + for no such round. `start` runs the command (a test passes a fake).""" + base = Path(base or REPLAY_BASE_PATH).resolve() + round_dir = (base / round_id).resolve() + if base not in round_dir.parents or not (round_dir / "summary.json").exists(): + return {"status": "missing"} + data = _read_json(round_dir / MAPS_FILE) + if data is not None: + strategies = {display_name(k): v for k, v in data.pop("strategies", {}).items() if not is_frozen(k)} + return {"status": "ready", **data, "strategies": strategies} + with _jobs_lock: + job = _jobs.get(round_dir) + if job is not None and job.poll() is not None: + del _jobs[round_dir] + return {"status": "failed"} + if job is None: + cmd = [ + sys.executable, + str(PITCH_MAPS), + str(round_dir), + "--data", + str(round_dir / MAPS_FILE), + "--workers", + "4", + ] + _jobs[round_dir] = start(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + return {"status": "computing"} diff --git a/utama_core/dashboard/views/tournament.py b/utama_core/dashboard/views/tournament.py deleted file mode 100644 index 70882e2b7..000000000 --- a/utama_core/dashboard/views/tournament.py +++ /dev/null @@ -1,64 +0,0 @@ -"""Tournament view — reads `replays//summary.json` written by -`round_robin.py` and exposes it to the dashboard. - -Fully standalone: no coupling to a running match or `StrategyRunner`. Just a -`GET /tournament/runs` route returning every run's full summary inline -(newest first), since the run count is small and this avoids needing a -second dynamic-path route on `DashboardServer`. Each result gains `replay`: -its replay's path under `REPLAY_BASE_PATH`, or None when there is no file, so -the page links only to replays that exist. -""" - -from __future__ import annotations - -import json -from pathlib import Path -from typing import List, Optional - -from utama_core.config.settings import REPLAY_BASE_PATH -from utama_core.dashboard.server import DashboardServer - - -def attach(server: DashboardServer) -> None: - server.add_route("/tournament/runs", _runs_bytes) - - -def _runs_bytes() -> bytes: - return json.dumps(_load_runs()).encode() - - -def _load_runs() -> List[dict]: - if not REPLAY_BASE_PATH.exists(): - return [] - - summaries = [] - for summary_path in REPLAY_BASE_PATH.glob("*/summary.json"): - try: - with open(summary_path) as f: - summary = json.load(f) - except (json.JSONDecodeError, OSError): - continue - for result in summary.get("results", []): - result["replay"] = _replay_path(summary_path.parent, result) - summaries.append(summary) - - summaries.sort(key=lambda s: s.get("run_id", ""), reverse=True) - return summaries - - -def _short(config: str) -> str: - return config.removeprefix("build_").removesuffix("_kernel_strategy") - - -def _replay_path(run_dir: Path, result: dict) -> Optional[str]: - """The result's replay, relative to `REPLAY_BASE_PATH`: `round_robin.py` writes - `_vs_.npz`. Older runs (the retired `ladder.py`, `full_match_tournament.py`) wrote - side and kickoff tags, `_vs__` (as `.pkl` for the latter).""" - stem = f"{_short(result['config_a'])}_vs_{_short(result['config_b'])}" - names = [f"{stem}.npz", f"{stem}.pkl"] - if "a_is_right" in result: - names.insert(0, f"{stem}_{'R' if result['a_is_right'] else 'L'}{'K' if result.get('a_kicks_off') else 'k'}.pkl") - for name in names: - if (run_dir / name).exists(): - return str((run_dir / name).relative_to(REPLAY_BASE_PATH)) - return None diff --git a/utama_core/data_processing/receivers/referee_receiver.py b/utama_core/data_processing/receivers/referee_receiver.py index 5783187d2..ba729e822 100644 --- a/utama_core/data_processing/receivers/referee_receiver.py +++ b/utama_core/data_processing/receivers/referee_receiver.py @@ -7,10 +7,8 @@ from utama_core.entities.game.team_info import TeamInfo from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.entities.referee.stage import Stage -from utama_core.team_controller.src.generated_code.ssl_gc_referee_message_pb2 import ( - Referee, -) -from utama_core.team_controller.src.utils import network_manager +from utama_core.team_controller.generated_code.ssl_gc_referee_message_pb2 import Referee +from utama_core.team_controller.utils import network_manager logger = logging.getLogger(__name__) diff --git a/utama_core/data_processing/receivers/vision_receiver.py b/utama_core/data_processing/receivers/vision_receiver.py index 7d6cc84b6..90d8bda2e 100644 --- a/utama_core/data_processing/receivers/vision_receiver.py +++ b/utama_core/data_processing/receivers/vision_receiver.py @@ -4,10 +4,10 @@ from utama_core.config.settings import MULTICAST_GROUP, VISION_PORT from utama_core.entities.data.raw_vision import RawBallData, RawRobotData, RawVisionData -from utama_core.team_controller.src.generated_code.ssl_vision_wrapper_pb2 import ( +from utama_core.team_controller.generated_code.ssl_vision_wrapper_pb2 import ( SSL_WrapperPacket, ) -from utama_core.team_controller.src.utils import network_manager +from utama_core.team_controller.utils import network_manager logger = logging.getLogger(__name__) diff --git a/utama_core/data_processing/refiners/filters/kalman.py b/utama_core/data_processing/refiners/filters/kalman.py index 431cdda8e..6b9c266f2 100644 --- a/utama_core/data_processing/refiners/filters/kalman.py +++ b/utama_core/data_processing/refiners/filters/kalman.py @@ -7,7 +7,7 @@ from utama_core.entities.data.vector import Vector3D from utama_core.entities.data.vision import VisionRobotData from utama_core.entities.game import Ball, Robot -from utama_core.global_utils.math_utils import deg_to_rad, normalise_heading +from utama_core.geometry.math_utils import deg_to_rad, normalise_heading # An unseen robot is carried on its velocity this long, then held where it is: one seen a few # times a second on the 2026-10-27 field test, carried on, ran off to 10^7 m at 7 m/s. diff --git a/utama_core/data_processing/refiners/position.py b/utama_core/data_processing/refiners/position.py index 164c2a51b..e4c8a6d52 100644 --- a/utama_core/data_processing/refiners/position.py +++ b/utama_core/data_processing/refiners/position.py @@ -24,7 +24,7 @@ from utama_core.entities.data.vector import Vector2D, Vector3D from utama_core.entities.data.vision import VisionBallData, VisionData, VisionRobotData from utama_core.entities.game import Ball, FieldBounds, GameFrame, Robot -from utama_core.global_utils.mapping_utils import map_friendly_enemy_to_colors +from utama_core.entities.game.mapping_utils import map_friendly_enemy_to_colors def _in_field_or_goal(x: float, y: float, dimensions: FieldDimensions) -> bool: diff --git a/utama_core/engine/abstract_strategy.py b/utama_core/engine/abstract_strategy.py index 27c961a64..ce0b20d97 100644 --- a/utama_core/engine/abstract_strategy.py +++ b/utama_core/engine/abstract_strategy.py @@ -26,17 +26,14 @@ from utama_core.entities.game import Game from utama_core.entities.game.field import FieldBounds from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.global_utils.math_utils import ( - assert_contains, - assert_valid_bounding_box, -) -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.rsoccer_simulator.src.ssl.ssl_gym_base import SSLBaseEnv -from utama_core.skills.src.utils.move_utils import empty_command -from utama_core.team_controller.src.controllers.common.robot_controller_abstract import ( +from utama_core.geometry.math_utils import assert_contains, assert_valid_bounding_box +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.simulator.ssl.ssl_gym_base import SSLBaseEnv +from utama_core.skills.utils.move_utils import empty_command +from utama_core.team_controller.controllers.common.robot_controller_abstract import ( AbstractRobotController, ) -from utama_core.team_controller.src.controllers.real.kicker_charge import KickerCharge +from utama_core.team_controller.controllers.real.kicker_charge import KickerCharge @dataclass(slots=True, frozen=True) @@ -57,8 +54,8 @@ class AbstractStrategy: """Kernel-tactic strategy base class, driven by `StrategyRunner`. Args: - build_kernel_strategy: called once, from `load_motion_controller`, as - `build_kernel_strategy(motion_controller) -> Strategy`. + build: called once, from `load_motion_controller`, as + `build(motion_controller) -> Strategy`. Deferred to a factory (rather than passed pre-built) only because `AbstractStrategy.__init__` itself runs before `StrategyRunner` has injected anything — `Strategy.__init__` never reads `game`, only @@ -82,10 +79,10 @@ class AbstractStrategy: the kernel `Strategy` in `load_motion_controller` (see `Strategy.referee_overrides`'s setter docstring for why this is a post-construction assignment rather than a constructor kwarg on - `build_kernel_strategy` itself). + `build` itself). control_scheme: optional name of the preferred motion control scheme to use (e.g. 'trajsample', 'fpp', 'dwa', 'pid'). If omitted, defaults to - class attribute `control_scheme` or `build_kernel_strategy.control_scheme`, + class attribute `control_scheme` or `build.control_scheme`, falling back to StrategyRunner's default ("fpp"). """ @@ -93,21 +90,21 @@ class attribute `control_scheme` or `build_kernel_strategy.control_scheme`, def __init__( self, - build_kernel_strategy, + build, goalkeeper_id: int = 0, exp_ball: bool = True, referee_overrides: Optional[dict[RefereeCommand, RefereeActionOverride]] = None, control_scheme: Optional[str] = None, ): self.exp_ball = exp_ball - self._build_kernel_strategy = build_kernel_strategy + self._build = build self._kernel_strategy: Optional[KernelSchedulerStrategy] = None self._goalkeeper_id = goalkeeper_id self._referee_overrides = referee_overrides self.control_scheme = ( control_scheme if control_scheme is not None - else getattr(self, "control_scheme", None) or getattr(build_kernel_strategy, "control_scheme", None) + else getattr(self, "control_scheme", None) or getattr(build, "control_scheme", None) ) ### These attributes are set by the StrategyRunner before the strategy is run. ### @@ -178,7 +175,7 @@ def load_motion_controller(self, motion_controller: MotionController): kernel `Strategy` (see class docstring for why this, not `load_game`, is the right timing).""" self.motion_controller = motion_controller - self._kernel_strategy = self._build_kernel_strategy(motion_controller) + self._kernel_strategy = self._build(motion_controller) if self._referee_overrides: self._kernel_strategy.referee_overrides = self._referee_overrides self._kernel_strategy.set_goalkeeper(self._goalkeeper_id) diff --git a/utama_core/engine/ball_release.py b/utama_core/engine/ball_release.py new file mode 100644 index 000000000..6cc36b2d9 --- /dev/null +++ b/utama_core/engine/ball_release.py @@ -0,0 +1,133 @@ +"""Aim and force a kick when holding the ball on any longer would cost it. + +Tactics decide when to shoot or pass; this is the backstop behind all of them, run on the commands +they return. A robot that finds no shot keeps sliding for one with the ball on its dribbler, with +nothing to end that. In the 2026-11-09 round-robin that gave 387 solo excessive-dribbling fouls, +and with an enemy on the same ball a jam of 90 s per match, 230 s at worst, the ball creeping just +enough for the no-progress rule never to fire. Kept here and not in tactics' memory so a hand-over +between tactics in the middle of a carry does not restart the count, as the referee's does not. +""" + +from __future__ import annotations + +import math +from typing import TYPE_CHECKING, Optional + +from utama_core.entities.data.command import RobotCommand +from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.geometry.pass_and_score_geometry import ( + ANNOUNCE_PASS_RAD, + RELEASE_LANE_CLEARANCE, + open_teammate, + oriented_towards, + reaches_own_goal, + release_heading, +) +from utama_core.skills.utils.move_utils import turn_on_spot + +if TYPE_CHECKING: + from utama_core.engine.context import TickContext + from utama_core.entities.game import Game + +# Past tactics' own CARRY_LIMIT_M (0.8): their carries are not cut short, this catches the rest. +CARRY_RELEASE_M = 0.96 +# Aim from here: a carry of 0.8 turning to shoot has stopped, and is left to its tactic. +CARRY_AIM_M = 0.85 +# Ball travel before a kick sent now leaves the robot: the command delay and a tick. +_RELEASE_LAG_S = 0.12 +_CARRY_BRAKING_MPS2 = 4.0 +PINNED_RELEASE_S = 1.5 +# With a teammate to kick to there is nothing to wait for: an enemy on the ball only gets stronger. +PINNED_WITH_LANE_S = 0.3 +# Stood on the ball this long with it not moving. Whatever a tactic is waiting for, this is what the +# stalls of the 2026-11-09 round-robin looked like: nothing else on the pitch moves it. +HELD_STILL_S = 2.0 +_HELD_STILL_M = 0.05 +# Kicked blind along the heading, 82% of pinned releases and 41% of carry ones went out of play +# (12 matches, 2026-11-09). A turn gets most of that back, without letting a release wait. +AIM_LIMIT_S = 0.6 +_AIM_TOLERANCE_RAD = 0.15 +CONTACT_M = 0.13 # robot centre to ball with both touching: 0.09 + 0.0215 and some slack +_LIVE_COMMANDS = frozenset({RefereeCommand.NORMAL_START, RefereeCommand.FORCE_START}) +_KICK = RobotCommand(local_forward_vel=0, local_left_vel=0, angular_vel=0, kick=1, chip=0, dribble=0) + + +class BallRelease: + def __init__(self) -> None: + self._carry_origin: dict[int, tuple[float, float]] = {} + self._pinned_since: dict[int, float] = {} + self._aiming_since: dict[int, float] = {} + self._still_at: dict[int, tuple[tuple[float, float], float]] = {} + + def reset(self) -> None: + self._still_at.clear() + self._carry_origin.clear() + self._pinned_since.clear() + self._aiming_since.clear() + + def apply(self, game: "Game", ctx: "TickContext", commands: dict[int, RobotCommand]) -> dict[int, RobotCommand]: + """`commands` with a kick for any robot that must release the ball now. Live play only.""" + referee = getattr(game, "referee", None) + ball = getattr(game, "ball", None) + if ball is None or referee is None or referee.referee_command not in _LIVE_COMMANDS: + self.reset() + return commands + + here = (ball.p.x, ball.p.y) + enemy_on_ball = any(math.dist((e.p.x, e.p.y), here) <= CONTACT_M for e in game.enemy_robots.values()) + for robot_id, robot in game.friendly_robots.items(): + if enemy_on_ball and math.dist((robot.p.x, robot.p.y), here) <= CONTACT_M: + self._pinned_since.setdefault(robot_id, game.ts) + else: + self._pinned_since.pop(robot_id, None) + if not robot.has_ball: + self._carry_origin.pop(robot_id, None) + self._aiming_since.pop(robot_id, None) + self._still_at.pop(robot_id, None) + continue + origin = self._carry_origin.setdefault(robot_id, here) + spot, still_since = self._still_at.setdefault(robot_id, (here, game.ts)) + if math.dist(here, spot) >= _HELD_STILL_M: + self._still_at[robot_id], still_since = (here, game.ts), game.ts + + command: Optional[RobotCommand] = commands.get(robot_id) + if command is None or command.kick or command.chip: + continue + carried = math.dist(here, origin) + speed = math.hypot(ball.v.x, ball.v.y) + pinned_since = self._pinned_since.get(robot_id) + teammate = open_teammate(game, robot_id, RELEASE_LANE_CLEARANCE) + if carried + speed * _RELEASE_LAG_S >= CARRY_RELEASE_M: + if not reaches_own_goal(game, robot.p, robot.orientation): + ctx.trace(game, f"release[{robot_id}]", "carry limit") + commands[robot_id] = _KICK + continue + if carried + speed * _RELEASE_LAG_S + speed**2 / (2.0 * _CARRY_BRAKING_MPS2) >= CARRY_AIM_M: + reason = "carry limit" + elif pinned_since is not None and game.ts - pinned_since >= PINNED_RELEASE_S: + reason = "pinned" + elif pinned_since is not None and game.ts - pinned_since >= PINNED_WITH_LANE_S and teammate is not None: + reason = "pinned, teammate open" + elif game.ts - still_since >= HELD_STILL_S: + reason = "held still" + else: + self._aiming_since.pop(robot_id, None) + continue + aiming_for = game.ts - self._aiming_since.setdefault(robot_id, game.ts) + heading = release_heading(game, robot_id) + if teammate is not None and oriented_towards(game, robot_id, heading, ANNOUNCE_PASS_RAD): + ctx.expected_receivers.add(teammate) + aimed = oriented_towards(game, robot_id, heading, _AIM_TOLERANCE_RAD) + if (aimed or aiming_for >= AIM_LIMIT_S) and not reaches_own_goal(game, robot.p, robot.orientation): + ctx.trace(game, f"release[{robot_id}]", reason) + commands[robot_id] = _KICK + else: + ctx.trace(game, f"release[{robot_id}]", f"aiming · {reason}") + commands[robot_id] = turn_on_spot( + game=game, + motion_controller=ctx.motion_controller, + robot_id=robot_id, + target_oren=heading, + dribbling=True, + ) + return commands diff --git a/utama_core/engine/ball_roles.py b/utama_core/engine/ball_roles.py new file mode 100644 index 000000000..27eb0ee0d --- /dev/null +++ b/utama_core/engine/ball_roles.py @@ -0,0 +1,165 @@ +"""Who on the team deals with the ball this tick, whichever tactics each robot is in. + +Tactics each decide for their own robots, so two of them (an attack slot and a press slot, say) +send one robot each at the same ball. In the 2026-11-09 round-robin a side with a robot on the ball +had a teammate within 0.6 m of it 46% of the time. Run on the commands every tactic returned: + +- the robot a free ball is rolling to meets it on its path, whether or not a pass was announced, + and stays on it until the ball arrives or goes elsewhere; +- a robot a teammate is turning to pass to stops and faces the ball; +- of the robots driving at a loose ball, the nearest carries on and the others cover it. With the + ball ours they keep clear of it where they are: covering pulled attackers back to our side of it. +""" + +from __future__ import annotations + +import math +from typing import TYPE_CHECKING, Iterable, Optional + +from utama_core.entities.data.command import RobotCommand +from utama_core.entities.data.vector import Vector2D +from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.geometry.pass_and_score_geometry import ( + ball_line_receive_point, + clamp_outside_enemy_defense_area, + clamp_outside_own_defense_area, + clamp_to_field, + receiver_of_rolling_ball, + still_receiving, +) +from utama_core.skills.utils.move_utils import move, turn_on_spot + +if TYPE_CHECKING: + from utama_core.engine.context import TickContext + from utama_core.entities.game import Game + +COVER_M = 1.0 # from the ball, on the line to our goal +_COVER_ANGLES_RAD = (0.0, 0.7, -0.7, 1.4, -1.4) +ON_BALL_SWITCH_MARGIN_M = 0.2 # nearer than the robot already on the ball by this, or it stays on it +_LIVE_COMMANDS = frozenset({RefereeCommand.NORMAL_START, RefereeCommand.FORCE_START}) + + +class BallRoles: + def __init__(self) -> None: + self._on_ball: Optional[int] = None + self._receiving: Optional[int] = None + + def reset(self) -> None: + self._on_ball = None + self._receiving = None + + def apply( + self, game: "Game", ctx: "TickContext", commands: dict[int, RobotCommand], outfield: Iterable[int] + ) -> dict[int, RobotCommand]: + """`commands` with the robots above changed. Live play only.""" + referee = getattr(game, "referee", None) + if getattr(game, "ball", None) is None or referee is None or referee.referee_command not in _LIVE_COMMANDS: + self.reset() + return commands + + candidates = [rid for rid in outfield if rid in commands and rid in game.friendly_robots] + # A new pick replaces the last one: the ball's velocity is unreliable on the first tick of a kick, + # and a robot chosen on it kept the job. The hold is for ticks when the reach check finds nobody. + pick = receiver_of_rolling_ball(game, candidates) + if pick is not None or self._receiving not in candidates or not still_receiving(game, self._receiving): + self._receiving = pick + receiver = self._receiving + if receiver is not None and not game.friendly_robots[receiver].has_ball: + self._receive(game, ctx, commands, receiver) + for robot_id in ctx.expected_receivers: + if robot_id in commands and robot_id != receiver and not game.friendly_robots[robot_id].has_ball: + self._get_ready(game, ctx, commands, robot_id) + self._one_on_the_ball(game, ctx, commands, receiver) + return commands + + def _receive(self, game: "Game", ctx: "TickContext", commands: dict[int, RobotCommand], robot_id: int) -> None: + spot = ball_line_receive_point(game, robot_id) + if spot is None: + return + ctx.trace(game, f"ball[{robot_id}]", "receiving") + robot = game.friendly_robots[robot_id] + commands[robot_id] = move( + game=game, + motion_controller=ctx.motion_controller, + robot_id=robot_id, + target_coords=clamp_outside_enemy_defense_area(game, clamp_outside_own_defense_area(game, spot)), + target_oren=robot.p.angle_to(game.ball.p.to_2d()), + dribbling=True, + # A 5 m/s pass 2 m away arrives in 0.4 s. In 20 free-kick drills sprinting, with the pick + # above, took passes received from 9 to 14 and balls out of play from 13 to 8 (2026-11-10). + sprint=True, + ) + + def _get_ready(self, game: "Game", ctx: "TickContext", commands: dict[int, RobotCommand], robot_id: int) -> None: + ctx.trace(game, f"ball[{robot_id}]", "waiting for the pass") + robot = game.friendly_robots[robot_id] + commands[robot_id] = turn_on_spot( + game=game, + motion_controller=ctx.motion_controller, + robot_id=robot_id, + target_oren=robot.p.angle_to(game.ball.p.to_2d()), + dribbling=True, + ) + + def _one_on_the_ball( + self, game: "Game", ctx: "TickContext", commands: dict[int, RobotCommand], receiver: Optional[int] + ) -> None: + claims = sorted(rid for rid in ctx.ball_claims if rid in commands and rid in game.friendly_robots) + holder = next((rid for rid, robot in game.friendly_robots.items() if robot.has_ball), None) + ours = receiver if receiver is not None else holder + if ours is not None: + self._on_ball = ours + for robot_id in claims: + if robot_id != ours: + ctx.trace(game, f"ball[{robot_id}]", "keeping clear") + self._send(game, ctx, commands, robot_id, _clear_of_ball(game, robot_id)) + return + if not claims: + self._on_ball = None + return + self._on_ball = self._nearest(game, claims) + closest = min(claims, key=lambda rid: game.friendly_robots[rid].p.distance_to(game.ball.p.to_2d())) + for rank, robot_id in enumerate(rid for rid in claims if rid not in (self._on_ball, closest)): + ctx.trace(game, f"ball[{robot_id}]", "covering") + self._send(game, ctx, commands, robot_id, _cover_point(game, rank)) + + def _send( + self, game: "Game", ctx: "TickContext", commands: dict[int, RobotCommand], robot_id: int, target: Vector2D + ) -> None: + commands[robot_id] = move( + game=game, + motion_controller=ctx.motion_controller, + robot_id=robot_id, + target_coords=target, + target_oren=game.friendly_robots[robot_id].p.angle_to(game.ball.p.to_2d()), + ) + + def _nearest(self, game: "Game", claims: list[int]) -> int: + ball = game.ball.p.to_2d() + distance = {rid: game.friendly_robots[rid].p.distance_to(ball) for rid in claims} + nearest = min(claims, key=lambda rid: distance[rid]) + current = self._on_ball + if current in distance and distance[nearest] > distance[current] - ON_BALL_SWITCH_MARGIN_M: + return current + return nearest + + +def _clear_of_ball(game: "Game", robot_id: int) -> Vector2D: + """Where the robot stands, or straight out from the ball to `COVER_M` if it is nearer than that.""" + ball = game.ball.p.to_2d() + position = game.friendly_robots[robot_id].p + offset = position - ball + distance = offset.mag() + if distance >= COVER_M or distance == 0.0: + return position + point = ball + offset * (COVER_M / distance) + return clamp_outside_enemy_defense_area(game, clamp_outside_own_defense_area(game, clamp_to_field(point, game))) + + +def _cover_point(game: "Game", rank: int) -> Vector2D: + """`COVER_M` from the ball towards our goal; the further covers spread either side of that line.""" + ball = game.ball.p.to_2d() + to_goal = ball.angle_to(Vector2D(float(game.field.my_goal_line[0][0]), 0.0)) + angle = to_goal + _COVER_ANGLES_RAD[rank % len(_COVER_ANGLES_RAD)] + point = ball + Vector2D(math.cos(angle), math.sin(angle)) * COVER_M + return clamp_outside_enemy_defense_area(game, clamp_outside_own_defense_area(game, clamp_to_field(point, game))) diff --git a/utama_core/engine/context.py b/utama_core/engine/context.py index d04a27bbd..d66ceea8f 100644 --- a/utama_core/engine/context.py +++ b/utama_core/engine/context.py @@ -12,10 +12,10 @@ from __future__ import annotations -from dataclasses import dataclass +from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, Optional -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController if TYPE_CHECKING: from utama_core.engine.match_log import MatchLog @@ -31,6 +31,10 @@ class TickContext: # match logging is disabled (the common case — tournament/CI runs) so # tracing a tick is a single `is not None` check, not a real cost. match_log: Optional["MatchLog"] = None + # This tick's: robots driving at the ball (`go_to_ball`, a presser) and robots a teammate is + # about to pass to. `BallRoles` reads both once every tactic has ticked; `Strategy` clears them. + ball_claims: set[int] = field(default_factory=set) + expected_receivers: set[int] = field(default_factory=set) def trace(self, game: "Game", key: str, value: Any) -> None: """`match_log.trace_if_changed` at this tick's time; nothing without a match log. A key diff --git a/utama_core/engine/match_stats.py b/utama_core/engine/match_stats.py index d6c453ad5..4734cc930 100644 --- a/utama_core/engine/match_stats.py +++ b/utama_core/engine/match_stats.py @@ -25,7 +25,7 @@ time, so the ball genuinely never "freezes" even though nothing useful is happening — see `_maybe_record_no_progress_possession`'s docstring for the live match this was found in). All three are pure observations recorded -for post-match reporting (see `round_robin.py`'s "STALLS" section) — +for post-match reporting (see `evaluate.py`'s "STALLS" section) — nothing here reads back into or alters gameplay. `turnovers`/`completed_passes`/`attacking_third_entries` (friendly-side) and @@ -53,6 +53,8 @@ gives post-match tooling that signal directly from `MatchStats` without a replay re-trace. See `MatchStats.pass_distances_m`'s docstring for the exact definitions and `_record_pass_quality` for where they're computed. + +`tools/metric_correlation.py`, cited below, was deleted on 2026-11-12; it is in git history. """ from __future__ import annotations @@ -65,11 +67,11 @@ from utama_core.config.field_params import STANDARD_FIELD_DIMS from utama_core.config.physical_constants import ROBOT_RADIUS -from utama_core.custom_referee.rules.base_rule import RuleViolation from utama_core.entities.data.vector import Vector2D from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.rules.base_rule import RuleViolation # Pitch is bucketed into thirds along x, from the recording side's own goal # (defensive) to the opponent's goal (attacking), independent of which @@ -85,7 +87,7 @@ # held continuously for longer than this many sim seconds without # auto-advancing back to a live command. A real kickoff/free-kick/ball- # placement ceremony resolves in a few seconds; this is a generous margin -# above that, not a tight tolerance -- see docs/STRATEGY_DEVELOPMENT.md's +# above that, not a tight tolerance -- see docs/strategy.md's # Observability section for the matches this was built to catch. _RESTART_STALL_SECONDS = 15.0 # COMMITTED_FROZEN: the ball has moved less than this many metres... @@ -299,7 +301,7 @@ class MatchStats: # the GiveAndGoTactic bug would have shown up as here. # # Kept as plain per-pass lists, not pre-aggregated into a mean/median -- - # post-match tooling (`round_robin.py`, `tools/metric_correlation.py`, + # post-match tooling (`evaluate.py`, `tools/metric_correlation.py`, # dashboards) can compute whatever summary statistic it wants from the # raw distribution; deciding that here would throw away information # (e.g. a bimodal distribution -- mostly fine passes plus a handful of @@ -430,6 +432,7 @@ def to_json(self, path: Union[str, Path]) -> None: # tools/metric_correlation.py's `_PASS_RELEASE_MPS`, which itself matches # this file's own `_SHOT_LOCK_RELEASE_MPS`). _PASS_RELEASE_MPS = 1.0 +_MIN_PASS_M = 0.5 # 90% of avalanche's "148 passes" per match were shorter (2026-11-09) # Hysteresis band around the attacking-third boundary (half_length + # _SHOT_ATTACKING_THIRD_M) so oscillation on that line doesn't double-count # entries. Matches tools/metric_correlation.py's `_ENTRY_HYSTERESIS_M`. @@ -915,12 +918,18 @@ def _update_possession_events( # holder's -- this is the passer->receiver vector a # completed pass measures distance/progress over. previous_position = self._poss_robot_position + # Two teammates side by side trading "nearest robot" is not a pass. + is_pass = ( + previous_position is None or previous_position.distance_to(nearest_robot_position) >= _MIN_PASS_M + ) if self._poss_side == nearest_side == "friendly": - self._completed_passes += 1 - self._record_pass_quality(previous_position, nearest_robot_position, own_goal_sign, "friendly") + if is_pass: + self._completed_passes += 1 + self._record_pass_quality(previous_position, nearest_robot_position, own_goal_sign, "friendly") elif self._poss_side == nearest_side == "enemy": - self._enemy_completed_passes += 1 - self._record_pass_quality(previous_position, nearest_robot_position, own_goal_sign, "enemy") + if is_pass: + self._enemy_completed_passes += 1 + self._record_pass_quality(previous_position, nearest_robot_position, own_goal_sign, "enemy") elif self._poss_side == "friendly" and nearest_side != "friendly": self._turnovers += 1 elif self._poss_side == "enemy" and nearest_side != "enemy": diff --git a/utama_core/engine/referee_override.py b/utama_core/engine/referee_override.py index d4127b585..3336b3fee 100644 --- a/utama_core/engine/referee_override.py +++ b/utama_core/engine/referee_override.py @@ -10,7 +10,7 @@ This module matches the current `RefereeCommand` and, when it is a restart, takes over every friendly robot's command for that tick, bypassing tactics entirely. It reuses the `*Step` classes in -`utama_core/custom_referee/actions.py` rather than reimplementing +`utama_core/referee/actions.py` rather than reimplementing keep-out-distance geometry — those classes only ever touch `blackboard.game`, `blackboard.motion_controller`, and `blackboard.cmd_map` (verified: no other blackboard key is read), so a @@ -26,7 +26,7 @@ together under "just freeze", which was wrong for the other two: - STOP's actual rule is stricter than a freeze: "stop in place, AND stay - >= 0.5m from the ball" (`docs/custom_referee_gui.md`). A robot already + >= 0.5m from the ball" (`docs/referee.md ("Operator panel")`). A robot already inside that keep-out radius at the exact instant STOP is entered (e.g. a carrier mid-dribble, or `goalkeep.py`'s own retrieval branch driving the keeper up to a loose ball) has no way to comply by freezing — it is @@ -55,7 +55,12 @@ from dataclasses import dataclass, field from typing import Callable, Optional -from utama_core.custom_referee.actions import ( +from utama_core.engine.tactic import RobotId +from utama_core.entities.data.command import RobotCommand +from utama_core.entities.game import Game +from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.referee.actions import ( BallPlacementOursStep, BallPlacementTheirsStep, DirectFreeOursStep, @@ -66,11 +71,6 @@ PreparePenaltyTheirsStep, StopStep, ) -from utama_core.engine.tactic import RobotId -from utama_core.entities.data.command import RobotCommand -from utama_core.entities.game import Game -from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.motion_planning.src.common.motion_controller import MotionController # Commands requiring a legal-position override: every stoppage/restart except # HALT, which `Strategy.tick()`'s `is_paused` check already handles by issuing diff --git a/utama_core/engine/strategy.py b/utama_core/engine/strategy.py index 02d4f4128..d53a2666b 100644 --- a/utama_core/engine/strategy.py +++ b/utama_core/engine/strategy.py @@ -24,7 +24,7 @@ Referee restarts (kickoff/ball-placement/free-kick/penalty) are handled before any tactic ticks at all, not by a tactic: `engine.referee_override` -reuses the `custom_referee/actions.py` Step classes (keep-out-distance +reuses the `referee/actions.py` Step classes (keep-out-distance geometry, formation positions) to take over every outfield robot's command for the duration of the restart. See `_OVERRIDE_COMMANDS` there and `referee_reset.py` for how this fits with the barrier-reset/pause tiers. @@ -37,6 +37,8 @@ from dataclasses import dataclass, field from typing import Callable, Optional +from utama_core.engine.ball_release import BallRelease +from utama_core.engine.ball_roles import BallRoles from utama_core.engine.context import TickContext from utama_core.engine.match_log import MatchLog from utama_core.engine.referee_override import ( @@ -177,6 +179,8 @@ def __init__( self._their_restart: Optional[tuple[RefereeCommand, float, float]] = None self._pending_barrier_reset: Optional[dict[TacticId, frozenset[RobotId]]] = None self._referee_override = RefereeOverride(overrides=referee_overrides) + self._ball_release = BallRelease() + self._ball_roles = BallRoles() # Robots the referee, not a tactic, drives this tick, with their job (see `referee_control`). self._referee_control: dict[RobotId, str] = {} @@ -191,8 +195,8 @@ def __init__( # Optional structured intention/trace log — assigned post-construction # by `StrategyRunner` (see its `match_log_path` param), not threaded - # through every `build_*_kernel_strategy` factory's constructor - # signature, since none of them currently take anything beyond + # through every strategy's `build` signature, since none of them + # currently take anything beyond # `motion_controller`. `None` disables it entirely. The setter below # also pushes it into `self._ctx.match_log`, the one instance shared # by every tactic/skill invoked this tick, so assigning it here is @@ -210,7 +214,7 @@ def referee_overrides(self, value: dict[RefereeCommand, RefereeActionOverride]) Assigned post-construction the same way `match_log` is — `AbstractStrategy.__init__` runs before `load_motion_controller` builds the kernel `Strategy` via each - `build_kernel_strategy(motion_controller)` factory, none of which know about + `build(motion_controller)` factory, none of which know about `referee_overrides`, so `AbstractStrategy.load_motion_controller` sets this right after construction instead of threading a new constructor kwarg through every existing factory. @@ -231,7 +235,7 @@ def set_goalkeeper(self, robot_id: int, tactic: Optional[Tactic] = None) -> None Assigned post-construction the same way `match_log`/`referee_overrides` are — `AbstractStrategy` knows `goalkeeper_id` independently of - whichever `build_kernel_strategy` factory built this `Strategy`, so + whichever `build` factory built this `Strategy`, so this is the one place a caller needs to touch, not a constructor param threaded through every factory. @@ -349,7 +353,15 @@ def _held_restart(self, game: Game, command: RefereeCommand) -> Optional[Referee def tick(self, game: Game) -> dict[RobotId, RobotCommand]: self._tick_count += 1 + self._ctx.ball_claims.clear() + self._ctx.expected_receivers.clear() commands = self._tick(game) + if self._referee_control: # a restart or HALT drives the robots: nothing to release + self._ball_release.reset() + self._ball_roles.reset() + else: + commands = self._ball_release.apply(game, self._ctx, commands) + commands = self._ball_roles.apply(game, self._ctx, commands, self._outfield_robot_ids) if self.match_log is not None: self.match_log.clear_untraced(self._tick_count, getattr(game, "ts", 0.0)) return commands diff --git a/utama_core/global_utils/mapping_utils.py b/utama_core/entities/game/mapping_utils.py similarity index 100% rename from utama_core/global_utils/mapping_utils.py rename to utama_core/entities/game/mapping_utils.py diff --git a/utama_core/tests/controller/__init__.py b/utama_core/geometry/__init__.py similarity index 100% rename from utama_core/tests/controller/__init__.py rename to utama_core/geometry/__init__.py diff --git a/utama_core/shared/field_scaling.py b/utama_core/geometry/field_scaling.py similarity index 100% rename from utama_core/shared/field_scaling.py rename to utama_core/geometry/field_scaling.py diff --git a/utama_core/global_utils/math_utils.py b/utama_core/geometry/math_utils.py similarity index 100% rename from utama_core/global_utils/math_utils.py rename to utama_core/geometry/math_utils.py diff --git a/utama_core/shared/pass_and_score_geometry.py b/utama_core/geometry/pass_and_score_geometry.py similarity index 79% rename from utama_core/shared/pass_and_score_geometry.py rename to utama_core/geometry/pass_and_score_geometry.py index 47919a4f8..703f237a6 100644 --- a/utama_core/shared/pass_and_score_geometry.py +++ b/utama_core/geometry/pass_and_score_geometry.py @@ -22,10 +22,8 @@ from utama_core.config.referee_constants import OPPONENT_DEFENSE_AREA_KEEP_DISTANCE from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.motion_planning.src.fastpathplanning.config import ( - fastpathplanningconfig, -) -from utama_core.skills.src.score_goal import ( # noqa: F401 (re-exported) +from utama_core.motion_planning.fastpathplanning.config import fastpathplanningconfig +from utama_core.skills.score_goal import ( # noqa: F401 (re-exported) _find_best_shot, is_goal_blocked, ) @@ -244,7 +242,7 @@ def carry_exhausted(game: Game, origin: Optional[Vector2D], stops_after: bool = reaction time (`_CARRY_REACTION_S`) included -- without it a ~1.4m/s lure braked another ~0.4m and fouled at 1.01m anyway. Leave False for a carrier that kicks while moving (GiveAndGo): counting it there ended - carries ~0.5m early and cost give_and_go_solo half its goals in an A/B + carries ~0.5m early and cost ricochet half its goals in an A/B (tournament_20260924_092119 bisect).""" if origin is None or game.ball is None: return False @@ -360,6 +358,16 @@ def intercept_point( _PASS_ROLLING_MPS = 0.5 +_BALL_CONTACT_M = 0.13 # robot centre to ball with both touching +_BALL_ROLL_DECEL_MPS2 = 0.3 # tools/evaluation/reference/world.json, ball_roll_decel +# Off a ball's path by this much a robot can still meet it: the width of its dribbler and a sidestep. +_RECEIVE_REACH_M = 0.1 +_RECEIVE_SIDESTEP_MPS = 1.0 +_RECEIVE_REACH_MAX_M = 1.0 +_INTERCEPT_MIN_M = 0.3 +_INTERCEPT_STEP_S = 0.05 +_CHASE_SPEED_MPS = 1.5 +_CHASE_START_S = 0.1 def ball_line_receive_point(game: Game, receiver_id: int) -> Optional[Vector2D]: @@ -379,6 +387,91 @@ def ball_line_receive_point(game: Game, receiver_id: int) -> Optional[Vector2D]: return clamp_to_field(ball_pos + velocity * (along / speed), game) +def _ball_untouched(game: Game) -> bool: + ball = game.ball.p.to_2d() + robots = [*game.friendly_robots.values(), *game.enemy_robots.values()] + return all(robot.p.distance_to(ball) > _BALL_CONTACT_M for robot in robots) + + +def receiver_of_rolling_ball(game: Game, robot_ids) -> Optional[int]: + """The first of `robot_ids` a ball rolling free will come to and that can get onto its path in + time. Whoever kicked it, a pass nobody announced or an enemy's: the ball is coming either way. + None for a shot at the enemy goal, which a teammate must not stop, or when an enemy is first + to it: going for those, the enemy got there first 42% of the time (2026-11-09).""" + if not robot_ids: + return None + ball = game.ball + velocity = Vector2D(ball.v.x, ball.v.y) + speed = velocity.mag() + if speed < _PASS_ROLLING_MPS or not _ball_untouched(game): + return None + start = ball.p.to_2d() + if _reaches_goal(game.field.enemy_goal_line, start, math.atan2(velocity.y, velocity.x), 0.0): + return None + best, best_along = None, None + for robot_id in robot_ids: + along = _distance_along_ball_path(game.friendly_robots[robot_id].p, start, velocity) + if along is not None and (best is None or along < best_along): + best, best_along = robot_id, along + if best is None: + return None + for enemy in game.enemy_robots.values(): + along = _distance_along_ball_path(enemy.p, start, velocity) + if along is not None and along < best_along: + return None + return best + + +def _distance_along_ball_path(position: Vector2D, start: Vector2D, velocity: Vector2D) -> Optional[float]: + """How far down the path of a ball rolling from `start` a robot at `position` can meet it. + None if it is behind the ball, past where the ball stops, or cannot get onto the path in time.""" + speed = velocity.mag() + direction = velocity * (1.0 / speed) + offset = position - start + along = offset.dot(direction) + if along <= 0.0 or along > speed**2 / (2.0 * _BALL_ROLL_DECEL_MPS2): + return None + lateral = abs(offset.x * direction.y - offset.y * direction.x) + if lateral > min(_RECEIVE_REACH_MAX_M, _RECEIVE_REACH_M + _RECEIVE_SIDESTEP_MPS * along / speed): + return None + return along + + +def still_receiving(game: Game, robot_id: int) -> bool: + """The free ball a robot set out to meet is still on its way to it. Looser than choosing the + receiver (`receiver_of_rolling_ball`), whose reach check came and went with vision noise and + left a robot receiving for 0.16 s on average (2026-11-09).""" + if ball_line_receive_point(game, robot_id) is None or not _ball_untouched(game): + return False + ball = game.ball + velocity = Vector2D(ball.v.x, ball.v.y) + offset = game.friendly_robots[robot_id].p - ball.p.to_2d() + return abs(offset.x * velocity.y - offset.y * velocity.x) / velocity.mag() <= _RECEIVE_REACH_MAX_M + + +def ball_intercept_point(game: Game, robot_id: int) -> Optional[Vector2D]: + """Where `robot_id` can first meet a ball rolling free, or where it comes to rest if never + before. None for a slow ball, one a robot is touching, or a robot already beside it.""" + ball = game.ball + velocity = Vector2D(ball.v.x, ball.v.y) + speed = velocity.mag() + start = ball.p.to_2d() + position = game.friendly_robots[robot_id].p + if speed < _PASS_ROLLING_MPS or position.distance_to(start) < _INTERCEPT_MIN_M or not _ball_untouched(game): + return None + direction = velocity * (1.0 / speed) + stops_after = speed / _BALL_ROLL_DECEL_MPS2 + t = 0.0 + while t < stops_after: + spot = start + direction * (speed * t - 0.5 * _BALL_ROLL_DECEL_MPS2 * t**2) + if position.distance_to(spot) / _CHASE_SPEED_MPS + _CHASE_START_S <= t: + break + t += _INTERCEPT_STEP_S + else: + spot = start + direction * (speed**2 / (2.0 * _BALL_ROLL_DECEL_MPS2)) + return clamp_outside_enemy_defense_area(game, clamp_outside_own_defense_area(game, clamp_to_field(spot, game))) + + def enemy_positions(game: Game) -> list[Vector2D]: return [enemy.p for enemy in game.enemy_robots.values() if enemy is not None] @@ -699,14 +792,154 @@ def find_best_shot( """Thin passthrough to Core's own shadow/ray-casting shot finder. `prev_best_shot_y`/`switch_margin`: optional hysteresis, forwarded - unchanged — see `_find_best_shot`'s docstring in `skills/src/score_goal.py`. + unchanged — see `_find_best_shot`'s docstring in `skills/score_goal.py`. Both default to no-hysteresis (today's exact behaviour); a caller opts in by passing its own previously-chosen shot y (typically from its `mem`). """ return _find_best_shot(point, enemy_robots, goal_x, goal_y1, goal_y2, prev_best_shot_y, switch_margin) +# A kick that has to go now: the lane only has to clear the ball's width past a robot's body, and +# a robot touching the ball beside this one does not block a kick that leaves away from it. +RELEASE_LANE_CLEARANCE = ROBOT_RADIUS + BALL_RADIUS + 0.05 +_OWN_GOAL_RELEASE_MARGIN_M = 0.3 +# Nearer than this a full-power kick reaches the teammate before it can adjust: 28% of passes under +# 1.5 m were received against about 50% from 1.5 m to 3.5 m (3131 passes, 2026-11-10). Skipping them +# in paired drills: +1.7 +/- 0.6 points of goal difference and the ball 0.26 m further upfield. +MIN_OPEN_TEAMMATE_M = 1.5 +# Further than this a full-power kick reached the teammate less than 45% of the time and left the +# pitch more than 40%, against 52% and 30% from 1.5 m to 3.5 m (36 matches, 2026-11-09). +MAX_OPEN_TEAMMATE_M = 3.5 +# A passer tells its receiver once it is this near its aim: a turn away from the kick. Told any +# earlier, the ball came to only 14% of the receivers that stopped for it (2026-11-09). +ANNOUNCE_PASS_RAD = 0.5 + + +def _reaches_goal(line, point: Vector2D, heading: float, margin: float) -> bool: + goal_x = float(line[0][0]) + half_width = max(abs(float(line[0][1])), abs(float(line[1][1]))) + to_line = goal_x - point.x + if math.cos(heading) * to_line <= 0.0: + return False + return abs(point.y + math.tan(heading) * to_line) <= half_width + margin + + +def reaches_own_goal(game: Game, point: Vector2D, heading: float) -> bool: + """A kick from `point` along `heading` would reach our goal mouth.""" + return _reaches_goal(game.field.my_goal_line, point, heading, _OWN_GOAL_RELEASE_MARGIN_M) + + +def open_teammate( + game: Game, + robot_id: int, + clearance: float = ROBOT_RADIUS + 0.15, + origin: Optional[Vector2D] = None, + min_distance: float = MIN_OPEN_TEAMMATE_M, +) -> Optional[int]: + """Id of the most advanced teammate in range of a kick down a clear lane, outside our own box. + From `origin` for a robot not at the ball yet, otherwise from where the robot stands.""" + position = game.friendly_robots[robot_id].p if origin is None else origin + enemies = enemy_positions(game) + goal_x = enemy_goal_line(game)[0] + best, best_to_goal = None, None + for teammate_id, teammate in game.friendly_robots.items(): + if teammate_id == robot_id or not min_distance <= position.distance_to(teammate.p) <= MAX_OPEN_TEAMMATE_M: + continue + if in_own_defense_area(game, teammate.p) or segment_blocked(position, teammate.p, enemies, clearance): + continue + to_goal = abs(goal_x - teammate.p.x) + if best is None or to_goal < best_to_goal: + best, best_to_goal = teammate_id, to_goal + return best + + +_RESTART_SUPPORT_M = 2.0 +_RESTART_SUPPORT_OFFSETS_RAD = (0.0, 0.5, -0.5, 1.0, -1.0) +_RESTART_SUPPORT_FIELD_MARGIN_M = 0.3 + + +def restart_support(game: Game, kicker_id: int, ball: Vector2D) -> Optional[tuple[int, Vector2D]]: + """(teammate, spot) for a restart with nobody to pass to: the nearest teammate outside our box and + a spot `_RESTART_SUPPORT_M` from the ball towards the enemy goal with a clear lane from it, kept + inside the pitch. None when no teammate can come or no such spot exists.""" + others = { + rid: robot + for rid, robot in game.friendly_robots.items() + if rid != kicker_id and not in_own_defense_area(game, robot.p) + } + if not others: + return None + enemies = enemy_positions(game) + goal_x, goal_y1, goal_y2 = enemy_goal_line(game) + to_goal = ball.angle_to(Vector2D(goal_x, (goal_y1 + goal_y2) / 2.0)) + for offset in _RESTART_SUPPORT_OFFSETS_RAD: + spot = ball + Vector2D(math.cos(to_goal + offset), math.sin(to_goal + offset)) * _RESTART_SUPPORT_M + in_field = ( + abs(spot.x) <= game.field.half_length - _RESTART_SUPPORT_FIELD_MARGIN_M + and abs(spot.y) <= game.field.half_width - _RESTART_SUPPORT_FIELD_MARGIN_M + ) + if not in_field or spot.distance_to(clamp_outside_enemy_defense_area(game, spot)) > 0.0: + continue + if spot.distance_to(clamp_outside_own_defense_area(game, spot)) > 0.0: + continue + if not segment_blocked(ball, spot, enemies, RELEASE_LANE_CLEARANCE): + return min(others, key=lambda rid: others[rid].p.distance_to(spot)), spot + return None + + +def _distance_to_field_edge(game: Game, point: Vector2D, heading: float) -> float: + dx, dy = math.cos(heading), math.sin(heading) + limits = [] + if abs(dx) > 1e-9: + limits.append((math.copysign(game.field.half_length, dx) - point.x) / dx) + if abs(dy) > 1e-9: + limits.append((math.copysign(game.field.half_width, dy) - point.y) / dy) + return max(0.0, min(limits)) + + +def release_heading(game: Game, robot_id: int) -> float: + """Where to kick a ball that cannot be held any longer: at an open teammate, otherwise at the + enemy goal, turned off it just enough to clear an enemy in the way. Kicked down whichever lane + looked clear instead, 56% left the pitch and on-target kicks halved (round-robin of 2026-11-09).""" + robot = game.friendly_robots[robot_id] + teammate = open_teammate(game, robot_id, RELEASE_LANE_CLEARANCE) + if teammate is not None: + return robot.p.angle_to(game.friendly_robots[teammate].p) + goal_x, goal_y1, goal_y2 = enemy_goal_line(game) + return _nearest_clear_heading( + game, robot_id, robot.p.angle_to(Vector2D(goal_x, (goal_y1 + goal_y2) / 2.0)), _RELEASE_OFFSETS_RAD + ) + + +_CLEARANCE_OFFSETS_RAD = (0.0, 0.26, -0.26, 0.52, -0.52) +# Wide enough to clear an enemy touching the ball dead ahead (a body 0.21 m from the kicker's). +_RELEASE_OFFSETS_RAD = (0.0, 0.35, -0.35, 0.7, -0.7, 1.05, -1.05, 1.4, -1.4) +_CLEARANCE_LANE_M = 2.0 + + +def upfield_heading(game: Game, robot_id: int) -> float: + """Straight upfield, or the nearest angle off it with a clear lane that stays in play.""" + return _nearest_clear_heading(game, robot_id, math.pi if game.my_team_is_right else 0.0, _CLEARANCE_OFFSETS_RAD) + + +def _nearest_clear_heading(game: Game, robot_id: int, base: float, offsets_rad: tuple[float, ...]) -> float: + """`base`, or the angle off it nearest to it with a clear lane that stays in play.""" + robot = game.friendly_robots[robot_id] + enemies = enemy_positions(game) + # Of two equal angles, the one towards the middle of the field. + ordered = sorted(offsets_rad, key=lambda o: (abs(o), abs(robot.p.y + _CLEARANCE_LANE_M * math.sin(base + o)))) + for offset in ordered: + heading = base + offset + if offset != 0.0 and _distance_to_field_edge(game, robot.p, heading) < _CLEARANCE_LANE_M: + continue + lane_end = robot.p + Vector2D(math.cos(heading), math.sin(heading)) * _CLEARANCE_LANE_M + if not segment_blocked(robot.p, lane_end, enemies, RELEASE_LANE_CLEARANCE): + return heading + return base + + _NO_SHOT_STRAFE_STEP = 0.6 # metres of lateral reposition per tick while hunting for a lane +_DEEP_NEAR_LINE_M = 1.5 def no_shot_reposition_target( @@ -719,7 +952,7 @@ def no_shot_reposition_target( the blocker is about to move on its own. Against a stationary keeper covering the whole goal from close range (the common case once a carrier reaches the goal mouth) nothing about that position ever changes, so the - freeze is permanent: this was the actual mechanism behind a `clear_danger` + freeze is permanent: this was the actual mechanism behind a `firebreak` vs `low_block` match pinning 0-0 for 48 straight seconds (see `docs/strategies.md`'s "Known open bugs" and `docs/investigation_default_vs_lowblock_stalemate.md` for the sibling @@ -765,6 +998,10 @@ def _clamped_target_y(sign: float) -> float: -field_half_width + margin, min(field_half_width - margin, carrier_pos.y + sign * _NO_SHOT_STRAFE_STEP) ) + if abs(goal_x - carrier_pos.x) < _DEEP_NEAR_LINE_M and not goal_y1 <= carrier_pos.y <= goal_y2: + # Deep and wide of the goal, the way out is towards the middle: the other way is the corner. + away_sign = 1.0 if carrier_pos.y < 0.0 else -1.0 + target_y = _clamped_target_y(away_sign) if abs(target_y - carrier_pos.y) < _NO_SHOT_STRAFE_STEP / 2: # The preferred direction was clamped away to a near-zero step — diff --git a/utama_core/shared/tolerance.py b/utama_core/geometry/tolerance.py similarity index 100% rename from utama_core/shared/tolerance.py rename to utama_core/geometry/tolerance.py diff --git a/utama_core/motion_planning/src/common/acceleration_limiter.py b/utama_core/motion_planning/common/acceleration_limiter.py similarity index 100% rename from utama_core/motion_planning/src/common/acceleration_limiter.py rename to utama_core/motion_planning/common/acceleration_limiter.py diff --git a/utama_core/motion_planning/src/common/control_schemes.py b/utama_core/motion_planning/common/control_schemes.py similarity index 85% rename from utama_core/motion_planning/src/common/control_schemes.py rename to utama_core/motion_planning/common/control_schemes.py index 2b4b1a058..14918dfff 100644 --- a/utama_core/motion_planning/src/common/control_schemes.py +++ b/utama_core/motion_planning/common/control_schemes.py @@ -1,7 +1,7 @@ from typing import Type -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.motion_planning.src.controllers import ( +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.motion_planning.controllers import ( DWAController, FastPathPlanningController, PIDController, diff --git a/utama_core/motion_planning/src/common/motion_controller.py b/utama_core/motion_planning/common/motion_controller.py similarity index 91% rename from utama_core/motion_planning/src/common/motion_controller.py rename to utama_core/motion_planning/common/motion_controller.py index c7db53c0f..5cd062706 100644 --- a/utama_core/motion_planning/src/common/motion_controller.py +++ b/utama_core/motion_planning/common/motion_controller.py @@ -3,12 +3,12 @@ from utama_core.config.enums import Mode from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.pose_ahead import ( +from utama_core.motion_planning.common.pose_ahead import ( _PARAMS_BY_MODE, PoseAhead, control_latency_s, ) -from utama_core.rsoccer_simulator.src.ssl.envs import SSLStandardEnv +from utama_core.simulator.ssl.envs import SSLStandardEnv class MotionController(ABC): @@ -19,6 +19,8 @@ def __init__(self, mode: Mode, rsim_env: SSLStandardEnv | None = None): self.pose_ahead = PoseAhead(control_latency_s(mode)) # `move()` holds a robot with the ball to these (`RobotParams.CARRY_SPEED`/`CARRY_TURN`). params = _PARAMS_BY_MODE[Mode(mode)] + self.max_speed: float = params.MAX_VEL + self.max_acceleration: float = params.MAX_ACCELERATION self.carry_speed: float | None = params.CARRY_SPEED self.carry_turn: float | None = params.CARRY_TURN self.min_turn: float | None = params.MIN_TURN diff --git a/utama_core/motion_planning/src/common/pose_ahead.py b/utama_core/motion_planning/common/pose_ahead.py similarity index 92% rename from utama_core/motion_planning/src/common/pose_ahead.py rename to utama_core/motion_planning/common/pose_ahead.py index 62724e9ac..9ab7b0c44 100644 --- a/utama_core/motion_planning/src/common/pose_ahead.py +++ b/utama_core/motion_planning/common/pose_ahead.py @@ -30,8 +30,9 @@ class PoseAhead: this (4 cm with no delay); the motion benchmark's collisions went from 7 to 3. Only our robots move ahead, and only for planning their motion (`move()`): the game itself, - its history and every other decision keep what vision saw. With no latency (the simulators) - `game()` returns the game unchanged. + its history and every other decision keep what vision saw. rsim with simulated delay uses this + too, at the middle of its range (`SimNoise.latency_estimate_s`). With no latency `game()` + returns the game unchanged. """ def __init__(self, latency_s: float): diff --git a/utama_core/motion_planning/controllers/__init__.py b/utama_core/motion_planning/controllers/__init__.py new file mode 100644 index 000000000..e24f0243f --- /dev/null +++ b/utama_core/motion_planning/controllers/__init__.py @@ -0,0 +1,8 @@ +from utama_core.motion_planning.controllers.dwa_controller import DWAController +from utama_core.motion_planning.controllers.fastpathplanning import ( + FastPathPlanningController, +) +from utama_core.motion_planning.controllers.pid_controller import PIDController +from utama_core.motion_planning.controllers.trajsampling import ( + TrajectorySamplingController, +) diff --git a/utama_core/motion_planning/src/controllers/dwa_controller.py b/utama_core/motion_planning/controllers/dwa_controller.py similarity index 77% rename from utama_core/motion_planning/src/controllers/dwa_controller.py rename to utama_core/motion_planning/controllers/dwa_controller.py index 2e70a2f77..023343a9a 100644 --- a/utama_core/motion_planning/src/controllers/dwa_controller.py +++ b/utama_core/motion_planning/controllers/dwa_controller.py @@ -1,13 +1,13 @@ from utama_core.config.enums import Mode from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.motion_planning.src.dwa.config import get_dwa_config -from utama_core.motion_planning.src.dwa.translation_controller import ( +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.motion_planning.dwa.config import get_dwa_config +from utama_core.motion_planning.dwa.translation_controller import ( DWATranslationController, ) -from utama_core.motion_planning.src.pid import PID, get_pids -from utama_core.rsoccer_simulator.src.ssl.envs.standard_ssl import SSLStandardEnv +from utama_core.motion_planning.pid import PID, get_pids +from utama_core.simulator.ssl.envs.standard_ssl import SSLStandardEnv class DWAController(MotionController): diff --git a/utama_core/motion_planning/src/controllers/fastpathplanning.py b/utama_core/motion_planning/controllers/fastpathplanning.py similarity index 84% rename from utama_core/motion_planning/src/controllers/fastpathplanning.py rename to utama_core/motion_planning/controllers/fastpathplanning.py index 35787d9c6..e083230b6 100644 --- a/utama_core/motion_planning/src/controllers/fastpathplanning.py +++ b/utama_core/motion_planning/controllers/fastpathplanning.py @@ -1,10 +1,10 @@ from utama_core.config.enums import Mode from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.motion_planning.src.fastpathplanning.planner import FastPathPlanner -from utama_core.motion_planning.src.pid.pid import get_pids -from utama_core.rsoccer_simulator.src.ssl.envs import SSLStandardEnv +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.motion_planning.fastpathplanning.planner import FastPathPlanner +from utama_core.motion_planning.pid.pid import get_pids +from utama_core.simulator.ssl.envs import SSLStandardEnv class FastPathPlanningController(MotionController): diff --git a/utama_core/motion_planning/src/controllers/pid_controller.py b/utama_core/motion_planning/controllers/pid_controller.py similarity index 83% rename from utama_core/motion_planning/src/controllers/pid_controller.py rename to utama_core/motion_planning/controllers/pid_controller.py index 1bcb9157a..c30191a7b 100644 --- a/utama_core/motion_planning/src/controllers/pid_controller.py +++ b/utama_core/motion_planning/controllers/pid_controller.py @@ -3,9 +3,9 @@ from utama_core.config.enums import Mode from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.motion_planning.src.pid.pid import get_pids -from utama_core.rsoccer_simulator.src.ssl.envs import SSLStandardEnv +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.motion_planning.pid.pid import get_pids +from utama_core.simulator.ssl.envs import SSLStandardEnv class PIDController(MotionController): diff --git a/utama_core/motion_planning/src/controllers/trajsampling.py b/utama_core/motion_planning/controllers/trajsampling.py similarity index 95% rename from utama_core/motion_planning/src/controllers/trajsampling.py rename to utama_core/motion_planning/controllers/trajsampling.py index 0cf02a697..b837a4763 100644 --- a/utama_core/motion_planning/src/controllers/trajsampling.py +++ b/utama_core/motion_planning/controllers/trajsampling.py @@ -39,15 +39,11 @@ class of bug `TwoDPID.set_final_target` works around for FPP's carrot. from utama_core.config.settings import CONTROL_FREQUENCY from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.motion_planning.src.pid.pid import get_pids -from utama_core.motion_planning.src.trajsampling.config import ( - trajsamplingconfig as config, -) -from utama_core.motion_planning.src.trajsampling.planner import ( - TrajectorySamplingPlanner, -) -from utama_core.rsoccer_simulator.src.ssl.envs import SSLStandardEnv +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.motion_planning.pid.pid import get_pids +from utama_core.motion_planning.trajsampling.config import trajsamplingconfig as config +from utama_core.motion_planning.trajsampling.planner import TrajectorySamplingPlanner +from utama_core.simulator.ssl.envs import SSLStandardEnv _PARAMS_BY_MODE = {Mode.RSIM: RSIM_PARAMS, Mode.GRSIM: GRSIM_PARAMS, Mode.REAL: REAL_PARAMS} diff --git a/utama_core/motion_planning/src/dwa/config.py b/utama_core/motion_planning/dwa/config.py similarity index 100% rename from utama_core/motion_planning/src/dwa/config.py rename to utama_core/motion_planning/dwa/config.py diff --git a/utama_core/motion_planning/src/dwa/planner.py b/utama_core/motion_planning/dwa/planner.py similarity index 96% rename from utama_core/motion_planning/src/dwa/planner.py rename to utama_core/motion_planning/dwa/planner.py index 788d0547e..a698119ce 100644 --- a/utama_core/motion_planning/src/dwa/planner.py +++ b/utama_core/motion_planning/dwa/planner.py @@ -7,17 +7,14 @@ from utama_core.config.settings import TIMESTEP from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game, Robot -from utama_core.global_utils.math_utils import normalise_heading -from utama_core.motion_planning.src.dwa.config import DynamicWindowConfig -from utama_core.motion_planning.src.planning.geometry import ( +from utama_core.geometry.math_utils import normalise_heading +from utama_core.motion_planning.dwa.config import DynamicWindowConfig +from utama_core.motion_planning.planning.geometry import ( AxisAlignedRectangle, point_segment_distance, ) -from utama_core.motion_planning.src.planning.obstacles import ( - ObstacleRegion, - to_rectangles, -) -from utama_core.rsoccer_simulator.src.ssl.envs import SSLStandardEnv +from utama_core.motion_planning.planning.obstacles import ObstacleRegion, to_rectangles +from utama_core.simulator.ssl.envs import SSLStandardEnv class DynamicWindowPlanner: diff --git a/utama_core/motion_planning/src/dwa/translation_controller.py b/utama_core/motion_planning/dwa/translation_controller.py similarity index 91% rename from utama_core/motion_planning/src/dwa/translation_controller.py rename to utama_core/motion_planning/dwa/translation_controller.py index c6bfa731b..de9282f3f 100644 --- a/utama_core/motion_planning/src/dwa/translation_controller.py +++ b/utama_core/motion_planning/dwa/translation_controller.py @@ -3,11 +3,9 @@ from utama_core.config.settings import TIMESTEP from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.acceleration_limiter import ( - AccelerationLimiter, -) -from utama_core.motion_planning.src.dwa.config import DynamicWindowConfig -from utama_core.rsoccer_simulator.src.ssl.envs import SSLStandardEnv +from utama_core.motion_planning.common.acceleration_limiter import AccelerationLimiter +from utama_core.motion_planning.dwa.config import DynamicWindowConfig +from utama_core.simulator.ssl.envs import SSLStandardEnv from .planner import DynamicWindowPlanner diff --git a/utama_core/motion_planning/src/fastpathplanning/config.py b/utama_core/motion_planning/fastpathplanning/config.py similarity index 100% rename from utama_core/motion_planning/src/fastpathplanning/config.py rename to utama_core/motion_planning/fastpathplanning/config.py diff --git a/utama_core/motion_planning/src/fastpathplanning/cpp/CMakeLists.txt b/utama_core/motion_planning/fastpathplanning/cpp/CMakeLists.txt similarity index 100% rename from utama_core/motion_planning/src/fastpathplanning/cpp/CMakeLists.txt rename to utama_core/motion_planning/fastpathplanning/cpp/CMakeLists.txt diff --git a/utama_core/motion_planning/src/fastpathplanning/cpp/planner.cpp b/utama_core/motion_planning/fastpathplanning/cpp/planner.cpp similarity index 100% rename from utama_core/motion_planning/src/fastpathplanning/cpp/planner.cpp rename to utama_core/motion_planning/fastpathplanning/cpp/planner.cpp diff --git a/utama_core/motion_planning/src/fastpathplanning/numba_kernels.py b/utama_core/motion_planning/fastpathplanning/numba_kernels.py similarity index 100% rename from utama_core/motion_planning/src/fastpathplanning/numba_kernels.py rename to utama_core/motion_planning/fastpathplanning/numba_kernels.py diff --git a/utama_core/motion_planning/src/fastpathplanning/planner.py b/utama_core/motion_planning/fastpathplanning/planner.py similarity index 99% rename from utama_core/motion_planning/src/fastpathplanning/planner.py rename to utama_core/motion_planning/fastpathplanning/planner.py index 946376587..e08c56d80 100644 --- a/utama_core/motion_planning/src/fastpathplanning/planner.py +++ b/utama_core/motion_planning/fastpathplanning/planner.py @@ -12,7 +12,7 @@ from utama_core.entities.game import Game from utama_core.entities.game.field import FieldBounds from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.global_utils.math_utils import ( +from utama_core.geometry.math_utils import ( closest_point_on_segment, detour_around_circle, distance, @@ -20,10 +20,10 @@ distance_point_to_segment, find_intersection, ) -from utama_core.motion_planning.src.fastpathplanning.config import ( +from utama_core.motion_planning.fastpathplanning.config import ( fastpathplanningconfig as config, ) -from utama_core.motion_planning.src.fastpathplanning.numba_kernels import ( +from utama_core.motion_planning.fastpathplanning.numba_kernels import ( clamp_to_obstacle_clearance_nb, collides_nb, find_segment_nb, @@ -33,10 +33,10 @@ scan_collides_nb, scan_find_subgoal_nb, ) -from utama_core.rsoccer_simulator.src.ssl.envs.standard_ssl import SSLStandardEnv +from utama_core.simulator.ssl.envs.standard_ssl import SSLStandardEnv try: - from utama_core.motion_planning.src.fastpathplanning import _fastpathplanner + from utama_core.motion_planning.fastpathplanning import _fastpathplanner HAS_CPP = True except ImportError: @@ -77,7 +77,7 @@ def _perp_rotation(subgoal_direction: int) -> Tuple[float, float]: return rot -# Same set `DefenseAreaRule` (custom_referee/rules/defense_area_rule.py) uses to +# Same set `DefenseAreaRule` (referee/rules/defense_area_rule.py) uses to # decide when defense-area encroachment is actually a foul — entry is legal # outside these commands (e.g. during a DIRECT_FREE_*/BALL_PLACEMENT_* restart # where the ball itself has come to rest in the opponent's box and a robot must @@ -375,7 +375,7 @@ def _enemy_defense_area_retrieval_exempt(self, game: Game, robot_id: Optional[in genuine ball-in-the-box retrieval or carry-to-place is exempted. Without this, `DIRECT_FREE_OURS`/`BALL_PLACEMENT_OURS` - (`custom_referee/actions.py`) can correctly choose to approach the + (`referee/actions.py`) can correctly choose to approach the ball (or, once carrying it, drive toward `designated_position`), but the planner refuses to route anywhere inside the rectangle at all — the kicker/placer converges to just outside @@ -666,7 +666,7 @@ def _find_subgoal_exact( # `multiple` (and which obstacle blocked last) changes, so this loops # instead, computing the direction once. Same arithmetic, same order, # so the same subgoal bit-for-bit (pinned against the recursive - # version in fastpathplanner_equivalence_test.py). + # version in test_fastpathplanner_equivalence.py). direction = target - robot_pos direction_norm = math.hypot(direction[0], direction[1]) unitvec = None @@ -1301,7 +1301,7 @@ def smooth_path( # A first subgoal sitting exactly on the robot (the detour recursion can # produce one) has no direction to normalise: dividing by its zero length # returned a NaN carrot. Skip such segments. Found by - # fastpathplanner_corner_test.py (a robot beside two blockers at the + # test_fastpathplanner_corner.py (a robot beside two blockers at the # enemy box corner). while len(trajectory) > 1 and math.hypot(*(trajectory[0][1] - robot_position)) == 0.0: trajectory = trajectory[1:] diff --git a/utama_core/motion_planning/pid/__init__.py b/utama_core/motion_planning/pid/__init__.py new file mode 100644 index 000000000..bf13217d9 --- /dev/null +++ b/utama_core/motion_planning/pid/__init__.py @@ -0,0 +1 @@ +from utama_core.motion_planning.pid.pid import PID, TwoDPID, get_pids diff --git a/utama_core/motion_planning/src/pid/configs.py b/utama_core/motion_planning/pid/configs.py similarity index 92% rename from utama_core/motion_planning/src/pid/configs.py rename to utama_core/motion_planning/pid/configs.py index 577055e04..17ecf7e95 100644 --- a/utama_core/motion_planning/src/pid/configs.py +++ b/utama_core/motion_planning/pid/configs.py @@ -29,6 +29,8 @@ class TranslationPIDConfigs: integral_min: Union[float, None] = None integral_max: Union[float, None] = None max_acceleration: float = 0.0 + # Share of the speed it can still stop from that a robot holds on its last metre; 0 leaves it to kp. + approach_brake_fraction: float = 0.0 @dataclass(slots=True) @@ -59,6 +61,8 @@ def get_pid_configs(mode: Mode) -> PIDConfigs: integral_min=-5, integral_max=5, max_acceleration=RSIM_PARAMS.MAX_ACCELERATION, + # 2026-11-10, 20 free-kick drills: taken 1 s sooner at the median. 0.8 left two untaken. + approach_brake_fraction=0.6, ), ) if mode == Mode.GRSIM: diff --git a/utama_core/motion_planning/src/pid/pid.py b/utama_core/motion_planning/pid/pid.py similarity index 90% rename from utama_core/motion_planning/src/pid/pid.py rename to utama_core/motion_planning/pid/pid.py index 259b0014c..343b60747 100644 --- a/utama_core/motion_planning/src/pid/pid.py +++ b/utama_core/motion_planning/pid/pid.py @@ -3,13 +3,13 @@ from utama_core.config.enums import Mode from utama_core.entities.data.vector import Vector2D -from utama_core.global_utils.math_utils import normalise_heading -from utama_core.motion_planning.src.pid.configs import ( +from utama_core.geometry.math_utils import normalise_heading +from utama_core.motion_planning.pid.configs import ( OrientationPIDConfigs, TranslationPIDConfigs, get_pid_configs, ) -from utama_core.motion_planning.src.pid.pid_abstract import AbstractPID +from utama_core.motion_planning.pid.pid_abstract import AbstractPID # A phase hand-off / reassignment re-aiming a robot swings the target by a # large angle in one tick (observed 100+ degrees in `switch_of_play`'s @@ -115,6 +115,11 @@ def _calculate( return output +_APPROACH_MIN_M = 0.1 # closer than this kp settles the robot, which a higher speed would overshoot +_APPROACH_MAX_M = 1.0 # the planner's carrot is this far ahead until then, so kp is at cruising speed +_STRAIGHT_RUN_M = 0.02 + + class TwoDPID(AbstractPID[Vector2D]): """A 2D PID controller that controls the X and Y dimensions and scales the resulting velocity vector to a maximum speed if needed.""" @@ -126,6 +131,7 @@ def __init__( super().__init__(config) self.max_velocity = config.max_velocity self.max_acceleration = config.max_acceleration + self.approach_brake_fraction = config.approach_brake_fraction # Set by a caller (`FastPathPlanningController`) right before # `calculate()` when `target` is a lookahead "carrot" rather than the # robot's actual destination — see `set_final_target`'s docstring for @@ -153,7 +159,7 @@ def set_final_target(self, robot_id: int, final_target: Vector2D | None) -> None flipping sign every few ticks — 6+ reversals — as it repeatedly shot past the target and corrected, until the ball rolled out of play during the oscillation window. Reproduced synthetically too - (`debug_match.py` trace): carrot pinned at `carrot_err≈1.0` while + (`tools/debug/debug_match.py` trace): carrot pinned at `carrot_err≈1.0` while `true_err` closed from >3m to <0.15m at 1.5-2.0 m/s, no deceleration signal reaching the PID until far too late. @@ -263,6 +269,15 @@ def _calculate(self, target: Vector2D, current: Vector2D, robot_id: int) -> Vect max_brake_vel = ( math.sqrt(2 * self.max_acceleration * brake_distance) if self.max_acceleration > 0 else self.max_velocity ) + if self.approach_brake_fraction and final_target is not None and error > 0.0: + # Kp * error is 0.45 m/s with 0.25 m to go, so the last half metre of every move took over 1 s. + # Only inside the last metre: cruising speed is left alone, a higher kp crashed crowded robots. + # And only straight at the destination: a nearer waypoint is a corner, which the planner + # takes by slowing down, and at speed a robot cut across the ball's keep-out circle. + if _APPROACH_MIN_M < brake_distance < _APPROACH_MAX_M and error >= brake_distance - _STRAIGHT_RUN_M: + floor = min(self.Kp * _APPROACH_MAX_M, self.approach_brake_fraction * max_brake_vel) + if output < floor: + x_vel, y_vel = floor * (dx / error), floor * (dy / error) return self._apply_speed_limits(x_vel, y_vel, min(self.max_velocity, max_brake_vel)) def _apply_speed_limits(self, x_vel: float, y_vel: float, max_vel: float) -> Vector2D: diff --git a/utama_core/motion_planning/src/pid/pid_abstract.py b/utama_core/motion_planning/pid/pid_abstract.py similarity index 94% rename from utama_core/motion_planning/src/pid/pid_abstract.py rename to utama_core/motion_planning/pid/pid_abstract.py index 69578e1de..7548f8883 100644 --- a/utama_core/motion_planning/src/pid/pid_abstract.py +++ b/utama_core/motion_planning/pid/pid_abstract.py @@ -2,10 +2,8 @@ from typing import Generic, Optional, TypeVar from utama_core.config.settings import SENDING_DELAY -from utama_core.motion_planning.src.common.acceleration_limiter import ( - AccelerationLimiter, -) -from utama_core.motion_planning.src.pid.configs import ( +from utama_core.motion_planning.common.acceleration_limiter import AccelerationLimiter +from utama_core.motion_planning.pid.configs import ( OrientationPIDConfigs, TranslationPIDConfigs, ) diff --git a/utama_core/motion_planning/src/planning/geometry.py b/utama_core/motion_planning/planning/geometry.py similarity index 100% rename from utama_core/motion_planning/src/planning/geometry.py rename to utama_core/motion_planning/planning/geometry.py diff --git a/utama_core/motion_planning/src/planning/obstacles.py b/utama_core/motion_planning/planning/obstacles.py similarity index 93% rename from utama_core/motion_planning/src/planning/obstacles.py rename to utama_core/motion_planning/planning/obstacles.py index 00106f48d..278b84e10 100644 --- a/utama_core/motion_planning/src/planning/obstacles.py +++ b/utama_core/motion_planning/planning/obstacles.py @@ -7,7 +7,7 @@ import numpy as np -from utama_core.motion_planning.src.planning.geometry import AxisAlignedRectangle +from utama_core.motion_planning.planning.geometry import AxisAlignedRectangle @dataclass(frozen=True) diff --git a/utama_core/motion_planning/src/controllers/__init__.py b/utama_core/motion_planning/src/controllers/__init__.py deleted file mode 100644 index b97d23b22..000000000 --- a/utama_core/motion_planning/src/controllers/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -from utama_core.motion_planning.src.controllers.dwa_controller import DWAController -from utama_core.motion_planning.src.controllers.fastpathplanning import ( - FastPathPlanningController, -) -from utama_core.motion_planning.src.controllers.pid_controller import PIDController -from utama_core.motion_planning.src.controllers.trajsampling import ( - TrajectorySamplingController, -) diff --git a/utama_core/motion_planning/src/pid/__init__.py b/utama_core/motion_planning/src/pid/__init__.py deleted file mode 100644 index 0963d98d7..000000000 --- a/utama_core/motion_planning/src/pid/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from utama_core.motion_planning.src.pid.pid import PID, TwoDPID, get_pids diff --git a/utama_core/tests/custom_referee/__init__.py b/utama_core/motion_planning/trajsampling/__init__.py similarity index 100% rename from utama_core/tests/custom_referee/__init__.py rename to utama_core/motion_planning/trajsampling/__init__.py diff --git a/utama_core/motion_planning/src/trajsampling/bang_bang.py b/utama_core/motion_planning/trajsampling/bang_bang.py similarity index 100% rename from utama_core/motion_planning/src/trajsampling/bang_bang.py rename to utama_core/motion_planning/trajsampling/bang_bang.py diff --git a/utama_core/motion_planning/src/trajsampling/collision_numba.py b/utama_core/motion_planning/trajsampling/collision_numba.py similarity index 100% rename from utama_core/motion_planning/src/trajsampling/collision_numba.py rename to utama_core/motion_planning/trajsampling/collision_numba.py diff --git a/utama_core/motion_planning/src/trajsampling/config.py b/utama_core/motion_planning/trajsampling/config.py similarity index 100% rename from utama_core/motion_planning/src/trajsampling/config.py rename to utama_core/motion_planning/trajsampling/config.py diff --git a/utama_core/motion_planning/src/trajsampling/obstacles.py b/utama_core/motion_planning/trajsampling/obstacles.py similarity index 98% rename from utama_core/motion_planning/src/trajsampling/obstacles.py rename to utama_core/motion_planning/trajsampling/obstacles.py index 144071cce..de4683269 100644 --- a/utama_core/motion_planning/src/trajsampling/obstacles.py +++ b/utama_core/motion_planning/trajsampling/obstacles.py @@ -24,7 +24,7 @@ import numpy as np -from utama_core.motion_planning.src.trajsampling.bang_bang import BangBang1D +from utama_core.motion_planning.trajsampling.bang_bang import BangBang1D class TimedObstacle(Protocol): diff --git a/utama_core/motion_planning/src/trajsampling/planner.py b/utama_core/motion_planning/trajsampling/planner.py similarity index 99% rename from utama_core/motion_planning/src/trajsampling/planner.py rename to utama_core/motion_planning/trajsampling/planner.py index e67d1a8f5..d04cd098c 100644 --- a/utama_core/motion_planning/src/trajsampling/planner.py +++ b/utama_core/motion_planning/trajsampling/planner.py @@ -49,12 +49,10 @@ from utama_core.entities.game import Game from utama_core.entities.game.field import FieldBounds from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.motion_planning.src.trajsampling import collision_numba as _cn -from utama_core.motion_planning.src.trajsampling.bang_bang import Trajectory2D -from utama_core.motion_planning.src.trajsampling.config import ( - trajsamplingconfig as config, -) -from utama_core.motion_planning.src.trajsampling.obstacles import ( +from utama_core.motion_planning.trajsampling import collision_numba as _cn +from utama_core.motion_planning.trajsampling.bang_bang import Trajectory2D +from utama_core.motion_planning.trajsampling.config import trajsamplingconfig as config +from utama_core.motion_planning.trajsampling.obstacles import ( ConstantVelocityObstacle, EnemyRobotObstacle, OwnRobotObstacle, diff --git a/utama_core/referee/__init__.py b/utama_core/referee/__init__.py new file mode 100644 index 000000000..3f0231aa7 --- /dev/null +++ b/utama_core/referee/__init__.py @@ -0,0 +1,4 @@ +from utama_core.referee.custom_referee import CustomReferee +from utama_core.referee.geometry import RefereeGeometry + +__all__ = ["CustomReferee", "RefereeGeometry"] diff --git a/utama_core/custom_referee/actions.py b/utama_core/referee/actions.py similarity index 85% rename from utama_core/custom_referee/actions.py rename to utama_core/referee/actions.py index 06c2188cd..9cd505ac5 100644 --- a/utama_core/custom_referee/actions.py +++ b/utama_core/referee/actions.py @@ -10,6 +10,7 @@ """ import math +from typing import Optional from utama_core.config.physical_constants import BALL_RADIUS, ROBOT_RADIUS from utama_core.config.referee_constants import ( @@ -22,15 +23,31 @@ PENALTY_LINE_Y_STEP_RATIO, PENALTY_MARK_HALF_FIELD_RATIO, ) -from utama_core.custom_referee.geometry import RefereeGeometry from utama_core.entities.data.command import RobotCommand from utama_core.entities.data.vector import Vector2D -from utama_core.global_utils.math_utils import ( +from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.geometry.math_utils import ( detour_around_circle, distance_point_to_segment, ) -from utama_core.shared.tolerance import Sticky -from utama_core.skills.src.utils.move_utils import empty_command, move, turn_on_spot +from utama_core.geometry.pass_and_score_geometry import ( + enemy_goal_line, + has_ball, + kick_bend, + open_teammate, + oriented_towards, + restart_support, +) +from utama_core.geometry.tolerance import Sticky +from utama_core.referee.geometry import RefereeGeometry +from utama_core.skills.man_mark import mark_target +from utama_core.skills.utils.move_utils import empty_command, kick, move, turn_on_spot + +_WALL_FROM_BALL_M = BALL_KEEP_OUT_DISTANCE + 0.15 +_STOP_FORMATION_SPEED_MPS = 1.2 # under RobotStopSpeedRule's limit +# A free kick's receiver stands waiting for a still ball: under 1 m it was received 53% of the time, +# as often as from 1.5 m to 2.5 m (2026-11-10), so restarts keep short passes that open play skips. +RESTART_MIN_TEAMMATE_M = 0.7 def _all_stop(blackboard) -> None: @@ -453,13 +470,19 @@ class StopStep: """Moves encroaching robots out of the keep-out radius and stops the rest.""" def update(self) -> None: + game = self.blackboard.game + next_is_theirs = _next_is_their_free_kick(game) _clear_to_legal_positions( self.blackboard, ball_keep_dist=BALL_KEEP_OUT_DISTANCE, clear_opp_defense_area=True, clear_own_defense_area=True, max_own_defenders=1, + intended_targets=their_free_kick_targets(game) if next_is_theirs else None, ) + if next_is_theirs: + for robot_id, command in self.blackboard.cmd_map.items(): + self.blackboard.cmd_map[robot_id] = _capped_speed(command, _STOP_FORMATION_SPEED_MPS) # --------------------------------------------------------------------------- @@ -978,11 +1001,16 @@ def update(self) -> None: class DirectFreeOursStep: - """Positions our robots for our direct free kick. + """Takes our direct free kick. - The robot closest to the ball becomes the kicker and approaches from the - field-inward side so it cannot push the ball out of bounds. - All other robots stop in place. + The robot closest to the ball becomes the kicker, gets behind it and kicks it + to an open teammate. With none in range the nearest teammate comes to a spot + towards the enemy goal first; only if there is no such spot does it shoot. All + other robots stop in place, the teammate being kicked to facing the ball. + + It used to stand behind the ball and leave the kick to the tactics once the + referee started play, which a real game controller does not do, and the taker + walked off or stood there for up to 10 s (round-robin of 2026-11-09). """ # How close the robot center should get behind the ball before turning/kicking. @@ -990,6 +1018,11 @@ class DirectFreeOursStep: _APPROACH_READY_DISTANCE = 0.04 _KICK_READY_DISTANCE = 0.16 _FACE_READY_ANGLE = 0.18 + # A receiver facing the ball within 10 degrees catches 95% of passes, 10-20 degrees 7%. + _RECEIVER_READY_ANGLE = 0.17 + _RECEIVER_AT_SPOT_M = 0.1 + _KEEP_OUT_EDGE_M = 0.05 + _NEW_RESTART_M = 0.05 # the ball this far from where the target was chosen is another free kick # Robot-body clearance only, not the full OPPONENT_DEFENSE_AREA_KEEP_ # DISTANCE (0.25m) `StopStep`/`_clear_to_legal_positions` use for general @@ -1026,21 +1059,38 @@ class DirectFreeOursStep: def __init__(self): self._kicker_sticky = Sticky[int](margin=self._KICKER_REASSIGN_MARGIN_M) + self._target: Optional[tuple[int, Vector2D, Optional[int], Optional[Vector2D], float]] = None @staticmethod def _angle_error(current: float, target: float) -> float: return math.atan2(math.sin(target - current), math.cos(target - current)) - def _nearest_enemy_to_ball(self, game, ball_pos: Vector2D): - if not game.enemy_robots: - return None, None - enemy_id = min(game.enemy_robots, key=lambda rid: game.enemy_robots[rid].p.distance_to(ball_pos)) - return enemy_id, game.enemy_robots[enemy_id] - - def _kick_target_enemy(self, game, ball_pos: Vector2D): - if 1 in game.enemy_robots: - return 1, game.enemy_robots[1] - return self._nearest_enemy_to_ball(game, ball_pos) + def _kick_target(self, game, kicker_id: int, ball_pos: Vector2D) -> tuple[Optional[int], Optional[Vector2D], float]: + """(teammate or None, the spot it must come to or None, heading from the ball). Chosen once a + free kick: a target flipping as lanes open and shut would send the kicker round the ball again. + Only the teammate is fixed: the heading follows it, once it is at any spot it was called to.""" + target = self._target + if target is None or target[0] != kicker_id or target[1].distance_to(ball_pos) > self._NEW_RESTART_M: + teammate = open_teammate(game, kicker_id, origin=ball_pos, min_distance=RESTART_MIN_TEAMMATE_M) + spot = None + if teammate is not None: + point = game.friendly_robots[teammate].p + else: + support = restart_support(game, kicker_id, ball_pos) + if support is not None: + teammate, spot = support + point = spot + else: + goal_x, goal_y1, goal_y2 = enemy_goal_line(game) + point = Vector2D(goal_x, (goal_y1 + goal_y2) / 2.0) + target = self._target = (kicker_id, ball_pos, teammate, spot, ball_pos.angle_to(point)) + teammate, spot, heading = target[2:] + if teammate in game.friendly_robots: + position = game.friendly_robots[teammate].p + if spot is None or position.distance_to(spot) <= self._RECEIVER_AT_SPOT_M: + # Who is fixed, where it stands is not: it has moved since, by 0.17 m at 2 m in a kick that missed. + heading = ball_pos.angle_to(position) + return teammate, spot, heading def update(self) -> None: game = self.blackboard.game @@ -1053,18 +1103,32 @@ def update(self) -> None: distances = {rid: game.friendly_robots[rid].p.distance_to(ball.p) for rid in game.friendly_robots} kicker_id = self._kicker_sticky.update(list(distances), score_fn=lambda rid: -distances[rid]) + receiver_command = None for robot_id in game.friendly_robots: if robot_id == kicker_id: robot = game.friendly_robots[robot_id] ball_pos = Vector2D(ball.p.x, ball.p.y) distance_to_ball = robot.p.distance_to(ball_pos) - _, enemy = self._kick_target_enemy(game, ball_pos) - - if enemy is None: - target_oren = robot.p.angle_to(ball_pos) - else: - target_oren = ball_pos.angle_to(enemy.p) + receiver_id, receiver_spot, kick_heading = self._kick_target(game, kicker_id, ball_pos) + target_oren = kick_heading - kick_bend(game, motion_controller, robot_id) + receiver_ready = True + if receiver_id in game.friendly_robots: + receiver = game.friendly_robots[receiver_id] + to_ball = receiver.p.angle_to(ball_pos) + if receiver_spot is not None and receiver.p.distance_to(receiver_spot) > self._RECEIVER_AT_SPOT_M: + receiver_ready = False + receiver_command = ( + receiver_id, + move(game, motion_controller, receiver_id, receiver_spot, receiver_spot.angle_to(ball_pos)), + ) + else: + receiver_ready = oriented_towards(game, receiver_id, to_ball, self._RECEIVER_READY_ANGLE) + if not receiver_ready: + receiver_command = ( + receiver_id, + turn_on_spot(game, motion_controller, receiver_id, to_ball), + ) kick_dir = Vector2D(math.cos(target_oren), math.sin(target_oren)) approach = Vector2D( @@ -1098,17 +1162,38 @@ def update(self) -> None: ) elif distance_to_ball > self._KICK_READY_DISTANCE: self.blackboard.cmd_map[robot_id] = move(game, motion_controller, robot_id, approach, target_oren) - else: + elif not receiver_ready: self.blackboard.cmd_map[robot_id] = empty_command(False) + elif has_ball(game, robot_id): + self.blackboard.cmd_map[robot_id] = kick() + else: + self.blackboard.cmd_map[robot_id] = move( + game, motion_controller, robot_id, ball_pos, target_oren, dribbling=True + ) + exempt = {kicker_id} + # A robot cleared in the stoppage stands a millimetre inside the circle, and clearing it again + # pointed it away from the ball: the receiver never turned and 69 free kicks timed out (2026-11-10). + if ( + receiver_command is not None + and BALL_KEEP_OUT_DISTANCE - self._KEEP_OUT_EDGE_M + <= distances[receiver_command[0]] + < BALL_KEEP_OUT_DISTANCE + ): + exempt.add(receiver_command[0]) _clear_to_legal_positions( self.blackboard, ball_keep_dist=BALL_KEEP_OUT_DISTANCE, clear_opp_defense_area=True, clear_own_defense_area=True, max_own_defenders=1, - exempt_robot_ids={kicker_id}, + exempt_robot_ids=exempt, ) + # That stops every robot already standing legally; this one still has to get ready. + if receiver_command is not None and ( + receiver_command[0] in exempt or self.blackboard.cmd_map[receiver_command[0]] == empty_command(False) + ): + self.blackboard.cmd_map[receiver_command[0]] = receiver_command[1] # --------------------------------------------------------------------------- @@ -1116,6 +1201,65 @@ def update(self) -> None: # --------------------------------------------------------------------------- +def _next_is_their_free_kick(game) -> bool: + command = getattr(game.referee, "next_command", None) + if game.my_team_is_yellow: + return command in (RefereeCommand.DIRECT_FREE_BLUE, RefereeCommand.INDIRECT_FREE_BLUE) + return command in (RefereeCommand.DIRECT_FREE_YELLOW, RefereeCommand.INDIRECT_FREE_YELLOW) + + +def their_free_kick_targets(game) -> dict[int, Vector2D]: + """Where to stand for an opponent's free kick: the nearest robot in the wall on the ball's line + to our goal, and each other one goal-side of a receiver, those nearest our goal first. Standing + wherever the stop left them, a side conceded 1.35 goals a match from free kicks (`docs/signals.md`). + The keeper keeps its own job.""" + ball = game.ball + if ball is None: + return {} + ref = game.referee + keeper_id = (ref.yellow_team if game.my_team_is_yellow else ref.blue_team).goalkeeper + ball_pos = Vector2D(ball.p.x, ball.p.y) + free = { + rid: robot.p + for rid, robot in game.friendly_robots.items() + if rid != keeper_id and not _must_clear_first(game, robot.p, ball_pos) + } + if not free: + return {} + goal = Vector2D(float(game.field.my_goal_line[0][0]), 0.0) + wall = _outside_own_defense_area(game, ball_pos + (goal - ball_pos).norm() * _WALL_FROM_BALL_M) + targets: dict[int, Vector2D] = {} + wall_robot = min(free, key=lambda rid: free[rid].distance_to(wall)) + targets[wall_robot] = wall + del free[wall_robot] + + enemies = sorted(game.enemy_robots, key=lambda eid: game.enemy_robots[eid].p.distance_to(ball_pos))[1:] + enemies.sort(key=lambda eid: game.enemy_robots[eid].p.distance_to(goal)) + for enemy_id in enemies: + if not free: + break + mark = _outside_own_defense_area(game, mark_target(game, enemy_id)) + marker = min(free, key=lambda rid: free[rid].distance_to(mark)) + targets[marker] = mark + del free[marker] + return targets + + +def _must_clear_first(game, position: Vector2D, ball_pos: Vector2D) -> bool: + """Inside the keep-out circle or a defense area: on its way out before it takes up a spot.""" + return ( + position.distance_to(ball_pos) < BALL_KEEP_OUT_DISTANCE + or _is_in_own_defense_area(game, position.x, position.y) + or _project_outside_opp_defense_area(game, position, OPPONENT_DEFENSE_AREA_KEEP_DISTANCE) != position + ) + + +def _outside_own_defense_area(game, point: Vector2D) -> Vector2D: + return ( + Vector2D(_own_defense_area_exit_x(game), point.y) if _is_in_own_defense_area(game, point.x, point.y) else point + ) + + class DirectFreeTheirsStep: """Actively clear our robots out of the ball keep-out radius and defense areas.""" @@ -1126,4 +1270,5 @@ def update(self) -> None: clear_opp_defense_area=True, clear_own_defense_area=True, max_own_defenders=1, + intended_targets=their_free_kick_targets(self.blackboard.game), ) diff --git a/utama_core/custom_referee/custom_referee.py b/utama_core/referee/custom_referee.py similarity index 93% rename from utama_core/custom_referee/custom_referee.py rename to utama_core/referee/custom_referee.py index 4fc33cdcd..4a5836f4d 100644 --- a/utama_core/custom_referee/custom_referee.py +++ b/utama_core/referee/custom_referee.py @@ -6,37 +6,30 @@ from typing import List, Optional from utama_core.config.field_params import STANDARD_FIELD_DIMS -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.profiles.profile_loader import ( - RefereeProfile, - load_profile, -) -from utama_core.custom_referee.rules.ball_placement_interference_rule import ( - BallPlacementInterferenceRule, -) -from utama_core.custom_referee.rules.ball_speed_rule import BallSpeedRule -from utama_core.custom_referee.rules.base_rule import BaseRule, RuleViolation -from utama_core.custom_referee.rules.crashing_rule import CrashingRule -from utama_core.custom_referee.rules.defense_area_rule import DefenseAreaRule -from utama_core.custom_referee.rules.defense_area_stoppage_rule import ( - DefenseAreaStoppageRule, -) -from utama_core.custom_referee.rules.double_touch_rule import DoubleTouchRule -from utama_core.custom_referee.rules.excessive_dribbling_rule import ( - ExcessiveDribblingRule, -) -from utama_core.custom_referee.rules.goal_rule import GoalRule -from utama_core.custom_referee.rules.keep_out_rule import KeepOutRule -from utama_core.custom_referee.rules.keeper_held_ball_rule import KeeperHeldBallRule -from utama_core.custom_referee.rules.no_progress_rule import NoProgressRule -from utama_core.custom_referee.rules.out_of_bounds_rule import OutOfBoundsRule -from utama_core.custom_referee.rules.penalty_time_limit_rule import PenaltyTimeLimitRule -from utama_core.custom_referee.rules.pushing_rule import PushingRule -from utama_core.custom_referee.rules.robot_stop_speed_rule import RobotStopSpeedRule -from utama_core.custom_referee.state_machine import GameStateMachine from utama_core.entities.data.referee import RefereeData from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.profiles.profile_loader import RefereeProfile, load_profile +from utama_core.referee.rules.ball_placement_interference_rule import ( + BallPlacementInterferenceRule, +) +from utama_core.referee.rules.ball_speed_rule import BallSpeedRule +from utama_core.referee.rules.base_rule import BaseRule, RuleViolation +from utama_core.referee.rules.crashing_rule import CrashingRule +from utama_core.referee.rules.defense_area_rule import DefenseAreaRule +from utama_core.referee.rules.defense_area_stoppage_rule import DefenseAreaStoppageRule +from utama_core.referee.rules.double_touch_rule import DoubleTouchRule +from utama_core.referee.rules.excessive_dribbling_rule import ExcessiveDribblingRule +from utama_core.referee.rules.goal_rule import GoalRule +from utama_core.referee.rules.keep_out_rule import KeepOutRule +from utama_core.referee.rules.keeper_held_ball_rule import KeeperHeldBallRule +from utama_core.referee.rules.no_progress_rule import NoProgressRule +from utama_core.referee.rules.out_of_bounds_rule import OutOfBoundsRule +from utama_core.referee.rules.penalty_time_limit_rule import PenaltyTimeLimitRule +from utama_core.referee.rules.pushing_rule import PushingRule +from utama_core.referee.rules.robot_stop_speed_rule import RobotStopSpeedRule +from utama_core.referee.state_machine import GameStateMachine # SSL rulebook §7: no goal if the scoring team committed a non-stopping foul # in the last two seconds before the ball entered the goal. diff --git a/utama_core/custom_referee/geometry.py b/utama_core/referee/geometry.py similarity index 100% rename from utama_core/custom_referee/geometry.py rename to utama_core/referee/geometry.py diff --git a/utama_core/referee/profiles/__init__.py b/utama_core/referee/profiles/__init__.py new file mode 100644 index 000000000..363d3f83b --- /dev/null +++ b/utama_core/referee/profiles/__init__.py @@ -0,0 +1,3 @@ +from utama_core.referee.profiles.profile_loader import load_profile + +__all__ = ["load_profile"] diff --git a/utama_core/custom_referee/profiles/human.yaml b/utama_core/referee/profiles/human.yaml similarity index 100% rename from utama_core/custom_referee/profiles/human.yaml rename to utama_core/referee/profiles/human.yaml diff --git a/utama_core/custom_referee/profiles/profile_loader.py b/utama_core/referee/profiles/profile_loader.py similarity index 100% rename from utama_core/custom_referee/profiles/profile_loader.py rename to utama_core/referee/profiles/profile_loader.py diff --git a/utama_core/custom_referee/profiles/simulation.yaml b/utama_core/referee/profiles/simulation.yaml similarity index 98% rename from utama_core/custom_referee/profiles/simulation.yaml rename to utama_core/referee/profiles/simulation.yaml index 30b6a600c..cda81c2b9 100644 --- a/utama_core/custom_referee/profiles/simulation.yaml +++ b/utama_core/referee/profiles/simulation.yaml @@ -64,7 +64,7 @@ game: stop_to_next_command: true # STOP → queued restart when all robots clear prepare_kickoff_to_normal: true # PREPARE_KICKOFF_* → NORMAL_START when kicker in circle prepare_penalty_to_normal: true # PREPARE_PENALTY_* → NORMAL_START when kicker reaches the mark - direct_free_to_normal: true # DIRECT_FREE_* → NORMAL_START when kicker ready + direct_free_to_normal: true # DIRECT_FREE_* → NORMAL_START when the kick is taken ball_placement_to_next: true # BALL_PLACEMENT_* → next_command when ball at target normal_start_to_force: true # NORMAL_START → FORCE_START on kickoff timeout end_of_half: true # half's playing time up → second half, then POST_GAME diff --git a/utama_core/referee/rules/__init__.py b/utama_core/referee/rules/__init__.py new file mode 100644 index 000000000..6cc236cf9 --- /dev/null +++ b/utama_core/referee/rules/__init__.py @@ -0,0 +1,14 @@ +from utama_core.referee.rules.base_rule import BaseRule, RuleViolation +from utama_core.referee.rules.defense_area_rule import DefenseAreaRule +from utama_core.referee.rules.goal_rule import GoalRule +from utama_core.referee.rules.keep_out_rule import KeepOutRule +from utama_core.referee.rules.out_of_bounds_rule import OutOfBoundsRule + +__all__ = [ + "BaseRule", + "RuleViolation", + "GoalRule", + "OutOfBoundsRule", + "DefenseAreaRule", + "KeepOutRule", +] diff --git a/utama_core/custom_referee/rules/ball_placement_interference_rule.py b/utama_core/referee/rules/ball_placement_interference_rule.py similarity index 96% rename from utama_core/custom_referee/rules/ball_placement_interference_rule.py rename to utama_core/referee/rules/ball_placement_interference_rule.py index 01aa7b791..0070cefe0 100644 --- a/utama_core/custom_referee/rules/ball_placement_interference_rule.py +++ b/utama_core/referee/rules/ball_placement_interference_rule.py @@ -26,11 +26,11 @@ from typing import Optional -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.base_rule import BaseRule, RuleViolation from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.global_utils.math_utils import distance_point_to_segment +from utama_core.geometry.math_utils import distance_point_to_segment +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.base_rule import BaseRule, RuleViolation _BALL_PLACEMENT_COMMANDS = { RefereeCommand.BALL_PLACEMENT_YELLOW, diff --git a/utama_core/custom_referee/rules/ball_speed_rule.py b/utama_core/referee/rules/ball_speed_rule.py similarity index 73% rename from utama_core/custom_referee/rules/ball_speed_rule.py rename to utama_core/referee/rules/ball_speed_rule.py index 173ce0408..edeca87ba 100644 --- a/utama_core/custom_referee/rules/ball_speed_rule.py +++ b/utama_core/referee/rules/ball_speed_rule.py @@ -5,11 +5,16 @@ import math from typing import Optional -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.base_rule import BaseRule, RuleViolation -from utama_core.custom_referee.rules.last_touch import infer_last_touch_team from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.base_rule import BaseRule, RuleViolation +from utama_core.referee.rules.last_touch import infer_last_touch_team + +# Frames in a row over the limit before it counts. 67-91% of the calls in the round-robins of +# 2026-11-09 were one frame, up to 39 m/s, with the robot's kick at a median 5.3 m/s: vision noise +# in the ball's velocity, not a kick. +_FRAMES_OVER_LIMIT = 2 _ACTIVE_PLAY_COMMANDS = { RefereeCommand.NORMAL_START, @@ -24,14 +29,14 @@ class BallSpeedRule(BaseRule): Only the ball's ground speed (x/y) counts — a bounce's z-velocity is not part of the kick-speed rule and would otherwise cause false positives. - Edge-detected: fires once when the ball crosses above the limit, not - every frame it remains fast, mirroring how a real kick is a single - event rather than a sustained state. + Fires once when the ball has been over the limit for `_FRAMES_OVER_LIMIT` + frames in a row, not every frame it remains fast, mirroring how a real + kick is a single event rather than a sustained state. """ def __init__(self, max_speed_mps: float = 6.5) -> None: self._max_speed = max_speed_mps - self._was_over_limit = False + self._frames_over_limit = 0 # True = friendly last touched, False = enemy, None = unknown. # Maintained colour-blind by `infer_last_touch_team` (see last_touch.py). self._last_touch_was_friendly: Optional[bool] = None @@ -46,7 +51,7 @@ def check( designated_position: Optional[tuple[float, float]] = None, ) -> Optional[RuleViolation]: if current_command not in _ACTIVE_PLAY_COMMANDS: - self._was_over_limit = False + self._frames_over_limit = 0 self._prev_ball_v = None # the ball may be moved or placed while play is stopped return None @@ -60,11 +65,9 @@ def check( self._prev_ball_v = (ball.v.x, ball.v.y) speed = math.hypot(ball.v.x, ball.v.y) - is_over_limit = speed > self._max_speed - rising_edge = is_over_limit and not self._was_over_limit - self._was_over_limit = is_over_limit + self._frames_over_limit = self._frames_over_limit + 1 if speed > self._max_speed else 0 - if not rising_edge or self._last_touch_was_friendly is None: + if self._frames_over_limit != _FRAMES_OVER_LIMIT or self._last_touch_was_friendly is None: return None # SSL rulebook §8.4.2 "Ball Speed" is a non-stopping foul: the kicking @@ -82,5 +85,5 @@ def check( ) def reset(self) -> None: - self._was_over_limit = False + self._frames_over_limit = 0 self._last_touch_was_friendly = None diff --git a/utama_core/custom_referee/rules/base_rule.py b/utama_core/referee/rules/base_rule.py similarity index 98% rename from utama_core/custom_referee/rules/base_rule.py rename to utama_core/referee/rules/base_rule.py index dd1186766..439272718 100644 --- a/utama_core/custom_referee/rules/base_rule.py +++ b/utama_core/referee/rules/base_rule.py @@ -6,9 +6,9 @@ from dataclasses import dataclass from typing import Optional -from utama_core.custom_referee.geometry import RefereeGeometry from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.geometry import RefereeGeometry @dataclass(frozen=True) diff --git a/utama_core/custom_referee/rules/crashing_rule.py b/utama_core/referee/rules/crashing_rule.py similarity index 97% rename from utama_core/custom_referee/rules/crashing_rule.py rename to utama_core/referee/rules/crashing_rule.py index cb359b6c8..b9b52e042 100644 --- a/utama_core/custom_referee/rules/crashing_rule.py +++ b/utama_core/referee/rules/crashing_rule.py @@ -33,11 +33,11 @@ import math from typing import Optional -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.base_rule import BaseRule, RuleViolation -from utama_core.custom_referee.rules.robot_contact import find_robot_pair_contacts from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.base_rule import BaseRule, RuleViolation +from utama_core.referee.rules.robot_contact import find_robot_pair_contacts _ACTIVE_PLAY_COMMANDS = { RefereeCommand.NORMAL_START, diff --git a/utama_core/custom_referee/rules/defense_area_rule.py b/utama_core/referee/rules/defense_area_rule.py similarity index 98% rename from utama_core/custom_referee/rules/defense_area_rule.py rename to utama_core/referee/rules/defense_area_rule.py index 1c9127b32..f618359e2 100644 --- a/utama_core/custom_referee/rules/defense_area_rule.py +++ b/utama_core/referee/rules/defense_area_rule.py @@ -7,11 +7,11 @@ from utama_core.config.physical_constants import ROBOT_RADIUS from utama_core.config.referee_constants import PENALTY_MARK_HALF_FIELD_RATIO -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.base_rule import BaseRule, RuleViolation from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.game.robot import Robot from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.base_rule import BaseRule, RuleViolation # Contact distance for "this defender is the one who touched the ball" — diff --git a/utama_core/custom_referee/rules/defense_area_stoppage_rule.py b/utama_core/referee/rules/defense_area_stoppage_rule.py similarity index 98% rename from utama_core/custom_referee/rules/defense_area_stoppage_rule.py rename to utama_core/referee/rules/defense_area_stoppage_rule.py index 87101cafe..ac1eea5eb 100644 --- a/utama_core/custom_referee/rules/defense_area_stoppage_rule.py +++ b/utama_core/referee/rules/defense_area_stoppage_rule.py @@ -24,10 +24,10 @@ from typing import Optional -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.base_rule import BaseRule, RuleViolation from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.base_rule import BaseRule, RuleViolation # "Before the ball has entered play" — STOP itself, plus a free kick that # hasn't yet transitioned to NORMAL_START. Kickoff/penalty prepare commands diff --git a/utama_core/custom_referee/rules/double_touch_rule.py b/utama_core/referee/rules/double_touch_rule.py similarity index 86% rename from utama_core/custom_referee/rules/double_touch_rule.py rename to utama_core/referee/rules/double_touch_rule.py index ac052f275..71d822f9e 100644 --- a/utama_core/custom_referee/rules/double_touch_rule.py +++ b/utama_core/referee/rules/double_touch_rule.py @@ -15,10 +15,10 @@ from utama_core.config.physical_constants import BALL_RADIUS, ROBOT_RADIUS from utama_core.config.referee_constants import OPPONENT_DEFENSE_AREA_KEEP_DISTANCE -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.base_rule import BaseRule, RuleViolation from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.base_rule import BaseRule, RuleViolation # Commands whose transition into NORMAL_START starts a restart-kick window. _RESTART_COMMANDS = frozenset( @@ -82,6 +82,9 @@ def __init__(self) -> None: self._kicker: Optional[RobotKey] = None self._kicking_team_is_yellow: Optional[bool] = None self._had_ball_last_frame: set[RobotKey] = set() + # The kicking team's robot on the ball while the restart was still being prepared. A free + # kick is struck under DIRECT_FREE_*: it is the kicker, not the first robot to receive it. + self._restart_toucher: Optional[RobotKey] = None def check( self, @@ -90,15 +93,20 @@ def check( current_command: RefereeCommand, designated_position: Optional[tuple[float, float]] = None, ) -> Optional[RuleViolation]: + if current_command in _RESTART_COMMANDS: + self._restart_toucher = self._toucher_of_kicking_team(game_frame, current_command) or self._restart_toucher if current_command == RefereeCommand.NORMAL_START and self._prev_command in _RESTART_COMMANDS: self._armed = True - self._kicker = None + self._kicker = self._restart_toucher self._kicking_team_is_yellow = self._prev_command in _YELLOW_RESTARTS - self._had_ball_last_frame = set() + # Still in contact at the changeover is the same touch, not a second one. + self._had_ball_last_frame = {self._kicker} if self._kicker is not None else set() elif current_command != RefereeCommand.NORMAL_START: self._armed = False self._kicker = None + if current_command not in _RESTART_COMMANDS: + self._restart_toucher = None self._prev_command = current_command if not self._armed: @@ -144,6 +152,12 @@ def check( return violation + @staticmethod + def _toucher_of_kicking_team(game_frame: GameFrame, command: RefereeCommand) -> Optional[RobotKey]: + is_friendly = game_frame.my_team_is_yellow == (command in _YELLOW_RESTARTS) + robots = game_frame.friendly_robots if is_friendly else game_frame.enemy_robots + return next(((is_friendly, robot.id) for robot in robots.values() if robot.has_ball), None) + def _other_robot_touching(self, game_frame: GameFrame) -> bool: ball = game_frame.ball if ball is None: @@ -169,6 +183,7 @@ def reset(self) -> None: def reset_for_new_episode(self) -> None: self.reset() self._prev_command = None + self._restart_toucher = None def _violation_for(self, kicker: RobotKey, game_frame: GameFrame, geometry: RefereeGeometry) -> RuleViolation: kicker_is_friendly, kicker_id = kicker diff --git a/utama_core/custom_referee/rules/excessive_dribbling_rule.py b/utama_core/referee/rules/excessive_dribbling_rule.py similarity index 97% rename from utama_core/custom_referee/rules/excessive_dribbling_rule.py rename to utama_core/referee/rules/excessive_dribbling_rule.py index 6d2af57b2..a0dcec2a5 100644 --- a/utama_core/custom_referee/rules/excessive_dribbling_rule.py +++ b/utama_core/referee/rules/excessive_dribbling_rule.py @@ -21,10 +21,10 @@ from typing import Optional from utama_core.config.referee_constants import OPPONENT_DEFENSE_AREA_KEEP_DISTANCE -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.base_rule import BaseRule, RuleViolation from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.base_rule import BaseRule, RuleViolation _ACTIVE_PLAY_COMMANDS = { RefereeCommand.NORMAL_START, diff --git a/utama_core/custom_referee/rules/goal_rule.py b/utama_core/referee/rules/goal_rule.py similarity index 96% rename from utama_core/custom_referee/rules/goal_rule.py rename to utama_core/referee/rules/goal_rule.py index 932e83458..aecea0ea0 100644 --- a/utama_core/custom_referee/rules/goal_rule.py +++ b/utama_core/referee/rules/goal_rule.py @@ -5,10 +5,10 @@ import math from typing import Optional -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.base_rule import BaseRule, RuleViolation from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.base_rule import BaseRule, RuleViolation # Commands that represent active play — goal detection is only relevant here. _ACTIVE_PLAY_COMMANDS = { diff --git a/utama_core/custom_referee/rules/keep_out_rule.py b/utama_core/referee/rules/keep_out_rule.py similarity index 90% rename from utama_core/custom_referee/rules/keep_out_rule.py rename to utama_core/referee/rules/keep_out_rule.py index e676d033e..864df776e 100644 --- a/utama_core/custom_referee/rules/keep_out_rule.py +++ b/utama_core/referee/rules/keep_out_rule.py @@ -5,10 +5,10 @@ import math from typing import Optional # used by BaseRule.check return type -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.base_rule import BaseRule, RuleViolation from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.base_rule import BaseRule, RuleViolation # §8.4.3 applies "during an opponent kick-off or free kick" only. STOP carries # "no automatic sanction" for being too close, and a robot out of position at a @@ -30,9 +30,8 @@ class KeepOutRule(BaseRule): keep-out radius of the ball during the other team's kick-off or free kick. Non-stopping: the rulebook's sanction is a foul-counter increment and a reset of - the kicking team's timer, not a stop. The timer reset needs nothing here: the - state machine only counts down a free kick or kick-off once every defender is - clear (`_free_kick_ready`), so an encroaching defender already holds it back. + the kicking team's timer, not a stop: the state machine restarts the free kick's + clock from the foul. Stopping play and re-awarding the free kick, as this rule used to, voided the restart -- in sim straight into a FORCE_START scramble. diff --git a/utama_core/custom_referee/rules/keeper_held_ball_rule.py b/utama_core/referee/rules/keeper_held_ball_rule.py similarity index 97% rename from utama_core/custom_referee/rules/keeper_held_ball_rule.py rename to utama_core/referee/rules/keeper_held_ball_rule.py index a8114243f..6d45b4584 100644 --- a/utama_core/custom_referee/rules/keeper_held_ball_rule.py +++ b/utama_core/referee/rules/keeper_held_ball_rule.py @@ -15,10 +15,10 @@ from typing import Optional from utama_core.config.referee_constants import OPPONENT_DEFENSE_AREA_KEEP_DISTANCE -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.base_rule import BaseRule, RuleViolation from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.base_rule import BaseRule, RuleViolation _ACTIVE_PLAY_COMMANDS = { RefereeCommand.NORMAL_START, diff --git a/utama_core/custom_referee/rules/last_touch.py b/utama_core/referee/rules/last_touch.py similarity index 100% rename from utama_core/custom_referee/rules/last_touch.py rename to utama_core/referee/rules/last_touch.py diff --git a/utama_core/custom_referee/rules/no_progress_rule.py b/utama_core/referee/rules/no_progress_rule.py similarity index 96% rename from utama_core/custom_referee/rules/no_progress_rule.py rename to utama_core/referee/rules/no_progress_rule.py index 3a1af1ea6..d8eff43b4 100644 --- a/utama_core/custom_referee/rules/no_progress_rule.py +++ b/utama_core/referee/rules/no_progress_rule.py @@ -21,10 +21,10 @@ from typing import Optional from utama_core.config.referee_constants import OPPONENT_DEFENSE_AREA_KEEP_DISTANCE -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.base_rule import BaseRule, RuleViolation from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.base_rule import BaseRule, RuleViolation _ACTIVE_PLAY_COMMANDS = { RefereeCommand.NORMAL_START, diff --git a/utama_core/custom_referee/rules/out_of_bounds_rule.py b/utama_core/referee/rules/out_of_bounds_rule.py similarity index 98% rename from utama_core/custom_referee/rules/out_of_bounds_rule.py rename to utama_core/referee/rules/out_of_bounds_rule.py index e78049f47..03c039460 100644 --- a/utama_core/custom_referee/rules/out_of_bounds_rule.py +++ b/utama_core/referee/rules/out_of_bounds_rule.py @@ -6,15 +6,15 @@ from typing import Optional from utama_core.config.referee_constants import OPPONENT_DEFENSE_AREA_KEEP_DISTANCE -from utama_core.custom_referee.geometry import CORNER_INFIELD_OFFSET, RefereeGeometry -from utama_core.custom_referee.rules.base_rule import BaseRule, RuleViolation -from utama_core.custom_referee.rules.last_touch import ( +from utama_core.entities.game.game_frame import GameFrame +from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.geometry import CORNER_INFIELD_OFFSET, RefereeGeometry +from utama_core.referee.rules.base_rule import BaseRule, RuleViolation +from utama_core.referee.rules.last_touch import ( infer_last_touch_team, touching_robot, touching_team, ) -from utama_core.entities.game.game_frame import GameFrame -from utama_core.entities.referee.referee_command import RefereeCommand _ACTIVE_PLAY_COMMANDS = { RefereeCommand.NORMAL_START, diff --git a/utama_core/custom_referee/rules/penalty_time_limit_rule.py b/utama_core/referee/rules/penalty_time_limit_rule.py similarity index 96% rename from utama_core/custom_referee/rules/penalty_time_limit_rule.py rename to utama_core/referee/rules/penalty_time_limit_rule.py index 93ae04cf6..e86c96a65 100644 --- a/utama_core/custom_referee/rules/penalty_time_limit_rule.py +++ b/utama_core/referee/rules/penalty_time_limit_rule.py @@ -10,10 +10,10 @@ from typing import Optional -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.base_rule import BaseRule, RuleViolation from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.base_rule import BaseRule, RuleViolation _ACTIVE_PLAY_COMMANDS = { RefereeCommand.NORMAL_START, diff --git a/utama_core/custom_referee/rules/pushing_rule.py b/utama_core/referee/rules/pushing_rule.py similarity index 97% rename from utama_core/custom_referee/rules/pushing_rule.py rename to utama_core/referee/rules/pushing_rule.py index 238b8aba8..78a1779dd 100644 --- a/utama_core/custom_referee/rules/pushing_rule.py +++ b/utama_core/referee/rules/pushing_rule.py @@ -17,11 +17,11 @@ from typing import Optional from utama_core.config.referee_constants import OPPONENT_DEFENSE_AREA_KEEP_DISTANCE -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.base_rule import BaseRule, RuleViolation -from utama_core.custom_referee.rules.robot_contact import find_robot_pair_contacts from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.base_rule import BaseRule, RuleViolation +from utama_core.referee.rules.robot_contact import find_robot_pair_contacts _ACTIVE_PLAY_COMMANDS = { RefereeCommand.NORMAL_START, diff --git a/utama_core/custom_referee/rules/robot_contact.py b/utama_core/referee/rules/robot_contact.py similarity index 100% rename from utama_core/custom_referee/rules/robot_contact.py rename to utama_core/referee/rules/robot_contact.py diff --git a/utama_core/custom_referee/rules/robot_stop_speed_rule.py b/utama_core/referee/rules/robot_stop_speed_rule.py similarity index 97% rename from utama_core/custom_referee/rules/robot_stop_speed_rule.py rename to utama_core/referee/rules/robot_stop_speed_rule.py index ebacd669a..c1caa76ff 100644 --- a/utama_core/custom_referee/rules/robot_stop_speed_rule.py +++ b/utama_core/referee/rules/robot_stop_speed_rule.py @@ -29,10 +29,10 @@ from typing import Optional from utama_core.config.referee_constants import BALL_KEEP_OUT_DISTANCE -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.base_rule import BaseRule, RuleViolation from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.base_rule import BaseRule, RuleViolation class RobotStopSpeedRule(BaseRule): diff --git a/utama_core/custom_referee/state_machine.py b/utama_core/referee/state_machine.py similarity index 94% rename from utama_core/custom_referee/state_machine.py rename to utama_core/referee/state_machine.py index 7c8bfb1d5..d46b9b42a 100644 --- a/utama_core/custom_referee/state_machine.py +++ b/utama_core/referee/state_machine.py @@ -10,14 +10,14 @@ from utama_core.config.field_params import STANDARD_FIELD_DIMS from utama_core.config.physical_constants import ROBOT_RADIUS from utama_core.config.referee_constants import PENALTY_MARK_HALF_FIELD_RATIO -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.profiles.profile_loader import AutoAdvanceConfig -from utama_core.custom_referee.rules.base_rule import RuleViolation from utama_core.entities.data.referee import RefereeData from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.game.team_info import TeamInfo from utama_core.entities.referee.referee_command import CLOCK_RUNS, RefereeCommand from utama_core.entities.referee.stage import Stage +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.profiles.profile_loader import AutoAdvanceConfig +from utama_core.referee.rules.base_rule import RuleViolation logger = logging.getLogger(__name__) @@ -188,7 +188,6 @@ def _reset_state(self) -> None: # Timestamps for sustained-readiness countdown before play-starting advances. # Set to math.inf when condition is not yet met; fire when elapsed >= _AUTO_ADVANCE_DELAY. self._advance2_ready_since: float = math.inf # PREPARE_* → NORMAL_START - self._advance3_ready_since: float = math.inf # DIRECT_FREE_* → NORMAL_START self._advance4_ready_since: float = math.inf # BALL_PLACEMENT_* → next_command # First Defender Too Close foul of the current free kick; restarts its clock. self._defender_too_close_at: float = -math.inf @@ -303,7 +302,6 @@ def step( self._advance4_ready_since = math.inf elif self.command in self._DIRECT_FREE_COMMANDS: self.next_command = RefereeCommand.NORMAL_START - self._advance3_ready_since = math.inf elif self.command in self._PREPARE_KICKOFF_COMMANDS or self.command in self._PREPARE_PENALTY_COMMANDS: self.next_command = RefereeCommand.NORMAL_START self._prepare_entered_time = current_time @@ -389,13 +387,10 @@ def step( self._advance2_ready_since = math.inf # ---------------------------------------------------------------- - # Auto-advance 3: DIRECT_FREE_* → NORMAL_START - # Fires when the kicker is within _KICKER_READY_DIST of the ball - # AND all defending robots are ≥ _BALL_CLEAR_DIST away, sustained - # for _AUTO_ADVANCE_DELAY seconds. + # Auto-advance 3: DIRECT_FREE_* → NORMAL_START once the kick is taken, + # FORCE_START if it is not within the time limit. # ---------------------------------------------------------------- elif self._auto_advance.direct_free_to_normal and self.command in self._DIRECT_FREE_COMMANDS: - ready = game_frame is not None and self._free_kick_ready(self.command, game_frame) kick_clock_start = max(self.command_timestamp, self._defender_too_close_at) if self._free_kick_taken(game_frame): # The kicker has kicked: the ball is in play, as after the kick of a ready free kick @@ -409,17 +404,7 @@ def step( self.command_timestamp = current_time self.next_command = None self.status_message = None - self._advance3_ready_since = math.inf self._last_transition_time = current_time - elif ready: - if self._advance3_ready_since == math.inf: - self._advance3_ready_since = current_time - logger.debug("Advance 3 countdown started (%s)", self.command.name) - elif (current_time - self._advance3_ready_since) >= _AUTO_ADVANCE_DELAY: - logger.info("Free kick ready — auto-advancing %s → NORMAL_START", self.command.name) - self._start_normal_play(current_time, game_frame) - else: - self._advance3_ready_since = math.inf # ---------------------------------------------------------------- # Auto-advance 4: BALL_PLACEMENT_* → next_command @@ -617,34 +602,6 @@ def _penalty_kicker_ready(self, command: RefereeCommand, game_frame: "GameFrame" closest = min(math.hypot(robot.p.x - penalty_mark_x, robot.p.y) for robot in attackers.values()) return closest <= _KICKER_READY_DIST - def _free_kick_ready(self, command: RefereeCommand, game_frame: "GameFrame") -> bool: - """Return True when a free kick is ready to start: - - The kicker (closest attacker to ball) is within _KICKER_READY_DIST of the ball. - - All defending robots are ≥ _BALL_CLEAR_DIST from the ball. - """ - ball = game_frame.ball - if ball is None: - return False - bx, by = ball.p.x, ball.p.y - - kicking_is_yellow = command == RefereeCommand.DIRECT_FREE_YELLOW - attackers = ( - game_frame.friendly_robots if kicking_is_yellow == game_frame.my_team_is_yellow else game_frame.enemy_robots - ) - defenders = ( - game_frame.enemy_robots if kicking_is_yellow == game_frame.my_team_is_yellow else game_frame.friendly_robots - ) - - # Check defending robots are all clear. - if any(math.hypot(r.p.x - bx, r.p.y - by) < _BALL_CLEAR_DIST for r in defenders.values()): - return False - - # Check at least one attacker is close to the ball (kicker in position). - if not attackers: - return False - closest = min(math.hypot(r.p.x - bx, r.p.y - by) for r in attackers.values()) - return closest <= _KICKER_READY_DIST - def _ball_has_moved(self, game_frame: "GameFrame") -> bool: """Return True if the ball has moved ≥ 0.05 m since NORMAL_START.""" if self._ball_pos_at_normal_start is None or game_frame.ball is None: @@ -666,8 +623,8 @@ def _ball_xy(game_frame: Optional["GameFrame"]) -> Optional[tuple[float, float]] return (game_frame.ball.p.x, game_frame.ball.p.y) def _start_normal_play(self, current_time: float, game_frame: "GameFrame") -> None: - """DIRECT_FREE_* → NORMAL_START (the kicker was ready, or the ball has been kicked): the ball - is in play, and NORMAL_START's own timeout measures from here.""" + """DIRECT_FREE_* → NORMAL_START (the ball has been kicked): the ball is in play, and + NORMAL_START's own timeout measures from here.""" self.command = RefereeCommand.NORMAL_START self.command_counter += 1 self.command_timestamp = current_time @@ -675,7 +632,6 @@ def _start_normal_play(self, current_time: float, game_frame: "GameFrame") -> No self.status_message = None self._normal_start_time = current_time self._ball_pos_at_normal_start = self._ball_xy(game_frame) - self._advance3_ready_since = math.inf self._last_transition_time = current_time def _ball_placement_done(self, game_frame: "GameFrame") -> bool: @@ -698,7 +654,6 @@ def _advance_past_ball_placement(self, current_time: float) -> None: self.command_timestamp = current_time if completed_command in self._DIRECT_FREE_COMMANDS: self.next_command = RefereeCommand.NORMAL_START - self._advance3_ready_since = math.inf elif completed_command in self._PREPARE_KICKOFF_COMMANDS or completed_command in self._PREPARE_PENALTY_COMMANDS: self.next_command = RefereeCommand.NORMAL_START self._prepare_entered_time = current_time @@ -818,7 +773,6 @@ def set_command(self, command: RefereeCommand, timestamp: float) -> None: self._post_ball_placement_command = None self.status_message = None self._advance2_ready_since = math.inf - self._advance3_ready_since = math.inf self._advance4_ready_since = math.inf if command in (RefereeCommand.STOP, RefereeCommand.HALT): @@ -852,7 +806,6 @@ def force_command( self._post_ball_placement_command = None self.status_message = None self._advance2_ready_since = math.inf - self._advance3_ready_since = math.inf self._advance4_ready_since = math.inf if ball_placement_target is not None: self.ball_placement_target = ball_placement_target @@ -874,7 +827,6 @@ def resume_from_halt(self, timestamp: float) -> bool: self._stop_entered_time = timestamp self.status_message = None self._advance2_ready_since = math.inf - self._advance3_ready_since = math.inf self._advance4_ready_since = math.inf logger.info("Resuming from HALT (queued: %s)", self.next_command.name if self.next_command else "None") return self.next_command in self._NEEDS_STOP_FIRST or self.next_command == RefereeCommand.FORCE_START diff --git a/utama_core/replay/eval_ledger.py b/utama_core/replay/eval_ledger.py deleted file mode 100644 index 96cc56275..000000000 --- a/utama_core/replay/eval_ledger.py +++ /dev/null @@ -1,100 +0,0 @@ -"""Every evaluation match's result, in one append-only file, for ratings across runs. - -`tools/evaluation/evaluate.py` and `round_robin.py` append one JSON line per match they play: -the environment it ran in, both sides with the fingerprint of their code, the noise seed, the -score and the shots. A rating fit reads back the matches of one environment, so each result -counts in every later evaluation until the code that played it changes. - -- **Environment** (`environment`): the shared code and machine (`fingerprint.base_fingerprint` - of the match runner), the match length, the planner and the sim noise without its seed. - Matches from different environments are never mixed: a planner or sim change replays all. -- **Player**: a strategy name and its `fingerprint.strategy_fingerprint`. Editing a strategy - makes it a new player; its old matches stay in the file but no longer count. -- **Fixture** (`fixture_id`): environment, both players, sides and seed. An rsim match is a - pure function of it, so a fixture already in the ledger is never played again. -""" - -from __future__ import annotations - -import json -from pathlib import Path -from typing import Iterable, Optional - -from utama_core.config.settings import REPLAY_BASE_PATH -from utama_core.replay.fingerprint import ROUND_ROBIN_ENTRY, CodeGraph, _digest - -LEDGER_PATH = Path(REPLAY_BASE_PATH) / "eval" / "ledger.jsonl" - - -def environment( - graph: CodeGraph, - *, - duration_seconds: float, - sim_noise: Optional[dict], - control_scheme: str = "fpp", -) -> str: - """Id of what every match of an evaluation shares; `sim_noise` is `SimNoise.to_dict()`, - its seed left out.""" - noise = {k: v for k, v in (sim_noise or {}).items() if k != "seed"} - return _digest( - [ - "evaluation environment", - graph.base_fingerprint([ROUND_ROBIN_ENTRY]), - json.dumps( - {"duration_seconds": duration_seconds, "control_scheme": control_scheme, "sim_noise": noise}, - sort_keys=True, - ), - ] - )[:16] - - -def fixture_id(env: str, a: str, a_fp: str, b: str, b_fp: str, seed: Optional[int]) -> str: - """config_a is always yellow and starts on the right, kicking off (`match.run_match`'s defaults).""" - return _digest([env, a, a_fp, b, b_fp, json.dumps(seed)])[:16] - - -def entry(env: str, graph: CodeGraph, result: dict, seed: Optional[int], source: str) -> dict: - """A ledger line for `result` (a `match.MatchResult` as a dict, with its stats).""" - a, b = result["config_a"], result["config_b"] - a_fp, b_fp = graph.strategy_fingerprint(a)[:16], graph.strategy_fingerprint(b)[:16] - shots = (result.get("stats") or {}).get("shots") or {} - return { - "fixture": fixture_id(env, a, a_fp, b, b_fp, seed), - "env": env, - "a": a, - "a_fp": a_fp, - "b": b, - "b_fp": b_fp, - "seed": seed, - "score_a": result["score_a"], - "score_b": result["score_b"], - "shots_a": shots.get("friendly"), - "shots_b": shots.get("enemy"), - "source": source, - } - - -def append(entries: Iterable[dict], path: Path = LEDGER_PATH) -> None: - """One line per entry; each write is a single append, so concurrent writers interleave - whole lines.""" - path.parent.mkdir(parents=True, exist_ok=True) - with open(path, "a") as f: - for e in entries: - f.write(json.dumps(e, sort_keys=True) + "\n") - f.flush() - - -def load(env: str, path: Path = LEDGER_PATH) -> dict[str, dict]: - """The ledger's entries for `env`, by fixture id (the last one wins if a fixture was played - twice).""" - out: dict[str, dict] = {} - if not path.exists(): - return out - for line in path.read_text().splitlines(): - try: - e = json.loads(line) - except json.JSONDecodeError: - continue # a torn last line from a crash - if e.get("env") == env: - out[e["fixture"]] = e - return out diff --git a/utama_core/replay/fingerprint.py b/utama_core/replay/fingerprint.py index 51b193362..9f0c02610 100644 --- a/utama_core/replay/fingerprint.py +++ b/utama_core/replay/fingerprint.py @@ -1,26 +1,24 @@ """Fingerprints of the code a match runs, so a deterministic rsim result can be reused. An rsim match is a pure function of the code each side runs, the pairing and the run -settings (`docs/STRATEGY_DEVELOPMENT.md`, "Determinism"). This module names that code: - -- `strategy_fingerprint(config)`: one `build_*_kernel_strategy` factory. `kernel_strategy.py` - only re-exports the factories; the module it imports each from counts as a whole file, - with every repo module that imports in turn (function-level imports included, the shared - `strategy/pickers.py` and the tactics among them). Editing one strategy's module leaves - the other configs' fingerprints alone; editing `pickers.py` moves every config that - imports it. -- `base_fingerprint(entry)`: everything both sides share, from the module that plays the - match (`tools.evaluation.match`): runner, planner, referee, sim wrapper, the rsim subprocess script, the files - next to that code (referee profiles), both pixi environments (every installed package's - name, version and build), the installed robosim binary, the CPU model and the - environment variables that change numerics. -- `match_key(...)`: those fingerprints plus every run setting. - -`kernel_strategy.py` imports every strategy module, and they run in every match whichever -config is playing, so a module only one config uses still runs its import-time code in every -match. A module whose -import-time code can change something outside itself (`_import_time_effects`) is moved -into the base. `audit()` lists every place the code reaches outside the import graph +settings (`docs/strategy.md`, "Determinism"). This module names that code: + +- `strategy_fingerprint(config)`: one player, a strategy in the catalog or a `.strategy` file: + every repo module its code imports (function-level imports included, the shared + `strategy/pickers.py`, the tactics, the planner) and the non-code files next to them (the + compiled planner among them). Its name is not part of it, so a file and the code it was built + from are the same player, while a file built from other code is not. Editing one strategy's + module leaves the other players alone; editing `pickers.py` moves every player that imports it. +- `base_fingerprint(entry)`: what the match process runs whoever plays, from the module that plays + the match (`tools.evaluation.match`): runner, referee, sim wrapper, the rsim subprocess script, the + files next to that code (referee profiles), both pixi environments (every installed package's + name, version and build), the installed robosim binary, the CPU model and the environment + variables that change numerics. Not the code behind the process boundary (`PLAYER_SIDE`): a + `.strategy` file brings its own, so editing a skill replays no match between two files. +- The run settings (duration, sim noise, sides) and the two players' + fingerprints make up a match's fixture in `replay/match_results.py`. + +`audit()` lists every place the code reaches outside the import graph (environment, files, subprocesses, dynamic imports, module-level state); `tests/replay/test_fingerprint.py` pins that list, so a new one fails a test until someone decides how it enters the fingerprint. @@ -46,12 +44,33 @@ from typing import Iterable, Optional REPO_ROOT = Path(__file__).resolve().parents[2] -KERNEL_STRATEGY = "utama_core.strategy.kernel_strategy" -ROUND_ROBIN_ENTRY = "tools.evaluation.match" +STRATEGY_PACKAGE = "utama_core.strategy" +MATCH_ENTRY = "tools.evaluation.match" + +# Behind the process boundary: a player's own code, which a `.strategy` file carries a copy of. +PLAYER_SIDE = ( + STRATEGY_PACKAGE, + "utama_core.tactics", + "utama_core.skills", + "utama_core.motion_planning", + "utama_core.engine", + "utama_core.geometry.pass_and_score_geometry", +) +# The parts of those the match process runs itself, whoever plays: looking a strategy up, the base +# class a `.strategy` file's proxy inherits, and the log and stats it writes. +RUNNER_SIDE = ( + "utama_core.strategy.catalog", + "utama_core.engine.abstract_strategy", + "utama_core.engine.match_log", + "utama_core.engine.match_stats", + "utama_core.engine.tactic", +) +# Part of every player though no strategy imports it: where a side's motion controller comes from. +PLAYER_ROOTS = ("utama_core.motion_planning.common.control_schemes",) # Code that runs but is not imported: `robosim_wrapper.py` starts it as a script in the # `robosim` pixi environment. -SUBPROCESS_SCRIPTS = ("utama_core.rsoccer_simulator.src.Simulators.robosim.robosim_subprocess",) +SUBPROCESS_SCRIPTS = ("utama_core.simulator.simulators.robosim.robosim_subprocess",) # Environment variables that change play: UTAMA_EXACT_MATH (`config/settings.py`) and the # thread/JIT knobs of numba and the BLAS numpy links against. @@ -119,6 +138,14 @@ def source(self) -> bytes: return self.path.read_bytes() if self.path is not None else b"" +def _within(module: str, packages: Iterable[str]) -> bool: + return any(module == p or module.startswith(p + ".") for p in packages) + + +def _is_player_side(module: str) -> bool: + return _within(module, PLAYER_SIDE) and not _within(module, RUNNER_SIDE) + + class CodeGraph: """The repo's import graph, parsed from source (nothing is imported). A snapshot: each file is read once, so build a new one after editing code.""" @@ -142,7 +169,7 @@ def _load(self, name: str) -> Optional[_Module]: mod = _Module(name, base.with_suffix(".py"), is_package=False) elif (base / "__init__.py").is_file(): mod = _Module(name, base / "__init__.py", is_package=True) - elif base.is_dir() and "." in name: # namespace package, e.g. utama_core/skills/src + elif base.is_dir() and "." in name: # namespace package, e.g. utama_core/motion_planning/common return _Module(name, None, is_package=True) else: return None @@ -233,74 +260,39 @@ def data_files(self, names: Iterable[str]) -> list[str]: rows.append(f"{p.relative_to(self.root).as_posix()} {_sha(p.read_bytes())}") return sorted(rows) - # --- kernel_strategy.py, the registry of factories ---------------------------------- - - @cached_property - def factory_modules(self) -> dict[str, str]: - """Each `build_*_kernel_strategy` the registry re-exports -> the repo module that - defines it.""" - mod = self.module(KERNEL_STRATEGY) - found = {} - for stmt in mod.tree.body: - if not isinstance(stmt, ast.ImportFrom): - continue - source = self._resolve_from(mod, stmt) - home = self.module(source) if source is not None else None - if home is None or home.tree is None: - continue - defined = {s.name for s in home.tree.body if isinstance(s, ast.FunctionDef)} - for alias in stmt.names: - name = alias.asname or alias.name - if name.startswith("build_") and name.endswith("_kernel_strategy") and alias.name in defined: - found[name] = source - return found - - def factory_module(self, config: str) -> str: - if config not in self.factory_modules: - raise KeyError(f"{config} is not a factory {KERNEL_STRATEGY} re-exports") - return self.factory_modules[config] - - # --- what both sides share ---------------------------------------------------------- - - def kernel_import_closure(self) -> set[str]: - """Every repo module `import kernel_strategy` runs, whichever config plays.""" - return self.closure([KERNEL_STRATEGY]) - {KERNEL_STRATEGY} - - def ambient_modules(self) -> dict[str, list[str]]: - """Modules kernel_strategy imports whose import-time code can reach outside them - (module name -> what it does). They run in every match, so they join the base.""" - found = {} - for name in sorted(self.kernel_import_closure()): - mod = self.module(name) - if mod.tree is None: - continue - effects = [e for stmt in mod.tree.body for e in _import_time_effects(stmt)] - if effects: - found[name] = effects - return found + # --- what a player runs, and what every match runs ------------------------------------ def base_modules(self, entries: Iterable[str]) -> set[str]: - entries = list(entries) - cut = {KERNEL_STRATEGY} - mods = self.closure(entries + list(SUBPROCESS_SCRIPTS), cut=cut) - cut - # The entries only look factories up by name. Shared code that imports kernel_strategy - # could call any factory or helper it re-exports, so every strategy module is then shared. - if any(KERNEL_STRATEGY in self.imports(m) for m in mods - set(entries)): - mods |= self.closure([KERNEL_STRATEGY]) - return mods | self.closure(self.ambient_modules()) + roots = list(entries) + list(SUBPROCESS_SCRIPTS) + cut = {m for m in self.closure(roots) if _is_player_side(m)} + return self.closure(roots, cut=cut) - cut def strategy_modules(self, config: str) -> set[str]: - return self.closure([self.factory_module(config)]) + module = f"{STRATEGY_PACKAGE}.{config}" + if self.module(module) is None: + raise KeyError(f"no strategy {config} in {self.root}") + return self.closure([module, *PLAYER_ROOTS]) def strategy_fingerprint(self, config: str) -> str: key = ("strategy", config) if key not in self._fingerprints: - mods = self.strategy_modules(config) - self._fingerprints[key] = _digest( - ["factory", config, self.factory_module(config), "files"] + self.file_digests(mods) - ) + if config.endswith(".strategy"): + self._fingerprints[key] = self._file_fingerprint(config) + else: + mods = self.strategy_modules(config) + self._fingerprints[key] = _digest( + ["player", "files"] + self.file_digests(mods) + ["data"] + self.data_files(mods) + ) return self._fingerprints[key] + def _file_fingerprint(self, path: str) -> str: + """The same function over the file's own copy of the repo. The host and the manifest it adds are + outside every closure, so a file and the code it was built from fingerprint the same.""" + from utama_core.bundle.archive import read_manifest, unpack + + root = unpack(self.root / path) + return CodeGraph(root).strategy_fingerprint(read_manifest(root)["strategy"]) + def base_fingerprint(self, entries: Iterable[str]) -> str: key = ("base", tuple(entries)) if key not in self._fingerprints: @@ -488,50 +480,3 @@ def environment_pin(root: Path = REPO_ROOT) -> dict: "cpu": _cpu_model(), "env": {k: v for k, v in sorted(os.environ.items()) if k.startswith(ENV_PREFIXES)}, } - - -def match_key( - graph: CodeGraph, - config_a: str, - config_b: str, - *, - duration_seconds: float, - a_is_right: bool = True, - a_kicks_off: bool = True, - control_scheme: str = "fpp", - fuzz_seed: Optional[int] = None, - fuzz_interval_s: tuple[float, float] = (25.0, 45.0), - recorded: bool = True, - sim_noise: Optional[dict] = None, -) -> str: - """Key of one `match.run_match` call: same key, same result. `recorded` is - whether it ran with a `run_dir` (the match log and stats recorder are then live). - `sim_noise` (`SimNoise.to_dict()`) enters the key only when set, so matches without it - keep their keys.""" - settings = { - "duration_seconds": duration_seconds, - "a_is_right": a_is_right, - "a_kicks_off": a_kicks_off, - "control_scheme": control_scheme, - "fuzz_seed": fuzz_seed, - "fuzz_interval_s": list(fuzz_interval_s) if fuzz_seed is not None else None, - "recorded": recorded, - } - if sim_noise is not None: - settings["sim_noise"] = sim_noise - return _digest( - [ - "round-robin match", - graph.base_fingerprint([ROUND_ROBIN_ENTRY]), - config_a, - graph.strategy_fingerprint(config_a), - config_b, - graph.strategy_fingerprint(config_b), - json.dumps(settings, sort_keys=True), - ] - ) - - -def config_names(graph: CodeGraph) -> list[str]: - """The round-robin's configs, as `match._CONFIG_NAMES` finds them, from source.""" - return sorted(n for n in graph.factory_modules if n != "build_default_kernel_strategy") diff --git a/utama_core/replay/game_log_writer.py b/utama_core/replay/game_log_writer.py index 3d4cd96ab..897f2a3b2 100644 --- a/utama_core/replay/game_log_writer.py +++ b/utama_core/replay/game_log_writer.py @@ -4,7 +4,7 @@ before any filter: every vision packet as received (raw detections with ssl-vision's `t_capture`), the referee's state, and the radio's bytes both ways. `GameLogWriter` writes them in the league's game-log format (`ssl_log.py`), so the tools for official logs read a -field test unchanged: `tools/convert_ssl_log.py` turns it into a replay, and its raw-vision +field test unchanged: `tools/realism/convert_ssl_log.py` turns it into a replay, and its raw-vision sidecar gives our camera's noise. Records: - `VISION_2014`: each `SSL_WrapperPacket`, byte for byte. @@ -37,9 +37,7 @@ from typing import Optional from utama_core.entities.data.referee import RefereeData -from utama_core.team_controller.src.generated_code.ssl_gc_referee_message_pb2 import ( - Referee, -) +from utama_core.team_controller.generated_code.ssl_gc_referee_message_pb2 import Referee # The league's format, as `ssl_log` reads it (not imported from there: the runner would pull # in the whole reader). diff --git a/utama_core/global_utils/git_utils.py b/utama_core/replay/git_utils.py similarity index 100% rename from utama_core/global_utils/git_utils.py rename to utama_core/replay/git_utils.py diff --git a/utama_core/replay/match_cache.py b/utama_core/replay/match_cache.py deleted file mode 100644 index ff7d6fc59..000000000 --- a/utama_core/replay/match_cache.py +++ /dev/null @@ -1,75 +0,0 @@ -"""Stored round-robin match results, reused while the code a match runs is unchanged. - -An rsim match is deterministic, so a result is a function of `fingerprint.match_key`: -both sides' code, the shared code and environment, and the run settings. A record holds -everything `round_robin.py` reads from a played match: the result and its stats, the -restart episodes (`restart_outcomes.analyse_match`) and the ball-loss record -(`turnover_breakdown.analyse_match`, with its `chances`). No replay is stored; `--pair A B` -plays any match again, byte for byte. The analysis code is not in the key: a record keeps -the analysis it was stored with, so after changing it, refresh the records from a run's -replays or the spot-check will report the difference. - -A fingerprint can miss a dependency (see `fingerprint.py`'s "Known gaps"), so a run also -replays a sample of the matches it would reuse (`spot_check_sample`) and compares the -fresh record with the stored one (`differences`). -""" - -from __future__ import annotations - -import json -import os -import random -from pathlib import Path -from typing import Iterable, Optional - -from utama_core.config.settings import REPLAY_BASE_PATH - -CACHE_DIR = Path(REPLAY_BASE_PATH) / "match_cache" -RECORD_PARTS = ("result", "restarts", "losses") - - -def _plain(value): - """`value` as it reads back from JSON (tuples become lists, keys become strings).""" - return json.loads(json.dumps(value)) - - -class MatchCache: - def __init__(self, root: Path = CACHE_DIR): - self.root = Path(root) - - def path(self, key: str) -> Path: - return self.root / key[:2] / f"{key}.json" - - def get(self, key: str) -> Optional[dict]: - try: - return json.loads(self.path(key).read_text()) - except (OSError, json.JSONDecodeError): - return None - - def put(self, key: str, record: dict) -> None: - path = self.path(key) - path.parent.mkdir(parents=True, exist_ok=True) - # One temp file per process: several round-robins (one per strategy branch) can share - # this cache and store the same match at once. A shared temp file could be renamed away - # mid-write by one of them, leaving a torn record and failing the other's rename. - tmp = path.with_suffix(f".{os.getpid()}.tmp") - tmp.write_text(json.dumps(_plain(record), sort_keys=True)) - tmp.replace(path) - - def evict(self, key: str) -> None: - self.path(key).unlink(missing_ok=True) - - -def spot_check_sample(keys: Iterable[str], fraction: float, seed: int = 0) -> set[str]: - """The cached keys a run replays to check them: `fraction` of them, at least one when - there are any and `fraction` > 0. Seeded, so a rerun checks the same matches.""" - keys = sorted(keys) - if not keys or fraction <= 0: - return set() - n = min(len(keys), max(1, round(fraction * len(keys)))) - return set(random.Random(seed).sample(keys, n)) - - -def differences(stored: dict, fresh: dict) -> list[str]: - """The record parts where a replayed match disagrees with its stored record.""" - return [part for part in RECORD_PARTS if _plain(stored.get(part)) != _plain(fresh.get(part))] diff --git a/utama_core/replay/match_results.py b/utama_core/replay/match_results.py new file mode 100644 index 000000000..2583bc4d0 --- /dev/null +++ b/utama_core/replay/match_results.py @@ -0,0 +1,172 @@ +"""Every match result the evaluation tools have played, in one store: `replays/match_results/`. + +An rsim match is deterministic, so its result is a function of its fixture: the environment (the +shared code and machine, the match length and the sim noise without its seed), both players' code fingerprints (`fingerprint.py`), their sides and the noise +seed. `tools/evaluation/evaluate.py`'s `play_and_record` plays a fixture and returns its record; +`evaluate.py` looks a fixture up first and plays it only when the store +does not hold it, then stores the record. Reuse is automatic: there is no flag. A player whose code +changed has new fingerprints, so only its matches play again. + +Layout: one JSON file per fixture, under its environment: `replays/match_results//.json`. +A record holds the score, the shots, the stall events, the full per-match stats, the restart +episodes and the ball-loss record of the match, the names of both players as labels, the run it came +from, and the fingerprints it was played with. Names are labels only: `load(env, fps)` relabels a +player by its fingerprint, so a `.strategy` file and the same code in the repo are one player. + +To force replays, delete the store, or one environment's folder inside it. The store does not check +itself: if a fingerprint misses a dependency (see `fingerprint.py`, "Known gaps"), the stale results +stay until the store is deleted. The earlier stores (`replays/match_cache/`, `replays/eval/ledger.jsonl`) +are no longer read or written. +""" + +from __future__ import annotations + +import json +import os +from pathlib import Path +from typing import Iterable, Optional + +from utama_core.replay.fingerprint import MATCH_ENTRY, CodeGraph, _digest + +STORE_NAME = "match_results" + + +def open_store(replay_base: Path) -> "MatchResults": + """The store under a replay base directory (`REPLAY_BASE_PATH` for the tools).""" + return MatchResults(Path(replay_base) / STORE_NAME) + + +def environment( + graph: CodeGraph, + *, + duration_seconds: float, + sim_noise: Optional[dict], +) -> str: + """Id of what every match of one evaluation or round-robin shares. `sim_noise` is + `SimNoise.to_dict()`, its seed left out (the seed is part of the fixture).""" + noise = {k: v for k, v in (sim_noise or {}).items() if k != "seed"} + settings = { + "duration_seconds": duration_seconds, + "sim_noise": noise, + } + return _digest( + [ + "evaluation environment", + graph.base_fingerprint([MATCH_ENTRY]), + json.dumps(settings, sort_keys=True), + ] + )[:16] + + +def fixture_id( + env: str, + a_fp: str, + b_fp: str, + seed: Optional[int], + *, + a_is_right: bool = True, + a_kicks_off: bool = True, +) -> str: + """One match: environment, both players' fingerprints, the sides and the noise seed. The sides + default to the tools' convention (config_a yellow, on the right, kicking off).""" + sides = {"a_is_right": a_is_right, "a_kicks_off": a_kicks_off} + return _digest([env, a_fp, b_fp, json.dumps(seed), json.dumps(sides, sort_keys=True)])[:16] + + +def stall_summary(events: Optional[Iterable[dict]]) -> Optional[list[dict]]: + """A match's stall events as stored rows (kind, sim time, and the diagnosis if there is one), + or None when the match's stats were not collected: unknown, which is not "no stalls". + The watchdog only watches config_a, so these are config_a's stalls.""" + if events is None: + return None + rows = [] + for e in events: + row = {"kind": e["kind"], "sim_time": e["sim_time"]} + if e.get("diagnosis"): + row["diagnosis"] = e["diagnosis"] + rows.append(row) + return rows + + +def record( + env: str, + a_fp: str, + b_fp: str, + result: dict, + *, + seed: Optional[int], + source: str, + restarts: Optional[list[dict]], + losses: Optional[dict], + a_is_right: bool = True, + a_kicks_off: bool = True, + replay: Optional[str] = None, +) -> dict: + """The stored record of one played match. `result` is a `match.MatchResult` as a dict; `restarts` + and `losses` are the replay analyses (None when the replay was not kept to analyse). `replay` is + where its files are, a stem relative to the replay base directory (`eval_/round_/a_vs_b`), + so a later run that reuses the match can link them into its own round folder.""" + stats = result.get("stats") or {} + shots = stats.get("shots") or {} + rec = { + "fixture": fixture_id(env, a_fp, b_fp, seed, a_is_right=a_is_right, a_kicks_off=a_kicks_off), + "env": env, + "a": result["config_a"], + "a_fp": a_fp, + "b": result["config_b"], + "b_fp": b_fp, + "a_is_right": a_is_right, + "a_kicks_off": a_kicks_off, + "seed": seed, + "source": source, + "score_a": result["score_a"], + "score_b": result["score_b"], + "shots_a": shots.get("friendly"), + "shots_b": shots.get("enemy"), + "stalls": stall_summary(stats.get("stall_events") if stats else None), + "stats": result.get("stats"), + "restarts": restarts, + "losses": losses, + "replay": replay, + } + return json.loads(json.dumps(rec)) # the shape it reads back in, tuples as lists + + +class MatchResults: + def __init__(self, root: Path): + self.root = Path(root) + + def path(self, env: str, fixture: str) -> Path: + return self.root / env / f"{fixture}.json" + + def get(self, env: str, fixture: str) -> Optional[dict]: + try: + return json.loads(self.path(env, fixture).read_text()) + except (OSError, json.JSONDecodeError): + return None + + def put(self, rec: dict) -> None: + path = self.path(rec["env"], rec["fixture"]) + path.parent.mkdir(parents=True, exist_ok=True) + # One temp file per process: several runs (one per strategy branch) can share the store and + # store the same match at once; a shared temp file could be renamed away mid-write. + tmp = path.with_suffix(f".{os.getpid()}.tmp") + tmp.write_text(json.dumps(rec, sort_keys=True)) + tmp.replace(path) + + def load(self, env: str, fps: Optional[dict[str, str]] = None) -> dict[str, dict]: + """The stored matches of `env`, by fixture id. With `fps` (name -> fingerprint), a player it + knows goes by that name, whatever the name was when the match was played.""" + names = {fp: name for name, fp in (fps or {}).items()} + out: dict[str, dict] = {} + folder = self.root / env + if not folder.is_dir(): + return out + for path in sorted(folder.glob("*.json")): + try: + rec = json.loads(path.read_text()) + except (OSError, json.JSONDecodeError): + continue # a torn write from a crash, or a file someone edited: not a result + rec["a"], rec["b"] = names.get(rec["a_fp"], rec["a"]), names.get(rec["b_fp"], rec["b"]) + out[rec["fixture"]] = rec + return out diff --git a/utama_core/replay/replay_player.py b/utama_core/replay/replay_player.py index 5e0f11faa..953d0ce95 100644 --- a/utama_core/replay/replay_player.py +++ b/utama_core/replay/replay_player.py @@ -12,14 +12,14 @@ from utama_core.entities.game import Ball as GameBall from utama_core.entities.game import Game, GameFrame from utama_core.entities.game import Robot as GameRobot -from utama_core.global_utils.mapping_utils import map_friendly_enemy_to_colors -from utama_core.global_utils.math_utils import rad_to_deg +from utama_core.entities.game.mapping_utils import map_friendly_enemy_to_colors +from utama_core.geometry.math_utils import rad_to_deg from utama_core.replay.entities import ReplayMetadata -from utama_core.rsoccer_simulator.src.Entities import Ball as RSoccerBall -from utama_core.rsoccer_simulator.src.Entities import Frame as RSoccerFrame -from utama_core.rsoccer_simulator.src.Entities import FrameSSL -from utama_core.rsoccer_simulator.src.Entities import Robot as RSoccerRobot -from utama_core.rsoccer_simulator.src.ssl.envs import SSLStandardEnv +from utama_core.simulator.entities import Ball as RSoccerBall +from utama_core.simulator.entities import Frame as RSoccerFrame +from utama_core.simulator.entities import FrameSSL +from utama_core.simulator.entities import Robot as RSoccerRobot +from utama_core.simulator.ssl.envs import SSLStandardEnv logger = logging.getLogger(__name__) diff --git a/utama_core/replay/scenario.py b/utama_core/replay/scenario.py index ec0a282b6..0f493be71 100644 --- a/utama_core/replay/scenario.py +++ b/utama_core/replay/scenario.py @@ -8,16 +8,16 @@ one tick. `scenario_from_replay()` + `apply_scenario()` skip that: read the single nearest frame from the replay, then teleport a freshly-constructed `StrategyRunner` (same two strategies, same profile — see -`repro_from_replay.py`) directly into that field state, so the investigator +`tools/debug/repro_from_replay.py`) directly into that field state, so the investigator can start ticking (with `match_log` tracing on) from just before the stall. Coordinate frame: `GameFrame.friendly_robots`/`enemy_robots`/`ball` store positions in plain pitch-frame metres — the same frame `AbstractSimController.teleport_ball`/`teleport_robot` take directly (see -`utama_core/rsoccer_simulator/src/ssl/ssl_gym_base.py`'s `teleport_ball`/ +`utama_core/simulator/ssl/ssl_gym_base.py`'s `teleport_ball`/ `teleport_robot`, which do the y-flip into rsim's internal frame themselves; callers, including the teleport accuracy test in -`utama_core/tests/strategy_runner/teleport_position_accuracy_test.py`, pass +`utama_core/tests/run/test_teleport_position_accuracy.py`, pass plain (x, y) metres and get them back unchanged on the next frame). There is no additional per-team-color mirroring at the `GameFrame` layer — that only exists one level up, in kernel-tactic target *storage* (see @@ -26,11 +26,11 @@ `p.x`/`p.y`/`orientation` and hand them to `apply_scenario` unchanged; this is verified by `apply_scenario` itself reading back the first post-teleport `GameFrame` and asserting positions match within a few cm (mirroring -`teleport_position_accuracy_test.py`'s `POSITION_TOLERANCE`). +`test_teleport_position_accuracy.py`'s `POSITION_TOLERANCE`). A replay only ever records one side's perspective (`ReplayWriterConfig`/ `ColumnarReplayWriterConfig.is_my_perspective`, and -`tournament.run_match`/`repro_from_replay.py` both always construct the +`tournament.run_match`/`tools/debug/repro_from_replay.py` both always construct the runner with `my_team_is_yellow=True, my_team_is_right=True` — config_a is always yellow/friendly, and right in the first half; `scenario_from_replay` turns a second-half frame so it is right here too) — so `friendly_robots` in the replay is @@ -40,8 +40,8 @@ Known limitations, stated here once rather than re-derived by every caller: - **Tactic `mem` is not in the replay.** Every `Tactic`'s internal per-slot - state (phase, committed targets, timers — see `docs/STRATEGY_DEVELOPMENT. - md`'s "Writing a Tactic") lives only in the live kernel `Strategy` + state (phase, committed targets, timers — see `docs/strategy.md`'s + "Writing a Tactic") lives only in the live kernel `Strategy` process, never serialized to the replay. A repro therefore always starts with **fresh tactic state** — the kernel re-partitions robots from scratch on the first tick after the scenario is applied, which may not @@ -96,10 +96,11 @@ from utama_core.entities.game import Ball, Game, GameFrame, GameHistory, Robot from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.replay.replay_player import _load_replay, load_frames_in_range +from utama_core.strategy.catalog import plain_name logger = logging.getLogger(__name__) -_POSITION_TOLERANCE_M = 0.15 # mirrors teleport_position_accuracy_test.py's POSITION_TOLERANCE +_POSITION_TOLERANCE_M = 0.15 # mirrors test_teleport_position_accuracy.py's POSITION_TOLERANCE _VERIFY_MAX_TICKS = 10 # see apply_scenario's verify=True docstring for why more than 1 tick is needed _SHOWING_WINDOW_S = 0.5 # how far past `t_seconds` `scenario_from_replay(showing=...)` looks _CLOCK_EPS_S = 1e-6 # float slack when a frame time sits exactly on a window edge @@ -133,7 +134,7 @@ class Scenario: `friendly_robots`/`enemy_robots` follow the replay's own perspective (see module docstring): friendly is config_a (yellow/right in every - `tournament.run_match`/`repro_from_replay.py` construction), enemy is + `tournament.run_match`/`tools/debug/repro_from_replay.py` construction), enemy is config_b. """ @@ -146,7 +147,7 @@ class Scenario: enemy_robots: tuple[RobotState, ...] referee_command: Optional[RefereeCommand] source_replay: Path - config_a_name: Optional[str] = None # e.g. "build_high_line_zone_kernel_strategy" (friendly) + config_a_name: Optional[str] = None # e.g. "high_line_zone" (friendly) config_b_name: Optional[str] = None # enemy frame_ts: float = field(default=0.0) # the actual frame's `ts`, may differ slightly from requested sim_time @@ -154,7 +155,7 @@ class Scenario: def _short_name(config_name: str) -> str: """Mirror `tournament._short_name` without importing the CLI script as a module (it's a root-level script, not a package).""" - return config_name.removeprefix("build_").removesuffix("_kernel_strategy") + return plain_name(config_name) def _robot_states(robots: dict, turn: bool = False) -> tuple[RobotState, ...]: @@ -175,7 +176,7 @@ def _robot_states(robots: dict, turn: bool = False) -> tuple[RobotState, ...]: def _frame_origin(replay_path: Path) -> float: - """The `ts` of the replay's first frame. Times on the sidecar's and `replay_trace.py`'s + """The `ts` of the replay's first frame. Times on the sidecar's and `tools/debug/replay_trace.py`'s clock (and the `t_seconds` callers pass, from `fouls` or a StallEvent) count from it, not from 0: a frame's `ts` starts at one tick (1/60 s in these replays).""" if replay_path.suffix == ".npz": @@ -318,7 +319,7 @@ def _first_frame_showing(replay_path: Path, t_seconds: float, command: RefereeCo def scenario_from_replay(replay_path, t_seconds: float, *, showing: Optional[RefereeCommand] = None) -> Scenario: """Read the frame nearest `t_seconds` from `replay_path` and build a `Scenario` from it. `t_seconds` counts from the replay's first frame, the clock the sidecar, - `fouls` and `replay_trace.py` use (see `_frame_origin`). It merges in the referee command from + `fouls` and `tools/debug/replay_trace.py` use (see `_frame_origin`). It merges in the referee command from the `.intentions.jsonl` sidecar (frames themselves carry no referee data — see module docstring) and the two strategy config names from the tournament directory's `summary.json`, when available. @@ -427,12 +428,12 @@ def _make_robot(rs: RobotState, is_friendly: bool) -> Robot: def apply_scenario(runner, scenario: Scenario, *, verify: bool = True) -> None: """Teleport `runner`'s ball and every robot into `scenario`'s field state, through `runner.sim_controller` (the same public attribute - `teleport_position_accuracy_test.py` drives directly). + `test_teleport_position_accuracy.py` drives directly). Friendly robots are teleported as `runner.my_team_is_yellow`'s color, enemy robots as the opposite color — matching how the replay was recorded (see module docstring: config_a/friendly is always yellow/right - in `tournament.run_match`/`repro_from_replay.py`, but `apply_scenario` + in `tournament.run_match`/`tools/debug/repro_from_replay.py`, but `apply_scenario` itself just follows whatever `runner.my_team_is_yellow` says, so it also works for a runner built with the opposite orientation). @@ -455,7 +456,7 @@ def apply_scenario(runner, scenario: Scenario, *, verify: bool = True) -> None: a coordinate-frame regression fails loudly instead of silently producing a wrong repro. More than one tick is needed in practice, not just the "one frame of physics settling" - `teleport_position_accuracy_test.py`'s `POSITION_TOLERANCE` was sized + `test_teleport_position_accuracy.py`'s `POSITION_TOLERANCE` was sized for: a robot/ball teleported far from wherever the runner's initial formation placed it (the normal case here — a real match's positions are essentially always far from a fresh runner's starting formation, @@ -465,7 +466,7 @@ def apply_scenario(runner, scenario: Scenario, *, verify: bool = True) -> None: robot teleported near the goal line, confirmed against a real replay, 2026-09-03). """ - from utama_core.custom_referee import CustomReferee + from utama_core.referee import CustomReferee sim_controller = runner.sim_controller if sim_controller is None: @@ -491,7 +492,7 @@ def apply_scenario(runner, scenario: Scenario, *, verify: bool = True) -> None: # direction of travel (observed: robot teleported to x=0.68 landed at # x=1.35 one tick later — reproduces exactly from the filter's own # closed-form update, not noise or a coordinate-frame bug). - # `teleport_position_accuracy_test.py` never hits this because it + # `test_teleport_position_accuracy.py` never hits this because it # teleports inside `reset_field()`, which `StrategyRunner._reset_game()` # always follows with `position_refiner.reset()` *and* a full # `GameGater`-driven `_load_game()` reload — which is what actually diff --git a/utama_core/replay/ssl_log.py b/utama_core/replay/ssl_log.py index 1ebfcc291..b71ca7a3e 100644 --- a/utama_core/replay/ssl_log.py +++ b/utama_core/replay/ssl_log.py @@ -4,7 +4,7 @@ match, gzipped. `convert_log` turns one into the `.npz` + `.sparse_referee.pkl` pair a round-robin match writes, through `ColumnarReplayWriter`, so `load_columnar_replay`, `render_window`, `scenario_from_replay` and the analyses read a real match like one of ours. -`tools/convert_ssl_log.py` converts files or downloads the published logs. +`tools/realism/convert_ssl_log.py` converts files or downloads the published logs. Log format: the header `SSL_LOG_FILE` and a big-endian int32 version, then records of int64 receive time [ns], int32 message type, int32 size and the serialized message. Types read here: @@ -52,7 +52,7 @@ - `.source.json`: the log, teams, final score, tracker source and field geometry, and under `extras` which of the sidecars below were written. -Sidecars, for measuring physics and vision rather than replaying (`tools/convert_ssl_log.py` +Sidecars, for measuring physics and vision rather than replaying (`tools/realism/convert_ssl_log.py` can add them to a replay already converted). Teams are in kick-off colours like the replay (yellow friendly), positions in metres in field coordinates, times `ts` in seconds on the replay's clock. The arrays are `np.savez_compressed` archives named `.zip`, so a glob for @@ -102,13 +102,11 @@ ColumnarReplayWriter, ColumnarReplayWriterConfig, ) -from utama_core.team_controller.src.generated_code.ssl_gc_referee_message_pb2 import ( - Referee, -) -from utama_core.team_controller.src.generated_code.ssl_vision_wrapper_pb2 import ( +from utama_core.team_controller.generated_code.ssl_gc_referee_message_pb2 import Referee +from utama_core.team_controller.generated_code.ssl_vision_wrapper_pb2 import ( SSL_WrapperPacket, ) -from utama_core.team_controller.src.generated_code.ssl_vision_wrapper_tracked_pb2 import ( +from utama_core.team_controller.generated_code.ssl_vision_wrapper_tracked_pb2 import ( TrackerWrapperPacket, ) @@ -615,7 +613,7 @@ def free_kick_taken(command: np.ndarray, counter: np.ndarray, ball_xy: np.ndarra The game controller keeps `DIRECT_FREE_*` through the play that follows, until the next stoppage. Our referee switches to `NORMAL_START` before the kick instead (its advance 3, see - `docs/custom_referee.md`), and the analyses count live play as `NORMAL_START`/`FORCE_START`, + `docs/referee.md`), and the analyses count live play as `NORMAL_START`/`FORCE_START`, so a converted replay says `NORMAL_START` from the kick on.""" taken = np.zeros(len(command), dtype=bool) in_kick = np.isin(command, list(FREE_KICKS)) diff --git a/utama_core/rsoccer_simulator/__init__.py b/utama_core/rsoccer_simulator/__init__.py deleted file mode 100644 index 8b1378917..000000000 --- a/utama_core/rsoccer_simulator/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/utama_core/rsoccer_simulator/src/Entities/__init__.py b/utama_core/rsoccer_simulator/src/Entities/__init__.py deleted file mode 100644 index 1d07343f0..000000000 --- a/utama_core/rsoccer_simulator/src/Entities/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from utama_core.rsoccer_simulator.src.Entities.Ball import Ball -from utama_core.rsoccer_simulator.src.Entities.Field import Field -from utama_core.rsoccer_simulator.src.Entities.Frame import Frame, FrameSSL, FrameVSS -from utama_core.rsoccer_simulator.src.Entities.Robot import Robot diff --git a/utama_core/rsoccer_simulator/src/Render/__init__.py b/utama_core/rsoccer_simulator/src/Render/__init__.py deleted file mode 100644 index 2d43723fd..000000000 --- a/utama_core/rsoccer_simulator/src/Render/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -from utama_core.rsoccer_simulator.src.Render.ball import RenderBall -from utama_core.rsoccer_simulator.src.Render.field import ( - Sim2DRenderField, - SSLRenderField, - VSSRenderField, -) -from utama_core.rsoccer_simulator.src.Render.overlay import RenderOverlay -from utama_core.rsoccer_simulator.src.Render.robot import ( - RenderSim2DRobot, - RenderSSLRobot, - RenderVSSRobot, -) -from utama_core.rsoccer_simulator.src.Render.utils import COLORS diff --git a/utama_core/rsoccer_simulator/src/Utils/__init__.py b/utama_core/rsoccer_simulator/src/Utils/__init__.py deleted file mode 100644 index 2a1b32c25..000000000 --- a/utama_core/rsoccer_simulator/src/Utils/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from utama_core.rsoccer_simulator.src.Utils.kdtree import KDTree diff --git a/utama_core/rsoccer_simulator/src/Utils/real_kick.py b/utama_core/rsoccer_simulator/src/Utils/real_kick.py deleted file mode 100644 index a9cf15d9d..000000000 --- a/utama_core/rsoccer_simulator/src/Utils/real_kick.py +++ /dev/null @@ -1,67 +0,0 @@ -"""Our robots' kickers as calibrated (`RobotProfile`), for the robots of a rehearsal in rsim. - -A real kick leaves at the robot's own speed (about 2.1 m/s, not the sim's 5), off its heading by -its bias, bent towards the side the ball sits on the dribbler, and scattered kick to kick. A run -that gives rsim our robots' profiles (the examples do) kicks them so; a match without profiles -(the evaluation) keeps the sim's kick. Angles here are in our frame, anticlockwise +. -""" - -from __future__ import annotations - -import math -from dataclasses import dataclass -from typing import Optional - -import numpy as np - -# rsim's ball leaves this much slower than the kick speed commanded, at any speed (measured -# 2026-10-29: 1 to 5 m/s); a profile's kick speed is the ball's, as calibration measures it. -CONTACT_LOSS = 0.26 - - -@dataclass(frozen=True) -class RealKick: - speed: Optional[float] = None # m/s; None: the sim's - bend_deg_per_cm: float = 0.0 - bias_deg: float = 0.0 - spread_deg: float = 0.0 # SD of each kick's direction about the fit - - @classmethod - def of(cls, profile) -> Optional["RealKick"]: - """The kick `profile` (a `RobotProfile`) measured; None if it measured none.""" - kick = cls( - profile.kick_speed, profile.kick_bend_deg_per_cm, profile.kick_bias_deg, profile.kick_spread_deg or 0.0 - ) - return None if kick == cls() else kick - - -class RealKicks: - """Each kick of a robot with a `RealKick`: its speed, and its direction drawn when the kick - command starts and held while it lasts (the kicker fires once per command).""" - - def __init__(self, kicks: dict[tuple[str, int], RealKick], seed: int = 0): - self.kicks = kicks - self._rngs = {key: np.random.default_rng([seed, i]) for i, key in enumerate(sorted(kicks))} - self._held: dict[tuple[str, int], Optional[float]] = {} - - def __contains__(self, key: tuple[str, int]) -> bool: - return key in self.kicks - - def reset(self) -> None: - self._held.clear() - - def speed(self, key: tuple[str, int], nominal: float) -> float: - speed = self.kicks[key].speed - return nominal if speed is None else speed + CONTACT_LOSS - - def angle(self, key: tuple[str, int], kicking: bool, ball_left_m: float) -> float: - """Radians off the heading, anticlockwise +, with the ball `ball_left_m` left of the - robot's centre line.""" - if not kicking: - self._held[key] = None - return 0.0 - if self._held.get(key) is None: - k = self.kicks[key] - deg = k.bias_deg + k.bend_deg_per_cm * ball_left_m * 100.0 + self._rngs[key].normal() * k.spread_deg - self._held[key] = math.radians(deg) - return self._held[key] diff --git a/utama_core/rsoccer_simulator/src/ssl/envs/__init__.py b/utama_core/rsoccer_simulator/src/ssl/envs/__init__.py deleted file mode 100644 index 1423630df..000000000 --- a/utama_core/rsoccer_simulator/src/ssl/envs/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from utama_core.rsoccer_simulator.src.ssl.envs.standard_ssl import SSLStandardEnv diff --git a/utama_core/run/field_fence.py b/utama_core/run/field_fence.py index 78dccbf30..caaef2c17 100644 --- a/utama_core/run/field_fence.py +++ b/utama_core/run/field_fence.py @@ -1,7 +1,7 @@ """Keeps our robots inside the area in play (`field_bounds`, what the camera sees) on camera runs. A tactic chasing a ball that left the camera's half drove its robot after it, out of sight, -where nothing tracks it (a 2026-10-22 grSim test of `examples/shooting_drill.py`: the +where nothing tracks it (a 2026-10-22 grSim test of `tools/field/shooting_drill.py`: the attacker 0.9 m past the half-way line). The field check only halts once a robot is already 0.3 m out. `FencedRobotController` sits under the strategy, like `ProfiledRobotController`, and caps each robot's speed towards each edge of the area to what it can still stop from with its body @@ -12,7 +12,7 @@ Only edges inside the field are fenced (the half-way line on a half-field run): a robot must cross the touch and goal lines to fetch a ball out of play, or a restart never completes -(`custom_referee/actions.py`, `_clamp_to_field_or_ball`), and the cameras see past them. +(`referee/actions.py`, `_clamp_to_field_or_ball`), and the cameras see past them. Keep-out zones (`StrategyRunner(keep_out=...)`) are rectangles no robot may enter, in every mode: the speed into each is capped the same way, on the sides a robot could reach before it stops. A diff --git a/utama_core/run/game_gater.py b/utama_core/run/game_gater.py index 2b77c3f94..27c1f6856 100644 --- a/utama_core/run/game_gater.py +++ b/utama_core/run/game_gater.py @@ -4,7 +4,7 @@ from utama_core.data_processing.refiners import PositionRefiner from utama_core.entities.data.raw_vision import RawVisionData from utama_core.entities.game.game_frame import GameFrame -from utama_core.rsoccer_simulator.src.ssl.ssl_gym_base import SSLBaseEnv +from utama_core.simulator.ssl.ssl_gym_base import SSLBaseEnv class GameGater: diff --git a/utama_core/run/live_status.py b/utama_core/run/live_status.py index e4a7be7d7..e0d11fc23 100644 --- a/utama_core/run/live_status.py +++ b/utama_core/run/live_status.py @@ -6,7 +6,7 @@ from rich.text import Text from utama_core.config.settings import FPS_PRINT_INTERVAL -from utama_core.custom_referee import CustomReferee +from utama_core.referee import CustomReferee from utama_core.run.referee_source import OfficialReferee diff --git a/utama_core/run/referee_source.py b/utama_core/run/referee_source.py index b22836962..dd244d06f 100644 --- a/utama_core/run/referee_source.py +++ b/utama_core/run/referee_source.py @@ -6,7 +6,7 @@ from typing import TYPE_CHECKING, Union if TYPE_CHECKING: - from utama_core.custom_referee import CustomReferee + from utama_core.referee import CustomReferee @dataclass(frozen=True) diff --git a/utama_core/run/side_runtime.py b/utama_core/run/side_runtime.py index e768ca7b6..5ff4fdfa5 100644 --- a/utama_core/run/side_runtime.py +++ b/utama_core/run/side_runtime.py @@ -15,7 +15,7 @@ from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game, GameFrame, GameHistory, Robot from utama_core.entities.game.field import FieldBounds -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController def _turned(robot: Robot, bounds: FieldBounds) -> Robot: diff --git a/utama_core/run/sim_setup.py b/utama_core/run/sim_setup.py new file mode 100644 index 000000000..834a4122d --- /dev/null +++ b/utama_core/run/sim_setup.py @@ -0,0 +1,115 @@ +"""The one way to load a strategy and to set up a simulated match. Every tool that plays one uses these: +`tools/evaluation/match.py` (round-robin, `evaluate.py`), `tools/debug/repro_from_replay.py`, `tools/debug/moments.py`, +`tools/debug/debug_match.py` and `main.py`. + +- `load_side(name)`: a strategy by catalog name, a `.strategy` file by path, or `PATH.py:FUNCTION` (a + `build(outfield_robot_ids, motion_controller)` in a scratch file, to try a tactic without a repo change). +- `sim_referee(...)`: the referee of an rsim match: the "simulation" profile, with the kickoff team. +- `sim_runner(strategy, opponent, ...)`: the `StrategyRunner` for a 6-a-side rsim match against a referee + (`sim_referee()` by default), our side yellow on the right, vision stream off. + +Nothing else constructs the referee or the rsim runner of a match. Changing this module changes the +fingerprint of every match (`utama_core/replay/fingerprint.py`), so a round-robin plays them all again. +""" + +from __future__ import annotations + +import dataclasses +import importlib.util +from functools import partial +from pathlib import Path +from typing import Callable, Optional + +from utama_core.bundle.strategy_file import SUFFIX, BundledStrategy +from utama_core.engine.abstract_strategy import AbstractStrategy +from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee import CustomReferee +from utama_core.referee.profiles.profile_loader import load_profile +from utama_core.run import StrategyRunner +from utama_core.simulator.utils.sim_noise import SimNoise +from utama_core.strategy import catalog + +N_OUTFIELD = 5 # + 1 goalkeeper per side +OUTFIELD_ROBOT_IDS = tuple(range(1, N_OUTFIELD + 1)) +N_ROBOTS = N_OUTFIELD + 1 # per side, the goalkeeper included + + +class UnknownStrategy(ValueError): + """A strategy name that is neither in the catalog, a `.strategy` file nor `PATH.py:FUNCTION`.""" + + +def is_file_spec(name: str) -> bool: + """`PATH.py:FUNCTION`, a factory in a scratch file.""" + path, sep, func = name.rpartition(":") + return bool(sep) and path.endswith(".py") and bool(func) + + +def factory_for(name: str) -> Callable: + """`f(outfield_robot_ids)` -> `AbstractStrategy`'s `build`, for a catalog strategy or `PATH.py:FUNCTION` + (imported as it is).""" + if not is_file_spec(name): + if catalog.current_name(name) not in catalog.names(): + raise UnknownStrategy(f"unknown strategy {name!r}; strategies: {', '.join(catalog.names())}") + return partial(catalog.builder, catalog.current_name(name)) + path, _, func = name.rpartition(":") + if not Path(path).is_file(): + raise UnknownStrategy(f"{name}: no such file {path}") + spec = importlib.util.spec_from_file_location(f"scratch_{Path(path).stem}", path) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + factory = getattr(module, func, None) + if not callable(factory): + raise UnknownStrategy(f"{name}: {path} has no factory {func!r}") + return lambda outfield_robot_ids: partial(factory, outfield_robot_ids) + + +def load_side(name: str, outfield_robot_ids: Optional[tuple[int, ...]] = None) -> AbstractStrategy: + """A strategy to play: a `.strategy` file by path, `PATH.py:FUNCTION`, or a catalog name. The robots + are the outfield ones unless given; a `.strategy` file plays the robots it was built for unless given.""" + if name.endswith(SUFFIX): + if not Path(name).is_file(): + raise UnknownStrategy(f"{name}: no such strategy file") + return BundledStrategy(name, outfield_robot_ids) + return AbstractStrategy(build=factory_for(name)(outfield_robot_ids or OUTFIELD_ROBOT_IDS)) + + +def sim_referee(*, kickoff_team: str = "yellow") -> CustomReferee: + """The referee of an rsim match: the "simulation" profile, `kickoff_team` taking the first kickoff.""" + profile = load_profile("simulation") + if kickoff_team != profile.game.kickoff_team: + profile = dataclasses.replace(profile, game=dataclasses.replace(profile.game, kickoff_team=kickoff_team)) + return CustomReferee(profile, n_robots_yellow=N_ROBOTS, n_robots_blue=N_ROBOTS) + + +def sim_runner( + strategy: AbstractStrategy, + opponent: AbstractStrategy, + *, + sim_noise: Optional[SimNoise] = None, + initial_command: Optional[RefereeCommand] = RefereeCommand.PREPARE_KICKOFF_YELLOW, + referee: Optional[CustomReferee] = None, + my_team_is_right: bool = True, + **runner_kwargs, +) -> tuple[StrategyRunner, CustomReferee]: + """A `StrategyRunner` for `strategy` (yellow) against `opponent` in rsim, refereed by `referee` (default + `sim_referee()`). `initial_command=None` keeps the runner's own default. Other keyword arguments go to + `StrategyRunner` (`match_log_path`, `stats_path`, `control_scheme`, `show_live_status`, ...).""" + if referee is None: + referee = sim_referee() + if initial_command is not None: + runner_kwargs["referee_initial_command"] = initial_command + runner = StrategyRunner( + strategy=strategy, + opp_strategy=opponent, + my_team_is_yellow=True, + my_team_is_right=my_team_is_right, + mode="rsim", + exp_friendly=N_ROBOTS, + exp_enemy=N_ROBOTS, + exp_ball=True, + referee=referee, + enable_vision_stream=False, + sim_noise=sim_noise, + **runner_kwargs, + ) + return runner, referee diff --git a/utama_core/run/strategy_runner.py b/utama_core/run/strategy_runner.py index 4a80fbfd3..9797ae96b 100644 --- a/utama_core/run/strategy_runner.py +++ b/utama_core/run/strategy_runner.py @@ -26,7 +26,6 @@ ROBOT_FEEDBACK_CONNECTION_TIMEOUT_SECONDS, TIMESTEP, ) -from utama_core.custom_referee import CustomReferee from utama_core.data_processing.receivers import RefereeMessageReceiver, VisionReceiver from utama_core.data_processing.refiners import ( PositionRefiner, @@ -41,25 +40,23 @@ from utama_core.entities.data.raw_vision import RawVisionData from utama_core.entities.game import Game, GameFrame, GameHistory from utama_core.entities.game.field import Field, FieldBounds -from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.global_utils.mapping_utils import ( +from utama_core.entities.game.mapping_utils import ( map_colors_to_friendly_enemy, map_friendly_enemy_to_colors, map_left_right_to_colors, ) -from utama_core.global_utils.math_utils import assert_valid_bounding_box -from utama_core.motion_planning.src.common.control_schemes import get_control_scheme -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.geometry.math_utils import assert_valid_bounding_box +from utama_core.geometry.pass_and_score_geometry import reset_possession_state +from utama_core.motion_planning.common.control_schemes import get_control_scheme +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.referee import CustomReferee from utama_core.replay.columnar_writer import ( ColumnarReplayWriter, ColumnarReplayWriterConfig, ) from utama_core.replay.game_log_writer import GameLogWriter, code_version from utama_core.replay.replay_writer import ReplayWriter, ReplayWriterConfig -from utama_core.rsoccer_simulator.src.ssl.envs import SSLStandardEnv -from utama_core.rsoccer_simulator.src.Utils.gaussian_noise import RsimGaussianNoise -from utama_core.rsoccer_simulator.src.Utils.real_kick import RealKick, RealKicks -from utama_core.rsoccer_simulator.src.Utils.sim_noise import SimNoise from utama_core.run import GameGater from utama_core.run.field_check import LOOP_STALL_S, FieldCheck from utama_core.run.field_fence import FencedRobotController, inner_edges @@ -75,10 +72,12 @@ ) from utama_core.run.vision_stream import GameFrameRenderer, RSimVisionStreamServer from utama_core.run.vision_stream_status import VisionStreamStatusMixin -from utama_core.shared.pass_and_score_geometry import reset_possession_state -from utama_core.skills.src.shielding import reset_shield_state +from utama_core.simulator.ssl.envs import SSLStandardEnv +from utama_core.simulator.utils.gaussian_noise import RsimGaussianNoise +from utama_core.simulator.utils.sim_noise import SimNoise +from utama_core.skills.shielding import reset_shield_state from utama_core.strategy.pickers import reset_closer_to_ball_state -from utama_core.team_controller.src.controllers import ( +from utama_core.team_controller.controllers import ( AbstractSimController, GRSimController, GRSimRobotController, @@ -87,7 +86,7 @@ RSimPVPManager, RSimRobotController, ) -from utama_core.team_controller.src.controllers.common.robot_profile import ( +from utama_core.team_controller.controllers.common.robot_profile import ( ProfiledRobotController, RobotProfile, ) @@ -246,7 +245,7 @@ class StrategyRunner(SimRecoveryMixin, VisionStreamStatusMixin, LiveStatusMixin) field_bounds (FieldBounds): Bounds of the subset of the full field being used. Defaults to None (ie full field). keep_out (Sequence[FieldBounds]): Rectangles no robot may enter (vision coordinates): each robot's speed into them is capped (`field_fence.py`), and on a camera run one inside - forces HALT (`field_check.py`). Defaults to none. + forces HALT (`tools/field/field_check.py`). Defaults to none. fence_field_lines (bool): On camera runs, fence the touch and goal lines as well as the edges of `field_bounds` inside the field; off by default, as a robot fetching a ball out of play must cross them. On for a run that never needs to (calibration). @@ -282,7 +281,7 @@ class StrategyRunner(SimRecoveryMixin, VisionStreamStatusMixin, LiveStatusMixin) Defaults to 0. sim_noise (SimNoise, optional): When running in rsim, seeded latency, kick and ball physics, motion limits and vision noise - (`utama_core/rsoccer_simulator/src/Utils/sim_noise.py`); replaces `rsim_noise` and `rsim_vanishing`. + (`utama_core/simulator/utils/sim_noise.py`); replaces `rsim_noise` and `rsim_vanishing`. Recorded in a columnar replay. Defaults to None (off). filtering (bool, optional): Turn on Kalman smoothing and vanished-robot imputation. Defaults to True. referee (RefereeSource, optional): Referee source. Pass a ``CustomReferee`` @@ -407,7 +406,7 @@ def __init__( self._vision_stream_renderer: Optional[GameFrameRenderer] = None if isinstance(self.referee, CustomReferee): - from utama_core.custom_referee.geometry import RefereeGeometry + from utama_core.referee.geometry import RefereeGeometry self.referee.override_geometry(RefereeGeometry.from_field_dims(self.full_field_dims)) @@ -995,7 +994,6 @@ def _load_sim( vanishing=rsim_vanishing, sim_noise=sim_noise, ) - rsim_env.real_kicks = self._real_kicks(sim_noise) if self.opp: self.opp.strategy.load_rsim_env(rsim_env) @@ -1094,7 +1092,7 @@ def auto_halt(self) -> Optional[str]: def resume_after_auto_halt(self) -> bool: """Force Start once the field check passes again after a HALT it forced, for a run nobody - resumes from the dashboard (`examples/calibrate_robot.py`). True when it resumed.""" + resumes from the dashboard (`tools/field/calibrate_robot.py`). True when it resumed.""" if self._auto_halt is None or self._prev_custom_ref_command != RefereeCommand.HALT: return False if self.field_check.halt_reason(self._field_check_rows) is not None: @@ -1363,22 +1361,14 @@ def _load_robot_controllers(self): self.opp.strategy.load_robot_controller(opp_robot_controller) self.opp.strategy.load_motion_controller(self._motion_controller(self.opp, opp_profiles)) - def _real_kicks(self, sim_noise: Optional[SimNoise]) -> Optional[RealKicks]: - """rsim's kicks for the robots given profiles that measured their kick (a rehearsal); None - when none did, as in the evaluation's matches.""" - kicks = { - (f"team_{colour}", rid): kick - for colour, profiles in (("yellow", self.yellow_robot_profiles), ("blue", self.blue_robot_profiles)) - for rid, profile in profiles.items() - if (kick := RealKick.of(profile)) is not None - } - return RealKicks(kicks, seed=sim_noise.seed if sim_noise is not None else 0) if kicks else None - def _motion_controller(self, team, profiles: dict[int, RobotProfile]) -> MotionController: - """`team`'s motion controller, with its profiled robots' kick bends, biases (real robots and - rsim, which kicks them so) and carry caps (`RobotProfile`).""" + """`team`'s motion controller, with its profiled robots' kick bends and biases (real robots + only: the sims keep their own kick) and carry caps (`RobotProfile`, every mode).""" controller = team.motion_controller(self.mode, self.rsim_env) - if self.mode in (Mode.REAL, Mode.RSIM): + sim_noise = getattr(self.rsim_env, "sim_noise", None) + if self.mode == Mode.RSIM and sim_noise is not None: # commands are delayed: compensate as real robots do + controller.pose_ahead.latency_s = sim_noise.latency_estimate_s + if self.mode == Mode.REAL: controller.kick_bend = { rid: math.radians(p.kick_bend_deg_per_cm) * 100.0 for rid, p in profiles.items() diff --git a/utama_core/run/vision_stream.py b/utama_core/run/vision_stream.py index 292bb8c50..5a0dea8fc 100644 --- a/utama_core/run/vision_stream.py +++ b/utama_core/run/vision_stream.py @@ -36,7 +36,7 @@ class GameFrameRenderer: def __init__(self, field_dims, scale: float = 100.0) -> None: import pygame - from utama_core.rsoccer_simulator.src.Render import SSLRenderField + from utama_core.simulator.render import SSLRenderField self._pygame = pygame self._field_renderer = SSLRenderField( @@ -61,11 +61,7 @@ def __init__(self, field_dims, scale: float = 100.0) -> None: def render(self, game_frame, friendly_color=None, enemy_color=None) -> np.ndarray: """Render a `GameFrame` into an RGB numpy array.""" - from utama_core.rsoccer_simulator.src.Render import ( - COLORS, - RenderBall, - RenderSSLRobot, - ) + from utama_core.simulator.render import COLORS, RenderBall, RenderSSLRobot if friendly_color is None: friendly_color = COLORS["YELLOW"] if game_frame.my_team_is_yellow else COLORS["BLUE"] diff --git a/utama_core/rsoccer_simulator/.gitignore b/utama_core/simulator/.gitignore similarity index 98% rename from utama_core/rsoccer_simulator/.gitignore rename to utama_core/simulator/.gitignore index e214c5c3d..2373779b3 100644 --- a/utama_core/rsoccer_simulator/.gitignore +++ b/utama_core/simulator/.gitignore @@ -1,6 +1,6 @@ .DS_Store *.pyc -rsoccer_simulator.src.egg-info/ +rsoccer_simulator.egg-info/ .vscode/* __pycache__ .idea/ diff --git a/utama_core/rsoccer_simulator/LICENSE b/utama_core/simulator/LICENSE similarity index 100% rename from utama_core/rsoccer_simulator/LICENSE rename to utama_core/simulator/LICENSE diff --git a/utama_core/rsoccer_simulator/README.md b/utama_core/simulator/README.md similarity index 98% rename from utama_core/rsoccer_simulator/README.md rename to utama_core/simulator/README.md index a121e7191..6804c4e6c 100644 --- a/utama_core/rsoccer_simulator/README.md +++ b/utama_core/simulator/README.md @@ -87,7 +87,7 @@ def teleport_robot( Functions used to draw points/lines/polygons of interest. Used for visualisation and debugging. Note that these are also sent together with robot commands ONLY at the end of the frame. -For the list of available colours, see `rsoccer_simulator/src/Render/utils.py`. +For the list of available colours, see `simulator/render/utils.py`. #### Draw Point diff --git a/utama_core/global_utils/__init__.py b/utama_core/simulator/__init__.py similarity index 100% rename from utama_core/global_utils/__init__.py rename to utama_core/simulator/__init__.py diff --git a/utama_core/rsoccer_simulator/src/Entities/Ball.py b/utama_core/simulator/entities/Ball.py similarity index 72% rename from utama_core/rsoccer_simulator/src/Entities/Ball.py rename to utama_core/simulator/entities/Ball.py index 42d6d2cbf..b680cde61 100644 --- a/utama_core/rsoccer_simulator/src/Entities/Ball.py +++ b/utama_core/simulator/entities/Ball.py @@ -2,7 +2,7 @@ from numpy.random import normal -from utama_core.rsoccer_simulator.src.Utils.gaussian_noise import RsimGaussianNoise +from utama_core.simulator.utils.gaussian_noise import RsimGaussianNoise @dataclass() diff --git a/utama_core/rsoccer_simulator/src/Entities/Field.py b/utama_core/simulator/entities/Field.py similarity index 100% rename from utama_core/rsoccer_simulator/src/Entities/Field.py rename to utama_core/simulator/entities/Field.py diff --git a/utama_core/rsoccer_simulator/src/Entities/Frame.py b/utama_core/simulator/entities/Frame.py similarity index 96% rename from utama_core/rsoccer_simulator/src/Entities/Frame.py rename to utama_core/simulator/entities/Frame.py index ea86510eb..b7f4701ac 100644 --- a/utama_core/rsoccer_simulator/src/Entities/Frame.py +++ b/utama_core/simulator/entities/Frame.py @@ -1,7 +1,7 @@ from typing import Dict -from utama_core.rsoccer_simulator.src.Entities.Ball import Ball -from utama_core.rsoccer_simulator.src.Entities.Robot import Robot +from utama_core.simulator.entities.Ball import Ball +from utama_core.simulator.entities.Robot import Robot class Frame: diff --git a/utama_core/rsoccer_simulator/src/Entities/Robot.py b/utama_core/simulator/entities/Robot.py similarity index 100% rename from utama_core/rsoccer_simulator/src/Entities/Robot.py rename to utama_core/simulator/entities/Robot.py diff --git a/utama_core/simulator/entities/__init__.py b/utama_core/simulator/entities/__init__.py new file mode 100644 index 000000000..d1f074ddc --- /dev/null +++ b/utama_core/simulator/entities/__init__.py @@ -0,0 +1,4 @@ +from utama_core.simulator.entities.Ball import Ball +from utama_core.simulator.entities.Field import Field +from utama_core.simulator.entities.Frame import Frame, FrameSSL, FrameVSS +from utama_core.simulator.entities.Robot import Robot diff --git a/utama_core/simulator/render/__init__.py b/utama_core/simulator/render/__init__.py new file mode 100644 index 000000000..716b5b5e6 --- /dev/null +++ b/utama_core/simulator/render/__init__.py @@ -0,0 +1,13 @@ +from utama_core.simulator.render.ball import RenderBall +from utama_core.simulator.render.field import ( + Sim2DRenderField, + SSLRenderField, + VSSRenderField, +) +from utama_core.simulator.render.overlay import RenderOverlay +from utama_core.simulator.render.robot import ( + RenderSim2DRobot, + RenderSSLRobot, + RenderVSSRobot, +) +from utama_core.simulator.render.utils import COLORS diff --git a/utama_core/rsoccer_simulator/src/Render/ball.py b/utama_core/simulator/render/ball.py similarity index 87% rename from utama_core/rsoccer_simulator/src/Render/ball.py rename to utama_core/simulator/render/ball.py index 6a7c4e04c..ad0dcb4a1 100644 --- a/utama_core/rsoccer_simulator/src/Render/ball.py +++ b/utama_core/simulator/render/ball.py @@ -1,6 +1,6 @@ import pygame -from utama_core.rsoccer_simulator.src.Render.utils import COLORS +from utama_core.simulator.render.utils import COLORS class RenderBall: diff --git a/utama_core/rsoccer_simulator/src/Render/field.py b/utama_core/simulator/render/field.py similarity index 99% rename from utama_core/rsoccer_simulator/src/Render/field.py rename to utama_core/simulator/render/field.py index 25febcbb5..95feeba39 100644 --- a/utama_core/rsoccer_simulator/src/Render/field.py +++ b/utama_core/simulator/render/field.py @@ -1,6 +1,6 @@ import pygame -from utama_core.rsoccer_simulator.src.Render.utils import COLORS +from utama_core.simulator.render.utils import COLORS class RenderField: diff --git a/utama_core/rsoccer_simulator/src/Render/overlay.py b/utama_core/simulator/render/overlay.py similarity index 95% rename from utama_core/rsoccer_simulator/src/Render/overlay.py rename to utama_core/simulator/render/overlay.py index 09eba2484..53bd358b8 100644 --- a/utama_core/rsoccer_simulator/src/Render/overlay.py +++ b/utama_core/simulator/render/overlay.py @@ -3,7 +3,7 @@ import pygame -from utama_core.rsoccer_simulator.src.Render.utils import COLORS +from utama_core.simulator.render.utils import COLORS class OverlayType(Enum): diff --git a/utama_core/rsoccer_simulator/src/Render/robot.py b/utama_core/simulator/render/robot.py similarity index 98% rename from utama_core/rsoccer_simulator/src/Render/robot.py rename to utama_core/simulator/render/robot.py index a025bfbeb..65a3b08b9 100644 --- a/utama_core/rsoccer_simulator/src/Render/robot.py +++ b/utama_core/simulator/render/robot.py @@ -1,7 +1,7 @@ import numpy as np import pygame -from utama_core.rsoccer_simulator.src.Render.utils import COLORS, TAG_ID_COLORS +from utama_core.simulator.render.utils import COLORS, TAG_ID_COLORS class RenderRobot: diff --git a/utama_core/rsoccer_simulator/src/Render/utils.py b/utama_core/simulator/render/utils.py similarity index 100% rename from utama_core/rsoccer_simulator/src/Render/utils.py rename to utama_core/simulator/render/utils.py diff --git a/utama_core/tests/shared/__init__.py b/utama_core/simulator/simulators/__init__.py similarity index 100% rename from utama_core/tests/shared/__init__.py rename to utama_core/simulator/simulators/__init__.py diff --git a/utama_core/rsoccer_simulator/src/Simulators/robosim/robosim_subprocess.py b/utama_core/simulator/simulators/robosim/robosim_subprocess.py similarity index 100% rename from utama_core/rsoccer_simulator/src/Simulators/robosim/robosim_subprocess.py rename to utama_core/simulator/simulators/robosim/robosim_subprocess.py diff --git a/utama_core/rsoccer_simulator/src/Simulators/robosim/robosim_wrapper.py b/utama_core/simulator/simulators/robosim/robosim_wrapper.py similarity index 99% rename from utama_core/rsoccer_simulator/src/Simulators/robosim/robosim_wrapper.py rename to utama_core/simulator/simulators/robosim/robosim_wrapper.py index da53582c6..f94f6660e 100644 --- a/utama_core/rsoccer_simulator/src/Simulators/robosim/robosim_wrapper.py +++ b/utama_core/simulator/simulators/robosim/robosim_wrapper.py @@ -188,7 +188,7 @@ def __init__(self, sim_type, n_blue, n_yellow, field_type, time_step_ms): # Ensure rc-robosim's scikit-build uses a compatible CMake policy level. env["CMAKE_ARGS"] = f"{env.get('CMAKE_ARGS', '')} {cmake_policy_flag}".strip() env["SKBUILD_CMAKE_ARGS"] = f"{env.get('SKBUILD_CMAKE_ARGS', '')} {cmake_policy_flag}".strip() - project_root = Path(__file__).resolve().parents[5] + project_root = Path(__file__).resolve().parents[4] robosim_env = project_root / ".pixi" / "envs" / "robosim" robosim_python = robosim_env / "bin" / "python" include_dir = robosim_env / "include" diff --git a/utama_core/rsoccer_simulator/src/Simulators/rsim.py b/utama_core/simulator/simulators/rsim.py similarity index 97% rename from utama_core/rsoccer_simulator/src/Simulators/rsim.py rename to utama_core/simulator/simulators/rsim.py index 0ef37b92e..79ddc502d 100644 --- a/utama_core/rsoccer_simulator/src/Simulators/rsim.py +++ b/utama_core/simulator/simulators/rsim.py @@ -2,8 +2,8 @@ import numpy as np -from utama_core.rsoccer_simulator.src.Entities import Field, Frame, FrameSSL -from utama_core.rsoccer_simulator.src.Simulators.robosim.robosim_wrapper import ( +from utama_core.simulator.entities import Field, Frame, FrameSSL +from utama_core.simulator.simulators.robosim.robosim_wrapper import ( RSimSubprocessWrapper, acquire_simulator, ) diff --git a/utama_core/simulator/ssl/__init__.py b/utama_core/simulator/ssl/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/utama_core/simulator/ssl/envs/__init__.py b/utama_core/simulator/ssl/envs/__init__.py new file mode 100644 index 000000000..5e819123f --- /dev/null +++ b/utama_core/simulator/ssl/envs/__init__.py @@ -0,0 +1 @@ +from utama_core.simulator.ssl.envs.standard_ssl import SSLStandardEnv diff --git a/utama_core/rsoccer_simulator/src/ssl/envs/standard_ssl.py b/utama_core/simulator/ssl/envs/standard_ssl.py similarity index 93% rename from utama_core/rsoccer_simulator/src/ssl/envs/standard_ssl.py rename to utama_core/simulator/ssl/envs/standard_ssl.py index b20b59fba..97c8affb4 100644 --- a/utama_core/rsoccer_simulator/src/ssl/envs/standard_ssl.py +++ b/utama_core/simulator/ssl/envs/standard_ssl.py @@ -1,5 +1,4 @@ import logging -import math import random from typing import List, Optional, Tuple @@ -17,17 +16,12 @@ from utama_core.entities.data.command import RobotResponse from utama_core.entities.data.raw_vision import RawBallData, RawRobotData, RawVisionData from utama_core.entities.data.referee import RefereeData -from utama_core.global_utils.math_utils import ( - deg_to_rad, - normalise_heading_deg, - rad_to_deg, -) -from utama_core.rsoccer_simulator.src.Entities import Ball, Frame, Robot -from utama_core.rsoccer_simulator.src.ssl.ssl_gym_base import SSLBaseEnv -from utama_core.rsoccer_simulator.src.Utils import KDTree -from utama_core.rsoccer_simulator.src.Utils.gaussian_noise import RsimGaussianNoise -from utama_core.rsoccer_simulator.src.Utils.real_kick import RealKicks -from utama_core.rsoccer_simulator.src.Utils.sim_noise import ( +from utama_core.geometry.math_utils import deg_to_rad, normalise_heading_deg, rad_to_deg +from utama_core.simulator.entities import Ball, Frame, Robot +from utama_core.simulator.ssl.ssl_gym_base import SSLBaseEnv +from utama_core.simulator.utils import KDTree +from utama_core.simulator.utils.gaussian_noise import RsimGaussianNoise +from utama_core.simulator.utils.sim_noise import ( CommandDelay, KickAngleNoise, KickSpeedNoise, @@ -172,8 +166,6 @@ def __init__( self._kick_noise: Optional[KickSpeedNoise] = None self._kick_angle: Optional[KickAngleNoise] = None self._motion_limits: Optional[MotionLimits] = None - # Our robots' kickers as calibrated, by (colour, id); set by StrategyRunner from robot profiles. - self.real_kicks: Optional[RealKicks] = None self._noise_rng = None # None: `gaussian_noise`/`vanishing` use the global RNG, as before if sim_noise is not None: assert gaussian_noise == RsimGaussianNoise() and not vanishing, "pass vision noise in sim_noise only" @@ -225,8 +217,6 @@ def reset(self, *, seed=None, options=None): self._kick_noise.reset() if self._kick_angle is not None: self._kick_angle.reset() - if self.real_kicks is not None: - self.real_kicks.reset() return super().reset(seed=seed, options=options) def step(self, action): @@ -387,8 +377,6 @@ def _get_commands(self, actions) -> list[Robot]: return commands def _kick_direction(self, colour: str, robot_id: int, kicking: bool) -> float: - if self.real_kicks is not None and (colour, robot_id) in self.real_kicks: - return -self.real_kicks.angle((colour, robot_id), kicking, self._ball_left(colour, robot_id)) if self._kick_angle is not None: return self._kick_angle.angle(colour, robot_id, kicking) return 0.0 @@ -400,17 +388,7 @@ def _apply_motion_limits(self, commands: list[Robot]) -> None: ) self._motion_limits.apply(colour, cmd.id, cmd, robots[cmd.id]) - def _ball_left(self, colour: str, robot_id: int) -> float: - """How far the ball sits left of the robot's centre line (m, our frame: the sim's y and - headings are mirrored).""" - robot = (self.frame.robots_yellow if colour == "team_yellow" else self.frame.robots_blue)[robot_id] - heading = -math.radians(robot.theta) - dx, dy = self.frame.ball.x - robot.x, -(self.frame.ball.y - robot.y) - return -math.sin(heading) * dx + math.cos(heading) * dy - def _kick_speed(self, colour: str, robot_id: int, kicking: bool) -> float: - if kicking and self.real_kicks is not None and (colour, robot_id) in self.real_kicks: - return self.real_kicks.speed((colour, robot_id), RSIM_PARAMS.KICK_SPD) if self._kick_noise is not None: return self._kick_noise.speed(colour, robot_id, kicking, RSIM_PARAMS.KICK_SPD) return RSIM_PARAMS.KICK_SPD if kicking else 0.0 diff --git a/utama_core/rsoccer_simulator/src/ssl/ssl_gym_base.py b/utama_core/simulator/ssl/ssl_gym_base.py similarity index 97% rename from utama_core/rsoccer_simulator/src/ssl/ssl_gym_base.py rename to utama_core/simulator/ssl/ssl_gym_base.py index d80355ea3..22cae4f4e 100644 --- a/utama_core/rsoccer_simulator/src/ssl/ssl_gym_base.py +++ b/utama_core/simulator/ssl/ssl_gym_base.py @@ -10,20 +10,20 @@ import numpy as np import pygame -from utama_core.global_utils.math_utils import rad_to_deg -from utama_core.rsoccer_simulator.src.Entities import Ball, Field, Frame, Robot -from utama_core.rsoccer_simulator.src.Render import ( +from utama_core.geometry.math_utils import rad_to_deg +from utama_core.simulator.entities import Ball, Field, Frame, Robot +from utama_core.simulator.render import ( COLORS, RenderBall, RenderSSLRobot, SSLRenderField, ) -from utama_core.rsoccer_simulator.src.Render.overlay import ( +from utama_core.simulator.render.overlay import ( OverlayObject, OverlayType, RenderOverlay, ) -from utama_core.rsoccer_simulator.src.Simulators.rsim import RSimSSL +from utama_core.simulator.simulators.rsim import RSimSSL class SSLBaseEnv: diff --git a/utama_core/simulator/utils/__init__.py b/utama_core/simulator/utils/__init__.py new file mode 100644 index 000000000..49192db16 --- /dev/null +++ b/utama_core/simulator/utils/__init__.py @@ -0,0 +1 @@ +from utama_core.simulator.utils.kdtree import KDTree diff --git a/utama_core/rsoccer_simulator/src/Utils/gaussian_noise.py b/utama_core/simulator/utils/gaussian_noise.py similarity index 100% rename from utama_core/rsoccer_simulator/src/Utils/gaussian_noise.py rename to utama_core/simulator/utils/gaussian_noise.py diff --git a/utama_core/rsoccer_simulator/src/Utils/kdtree.py b/utama_core/simulator/utils/kdtree.py similarity index 100% rename from utama_core/rsoccer_simulator/src/Utils/kdtree.py rename to utama_core/simulator/utils/kdtree.py diff --git a/utama_core/rsoccer_simulator/src/Utils/sim_noise.py b/utama_core/simulator/utils/sim_noise.py similarity index 97% rename from utama_core/rsoccer_simulator/src/Utils/sim_noise.py rename to utama_core/simulator/utils/sim_noise.py index be1d9d9da..18d547efd 100644 --- a/utama_core/rsoccer_simulator/src/Utils/sim_noise.py +++ b/utama_core/simulator/utils/sim_noise.py @@ -26,7 +26,7 @@ import numpy as np -from utama_core.rsoccer_simulator.src.Utils.gaussian_noise import RsimGaussianNoise +from utama_core.simulator.utils.gaussian_noise import RsimGaussianNoise COLOURS = ("team_blue", "team_yellow") @@ -103,6 +103,12 @@ def __post_init__(self): assert self.kick_angle_offset_sd_deg >= 0 and self.kick_angle_sd_deg >= 0 assert self.substeps >= 1 + @property + def latency_estimate_s(self) -> float: + """The one delay the control layer assumes (`PoseAhead`): the middle of `latency_s`. Each + robot's real draw differs from it, as a real robot's delay differs from its setting.""" + return sum(self.latency_s) / 2 + @property def native_physics(self) -> bool: """Whether any setting needs the fork's C++ physics (`set_physics_params`).""" diff --git a/utama_core/skills/src/block.py b/utama_core/skills/block.py similarity index 96% rename from utama_core/skills/src/block.py rename to utama_core/skills/block.py index dfcf2019a..73238feb5 100644 --- a/utama_core/skills/src/block.py +++ b/utama_core/skills/block.py @@ -15,8 +15,8 @@ from utama_core.entities.data.command import RobotCommand from utama_core.entities.data.vector import Vector2D from utama_core.entities.game.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.skills.src.utils.move_utils import move +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.skills.utils.move_utils import move _STEAL_RANGE = 0.5 # metres — inside this, contest the ball directly instead of only shadowing the shot line diff --git a/utama_core/skills/src/defend_parameter.py b/utama_core/skills/defend_parameter.py similarity index 97% rename from utama_core/skills/src/defend_parameter.py rename to utama_core/skills/defend_parameter.py index b5309344f..ee1996c25 100644 --- a/utama_core/skills/src/defend_parameter.py +++ b/utama_core/skills/defend_parameter.py @@ -18,9 +18,9 @@ from utama_core.data_processing.predictors.position import predict_ball_pos_at_x from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.skills.src.go_to_point import go_to_point -from utama_core.skills.src.utils.defense_utils import ( +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.skills.go_to_point import go_to_point +from utama_core.skills.utils.defense_utils import ( clamp_y, intersection_with_x_line, single_defender_stop_y, diff --git a/utama_core/skills/src/go_to_ball.py b/utama_core/skills/go_to_ball.py similarity index 74% rename from utama_core/skills/src/go_to_ball.py rename to utama_core/skills/go_to_ball.py index 07e4dca85..b1f283fe5 100644 --- a/utama_core/skills/src/go_to_ball.py +++ b/utama_core/skills/go_to_ball.py @@ -3,7 +3,7 @@ The lowest-level "get the ball" primitive; every attacking tactic that needs a robot to reach a loose or contested ball calls this rather than computing an approach itself. By default the approach angle is opponent-aware (see -`utama_core.skills.src.shielding`) so a robot converging on a ball an enemy +`utama_core.skills.shielding`) so a robot converging on a ball an enemy is also converging on ends up shielding it from that enemy's side instead of wedging to a stop short of the ball entirely — the exact mechanism behind the `default_vs_lowblock` stalemate investigation @@ -22,7 +22,7 @@ held the ball in its own box). Handled here, not per-tactic, since every `go_to_ball` caller hits the same planner clamp the same way. -See `utama_core.skills.src.shielding`'s module docstring for why the +See `utama_core.skills.shielding`'s module docstring for why the shielding logic was pulled out of this file rather than kept as private helpers here (in short: it was reach-driven — "many tactics call `go_to_ball`, so fixing it here fixes them all" — not a considered fit for a @@ -36,19 +36,22 @@ import math from typing import Optional +from utama_core.config.enums import Mode from utama_core.config.physical_constants import ROBOT_RADIUS from utama_core.engine.context import TickContext from utama_core.entities.data.command import RobotCommand from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.shared.pass_and_score_geometry import ( +from utama_core.geometry.pass_and_score_geometry import ( ball_in_enemy_defense_area, + ball_intercept_point, + clamp_outside_own_defense_area, enemy_defense_area_hold_point, ) -from utama_core.skills.src.go_to_point import go_to_point -from utama_core.skills.src.shielding import shielded_approach_angle -from utama_core.skills.src.utils.move_utils import move +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.skills.go_to_point import go_to_point +from utama_core.skills.shielding import shielded_approach_angle +from utama_core.skills.utils.move_utils import move # Overshoot past ball center so the DWA keeps driving until the robot makes # contact. The dribbler-on approach can push further; the dribbler-off approach @@ -56,6 +59,13 @@ _APPROACH_OVERSHOOT_M = ROBOT_RADIUS * 0 _DRIBBLE_OVERSHOOT_M = ROBOT_RADIUS * (1 / 10) +# A ball with an enemy on it or about to reach it is a race, and the planner covers the last metre +# slowly. In about 230 paired drills of contested balls, sprinting gave our side 7.1 points more +# possession (±2.2) at a free ball and a further 7.3 (±1.9) at one an enemy holds, with hard contacts +# roughly level (2026-11-10). Simulation only: no field data for it yet. +_RACE_ROBOT_RANGE_M = 1.2 +_RACE_ENEMY_RANGE_M = 0.6 + def _target_past_ball(ball: Vector2D, approach_oren: float, overshoot_distance: float) -> Vector2D: if overshoot_distance <= 0.0: @@ -66,6 +76,12 @@ def _target_past_ball(ball: Vector2D, approach_oren: float, overshoot_distance: return Vector2D(ball.x + dx * overshoot_distance, ball.y + dy * overshoot_distance) +def _racing_for_ball(game: Game, motion_controller: MotionController, robot: Vector2D, ball: Vector2D) -> bool: + if motion_controller.mode == Mode.REAL or robot.distance_to(ball) >= _RACE_ROBOT_RANGE_M: + return False + return any(enemy.p.distance_to(ball) < _RACE_ENEMY_RANGE_M for enemy in game.enemy_robots.values()) + + def go_to_ball( game: Game, motion_controller: MotionController, @@ -88,7 +104,7 @@ def go_to_ball( which approach branch ("shield" vs "direct") was taken this call. Omit for callers outside a `Tactic.tick()` that don't have a `ctx`. shield: if True (default), approach from the far side of any - contesting enemy (see `utama_core.skills.src.shielding`) instead + contesting enemy (see `utama_core.skills.shielding`) instead of a straight line from the robot's own position. Pass False to always approach directly — e.g. a fast-break tactic racing for a clearly-winnable loose ball, where the shield detour only costs @@ -97,6 +113,9 @@ def go_to_ball( ball = game.ball.p.to_2d() robot = game.friendly_robots[robot_id].p + if ctx is not None: + ctx.ball_claims.add(robot_id) + if ball_in_enemy_defense_area(game): if ctx is not None and ctx.match_log is not None: ctx.match_log.trace_if_changed( @@ -110,6 +129,29 @@ def go_to_ball( game=game, motion_controller=motion_controller, robot_id=robot_id, target_coords=hold, dribbling=False ) + intercept = ball_intercept_point(game, robot_id) + if intercept is not None: + # Moving, the ball will be somewhere else by the time the robot arrives. + return move( + game=game, + motion_controller=motion_controller, + robot_id=robot_id, + target_coords=intercept, + target_oren=robot.angle_to(ball), + dribbling=dribble_when_near, + ) + + if _racing_for_ball(game, motion_controller, robot, ball): + return move( + game=game, + motion_controller=motion_controller, + robot_id=robot_id, + target_coords=clamp_outside_own_defense_area(game, ball), + target_oren=robot.angle_to(ball), + dribbling=dribble_when_near, + sprint=True, + ) + if shield: approach_oren, shielding = shielded_approach_angle(game, robot, ball, robot_id) else: diff --git a/utama_core/skills/src/go_to_point.py b/utama_core/skills/go_to_point.py similarity index 85% rename from utama_core/skills/src/go_to_point.py rename to utama_core/skills/go_to_point.py index 11798f347..3679d38f7 100644 --- a/utama_core/skills/src/go_to_point.py +++ b/utama_core/skills/go_to_point.py @@ -6,7 +6,7 @@ that needs to hold a specific orientation while stationary (e.g. facing a pass target, not the ball) must call `move()` directly with an explicit `target_oren` instead. This has bitten more than one tactic (see -`docs/STRATEGY_DEVELOPMENT.md`'s "Writing a Tactic" section) — grep every +`docs/strategy.md`'s "Writing a Tactic" section) — grep every `go_to_point(` call in a new tactic and check whether orientation actually matters at that call site. """ @@ -16,8 +16,8 @@ from utama_core.entities.data.command import RobotCommand from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.skills.src.utils.move_utils import face_ball, move +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.skills.utils.move_utils import face_ball, move def go_to_point( diff --git a/utama_core/skills/src/goalkeep.py b/utama_core/skills/goalkeep.py similarity index 86% rename from utama_core/skills/src/goalkeep.py rename to utama_core/skills/goalkeep.py index f2f75427d..723a7a2ef 100644 --- a/utama_core/skills/src/goalkeep.py +++ b/utama_core/skills/goalkeep.py @@ -1,7 +1,7 @@ """`goalkeep` — position the goalkeeper on the goal line to cover the predicted shot. Called directly on robot 0 (pinned outside the kernel scheduler — see -`docs/STRATEGY_DEVELOPMENT.md`'s "Single-writer partition invariant"), not +`docs/strategy.md`'s "Single-writer partition invariant"), not wrapped in a `Tactic`. The keeper's target y-position on the goal line is `predict_ball_pos_at_x`'s intercept when available, adjusted to account for one or two outfield defenders standing between the ball and goal (so the @@ -16,29 +16,42 @@ did: it always drove to a goal-line intercept regardless of where the ball actually was, so a ball that rolled dead in the box (not heading at goal, `predict_ball_pos_at_x` returns `None` for a near-stationary ball) just sat -there for the rest of the match. Found live: a `clear_danger` vs `low_block` +there for the rest of the match. Found live: a `firebreak` vs `low_block` match pinned for the last 28 s of a 60 s game this way (see `docs/strategies.md`'s "Known open bugs"). """ -from typing import Optional +from typing import TYPE_CHECKING, Optional from utama_core.config.physical_constants import BALL_RADIUS, ROBOT_RADIUS from utama_core.data_processing.predictors.position import predict_ball_pos_at_x from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.shared.pass_and_score_geometry import ball_in_own_defense_area, has_ball -from utama_core.skills.src.go_to_point import go_to_point -from utama_core.skills.src.kick_upfield import kick_upfield -from utama_core.skills.src.utils.defense_utils import ( +from utama_core.geometry.pass_and_score_geometry import ( + ANNOUNCE_PASS_RAD, + ball_in_own_defense_area, + has_ball, + open_teammate, + oriented_towards, +) +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.skills.go_to_point import go_to_point +from utama_core.skills.kick_upfield import kick_upfield +from utama_core.skills.utils.defense_utils import ( clamp_y, intersection_with_x_line, single_defender_stop_y, ) +from utama_core.skills.utils.move_utils import kick, turn_on_spot + +if TYPE_CHECKING: + from utama_core.engine.context import TickContext # TODO: instead of checking number of friendly, should check roles +# A pass out from our own goal has to be safe: an enemy this near its line can step onto it. +_KEEPER_PASS_CLEARANCE = 0.4 +_KEEPER_PASS_TOLERANCE_RAD = 0.12 _RETRIEVE_BALL_SPEED = 0.3 # m/s — below this, a ball in our box is "at rest," not a live shot to block # `predict_ball_pos_at_x` returns None the instant the ball's x reaches (or @@ -109,10 +122,26 @@ def _ball_needs_clearing(game: Game, robot_id: int) -> bool: return has_ball(game, robot_id, visual=True) +def _distribute(game: Game, motion_controller: MotionController, robot_id: int, ctx: Optional["TickContext"]): + """Kick the held ball to a teammate standing free, and only without one upfield.""" + teammate = open_teammate(game, robot_id, _KEEPER_PASS_CLEARANCE) + if teammate is None: + return kick_upfield(game, motion_controller, robot_id) + target_oren = game.friendly_robots[robot_id].p.angle_to(game.friendly_robots[teammate].p) + if ctx is not None and oriented_towards(game, robot_id, target_oren, ANNOUNCE_PASS_RAD): + ctx.expected_receivers.add(teammate) + if oriented_towards(game, robot_id, target_oren, _KEEPER_PASS_TOLERANCE_RAD): + return kick() + return turn_on_spot( + game=game, motion_controller=motion_controller, robot_id=robot_id, target_oren=target_oren, dribbling=True + ) + + def goalkeep( game: Game, motion_controller: MotionController, robot_id: int, + ctx: Optional["TickContext"] = None, ): """Move `robot_id` (the goalkeeper) to cover the predicted shot on the goal line. @@ -148,7 +177,7 @@ def goalkeep( # creep in the box until `KeeperHeldBallRule` fired (5-6 per round-robin). # Face the ball and take it onto the dribbler first, as retrieval does. return go_to_point(game, motion_controller, robot_id, game.ball.p.to_2d(), dribbling=True) - return kick_upfield(game, motion_controller, robot_id) + return _distribute(game, motion_controller, robot_id, ctx) edge_offset = BALL_RADIUS + ROBOT_RADIUS goal_x = game.field.my_goal_line[0][0] diff --git a/utama_core/skills/src/kick_upfield.py b/utama_core/skills/kick_upfield.py similarity index 68% rename from utama_core/skills/src/kick_upfield.py rename to utama_core/skills/kick_upfield.py index bd2f63dc4..ce885d4f0 100644 --- a/utama_core/skills/src/kick_upfield.py +++ b/utama_core/skills/kick_upfield.py @@ -7,11 +7,13 @@ `ShadowAndMarkTactic`. """ -from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.shared.pass_and_score_geometry import oriented_towards -from utama_core.skills.src.utils.move_utils import kick, turn_on_spot +from utama_core.geometry.pass_and_score_geometry import ( + oriented_towards, + upfield_heading, +) +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.skills.utils.move_utils import kick, turn_on_spot # A clearance only has to go upfield, not along a line: kick within ~11 degrees of it. With the # 0.05 rad shot/pass tolerance the real keeper never kicked (2026-10-27 field runs): 0.07 rad @@ -21,13 +23,11 @@ def kick_upfield(game: Game, motion_controller: MotionController, robot_id: int): - """Kick once facing straight upfield (away from our own goal, along the - field's long axis); until then, turn on the spot with the dribbler on. + """Kick once facing upfield (`upfield_heading`: straight, or off it when + that lane is blocked); until then, turn on the spot with the dribbler on. Assumes the ball is on `robot_id`'s dribbler — check contact `has_ball` first, a kick without it does nothing.""" - robot = game.friendly_robots[robot_id] - upfield_sign = -1.0 if game.my_team_is_right else 1.0 - target_oren = robot.p.angle_to(Vector2D(robot.p.x + upfield_sign * 2.0, robot.p.y)) + target_oren = upfield_heading(game, robot_id) if oriented_towards(game, robot_id, target_oren, CLEARANCE_TOLERANCE_RAD): return kick() return turn_on_spot( diff --git a/utama_core/skills/src/man_mark.py b/utama_core/skills/man_mark.py similarity index 59% rename from utama_core/skills/src/man_mark.py rename to utama_core/skills/man_mark.py index bc07ff222..b08c92891 100644 --- a/utama_core/skills/src/man_mark.py +++ b/utama_core/skills/man_mark.py @@ -11,12 +11,17 @@ `press_and_contain.py`. """ +import math + from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.skills.src.utils.move_utils import face_ball, move +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.skills.utils.move_utils import face_ball, move MARK_STANDOFF = 0.6 # metres — mark from this distance on the goal side of the opponent, not on top of them +_ON_BALL_M = 0.13 # robot centre to ball with both touching +_MIN_READ_PASS_M = 1.2 # nearer than the standoff and a bit, there is no room to step between them +_PASS_READ_RAD = 0.2 def mark_target(game: Game, opponent_id: int) -> Vector2D: @@ -26,9 +31,32 @@ def mark_target(game: Game, opponent_id: int) -> Vector2D: # Toward our own goal. The sign was reversed until 2026-10-05: markers stood on the # far side, leaving the opponent a clear run at goal. direction = -1.0 if goal_x < opponent.p.x else 1.0 + passer = _passer_facing(game, opponent_id) + if passer is not None: + # The ball is about to come to this opponent: stand in its way rather than behind it. + towards_passer = (passer.p - opponent.p).norm() + return opponent.p + towards_passer * MARK_STANDOFF return Vector2D(opponent.p.x + direction * MARK_STANDOFF, opponent.p.y) +def _passer_facing(game: Game, opponent_id: int): + """The enemy on the ball if it is facing `opponent_id` from far enough to pass to it.""" + ball = game.ball + if ball is None: + return None + here = ball.p.to_2d() + opponent = game.enemy_robots[opponent_id] + for enemy_id, enemy in game.enemy_robots.items(): + if enemy_id == opponent_id or enemy.p.distance_to(here) > _ON_BALL_M: + continue + if enemy.p.distance_to(opponent.p) < _MIN_READ_PASS_M: + continue + off = (enemy.p.angle_to(opponent.p) - enemy.orientation + math.pi) % (2.0 * math.pi) - math.pi + if abs(off) <= _PASS_READ_RAD: + return enemy + return None + + def man_mark(game: Game, motion_controller: MotionController, robot_id: int, target_id: int): """Move `robot_id` to `mark_target` for `target_id`, facing the ball.""" robot = game.friendly_robots[robot_id] diff --git a/utama_core/skills/src/score_goal.py b/utama_core/skills/score_goal.py similarity index 99% rename from utama_core/skills/src/score_goal.py rename to utama_core/skills/score_goal.py index 9a893e100..d4c7db971 100644 --- a/utama_core/skills/src/score_goal.py +++ b/utama_core/skills/score_goal.py @@ -20,9 +20,7 @@ from utama_core.config.physical_constants import ROBOT_RADIUS from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game, Robot -from utama_core.global_utils.math_utils import ( - angle_between_points as _angle_between_points, -) +from utama_core.geometry.math_utils import angle_between_points as _angle_between_points logger = logging.getLogger(__name__) diff --git a/utama_core/skills/src/shielding.py b/utama_core/skills/shielding.py similarity index 100% rename from utama_core/skills/src/shielding.py rename to utama_core/skills/shielding.py diff --git a/utama_core/skills/src/utils/defense_utils.py b/utama_core/skills/utils/defense_utils.py similarity index 100% rename from utama_core/skills/src/utils/defense_utils.py rename to utama_core/skills/utils/defense_utils.py diff --git a/utama_core/skills/src/utils/move_utils.py b/utama_core/skills/utils/move_utils.py similarity index 76% rename from utama_core/skills/src/utils/move_utils.py rename to utama_core/skills/utils/move_utils.py index e33aa7c12..dcd2add5b 100644 --- a/utama_core/skills/src/utils/move_utils.py +++ b/utama_core/skills/utils/move_utils.py @@ -7,15 +7,52 @@ from utama_core.entities.data.command import RobotCommand from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.global_utils.math_utils import normalise_heading, rotate_vector -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.geometry.math_utils import normalise_heading, rotate_vector +from utama_core.motion_planning.common.motion_controller import MotionController # Off its target orientation by more than this, a robot turns at least `MotionController.min_turn`. _MIN_TURN_FROM_RAD = 0.01 +# Crashing is a foul above 1.5 m/s of closing speed. In 12 matches on 2026-11-09 all 33 charges +# were head-on, both robots closing at 1.2-1.5 m/s from 1.5-2 m apart and neither braking: the +# path planner steers around robots but does not slow for them. Each robot sheds its own share, +# so two robots using this meet legally, and one facing an enemy that does not slow is the slower. +_LEGAL_CLOSING_MPS = 1.3 +_MIN_CONTACT_APPROACH_MPS = 0.5 +_ENEMY_BRAKING_MPS2 = 3.0 # of rsim's 4 m/s²: leaves room for the command delay +_ENEMY_BRAKING_RANGE_M = 1.2 + ### TODO: IT IS CONTENTIOUS IF WE EVEN NEED THIS MOVE FUNCTION ANYMORE. POTENTIALLY JUST SEND DIRECTLY TO MOTION CONTROLLER ### +def _limit_closing_speed(robot, enemies, velocity: Vector2D) -> Vector2D: + """`velocity` with its component towards each nearby enemy capped to what can still brake.""" + vx, vy = velocity.x, velocity.y + for enemy in enemies: + dx, dy = enemy.p.x - robot.p.x, enemy.p.y - robot.p.y + distance = math.hypot(dx, dy) + if not 1e-6 < distance < _ENEMY_BRAKING_RANGE_M: + continue + ux, uy = dx / distance, dy / distance + approach = vx * ux + vy * uy + enemy_approach = max(0.0, -(enemy.v.x * ux + enemy.v.y * uy)) + at_contact = max(_MIN_CONTACT_APPROACH_MPS, _LEGAL_CLOSING_MPS - enemy_approach) + limit = at_contact + math.sqrt(_ENEMY_BRAKING_MPS2 * max(0.0, distance - 2.0 * ROBOT_RADIUS)) + if approach > limit: + vx -= (approach - limit) * ux + vy -= (approach - limit) * uy + return Vector2D(vx, vy) if (vx, vy) != (velocity.x, velocity.y) else velocity + + +def _sprint_velocity(position: Vector2D, target: Vector2D, max_speed: float, max_acceleration: float) -> Vector2D: + """Towards `target`, as fast as a robot braking at `max_acceleration` can still stop on it.""" + offset = target - position + distance = offset.mag() + if distance == 0.0: + return Vector2D(0.0, 0.0) + return offset * (min(max_speed, math.sqrt(2.0 * max_acceleration * distance)) / distance) + + def move( game: Game, motion_controller: MotionController, @@ -23,8 +60,11 @@ def move( target_coords: Vector2D, target_oren: float, dribbling: bool = False, + sprint: bool = False, ) -> RobotCommand: - """Calculate the robot command to move towards a target point with a specified orientation.""" + """Calculate the robot command to move towards a target point with a specified orientation. + `sprint`: straight at the target, as fast as it can still stop there, instead of along the planner's + path, which covers a short hop at about 0.45 m/s. Only for a short, clear step that cannot wait.""" # From where our robots will be when this command takes effect (`PoseAhead`), and in the # robot's frame as it will be turned by then. @@ -38,8 +78,14 @@ def move( target_oren=target_oren, ) + if sprint: + global_velocity = _sprint_velocity( + robot.p, target_coords, motion_controller.max_speed, motion_controller.max_acceleration + ) + capped_velocity = _limit_closing_speed(robot, ahead.enemy_robots.values(), global_velocity) + adjusted = sprint or capped_velocity is not global_velocity + global_velocity = capped_velocity forward_vel, left_vel = rotate_vector(global_velocity.x, global_velocity.y, robot.orientation) - adjusted = False # A turn slower than the robot can make leaves it short of its target orientation for good. min_turn = motion_controller.min_turn diff --git a/utama_core/strategy/overload_press.py b/utama_core/strategy/avalanche.py similarity index 83% rename from utama_core/strategy/overload_press.py rename to utama_core/strategy/avalanche.py index 402ad69e3..47fb29197 100644 --- a/utama_core/strategy/overload_press.py +++ b/utama_core/strategy/avalanche.py @@ -1,4 +1,4 @@ -"""The `overload_press` kernel strategy: `build_overload_press_kernel_strategy` and the pickers only it uses.""" +"""`avalanche` (until 2026-11-12 `overload_press`): floods one area with four robots, one blocks. The pickers only it uses are here.""" from __future__ import annotations @@ -8,7 +8,7 @@ from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy from utama_core.engine.tactic import RobotId from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController from utama_core.strategy.pickers import ( allocate_ordered, carrier_first, @@ -42,7 +42,7 @@ # --------------------------------------------------------------------------- -def _overload_press_picker( +def _avalanche_picker( game: Game, free_robots: frozenset[RobotId], prev_partition: Optional[dict[str, frozenset[RobotId]]], @@ -96,35 +96,32 @@ def _overload_press_picker( return {} -def build_overload_press_kernel_strategy(outfield_robot_ids: tuple[int, ...]): +def build(outfield_robot_ids: tuple[int, ...], motion_controller: MotionController) -> KernelSchedulerStrategy: """Numbers-overload team built to beat tiki_taka's shot-line-only shadow defense, with a direct pre-press counter for the transition window. Four concurrent slots — `DecoyOverloadTactic` ("overload"), `SwitchOfPlayTactic` ("switch"), `LeadAndSupportTactic` ("counter"), and - `BlockShapeTactic` ("block") — allocated by `_overload_press_picker`: + `BlockShapeTactic` ("block") — allocated by `_avalanche_picker`: 4 robots overload/switch the attack (more bodies than tiki_taka's 2-robot defense slot ever marks) with 1 held on the block screen while we have the ball; on loss, the whole team goes direct via the counter rather than building a press, to hit before tiki_taka's own 3-press organizes. - Returns a `build_kernel_strategy(motion_controller)` + Returns a `build(motion_controller)` callable suitable for `AbstractStrategy`'s constructor argument of the same name. """ - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={ - "overload": DecoyOverloadTactic(), - "switch": SwitchOfPlayTactic(), - "counter": LeadAndSupportTactic(), - "block": BlockShapeTactic(), - }, - partitioner=_overload_press_picker, - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build + ctx = TickContext(motion_controller=motion_controller) + return KernelSchedulerStrategy( + tactics={ + "overload": DecoyOverloadTactic(), + "switch": SwitchOfPlayTactic(), + "counter": LeadAndSupportTactic(), + "block": BlockShapeTactic(), + }, + partitioner=_avalanche_picker, + outfield_robot_ids=outfield_robot_ids, + ctx=ctx, + ) diff --git a/utama_core/strategy/clear_press_plus.py b/utama_core/strategy/breakwater.py similarity index 73% rename from utama_core/strategy/clear_press_plus.py rename to utama_core/strategy/breakwater.py index 5257f8130..d84051236 100644 --- a/utama_core/strategy/clear_press_plus.py +++ b/utama_core/strategy/breakwater.py @@ -1,4 +1,4 @@ -"""The `clear_press_plus` kernel strategy: `build_clear_press_plus_kernel_strategy` and the pickers only it uses.""" +"""`breakwater` (until 2026-11-12 `clear_press_plus`): breaks attacks, clears danger from its own third, then overloads the final third. The pickers only it uses are here.""" from __future__ import annotations @@ -8,7 +8,7 @@ from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy from utama_core.engine.tactic import RobotId from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController from utama_core.strategy.pickers import ( allocate_ordered, ball_zone, @@ -23,12 +23,12 @@ from utama_core.tactics.press_and_contain import PressAndContainTactic # --------------------------------------------------------------------------- -# clear_press_plus (2026-09-02 addition) +# breakwater (2026-09-02 addition) # # Stacks the catalog's two most validated single-wrinkle additions onto one -# base instead of picking between them: `clear_danger`'s safety valve (a +# base instead of picking between them: `firebreak`'s safety valve (a # deep-and-contested own-third clearance, the one situational gap no other -# strategy fills) plus `tiki_taka_plus`'s final-third overload handoff (the +# strategy fills) plus `weaver`'s final-third overload handoff (the # only other single-wrinkle addition with a confirmed independent win -- # 10W-6D in its most recent tournament, clearing the field outright). The # two wrinkles fire in disjoint game states by construction (the valve needs @@ -38,19 +38,19 @@ # --------------------------------------------------------------------------- -def _clear_press_plus_picker( +def _breakwater_picker( game: Game, free_robots: frozenset[RobotId], prev_partition: Optional[dict[str, frozenset[RobotId]]], available_tactic_ids: frozenset[str], ) -> dict[str, frozenset[RobotId]]: - """`_clear_danger_picker`'s allocation, with `_tiki_taka_plus_picker`'s + """`_firebreak_picker`'s allocation, with `_weaver_picker`'s final-third handoff grafted onto its attacking branch: when we hold the ball and it is not deep-and-contested in our own third, the final third hands off from the give-and-go trio to the 2-robot overload duet instead of running give-and-go the length of the pitch. The clearance valve and the losing-possession press/block branches are unchanged from - `_clear_danger_picker`. + `_firebreak_picker`. """ ordered = carrier_first(game, free_robots) if not ordered: @@ -97,35 +97,32 @@ def _clear_press_plus_picker( return {} -def build_clear_press_plus_kernel_strategy(outfield_robot_ids: tuple[int, ...]): - """`clear_danger` plus `tiki_taka_plus`'s final-third overload handoff. +def build(outfield_robot_ids: tuple[int, ...], motion_controller: MotionController) -> KernelSchedulerStrategy: + """`firebreak` plus `weaver`'s final-third overload handoff. Five concurrent slots -- `GiveAndGoTactic` ("attack"), `DecoyOverloadTactic` ("overload"), `ClearBallTactic` ("clear"), `PressAndContainTactic` ("press"), and `BlockShapeTactic` ("block") -- - allocated by `_clear_press_plus_picker`: identical to `clear_danger` + allocated by `_breakwater_picker`: identical to `firebreak` except the attacking branch hands off from give-and-go to the overload duet once the ball reaches the final third, the same swap - `tiki_taka_plus` validated on `tiki_taka`'s base. + `weaver` validated on `tiki_taka`'s base. - Returns a `build_kernel_strategy(motion_controller)` + Returns a `build(motion_controller)` callable suitable for `AbstractStrategy`'s constructor argument of the same name. """ - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={ - "attack": GiveAndGoTactic(), - "overload": DecoyOverloadTactic(), - "clear": ClearBallTactic(), - "press": PressAndContainTactic(), - "block": BlockShapeTactic(), - }, - partitioner=_clear_press_plus_picker, - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build + ctx = TickContext(motion_controller=motion_controller) + return KernelSchedulerStrategy( + tactics={ + "attack": GiveAndGoTactic(), + "overload": DecoyOverloadTactic(), + "clear": ClearBallTactic(), + "press": PressAndContainTactic(), + "block": BlockShapeTactic(), + }, + partitioner=_breakwater_picker, + outfield_robot_ids=outfield_robot_ids, + ctx=ctx, + ) diff --git a/utama_core/strategy/catalog.py b/utama_core/strategy/catalog.py new file mode 100644 index 000000000..fdf35223d --- /dev/null +++ b/utama_core/strategy/catalog.py @@ -0,0 +1,61 @@ +"""The strategies: a module in this package with one `build(outfield_robot_ids, motion_controller)`. + +The module's name is the strategy's name, so a new strategy is a new file and nothing else. +""" + +from __future__ import annotations + +from functools import partial +from importlib import import_module +from pathlib import Path +from typing import Callable + +_PACKAGE = Path(__file__).parent + + +def names() -> list[str]: + """Every strategy, found from source: importing them all would run every module's import-time code.""" + return sorted(p.stem for p in _PACKAGE.glob("*.py") if "\ndef build(" in p.read_text()) + + +TEST_ONLY = "default" # everyone attacks with one tactic: the tests' minimal strategy, never a player + + +def player_names() -> list[str]: + """Every strategy that plays matches: `names()` without the tests' minimal one.""" + return [name for name in names() if name != TEST_ONLY] + + +# The names strategies had until 2026-11-12, so old replays and summaries still load. Only `builder` +# and `current_name` read this: replay files keep the names they were saved under, so `plain_name` +# (which tools use to find those files) does not. +RENAMED = { + "split_shape": "pendulum", + "clear_press_plus": "breakwater", + "overload_press": "avalanche", + "high_press": "wolfpack", + "decoy_and_overload": "mirage", + "counter_flow": "riptide", + "score_aware_counter_flow": "chameleon", + "press_trigger_flow": "tripwire", + "clear_danger": "firebreak", + "press_and_pass": "terrier", + "tiki_taka_plus": "weaver", + "give_and_go_solo": "ricochet", +} + + +def current_name(name: str) -> str: + """`name` as the catalog calls it today: old `build_*_kernel_strategy` and pre-2026-11-12 names map on.""" + plain = plain_name(name) + return RENAMED.get(plain, plain) + + +def builder(name: str, outfield_robot_ids: tuple[int, ...]) -> Callable: + """`AbstractStrategy`'s first argument for strategy `name` (an old name works too).""" + return partial(import_module(f"utama_core.strategy.{current_name(name)}").build, outfield_robot_ids) + + +def plain_name(name: str) -> str: + """`name`, also accepting the `build__kernel_strategy` of replays recorded before 2026-11-10.""" + return name.removeprefix("build_").removesuffix("_kernel_strategy") diff --git a/utama_core/strategy/score_aware_counter_flow.py b/utama_core/strategy/chameleon.py similarity index 72% rename from utama_core/strategy/score_aware_counter_flow.py rename to utama_core/strategy/chameleon.py index d2ccae48d..e68d28ac1 100644 --- a/utama_core/strategy/score_aware_counter_flow.py +++ b/utama_core/strategy/chameleon.py @@ -1,4 +1,4 @@ -"""The `score_aware_counter_flow` kernel strategy: `build_score_aware_counter_flow_kernel_strategy` and the pickers only it uses.""" +"""`chameleon` (until 2026-11-12 `score_aware_counter_flow`): `riptide` that changes its play with the score. The pickers only it uses are here.""" from __future__ import annotations @@ -8,7 +8,7 @@ from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy from utama_core.engine.tactic import RobotId from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController from utama_core.strategy.pickers import ( allocate_ordered, carrier_first, @@ -21,35 +21,35 @@ from utama_core.tactics.press_and_contain import PressAndContainTactic # --------------------------------------------------------------------------- -# score_aware_counter_flow (2026-09-02 addition) +# chameleon (2026-09-02 addition) # # `score_aware_zone_flow` validated the scoreline-aware attack/defense split # shift as a free improvement grafted onto `zone_fluid`'s picker with zero # other changes -- but `zone_fluid` is one of the catalog's weaker bases # (2W-6D-5L in the 2026-08-21 backfill). This strategy applies the identical # mechanism (shrink the attacking commitment when ahead late, grow it when -# behind late) to `counter_flow`'s picker instead -- the catalog's only +# behind late) to `riptide`'s picker instead -- the catalog's only # undefeated strategy, 0L across every backfill/tournament to date. Every # other axis is left untouched: same 3 tactics (`GiveAndGoTactic`/ # `PressAndContainTactic`/`BlockShapeTactic`), same sticky possession-edge # hysteresis, same 3/2 split everywhere except the late-game scoreline -# branch -- so any observed difference from plain `counter_flow` is +# branch -- so any observed difference from plain `riptide` is # attributable to the new scoreline input alone, not a different base. # --------------------------------------------------------------------------- -def _score_aware_counter_flow_picker( +def _chameleon_picker( game: Game, free_robots: frozenset[RobotId], prev_partition: Optional[dict[str, frozenset[RobotId]]], available_tactic_ids: frozenset[str], ) -> dict[str, frozenset[RobotId]]: - """`_counter_flow_picker`'s allocation, with the attacking commitment size + """`_riptide_picker`'s allocation, with the attacking commitment size shifted late in a half by whether we're ahead or behind -- see `_score_aware_zone_flow_picker` for the identical mechanism applied to a different base. - Not late, tied, or score unreadable: identical to `_counter_flow_picker` + Not late, tied, or score unreadable: identical to `_riptide_picker` (3 attack/2 block when we hold the edge, 3 press/2 block when we don't). Late and ahead: only 2 attack, 3 block -- protect the lead behind a heavier screen. Late and behind: 4 attack, 1 block -- chase an @@ -97,29 +97,26 @@ def _score_aware_counter_flow_picker( return {} -def build_score_aware_counter_flow_kernel_strategy(outfield_robot_ids: tuple[int, ...]): - """`counter_flow` (the catalog's only undefeated strategy) with the same +def build(outfield_robot_ids: tuple[int, ...], motion_controller: MotionController) -> KernelSchedulerStrategy: + """`riptide` (the catalog's only undefeated strategy) with the same scoreline-aware attack-commitment shift `score_aware_zone_flow` validated - on a weaker base. Same three tactics/slots as `counter_flow` + on a weaker base. Same three tactics/slots as `riptide` (`GiveAndGoTactic`/`PressAndContainTactic`/`BlockShapeTactic`) and the same sticky possession-edge hysteresis -- only the picker's late-game - attack-count decision differs. See `_score_aware_counter_flow_picker`. + attack-count decision differs. See `_chameleon_picker`. - Returns a `build_kernel_strategy(motion_controller)` callable suitable + Returns a `build(motion_controller)` callable suitable for `AbstractStrategy`'s constructor argument of the same name. """ - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={ - "attack": GiveAndGoTactic(), - "press": PressAndContainTactic(), - "block": BlockShapeTactic(), - }, - partitioner=_score_aware_counter_flow_picker, - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build + ctx = TickContext(motion_controller=motion_controller) + return KernelSchedulerStrategy( + tactics={ + "attack": GiveAndGoTactic(), + "press": PressAndContainTactic(), + "block": BlockShapeTactic(), + }, + partitioner=_chameleon_picker, + outfield_robot_ids=outfield_robot_ids, + ctx=ctx, + ) diff --git a/utama_core/strategy/counter_press.py b/utama_core/strategy/counter_press.py deleted file mode 100644 index 03009ca68..000000000 --- a/utama_core/strategy/counter_press.py +++ /dev/null @@ -1,97 +0,0 @@ -"""The `counter_press` kernel strategy: `build_counter_press_kernel_strategy` and the pickers only it uses.""" - -from __future__ import annotations - -from typing import Optional - -from utama_core.engine.context import TickContext -from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy -from utama_core.engine.tactic import RobotId -from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.strategy.pickers import ( - allocate_ordered, - carrier_first, - friendly_closer_to_ball, -) -from utama_core.tactics.block_shape import BlockShapeTactic -from utama_core.tactics.press_and_contain import PressAndContainTactic -from utama_core.tactics.switch_of_play import SwitchOfPlayTactic - - -def _counter_press_picker( - game: Game, - free_robots: frozenset[RobotId], - prev_partition: Optional[dict[str, frozenset[RobotId]]], - available_tactic_ids: frozenset[str], -) -> dict[str, frozenset[RobotId]]: - """Counter-press posture: all-out pressure when we lose it, low block when - there is nothing to press, four-up on the switch when we regain it. - - - Opponent has the ball and pressing is possible: everyone presses - (1 ball-presser + everyone else man-marking) — the ball is smothered - where it was lost. - - Opponent has the ball but nothing is pressable: everyone holds the - `block_shape` zone screen — the compact low block. - - We have the ball: the switch-of-play needs its three roles - (carrier/pivot/runner), so 4 robots attack through the weak side while - 1 keeps the screen shape as insurance on the counter. - """ - ordered = carrier_first(game, free_robots) - if not ordered: - return {} - - friendly_edge = friendly_closer_to_ball(game) - losing = friendly_edge is not True - - press_ok = "press" in available_tactic_ids - attack_ok = "attack" in available_tactic_ids - block_ok = "block" in available_tactic_ids - - if losing: - if press_ok: - return allocate_ordered(ordered, "press", len(ordered)) - if block_ok: - return allocate_ordered(ordered, "block", len(ordered)) - if attack_ok: - return allocate_ordered(ordered, "attack", len(ordered)) - return {} - if attack_ok: - return allocate_ordered(ordered, "attack", 4, "block" if block_ok else None) - if block_ok: - return allocate_ordered(ordered, "block", len(ordered)) - return {} - - -def build_counter_press_kernel_strategy(outfield_robot_ids: tuple[int, ...]): - """High-intensity transition team: smother the ball where it was lost, - then switch the play to the weak side at full commitment. - - Three concurrent slots — `SwitchOfPlayTactic` ("attack"), - `PressAndContainTactic` ("press"), and the new `BlockShapeTactic` - ("block") — allocated by `_counter_press_picker`: everyone presses while - the opponent has it (and something is pressable), everyone drops into - the zone screen when they are shielded from the press, and 4 robots - attack through the pivot/runner switch the moment the ball is won. The - three-role switch (carrier/pivot/runner) needs at least 3 robots, hence - the 4+1 split. - - Returns a `build_kernel_strategy(motion_controller)` - callable suitable for `AbstractStrategy`'s constructor argument of the - same name. - """ - - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={ - "attack": SwitchOfPlayTactic(), - "press": PressAndContainTactic(), - "block": BlockShapeTactic(), - }, - partitioner=_counter_press_picker, - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build diff --git a/utama_core/strategy/default.py b/utama_core/strategy/default.py index 8b6286c8b..7bd01b682 100644 --- a/utama_core/strategy/default.py +++ b/utama_core/strategy/default.py @@ -1,14 +1,14 @@ -"""The `default` kernel strategy: `build_default_kernel_strategy` and the pickers only it uses.""" +"""The `default` kernel strategy: `default` and the pickers only it uses.""" from __future__ import annotations from utama_core.engine.context import TickContext from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController from utama_core.tactics.pass_and_shoot import PassAndShootTactic -def build_default_kernel_strategy(outfield_robot_ids: tuple[int, ...]): +def build(outfield_robot_ids: tuple[int, ...], motion_controller: MotionController) -> KernelSchedulerStrategy: """Minimal, single-tactic-pool `Strategy` factory: everyone attacks. Only one real multi-robot tactic exists so far (`pass_and_shoot`), so @@ -18,18 +18,15 @@ def build_default_kernel_strategy(outfield_robot_ids: tuple[int, ...]): Callers with more than one outfield tactic should build their own `Strategy` with a real `Picker` instead of using this helper. - Returns a `build_kernel_strategy(motion_controller)` + Returns a `build(motion_controller)` callable suitable for `AbstractStrategy`'s constructor argument of the same name. """ - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={"pass_and_shoot": PassAndShootTactic()}, - partitioner=KernelSchedulerStrategy.single_tactic_picker(lambda game, active: "pass_and_shoot"), - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build + ctx = TickContext(motion_controller=motion_controller) + return KernelSchedulerStrategy( + tactics={"pass_and_shoot": PassAndShootTactic()}, + partitioner=KernelSchedulerStrategy.single_tactic_picker(lambda game, active: "pass_and_shoot"), + outfield_robot_ids=outfield_robot_ids, + ctx=ctx, + ) diff --git a/utama_core/strategy/clear_danger.py b/utama_core/strategy/firebreak.py similarity index 73% rename from utama_core/strategy/clear_danger.py rename to utama_core/strategy/firebreak.py index cbb9e4b3a..c5278e9bb 100644 --- a/utama_core/strategy/clear_danger.py +++ b/utama_core/strategy/firebreak.py @@ -1,4 +1,4 @@ -"""The `clear_danger` kernel strategy: `build_clear_danger_kernel_strategy` and the pickers only it uses.""" +"""`firebreak` (until 2026-11-12 `clear_danger`): `riptide` that clears the ball out of its own third when it is in danger. The pickers only it uses are here.""" from __future__ import annotations @@ -8,7 +8,7 @@ from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy from utama_core.engine.tactic import RobotId from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController from utama_core.strategy.pickers import ( allocate_ordered, carrier_first, @@ -21,13 +21,13 @@ from utama_core.tactics.press_and_contain import PressAndContainTactic -def _clear_danger_picker( +def _firebreak_picker( game: Game, free_robots: frozenset[RobotId], prev_partition: Optional[dict[str, frozenset[RobotId]]], available_tactic_ids: frozenset[str], ) -> dict[str, frozenset[RobotId]]: - """Safety-valve posture: counter_flow's proven attack/press/block postures, + """Safety-valve posture: riptide's proven attack/press/block postures, plus a danger valve — when the ball is deep in our own third AND contested (`ClearBallTactic.applicable()`, the real §15 gate this config exists to exercise), one robot clears it long while everyone else holds the screen. @@ -36,19 +36,19 @@ def _clear_danger_picker( other postures: building out of a contested own-third pocket is exactly what `GiveAndGoTactic` should not be doing (its hops are short by design), and pressing leaves nobody removing the ball. - - Lost, no danger: counter_flow's defensive posture — press 3 + block 2 + - Lost, no danger: riptide's defensive posture — press 3 + block 2 when something is pressable, all-block otherwise. - - Won: counter_flow's attacking posture — attack 3 + block 2. + - Won: riptide's attacking posture — attack 3 + block 2. The press slot is NOT optional here (an earlier draft dropped it in favour of block-everyone-unless-danger): traced live, that team never contests any ball anywhere — possession collapsed to ~1% as the opponent's carrier parked unpressured at midfield, and the ball never even reached our third, so the valve itself never fired. Ball control, not territory, is the bottleneck - (the same lesson as `go_to_ball`'s shield fix); counter_flow's press stays, + (the same lesson as `go_to_ball`'s shield fix); riptide's press stays, the valve rides on top of it. - Sticky possession edge, same fix `_counter_flow_picker`/`_high_line_zone_picker` + Sticky possession edge, same fix `_riptide_picker`/`_high_line_zone_picker` needed: re-reading `friendly_closer_to_ball` every tick flips constantly in a genuinely contested match and resets `GiveAndGoTactic`'s hop cycle before a single hop completes. `prev_partition` ("did we hold attack last tick") is @@ -97,36 +97,33 @@ def _clear_danger_picker( return {} -def build_clear_danger_kernel_strategy(outfield_robot_ids: tuple[int, ...]): - """Safety-valve team: counter_flow's postures plus a danger-clearance valve. +def build(outfield_robot_ids: tuple[int, ...], motion_controller: MotionController) -> KernelSchedulerStrategy: + """Safety-valve team: riptide's postures plus a danger-clearance valve. Four concurrent slots — `GiveAndGoTactic` ("attack"), `ClearBallTactic` ("clear"), `PressAndContainTactic` ("press"), and - `BlockShapeTactic` ("block") — allocated by `_clear_danger_picker`. - Identical to `counter_flow` whenever the ball is not deep-and-contested in + `BlockShapeTactic` ("block") — allocated by `_firebreak_picker`. + Identical to `riptide` whenever the ball is not deep-and-contested in our own third; when it is, the valve takes one robot and removes the ball instead of only screening it. Fills the one hole the catalog has: no existing tactic ever deliberately kicks the ball out of danger (the only kick sites aim at the enemy goal), so pinned-deep teams can only shadow/mark/block and wait. - Returns a `build_kernel_strategy(motion_controller)` + Returns a `build(motion_controller)` callable suitable for `AbstractStrategy`'s constructor argument of the same name. """ - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={ - "attack": GiveAndGoTactic(), - "clear": ClearBallTactic(), - "press": PressAndContainTactic(), - "block": BlockShapeTactic(), - }, - partitioner=_clear_danger_picker, - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build + ctx = TickContext(motion_controller=motion_controller) + return KernelSchedulerStrategy( + tactics={ + "attack": GiveAndGoTactic(), + "clear": ClearBallTactic(), + "press": PressAndContainTactic(), + "block": BlockShapeTactic(), + }, + partitioner=_firebreak_picker, + outfield_robot_ids=outfield_robot_ids, + ctx=ctx, + ) diff --git a/utama_core/strategy/give_and_go_solo.py b/utama_core/strategy/give_and_go_solo.py deleted file mode 100644 index 4e6fdb593..000000000 --- a/utama_core/strategy/give_and_go_solo.py +++ /dev/null @@ -1,35 +0,0 @@ -"""The `give_and_go_solo` kernel strategy: `build_give_and_go_solo_kernel_strategy` and the pickers only it uses.""" - -from __future__ import annotations - -from utama_core.engine.context import TickContext -from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.tactics.give_and_go import GiveAndGoTactic - - -def build_give_and_go_solo_kernel_strategy(outfield_robot_ids: tuple[int, ...]): - """Single-tactic `Strategy` factory: the entire outfield pool always runs - `GiveAndGoTactic`, no defense slot at all. Mirrors - `build_default_kernel_strategy`'s shape (single Tactic, no real - allocation decision, via `single_tactic_picker`) but for the newer - passing tactic — useful as an isolated benchmark/eval config when - testing `GiveAndGoTactic` in isolation matters more than realistic match - posture (e.g. tuning `_MAX_HOPS_PER_POSSESSION` or the support-scoring - weights without a defensive Tactic's behaviour as a confound). - - Returns a `build_kernel_strategy(motion_controller)` - callable suitable for `AbstractStrategy`'s constructor argument of the - same name. - """ - - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={"attack": GiveAndGoTactic()}, - partitioner=KernelSchedulerStrategy.single_tactic_picker(lambda game, active: "attack"), - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build diff --git a/utama_core/strategy/high_line_zone.py b/utama_core/strategy/high_line_zone.py deleted file mode 100644 index 74d2d690f..000000000 --- a/utama_core/strategy/high_line_zone.py +++ /dev/null @@ -1,131 +0,0 @@ -"""The `high_line_zone` kernel strategy: `build_high_line_zone_kernel_strategy` and the pickers only it uses.""" - -from __future__ import annotations - -from typing import Optional - -from utama_core.engine.context import TickContext -from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy -from utama_core.engine.tactic import RobotId -from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.strategy.pickers import ( - allocate_ordered, - ball_zone, - carrier_first, - friendly_closer_to_ball, -) -from utama_core.tactics.block_shape import BlockShapeTactic -from utama_core.tactics.decoy_and_overload import DecoyOverloadTactic -from utama_core.tactics.switch_of_play import SwitchOfPlayTactic - - -def _high_line_zone_picker( - game: Game, - free_robots: frozenset[RobotId], - prev_partition: Optional[dict[str, frozenset[RobotId]]], - available_tactic_ids: frozenset[str], -) -> dict[str, frozenset[RobotId]]: - """High-line zone posture: deny tiki_taka's give-and-go trio the 1v1s it - wants with a zone screen instead of man-marking, switch the ball to the - weak side its 2-robot defense can't cover, finish with the overload duet - once we're through. - - - The opponent has the ball: the whole team holds `BlockShapeTactic`'s - shifting zone line — tiki_taka's give-and-go build-up is a 3-robot - short-passing relay that thrives against man-marking cover it can - dribble/pass past one defender at a time; a zone screen that shifts - with the ball and never breaks shape denies it the individual - matchups it's built around, unlike `ShadowAndMarkTactic`'s greedy - per-robot marking (which is what tiki_taka's own defense runs, and - exactly the shape `overload_press` targets instead). - - We have the ball, not yet in the final third: `SwitchOfPlayTactic` - leads — tiki_taka's defense is only ever 2 robots, so a genuine - weak-side imbalance is easy to manufacture; 2 hold the block screen as - insurance against the counter. - - We have the ball in the final third: switch to the overload duet - (`DecoyOverloadTactic`) to finish, same final-third handoff - `_zone_flow_picker` uses — the switch has already done its job of - breaking the defense's shape open by this point. - """ - ordered = carrier_first(game, free_robots) - if not ordered: - return {} - - block_ok = "block" in available_tactic_ids - switch_ok = "switch" in available_tactic_ids - overload_ok = "overload" in available_tactic_ids - - # Sticky possession edge: a plain `friendly_closer_to_ball` re-read every - # tick flips constantly in a genuinely contested 50/50 (measured: switch - # assigned and released again within single-digit ticks, over and over, - # for the first ~10s of a live match against tiki_taka) — `switch`'s - # carrier/pivot/runner relay needs several seconds to settle and never - # got the chance, discarded before `is_committed()` ever saw it commit. - # `prev_partition` is this picker's only persistent state (a `Partitioner` - # is a plain function, no `mem` of its own — unlike a `Tactic`, which - # gets one), so use "did we hold switch/overload last tick" as the - # attacking side's memory and require a full possession loss (proximity - # edge, not just "not clearly ahead") before dropping it. Mirrors - # `SwitchOfPlayTactic`'s own internal weak-side hysteresis, one level up. - prev_partition = prev_partition or {} - currently_attacking = bool(prev_partition.get("switch")) or bool(prev_partition.get("overload")) - friendly_edge = friendly_closer_to_ball(game) - if currently_attacking: - losing = friendly_edge is False # only give up the ball on a clear loss, not just "unknown" - else: - losing = friendly_edge is not True # regaining needs a clear win, same conservative default as elsewhere - - if losing: - if block_ok: - return allocate_ordered(ordered, "block", len(ordered)) - if switch_ok: - return allocate_ordered(ordered, "switch", len(ordered)) - if overload_ok: - return allocate_ordered(ordered, "overload", len(ordered)) - return {} - - zone = ball_zone(game) - if zone == "final" and overload_ok: - return allocate_ordered(ordered, "overload", 2, "block" if block_ok else None) - if switch_ok: - return allocate_ordered(ordered, "switch", 3, "block" if block_ok else None) - if overload_ok: - return allocate_ordered(ordered, "overload", len(ordered)) - if block_ok: - return allocate_ordered(ordered, "block", len(ordered)) - return {} - - -def build_high_line_zone_kernel_strategy(outfield_robot_ids: tuple[int, ...]): - """Zone-defense team built to deny tiki_taka's give-and-go trio the 1v1s - it's designed around, switching the ball past its thin 2-robot cover. - - Three concurrent slots — `SwitchOfPlayTactic` ("switch"), - `DecoyOverloadTactic` ("overload"), and `BlockShapeTactic` ("block") — - allocated by `_high_line_zone_picker`: the whole team holds the zone - screen when the ball is lost (denying man-marking 1v1s instead of - running them, unlike tiki_taka's own `ShadowAndMarkTactic` defense); - 3 robots read the weak side and switch there once we have it (tiki_taka's - defense is always just 2 robots — an imbalance is easy to create); the - final third hands off to the overload duet to finish. - - Returns a `build_kernel_strategy(motion_controller)` - callable suitable for `AbstractStrategy`'s constructor argument of the - same name. - """ - - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={ - "switch": SwitchOfPlayTactic(), - "overload": DecoyOverloadTactic(), - "block": BlockShapeTactic(), - }, - partitioner=_high_line_zone_picker, - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build diff --git a/utama_core/strategy/kernel_strategy.py b/utama_core/strategy/kernel_strategy.py deleted file mode 100644 index 4ad83506a..000000000 --- a/utama_core/strategy/kernel_strategy.py +++ /dev/null @@ -1,72 +0,0 @@ -"""Kernel `Strategy` factories — `build_kernel_strategy(motion_controller) -> Strategy` -callables suitable for `AbstractStrategy`'s constructor argument of the same name. - -See `utama_core.engine.abstract_strategy.AbstractStrategy` for the class that -consumes these and drives them under `StrategyRunner`. - -Each factory lives in its own module, `utama_core/strategy/.py`, next to the pickers only it -uses; helpers shared by more than one strategy are in `pickers.py`. This module only re-exports them, so -`from utama_core.strategy.kernel_strategy import build_X_kernel_strategy` and `dir(kernel_strategy)` -discovery keep working. The private pickers re-exported below are the ones tests import. -""" - -# ruff: noqa: F401 - -from utama_core.strategy.clear_danger import ( - _clear_danger_picker, - build_clear_danger_kernel_strategy, -) -from utama_core.strategy.clear_press_plus import ( - _clear_press_plus_picker, - build_clear_press_plus_kernel_strategy, -) -from utama_core.strategy.counter_flow import ( - _counter_flow_picker, - build_counter_flow_kernel_strategy, -) -from utama_core.strategy.counter_press import ( - _counter_press_picker, - build_counter_press_kernel_strategy, -) -from utama_core.strategy.decoy_and_overload import ( - build_decoy_and_overload_kernel_strategy, -) -from utama_core.strategy.default import build_default_kernel_strategy -from utama_core.strategy.give_and_go_solo import build_give_and_go_solo_kernel_strategy -from utama_core.strategy.high_line_zone import build_high_line_zone_kernel_strategy -from utama_core.strategy.high_press import build_high_press_kernel_strategy -from utama_core.strategy.low_block import build_low_block_kernel_strategy -from utama_core.strategy.overload_flow import build_overload_flow_kernel_strategy -from utama_core.strategy.overload_press import build_overload_press_kernel_strategy -from utama_core.strategy.pickers import ( - carrier_first, - fixed_ratio_picker, - friendly_closer_to_ball, - reset_closer_to_ball_state, -) -from utama_core.strategy.press_and_pass import build_press_and_pass_kernel_strategy -from utama_core.strategy.press_trigger_flow import ( - build_press_trigger_flow_kernel_strategy, -) -from utama_core.strategy.score_aware_counter_flow import ( - build_score_aware_counter_flow_kernel_strategy, -) -from utama_core.strategy.score_aware_zone_flow import ( - build_score_aware_zone_flow_kernel_strategy, -) -from utama_core.strategy.shadow_switch import build_shadow_switch_kernel_strategy -from utama_core.strategy.split_shape import build_split_shape_kernel_strategy -from utama_core.strategy.switch_of_play import build_switch_of_play_kernel_strategy -from utama_core.strategy.three_slot import ( - _three_way_picker, - build_three_slot_kernel_strategy, -) -from utama_core.strategy.tiki_taka import ( - _tiki_taka_picker, - build_tiki_taka_kernel_strategy, -) -from utama_core.strategy.tiki_taka_plus import build_tiki_taka_plus_kernel_strategy -from utama_core.strategy.zone_fluid import ( - _zone_flow_picker, - build_zone_fluid_kernel_strategy, -) diff --git a/utama_core/strategy/low_block.py b/utama_core/strategy/low_block.py deleted file mode 100644 index 3bfc016d2..000000000 --- a/utama_core/strategy/low_block.py +++ /dev/null @@ -1,37 +0,0 @@ -"""The `low_block` kernel strategy: `build_low_block_kernel_strategy` and the pickers only it uses.""" - -from __future__ import annotations - -from utama_core.engine.context import TickContext -from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.strategy.pickers import fixed_ratio_picker -from utama_core.tactics.defense import DefenseTactic -from utama_core.tactics.pass_and_shoot import PassAndShootTactic - - -def build_low_block_kernel_strategy(outfield_robot_ids: tuple[int, ...]): - """5-robot (or fewer) `Strategy` factory: a conservative, defense-heavy - counterpart to `build_high_press_kernel_strategy` — most of the pool - stays back regardless of possession (floored at `min_attack=2`, since - `PassAndShootTactic` hard-requires at least 2 robots). Wires - `PassAndShootTactic` ("attack") and `DefenseTactic` ("defense"), the - original two ported Tactics, still useful as the minimal-risk baseline - they were designed to be (§1/§2's original pairing) rather than the - newer, more elaborate Tactics used elsewhere in this file. - - Returns a `build_kernel_strategy(motion_controller)` - callable suitable for `AbstractStrategy`'s constructor argument of the - same name. - """ - - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={"attack": PassAndShootTactic(), "defense": DefenseTactic()}, - partitioner=fixed_ratio_picker("attack", "defense", attack_fraction=0.2, min_attack=2), - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build diff --git a/utama_core/strategy/decoy_and_overload.py b/utama_core/strategy/mirage.py similarity index 53% rename from utama_core/strategy/decoy_and_overload.py rename to utama_core/strategy/mirage.py index 5cb00ea9c..7272b53ba 100644 --- a/utama_core/strategy/decoy_and_overload.py +++ b/utama_core/strategy/mirage.py @@ -1,39 +1,36 @@ -"""The `decoy_and_overload` kernel strategy: `build_decoy_and_overload_kernel_strategy` and the pickers only it uses.""" +"""`mirage` (until 2026-11-12 `decoy_and_overload`): decoy runs pull defenders away from the real attack. The pickers only it uses are here.""" from __future__ import annotations from utama_core.engine.context import TickContext from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController from utama_core.strategy.pickers import fixed_ratio_picker from utama_core.tactics.decoy_and_overload import DecoyOverloadTactic from utama_core.tactics.shadow_and_mark import ShadowAndMarkTactic -def build_decoy_and_overload_kernel_strategy(outfield_robot_ids: tuple[int, ...]): +def build(outfield_robot_ids: tuple[int, ...], motion_controller: MotionController) -> KernelSchedulerStrategy: """5-robot (or fewer) `Strategy` factory exercising `DecoyOverloadTactic`. Wires `DecoyOverloadTactic` ("attack") and `ShadowAndMarkTactic` ("defense"), split by `fixed_ratio_picker` with `min_attack=2` — `DecoyOverloadTactic` hard-requires at least 2 robots (a decoy and an overloader) the same way `PassAndShootTactic` does, so it needs the - same floor `build_low_block_kernel_strategy` gives that tactic. Attack + same floor `low_block` gives that tactic. Attack fraction left at a plain 0.5 split (possession-agnostic) since nothing about the lure/overload pattern is more or less urgent when the opponent has the ball, unlike the press/shadow pairings above. - Returns a `build_kernel_strategy(motion_controller)` + Returns a `build(motion_controller)` callable suitable for `AbstractStrategy`'s constructor argument of the same name. """ - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={"attack": DecoyOverloadTactic(), "defense": ShadowAndMarkTactic()}, - partitioner=fixed_ratio_picker("attack", "defense", attack_fraction=0.5, min_attack=2), - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build + ctx = TickContext(motion_controller=motion_controller) + return KernelSchedulerStrategy( + tactics={"attack": DecoyOverloadTactic(), "defense": ShadowAndMarkTactic()}, + partitioner=fixed_ratio_picker("attack", "defense", attack_fraction=0.5, min_attack=2), + outfield_robot_ids=outfield_robot_ids, + ctx=ctx, + ) diff --git a/utama_core/strategy/overload_flow.py b/utama_core/strategy/overload_flow.py deleted file mode 100644 index be1559f57..000000000 --- a/utama_core/strategy/overload_flow.py +++ /dev/null @@ -1,152 +0,0 @@ -"""The `overload_flow` kernel strategy: `build_overload_flow_kernel_strategy` and the pickers only it uses.""" - -from __future__ import annotations - -from typing import Optional - -from utama_core.engine.context import TickContext -from utama_core.engine.strategy import Partitioner -from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy -from utama_core.engine.tactic import RobotId -from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.strategy.pickers import ( - allocate_ordered, - ball_zone, - carrier_first, - friendly_closer_to_ball, -) -from utama_core.tactics.decoy_and_overload import DecoyOverloadTactic -from utama_core.tactics.give_and_go import GiveAndGoTactic -from utama_core.tactics.shadow_and_mark import ShadowAndMarkTactic - -# --------------------------------------------------------------------------- -# overload_flow (2026-09-02 addition) -# -# Every existing possession-edge picker (including `_zone_flow_picker`, -# which this strategy is otherwise identical to) reacts to a single tick's -# edge read alone. `score_aware_zone_flow` proved a cheap graft onto that -# same base is worth testing (the scoreline); this strategy grafts a -# different, still-unused signal instead: how *long* the possession edge has -# held, not just its current value. Rationale: `_zone_flow_picker`'s -# give-and-go trio already builds patiently through the middle thirds -- -# committing a 4th attacker the instant the edge flips, before that -# possession is actually secure, risks overextending into exactly the kind -# of single-tick noise `CLOSER_TO_BALL_MARGIN` and every sticky-edge picker -# (`counter_flow`, `high_line_zone`, `shadow_switch`) already had to guard -# against elsewhere. Only commit the extra body once the edge has held for a -# real, sustained window. -# --------------------------------------------------------------------------- - -# ~1.5s at the kernel's tick rate (60Hz, matching every other tick-count -# constant in this file, e.g. `PressAndContainTactic`'s hysteresis window) -# -- long enough to filter a -# single contested-ball flicker, short enough that a genuine sustained -# possession spell still gets the extra attacker well before a give-and-go -# hop cycle completes. -_POSSESSION_STREAK_TICKS = 90 - - -def _overload_flow_picker() -> Partitioner: - """A fresh picker with its own possession streak. - - A `Partitioner` has no `mem`, and `prev_partition` can't carry a tick count, - so the streak lives in this closure: one per strategy instance. It was a - module-level `global`, which both teams share when they play the same - strategy in one process, and which carried from one match to the next in a - round-robin worker unless the factory reset it. - """ - streak = 0 - - def pick( - game: Game, - free_robots: frozenset[RobotId], - prev_partition: Optional[dict[str, frozenset[RobotId]]], - available_tactic_ids: frozenset[str], - ) -> dict[str, frozenset[RobotId]]: - nonlocal streak - ordered = carrier_first(game, free_robots) - if not ordered: - return {} - losing = friendly_closer_to_ball(game) is not True - streak = 0 if losing else min(streak + 1, _POSSESSION_STREAK_TICKS) - return _allocate(game, ordered, available_tactic_ids, losing, streak) - - return pick - - -def _allocate( - game: Game, - ordered: list[RobotId], - available_tactic_ids: frozenset[str], - losing: bool, - streak: int, -) -> dict[str, frozenset[RobotId]]: - """`_zone_flow_picker`'s allocation, with the own/mid-third give-and-go - attacker count growing from 3 to 4 only once the possession edge has - held for `_POSSESSION_STREAK_TICKS` consecutive ticks, instead of - reacting to the edge's current value alone. - - Not late in a possession spell, losing, or in the final third: - identical to `_zone_flow_picker`. Final-third handoff to the overload - duet is unchanged (that tactic is a 2-role duet regardless of streak - length -- the streak only ever affects the own/mid-third give-and-go - count). - """ - defense_ok = "defense" in available_tactic_ids - givego_ok = "givego" in available_tactic_ids - overload_ok = "overload" in available_tactic_ids - - if losing: - if defense_ok: - return allocate_ordered(ordered, "defense", len(ordered)) - if givego_ok: - return allocate_ordered(ordered, "givego", len(ordered)) - if overload_ok: - return allocate_ordered(ordered, "overload", len(ordered)) - return {} - - zone = ball_zone(game) - if zone == "final" and overload_ok: - return allocate_ordered(ordered, "overload", 2, "defense" if defense_ok else None) - if givego_ok: - attackers = 4 if streak >= _POSSESSION_STREAK_TICKS else 3 - return allocate_ordered(ordered, "givego", attackers, "defense" if defense_ok else None) - if overload_ok: - return allocate_ordered(ordered, "overload", len(ordered)) - if defense_ok: - return allocate_ordered(ordered, "defense", len(ordered)) - return {} - - -def build_overload_flow_kernel_strategy(outfield_robot_ids: tuple[int, ...]): - """`zone_fluid` with a possession-*duration*-aware give-and-go attacker - count: 3 attackers as usual, growing to 4 only once the possession edge - has held for a sustained window (`_POSSESSION_STREAK_TICKS`), instead of - reacting to a single tick's edge read the way every other picker in the - catalog does. See the "overload_flow" comment block above - `_overload_flow_picker` for the full rationale. - - Same three tactics/slots as `zone_fluid` (`GiveAndGoTactic`/ - `DecoyOverloadTactic`/`ShadowAndMarkTactic`) -- only the picker's - attacker-count decision differs, so any observed difference from plain - `zone_fluid` is attributable to the streak requirement alone. - - Returns a `build_kernel_strategy(motion_controller)` callable suitable - for `AbstractStrategy`'s constructor argument of the same name. - """ - - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={ - "givego": GiveAndGoTactic(), - "overload": DecoyOverloadTactic(), - "defense": ShadowAndMarkTactic(), - }, - partitioner=_overload_flow_picker(), - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build diff --git a/utama_core/strategy/split_shape.py b/utama_core/strategy/pendulum.py similarity index 68% rename from utama_core/strategy/split_shape.py rename to utama_core/strategy/pendulum.py index 37f0548b4..675954cd1 100644 --- a/utama_core/strategy/split_shape.py +++ b/utama_core/strategy/pendulum.py @@ -1,4 +1,4 @@ -"""The `split_shape` kernel strategy: `build_split_shape_kernel_strategy` and the pickers only it uses.""" +"""`pendulum` (until 2026-11-12 `split_shape`): swings between attack and defence with possession. The pickers only it uses are here.""" from __future__ import annotations @@ -8,12 +8,21 @@ from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy from utama_core.engine.tactic import RobotId from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController from utama_core.strategy.pickers import carrier_first, friendly_closer_to_ball from utama_core.tactics.lead_and_support import LeadAndSupportTactic from utama_core.tactics.shadow_and_mark import ShadowAndMarkTactic +def _defending_attack_count(robots: int) -> int: + """Robots kept in "attack" while the enemy is nearer the ball: one goes to the ball and, from four + robots up, one more holds open space upfield. A ball won with nobody ahead of it led to a shot 3% + of the time, with four ahead 23% (2026-11-10 round-robin); in 684 paired 12 s drills from enemy + possession the second attacker scored +2.6 +/- 0.9 points more often, conceded no more (+0.3 +/- 0.7) + but gave away more free kicks (+7.3 +/- 2.5 points). Three robots keep all three back.""" + return robots // 2 if robots >= 4 else robots // 2 - 1 + + def _possession_split_picker( game: Game, free_robots: frozenset[RobotId], @@ -50,7 +59,7 @@ def _possession_split_picker( if "defense" not in available_tactic_ids: return {"attack": frozenset(ordered)} - attack_count = (len(ordered) + 1) // 2 + 1 if friendly_has_ball_edge else len(ordered) // 2 - 1 + attack_count = (len(ordered) + 1) // 2 + 1 if friendly_has_ball_edge else _defending_attack_count(len(ordered)) attack_count = max(0, min(len(ordered), attack_count)) partition = {} @@ -61,7 +70,7 @@ def _possession_split_picker( return partition -def build_split_shape_kernel_strategy(outfield_robot_ids: tuple[int, ...]): +def build(outfield_robot_ids: tuple[int, ...], motion_controller: MotionController) -> KernelSchedulerStrategy: """5-robot (or fewer) split-shape `Strategy` factory. Wires `LeadAndSupportTactic` ("attack") and `ShadowAndMarkTactic` @@ -69,18 +78,15 @@ def build_split_shape_kernel_strategy(outfield_robot_ids: tuple[int, ...]): `_possession_split_picker`. This is the concrete forcing case the design doc's §7 deferral was waiting on — see §11 for the full rationale. - Returns a `build_kernel_strategy(motion_controller)` + Returns a `build(motion_controller)` callable suitable for `AbstractStrategy`'s constructor argument of the same name. """ - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={"attack": LeadAndSupportTactic(), "defense": ShadowAndMarkTactic()}, - partitioner=_possession_split_picker, - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build + ctx = TickContext(motion_controller=motion_controller) + return KernelSchedulerStrategy( + tactics={"attack": LeadAndSupportTactic(), "defense": ShadowAndMarkTactic()}, + partitioner=_possession_split_picker, + outfield_robot_ids=outfield_robot_ids, + ctx=ctx, + ) diff --git a/utama_core/strategy/pickers.py b/utama_core/strategy/pickers.py index c4bca5b22..d99e3e954 100644 --- a/utama_core/strategy/pickers.py +++ b/utama_core/strategy/pickers.py @@ -65,7 +65,7 @@ def _partitioner( # --------------------------------------------------------------------------- # Arena strategies — plan-driven multi-tactic teams (2026-08-20 addition) # -# The barebone factories (default/split_shape/low_block/...) exist to exercise +# The barebone factories (default/pendulum/low_block/...) exist to exercise # the kernel machinery; these three are meant as *playable* teams: every # posture reads live game state (ball ownership, ball zone), every posture # has both an attack and a defense answer, and the allocation reacts to the @@ -286,14 +286,10 @@ def dist(robot) -> float: rid, robot = min(game.friendly_robots.items(), key=lambda item: dist(item[1])) enemy_nearest = min((dist(e) for e in game.enemy_robots.values()), default=math.inf) - return rid if dist(robot) <= _KICK_REACH_M and dist(robot) < enemy_nearest else None - - -def holds_ball(game: Game, robot_id: RobotId) -> bool: - """True if `robot_id` is on the ball (dribbler contact) or is the kicker waiting at a - still ball: the robot `carrier_first` puts first.""" - robot = game.friendly_robots.get(robot_id) - return robot is not None and (robot.has_ball or robot_id == _kicker_at_still_ball(game)) + # An enemy in reach too is a contest, not a kicker waiting. Comparing the two distances there + # (0.112 m against 0.113 m) changed the answer every tick and with it who held the attack + # slot, each change wiping that tactic's memory (press_and_pass_vs_tiki_taka_plus, 2026-11-09). + return rid if dist(robot) <= _KICK_REACH_M < enemy_nearest else None def clearer_first(game: Game, ordered: list[RobotId]) -> list[RobotId]: diff --git a/utama_core/strategy/ricochet.py b/utama_core/strategy/ricochet.py new file mode 100644 index 000000000..354f1146a --- /dev/null +++ b/utama_core/strategy/ricochet.py @@ -0,0 +1,32 @@ +"""`ricochet` (until 2026-11-12 `give_and_go_solo`): all one-twos, no defence. The pickers only it uses are here.""" + +from __future__ import annotations + +from utama_core.engine.context import TickContext +from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.tactics.give_and_go import GiveAndGoTactic + + +def build(outfield_robot_ids: tuple[int, ...], motion_controller: MotionController) -> KernelSchedulerStrategy: + """Single-tactic `Strategy` factory: the entire outfield pool always runs + `GiveAndGoTactic`, no defense slot at all. Mirrors + `default`'s shape (single Tactic, no real + allocation decision, via `single_tactic_picker`) but for the newer + passing tactic — useful as an isolated benchmark/eval config when + testing `GiveAndGoTactic` in isolation matters more than realistic match + posture (e.g. tuning `_MAX_HOPS_PER_POSSESSION` or the support-scoring + weights without a defensive Tactic's behaviour as a confound). + + Returns a `build(motion_controller)` + callable suitable for `AbstractStrategy`'s constructor argument of the + same name. + """ + + ctx = TickContext(motion_controller=motion_controller) + return KernelSchedulerStrategy( + tactics={"attack": GiveAndGoTactic()}, + partitioner=KernelSchedulerStrategy.single_tactic_picker(lambda game, active: "attack"), + outfield_robot_ids=outfield_robot_ids, + ctx=ctx, + ) diff --git a/utama_core/strategy/counter_flow.py b/utama_core/strategy/riptide.py similarity index 83% rename from utama_core/strategy/counter_flow.py rename to utama_core/strategy/riptide.py index 0ae47fd3c..70a098f08 100644 --- a/utama_core/strategy/counter_flow.py +++ b/utama_core/strategy/riptide.py @@ -1,4 +1,4 @@ -"""The `counter_flow` kernel strategy: `build_counter_flow_kernel_strategy` and the pickers only it uses.""" +"""`riptide` (until 2026-11-12 `counter_flow`): soaks up pressure, then counters fast. The pickers only it uses are here.""" from __future__ import annotations @@ -8,7 +8,7 @@ from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy from utama_core.engine.tactic import RobotId from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController from utama_core.strategy.pickers import ( allocate_ordered, carrier_first, @@ -19,7 +19,7 @@ from utama_core.tactics.press_and_contain import PressAndContainTactic -def _counter_flow_picker( +def _riptide_picker( game: Game, free_robots: frozenset[RobotId], prev_partition: Optional[dict[str, frozenset[RobotId]]], @@ -30,7 +30,7 @@ def _counter_flow_picker( window with our own press instead of ceding it, and fall back to a space-denying screen (not man-shadow) when neither side has an edge. - Both `overload_press` and `high_line_zone` tried to out-number + Both `avalanche` and `high_line_zone` tried to out-number tiki_taka's 2-robot shadow defense and lost before that numbers edge ever got to matter — tiki_taka's 3-robot press (1 presser + 2 markers, `PressAndContainTactic` only becomes applicable within 1.5 m of the @@ -102,37 +102,34 @@ def _counter_flow_picker( return {} -def build_counter_flow_kernel_strategy(outfield_robot_ids: tuple[int, ...]): +def build(outfield_robot_ids: tuple[int, ...], motion_controller: MotionController) -> KernelSchedulerStrategy: """Direct answer to tiki_taka: our own give-and-go attack, our own press on the ball, a space-denying screen everywhere else. Three concurrent slots — `GiveAndGoTactic` ("attack"), `PressAndContainTactic` ("press"), and `BlockShapeTactic` ("block") — - allocated by `_counter_flow_picker` on a 3/2 split matching tiki_taka's + allocated by `_riptide_picker` on a 3/2 split matching tiki_taka's own commitment in both postures, rather than the numbers-overload bet - `overload_press`/`high_line_zone` made and lost. The theory: neither + `avalanche`/`high_line_zone` made and lost. The theory: neither prior anti-tiki_taka attempt ever got far enough to test its numbers edge because tiki_taka's press won the transition window outright: this strategy contests that window symmetrically (our own 3-press) instead of trying to dodge it, and uses tiki_taka's own proven-undefeated attack engine rather than a fresh pattern. - Returns a `build_kernel_strategy(motion_controller)` + Returns a `build(motion_controller)` callable suitable for `AbstractStrategy`'s constructor argument of the same name. """ - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={ - "attack": GiveAndGoTactic(), - "press": PressAndContainTactic(), - "block": BlockShapeTactic(), - }, - partitioner=_counter_flow_picker, - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build + ctx = TickContext(motion_controller=motion_controller) + return KernelSchedulerStrategy( + tactics={ + "attack": GiveAndGoTactic(), + "press": PressAndContainTactic(), + "block": BlockShapeTactic(), + }, + partitioner=_riptide_picker, + outfield_robot_ids=outfield_robot_ids, + ctx=ctx, + ) diff --git a/utama_core/strategy/score_aware_zone_flow.py b/utama_core/strategy/score_aware_zone_flow.py deleted file mode 100644 index f87a06daa..000000000 --- a/utama_core/strategy/score_aware_zone_flow.py +++ /dev/null @@ -1,127 +0,0 @@ -"""The `score_aware_zone_flow` kernel strategy: `build_score_aware_zone_flow_kernel_strategy` and the pickers only it uses.""" - -from __future__ import annotations - -from typing import Optional - -from utama_core.engine.context import TickContext -from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy -from utama_core.engine.tactic import RobotId -from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.strategy.pickers import ( - allocate_ordered, - ball_zone, - carrier_first, - friendly_closer_to_ball, - friendly_score_diff, - is_late_in_half, -) -from utama_core.tactics.decoy_and_overload import DecoyOverloadTactic -from utama_core.tactics.give_and_go import GiveAndGoTactic -from utama_core.tactics.shadow_and_mark import ShadowAndMarkTactic - -# --------------------------------------------------------------------------- -# Score-aware zone-flow (2026-08-23 addition) -# -# Every existing picker reads possession/ball-zone but none reads the -# scoreline itself, even though `game.referee.{yellow,blue}_team.score` is -# already populated in any refereed match (`round_robin.py` reads the same fields to report a -# match's result). -# This variant is `_zone_flow_picker`'s allocation with one added axis: late -# in a half, shift the *size* of the attack/defense split based on whether -# we're ahead or behind, instead of holding the same 3/2-ish split regardless -# of score. Ahead late: fewer bodies committed forward, more men behind the -# ball to protect the lead. Behind late: the reverse, chase the game. Tied, -# early in the half, or score unreadable (`game.referee is None`): identical -# to `_zone_flow_picker`, so this strategy only diverges from `zone_fluid` -# when the new signal actually has something to say. -# --------------------------------------------------------------------------- - - -def _score_aware_zone_flow_picker( - game: Game, - free_robots: frozenset[RobotId], - prev_partition: Optional[dict[str, frozenset[RobotId]]], - available_tactic_ids: frozenset[str], -) -> dict[str, frozenset[RobotId]]: - """`_zone_flow_picker`'s allocation, with the attack/defense split size - shifted late in a half by whether we're ahead or behind. - - Not late, tied, or score unreadable: identical to `_zone_flow_picker` - (3 attackers/2 defenders when we have the ball, everyone shadows when we - don't). Late and ahead: only 2 forward, 3 back, to protect the lead. Late - and behind: 4 forward, 1 back, to chase an equaliser. The final-third - overload duet always stays 2 robots regardless (that tactic is a - two-role duet by design, see `_zone_flow_picker`) — only the - own/mid-third give-and-go split size reacts to the scoreline. - """ - ordered = carrier_first(game, free_robots) - if not ordered: - return {} - - friendly_edge = friendly_closer_to_ball(game) - losing_possession = friendly_edge is not True - - defense_ok = "defense" in available_tactic_ids - givego_ok = "givego" in available_tactic_ids - overload_ok = "overload" in available_tactic_ids - - if losing_possession: - if defense_ok: - return allocate_ordered(ordered, "defense", len(ordered)) - if givego_ok: - return allocate_ordered(ordered, "givego", len(ordered)) - if overload_ok: - return allocate_ordered(ordered, "overload", len(ordered)) - return {} - - zone = ball_zone(game) - if zone == "final" and overload_ok: - return allocate_ordered(ordered, "overload", 2, "defense" if defense_ok else None) - - if givego_ok: - attackers = 3 - if is_late_in_half(game): - score_diff = friendly_score_diff(game) - if score_diff is not None and score_diff > 0: - attackers = 2 - elif score_diff is not None and score_diff < 0: - attackers = 4 - return allocate_ordered(ordered, "givego", attackers, "defense" if defense_ok else None) - if overload_ok: - return allocate_ordered(ordered, "overload", len(ordered)) - if defense_ok: - return allocate_ordered(ordered, "defense", len(ordered)) - return {} - - -def build_score_aware_zone_flow_kernel_strategy(outfield_robot_ids: tuple[int, ...]): - """Zone-flow team (see `build_zone_fluid_kernel_strategy`) with one added - decision input nothing else in the catalog uses: the scoreline. Late in a - half, the give-and-go attack/defense split shrinks when we're ahead - (protect the lead) and grows when we're behind (chase the game), instead - of holding the same split regardless of score. Same three tactics/slots - as `zone_fluid` (`GiveAndGoTactic`/`DecoyOverloadTactic`/ - `ShadowAndMarkTactic`) — only the picker differs, so any difference in - results is attributable to the new score-aware allocation, not a - different tactic set. - - Returns a `build_kernel_strategy(motion_controller)` callable suitable - for `AbstractStrategy`'s constructor argument of the same name. - """ - - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={ - "givego": GiveAndGoTactic(), - "overload": DecoyOverloadTactic(), - "defense": ShadowAndMarkTactic(), - }, - partitioner=_score_aware_zone_flow_picker, - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build diff --git a/utama_core/strategy/shadow_switch.py b/utama_core/strategy/shadow_switch.py deleted file mode 100644 index 31678410f..000000000 --- a/utama_core/strategy/shadow_switch.py +++ /dev/null @@ -1,119 +0,0 @@ -"""The `shadow_switch` kernel strategy: `build_shadow_switch_kernel_strategy` and the pickers only it uses.""" - -from __future__ import annotations - -from typing import Optional - -from utama_core.engine.context import TickContext -from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy -from utama_core.engine.tactic import RobotId -from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.strategy.pickers import ( - allocate_ordered, - carrier_first, - friendly_closer_to_ball, -) -from utama_core.tactics.shadow_and_mark import ShadowAndMarkTactic -from utama_core.tactics.switch_of_play import SwitchOfPlayTactic - -# --------------------------------------------------------------------------- -# shadow_switch (2026-09-02 addition) -# -# `high_line_zone` paired `SwitchOfPlayTactic` with `BlockShapeTactic`'s zone -# screen and stayed parked (2-7-4 in its best backfill) -- the screen denies -# individual matchups, but the switch's carrier/pivot/runner relay still -# needs several seconds to settle, which a genuinely contested match rarely -# grants. `tiki_taka`'s `ShadowAndMarkTactic` defense is independently -# proven viable (it's the top-tested strategy's own defense, 1W-8D-4L in -# isolation but never the bottleneck -- every loss traced to the *attack* -# side, not the shadow cover). This pairing -- switch's attack, shadow's -# defense -- has never been tried: `high_line_zone` used switch with the -# zone screen, `tiki_taka`/`tiki_taka_plus` used shadow with give-and-go. -# Hypothesis: man-marking cover (proven to hold up on its own) may free the -# switch attack to develop without the zone screen's own unproven defensive -# contribution as a confound in either direction. -# --------------------------------------------------------------------------- - - -def _shadow_switch_picker( - game: Game, - free_robots: frozenset[RobotId], - prev_partition: Optional[dict[str, frozenset[RobotId]]], - available_tactic_ids: frozenset[str], -) -> dict[str, frozenset[RobotId]]: - """Switch-attack, shadow-defense posture. - - - The opponent has the ball: the whole team shadows/marks - (`ShadowAndMarkTactic`), same defensive shape `tiki_taka` already - validates. - - We have the ball: `SwitchOfPlayTactic` leads with 3 (the relay's - carrier/pivot/runner roles), 2 hold shadow cover behind it -- same - 3/2 split shape as `high_line_zone`'s switch branch, defense slot - swapped. - - Sticky possession edge, same fix `_high_line_zone_picker`/ - `_counter_flow_picker` needed: the switch relay needs several seconds to - settle, which a tick-by-tick possession-edge re-read does not reliably - give it in a contested match. `prev_partition` ("did we hold switch last - tick") is the memory; require a clear possession loss to drop it. - """ - ordered = carrier_first(game, free_robots) - if not ordered: - return {} - - prev_partition = prev_partition or {} - currently_attacking = bool(prev_partition.get("switch")) - friendly_edge = friendly_closer_to_ball(game) - if currently_attacking: - losing = friendly_edge is False - else: - losing = friendly_edge is not True - - switch_ok = "switch" in available_tactic_ids - defense_ok = "defense" in available_tactic_ids - - if losing: - if defense_ok: - return allocate_ordered(ordered, "defense", len(ordered)) - if switch_ok: - return allocate_ordered(ordered, "switch", len(ordered)) - return {} - - if switch_ok: - return allocate_ordered(ordered, "switch", 3, "defense" if defense_ok else None) - if defense_ok: - return allocate_ordered(ordered, "defense", len(ordered)) - return {} - - -def build_shadow_switch_kernel_strategy(outfield_robot_ids: tuple[int, ...]): - """Switch-of-play attack with man-marking cover -- a tactic pairing never - tried elsewhere in the catalog (`high_line_zone` paired the switch with - a zone screen; `tiki_taka`/`tiki_taka_plus` paired shadow-and-mark with - give-and-go). See the "shadow_switch" comment block above - `_shadow_switch_picker` for the full rationale. - - Two concurrent slots -- `SwitchOfPlayTactic` ("switch") and - `ShadowAndMarkTactic` ("defense") -- allocated by `_shadow_switch_picker` - on a 3/2 split with sticky possession-edge hysteresis, matching the - settling time the switch relay needs. - - Returns a `build_kernel_strategy(motion_controller)` - callable suitable for `AbstractStrategy`'s constructor argument of the - same name. - """ - - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={ - "switch": SwitchOfPlayTactic(), - "defense": ShadowAndMarkTactic(), - }, - partitioner=_shadow_switch_picker, - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build diff --git a/utama_core/strategy/switch_of_play.py b/utama_core/strategy/switch_of_play.py deleted file mode 100644 index 78a9d540b..000000000 --- a/utama_core/strategy/switch_of_play.py +++ /dev/null @@ -1,42 +0,0 @@ -"""The `switch_of_play` kernel strategy: `build_switch_of_play_kernel_strategy` and the pickers only it uses.""" - -from __future__ import annotations - -from utama_core.engine.context import TickContext -from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.strategy.pickers import fixed_ratio_picker -from utama_core.tactics.defense import DefenseTactic -from utama_core.tactics.switch_of_play import SwitchOfPlayTactic - - -def build_switch_of_play_kernel_strategy(outfield_robot_ids: tuple[int, ...]): - """5-robot (or fewer) `Strategy` factory exercising `SwitchOfPlayTactic`. - - Wires `SwitchOfPlayTactic` ("attack") and `DefenseTactic` ("defense"), - split by `fixed_ratio_picker` with `min_attack=3` — the tactic's full - carrier/pivot/runner relay needs 3 robots to actually exercise the - "switch" leg (the pivot outlet) rather than silently degrading to its - 2-robot direct-pass fallback every tick, the same floor rationale - `build_low_block_kernel_strategy` gives `PassAndShootTactic` and - `build_decoy_and_overload_kernel_strategy` gives `DecoyOverloadTactic`. - Attack fraction left at a plain 0.5 split (possession-agnostic), same as - `build_decoy_and_overload_kernel_strategy` — nothing about reading the - weak side and relaying the ball across it is more or less urgent when the - opponent has the ball. - - Returns a `build_kernel_strategy(motion_controller)` - callable suitable for `AbstractStrategy`'s constructor argument of the - same name. - """ - - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={"attack": SwitchOfPlayTactic(), "defense": DefenseTactic()}, - partitioner=fixed_ratio_picker("attack", "defense", attack_fraction=0.5, min_attack=3), - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build diff --git a/utama_core/strategy/press_and_pass.py b/utama_core/strategy/terrier.py similarity index 73% rename from utama_core/strategy/press_and_pass.py rename to utama_core/strategy/terrier.py index 6d45d7b0a..294894d24 100644 --- a/utama_core/strategy/press_and_pass.py +++ b/utama_core/strategy/terrier.py @@ -1,4 +1,4 @@ -"""The `press_and_pass` kernel strategy: `build_press_and_pass_kernel_strategy` and the pickers only it uses.""" +"""`terrier` (until 2026-11-12 `press_and_pass`): presses, then plays quick one-twos. The pickers only it uses are here.""" from __future__ import annotations @@ -8,13 +8,13 @@ from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy from utama_core.engine.tactic import RobotId from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController from utama_core.strategy.pickers import carrier_first, friendly_closer_to_ball from utama_core.tactics.give_and_go import GiveAndGoTactic from utama_core.tactics.press_and_contain import PressAndContainTactic -def _press_and_pass_split_picker( +def _terrier_split_picker( game: Game, free_robots: frozenset[RobotId], prev_partition: Optional[dict[str, frozenset[RobotId]]], @@ -54,28 +54,25 @@ def _press_and_pass_split_picker( return partition -def build_press_and_pass_kernel_strategy(outfield_robot_ids: tuple[int, ...]): +def build(outfield_robot_ids: tuple[int, ...], motion_controller: MotionController) -> KernelSchedulerStrategy: """5-robot (or fewer) `Strategy` factory exercising the newer tactics. Wires `GiveAndGoTactic` ("attack") and `PressAndContainTactic` ("defense") as two concurrently active slots, split by - `_press_and_pass_split_picker`. Sibling to - `build_split_shape_kernel_strategy`, same shape, different tactic pair — + `_terrier_split_picker`. Sibling to + `pendulum`, same shape, different tactic pair — lets the give-and-go/press-and-contain tactics be driven end to end via `StrategyRunner` instead of only unit-level `tick()` calls. - Returns a `build_kernel_strategy(motion_controller)` + Returns a `build(motion_controller)` callable suitable for `AbstractStrategy`'s constructor argument of the same name. """ - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={"attack": GiveAndGoTactic(), "defense": PressAndContainTactic()}, - partitioner=_press_and_pass_split_picker, - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build + ctx = TickContext(motion_controller=motion_controller) + return KernelSchedulerStrategy( + tactics={"attack": GiveAndGoTactic(), "defense": PressAndContainTactic()}, + partitioner=_terrier_split_picker, + outfield_robot_ids=outfield_robot_ids, + ctx=ctx, + ) diff --git a/utama_core/strategy/three_slot.py b/utama_core/strategy/three_slot.py deleted file mode 100644 index be5054377..000000000 --- a/utama_core/strategy/three_slot.py +++ /dev/null @@ -1,98 +0,0 @@ -"""The `three_slot` kernel strategy: `build_three_slot_kernel_strategy` and the pickers only it uses.""" - -from __future__ import annotations - -from typing import Optional - -from utama_core.engine.context import TickContext -from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy -from utama_core.engine.tactic import RobotId -from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.strategy.pickers import carrier_first, holds_ball -from utama_core.tactics.give_and_go import GiveAndGoTactic -from utama_core.tactics.press_and_contain import PressAndContainTactic -from utama_core.tactics.shadow_and_mark import ShadowAndMarkTactic - - -def _three_way_picker( - game: Game, - free_robots: frozenset[RobotId], - prev_partition: Optional[dict[str, frozenset[RobotId]]], - available_tactic_ids: frozenset[str], -) -> dict[str, frozenset[RobotId]]: - """Splits the free pool three ways — first exercise of `Strategy` running - more than two concurrent slots (nothing in `Strategy`/`_validate_partition` - is hardcoded to two, but no config before this one had actually tried - three). One presser, one shadow-and-mark defensive pair when there are - enough robots to spare, everyone else attacks via give-and-go. Falls back - to redistributing a slot's share to "attack" whenever that slot's Tactic - is currently inapplicable or pinned elsewhere, same defensive pattern as - `_press_and_pass_split_picker`. - """ - ordered = carrier_first(game, free_robots) - if not ordered: - return {} - - press_ok = "press" in available_tactic_ids - mark_ok = "mark" in available_tactic_ids - attack_ok = "attack" in available_tactic_ids - - remaining = list(ordered) - partition: dict[str, frozenset[RobotId]] = {} - - # The robot on the ball (a free-kick taker included) attacks. Handed to "press" or "mark" - # it clears the ball blind, straight upfield (`kick_upfield`), and the kick ran the length - # of the pitch and out over the far goal line: 24 a match, most of three_slot's out-of-bounds - # fouls (three_slot_vs_zone_fluid t=87.8: the taker of our free kick in "mark"). - holder = [remaining.pop(0)] if attack_ok and holds_ball(game, remaining[0]) else [] - - if press_ok and remaining: - partition["press"] = frozenset([remaining.pop(0)]) - if mark_ok and len(remaining) >= 2: - partition["mark"] = frozenset(remaining[:2]) - remaining = remaining[2:] - if attack_ok: - if holder or remaining: - partition["attack"] = frozenset(holder + remaining) - elif remaining: - # "attack" unavailable too — nothing left to hand the rest to; leave - # them off the partition only if every other slot already claimed - # everyone, otherwise this would violate the exhaustive-cover - # invariant, so fall back to whichever defensive slot is still open. - if mark_ok: - partition["mark"] = frozenset(set(partition.get("mark", frozenset())) | set(remaining)) - elif press_ok: - partition["press"] = frozenset(set(partition.get("press", frozenset())) | set(remaining)) - - return partition - - -def build_three_slot_kernel_strategy(outfield_robot_ids: tuple[int, ...]): - """5-robot (or fewer) `Strategy` factory running three concurrent Tactic - slots at once: `PressAndContainTactic` ("press"), `ShadowAndMarkTactic` - ("mark"), and `GiveAndGoTactic` ("attack"). Distinct in kind from every - other factory in this file, which all run exactly two slots — this is - the first config to actually exercise `Strategy` with N>2, which the - kernel has always structurally supported (`_validate_partition` iterates - `partition.items()` generically) but nothing had tested until now. - - Returns a `build_kernel_strategy(motion_controller)` - callable suitable for `AbstractStrategy`'s constructor argument of the - same name. - """ - - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={ - "press": PressAndContainTactic(), - "mark": ShadowAndMarkTactic(), - "attack": GiveAndGoTactic(), - }, - partitioner=_three_way_picker, - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build diff --git a/utama_core/strategy/tiki_taka.py b/utama_core/strategy/tiki_taka.py deleted file mode 100644 index 22bf9af19..000000000 --- a/utama_core/strategy/tiki_taka.py +++ /dev/null @@ -1,106 +0,0 @@ -"""The `tiki_taka` kernel strategy: `build_tiki_taka_kernel_strategy` and the pickers only it uses.""" - -from __future__ import annotations - -from typing import Optional - -from utama_core.engine.context import TickContext -from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy -from utama_core.engine.tactic import RobotId -from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.strategy.pickers import ( - allocate_ordered, - carrier_first, - friendly_closer_to_ball, -) -from utama_core.tactics.give_and_go import GiveAndGoTactic -from utama_core.tactics.press_and_contain import PressAndContainTactic -from utama_core.tactics.shadow_and_mark import ShadowAndMarkTactic - - -def _tiki_taka_picker( - game: Game, - free_robots: frozenset[RobotId], - prev_partition: Optional[dict[str, frozenset[RobotId]]], - available_tactic_ids: frozenset[str], -) -> dict[str, frozenset[RobotId]]: - """Tiki-taka posture: possession attack with give-and-go, press on loss, - shadow-and-mark cover in both postures. - - - We have the ball (friendly closer to it, or unknown): 3 attackers - (give-and-go trio), 2 defenders (one shadowing pair on the shot line). - - The opponent has the ball: 3 pressers (1 ball-presser + 2 man-markers) - and 2 shadowers — the press denies the immediate play while the shadow - pair keeps the shot line honest behind it. - - A slot that is unavailable (inapplicable — PressAndContain only, or - commitment-pinned so it never appears in `available_tactic_ids`) has - its share folded into the other non-pinned attacker/defender slot, so - every free robot always lands somewhere. - """ - ordered = carrier_first(game, free_robots) - if not ordered: - return {} - - friendly_edge = friendly_closer_to_ball(game) - losing = friendly_edge is not True # enemy closer, or unknown -> conservative - - press_ok = "press" in available_tactic_ids - attack_ok = "attack" in available_tactic_ids - defense_ok = "defense" in available_tactic_ids - - if losing and press_ok: - # Press with the ball-side group, shadow with the rest; if there is - # nothing to shadow behind (no defense slot), press with everyone. - if defense_ok: - return allocate_ordered(ordered, "press", 3, "defense") - return allocate_ordered(ordered, "press", len(ordered)) - if losing: - # No press available: everyone shadows/marks. - if defense_ok: - return allocate_ordered(ordered, "defense", len(ordered)) - if attack_ok: - return allocate_ordered(ordered, "attack", len(ordered)) - return {} - - # We have the ball: attack with the forward group, keep a covering pair. - if attack_ok: - return allocate_ordered(ordered, "attack", 3, "defense" if defense_ok else None) - if defense_ok: - return allocate_ordered(ordered, "defense", len(ordered)) - return {} - - -def build_tiki_taka_kernel_strategy(outfield_robot_ids: tuple[int, ...]): - """Real possession-play team: give-and-go build-up, press on loss, - shadow-and-mark cover behind every attack. - - Three concurrent slots — `GiveAndGoTactic` ("attack"), - `PressAndContainTactic` ("press", only when an enemy is within pressing - range of the ball — its `applicable()`), and - `ShadowAndMarkTactic` ("defense") — allocated by `_tiki_taka_picker` on - the possession edge: 3+2 attack/cover when the ball is ours, 3+2 - press/cover when it is lost. The give-and-go loop is the build-up engine: - short hops under pressure instead of `PassAndShootTactic`'s scripted - setup-then-shoot, which the match-stuck investigation showed cannot - complete under contest. - - Returns a `build_kernel_strategy(motion_controller)` - callable suitable for `AbstractStrategy`'s constructor argument of the - same name. - """ - - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={ - "attack": GiveAndGoTactic(), - "press": PressAndContainTactic(), - "defense": ShadowAndMarkTactic(), - }, - partitioner=_tiki_taka_picker, - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build diff --git a/utama_core/strategy/press_trigger_flow.py b/utama_core/strategy/tripwire.py similarity index 66% rename from utama_core/strategy/press_trigger_flow.py rename to utama_core/strategy/tripwire.py index 04d019693..3cee56430 100644 --- a/utama_core/strategy/press_trigger_flow.py +++ b/utama_core/strategy/tripwire.py @@ -1,4 +1,4 @@ -"""The `press_trigger_flow` kernel strategy: `build_press_trigger_flow_kernel_strategy` and the pickers only it uses.""" +"""`tripwire` (until 2026-11-12 `press_trigger_flow`): `riptide` that goes all in on the ball once it is lost in its own third. The pickers only it uses are here.""" from __future__ import annotations @@ -8,7 +8,7 @@ from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy from utama_core.engine.tactic import RobotId from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController from utama_core.strategy.pickers import ( allocate_ordered, ball_zone, @@ -20,35 +20,35 @@ from utama_core.tactics.press_and_contain import PressAndContainTactic # --------------------------------------------------------------------------- -# press_trigger_flow (2026-09-02 addition) +# tripwire (2026-09-02 addition) # -# `counter_flow` presses with a fixed 3 robots any time pressing is +# `riptide` presses with a fixed 3 robots any time pressing is # applicable at all, regardless of where on the pitch that press happens -- # the same commitment whether the ball was lost at the halfway line or deep # in our own third. `ball_zone` is already read by every zone-handoff -# picker (`zone_fluid`, `tiki_taka_plus`, `high_line_zone`, ...) to change +# picker (`zone_fluid`, `weaver`, `high_line_zone`, ...) to change # the *attacking* pattern by zone, but no picker in the catalog uses it to # change the *press* commitment by zone -- this strategy is that missing -# combination: counter_flow's proven engine, with the press going all-in +# combination: riptide's proven engine, with the press going all-in # (every free robot, not just 3) specifically when the loss happens in our # own third, since a loose ball that close to our own goal is the one -# situation where `clear_danger`'s own author-noted lesson ("ball control, +# situation where `firebreak`'s own author-noted lesson ("ball control, # not territory, is the bottleneck") is most costly to get wrong. Everywhere # else (mid/final third losses, and every attacking-side branch), this is -# byte-for-byte identical to `_counter_flow_picker`. +# byte-for-byte identical to `_riptide_picker`. # --------------------------------------------------------------------------- -def _press_trigger_flow_picker( +def _tripwire_picker( game: Game, free_robots: frozenset[RobotId], prev_partition: Optional[dict[str, frozenset[RobotId]]], available_tactic_ids: frozenset[str], ) -> dict[str, frozenset[RobotId]]: - """`_counter_flow_picker`'s allocation, with an all-in press (every free + """`_riptide_picker`'s allocation, with an all-in press (every free robot, not the usual 3+2 split) when the ball is lost specifically in our own third. Mid/final-third losses and every attacking-side branch - are unchanged from `_counter_flow_picker` -- see that picker's + are unchanged from `_riptide_picker` -- see that picker's docstring for the shared attack/press/block rationale this one inherits unmodified outside the own-third-press branch. """ @@ -87,34 +87,31 @@ def _press_trigger_flow_picker( return {} -def build_press_trigger_flow_kernel_strategy(outfield_robot_ids: tuple[int, ...]): - """`counter_flow` with a zone-triggered all-in press: the usual 3-press/ +def build(outfield_robot_ids: tuple[int, ...], motion_controller: MotionController) -> KernelSchedulerStrategy: + """`riptide` with a zone-triggered all-in press: the usual 3-press/ 2-block split everywhere, except an all-in press (every free robot) when the ball is lost in our own third specifically. See the - "press_trigger_flow" comment block above `_press_trigger_flow_picker` + "tripwire" comment block above `_tripwire_picker` for the full rationale. - Same three tactics/slots as `counter_flow` (`GiveAndGoTactic`/ + Same three tactics/slots as `riptide` (`GiveAndGoTactic`/ `PressAndContainTactic`/`BlockShapeTactic`) -- only the picker's own-third press commitment differs, so any observed difference from - plain `counter_flow` is attributable to the zone-triggered press alone. + plain `riptide` is attributable to the zone-triggered press alone. - Returns a `build_kernel_strategy(motion_controller)` + Returns a `build(motion_controller)` callable suitable for `AbstractStrategy`'s constructor argument of the same name. """ - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={ - "attack": GiveAndGoTactic(), - "press": PressAndContainTactic(), - "block": BlockShapeTactic(), - }, - partitioner=_press_trigger_flow_picker, - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build + ctx = TickContext(motion_controller=motion_controller) + return KernelSchedulerStrategy( + tactics={ + "attack": GiveAndGoTactic(), + "press": PressAndContainTactic(), + "block": BlockShapeTactic(), + }, + partitioner=_tripwire_picker, + outfield_robot_ids=outfield_robot_ids, + ctx=ctx, + ) diff --git a/utama_core/strategy/tiki_taka_plus.py b/utama_core/strategy/weaver.py similarity index 78% rename from utama_core/strategy/tiki_taka_plus.py rename to utama_core/strategy/weaver.py index 618baed5e..11f16810f 100644 --- a/utama_core/strategy/tiki_taka_plus.py +++ b/utama_core/strategy/weaver.py @@ -1,4 +1,4 @@ -"""The `tiki_taka_plus` kernel strategy: `build_tiki_taka_plus_kernel_strategy` and the pickers only it uses.""" +"""`weaver` (until 2026-11-12 `tiki_taka_plus`): short passing, then a two-robot move in the final third. The pickers only it uses are here.""" from __future__ import annotations @@ -8,7 +8,7 @@ from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy from utama_core.engine.tactic import RobotId from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController from utama_core.strategy.pickers import ( allocate_ordered, ball_zone, @@ -21,24 +21,24 @@ from utama_core.tactics.shadow_and_mark import ShadowAndMarkTactic # --------------------------------------------------------------------------- -# tiki_taka_plus (2026-08-23 addition) +# weaver (2026-08-23 addition) # -# Every "beat tiki_taka" attempt in the catalog (`overload_press`, -# `high_line_zone`, `counter_flow`) targeted the same weakness: tiki_taka's +# Every "beat tiki_taka" attempt in the catalog (`avalanche`, +# `high_line_zone`, `riptide`) targeted the same weakness: tiki_taka's # defensive cover is a flat 2 robots in *every* posture, with no # specialization anywhere on the pitch. The two attempts that tried to # outnumber that thin line lost before the numbers edge ever mattered -- # tiki_taka's own 3-robot press smothered them in the transition window -# first. `counter_flow` won instead by matching tiki_taka's engine +# first. `riptide` won instead by matching tiki_taka's engine # (`GiveAndGoTactic`, same press numbers) and adding a wrinkle tiki_taka # itself lacks (a space-denying block screen instead of man-marking). # -# `tiki_taka_plus` applies that same lesson *to* tiki_taka rather than +# `weaver` applies that same lesson *to* tiki_taka rather than # *against* it: keep tiki_taka's proven build-up/press engine untouched, and # add the one wrinkle it doesn't have -- a distinct final-third finishing # move. `_zone_flow_picker` already validated handing the attacking slot # from `GiveAndGoTactic` to `DecoyOverloadTactic`'s two-role duet once the -# ball crosses into the final third (see `build_zone_fluid_kernel_strategy`); +# ball crosses into the final third (see `zone_fluid`); # this grafts that same handoff onto tiki_taka's stronger 3/2 base shape # instead of `zone_fluid`'s weaker one. # @@ -52,13 +52,13 @@ # presses with 3 robots (not just the 2 original cover robots) any time the # ball is lost. tiki_taka's cover pair already gets folded into the press # the moment possession is lost -- there is no separate "poaching" gap to -# close at the picker level. So `tiki_taka_plus` only implements the +# close at the picker level. So `weaver` only implements the # final-third handoff; it reuses `_tiki_taka_picker`'s possession-edge and # press logic unchanged. # --------------------------------------------------------------------------- -def _tiki_taka_plus_picker( +def _weaver_picker( game: Game, free_robots: frozenset[RobotId], prev_partition: Optional[dict[str, frozenset[RobotId]]], @@ -117,47 +117,44 @@ def _tiki_taka_plus_picker( return {} -def build_tiki_taka_plus_kernel_strategy(outfield_robot_ids: tuple[int, ...]): +def build(outfield_robot_ids: tuple[int, ...], motion_controller: MotionController) -> KernelSchedulerStrategy: """`tiki_taka` with a final-third finishing wrinkle: same give-and-go build-up and press-on-loss engine, but the attacking slot hands off to `DecoyOverloadTactic`'s two-role duet once the ball reaches the final third, instead of running the give-and-go trio the whole length of the - pitch. See the "tiki_taka_plus" comment block above - `_tiki_taka_plus_picker` for the full design rationale, including why a + pitch. See the "weaver" comment block above + `_weaver_picker` for the full design rationale, including why a second considered change (press applicability for the cover pair) turned out to already be present in tiki_taka's existing structure. Four concurrent slots -- `GiveAndGoTactic` ("attack"), `DecoyOverloadTactic` ("overload"), `PressAndContainTactic` ("press"), and `ShadowAndMarkTactic` ("defense") -- allocated by - `_tiki_taka_plus_picker`: 3+2 attack/cover in the own/mid thirds, 2+3 + `_weaver_picker`: 3+2 attack/cover in the own/mid thirds, 2+3 overload/cover in the final third, 3+2 press/cover when the ball is lost. Promoted into `full_match_tournament.py`'s `competitive` tier 2026-08-23 on its first decoupled side x kickoff round-robin result (6W-7D over 16 - matches, tying `counter_flow` for most wins and clearly outperforming its - own base `tiki_taka`, 3W-10D) -- see `docs/strategies.md`'s "tiki_taka_plus + matches, tying `riptide` for most wins and clearly outperforming its + own base `tiki_taka`, 3W-10D) -- see `docs/strategies.md`'s "weaver added" section for the full writeup, including the caveat that one 40-match run isn't yet enough to rule out variance at this sample size. - Returns a `build_kernel_strategy(motion_controller)` + Returns a `build(motion_controller)` callable suitable for `AbstractStrategy`'s constructor argument of the same name. """ - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={ - "attack": GiveAndGoTactic(), - "overload": DecoyOverloadTactic(), - "press": PressAndContainTactic(), - "defense": ShadowAndMarkTactic(), - }, - partitioner=_tiki_taka_plus_picker, - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build + ctx = TickContext(motion_controller=motion_controller) + return KernelSchedulerStrategy( + tactics={ + "attack": GiveAndGoTactic(), + "overload": DecoyOverloadTactic(), + "press": PressAndContainTactic(), + "defense": ShadowAndMarkTactic(), + }, + partitioner=_weaver_picker, + outfield_robot_ids=outfield_robot_ids, + ctx=ctx, + ) diff --git a/utama_core/strategy/high_press.py b/utama_core/strategy/wolfpack.py similarity index 54% rename from utama_core/strategy/high_press.py rename to utama_core/strategy/wolfpack.py index b14397c72..d5ac46f0f 100644 --- a/utama_core/strategy/high_press.py +++ b/utama_core/strategy/wolfpack.py @@ -1,19 +1,19 @@ -"""The `high_press` kernel strategy: `build_high_press_kernel_strategy` and the pickers only it uses.""" +"""`wolfpack` (until 2026-11-12 `high_press`): hunts the ball high up as a group, a fixed 80/20 attack-heavy split. The pickers only it uses are here.""" from __future__ import annotations from utama_core.engine.context import TickContext from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController from utama_core.strategy.pickers import fixed_ratio_picker from utama_core.tactics.give_and_go import GiveAndGoTactic from utama_core.tactics.press_and_contain import PressAndContainTactic -def build_high_press_kernel_strategy(outfield_robot_ids: tuple[int, ...]): +def build(outfield_robot_ids: tuple[int, ...], motion_controller: MotionController) -> KernelSchedulerStrategy: """5-robot (or fewer) `Strategy` factory: an aggressive, *non-reactive* posture — most of the pool commits forward regardless of who has the - ball, unlike `build_press_and_pass_kernel_strategy`'s possession-edge + ball, unlike `terrier`'s possession-edge split. Wires the same `GiveAndGoTactic`/`PressAndContainTactic` pair as that config, but the two are not interchangeable: the point here is to demonstrate that the same Tactic set can be driven by a mechanically @@ -21,18 +21,15 @@ def build_high_press_kernel_strategy(outfield_robot_ids: tuple[int, ...]): scheduling *policy* is what varies between example strategies, not just the Tactic roster. - Returns a `build_kernel_strategy(motion_controller)` + Returns a `build(motion_controller)` callable suitable for `AbstractStrategy`'s constructor argument of the same name. """ - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={"attack": GiveAndGoTactic(), "defense": PressAndContainTactic()}, - partitioner=fixed_ratio_picker("attack", "defense", attack_fraction=0.8), - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build + ctx = TickContext(motion_controller=motion_controller) + return KernelSchedulerStrategy( + tactics={"attack": GiveAndGoTactic(), "defense": PressAndContainTactic()}, + partitioner=fixed_ratio_picker("attack", "defense", attack_fraction=0.8), + outfield_robot_ids=outfield_robot_ids, + ctx=ctx, + ) diff --git a/utama_core/strategy/zone_fluid.py b/utama_core/strategy/zone_fluid.py deleted file mode 100644 index 730a0dcda..000000000 --- a/utama_core/strategy/zone_fluid.py +++ /dev/null @@ -1,104 +0,0 @@ -"""The `zone_fluid` kernel strategy: `build_zone_fluid_kernel_strategy` and the pickers only it uses.""" - -from __future__ import annotations - -from typing import Optional - -from utama_core.engine.context import TickContext -from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy -from utama_core.engine.tactic import RobotId -from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.strategy.pickers import ( - allocate_ordered, - ball_zone, - carrier_first, - friendly_closer_to_ball, -) -from utama_core.tactics.decoy_and_overload import DecoyOverloadTactic -from utama_core.tactics.give_and_go import GiveAndGoTactic -from utama_core.tactics.shadow_and_mark import ShadowAndMarkTactic - - -def _zone_flow_picker( - game: Game, - free_robots: frozenset[RobotId], - prev_partition: Optional[dict[str, frozenset[RobotId]]], - available_tactic_ids: frozenset[str], -) -> dict[str, frozenset[RobotId]]: - """Zone-flow posture: the attacking *pattern* changes with ball zone, the - defense stays man-shaped throughout. - - - Opponent has the ball: everyone shadows/marks (the whole team in - shape). - - We have the ball in our own or middle third: a give-and-go trio works - the ball forward while 2 shadow/mark. - - We have the ball in the final third: the decoy-and-overload pair - lures the last line out of position (2 robots — that tactic is a - two-role duet by design) while the other 3 hold the defensive shape. - """ - ordered = carrier_first(game, free_robots) - if not ordered: - return {} - - friendly_edge = friendly_closer_to_ball(game) - losing = friendly_edge is not True - - defense_ok = "defense" in available_tactic_ids - givego_ok = "givego" in available_tactic_ids - overload_ok = "overload" in available_tactic_ids - - if losing: - if defense_ok: - return allocate_ordered(ordered, "defense", len(ordered)) - if givego_ok: - return allocate_ordered(ordered, "givego", len(ordered)) - if overload_ok: - return allocate_ordered(ordered, "overload", len(ordered)) - return {} - - zone = ball_zone(game) - if zone == "final" and overload_ok: - return allocate_ordered(ordered, "overload", 2, "defense" if defense_ok else None) - if givego_ok: - return allocate_ordered(ordered, "givego", 3, "defense" if defense_ok else None) - if overload_ok: - return allocate_ordered(ordered, "overload", len(ordered)) - if defense_ok: - return allocate_ordered(ordered, "defense", len(ordered)) - return {} - - -def build_zone_fluid_kernel_strategy(outfield_robot_ids: tuple[int, ...]): - """Zone-adaptive team: the attacking pattern itself changes with ball - position, the first strategy in the catalog with two concurrent ATTACK- - tagged slots that the picker chooses between — exactly the use the closed - `TacticTag` vocabulary exists for. - - Three concurrent slots — `GiveAndGoTactic` ("givego"), - `DecoyOverloadTactic` ("overload"), and `ShadowAndMarkTactic` - ("defense") — allocated by `_zone_flow_picker`: the whole team takes - man-shape when the ball is lost; the give-and-go trio builds up through - the middle thirds; and in the final third the two-robot decoy/overload - duet replaces the trio, luring the last line out of position instead of - passing into it. - - Returns a `build_kernel_strategy(motion_controller)` - callable suitable for `AbstractStrategy`'s constructor argument of the - same name. - """ - - def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: - ctx = TickContext(motion_controller=motion_controller) - return KernelSchedulerStrategy( - tactics={ - "givego": GiveAndGoTactic(), - "overload": DecoyOverloadTactic(), - "defense": ShadowAndMarkTactic(), - }, - partitioner=_zone_flow_picker, - outfield_robot_ids=outfield_robot_ids, - ctx=ctx, - ) - - return _build diff --git a/utama_core/tactics/_pass_and_score.py b/utama_core/tactics/_pass_and_score.py index 2bf6c1dea..5e8fd5188 100644 --- a/utama_core/tactics/_pass_and_score.py +++ b/utama_core/tactics/_pass_and_score.py @@ -22,8 +22,9 @@ from utama_core.entities.data.command import RobotCommand from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.shared.field_scaling import scale_point_from_standard_field -from utama_core.shared.pass_and_score_geometry import ( +from utama_core.geometry.field_scaling import scale_point_from_standard_field +from utama_core.geometry.pass_and_score_geometry import ( + ANNOUNCE_PASS_RAD, at_target, ball_line_receive_point, carry_exhausted, @@ -39,18 +40,14 @@ intercept_point, kick_bend, no_shot_reposition_target, + open_teammate, oriented_towards, score_pass_setup, segment_blocked, shot_heading_reachable, ) -from utama_core.skills.src.go_to_ball import go_to_ball -from utama_core.skills.src.utils.move_utils import ( - empty_command, - kick, - move, - turn_on_spot, -) +from utama_core.skills.go_to_ball import go_to_ball +from utama_core.skills.utils.move_utils import empty_command, kick, move, turn_on_spot _MIN_SETUP_CLEARANCE = 0.35 # metres — must be > FPP's SAFE_OBSTACLES_RADIUS (0.26 m) _SETUP_SAMPLE_COUNT = 48 @@ -445,15 +442,37 @@ def _pass_exec( FACE_GOAL_RAD = 0.3 +_LAY_OFF_TOLERANCE_RAD = 0.1 + + def move_for_a_shot(game: Game, ctx: TickContext, robot_id: int) -> RobotCommand: - """No clear shot: with the ball, slide sideways for one (`no_shot_reposition_target`), - facing the goal. A robot that took the ball facing elsewhere pivots on it to face the goal + """No clear shot: pass to an open teammate; with none, slide sideways for a shot + (`no_shot_reposition_target`), facing the goal. A robot that took the ball facing elsewhere pivots on it to face the goal first: turning while sliding lost the ball every time on the real robots (shooting drill, 2026-10-28), while the pivot is what pass_receive turns with. It pivots only with the ball sensor on: seen on the dribbler's edge but not on the sensor, the pivot turned away from the ball and pushed it off (save_and_counter, 2026-10-28), so it settles the ball first.""" goal_x, goal_y1, goal_y2 = enemy_goal_line(game) robot = game.friendly_robots[robot_id] + teammate = open_teammate(game, robot_id) if has_ball(game, robot_id) else None + if teammate is not None: + # Sliding sideways gains no ground and was the loop behind the jams of 2026-11-09. + target_oren = robot.p.angle_to(game.friendly_robots[teammate].p) - kick_bend( + game, ctx.motion_controller, robot_id + ) + if oriented_towards(game, robot_id, target_oren, ANNOUNCE_PASS_RAD): + ctx.expected_receivers.add(teammate) + if oriented_towards(game, robot_id, target_oren, _LAY_OFF_TOLERANCE_RAD): + ctx.trace(game, f"shoot[{robot_id}]", "no clear shot · passing") + return kick() + ctx.trace(game, f"shoot[{robot_id}]", "no clear shot · turning to pass") + return turn_on_spot( + game=game, + motion_controller=ctx.motion_controller, + robot_id=robot_id, + target_oren=target_oren, + dribbling=True, + ) goal_oren = robot.p.angle_to(Vector2D(goal_x, (goal_y1 + goal_y2) / 2.0)) if not oriented_towards(game, robot_id, goal_oren, FACE_GOAL_RAD): if not has_ball(game, robot_id): diff --git a/utama_core/tactics/block_shape.py b/utama_core/tactics/block_shape.py index 8260a0f48..fde95b2ac 100644 --- a/utama_core/tactics/block_shape.py +++ b/utama_core/tactics/block_shape.py @@ -23,7 +23,7 @@ sense as a "slow the carrier down" standoff, which is meaningless once there is no carrier at all; without this a loose ball near (but wide of) our own box just sits there with the first defender parked on an axis nobody is threatening. - Found live: a `clear_danger` vs `low_block`-shaped match pinned 28 seconds this + Found live: a `firebreak` vs `low_block`-shaped match pinned 28 seconds this way (see `tactics/defense.py`'s matching fix for the sibling case in `DefenseTactic`). - **screen** (everyone else): holds the line at `_SCREEN_OFFSET` in front of our @@ -46,12 +46,12 @@ from utama_core.entities.data.command import RobotCommand from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.shared.pass_and_score_geometry import ( +from utama_core.geometry.pass_and_score_geometry import ( ball_in_own_defense_area, ball_is_loose, ) -from utama_core.skills.src.go_to_ball import go_to_ball -from utama_core.skills.src.go_to_point import go_to_point +from utama_core.skills.go_to_ball import go_to_ball +from utama_core.skills.go_to_point import go_to_point # Depth of our own defense area (standard SSL penalty box front edge). _DEFENSE_AREA_DEPTH = 1.3 diff --git a/utama_core/tactics/clear_ball.py b/utama_core/tactics/clear_ball.py index 012d2e74e..2fa6e57db 100644 --- a/utama_core/tactics/clear_ball.py +++ b/utama_core/tactics/clear_ball.py @@ -46,7 +46,7 @@ from utama_core.entities.data.command import RobotCommand from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.shared.pass_and_score_geometry import ( +from utama_core.geometry.pass_and_score_geometry import ( ball_in_own_defense_area, clamp_outside_own_defense_area, enemy_positions, @@ -55,10 +55,10 @@ own_defense_area_exit_point, segment_clearance, ) -from utama_core.shared.tolerance import Sticky -from utama_core.skills.src.go_to_ball import go_to_ball -from utama_core.skills.src.go_to_point import go_to_point -from utama_core.skills.src.utils.move_utils import kick, turn_on_spot +from utama_core.geometry.tolerance import Sticky +from utama_core.skills.go_to_ball import go_to_ball +from utama_core.skills.go_to_point import go_to_point +from utama_core.skills.utils.move_utils import kick, turn_on_spot # Ball deeper than this (distance from our own goal line) counts as "danger # zone" for applicability. Slightly tighter than the whole own third @@ -136,13 +136,13 @@ def _clearance_candidates(game: Game, ball_p: Vector2D) -> list[Vector2D]: def _best_clear_target(game: Game, ball_p: Vector2D, prev_target: Optional[Vector2D]) -> Vector2D: """Openest upfield lane, with hysteresis toward the previous choice. - Uses `shared.tolerance.Sticky` — this function (along with + Uses `geometry.tolerance.Sticky` — this function (along with `pass_and_shoot.assign_passer_receiver`) is the real-world shape `Sticky` was designed to fit: a fixed candidate set scored fresh each tick, sticking with the incumbent unless a challenger clears a margin. Confirmed behaviour-identical to the previous hand-rolled fold via `test_sticky_matches_hand_rolled_margin_logic_seeded_random` - (`tests/shared/test_tolerance.py`), 300 seeded-random candidate sets, + (`tests/geometry/test_tolerance.py`), 300 seeded-random candidate sets, zero mismatches. """ enemies = enemy_positions(game) @@ -297,7 +297,7 @@ def _trace( phase: str, command: Optional[RobotCommand], ) -> None: - """Per-tick mechanism trace (see STRATEGY_DEVELOPMENT.md's observability + """Per-tick mechanism trace (see strategy.md's observability section). `match_log` is None on tournament/CI runs, so this is a no-op there and stays in permanently.""" if ctx.match_log is None: diff --git a/utama_core/tactics/decoy_and_overload.py b/utama_core/tactics/decoy_and_overload.py index 54c84373c..44d35c75a 100644 --- a/utama_core/tactics/decoy_and_overload.py +++ b/utama_core/tactics/decoy_and_overload.py @@ -39,7 +39,7 @@ Reuses `_pass_and_score`'s `_pass_exec`/`_score_goal` for the mechanics of the pass/shot (generic two-robot ball transfer and shot-taking, not specific to any one tactic's phase sequence — same reuse rationale `GiveAndGoTactic` -gives), and `go_to_point`/`shared.pass_and_score_geometry` for movement and +gives), and `go_to_point`/`geometry.pass_and_score_geometry` for movement and shot-lane checks. What's new is only the lure decision and the dragged-marker detection layered on top. @@ -61,7 +61,7 @@ from utama_core.entities.data.object import ObjectType, TeamType from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.shared.pass_and_score_geometry import ( +from utama_core.geometry.pass_and_score_geometry import ( carry_exhausted, carry_origin, clamp_outside_enemy_defense_area, @@ -71,8 +71,8 @@ has_ball, segment_blocked, ) -from utama_core.skills.src.go_to_ball import go_to_ball -from utama_core.skills.src.go_to_point import go_to_point +from utama_core.skills.go_to_ball import go_to_ball +from utama_core.skills.go_to_point import go_to_point from utama_core.tactics._pass_and_score import _pass_exec, _score_goal _LURE_DRAG_THRESHOLD = 0.8 # metres — marker must be pulled at least this far off the central shot lane's y diff --git a/utama_core/tactics/defense.py b/utama_core/tactics/defense.py index ffb53c03e..5b264035a 100644 --- a/utama_core/tactics/defense.py +++ b/utama_core/tactics/defense.py @@ -4,7 +4,7 @@ BT strategy was almost entirely role-assignment plumbing (`SetRoles` pinning robot 4 as goalkeeper, `execute_default_action` dispatching by `Role`) around a single already-self-contained skill function, -`utama_core.skills.src.defend_parameter.defend_parameter` — the actual +`utama_core.skills.defend_parameter.defend_parameter` — the actual positioning logic (choosing which post to cover, shadowing the shot line, picking sides dynamically for a 2-defender team) already lives in Core and needed no porting itself. This tactic is that same dispatch, expressed as a @@ -13,7 +13,7 @@ Exception: a loose ball with no enemy contesting it (see `ball_is_loose`) never gets shadowed at all — shadowing only ever reacts to the ball's current position, so an abandoned ball just sits there forever with a -defender parked a shot-shadow's distance away. Found live: a `clear_danger` +defender parked a shot-shadow's distance away. Found live: a `firebreak` vs `low_block` match pinned 28 straight seconds this way, ball dead in a corner near `low_block`'s own goal line, three defenders standing 1.1-1.5m away all still shadowing a shot no one was taking. The nearest @@ -49,25 +49,21 @@ from utama_core.engine.context import TickContext from utama_core.engine.tactic import BaseTactic, RobotId, TacticTag from utama_core.entities.data.command import RobotCommand -from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.shared.pass_and_score_geometry import ( +from utama_core.geometry.pass_and_score_geometry import ( ball_in_own_defense_area, ball_is_loose, has_ball, oriented_towards, own_defense_area_exit_point, + upfield_heading, ) -from utama_core.skills.src.defend_parameter import defend_parameter -from utama_core.skills.src.go_to_ball import go_to_ball -from utama_core.skills.src.go_to_point import go_to_point -from utama_core.skills.src.utils.move_utils import kick, turn_on_spot +from utama_core.skills.defend_parameter import defend_parameter +from utama_core.skills.go_to_ball import go_to_ball +from utama_core.skills.go_to_point import go_to_point +from utama_core.skills.utils.move_utils import kick, turn_on_spot _LOOSE_BALL_CLAIM_RANGE = 1.5 # metres — matches ball_is_loose's own contest range -# How far upfield (away from our own goal) the clearance aims, along the -# ball's current y — simpler than `ClearBallTactic`'s multi-lane scoring, -# appropriate for this tactic's "minimal baseline" role (see class docstring). -_CLEAR_DISTANCE = 4.5 @dataclass @@ -190,12 +186,7 @@ def _clear(self, game: Game, ctx: TickContext, robot_id: RobotId) -> RobotComman docstring). `robot_id` is only ever called here once it already has the ball (`carrier_id`'s definition in `tick()`), so there is no chase branch.""" - ball_pos = game.ball.p.to_2d() - attack_dir = -1.0 if game.my_team_is_right else 1.0 - half_length = game.field.half_length - target_x = max(-half_length + 0.5, min(half_length - 0.5, ball_pos.x + attack_dir * _CLEAR_DISTANCE)) - target = Vector2D(target_x, ball_pos.y) - target_oren = game.friendly_robots[robot_id].p.angle_to(target) + target_oren = upfield_heading(game, robot_id) if oriented_towards(game, robot_id, target_oren) and has_ball(game, robot_id): return kick() return turn_on_spot( diff --git a/utama_core/tactics/dribble.py b/utama_core/tactics/dribble.py index c58cafc6c..3db5cd61f 100644 --- a/utama_core/tactics/dribble.py +++ b/utama_core/tactics/dribble.py @@ -21,9 +21,9 @@ from utama_core.entities.data.command import RobotCommand from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.shared.pass_and_score_geometry import at_target, has_ball -from utama_core.skills.src.go_to_ball import go_to_ball -from utama_core.skills.src.utils.move_utils import empty_command, move +from utama_core.geometry.pass_and_score_geometry import at_target, has_ball +from utama_core.skills.go_to_ball import go_to_ball +from utama_core.skills.utils.move_utils import empty_command, move # Rectangle corners as fractions of field half-dimensions, in traversal order. _RECT_X_FRAC = 0.55 diff --git a/utama_core/tactics/give_and_go.py b/utama_core/tactics/give_and_go.py index 8faf854ba..d6060e4a4 100644 --- a/utama_core/tactics/give_and_go.py +++ b/utama_core/tactics/give_and_go.py @@ -39,13 +39,15 @@ from dataclasses import dataclass, field from typing import Optional +from utama_core.config.physical_constants import ROBOT_RADIUS from utama_core.config.settings import CONTROL_FREQUENCY from utama_core.engine.context import TickContext from utama_core.engine.tactic import BaseTactic, RobotId, TacticId, TacticTag from utama_core.entities.data.command import RobotCommand from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.shared.pass_and_score_geometry import ( +from utama_core.geometry.pass_and_score_geometry import ( + MIN_OPEN_TEAMMATE_M, ball_in_own_defense_area, ball_line_receive_point, carry_exhausted, @@ -63,13 +65,14 @@ no_shot_reposition_target, oriented_towards, own_defense_area_exit_point, + release_heading, score_pass_setup, segment_blocked, shot_heading_reachable, ) -from utama_core.skills.src.go_to_ball import go_to_ball -from utama_core.skills.src.go_to_point import go_to_point -from utama_core.skills.src.utils.move_utils import kick, move, turn_on_spot +from utama_core.skills.go_to_ball import go_to_ball +from utama_core.skills.go_to_point import go_to_point +from utama_core.skills.utils.move_utils import kick, move, turn_on_spot from utama_core.tactics._pass_and_score import _pass_exec, move_for_a_shot _MAX_HOPS_PER_POSSESSION = 6 # safety valve — force a shot attempt rather than passing forever @@ -83,13 +86,17 @@ # field corner locked a receiver_id and then held the ball motionless for # the rest of a 600s match — `is_committed()` returns True whenever # receiver_id is not None, so nothing ever reassigns these robots either, -# and no custom_referee rule catches a legally-dribbling, barely-moving +# and no referee rule catches a legally-dribbling, barely-moving # ball outside a defense area (keeper_held_ball only watches the defense # area; excessive_dribbling only watches distance carried, not hold time). # Abandoning a hop that's taken too long and forcing the fallback shoot/ # reposition path (same one used when no pass lane exists at all) breaks # the deadlock regardless of which specific geometry caused the receiver to # never arrive. +# How long a carrier waits with the ball for its receiver to get into place before passing to it +# where it stands. Waited out to `_MAX_HOP_TICKS`, twice over on a first touch, carriers stood still +# for 9 s after free kicks (high_press_vs_split_shape t=500.6, tournament_20261109_225810). +_MAX_PASS_WAIT_TICKS = round(1.0 * CONTROL_FREQUENCY) _MAX_HOP_TICKS = round(4.0 * CONTROL_FREQUENCY) # 4s — generous vs. a real catch, short vs. a match # An enemy walking onto the direct carrier-receiver line mid-hop makes the # pass interceptable, but is a much more urgent signal than "receiver is @@ -130,6 +137,7 @@ # `_MAX_HOPS_PER_POSSESSION` and force the shot rather than repositioning # forever. _FIRST_TOUCH_FORCE_SHOT_TICKS = round(15.0 * CONTROL_FREQUENCY) # 15s — well past any real restart window +_RELOCATE_LANE_CLEARANCE = ROBOT_RADIUS + 0.1 _RELOCATE_MIN_SEPARATION = 0.9 # metres — a relocating support point must clear the carrier and other supports # Retreat standoff from our own area front edge while the ball is in our own # half: support robots hold this far off the box line instead of packing it. @@ -150,7 +158,6 @@ def _best_receiver(game: Game, carrier_id: int, candidate_ids: tuple[int, ...]) return best_id -_MIN_SAFE_PASS_DISTANCE = 0.7 # metres — matches score_pass_setup's own min_pass_distance _SHOT_SWITCH_MARGIN = 0.15 # metres a new shot gap must beat the aimed-at one by; same as _pass_and_score's @@ -174,7 +181,7 @@ def _nearest_safe_receiver(game: Game, carrier_id: int, candidate_ids: tuple[int for candidate_id in candidate_ids: candidate_pos = game.friendly_robots[candidate_id].p dist = carrier_pos.distance_to(candidate_pos) - if dist < _MIN_SAFE_PASS_DISTANCE: + if dist < MIN_OPEN_TEAMMATE_M: continue if segment_blocked(carrier_pos, candidate_pos, enemies): continue @@ -201,7 +208,7 @@ def _relocate_target(game: Game, robot_id: int, avoid: list[Vector2D]) -> Vector team always attacks toward `+x` — for `my_team_is_right=False` (attacking `-x`), every candidate this produced sat *behind* the ball, toward this team's own goal, not ahead of it. Found live investigating a real "these - strategies never shoot" bug (`high_press`/`overload_flow`/ + strategies never shoot" bug (`wolfpack`/`overload_flow`/ `score_aware_zone_flow`, 2026-09-05, `docs/roadmap.md`): traced replay showed `give_and_go.shot_lane.open=True` 132 times in one match, yet the carrier's x-position never advanced past -1.10 toward a goal at -4.5 — @@ -261,8 +268,13 @@ def _relocate_target(game: Game, robot_id: int, avoid: list[Vector2D]) -> Vector # reachable run beats a short lateral shuffle); among similarly # advanced options, the one nearest this robot, so the target holds # still once reached. `avoid` already keeps support robots apart. + # A run nobody can pass to first of all: the lane from the ball counts before the progress. + # Wider for a spot further from where the robot stands, so it does not leave a lane it has + # for one that only looks a little better. + lane = _RELOCATE_LANE_CLEARANCE + (0.1 if point.distance_to(current) > 0.5 else 0.0) + lane_open = not segment_blocked(game.ball.p.to_2d(), point, enemy_positions(game), lane) progress = point.x * attack_sign - key = (progress, -point.distance_to(current)) + key = (lane_open, progress, -point.distance_to(current)) if best_progress is None or key > best_progress: best, best_progress = point, key return best if best is not None else current @@ -487,8 +499,7 @@ def tick( # the shoot branch below, which would reintroduce the double- # touch bug this whole block exists to prevent. Retry next tick # as `_relocate_others` keeps repositioning teammates; give up - # and force a solo shot only after `_MAX_HOP_TICKS`, the same - # timeout budget the in-flight pass handshake already uses. + # and force a solo shot after `_MAX_PASS_WAIT_TICKS`. # # The give-up is once per possession (`first_touch_hold_spent`): # it used to fall through for one tick and then hold again for @@ -501,7 +512,7 @@ def tick( # around them (tournament_20261003_102921, # clear_danger_vs_overload_flow_RK t=171-192 s). mem.hop_ticks += 1 - if mem.hop_ticks < _MAX_HOP_TICKS: + if mem.hop_ticks < _MAX_PASS_WAIT_TICKS: carrier_pos = game.friendly_robots[carrier_id].p goal_x, goal_y1, goal_y2 = enemy_goal_line(game) commands[carrier_id] = move( @@ -540,7 +551,9 @@ def tick( mem.hop_ticks = 0 mem.lane_blocked_ticks = 0 else: - hop_commands, pass_complete, lane_blocked = _pass_exec(game, ctx, carrier_id, mem.receiver_id) + hop_commands, pass_complete, lane_blocked = _pass_exec( + game, ctx, carrier_id, mem.receiver_id, kick_now=mem.hop_ticks >= _MAX_PASS_WAIT_TICKS + ) mem.lane_blocked_ticks = mem.lane_blocked_ticks + 1 if lane_blocked else 0 commands.update(hop_commands) self._relocate_others(game, ctx, robot_ids, carrier_id, commands, also_exclude=mem.receiver_id) @@ -588,12 +601,10 @@ def tick( # The strafe below carries the ball sideways with no end of its own; # past 1.0m that is an excessive-dribbling foul (51 in the 2026-09-23 - # round-robin). Once the carry is spent, shoot at the goal centre - # instead: a blocked shot keeps the ball live, a foul hands it over. + # round-robin). Once the carry is spent, kick to an open teammate or + # open space instead: a foul hands the ball over. carry_spent = carry_exhausted(game, mem.carry_origin) blind_shot = carry_spent and best_shot_y is None - if blind_shot: - best_shot_y = (goal_y1 + goal_y2) / 2.0 if not carry_spent and (best_shot_y is None or (first_touch_stuck and not force_shot)): # No open lane at all — freezing here (the old behaviour) never # resolves against a stationary blocker (e.g. a keeper at the @@ -603,8 +614,10 @@ def tick( commands[carrier_id] = move_for_a_shot(game, ctx, carrier_id) else: bend = kick_bend(game, ctx.motion_controller, carrier_id) - target_oren = carrier_pos.angle_to(Vector2D(goal_x, best_shot_y)) - bend - # A blind shot has no clear line to wait for: it kicks once aimed at the goal centre. + # A blind shot has no clear line to the goal: to an open teammate, or at the goal anyway. + target_oren = ( + release_heading(game, carrier_id) if blind_shot else carrier_pos.angle_to(Vector2D(goal_x, best_shot_y)) + ) - bend aimed = ( oriented_towards(game, carrier_id, target_oren) if blind_shot diff --git a/utama_core/tactics/goalkeeper.py b/utama_core/tactics/goalkeeper.py index 571028a6c..7eef0f5b6 100644 --- a/utama_core/tactics/goalkeeper.py +++ b/utama_core/tactics/goalkeeper.py @@ -23,9 +23,9 @@ from utama_core.engine.tactic import BaseTactic, RobotId, TacticTag from utama_core.entities.data.command import RobotCommand from utama_core.entities.game import Game -from utama_core.motion_planning.src.controllers.pid_controller import PIDController -from utama_core.skills.src.goalkeep import goalkeep -from utama_core.skills.src.utils.move_utils import empty_command +from utama_core.motion_planning.controllers.pid_controller import PIDController +from utama_core.skills.goalkeep import goalkeep +from utama_core.skills.utils.move_utils import empty_command @dataclass @@ -80,7 +80,7 @@ def tick( if mem.pid_controller is None: mem.pid_controller = PIDController(ctx.motion_controller.mode, ctx.motion_controller.rsim_env) - command = goalkeep(game, mem.pid_controller, self.robot_id) + command = goalkeep(game, mem.pid_controller, self.robot_id, ctx) if command is None: command = empty_command(False) return {self.robot_id: command}, mem diff --git a/utama_core/tactics/lead_and_support.py b/utama_core/tactics/lead_and_support.py index b99845e28..42aada6f7 100644 --- a/utama_core/tactics/lead_and_support.py +++ b/utama_core/tactics/lead_and_support.py @@ -8,7 +8,7 @@ when a lane opens, or pass to the best-scoring support point), every other assigned robot continuously re-picks the best open support point on the attacking half. Reuses existing skill/geometry primitives -(`go_to_ball`/`go_to_point`/`move`, and `shared/pass_and_score_geometry`'s +(`go_to_ball`/`go_to_point`/`move`, and `geometry/pass_and_score_geometry`'s shot-finding and pass-scoring functions) — the primitives are fundamental motion/geometry, not tactical decisions, so they were kept rather than reinvented. @@ -34,7 +34,7 @@ from utama_core.entities.data.object import TeamType from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.shared.pass_and_score_geometry import ( +from utama_core.geometry.pass_and_score_geometry import ( clamp_outside_enemy_defense_area, enemy_goal_line, enemy_positions, @@ -47,9 +47,9 @@ segment_blocked, shot_heading_reachable, ) -from utama_core.skills.src.go_to_ball import go_to_ball -from utama_core.skills.src.go_to_point import go_to_point -from utama_core.skills.src.utils.move_utils import kick, move, turn_on_spot +from utama_core.skills.go_to_ball import go_to_ball +from utama_core.skills.go_to_point import go_to_point +from utama_core.skills.utils.move_utils import kick, move, turn_on_spot from utama_core.tactics._pass_and_score import move_for_a_shot _MIN_SUPPORT_SEPARATION = 0.9 # metres — supports must not crowd each other or the leader @@ -73,7 +73,7 @@ def _candidate_support_points(game: Game, count: int) -> list[Vector2D]: # boundary itself, right through the enemy defense area — an outfield # robot standing there is an attacker-infringement foul # (`DefenseAreaRule`). Found via 20 `defense_area` fouls in one live - # match (`overload_press`'s "counter" slot uses this tactic on every + # match (`avalanche`'s "counter" slot uses this tactic on every # tick it doesn't have the ball). Clamp the deep edge with the same # box-avoidance helper `decoy_and_overload.py`'s `_overload_target` uses. clamped_edge = clamp_outside_enemy_defense_area(game, Vector2D(x_hi, 0.0)).x diff --git a/utama_core/tactics/pass_and_shoot.py b/utama_core/tactics/pass_and_shoot.py index 1cf12d0a2..1a937ce4f 100644 --- a/utama_core/tactics/pass_and_shoot.py +++ b/utama_core/tactics/pass_and_shoot.py @@ -35,8 +35,8 @@ from utama_core.entities.data.object import TeamType from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.shared.pass_and_score_geometry import carry_exhausted, carry_origin -from utama_core.shared.tolerance import Sticky +from utama_core.geometry.pass_and_score_geometry import carry_exhausted, carry_origin +from utama_core.geometry.tolerance import Sticky from utama_core.tactics._pass_and_score import ( PassAndScoreMem, _pass_exec, @@ -65,13 +65,13 @@ def assign_passer_receiver( over. Keep the previous passer unless the other robot is closer by a real margin, not just nominally closer. - Uses `shared.tolerance.Sticky` (score = negative distance, so "closer" + Uses `geometry.tolerance.Sticky` (score = negative distance, so "closer" maximizes the score the same way `Sticky` expects everywhere else it's used) — confirmed behaviour-identical to the previous hand-rolled `distances[prev_receiver] + margin >= distances[prev_passer]` check via a seeded-random equivalence probe (500 random distance pairs, 0 mismatches; see `test_sticky_matches_pass_and_shoot_margin_logic` in - `tests/shared/test_tolerance.py`). + `tests/geometry/test_tolerance.py`). """ ball_pos = game.ball.p.to_2d() distances = { diff --git a/utama_core/tactics/press_and_contain.py b/utama_core/tactics/press_and_contain.py index ed6fd5a9e..4266e9f23 100644 --- a/utama_core/tactics/press_and_contain.py +++ b/utama_core/tactics/press_and_contain.py @@ -31,17 +31,17 @@ from utama_core.engine.tactic import BaseTactic, RobotId, TacticTag from utama_core.entities.data.command import RobotCommand from utama_core.entities.game import Game -from utama_core.shared.pass_and_score_geometry import ( +from utama_core.geometry.pass_and_score_geometry import ( ball_in_own_defense_area, has_ball, own_defense_area_exit_point, ) -from utama_core.shared.tolerance import Sticky -from utama_core.skills.src.block import block_attacker -from utama_core.skills.src.go_to_ball import go_to_ball -from utama_core.skills.src.go_to_point import go_to_point -from utama_core.skills.src.kick_upfield import kick_upfield -from utama_core.skills.src.man_mark import man_mark +from utama_core.geometry.tolerance import Sticky +from utama_core.skills.block import block_attacker +from utama_core.skills.go_to_ball import go_to_ball +from utama_core.skills.go_to_point import go_to_point +from utama_core.skills.kick_upfield import kick_upfield +from utama_core.skills.man_mark import man_mark _PRESS_ENTER_RANGE = 1.4 # metres — ball must be within this of an enemy to start pressing _PRESS_EXIT_RANGE = 1.7 # metres — enemy must clear past this to release pressing @@ -55,7 +55,7 @@ # then away, then back, several times a second, until the unstable contact # knocked the ball out of bounds — mirrors the same "sticky edge" fix # `friendly_closer_to_ball`-consuming pickers already needed, see -# `counter_flow.py`'s `_counter_flow_picker`/`high_line_zone.py`'s `_high_line_zone_picker`). +# `riptide.py`'s `_riptide_picker`/`high_line_zone.py`'s `_high_line_zone_picker`). # Require the *opposite* classification to hold for this many consecutive # ticks before actually switching mode. _LOOSE_BALL_HYSTERESIS_TICKS = 15 # 0.25s at 60Hz — enough to reject single-tick flicker, short enough to react promptly once a contest genuinely resolves @@ -180,6 +180,7 @@ def tick( ) marker_ids = tuple(rid for rid in robot_ids if rid != presser_id) mem.presser_id = presser_id + ctx.ball_claims.add(presser_id) if ctx.match_log is not None: ctx.match_log.trace_if_changed( diff --git a/utama_core/tactics/scripted_moves.py b/utama_core/tactics/scripted_moves.py index c56890405..d2db4fcf0 100644 --- a/utama_core/tactics/scripted_moves.py +++ b/utama_core/tactics/scripted_moves.py @@ -3,9 +3,9 @@ `ScriptedMovesTactic` sends `CALIBRATION_SCRIPT`'s raw velocity commands, step by step, to the one robot it is given, then stands still. Run with a game log being recorded (`StrategyRunner(game_log_path=...)`), the log holds each command as sent and the robot's -motion as the camera saw it; `tools/robot_calibration.py` turns that into the robot's +motion as the camera saw it; `tools/field/robot_calibration.py` turns that into the robot's numbers (vision noise, delay, speed and turn tracking, acceleration). The ball part of a -calibration fetches the ball itself instead (`examples/ball_trials.py`). +calibration fetches the ball itself instead (`tools/field/ball_trials.py`). Each move goes and comes back (forward then backward, left then right), so the robot ends near where it started; the longest is 0.8 m forward. Pauses (HALT, STOP) do not @@ -17,7 +17,7 @@ (`analysis/robot_calibration.py`), leaves it out. A move with a `prompt` holds the robot still until `proceed()`: the operator sets something up -(a ball on the dribbler) and says so. `examples/calibrate_robot.py` asks in the terminal. +(a ball on the dribbler) and says so. `tools/field/calibrate_robot.py` asks in the terminal. """ from __future__ import annotations diff --git a/utama_core/tactics/shadow_and_mark.py b/utama_core/tactics/shadow_and_mark.py index e228940cb..6a8d73a1a 100644 --- a/utama_core/tactics/shadow_and_mark.py +++ b/utama_core/tactics/shadow_and_mark.py @@ -40,17 +40,17 @@ from utama_core.entities.data.command import RobotCommand from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.shared.pass_and_score_geometry import ( +from utama_core.geometry.pass_and_score_geometry import ( ball_in_own_defense_area, ball_is_loose, has_ball, own_defense_area_exit_point, ) -from utama_core.skills.src.defend_parameter import defend_parameter -from utama_core.skills.src.go_to_ball import go_to_ball -from utama_core.skills.src.go_to_point import go_to_point -from utama_core.skills.src.kick_upfield import kick_upfield -from utama_core.skills.src.man_mark import mark_target +from utama_core.skills.defend_parameter import defend_parameter +from utama_core.skills.go_to_ball import go_to_ball +from utama_core.skills.go_to_point import go_to_point +from utama_core.skills.kick_upfield import kick_upfield +from utama_core.skills.man_mark import mark_target _LOOSE_BALL_CLAIM_RANGE = 1.5 # metres — matches ball_is_loose's own contest range diff --git a/utama_core/tactics/switch_of_play.py b/utama_core/tactics/switch_of_play.py index 393e0d763..7f3d75193 100644 --- a/utama_core/tactics/switch_of_play.py +++ b/utama_core/tactics/switch_of_play.py @@ -40,7 +40,7 @@ Reuses `_pass_and_score`'s `_pass_exec`/`_score_goal` for the two legs of the relay and the final shot (generic two-robot ball transfer / shot-taking, same reuse rationale every other attack tactic here gives), and -`shared/pass_and_score_geometry` for the weak-side read and shot check. What's +`geometry/pass_and_score_geometry` for the weak-side read and shot check. What's new is only the weak-side decision, the pivot/runner positioning, and the 3-leg phase sequence layered on top. @@ -64,7 +64,7 @@ from utama_core.entities.data.command import RobotCommand from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.shared.pass_and_score_geometry import ( +from utama_core.geometry.pass_and_score_geometry import ( at_target, ball_line_receive_point, enemy_goal_line, @@ -73,9 +73,9 @@ has_ball, segment_blocked, ) -from utama_core.skills.src.go_to_ball import go_to_ball -from utama_core.skills.src.go_to_point import go_to_point -from utama_core.skills.src.utils.move_utils import move +from utama_core.skills.go_to_ball import go_to_ball +from utama_core.skills.go_to_point import go_to_point +from utama_core.skills.utils.move_utils import move from utama_core.tactics._pass_and_score import _pass_exec, _score_goal # Guidance point 3: a naive "count enemies on each half of the field" read @@ -140,7 +140,7 @@ # Widening `_ARRIVAL_SPEED_THRESHOLD` (above) was not sufficient on its own: # a robot converged on a static target still never truly settles under this # codebase's PID translation controller (`TwoDPID._calculate` in -# `motion_planning/src/pid/pid.py` — proportional-only near the target, no +# `motion_planning/pid/pid.py` — proportional-only near the target, no # terminal deadband above its 3mm snap-to-zero), so speed keeps oscillating # in a small band straddling the threshold indefinitely rather than # converging below it. Live-traced on `shadow_switch_vs_zone_fluid` @@ -457,7 +457,7 @@ def tick( # "Known open bugs") has hand-written a one-off print of exactly this # tuple in a throwaway trace script. Recording it here instead means # any future investigation can get it back for free via - # `debug_match.py --match-log ` + `load_jsonl`, with zero + # `tools/debug/debug_match.py --match-log ` + `load_jsonl`, with zero # runtime cost when match_log is unset (the default for every normal # run/test/tournament). if ctx.match_log is not None: @@ -494,7 +494,7 @@ def tick( # open, otherwise carry it toward one (`_score_goal`), so "assess" # never advancing past itself is fine. It used to hold the ball # where it stood, which held it forever: at its own corner free - # kicks overload_press's lone switch robot stopped 0.13 m from the + # kicks avalanche's lone switch robot stopped 0.13 m from the # ball (inside the visual has_ball box, short of contact) for 10 s # until no_progress, with the overload slot committed and waiting # (tournament_20261005_170958: vs split_shape t=479, vs three_slot diff --git a/utama_core/team_controller/README.md b/utama_core/team_controller/README.md index 22db8c51c..843f91fdf 100644 --- a/utama_core/team_controller/README.md +++ b/utama_core/team_controller/README.md @@ -32,7 +32,7 @@ This folder contains all the files which perform the initial processing of data - Updates internal data structures with the latest referee commands, stage, team information, and designated ball placement positions. - Provides methods to retrieve the latest referee data, command, stage, and other relevant information. - **Vision Data** - - The `VisionDataReceiver` class is responsible for receiving and managing vision data for robots and the ball in a multi-robot game environment. It interfaces with a network manager to receive packets containing positional data for the ball and robots on both teams. The class updates internal data structures accordingly. Here is an [example usage](../tests/receivers/vision_receiver_unit_test.py) (and an [integration test](../tests/receivers/vision_receiver_integration_test.py)). + - The `VisionDataReceiver` class is responsible for receiving and managing vision data for robots and the ball in a multi-robot game environment. It interfaces with a network manager to receive packets containing positional data for the ball and robots on both teams. The class updates internal data structures accordingly. Here is an [example usage](../tests/data_processing/test_vision_receiver_unit.py) (and an [integration test](../tests/data_processing/test_vision_receiver_integration.py)). - **Data Types**: - `Ball`: A named tuple representing the ball's position with fields `x`, `y`, and `z`. - `Robot`: A named tuple representing a robot's position with fields `x`, `y`, and `orientation`. diff --git a/utama_core/team_controller/controllers/__init__.py b/utama_core/team_controller/controllers/__init__.py new file mode 100644 index 000000000..b7dff8b07 --- /dev/null +++ b/utama_core/team_controller/controllers/__init__.py @@ -0,0 +1,18 @@ +from utama_core.team_controller.controllers.common.robot_controller_abstract import ( + AbstractRobotController, +) +from utama_core.team_controller.controllers.common.sim_controller_abstract import ( + AbstractSimController, +) +from utama_core.team_controller.controllers.real.real_robot_controller import ( + RealRobotController, +) +from utama_core.team_controller.controllers.sim.grsim_controller import GRSimController +from utama_core.team_controller.controllers.sim.grsim_robot_controller import ( + GRSimRobotController, +) +from utama_core.team_controller.controllers.sim.rsim_controller import RSimController +from utama_core.team_controller.controllers.sim.rsim_robot_controller import ( + RSimPVPManager, + RSimRobotController, +) diff --git a/utama_core/team_controller/src/controllers/common/robot_controller_abstract.py b/utama_core/team_controller/controllers/common/robot_controller_abstract.py similarity index 100% rename from utama_core/team_controller/src/controllers/common/robot_controller_abstract.py rename to utama_core/team_controller/controllers/common/robot_controller_abstract.py diff --git a/utama_core/team_controller/src/controllers/common/robot_profile.py b/utama_core/team_controller/controllers/common/robot_profile.py similarity index 94% rename from utama_core/team_controller/src/controllers/common/robot_profile.py rename to utama_core/team_controller/controllers/common/robot_profile.py index bbcfc2ec4..0c3831b3c 100644 --- a/utama_core/team_controller/src/controllers/common/robot_profile.py +++ b/utama_core/team_controller/controllers/common/robot_profile.py @@ -27,7 +27,7 @@ from utama_core.config.settings import CONTROL_FREQUENCY from utama_core.entities.data.command import RobotCommand -from utama_core.team_controller.src.controllers.common.robot_controller_abstract import ( +from utama_core.team_controller.controllers.common.robot_controller_abstract import ( AbstractRobotController, ) @@ -49,8 +49,7 @@ class RobotProfile: `kick_bend_deg_per_cm`: how far its kick leaves the heading towards the side the ball sits on the dribbler, per cm the ball is off-centre. Passes and shots aim against it - (`kick_bend`), on real robots and in rsim, which kicks a profiled robot so (`real_kick.py`); - grSim kicks along the heading. + (`kick_bend`), on real robots only: the sims keep their own kick, along the heading. `kick_bias_deg`: how far its kick leaves the heading vision reports with the ball centred, anticlockwise + (a kicker, or a tag stuck on turned); aimed against with the bend. Fitted @@ -61,8 +60,8 @@ class RobotProfile: (`PositionRefiner`); a tag is a sticker, measured once per lid. `kick_speed`: its kick's ball speed (m/s, the median of its kicks); `kick_spread_deg`: how far - its kicks scatter about bias and bend (rms of the fit). rsim kicks a profiled robot so. None: - not measured, the sim's speed and no scatter. + its kicks scatter about bias and bend (rms of the fit). Calibration records these as measurements; + the sims keep their own kick. None: not measured, the sim's speed and no scatter. `carry_speed`, `carry_turn`: the fastest it carries the ball, m/s and rad/s, from its carry ladder; `move()` holds it to them. None: the team's (`RobotParams.CARRY_*`). @@ -85,7 +84,7 @@ class RobotProfile: # One file per robot, by radio ID: `pixi run calibrate` writes it, every script reads it. -PROFILE_DIR = Path(__file__).resolve().parents[4] / "config" / "robots" +PROFILE_DIR = Path(__file__).resolve().parents[3] / "config" / "robots" def profile_path(radio_id: int, directory: Path = PROFILE_DIR) -> Path: diff --git a/utama_core/team_controller/src/controllers/common/sim_controller_abstract.py b/utama_core/team_controller/controllers/common/sim_controller_abstract.py similarity index 98% rename from utama_core/team_controller/src/controllers/common/sim_controller_abstract.py rename to utama_core/team_controller/controllers/common/sim_controller_abstract.py index 2e00e8325..a858cebb0 100644 --- a/utama_core/team_controller/src/controllers/common/sim_controller_abstract.py +++ b/utama_core/team_controller/controllers/common/sim_controller_abstract.py @@ -2,7 +2,7 @@ from utama_core.config.settings import OFF_PITCH_OFFSET from utama_core.entities.game.field import FieldBounds -from utama_core.global_utils.math_utils import in_field_bounds +from utama_core.geometry.math_utils import in_field_bounds class AbstractSimController: diff --git a/utama_core/team_controller/src/controllers/real/find_robots.py b/utama_core/team_controller/controllers/real/find_robots.py similarity index 97% rename from utama_core/team_controller/src/controllers/real/find_robots.py rename to utama_core/team_controller/controllers/real/find_robots.py index e4546b609..3df4fe982 100644 --- a/utama_core/team_controller/src/controllers/real/find_robots.py +++ b/utama_core/team_controller/controllers/real/find_robots.py @@ -30,15 +30,15 @@ from utama_core.config.settings import MULTICAST_GROUP, VISION_PORT from utama_core.entities.data.command import RobotCommand -from utama_core.team_controller.src.controllers.common.robot_profile import ( +from utama_core.team_controller.controllers.common.robot_profile import ( PROFILE_DIR, profile_path, ) -from utama_core.team_controller.src.generated_code.ssl_vision_wrapper_pb2 import ( +from utama_core.team_controller.generated_code.ssl_vision_wrapper_pb2 import ( SSL_WrapperPacket, ) -FOUND_PATH = Path(__file__).resolve().parents[5] / "replays" / "field" / "robots_found.json" +FOUND_PATH = Path(__file__).resolve().parents[4] / "replays" / "field" / "robots_found.json" RADIOS = tuple(range(8)) TICK_S = 1 / 60 ANSWER_S = 0.3 # still, listening for the radio's answer and the lids' headings before the turn @@ -145,7 +145,7 @@ def radio(self, radio: int) -> dict: def find(radios=RADIOS, controller=None, sock=None, clock=time.monotonic, sleep=time.sleep) -> dict: """Probes each of `radios`; the lids seen, and per radio whether it answered and its lid.""" if controller is None: - from utama_core.team_controller.src.controllers.real.real_robot_controller import ( + from utama_core.team_controller.controllers.real.real_robot_controller import ( RealRobotController, ) diff --git a/utama_core/team_controller/src/controllers/real/kicker_charge.py b/utama_core/team_controller/controllers/real/kicker_charge.py similarity index 100% rename from utama_core/team_controller/src/controllers/real/kicker_charge.py rename to utama_core/team_controller/controllers/real/kicker_charge.py diff --git a/utama_core/team_controller/src/controllers/real/real_robot_controller.py b/utama_core/team_controller/controllers/real/real_robot_controller.py similarity index 99% rename from utama_core/team_controller/src/controllers/real/real_robot_controller.py rename to utama_core/team_controller/controllers/real/real_robot_controller.py index 82e0d0084..e095d0966 100644 --- a/utama_core/team_controller/src/controllers/real/real_robot_controller.py +++ b/utama_core/team_controller/controllers/real/real_robot_controller.py @@ -25,8 +25,8 @@ DRIBBLER_DRAIN_RATE: float = 2.0 # bucket seconds drained per real second DRIBBLER_RESUME_SECONDS: float = 10.0 from utama_core.entities.data.command import RobotCommand, RobotResponse -from utama_core.skills.src.utils.move_utils import empty_command -from utama_core.team_controller.src.controllers.common.robot_controller_abstract import ( +from utama_core.skills.utils.move_utils import empty_command +from utama_core.team_controller.controllers.common.robot_controller_abstract import ( AbstractRobotController, ) diff --git a/utama_core/team_controller/src/controllers/sim/grsim_controller.py b/utama_core/team_controller/controllers/sim/grsim_controller.py similarity index 93% rename from utama_core/team_controller/src/controllers/sim/grsim_controller.py rename to utama_core/team_controller/controllers/sim/grsim_controller.py index 87879c511..b67e950ab 100644 --- a/utama_core/team_controller/src/controllers/sim/grsim_controller.py +++ b/utama_core/team_controller/controllers/sim/grsim_controller.py @@ -9,20 +9,17 @@ TELEPORT_X_COORDS, ) from utama_core.entities.game.field import FieldBounds -from utama_core.team_controller.src.controllers.common.sim_controller_abstract import ( +from utama_core.team_controller.controllers.common.sim_controller_abstract import ( AbstractSimController, ) -from utama_core.team_controller.src.generated_code.ssl_gc_common_pb2 import ( - RobotId, - Team, -) -from utama_core.team_controller.src.generated_code.ssl_simulation_control_pb2 import ( +from utama_core.team_controller.generated_code.ssl_gc_common_pb2 import RobotId, Team +from utama_core.team_controller.generated_code.ssl_simulation_control_pb2 import ( SimulatorCommand, SimulatorControl, TeleportBall, TeleportRobot, ) -from utama_core.team_controller.src.utils import network_manager +from utama_core.team_controller.utils import network_manager class GRSimController(AbstractSimController): diff --git a/utama_core/team_controller/src/controllers/sim/grsim_robot_controller.py b/utama_core/team_controller/controllers/sim/grsim_robot_controller.py similarity index 94% rename from utama_core/team_controller/src/controllers/sim/grsim_robot_controller.py rename to utama_core/team_controller/controllers/sim/grsim_robot_controller.py index c81954bac..7c47cf461 100644 --- a/utama_core/team_controller/src/controllers/sim/grsim_robot_controller.py +++ b/utama_core/team_controller/controllers/sim/grsim_robot_controller.py @@ -14,16 +14,16 @@ RobotResponse, RobotVelCommand, ) -from utama_core.team_controller.src.controllers.common.robot_controller_abstract import ( +from utama_core.team_controller.controllers.common.robot_controller_abstract import ( AbstractRobotController, ) -from utama_core.team_controller.src.generated_code.ssl_simulation_robot_control_pb2 import ( +from utama_core.team_controller.generated_code.ssl_simulation_robot_control_pb2 import ( RobotControl, ) -from utama_core.team_controller.src.generated_code.ssl_simulation_robot_feedback_pb2 import ( +from utama_core.team_controller.generated_code.ssl_simulation_robot_feedback_pb2 import ( RobotControlResponse, ) -from utama_core.team_controller.src.utils import network_manager +from utama_core.team_controller.utils import network_manager logger = logging.getLogger(__name__) diff --git a/utama_core/team_controller/src/controllers/sim/rsim_controller.py b/utama_core/team_controller/controllers/sim/rsim_controller.py similarity index 93% rename from utama_core/team_controller/src/controllers/sim/rsim_controller.py rename to utama_core/team_controller/controllers/sim/rsim_controller.py index 8879cdecd..296ec482f 100644 --- a/utama_core/team_controller/src/controllers/sim/rsim_controller.py +++ b/utama_core/team_controller/controllers/sim/rsim_controller.py @@ -2,8 +2,8 @@ from utama_core.config.settings import ADD_Y_COORD, REMOVAL_Y_COORD, TELEPORT_X_COORDS from utama_core.entities.game.field import FieldBounds -from utama_core.rsoccer_simulator.src.ssl.ssl_gym_base import SSLBaseEnv -from utama_core.team_controller.src.controllers.common.sim_controller_abstract import ( +from utama_core.simulator.ssl.ssl_gym_base import SSLBaseEnv +from utama_core.team_controller.controllers.common.sim_controller_abstract import ( AbstractSimController, ) diff --git a/utama_core/team_controller/src/controllers/sim/rsim_robot_controller.py b/utama_core/team_controller/controllers/sim/rsim_robot_controller.py similarity index 97% rename from utama_core/team_controller/src/controllers/sim/rsim_robot_controller.py rename to utama_core/team_controller/controllers/sim/rsim_robot_controller.py index fb2f75fd7..f6b7aaf35 100644 --- a/utama_core/team_controller/src/controllers/sim/rsim_robot_controller.py +++ b/utama_core/team_controller/controllers/sim/rsim_robot_controller.py @@ -5,8 +5,8 @@ from numpy.typing import NDArray from utama_core.entities.data.command import RobotCommand, RobotResponse -from utama_core.rsoccer_simulator.src.ssl.ssl_gym_base import SSLBaseEnv -from utama_core.team_controller.src.controllers.common.robot_controller_abstract import ( +from utama_core.simulator.ssl.ssl_gym_base import SSLBaseEnv +from utama_core.team_controller.controllers.common.robot_controller_abstract import ( AbstractRobotController, ) diff --git a/utama_core/team_controller/src/debug_utils/telop_gui.py b/utama_core/team_controller/debug_utils/telop_gui.py similarity index 99% rename from utama_core/team_controller/src/debug_utils/telop_gui.py rename to utama_core/team_controller/debug_utils/telop_gui.py index fc779193b..27df69759 100644 --- a/utama_core/team_controller/src/debug_utils/telop_gui.py +++ b/utama_core/team_controller/debug_utils/telop_gui.py @@ -26,7 +26,7 @@ if not USE_DUMMY_CONTROLLER: - from utama_core.team_controller.src.controllers.real.real_robot_controller import ( + from utama_core.team_controller.controllers.real.real_robot_controller import ( RealRobotController, RobotCommand, empty_command, diff --git a/utama_core/team_controller/src/generated_code/ssl_gc_common_pb2.py b/utama_core/team_controller/generated_code/ssl_gc_common_pb2.py similarity index 100% rename from utama_core/team_controller/src/generated_code/ssl_gc_common_pb2.py rename to utama_core/team_controller/generated_code/ssl_gc_common_pb2.py diff --git a/utama_core/team_controller/src/generated_code/ssl_gc_game_event_pb2.py b/utama_core/team_controller/generated_code/ssl_gc_game_event_pb2.py similarity index 100% rename from utama_core/team_controller/src/generated_code/ssl_gc_game_event_pb2.py rename to utama_core/team_controller/generated_code/ssl_gc_game_event_pb2.py diff --git a/utama_core/team_controller/src/generated_code/ssl_gc_geometry_pb2.py b/utama_core/team_controller/generated_code/ssl_gc_geometry_pb2.py similarity index 100% rename from utama_core/team_controller/src/generated_code/ssl_gc_geometry_pb2.py rename to utama_core/team_controller/generated_code/ssl_gc_geometry_pb2.py diff --git a/utama_core/team_controller/src/generated_code/ssl_gc_referee_message_pb2.py b/utama_core/team_controller/generated_code/ssl_gc_referee_message_pb2.py similarity index 100% rename from utama_core/team_controller/src/generated_code/ssl_gc_referee_message_pb2.py rename to utama_core/team_controller/generated_code/ssl_gc_referee_message_pb2.py diff --git a/utama_core/team_controller/src/generated_code/ssl_gc_state_pb2.py b/utama_core/team_controller/generated_code/ssl_gc_state_pb2.py similarity index 100% rename from utama_core/team_controller/src/generated_code/ssl_gc_state_pb2.py rename to utama_core/team_controller/generated_code/ssl_gc_state_pb2.py diff --git a/utama_core/team_controller/src/generated_code/ssl_simulation_config_pb2.py b/utama_core/team_controller/generated_code/ssl_simulation_config_pb2.py similarity index 100% rename from utama_core/team_controller/src/generated_code/ssl_simulation_config_pb2.py rename to utama_core/team_controller/generated_code/ssl_simulation_config_pb2.py diff --git a/utama_core/team_controller/src/generated_code/ssl_simulation_control_pb2.py b/utama_core/team_controller/generated_code/ssl_simulation_control_pb2.py similarity index 100% rename from utama_core/team_controller/src/generated_code/ssl_simulation_control_pb2.py rename to utama_core/team_controller/generated_code/ssl_simulation_control_pb2.py diff --git a/utama_core/team_controller/src/generated_code/ssl_simulation_error_pb2.py b/utama_core/team_controller/generated_code/ssl_simulation_error_pb2.py similarity index 100% rename from utama_core/team_controller/src/generated_code/ssl_simulation_error_pb2.py rename to utama_core/team_controller/generated_code/ssl_simulation_error_pb2.py diff --git a/utama_core/team_controller/src/generated_code/ssl_simulation_robot_control_pb2.py b/utama_core/team_controller/generated_code/ssl_simulation_robot_control_pb2.py similarity index 100% rename from utama_core/team_controller/src/generated_code/ssl_simulation_robot_control_pb2.py rename to utama_core/team_controller/generated_code/ssl_simulation_robot_control_pb2.py diff --git a/utama_core/team_controller/src/generated_code/ssl_simulation_robot_feedback_pb2.py b/utama_core/team_controller/generated_code/ssl_simulation_robot_feedback_pb2.py similarity index 100% rename from utama_core/team_controller/src/generated_code/ssl_simulation_robot_feedback_pb2.py rename to utama_core/team_controller/generated_code/ssl_simulation_robot_feedback_pb2.py diff --git a/utama_core/team_controller/src/generated_code/ssl_simulation_synchronous_pb2.py b/utama_core/team_controller/generated_code/ssl_simulation_synchronous_pb2.py similarity index 100% rename from utama_core/team_controller/src/generated_code/ssl_simulation_synchronous_pb2.py rename to utama_core/team_controller/generated_code/ssl_simulation_synchronous_pb2.py diff --git a/utama_core/team_controller/src/generated_code/ssl_vision_detection_pb2.py b/utama_core/team_controller/generated_code/ssl_vision_detection_pb2.py similarity index 100% rename from utama_core/team_controller/src/generated_code/ssl_vision_detection_pb2.py rename to utama_core/team_controller/generated_code/ssl_vision_detection_pb2.py diff --git a/utama_core/team_controller/src/generated_code/ssl_vision_detection_tracked_pb2.py b/utama_core/team_controller/generated_code/ssl_vision_detection_tracked_pb2.py similarity index 100% rename from utama_core/team_controller/src/generated_code/ssl_vision_detection_tracked_pb2.py rename to utama_core/team_controller/generated_code/ssl_vision_detection_tracked_pb2.py diff --git a/utama_core/team_controller/src/generated_code/ssl_vision_geometry_pb2.py b/utama_core/team_controller/generated_code/ssl_vision_geometry_pb2.py similarity index 100% rename from utama_core/team_controller/src/generated_code/ssl_vision_geometry_pb2.py rename to utama_core/team_controller/generated_code/ssl_vision_geometry_pb2.py diff --git a/utama_core/team_controller/src/generated_code/ssl_vision_wrapper_pb2.py b/utama_core/team_controller/generated_code/ssl_vision_wrapper_pb2.py similarity index 100% rename from utama_core/team_controller/src/generated_code/ssl_vision_wrapper_pb2.py rename to utama_core/team_controller/generated_code/ssl_vision_wrapper_pb2.py diff --git a/utama_core/team_controller/src/generated_code/ssl_vision_wrapper_tracked_pb2.py b/utama_core/team_controller/generated_code/ssl_vision_wrapper_tracked_pb2.py similarity index 100% rename from utama_core/team_controller/src/generated_code/ssl_vision_wrapper_tracked_pb2.py rename to utama_core/team_controller/generated_code/ssl_vision_wrapper_tracked_pb2.py diff --git a/utama_core/team_controller/src/controllers/__init__.py b/utama_core/team_controller/src/controllers/__init__.py deleted file mode 100644 index e8ce33d93..000000000 --- a/utama_core/team_controller/src/controllers/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -from utama_core.team_controller.src.controllers.common.robot_controller_abstract import ( - AbstractRobotController, -) -from utama_core.team_controller.src.controllers.common.sim_controller_abstract import ( - AbstractSimController, -) -from utama_core.team_controller.src.controllers.real.real_robot_controller import ( - RealRobotController, -) -from utama_core.team_controller.src.controllers.sim.grsim_controller import ( - GRSimController, -) -from utama_core.team_controller.src.controllers.sim.grsim_robot_controller import ( - GRSimRobotController, -) -from utama_core.team_controller.src.controllers.sim.rsim_controller import ( - RSimController, -) -from utama_core.team_controller.src.controllers.sim.rsim_robot_controller import ( - RSimPVPManager, - RSimRobotController, -) diff --git a/utama_core/team_controller/src/utils/network_manager.py b/utama_core/team_controller/utils/network_manager.py similarity index 97% rename from utama_core/team_controller/src/utils/network_manager.py rename to utama_core/team_controller/utils/network_manager.py index 52c242eb7..9f0f1614b 100644 --- a/utama_core/team_controller/src/utils/network_manager.py +++ b/utama_core/team_controller/utils/network_manager.py @@ -2,7 +2,7 @@ import socket from typing import Optional, Tuple -from utama_core.team_controller.src.utils import network_utils +from utama_core.team_controller.utils import network_utils logger = logging.getLogger(__name__) diff --git a/utama_core/team_controller/src/utils/network_utils.py b/utama_core/team_controller/utils/network_utils.py similarity index 100% rename from utama_core/team_controller/src/utils/network_utils.py rename to utama_core/team_controller/utils/network_utils.py diff --git a/utama_core/tests/analysis/test_field_physics.py b/utama_core/tests/analysis/test_field_physics.py new file mode 100644 index 000000000..ddd245d7a --- /dev/null +++ b/utama_core/tests/analysis/test_field_physics.py @@ -0,0 +1,152 @@ +"""Unit tests for tools/field/field_physics.py: the register filter, step delays, ball rolls, agreement. + +No real logs and no rsim: the ball roll is checked on a synthetic ball with a known deceleration. +""" + +from __future__ import annotations + +import types + +import numpy as np +import pytest + +from tools.field import field_physics + + +def _group(median: float, n: int) -> dict: + return {"median": median, "lo": median, "hi": median, "n": n} + + +# allowed + + +def test_allowed_listed_measurement_true_unlisted_false(): + register = {"sessions": {"20261028": {"use": ["loop_delay", "ball_roll"]}}} + assert field_physics.allowed(register, "20261028", "loop_delay") is True + assert field_physics.allowed(register, "20261028", "ball_noise") is False + + +def test_allowed_unregistered_day_false(): + register = {"sessions": {"20261028": {"use": ["loop_delay"]}}} + assert field_physics.allowed(register, "20261030", "loop_delay") is False + + +def test_allowed_on_real_register(): + register = field_physics.load_register() + for measurement in field_physics.MEASUREMENTS: + assert field_physics.allowed(register, "20261021", measurement) is False + assert field_physics.allowed(register, "20261029", "loop_delay") is False + assert field_physics.allowed(register, "20261029", "ball_noise") is True + + +# step_delays_ms + + +def test_step_delays_commanded_boundary(): + steps = [ + {"axis": "forward", "commanded": 0.3, "delay_s": 0.05}, + {"axis": "forward", "commanded": 0.29, "delay_s": 0.05}, + ] + assert field_physics.step_delays_ms(steps) == pytest.approx([50.0]) + + +def test_step_delays_excludes_turn_zero_delay_and_missing_delay(): + steps = [ + {"axis": "turn", "commanded": 1.0, "delay_s": 0.05}, + {"axis": "left", "commanded": -0.5, "delay_s": 0.06}, + {"axis": "forward", "commanded": 0.5, "delay_s": 0.0}, + {"axis": "forward", "commanded": 0.5}, + ] + assert field_physics.step_delays_ms(steps) == pytest.approx([60.0]) + + +# ball_rolls + + +def _synthetic_log(robots: dict | None = None, duration: float = 4.0): + """A ball rolling from x=0 at 2 m/s with deceleration 0.25 m/s^2, seen at 60 Hz by one camera.""" + t = np.arange(0.0, duration, 1 / 60) + x = 2.0 * t - 0.5 * 0.25 * t**2 + balls = np.column_stack([t, np.zeros_like(t), x, np.zeros_like(t)]) + return types.SimpleNamespace(balls=balls, robots=robots or {}) + + +BOUNDS = ((-4.5, 3.0), (4.5, -3.0)) +KICK = [{"t": 0.0, "ball_speed": 2.0, "chip": False}] + + +def test_ball_rolls_recovers_known_decel(): + rolls = field_physics.ball_rolls(_synthetic_log(), KICK, BOUNDS) + assert len(rolls) == 1 + assert rolls[0]["decel"] == pytest.approx(0.25, abs=0.01) + assert rolls[0]["rms_mm"] < 1.0 + + +def test_ball_rolls_truncated_by_robot_in_path_does_not_crash(): + # A robot 2.5 m along the ball's path stops the fit early: a shorter fit, still the right decel. + robot = np.column_stack( + [np.arange(0.0, 4.0, 1 / 60), np.zeros(240), np.full(240, 2.5), np.zeros(240), np.zeros(240)] + ) + rolls = field_physics.ball_rolls(_synthetic_log(robots={("yellow", 3): robot}), KICK, BOUNDS) + assert len(rolls) == 1 + assert rolls[0]["decel"] == pytest.approx(0.25, abs=0.01) + assert rolls[0]["secs"] < 1.5 + + +def test_ball_rolls_robot_at_half_metre_leaves_no_fit(): + # A robot 0.5 m along the path is already inside the 0.25 m exclusion when the fit starts (0.3 s): + # no fit, and no crash. + robot = np.column_stack( + [np.arange(0.0, 4.0, 1 / 60), np.zeros(240), np.full(240, 0.5), np.zeros(240), np.zeros(240)] + ) + assert field_physics.ball_rolls(_synthetic_log(robots={("yellow", 3): robot}), KICK, BOUNDS) == [] + + +# agreement + + +def test_agreement_close_medians_agree(): + groups = {("20261028", 0): _group(0.20, 10), ("20261027", None): _group(0.25, 10)} + res = field_physics.agreement(groups, tolerance=0.25) + # highest - lowest = 0.05 must be <= 0.25 * median(0.20, 0.25) = 0.05625 + assert 0.25 - 0.20 <= 0.25 * np.median([0.20, 0.25]) + assert res["agree"] is True + assert res["medians"] == [0.20, 0.25] + assert res["groups_used"] == 2 + + +def test_agreement_exact_boundary_agrees(): + # 9 - 7 = 2.0 equals 0.25 * median(7, 9) = 2.0: exactly equal counts as agreeing. + groups = {("a", 0): _group(7.0, 10), ("b", 0): _group(9.0, 10)} + assert field_physics.agreement(groups, tolerance=0.25)["agree"] is True + + +def test_agreement_just_past_boundary_disagrees(): + groups = {("a", 0): _group(7.0, 10), ("b", 0): _group(9.01, 10)} + assert field_physics.agreement(groups, tolerance=0.25)["agree"] is False + + +def test_agreement_clearly_larger_spread_disagrees(): + groups = {("20261028", 0): _group(0.20, 10), ("20261027", None): _group(0.40, 10)} + res = field_physics.agreement(groups, tolerance=0.25) + assert res["agree"] is False + assert res["groups_used"] == 2 + + +def test_agreement_ignores_groups_below_min_n(): + groups = { + ("20261028", 0): _group(0.20, 10), + ("20261027", None): _group(0.25, 10), + ("20261028", 1): _group(0.90, 4), + } + res = field_physics.agreement(groups) + assert res["groups_used"] == 2 + assert res["medians"] == [0.20, 0.25] + assert res["agree"] is True + + +def test_agreement_one_usable_group_is_none(): + groups = {("20261028", 0): _group(0.20, 10), ("20261028", 1): _group(0.90, 4)} + res = field_physics.agreement(groups) + assert res["agree"] is None + assert res["groups_used"] == 1 diff --git a/utama_core/tests/analysis/test_triage.py b/utama_core/tests/analysis/test_find_bugs.py similarity index 67% rename from utama_core/tests/analysis/test_triage.py rename to utama_core/tests/analysis/test_find_bugs.py index 073593ffb..131231dd0 100644 --- a/utama_core/tests/analysis/test_triage.py +++ b/utama_core/tests/analysis/test_find_bugs.py @@ -1,4 +1,4 @@ -"""tools/triage.py without replays: which matches are chosen (each strategy's worst N as config_a, by goal +"""tools/debug/find_bugs.py without replays: which matches are chosen (each strategy's worst N as config_a, by goal difference), the picture ranking and cap, and the index's text. Match files are empty stubs and their scores come from a fake `final_score`, so nothing is simulated or drawn from a real replay.""" @@ -6,11 +6,11 @@ import pytest -from tools import triage +from tools.debug import find_bugs from utama_core.analysis import matches as match_files from utama_core.analysis.findings import Finding -A, B, C = "build_alpha_kernel_strategy", "build_beta_kernel_strategy", "build_gamma_kernel_strategy" +A, B, C = "alpha", "beta", "gamma" def _finding(kind, value, *, robots=(1,), t0=0.0, t1=10.0, message=None): @@ -48,41 +48,41 @@ def run_dir(tmp_path, monkeypatch): def test_worst_n_by_goal_difference_as_config_a(run_dir): - chosen = triage.select_matches(run_dir, None, 2) + chosen = find_bugs.select_matches(run_dir, None, 2) alpha = [m.npz.name for m in chosen if m.a == "alpha"] assert alpha == ["alpha_vs_beta.npz", "alpha_vs_gamma_s1.npz"] # GD -3 then 0; the +1 match is the best and cut def test_strategy_filter_takes_full_or_short_names(run_dir): - chosen = triage.select_matches(run_dir, {A}, 5) + chosen = find_bugs.select_matches(run_dir, {A}, 5) assert {m.a for m in chosen} == {"alpha"} assert len(chosen) == 3 - chosen = triage.select_matches(run_dir, {"beta"}, 5) + chosen = find_bugs.select_matches(run_dir, {"beta"}, 5) assert [m.npz.name for m in chosen] == ["beta_vs_gamma.npz", "beta_vs_alpha.npz"] # GD 0 then +4 def test_every_strategy_gets_its_own_worst_matches(run_dir): - chosen = triage.select_matches(run_dir, None, 1) + chosen = find_bugs.select_matches(run_dir, None, 1) assert sorted((m.a, m.npz.name) for m in chosen) == [ ("alpha", "alpha_vs_beta.npz"), ("beta", "beta_vs_gamma.npz"), ] -def _timeline(t0: float = 0.0) -> triage.TimelinePicture: - return triage.TimelinePicture(Path("m.npz"), t0, t0 + 40.0) +def _timeline(t0: float = 0.0) -> find_bugs.TimelinePicture: + return find_bugs.TimelinePicture(Path("m.npz"), t0, t0 + 40.0) def test_rank_puts_kind_priority_first_then_value(): items = [ - triage.Item(_finding("tactic_thrash", 50.0), request=_timeline(1.0)), - triage.Item(_finding("stall", 3.0), request=_timeline(2.0)), - triage.Item(_finding("tactic_thrash", 9.0), request=_timeline(3.0)), - triage.Item(_finding("keep_out_short", 1.0), request=triage.RestartPicture(Path("r.npz"), 2.0, None)), - triage.Item(_finding("target_in_keep_out", 0.1), request=triage.RestartPicture(Path("r.npz"), 1.0, None)), - triage.Item(_finding("stall", 9.0)), # no picture source: never ranked + find_bugs.Item(_finding("tactic_thrash", 50.0), request=_timeline(1.0)), + find_bugs.Item(_finding("stall", 3.0), request=_timeline(2.0)), + find_bugs.Item(_finding("tactic_thrash", 9.0), request=_timeline(3.0)), + find_bugs.Item(_finding("keep_out_short", 1.0), request=find_bugs.RestartPicture(Path("r.npz"), 2.0, None)), + find_bugs.Item(_finding("target_in_keep_out", 0.1), request=find_bugs.RestartPicture(Path("r.npz"), 1.0, None)), + find_bugs.Item(_finding("stall", 9.0)), # no picture source: never ranked ] - ranked = triage.rank(items) + ranked = find_bugs.rank(items) assert [it.finding.kind for it in ranked] == [ "stall", "target_in_keep_out", @@ -100,13 +100,13 @@ def fake_build(npz, t0, t1, side, out): drawn.append((t0, t1)) Path(out).write_bytes(b"\x89PNG stub") - monkeypatch.setattr(triage.match_timeline, "build", fake_build) - items = [triage.Item(_finding("stall", 3.0), request=_timeline())] - items += [triage.Item(_finding("tactic_thrash", 2.0 + i), request=_timeline()) for i in range(3)] - items += [triage.Item(_finding("tactic_thrash", 1.0), request=_timeline(100.0))] + monkeypatch.setattr(find_bugs.match_timeline, "build", fake_build) + items = [find_bugs.Item(_finding("stall", 3.0), request=_timeline())] + items += [find_bugs.Item(_finding("tactic_thrash", 2.0 + i), request=_timeline()) for i in range(3)] + items += [find_bugs.Item(_finding("tactic_thrash", 1.0), request=_timeline(100.0))] pictures = tmp_path / "pictures" pictures.mkdir() - shown = triage.draw_pictures(items, pictures, max_pictures=2) + shown = find_bugs.draw_pictures(items, pictures, max_pictures=2) assert len(shown) == 2 pictured = [it for it in items if it.image is not None] assert [it.finding.kind for it in pictured] == ["stall", "tactic_thrash"] @@ -118,18 +118,18 @@ def test_index_has_each_pictured_finding_message_and_path(run_dir, tmp_path): out.mkdir() picture = out / "01_stall.png" picture.write_bytes(b"x") - stall = triage.Item( + stall = find_bugs.Item( _finding("stall", 3.0, message="R1 oscillates with the ball frozen for 3.0 s."), request=_timeline(773.0), window=(773.0, 796.0), image=picture, ) - quiet = triage.Item( + quiet = find_bugs.Item( _finding("tactic_thrash", 4.0, message="R2 thrashes, no picture.") ) # not pictured: counted only - m = triage.select_matches(run_dir, {A}, 1)[0] - report = triage.MatchReport(m, [stall, quiet], notes=[]) - index = triage.write_index(out, run_dir, [report], max_pictures=8, restarts=False).read_text() + m = find_bugs.select_matches(run_dir, {A}, 1)[0] + report = find_bugs.MatchReport(m, [stall, quiet], notes=[]) + index = find_bugs.write_index(out, run_dir, [report], max_pictures=8, restarts=False).read_text() assert "R1 oscillates with the ball frozen for 3.0 s." in index assert str(picture.resolve()) in index assert "Picture of 773.0-796.0 s" in index @@ -141,5 +141,5 @@ def test_index_has_each_pictured_finding_message_and_path(run_dir, tmp_path): def test_index_says_so_when_a_strategy_has_no_matches(tmp_path): out = tmp_path / "out" out.mkdir() - index = triage.write_index(out, tmp_path, [], max_pictures=8, restarts=False).read_text() + index = find_bugs.write_index(out, tmp_path, [], max_pictures=8, restarts=False).read_text() assert "No matches with this strategy" in index diff --git a/utama_core/tests/analysis/test_fouls.py b/utama_core/tests/analysis/test_fouls.py new file mode 100644 index 000000000..5a521ea4a --- /dev/null +++ b/utama_core/tests/analysis/test_fouls.py @@ -0,0 +1,135 @@ +"""`utama_core/analysis/fouls.py`: our side's fouls in a run with the referee command active, as +`tools/debug/find_bugs.py --fouls` lists them (moved from `tools/debug/moments.py fouls` on 2026-11-11).""" + +import json + +import pytest + +from utama_core.analysis import fouls as F +from utama_core.entities.referee.referee_command import RefereeCommand + + +@pytest.mark.parametrize( + "command, we_are_yellow, side", + [ + ("DIRECT_FREE_YELLOW", True, "ours"), + ("BALL_PLACEMENT_YELLOW", True, "ours"), + ("DIRECT_FREE_BLUE", True, "theirs"), + ("DIRECT_FREE_BLUE", False, "ours"), + ("NORMAL_START", True, None), + ("STOP", True, None), + ("TIMEOUT_YELLOW", True, None), + ], +) +def test_restart_side_is_ours_theirs_or_neither(command, we_are_yellow, side): + assert F.restart_side(RefereeCommand[command], we_are_yellow) == side + assert F.restart_side(None, we_are_yellow) is None + + +def _run(tmp_path, fouls, sidecar_rows=None): + results = [{"config_a": "a", "config_b": "b", "stats": {"fouls": fouls}}] + (tmp_path / "summary.json").write_text(json.dumps({"results": results})) + if sidecar_rows is not None: + (tmp_path / "a_vs_b.intentions.jsonl").write_text("\n".join(json.dumps(r) for r in sidecar_rows) + "\n") + return tmp_path + + +def _foul(t, side="friendly", rule="keep_out"): + return {"rule": rule, "sim_time": t, "side": side, "robot_id": 1, "tactic": "X", "inferred": False} + + +def test_our_fouls_names_the_command_active_and_the_restart_side(tmp_path): + rows = [ + {"event": "referee", "sim_time": 0.0, "command": "NORMAL_START"}, + {"event": "referee", "sim_time": 4.0, "command": "DIRECT_FREE_BLUE"}, + {"event": "referee", "sim_time": 10.0, "command": "DIRECT_FREE_YELLOW"}, + ] + run = _run(tmp_path, [_foul(1.0), _foul(5.0), _foul(12.0), _foul(20.0), _foul(6.0, side="enemy")], rows) + found = F.our_fouls(run) + assert [(f["sim_time"], f["command"], f["restart"]) for f in found] == [ + (1.0, "NORMAL_START", None), + (5.0, "DIRECT_FREE_BLUE", "theirs"), + (12.0, "DIRECT_FREE_YELLOW", "ours"), + (20.0, "DIRECT_FREE_YELLOW", "ours"), + ] + assert [f["sim_time"] for f in F.without_own_restarts(found)] == [1.0, 5.0] + + +def test_our_fouls_names_the_match_replay_relative_to_the_repo(tmp_path): + run = _run(tmp_path, [_foul(3.0)]) + (found,) = F.our_fouls(run) + assert found["replay"] is None # no a_vs_b replay in the run dir + (tmp_path / "a_vs_b.npz").write_bytes(b"") + (found,) = F.our_fouls(run) + assert found["replay"] == str(tmp_path / "a_vs_b.npz") # outside the repo: as given + (tmp_path / "a_vs_b.npz").unlink() + (tmp_path / "a_vs_b.pkl").write_bytes(b"") + (found,) = F.our_fouls(run) + assert found["replay"] == str(tmp_path / "a_vs_b.pkl") + + +def test_repo_relative_paths_drop_the_repo_root(): + assert F._repo_relative(F.REPO_ROOT / "replays" / "t" / "a_vs_b.npz") == "replays/t/a_vs_b.npz" + + +def test_our_fouls_without_a_match_log_has_no_command(tmp_path): + (found,) = F.our_fouls(_run(tmp_path, [_foul(3.0)])) + assert found["command"] is None and found["restart"] is None + assert F.without_own_restarts([found]) == [found] + + +def _row(config_a, rule, restart=None, tactic="X"): + return {"config_a": config_a, "config_b": "b", "rule": rule, "tactic": tactic, "restart": restart} + + +def test_count_fouls_groups_by_the_given_columns_most_common_first(): + rows = [_row("a", "keep_out"), _row("b", "crashing"), _row("a", "keep_out")] + rows += [_row("a", "crashing"), _row("b", "crashing"), _row("b", "crashing")] + assert F.count_fouls(rows, ["strategy", "rule"]) == [ + (("b", "crashing"), 3), + (("a", "keep_out"), 2), + (("a", "crashing"), 1), + ] + + +def test_count_fouls_names_a_missing_restart_live_and_a_missing_tactic_dash(): + rows = [_row("a", "keep_out", restart=None, tactic=None), _row("a", "keep_out", restart="theirs")] + assert F.count_fouls(rows, ["restart", "tactic"]) == [(("live", "-"), 1), (("theirs", "X"), 1)] + + +def test_count_fouls_ties_are_in_name_order(): + assert [k for k, _ in F.count_fouls([_row("b", "keep_out"), _row("a", "keep_out")], ["strategy"])] == [ + ("a",), + ("b",), + ] + + +def test_without_stoppages_drops_out_of_bounds_and_keeps_rules_fouls(): + rows = [_row("a", "out_of_bounds"), _row("a", "defense_area_stoppage"), _row("a", "keep_out")] + assert [f["rule"] for f in F.without_stoppages(rows)] == ["defense_area_stoppage", "keep_out"] + + +def test_fouls_by_table_has_header_counts_and_total(): + lines = F.fouls_by_table([_row("a", "keep_out"), _row("a", "keep_out")], ["strategy", "rule"]) + assert [line.split() for line in lines] == [["count", "strategy", "rule"], ["2", "a", "keep_out"], ["2", "total"]] + + +def test_fouls_json_is_the_foul_list_or_the_by_counts_as_rows(): + rows = [_row("a", "keep_out", restart=None), _row("a", "keep_out"), _row("b", "crashing")] + assert json.loads(F.fouls_json(rows)) == rows + assert json.loads(F.fouls_json(rows, ["strategy", "rule"])) == [ + {"strategy": "a", "rule": "keep_out", "count": 2}, + {"strategy": "b", "rule": "crashing", "count": 1}, + ] + + +def test_find_bugs_fouls_filters_then_counts(tmp_path): + from tools.debug.find_bugs import fouls_report + + run = _run(tmp_path, [_foul(1.0), _foul(2.0, rule="out_of_bounds"), _foul(3.0, rule="crashing")]) + assert len(fouls_report(run)) == 2 # out_of_bounds is a stoppage, left out + assert len(fouls_report(run, include_stoppages=True)) == 3 + assert fouls_report(run, rule="crashing")[0].startswith("crashing") + assert [line.split() for line in fouls_report(run, by="rule")][-1] == ["2", "total"] + with pytest.raises(ValueError, match="unknown column"): + fouls_report(run, by="nope") diff --git a/utama_core/tests/analysis/test_goal_ledger.py b/utama_core/tests/analysis/test_goal_sources.py similarity index 99% rename from utama_core/tests/analysis/test_goal_ledger.py rename to utama_core/tests/analysis/test_goal_sources.py index 3496974f2..1dbec6091 100644 --- a/utama_core/tests/analysis/test_goal_ledger.py +++ b/utama_core/tests/analysis/test_goal_sources.py @@ -3,7 +3,7 @@ import numpy as np import pytest -from utama_core.analysis.goal_ledger import ( +from utama_core.analysis.goal_sources import ( SUSTAINED, attribute, find_goals, diff --git a/utama_core/tests/analysis/test_match_timeline.py b/utama_core/tests/analysis/test_match_timeline.py index c56d9db9e..5e16a9f66 100644 --- a/utama_core/tests/analysis/test_match_timeline.py +++ b/utama_core/tests/analysis/test_match_timeline.py @@ -2,7 +2,7 @@ import numpy as np -from tools.match_timeline import ( +from tools.debug.match_timeline import ( FLIP_BACKS_PER_MIN, FLIP_S, MIN_LIVE_S, diff --git a/utama_core/tests/analysis/test_pitch_maps.py b/utama_core/tests/analysis/test_pitch_maps.py index b7f34e98f..06c737fc1 100644 --- a/utama_core/tests/analysis/test_pitch_maps.py +++ b/utama_core/tests/analysis/test_pitch_maps.py @@ -1,10 +1,12 @@ -"""`tools/pitch_maps.py` on tiny synthetic replays: the side normalisation, possession and the +"""`tools/debug/pitch_maps.py` on tiny synthetic replays: the side normalisation, possession and the goalkeeper exclusion, and that each figure is written.""" +import json + import numpy as np import pytest -from tools import pitch_maps as pm +from tools.debug import pitch_maps as pm from utama_core.engine.match_stats import _POSSESSION_RADIUS_M from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.replay.columnar_reader import ColumnarReplay @@ -139,7 +141,7 @@ def test_position_grid_shares_sum_to_one_and_means_are_per_robot(): def _views(): - names = ["build_a_kernel_strategy", "build_b_kernel_strategy"] + names = ["a", "b"] shots = [{"x": 2.0, "y": 0.5, "scored": True, "own": True}, {"x": -1.0, "y": 0.0, "scored": False, "own": False}] fouls = [{"x": 1.0, "y": -1.0, "rule": "crashing"}, {"x": -2.0, "y": 1.0, "rule": "double_touch"}] views = [] @@ -171,20 +173,32 @@ def test_each_figure_is_written(tmp_path, which): assert path.read_bytes()[:8] == b"\x89PNG\r\n\x1a\n" +def test_map_data_is_json_with_both_grids_the_shots_and_one_scale_per_grid(): + order, _, views = _views() + data = json.loads(json.dumps(pm.map_data(views, order))) # plain JSON all the way down + a = data["strategies"]["a"] + rows, cols = len(a["attack"]["share"]), len(a["attack"]["share"][0]) + assert (rows, cols) == (round(2 * pm.W / pm.BIN_M), round(2 * pm.L / pm.BIN_M)) + assert sum(map(sum, a["attack"]["share"])) == pytest.approx(1.0) + assert a["defence"]["means"] == [[1.0, 0.5]] # robot 1's only sample without the ball + assert a["shots"] == {"own": [[2.0, 0.5, True]], "faced": [[-1.0, 0.0, False]]} + assert set(data["vmax"]) == {"attack", "defence"} and data["pitch"]["half_length"] == pm.L + + def test_rule_colours_take_fixed_slots_in_rank_order(): assert pm.rule_colours(["crashing", "double_touch"]) == {"crashing": pm.sr.SLOTS[0], "double_touch": pm.sr.SLOTS[1]} def test_zone_findings_are_six_descriptive_shares_per_strategy_in_the_pitch_zone_names(): - # Common frame: the strategy attacks +x, thirds at x = -1.5 and +1.5 m (docs/pitch_zones.md). + # Common frame: the strategy attacks +x, thirds at x = -1.5 and +1.5 m (docs/signals.md ("Pitch zones")). view = pm.MatchView( - strategy="build_a_kernel_strategy", + strategy="a", pos_x=np.array([-2.0, 0.0, 2.0, 2.5]), pos_y=np.zeros(4), pos_in=np.array([True, True, True, False]), # three in possession, one out pos_robot=np.array([1, 2, 3, 1]), ) - findings = pm.zone_findings([view], ["build_a_kernel_strategy"], {"in possession": "a.png"}) + findings = pm.zone_findings([view], ["a"], {"in possession": "a.png"}) assert len(findings) == 6 assert all(f.kind == "zone_share" and f.threshold is None and f.replay is None for f in findings) diff --git a/utama_core/tests/analysis/test_plan_snapshot.py b/utama_core/tests/analysis/test_plan_snapshot.py index 9dc818b1d..c19beeb86 100644 --- a/utama_core/tests/analysis/test_plan_snapshot.py +++ b/utama_core/tests/analysis/test_plan_snapshot.py @@ -1,4 +1,4 @@ -"""tools/plan_snapshot.py's drawing function, on the kick-off state of +"""tools/debug/plan_snapshot.py's drawing function, on the kick-off state of test_fpp_inside_ball_keep_out.py (no simulator).""" import math diff --git a/utama_core/tests/analysis/test_plan_trace.py b/utama_core/tests/analysis/test_plan_trace.py index dc1d54152..0e010bdb8 100644 --- a/utama_core/tests/analysis/test_plan_trace.py +++ b/utama_core/tests/analysis/test_plan_trace.py @@ -1,4 +1,4 @@ -"""tools/plan_trace.py's trace function on synthetic games over time (no replay, no simulator).""" +"""tools/debug/plan_trace.py's trace function on synthetic games over time (no replay, no simulator).""" import math diff --git a/utama_core/tests/analysis/test_ratings.py b/utama_core/tests/analysis/test_ratings.py index 84abf28aa..5927739b0 100644 --- a/utama_core/tests/analysis/test_ratings.py +++ b/utama_core/tests/analysis/test_ratings.py @@ -1,71 +1,31 @@ -import numpy as np import pytest +from scipy import stats from utama_core.analysis import ratings -def test_no_matches_keeps_the_prior(): - r = ratings.fit([], names=["x", "y"]) - assert r.strength("x") == pytest.approx((0.0, ratings.PRIOR_SD)) - assert r.p_better("x", "y") == pytest.approx(0.5) +def test_identical_code_gives_no_evidence(): + # identical code plays identical matches: every diff is exactly 0 + assert ratings.paired_test([0.0] * 30).p == 1.0 -def test_many_matches_recover_true_strengths(): - """With plenty of noisy matches the posterior mean lands on the true margins and its SD - shrinks like 1/sqrt(matches).""" - rng = np.random.default_rng(0) - true = {"x": 1.0, "y": 0.0, "z": -1.0} - pairs = [("x", "y"), ("y", "z"), ("z", "x")] - matches = [(a, b, true[a] - true[b] + rng.normal(0, 1.6)) for _ in range(400) for a, b in pairs] - r = ratings.fit(matches) - for n, s in true.items(): - assert r.strength(n)[0] == pytest.approx(s, abs=0.1) - assert r.noise_sd == pytest.approx(1.6, abs=0.1) - assert r.p_better("x", "z") > 0.999 +def test_too_few_diffs_give_no_evidence(): + assert ratings.paired_test([]).p == 1.0 + assert ratings.paired_test([3.0]).p == 1.0 -def test_margin_is_shrunk_toward_zero_by_the_prior(): - """One 3-0 win is not a 3-goal strength gap: the prior pulls it in.""" - r = ratings.fit([("x", "y", 3.0)], noise_sd=1.6) - m, sd = r.diff("x", "y") - assert 0 < m < 3.0 - expected = 2 * ratings.PRIOR_SD**2 / (2 * ratings.PRIOR_SD**2 + 1.6**2) * 3.0 - assert m == pytest.approx(expected) +def test_the_p_value_is_the_one_sided_t_test(): + diffs = [1.0, 0.0, 1.0, 1.0, 1.0] + t = ratings.paired_test(diffs) + assert t.mean == pytest.approx(0.8) + assert t.se == pytest.approx(0.2) # sample SD 0.447 over sqrt(5) + assert t.p == pytest.approx(stats.ttest_1samp(diffs, 0.0, alternative="greater").pvalue) -def test_noise_sd_cannot_collapse_on_few_matches(): - """Two matches that fit perfectly still leave noise_sd near its prior.""" - r = ratings.fit([("x", "y", 1.0), ("x", "y", 1.0)]) - assert r.noise_sd > 0.8 * ratings.NOISE_SD +def test_a_worse_candidate_has_a_large_p(): + assert ratings.paired_test([-1.0, -2.0, 0.0, -1.0]).p > 0.9 -def test_common_opponents_compare_two_strategies_that_never_met(): - """x beats o by more than y does, so x is likely stronger than y without x v y matches.""" - matches = [("x", "o", 2.0)] * 20 + [("y", "o", 0.0)] * 20 - r = ratings.fit(matches) - assert r.p_better("x", "y") > 0.99 - - -def test_identical_paired_results_pin_the_difference_near_zero(): - """The case that forced the paired test: a copy of the champion matches its results exactly - against every opponent, and a few lucky head-to-head wins must not make it 'better'.""" - m, sd = ratings.paired_difference([0.0] * 24, [1, 4, 1, 0], noise_sd=1.9) - assert abs(m) < 0.3 - assert ratings.p_positive(m, sd) < 0.9 - - -def test_paired_spread_is_shrunk_toward_no_cancelling(): - """Two equal diffs have zero spread, but the variance stays near 2 * noise_sd^2 * N0 / (N0 + 1).""" - m, sd = ratings.paired_difference([1.0, 1.0], [], noise_sd=1.9) - var_d = ratings.PAIRED_PRIOR_N * 2 * 1.9**2 / (ratings.PAIRED_PRIOR_N + 1) - assert sd == pytest.approx((1 / (2 * ratings.PRIOR_SD**2) + 2 / var_d) ** -0.5) - - -def test_consistent_paired_gains_are_decisive(): - m, sd = ratings.paired_difference([1.0, 2.0, 1.0, 1.5] * 6, [], noise_sd=1.9) - assert ratings.p_positive(m, sd) > 0.99 - - -def test_no_evidence_is_a_coin_flip(): - m, sd = ratings.paired_difference([], [], noise_sd=1.9) - assert ratings.p_positive(m, sd) == pytest.approx(0.5) +def test_a_repeated_exact_margin_is_decisive_either_way(): + assert ratings.paired_test([1.0, 1.0, 1.0]).p == 0.0 + assert ratings.paired_test([-1.0, -1.0, -1.0]).p == 1.0 diff --git a/utama_core/tests/analysis/test_restart_picture.py b/utama_core/tests/analysis/test_restart_picture.py index d941705af..1b58a682b 100644 --- a/utama_core/tests/analysis/test_restart_picture.py +++ b/utama_core/tests/analysis/test_restart_picture.py @@ -1,4 +1,4 @@ -"""tools/restart_picture.py's capture of the referee override's commanded targets (no simulator).""" +"""tools/debug/restart_picture.py's capture of the referee override's commanded targets (no simulator).""" import json import math @@ -14,11 +14,11 @@ render_restart, ) from utama_core.config.referee_constants import BALL_KEEP_OUT_DISTANCE -from utama_core.custom_referee import actions from utama_core.entities.data.referee import RefereeData from utama_core.entities.game.team_info import TeamInfo from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.entities.referee.stage import Stage +from utama_core.referee import actions from utama_core.tests.fixtures.game_builder import build_game, make_ball, make_robot diff --git a/utama_core/tests/analysis/test_robot_calibration.py b/utama_core/tests/analysis/test_robot_calibration.py index 6691ea296..6ba01e08c 100644 --- a/utama_core/tests/analysis/test_robot_calibration.py +++ b/utama_core/tests/analysis/test_robot_calibration.py @@ -25,13 +25,11 @@ from utama_core.entities.referee.stage import Stage from utama_core.replay.game_log_writer import RADIO_OUT, GameLogWriter from utama_core.replay.ssl_log import REFEREE, read_records, referee_data -from utama_core.team_controller.src.controllers.real.real_robot_controller import ( +from utama_core.team_controller.controllers.real.real_robot_controller import ( RealRobotController, ) -from utama_core.team_controller.src.generated_code.ssl_gc_referee_message_pb2 import ( - Referee, -) -from utama_core.team_controller.src.generated_code.ssl_vision_wrapper_pb2 import ( +from utama_core.team_controller.generated_code.ssl_gc_referee_message_pb2 import Referee +from utama_core.team_controller.generated_code.ssl_vision_wrapper_pb2 import ( SSL_WrapperPacket, ) diff --git a/utama_core/tests/analysis/test_signal_report.py b/utama_core/tests/analysis/test_signal_report.py deleted file mode 100644 index 6807f9b30..000000000 --- a/utama_core/tests/analysis/test_signal_report.py +++ /dev/null @@ -1,52 +0,0 @@ -from tools.signal_report import build, markdown - - -def _result(a: str, b: str, score_a: int, score_b: int) -> dict: - return { - "config_a": f"build_{a}_kernel_strategy", - "config_b": f"build_{b}_kernel_strategy", - "score_a": score_a, - "score_b": score_b, - "stats": {"shots": {"friendly": 2, "enemy": 1}, "pass_progress_m": [1.5], "enemy_pass_progress_m": [0.2]}, - } - - -def test_build_writes_every_figure(tmp_path): - shot = {"side": "friendly", "distance_m": 2.2, "angle_deg": 10.0, "open_goal": 0.6, "scored": True} - chances = { - "shots": [shot, {**shot, "side": "enemy", "scored": False}], - "unshot_goals": {"friendly": 0, "enemy": 0}, - "regains": [{"side": "friendly", "t": 1.0, "shot_after_s": 2.0}], - "danger": {"friendly": {"s": 5.0, "spells": 1}, "enemy": {"s": 9.0, "spells": 2}}, - "free_kicks": [{"side": "enemy", "t": 3.0, "attacking_third": False, "shot_after_s": None}], - } - losses = [ - { - "match": "x_vs_y", - "turnovers": [ - {"kind": "tackled", "t": 0.0, "tactic": "T", "just_restarted": False, "regained_after_s": None} - ], - "restarts": [], - "chances": chances, - } - ] - summary = { - "results": [_result("x", "y", 1, 0)], - "fouls": {"crashing": {"total": 1, "inferred": 0, "by_tactic": {"x/T": 1}}}, - } - - table = build(summary, losses, tmp_path) - - assert sorted(p.name for p in tmp_path.iterdir()) == [ - "ball_losses.png", - "fouls.png", - "results.png", - "shot_quality.png", - "signals.png", - ] - assert table["build_x_kernel_strategy"]["chances"]["regain_to_shot"] == 1.0 - # Shots faced are the other side's shots: x (config_a, friendly) faced the enemy's 1, y faced 2. - assert table["build_x_kernel_strategy"]["shots_faced"] == 1 - assert table["build_y_kernel_strategy"]["shots_faced"] == 2 - rows = markdown(table).splitlines() - assert rows[2].startswith("| `x` | 3.00 | 1.0 | 0.0 | 2.0 | 1.0 | 50% | 0% |") diff --git a/utama_core/tests/bundle/__init__.py b/utama_core/tests/bundle/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/utama_core/tests/bundle/test_strategy_file.py b/utama_core/tests/bundle/test_strategy_file.py new file mode 100644 index 000000000..a1c75ec9c --- /dev/null +++ b/utama_core/tests/bundle/test_strategy_file.py @@ -0,0 +1,326 @@ +import dataclasses +import json +import subprocess +import sys +import zipfile +from pathlib import Path + +import pytest + +from tools.evaluation import evaluate, match +from utama_core.bundle import archive, host, strategy_file, wire +from utama_core.config.enums import Mode +from utama_core.engine.abstract_strategy import AbstractStrategy +from utama_core.engine.match_log import MatchLog +from utama_core.entities.data.referee import RefereeData +from utama_core.entities.data.vector import Vector2D, Vector3D +from utama_core.entities.game import Ball, Field, Game, GameFrame, GameHistory, Robot +from utama_core.entities.game.team_info import TeamInfo +from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.entities.referee.stage import Stage +from utama_core.motion_planning.common.control_schemes import get_control_scheme +from utama_core.replay.fingerprint import CodeGraph +from utama_core.strategy import catalog + +STRATEGY = "pendulum" + + +def _robot(rid: int, friendly: bool, x: float, y: float) -> Robot: + return Robot(rid, friendly, False, Vector2D(x, y), Vector2D(0.1, -0.2), Vector2D(0.0, 0.3), 0.1 + rid / 3) + + +def _frame(ts: float = 1.0) -> GameFrame: + referee = RefereeData( + source_identifier=None, + time_sent=ts, + time_received=ts, + referee_command=RefereeCommand.NORMAL_START, + referee_command_timestamp=0.0, + stage=Stage.NORMAL_FIRST_HALF, + stage_time_left=120.0, + blue_team=TeamInfo("blue", score=2, yellow_card_times=[3]), + yellow_team=TeamInfo("yellow", goalkeeper=0), + designated_position=(0.5, -0.25), + next_command=RefereeCommand.STOP, + ) + return GameFrame( + ts=ts, + my_team_is_yellow=True, + my_team_is_right=True, + friendly_robots={i: _robot(i, True, 1.0 + i / 7, i / 3 - 0.5) for i in range(6)}, + enemy_robots={i: _robot(i, False, -1.0 - i / 7, 0.5 - i / 3) for i in range(6)}, + ball=Ball(Vector3D(0.2, 0.1, 0.0), Vector3D(1 / 3, 0.0, 0.0), Vector3D(0.0, 0.0, 0.0)), + referee=referee, + ) + + +def _field() -> Field: + return host.decode_field( + { + "my_team_is_right": True, + "dims": { + "full_field_half_length": 4.5, + "full_field_half_width": 3.0, + "half_defense_area_depth": 0.5, + "half_defense_area_width": 1.0, + "half_goal_width": 0.5, + "center_circle_radius": 0.5, + "goal_depth": 0.18, + }, + "top_left": [-4.5, 3.0], + "bottom_right": [4.5, -3.0], + "defense_area_rules": True, + } + ) + + +def _over_the_wire(data): + return json.loads(json.dumps(data)) + + +def test_a_frame_comes_back_with_every_float_exact(): + frame = _frame() + decoded = host.decode_frame(_over_the_wire(wire.encode_frame(frame))) + assert [ + (r.id, r.is_friendly, r.has_ball, r.p, r.v, r.a, r.orientation) for r in decoded.friendly_robots.values() + ] == [(r.id, r.is_friendly, r.has_ball, r.p, r.v, r.a, r.orientation) for r in frame.friendly_robots.values()] + assert list(decoded.enemy_robots) == list(frame.enemy_robots) + assert (decoded.ball.p, decoded.ball.v, decoded.ball.a) == (frame.ball.p, frame.ball.v, frame.ball.a) + assert decoded.ts == frame.ts + + +def test_a_frame_comes_back_with_the_whole_referee(): + referee = host.decode_frame(_over_the_wire(wire.encode_frame(_frame()))).referee + assert referee.referee_command == RefereeCommand.NORMAL_START + assert referee.next_command == RefereeCommand.STOP + assert referee.stage == Stage.NORMAL_FIRST_HALF + assert referee.designated_position == (0.5, -0.25) + assert (referee.blue_team.score, referee.blue_team.yellow_card_times) == (2, [3]) + + +def test_a_frame_without_ball_or_referee_survives(): + frame = dataclasses.replace(_frame(), ball=None, referee=None) + decoded = host.decode_frame(_over_the_wire(wire.encode_frame(frame))) + assert decoded.ball is None and decoded.referee is None + + +def test_the_same_code_builds_the_same_bytes(tmp_path): + first = strategy_file.build(STRATEGY, tmp_path / "a.strategy") + second = strategy_file.build(STRATEGY, tmp_path / "b.strategy") + assert first.read_bytes() == second.read_bytes() + + +def test_a_bundle_holds_its_code_and_no_tests(tmp_path): + path = strategy_file.build(STRATEGY, tmp_path / "a.strategy") + with zipfile.ZipFile(path) as archive: + names = set(archive.namelist()) + manifest = json.loads(archive.read("manifest.json")) + assert {"utama_core/bundle/host.py", "utama_core/strategy/pendulum.py"} <= names + assert not any(name.startswith("utama_core/tests/") for name in names) + assert manifest["strategy"] == STRATEGY and manifest["format"] == strategy_file.FORMAT_VERSION + + +def test_a_strategy_that_does_not_exist_is_refused(tmp_path): + with pytest.raises(ValueError, match="nobody"): + strategy_file.build("nobody", tmp_path / "a.strategy") + + +def test_a_frozen_file_is_named_after_its_commit_and_never_rebuilt(tmp_path): + first = strategy_file.frozen(STRATEGY, "HEAD", tmp_path) + assert first.name == f"pendulum@{strategy_file._commit_of('HEAD')[:8]}.strategy" + first.write_bytes(b"kept") + assert strategy_file.frozen(STRATEGY, "HEAD", tmp_path).read_bytes() == b"kept" + + +def test_an_annotated_tag_resolves_to_its_commit(tmp_path, monkeypatch): + git = ["git", "-c", "user.name=t", "-c", "user.email=t@t", "-c", "commit.gpgsign=false", "-c", "tag.gpgsign=false"] + subprocess.run([*git, "init", "-q"], cwd=tmp_path, check=True) + subprocess.run([*git, "commit", "-q", "--allow-empty", "-m", "x"], cwd=tmp_path, check=True) + subprocess.run([*git, "tag", "-a", "v1", "-m", "x"], cwd=tmp_path, check=True) + commit = subprocess.run(["git", "rev-parse", "HEAD"], cwd=tmp_path, capture_output=True, text=True).stdout.strip() + monkeypatch.setattr(strategy_file, "_REPO", tmp_path) + assert strategy_file._commit_of("v1") == commit + + +def _rewritten(source: Path, output: Path, member: str, change) -> Path: + with zipfile.ZipFile(source) as old, zipfile.ZipFile(output, "w") as new: + for name in old.namelist(): + data = old.read(name) + new.writestr(name, change(data) if name == member else data) + return output + + +def test_a_file_and_the_code_it_was_built_from_are_the_same_player(tmp_path, monkeypatch): + monkeypatch.setattr(archive, "_CACHE", tmp_path / "cache") + path = strategy_file.build(STRATEGY, tmp_path / "a.strategy") + graph = CodeGraph() + assert graph.strategy_fingerprint(path.as_posix()) == graph.strategy_fingerprint(STRATEGY) + + +def test_what_a_file_adds_around_the_code_is_not_part_of_the_player(tmp_path, monkeypatch): + monkeypatch.setattr(archive, "_CACHE", tmp_path / "cache") + path = strategy_file.build(STRATEGY, tmp_path / "a.strategy") + other = _rewritten(path, tmp_path / "b.strategy", "utama_core/bundle/host.py", lambda d: d + b"\nX = 1\n") + graph = CodeGraph() + assert graph.strategy_fingerprint(other.as_posix()) == graph.strategy_fingerprint(path.as_posix()) + + +@pytest.mark.parametrize( + "member", + [ + "utama_core/strategy/pendulum.py", + "utama_core/skills/go_to_ball.py", + "utama_core/motion_planning/common/control_schemes.py", + ], +) +def test_a_file_of_different_code_is_a_different_player(tmp_path, monkeypatch, member): + monkeypatch.setattr(archive, "_CACHE", tmp_path / "cache") + path = strategy_file.build(STRATEGY, tmp_path / "a.strategy") + other = _rewritten(path, tmp_path / "b.strategy", member, lambda d: d + b"\nX = 1\n") + graph = CodeGraph() + assert graph.strategy_fingerprint(other.as_posix()) != graph.strategy_fingerprint(path.as_posix()) + + +def test_a_frozen_player_and_the_same_strategy_today_get_different_match_tags(): + assert match._short_name("replays/eval/frozen/pendulum@09493fd2.strategy") == "pendulum@09493fd2" + assert match._short_name(STRATEGY) == "pendulum" + + +class _Commands: + keeps_kickers_charged = False + + def __init__(self): + self.sent = {} + + def add_robot_commands(self, command, robot_id): + self.sent[robot_id] = command + + def send_robot_commands(self): + pass + + +def _run(strategy) -> list[dict]: + """Three ticks; the second and third depend on what the strategy kept from the first.""" + controller = _Commands() + strategy.load_robot_controller(controller) + strategy.load_motion_controller(get_control_scheme("fpp")(Mode.RSIM, None)) + game = Game(GameHistory(20), _frame(), field=_field()) + strategy.load_game(game) + out = [] + for tick in range(3): + game.add_game_frame(_frame(1.0 + (tick + 1) / 60)) + controller.sent = {} + strategy.step() + out.append(dict(controller.sent)) + return out + + +def test_a_bundled_strategy_sends_exactly_the_commands_of_the_same_strategy_in_process(tmp_path, monkeypatch): + monkeypatch.setattr(archive, "_CACHE", tmp_path / "cache") + bundled = strategy_file.BundledStrategy(strategy_file.build(STRATEGY, tmp_path / "a.strategy")) + in_process = AbstractStrategy(catalog.builder(STRATEGY, (1, 2, 3, 4, 5))) + assert _run(bundled) == _run(in_process) + + +def _setup_of(strategy, mode=Mode.REAL) -> dict: + sent = [] + strategy._send = sent.append + controller = get_control_scheme("fpp")(mode, None) + controller.kick_bend, controller.kick_bias = {1: 0.5}, {2: -0.25} + controller.robot_carry = {3: (0.3, 0.6)} + controller.pose_ahead.latency_s = 0.079 + strategy.load_motion_controller(controller) + return sent[0] + + +def test_real_robots_kick_calibration_reaches_the_files_controller(tmp_path, monkeypatch): + monkeypatch.setattr(archive, "_CACHE", tmp_path / "cache") + strategy = strategy_file.BundledStrategy(strategy_file.build(STRATEGY, tmp_path / "a.strategy")) + send = strategy._send + setup = _setup_of(strategy) + strategy._send = send # for close() + controller = host._controller(wire_round_trip(setup)) + assert controller.mode == Mode.REAL + assert (controller.kick_bend, controller.kick_bias) == ({1: 0.5}, {2: -0.25}) + assert controller.robot_carry == {3: (0.3, 0.6)} + assert controller.pose_ahead.latency_s == 0.079 + + +def wire_round_trip(message: dict) -> dict: + return json.loads(json.dumps(message)) + + +class _KeepsCharged(_Commands): + keeps_kickers_charged = True + + +def test_a_real_robots_kicker_charge_is_applied_to_a_files_commands(tmp_path, monkeypatch): + """The charge step needs the real controller, so it stays with the runner: same commands as in process.""" + monkeypatch.setattr(archive, "_CACHE", tmp_path / "cache") + monkeypatch.setattr(sys.modules[__name__], "_Commands", _KeepsCharged) + bundled = strategy_file.BundledStrategy(strategy_file.build(STRATEGY, tmp_path / "a.strategy")) + in_process = AbstractStrategy(catalog.builder(STRATEGY, (1, 2, 3, 4, 5))) + assert _run(bundled) == _run(in_process) + assert bundled._kicker_charge is not None + + +def test_a_file_can_play_with_the_robots_a_run_has(tmp_path, monkeypatch): + monkeypatch.setattr(archive, "_CACHE", tmp_path / "cache") + path = strategy_file.build(STRATEGY, tmp_path / "a.strategy") + bundled = strategy_file.BundledStrategy(path, (1, 2)) + assert _run(bundled) == _run(AbstractStrategy(catalog.builder(STRATEGY, (1, 2)))) + + +def _observed(strategy, path) -> dict: + """Everything the runner reads from a strategy, one tick of each kind.""" + controller = _Commands() + strategy.load_robot_controller(controller) + strategy.load_motion_controller(get_control_scheme("fpp")(Mode.RSIM, None)) + log = MatchLog() + kernel = strategy._kernel_strategy + kernel.match_log = log + game = Game(GameHistory(20), _frame(), field=_field()) + strategy.load_game(game) + seen = {"commands": [], "committed": [], "partition": [], "names": [], "status": []} + for tick in range(4): + game.add_game_frame(_frame(1.0 + (tick + 1) / 60)) + # The runner's order: committed tactics are read on the new frame, before the step. + seen["committed"].append( + {tid: sorted(info["robots"]) for tid, info in kernel.slot_status(game).items() if info["committed"]} + ) + controller.sent = {} + strategy.step() + seen["commands"].append(dict(controller.sent)) + partition = kernel.active_partition + seen["partition"].append({tid: sorted(robots) for tid, robots in partition.items()}) + seen["names"].append({tid: type(kernel._tactics[tid]).__name__ for tid in partition}) + seen["status"].append(strategy.debug_status()) + log.to_jsonl(path) + seen["log"] = Path(path).read_text() + seen["keeper"] = kernel._pinned_robot_id if hasattr(kernel, "_pinned_robot_id") else None + return seen + + +def test_the_runner_reads_the_same_from_a_bundled_strategy_as_from_the_same_strategy_in_process(tmp_path, monkeypatch): + monkeypatch.setattr(archive, "_CACHE", tmp_path / "cache") + bundled = strategy_file.BundledStrategy(strategy_file.build(STRATEGY, tmp_path / "a.strategy")) + in_process = AbstractStrategy(catalog.builder(STRATEGY, (1, 2, 3, 4, 5))) + seen_bundled = _observed(bundled, tmp_path / "bundled.jsonl") + seen_in_process = _observed(in_process, tmp_path / "in_process.jsonl") + assert seen_bundled["log"] # the comparison below must not pass on two empty logs + assert seen_bundled == seen_in_process + + +def test_a_strategy_file_is_named_like_any_strategy(): + names = evaluate.resolve_names(["split_shape", "replays/x@abc.strategy"]) # an old name works too + assert names == [STRATEGY, "replays/x@abc.strategy"] + + +def test_a_bundle_whose_process_died_says_so(tmp_path, monkeypatch): + monkeypatch.setattr(archive, "_CACHE", tmp_path / "cache") + bundled = strategy_file.BundledStrategy(strategy_file.build(STRATEGY, tmp_path / "a.strategy")) + bundled._process.kill() + bundled._process.wait() + with pytest.raises((RuntimeError, BrokenPipeError), match="exit code|Broken pipe"): + bundled._send({"type": "tick"}) + bundled._reply() diff --git a/utama_core/tests/common/abstract_test_manager.py b/utama_core/tests/common/abstract_test_manager.py index f219b1daa..43c9fda50 100644 --- a/utama_core/tests/common/abstract_test_manager.py +++ b/utama_core/tests/common/abstract_test_manager.py @@ -3,7 +3,7 @@ from utama_core.engine.abstract_strategy import AbstractStrategy from utama_core.entities.game import Game -from utama_core.team_controller.src.controllers import AbstractSimController +from utama_core.team_controller.controllers import AbstractSimController class TestingStatus(Enum): diff --git a/utama_core/tests/custom_referee/test_restart_fuzzer.py b/utama_core/tests/custom_referee/test_restart_fuzzer.py deleted file mode 100644 index a310ff6d0..000000000 --- a/utama_core/tests/custom_referee/test_restart_fuzzer.py +++ /dev/null @@ -1,277 +0,0 @@ -"""Tests for `RestartFuzzingReferee` (utama_core/custom_referee/restart_fuzzer.py). - -Covers: - - Seed determinism: same seed → identical injection schedule/kinds/positions. - - Injections only fire during live play (never mid-restart, never right - after a goal before the queued kickoff resolves). - - Every drawn `designated_position` is legal (inside field with margin, - outside both defense areas with margin) — checked over several hundred - seeded draws. - - The `kinds` filter is respected. - -No rsim match: how many injections a match gets depends on how play unfolds, which differs by CPU, -so such a test failed on CI while passing locally. -""" - -from __future__ import annotations - -import math - -from utama_core.config.field_params import STANDARD_FIELD_DIMS -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.restart_fuzzer import ( - ALL_KINDS, - KIND_BALL_PLACEMENT_DIRECT_FREE, - KIND_FORCE_START, - KIND_PREPARE_KICKOFF, - RestartFuzzingReferee, -) -from utama_core.engine.abstract_strategy import AbstractStrategy -from utama_core.entities.data.vector import Vector2D, Vector3D -from utama_core.entities.game.ball import Ball -from utama_core.entities.game.game_frame import GameFrame -from utama_core.entities.game.robot import Robot -from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.run.strategy_runner import StrategyRunner -from utama_core.strategy.kernel_strategy import build_default_kernel_strategy - -GEO = RefereeGeometry.from_field_dims(STANDARD_FIELD_DIMS) - -# --------------------------------------------------------------------------- -# Helpers (mirrors utama_core/tests/custom_referee/test_custom_referee.py) -# --------------------------------------------------------------------------- - - -def _ball(x: float, y: float, vx: float = 0.0, vy: float = 0.0) -> Ball: - return Ball(p=Vector3D(x, y, 0.0), v=Vector3D(vx, vy, 0.0), a=Vector3D(0, 0, 0)) - - -def _robot(robot_id: int, x: float, y: float, is_friendly: bool) -> Robot: - return Robot( - id=robot_id, - is_friendly=is_friendly, - has_ball=False, - p=Vector2D(x, y), - v=Vector2D(0, 0), - a=Vector2D(0, 0), - orientation=0.0, - ) - - -def _frame( - ts: float, - ball_xy: tuple[float, float] = (0.0, 0.0), - friendly: dict | None = None, - enemy: dict | None = None, -) -> GameFrame: - return GameFrame( - ts=ts, - my_team_is_yellow=True, - my_team_is_right=False, - friendly_robots=friendly or {}, - enemy_robots=enemy or {}, - ball=_ball(*ball_xy), - referee=None, - ) - - -def _far_from_ball_robots() -> dict[int, Robot]: - """A handful of robots far from the ball/centre so `_all_robots_clear()` - is satisfied immediately and STOP auto-advances without needing to wait - out `_STOP_CLEAR_TIMEOUT_SECONDS`.""" - return { - 0: _robot(0, -3.0, 2.0, True), - 1: _robot(1, -3.0, -2.0, True), - 2: _robot(2, 3.0, 2.0, True), - } - - -def _run_ticks(referee: RestartFuzzingReferee, n_ticks: int, dt: float = 1 / 60) -> None: - """Drive `referee.step()` for `n_ticks` synthetic ticks, holding the ball - at the origin and robots far away throughout (so any STOP auto-advances - immediately) — enough to exercise scheduling/injection logic without a - real simulator. - """ - referee.seed_clock(0.0, RefereeCommand.NORMAL_START) - friendly = _far_from_ball_robots() - enemy = {10: _robot(10, 3.0, -2.0, False)} - t = 0.0 - for _ in range(n_ticks): - frame = _frame(t, ball_xy=(0.0, 0.0), friendly=friendly, enemy=enemy) - referee.step(frame, t) - t += dt - - -# --------------------------------------------------------------------------- -# Seed determinism -# --------------------------------------------------------------------------- - - -def test_seed_determinism_same_schedule_and_positions(): - ref_a = RestartFuzzingReferee.from_profile_name( - "simulation", seed=42, interval_s=(0.5, 1.0), n_robots_yellow=3, n_robots_blue=3 - ) - ref_b = RestartFuzzingReferee.from_profile_name( - "simulation", seed=42, interval_s=(0.5, 1.0), n_robots_yellow=3, n_robots_blue=3 - ) - - _run_ticks(ref_a, 600) # 10s @ 60Hz - _run_ticks(ref_b, 600) - - assert len(ref_a.injections) > 0, "test setup produced no injections to compare" - assert ref_a.injections == ref_b.injections - - -def test_different_seed_different_schedule(): - ref_a = RestartFuzzingReferee.from_profile_name( - "simulation", seed=1, interval_s=(0.5, 1.0), n_robots_yellow=3, n_robots_blue=3 - ) - ref_b = RestartFuzzingReferee.from_profile_name( - "simulation", seed=2, interval_s=(0.5, 1.0), n_robots_yellow=3, n_robots_blue=3 - ) - - _run_ticks(ref_a, 600) - _run_ticks(ref_b, 600) - - assert ref_a.injections != ref_b.injections - - -# --------------------------------------------------------------------------- -# Injections only during live play -# --------------------------------------------------------------------------- - - -def test_injection_never_starts_mid_restart(): - """Force the referee into a non-live-play command right when an - injection would be due, and confirm the fuzzer waits rather than - injecting on top of an in-flight restart.""" - referee = RestartFuzzingReferee.from_profile_name( - "simulation", seed=7, interval_s=(0.1, 0.1), n_robots_yellow=3, n_robots_blue=3 - ) - referee.seed_clock(0.0, RefereeCommand.NORMAL_START) - - friendly = _far_from_ball_robots() - enemy = {10: _robot(10, 3.0, -2.0, False)} - - # Put the referee into a real, in-flight restart (DIRECT_FREE_YELLOW) - # that will not auto-advance immediately (kicker/defenders not in - # position), then drive ticks through the scheduled injection time and - # confirm no injection fires while command != live play. - referee.force_command(RefereeCommand.DIRECT_FREE_YELLOW, 0.0) - - t = 0.0 - for _ in range(30): # 0.5s @ 60Hz — well past the 0.1s interval - frame = _frame(t, ball_xy=(0.0, 0.0), friendly=friendly, enemy=enemy) - result = referee.step(frame, t) - if result.referee_command in (RefereeCommand.NORMAL_START, RefereeCommand.FORCE_START): - # Auto-advanced back to live play — from here on injections are - # legitimately allowed again, so stop asserting. - break - assert len(referee.injections) == 0, "fuzzer injected while a restart was already in flight" - t += 1 / 60 - - -def test_all_injections_recorded_during_live_play_command_at_time_of_injection(): - """Every recorded injection's `sim_time` must correspond to a tick where - the referee's command-before-injection was live play (NORMAL_START or - FORCE_START) with no restart already queued — i.e. `_is_live_play` held - at the moment `set_command` was first called for that injection.""" - referee = RestartFuzzingReferee.from_profile_name( - "simulation", seed=3, interval_s=(0.2, 0.4), n_robots_yellow=3, n_robots_blue=3 - ) - referee.seed_clock(0.0, RefereeCommand.NORMAL_START) - - friendly = _far_from_ball_robots() - enemy = {10: _robot(10, 3.0, -2.0, False)} - t = 0.0 - live_play_ticks: set[float] = set() - for _ in range(1200): # 20s @ 60Hz - frame = _frame(t, ball_xy=(0.0, 0.0), friendly=friendly, enemy=enemy) - result_before = (referee._state.command, referee._state.next_command) - referee.step(frame, t) - if result_before[0] in (RefereeCommand.NORMAL_START, RefereeCommand.FORCE_START) and result_before[1] is None: - live_play_ticks.add(round(t, 6)) - t += 1 / 60 - - assert len(referee.injections) > 0 - for inj in referee.injections: - assert round(inj.sim_time, 6) in live_play_ticks, ( - f"injection at sim_time={inj.sim_time} did not occur while the referee was in live play " - "with no restart queued" - ) - - -# --------------------------------------------------------------------------- -# Legal positions -# --------------------------------------------------------------------------- - - -def _assert_legal(x: float, y: float) -> None: - assert GEO.is_in_field(x, y), f"({x}, {y}) is not inside the field" - # Field-line margin: strictly inside the shrunk rectangle used for sampling. - assert abs(x) <= GEO.half_length - 0.25 + 1e-9 - assert abs(y) <= GEO.half_width - 0.25 + 1e-9 - assert GEO.distance_to_left_defense_area(x, y) >= 0.2 - 1e-9, f"({x}, {y}) too close to left defense area" - assert GEO.distance_to_right_defense_area(x, y) >= 0.2 - 1e-9, f"({x}, {y}) too close to right defense area" - - -def test_random_legal_position_always_legal_many_seeded_draws(): - for seed in range(300): - referee = RestartFuzzingReferee.from_profile_name( - "simulation", seed=seed, interval_s=(1.0, 1.0), n_robots_yellow=3, n_robots_blue=3 - ) - x, y = referee._random_legal_position() - _assert_legal(x, y) - - -def test_ball_placement_injections_use_legal_positions_end_to_end(): - referee = RestartFuzzingReferee.from_profile_name( - "simulation", - seed=11, - interval_s=(0.2, 0.3), - kinds=(KIND_BALL_PLACEMENT_DIRECT_FREE,), - n_robots_yellow=3, - n_robots_blue=3, - ) - _run_ticks(referee, 1200) # 20s @ 60Hz - - ball_placement_injections = [inj for inj in referee.injections if inj.kind == KIND_BALL_PLACEMENT_DIRECT_FREE] - assert len(ball_placement_injections) > 0 - for inj in ball_placement_injections: - assert inj.position is not None - _assert_legal(*inj.position) - - -# --------------------------------------------------------------------------- -# kinds filter -# --------------------------------------------------------------------------- - - -def test_kinds_filter_restricts_injected_kinds(): - for only_kind in ALL_KINDS: - referee = RestartFuzzingReferee.from_profile_name( - "simulation", - seed=5, - interval_s=(0.1, 0.2), - kinds=(only_kind,), - n_robots_yellow=3, - n_robots_blue=3, - ) - _run_ticks(referee, 1200) # 20s @ 60Hz - - assert len(referee.injections) > 0, f"no injections at all for kinds=({only_kind},)" - assert all(inj.kind == only_kind for inj in referee.injections) - - -def test_kinds_filter_rejects_unknown_kind(): - import pytest - - with pytest.raises(ValueError): - RestartFuzzingReferee.from_profile_name("simulation", seed=1, kinds=("not_a_real_kind",)) - - -def test_invalid_interval_raises(): - import pytest - - with pytest.raises(ValueError): - RestartFuzzingReferee.from_profile_name("simulation", seed=1, interval_s=(5.0, 1.0)) diff --git a/utama_core/tests/dashboard/test_referee_view_serialization.py b/utama_core/tests/dashboard/test_referee_view_serialization.py index 33b2662fa..dc66a4936 100644 --- a/utama_core/tests/dashboard/test_referee_view_serialization.py +++ b/utama_core/tests/dashboard/test_referee_view_serialization.py @@ -119,12 +119,12 @@ def test_a_command_from_the_page_is_stamped_on_the_referees_clock_not_the_wall_c """In rsim the referee runs on sim time; a wall-clock stamp put its match clock 1.8e9 s out.""" from types import SimpleNamespace - from utama_core.custom_referee import CustomReferee from utama_core.dashboard.views import referee as referee_view from utama_core.entities.data.vector import Vector3D from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand + from utama_core.referee import CustomReferee handlers = {} server = SimpleNamespace( diff --git a/utama_core/tests/dashboard/test_strategies_view.py b/utama_core/tests/dashboard/test_strategies_view.py new file mode 100644 index 000000000..d7dac4574 --- /dev/null +++ b/utama_core/tests/dashboard/test_strategies_view.py @@ -0,0 +1,226 @@ +"""`utama_core.dashboard.views.strategies`: the Strategies tab's payloads, from a small fake `replays/`.""" + +from __future__ import annotations + +import json + +import pytest + +from utama_core.dashboard.views import strategies as view + + +def _write(path, payload): + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(json.dumps(payload)) + + +def _row(a, b, score_a, score_b, **extra): + return {"config_a": a, "config_b": b, "score_a": score_a, "score_b": score_b, "seed": 1, **extra} + + +@pytest.fixture +def replays(tmp_path): + """One finished evaluate.py run: mirage the candidate (dropped), the reference a frozen pendulum.""" + run = tmp_path / "eval_20261112_100000" + frozen = "replays/eval/frozen/pendulum@ab12cd34.strategy" + _write( + run / "round_1" / "summary.json", + { + "run_id": "eval_20261112_100000/round_1", + "round": 1, + "seed": 1, + "results": [ + _row("mirage", "wolfpack", 3, 1, stats={"stall_events": [{"t": 40.0}], "shots": 9}), + _row(frozen, "mirage", 2, 0), + _row("wolfpack", "mirage", 1, 1, reused=True), # played by an earlier run + ], + "strategies": { + "mirage": {"matches": 2, "goals_for": 3, "shots": 10, "stalled": 1}, + "wolfpack": {"matches": 1, "goals_for": 1, "shots": 4, "stalled": 0}, + frozen: {"matches": 1, "goals_for": 2, "shots": 8, "stalled": 0}, + }, + }, + ) + (run / "round_1" / "mirage_vs_wolfpack.npz").write_bytes(b"") + _write( + run / "report.json", + { + "run_id": "eval_20261112_100000", + "reference": frozen, + "candidates": { + "mirage": { + "verdict": "dropped", + "decided_in": "screen", + "rounds": 2, + "screen": {"n": 8, "mean": -1.2, "se": 0.4, "p": 0.99}, + "stalls": {"too": "big"}, + } + }, + }, + ) + return tmp_path + + +def _strategy(payload, name): + (s,) = [s for s in payload["strategies"] if s["name"] == name] + return s + + +def test_frozen_files_and_old_names_show_as_the_catalog_name(): + assert view.display_name("replays/eval/frozen/pendulum@ab12cd34.strategy") == "pendulum" + assert view.display_name("build_split_shape_kernel_strategy") == "pendulum" + assert view.display_name("high_press") == "wolfpack" + assert view.display_name("split_shape@cffe3a28") == "pendulum" # how evaluate.py records the reference + + +def test_the_summary_drops_the_name_and_the_boilerplate(): + doc = "`wolfpack` (until 2026-11-12 `high_press`): hunts the ball high up. The pickers only it uses are here." + assert view.summary_of(doc) == "Hunts the ball high up." + assert view.summary_of("Helpers shared by more than one strategy.") == "Helpers shared by more than one strategy." + + +def test_signals_come_from_a_real_round_not_a_newer_exhibition_match(replays, monkeypatch): + monkeypatch.setattr(view, "MIN_SIGNAL_MATCHES", 2) # mirage plays 2 in the fixture's round + _write( + replays / "tournament_20261113_000000" / "summary.json", + {"run_id": "tournament_20261113_000000", "results": [], "strategies": {"mirage": {"matches": 1, "shots": 99}}}, + ) + sig = _strategy(view.load_strategies(replays), "mirage")["signals"] + assert sig["run_id"] == "eval_20261112_100000/round_1" + + +def test_runs_are_newest_first_by_date_whatever_their_prefix(replays): + _write(replays / "tournament_20261110_000000" / "summary.json", {"run_id": "tournament_20261110_000000"}) + assert [r["run_id"] for r in view.load_runs(replays)] == ["eval_20261112_100000", "tournament_20261110_000000"] + + +def test_every_catalog_strategy_is_listed_once_with_its_role(replays): + payload = view.load_strategies(replays) + names = [s["name"] for s in payload["strategies"]] + assert sorted(names) == sorted(set(names)) and "pendulum" in names + assert _strategy(payload, payload["champion"])["role"] == "champion" + assert {_strategy(payload, n)["role"] for n in payload["core"] if n != payload["champion"]} == {"core"} + assert not any(n.endswith(".strategy") for n in names) + + +def test_a_strategy_carries_its_description_file_and_tactics(replays): + wolfpack = _strategy(view.load_strategies(replays), "wolfpack") + assert wolfpack["summary"] and wolfpack["file"] == "utama_core/strategy/wolfpack.py" + assert {"GiveAndGoTactic", "PressAndContainTactic"} <= {t["name"] for t in wolfpack["tactics"]} + assert "high_press" in wolfpack["old_names"] + + +def test_a_candidates_verdict_is_shown_against_the_champion_by_name(replays): + (v,) = _strategy(view.load_strategies(replays), "mirage")["verdicts"] + assert (v["verdict"], v["decided_in"], v["rounds"], v["mean"], v["n"]) == ("dropped", "screen", 2, -1.2, 8) + assert v["reference"] == "pendulum" and v["date"] == "2026-11-12" + + +def test_matches_are_from_the_strategys_side_with_their_replays_and_reused_ones_once(replays): + matches = _strategy(view.load_strategies(replays), "mirage")["matches"] + assert sorted((m["opponent"], tuple(m["score"])) for m in matches) == [ + ("pendulum (last release)", (0, 2)), + ("wolfpack", (3, 1)), + ] + by_opponent = {m["opponent"]: m["replay"] for m in matches} + assert by_opponent["wolfpack"] == "eval_20261112_100000/round_1/mirage_vs_wolfpack.npz" + assert by_opponent["pendulum (last release)"] is None # no replay file in the fixture + + +def test_a_frozen_files_replay_is_found_under_the_name_evaluate_saves_it_as(replays): + (replays / "eval_20261112_100000" / "round_1" / "pendulum@ab12cd34_vs_mirage.npz").write_bytes(b"") + matches = _strategy(view.load_strategies(replays), "mirage")["matches"] + (m,) = [m for m in matches if m["opponent"] == "pendulum (last release)"] + assert m["replay"] == "eval_20261112_100000/round_1/pendulum@ab12cd34_vs_mirage.npz" + + +def test_todays_strategy_against_its_last_release_is_listed(replays): + path = replays / "eval_20261112_100000" / "round_1" / "summary.json" + summary = json.loads(path.read_text()) + summary["results"].append(_row("replays/eval/frozen/pendulum@ab12cd34.strategy", "pendulum", 0, 4)) + _write(path, summary) + (m,) = _strategy(view.load_strategies(replays), "pendulum")["matches"] + assert (m["opponent"], m["score"]) == ("pendulum (last release)", [4, 0]) + + +def test_the_tests_minimal_strategy_is_not_listed(replays): + assert "default" not in [s["name"] for s in view.load_strategies(replays)["strategies"]] + + +def test_the_frozen_files_matches_are_not_todays_strategys(replays): + assert _strategy(view.load_strategies(replays), "pendulum")["matches"] == [] + + +def test_signals_are_per_match_beside_the_other_strategies_average(replays): + sig = _strategy(view.load_strategies(replays), "mirage")["signals"] + rows = {r["key"]: r for r in sig["rows"]} + assert rows["shots"]["value"] == 5.0 # 10 shots in 2 matches + assert rows["shots"]["field"] == 4.0 # wolfpack; the frozen pendulum file is not in the field + assert rows["stalled"]["value"] == 0.5 + assert rows["fouls"]["value"] is None # not in this round's table + + +def test_a_run_groups_its_rounds_and_its_report_without_the_bulky_stalls(replays): + (run,) = view.load_runs(replays) + assert run["run_id"] == "eval_20261112_100000" and run["reference"] == "pendulum" + assert run["report"]["candidates"]["mirage"]["verdict"] == "dropped" + assert "stalls" not in run["report"]["candidates"]["mirage"] + results = run["rounds"][0]["results"] + assert [r["display_a"] for r in results] == ["mirage", "pendulum (last release)", "wolfpack"] + # only the stall flag of each match's stats is sent: the full stats are megabytes over all runs + assert [r["stalled"] for r in results] == [True, False, False] + assert not any("stats" in r for r in results) + + +def test_an_older_round_robin_is_one_round_and_finds_side_tagged_replays(tmp_path): + run = tmp_path / "tournament_1" + _write( + run / "summary.json", + {"run_id": "tournament_1", "results": [_row("a", "b", 1, 0, a_is_right=False, a_kicks_off=True)]}, + ) + (run / "a_vs_b_LK.pkl").write_bytes(b"") + (loaded,) = view.load_runs(tmp_path) + assert loaded["report"] is None + assert loaded["rounds"][0]["results"][0]["replay"] == "tournament_1/a_vs_b_LK.pkl" + + +def test_no_replays_folder_gives_empty_pages(tmp_path): + assert view.load_runs(tmp_path / "missing") == [] + assert all(not s["matches"] for s in view.load_strategies(tmp_path / "missing")["strategies"]) + + +class _Job: + def __init__(self, done=False): + self.done = done + + def poll(self): + return 0 if self.done else None + + +def test_maps_start_once_in_the_background_then_come_back_by_catalog_name(replays, monkeypatch): + monkeypatch.setattr(view, "_jobs", {}) + started = [] + start = lambda cmd, **kw: started.append(cmd) or _Job() # noqa: E731 + round_id = "eval_20261112_100000/round_1" + assert view.maps_of(round_id, replays, start)["status"] == "computing" + assert view.maps_of(round_id, replays, start)["status"] == "computing" + assert len(started) == 1 and "--data" in started[0] + _write( + replays / round_id / view.MAPS_FILE, + {"vmax": {"attack": 0.1}, "strategies": {"high_press": {"shots": {}}, "pendulum@ab12cd34": {"shots": {}}}}, + ) + maps = view.maps_of(round_id, replays, start) + assert maps["status"] == "ready" and maps["vmax"] == {"attack": 0.1} + assert list(maps["strategies"]) == ["wolfpack"] # renamed; the frozen file left out + + +def test_maps_report_a_failed_job_once_then_retry(replays, monkeypatch): + round_dir = (replays / "eval_20261112_100000" / "round_1").resolve() + monkeypatch.setattr(view, "_jobs", {round_dir: _Job(done=True)}) + assert view.maps_of("eval_20261112_100000/round_1", replays, lambda cmd, **kw: _Job())["status"] == "failed" + assert view.maps_of("eval_20261112_100000/round_1", replays, lambda cmd, **kw: _Job())["status"] == "computing" + + +def test_maps_never_leave_the_replays_folder(replays): + assert view.maps_of("../../etc", replays)["status"] == "missing" + assert view.maps_of("eval_20261112_100000/round_9", replays)["status"] == "missing" diff --git a/utama_core/tests/dashboard/test_tournament_view.py b/utama_core/tests/dashboard/test_tournament_view.py deleted file mode 100644 index 0eaec05d1..000000000 --- a/utama_core/tests/dashboard/test_tournament_view.py +++ /dev/null @@ -1,52 +0,0 @@ -"""Tests for `utama_core.dashboard.views.tournament`'s `/tournament/runs` payload.""" - -from __future__ import annotations - -import json - -from utama_core.dashboard.views import tournament as tournament_view - - -def _write_run(root, results): - run = root / "tournament_1" - run.mkdir() - (run / "summary.json").write_text(json.dumps({"run_id": "tournament_1", "results": results})) - return run - - -def test_each_match_carries_the_path_of_its_replay_when_the_file_exists(tmp_path, monkeypatch): - # round_robin.py names a replay "_vs_.npz"; the dashboard must not guess - # another runner's naming and link to a file that isn't there - run = _write_run( - tmp_path, - [ - {"config_a": "build_low_block_kernel_strategy", "config_b": "build_three_slot_kernel_strategy"}, - {"config_a": "build_tiki_taka_kernel_strategy", "config_b": "build_counter_flow_kernel_strategy"}, - ], - ) - (run / "low_block_vs_three_slot.npz").write_bytes(b"") - monkeypatch.setattr(tournament_view, "REPLAY_BASE_PATH", tmp_path) - - (loaded,) = tournament_view._load_runs() - - assert [r["replay"] for r in loaded["results"]] == ["tournament_1/low_block_vs_three_slot.npz", None] - - -def test_replays_with_side_and_kickoff_tags_are_found(tmp_path, monkeypatch): - run = _write_run( - tmp_path, - [ - { - "config_a": "build_a_kernel_strategy", - "config_b": "build_b_kernel_strategy", - "a_is_right": False, - "a_kicks_off": True, - } - ], - ) - (run / "a_vs_b_LK.pkl").write_bytes(b"") - monkeypatch.setattr(tournament_view, "REPLAY_BASE_PATH", tmp_path) - - (loaded,) = tournament_view._load_runs() - - assert loaded["results"][0]["replay"] == "tournament_1/a_vs_b_LK.pkl" diff --git a/utama_core/tests/refiners/one_camera_ball_repro.json b/utama_core/tests/data_processing/one_camera_ball_repro.json similarity index 100% rename from utama_core/tests/refiners/one_camera_ball_repro.json rename to utama_core/tests/data_processing/one_camera_ball_repro.json diff --git a/utama_core/tests/refiners/camera_combiner_test.py b/utama_core/tests/data_processing/test_camera_combiner.py similarity index 100% rename from utama_core/tests/refiners/camera_combiner_test.py rename to utama_core/tests/data_processing/test_camera_combiner.py diff --git a/utama_core/tests/refiners/kalman_test.py b/utama_core/tests/data_processing/test_kalman.py similarity index 100% rename from utama_core/tests/refiners/kalman_test.py rename to utama_core/tests/data_processing/test_kalman.py diff --git a/utama_core/tests/refiners/test_local_camera_consistency.py b/utama_core/tests/data_processing/test_local_camera_consistency.py similarity index 100% rename from utama_core/tests/refiners/test_local_camera_consistency.py rename to utama_core/tests/data_processing/test_local_camera_consistency.py diff --git a/utama_core/tests/refiners/position_refiner_integration_test.py b/utama_core/tests/data_processing/test_position_refiner_integration.py similarity index 100% rename from utama_core/tests/refiners/position_refiner_integration_test.py rename to utama_core/tests/data_processing/test_position_refiner_integration.py diff --git a/utama_core/tests/refiners/position_unit_test.py b/utama_core/tests/data_processing/test_position_unit.py similarity index 100% rename from utama_core/tests/refiners/position_unit_test.py rename to utama_core/tests/data_processing/test_position_unit.py diff --git a/utama_core/tests/receivers/referee_receiver_test.py b/utama_core/tests/data_processing/test_referee_receiver.py similarity index 94% rename from utama_core/tests/receivers/referee_receiver_test.py rename to utama_core/tests/data_processing/test_referee_receiver.py index 7c92cbb74..50e29b71f 100644 --- a/utama_core/tests/receivers/referee_receiver_test.py +++ b/utama_core/tests/data_processing/test_referee_receiver.py @@ -4,9 +4,7 @@ from utama_core.data_processing.receivers import referee_receiver from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.team_controller.src.generated_code.ssl_gc_referee_message_pb2 import ( - Referee, -) +from utama_core.team_controller.generated_code.ssl_gc_referee_message_pb2 import Referee def _packet() -> bytes: diff --git a/utama_core/tests/refiners/robot_info_test.py b/utama_core/tests/data_processing/test_robot_info.py similarity index 100% rename from utama_core/tests/refiners/robot_info_test.py rename to utama_core/tests/data_processing/test_robot_info.py diff --git a/utama_core/tests/refiners/velocity_test.py b/utama_core/tests/data_processing/test_velocity.py similarity index 100% rename from utama_core/tests/refiners/velocity_test.py rename to utama_core/tests/data_processing/test_velocity.py diff --git a/utama_core/tests/receivers/vision_receiver_integration_test.py b/utama_core/tests/data_processing/test_vision_receiver_integration.py similarity index 100% rename from utama_core/tests/receivers/vision_receiver_integration_test.py rename to utama_core/tests/data_processing/test_vision_receiver_integration.py diff --git a/utama_core/tests/receivers/vision_receiver_unit_test.py b/utama_core/tests/data_processing/test_vision_receiver_unit.py similarity index 98% rename from utama_core/tests/receivers/vision_receiver_unit_test.py rename to utama_core/tests/data_processing/test_vision_receiver_unit.py index ecdb5e10c..4b99dab15 100644 --- a/utama_core/tests/receivers/vision_receiver_unit_test.py +++ b/utama_core/tests/data_processing/test_vision_receiver_unit.py @@ -8,7 +8,7 @@ RawRobotData, VisionReceiver, ) -from utama_core.team_controller.src.generated_code.ssl_vision_wrapper_pb2 import ( +from utama_core.team_controller.generated_code.ssl_vision_wrapper_pb2 import ( SSL_WrapperPacket, ) diff --git a/utama_core/tests/abstract_strategy/test_assertions.py b/utama_core/tests/engine/test_abstract_strategy_assertions.py similarity index 95% rename from utama_core/tests/abstract_strategy/test_assertions.py rename to utama_core/tests/engine/test_abstract_strategy_assertions.py index 0891bc382..8f7afcefa 100644 --- a/utama_core/tests/abstract_strategy/test_assertions.py +++ b/utama_core/tests/engine/test_abstract_strategy_assertions.py @@ -11,7 +11,7 @@ from utama_core.config.field_params import STANDARD_FIELD_DIMS from utama_core.engine.abstract_strategy import AbstractStrategy, SpaceRequirements from utama_core.entities.game.field import Field, FieldBounds -from utama_core.strategy.kernel_strategy import build_default_kernel_strategy +from utama_core.strategy.catalog import builder def make_dummy_game(field_bounds): @@ -22,7 +22,7 @@ class _Game: def _strategy(min_bb) -> AbstractStrategy: - strategy = AbstractStrategy(build_kernel_strategy=build_default_kernel_strategy(())) + strategy = AbstractStrategy(build=builder("default", ())) strategy.get_min_bounding_req = lambda: min_bb return strategy diff --git a/utama_core/tests/engine/test_all_strategy_configs.py b/utama_core/tests/engine/test_all_strategy_configs.py index 6453eac44..c0bc89c91 100644 --- a/utama_core/tests/engine/test_all_strategy_configs.py +++ b/utama_core/tests/engine/test_all_strategy_configs.py @@ -1,22 +1,20 @@ -"""Comprehensive, table-driven tests over every `build_*_kernel_strategy` factory -re-exported by `utama_core/strategy/kernel_strategy.py`. +"""Comprehensive, table-driven tests over every strategy +in `utama_core/strategy/`. -Replaces the earlier one-file-per-config pattern (`test_split_shape_kernel_strategy.py`, -`test_press_and_pass_kernel_strategy.py`, `test_high_press_kernel_strategy.py`, -`test_low_block_kernel_strategy.py`, `test_three_slot_kernel_strategy.py`, -`test_give_and_go_solo_kernel_strategy.py`), each of which re-asserted the same +Replaces the earlier one-file-per-config pattern (`test_pendulum_kernel_strategy.py`, +`test_terrier_kernel_strategy.py`, `test_wolfpack_kernel_strategy.py`, +`test_ricochet_kernel_strategy.py`), each of which re-asserted the same handful of generic properties ("builds a Strategy", "runs N ticks without error", "partition covers every outfield robot", "goalkeeper stays pinned") around a near-identical `StrategyRunner`/rsim fixture. A single parametrized suite over `_CONFIGS` gives the same coverage without the duplication. Does not replace `test_kernel_strategy.py` (tests the `AbstractStrategy` -adapter/blackboard wiring itself, via `build_default_kernel_strategy` as one +adapter/blackboard wiring itself, via `default` as one convenient example config — not "does this config's partition behave correctly") or `test_kernel_strategy_debug_status.py` (tests `debug_status()` mechanics specifically). Picker-level unit tests that don't need rsim at all -(e.g. `fixed_ratio_picker`'s exact split ratios, `_three_way_picker`'s slot -allocation) also stay separate, below, since they're cheap, precise, and +(e.g. `fixed_ratio_picker`'s exact split ratios) also stay separate, below, since they're cheap, precise, and don't belong in a `StrategyRunner`-driven table. """ @@ -29,38 +27,18 @@ from utama_core.engine.abstract_strategy import AbstractStrategy from utama_core.engine.strategy import Strategy from utama_core.entities.data.object import TeamType -from utama_core.strategy import kernel_strategy -from utama_core.strategy.kernel_strategy import ( - _clear_danger_picker, - _clear_press_plus_picker, - _counter_flow_picker, - _counter_press_picker, - _three_way_picker, - _tiki_taka_picker, - _zone_flow_picker, - build_clear_danger_kernel_strategy, - build_counter_press_kernel_strategy, - build_decoy_and_overload_kernel_strategy, - build_give_and_go_solo_kernel_strategy, - build_high_press_kernel_strategy, - build_low_block_kernel_strategy, - build_press_and_pass_kernel_strategy, - build_split_shape_kernel_strategy, - build_three_slot_kernel_strategy, - build_tiki_taka_kernel_strategy, - build_zone_fluid_kernel_strategy, - fixed_ratio_picker, -) +from utama_core.strategy import catalog +from utama_core.strategy.breakwater import _breakwater_picker +from utama_core.strategy.catalog import builder +from utama_core.strategy.firebreak import _firebreak_picker +from utama_core.strategy.pickers import fixed_ratio_picker +from utama_core.strategy.riptide import _riptide_picker _OUTFIELD_IDS = (1, 2, 3, 4, 5) -# Every factory `kernel_strategy` re-exports, as round-robins discover them, so a new strategy is -# covered without editing this file (a strategy branch can't: see tools/check_strategy_branch.py). -_CONFIGS = [ - pytest.param(getattr(kernel_strategy, name), id=name.removeprefix("build_").removesuffix("_kernel_strategy")) - for name in sorted(dir(kernel_strategy)) - if name.startswith("build_") and name.endswith("_kernel_strategy") and name != "build_default_kernel_strategy" -] +# Every strategy, as round-robins discover them, so a new one is covered without editing this +# file (a strategy branch can't: see tools/dev/check_strategy_branch.py). +_CONFIGS = [pytest.param(name, id=name) for name in catalog.player_names()] @pytest.fixture @@ -69,8 +47,8 @@ def make_runner(): made = [] - def _make(build_kernel_strategy_factory): - strategy = AbstractStrategy(build_kernel_strategy=build_kernel_strategy_factory(_OUTFIELD_IDS)) + def _make(name): + strategy = AbstractStrategy(build=catalog.builder(name, _OUTFIELD_IDS)) r = StrategyRunner( strategy=strategy, my_team_is_yellow=True, @@ -88,13 +66,13 @@ def _make(build_kernel_strategy_factory): r.close() -@pytest.mark.parametrize("build_factory", _CONFIGS) -def test_partitions_every_outfield_robot_and_never_the_keeper_for_30_ticks(build_factory, make_runner): +@pytest.mark.parametrize("name", _CONFIGS) +def test_partitions_every_outfield_robot_and_never_the_keeper_for_30_ticks(name, make_runner): """30 ticks, not 5-10: enough for PressAndContainTactic's applicable() to plausibly flip in configs that use it, exercising the exact hazard - `_press_and_pass_split_picker`/`_three_way_picker` exist to avoid (a + `_terrier_split_picker`/`_three_way_picker` exist to avoid (a Partitioner proposing robots for a currently-inapplicable tactic).""" - runner = make_runner(build_factory) + runner = make_runner(name) strategy = runner.my.strategy assert isinstance(strategy._kernel_strategy, Strategy) assert strategy._goalkeeper_id == 0 @@ -112,7 +90,7 @@ def test_partitions_every_outfield_robot_and_never_the_keeper_for_30_ticks(build _NOBODY_ON_BALL = SimpleNamespace(friendly_robots={}) -def test_fixed_ratio_picker_high_press_split(): +def test_fixed_ratio_picker_wolfpack_split(): picker = fixed_ratio_picker("attack", "defense", attack_fraction=0.8) partition = picker( game=_NOBODY_ON_BALL, @@ -124,11 +102,11 @@ def test_fixed_ratio_picker_high_press_split(): assert len(partition["defense"]) == 1 -def test_fixed_ratio_picker_low_block_split_respects_min_attack_floor(): +def test_fixed_ratio_picker_defense_heavy_split_respects_min_attack_floor(): """attack_fraction=0.2 on 5 robots rounds to 1, but PassAndShootTactic hard-requires >=2 (it unconditionally reads robot_ids[1]) — min_attack=2 - floors the split rather than letting `build_low_block_kernel_strategy` - crash the tactic it wires (the exact regression this test guards).""" + floors the split rather than letting a defense-heavy + split crash the tactic it wires (the exact regression this test guards).""" picker = fixed_ratio_picker("attack", "defense", attack_fraction=0.2, min_attack=2) partition = picker( game=_NOBODY_ON_BALL, @@ -140,68 +118,8 @@ def test_fixed_ratio_picker_low_block_split_respects_min_attack_floor(): assert len(partition["defense"]) == 3 -def test_three_way_picker_splits_all_three_slots_when_all_applicable(): - partition = _three_way_picker( - game=_NOBODY_ON_BALL, - free_robots=frozenset({1, 2, 3, 4, 5}), - prev_partition=None, - available_tactic_ids=frozenset({"press", "mark", "attack"}), - ) - assert len(partition["press"]) == 1 - assert len(partition["mark"]) == 2 - assert len(partition["attack"]) == 2 - assert frozenset().union(*partition.values()) == frozenset({1, 2, 3, 4, 5}) - - -def _holder_game(holder_id): - """A still ball in one robot's dribbler; nobody else near it.""" - return SimpleNamespace( - ball=SimpleNamespace(p=SimpleNamespace(x=0.0, y=0.0), v=SimpleNamespace(x=0.0, y=0.0)), - friendly_robots={ - rid: SimpleNamespace(has_ball=rid == holder_id, p=SimpleNamespace(x=-1.0 - rid, y=0.0)) - for rid in range(1, 6) - }, - enemy_robots={}, - ) - - -def test_three_way_picker_gives_the_ball_holder_to_attack_not_press_or_mark(): - # three_slot_vs_zone_fluid (2026-10-05) t=87.8: the taker of our free kick sat in "mark" and - # `kick_upfield` sent the ball the length of the pitch and out; 24 such kicks a match went to - # the presser or a shadow. The holder attacks, whichever slots are open. - for open_slots in ({"press", "mark", "attack"}, {"mark", "attack"}, {"press", "attack"}): - partition = _three_way_picker( - game=_holder_game(holder_id=5), - free_robots=frozenset({1, 2, 3, 4, 5}), - prev_partition=None, - available_tactic_ids=frozenset(open_slots), - ) - assert 5 in partition["attack"], open_slots - assert frozenset().union(*partition.values()) == frozenset({1, 2, 3, 4, 5}) - - -def test_three_way_picker_keeps_the_holder_in_press_when_attack_is_unavailable(): - partition = _three_way_picker( - game=_holder_game(holder_id=5), - free_robots=frozenset({1, 2, 3, 4, 5}), - prev_partition=None, - available_tactic_ids=frozenset({"press", "mark"}), - ) - assert partition["press"] == frozenset({5}) - - -def test_three_way_picker_falls_back_to_attack_when_press_and_mark_inapplicable(): - partition = _three_way_picker( - game=_NOBODY_ON_BALL, - free_robots=frozenset({1, 2, 3}), - prev_partition=None, - available_tactic_ids=frozenset({"attack"}), - ) - assert partition == {"attack": frozenset({1, 2, 3})} - - -def test_give_and_go_solo_always_assigns_everyone_to_attack(make_runner): - runner = make_runner(build_give_and_go_solo_kernel_strategy) +def test_ricochet_always_assigns_everyone_to_attack(make_runner): + runner = make_runner("ricochet") runner.step_once() partition = runner.my.strategy._kernel_strategy.active_partition assert partition == {"attack": frozenset(_OUTFIELD_IDS)} @@ -243,160 +161,15 @@ def _stub_game(friendly_dist, enemy_dist, ball_x: float, my_team_is_right: bool _FIVE = frozenset({1, 2, 3, 4, 5}) -_ALL = frozenset({"attack", "defense", "press", "givego", "overload", "block"}) - - -def test_tiki_taka_attacks_with_three_when_ball_is_ours(): - partition = _tiki_taka_picker( - _stub_game(friendly_dist=0.2, enemy_dist=1.5, ball_x=0.0), - _FIVE, - None, - _ALL, - ) - assert len(partition["attack"]) == 3 - assert len(partition["defense"]) == 2 - assert frozenset().union(*partition.values()) == _FIVE - - -def test_tiki_taka_presses_with_three_when_ball_is_lost(): - partition = _tiki_taka_picker( - _stub_game(friendly_dist=1.5, enemy_dist=0.2, ball_x=0.0), - _FIVE, - None, - _ALL, - ) - assert len(partition["press"]) == 3 - assert len(partition["defense"]) == 2 - - -def test_tiki_taka_unknown_edge_falls_back_to_conservative_press(): - # Unknown possession edge (both None) must not send everyone forward. - partition = _tiki_taka_picker( - _stub_game(friendly_dist=None, enemy_dist=None, ball_x=0.0), - _FIVE, - None, - _ALL, - ) - assert len(partition["press"]) == 3 - assert len(partition["defense"]) == 2 - - -def test_tiki_taka_press_inapplicable_covers_with_defense(): - partition = _tiki_taka_picker( - _stub_game(friendly_dist=1.5, enemy_dist=0.2, ball_x=0.0), - _FIVE, - None, - frozenset({"attack", "defense"}), # press out of pressing range - ) - assert partition == {"defense": _FIVE} - - -def test_tiki_taka_attack_pinned_folds_share_into_defense(): - # Give-and-go committed mid-hop: its robots are pinned (not in the free - # pool) and "attack" never appears in available_tactic_ids — everyone - # free must still land in a legal slot. - partition = _tiki_taka_picker( - _stub_game(friendly_dist=0.2, enemy_dist=1.5, ball_x=-3.0), - _FIVE, - None, - frozenset({"defense", "press"}), - ) - assert partition == {"defense": _FIVE} - - -def test_counter_press_everyone_presses_when_lost(): - partition = _counter_press_picker( - _stub_game(friendly_dist=2.0, enemy_dist=0.3, ball_x=0.0), - _FIVE, - None, - _ALL, - ) - assert partition == {"press": _FIVE} - - -def test_counter_press_drops_into_low_block_when_nothing_to_press(): - partition = _counter_press_picker( - _stub_game(friendly_dist=2.0, enemy_dist=0.3, ball_x=0.0), - _FIVE, - None, - frozenset({"attack", "block"}), # opponent shielded from the press - ) - assert partition == {"block": _FIVE} - - -def test_counter_press_attacks_with_four_and_one_screen_when_won(): - partition = _counter_press_picker( - _stub_game(friendly_dist=0.3, enemy_dist=2.0, ball_x=-3.0), - _FIVE, - None, - _ALL, - ) - assert len(partition["attack"]) == 4 - assert len(partition["block"]) == 1 - - -def test_counter_press_won_ball_without_block_sends_all_five_forward(): - partition = _counter_press_picker( - _stub_game(friendly_dist=0.3, enemy_dist=2.0, ball_x=-3.0), - _FIVE, - None, - frozenset({"attack", "press"}), - ) - assert partition == {"attack": _FIVE} - - -def test_zone_flow_everyone_takes_shape_when_ball_lost(): - partition = _zone_flow_picker( - _stub_game(friendly_dist=2.0, enemy_dist=0.3, ball_x=0.0), - _FIVE, - None, - _ALL, - ) - assert partition == {"defense": _FIVE} - - -def test_zone_flow_givego_trio_builds_up_in_middle_third(): - partition = _zone_flow_picker( - _stub_game(friendly_dist=0.3, enemy_dist=2.0, ball_x=0.0), # mid third - _FIVE, - None, - _ALL, - ) - assert len(partition["givego"]) == 3 - assert len(partition["defense"]) == 2 - - -def test_zone_flow_overload_pair_swaps_in_for_final_third(): - partition = _zone_flow_picker( - _stub_game(friendly_dist=0.3, enemy_dist=2.0, ball_x=-3.0), # final third - _FIVE, - None, - _ALL, - ) - assert partition["overload"] == frozenset({1, 2}) - assert len(partition["defense"]) == 3 - - -def test_zone_flow_overload_pinned_builds_with_givego_instead(): - partition = _zone_flow_picker( - _stub_game(friendly_dist=0.3, enemy_dist=2.0, ball_x=-3.0), # final third - _FIVE, - None, - frozenset({"givego", "defense"}), # decoy/overload duet elsewhere - ) - assert len(partition["givego"]) == 3 - assert len(partition["defense"]) == 2 - -# --- clear-danger picker unit tests (danger valve + counter_flow postures) --- _CLEAR_ALL = frozenset({"attack", "press", "block", "clear"}) -def test_clear_danger_valve_takes_one_robot_when_applicable(): +def test_firebreak_valve_takes_one_robot_when_applicable(): """Danger read fires (kernel reports 'clear' applicable): 1 clearer + block screen with the rest, regardless of the possession edge.""" - partition = _clear_danger_picker( + partition = _firebreak_picker( _stub_game(friendly_dist=2.0, enemy_dist=0.3, ball_x=3.0), # losing, deep _FIVE, None, @@ -407,8 +180,8 @@ def test_clear_danger_valve_takes_one_robot_when_applicable(): assert frozenset().union(*partition.values()) == _FIVE -def test_clear_danger_valve_folds_everyone_in_when_block_unavailable(): - partition = _clear_danger_picker( +def test_firebreak_valve_folds_everyone_in_when_block_unavailable(): + partition = _firebreak_picker( _stub_game(friendly_dist=2.0, enemy_dist=0.3, ball_x=3.0), _FIVE, None, @@ -417,8 +190,8 @@ def test_clear_danger_valve_folds_everyone_in_when_block_unavailable(): assert partition == {"clear": _FIVE} -def test_clear_danger_uses_counter_flow_press_posture_when_lost_no_danger(): - partition = _clear_danger_picker( +def test_firebreak_uses_riptide_press_posture_when_lost_no_danger(): + partition = _firebreak_picker( _stub_game(friendly_dist=1.5, enemy_dist=0.2, ball_x=0.0), _FIVE, None, @@ -428,8 +201,8 @@ def test_clear_danger_uses_counter_flow_press_posture_when_lost_no_danger(): assert len(partition["block"]) == 2 -def test_clear_danger_attacks_with_three_when_won_no_danger(): - partition = _clear_danger_picker( +def test_firebreak_attacks_with_three_when_won_no_danger(): + partition = _firebreak_picker( _stub_game(friendly_dist=0.3, enemy_dist=1.5, ball_x=0.0), _FIVE, None, @@ -439,12 +212,12 @@ def test_clear_danger_attacks_with_three_when_won_no_danger(): assert len(partition["block"]) == 2 -def test_clear_danger_attack_stays_on_unknown_possession_edge(): - """Sticky possession edge (same fix counter_flow/high_line_zone needed): +def test_firebreak_attack_stays_on_unknown_possession_edge(): + """Sticky possession edge (same fix riptide/high_line_zone needed): while we held attack last tick, an unreadable edge must not reset the give-and-go trio — only a clear loss (enemy strictly closer) does.""" prev = {"attack": frozenset({1, 2, 3}), "block": frozenset({4, 5})} - partition = _clear_danger_picker( + partition = _firebreak_picker( _stub_game(friendly_dist=None, enemy_dist=None, ball_x=0.0), _FIVE, prev, @@ -453,11 +226,11 @@ def test_clear_danger_attack_stays_on_unknown_possession_edge(): assert len(partition["attack"]) == 3 -def test_clear_danger_valve_overrides_standing_attack(): +def test_firebreak_valve_overrides_standing_attack(): """Danger fires while we were attacking last tick: the valve still takes its robot — danger is depth+pressure, not just possession.""" prev = {"attack": frozenset({1, 2, 3}), "block": frozenset({4, 5})} - partition = _clear_danger_picker( + partition = _firebreak_picker( _stub_game(friendly_dist=0.5, enemy_dist=1.5, ball_x=3.0), # we're closer BUT deep+contested _FIVE, prev, @@ -476,10 +249,10 @@ def test_clear_danger_valve_overrides_standing_attack(): # picker now decides from the possession edge alone. -def test_clear_danger_ignores_a_prior_clear_robot_missing_from_the_free_pool(): +def test_firebreak_ignores_a_prior_clear_robot_missing_from_the_free_pool(): free = frozenset({2, 3, 4, 5}) # robot 1 held "clear" last tick, is not free now prev = {"clear": frozenset({1})} - partition = _clear_danger_picker( + partition = _firebreak_picker( _stub_game(friendly_dist=0.2, enemy_dist=1.5, ball_x=0.0), # we're closer: attack free, prev, @@ -489,10 +262,10 @@ def test_clear_danger_ignores_a_prior_clear_robot_missing_from_the_free_pool(): assert len(partition["block"]) == 1 -def test_clear_press_plus_ignores_a_prior_clear_robot_missing_from_the_free_pool(): +def test_breakwater_ignores_a_prior_clear_robot_missing_from_the_free_pool(): free = frozenset({2, 3, 4, 5}) prev = {"clear": frozenset({1})} - partition = _clear_press_plus_picker( + partition = _breakwater_picker( _stub_game(friendly_dist=0.2, enemy_dist=1.5, ball_x=0.0), free, prev, @@ -517,13 +290,13 @@ def _clear_game(positions: dict[int, tuple[float, float]], carrier: int | None = _SPREAD = {1: (-2.0, 1.0), 2: (0.0, -1.0), 3: (1.0, 1.0), 4: (2.7, 0.2), 5: (-1.0, 0.0)} -def test_clear_danger_valve_goes_to_the_robot_nearest_the_ball(): - partition = _clear_danger_picker(_clear_game(_SPREAD), _FIVE, None, _CLEAR_ALL) +def test_firebreak_valve_goes_to_the_robot_nearest_the_ball(): + partition = _firebreak_picker(_clear_game(_SPREAD), _FIVE, None, _CLEAR_ALL) assert partition["clear"] == frozenset({4}) -def test_clear_press_plus_valve_goes_to_the_robot_nearest_the_ball(): - partition = _clear_press_plus_picker(_clear_game(_SPREAD), _FIVE, None, _CLEAR_ALL | {"overload"}) +def test_breakwater_valve_goes_to_the_robot_nearest_the_ball(): + partition = _breakwater_picker(_clear_game(_SPREAD), _FIVE, None, _CLEAR_ALL | {"overload"}) assert partition["clear"] == frozenset({4}) @@ -531,13 +304,13 @@ def test_clear_valve_keeps_the_carrier_even_when_another_robot_is_nearer(): # Robot 2 holds the ball (so it is first from `carrier_first`); robot 4 happens to # be nearer the ball's reported position. The carrier keeps the clearance. game = _clear_game(_SPREAD, carrier=2) - assert _clear_danger_picker(game, _FIVE, None, _CLEAR_ALL)["clear"] == frozenset({2}) - assert _clear_press_plus_picker(game, _FIVE, None, _CLEAR_ALL | {"overload"})["clear"] == frozenset({2}) + assert _firebreak_picker(game, _FIVE, None, _CLEAR_ALL)["clear"] == frozenset({2}) + assert _breakwater_picker(game, _FIVE, None, _CLEAR_ALL | {"overload"})["clear"] == frozenset({2}) def test_clear_valve_breaks_a_distance_tie_by_lowest_id(): tied = {1: (2.0, 1.0), 2: (2.0, -1.0), 3: (-2.0, 0.0), 4: (-2.0, 1.0), 5: (-2.0, -1.0)} - partition = _clear_danger_picker(_clear_game(tied), _FIVE, None, _CLEAR_ALL) + partition = _firebreak_picker(_clear_game(tied), _FIVE, None, _CLEAR_ALL) assert partition["clear"] == frozenset({1}) @@ -546,28 +319,28 @@ def test_clear_valve_breaks_a_distance_tie_by_lowest_id(): _COUNTER_FLOW_ALL = frozenset({"attack", "press", "block"}) -def test_counter_flow_keeps_attack_through_a_near_tie_for_the_ball(): +def test_riptide_keeps_attack_through_a_near_tie_for_the_ball(): """Friendly 3 cm behind the nearest enemy is inside `CLOSER_TO_BALL_MARGIN`: undecided, so a side that held attack last tick keeps it (the documented hysteresis). `friendly_closer_to_ball` used to return False here, which dropped attack on noise-level gaps.""" prev = {"attack": frozenset({1, 2, 3}), "block": frozenset({4, 5})} - partition = _counter_flow_picker( + partition = _riptide_picker( _stub_game(friendly_dist=0.33, enemy_dist=0.30, ball_x=0.0), _FIVE, prev, _COUNTER_FLOW_ALL ) assert len(partition["attack"]) == 3 -def test_counter_flow_without_prior_attack_stays_conservative_on_a_near_tie(): - partition = _counter_flow_picker( +def test_riptide_without_prior_attack_stays_conservative_on_a_near_tie(): + partition = _riptide_picker( _stub_game(friendly_dist=0.33, enemy_dist=0.30, ball_x=0.0), _FIVE, {}, _COUNTER_FLOW_ALL ) assert "attack" not in partition -def test_counter_flow_drops_attack_on_a_clear_loss(): +def test_riptide_drops_attack_on_a_clear_loss(): prev = {"attack": frozenset({1, 2, 3}), "block": frozenset({4, 5})} - partition = _counter_flow_picker( + partition = _riptide_picker( _stub_game(friendly_dist=0.5, enemy_dist=0.30, ball_x=0.0), _FIVE, prev, _COUNTER_FLOW_ALL ) assert "attack" not in partition diff --git a/utama_core/tests/engine/test_all_tactics.py b/utama_core/tests/engine/test_all_tactics.py index 839b7ffc6..6bdbae813 100644 --- a/utama_core/tests/engine/test_all_tactics.py +++ b/utama_core/tests/engine/test_all_tactics.py @@ -8,7 +8,7 @@ near-identical boilerplate around a real `StrategyRunner`/rsim fixture. A single parametrized suite over `_TACTIC_CASES` below gives the same coverage without the duplication, and — concretely — would have caught -`PassAndShootTactic`'s `robot_ids[1]` crash (see `build_low_block_kernel_strategy` +`PassAndShootTactic`'s `robot_ids[1]` crash (see `low_block` in `strategy/low_block.py`) automatically instead of requiring a bespoke test to notice a Tactic has an undeclared minimum robot count. @@ -58,7 +58,7 @@ @pytest.fixture def runner_factory(): from utama_core.run.strategy_runner import StrategyRunner - from utama_core.tests.strategy_runner.strat_runner_test_utils import DummyStrategy + from utama_core.tests.run.strat_runner_test_utils import DummyStrategy made = [] @@ -627,7 +627,7 @@ def test_give_and_go_first_touch_never_shoots_solo_with_a_teammate_available(run ends up the only robot near the dead ball and re-touches it itself, which SSL's double-touch rule forbids for the whole window from NORMAL_START until some *other* robot touches the ball first. Found - live: `build_tiki_taka_kernel_strategy` vs `build_counter_press_kernel_strategy`, + live: `tiki_taka` vs `counter_press`, robot 1 shot from the kickoff spot on the very first tick with two idle teammates standing by, then re-collected its own dead ball ~3.5s later. diff --git a/utama_core/tests/engine/test_ball_release.py b/utama_core/tests/engine/test_ball_release.py new file mode 100644 index 000000000..682b96b50 --- /dev/null +++ b/utama_core/tests/engine/test_ball_release.py @@ -0,0 +1,332 @@ +"""The backstop that kicks before a held ball costs a foul or jams against an enemy.""" + +import math +from types import SimpleNamespace +from unittest.mock import MagicMock + +import numpy as np +import pytest + +from utama_core.engine.ball_release import ( + AIM_LIMIT_S, + CARRY_AIM_M, + CONTACT_M, + HELD_STILL_S, + PINNED_RELEASE_S, + PINNED_WITH_LANE_S, + BallRelease, +) +from utama_core.engine.context import TickContext +from utama_core.entities.data.command import RobotCommand +from utama_core.entities.data.vector import Vector2D +from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.geometry.pass_and_score_geometry import ( + ANNOUNCE_PASS_RAD, + MAX_OPEN_TEAMMATE_M, + open_teammate, + reaches_own_goal, + release_heading, + upfield_heading, +) +from utama_core.tactics import _pass_and_score as pas + +_STRAFE = RobotCommand(local_forward_vel=0, local_left_vel=0.3, angular_vel=0, kick=0, chip=0, dribble=1) +_TURN = RobotCommand(local_forward_vel=0, local_left_vel=0, angular_vel=2.0, kick=0, chip=0, dribble=1) +_ROBOT = 1 + + +def _game( + ts=0.0, + ball=(0.0, 0.0), + v=(0.0, 0.0), + has_ball=True, + heading=math.pi, + enemy=None, + cmd=RefereeCommand.NORMAL_START, + mates=(), +): + """Our goal at +x, the robot just behind the ball, facing the enemy goal (-x) by default.""" + robot = SimpleNamespace(p=Vector2D(ball[0] + 0.09, ball[1]), orientation=heading, has_ball=has_ball) + enemies = {} if enemy is None else {0: SimpleNamespace(p=Vector2D(*enemy))} + friends = {_ROBOT: robot, **{i + 2: SimpleNamespace(p=Vector2D(*m), has_ball=False) for i, m in enumerate(mates)}} + return SimpleNamespace( + ts=ts, + ball=SimpleNamespace(p=Vector2D(*ball), v=Vector2D(*v)), + referee=SimpleNamespace(referee_command=cmd), + friendly_robots=friends, + enemy_robots=enemies, + field=SimpleNamespace( + my_goal_line=np.array([[4.5, 0.5], [4.5, -0.5]]), + enemy_goal_line=np.array([[-4.5, 0.5], [-4.5, -0.5]]), + my_defense_area=np.array([[4.5, 1.0], [3.5, 1.0], [3.5, -1.0], [4.5, -1.0]]), + half_length=4.5, + half_width=3.0, + ), + ) + + +@pytest.fixture(autouse=True) +def _turn(monkeypatch): + monkeypatch.setattr("utama_core.engine.ball_release.turn_on_spot", lambda **kw: _TURN) + + +@pytest.fixture +def no_held_limit(monkeypatch): + monkeypatch.setattr("utama_core.engine.ball_release.HELD_STILL_S", 100.0) + + +def _step(release, game, command=_STRAFE): + return release.apply(game, MagicMock(), {_ROBOT: command})[_ROBOT] + + +def test_carry_is_left_alone_just_short_of_the_limit(): + release = BallRelease() + _step(release, _game()) + assert _step(release, _game(ts=1.0, ball=(0.0, CARRY_AIM_M - 0.01))) is _STRAFE + + +def test_carry_is_released_at_the_limit(): + release = BallRelease() + _step(release, _game()) + assert _step(release, _game(ts=1.0, ball=(0.0, 0.97))).kick + + +def test_a_fast_carry_is_released_early_enough_for_the_kick_to_land(): + release = BallRelease() + _step(release, _game()) + assert _step(release, _game(ts=1.0, ball=(0.0, 0.85), v=(0.0, 1.0))).kick + + +def test_losing_the_ball_restarts_the_carry(): + release = BallRelease() + _step(release, _game()) + _step(release, _game(ts=1.0, ball=(0.0, 0.5), has_ball=False)) + _step(release, _game(ts=1.1, ball=(0.0, 0.5))) + assert not _step(release, _game(ts=2.0, ball=(0.0, 1.2))).kick + + +def test_pinned_with_a_lane_open_is_released_early(monkeypatch): + enemy = (-CONTACT_M + 0.01, 0.0) + monkeypatch.setattr("utama_core.engine.ball_release.open_teammate", lambda *a: 2) + release = BallRelease() + _step(release, _game(enemy=enemy)) + assert _step(release, _game(ts=PINNED_WITH_LANE_S - 0.01, enemy=enemy)) is _STRAFE + assert _step(release, _game(ts=PINNED_WITH_LANE_S, enemy=enemy)) is not _STRAFE + + +def test_pinned_against_an_enemy_is_released_only_after_the_limit(monkeypatch): + monkeypatch.setattr("utama_core.engine.ball_release.open_teammate", lambda *a: None) + enemy = (-CONTACT_M + 0.01, 0.0) + release = BallRelease() + _step(release, _game(enemy=enemy)) + assert _step(release, _game(ts=PINNED_RELEASE_S - 0.01, enemy=enemy)) is _STRAFE + assert _step(release, _game(ts=PINNED_RELEASE_S, enemy=enemy)) is not _STRAFE + + +def test_an_enemy_leaving_the_ball_restarts_the_pinned_clock(no_held_limit, monkeypatch): + monkeypatch.setattr("utama_core.engine.ball_release.open_teammate", lambda *a: None) + enemy = (-CONTACT_M + 0.01, 0.0) + release = BallRelease() + _step(release, _game(enemy=enemy)) + _step(release, _game(ts=1.0, enemy=(-1.0, 0.0))) + _step(release, _game(ts=1.1, enemy=enemy)) + assert _step(release, _game(ts=1.1 + PINNED_RELEASE_S - 0.01, enemy=enemy)) is _STRAFE + + +def test_an_enemy_out_of_contact_does_not_pin(no_held_limit): + enemy = (-CONTACT_M - 0.01, 0.0) + release = BallRelease() + _step(release, _game(enemy=enemy)) + assert _step(release, _game(ts=5.0, enemy=enemy)) is _STRAFE + + +def test_never_kicks_at_our_own_goal(): + release = BallRelease() + _step(release, _game(heading=0.0)) + assert not _step(release, _game(ts=1.0, ball=(0.0, 0.1), heading=0.0)).kick + # past the carry limit but still dead on our goal (the ball is 1.0 up, the goal line 4.5 away) + heading_at_goal = math.atan2(-1.0, 4.41) + assert not _step(release, _game(ts=2.0, ball=(0.0, 1.0), heading=heading_at_goal)).kick + + +def test_a_heading_wide_of_our_goal_may_kick(): + release = BallRelease() + _step(release, _game(heading=math.pi / 2)) + assert _step(release, _game(ts=1.0, ball=(0.0, 0.97), heading=math.pi / 2)).kick + + +def test_only_in_live_play(): + release = BallRelease() + _step(release, _game(cmd=RefereeCommand.STOP)) + _step(release, _game(ts=1.0, ball=(0.0, 0.5), cmd=RefereeCommand.STOP)) + assert not _step(release, _game(ts=2.0, ball=(0.0, 0.97), cmd=RefereeCommand.STOP)).kick + + +def test_no_referee_means_no_release(): + release = BallRelease() + game = _game() + game.referee = None + _step(release, game) + far = _game(ts=1.0, ball=(0.0, 2.0)) + far.referee = None + assert not _step(release, far).kick + + +def test_a_robot_with_no_command_stays_without_one(): + release = BallRelease() + release.apply(_game(), MagicMock(), {}) + assert release.apply(_game(ts=1.0, ball=(0.0, 0.97)), MagicMock(), {}) == {} + + +def test_a_release_turns_away_from_the_enemy_it_is_pinned_against(no_held_limit): + enemy = (-CONTACT_M + 0.01, 0.0) # dead ahead of a robot facing -x + release = BallRelease() + _step(release, _game(enemy=enemy)) + assert _step(release, _game(ts=PINNED_RELEASE_S, enemy=enemy)) is _TURN + + +def test_a_release_kicks_at_the_aim_limit_even_when_not_aimed(no_held_limit): + enemy = (-CONTACT_M + 0.01, 0.0) + release = BallRelease() + _step(release, _game(enemy=enemy)) + _step(release, _game(ts=PINNED_RELEASE_S, enemy=enemy)) + assert _step(release, _game(ts=PINNED_RELEASE_S + AIM_LIMIT_S - 0.01, enemy=enemy)) is _TURN + assert _step(release, _game(ts=PINNED_RELEASE_S + AIM_LIMIT_S, enemy=enemy)).kick + + +def test_a_carry_aims_before_the_hard_limit_and_kicks_without_waiting_at_it(): + release = BallRelease() + _step(release, _game(heading=0.3)) + assert _step(release, _game(ts=1.0, ball=(0.0, CARRY_AIM_M), heading=0.3)) is _TURN + assert _step(release, _game(ts=1.1, ball=(0.0, 0.97), heading=0.3)).kick + + +def test_release_heading_prefers_an_open_teammate(): + game = _game(mates=[(-1.0, 2.0)]) + robot = game.friendly_robots[_ROBOT] + assert release_heading(game, _ROBOT) == pytest.approx(robot.p.angle_to(Vector2D(-1.0, 2.0))) + + +def test_a_teammate_behind_an_enemy_is_not_open(): + assert open_teammate(_game(mates=[(-2.0, 0.0)], enemy=(-1.0, 0.0)), _ROBOT) is None + + +def test_a_teammate_inside_our_own_box_is_not_open(): + assert open_teammate(_game(mates=[(4.0, 0.0)]), _ROBOT) is None + + +def test_the_most_advanced_open_teammate_is_chosen(): + assert open_teammate(_game(mates=[(-1.0, 2.0), (-2.5, -2.0)]), _ROBOT) == 3 + + +def test_a_teammate_out_of_kicking_range_is_not_open(): + robot_x = 0.09 # `_game` stands the robot just behind the ball + assert open_teammate(_game(mates=[(robot_x - MAX_OPEN_TEAMMATE_M + 0.01, 0.0)]), _ROBOT) == 2 + assert open_teammate(_game(mates=[(robot_x - MAX_OPEN_TEAMMATE_M - 0.01, 0.0)]), _ROBOT) is None + + +def test_a_release_goes_round_an_enemy_dead_ahead_and_no_wider_than_it_must(): + game = _game(enemy=(-CONTACT_M + 0.01, 0.0)) + offset = abs(math.remainder(release_heading(game, _ROBOT) - math.pi, 2.0 * math.pi)) + assert offset == pytest.approx(1.05) + + +def test_release_with_no_open_teammate_goes_at_the_enemy_goal(): + game = _game(ball=(0.0, 2.9), enemy=(-1.0, 2.9), heading=math.pi / 2) + robot = game.friendly_robots[_ROBOT] + assert release_heading(game, _ROBOT) == pytest.approx(robot.p.angle_to(Vector2D(-4.5, 0.0))) + + +def test_a_robot_standing_on_the_ball_releases_it_only_at_the_limit(): + release = BallRelease() + _step(release, _game()) + assert _step(release, _game(ts=HELD_STILL_S - 0.01)) is _STRAFE + assert _step(release, _game(ts=HELD_STILL_S)).kick + + +def test_moving_the_ball_restarts_the_held_still_clock(): + release = BallRelease() + _step(release, _game()) + _step(release, _game(ts=1.5, ball=(0.0, 0.06))) + assert _step(release, _game(ts=1.5 + HELD_STILL_S - 0.01, ball=(0.0, 0.06))) is _STRAFE + + +def _announced(heading): + release = BallRelease() + ctx = TickContext(motion_controller=None, expected_receivers=set()) + release.apply(_game(heading=heading, mates=[(-2.0, 0.0)]), ctx, {_ROBOT: _STRAFE}) + release.apply(_game(ts=HELD_STILL_S, heading=heading, mates=[(-2.0, 0.0)]), ctx, {_ROBOT: _STRAFE}) + return ctx.expected_receivers + + +def test_a_receiver_is_told_only_once_the_passer_is_nearly_aimed(): + assert _announced(math.pi + ANNOUNCE_PASS_RAD - 0.01) == {2} + assert _announced(math.pi + ANNOUNCE_PASS_RAD + 0.01) == set() + + +def test_release_heading_at_the_touchline_points_back_into_play(): + game = _game(ball=(0.0, 2.9), heading=math.pi / 2) + assert math.sin(release_heading(game, _ROBOT)) <= 0.0 + + +def test_release_heading_never_points_at_our_own_goal(): + game = _game(ball=(2.0, 0.0), enemy=(1.0, 0.0), heading=0.0) + robot = game.friendly_robots[_ROBOT] + assert not reaches_own_goal(game, robot.p, release_heading(game, _ROBOT)) + + +def _upfield_game(enemy=None, y=0.0): + game = _game(ball=(0.0, y), enemy=enemy) + game.my_team_is_right = True + return game + + +def test_clearance_goes_straight_when_the_lane_is_clear(): + assert upfield_heading(_upfield_game(), _ROBOT) == pytest.approx(math.pi) + + +def test_clearance_angles_off_a_blocked_lane(): + heading = upfield_heading(_upfield_game(enemy=(-1.5, 0.0)), _ROBOT) + assert abs(heading - math.pi) == pytest.approx(0.26) + + +def test_clearance_angles_towards_the_middle_of_the_field(): + heading = upfield_heading(_upfield_game(enemy=(-0.5, 1.0), y=1.0), _ROBOT) + assert math.sin(heading) < 0.0 # y falls towards the middle + + +def test_clearance_does_not_angle_off_the_field(): + # Blocked straight ahead on the touchline: the only angle left aims back into play. + heading = upfield_heading(_upfield_game(enemy=(-0.5, 2.9), y=2.9), _ROBOT) + assert math.sin(heading) < 0.0 + + +def _shot_game(mates=(), enemy=None, heading=math.pi): + game = _game(mates=mates, enemy=enemy, heading=heading) + game.my_team_is_right = True + return game + + +def _ctx(): + ctx = MagicMock() + ctx.motion_controller.kick_bend = 0.0 + return ctx + + +def test_no_shot_passes_to_an_open_teammate_once_aimed(monkeypatch): + monkeypatch.setattr(pas, "kick_bend", lambda *a: 0.0) + assert pas.move_for_a_shot(_shot_game(mates=[(-2.0, 0.0)]), _ctx(), _ROBOT).kick + + +def test_no_shot_turns_towards_the_teammate_first(monkeypatch): + monkeypatch.setattr(pas, "kick_bend", lambda *a: 0.0) + monkeypatch.setattr(pas, "turn_on_spot", lambda **kw: _TURN) + assert pas.move_for_a_shot(_shot_game(mates=[(-2.0, 0.0)], heading=0.3), _ctx(), _ROBOT) is _TURN + + +def test_no_shot_with_nobody_open_keeps_moving_for_one(monkeypatch): + monkeypatch.setattr(pas, "kick_bend", lambda *a: 0.0) + monkeypatch.setattr(pas, "open_teammate", lambda *a: None) + monkeypatch.setattr(pas, "no_shot_reposition_target", lambda *a: Vector2D(0.0, 0.6)) + monkeypatch.setattr(pas, "move", lambda **kw: _STRAFE) + assert pas.move_for_a_shot(_shot_game(), _ctx(), _ROBOT) is _STRAFE diff --git a/utama_core/tests/engine/test_ball_roles.py b/utama_core/tests/engine/test_ball_roles.py new file mode 100644 index 000000000..fe0d4eef1 --- /dev/null +++ b/utama_core/tests/engine/test_ball_roles.py @@ -0,0 +1,323 @@ +"""`BallRoles` and the shared helpers it and the tactics lean on: who deals with the ball.""" + +import math +from types import SimpleNamespace + +import numpy as np +import pytest + +from utama_core.config.physical_constants import ROBOT_RADIUS +from utama_core.engine.ball_roles import COVER_M, ON_BALL_SWITCH_MARGIN_M, BallRoles +from utama_core.engine.context import TickContext +from utama_core.entities.data.command import RobotCommand +from utama_core.entities.data.vector import Vector2D +from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.geometry.pass_and_score_geometry import ( + _DEEP_NEAR_LINE_M, + _INTERCEPT_MIN_M, + _PASS_ROLLING_MPS, + ball_intercept_point, + no_shot_reposition_target, + receiver_of_rolling_ball, + segment_blocked, +) +from utama_core.referee.actions import ( + _WALL_FROM_BALL_M, + _is_in_own_defense_area, + _next_is_their_free_kick, + their_free_kick_targets, +) +from utama_core.skills.man_mark import MARK_STANDOFF, mark_target +from utama_core.tactics.give_and_go import _relocate_target + +_ORIGINAL = RobotCommand(local_forward_vel=1, local_left_vel=0, angular_vel=0, kick=0, chip=0, dribble=0) +_TURN = RobotCommand(local_forward_vel=0, local_left_vel=0, angular_vel=2.0, kick=0, chip=0, dribble=1) + + +def _robot(x, y, has_ball=False, orientation=0.0): + return SimpleNamespace(p=Vector2D(x, y), orientation=orientation, has_ball=has_ball) + + +def _game(friends, enemies=(), ball=(0.0, 0.0), v=(0.0, 0.0), cmd=RefereeCommand.NORMAL_START): + """Our goal at +x, attacking -x. `friends`/`enemies` are robots or (x, y); friend ids are their indices.""" + make = lambda items: {i: (r if isinstance(r, SimpleNamespace) else _robot(*r)) for i, r in enumerate(items)} # noqa + return SimpleNamespace( + ts=0.0, + ball=SimpleNamespace(p=SimpleNamespace(x=ball[0], y=ball[1], to_2d=lambda: Vector2D(*ball)), v=Vector2D(*v)), + referee=SimpleNamespace(referee_command=cmd), + friendly_robots=make(friends), + enemy_robots=make(enemies), + my_team_is_right=True, + field=SimpleNamespace( + my_goal_line=np.array([[4.5, 0.5], [4.5, -0.5]]), + enemy_goal_line=np.array([[-4.5, 0.5], [-4.5, -0.5]]), + my_defense_area=np.array([[4.5, 1.0], [3.5, 1.0], [3.5, -1.0], [4.5, -1.0]]), + enemy_defense_area=np.array([[-4.5, 1.0], [-3.5, 1.0], [-3.5, -1.0], [-4.5, -1.0]]), + half_length=4.5, + half_width=3.0, + half_defense_area_width=1.0, + half_defense_area_depth=0.5, + defense_area_rules=True, + ), + ) + + +@pytest.fixture +def moves(monkeypatch): + calls = {} + + def _move(**kw): + calls[kw["robot_id"]] = kw + return RobotCommand(local_forward_vel=0, local_left_vel=0, angular_vel=0, kick=0, chip=0, dribble=9) + + monkeypatch.setattr("utama_core.engine.ball_roles.move", _move) + monkeypatch.setattr("utama_core.engine.ball_roles.turn_on_spot", lambda **kw: _TURN) + return calls + + +def _ctx(claims=(), expected=()): + return TickContext(motion_controller=None, ball_claims=set(claims), expected_receivers=set(expected)) + + +def _commands(n): + return {i: _ORIGINAL for i in range(n)} + + +# --- one robot on the ball --------------------------------------------------------------- + + +def test_of_two_robots_driving_at_the_ball_the_further_covers(moves): + game = _game([(1.0, 0.0), (0.5, 0.0)]) + commands = BallRoles().apply(game, _ctx(claims=[0, 1]), _commands(2), [0, 1]) + assert commands[1] is _ORIGINAL + assert commands[0] is not _ORIGINAL + assert moves[0]["target_coords"].distance_to(Vector2D(COVER_M, 0.0)) < 1e-6 # towards our goal at +x + + +def test_a_single_claim_is_left_alone(moves): + assert BallRoles().apply(_game([(1.0, 0.0)]), _ctx(claims=[0]), _commands(1), [0])[0] is _ORIGINAL + + +def test_the_robot_on_the_ball_keeps_it_until_another_is_clearly_nearer(moves): + roles = BallRoles() + roles.apply(_game([(0.5, 0.0), (1.0, 0.0)]), _ctx(claims=[0, 1]), _commands(2), [0, 1]) + just_short = 1.0 - ON_BALL_SWITCH_MARGIN_M + 0.01 + assert ( + roles.apply(_game([(1.0, 0.0), (just_short, 0.0)]), _ctx(claims=[0, 1]), _commands(2), [0, 1])[0] is _ORIGINAL + ) + clearly = 1.0 - ON_BALL_SWITCH_MARGIN_M - 0.01 + assert roles.apply(_game([(1.0, 0.0), (clearly, 0.0)]), _ctx(claims=[0, 1]), _commands(2), [0, 1])[1] is _ORIGINAL + + +def test_a_teammate_holding_the_ball_sends_a_claimer_to_cover(moves): + game = _game([_robot(0.1, 0.0, has_ball=True), (1.0, 0.0)]) + assert BallRoles().apply(game, _ctx(claims=[1]), _commands(2), [0, 1])[1] is not _ORIGINAL + + +def test_a_claimer_near_a_held_ball_steps_straight_out_and_is_not_pulled_back(moves): + game = _game([_robot(0.1, 0.0, has_ball=True), (-0.5, 0.0)]) # the attacker is on the far side of the ball + BallRoles().apply(game, _ctx(claims=[1]), _commands(2), [0, 1]) + assert moves[1]["target_coords"].distance_to(Vector2D(-COVER_M, 0.0)) < 1e-6 + + +def test_a_claimer_far_from_a_held_ball_stays_where_it_is(moves): + game = _game([_robot(0.1, 0.0, has_ball=True), (-2.0, 1.0)]) + BallRoles().apply(game, _ctx(claims=[1]), _commands(2), [0, 1]) + assert moves[1]["target_coords"].distance_to(Vector2D(-2.0, 1.0)) < 1e-6 + + +def test_the_closest_robot_is_not_made_to_cover_a_loose_ball(moves): + roles = BallRoles() + roles.apply(_game([(0.5, 0.0), (1.0, 0.0)]), _ctx(claims=[0, 1]), _commands(2), [0, 1]) + # 1 has become closest but not by the margin that moves the ball to it: both carry on + commands = roles.apply(_game([(0.8, 0.0), (0.7, 0.0)]), _ctx(claims=[0, 1]), _commands(2), [0, 1]) + assert commands[0] is _ORIGINAL and commands[1] is _ORIGINAL + + +def test_nothing_changes_outside_live_play(moves): + game = _game([(1.0, 0.0), (0.5, 0.0)], cmd=RefereeCommand.STOP) + assert BallRoles().apply(game, _ctx(claims=[0, 1]), _commands(2), [0, 1])[0] is _ORIGINAL + + +# --- receiving --------------------------------------------------------------------------- + + +def test_the_robot_a_free_ball_rolls_to_meets_it_on_its_path(moves): + game = _game([(2.0, 0.3), (-2.0, 0.0)], v=(3.0, 0.0)) + commands = BallRoles().apply(game, _ctx(), _commands(2), [0, 1]) + assert commands[0] is not _ORIGINAL and commands[1] is _ORIGINAL + assert moves[0]["dribbling"] is True + assert abs(moves[0]["target_coords"].y) < 1e-6 + + +def test_a_passer_chasing_its_own_pass_covers_while_the_receiver_takes_it(moves): + game = _game([(2.0, 0.0), (-0.5, 0.0)], v=(3.0, 0.0)) + commands = BallRoles().apply(game, _ctx(claims=[1]), _commands(2), [0, 1]) + assert commands[1] is not _ORIGINAL + assert moves[0]["dribbling"] is True + + +def test_a_receiver_stays_on_the_ball_when_the_reach_check_drops_it(moves): + roles = BallRoles() + roles.apply(_game([(1.0, 0.1)], v=(3.0, 0.0)), _ctx(), _commands(1), [0]) + assert receiver_of_rolling_ball(_game([(1.0, 0.6)], v=(3.0, 0.0)), [0]) is None + assert roles.apply(_game([(1.0, 0.6)], v=(3.0, 0.0)), _ctx(), _commands(1), [0])[0] is not _ORIGINAL + + +def test_a_receiver_lets_go_once_the_ball_has_passed(moves): + roles = BallRoles() + roles.apply(_game([(1.0, 0.1)], v=(3.0, 0.0)), _ctx(), _commands(1), [0]) + assert roles.apply(_game([(-0.5, 0.1)], v=(3.0, 0.0)), _ctx(), _commands(1), [0])[0] is _ORIGINAL + + +def test_a_receiver_sprints_onto_the_path(moves): + BallRoles().apply(_game([(1.0, 0.1)], v=(3.0, 0.0)), _ctx(), _commands(1), [0]) + assert moves[0]["sprint"] is True + + +def test_a_new_pick_replaces_a_robot_the_first_tick_chose(moves): + roles = BallRoles() + roles.apply(_game([(1.0, 0.1), (3.0, 3.0)], v=(3.0, 0.0)), _ctx(), _commands(2), [0, 1]) + assert roles._receiving == 0 + # robot 0 is still within the hold's reach of the path, but robot 1 is the one the ball comes to + roles.apply(_game([(1.0, 0.6), (0.5, 0.05)], v=(3.0, 0.0)), _ctx(), _commands(2), [0, 1]) + assert roles._receiving == 1 + + +def test_a_ball_an_enemy_reaches_first_is_not_received(): + assert receiver_of_rolling_ball(_game([(2.0, 0.0)], [(1.0, 0.05)], v=(3.0, 0.0)), [0]) is None + assert receiver_of_rolling_ball(_game([(1.0, 0.0)], [(2.0, 0.05)], v=(3.0, 0.0)), [0]) == 0 + + +def test_only_the_first_robot_along_the_path_receives(): + game = _game([(3.0, 0.0), (1.5, 0.0)], v=(3.0, 0.0)) + assert receiver_of_rolling_ball(game, [0, 1]) == 1 + + +def test_a_shot_at_the_enemy_goal_is_not_received(): + assert receiver_of_rolling_ball(_game([(-2.0, 0.0)], v=(-3.0, 0.0)), [0]) is None + + +def test_a_slow_ball_is_not_received(): + game = _game([(0.5, 0.0)], v=(_PASS_ROLLING_MPS - 0.01, 0.0)) + assert receiver_of_rolling_ball(game, [0]) is None + + +def test_a_ball_at_a_robots_feet_is_not_a_free_ball(): + assert receiver_of_rolling_ball(_game([(2.0, 0.0)], [(0.1, 0.0)], v=(3.0, 0.0)), [0]) is None + + +def test_a_ball_that_stops_short_is_not_received(): + speed = 1.0 # rolls 1 / (2 * 0.3) = 1.67 m + assert receiver_of_rolling_ball(_game([(1.6, 0.0)], v=(speed, 0.0)), [0]) == 0 + assert receiver_of_rolling_ball(_game([(1.75, 0.0)], v=(speed, 0.0)), [0]) is None + + +def test_a_receiver_out_of_reach_of_the_path_is_passed_over(): + assert receiver_of_rolling_ball(_game([(0.6, 0.19)], v=(6.0, 0.0)), [0]) == 0 # reach 0.1 + 0.1 + assert receiver_of_rolling_ball(_game([(0.6, 0.21)], v=(6.0, 0.0)), [0]) is None + + +def test_the_robot_about_to_be_passed_to_stops_and_faces_the_ball(moves): + commands = BallRoles().apply(_game([(2.0, 0.3)]), _ctx(expected=[0]), _commands(1), [0]) + assert commands[0] is _TURN + + +# --- going to where the ball will be ----------------------------------------------------- + + +def test_a_chaser_heads_for_where_it_can_catch_the_ball(): + spot = ball_intercept_point(_game([(1.0, 1.0)], v=(1.0, 0.0)), 0) + assert 0.5 < spot.x < 1.67 and spot.y == pytest.approx(0.0) + + +def test_a_chaser_that_cannot_catch_it_goes_to_where_it_stops(): + spot = ball_intercept_point(_game([(-3.0, 0.0)], v=(1.0, 0.0)), 0) + assert spot.x == pytest.approx(1.0 / (2 * 0.3), abs=0.01) + + +def test_no_intercept_for_a_slow_ball_or_a_robot_beside_it(): + assert ball_intercept_point(_game([(1.0, 1.0)], v=(_PASS_ROLLING_MPS - 0.01, 0.0)), 0) is None + assert ball_intercept_point(_game([(_INTERCEPT_MIN_M - 0.01, 0.0)], v=(3.0, 0.0)), 0) is None + + +def test_the_intercept_stays_out_of_our_box(): + spot = ball_intercept_point(_game([(-3.0, 0.0)], ball=(2.5, 0.0), v=(3.0, 0.0)), 0) + assert spot.x < 3.5 + + +# --- releases, corners, supporters, marking ---------------------------------------------- + + +def _reposition(x, y, enemy): + return no_shot_reposition_target(Vector2D(x, y), [enemy], -4.5, -0.3, 0.3, 3.0) + + +def test_deep_and_wide_of_the_goal_a_carrier_strafes_towards_the_middle(): + deep = -4.5 + _DEEP_NEAR_LINE_M - 0.01 + assert _reposition(deep, 2.0, Vector2D(deep, 1.8)).y < 2.0 # the blocker would send it to the corner + assert _reposition(deep, -2.0, Vector2D(deep, -1.8)).y > -2.0 + + +def test_short_of_the_deep_zone_a_carrier_still_strafes_away_from_the_blocker(): + shallow = -4.5 + _DEEP_NEAR_LINE_M + 0.01 + assert _reposition(shallow, 2.0, Vector2D(shallow, 1.8)).y > 2.0 + + +def test_a_support_run_with_a_lane_beats_a_deeper_one_without(): + open_field = _relocate_target(_game([(-1.0, 1.2), (0.1, 0.0)]), 0, []) + blocker = (open_field.x * 0.5, open_field.y * 0.5) + chosen = _relocate_target(_game([(-1.0, 1.2), (0.1, 0.0)], [blocker]), 0, []) + assert chosen.distance_to(open_field) > 0.1 + assert not segment_blocked(Vector2D(0.0, 0.0), chosen, [Vector2D(*blocker)], ROBOT_RADIUS + 0.1) + + +def _facing(angle): + return _robot(0.05, 0.0, orientation=angle) + + +def test_a_marker_steps_into_the_lane_when_the_passer_faces_its_opponent(): + game = _game([], [_facing(0.0), (2.0, 0.0)]) + target = mark_target(game, 1) + assert target.x == pytest.approx(2.0 - MARK_STANDOFF) # between the passer and the opponent + + +def test_a_marker_stays_goal_side_when_the_passer_looks_elsewhere(): + game = _game([], [_facing(0.21), (2.0, 0.0)]) + assert mark_target(game, 1).x == pytest.approx(2.0 + MARK_STANDOFF) + + +def test_a_marker_stays_goal_side_when_the_passer_is_too_near_to_step_between(): + game = _game([], [_facing(0.0), (1.2, 0.0)]) + assert mark_target(game, 1).x == pytest.approx(1.2 + MARK_STANDOFF) + + +# --- an opponent's free kick ------------------------------------------------------------- + + +def _free_kick_game(friends, enemies, ball): + game = _game(friends, enemies, ball=ball) + game.my_team_is_yellow = True + game.referee.yellow_team = SimpleNamespace(goalkeeper=0) + game.referee.next_command = RefereeCommand.DIRECT_FREE_BLUE + return game + + +def test_their_free_kick_puts_a_wall_on_the_line_and_marks_the_receivers(): + game = _free_kick_game([(4.2, 0.0), (1.0, 0.5), (0.0, 2.0)], [(-0.15, 0.0), (0.0, -2.0), (2.5, 2.0)], (0.0, 0.0)) + targets = their_free_kick_targets(game) + assert 0 not in targets # the keeper keeps its own job + assert targets[1].distance_to(Vector2D(_WALL_FROM_BALL_M, 0.0)) < 1e-6 + assert targets[2].distance_to(Vector2D(2.5 + MARK_STANDOFF, 2.0)) < 1e-6 # nearest our goal first, not the taker + + +def test_the_wall_stays_out_of_our_own_box(): + game = _free_kick_game([(4.2, 0.0), (2.0, 0.5)], [(2.85, 0.0)], (3.0, 0.0)) + assert not _is_in_own_defense_area(game, *their_free_kick_targets(game)[1]) + + +def test_stop_only_prepares_for_a_free_kick_that_is_theirs(): + game = _free_kick_game([(4.2, 0.0)], [], (0.0, 0.0)) + assert _next_is_their_free_kick(game) + game.referee.next_command = RefereeCommand.DIRECT_FREE_YELLOW + assert not _next_is_their_free_kick(game) diff --git a/utama_core/tests/engine/test_block_shape_tactic.py b/utama_core/tests/engine/test_block_shape_tactic.py index 260b74d4f..afbb59b48 100644 --- a/utama_core/tests/engine/test_block_shape_tactic.py +++ b/utama_core/tests/engine/test_block_shape_tactic.py @@ -5,7 +5,7 @@ match"): `go_to_point()`'s signature declares `target_coords: Vector2D`, and `move()` forwards that value straight through to `motion_controller.calculate(..., target_pos=target_coords, ...)` -unconverted (`utama_core/skills/src/utils/move_utils.py`). FPP/DWA happened +unconverted (`utama_core/skills/utils/move_utils.py`). FPP/DWA happened to tolerate a raw tuple silently; trajsampling's stricter `target_pos.x`/`.y` attribute access crashed outright — the actual reason a full trajsample tournament scored 0-0 everywhere. Both of `BlockShapeTactic.tick()`'s @@ -30,7 +30,7 @@ from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.game.robot import Robot -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController from utama_core.tactics.block_shape import BlockShapeTactic diff --git a/utama_core/tests/engine/test_carrier_first.py b/utama_core/tests/engine/test_carrier_first.py new file mode 100644 index 000000000..0b98aafb4 --- /dev/null +++ b/utama_core/tests/engine/test_carrier_first.py @@ -0,0 +1,36 @@ +"""`carrier_first`'s kicker at a still ball: a free-kick taker counts, a contested ball does not.""" + +from types import SimpleNamespace + +from utama_core.strategy.pickers import _KICK_REACH_M, carrier_first + + +def _robot(x, has_ball=False): + return SimpleNamespace(p=SimpleNamespace(x=x, y=0.0), has_ball=has_ball) + + +def _game(kicker_x, enemy_x): + return SimpleNamespace( + ball=SimpleNamespace(p=SimpleNamespace(x=0.0, y=0.0), v=SimpleNamespace(x=0.0, y=0.0)), + friendly_robots={1: _robot(0.8), 3: _robot(kicker_x)}, + enemy_robots={0: _robot(enemy_x)}, + ) + + +def test_a_kicker_waiting_at_a_still_ball_goes_first(): + assert carrier_first(_game(0.11, 0.6), frozenset({1, 3})) == [3, 1] + + +def test_a_contested_ball_has_no_waiting_kicker_whichever_robot_is_nearer(): + assert carrier_first(_game(0.111, 0.112), frozenset({1, 3})) == [1, 3] + assert carrier_first(_game(0.113, 0.112), frozenset({1, 3})) == [1, 3] + + +def test_an_enemy_just_out_of_reach_leaves_the_kicker_first(): + assert carrier_first(_game(0.11, _KICK_REACH_M + 0.001), frozenset({1, 3})) == [3, 1] + + +def test_a_robot_with_the_ball_goes_first_even_when_contested(): + game = _game(0.11, 0.112) + game.friendly_robots[3].has_ball = True + assert carrier_first(game, frozenset({1, 3})) == [3, 1] diff --git a/utama_core/tests/engine/test_check_strategy_branch.py b/utama_core/tests/engine/test_check_strategy_branch.py index b334ba0ef..729530efd 100644 --- a/utama_core/tests/engine/test_check_strategy_branch.py +++ b/utama_core/tests/engine/test_check_strategy_branch.py @@ -1,4 +1,4 @@ -"""`tools/check_strategy_branch.py`: a strategy branch may change strategy code only, may not change +"""`tools/dev/check_strategy_branch.py`: a strategy branch may change strategy code only, may not change its opponents, and its code may not reach outside itself. Lives outside `tests/strategy/` on purpose: that directory is on the allowlist, so a strategy branch @@ -11,7 +11,7 @@ import pytest -from tools.check_strategy_branch import ( +from tools.dev.check_strategy_branch import ( ALLOWED, _load_fingerprint, changed_paths, @@ -19,7 +19,6 @@ opponent_problems, outside_allowlist, reach_problems, - registry_problems, ) REPO_ROOT = Path(__file__).resolve().parents[3] @@ -30,9 +29,7 @@ def test_strategy_modules_tests_and_catalog_are_allowed(): outside_allowlist( [ "utama_core/strategy/new_idea.py", - "utama_core/strategy/kernel_strategy.py", "utama_core/tests/strategy/test_new_idea.py", - "docs/strategies.md", ] ) == [] @@ -43,14 +40,14 @@ def test_strategy_modules_tests_and_catalog_are_allowed(): "path", [ "utama_core/engine/strategy.py", - "utama_core/analysis/goal_ledger.py", + "utama_core/analysis/goal_sources.py", "tools/evaluation/match.py", - "tools/check_strategy_branch.py", + "tools/dev/check_strategy_branch.py", ".github/workflows/ci.yml", # Prefix matches on whole directory names only. "utama_core/strategy_runner/x.py", - "utama_core/tests/strategy_runner/test_x.py", - "docs/strategies.md.bak", + "utama_core/tests/run/test_x.py", + "docs/strategies.md", # the catalog doc is gone: the dashboard reads the strategies ], ) def test_anything_else_is_reported(path): @@ -63,7 +60,6 @@ def test_allowlist_is_strategy_code_only(): "utama_core/strategy/", "utama_core/tactics/", "utama_core/tests/strategy/", - "docs/strategies.md", ) @@ -71,11 +67,6 @@ def _git(repo, *args): subprocess.run(["git", "-c", "user.name=t", "-c", "user.email=t@t", *args], cwd=repo, check=True) -REGISTRY_SRC = ( - '"""Factories."""\n' - "from utama_core.strategy.a import build_a_kernel_strategy\n" - "from utama_core.strategy.b import build_b_kernel_strategy\n" -) STRATEGY_SRC = ( "from utama_core.strategy.pickers import helper\n\n\ndef build_{n}_kernel_strategy(ids):\n return helper(ids)\n" ) @@ -86,7 +77,7 @@ def repo(tmp_path, monkeypatch): _git(tmp_path, "init", "-q", "-b", "main") s = tmp_path / "utama_core/strategy" s.mkdir(parents=True) - (s / "kernel_strategy.py").write_text(REGISTRY_SRC) + (s / "catalog.py").write_text("def names():\n return []\n") (s / "pickers.py").write_text("def helper(ids):\n return ids\n") for n in "ab": (s / f"{n}.py").write_text(STRATEGY_SRC.format(n=n)) @@ -115,22 +106,19 @@ def test_tuning_one_strategy_passes(repo): assert main(["--base", "main"]) == 0 -def test_adding_a_strategy_and_its_import_passes(repo): - registry = REGISTRY_SRC + "from utama_core.strategy.c import build_c_kernel_strategy\n" +def test_adding_a_strategy_passes(repo): _commit( repo, - {"utama_core/strategy/c.py": STRATEGY_SRC.format(n="c"), "utama_core/strategy/kernel_strategy.py": registry}, + {"utama_core/strategy/c.py": STRATEGY_SRC.format(n="c")}, ) assert main(["--base", "main"]) == 0 def test_adding_a_strategy_and_weakening_another_fails(repo): - registry = REGISTRY_SRC + "from utama_core.strategy.c import build_c_kernel_strategy\n" _commit( repo, { "utama_core/strategy/c.py": STRATEGY_SRC.format(n="c"), - "utama_core/strategy/kernel_strategy.py": registry, "utama_core/strategy/b.py": STRATEGY_SRC.format(n="b").replace("helper(ids)", "[]"), }, ) @@ -139,14 +127,12 @@ def test_adding_a_strategy_and_weakening_another_fails(repo): def test_adding_a_tactic_and_a_strategy_that_uses_it_passes(repo): tactic = "from utama_core.tactics.press import PressTactic\n\n\nclass FastPress(PressTactic):\n reach = 2\n" - registry = REGISTRY_SRC + "from utama_core.strategy.c import build_c_kernel_strategy\n" - strategy = "from utama_core.tactics.fast_press import FastPress\n\n\ndef build_c_kernel_strategy(ids):\n return FastPress()\n" + strategy = "from utama_core.tactics.fast_press import FastPress\n\n\ndef c(ids):\n return FastPress()\n" _commit( repo, { "utama_core/tactics/fast_press.py": tactic, "utama_core/strategy/c.py": strategy, - "utama_core/strategy/kernel_strategy.py": registry, }, ) assert main(["--base", "main"]) == 0 @@ -205,37 +191,17 @@ def test_changing_pickers_or_deleting_a_strategy_is_reported(): assert opponent_problems({"utama_core/strategy/b.py": "D"}) -def test_tests_and_the_catalog_do_not_count_as_strategies(): +def test_tests_do_not_count_as_strategies(): changes = { "utama_core/strategy/a.py": "M", "utama_core/tests/strategy/test_a.py": "A", - "docs/strategies.md": "M", } assert opponent_problems(changes) == [] -def test_registry_may_only_gain_imports_from_added_modules(): - added = {"utama_core.strategy.c"} - new_import = "from utama_core.strategy.c import build_c_kernel_strategy\n" - # isort may put the new import anywhere. - first = REGISTRY_SRC.replace('"""Factories."""\n', '"""Factories."""\n' + new_import) - assert registry_problems(REGISTRY_SRC, first, added) == [] - assert registry_problems(REGISTRY_SRC, REGISTRY_SRC + new_import, set()) - repointed = REGISTRY_SRC.replace("strategy.b import", "strategy.c import") - assert registry_problems(REGISTRY_SRC, repointed, added) - assert registry_problems(REGISTRY_SRC, REGISTRY_SRC + "build_b_kernel_strategy = None\n", added) - - -def test_an_added_module_may_not_rebind_or_rename_a_registry_name(): - added = {"utama_core.strategy.c"} - # placed after b's import, this would replace the opponent b's factory with c's code - shadow = REGISTRY_SRC + "from utama_core.strategy.c import build_b_kernel_strategy\n" - assert registry_problems(REGISTRY_SRC, shadow, added) - renamed = REGISTRY_SRC + "from utama_core.strategy.c import build_c_kernel_strategy as build_a_kernel_strategy\n" - assert registry_problems(REGISTRY_SRC, renamed, added) - - -# --- reach ------------------------------------------------------------------------------------ +def test_changing_the_catalog_fails(repo): + _commit(repo, {"utama_core/strategy/catalog.py": "def names():\n return ['a']\n"}) + assert main(["--base", "main"]) == 1 @pytest.fixture(scope="module") @@ -255,7 +221,7 @@ def test_a_plain_strategy_reaches_nothing(fingerprint): "from utama_core.tactics import press\n\n\ndef build(ids):\n press.TABLE['k'] = 0\n", "from utama_core.tactics import press\n\n\ndef build(ids):\n setattr(press, 'reach', 0)\n", # Reaching another strategy, the opponent. - "from utama_core.strategy.tiki_taka import build_tiki_taka_kernel_strategy\n", + "from utama_core.strategy.tiki_taka import tiki_taka\n", "import utama_core.strategy.tiki_taka\n", # Import-time effects and hazards. "import sys\n\nsys.path.append('x')\n", @@ -298,9 +264,7 @@ def test_setting_attributes_on_its_own_objects_is_fine(fingerprint): assert reach_problems("s.py", local, fingerprint) == [] -@pytest.mark.parametrize( - "body", ["from .tiki_taka import build_tiki_taka_kernel_strategy\n", "from . import tiki_taka\n"] -) +@pytest.mark.parametrize("body", ["from .tiki_taka import tiki_taka\n", "from . import tiki_taka\n"]) def test_a_relative_import_of_another_strategy_is_reported(fingerprint, body): assert reach_problems("utama_core/strategy/c.py", body, fingerprint) assert reach_problems("utama_core/strategy/c.py", "from .pickers import helper\n", fingerprint) == [] @@ -312,7 +276,7 @@ def test_every_existing_strategy_passes_the_reach_check(fingerprint): failing = { p.name for p in (REPO_ROOT / "utama_core/strategy").glob("*.py") - if p.name not in ("__init__.py", "kernel_strategy.py", "pickers.py") + if p.name not in ("__init__.py", "catalog.py", "pickers.py") and reach_problems(p.name, p.read_text(), fingerprint) } assert failing == set() diff --git a/utama_core/tests/engine/test_commitment_deadline.py b/utama_core/tests/engine/test_commitment_deadline.py index b13ed0efb..3d15a1d32 100644 --- a/utama_core/tests/engine/test_commitment_deadline.py +++ b/utama_core/tests/engine/test_commitment_deadline.py @@ -5,7 +5,7 @@ and `game.ball` off whatever it's given) plus a stub `Tactic` whose `is_committed()` always returns `True` — the exact "missing release path" shape behind the 42 "match freeze" bug-fix commits this mechanism responds -to (see `docs/tactic_model_design_decisions.md` §3/§15's "open item"). +to (see `docs/strategy_design.md` §3/§15's "open item"). The deadline overrides `_choose_partition`'s pinning decision only — it does not change `Tactic.is_committed()` semantics (still `True` throughout every @@ -15,6 +15,7 @@ from __future__ import annotations from dataclasses import dataclass +from types import SimpleNamespace from typing import Optional from utama_core.engine.context import TickContext @@ -54,6 +55,8 @@ def __init__( self.referee = _FakeReferee(referee_command) if referee_command is not None else None self.ts = ts self.ball = _FakeBall(_FakeVector(ball_x, ball_y)) + self.friendly_robots = {0: SimpleNamespace(has_ball=False, p=_FakeVector(9.0, 9.0))} # the pinned keeper + self.enemy_robots = {} @dataclass diff --git a/utama_core/tests/engine/test_decoy_and_overload_tactic.py b/utama_core/tests/engine/test_decoy_and_overload_tactic.py index 33802b183..2d59636df 100644 --- a/utama_core/tests/engine/test_decoy_and_overload_tactic.py +++ b/utama_core/tests/engine/test_decoy_and_overload_tactic.py @@ -36,7 +36,7 @@ from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.game.robot import Robot -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController from utama_core.tactics.decoy_and_overload import ( _ENEMY_BALL_RELEASE_TICKS, _FINISH_TIMEOUT_TICKS, diff --git a/utama_core/tests/engine/test_evaluate.py b/utama_core/tests/engine/test_evaluate.py index cc67208b5..21828d2b4 100644 --- a/utama_core/tests/engine/test_evaluate.py +++ b/utama_core/tests/engine/test_evaluate.py @@ -1,45 +1,31 @@ -from tools.evaluation import evaluate -from utama_core.replay import eval_ledger - - -def test_round_fixtures_pair_candidate_and_champion_on_the_same_opponents_and_seed(): - fixtures = evaluate.round_fixtures(["c"], "ch", ["o1", "o2"], 1) - assert set(fixtures) == {("c", "o1", 1), ("c", "o2", 1), ("c", "ch", 1), ("ch", "o1", 1), ("ch", "o2", 1)} - - -def test_round_fixtures_swap_sides_in_even_rounds(): - assert ("o1", "c", 2) in evaluate.round_fixtures(["c"], "ch", ["o1"], 2) - assert ("ch", "c", 2) in evaluate.round_fixtures(["c"], "ch", ["o1"], 2) +import pytest - -def test_two_candidates_share_the_champions_fixtures(): - fixtures = evaluate.round_fixtures(["c1", "c2"], "ch", ["o1"], 1) - assert fixtures.count(("ch", "o1", 1)) == 1 - assert ("c1", "c2", 1) not in fixtures +from tools.evaluation import evaluate +from utama_core.analysis import ratings -def test_verdict_thresholds_are_inclusive_and_cap_rounds(): - assert evaluate.verdict(evaluate.PROMOTE, 1, 6) == "better" - assert evaluate.verdict(evaluate.DROP, 1, 6) == "worse" - assert evaluate.verdict(0.5, 5, 6) is None - assert evaluate.verdict(0.5, 6, 6) == "undecided" +def test_every_round_is_every_pair_once_under_its_seed(): + for k in (1, 2): + fixtures = evaluate.round_fixtures(k, ["c"], "ref", ["o1", "o2"]) + assert len(fixtures) == 6 and {f[2] for f in fixtures} == {k} + assert {frozenset(f[:2]) for f in fixtures} == { + frozenset(p) for p in [("c", "ref"), ("c", "o1"), ("c", "o2"), ("ref", "o1"), ("ref", "o2"), ("o1", "o2")] + } -def test_ledger_round_trip_keeps_the_last_entry_per_fixture_and_skips_torn_lines(tmp_path): - path = tmp_path / "ledger.jsonl" - base = {"env": "e", "a": "x", "b": "y", "a_fp": "1", "b_fp": "2", "seed": 1} - eval_ledger.append([{**base, "fixture": "f", "score_a": 1}, {**base, "env": "other", "fixture": "g"}], path) - eval_ledger.append([{**base, "fixture": "f", "score_a": 2}], path) - with open(path, "a") as f: - f.write('{"env": "e", "fixt') - loaded = eval_ledger.load("e", path) - assert list(loaded) == ["f"] and loaded["f"]["score_a"] == 2 +def test_candidate_and_reference_meet_each_opponent_with_the_same_colour(): + for k in (1, 2, 3): + fixtures = evaluate.round_fixtures(k, ["c"], "ref", ["o"]) + c_is_a = ("c", "o", k) in fixtures + assert c_is_a == (k % 2 == 1) + assert (("ref", "o", k) in fixtures) == c_is_a -def test_fixture_id_depends_on_seed_and_code(): - f = eval_ledger.fixture_id - assert f("e", "x", "1", "y", "2", 1) != f("e", "x", "1", "y", "2", 2) - assert f("e", "x", "1", "y", "2", 1) != f("e", "x", "9", "y", "2", 1) +def test_the_confirm_stage_plays_fresh_seeds_and_decides_on_them_alone(monkeypatch): + monkeypatch.setattr(ratings, "ROUNDS", 3) + assert [evaluate.seed_of(k) for k in range(1, 7)] == [1, 2, 3, 101, 102, 103] + assert evaluate.stage_seeds(2) == {1, 2} + assert evaluate.stage_seeds(5) == {101, 102} def test_per_opponent_compares_only_matches_with_the_same_seed_and_colour(): @@ -75,26 +61,105 @@ def e(a, b, sa, sb, seed): assert h2h == [-3] -def test_a_verdict_after_round_k_ignores_later_seeds_already_in_the_ledger(): - ledger = {"1": {"seed": 1}, "2": {"seed": 2}, "3": {"seed": None}} - assert list(evaluate._up_to_round(ledger, 1)) == ["1"] +def test_a_decision_uses_its_stages_seeds_only(): + ledger = {"1": {"seed": 1}, "2": {"seed": 2}, "101": {"seed": 101}, "x": {"seed": None}} + assert list(evaluate._with_seeds(ledger, {1, 2})) == ["1", "2"] + assert list(evaluate._with_seeds(ledger, {101})) == ["101"] + + +def test_colours_follow_the_seed_not_the_round(): + # a confirm seed is played in round ROUNDS+1 or later, so a run with another ROUNDS plays it in a + # round of the other parity: the store would then hold it in both colours, and the verdict would + # count both (test_the_verdict_does_not_depend_on_other_seeds_already_in_the_store) + for k in (1, 2, 7, 8): + assert ("c", "o", 101) in evaluate.round_fixtures(k, ["c"], "ref", ["o"], seed=101) + assert ("o", "c", 102) in evaluate.round_fixtures(k, ["c"], "ref", ["o"], seed=102) + +def test_the_players_load_and_the_core_is_in_the_catalog(): + from tools.evaluation.match import _CONFIG_NAMES + from tools.evaluation.sim_settings import load_players -def test_pools_are_valid_and_load_cleanly(): + players = load_players() + assert players["champion"] in players["core"] + assert set(players["core"]) <= set(_CONFIG_NAMES) + + +def test_the_reference_world_and_robots_make_one_valid_sim_noise(): + from tools.evaluation.sim_settings import reference_noise + from utama_core.simulator.utils.sim_noise import SimNoise + + noise = SimNoise.from_dict(reference_noise(seed=3)) + assert noise.seed == 3 + assert noise.latency_estimate_s == pytest.approx(0.07) + + +def test_every_reference_setting_names_its_source(): import json - from pathlib import Path - - from utama_core.rsoccer_simulator.src.Utils.sim_noise import SimNoise - - pools_dir = Path(__file__).resolve().parents[3] / "tools" / "evaluation" / "pools" - pool_files = list(pools_dir.glob("pool_v*.json")) - assert len(pool_files) >= 1 # pool_v1.json - - for path in pool_files: - data = json.loads(path.read_text()) - assert "version" in data and "champion" in data and "opponents" in data - assert "held_out" in data and "sim_noise" in data - assert len(data["opponents"]) > 0 - assert len(data["held_out"]) > 0 - noise = SimNoise.from_dict(data["sim_noise"]) - assert noise.vanishing >= 0 + + from tools.evaluation.sim_settings import REFERENCE_DIR + + for name in ("world", "robots"): + data = json.loads((REFERENCE_DIR / f"{name}.json").read_text()) + assert set(data["sources"]) == set(data["values"]), name + + +def test_the_reference_sim_does_not_draw_robot_motor_limits(): + """Acceleration is the command cap; a per-match draw would be a robot capability as noise.""" + from tools.evaluation.sim_settings import reference_noise + from utama_core.simulator.utils.sim_noise import SimNoise + + assert not SimNoise.from_dict(reference_noise()).motion_limits + + +FPS = {"c": "fc", "o": "fo", "ch": "fch"} + + +def _ledger_row(a, b, stalls, fixture, seed=1, a_fp=None): + return { + "fixture": fixture, + "a": a, + "b": b, + "a_fp": a_fp or FPS[a], + "b_fp": FPS[b], + "seed": seed, + "stalls": stalls, + } + + +def test_stall_coverage_counts_only_matches_where_the_candidate_was_config_a(): + ledger = { + "1": _ledger_row("c", "o", [], "1"), # checked, no stalls + "2": _ledger_row("o", "c", None, "2"), # candidate as config_b: unchecked + "3": _ledger_row("c", "o", None, "3", seed=2), # reused old line: unknown, unchecked + "4": _ledger_row("o", "c", [{"kind": "RESTART_STALL", "sim_time": 5.0}], "4", seed=2), + } + cov = evaluate.stall_coverage(ledger, FPS, "c") + assert (cov["checked"], cov["total"]) == (1, 4) + assert cov["stalls"] == [] + + +def test_stall_coverage_lists_each_stall_with_its_match_seed_kind_and_time(): + ledger = { + "1": _ledger_row("c", "o", [{"kind": "RESTART_STALL", "sim_time": 5.0, "diagnosis": "ball in goal"}], "1") + } + cov = evaluate.stall_coverage(ledger, FPS, "c") + assert cov["checked"] == 1 and cov["total"] == 1 + assert cov["stalls"] == [ + {"a": "c", "b": "o", "seed": 1, "kind": "RESTART_STALL", "sim_time": 5.0, "diagnosis": "ball in goal"} + ] + + +def test_stall_coverage_ignores_matches_at_other_code_and_other_players(): + ledger = { + "1": _ledger_row("c", "o", [], "1", a_fp="old"), # the candidate's code has changed since + "2": _ledger_row("ch", "o", [], "2", a_fp="fch"), # the champion's match, not the candidate's + } + assert evaluate.stall_coverage(ledger, FPS, "c") == {"checked": 0, "total": 0, "stalls": []} + + +def test_stall_lines_say_none_only_when_checked_and_unknown_when_not(): + assert evaluate.stall_lines({"checked": 3, "total": 7, "stalls": []}, "candidate") == [ + "stalls checked in 3 of 7 candidate matches (watchdog covers config_a only): none" + ] + assert evaluate.stall_lines({"checked": 0, "total": 7, "stalls": []}, "candidate")[0].endswith(": unknown") diff --git a/utama_core/tests/engine/test_evaluate_run.py b/utama_core/tests/engine/test_evaluate_run.py new file mode 100644 index 000000000..f80ed5a36 --- /dev/null +++ b/utama_core/tests/engine/test_evaluate_run.py @@ -0,0 +1,281 @@ +"""`evaluate.py` end to end with matches, fingerprints and the catalog stubbed: which matches each round +plays, what the match results store saves them from, and what the flags change. + +A player's fingerprint is its name plus a version number, so "editing" a strategy is bumping its +version. `tests/replay/test_match_results.py` covers the store itself. +""" + +from __future__ import annotations + +import json +from pathlib import Path + +import pytest + +from tools.evaluation import evaluate +from tools.evaluation.match import MatchResult +from utama_core.analysis import ratings +from utama_core.replay import match_results + +CORE = ["a", "b", "d"] +RESERVE = ["r1", "r2", "r3"] + + +def candidate_wins(a, b, seed): + """The candidate "c" wins 2-0 whatever its colour; every other match is 1-0 to config_a.""" + return (2, 0) if a == "c" else (0, 2) if b == "c" else (1, 0) + + +class _Graph: + def __init__(self, rig): + self.rig = rig + + def base_fingerprint(self, entries): + return "base" + + def strategy_fingerprint(self, name): + if name.endswith(".strategy"): # a frozen file: the code of the strategy it was built from, then + base = Path(name).stem.split("@")[0] + return f"{self.rig.frozen_version}-{base}" + return f"{self.rig.version[name]}-{name}" # version first: the tool keeps 16 characters + + +@pytest.fixture +def rig(tmp_path, monkeypatch): + rig = type("Rig", (), {})() + rig.played, rig.kwargs = [], [] + rig.version = {n: 0 for n in [*CORE, *RESERVE, "c"]} + rig.stats = {} # (a, b) -> stats of that match + rig.on_play = None + rig.frozen_version = 0 # a frozen file's code is its strategy at version 0 + rig.score = lambda a, b, seed: (1, 0) + rig.crash = set() # (a, b) pairs whose match raises + + def fake_run_match(a, b, run_dir=None, **kwargs): + rig.played.append((a, b, kwargs["sim_noise"].seed)) + rig.kwargs.append(kwargs) + if rig.on_play is not None: + rig.on_play() + if (a, b) in rig.crash: + raise RuntimeError("rsim died") + score_a, score_b = rig.score(a, b, kwargs["sim_noise"].seed) + return MatchResult( + config_a=a, config_b=b, score_a=score_a, score_b=score_b, stats=rig.stats.get((a, b), {"x": 1}) + ) + + players = tmp_path / "players.json" + players.write_text(json.dumps({"champion": "a", "core": CORE})) + monkeypatch.setattr(evaluate, "run_match", fake_run_match) + monkeypatch.setattr(evaluate, "REPLAY_BASE_PATH", tmp_path) + monkeypatch.setattr(evaluate, "CodeGraph", lambda: _Graph(rig)) + monkeypatch.setattr(evaluate, "_CONFIG_NAMES", [*CORE, *RESERVE, "c"]) + monkeypatch.setattr(evaluate, "WORKERS", 1) # in this process, so the stubs apply + monkeypatch.setattr(evaluate, "at_ref", lambda name, ref: name) # the reference: the core's own "a" + monkeypatch.setattr(evaluate, "latest_release", lambda: "v0") + + def run(*argv): + rig.played.clear() + rig.kwargs.clear() + evaluate.main(["--players", str(players), *argv]) + (run_dir,) = sorted(tmp_path.glob("eval_*"))[-1:] + return run_dir + + rig.run = run + rig.store = match_results.open_store(tmp_path) + return rig + + +def test_with_no_candidate_one_round_plays_every_pair_of_the_core(rig): + run_dir = rig.run() + + # the core a, b, d; a is also the reference; the reserve r1, r2, r3 and c play only with --all + assert sorted((x, y) for x, y, _ in rig.played) == [("a", "b"), ("a", "d"), ("b", "d")] + assert {seed for *_, seed in rig.played} == {1} + summary = json.loads((run_dir / "round_1" / "summary.json").read_text()) + assert len(summary["results"]) == 3 and "strategies" in summary + assert not (run_dir / "round_2").exists() + assert json.loads((run_dir / "report.json").read_text())["candidates"] == {} + + +def test_all_adds_every_other_strategy_in_the_catalog(rig): + rig.run("--all") + assert len(rig.played) == 7 * 6 // 2 # a, b, d, r1, r2, r3, c: every pair once + + +def test_a_second_run_plays_nothing_and_after_an_edit_only_that_strategys_matches_play(rig): + rig.run() + rig.run() + assert rig.played == [] + + rig.version["d"] += 1 + rig.run() + assert sorted((x, y) for x, y, _ in rig.played) == [("a", "d"), ("b", "d")] + + +def test_a_later_round_is_the_same_round_robin_under_the_next_seed_with_colours_swapped(rig, monkeypatch): + monkeypatch.setattr(ratings, "ROUNDS", 2) + run_dir = rig.run("c") + + round_2 = [(x, y) for x, y, seed in rig.played if seed == 2] # the screen never decides after one round + assert sorted(round_2) == [("a", "c"), ("b", "a"), ("b", "c"), ("d", "a"), ("d", "b"), ("d", "c")] + + rig.version["c"] += 1 # edit the candidate: only its matches play again, in both rounds + rig.run("c") + assert all("c" in (x, y) for x, y, _ in rig.played) and len(rig.played) == 6 + report = json.loads((run_dir / "report.json").read_text()) + # equal results: every diff 0, so the mean diff is <= 0 and the screen drops it at its second round + assert report["candidates"]["c"]["verdict"] == "dropped" + assert report["candidates"]["c"]["rounds"] == 2 + assert {s["seed"] for s in report["rounds"]} == {1, 2} # a dropped candidate never reaches seed 101 + + +def test_a_match_is_stored_only_if_its_code_is_unchanged_when_it_finishes(rig): + def edit(): + rig.version["d"] = 9 + + rig.on_play = edit + rig.run() + + stored = {(r["a"], r["b"]) for r in map(json.loads, map(lambda p: p.read_text(), rig.store.root.rglob("*.json")))} + assert ("a", "b") in stored + assert not any("d" in pair for pair in stored) + + +def test_at_ref_falls_back_to_the_name_a_strategy_had_at_that_commit(monkeypatch, tmp_path): + built = [] + + def fake_frozen(name, ref, directory): + built.append(name) + if name != "split_shape": + raise ValueError(f"no strategy {name}") + return tmp_path / f"{name}@abc.strategy" + + monkeypatch.setattr(evaluate, "frozen", fake_frozen) + assert evaluate.at_ref("pendulum", "v2.5.0").endswith("split_shape@abc.strategy") + assert built == ["pendulum", "split_shape"] + + +def test_a_reused_match_is_linked_into_the_new_rounds_folder_from_the_run_that_played_it(rig, monkeypatch): + def run_match_writing_files(a, b, run_dir=None, **kwargs): + rig.played.append((a, b, kwargs["sim_noise"].seed)) + for suffix in (".npz", ".stats.json"): + (run_dir / f"{evaluate.tag(a, b)}{suffix}").write_text(a + b) + return MatchResult(config_a=a, config_b=b, score_a=1, score_b=0, stats={"x": 1}) + + monkeypatch.setattr(evaluate, "run_match", run_match_writing_files) + monkeypatch.setattr(evaluate, "analyse_replay", lambda npz: (None, None)) + first = rig.run() + rig.version["d"] += 1 + second = rig.run() + + assert sorted((x, y) for x, y, _ in rig.played) == [("a", "d"), ("b", "d")] + linked = second / "round_1" / "a_vs_b.npz" + assert linked.is_symlink() and linked.resolve() == (first / "round_1" / "a_vs_b.npz").resolve() + assert (second / "round_1" / "a_vs_b.stats.json").read_text() == "ab" + assert len(list((second / "round_1").glob("*.npz"))) == 3 # every match of the round, played or reused + + +FROZEN_A = "replays/eval/frozen/a@v0.strategy" + + +def test_the_frozen_champion_and_the_unchanged_champion_are_one_player(rig, monkeypatch): + # Right after a release the frozen champion is the working-tree champion's code: two names, one + # fingerprint. Both playing made the reference play itself and its matches go by either name. + monkeypatch.setattr(evaluate, "at_ref", lambda name, ref: FROZEN_A) + run_dir = rig.run("c") + + assert not any("a" in (x, y) for x, y, _ in rig.played) # the working-tree "a" is left out + assert ("c", FROZEN_A) in {(x, y) for x, y, _ in rig.played} + report = json.loads((run_dir / "report.json").read_text()) + assert report["core"] == ["b", "d"] + assert report["candidates"]["c"]["per_opponent"]["b"]["matches"] >= 1 # paired against the reference + + rig.version["a"] += 1 # the champion edited since the release: two players again + rig.run() + assert {("a", "b"), ("a", "d")} <= {(x, y) for x, y, _ in rig.played} + + +def test_the_reference_is_the_champion_named_at_the_release_not_one_promoted_since(rig, monkeypatch): + real_git = evaluate._git + released = json.dumps({"champion": "b", "core": CORE}) + monkeypatch.setattr(evaluate, "_git", lambda *a: released if a[0] == "show" else real_git(*a)) + run_dir = rig.run() # today's players.json names "a" + assert json.loads((run_dir / "report.json").read_text())["reference"] == "b" + + +def test_the_champion_at_a_release_without_a_players_file_is_todays(monkeypatch): + monkeypatch.setattr(evaluate, "_git", lambda *a: None) + assert evaluate.champion_at("v2.5.0", "pendulum") == "pendulum" + + +def test_no_release_tag_stops_instead_of_using_todays_code(monkeypatch): + monkeypatch.setattr(evaluate, "_git", lambda *a: None) + with pytest.raises(SystemExit, match="No release tag"): + evaluate.latest_release() + + +def test_the_verdict_does_not_depend_on_other_seeds_already_in_the_store(rig, monkeypatch): + monkeypatch.setattr(ratings, "ROUNDS", 2) + rig.score = candidate_wins + first = json.loads((rig.run("c") / "report.json").read_text())["candidates"]["c"] + + # a longer run leaves seeds 3 and 103 in the store, with very different scores + monkeypatch.setattr(ratings, "ROUNDS", 3) + rig.score = lambda a, b, seed: (0, 9) if seed in (3, 103) else candidate_wins(a, b, seed) + rig.run("c") + + monkeypatch.setattr(ratings, "ROUNDS", 2) + again = json.loads((rig.run("c") / "report.json").read_text())["candidates"]["c"] + assert rig.played == [] + assert (again["screen"], again["confirm"]) == (first["screen"], first["confirm"]) + + +def test_a_crashed_match_is_reported_not_stored_and_the_run_finishes(rig): + rig.crash = {("b", "d")} + run_dir = rig.run() + + summary = json.loads((run_dir / "round_1" / "summary.json").read_text()) + assert [(f["config_a"], f["config_b"]) for f in summary["failed"]] == [("b", "d")] + assert len(summary["results"]) == 2 + assert json.loads((run_dir / "report.json").read_text())["failed"][0]["error"] == "RuntimeError('rsim died')" + rig.crash = set() + rig.run() + assert [(x, y) for x, y, _ in rig.played] == [("b", "d")] # not stored, so played next time + + +def test_same_code_keeps_the_first_name_of_each_fingerprint(): + fps = {"ref": "1", "cand": "2", "a": "1", "b": "3", "c": "2"} + assert evaluate.same_code(["ref", "cand", "a", "b", "c"], fps) == {"a": "ref", "c": "cand"} + + +def test_a_candidate_that_survives_the_screen_is_accepted_only_on_fresh_seeds(rig, monkeypatch): + monkeypatch.setattr(ratings, "ROUNDS", 2) + rig.score = candidate_wins + run_dir = rig.run("c") + + assert {seed for *_, seed in rig.played} == {1, 2, 101, 102} + report = json.loads((run_dir / "report.json").read_text()) + c = report["candidates"]["c"] + assert (c["verdict"], c["decided_in"], c["rounds"]) == ("better", "confirm", 4) + assert c["confirm"]["n"] == 2 * 2 # the confirm stage's own diffs: 2 opponents x 2 rounds, not the screen's + assert json.loads((run_dir / "round_3" / "summary.json").read_text())["seed"] == 101 + + +def test_the_candidate_is_also_measured_against_todays_champion_when_shared_code_moved(rig, tmp_path, monkeypatch): + # today's champion "d" sits last in the core; the release froze it before a shared-code change + players = tmp_path / "players_d.json" + players.write_text(json.dumps({"champion": "d", "core": CORE})) + monkeypatch.setattr(evaluate, "at_ref", lambda name, ref: f"replays/eval/frozen/{name}@v0.strategy") + rig.version["d"] = 1 # differs from its frozen copy (version 0) + monkeypatch.setattr(ratings, "ROUNDS", 2) + run_dir = rig.run("c", "--players", str(players)) + + r = json.loads((run_dir / "report.json").read_text())["candidates"]["c"] + vs = r["vs_todays_champion"] + # paired against "a" and "b" in every round: "d" meets them in the candidate's colour + assert vs["name"] == "d" and vs["n"] == 2 * r["rounds"] + + +def test_no_second_estimate_when_todays_champion_is_the_reference(rig): + run_dir = rig.run("c") # the stub reference is "a" itself + assert "vs_todays_champion" not in json.loads((run_dir / "report.json").read_text())["candidates"]["c"] diff --git a/utama_core/tests/engine/test_tournament_summary.py b/utama_core/tests/engine/test_evaluate_signals.py similarity index 73% rename from utama_core/tests/engine/test_tournament_summary.py rename to utama_core/tests/engine/test_evaluate_signals.py index 8e9f52fe6..9369e8cc8 100644 --- a/utama_core/tests/engine/test_tournament_summary.py +++ b/utama_core/tests/engine/test_evaluate_signals.py @@ -1,11 +1,11 @@ -from tools.evaluation.round_robin import foul_table, stall_incidents +from tools.evaluation.evaluate import foul_table, stall_incidents from utama_core.analysis.strategy_table import strategy_table def _result(a: str, b: str, score_a: int, score_b: int) -> dict: return { - "config_a": f"build_{a}_kernel_strategy", - "config_b": f"build_{b}_kernel_strategy", + "config_a": a, + "config_b": b, "score_a": score_a, "score_b": score_b, "stats": { @@ -29,7 +29,7 @@ def test_strategy_table_reads_each_side_from_its_own_perspective(): results, real_losses_by_match={"x_vs_y": {"tackled": 3, "foul": 1}, "y_vs_x": {"pass_intercepted": 6}} ) - x = table["build_x_kernel_strategy"] + x = table["x"] assert (x["matches"], x["wins"], x["draws"], x["losses"]) == (2, 1, 1, 0) assert (x["goals_for"], x["goals_against"]) == (2, 1) assert x["shots"] == 3 + 1 # friendly in x_vs_y, enemy in y_vs_x @@ -39,7 +39,7 @@ def test_strategy_table_reads_each_side_from_its_own_perspective(): assert (x["matches_as_a"], x["real_losses_as_a"]) == (1, 4) assert x["real_loss_kinds_as_a"] == {"tackled": 3, "foul": 1} - y = table["build_y_kernel_strategy"] + y = table["y"] assert (y["wins"], y["draws"], y["losses"]) == (0, 1, 1) assert (y["matches_as_a"], y["real_losses_as_a"]) == (1, 6) @@ -60,12 +60,12 @@ def test_strategy_table_reads_chances_and_pass_progress_for_both_sides(): table = strategy_table([a, b], chances_by_match={"x_vs_y": record}) - x, y = table["build_x_kernel_strategy"]["chances"], table["build_y_kernel_strategy"]["chances"] + x, y = table["x"]["chances"], table["y"]["chances"] assert (x["matches"], x["shots"], x["conversion"], x["save_rate"]) == (1, 2, 0.5, 1.0) assert (y["matches"], y["shots"], y["save_rate"], y["danger_s_per_match"]) == (1, 1, 0.5, 8.0) - assert table["build_x_kernel_strategy"]["pass_progress_m"] == 1.0 - assert table["build_x_kernel_strategy"]["forward_pass_share"] == 0.5 - assert table["build_y_kernel_strategy"]["pass_progress_m"] == -1.0 + assert table["x"]["pass_progress_m"] == 1.0 + assert table["x"]["forward_pass_share"] == 0.5 + assert table["y"]["pass_progress_m"] == -1.0 def test_strategy_table_counts_stalled_matches_for_both_sides(): @@ -78,15 +78,15 @@ def test_strategy_table_counts_stalled_matches_for_both_sides(): table = strategy_table([stalled, backstop, _result("y", "z", 2, 0)]) - assert table["build_x_kernel_strategy"]["stalled"] == 2 - assert table["build_x_kernel_strategy"]["wins"] == 1 - assert table["build_y_kernel_strategy"]["stalled"] == 1 - assert table["build_z_kernel_strategy"]["stalled"] == 1 + assert table["x"]["stalled"] == 2 + assert table["x"]["wins"] == 1 + assert table["y"]["stalled"] == 1 + assert table["z"]["stalled"] == 1 def test_strategy_table_without_replays_leaves_real_losses_empty(): table = strategy_table([_result("x", "y", 1, 1)]) - assert table["build_x_kernel_strategy"]["matches_as_a"] == 0 + assert table["x"]["matches_as_a"] == 0 def test_foul_table_attributes_each_side_to_its_own_strategy(): @@ -97,8 +97,8 @@ def foul(rule, side, tactic, inferred=False): results = [ { - "config_a": "build_alpha_kernel_strategy", - "config_b": "build_beta_kernel_strategy", + "config_a": "alpha", + "config_b": "beta", "stats": { "fouls": [ foul("excessive_dribbling", "friendly", "lure"), @@ -108,7 +108,7 @@ def foul(rule, side, tactic, inferred=False): ] }, }, - {"config_a": "build_beta_kernel_strategy", "config_b": "build_alpha_kernel_strategy", "stats": None}, + {"config_a": "beta", "config_b": "alpha", "stats": None}, ] table = foul_table(results) @@ -126,31 +126,22 @@ def _stalled(a: str, b: str, sim_time: float, duration_s: float = 11.3) -> dict: def test_one_deterministic_freeze_against_two_opponents_is_one_incident(): """RR 2026-09-28: overload_flow froze at t=20.5 for 11.3 s against both - press_trigger_flow and score_aware_counter_flow -- the same freeze, since rsim is + tripwire and chameleon -- the same freeze, since rsim is deterministic and neither opponent had diverged yet. The same times with no shared strategy, or a tick apart, are different incidents.""" results = [ - _stalled("overload_flow", "press_trigger_flow", 20.5), - _stalled("overload_flow", "score_aware_counter_flow", 20.5 + 1e-9), + _stalled("overload_flow", "tripwire", 20.5), + _stalled("overload_flow", "chameleon", 20.5 + 1e-9), _stalled("tiki_taka", "zone_fluid", 20.5), _stalled("overload_flow", "low_block", 20.5 + 1 / 60), - _result("overload_flow", "high_press", 0, 0), + _result("overload_flow", "wolfpack", 0, 0), ] incidents = stall_incidents(results) assert [i["matches"] for i in incidents] == [ - ["overload_flow_vs_press_trigger_flow", "overload_flow_vs_score_aware_counter_flow"], + ["overload_flow_vs_tripwire", "overload_flow_vs_chameleon"], ["tiki_taka_vs_zone_fluid"], ["overload_flow_vs_low_block"], ] assert incidents[0]["kind"] == "COMMITTED_FROZEN" - - -def test_ratings_table_ranks_by_goal_margin_with_an_sd(): - from tools.evaluation.round_robin import _ratings - - table = _ratings([_result("x", "y", 3, 0), _result("y", "z", 2, 0), _result("x", "z", 4, 1)]) - x, z = table["build_x_kernel_strategy"], table["build_z_kernel_strategy"] - assert x["strength"] > table["build_y_kernel_strategy"]["strength"] > z["strength"] - assert x["sd"] > 0 diff --git a/utama_core/tests/engine/test_explain.py b/utama_core/tests/engine/test_explain.py index 78ff6ab7d..1143a7fcd 100644 --- a/utama_core/tests/engine/test_explain.py +++ b/utama_core/tests/engine/test_explain.py @@ -1,13 +1,12 @@ """`tools/evaluation/explain.py` on a synthetic run dir of real columnar replays: the side assignment (a candidate's numbers come from its own matches, against any opponent), the goals from the final -referee state, the paired goal difference, the four files, and `evaluate.py --explain` off by default.""" +referee state, the paired goal difference and the four files.""" import json import pytest -from tools import pitch_maps as pm -from tools.evaluation import evaluate, explain +from tools.evaluation import explain from utama_core.entities.data.referee import RefereeData from utama_core.entities.data.vector import Vector2D, Vector3D from utama_core.entities.game import Ball, GameFrame, Robot @@ -20,8 +19,8 @@ ) CAND, CHAMP, OPP1, OPP2 = ( - "build_cand_kernel_strategy", - "build_champ_kernel_strategy", + "cand", + "champ", "build_opp1_kernel_strategy", "build_opp2_kernel_strategy", ) @@ -55,8 +54,8 @@ def _referee(score_yellow, score_blue): def _write_match(run_dir, a, b, score_a, score_b, seed=None): """A three-tick match, config_a (yellow, friendly) scoring `score_a`; the team with the ball is - always the friendly one. Written the way `evaluate.py`/`round_robin.py` name their files.""" - stem = f"{pm.sr.short(a)}_vs_{pm.sr.short(b)}" + ("" if seed is None else f"_s{seed}") + always the friendly one. Written the way `evaluate.py` names their files.""" + stem = f"{explain._short_name(a)}_vs_{explain._short_name(b)}" + ("" if seed is None else f"_s{seed}") path = run_dir / f"{stem}.npz" cfg = ColumnarReplayWriterConfig(replay_name=stem, overwrite_existing=True, checkpoint_every_s=0) writer = ColumnarReplayWriter(cfg, my_team_is_yellow=True, exp_friendly=3, exp_enemy=3, path=path) @@ -107,7 +106,7 @@ def test_explain_writes_the_four_files(run_dir, tmp_path): data = (out / name).read_bytes() assert data[:8] == b"\x89PNG\r\n\x1a\n" and len(data) < 250_000 assert json.loads((out / "summary.json").read_text())["candidate"] == "cand" - assert (out / "triage" / "index.md").exists() # the candidate's worst matches, as config_a + assert (out / "find_bugs" / "index.md").exists() # the candidate's worst matches, as config_a def test_each_side_counts_its_own_matches_and_goals(run_dir, tmp_path): @@ -133,17 +132,4 @@ def test_paired_difference_uses_same_opponent_seed_and_colour(run_dir, tmp_path) def test_explain_refuses_when_a_side_has_no_replay(run_dir, tmp_path): with pytest.raises(FileNotFoundError): - explain.explain(run_dir, "build_nobody_kernel_strategy", CHAMP, tmp_path / "out", workers=1) - - -def test_evaluate_explain_is_off_by_default(): - assert evaluate.build_parser().parse_args(["build_x_kernel_strategy"]).explain is False - assert evaluate.build_parser().parse_args(["build_x_kernel_strategy", "--explain"]).explain is True - - -def test_an_explain_failure_never_escapes(monkeypatch, tmp_path): - def boom(*args, **kwargs): - raise RuntimeError("no replays") - - monkeypatch.setattr(explain, "explain", boom) - evaluate._explain(tmp_path, "eval_test", [CAND], CHAMP) # must print and return, not raise + explain.explain(run_dir, "nobody", CHAMP, tmp_path / "out", workers=1) diff --git a/utama_core/tests/engine/test_give_and_go_tactic.py b/utama_core/tests/engine/test_give_and_go_tactic.py index d6faf3b08..bf03dc933 100644 --- a/utama_core/tests/engine/test_give_and_go_tactic.py +++ b/utama_core/tests/engine/test_give_and_go_tactic.py @@ -35,14 +35,19 @@ from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.game.robot import Robot -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.shared.pass_and_score_geometry import find_best_shot +from utama_core.geometry.pass_and_score_geometry import ( + MIN_OPEN_TEAMMATE_M, + find_best_shot, +) +from utama_core.motion_planning.common.motion_controller import MotionController from utama_core.tactics.give_and_go import ( _FIRST_TOUCH_FORCE_SHOT_TICKS, _MAX_FIRST_TOUCH_TICKS, _MAX_HOP_TICKS, + _MAX_PASS_WAIT_TICKS, GiveAndGoMem, GiveAndGoTactic, + _nearest_safe_receiver, _relocate_target, ) @@ -185,7 +190,7 @@ def test_carrier_does_not_hold_again_after_the_first_touch_hold_times_out(): tactic = GiveAndGoTactic() mem = tactic.initial_mem() - for _ in range(_MAX_HOP_TICKS - 1): + for _ in range(_MAX_PASS_WAIT_TICKS - 1): _, mem = tactic.tick(game, ctx, (1, 2), mem) held = ctx.motion_controller.targets[1] assert held.distance_to(Vector2D(0.0, 0.0)) < 1e-6 # holding in place during the hold @@ -198,6 +203,25 @@ def test_carrier_does_not_hold_again_after_the_first_touch_hold_times_out(): assert ctx.motion_controller.targets[1].distance_to(Vector2D(0.0, 0.0)) > 0.5 +def test_a_carrier_stops_waiting_for_its_receiver_after_the_limit(monkeypatch): + """Carriers stood with the ball for 9 s after free kicks, two 4 s waits for a receiver in + a row (high_press_vs_split_shape t=500.6, tournament_20261109_225810).""" + calls = [] + + def _fake_pass_exec(game, ctx, passer, receiver, kick_now=False): + calls.append(kick_now) + return {}, False, False + + monkeypatch.setattr("utama_core.tactics.give_and_go._pass_exec", _fake_pass_exec) + game = _make_game(carrier_pos=Vector2D(0.0, 0.0), teammate_pos=Vector2D(1.5, 1.5), enemy_pos=Vector2D(3.0, -2.5)) + ctx = TickContext(motion_controller=_PerRobotMotionController(), match_log=None) + tactic = GiveAndGoTactic() + mem = tactic.initial_mem() + for _ in range(_MAX_PASS_WAIT_TICKS): + _, mem = tactic.tick(game, ctx, (1, 2), mem) + assert calls[-2:] == [False, True] + + def _make_flicker_game() -> Game: """Carrier facing +x, teammate off-axis at (1.5, 2.0), enemy at (1.0, 0.0). @@ -257,11 +281,11 @@ def test_first_touch_stuck_gives_up_after_max_first_touch_ticks(): assert mem.hop_count == 0 -def _make_open_lane_game(carrier_orientation: float) -> Game: +def _make_open_lane_game(carrier_orientation: float, teammate_pos: Vector2D = Vector2D(0.3, 0.3)) -> Game: """No enemies at all (shot lane always open — `find_best_shot` never returns None) and a teammate close enough to be a real ally but inside - `_MIN_SAFE_PASS_DISTANCE`, so `_nearest_safe_receiver` never selects it - (`dist < _MIN_SAFE_PASS_DISTANCE: continue`) -- `mem.receiver_id` stays + `MIN_OPEN_TEAMMATE_M`, so `_nearest_safe_receiver` never selects it + (`dist < MIN_OPEN_TEAMMATE_M: continue`) -- `mem.receiver_id` stays None forever without needing a blocked lane, isolating the `first_touch_stuck`/`force_shot` interaction from any pass mechanics. `carrier_orientation` lets a test aim the carrier at the enemy goal @@ -269,7 +293,6 @@ def _make_open_lane_game(carrier_orientation: float) -> Game: takes the immediate-`kick()` branch rather than `turn_on_spot`. """ carrier_pos = Vector2D(0.0, 0.0) - teammate_pos = Vector2D(0.3, 0.3) # well under _MIN_SAFE_PASS_DISTANCE (0.7m) friendly = { 1: Robot( id=1, @@ -336,7 +359,7 @@ def test_first_touch_stuck_eventually_force_shoots_instead_of_repositioning_fore # --------------------------------------------------------------------------- # # Found live investigating a real "these strategies never shoot" bug -# (high_press/overload_flow/score_aware_zone_flow, 2026-09-05, +# (wolfpack/overload_flow/score_aware_zone_flow, 2026-09-05, # docs/roadmap.md): `_relocate_target` generated candidates at # `ball_x + dx` with hardcoded positive `dx` -- correct for a team attacking # +x, but for `my_team_is_right=True` (this codebase's convention: the enemy @@ -472,13 +495,14 @@ def test_relocate_others_clamps_deep_targets_outside_the_enemy_defense_area(): @pytest.mark.parametrize(("carried", "expect_kick"), [(0.79, False), (0.80, True)]) -def test_no_lane_strafe_shoots_once_the_carry_reaches_0_8m(carried, expect_kick): +def test_no_lane_strafe_shoots_once_the_carry_reaches_0_8m(carried, expect_kick, monkeypatch): """With every shot lane walled off, the carrier strafes sideways looking for one (`no_shot_reposition_target`). That strafe had no end of its own and carried the ball past `ExcessiveDribblingRule`'s 1.0m — 51 fouls in the 2026-09-23 round-robin. At `CARRY_LIMIT_M` (0.8m) from where the - dribble began, it must shoot at the goal centre instead (already facing - it here, so `kick()` this tick).""" + dribble began, it must kick along `release_heading` instead (already + facing it here, so `kick()` this tick).""" + monkeypatch.setattr("utama_core.tactics.give_and_go.release_heading", lambda *a: math.pi) carrier_pos = Vector2D(-3.0, 0.0) friendly = { 1: Robot( @@ -674,3 +698,11 @@ def test_lone_carrier_switches_aim_when_the_keeper_clearly_opens_the_other_side( # The keeper steps 0.3 m toward the aimed-at corner: the other side is now far wider. first, after_step = _aimed_side([0.01, -0.3 if aims_low else 0.3]) assert first != after_step + + +@pytest.mark.parametrize("gap, chosen", [(MIN_OPEN_TEAMMATE_M - 0.05, False), (MIN_OPEN_TEAMMATE_M + 0.05, True)]) +def test_first_touch_pass_skips_a_teammate_too_near_to_adjust(gap, chosen): + """A first-touch pass goes to a teammate at least `MIN_OPEN_TEAMMATE_M` away: nearer, a + full-power kick arrives before the receiver can adjust (28% received under 1.5 m).""" + game = _make_open_lane_game(0.0, teammate_pos=Vector2D(gap, 0.0)) + assert (_nearest_safe_receiver(game, 1, (2,)) == 2) is chosen diff --git a/utama_core/tests/engine/test_kernel_strategy.py b/utama_core/tests/engine/test_kernel_strategy.py index 2be40aafc..70f228e19 100644 --- a/utama_core/tests/engine/test_kernel_strategy.py +++ b/utama_core/tests/engine/test_kernel_strategy.py @@ -13,14 +13,14 @@ import pytest from utama_core.engine.abstract_strategy import AbstractStrategy -from utama_core.strategy.kernel_strategy import build_default_kernel_strategy +from utama_core.strategy.catalog import builder @pytest.fixture def kernel_runner(): from utama_core.run.strategy_runner import StrategyRunner - strategy = AbstractStrategy(build_kernel_strategy=build_default_kernel_strategy((1, 2))) + strategy = AbstractStrategy(build=builder("default", (1, 2))) runner = StrategyRunner( strategy=strategy, my_team_is_yellow=True, @@ -65,7 +65,7 @@ def test_kernel_strategy_is_built_by_load_motion_controller_alone(): """Direct unit-level check (no rsim, no full runner) that `AbstractStrategy` doesn't need `load_game` at all to build its `Strategy` — only `load_motion_controller`, called with a bare stand-in object.""" - strategy = AbstractStrategy(build_kernel_strategy=build_default_kernel_strategy((1, 2))) + strategy = AbstractStrategy(build=builder("default", (1, 2))) assert strategy._kernel_strategy is None strategy.load_motion_controller(motion_controller=object()) diff --git a/utama_core/tests/engine/test_kernel_strategy_debug_status.py b/utama_core/tests/engine/test_kernel_strategy_debug_status.py index 07aefc69f..3d923b995 100644 --- a/utama_core/tests/engine/test_kernel_strategy_debug_status.py +++ b/utama_core/tests/engine/test_kernel_strategy_debug_status.py @@ -11,14 +11,14 @@ from utama_core.engine.abstract_strategy import AbstractStrategy, robot_steps from utama_core.engine.tactic import TacticTag from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.strategy.kernel_strategy import build_split_shape_kernel_strategy +from utama_core.strategy.catalog import builder @pytest.fixture -def split_shape_runner(): +def pendulum_runner(): from utama_core.run.strategy_runner import StrategyRunner - strategy = AbstractStrategy(build_kernel_strategy=build_split_shape_kernel_strategy((1, 2, 3, 4, 5))) + strategy = AbstractStrategy(build=builder("pendulum", (1, 2, 3, 4, 5))) runner = StrategyRunner( strategy=strategy, my_team_is_yellow=True, @@ -32,9 +32,9 @@ def split_shape_runner(): runner.close() -def test_debug_status_covers_goalkeeper_and_all_outfield_robots(split_shape_runner): - split_shape_runner.step_once() - strategy = split_shape_runner.my.strategy +def test_debug_status_covers_goalkeeper_and_all_outfield_robots(pendulum_runner): + pendulum_runner.step_once() + strategy = pendulum_runner.my.strategy status = strategy.debug_status() assert status[0][:2] == ["goalkeeper", ""] @@ -43,9 +43,9 @@ def test_debug_status_covers_goalkeeper_and_all_outfield_robots(split_shape_runn assert len(status[robot_id]) == 3 # [label, tag, steps] -def test_debug_status_labels_match_active_partition(split_shape_runner): - split_shape_runner.step_once() - strategy = split_shape_runner.my.strategy +def test_debug_status_labels_match_active_partition(pendulum_runner): + pendulum_runner.step_once() + strategy = pendulum_runner.my.strategy status = strategy.debug_status() partition = strategy._kernel_strategy.active_partition @@ -54,10 +54,10 @@ def test_debug_status_labels_match_active_partition(split_shape_runner): assert status[robot_id][0].startswith(tactic_id) -def test_slot_status_reports_committed_flag(split_shape_runner): - split_shape_runner.step_once() - strategy = split_shape_runner.my.strategy - game = split_shape_runner.my.game +def test_slot_status_reports_committed_flag(pendulum_runner): + pendulum_runner.step_once() + strategy = pendulum_runner.my.strategy + game = pendulum_runner.my.game status = strategy._kernel_strategy.slot_status(game) for tactic_id, info in status.items(): @@ -65,12 +65,12 @@ def test_slot_status_reports_committed_flag(split_shape_runner): assert info["robots"] -def test_debug_status_tag_is_the_assigned_tactics_own_tag(split_shape_runner): +def test_debug_status_tag_is_the_assigned_tactics_own_tag(pendulum_runner): # The dashboard colours each robot by this second element, so it must be the tag the # tactic currently holding the robot declares, not a per-robot or per-strategy guess. - split_shape_runner.step_once() - strategy = split_shape_runner.my.strategy - game = split_shape_runner.my.game + pendulum_runner.step_once() + strategy = pendulum_runner.my.strategy + game = pendulum_runner.my.game status = strategy.debug_status() for tactic_id, info in strategy._kernel_strategy.slot_status(game).items(): @@ -84,7 +84,7 @@ def test_debug_status_leaves_out_a_goalkeeper_whose_robot_is_not_on_the_field(): phantom "goalkeeper" row for a robot ID that is not there.""" from utama_core.run.strategy_runner import StrategyRunner - strategy = AbstractStrategy(build_kernel_strategy=build_split_shape_kernel_strategy((0, 1)), goalkeeper_id=15) + strategy = AbstractStrategy(build=builder("pendulum", (0, 1)), goalkeeper_id=15) runner = StrategyRunner( strategy=strategy, my_team_is_yellow=True, my_team_is_right=True, mode="rsim", exp_friendly=2, exp_enemy=0 ) @@ -98,14 +98,14 @@ def test_debug_status_leaves_out_a_goalkeeper_whose_robot_is_not_on_the_field(): def _refereed_runner(command, notifier=None): - """`split_shape` under our own referee, seeded with `command`; `notifier` stands in for a dashboard.""" - from utama_core.custom_referee import CustomReferee + """`pendulum` under our own referee, seeded with `command`; `notifier` stands in for a dashboard.""" + from utama_core.referee import CustomReferee from utama_core.run.strategy_runner import StrategyRunner referee = CustomReferee.from_profile_name("simulation", n_robots_yellow=6, n_robots_blue=3) if notifier is not None: referee.attach_dashboard_notifier(notifier) - strategy = AbstractStrategy(build_kernel_strategy=build_split_shape_kernel_strategy((1, 2, 3, 4, 5))) + strategy = AbstractStrategy(build=builder("pendulum", (1, 2, 3, 4, 5))) return StrategyRunner( strategy=strategy, my_team_is_yellow=True, @@ -147,11 +147,8 @@ def test_in_live_play_no_robot_shows_the_referee(): def test_the_placer_and_the_free_kick_taker_are_named(): - from utama_core.custom_referee.actions import ( - BallPlacementOursStep, - DirectFreeOursStep, - ) from utama_core.engine.referee_override import _job + from utama_core.referee.actions import BallPlacementOursStep, DirectFreeOursStep placement = BallPlacementOursStep() placement._placer_id = 2 diff --git a/utama_core/tests/engine/test_kickoff_goalkeeper_exemption.py b/utama_core/tests/engine/test_kickoff_goalkeeper_exemption.py index d77812c0e..fdbba4405 100644 --- a/utama_core/tests/engine/test_kickoff_goalkeeper_exemption.py +++ b/utama_core/tests/engine/test_kickoff_goalkeeper_exemption.py @@ -30,7 +30,7 @@ from utama_core.entities.game.team_info import TeamInfo from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.entities.referee.stage import Stage -from utama_core.strategy.kernel_strategy import build_split_shape_kernel_strategy +from utama_core.strategy.catalog import builder def _set_referee_command( @@ -59,10 +59,10 @@ def _set_referee_command( @pytest.fixture -def split_shape_runner(): +def pendulum_runner(): from utama_core.run.strategy_runner import StrategyRunner - strategy = AbstractStrategy(build_kernel_strategy=build_split_shape_kernel_strategy((1, 2, 3, 4, 5))) + strategy = AbstractStrategy(build=builder("pendulum", (1, 2, 3, 4, 5))) runner = StrategyRunner( strategy=strategy, my_team_is_yellow=True, @@ -87,7 +87,7 @@ def nonzero_keeper_runner(): from utama_core.run.strategy_runner import StrategyRunner strategy = AbstractStrategy( - build_kernel_strategy=build_split_shape_kernel_strategy((0, 1, 2, 4, 5)), + build=builder("pendulum", (0, 1, 2, 4, 5)), goalkeeper_id=3, ) runner = StrategyRunner( @@ -181,23 +181,23 @@ def test_their_kickoff_nonzero_keeper_is_never_in_defensive_wall(nonzero_keeper_ assert dist_to_ball >= BALL_KEEP_OUT_DISTANCE - 0.05, f"non-keeper robot {rid} inside centre keep-out zone" -def test_our_kickoff_default_keeper_id_zero_still_exempt(split_shape_runner): +def test_our_kickoff_default_keeper_id_zero_still_exempt(pendulum_runner): """Regression check for the common case: with the default `goalkeeper_id=0` (matching `TeamInfo`'s default `goalkeeper=0`), robot 0 must still be excluded from both kicker-selection and the support formation — this isn't relying on "any non-zero ID," it must hold for the original id-0 case too. As with the non-zero-keeper tests above, "exempt" means "goes to GoalkeeperTactic's own-goal tracking," not "frozen.\" """ - game = split_shape_runner.my.game - split_shape_runner.step_once() + game = pendulum_runner.my.game + pendulum_runner.step_once() - split_shape_runner.sim_controller.teleport_robot(True, 0, -3.0, 2.0, 0.0) - split_shape_runner.step_once() + pendulum_runner.sim_controller.teleport_robot(True, 0, -3.0, 2.0, 0.0) + pendulum_runner.step_once() - _set_referee_command(split_shape_runner, RefereeCommand.PREPARE_KICKOFF_YELLOW, yellow_goalkeeper=0) + _set_referee_command(pendulum_runner, RefereeCommand.PREPARE_KICKOFF_YELLOW, yellow_goalkeeper=0) for _ in range(200): - split_shape_runner.step_once() + pendulum_runner.step_once() keeper = game.friendly_robots[0] dist_keeper_to_ball = math.hypot(keeper.p.x - game.ball.p.x, keeper.p.y - game.ball.p.y) @@ -279,7 +279,7 @@ def test_our_kickoff_with_only_keeper_present_does_not_raise(nonzero_keeper_runn keeper). Exercised directly against the Step class with a minimal object, since reproducing "rsim spawned only one robot" isn't practical through the fixture — this only needs to prove the early-return guard fires.""" - from utama_core.custom_referee.actions import PrepareKickoffOursStep + from utama_core.referee.actions import PrepareKickoffOursStep class _FakeRef: designated_position = None @@ -309,7 +309,7 @@ class _Blackboard: assert step.blackboard.cmd_map == {} -def test_their_kickoff_from_the_wrong_half_goes_round_the_centre_circle(split_shape_runner): +def test_their_kickoff_from_the_wrong_half_goes_round_the_centre_circle(pendulum_runner): """After a goal the conceding team is still in the scorer's half (STOP only clears robots near the ball). At PREPARE_KICKOFF they drove straight at their own-half spots through the centre circle and lingered inside the keep-out radius, so @@ -318,10 +318,10 @@ def test_their_kickoff_from_the_wrong_half_goes_round_the_centre_circle(split_sh on the circle in the wrong half (the old push-out left a robot a hair inside the edge, "encroaching", its target its own position).""" from utama_core.config.field_params import STANDARD_FIELD_DIMS - from utama_core.custom_referee.geometry import RefereeGeometry - from utama_core.custom_referee.rules.keep_out_rule import KeepOutRule + from utama_core.referee.geometry import RefereeGeometry + from utama_core.referee.rules.keep_out_rule import KeepOutRule - runner = split_shape_runner + runner = pendulum_runner game = runner.my.game runner.step_once() # my_team_is_right=True: our half is +x. Line the outfield robots up in the diff --git a/utama_core/tests/engine/test_lead_and_support_tactic.py b/utama_core/tests/engine/test_lead_and_support_tactic.py index a68e7c001..3d56561c9 100644 --- a/utama_core/tests/engine/test_lead_and_support_tactic.py +++ b/utama_core/tests/engine/test_lead_and_support_tactic.py @@ -20,8 +20,8 @@ from utama_core.engine.context import TickContext from utama_core.entities.data.vector import Vector2D, Vector3D from utama_core.entities.game import Ball, Field, Game, GameFrame, GameHistory, Robot -from utama_core.motion_planning.src.common.pose_ahead import PoseAhead -from utama_core.shared.pass_and_score_geometry import enemy_defense_area_hold_point +from utama_core.geometry.pass_and_score_geometry import enemy_defense_area_hold_point +from utama_core.motion_planning.common.pose_ahead import PoseAhead from utama_core.tactics.lead_and_support import LeadAndSupportTactic diff --git a/utama_core/tests/engine/test_match_stats.py b/utama_core/tests/engine/test_match_stats.py index cb3ccc2fe..2665ac798 100644 --- a/utama_core/tests/engine/test_match_stats.py +++ b/utama_core/tests/engine/test_match_stats.py @@ -6,7 +6,6 @@ import pytest -from utama_core.custom_referee.rules.base_rule import RuleViolation from utama_core.engine.match_stats import MatchStatsAccumulator from utama_core.entities.data.referee import RefereeData from utama_core.entities.data.vector import Vector2D, Vector3D @@ -16,6 +15,7 @@ from utama_core.entities.game.team_info import TeamInfo from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.entities.referee.stage import Stage +from utama_core.referee.rules.base_rule import RuleViolation def _robot(rid: int, x: float, y: float, is_friendly: bool) -> Robot: @@ -799,3 +799,18 @@ def test_motion_planning_collision_and_clearance_tracking(tmp_path): assert data["opponent_overlap_ticks"] == 0 assert data["opponent_overlap_incidents"] == 0 assert data["worst_clearance_m"] == pytest.approx(-0.08, abs=1e-3) + + +@pytest.mark.parametrize("receiver_x, counted", [(0.49, 0), (0.5, 1)]) +def test_a_handoff_between_adjacent_teammates_is_not_a_pass(receiver_x, counted): + acc = MatchStatsAccumulator() + friendly1 = {1: _robot(1, 0.0, 0.0, True), 3: _robot(3, 5.0, 5.0, True)} + friendly2 = {1: _robot(1, 5.0, 5.0, True), 3: _robot(3, receiver_x, 0.0, True)} + enemy = {2: _robot(2, -5.0, -5.0, False)} + + acc.record_tick(_poss_frame((0.0, 0.0), (0.0, 0.0), friendly1, enemy)) + acc.record_tick(_poss_frame((receiver_x, 0.0), (0.0, 0.0), friendly2, enemy)) + + stats = acc.finalize() + assert stats.completed_passes == counted + assert len(stats.pass_distances_m) == counted diff --git a/utama_core/tests/engine/test_pass_and_score_pass_exec.py b/utama_core/tests/engine/test_pass_and_score_pass_exec.py index 930d82e47..e88acf141 100644 --- a/utama_core/tests/engine/test_pass_and_score_pass_exec.py +++ b/utama_core/tests/engine/test_pass_and_score_pass_exec.py @@ -4,7 +4,7 @@ hop at a receiver for 4+ seconds after two enemies settled onto the direct carrier-receiver line, producing a highly interceptable pass every tick with no way for the caller to notice and abandon early — see -`build_tiki_taka_kernel_strategy` vs `build_counter_press_kernel_strategy`, +`tiki_taka` vs `counter_press`, t≈23s, `give_and_go.pass_target` locked on receiver 3 while enemies 1/5 sat ~0.15m off the direct line (well inside `segment_blocked`'s own default clearance). @@ -30,7 +30,7 @@ def runner(): # `runner_factory` (not shared via conftest — duplicated here rather # than introducing new shared test infra for one extra file). from utama_core.run.strategy_runner import StrategyRunner - from utama_core.tests.strategy_runner.strat_runner_test_utils import DummyStrategy + from utama_core.tests.run.strat_runner_test_utils import DummyStrategy r = StrategyRunner( strategy=DummyStrategy(), diff --git a/utama_core/tests/engine/test_pass_and_shoot_tactic.py b/utama_core/tests/engine/test_pass_and_shoot_tactic.py index 91c140764..1a0092e7e 100644 --- a/utama_core/tests/engine/test_pass_and_shoot_tactic.py +++ b/utama_core/tests/engine/test_pass_and_shoot_tactic.py @@ -22,7 +22,7 @@ from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.game.robot import Robot -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController from utama_core.tactics._pass_and_score import PassAndScoreMem, run_setup_phase from utama_core.tactics.pass_and_shoot import ( _LANE_BLOCKED_ABANDON_TICKS, diff --git a/utama_core/tests/engine/test_press_and_contain_tactic.py b/utama_core/tests/engine/test_press_and_contain_tactic.py index 1d5b70124..02eb5aace 100644 --- a/utama_core/tests/engine/test_press_and_contain_tactic.py +++ b/utama_core/tests/engine/test_press_and_contain_tactic.py @@ -18,7 +18,7 @@ from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.game.robot import Robot -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController from utama_core.tactics.press_and_contain import ( PressAndContainMem, PressAndContainTactic, diff --git a/utama_core/tests/engine/test_referee_override.py b/utama_core/tests/engine/test_referee_override.py index c7f2a7589..c88e8b66c 100644 --- a/utama_core/tests/engine/test_referee_override.py +++ b/utama_core/tests/engine/test_referee_override.py @@ -35,14 +35,14 @@ from utama_core.entities.game.team_info import TeamInfo from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.entities.referee.stage import Stage -from utama_core.strategy.kernel_strategy import build_split_shape_kernel_strategy +from utama_core.strategy.catalog import builder @pytest.fixture -def split_shape_runner(): +def pendulum_runner(): from utama_core.run.strategy_runner import StrategyRunner - strategy = AbstractStrategy(build_kernel_strategy=build_split_shape_kernel_strategy((1, 2, 3, 4, 5))) + strategy = AbstractStrategy(build=builder("pendulum", (1, 2, 3, 4, 5))) runner = StrategyRunner( strategy=strategy, my_team_is_yellow=True, @@ -92,22 +92,22 @@ def _set_referee_command(runner, command: RefereeCommand, designated_position=No _CLEAR_OF_BALL = 0.2 -def test_their_ball_placement_clears_our_robots_from_keep_out_zone(split_shape_runner): +def test_their_ball_placement_clears_our_robots_from_keep_out_zone(pendulum_runner): """During the opponent's ball placement, a robot starting inside the keep-out zone around the ball moves outside it — a plain tactic tick has no notion of this rule and would just leave it there or drive it closer.""" - game = split_shape_runner.my.game - split_shape_runner.step_once() + game = pendulum_runner.my.game + pendulum_runner.step_once() ball_x, ball_y = game.ball.p.x, game.ball.p.y - split_shape_runner.sim_controller.teleport_robot(True, 1, ball_x + _CLEAR_OF_BALL, ball_y, 0.0) - split_shape_runner.step_once() # let the teleport land in game state + pendulum_runner.sim_controller.teleport_robot(True, 1, ball_x + _CLEAR_OF_BALL, ball_y, 0.0) + pendulum_runner.step_once() # let the teleport land in game state designated = (1.5, 0.0) - _set_referee_command(split_shape_runner, RefereeCommand.BALL_PLACEMENT_BLUE, designated_position=designated) + _set_referee_command(pendulum_runner, RefereeCommand.BALL_PLACEMENT_BLUE, designated_position=designated) for _ in range(200): - split_shape_runner.step_once() + pendulum_runner.step_once() ball = game.ball.p for robot_id, robot in game.friendly_robots.items(): @@ -117,21 +117,21 @@ def test_their_ball_placement_clears_our_robots_from_keep_out_zone(split_shape_r assert dist_to_spot >= BALL_KEEP_OUT_DISTANCE - 0.05, f"robot {robot_id} too close to designated spot" -def test_their_kickoff_clears_our_robots_outside_center_circle(split_shape_runner): +def test_their_kickoff_clears_our_robots_outside_center_circle(pendulum_runner): """A robot starting at the centre spot for the opponent's kickoff moves outside the keep-out radius.""" - game = split_shape_runner.my.game - split_shape_runner.step_once() + game = pendulum_runner.my.game + pendulum_runner.step_once() # Inside the keep-out radius but clear of the ball: a robot teleported onto # the ball knocks it off the spot, and where it stops then decides the test. - split_shape_runner.sim_controller.teleport_robot(True, 1, _CLEAR_OF_BALL, 0.0, 0.0) - split_shape_runner.step_once() + pendulum_runner.sim_controller.teleport_robot(True, 1, _CLEAR_OF_BALL, 0.0, 0.0) + pendulum_runner.step_once() - _set_referee_command(split_shape_runner, RefereeCommand.PREPARE_KICKOFF_BLUE) + _set_referee_command(pendulum_runner, RefereeCommand.PREPARE_KICKOFF_BLUE) for _ in range(200): - split_shape_runner.step_once() + pendulum_runner.step_once() ball = game.ball.p assert math.hypot(ball.x, ball.y) < 0.05, "ball left the centre spot" @@ -140,25 +140,25 @@ def test_their_kickoff_clears_our_robots_outside_center_circle(split_shape_runne assert dist_to_ball >= BALL_KEEP_OUT_DISTANCE - 0.05, f"robot {robot_id} inside centre keep-out zone" -def test_override_ends_and_tactics_resume_on_normal_start(split_shape_runner): +def test_override_ends_and_tactics_resume_on_normal_start(pendulum_runner): """Once NORMAL_START arrives after a restart, tactics tick again (mem was reset by the barrier transition on the way in) instead of the override continuing to hold every robot in place forever. Our own kick-off: after the opponent's, the hold lasts until their kicker moves the ball (5.4).""" - strategy = split_shape_runner.my.strategy + strategy = pendulum_runner.my.strategy - _set_referee_command(split_shape_runner, RefereeCommand.PREPARE_KICKOFF_YELLOW) + _set_referee_command(pendulum_runner, RefereeCommand.PREPARE_KICKOFF_YELLOW) for _ in range(50): - split_shape_runner.step_once() + pendulum_runner.step_once() - _set_referee_command(split_shape_runner, RefereeCommand.NORMAL_START) - split_shape_runner.step_once() + _set_referee_command(pendulum_runner, RefereeCommand.NORMAL_START) + pendulum_runner.step_once() partition = strategy._kernel_strategy.active_partition assert partition, "tactics never resumed after the restart ended" -def test_back_to_back_restarts_dispatch_a_fresh_step_each_time(split_shape_runner): +def test_back_to_back_restarts_dispatch_a_fresh_step_each_time(pendulum_runner): """A second restart arriving without an intervening NORMAL_START (e.g. a kickoff foul immediately becoming a ball placement) must dispatch to the *new* command's Step, not keep re-running the first command's Step just @@ -174,23 +174,23 @@ def test_back_to_back_restarts_dispatch_a_fresh_step_each_time(split_shape_runne for "did the override switch commands," even though the switch itself is correct and instant. """ - game = split_shape_runner.my.game - strategy = split_shape_runner.my.strategy._kernel_strategy - split_shape_runner.step_once() + game = pendulum_runner.my.game + strategy = pendulum_runner.my.strategy._kernel_strategy + pendulum_runner.step_once() - _set_referee_command(split_shape_runner, RefereeCommand.PREPARE_KICKOFF_BLUE) - split_shape_runner.step_once() + _set_referee_command(pendulum_runner, RefereeCommand.PREPARE_KICKOFF_BLUE) + pendulum_runner.step_once() kickoff_commands = strategy.tick(game) # No NORMAL_START in between — straight into a second, different restart. - _set_referee_command(split_shape_runner, RefereeCommand.BALL_PLACEMENT_BLUE, designated_position=(1.0, 1.0)) - split_shape_runner.step_once() + _set_referee_command(pendulum_runner, RefereeCommand.BALL_PLACEMENT_BLUE, designated_position=(1.0, 1.0)) + pendulum_runner.step_once() placement_commands = strategy.tick(game) assert kickoff_commands != placement_commands, "override did not re-dispatch for the second restart command" -def test_stop_clears_an_encroaching_robot_from_the_keep_out_zone(split_shape_runner): +def test_stop_clears_an_encroaching_robot_from_the_keep_out_zone(pendulum_runner): """STOP is an override command now, not a pure freeze (see `referee_override.py`'s module docstring): a robot already inside the ball keep-out radius at the moment STOP is entered must actively move @@ -198,17 +198,17 @@ def test_stop_clears_an_encroaching_robot_from_the_keep_out_zone(split_shape_run `CustomReferee`'s own STOP-to-queued-restart auto-advance requires every robot to clear `BALL_KEEP_OUT_DISTANCE` first, which a frozen encroaching robot can never satisfy.""" - game = split_shape_runner.my.game - split_shape_runner.step_once() + game = pendulum_runner.my.game + pendulum_runner.step_once() ball_x, ball_y = game.ball.p.x, game.ball.p.y - split_shape_runner.sim_controller.teleport_robot(True, 1, ball_x + _CLEAR_OF_BALL, ball_y, 0.0) - split_shape_runner.step_once() + pendulum_runner.sim_controller.teleport_robot(True, 1, ball_x + _CLEAR_OF_BALL, ball_y, 0.0) + pendulum_runner.step_once() - _set_referee_command(split_shape_runner, RefereeCommand.STOP) + _set_referee_command(pendulum_runner, RefereeCommand.STOP) for _ in range(200): - split_shape_runner.step_once() + pendulum_runner.step_once() ball = game.ball.p for robot_id, robot in game.friendly_robots.items(): @@ -216,23 +216,23 @@ def test_stop_clears_an_encroaching_robot_from_the_keep_out_zone(split_shape_run assert dist_to_ball >= BALL_KEEP_OUT_DISTANCE - 0.05, f"robot {robot_id} too close to ball during STOP" -def test_timeout_clears_an_encroaching_robot_from_the_keep_out_zone(split_shape_runner): +def test_timeout_clears_an_encroaching_robot_from_the_keep_out_zone(pendulum_runner): """TIMEOUT_YELLOW/BLUE is also an override command, routed to `StopStep` exactly like STOP (see `referee_override.py`'s module docstring). It was once wired into neither `is_paused` nor `is_override_command`, so a timeout left tactics ticking and issuing ordinary motion commands straight through it.""" - game = split_shape_runner.my.game - split_shape_runner.step_once() + game = pendulum_runner.my.game + pendulum_runner.step_once() ball_x, ball_y = game.ball.p.x, game.ball.p.y - split_shape_runner.sim_controller.teleport_robot(True, 1, ball_x + _CLEAR_OF_BALL, ball_y, 0.0) - split_shape_runner.step_once() + pendulum_runner.sim_controller.teleport_robot(True, 1, ball_x + _CLEAR_OF_BALL, ball_y, 0.0) + pendulum_runner.step_once() - _set_referee_command(split_shape_runner, RefereeCommand.TIMEOUT_YELLOW) + _set_referee_command(pendulum_runner, RefereeCommand.TIMEOUT_YELLOW) for _ in range(200): - split_shape_runner.step_once() + pendulum_runner.step_once() ball = game.ball.p for robot_id, robot in game.friendly_robots.items(): @@ -240,20 +240,20 @@ def test_timeout_clears_an_encroaching_robot_from_the_keep_out_zone(split_shape_ assert dist_to_ball >= BALL_KEEP_OUT_DISTANCE - 0.05, f"robot {robot_id} too close to ball during TIMEOUT" -def test_goalkeeper_stops_during_halt(split_shape_runner): +def test_goalkeeper_stops_during_halt(pendulum_runner): """The goalkeeper must stop issuing motion commands during HALT, same as the outfield pool (`Strategy.tick()`'s `is_paused` check) — it must not keep chasing the ball just because it's ticked outside `Strategy`.""" - game = split_shape_runner.my.game - split_shape_runner.step_once() + game = pendulum_runner.my.game + pendulum_runner.step_once() - _set_referee_command(split_shape_runner, RefereeCommand.HALT) + _set_referee_command(pendulum_runner, RefereeCommand.HALT) for _ in range(30): # let residual velocity from before HALT decay first - split_shape_runner.step_once() + pendulum_runner.step_once() gk_pos_before = (game.friendly_robots[0].p.x, game.friendly_robots[0].p.y) for _ in range(20): - split_shape_runner.step_once() + pendulum_runner.step_once() gk_pos_after = (game.friendly_robots[0].p.x, game.friendly_robots[0].p.y) dist_moved = math.hypot(gk_pos_after[0] - gk_pos_before[0], gk_pos_after[1] - gk_pos_before[1]) @@ -267,28 +267,28 @@ def test_goalkeeper_stops_during_halt(split_shape_runner): # --------------------------------------------------------------------------- -def test_their_penalty_clears_our_robots_from_the_penalty_area(split_shape_runner): +def test_their_penalty_clears_our_robots_from_the_penalty_area(pendulum_runner): """During the opponent's penalty, PreparePenaltyTheirsStep's own two-part formation is actually reached: our goalkeeper moves to our goal line centre, and a non-keeper robot moves onto the behind-the-line formation in our own half — not just "moved somewhere far away" (there is no ball-keep-out-distance rule here at all; it's a fixed formation).""" - game = split_shape_runner.my.game - split_shape_runner.step_once() + game = pendulum_runner.my.game + pendulum_runner.step_once() # Robot 0 (goalkeeper) and robot 1 both start on the wrong side of the # field entirely, so a passing test demonstrates the override actually # repositioned them rather than them already sitting somewhere plausible # — but close enough to their targets to cover the distance within the # 200-tick (~3.3s) budget this file's other tests use. - split_shape_runner.sim_controller.teleport_robot(True, 0, 2.0, 0.0, 0.0) - split_shape_runner.sim_controller.teleport_robot(True, 1, 0.5, 2.0, 0.0) - split_shape_runner.step_once() + pendulum_runner.sim_controller.teleport_robot(True, 0, 2.0, 0.0, 0.0) + pendulum_runner.sim_controller.teleport_robot(True, 1, 0.5, 2.0, 0.0) + pendulum_runner.step_once() - _set_referee_command(split_shape_runner, RefereeCommand.PREPARE_PENALTY_BLUE) + _set_referee_command(pendulum_runner, RefereeCommand.PREPARE_PENALTY_BLUE) for _ in range(200): - split_shape_runner.step_once() + pendulum_runner.step_once() field = game.field # PreparePenaltyTheirsStep: our_goal_x = +half_length when my_team_is_right @@ -306,28 +306,28 @@ def test_their_penalty_clears_our_robots_from_the_penalty_area(split_shape_runne assert dist_to_line < 0.5, f"robot 1 did not reach the behind-the-line formation: dist_x={dist_to_line:.3f}m" -def test_their_penalty_defenders_never_enter_the_keep_out_circle(split_shape_runner): +def test_their_penalty_defenders_never_enter_the_keep_out_circle(pendulum_runner): """RR#6 low_block_vs_three_slot (2026-09-28, t=38.6): with the ball on the opponent's mark, four of our robots stood goal-side of it and had to reach the line 1 m behind. Robot 5 cut to 0.38 m from the ball and KeepOutRule (0.5 m) voided the penalty. Start positions are the recorded ones.""" - game = split_shape_runner.my.game - split_shape_runner.step_once() + game = pendulum_runner.my.game + pendulum_runner.step_once() mark = (2.25, 0.0) - split_shape_runner.sim_controller.teleport_ball(*mark) + pendulum_runner.sim_controller.teleport_ball(*mark) recorded = {0: (4.39, 0.04), 2: (3.39, 0.81), 3: (3.04, 1.01), 4: (3.64, 1.71), 5: (2.81, 0.96)} for robot_id, (x, y) in recorded.items(): - split_shape_runner.sim_controller.teleport_robot(True, robot_id, x, y, math.pi) - split_shape_runner.sim_controller.teleport_robot(False, 1, 3.24, 1.63, 0.0) - split_shape_runner.sim_controller.teleport_robot(False, 2, 3.09, -1.49, 0.0) - split_shape_runner.step_once() + pendulum_runner.sim_controller.teleport_robot(True, robot_id, x, y, math.pi) + pendulum_runner.sim_controller.teleport_robot(False, 1, 3.24, 1.63, 0.0) + pendulum_runner.sim_controller.teleport_robot(False, 2, 3.09, -1.49, 0.0) + pendulum_runner.step_once() - _set_referee_command(split_shape_runner, RefereeCommand.PREPARE_PENALTY_BLUE) + _set_referee_command(pendulum_runner, RefereeCommand.PREPARE_PENALTY_BLUE) closest = {} for _ in range(300): - split_shape_runner.step_once() + pendulum_runner.step_once() ball = game.ball.p for robot_id, robot in game.friendly_robots.items(): d = math.hypot(robot.p.x - ball.x, robot.p.y - ball.y) @@ -336,25 +336,25 @@ def test_their_penalty_defenders_never_enter_the_keep_out_circle(split_shape_run assert min(closest.values()) >= 0.5, f"closest approach to the ball per robot: {closest}" -def test_our_penalty_moves_kicker_to_the_penalty_mark(split_shape_runner): +def test_our_penalty_moves_kicker_to_the_penalty_mark(pendulum_runner): """During our own penalty, the (non-goalkeeper) kicker drives to the opponent's penalty mark — PreparePenaltyOursStep's actual target, not just "moved somewhere".""" - game = split_shape_runner.my.game - split_shape_runner.step_once() + game = pendulum_runner.my.game + pendulum_runner.step_once() # Robot 1 starts far from the opponent's penalty mark. - split_shape_runner.sim_controller.teleport_robot(True, 1, -1.0, 2.0, 0.0) - split_shape_runner.step_once() + pendulum_runner.sim_controller.teleport_robot(True, 1, -1.0, 2.0, 0.0) + pendulum_runner.step_once() - _set_referee_command(split_shape_runner, RefereeCommand.PREPARE_PENALTY_YELLOW) + _set_referee_command(pendulum_runner, RefereeCommand.PREPARE_PENALTY_YELLOW) for _ in range(200): - split_shape_runner.step_once() + pendulum_runner.step_once() field = game.field # PreparePenaltyOursStep: opp_goal_x = +half_length if NOT my_team_is_right - # else -half_length. split_shape_runner has my_team_is_right=True, so the + # else -half_length. pendulum_runner has my_team_is_right=True, so the # opponent's goal (and penalty mark) is on the NEGATIVE-x side. penalty_x = -0.5 * field.full_field_half_length non_goalkeeper_ids = [rid for rid in game.friendly_robots if rid != 0] @@ -364,21 +364,21 @@ def test_our_penalty_moves_kicker_to_the_penalty_mark(split_shape_runner): assert dist_to_mark < 0.3, f"kicker (robot {kicker_id}) did not reach the penalty mark: dist={dist_to_mark:.3f}m" -def test_their_direct_free_clears_our_robots_from_ball_keep_out_zone(split_shape_runner): +def test_their_direct_free_clears_our_robots_from_ball_keep_out_zone(pendulum_runner): """During the opponent's direct free kick, a robot starting on the ball clears the keep-out radius — same observable contract as ball placement's "theirs" test above, different command family.""" - game = split_shape_runner.my.game - split_shape_runner.step_once() + game = pendulum_runner.my.game + pendulum_runner.step_once() ball_x, ball_y = game.ball.p.x, game.ball.p.y - split_shape_runner.sim_controller.teleport_robot(True, 1, ball_x, ball_y, 0.0) - split_shape_runner.step_once() + pendulum_runner.sim_controller.teleport_robot(True, 1, ball_x, ball_y, 0.0) + pendulum_runner.step_once() - _set_referee_command(split_shape_runner, RefereeCommand.DIRECT_FREE_BLUE) + _set_referee_command(pendulum_runner, RefereeCommand.DIRECT_FREE_BLUE) for _ in range(200): - split_shape_runner.step_once() + pendulum_runner.step_once() ball = game.ball.p for robot_id, robot in game.friendly_robots.items(): @@ -386,29 +386,27 @@ def test_their_direct_free_clears_our_robots_from_ball_keep_out_zone(split_shape assert dist_to_ball >= BALL_KEEP_OUT_DISTANCE - 0.05, f"robot {robot_id} too close to ball" -def test_our_direct_free_moves_kicker_to_the_ball(split_shape_runner): +def test_our_direct_free_moves_kicker_to_the_ball(pendulum_runner): """During our own direct free kick, the closest robot to the ball drives to an approach position near it (DirectFreeOursStep) — the same contract `_ApproachBallManager` verifies on the BT-replacement ball-placement path, for a different command family.""" - game = split_shape_runner.my.game - split_shape_runner.step_once() + game = pendulum_runner.my.game + pendulum_runner.step_once() ball_x, ball_y = game.ball.p.x, game.ball.p.y - split_shape_runner.sim_controller.teleport_robot(True, 1, ball_x + 1.5, ball_y, 0.0) - split_shape_runner.step_once() + pendulum_runner.sim_controller.teleport_robot(True, 1, ball_x + 1.5, ball_y, 0.0) + pendulum_runner.step_once() - _set_referee_command(split_shape_runner, RefereeCommand.DIRECT_FREE_YELLOW) + _set_referee_command(pendulum_runner, RefereeCommand.DIRECT_FREE_YELLOW) + dist_to_ball = math.inf for _ in range(200): - split_shape_runner.step_once() + pendulum_runner.step_once() + ball = game.ball.p + for robot in game.friendly_robots.values(): + dist_to_ball = min(dist_to_ball, math.hypot(robot.p.x - ball.x, robot.p.y - ball.y)) - ball = game.ball.p - kicker = min( - game.friendly_robots.values(), - key=lambda robot: math.hypot(robot.p.x - ball.x, robot.p.y - ball.y), - ) - dist_to_ball = math.hypot(kicker.p.x - ball.x, kicker.p.y - ball.y) assert ( dist_to_ball < 0.3 ), f"no robot approached the ball for our direct free kick: closest dist={dist_to_ball:.3f}m" diff --git a/utama_core/tests/engine/test_referee_overrides_customization.py b/utama_core/tests/engine/test_referee_overrides_customization.py index 3bb92b803..4c3ac4a97 100644 --- a/utama_core/tests/engine/test_referee_overrides_customization.py +++ b/utama_core/tests/engine/test_referee_overrides_customization.py @@ -3,7 +3,7 @@ `RefereeOverride.overrides` (set via `AbstractStrategy(..., referee_overrides=...)` or `Strategy.referee_overrides = ...`) lets a strategy replace the built-in `*Step` formation for one specific `RefereeCommand` with its own callable, -without touching `custom_referee/actions.py` itself. This file covers: +without touching `referee/actions.py` itself. This file covers: - a registered override actually runs instead of the built-in Step (`test_registered_override_replaces_built_in_step`) @@ -23,7 +23,7 @@ `self._goalkeeper_id not in cmd_map` gate (`test_goalkeeper_ticks_normally_when_override_omits_it`) -Uses the same `split_shape_runner`/`_set_referee_command` pattern as +Uses the same `pendulum_runner`/`_set_referee_command` pattern as `test_referee_override.py` for the end-to-end cases (a real rsim `Game` via `AbstractStrategy`/`StrategyRunner`, since the override integration point — `AbstractStrategy.load_motion_controller` assigning `Strategy.referee_overrides` @@ -51,7 +51,7 @@ from utama_core.entities.game.team_info import TeamInfo from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.entities.referee.stage import Stage -from utama_core.strategy.kernel_strategy import build_split_shape_kernel_strategy +from utama_core.strategy.catalog import builder from .test_referee_override import ( # noqa: F401 (re-used fixture helper) _set_referee_command, @@ -144,6 +144,7 @@ def tick(self, game, ctx, robot_ids, mem): ) game = Mock() + game.friendly_robots = game.enemy_robots = {} game.my_team_is_yellow = True referee = Mock() referee.referee_command = RefereeCommand.NORMAL_START @@ -193,7 +194,7 @@ def kickoff_override(game, motion_controller): return {1: _SENTINEL_COMMAND} strategy = AbstractStrategy( - build_kernel_strategy=build_split_shape_kernel_strategy((1, 2, 3, 4, 5)), + build=builder("pendulum", (1, 2, 3, 4, 5)), referee_overrides={RefereeCommand.PREPARE_KICKOFF_YELLOW: kickoff_override}, ) runner = StrategyRunner( diff --git a/utama_core/tests/engine/test_shadow_and_mark_tactic.py b/utama_core/tests/engine/test_shadow_and_mark_tactic.py index 876feff0c..bc724fc06 100644 --- a/utama_core/tests/engine/test_shadow_and_mark_tactic.py +++ b/utama_core/tests/engine/test_shadow_and_mark_tactic.py @@ -20,8 +20,8 @@ from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.game.robot import Robot -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.skills.src.man_mark import MARK_STANDOFF, mark_target +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.skills.man_mark import MARK_STANDOFF, mark_target from utama_core.tactics.shadow_and_mark import ShadowAndMarkTactic @@ -51,7 +51,7 @@ def test_shadow_holding_the_ball_clears_it_instead_of_defending_on_it(): 3: _robot(3, 3.3, 0.0, True, has_ball=True, orientation=math.pi), 4: _robot(4, 3.3, 0.25, True), } - enemy = {1: _robot(1, 2.8, 0.0, False)} # close enough that the ball isn't "loose" + enemy = {1: _robot(1, 2.8, 0.8, False)} # close enough that the ball isn't "loose", off the lane zero = Vector3D(0.0, 0.0, 0.0) frame = GameFrame( ts=0.0, diff --git a/utama_core/tests/engine/test_strategy.py b/utama_core/tests/engine/test_strategy.py index 61bda2655..2dbbca94b 100644 --- a/utama_core/tests/engine/test_strategy.py +++ b/utama_core/tests/engine/test_strategy.py @@ -872,7 +872,10 @@ def __init__(self, command: RefereeCommand, ball_x: float = 0.0): self.referee = _FakeReferee(command) self.my_team_is_yellow = True - self.ball = SimpleNamespace(p=SimpleNamespace(x=ball_x, y=0.0)) + self.ball = SimpleNamespace(p=SimpleNamespace(x=ball_x, y=0.0), v=SimpleNamespace(x=0.0, y=0.0)) + self.friendly_robots = {} + self.enemy_robots = {} + self.ts = 0.0 def _held_restart_strategy(): diff --git a/utama_core/tests/engine/test_switch_of_play_tactic.py b/utama_core/tests/engine/test_switch_of_play_tactic.py index 9ca17cdf6..b969ad59a 100644 --- a/utama_core/tests/engine/test_switch_of_play_tactic.py +++ b/utama_core/tests/engine/test_switch_of_play_tactic.py @@ -40,8 +40,8 @@ from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.game.robot import Robot -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.shared.pass_and_score_geometry import reset_possession_state +from utama_core.geometry.pass_and_score_geometry import reset_possession_state +from utama_core.motion_planning.common.motion_controller import MotionController from utama_core.tactics.switch_of_play import ( _SETTLE_DEBOUNCE_TICKS, SwitchOfPlayMem, diff --git a/utama_core/tests/engine/test_tournament_cli_args.py b/utama_core/tests/engine/test_tournament_cli_args.py deleted file mode 100644 index 1c1d469b3..000000000 --- a/utama_core/tests/engine/test_tournament_cli_args.py +++ /dev/null @@ -1,228 +0,0 @@ -"""Tests for `round_robin.py`'s hand-rolled -`--fuzz-restarts`/`--fuzz-interval` CLI parsing (see `docs/STRATEGY_DEVELOPMENT.md`). -`round_robin.py` has no `argparse` — flags are parsed by -scanning `sys.argv` directly inside `main()` — so these tests monkeypatch -`sys.argv` and stub out `run_match` (never actually running a match/simulator) -to check the flags are parsed and threaded through correctly. -""" - -from __future__ import annotations - -import json - -from tools.evaluation import round_robin as tournament - - -def _stub_result(config_a_name, config_b_name, **_kwargs): - return tournament.MatchResult(config_a=config_a_name, config_b=config_b_name, score_a=1, score_b=0, stats=None) - - -def test_fuzz_restarts_and_interval_parsed_and_passed_to_run_match(tmp_path, monkeypatch): - calls = [] - - def _fake_run_match( - config_a_name, config_b_name, run_dir=None, control_scheme="fpp", fuzz_seed=None, fuzz_interval_s=(25.0, 45.0) - ): - calls.append( - { - "config_a": config_a_name, - "config_b": config_b_name, - "fuzz_seed": fuzz_seed, - "fuzz_interval_s": fuzz_interval_s, - } - ) - return _stub_result(config_a_name, config_b_name) - - monkeypatch.setattr(tournament, "run_match", _fake_run_match) - monkeypatch.setattr(tournament, "REPLAY_BASE_PATH", tmp_path) - monkeypatch.setattr( - "sys.argv", - [ - "tournament.py", - "--sequential", - "--fuzz-restarts", - "7", - "--fuzz-interval", - "5", - "10", - "build_low_block_kernel_strategy", - "build_tiki_taka_kernel_strategy", - ], - ) - - tournament.main() - - assert len(calls) == 1 - assert calls[0]["fuzz_seed"] == 7 - assert calls[0]["fuzz_interval_s"] == (5.0, 10.0) - - # summary.json must record the seed/interval for reproducibility. - run_dirs = list(tmp_path.glob("tournament_*")) - assert len(run_dirs) == 1 - summary = json.loads((run_dirs[0] / "summary.json").read_text()) - assert summary["fuzz_seed"] == 7 - assert summary["fuzz_interval_s"] == [5.0, 10.0] - - -def test_fuzz_restarts_off_by_default(tmp_path, monkeypatch): - calls = [] - - def _fake_run_match( - config_a_name, config_b_name, run_dir=None, control_scheme="fpp", fuzz_seed=None, fuzz_interval_s=(25.0, 45.0) - ): - calls.append({"fuzz_seed": fuzz_seed, "fuzz_interval_s": fuzz_interval_s}) - return _stub_result(config_a_name, config_b_name) - - monkeypatch.setattr(tournament, "run_match", _fake_run_match) - monkeypatch.setattr(tournament, "REPLAY_BASE_PATH", tmp_path) - monkeypatch.setattr( - "sys.argv", - [ - "tournament.py", - "--sequential", - "build_low_block_kernel_strategy", - "build_tiki_taka_kernel_strategy", - ], - ) - - tournament.main() - - assert len(calls) == 1 - assert calls[0]["fuzz_seed"] is None - # Default interval is still threaded through even when fuzzing is off. - assert calls[0]["fuzz_interval_s"] == (25.0, 45.0) - - run_dirs = list(tmp_path.glob("tournament_*")) - summary = json.loads((run_dirs[0] / "summary.json").read_text()) - assert summary["fuzz_seed"] is None - assert summary["fuzz_interval_s"] is None - # The run's matches go to the evaluation ledger under REPLAY_BASE_PATH, so a test run never - # writes into the real one. - (line,) = (tmp_path / "eval" / "ledger.jsonl").read_text().splitlines() - assert json.loads(line)["source"] == run_dirs[0].name - - -def test_pair_plays_exactly_that_one_pairing_in_the_given_order(tmp_path, monkeypatch): - """`--pair a b` replays one fixture (e.g. to diagnose a stall) with a as config_a, - not the sorted order a round-robin over those two configs would use.""" - calls = [] - - def _fake_run_match(config_a_name, config_b_name, *_args, **_kwargs): - calls.append((config_a_name, config_b_name)) - return _stub_result(config_a_name, config_b_name) - - monkeypatch.setattr(tournament, "run_match", _fake_run_match) - monkeypatch.setattr(tournament, "REPLAY_BASE_PATH", tmp_path) - monkeypatch.setattr("sys.argv", ["tournament.py", "--sequential", "--no-save", "--pair", "tiki_taka", "low_block"]) - - tournament.main() - - assert calls == [("build_tiki_taka_kernel_strategy", "build_low_block_kernel_strategy")] - - -def test_help_prints_usage_and_plays_nothing(monkeypatch, capsys): - # `--help` used to be taken for a config name, so it failed instead of listing the flags. - def _no_match(*_args, **_kwargs): - raise AssertionError("--help must not play a match") - - monkeypatch.setattr(tournament, "run_match", _no_match) - for flag in ("--help", "-h"): - monkeypatch.setattr("sys.argv", ["round_robin.py", flag]) - tournament.main() - out = capsys.readouterr().out - assert "--pair A B" in out and "--reuse" in out - - -def test_no_configs_plays_every_config_but_the_retired_and_a_named_retired_one_still_plays(tmp_path, monkeypatch): - calls = [] - - def _fake_run_match(config_a_name, config_b_name, *_args, **_kwargs): - calls.append((config_a_name, config_b_name)) - return _stub_result(config_a_name, config_b_name) - - names = ["build_a_kernel_strategy", "build_b_kernel_strategy", "build_c_kernel_strategy"] - monkeypatch.setattr(tournament, "run_match", _fake_run_match) - monkeypatch.setattr(tournament, "REPLAY_BASE_PATH", tmp_path) - monkeypatch.setattr(tournament, "_CONFIG_NAMES", names) - monkeypatch.setattr(tournament, "RETIRED", {"build_c_kernel_strategy"}) - - monkeypatch.setattr("sys.argv", ["round_robin.py", "--sequential", "--no-save"]) - tournament.main() - assert calls == [("build_a_kernel_strategy", "build_b_kernel_strategy")] - - calls.clear() - monkeypatch.setattr("sys.argv", ["round_robin.py", "--sequential", "--no-save", "a", "c"]) - tournament.main() - assert calls == [("build_a_kernel_strategy", "build_c_kernel_strategy")] - - -def test_sim_noise_parsed_and_passed_to_run_match_and_summary(tmp_path, monkeypatch): - from utama_core.rsoccer_simulator.src.Utils.sim_noise import SimNoise - - calls = [] - - def _fake_run_match(config_a_name, config_b_name, **kwargs): - calls.append(kwargs.get("sim_noise")) - return _stub_result(config_a_name, config_b_name) - - monkeypatch.setattr(tournament, "run_match", _fake_run_match) - monkeypatch.setattr(tournament, "REPLAY_BASE_PATH", tmp_path) - monkeypatch.setattr( - "sys.argv", - [ - "tournament.py", - "--sequential", - "--sim-noise", - '{"seed": 3, "latency_s": [0.05, 0.1], "kick_speed_sd": 0.2}', - "build_low_block_kernel_strategy", - "build_tiki_taka_kernel_strategy", - ], - ) - - tournament.main() - - assert calls == [SimNoise(seed=3, latency_s=(0.05, 0.1), kick_speed_sd=0.2)] - (summary_path,) = tmp_path.glob("tournament_*/summary.json") - assert json.loads(summary_path.read_text())["sim_noise"]["seed"] == 3 - - -def test_match_seconds_keys_the_match_cache_and_is_recorded_in_the_summary(tmp_path, monkeypatch): - # A shortened run's matches must not be cached under the full-length key, or a later - # full-length `--reuse` run would serve them as full matches. - durations = [] - - def _fake_match_key(_graph, _a, _b, *, duration_seconds, **_kwargs): - durations.append(duration_seconds) - return f"key-{duration_seconds}" - - class _EmptyCache: - def get(self, _key): - return None - - def put(self, _key, _record): - pass - - monkeypatch.setattr(tournament, "run_match", _stub_result) - monkeypatch.setattr(tournament, "match_key", _fake_match_key) - monkeypatch.setattr(tournament, "CodeGraph", lambda: None) - monkeypatch.setattr(tournament, "_append_to_ledger", lambda *a: None) # needs real fingerprints - monkeypatch.setattr(tournament.match_cache, "MatchCache", _EmptyCache) - monkeypatch.setattr(tournament, "REPLAY_BASE_PATH", tmp_path) - monkeypatch.setattr( - "sys.argv", - [ - "tournament.py", - "--sequential", - "--reuse", - "--match-seconds", - "300", - "build_low_block_kernel_strategy", - "build_tiki_taka_kernel_strategy", - ], - ) - - tournament.main() - - assert durations and set(durations) == {300.0} - (summary_path,) = tmp_path.glob("tournament_*/summary.json") - assert json.loads(summary_path.read_text())["max_match_seconds"] == 300.0 diff --git a/utama_core/tests/engine/test_tournament_match_end.py b/utama_core/tests/engine/test_tournament_match_end.py index a41bb73f9..62ac2614b 100644 --- a/utama_core/tests/engine/test_tournament_match_end.py +++ b/utama_core/tests/engine/test_tournament_match_end.py @@ -7,6 +7,7 @@ from tools.evaluation import match from utama_core.entities.referee.stage import Stage +from utama_core.run import sim_setup class _FakeRunner: @@ -34,11 +35,9 @@ def close(self): def test_a_match_ends_at_full_time_not_at_the_sim_time_cap(monkeypatch): - monkeypatch.setattr(match, "StrategyRunner", _FakeRunner) + monkeypatch.setattr(sim_setup, "StrategyRunner", _FakeRunner) - result = match.run_match( - "build_tiki_taka_kernel_strategy", "build_low_block_kernel_strategy", duration_seconds=1200.0 - ) + result = match.run_match("weaver", "pendulum", duration_seconds=1200.0) assert _FakeRunner.last.ticks == _FakeRunner.full_time_ticks assert (result.score_a, result.score_b) == (2, 1) @@ -46,8 +45,8 @@ def test_a_match_ends_at_full_time_not_at_the_sim_time_cap(monkeypatch): def test_the_cap_still_ends_a_match_that_never_reaches_full_time(monkeypatch): monkeypatch.setattr(_FakeRunner, "full_time_ticks", 10**9) - monkeypatch.setattr(match, "StrategyRunner", _FakeRunner) + monkeypatch.setattr(sim_setup, "StrategyRunner", _FakeRunner) - match.run_match("build_tiki_taka_kernel_strategy", "build_low_block_kernel_strategy", duration_seconds=1.0) + match.run_match("weaver", "pendulum", duration_seconds=1.0) assert _FakeRunner.last.ticks == match.TICKS_PER_SECOND diff --git a/utama_core/tests/engine/test_tournament_reuse.py b/utama_core/tests/engine/test_tournament_reuse.py deleted file mode 100644 index 02a8b90e6..000000000 --- a/utama_core/tests/engine/test_tournament_reuse.py +++ /dev/null @@ -1,138 +0,0 @@ -"""`round_robin.py --reuse`: a match whose key is stored is not played again. - -Matches, keys and the replay analyses are stubbed: `fingerprint.match_key` is replaced by -a key built from a per-config version number, so "editing" a config is bumping its -version. `tests/replay/test_fingerprint.py` covers the real keys and -`tests/replay/test_match_cache.py` the store. -""" - -from __future__ import annotations - -import json - -import pytest - -from tools.evaluation import round_robin as tournament -from utama_core.replay.match_cache import MatchCache - -_CONFIGS = ["tiki_taka", "low_block", "high_press"] - - -class _Always5(dict): - def get(self, key, default=None): - return 5 - - -_EVERY_PAIR_SCORES_5 = _Always5() - - -@pytest.fixture -def rig(tmp_path, monkeypatch): - rig = type("Rig", (), {})() - rig.played = [] - rig.version = {f"build_{c}_kernel_strategy": 0 for c in _CONFIGS} - rig.score = {} # pair -> score_a, to make a replay disagree with its stored record - rig.cache = MatchCache(tmp_path / "cache") - rig.on_play = None - - def fake_run_match(a, b, run_dir=None, *_args, **_kwargs): - rig.played.append((a, b)) - (run_dir / f"{tournament._tag((a, b))}.npz").write_bytes(b"") - if rig.on_play is not None: - rig.on_play() - return tournament.MatchResult(config_a=a, config_b=b, score_a=rig.score.get((a, b), 1), score_b=0, stats={}) - - def fake_losses(npz_path): - return {"match": npz_path.rsplit("/", 1)[-1][: -len(".npz")], "turnovers": [], "restarts": []} - - monkeypatch.setattr(tournament, "run_match", fake_run_match) - monkeypatch.setattr(tournament, "REPLAY_BASE_PATH", tmp_path) - monkeypatch.setattr(tournament, "CodeGraph", lambda: None) - monkeypatch.setattr(tournament, "_append_to_ledger", lambda *a: None) # needs real fingerprints - monkeypatch.setattr(tournament, "match_key", lambda _g, a, b, **_kw: f"{a}{rig.version[a]}{b}{rig.version[b]}") - monkeypatch.setattr(tournament.match_cache, "MatchCache", lambda: rig.cache) - monkeypatch.setattr(tournament.restart_outcomes, "analyse_match", lambda path: []) - monkeypatch.setattr(tournament.turnover_breakdown, "analyse_match", fake_losses) - monkeypatch.setattr(tournament.turnover_breakdown, "breakdown", lambda losses: {}) - monkeypatch.setattr(tournament.turnover_breakdown, "report", lambda *a: "") - monkeypatch.setattr(tournament.turnover_breakdown, "real_loss_kinds", lambda r: {}) - monkeypatch.setattr(tournament, "_print_ball_losses", lambda *a: None) - - def run(*flags): - rig.played.clear() - monkeypatch.setattr("sys.argv", ["tournament.py", "--sequential", "--reuse", *flags, *_CONFIGS]) - tournament.main() - (summary_path,) = sorted(tmp_path.glob("tournament_*/summary.json"))[-1:] - return json.loads(summary_path.read_text()) - - rig.run = run - return rig - - -def test_a_second_run_reuses_every_stored_match_and_reports_the_same_results(rig): - first = rig.run("--spot-check", "0") - second = rig.run("--spot-check", "0") - - assert rig.played == [] - assert second["reuse"] == {"reused": 3, "spot_checked": 0, "played": 0, "mismatches": []} - assert all(r["reused"] for r in second["results"]) - key = lambda r: (r["config_a"], r["config_b"]) # noqa: E731 - strip = lambda rs: sorted(({k: v for k, v in r.items() if k != "reused"} for r in rs), key=key) # noqa: E731 - assert strip(second["results"]) == strip(first["results"]) - assert second["standings"] == first["standings"] - - -def test_after_one_config_changes_only_its_matches_play(rig): - rig.run("--spot-check", "0") - rig.version["build_low_block_kernel_strategy"] += 1 - - rig.run("--spot-check", "0") - - assert sorted(rig.played) == [ - ("build_high_press_kernel_strategy", "build_low_block_kernel_strategy"), - ("build_low_block_kernel_strategy", "build_tiki_taka_kernel_strategy"), - ] - - -def test_a_spot_check_mismatch_evicts_the_run_s_records_and_fails_strict(rig): - rig.run("--spot-check", "0") - rig.score = _EVERY_PAIR_SCORES_5 # whichever match is spot-checked now disagrees - - with pytest.raises(SystemExit, match="differ from their stored records"): - rig.run("--spot-check", "0.34", "--strict") - - assert len(rig.played) == 1 # one of three replayed as the spot-check - assert list(rig.cache.root.rglob("*.json")) == [] # the mismatch and the two it reused - - -def test_a_spot_check_mismatch_is_recorded_in_the_summary(rig): - rig.run("--spot-check", "0") - rig.score = _EVERY_PAIR_SCORES_5 - - summary = rig.run("--spot-check", "0.34") - - (pair,) = rig.played - assert summary["reuse"]["mismatches"] == [tournament._tag(pair)] - - -def test_a_match_is_stored_only_if_its_key_is_unchanged_when_it_finishes(rig): - # Matches are stored as they finish, so a crash keeps them. Editing tiki_taka during the first - # match (high_press vs low_block, sorted pairs played in order) leaves that match's key as it - # was: it is stored. Both tiki_taka matches finish under a changed key: neither is. - def edit(): - rig.version["build_tiki_taka_kernel_strategy"] = 9 - - rig.on_play = edit - - rig.run("--spot-check", "0") - - stored = [json.loads(p.read_text())["result"] for p in rig.cache.root.rglob("*.json")] - assert [(r["config_a"], r["config_b"]) for r in stored] == [ - ("build_high_press_kernel_strategy", "build_low_block_kernel_strategy") - ] - - -def test_reuse_with_no_save_is_refused(monkeypatch): - monkeypatch.setattr("sys.argv", ["tournament.py", "--reuse", "--no-save", *_CONFIGS]) - with pytest.raises(SystemExit, match="--reuse"): - tournament.main() diff --git a/utama_core/tests/global_utils/test_mapping_utils.py b/utama_core/tests/entities/test_mapping_utils.py similarity index 97% rename from utama_core/tests/global_utils/test_mapping_utils.py rename to utama_core/tests/entities/test_mapping_utils.py index 8d646817b..4b3dec082 100644 --- a/utama_core/tests/global_utils/test_mapping_utils.py +++ b/utama_core/tests/entities/test_mapping_utils.py @@ -1,6 +1,6 @@ import pytest -from utama_core.global_utils.mapping_utils import ( +from utama_core.entities.game.mapping_utils import ( map_friendly_enemy_to_colors, map_left_right_to_colors, ) diff --git a/utama_core/tests/examples/test_ball_trials.py b/utama_core/tests/examples/test_ball_trials.py index 592d6a3ca..bcbc01815 100644 --- a/utama_core/tests/examples/test_ball_trials.py +++ b/utama_core/tests/examples/test_ball_trials.py @@ -1,4 +1,4 @@ -"""`examples/ball_trials.py`, the ball part of `pixi run calibrate`: each carry is the distance it +"""`tools/field/ball_trials.py`, the ball part of `pixi run calibrate`: each carry is the distance it says from standing to standing, runs towards the middle of the field, and the ladder stops a direction at the first speed that loses the ball; every kick comes charged.""" @@ -10,16 +10,10 @@ import pytest +import tools.field.ball_trials as ex from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import FieldBounds -EXAMPLES = Path(__file__).resolve().parents[3] / "examples" -sys.path.insert(0, str(EXAMPLES)) -try: - import ball_trials as ex -finally: - sys.path.remove(str(EXAMPLES)) - BOUNDS = FieldBounds(top_left=(-1.5, 1.125), bottom_right=(1.5, -1.125)) diff --git a/utama_core/tests/examples/test_calibrate_robot.py b/utama_core/tests/examples/test_calibrate_robot.py index 2d0681d81..cc47e740c 100644 --- a/utama_core/tests/examples/test_calibrate_robot.py +++ b/utama_core/tests/examples/test_calibrate_robot.py @@ -1,4 +1,4 @@ -"""`examples/calibrate_robot.py` writes what a run measured into the robot's profile, keeping +"""`tools/field/calibrate_robot.py` writes what a run measured into the robot's profile, keeping what it did not measure; the profile file reads back as written.""" from __future__ import annotations @@ -8,19 +8,13 @@ import pytest -from utama_core.team_controller.src.controllers.common.robot_profile import ( +import tools.field.calibrate_robot as ex +from utama_core.team_controller.controllers.common.robot_profile import ( RobotProfile, load_profile, save_profile, ) -EXAMPLES = Path(__file__).resolve().parents[3] / "examples" -sys.path.insert(0, str(EXAMPLES)) -try: - import calibrate_robot as ex -finally: - sys.path.remove(str(EXAMPLES)) - KEPT = { "forward": 1.0, "backward": 0.5, diff --git a/utama_core/tests/examples/test_demos.py b/utama_core/tests/examples/test_demos.py index e4ba4821c..9e542bbaa 100644 --- a/utama_core/tests/examples/test_demos.py +++ b/utama_core/tests/examples/test_demos.py @@ -16,8 +16,9 @@ import pass_receive import save_and_counter import score_goal - import shooting_drill import teleop + + import tools.field.shooting_drill as shooting_drill finally: sys.path.remove(str(EXAMPLES)) diff --git a/utama_core/tests/examples/test_examples_run_as_scripts.py b/utama_core/tests/examples/test_examples_run_as_scripts.py index 7c71f4cdc..508167915 100644 --- a/utama_core/tests/examples/test_examples_run_as_scripts.py +++ b/utama_core/tests/examples/test_examples_run_as_scripts.py @@ -10,28 +10,29 @@ import pytest -EXAMPLES = Path(__file__).resolve().parents[3] / "examples" +REPO = Path(__file__).resolve().parents[3] +EXAMPLES = REPO / "examples" @pytest.mark.parametrize( "name", [ - "shooting_drill.py", - "score_goal.py", - "dribble_and_shoot.py", - "pass_receive.py", - "passing_rally.py", - "save_and_counter.py", - "calibrate_robot.py", - "planner_ab.py", - "demos.py", - "teleop.py", - "demo_referee_feedback_gui.py", + "tools/field/shooting_drill.py", + "examples/score_goal.py", + "examples/dribble_and_shoot.py", + "examples/pass_receive.py", + "examples/passing_rally.py", + "examples/save_and_counter.py", + "tools/field/calibrate_robot.py", + "examples/planner_ab.py", + "examples/demos.py", + "examples/teleop.py", + "examples/demo_referee_feedback_gui.py", ], ) def test_an_example_with_options_prints_its_help_run_by_path(name, tmp_path): done = subprocess.run( - [sys.executable, str(EXAMPLES / name), "--help"], cwd=tmp_path, capture_output=True, text=True, timeout=120 + [sys.executable, str(REPO / name), "--help"], cwd=tmp_path, capture_output=True, text=True, timeout=120 ) assert done.returncode == 0, done.stderr[-2000:] assert "usage:" in done.stdout @@ -42,10 +43,30 @@ def test_the_field_example_holds_while_its_tactic_does_not_apply(): raise, stopping the run the first time the defender played it.""" sys.path.insert(0, str(EXAMPLES)) try: - import shooting_drill as example + import tools.field.shooting_drill as example finally: sys.path.remove(str(EXAMPLES)) robots = frozenset({1}) assert example._play_or_hold(None, robots, None, frozenset({"hold"})) == {"hold": robots} assert example._play_or_hold(None, robots, None, frozenset({"play", "hold"})) == {"play": robots} assert example._play_or_hold(None, frozenset(), None, frozenset({"play", "hold"})) == {} + + +# the field scripts moved out of examples/ on 2026-11-12 keep the same check +FIELD_SCRIPTS = [REPO / "tools" / "field" / n for n in ("ball_trials.py", "calibrate_robot.py", "shooting_drill.py")] + + +@pytest.mark.parametrize("path", sorted(EXAMPLES.glob("*.py")) + FIELD_SCRIPTS, ids=lambda p: p.name) +def test_every_example_imports(path, tmp_path): + """Every example's imports resolve. Until 2026-11-11 two demos still imported the removed + `utama_core.strategy.kernel_strategy` (gone when strategies became `strategy/.py`) and one + the long-deleted `WanderingStrategy`, and nothing ran them.""" + code = ( + "import importlib.util, sys; " + f"sys.path.insert(0, {str(EXAMPLES)!r}); " + f"spec = importlib.util.spec_from_file_location('example_under_test', {str(path)!r}); " + "module = sys.modules['example_under_test'] = importlib.util.module_from_spec(spec); " + "spec.loader.exec_module(module)" + ) + done = subprocess.run([sys.executable, "-c", code], cwd=tmp_path, capture_output=True, text=True, timeout=120) + assert done.returncode == 0, done.stderr[-2000:] diff --git a/utama_core/tests/examples/test_pass_receive.py b/utama_core/tests/examples/test_pass_receive.py index 60d18ebe8..22f836fd7 100644 --- a/utama_core/tests/examples/test_pass_receive.py +++ b/utama_core/tests/examples/test_pass_receive.py @@ -10,7 +10,7 @@ import pytest -from utama_core.shared.pass_and_score_geometry import reset_possession_state +from utama_core.geometry.pass_and_score_geometry import reset_possession_state from utama_core.tests.fixtures.game_builder import build_game, make_ball, make_robot EXAMPLES = Path(__file__).resolve().parents[3] / "examples" diff --git a/utama_core/tests/examples/test_passing_rally.py b/utama_core/tests/examples/test_passing_rally.py index b63a29a37..00973f768 100644 --- a/utama_core/tests/examples/test_passing_rally.py +++ b/utama_core/tests/examples/test_passing_rally.py @@ -11,7 +11,7 @@ import pytest from utama_core.entities.data.vector import Vector2D -from utama_core.shared.pass_and_score_geometry import reset_possession_state +from utama_core.geometry.pass_and_score_geometry import reset_possession_state from utama_core.tests.fixtures.game_builder import build_game, make_ball, make_robot EXAMPLES = Path(__file__).resolve().parents[3] / "examples" diff --git a/utama_core/tests/examples/test_save_and_counter.py b/utama_core/tests/examples/test_save_and_counter.py index 7dbd6e46f..0f9cf06d2 100644 --- a/utama_core/tests/examples/test_save_and_counter.py +++ b/utama_core/tests/examples/test_save_and_counter.py @@ -12,8 +12,8 @@ from utama_core.engine.context import TickContext from utama_core.entities.data.vector import Vector2D -from utama_core.motion_planning.src.common.pose_ahead import PoseAhead -from utama_core.shared.pass_and_score_geometry import reset_possession_state +from utama_core.geometry.pass_and_score_geometry import reset_possession_state +from utama_core.motion_planning.common.pose_ahead import PoseAhead from utama_core.tests.fixtures.game_builder import build_game, make_ball, make_robot EXAMPLES = Path(__file__).resolve().parents[3] / "examples" diff --git a/utama_core/tests/examples/test_shooting_drill.py b/utama_core/tests/examples/test_shooting_drill.py index 93caea71b..8e3c5d38d 100644 --- a/utama_core/tests/examples/test_shooting_drill.py +++ b/utama_core/tests/examples/test_shooting_drill.py @@ -1,4 +1,4 @@ -"""`examples/shooting_drill.py`'s demo keeper: it keeps goal, and a ball it holds goes back +"""`tools/field/shooting_drill.py`'s demo keeper: it keeps goal, and a ball it holds goes back to the attacker, so the demo loops.""" from __future__ import annotations @@ -9,20 +9,14 @@ import pytest +import tools.field.shooting_drill as ex from utama_core.config.enums import Mode from utama_core.engine.context import TickContext from utama_core.entities.data.vector import Vector2D -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.shared.pass_and_score_geometry import reset_possession_state +from utama_core.geometry.pass_and_score_geometry import reset_possession_state +from utama_core.motion_planning.common.motion_controller import MotionController from utama_core.tests.fixtures.game_builder import build_game, make_ball, make_robot -EXAMPLES = Path(__file__).resolve().parents[3] / "examples" -sys.path.insert(0, str(EXAMPLES)) -try: - import shooting_drill as ex -finally: - sys.path.remove(str(EXAMPLES)) - @pytest.fixture(autouse=True) def _fresh_possession_state(): diff --git a/utama_core/tests/fixtures/exact_math.py b/utama_core/tests/fixtures/exact_math.py index 4d6c8f231..6c1cf9f35 100644 --- a/utama_core/tests/fixtures/exact_math.py +++ b/utama_core/tests/fixtures/exact_math.py @@ -8,9 +8,9 @@ """ from utama_core.data_processing.refiners.filters import kalman -from utama_core.global_utils import math_utils -from utama_core.motion_planning.src.fastpathplanning import planner -from utama_core.motion_planning.src.fastpathplanning.planner import FastPathPlanner +from utama_core.geometry import math_utils +from utama_core.motion_planning.fastpathplanning import planner +from utama_core.motion_planning.fastpathplanning.planner import FastPathPlanner SWITCHES = [ (math_utils, "distance", math_utils._distance_numpy, math_utils._distance_fast), diff --git a/utama_core/tests/geometry/__init__.py b/utama_core/tests/geometry/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/utama_core/tests/shared/test_defense_area_rules_off.py b/utama_core/tests/geometry/test_defense_area_rules_off.py similarity index 91% rename from utama_core/tests/shared/test_defense_area_rules_off.py rename to utama_core/tests/geometry/test_defense_area_rules_off.py index 821f8339c..2d0a4b0b6 100644 --- a/utama_core/tests/shared/test_defense_area_rules_off.py +++ b/utama_core/tests/geometry/test_defense_area_rules_off.py @@ -7,7 +7,6 @@ import pytest from utama_core.config.field_params import STANDARD_FIELD_DIMS -from utama_core.custom_referee import actions from utama_core.entities.data.vector import Vector2D, Vector3D from utama_core.entities.game.ball import Ball from utama_core.entities.game.field import Field @@ -16,16 +15,15 @@ from utama_core.entities.game.game_history import GameHistory from utama_core.entities.game.robot import Robot from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.motion_planning.src.fastpathplanning.planner import FastPathPlanner -from utama_core.motion_planning.src.trajsampling.planner import ( - TrajectorySamplingPlanner, -) -from utama_core.shared.pass_and_score_geometry import ( +from utama_core.geometry.pass_and_score_geometry import ( ball_in_enemy_defense_area, ball_in_own_defense_area, clamp_outside_enemy_defense_area, clamp_outside_own_defense_area, ) +from utama_core.motion_planning.fastpathplanning.planner import FastPathPlanner +from utama_core.motion_planning.trajsampling.planner import TrajectorySamplingPlanner +from utama_core.referee import actions # We are on the right: our box spans x >= 3.5, the opponent's x <= -3.5 (standard field). _ENEMY_BOX = Vector2D(-4.0, 0.0) @@ -79,7 +77,7 @@ def test_the_planners_route_through_the_opponents_box_in_open_play_without_the_r @pytest.mark.parametrize("profile, rules", [("simulation", True), ("human", False)]) def test_the_runner_takes_the_box_rules_from_the_referee_profile(profile, rules): """`human` (and the real examples, built on it) has no defense-area rule, so robots ignore the boxes.""" - from utama_core.custom_referee import CustomReferee + from utama_core.referee import CustomReferee from utama_core.run.strategy_runner import StrategyRunner runner = SimpleNamespace(referee=CustomReferee.from_profile_name(profile)) diff --git a/utama_core/tests/shared/test_geometry_edge_cases.py b/utama_core/tests/geometry/test_geometry_edge_cases.py similarity index 99% rename from utama_core/tests/shared/test_geometry_edge_cases.py rename to utama_core/tests/geometry/test_geometry_edge_cases.py index 3fc73dd11..de6a91e9d 100644 --- a/utama_core/tests/shared/test_geometry_edge_cases.py +++ b/utama_core/tests/geometry/test_geometry_edge_cases.py @@ -1,7 +1,7 @@ """Boundary-condition and randomized-invariant sweep over `pass_and_score_geometry`'s public functions. -Public functions in `utama_core/shared/pass_and_score_geometry.py` (`def`/`class` +Public functions in `utama_core/geometry/pass_and_score_geometry.py` (`def`/`class` not prefixed `_`, as of this writing): `reset_possession_state`, `has_ball`, `at_target`, `oriented_towards`, `clamp_to_field`, `intercept_point`, `enemy_positions`, `ball_is_loose`, `segment_clearance`, `segment_blocked`, @@ -59,7 +59,7 @@ from utama_core.entities.game.game import Game from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.game.game_history import GameHistory -from utama_core.shared.pass_and_score_geometry import ( +from utama_core.geometry.pass_and_score_geometry import ( at_target, ball_is_loose, clamp_to_field, diff --git a/utama_core/tests/global_utils/test_math_utils.py b/utama_core/tests/geometry/test_math_utils.py similarity index 98% rename from utama_core/tests/global_utils/test_math_utils.py rename to utama_core/tests/geometry/test_math_utils.py index 321bdad8d..aaccf3b5e 100644 --- a/utama_core/tests/global_utils/test_math_utils.py +++ b/utama_core/tests/geometry/test_math_utils.py @@ -5,7 +5,7 @@ from utama_core.entities.data.vector import Vector2D from utama_core.entities.game.field import FieldBounds -from utama_core.global_utils.math_utils import ( +from utama_core.geometry.math_utils import ( angle_between_points, assert_valid_bounding_box, compute_bounding_zone_from_points, @@ -220,7 +220,7 @@ def test_find_intersection_matches_numpy_version_bit_for_bit(): """Random crossing, missing, parallel, degenerate and endpoint-touching segments, as float64 arrays, int arrays and tuples: same None-ness and exactly the same point as the numpy implementation.""" - from utama_core.global_utils.math_utils import find_intersection + from utama_core.geometry.math_utils import find_intersection rng = np.random.default_rng(3) for _ in range(20000): diff --git a/utama_core/tests/shared/test_pass_and_score_geometry.py b/utama_core/tests/geometry/test_pass_and_score_geometry.py similarity index 99% rename from utama_core/tests/shared/test_pass_and_score_geometry.py rename to utama_core/tests/geometry/test_pass_and_score_geometry.py index 8d4f2ea4d..57e9d72f2 100644 --- a/utama_core/tests/shared/test_pass_and_score_geometry.py +++ b/utama_core/tests/geometry/test_pass_and_score_geometry.py @@ -17,10 +17,7 @@ from utama_core.config.referee_constants import OPPONENT_DEFENSE_AREA_KEEP_DISTANCE from utama_core.entities.data.vector import Vector2D, Vector3D from utama_core.entities.game import Ball, Field, Game, GameFrame, GameHistory, Robot -from utama_core.motion_planning.src.fastpathplanning.config import ( - fastpathplanningconfig, -) -from utama_core.shared.pass_and_score_geometry import ( +from utama_core.geometry.pass_and_score_geometry import ( _ACQUIRE_LATERAL_MAX, _DEFENSE_AREA_CLAMP_MARGIN, _GOAL_POST_SAFETY_MARGIN, @@ -47,6 +44,7 @@ score_pass_setup, shot_heading_reachable, ) +from utama_core.motion_planning.fastpathplanning.config import fastpathplanningconfig _FIELD = Field( my_team_is_right=True, field_dims=STANDARD_FIELD_DIMS, field_bounds=STANDARD_FIELD_DIMS.full_field_bounds @@ -704,7 +702,7 @@ def test_carry_origin_starts_at_pickup_and_clears_when_the_ball_is_dropped(): from types import SimpleNamespace from utama_core.entities.data.vector import Vector3D - from utama_core.shared.pass_and_score_geometry import ( + from utama_core.geometry.pass_and_score_geometry import ( CARRY_LIMIT_M, carry_exhausted, carry_origin, @@ -735,7 +733,7 @@ def test_carry_exhausted_counts_the_distance_needed_to_stop(): from types import SimpleNamespace from utama_core.entities.data.vector import Vector2D, Vector3D - from utama_core.shared.pass_and_score_geometry import carry_exhausted + from utama_core.geometry.pass_and_score_geometry import carry_exhausted origin = Vector2D(0.0, 0.0) moving = SimpleNamespace(ball=SimpleNamespace(p=Vector3D(0.5, 0.0, 0.0), v=Vector3D(1.6, 0.0, 0.0))) @@ -744,7 +742,7 @@ def test_carry_exhausted_counts_the_distance_needed_to_stop(): assert carry_exhausted(moving, origin, stops_after=True) assert not carry_exhausted(at_rest, origin, stops_after=True) # A carrier that kicks while moving (GiveAndGo) never brakes with the ball, so - # its carry isn't cut short by speed: counting it cost give_and_go_solo half + # its carry isn't cut short by speed: counting it cost ricochet half # its goals in an A/B. assert not carry_exhausted(moving, origin) @@ -758,7 +756,7 @@ def test_carry_exhausted_counts_the_reaction_time_before_braking(): from types import SimpleNamespace from utama_core.entities.data.vector import Vector2D, Vector3D - from utama_core.shared.pass_and_score_geometry import carry_exhausted + from utama_core.geometry.pass_and_score_geometry import carry_exhausted origin = Vector2D(0.0, 0.0) lure = SimpleNamespace(ball=SimpleNamespace(p=Vector3D(0.5, 0.0, 0.0), v=Vector3D(1.2, 0.0, 0.0))) diff --git a/utama_core/tests/shared/test_tolerance.py b/utama_core/tests/geometry/test_tolerance.py similarity index 98% rename from utama_core/tests/shared/test_tolerance.py rename to utama_core/tests/geometry/test_tolerance.py index 319ae711a..70a281d27 100644 --- a/utama_core/tests/shared/test_tolerance.py +++ b/utama_core/tests/geometry/test_tolerance.py @@ -1,4 +1,4 @@ -"""Boundary-condition tests for `utama_core.shared.tolerance`. +"""Boundary-condition tests for `utama_core.geometry.tolerance`. Every test here pins an exact boundary (at tolerance, just under/over it, a tie, an empty list, a vanished previous choice) rather than exercising happy @@ -11,7 +11,7 @@ import pytest from utama_core.entities.data.vector import Vector2D -from utama_core.shared.tolerance import Sticky, approx_eq +from utama_core.geometry.tolerance import Sticky, approx_eq # --------------------------------------------------------------------------- # approx_eq — scalars diff --git a/utama_core/tests/moments/free_kick_defender_dodges_into_ball.json b/utama_core/tests/moments/free_kick_defender_dodges_into_ball.json index e62c30307..78e16ff61 100644 --- a/utama_core/tests/moments/free_kick_defender_dodges_into_ball.json +++ b/utama_core/tests/moments/free_kick_defender_dodges_into_ball.json @@ -6,7 +6,7 @@ "t": 254.65 }, "strategy": "all", - "opponent": "build_split_shape_kernel_strategy", + "opponent": "pendulum", "seconds": 2.0, "checks": [ "keeps_clear" diff --git a/utama_core/tests/moments/free_kick_robot_drives_in_at_start.json b/utama_core/tests/moments/free_kick_robot_drives_in_at_start.json index fb7d44966..1abf929e8 100644 --- a/utama_core/tests/moments/free_kick_robot_drives_in_at_start.json +++ b/utama_core/tests/moments/free_kick_robot_drives_in_at_start.json @@ -6,7 +6,7 @@ "t": 155.3 }, "strategy": "all", - "opponent": "build_overload_press_kernel_strategy", + "opponent": "avalanche", "seconds": 3.0, "checks": [ "keep_out", diff --git a/utama_core/tests/moments/placement_corner_robot_drives_onto_ball.json b/utama_core/tests/moments/placement_corner_robot_drives_onto_ball.json index 2e4640052..697cf0500 100644 --- a/utama_core/tests/moments/placement_corner_robot_drives_onto_ball.json +++ b/utama_core/tests/moments/placement_corner_robot_drives_onto_ball.json @@ -6,7 +6,7 @@ "t": 333.5 }, "strategy": "all", - "opponent": "build_press_trigger_flow_kernel_strategy", + "opponent": "tripwire", "seconds": 3.0, "checks": [ "keeps_clear", diff --git a/utama_core/tests/moments/placement_in_corner_traps_defender.json b/utama_core/tests/moments/placement_in_corner_traps_defender.json index aba4a11d4..c4b791c0d 100644 --- a/utama_core/tests/moments/placement_in_corner_traps_defender.json +++ b/utama_core/tests/moments/placement_in_corner_traps_defender.json @@ -6,7 +6,7 @@ "t": 163.0 }, "strategy": "all", - "opponent": "build_give_and_go_solo_kernel_strategy", + "opponent": "ricochet", "seconds": 3.0, "checks": [ "keeps_clear", diff --git a/utama_core/tests/moments/placement_robot_drives_in_mid_pitch.json b/utama_core/tests/moments/placement_robot_drives_in_mid_pitch.json index 3e6955718..c0afc8f44 100644 --- a/utama_core/tests/moments/placement_robot_drives_in_mid_pitch.json +++ b/utama_core/tests/moments/placement_robot_drives_in_mid_pitch.json @@ -6,7 +6,7 @@ "t": 122.5 }, "strategy": "all", - "opponent": "build_score_aware_counter_flow_kernel_strategy", + "opponent": "chameleon", "seconds": 3.0, "checks": [ "keeps_clear" diff --git a/utama_core/tests/moments/test_moment_authoring.py b/utama_core/tests/moments/test_moment_authoring.py index 57e09ec51..ccd223c4f 100644 --- a/utama_core/tests/moments/test_moment_authoring.py +++ b/utama_core/tests/moments/test_moment_authoring.py @@ -1,15 +1,20 @@ -"""Pure checks (no rsim) of hand-made moments in `tools/moments.py`: the template and the -validation errors.""" +"""Pure checks (no rsim) of moments in `tools/debug/moments.py`: loading, saving, the validation errors and +`play --seed`. (Hand-made templates, `tools/debug/moments.py new`, were removed on 2026-11-11: moments are captured +from replays.)""" import dataclasses +import re import pytest -from tools import moments +from tools.debug import moments + +PROBE = moments.MOMENTS_DIR / "free_kick_defender_dodges_into_ball.json" def _template(): - return moments.template("probe", "a note", "NORMAL_START", ["keeps_clear"]) + """A captured moment (seed 2), renamed, checking `keeps_clear` only.""" + return dataclasses.replace(moments.load(PROBE), name="probe", note="a note", checks=["keeps_clear"]) def _with_friendly(m, robots): @@ -24,24 +29,15 @@ def _replace_robot(robots, rid, **changes): return tuple(dataclasses.replace(r, **changes) if r.id == rid else r for r in robots) -def test_template_round_trips_through_load(tmp_path): +def test_a_moment_round_trips_through_save_and_load(tmp_path): m = _template() path = moments.save(m, tmp_path / "probe.json") again = moments.load(path) assert moments.to_dict(again) == moments.to_dict(m) - assert again.sim_noise["seed"] == 1 assert sorted(r.id for r in again.scenario.friendly_robots) == list(range(6)) assert sorted(r.id for r in again.scenario.enemy_robots) == list(range(6)) -def test_template_is_our_side_on_the_right_facing_left(): - m = _template() - ours = {r.id: r for r in m.scenario.friendly_robots} - theirs = {r.id: r for r in m.scenario.enemy_robots} - assert ours[0].x > 0 and theirs[0].x < 0 - assert all(ours[i].x > 0 and theirs[i].x < 0 for i in range(6)) - - def test_existing_moments_still_load(): for path in sorted(moments.MOMENTS_DIR.glob("*.json")): moments.load(path) @@ -64,13 +60,13 @@ def test_each_side_needs_ids_0_to_5_exactly_once(): def test_robots_must_be_on_the_pitch(): m = _with_friendly(_template(), _replace_robot(_template().scenario.friendly_robots, 2, x=5.0)) - with pytest.raises(moments.MomentError, match=r"friendly robot 2 at \(5.00, -1.20\) is off the pitch"): + with pytest.raises(moments.MomentError, match=r"friendly robot 2 at \(5.00, -?\d+\.\d\d\) is off the pitch"): moments.validate(m) def test_the_ball_must_be_on_the_pitch(): m = dataclasses.replace(_template(), scenario=dataclasses.replace(_template().scenario, ball_y=3.5)) - with pytest.raises(moments.MomentError, match=r"ball at \(0.00, 3.50\) is off the pitch"): + with pytest.raises(moments.MomentError, match=r"ball at \(-?\d+\.\d\d, 3.50\) is off the pitch"): moments.validate(m) @@ -91,9 +87,9 @@ def test_a_real_rule_name_and_star_are_valid_checks(): def test_unknown_strategy_and_opponent_are_named(): with pytest.raises(moments.MomentError, match=r"unknown strategy 'nope'"): - moments.validate(dataclasses.replace(_template(), strategy="build_nope_kernel_strategy")) + moments.validate(dataclasses.replace(_template(), strategy="nope")) with pytest.raises(moments.MomentError, match=r"unknown opponent 'nope'"): - moments.validate(dataclasses.replace(_template(), opponent="build_nope_kernel_strategy")) + moments.validate(dataclasses.replace(_template(), opponent="nope")) def test_seconds_must_be_positive(): @@ -108,7 +104,7 @@ def test_every_problem_is_reported_together(): assert "unknown check 'nope'" in str(err.value) and "seconds must be positive" in str(err.value) -# --- `play --seed`, and the foul listing's restart side --------------------------------------- +# --- `play --seed` and `--against` --------------------------------------------------------------- def test_with_seed_replaces_only_the_seed_and_does_not_mutate_the_moment(): @@ -118,7 +114,7 @@ def test_with_seed_replaces_only_the_seed_and_does_not_mutate_the_moment(): assert {k: v for k, v in seeded.sim_noise.items() if k != "seed"} == { k: v for k, v in m.sim_noise.items() if k != "seed" } - assert m.sim_noise["seed"] == 1 + assert m.sim_noise["seed"] == 2 def test_with_seed_needs_noise_to_seed(): @@ -126,153 +122,8 @@ def test_with_seed_needs_noise_to_seed(): moments.with_seed(dataclasses.replace(_template(), sim_noise=None), 3) -@pytest.mark.parametrize( - "command, we_are_yellow, side", - [ - ("DIRECT_FREE_YELLOW", True, "ours"), - ("BALL_PLACEMENT_YELLOW", True, "ours"), - ("DIRECT_FREE_BLUE", True, "theirs"), - ("DIRECT_FREE_BLUE", False, "ours"), - ("NORMAL_START", True, None), - ("STOP", True, None), - ("TIMEOUT_YELLOW", True, None), - ], -) -def test_restart_side_is_ours_theirs_or_neither(command, we_are_yellow, side): - from utama_core.entities.referee.referee_command import RefereeCommand - - assert moments.restart_side(RefereeCommand[command], we_are_yellow) == side - assert moments.restart_side(None, we_are_yellow) is None - - -def test_our_fouls_names_the_command_active_and_the_restart_side(tmp_path): - import json - - def foul(t, side="friendly", rule="keep_out"): - return {"rule": rule, "sim_time": t, "side": side, "robot_id": 1, "tactic": "X", "inferred": False} - - results = [ - { - "config_a": "build_a_kernel_strategy", - "config_b": "build_b_kernel_strategy", - "stats": {"fouls": [foul(1.0), foul(5.0), foul(12.0), foul(20.0), foul(6.0, side="enemy")]}, - } - ] - (tmp_path / "summary.json").write_text(json.dumps({"results": results})) - rows = [ - {"event": "referee", "sim_time": 0.0, "command": "NORMAL_START"}, - {"event": "referee", "sim_time": 4.0, "command": "DIRECT_FREE_BLUE"}, - {"event": "referee", "sim_time": 10.0, "command": "DIRECT_FREE_YELLOW"}, - ] - (tmp_path / "a_vs_b.intentions.jsonl").write_text("\n".join(json.dumps(r) for r in rows) + "\n") - - fouls = moments.our_fouls(tmp_path) - assert [(f["sim_time"], f["command"], f["restart"]) for f in fouls] == [ - (1.0, "NORMAL_START", None), - (5.0, "DIRECT_FREE_BLUE", "theirs"), - (12.0, "DIRECT_FREE_YELLOW", "ours"), - (20.0, "DIRECT_FREE_YELLOW", "ours"), - ] - kept = moments.without_own_restarts(fouls) - assert [f["sim_time"] for f in kept] == [1.0, 5.0] - - -def test_our_fouls_names_the_match_replay_relative_to_the_repo(tmp_path): - import json - - row = {"rule": "keep_out", "sim_time": 3.0, "side": "friendly", "robot_id": 1, "tactic": "X"} - results = [ - {"config_a": "build_a_kernel_strategy", "config_b": "build_b_kernel_strategy", "stats": {"fouls": [row]}} - ] - (tmp_path / "summary.json").write_text(json.dumps({"results": results})) - (fouls,) = moments.our_fouls(tmp_path) - assert fouls["replay"] is None # no a_vs_b replay in the run dir - - (tmp_path / "a_vs_b.npz").write_bytes(b"") - (fouls,) = moments.our_fouls(tmp_path) - assert fouls["replay"] == str(tmp_path / "a_vs_b.npz") # outside the repo: as given - - (tmp_path / "a_vs_b.npz").unlink() - (tmp_path / "a_vs_b.pkl").write_bytes(b"") - (fouls,) = moments.our_fouls(tmp_path) - assert fouls["replay"] == str(tmp_path / "a_vs_b.pkl") - - -def test_repo_relative_paths_drop_the_repo_root(): - assert moments._repo_relative(moments.REPO_ROOT / "replays" / "t" / "a_vs_b.npz") == "replays/t/a_vs_b.npz" - - -def test_our_fouls_without_a_match_log_has_no_command(tmp_path): - import json - - row = {"rule": "keep_out", "sim_time": 3.0, "side": "friendly", "robot_id": 1, "tactic": "X"} - results = [ - {"config_a": "build_a_kernel_strategy", "config_b": "build_b_kernel_strategy", "stats": {"fouls": [row]}} - ] - (tmp_path / "summary.json").write_text(json.dumps({"results": results})) - (fouls,) = moments.our_fouls(tmp_path) - assert fouls["command"] is None and fouls["restart"] is None - assert moments.without_own_restarts([fouls]) == [fouls] - - -def _foul_row(config_a, rule, restart=None, tactic="X"): - return { - "config_a": f"build_{config_a}_kernel_strategy", - "config_b": "build_b_kernel_strategy", - "rule": rule, - "tactic": tactic, - "restart": restart, - } - - -def test_count_fouls_groups_by_the_given_columns_most_common_first(): - fouls = [ - _foul_row("a", "keep_out"), - _foul_row("b", "crashing"), - _foul_row("a", "keep_out"), - _foul_row("a", "crashing"), - _foul_row("b", "crashing"), - _foul_row("b", "crashing"), - ] - assert moments.count_fouls(fouls, ["strategy", "rule"]) == [ - (("b", "crashing"), 3), - (("a", "keep_out"), 2), - (("a", "crashing"), 1), - ] - - -def test_count_fouls_names_a_missing_restart_live_and_a_missing_tactic_dash(): - fouls = [_foul_row("a", "keep_out", restart=None, tactic=None), _foul_row("a", "keep_out", restart="theirs")] - assert moments.count_fouls(fouls, ["restart", "tactic"]) == [(("live", "-"), 1), (("theirs", "X"), 1)] - - -def test_count_fouls_ties_are_in_name_order(): - fouls = [_foul_row("b", "keep_out"), _foul_row("a", "keep_out")] - assert [key for key, _ in moments.count_fouls(fouls, ["strategy"])] == [("a",), ("b",)] - - -def test_without_stoppages_drops_out_of_bounds_and_keeps_rules_fouls(): - fouls = [_foul_row("a", "out_of_bounds"), _foul_row("a", "defense_area_stoppage"), _foul_row("a", "keep_out")] - assert [f["rule"] for f in moments.without_stoppages(fouls)] == ["defense_area_stoppage", "keep_out"] - - -def test_print_fouls_by_prints_header_counts_and_total(capsys): - moments.print_fouls_by([_foul_row("a", "keep_out"), _foul_row("a", "keep_out")], ["strategy", "rule"]) - lines = capsys.readouterr().out.splitlines() - assert lines[0].split() == ["count", "strategy", "rule"] - assert lines[1].split() == ["2", "a", "keep_out"] - assert lines[2].split() == ["2", "total"] - - -def test_fouls_json_is_the_foul_list_or_the_by_counts_as_rows(): - import json - - fouls = [_foul_row("a", "keep_out", restart=None), _foul_row("a", "keep_out"), _foul_row("b", "crashing")] - as_list = json.loads(moments.fouls_json(fouls)) - assert as_list == fouls - - rows = json.loads(moments.fouls_json(fouls, ["strategy", "rule"])) - assert rows == [ - {"strategy": "a", "rule": "keep_out", "count": 2}, - {"strategy": "b", "rule": "crashing", "count": 1}, - ] +def test_against_worktrees_sit_beside_the_repo_in_an_undated_folder(): + """Until 2026-11-11 `--against` used `moments-work-20261017/against`, a dated folder from one session.""" + assert moments.AGAINST_DIR.parent == moments.REPO_ROOT.parent + assert moments.AGAINST_DIR.name == f"{moments.REPO_ROOT.name}-moments-against" + assert not re.search(r"\d{8}", str(moments.AGAINST_DIR.relative_to(moments.REPO_ROOT.parent))) diff --git a/utama_core/tests/moments/test_moments.py b/utama_core/tests/moments/test_moments.py index d31cc4ac0..73d323f57 100644 --- a/utama_core/tests/moments/test_moments.py +++ b/utama_core/tests/moments/test_moments.py @@ -1,10 +1,10 @@ -"""Every regression moment (`tools/moments.py`, the JSON files beside this one) against every +"""Every regression moment (`tools/debug/moments.py`, the JSON files beside this one) against every strategy it concerns. A moment with a `known_failure` is a strict xfail, so its fix shows as XPASS: then delete the `known_failure`.""" import pytest -from tools import moments +from tools.debug import moments def _cases(): diff --git a/utama_core/tests/moments/test_play_options.py b/utama_core/tests/moments/test_play_options.py index c6d1768ed..a95a25315 100644 --- a/utama_core/tests/moments/test_play_options.py +++ b/utama_core/tests/moments/test_play_options.py @@ -1,9 +1,9 @@ -"""Pure checks (no rsim) of `play`'s options in `tools/moments.py`: the seed parser, the events +"""Pure checks (no rsim) of `play`'s options in `tools/debug/moments.py`: the seed parser, the events list and the strategy resolver.""" import pytest -from tools import moments +from tools.debug import moments from utama_core.entities.referee.referee_command import RefereeCommand DT = 1 / moments.TICKS_PER_SECOND @@ -84,24 +84,19 @@ def test_events_of_nothing_is_nothing(): assert moments.events([]) == [] -def test_factory_for_resolves_a_catalog_name_to_its_factory(): - from utama_core.strategy import kernel_strategy +def test_factory_for_resolves_a_catalog_name_to_its_builder(): + from utama_core.strategy.pendulum import build - factory = moments.factory_for("build_split_shape_kernel_strategy") - assert factory is kernel_strategy.build_split_shape_kernel_strategy + assert moments.factory_for("pendulum")((1, 2)).func is build -def test_factory_for_imports_a_factory_from_a_scratch_file(tmp_path): +def test_factory_for_imports_a_build_from_a_scratch_file(tmp_path): scratch = tmp_path / "mine.py" - scratch.write_text( - "from utama_core.strategy import kernel_strategy\n\n" - "def build_mine_kernel_strategy(ids):\n" - " return kernel_strategy.build_split_shape_kernel_strategy(ids)\n" - ) - name = f"{scratch}:build_mine_kernel_strategy" - assert callable(moments.factory_for(name)(moments.OUTFIELD_ROBOT_IDS)) + scratch.write_text("def mine(ids, motion_controller):\n return ids, motion_controller\n") + name = f"{scratch}:mine" + assert moments.factory_for(name)(moments.OUTFIELD_ROBOT_IDS)("mc") == (moments.OUTFIELD_ROBOT_IDS, "mc") assert moments._full_name(name) == name - assert moments.label(name) == "mine:build_mine_kernel_strategy" + assert moments.label(name) == "mine:mine" def test_factory_for_names_a_missing_file_a_missing_factory_and_an_unknown_strategy(tmp_path): @@ -112,4 +107,4 @@ def test_factory_for_names_a_missing_file_a_missing_factory_and_an_unknown_strat with pytest.raises(moments.MomentError, match="has no factory 'build_x'"): moments.factory_for(f"{scratch}:build_x") with pytest.raises(moments.MomentError, match="unknown strategy 'nope'"): - moments.factory_for("build_nope_kernel_strategy") + moments.factory_for("nope") diff --git a/utama_core/tests/moments/test_requires_and_outcomes.py b/utama_core/tests/moments/test_requires_and_outcomes.py index f03502379..5f49a3593 100644 --- a/utama_core/tests/moments/test_requires_and_outcomes.py +++ b/utama_core/tests/moments/test_requires_and_outcomes.py @@ -1,11 +1,11 @@ -"""Pure checks (no rsim) of the `requires` conditions in `tools/moments.py`: each fires on the case it guards and not on the one it must allow, over +"""Pure checks (no rsim) of the `requires` conditions in `tools/debug/moments.py`: each fires on the case it guards and not on the one it must allow, over synthetic ticks.""" import dataclasses import pytest -from tools import moments +from tools.debug import moments from utama_core.entities.referee.referee_command import RefereeCommand DT = 1 / moments.TICKS_PER_SECOND @@ -24,7 +24,9 @@ def _tick(t, command, ball, ours): def _probe(**changes): - return dataclasses.replace(moments.template("probe", "a note", "NORMAL_START", ["*"]), **changes) + """A captured moment, renamed, with no requirements and every rule checked unless `changes` say.""" + m = moments.load(moments.MOMENTS_DIR / "free_kick_defender_dodges_into_ball.json") + return dataclasses.replace(m, **{"name": "probe", "note": "a note", "checks": ["*"], "requires": [], **changes}) # --- restart_lasts ------------------------------------------------------------------------------- diff --git a/utama_core/tests/motion_planning/_kernel_test_strategies.py b/utama_core/tests/motion_planning/_kernel_test_strategies.py index f9d55eabe..2940268a4 100644 --- a/utama_core/tests/motion_planning/_kernel_test_strategies.py +++ b/utama_core/tests/motion_planning/_kernel_test_strategies.py @@ -22,8 +22,8 @@ from utama_core.entities.data.command import RobotCommand from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.skills.src.utils.move_utils import move +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.skills.utils.move_utils import move @dataclass @@ -77,7 +77,7 @@ def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: ctx=ctx, ) - return AbstractStrategy(build_kernel_strategy=_build, exp_ball=False) + return AbstractStrategy(build=_build, exp_ball=False) def single_robot_go_to_point_strategy( @@ -143,7 +143,7 @@ def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: ctx=ctx, ) - return AbstractStrategy(build_kernel_strategy=_build, exp_ball=False) + return AbstractStrategy(build=_build, exp_ball=False) @dataclass @@ -199,7 +199,7 @@ def tick( def oscillating_obstacle_strategy(obstacle_configs: list) -> AbstractStrategy: """`obstacle_configs`: list of objects with `center_position`, `oscillation_axis`, `amplitude`, `direction_up_or_right`, `speed` - (matching `MovingObstacleConfig` in `single_robot_moving_obstacle_test.py`) + (matching `MovingObstacleConfig` in `test_single_robot_moving_obstacle.py`) — obstacle_id is assigned by list position (0, 1, 2, ...), matching the deleted BT strategy's convention.""" configs = [ @@ -224,7 +224,7 @@ def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: ctx=ctx, ) - return AbstractStrategy(build_kernel_strategy=_build, exp_ball=False) + return AbstractStrategy(build=_build, exp_ball=False) __all__ = [ diff --git a/utama_core/tests/motion_planning/contract/controller_contract_test.py b/utama_core/tests/motion_planning/contract/test_controller_contract.py similarity index 91% rename from utama_core/tests/motion_planning/contract/controller_contract_test.py rename to utama_core/tests/motion_planning/contract/test_controller_contract.py index c2ad22f5e..c124f24d6 100644 --- a/utama_core/tests/motion_planning/contract/controller_contract_test.py +++ b/utama_core/tests/motion_planning/contract/test_controller_contract.py @@ -5,11 +5,11 @@ import pytest from utama_core.config.enums import Mode -from utama_core.motion_planning.src.common.control_schemes import ( +from utama_core.motion_planning.common.control_schemes import ( CONTROL_SCHEME_MAP, get_control_scheme, ) -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController EXPECTED_CALCULATE_PARAMETERS = ( "self", diff --git a/utama_core/tests/motion_planning/implementation/bang_bang_edge_cases_test.py b/utama_core/tests/motion_planning/implementation/test_bang_bang_edge_cases.py similarity index 98% rename from utama_core/tests/motion_planning/implementation/bang_bang_edge_cases_test.py rename to utama_core/tests/motion_planning/implementation/test_bang_bang_edge_cases.py index c7995707d..8a4b3330a 100644 --- a/utama_core/tests/motion_planning/implementation/bang_bang_edge_cases_test.py +++ b/utama_core/tests/motion_planning/implementation/test_bang_bang_edge_cases.py @@ -1,7 +1,7 @@ """Boundary-condition and randomized-invariant sweep over `BangBang1D`/ -`Trajectory2D` (`utama_core/motion_planning/src/trajsampling/bang_bang.py`). +`Trajectory2D` (`utama_core/motion_planning/trajsampling/bang_bang.py`). -`trajsampling_correctness_test.py` (read before writing this file) already +`test_trajsampling_correctness.py` (read before writing this file) already covers: rejecting non-positive `v_max`/`a_max`; endpoint/kinematic invariants for a handful of hand-picked (p0, v0, p1, v_max, a_max) tuples, including one opposing-v0 case; position-continuity at the trajectory's own end time; @@ -57,10 +57,7 @@ import pytest -from utama_core.motion_planning.src.trajsampling.bang_bang import ( - BangBang1D, - Trajectory2D, -) +from utama_core.motion_planning.trajsampling.bang_bang import BangBang1D, Trajectory2D _N_SEEDS = 200 _END_TOL = 1e-6 @@ -396,7 +393,7 @@ def test_trajectory_2d_random_velocity_cap_and_continuity(seed): @pytest.mark.parametrize("seed", range(50)) def test_trajectory_2d_p0_equals_p1_with_nonzero_v0(seed): """The degenerate zero-distance case (pins fe6a07e's fix at the - `Trajectory2D` level, complementing `trajsampling_correctness_test.py`'s + `Trajectory2D` level, complementing `test_trajsampling_correctness.py`'s single hand-picked case with a random sweep): braking uses v0's own direction, not a fixed axis, so the full speed is captured and the robot actually comes to rest at p0.""" diff --git a/utama_core/tests/motion_planning/implementation/trajsampling_controller_test.py b/utama_core/tests/motion_planning/implementation/test_trajsampling_controller.py similarity index 96% rename from utama_core/tests/motion_planning/implementation/trajsampling_controller_test.py rename to utama_core/tests/motion_planning/implementation/test_trajsampling_controller.py index d09d47a2c..fcf91cb48 100644 --- a/utama_core/tests/motion_planning/implementation/trajsampling_controller_test.py +++ b/utama_core/tests/motion_planning/implementation/test_trajsampling_controller.py @@ -9,11 +9,11 @@ from utama_core.config.field_params import STANDARD_FIELD_DIMS from utama_core.entities.data.vector import Vector2D, Vector3D from utama_core.entities.game import Ball, Field, Game, GameFrame, GameHistory, Robot -from utama_core.motion_planning.src.controllers.trajsampling import ( +from utama_core.motion_planning.controllers.trajsampling import ( TrajectorySamplingController, ) -from utama_core.motion_planning.src.trajsampling.bang_bang import Trajectory2D -from utama_core.motion_planning.src.trajsampling.planner import PlanResult +from utama_core.motion_planning.trajsampling.bang_bang import Trajectory2D +from utama_core.motion_planning.trajsampling.planner import PlanResult def _game_with_robot(p_xy, v_xy) -> Game: diff --git a/utama_core/tests/motion_planning/implementation/trajsampling_correctness_test.py b/utama_core/tests/motion_planning/implementation/test_trajsampling_correctness.py similarity index 97% rename from utama_core/tests/motion_planning/implementation/trajsampling_correctness_test.py rename to utama_core/tests/motion_planning/implementation/test_trajsampling_correctness.py index 0eba11b62..afd00008e 100644 --- a/utama_core/tests/motion_planning/implementation/trajsampling_correctness_test.py +++ b/utama_core/tests/motion_planning/implementation/test_trajsampling_correctness.py @@ -9,18 +9,15 @@ from utama_core.entities.data.vector import Vector2D, Vector3D from utama_core.entities.game import Ball, Field, Game, GameFrame, GameHistory, Robot from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.motion_planning.src.trajsampling import collision_numba as collision -from utama_core.motion_planning.src.trajsampling.bang_bang import ( - BangBang1D, - Trajectory2D, -) -from utama_core.motion_planning.src.trajsampling.obstacles import ( +from utama_core.motion_planning.trajsampling import collision_numba as collision +from utama_core.motion_planning.trajsampling.bang_bang import BangBang1D, Trajectory2D +from utama_core.motion_planning.trajsampling.obstacles import ( ConstantVelocityObstacle, EnemyRobotObstacle, OwnRobotObstacle, StaticSegmentObstacle, ) -from utama_core.motion_planning.src.trajsampling.planner import ( +from utama_core.motion_planning.trajsampling.planner import ( PlanResult, TrajectorySamplingPlanner, _bangbang_to_row, @@ -341,7 +338,7 @@ def test_first_collision_numba_grants_escape_grace_when_starting_inside_obstacle the robot's own starting position was "the collision" -- so a trajectory heading directly AWAY from the obstacle was still rejected at t=0. """ - from utama_core.motion_planning.src.trajsampling.config import ( + from utama_core.motion_planning.trajsampling.config import ( trajsamplingconfig as config, ) @@ -475,7 +472,7 @@ def test_try_reuse_notices_a_priority_obstacle_only_encroaching_later_in_the_tra i.e. collision-free by the harder threshold, but priority-blocked by the softer one. """ - from utama_core.motion_planning.src.trajsampling.config import ( + from utama_core.motion_planning.trajsampling.config import ( trajsamplingconfig as config, ) @@ -528,7 +525,7 @@ def test_try_reuse_does_not_invalidate_on_a_priority_conflict_beyond_the_recheck `MAX_LOOKAHEAD_TIME`-capped scan remains the backstop for anything genuinely dangerous further out. """ - from utama_core.motion_planning.src.trajsampling.config import ( + from utama_core.motion_planning.trajsampling.config import ( trajsamplingconfig as config, ) @@ -564,7 +561,7 @@ def test_try_reuse_ignores_priority_conflict_when_priority_blocking_disabled(): """Pins the restart-formation fix (roadmap "trajsample liveness fixes", session following the recheck-window fix above): even after shrinking the recheck window to 0.5s, a real kickoff still stalled 100% of the time in a live - `debug_match.py` run, traced to a DIFFERENT mechanism than the recheck + `tools/debug/debug_match.py` run, traced to a DIFFERENT mechanism than the recheck window -- priority-blocking itself, not just how far ahead it looks. At a `PREPARE_KICKOFF_YELLOW`/similar restart, every non-keeper teammate @@ -593,7 +590,7 @@ def test_try_reuse_ignores_priority_conflict_when_priority_blocking_disabled(): would still reject the reuse) -- but passes `priority_enabled=False` and asserts the reuse now survives instead. """ - from utama_core.motion_planning.src.trajsampling.config import ( + from utama_core.motion_planning.trajsampling.config import ( trajsamplingconfig as config, ) @@ -774,7 +771,7 @@ def test_intermediate_targets_drops_a_stale_backward_pointing_last_target(): candidates = planner._intermediate_targets(robot_id=0, p0=p0, final_target=final_target) - from utama_core.motion_planning.src.trajsampling.config import ( + from utama_core.motion_planning.trajsampling.config import ( trajsamplingconfig as config, ) @@ -823,7 +820,7 @@ def test_intermediate_targets_keeps_a_last_target_that_is_still_a_reasonable_det candidates = planner._intermediate_targets(robot_id=0, p0=p0, final_target=final_target) - from utama_core.motion_planning.src.trajsampling.config import ( + from utama_core.motion_planning.trajsampling.config import ( trajsamplingconfig as config, ) @@ -857,10 +854,10 @@ def test_intermediate_targets_inserts_same_side_jitter_around_a_kept_last_target candidates = planner._intermediate_targets(robot_id=0, p0=p0, final_target=final_target) - from utama_core.motion_planning.src.trajsampling.config import ( + from utama_core.motion_planning.trajsampling.config import ( trajsamplingconfig as config, ) - from utama_core.motion_planning.src.trajsampling.planner import ( + from utama_core.motion_planning.trajsampling.planner import ( _N_NEAR_LAST_JITTER, _NEAR_LAST_JITTER_STEP_RAD, ) @@ -896,7 +893,7 @@ def test_collision_leniency_accepts_a_far_collision_when_priority_blocking_disab unchanged -- a fast collision with real braking distance left is still rejected even with priority disabled. """ - from utama_core.motion_planning.src.trajsampling.config import ( + from utama_core.motion_planning.trajsampling.config import ( trajsamplingconfig as config, ) @@ -1041,7 +1038,7 @@ def test_with_current_clearance_excludes_an_obstacle_the_robot_is_still_escaping penetrated obstacle must NOT be reported as nearest -- the clear one must win instead. """ - from utama_core.motion_planning.src.trajsampling.config import ( + from utama_core.motion_planning.trajsampling.config import ( trajsamplingconfig as config, ) @@ -1069,7 +1066,7 @@ def test_with_current_clearance_still_reports_a_genuinely_approaching_obstacle() only ever exclude an obstacle the robot is already inside, never a genuinely approaching one that the emergency brake still needs to see. """ - from utama_core.motion_planning.src.trajsampling.config import ( + from utama_core.motion_planning.trajsampling.config import ( trajsamplingconfig as config, ) @@ -1132,7 +1129,7 @@ def test_enemy_obstacle_lateral_clearance_is_tube_not_inflated_sphere(): robot radius, not an inflated circle of radius (radius + r_dyn). A query point located laterally at y=0.35m from an opponent traveling along y=0 must have clearance equal to 0.35 - radius, without being encroached upon by r_dyn.""" - from utama_core.motion_planning.src.trajsampling.obstacles import EnemyRobotObstacle + from utama_core.motion_planning.trajsampling.obstacles import EnemyRobotObstacle obs = EnemyRobotObstacle( p0=(0.0, 0.0), @@ -1156,7 +1153,7 @@ def test_has_priority_role_aware_ball_carrier_and_fallback(): When neither has the ball, or game is None, falls back to ID-based tie breaking.""" from dataclasses import replace - from utama_core.motion_planning.src.trajsampling.planner import _has_priority + from utama_core.motion_planning.trajsampling.planner import _has_priority # Standalone (no game): higher ID wins assert _has_priority(2, 1, game=None) is True diff --git a/utama_core/tests/motion_planning/implementation/trajsampling_sideways_test.py b/utama_core/tests/motion_planning/implementation/test_trajsampling_sideways.py similarity index 92% rename from utama_core/tests/motion_planning/implementation/trajsampling_sideways_test.py rename to utama_core/tests/motion_planning/implementation/test_trajsampling_sideways.py index 9ca743d5b..cdfac6e15 100644 --- a/utama_core/tests/motion_planning/implementation/trajsampling_sideways_test.py +++ b/utama_core/tests/motion_planning/implementation/test_trajsampling_sideways.py @@ -7,13 +7,11 @@ from utama_core.config.enums import Mode from utama_core.config.robot_params import REAL_PARAMS, RSIM_PARAMS -from utama_core.motion_planning.src.controllers.trajsampling import ( +from utama_core.motion_planning.controllers.trajsampling import ( TrajectorySamplingController, ) -from utama_core.motion_planning.src.trajsampling.bang_bang import Trajectory2D -from utama_core.motion_planning.src.trajsampling.planner import ( - TrajectorySamplingPlanner, -) +from utama_core.motion_planning.trajsampling.bang_bang import Trajectory2D +from utama_core.motion_planning.trajsampling.planner import TrajectorySamplingPlanner from utama_core.tests.fixtures.game_builder import build_game, make_ball, make_robot A_MAX, A_SIDEWAYS = 4.0, 1.8 diff --git a/utama_core/tests/motion_planning/standardized/harness.py b/utama_core/tests/motion_planning/standardized/harness.py index ff9569e5f..24735d6f7 100644 --- a/utama_core/tests/motion_planning/standardized/harness.py +++ b/utama_core/tests/motion_planning/standardized/harness.py @@ -17,7 +17,7 @@ from utama_core.entities.game import Game from utama_core.entities.game.robot import Robot from utama_core.run import StrategyRunner -from utama_core.team_controller.src.controllers import AbstractSimController +from utama_core.team_controller.controllers import AbstractSimController from utama_core.tests.common.abstract_test_manager import ( AbstractTestManager, TestingStatus, diff --git a/utama_core/tests/motion_planning/standardized/test_scenarios.py b/utama_core/tests/motion_planning/standardized/test_scenarios.py index f661fbd11..dc46bba0d 100644 --- a/utama_core/tests/motion_planning/standardized/test_scenarios.py +++ b/utama_core/tests/motion_planning/standardized/test_scenarios.py @@ -171,7 +171,7 @@ # trajectory, per the fix's own roadmap entry), not a hard veto this # simpler shape reproduces standalone. The exact boundary condition # (`first_collision_numba`'s escape grace) is pinned deterministically - # by a dedicated unit test instead (see trajsampling_correctness_test.py); + # by a dedicated unit test instead (see test_trajsampling_correctness.py); # this scenario keeps the realistic "start already overlapping" case # in the black-box regression suite going forward. friendly_starts=((0.10, 0.0),), diff --git a/utama_core/tests/motion_planning/defense_area_avoidance_test.py b/utama_core/tests/motion_planning/test_defense_area_avoidance.py similarity index 96% rename from utama_core/tests/motion_planning/defense_area_avoidance_test.py rename to utama_core/tests/motion_planning/test_defense_area_avoidance.py index 1359213de..b2ed02c30 100644 --- a/utama_core/tests/motion_planning/defense_area_avoidance_test.py +++ b/utama_core/tests/motion_planning/test_defense_area_avoidance.py @@ -1,7 +1,7 @@ """FastPathPlanner must route around the opponent's defense area. Found via a live grsim run of the split-shape kernel strategy -(`demo_split_shape_match.py`): an outfield attacker chasing the ball drove +(`demo_pendulum_match.py`): an outfield attacker chasing the ball drove straight into the opponent's defense area — an SSL rule violation flagged by the referee GUI. `FastPathPlanner._get_obstacles` treated only robots and the field boundary as obstacles; nothing represented the opponent's defense area @@ -14,7 +14,7 @@ from utama_core.config.field_params import STANDARD_FIELD_DIMS from utama_core.entities.game import Game from utama_core.run import StrategyRunner -from utama_core.team_controller.src.controllers import AbstractSimController +from utama_core.team_controller.controllers import AbstractSimController from utama_core.tests.common.abstract_test_manager import ( AbstractTestManager, TestingStatus, diff --git a/utama_core/tests/motion_planning/fastpathplanner_corner_test.py b/utama_core/tests/motion_planning/test_fastpathplanner_corner.py similarity index 98% rename from utama_core/tests/motion_planning/fastpathplanner_corner_test.py rename to utama_core/tests/motion_planning/test_fastpathplanner_corner.py index bb32a2f85..d378f0899 100644 --- a/utama_core/tests/motion_planning/fastpathplanner_corner_test.py +++ b/utama_core/tests/motion_planning/test_fastpathplanner_corner.py @@ -29,7 +29,7 @@ import numpy as np import pytest -from utama_core.motion_planning.src.fastpathplanning.planner import FastPathPlanner +from utama_core.motion_planning.fastpathplanning.planner import FastPathPlanner from utama_core.tests.fixtures.game_builder import build_game, make_ball, make_robot _STEP_M = 3.0 / 60 diff --git a/utama_core/tests/motion_planning/test_fastpathplanner_cpp.py b/utama_core/tests/motion_planning/test_fastpathplanner_cpp.py index 5e10553f8..83ac3bf11 100644 --- a/utama_core/tests/motion_planning/test_fastpathplanner_cpp.py +++ b/utama_core/tests/motion_planning/test_fastpathplanner_cpp.py @@ -16,10 +16,10 @@ import numpy as np import pytest -_fastpathplanner = pytest.importorskip("utama_core.motion_planning.src.fastpathplanning._fastpathplanner") +_fastpathplanner = pytest.importorskip("utama_core.motion_planning.fastpathplanning._fastpathplanner") -from utama_core.motion_planning.src.fastpathplanning import numba_kernels # noqa: E402 -from utama_core.motion_planning.src.fastpathplanning.planner import ( # noqa: E402 +from utama_core.motion_planning.fastpathplanning import numba_kernels # noqa: E402 +from utama_core.motion_planning.fastpathplanning.planner import ( # noqa: E402 HAS_CPP, FastPathPlanner, ) @@ -135,7 +135,7 @@ class DummyBounds: ) # Reference Python (with HAS_CPP=False) - import utama_core.motion_planning.src.fastpathplanning.planner as planner_mod + import utama_core.motion_planning.fastpathplanning.planner as planner_mod planner_mod.HAS_CPP = False try: diff --git a/utama_core/tests/motion_planning/fastpathplanner_equivalence_test.py b/utama_core/tests/motion_planning/test_fastpathplanner_equivalence.py similarity index 97% rename from utama_core/tests/motion_planning/fastpathplanner_equivalence_test.py rename to utama_core/tests/motion_planning/test_fastpathplanner_equivalence.py index 601e26368..c1a853fe9 100644 --- a/utama_core/tests/motion_planning/fastpathplanner_equivalence_test.py +++ b/utama_core/tests/motion_planning/test_fastpathplanner_equivalence.py @@ -10,7 +10,7 @@ This is the exact-numerics contract (`EXACT_MATH`, settings.py), so every test here runs with the exact implementations selected whatever the -environment says; fastpathplanner_fast_math_test.py covers the fast ones. +environment says; test_fastpathplanner_fast_math.py covers the fast ones. """ import math @@ -19,20 +19,20 @@ import pytest from utama_core.config.field_params import STANDARD_FIELD_DIMS -from utama_core.global_utils.math_utils import ( +from utama_core.geometry.math_utils import ( _closest_point_on_segment_numpy as closest_point_on_segment, ) -from utama_core.global_utils.math_utils import _distance_numpy as distance -from utama_core.global_utils.math_utils import ( +from utama_core.geometry.math_utils import _distance_numpy as distance +from utama_core.geometry.math_utils import ( distance_point_to_segment, find_intersection, rotate_vector, ) -from utama_core.motion_planning.src.fastpathplanning.numba_kernels import ( +from utama_core.motion_planning.fastpathplanning.numba_kernels import ( scan_collides_nb, scan_find_subgoal_nb, ) -from utama_core.motion_planning.src.fastpathplanning.planner import ( +from utama_core.motion_planning.fastpathplanning.planner import ( FastPathPlanner, _same_segment, _segment_key, @@ -428,7 +428,7 @@ class DummyGame: assert len(planner._obstacle_arrays_cache) == 1 cached_obs, cached_arrs = planner._obstacle_arrays_cache[0] assert cached_obs is obstacles - from utama_core.motion_planning.src.fastpathplanning.numba_kernels import ( + from utama_core.motion_planning.fastpathplanning.numba_kernels import ( flatten_obstacles, ) diff --git a/utama_core/tests/motion_planning/fastpathplanner_fast_math_test.py b/utama_core/tests/motion_planning/test_fastpathplanner_fast_math.py similarity index 97% rename from utama_core/tests/motion_planning/fastpathplanner_fast_math_test.py rename to utama_core/tests/motion_planning/test_fastpathplanner_fast_math.py index 4513e169a..b09a0543f 100644 --- a/utama_core/tests/motion_planning/fastpathplanner_fast_math_test.py +++ b/utama_core/tests/motion_planning/test_fastpathplanner_fast_math.py @@ -1,7 +1,7 @@ """The fast numerics (`EXACT_MATH` off, the default) compute what the exact ones do, up to rounding: on random scenes every fast planner step makes the same choice (same obstacle, same None/not-None) and lands within 1e-9 m of -the exact result. fastpathplanner_equivalence_test.py pins the exact ones bit +the exact result. test_fastpathplanner_equivalence.py pins the exact ones bit for bit against the pre-rewrite code.""" import math @@ -10,8 +10,8 @@ import pytest from utama_core.data_processing.refiners.filters import kalman -from utama_core.global_utils import math_utils -from utama_core.motion_planning.src.fastpathplanning.planner import ( +from utama_core.geometry import math_utils +from utama_core.motion_planning.fastpathplanning.planner import ( FastPathPlanner, _same_segment, _segment_key, diff --git a/utama_core/tests/motion_planning/fastpathplanner_subgoal_test.py b/utama_core/tests/motion_planning/test_fastpathplanner_subgoal.py similarity index 99% rename from utama_core/tests/motion_planning/fastpathplanner_subgoal_test.py rename to utama_core/tests/motion_planning/test_fastpathplanner_subgoal.py index 95cd43b2c..f480e97e8 100644 --- a/utama_core/tests/motion_planning/fastpathplanner_subgoal_test.py +++ b/utama_core/tests/motion_planning/test_fastpathplanner_subgoal.py @@ -25,7 +25,7 @@ import numpy as np from utama_core.config.field_params import STANDARD_FIELD_DIMS -from utama_core.motion_planning.src.fastpathplanning.planner import FastPathPlanner +from utama_core.motion_planning.fastpathplanning.planner import FastPathPlanner def _planner() -> FastPathPlanner: diff --git a/utama_core/tests/motion_planning/test_fpp_ball_keep_out.py b/utama_core/tests/motion_planning/test_fpp_ball_keep_out.py index 414c4309b..88347c416 100644 --- a/utama_core/tests/motion_planning/test_fpp_ball_keep_out.py +++ b/utama_core/tests/motion_planning/test_fpp_ball_keep_out.py @@ -23,7 +23,7 @@ from utama_core.entities.game.game_history import GameHistory from utama_core.entities.game.robot import Robot from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.motion_planning.src.fastpathplanning.planner import FastPathPlanner +from utama_core.motion_planning.fastpathplanning.planner import FastPathPlanner _BALL = (2.25, 0.0) diff --git a/utama_core/tests/motion_planning/test_fpp_inside_ball_keep_out.py b/utama_core/tests/motion_planning/test_fpp_inside_ball_keep_out.py index 3079ec109..a14b37a67 100644 --- a/utama_core/tests/motion_planning/test_fpp_inside_ball_keep_out.py +++ b/utama_core/tests/motion_planning/test_fpp_inside_ball_keep_out.py @@ -17,8 +17,8 @@ from utama_core.config.field_params import STANDARD_FIELD_DIMS, FieldDimensions from utama_core.config.referee_constants import BALL_KEEP_OUT_DISTANCE from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.global_utils.math_utils import distance_point_to_segment -from utama_core.motion_planning.src.fastpathplanning.planner import FastPathPlanner +from utama_core.geometry.math_utils import distance_point_to_segment +from utama_core.motion_planning.fastpathplanning.planner import FastPathPlanner from utama_core.tests.fixtures.game_builder import build_game, make_ball, make_robot _BALL = (-3.747805, -2.497416) @@ -84,7 +84,7 @@ def test_a_robot_just_inside_the_ball_keep_out_is_sent_out_of_it_not_onto_its_ed assert distance_point_to_segment(np.zeros(2), np.array(us), carrot) >= np.linalg.norm(us) - 1e-6 -# The 3 m x 2.25 m lab field (`examples/shooting_drill.py`'s FIELD). +# The 3 m x 2.25 m lab field (`tools/field/shooting_drill.py`'s FIELD). _LAB = FieldDimensions( full_field_half_length=1.5, full_field_half_width=1.125, diff --git a/utama_core/tests/motion_planning/test_fpp_pressed_against_robot.py b/utama_core/tests/motion_planning/test_fpp_pressed_against_robot.py index cc7885dbe..83715a650 100644 --- a/utama_core/tests/motion_planning/test_fpp_pressed_against_robot.py +++ b/utama_core/tests/motion_planning/test_fpp_pressed_against_robot.py @@ -11,8 +11,8 @@ from utama_core.config.field_params import STANDARD_FIELD_DIMS from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.global_utils.math_utils import distance_point_to_segment -from utama_core.motion_planning.src.fastpathplanning.planner import ( +from utama_core.geometry.math_utils import distance_point_to_segment +from utama_core.motion_planning.fastpathplanning.planner import ( FastPathPlanner, _leaving, ) diff --git a/utama_core/tests/motion_planning/test_fpp_wall_near_robot.py b/utama_core/tests/motion_planning/test_fpp_wall_near_robot.py index ce3c02747..ec7f82eb7 100644 --- a/utama_core/tests/motion_planning/test_fpp_wall_near_robot.py +++ b/utama_core/tests/motion_planning/test_fpp_wall_near_robot.py @@ -13,10 +13,10 @@ from utama_core.config.field_params import FieldDimensions from utama_core.entities.data.vector import Vector2D -from utama_core.motion_planning.src.fastpathplanning.planner import FastPathPlanner +from utama_core.motion_planning.fastpathplanning.planner import FastPathPlanner from utama_core.tests.fixtures.game_builder import build_game, make_ball, make_robot -# The lab field: 3 m x 2.25 m (`examples/shooting_drill.py`'s FIELD). +# The lab field: 3 m x 2.25 m (`tools/field/shooting_drill.py`'s FIELD). _LAB = FieldDimensions( full_field_half_length=1.5, full_field_half_width=1.125, diff --git a/utama_core/tests/motion_planning/motion_planning_benchmark_figures_test.py b/utama_core/tests/motion_planning/test_motion_planning_benchmark_figures.py similarity index 100% rename from utama_core/tests/motion_planning/motion_planning_benchmark_figures_test.py rename to utama_core/tests/motion_planning/test_motion_planning_benchmark_figures.py diff --git a/utama_core/tests/motion_planning/multiple_robots_test.py b/utama_core/tests/motion_planning/test_multiple_robots.py similarity index 99% rename from utama_core/tests/motion_planning/multiple_robots_test.py rename to utama_core/tests/motion_planning/test_multiple_robots.py index bd3b62611..50024a878 100644 --- a/utama_core/tests/motion_planning/multiple_robots_test.py +++ b/utama_core/tests/motion_planning/test_multiple_robots.py @@ -9,7 +9,7 @@ from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game from utama_core.run import StrategyRunner -from utama_core.team_controller.src.controllers import AbstractSimController +from utama_core.team_controller.controllers import AbstractSimController from utama_core.tests.common.abstract_test_manager import ( AbstractTestManager, TestingStatus, diff --git a/utama_core/tests/motion_planning/test_pid_approach.py b/utama_core/tests/motion_planning/test_pid_approach.py new file mode 100644 index 000000000..553f38098 --- /dev/null +++ b/utama_core/tests/motion_planning/test_pid_approach.py @@ -0,0 +1,58 @@ +"""The last metre of a move: speed floor under `TwoDPID`, leaving cruising and settling to kp.""" + +import pytest + +from utama_core.entities.data.vector import Vector2D +from utama_core.motion_planning.pid.configs import TranslationPIDConfigs +from utama_core.motion_planning.pid.pid import TwoDPID + +_ORIGIN = Vector2D(0.0, 0.0) +_KP = 1.8 + + +def _speed(distance: float, fraction: float = 0.6, has_final_target: bool = True) -> float: + pid = TwoDPID( + TranslationPIDConfigs(max_velocity=2.0, kp=_KP, max_acceleration=4.0, approach_brake_fraction=fraction) + ) + target = Vector2D(distance, 0.0) + if has_final_target: + pid.set_final_target(0, target) + return pid._calculate(target, _ORIGIN, 0).mag() + + +def test_the_last_metre_holds_a_share_of_the_speed_it_can_stop_from(): + assert _speed(0.25) == pytest.approx(0.6 * (2 * 4.0 * 0.25) ** 0.5) + + +def test_the_floor_starts_just_inside_a_metre(): + assert _speed(0.99) > _KP * 0.99 - 1e-9 + assert _speed(1.01) == pytest.approx(_KP * 1.01, rel=0.02) + + +def test_the_floor_never_exceeds_cruising_speed(): + assert _speed(0.95, fraction=1.0) <= _KP + 1e-9 + + +def test_kp_settles_the_robot_inside_the_last_ten_centimetres(): + assert _speed(0.09) == pytest.approx(_KP * 0.09, rel=0.02) + assert _speed(0.11) == pytest.approx(0.6 * (2 * 4.0 * 0.11) ** 0.5) + + +def test_a_fraction_of_zero_leaves_the_speed_to_kp(): + assert _speed(0.25, fraction=0.0) == pytest.approx(_KP * 0.25, rel=0.02) + + +def test_a_caller_without_a_final_target_is_left_to_kp(): + assert _speed(0.25, has_final_target=False) == pytest.approx(_KP * 0.25, rel=0.02) + + +def test_a_waypoint_nearer_than_the_destination_is_left_to_kp(): + def speed(destination_x: float) -> float: + pid = TwoDPID( + TranslationPIDConfigs(max_velocity=2.0, kp=_KP, max_acceleration=4.0, approach_brake_fraction=0.6) + ) + pid.set_final_target(0, Vector2D(destination_x, 0.0)) + return pid._calculate(Vector2D(0.25, 0.0), _ORIGIN, 0).mag() + + assert speed(0.26) > _KP * 0.25 + 0.1 # 1 cm past the waypoint: still a straight run + assert speed(0.28) == pytest.approx(_KP * 0.25, rel=0.02) # 3 cm: a corner diff --git a/utama_core/tests/motion_planning/test_placement_near_enemy_box.py b/utama_core/tests/motion_planning/test_placement_near_enemy_box.py index 3887349ca..17b989c5e 100644 --- a/utama_core/tests/motion_planning/test_placement_near_enemy_box.py +++ b/utama_core/tests/motion_planning/test_placement_near_enemy_box.py @@ -19,10 +19,8 @@ from utama_core.entities.game.game_history import GameHistory from utama_core.entities.game.robot import Robot from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.motion_planning.src.fastpathplanning.planner import FastPathPlanner -from utama_core.motion_planning.src.trajsampling.planner import ( - TrajectorySamplingPlanner, -) +from utama_core.motion_planning.fastpathplanning.planner import FastPathPlanner +from utama_core.motion_planning.trajsampling.planner import TrajectorySamplingPlanner def _game(command: RefereeCommand, ball_gap_m: float) -> Game: diff --git a/utama_core/tests/motion_planning/test_pose_ahead.py b/utama_core/tests/motion_planning/test_pose_ahead.py index e9970ff97..0757093a6 100644 --- a/utama_core/tests/motion_planning/test_pose_ahead.py +++ b/utama_core/tests/motion_planning/test_pose_ahead.py @@ -5,12 +5,9 @@ import pytest from utama_core.entities.data.vector import Vector2D -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.motion_planning.src.common.pose_ahead import ( - PoseAhead, - control_latency_s, -) -from utama_core.skills.src.utils.move_utils import move +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.motion_planning.common.pose_ahead import PoseAhead, control_latency_s +from utama_core.skills.utils.move_utils import move from utama_core.tests.fixtures.game_builder import build_game, make_ball, make_robot LATENCY = 0.08 diff --git a/utama_core/tests/motion_planning/single_robot_moving_obstacle_test.py b/utama_core/tests/motion_planning/test_single_robot_moving_obstacle.py similarity index 99% rename from utama_core/tests/motion_planning/single_robot_moving_obstacle_test.py rename to utama_core/tests/motion_planning/test_single_robot_moving_obstacle.py index 69637ce66..ea9d0217d 100644 --- a/utama_core/tests/motion_planning/single_robot_moving_obstacle_test.py +++ b/utama_core/tests/motion_planning/test_single_robot_moving_obstacle.py @@ -6,7 +6,7 @@ from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game from utama_core.run import StrategyRunner -from utama_core.team_controller.src.controllers import AbstractSimController +from utama_core.team_controller.controllers import AbstractSimController from utama_core.tests.common.abstract_test_manager import ( AbstractTestManager, TestingStatus, diff --git a/utama_core/tests/motion_planning/single_robot_static_obstacle_test.py b/utama_core/tests/motion_planning/test_single_robot_static_obstacle.py similarity index 98% rename from utama_core/tests/motion_planning/single_robot_static_obstacle_test.py rename to utama_core/tests/motion_planning/test_single_robot_static_obstacle.py index 332ddd2a8..4ff26d55a 100644 --- a/utama_core/tests/motion_planning/single_robot_static_obstacle_test.py +++ b/utama_core/tests/motion_planning/test_single_robot_static_obstacle.py @@ -6,7 +6,7 @@ from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game from utama_core.run import StrategyRunner -from utama_core.team_controller.src.controllers import AbstractSimController +from utama_core.team_controller.controllers import AbstractSimController from utama_core.tests.common.abstract_test_manager import ( AbstractTestManager, TestingStatus, diff --git a/utama_core/tests/custom_referee/helpers.py b/utama_core/tests/referee/helpers.py similarity index 100% rename from utama_core/tests/custom_referee/helpers.py rename to utama_core/tests/referee/helpers.py diff --git a/utama_core/tests/custom_referee/test_aimless_kick.py b/utama_core/tests/referee/test_aimless_kick.py similarity index 90% rename from utama_core/tests/custom_referee/test_aimless_kick.py rename to utama_core/tests/referee/test_aimless_kick.py index 79e35bf63..8978b3835 100644 --- a/utama_core/tests/custom_referee/test_aimless_kick.py +++ b/utama_core/tests/referee/test_aimless_kick.py @@ -10,13 +10,13 @@ import pytest from utama_core.config.field_params import STANDARD_FIELD_DIMS -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.profiles.profile_loader import load_profile -from utama_core.custom_referee.rules.out_of_bounds_rule import OutOfBoundsRule from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.tests.custom_referee.helpers import ball as _ball -from utama_core.tests.custom_referee.helpers import frame as _frame -from utama_core.tests.custom_referee.helpers import robot as _robot +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.profiles.profile_loader import load_profile +from utama_core.referee.rules.out_of_bounds_rule import OutOfBoundsRule +from utama_core.tests.referee.helpers import ball as _ball +from utama_core.tests.referee.helpers import frame as _frame +from utama_core.tests.referee.helpers import robot as _robot GEO = RefereeGeometry.from_field_dims(STANDARD_FIELD_DIMS) # Yellow (friendly) defends the left goal, so it attacks the right goal line. diff --git a/utama_core/tests/custom_referee/test_ball_contest_deadlock.py b/utama_core/tests/referee/test_ball_contest_deadlock.py similarity index 98% rename from utama_core/tests/custom_referee/test_ball_contest_deadlock.py rename to utama_core/tests/referee/test_ball_contest_deadlock.py index f563e5013..e43332a43 100644 --- a/utama_core/tests/custom_referee/test_ball_contest_deadlock.py +++ b/utama_core/tests/referee/test_ball_contest_deadlock.py @@ -27,13 +27,13 @@ from utama_core.config.field_params import STANDARD_FIELD_DIMS from utama_core.config.referee_constants import BALL_KEEP_OUT_DISTANCE -from utama_core.custom_referee.custom_referee import CustomReferee from utama_core.engine.referee_override import RefereeOverride from utama_core.entities.data.vector import Vector2D, Vector3D from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.game.robot import Robot from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.custom_referee import CustomReferee # Robots placed exactly at PushingRule's contact distance (2*ROBOT_RADIUS + # 0.03 = 0.18m) along the x-axis, ball trapped exactly between their fronts — @@ -162,7 +162,7 @@ def _fake_move(game, motion_controller, robot_id, target_coords, target_oren, dr local_forward_vel=0.0, local_left_vel=0.0, angular_vel=0.0, kick=False, chip=False, dribble=False ) - import utama_core.custom_referee.actions as referee_actions + import utama_core.referee.actions as referee_actions original_move = referee_actions.move referee_actions.move = _fake_move diff --git a/utama_core/tests/custom_referee/test_custom_referee.py b/utama_core/tests/referee/test_custom_referee.py similarity index 93% rename from utama_core/tests/custom_referee/test_custom_referee.py rename to utama_core/tests/referee/test_custom_referee.py index 77ae529fb..c4b21abdf 100644 --- a/utama_core/tests/custom_referee/test_custom_referee.py +++ b/utama_core/tests/referee/test_custom_referee.py @@ -8,23 +8,23 @@ import pytest from utama_core.config.field_params import STANDARD_FIELD_DIMS -from utama_core.custom_referee.custom_referee import CustomReferee -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.profiles.profile_loader import load_profile -from utama_core.custom_referee.rules.ball_speed_rule import BallSpeedRule -from utama_core.custom_referee.rules.defense_area_rule import DefenseAreaRule -from utama_core.custom_referee.rules.double_touch_rule import DoubleTouchRule -from utama_core.custom_referee.rules.goal_rule import GoalRule -from utama_core.custom_referee.rules.keep_out_rule import KeepOutRule -from utama_core.custom_referee.rules.out_of_bounds_rule import OutOfBoundsRule -from utama_core.custom_referee.state_machine import GameStateMachine from utama_core.entities.data.referee import RefereeData from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.entities.referee.stage import Stage -from utama_core.tests.custom_referee.helpers import ball as _ball -from utama_core.tests.custom_referee.helpers import frame as _frame -from utama_core.tests.custom_referee.helpers import robot as _robot +from utama_core.referee.custom_referee import CustomReferee +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.profiles.profile_loader import load_profile +from utama_core.referee.rules.ball_speed_rule import BallSpeedRule +from utama_core.referee.rules.defense_area_rule import DefenseAreaRule +from utama_core.referee.rules.double_touch_rule import DoubleTouchRule +from utama_core.referee.rules.goal_rule import GoalRule +from utama_core.referee.rules.keep_out_rule import KeepOutRule +from utama_core.referee.rules.out_of_bounds_rule import OutOfBoundsRule +from utama_core.referee.state_machine import GameStateMachine +from utama_core.tests.referee.helpers import ball as _ball +from utama_core.tests.referee.helpers import frame as _frame +from utama_core.tests.referee.helpers import robot as _robot # --------------------------------------------------------------------------- # Helpers @@ -239,6 +239,7 @@ def test_fires_when_ball_exceeds_speed_limit(self): rule = BallSpeedRule(max_speed_mps=6.5) friendly = {0: _robot(0, 0.0, 0.0, is_friendly=True, has_ball=True)} frame = _frame(ball=_ball(0.0, 0.0, vx=7.0, vy=0.0), friendly_robots=friendly, my_team_is_yellow=True) + rule.check(frame, GEO, RefereeCommand.NORMAL_START) violation = rule.check(frame, GEO, RefereeCommand.NORMAL_START) assert violation is not None assert violation.rule_name == "ball_speed" @@ -260,10 +261,9 @@ def test_only_fires_once_per_kick_not_every_frame(self): rule = BallSpeedRule(max_speed_mps=6.5) friendly = {0: _robot(0, 0.0, 0.0, is_friendly=True, has_ball=True)} frame = _frame(ball=_ball(0.0, 0.0, vx=7.0, vy=0.0), friendly_robots=friendly, my_team_is_yellow=True) - first = rule.check(frame, GEO, RefereeCommand.NORMAL_START) - second = rule.check(frame, GEO, RefereeCommand.NORMAL_START) - assert first is not None - assert second is None # still fast, but not a new kick + assert rule.check(frame, GEO, RefereeCommand.NORMAL_START) is None + assert rule.check(frame, GEO, RefereeCommand.NORMAL_START) is not None + assert rule.check(frame, GEO, RefereeCommand.NORMAL_START) is None # still fast, but not a new kick def test_fires_again_after_dropping_below_and_back_above_limit(self): rule = BallSpeedRule(max_speed_mps=6.5) @@ -271,10 +271,21 @@ def test_fires_again_after_dropping_below_and_back_above_limit(self): fast = _frame(ball=_ball(0.0, 0.0, vx=7.0, vy=0.0), friendly_robots=friendly, my_team_is_yellow=True) slow = _frame(ball=_ball(0.0, 0.0, vx=1.0, vy=0.0), friendly_robots=friendly, my_team_is_yellow=True) + rule.check(fast, GEO, RefereeCommand.NORMAL_START) assert rule.check(fast, GEO, RefereeCommand.NORMAL_START) is not None assert rule.check(slow, GEO, RefereeCommand.NORMAL_START) is None + rule.check(fast, GEO, RefereeCommand.NORMAL_START) assert rule.check(fast, GEO, RefereeCommand.NORMAL_START) is not None + def test_one_frame_over_the_limit_is_noise_not_a_kick(self): + rule = BallSpeedRule(max_speed_mps=6.5) + friendly = {0: _robot(0, 0.0, 0.0, is_friendly=True, has_ball=True)} + spike = _frame(ball=_ball(0.0, 0.0, vx=39.0, vy=0.0), friendly_robots=friendly, my_team_is_yellow=True) + normal = _frame(ball=_ball(0.0, 0.0, vx=5.3, vy=0.0), friendly_robots=friendly, my_team_is_yellow=True) + for _ in range(3): + assert rule.check(spike, GEO, RefereeCommand.NORMAL_START) is None + assert rule.check(normal, GEO, RefereeCommand.NORMAL_START) is None + def test_non_stopping_foul_charged_to_the_kicking_team(self): """SSL rulebook §8.4.2 lists Ball Speed as a non-stopping foul: friendly (yellow) kicked too fast -> yellow is charged, play continues. Ours used @@ -282,6 +293,7 @@ def test_non_stopping_foul_charged_to_the_kicking_team(self): rule = BallSpeedRule(max_speed_mps=6.5) friendly = {0: _robot(0, 0.0, 0.0, is_friendly=True, has_ball=True)} frame = _frame(ball=_ball(0.0, 0.0, vx=7.0, vy=0.0), friendly_robots=friendly, my_team_is_yellow=True) + rule.check(frame, GEO, RefereeCommand.NORMAL_START) violation = rule.check(frame, GEO, RefereeCommand.NORMAL_START) assert violation is not None assert violation.is_stopping is False @@ -304,6 +316,7 @@ def test_enemy_kick_attributed_symmetrically(self): rule = BallSpeedRule(max_speed_mps=6.5) enemy = {0: _robot(0, 0.0, 0.0, is_friendly=False, has_ball=True)} frame = _frame(ball=_ball(0.0, 0.0, vx=7.0, vy=0.0), enemy_robots=enemy, my_team_is_yellow=True) + rule.check(frame, GEO, RefereeCommand.NORMAL_START) violation = rule.check(frame, GEO, RefereeCommand.NORMAL_START) assert violation is not None assert violation.offending_teams == (False,) @@ -315,6 +328,7 @@ def test_scrum_kick_tie_broken_by_distance_not_colour(self): friendly = {0: _robot(0, 0.08, 0.0, is_friendly=True, has_ball=True)} enemy = {0: _robot(0, 0.03, 0.0, is_friendly=False, has_ball=True)} # 0.03 m — closer frame = _frame(ball=_ball(0.0, 0.0, vx=7.0, vy=0.0), friendly_robots=friendly, enemy_robots=enemy) + rule.check(frame, GEO, RefereeCommand.NORMAL_START) violation = rule.check(frame, GEO, RefereeCommand.NORMAL_START) assert violation is not None assert violation.offending_teams == (False,) # enemy (blue) kicked @@ -336,6 +350,44 @@ def _arm_double_touch(rule: DoubleTouchRule, restart_command: RefereeCommand) -> class TestDoubleTouchRule: + @staticmethod + def _kick_during_the_free_kick(rule): + kicking = {0: _robot(0, 0.0, 0.0, is_friendly=True, has_ball=True)} + rule.check( + _frame(ball=_ball(0.0, 0.0), friendly_robots=kicking, my_team_is_yellow=True), + GEO, + RefereeCommand.DIRECT_FREE_YELLOW, + ) + rule.reset() + gone = {0: _robot(0, 0.0, 0.0, is_friendly=True, has_ball=False)} + rule.check( + _frame(ball=_ball(0.5, 0.0, vx=5.0), friendly_robots=gone, my_team_is_yellow=True), + GEO, + RefereeCommand.NORMAL_START, + ) + + def test_the_taker_of_a_kick_struck_before_play_started_cannot_touch_it_again(self): + rule = DoubleTouchRule() + self._kick_during_the_free_kick(rule) + back = {0: _robot(0, 0.5, 0.0, is_friendly=True, has_ball=True)} + violation = rule.check( + _frame(ball=_ball(0.5, 0.0), friendly_robots=back, my_team_is_yellow=True), GEO, RefereeCommand.NORMAL_START + ) + assert violation is not None and violation.offending_robots == ((True, 0),) + + def test_the_receiver_of_a_kick_struck_before_play_started_is_not_the_kicker(self): + rule = DoubleTouchRule() + self._kick_during_the_free_kick(rule) + taker_away = _robot(0, -2.0, 0.0, is_friendly=True, has_ball=False) + for has_ball in (True, False, True): + robots = {0: taker_away, 1: _robot(1, 2.0, 0.0, is_friendly=True, has_ball=has_ball)} + violation = rule.check( + _frame(ball=_ball(2.0, 0.0), friendly_robots=robots, my_team_is_yellow=True), + GEO, + RefereeCommand.NORMAL_START, + ) + assert violation is None + def test_same_robot_touching_twice_after_a_restart_fouls(self): rule = DoubleTouchRule() _arm_double_touch(rule, RefereeCommand.DIRECT_FREE_YELLOW) @@ -788,7 +840,7 @@ def test_no_automatic_sanction_during_a_penalty_or_stop(self, command): class TestGameStateMachine: def test_goal_increments_yellow_score(self): - from utama_core.custom_referee.rules.base_rule import RuleViolation + from utama_core.referee.rules.base_rule import RuleViolation sm = _state_machine() violation = RuleViolation( @@ -804,7 +856,7 @@ def test_goal_increments_yellow_score(self): assert data.next_command == RefereeCommand.BALL_PLACEMENT_BLUE def test_goal_increments_blue_score(self): - from utama_core.custom_referee.rules.base_rule import RuleViolation + from utama_core.referee.rules.base_rule import RuleViolation sm = _state_machine() violation = RuleViolation( @@ -818,7 +870,7 @@ def test_goal_increments_blue_score(self): assert sm.yellow_team.score == 0 def test_transition_cooldown_suppresses_duplicate(self): - from utama_core.custom_referee.rules.base_rule import RuleViolation + from utama_core.referee.rules.base_rule import RuleViolation sm = _state_machine() violation = RuleViolation( @@ -835,7 +887,7 @@ def test_transition_cooldown_suppresses_duplicate(self): assert sm.yellow_team.score == 1 # still 1 def test_goal_sets_designated_position_to_centre(self): - from utama_core.custom_referee.rules.base_rule import RuleViolation + from utama_core.referee.rules.base_rule import RuleViolation sm = _state_machine() violation = RuleViolation( @@ -848,7 +900,7 @@ def test_goal_sets_designated_position_to_centre(self): assert data.designated_position == (0.0, 0.0) def test_goal_status_message_is_propagated_into_referee_data(self): - from utama_core.custom_referee.rules.base_rule import RuleViolation + from utama_core.referee.rules.base_rule import RuleViolation sm = _state_machine() violation = RuleViolation( @@ -875,7 +927,7 @@ def test_halt_escalation_mid_goal_restart_preserves_kickoff_and_ball_target(self match. _handle_foul must preserve next_command/ball_placement_target when the escalating violation doesn't provide its own. """ - from utama_core.custom_referee.rules.base_rule import RuleViolation + from utama_core.referee.rules.base_rule import RuleViolation sm = _state_machine() goal = RuleViolation( @@ -907,7 +959,7 @@ def test_halt_escalation_with_its_own_restart_still_overrides(self): (e.g. a genuinely new stopping foul) must still take effect as before -- the preservation above only guards against an escalation with nothing of its own to give.""" - from utama_core.custom_referee.rules.base_rule import RuleViolation + from utama_core.referee.rules.base_rule import RuleViolation sm = _state_machine() goal = RuleViolation( @@ -933,7 +985,7 @@ def test_halt_escalation_with_its_own_restart_still_overrides(self): assert data.designated_position == (1.5, 2.0) def test_manual_command_clears_status_message(self): - from utama_core.custom_referee.rules.base_rule import RuleViolation + from utama_core.referee.rules.base_rule import RuleViolation sm = _state_machine() violation = RuleViolation( @@ -986,7 +1038,7 @@ def test_manual_penalty_auto_advances_from_stop_and_then_to_normal_start(self): assert data.next_command is None def test_reset_restores_score_command_and_stage(self): - from utama_core.custom_referee.rules.base_rule import RuleViolation + from utama_core.referee.rules.base_rule import RuleViolation sm = _state_machine() violation = RuleViolation( @@ -1020,7 +1072,6 @@ def test_reset_clears_auto_advance_timers(self): sm.reset() assert sm._advance2_ready_since == math.inf - assert sm._advance3_ready_since == math.inf assert sm._advance4_ready_since == math.inf assert sm._last_transition_time == -math.inf @@ -1173,7 +1224,7 @@ def test_simulation_stop_advances_after_timeout_even_if_a_robot_never_clears(sel must force the advance through regardless once enough time has passed, the same way a real GC operator eventually would. """ - from utama_core.custom_referee.rules.base_rule import RuleViolation + from utama_core.referee.rules.base_rule import RuleViolation sm = _state_machine() stuck_ball = _ball(0.0, 0.0) @@ -1212,7 +1263,7 @@ def test_simulation_stop_still_advances_immediately_when_robots_clear_normally(s clear the ball, STOP still advances immediately rather than waiting out the new timeout -- the timeout is a fallback, not a new floor on every restart's latency.""" - from utama_core.custom_referee.rules.base_rule import RuleViolation + from utama_core.referee.rules.base_rule import RuleViolation sm = _state_machine() clear_frame = _frame( @@ -1270,23 +1321,20 @@ def test_simulation_double_touch_after_direct_free_kick_is_flagged(self): data = referee.step(clear_frame, current_time=2.0) assert data.referee_command == RefereeCommand.DIRECT_FREE_BLUE - # Blue kicker ready, defenders clear -> auto-advances to NORMAL_START. - ready_frame = _frame( - ball=_ball(0.0, 0.0), - enemy_robots={0: _robot(0, 0.0, 0.0, is_friendly=False)}, - ts=5.0, - ) - referee.step(ready_frame, current_time=5.0) - data = referee.step(ready_frame, current_time=8.0) - assert data.referee_command == RefereeCommand.NORMAL_START - - # Blue kicker touches the ball (the restart kick itself). + # Blue kicker strikes the ball: it has moved, so the free kick is taken. kicker_touch = _frame( ball=_ball(0.0, 0.0), enemy_robots={0: _robot(0, 0.0, 0.0, is_friendly=False, has_ball=True)}, - ts=8.1, + ts=5.0, + ) + referee.step(kicker_touch, current_time=5.0) + struck = _frame( + ball=_ball(0.1, 0.0), + enemy_robots={0: _robot(0, 0.0, 0.0, is_friendly=False, has_ball=False)}, + ts=5.1, ) - referee.step(kicker_touch, current_time=8.1) + data = referee.step(struck, current_time=5.1) + assert data.referee_command == RefereeCommand.NORMAL_START # Kicker releases, then touches again — no one else touched it. Foul. released = _frame( diff --git a/utama_core/tests/custom_referee/test_dribble_placement_stopspeed.py b/utama_core/tests/referee/test_dribble_placement_stopspeed.py similarity index 97% rename from utama_core/tests/custom_referee/test_dribble_placement_stopspeed.py rename to utama_core/tests/referee/test_dribble_placement_stopspeed.py index 0be2a8526..939661a52 100644 --- a/utama_core/tests/custom_referee/test_dribble_placement_stopspeed.py +++ b/utama_core/tests/referee/test_dribble_placement_stopspeed.py @@ -6,18 +6,16 @@ import pytest from utama_core.config.field_params import STANDARD_FIELD_DIMS -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.excessive_dribbling_rule import ( - ExcessiveDribblingRule, -) -from utama_core.custom_referee.rules.keeper_held_ball_rule import KeeperHeldBallRule -from utama_core.custom_referee.rules.robot_stop_speed_rule import RobotStopSpeedRule from utama_core.entities.data.vector import Vector2D, Vector3D from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.game.robot import Robot from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.tests.custom_referee.helpers import frame as _frame +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.excessive_dribbling_rule import ExcessiveDribblingRule +from utama_core.referee.rules.keeper_held_ball_rule import KeeperHeldBallRule +from utama_core.referee.rules.robot_stop_speed_rule import RobotStopSpeedRule +from utama_core.tests.referee.helpers import frame as _frame GEO = RefereeGeometry.from_field_dims(STANDARD_FIELD_DIMS) diff --git a/utama_core/tests/custom_referee/test_foul_counter_end_to_end.py b/utama_core/tests/referee/test_foul_counter_end_to_end.py similarity index 98% rename from utama_core/tests/custom_referee/test_foul_counter_end_to_end.py rename to utama_core/tests/referee/test_foul_counter_end_to_end.py index 601b5d673..76a6607fc 100644 --- a/utama_core/tests/custom_referee/test_foul_counter_end_to_end.py +++ b/utama_core/tests/referee/test_foul_counter_end_to_end.py @@ -15,9 +15,9 @@ from __future__ import annotations -from utama_core.custom_referee.rules.base_rule import RuleViolation -from utama_core.custom_referee.state_machine import GameStateMachine from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.rules.base_rule import RuleViolation +from utama_core.referee.state_machine import GameStateMachine # GameStateMachine._TRANSITION_COOLDOWN is 0.3s — a stopping foul's # transition is suppressed if it arrives sooner than that after the last diff --git a/utama_core/tests/custom_referee/test_free_kick_taken.py b/utama_core/tests/referee/test_free_kick_taken.py similarity index 97% rename from utama_core/tests/custom_referee/test_free_kick_taken.py rename to utama_core/tests/referee/test_free_kick_taken.py index 8367dc893..2adf9f943 100644 --- a/utama_core/tests/custom_referee/test_free_kick_taken.py +++ b/utama_core/tests/referee/test_free_kick_taken.py @@ -3,11 +3,11 @@ auto-advance, so a defender the ball rolled onto was still charged with keep_out. """ -from utama_core.custom_referee.state_machine import GameStateMachine from utama_core.entities.data.vector import Vector3D from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.state_machine import GameStateMachine def _frame(ts: float, ball_xy: tuple[float, float]) -> GameFrame: diff --git a/utama_core/tests/custom_referee/test_free_kick_timeout.py b/utama_core/tests/referee/test_free_kick_timeout.py similarity index 93% rename from utama_core/tests/custom_referee/test_free_kick_timeout.py rename to utama_core/tests/referee/test_free_kick_timeout.py index 163fc0c4a..0f0a23187 100644 --- a/utama_core/tests/custom_referee/test_free_kick_timeout.py +++ b/utama_core/tests/referee/test_free_kick_timeout.py @@ -3,11 +3,11 @@ with no limit, so a free kick nobody took held the game forever. """ -from utama_core.custom_referee.state_machine import GameStateMachine from utama_core.entities.data.vector import Vector3D from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.state_machine import GameStateMachine def _frame(ts: float) -> GameFrame: @@ -34,7 +34,7 @@ def test_untaken_free_kick_is_in_play_after_ten_seconds(): def test_defender_too_close_restarts_the_free_kick_clock(): """§8.4.3: on a Defender Too Close foul "the timer of the opponent team for bringing the ball into play is reset".""" - from utama_core.custom_referee.rules.base_rule import RuleViolation + from utama_core.referee.rules.base_rule import RuleViolation sm = GameStateMachine(half_duration_seconds=300.0, kickoff_team="yellow", n_robots_yellow=3, n_robots_blue=3) sm.seed_clock(0.0) @@ -55,7 +55,7 @@ def test_defender_too_close_restarts_the_free_kick_clock(): def test_only_the_first_defender_too_close_foul_restarts_the_free_kick_clock(): """A defender parked inside 0.5 m re-raises keep_out every 2 s; when each foul restarted the clock, the free kick was never forced and held the rest of a match.""" - from utama_core.custom_referee.rules.base_rule import RuleViolation + from utama_core.referee.rules.base_rule import RuleViolation sm = GameStateMachine(half_duration_seconds=300.0, kickoff_team="yellow", n_robots_yellow=3, n_robots_blue=3) sm.seed_clock(0.0) diff --git a/utama_core/tests/custom_referee/test_geometry.py b/utama_core/tests/referee/test_geometry.py similarity index 98% rename from utama_core/tests/custom_referee/test_geometry.py rename to utama_core/tests/referee/test_geometry.py index 1b82052e5..97a713f86 100644 --- a/utama_core/tests/custom_referee/test_geometry.py +++ b/utama_core/tests/referee/test_geometry.py @@ -26,8 +26,8 @@ from utama_core.config.field_params import STANDARD_FIELD_DIMS from utama_core.config.referee_constants import OPPONENT_DEFENSE_AREA_KEEP_DISTANCE -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.out_of_bounds_rule import ( +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.out_of_bounds_rule import ( _CORNER_INFIELD_OFFSET, OutOfBoundsRule, ) @@ -262,7 +262,7 @@ def test_a_restart_near_the_box_leaves_room_for_the_kickers_approach(x: float, y towards the box whenever the kick points away from it; that spot has to clear the planner's ring too. A free kick at (-4.25, -1.54), 0.54 m from the side edge, held its kicker 1.3 m away for 20 s (tournament_20260927_230330).""" - from utama_core.custom_referee.actions import DirectFreeOursStep + from utama_core.referee.actions import DirectFreeOursStep px, py = GEO.legal_restart_position(x, y, OPPONENT_DEFENSE_AREA_KEEP_DISTANCE) inner_x = GEO.half_length - 2.0 * GEO.half_defense_depth diff --git a/utama_core/tests/custom_referee/test_goal_after_non_stopping_foul.py b/utama_core/tests/referee/test_goal_after_non_stopping_foul.py similarity index 94% rename from utama_core/tests/custom_referee/test_goal_after_non_stopping_foul.py rename to utama_core/tests/referee/test_goal_after_non_stopping_foul.py index a0bfde486..f88678944 100644 --- a/utama_core/tests/custom_referee/test_goal_after_non_stopping_foul.py +++ b/utama_core/tests/referee/test_goal_after_non_stopping_foul.py @@ -6,12 +6,12 @@ import pytest -from utama_core.custom_referee.custom_referee import CustomReferee -from utama_core.custom_referee.rules.base_rule import BaseRule, RuleViolation from utama_core.entities.data.vector import Vector3D from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.custom_referee import CustomReferee +from utama_core.referee.rules.base_rule import BaseRule, RuleViolation class _FoulOnce(BaseRule): diff --git a/utama_core/tests/custom_referee/test_halt_resume.py b/utama_core/tests/referee/test_halt_resume.py similarity index 93% rename from utama_core/tests/custom_referee/test_halt_resume.py rename to utama_core/tests/referee/test_halt_resume.py index f5d46d268..856e7eebb 100644 --- a/utama_core/tests/custom_referee/test_halt_resume.py +++ b/utama_core/tests/referee/test_halt_resume.py @@ -9,10 +9,10 @@ from __future__ import annotations -from utama_core.custom_referee.rules.base_rule import RuleViolation -from utama_core.custom_referee.state_machine import GameStateMachine from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.tests.custom_referee.helpers import ball, frame +from utama_core.referee.rules.base_rule import RuleViolation +from utama_core.referee.state_machine import GameStateMachine +from utama_core.tests.referee.helpers import ball, frame _HALT = RuleViolation( rule_name="defense_area_stoppage", diff --git a/utama_core/tests/custom_referee/test_last_touch.py b/utama_core/tests/referee/test_last_touch.py similarity index 96% rename from utama_core/tests/custom_referee/test_last_touch.py rename to utama_core/tests/referee/test_last_touch.py index 8347bc6cd..30fbc8efd 100644 --- a/utama_core/tests/custom_referee/test_last_touch.py +++ b/utama_core/tests/referee/test_last_touch.py @@ -10,14 +10,14 @@ from __future__ import annotations from utama_core.config.field_params import STANDARD_FIELD_DIMS -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.last_touch import infer_last_touch_team -from utama_core.custom_referee.rules.out_of_bounds_rule import OutOfBoundsRule from utama_core.entities.data.vector import Vector3D from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.tests.custom_referee.helpers import robot as _robot +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.last_touch import infer_last_touch_team +from utama_core.referee.rules.out_of_bounds_rule import OutOfBoundsRule +from utama_core.tests.referee.helpers import robot as _robot def _ball(x: float, y: float) -> Ball: diff --git a/utama_core/tests/custom_referee/test_no_progress_rule.py b/utama_core/tests/referee/test_no_progress_rule.py similarity index 97% rename from utama_core/tests/custom_referee/test_no_progress_rule.py rename to utama_core/tests/referee/test_no_progress_rule.py index 7941952a7..6cff44f40 100644 --- a/utama_core/tests/custom_referee/test_no_progress_rule.py +++ b/utama_core/tests/referee/test_no_progress_rule.py @@ -9,14 +9,14 @@ import pytest from utama_core.config.field_params import STANDARD_FIELD_DIMS -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.no_progress_rule import NoProgressRule -from utama_core.custom_referee.state_machine import GameStateMachine from utama_core.entities.data.vector import Vector2D, Vector3D from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.game.robot import Robot from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.no_progress_rule import NoProgressRule +from utama_core.referee.state_machine import GameStateMachine GEO = RefereeGeometry.from_field_dims(STANDARD_FIELD_DIMS) @@ -87,7 +87,7 @@ def test_state_machine_continues_with_force_start_once_robots_clear(): def test_simulation_profile_stops_a_frozen_game(): - from utama_core.custom_referee.custom_referee import CustomReferee + from utama_core.referee.custom_referee import CustomReferee referee = CustomReferee.from_profile_name("simulation", n_robots_yellow=1, n_robots_blue=1) referee.seed_clock(0.0, initial_command=RefereeCommand.FORCE_START) diff --git a/utama_core/tests/custom_referee/test_out_of_bounds_offender.py b/utama_core/tests/referee/test_out_of_bounds_offender.py similarity index 88% rename from utama_core/tests/custom_referee/test_out_of_bounds_offender.py rename to utama_core/tests/referee/test_out_of_bounds_offender.py index b2505cf53..7e4f335ed 100644 --- a/utama_core/tests/custom_referee/test_out_of_bounds_offender.py +++ b/utama_core/tests/referee/test_out_of_bounds_offender.py @@ -7,13 +7,13 @@ """ from utama_core.config.field_params import STANDARD_FIELD_DIMS -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.out_of_bounds_rule import OutOfBoundsRule from utama_core.engine.match_stats import MatchStatsAccumulator from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.tests.custom_referee.helpers import ball as _ball -from utama_core.tests.custom_referee.helpers import frame as _frame -from utama_core.tests.custom_referee.helpers import robot as _robot +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.out_of_bounds_rule import OutOfBoundsRule +from utama_core.tests.referee.helpers import ball as _ball +from utama_core.tests.referee.helpers import frame as _frame +from utama_core.tests.referee.helpers import robot as _robot GEO = RefereeGeometry.from_field_dims(STANDARD_FIELD_DIMS) _OVER_THE_TOUCH_LINE = (1.0, GEO.half_width + 0.05) diff --git a/utama_core/tests/custom_referee/test_penalty_time_limit_rule.py b/utama_core/tests/referee/test_penalty_time_limit_rule.py similarity index 94% rename from utama_core/tests/custom_referee/test_penalty_time_limit_rule.py rename to utama_core/tests/referee/test_penalty_time_limit_rule.py index 8e05e060c..b367ede64 100644 --- a/utama_core/tests/custom_referee/test_penalty_time_limit_rule.py +++ b/utama_core/tests/referee/test_penalty_time_limit_rule.py @@ -8,12 +8,12 @@ import pytest from utama_core.config.field_params import STANDARD_FIELD_DIMS -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.penalty_time_limit_rule import PenaltyTimeLimitRule from utama_core.entities.data.vector import Vector3D from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.penalty_time_limit_rule import PenaltyTimeLimitRule GEO = RefereeGeometry.from_field_dims(STANDARD_FIELD_DIMS) @@ -79,7 +79,7 @@ def test_ordinary_kickoff_has_no_time_limit(): def test_simulation_profile_stops_a_penalty_after_ten_seconds(): - from utama_core.custom_referee.custom_referee import CustomReferee + from utama_core.referee.custom_referee import CustomReferee referee = CustomReferee.from_profile_name("simulation", n_robots_yellow=1, n_robots_blue=1) referee.seed_clock(0.0, initial_command=RefereeCommand.FORCE_START) diff --git a/utama_core/tests/custom_referee/test_placement_interference_and_defense_fixes.py b/utama_core/tests/referee/test_placement_interference_and_defense_fixes.py similarity index 96% rename from utama_core/tests/custom_referee/test_placement_interference_and_defense_fixes.py rename to utama_core/tests/referee/test_placement_interference_and_defense_fixes.py index 31dc217ff..1e421f25a 100644 --- a/utama_core/tests/custom_referee/test_placement_interference_and_defense_fixes.py +++ b/utama_core/tests/referee/test_placement_interference_and_defense_fixes.py @@ -7,20 +7,18 @@ import pytest from utama_core.config.field_params import STANDARD_FIELD_DIMS -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.ball_placement_interference_rule import ( - BallPlacementInterferenceRule, -) -from utama_core.custom_referee.rules.defense_area_rule import DefenseAreaRule -from utama_core.custom_referee.rules.defense_area_stoppage_rule import ( - DefenseAreaStoppageRule, -) -from utama_core.custom_referee.rules.out_of_bounds_rule import OutOfBoundsRule from utama_core.entities.data.vector import Vector3D from utama_core.entities.game.ball import Ball from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.tests.custom_referee.helpers import frame as _frame -from utama_core.tests.custom_referee.helpers import robot as _robot +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.ball_placement_interference_rule import ( + BallPlacementInterferenceRule, +) +from utama_core.referee.rules.defense_area_rule import DefenseAreaRule +from utama_core.referee.rules.defense_area_stoppage_rule import DefenseAreaStoppageRule +from utama_core.referee.rules.out_of_bounds_rule import OutOfBoundsRule +from utama_core.tests.referee.helpers import frame as _frame +from utama_core.tests.referee.helpers import robot as _robot GEO = RefereeGeometry.from_field_dims(STANDARD_FIELD_DIMS) diff --git a/utama_core/tests/custom_referee/test_pushing_crashing.py b/utama_core/tests/referee/test_pushing_crashing.py similarity index 98% rename from utama_core/tests/custom_referee/test_pushing_crashing.py rename to utama_core/tests/referee/test_pushing_crashing.py index 1bf38fdd5..26db7388c 100644 --- a/utama_core/tests/custom_referee/test_pushing_crashing.py +++ b/utama_core/tests/referee/test_pushing_crashing.py @@ -3,14 +3,14 @@ from __future__ import annotations from utama_core.config.field_params import STANDARD_FIELD_DIMS -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.crashing_rule import CrashingRule -from utama_core.custom_referee.rules.pushing_rule import PushingRule from utama_core.entities.data.vector import Vector2D, Vector3D from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.game.robot import Robot from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.crashing_rule import CrashingRule +from utama_core.referee.rules.pushing_rule import PushingRule GEO = RefereeGeometry.from_field_dims(STANDARD_FIELD_DIMS) diff --git a/utama_core/tests/custom_referee/test_referee_rules_integration.py b/utama_core/tests/referee/test_referee_rules_integration.py similarity index 99% rename from utama_core/tests/custom_referee/test_referee_rules_integration.py rename to utama_core/tests/referee/test_referee_rules_integration.py index b16812089..d0d999faf 100644 --- a/utama_core/tests/custom_referee/test_referee_rules_integration.py +++ b/utama_core/tests/referee/test_referee_rules_integration.py @@ -13,12 +13,12 @@ from __future__ import annotations -from utama_core.custom_referee.custom_referee import CustomReferee from utama_core.entities.data.vector import Vector2D, Vector3D from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.game.robot import Robot from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.custom_referee import CustomReferee def _ball(x: float = 0.0, y: float = 0.0, vx: float = 0.0, vy: float = 0.0) -> Ball: diff --git a/utama_core/tests/custom_referee/test_referee_scan_order.py b/utama_core/tests/referee/test_referee_scan_order.py similarity index 97% rename from utama_core/tests/custom_referee/test_referee_scan_order.py rename to utama_core/tests/referee/test_referee_scan_order.py index f027198a2..be428df14 100644 --- a/utama_core/tests/custom_referee/test_referee_scan_order.py +++ b/utama_core/tests/referee/test_referee_scan_order.py @@ -30,14 +30,14 @@ from typing import Optional -from utama_core.custom_referee.custom_referee import CustomReferee -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.base_rule import BaseRule, RuleViolation from utama_core.entities.data.vector import Vector2D, Vector3D from utama_core.entities.game.ball import Ball from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.game.robot import Robot from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee.custom_referee import CustomReferee +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.base_rule import BaseRule, RuleViolation # Robots at PushingRule/CrashingRule's contact distance (2*ROBOT_RADIUS+0.03 = # 0.18m), same convention as test_pushing_crashing.py. @@ -148,7 +148,7 @@ def test_first_stopping_rule_in_priority_order_wins_and_later_rules_are_never_co # check() with a call counter, in place, so the rest of # CustomReferee's internals (the same self._rules list _step() # iterates) are completely untouched. - from utama_core.custom_referee.rules.out_of_bounds_rule import OutOfBoundsRule + from utama_core.referee.rules.out_of_bounds_rule import OutOfBoundsRule oob_rule = next(r for r in referee._rules if isinstance(r, OutOfBoundsRule)) call_count = 0 diff --git a/utama_core/tests/referee/test_referee_unit.py b/utama_core/tests/referee/test_referee_unit.py index e145025be..c6e434120 100644 --- a/utama_core/tests/referee/test_referee_unit.py +++ b/utama_core/tests/referee/test_referee_unit.py @@ -33,8 +33,8 @@ from utama_core.entities.game.team_info import TeamInfo from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.entities.referee.stage import Stage -from utama_core.motion_planning.src.common.pose_ahead import PoseAhead -from utama_core.skills.src.utils.move_utils import empty_command +from utama_core.motion_planning.common.pose_ahead import PoseAhead +from utama_core.skills.utils.move_utils import empty_command # --------------------------------------------------------------------------- # Helpers @@ -131,7 +131,11 @@ def _make_blackboard(game: Game, cmd_map=None): bb.game = game bb.cmd_map = cmd_map if cmd_map is not None else {} bb.motion_controller = SimpleNamespace( - calculate=lambda **kwargs: (Vector2D(0.0, 0.0), 0.0), pose_ahead=PoseAhead(0.0), min_turn=None + calculate=lambda **kwargs: (Vector2D(0.0, 0.0), 0.0), + pose_ahead=PoseAhead(0.0), + min_turn=None, + kick_bend={}, + kick_bias={}, ) return bb @@ -312,7 +316,7 @@ def _run_step(self, step_class, game: Game) -> dict: return cmd_map def test_halt_writes_to_all_robots(self): - from utama_core.custom_referee.actions import HaltStep + from utama_core.referee.actions import HaltStep robots = {0: _robot(0), 1: _robot(1)} game = _make_game(friendly_robots=robots, referee=_make_referee_data()) @@ -322,7 +326,7 @@ def test_halt_writes_to_all_robots(self): assert cmd_map[rid] is not None def test_stop_writes_to_all_robots(self): - from utama_core.custom_referee.actions import StopStep + from utama_core.referee.actions import StopStep robots = {0: _robot(0), 1: _robot(1), 2: _robot(2)} game = _make_game(friendly_robots=robots, referee=_make_referee_data()) @@ -337,7 +341,7 @@ def test_stop_writes_to_all_robots(self): class TestBallPlacementOursStep: def test_robot_without_ball_moves_to_ball_first(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -408,7 +412,7 @@ def test_robot_without_ball_approaches_an_out_of_bounds_ball_with_offset(self, m whatever tick sees the ball still out of bounds (e.g. the one tick before that teleport lands). """ - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -461,7 +465,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri expected = referee_actions._clamp_to_field_or_ball(approach, game, ball_pos) # The placer starts on the designated side, so it routes round the ball to the # (clamped) approach point rather than straight at it. - from utama_core.global_utils.math_utils import detour_around_circle + from utama_core.geometry.math_utils import detour_around_circle expected = detour_around_circle(Vector2D(4.0, 0.0), expected, ball_pos, referee_actions._BALL_DETOUR_RADIUS_M) assert captured[0][1].x == pytest.approx(expected.x) @@ -477,7 +481,7 @@ def test_placer_choice_is_sticky_across_near_tied_distances(self, monkeypatch): placer choice via `Sticky` across ticks (the instance persists across ticks -- constructed once in `RefereeOverride.__init__`). """ - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured_placer_ids = [] @@ -534,7 +538,7 @@ def test_placer_reassigns_when_a_robot_is_clearly_closer(self, monkeypatch): """The sticky placer choice must still yield to a genuinely closer robot -- hysteresis should suppress noise-level flips, not freeze the assignment forever.""" - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured_placer_ids = [] @@ -588,7 +592,7 @@ def test_teammate_parked_on_the_spot_is_cleared_off_the_ball_path(self, monkeypa (7 of 441 placements in that run). Teammates now keep off the ball's path to the spot, as the other team already must.""" from utama_core.config.referee_constants import BALL_KEEP_OUT_DISTANCE - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = {} @@ -631,7 +635,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri def test_robot_with_ball_moves_to_designated_position(self, monkeypatch): import math - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions move_captured = [] turn_captured = [] @@ -708,7 +712,7 @@ def test_release_withheld_while_ball_still_moving_fast_near_target(self, monkeyp must keep driving the placer (move(), not empty_command()) rather than starting the release countdown. """ - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions move_captured = [] @@ -768,7 +772,7 @@ def test_release_starts_once_ball_is_close_and_settled(self, monkeypatch): """Companion to the fast-ball case above: once the ball is both within BALL_PLACEMENT_DONE_DISTANCE and slow (<= _SETTLED_SPEED_MPS), the release countdown must actually start.""" - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions monkeypatch.setattr(referee_actions, "move", lambda *a, **k: ("move", a[2])) @@ -814,7 +818,7 @@ def test_release_starts_once_ball_is_close_and_settled(self, monkeypatch): assert node._release_started_at == 0.0 def test_non_placing_teammate_clears_from_ball(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -862,7 +866,7 @@ class TestBallPlacementOursCarry: @pytest.fixture(autouse=True) def _fresh_possession_state(self): - from utama_core.shared.pass_and_score_geometry import reset_possession_state + from utama_core.geometry.pass_and_score_geometry import reset_possession_state reset_possession_state() yield @@ -873,8 +877,8 @@ def _tick(self, monkeypatch, node, ts, has_ball, ball_x=0.09, ball_v=0.0, full_s Returns (where it was sent, the command it got).""" import dataclasses - from utama_core.custom_referee import actions as referee_actions from utama_core.entities.data.command import RobotCommand + from utama_core.referee import actions as referee_actions sent = {} @@ -905,13 +909,13 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri @pytest.mark.parametrize("full_speed", [0.49, 0.51, 1.0]) def test_the_carry_is_capped_at_carry_speed(self, monkeypatch, full_speed): - from utama_core.custom_referee.actions import BallPlacementOursStep as Step + from utama_core.referee.actions import BallPlacementOursStep as Step _, cmd = self._tick(monkeypatch, Step(), 0.0, True, full_speed=full_speed) assert cmd.local_forward_vel == pytest.approx(min(full_speed, Step._CARRY_SPEED_MPS)) def test_the_carry_slows_to_stop_at_the_spot(self, monkeypatch): - from utama_core.custom_referee.actions import BallPlacementOursStep as Step + from utama_core.referee.actions import BallPlacementOursStep as Step # Still rolling 0.08 m from the spot (not settled): no faster than braking at the carry rate allows. _, cmd = self._tick(monkeypatch, Step(), 0.0, True, ball_x=self.DESIGNATED[0] - 0.08, ball_v=0.4) @@ -934,7 +938,7 @@ class TestBallPlacementOursApproachAroundBall: def _placer_move(self, monkeypatch, robot_xy, ball_v=(0.0, 0.0)): """(target, orientation) the placer at `robot_xy` is sent to.""" - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = {} @@ -1011,7 +1015,7 @@ def test_placer_meets_a_rolling_ball_on_its_path_facing_it(self, monkeypatch, sp placer's back to it, heading for a point behind it facing the spot, and never caught. Rolling faster than `_SETTLED_SPEED_MPS`, the placer goes to where it will meet the ball, ahead on its path, facing back along it.""" - from utama_core.custom_referee.actions import BallPlacementOursStep as step + from utama_core.referee.actions import BallPlacementOursStep as step assert step._SETTLED_SPEED_MPS == 0.3 start = (-2.0, -2.0) @@ -1036,7 +1040,7 @@ def test_placer_parked_at_the_approach_point_creeps_onto_the_ball(self, monkeypa """Field test 2026-10-27: real placers parked 0.10-0.11 m from the ball, ~1 cm short of dribbler contact, for 15-20 s. Lined up within _CREEP_RANGE_M of the approach point without the ball, the target moves _CREEP_M further along the carry direction.""" - from utama_core.custom_referee.actions import BallPlacementOursStep as step + from utama_core.referee.actions import BallPlacementOursStep as step at_edge = (self.APPROACH[0] - step._CREEP_RANGE_M, self.APPROACH[1]) target = self._placer_target(monkeypatch, at_edge) @@ -1044,7 +1048,7 @@ def test_placer_parked_at_the_approach_point_creeps_onto_the_ball(self, monkeypa assert (target.x, target.y) == pytest.approx((self.APPROACH[0] + step._CREEP_M, self.APPROACH[1])) def test_placer_short_of_the_creep_range_aims_at_the_approach_point(self, monkeypatch): - from utama_core.custom_referee.actions import BallPlacementOursStep as step + from utama_core.referee.actions import BallPlacementOursStep as step target = self._placer_target(monkeypatch, (self.APPROACH[0] - step._CREEP_RANGE_M - 0.001, self.APPROACH[1])) @@ -1058,7 +1062,7 @@ def test_placer_short_of_the_creep_range_aims_at_the_approach_point(self, monkey class TestRefereeKeepOutRetreat: def test_stop_moves_only_robots_inside_keep_out_radius(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -1085,7 +1089,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri assert cmd_map[1] is not None def test_stop_clears_robot_from_opponent_defense_area(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -1129,7 +1133,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri assert captured[0][1] == Vector2D(-3.25, 0.0) def test_direct_free_theirs_clears_robot_from_opponent_defense_area(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -1168,12 +1172,12 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri node.update() - assert len(captured) == 1 + assert len(captured) == 2 # the other robot takes the wall assert captured[0][0] == 0 assert captured[0][1] == Vector2D(-3.25, 0.0) def test_direct_free_theirs_evicts_excess_defenders_from_own_defense_area(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -1217,7 +1221,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri assert captured[0][1] == Vector2D(3.27, 0.2) def test_ball_placement_theirs_clears_robot_from_opponent_defense_area(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -1261,7 +1265,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri assert captured[0][1] == Vector2D(-3.25, 0.0) def test_ball_placement_theirs_clears_encroaching_robot(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -1288,7 +1292,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri assert captured[0][1] == Vector2D(0.8, 0.0) def test_ball_placement_theirs_clears_robot_from_designated_position(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -1333,7 +1337,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri assert captured[0][1] == Vector2D(1.8, 1.0) def test_direct_free_theirs_clears_encroaching_robot(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -1355,14 +1359,14 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri node.update() - assert len(captured) == 1 + assert len(captured) == 2 # the other robot takes the wall assert captured[0][0] == 0 assert captured[0][1] == Vector2D(0.8, 0.0) class TestPenaltyPositioning: def test_prepare_penalty_ours_kicker_stays_on_attacking_half(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -1393,7 +1397,7 @@ def test_prepare_penalty_ours_kicker_waits_behind_the_ball_not_on_it(self, monke # decoy_and_overload_vs_score_aware_zone_flow (2026-09-28): the kicker was # sent to the mark itself, i.e. onto the placed ball, shoved it away at # 1.5 m/s before NORMAL_START, and keep-out voided the penalty. - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = {} @@ -1424,7 +1428,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri assert (kicker_target - mark).mag() <= KICKER_READY_DISTANCE def test_prepare_penalty_theirs_support_robots_stay_on_our_half(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -1463,7 +1467,7 @@ def test_prepare_penalty_theirs_support_robots_stand_outside_the_keep_out_circle # decoy_and_overload_vs_low_block (2026-09-28): the line 0.4 m behind the # mark put a defender 0.44 m from the ball, KeepOutRule (0.5 m) fired # 1 s into every PREPARE_PENALTY, and the penalty was never taken. - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -1490,7 +1494,7 @@ def test_prepare_penalty_theirs_goal_side_defender_walks_round_the_ball(self, mo # decoy_and_overload_vs_low_block (2026-09-28): a defender starting between # the mark and its own goal drove straight through the ball to the line # behind it, 0.30 m from the ball for 0.5 s -- keep-out voided the penalty. - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = {} @@ -1524,7 +1528,7 @@ def test_prepare_penalty_ours_goal_side_teammate_walks_round_the_ball(self, monk # Mirror of the defender case: a non-kicker of ours left goal-side of the # mark drove straight through the placed ball to its line 1 m behind it, # knocking the ball off the mark before the kick. - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = {} @@ -1557,7 +1561,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri def test_prepare_penalty_ours_goalkeeper_stays_on_own_goal_line(self, monkeypatch): # PreparePenaltyOursStep must keep the friendly goalkeeper on our own goal line, # not displace it into the opponent's half behind the penalty mark. - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = {} @@ -1590,7 +1594,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri def test_prepare_penalty_line_formation_centered_symmetrically(self, monkeypatch): # Penalty support robots on the line behind the mark must be centered # symmetrically around y=0. - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = {} @@ -1623,7 +1627,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri def test_prepare_penalty_theirs_clears_extra_defender_from_own_defense_area(self, monkeypatch): # PreparePenaltyTheirsStep must clear any outfield defender beyond the keeper # out of own defense area (clear_own_defense_area=True). - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = {} @@ -1653,7 +1657,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri def test_prepare_penalty_ours_clears_teammate_from_opp_defense_area(self, monkeypatch): # PreparePenaltyOursStep must clear teammates from opponent defense area # (clear_opp_defense_area=True). - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = {} @@ -1690,7 +1694,7 @@ def test_point_inside_circle_near_boundary_is_projected_onto_circle(self): # inside the keep-out circle. _reachable_on_circle must not return the # unprojected inside-the-circle point; it must return a point at radius # distance from center that is inside the pitch boundaries. - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions game = _make_game(my_team_is_yellow=True, my_team_is_right=False) center = Vector2D(1.79, 2.75) # ball near top sideline (y = 3.0) @@ -1706,7 +1710,7 @@ def test_point_inside_circle_near_boundary_is_projected_onto_circle(self): class TestVariableFieldScaling: def test_prepare_kickoff_ours_scales_support_positions_with_field_bounds(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -1751,7 +1755,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri assert support_target.distance_to(Vector2D(0.0, 0.0)) >= 0.5 def test_prepare_kickoff_ours_uses_own_half_when_defending_left(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -1792,7 +1796,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri assert support_target.x < 0.0, "support robot must stay on own half (defending left)" def test_prepare_penalty_ours_scales_penalty_mark_with_field_bounds(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -1834,7 +1838,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri class TestPrepareKickoffTheirsStep: def test_all_robots_placed_on_own_half_right(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = {} @@ -1862,7 +1866,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri assert target.x > 0.0, f"Expected positive-x (own half right), got {target}" def test_all_robots_placed_on_own_half_left(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = {} @@ -1892,7 +1896,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri assert target.x < 0.0, f"Expected negative-x (own half left), got {target}" def test_positions_outside_centre_circle(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -1916,7 +1920,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri assert dist >= 0.5, f"Target {target} inside centre circle" def test_scales_with_custom_field_bounds(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -1954,8 +1958,121 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri class TestDirectFreeOursStep: + @staticmethod + def _at_the_ball(friendly_robots, enemy_robots=None): + """Attacking -x, ball at (1, 0), robot 0 on it from behind.""" + frame = GameFrame( + ts=0.0, + my_team_is_yellow=True, + my_team_is_right=True, + friendly_robots=friendly_robots, + enemy_robots=enemy_robots or {}, + ball=_ball(1.0, 0.0), + referee=_make_referee_data(command=RefereeCommand.DIRECT_FREE_YELLOW), + ) + game = Game( + past=GameHistory(10), + current=frame, + field=Field( + my_team_is_right=True, + field_dims=STANDARD_FIELD_DIMS, + field_bounds=STANDARD_FIELD_DIMS.full_field_bounds, + ), + ) + from utama_core.referee import actions as referee_actions + + node = referee_actions.DirectFreeOursStep() + node.blackboard = _make_blackboard(game, _make_cmd_map(game)) + return node + + @staticmethod + def _taker(orientation=math.pi, has_ball=True): + return dataclasses.replace(_robot(0, 1.1, 0.0), orientation=orientation, has_ball=has_ball) + + def test_the_taker_kicks_at_the_goal_with_no_teammate_open(self): + node = self._at_the_ball({0: self._taker()}) + node.update() + assert node.blackboard.cmd_map[0].kick == 1 + + def test_the_taker_kicks_only_with_the_ball_on_the_kicker(self): + node = self._at_the_ball({0: self._taker(has_ball=False)}) + node.update() + assert node.blackboard.cmd_map[0].kick == 0 + + def test_the_taker_waits_for_the_teammate_to_face_the_ball_and_it_turns(self, monkeypatch): + from utama_core.entities.data.command import RobotCommand + from utama_core.referee import actions as referee_actions + + turning = RobotCommand(local_forward_vel=0, local_left_vel=0, angular_vel=2.0, kick=0, chip=0, dribble=0) + monkeypatch.setattr(referee_actions, "turn_on_spot", lambda *a, **k: turning) + away = dataclasses.replace(_robot(1, -1.0, 0.0), orientation=math.pi) + node = self._at_the_ball({0: self._taker(), 1: away}) + node.update() + assert node.blackboard.cmd_map[0].kick == 0 + assert node.blackboard.cmd_map[1] is turning + + @pytest.mark.parametrize("from_ball, turns", [(0.799, True), (0.751, True), (0.749, False)]) + def test_a_receiver_on_the_keep_out_edge_turns_instead_of_being_cleared(self, monkeypatch, from_ball, turns): + from utama_core.referee import actions as referee_actions + + turning = object() + cleared = object() + monkeypatch.setattr(referee_actions, "turn_on_spot", lambda *a, **k: turning) + monkeypatch.setattr(referee_actions, "move", lambda *a, **k: cleared) + away = dataclasses.replace(_robot(1, 1.0 - from_ball, 0.0), orientation=math.pi) + node = self._at_the_ball({0: self._taker(), 1: away}) + node.update() + assert node.blackboard.cmd_map[1] is (turning if turns else cleared) + + def test_the_taker_kicks_once_the_teammate_faces_the_ball(self): + facing = dataclasses.replace(_robot(1, -1.0, 0.0), orientation=0.17 - 0.01) + node = self._at_the_ball({0: self._taker(), 1: facing}) + node.update() + assert node.blackboard.cmd_map[0].kick == 1 + + def test_the_kick_target_is_kept_while_lanes_open_and_shut(self): + facing = dataclasses.replace(_robot(1, -1.0, 0.0), orientation=0.0) + node = self._at_the_ball({0: self._taker(), 1: facing}) + game = node.blackboard.game + assert node._kick_target(game, 0, Vector2D(1.0, 0.0))[0] == 1 + node._target = (0, Vector2D(1.0, 0.0), None, None, 0.25) + assert node._kick_target(game, 0, Vector2D(1.04, 0.0)) == (None, None, 0.25) + assert node._kick_target(game, 0, Vector2D(1.06, 0.0))[0] == 1 + + def test_with_nobody_in_range_the_nearest_teammate_comes_and_the_taker_waits(self, monkeypatch): + from utama_core.referee import actions as referee_actions + + monkeypatch.setattr(referee_actions, "move", lambda *a, **k: ("move", a[2], a[3])) + far = dataclasses.replace(_robot(1, -3.0, 2.5), orientation=0.0) + node = self._at_the_ball({0: self._taker(), 1: far}) + node.update() + receiver, spot, _ = node._kick_target(node.blackboard.game, 0, Vector2D(1.0, 0.0)) + assert receiver == 1 and abs(spot.distance_to(Vector2D(1.0, 0.0)) - 2.0) < 1e-6 + assert node.blackboard.cmd_map[1] == ("move", 1, spot) + assert node.blackboard.cmd_map[0].kick == 0 + + def test_the_kick_follows_the_chosen_teammate_where_it_stands_now(self): + ball = Vector2D(1.0, 0.0) + node = self._at_the_ball({0: self._taker(), 1: _robot(1, -1.0, 1.0)}) + node._target = (0, ball, 1, None, 0.25) + assert node._kick_target(node.blackboard.game, 0, ball)[2] == pytest.approx(ball.angle_to(Vector2D(-1.0, 1.0))) + + def test_the_kick_follows_a_called_teammate_only_once_it_has_arrived(self): + ball = Vector2D(1.0, 0.0) + for off_spot, expected in ((0.11, 0.25), (0.09, math.pi)): # arrived within 0.1 m + node = self._at_the_ball({0: self._taker(), 1: _robot(1, -1.0 + off_spot, 0.0)}) + node._target = (0, ball, 1, Vector2D(-1.0, 0.0), 0.25) + assert node._kick_target(node.blackboard.game, 0, ball)[2] == pytest.approx(expected) + + def test_the_taker_kicks_when_the_called_teammate_has_arrived(self): + arrived = dataclasses.replace(_robot(1, -1.0, 0.0), orientation=0.0) + node = self._at_the_ball({0: self._taker(), 1: arrived}) + node._target = (0, Vector2D(1.0, 0.0), 1, Vector2D(-1.0, 0.0), math.pi) + node.update() + assert node.blackboard.cmd_map[0].kick == 1 + def test_kicker_is_closest_robot_to_ball(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -2025,7 +2142,7 @@ def test_approach_point_stays_reachable_when_ball_is_near_opponent_box(self, mon enemy id=1 southeast of the ball so `_kick_target_enemy` picks the same kick direction traced live. """ - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -2079,7 +2196,7 @@ def test_kicker_goes_round_the_ball_to_an_approach_point_on_its_far_side(self, m kick placed 0.25 m inside the goal line back onto the line, where the first touch put it out: 90 of 478 free kicks, tournament_20260927_223257.""" from utama_core.config.physical_constants import BALL_RADIUS, ROBOT_RADIUS - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -2121,7 +2238,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri assert closest >= ROBOT_RADIUS + BALL_RADIUS + 0.05 # 5 cm between robot and ball (2026-10-27) def test_kicker_moves_toward_ball(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -2166,7 +2283,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri assert target.distance_to(ball_pos) < robot_start.distance_to(ball_pos) def test_non_kicker_robots_get_stop_command(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions monkeypatch.setattr(referee_actions, "move", lambda *a, **kw: ("move",)) @@ -2194,7 +2311,7 @@ def test_non_kicker_robots_get_stop_command(self, monkeypatch): assert cmd_map[2] != ("move", 2) def test_writes_command_for_every_robot(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions monkeypatch.setattr(referee_actions, "move", lambda *a, **kw: ("move",)) @@ -2223,7 +2340,7 @@ def test_kicker_choice_is_sticky_across_near_tied_distances(self, monkeypatch): reuse the same instance across ticks (it does — constructed once in `RefereeOverride.__init__`) and hold its choice via `Sticky`. """ - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured_kicker_ids = [] @@ -2260,7 +2377,7 @@ def test_kicker_reassigns_when_a_robot_is_clearly_closer(self, monkeypatch): """The sticky kicker choice must still yield to a genuinely closer robot — hysteresis should suppress noise-level flips, not freeze the assignment forever.""" - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured_kicker_ids = [] @@ -2292,7 +2409,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri assert captured_kicker_ids[-1] == 3 def test_direct_free_ours_clears_non_kicker_from_opponent_defense_area(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -2301,6 +2418,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri return ("move", robot_id) monkeypatch.setattr(referee_actions, "move", fake_move) + monkeypatch.setattr(referee_actions, "restart_support", lambda *a: None) # Robot 1 is kicker near ball at (1.0, 0.0); Robot 0 is inside opp defense area at (-4.3, 0.0) robots = {0: _robot(0, -4.3, 0.0), 1: _robot(1, 1.2, 0.0)} @@ -2335,7 +2453,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri assert r0_moves[0][1] == Vector2D(-3.25, 0.0) def test_direct_free_ours_clears_non_kicker_from_ball_keep_out(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -2344,6 +2462,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri return ("move", robot_id) monkeypatch.setattr(referee_actions, "move", fake_move) + monkeypatch.setattr(referee_actions, "restart_support", lambda *a: None) # Ball at (1.0, 0.0). Robot 1 is kicker at (1.1, 0.0). Robot 0 is non-kicker at (1.3, 0.0) inside 0.8m keep-out. robots = {0: _robot(0, 1.3, 0.0), 1: _robot(1, 1.1, 0.0)} @@ -2384,7 +2503,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri class TestDirectFreeTheirsStep: def test_robot_outside_keep_out_stays_put(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions monkeypatch.setattr(referee_actions, "move", lambda *a, **kw: ("move",)) @@ -2401,8 +2520,8 @@ def test_robot_outside_keep_out_stays_put(self, monkeypatch): assert cmd_map[0] is not None assert cmd_map[0] != ("move", 0) - def test_multiple_robots_only_encroaching_ones_move(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + def test_encroaching_robot_clears_and_the_nearest_other_takes_the_wall(self, monkeypatch): + from utama_core.referee import actions as referee_actions captured = [] @@ -2427,12 +2546,12 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri node.update() moved_ids = [rid for rid, _ in captured] - assert moved_ids == [0] + assert moved_ids == [0, 1] assert cmd_map[1] is not None assert cmd_map[2] is not None def test_encroaching_robot_projected_to_keep_out_boundary(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -2461,7 +2580,7 @@ def test_robot_one_centimetre_short_of_keep_out_boundary_is_commanded_to_boundar Before the fix, dx * dx + dy * dy < 1e-4 treated it as already at target and issued empty_command(False), leaving it stranded at 0.795 m inside the keep-out. """ - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -2488,7 +2607,7 @@ def test_robot_between_ball_and_opponent_box_clears_round_the_ball(self, monkeyp """A free kick 1 m in front of the opponent box (inner edge x = -3.5 here): straight out from the ball is (-3.3, 0), where the planner's box margin stopped the robot 0.48 m from the ball, a Defender Too Close foul.""" - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] monkeypatch.setattr( @@ -2511,7 +2630,7 @@ def test_robot_by_a_ball_in_the_corner_clears_round_the_ball_onto_the_pitch(self """Ball at (4.0, 2.5): straight out from it the robot's spot is off the pitch, and clamped back on (x <= 4.4) it was 0.48 m from the ball, so the robot never left (moment placement_in_corner_traps_defender).""" - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] monkeypatch.setattr( @@ -2531,7 +2650,7 @@ def test_robot_by_a_ball_in_the_corner_clears_round_the_ball_onto_the_pitch(self assert referee_actions._clamp_to_field(target, game) == target def test_all_robots_get_commands(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions monkeypatch.setattr(referee_actions, "move", lambda *a, **kw: ("move",)) @@ -2549,7 +2668,7 @@ def test_all_robots_get_commands(self, monkeypatch): assert v is not None def test_clear_to_legal_positions_touchline_clamping_preserves_keep_out(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = [] @@ -2581,7 +2700,7 @@ class TestDetourAroundCircle: """`detour_around_circle`: robots crossing the ball's keep-out circle go round it.""" def _detour(self, start, target): - from utama_core.global_utils.math_utils import detour_around_circle + from utama_core.geometry.math_utils import detour_around_circle return detour_around_circle(Vector2D(*start), Vector2D(*target), Vector2D(0.0, 0.0), 0.8) @@ -2614,8 +2733,8 @@ def test_robot_between_ball_and_spot_is_sent_clear_of_both(self, monkeypatch, st import dataclasses from utama_core.config.referee_constants import BALL_KEEP_OUT_DISTANCE - from utama_core.custom_referee import actions as referee_actions - from utama_core.global_utils.math_utils import distance_point_to_segment + from utama_core.geometry.math_utils import distance_point_to_segment + from utama_core.referee import actions as referee_actions captured = {} @@ -2650,7 +2769,7 @@ class TestClearingTargetsKeepOffRobots: START = (4.70, -0.68) def _stop_target(self, monkeypatch, keeper=KEEPER): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions captured = {} @@ -2687,7 +2806,7 @@ def fake_move(game, motion_controller, robot_id, target_coords, target_oren, dri return game, captured[1] def test_a_robot_cleared_from_the_ball_is_not_sent_onto_another_robot(self, monkeypatch): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions game, target = self._stop_target(monkeypatch) assert target.distance_to(Vector2D(*self.KEEPER)) >= referee_actions._ROBOT_SPACING_M @@ -2701,7 +2820,7 @@ def test_with_no_robot_near_it_keeps_its_nearest_spot(self, monkeypatch): @pytest.mark.parametrize("gap", [-0.001, 0.001]) def test_robot_spacing_boundary(self, gap): - from utama_core.custom_referee import actions as referee_actions + from utama_core.referee import actions as referee_actions game = _make_game(friendly_robots={0: _robot(0, 0.0, 0.0), 1: _robot(1, 3.0, 0.0)}) point = Vector2D(referee_actions._ROBOT_SPACING_M + gap, 0.0) diff --git a/utama_core/tests/custom_referee/test_stage_advance.py b/utama_core/tests/referee/test_stage_advance.py similarity index 96% rename from utama_core/tests/custom_referee/test_stage_advance.py rename to utama_core/tests/referee/test_stage_advance.py index b1448bd42..3c72dcd44 100644 --- a/utama_core/tests/custom_referee/test_stage_advance.py +++ b/utama_core/tests/referee/test_stage_advance.py @@ -4,12 +4,12 @@ half, and score-aware strategies (strategy.pickers.is_late_in_half) never saw one. """ -from utama_core.custom_referee.state_machine import GameStateMachine from utama_core.entities.data.vector import Vector2D, Vector3D from utama_core.entities.game import Ball, GameFrame, Robot from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.entities.referee.stage import Stage -from utama_core.tests.custom_referee.test_free_kick_timeout import _frame +from utama_core.referee.state_machine import GameStateMachine +from utama_core.tests.referee.test_free_kick_timeout import _frame def _machine() -> GameStateMachine: @@ -143,7 +143,7 @@ def test_the_second_half_starts_with_its_kick_off_and_ends_the_match(): def test_after_full_time_no_violation_restarts_play(): - from utama_core.custom_referee.rules.base_rule import RuleViolation + from utama_core.referee.rules.base_rule import RuleViolation sm = _machine() _playing(sm, 10.0) @@ -164,7 +164,7 @@ def test_after_full_time_no_violation_restarts_play(): def test_an_operator_profile_ends_no_half_itself(): - from utama_core.custom_referee.profiles.profile_loader import AutoAdvanceConfig + from utama_core.referee.profiles.profile_loader import AutoAdvanceConfig sm = GameStateMachine( half_duration_seconds=300.0, @@ -180,7 +180,7 @@ def test_an_operator_profile_ends_no_half_itself(): def test_late_in_half_means_the_last_minute_of_playing_time_not_of_sim_time(): - """strategy.pickers.is_late_in_half (score_aware_counter_flow, score_aware_zone_flow): with the + """strategy.pickers.is_late_in_half (chameleon, score_aware_zone_flow): with the clock counting sim time and stopping at 0, a 600 s round-robin match was "late" from 240 s of sim time to the end.""" from types import SimpleNamespace diff --git a/utama_core/tests/referee/wandering_strategy.py b/utama_core/tests/referee/wandering_strategy.py index 886b97da8..a76ae3abb 100644 --- a/utama_core/tests/referee/wandering_strategy.py +++ b/utama_core/tests/referee/wandering_strategy.py @@ -18,8 +18,8 @@ from utama_core.entities.data.command import RobotCommand from utama_core.entities.data.vector import Vector2D from utama_core.entities.game import Game -from utama_core.motion_planning.src.common.motion_controller import MotionController -from utama_core.skills.src.utils.move_utils import move +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.skills.utils.move_utils import move # Waypoints defined as fractions of the standard field half-dimensions # (half_length=4.5, half_width=3.0) so they scale correctly to any field. @@ -114,7 +114,7 @@ def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: ctx=ctx, ) - return AbstractStrategy(build_kernel_strategy=_build) + return AbstractStrategy(build=_build) __all__ = ["WanderingTactic", "wandering_strategy"] diff --git a/utama_core/tests/replay/test_convert_corpus.py b/utama_core/tests/replay/test_convert_corpus.py index d8bc84071..54686a2bf 100644 --- a/utama_core/tests/replay/test_convert_corpus.py +++ b/utama_core/tests/replay/test_convert_corpus.py @@ -1,10 +1,10 @@ -"""`tools/convert_ssl_log.py`'s per-log corpus job: what it downloads, converts and keeps.""" +"""`tools/realism/convert_ssl_log.py`'s per-log corpus job: what it downloads, converts and keeps.""" from __future__ import annotations import json -from tools import convert_ssl_log +from tools.realism import convert_ssl_log def _job(tmp_path, keep_raw): @@ -88,7 +88,7 @@ def test_limit_memory_turns_an_oversized_allocation_into_memory_error(): import sys code = ( - "from tools.convert_ssl_log import limit_memory\n" + "from tools.realism.convert_ssl_log import limit_memory\n" "limit_memory(1.5)\n" "try:\n" " bytearray(2 * 2**30)\n" diff --git a/utama_core/tests/replay/test_fingerprint.py b/utama_core/tests/replay/test_fingerprint.py index a9f2f7e0c..cf3dee454 100644 --- a/utama_core/tests/replay/test_fingerprint.py +++ b/utama_core/tests/replay/test_fingerprint.py @@ -1,8 +1,7 @@ """`utama_core.replay.fingerprint`: which edits change which fingerprints. -Most tests build a small repo in `tmp_path` with the real layout (a `kernel_strategy.py` -registry, one module per strategy and a shared `pickers.py`, tactic modules, a planner the -runner imports, `tools/evaluation/match.py`), edit one file, and check exactly the +Most tests build a small repo in `tmp_path` with the real layout (one module per strategy and +a shared `pickers.py`, tactic modules, a planner the runner imports, `tools/evaluation/match.py`), edit one file, and check exactly the fingerprints that should move do. The rest run against this repo itself.""" from __future__ import annotations @@ -13,22 +12,9 @@ import pytest from utama_core.replay import fingerprint as fp -from utama_core.replay.fingerprint import ( - KERNEL_STRATEGY, - REPO_ROOT, - ROUND_ROBIN_ENTRY, - CodeGraph, - config_names, - match_key, -) - -REGISTRY = '''\ -"""Factories.""" - -from utama_core.strategy.a import build_a_kernel_strategy -from utama_core.strategy.b import build_b_kernel_strategy -from utama_core.strategy.c import build_c_kernel_strategy -''' +from utama_core.replay import match_results +from utama_core.replay.fingerprint import MATCH_ENTRY, REPO_ROOT, CodeGraph +from utama_core.strategy import catalog PICKERS = """\ _MARGIN = 0.05 # used by the shared helper @@ -45,7 +31,7 @@ def _shared_helper(x): from utama_core.tactics.attack import AttackTactic -def build_a_kernel_strategy(ids): +def a(ids): return [AttackTactic(), _shared_helper(1)] """ @@ -65,7 +51,7 @@ def _b_picker(x): return _shared_helper(x) * _ONLY_B -def build_b_kernel_strategy(ids): +def b(ids): return [DefendTactic(), _b_picker(2)] """ @@ -76,14 +62,14 @@ def build_b_kernel_strategy(ids): from utama_core.tactics.unused import UnusedTactic -def build_c_kernel_strategy(ids): +def c(ids): # no helper, no tactic of its own return [len(ids)] """ FILES = { "tools/evaluation/__init__.py": "", - "tools/evaluation/match.py": "from utama_core.run.runner import run\nfrom utama_core.strategy import kernel_strategy\n", + "tools/evaluation/match.py": "from utama_core.run.runner import run\nfrom utama_core.strategy import catalog\n", "utama_core/__init__.py": '__version__ = "1.0.0"\n', "utama_core/run/__init__.py": "", "utama_core/run/runner.py": "from ..planning import planner\nfrom utama_core.profiles import loader\n\n\ndef run():\n" @@ -94,7 +80,7 @@ def build_c_kernel_strategy(ids): "utama_core/profiles/loader.py": "def load():\n return open('sim.yaml').read()\n", "utama_core/profiles/sim.yaml": "speed: 1\n", "utama_core/strategy/__init__.py": "", - "utama_core/strategy/kernel_strategy.py": REGISTRY, + "utama_core/strategy/catalog.py": "def names():\n return []\n", "utama_core/strategy/pickers.py": PICKERS, "utama_core/strategy/a.py": STRATEGY_A, "utama_core/strategy/b.py": STRATEGY_B, @@ -107,9 +93,9 @@ def build_c_kernel_strategy(ids): "utama_core/skills/aim.py": "def aim():\n return 0\n", "utama_core/tactics/defend.py": "class DefendTactic:\n pass\n", "utama_core/tactics/unused.py": 'class UnusedTactic:\n pass\n\n\nif __name__ == "__main__":\n print(1)\n', - "utama_core/rsoccer_simulator/src/Simulators/robosim/robosim_subprocess.py": "import json\n", + "utama_core/simulator/simulators/robosim/robosim_subprocess.py": "import json\n", } -CONFIGS = ["build_a_kernel_strategy", "build_b_kernel_strategy", "build_c_kernel_strategy"] +CONFIGS = ["a", "b", "c"] @pytest.fixture @@ -118,7 +104,7 @@ def repo(tmp_path: Path) -> Path: path = tmp_path / rel path.parent.mkdir(parents=True, exist_ok=True) path.write_text(text) - for pkg in ("utama_core/rsoccer_simulator", "utama_core/rsoccer_simulator/src"): + for pkg in ("utama_core/simulator", "utama_core/simulator"): (tmp_path / pkg / "__init__.py").write_text("") return tmp_path @@ -126,7 +112,7 @@ def repo(tmp_path: Path) -> Path: def _fingerprints(root: Path) -> dict[str, str]: g = CodeGraph(root) out = {c: g.strategy_fingerprint(c) for c in CONFIGS} - out["base"] = g.base_fingerprint([ROUND_ROBIN_ENTRY]) + out["base"] = g.base_fingerprint([MATCH_ENTRY]) return out @@ -140,53 +126,36 @@ def _changed_after(root: Path, rel: str, old: str, new: str) -> set[str]: return {k for k in before if before[k] != after[k]} -def _short(changed: set[str]) -> set[str]: - return {c.removeprefix("build_").removesuffix("_kernel_strategy") for c in changed} - - -KS = "utama_core/strategy/kernel_strategy.py" PICKERS_PY = "utama_core/strategy/pickers.py" A_PY, B_PY, C_PY = ("utama_core/strategy/a.py", "utama_core/strategy/b.py", "utama_core/strategy/c.py") def test_editing_one_strategy_changes_only_that_config(repo): - assert _short(_changed_after(repo, C_PY, "return [len(ids)]", "return [len(ids) + 1]")) == {"c"} - assert _short(_changed_after(repo, A_PY, "AttackTactic(), ", "AttackTactic(), 0, ")) == {"a"} + assert (_changed_after(repo, C_PY, "return [len(ids)]", "return [len(ids) + 1]")) == {"c"} + assert (_changed_after(repo, A_PY, "AttackTactic(), ", "AttackTactic(), 0, ")) == {"a"} def test_editing_a_constant_or_state_in_one_strategy_changes_only_that_config(repo): - assert _short(_changed_after(repo, B_PY, "_ONLY_B = 3", "_ONLY_B = 4")) == {"b"} - assert _short(_changed_after(repo, B_PY, "_streak = 0", "_streak = 5")) == {"b"} + assert (_changed_after(repo, B_PY, "_ONLY_B = 3", "_ONLY_B = 4")) == {"b"} + assert (_changed_after(repo, B_PY, "_streak = 0", "_streak = 5")) == {"b"} def test_editing_the_shared_pickers_changes_the_configs_that_import_them(repo): - assert _short(_changed_after(repo, PICKERS_PY, "return x + _MARGIN", "return x - _MARGIN")) == {"a", "b"} - assert _short(_changed_after(repo, PICKERS_PY, "_MARGIN = 0.05", "_MARGIN = 0.06")) == {"a", "b"} - - -def test_the_registry_is_not_part_of_any_strategy_fingerprint(repo): - assert _changed_after(repo, KS, '"""Factories."""', '"""Factories."""\n_EDITED = 1') == set() - - -def test_pointing_a_factory_at_another_module_changes_that_config(repo): - (repo / "utama_core/strategy/c2.py").write_text(STRATEGY_C) - changed = _changed_after( - repo, KS, "from utama_core.strategy.c import build_c", "from utama_core.strategy.c2 import build_c" - ) - assert _short(changed) == {"c"} + assert (_changed_after(repo, PICKERS_PY, "return x + _MARGIN", "return x - _MARGIN")) == {"a", "b"} + assert (_changed_after(repo, PICKERS_PY, "_MARGIN = 0.05", "_MARGIN = 0.06")) == {"a", "b"} def test_editing_a_tactic_changes_exactly_the_configs_that_import_it(repo): rel = "utama_core/tactics/attack.py" - assert _short(_changed_after(repo, rel, "return kick()", "return kick() + 1")) == {"a"} + assert (_changed_after(repo, rel, "return kick()", "return kick() + 1")) == {"a"} def test_a_function_level_import_is_followed(repo): - assert _short(_changed_after(repo, "utama_core/skills/aim.py", "return 0", "return 1")) == {"a"} + assert (_changed_after(repo, "utama_core/skills/aim.py", "return 0", "return 1")) == {"a"} def test_an_imported_tactic_counts_even_if_the_strategy_never_uses_it(repo): - assert _short(_changed_after(repo, "utama_core/tactics/unused.py", "pass", "x = 1")) == {"c"} + assert (_changed_after(repo, "utama_core/tactics/unused.py", "pass", "x = 1")) == {"c"} def test_a_tactic_no_strategy_imports_changes_nothing(repo): @@ -194,51 +163,82 @@ def test_a_tactic_no_strategy_imports_changes_nothing(repo): assert _changed_after(repo, "utama_core/tactics/orphan.py", "pass", "x = 1") == set() -def test_import_time_effects_move_a_module_into_the_base(repo): - # `unused` runs in every match (strategy c imports it, and kernel_strategy imports c): once - # its import-time code can reach outside it, it is part of what every match runs. - rel = "utama_core/tactics/unused.py" - assert _short( - _changed_after(repo, rel, "class UnusedTactic:", "import sys\nsys.path.append('x')\n\n\nclass UnusedTactic:") - ) == {"base", "c"} - assert "utama_core.tactics.unused" in CodeGraph(repo).ambient_modules() - assert _short(_changed_after(repo, rel, "pass", "y = 2")) == {"base", "c"} - - -def test_import_time_effects_in_a_strategy_module_move_it_into_the_base(repo): - changed = _changed_after(repo, A_PY, "\n\ndef build_a", "\nREGISTRY = {}\nREGISTRY.update(a=1)\n\n\ndef build_a") - assert _short(changed) == {"base", "a"} - assert "utama_core.strategy.a" in CodeGraph(repo).ambient_modules() - - -def test_a_main_guard_is_not_an_import_time_effect(repo): - assert CodeGraph(repo).ambient_modules() == {} +def _fixture( + g, + a, + b, + *, + duration=65.0, + sim_noise=None, + a_is_right=True, + a_kicks_off=True, +): + """The fixture id `match_results` gives a match of `a` (config_a) against `b`.""" + env = match_results.environment( + g, + duration_seconds=duration, + sim_noise=sim_noise, + ) + seed = sim_noise.get("seed") if sim_noise else None + return match_results.fixture_id( + env, + g.strategy_fingerprint(a)[:16], + g.strategy_fingerprint(b)[:16], + seed, + a_is_right=a_is_right, + a_kicks_off=a_kicks_off, + ) -def test_editing_shared_infrastructure_changes_the_base_and_every_match_key(repo): +def test_editing_shared_infrastructure_changes_the_base_and_every_fixture(repo): g = CodeGraph(repo) - keys = {(a, b): match_key(g, a, b, duration_seconds=65.0) for a in CONFIGS for b in CONFIGS if a < b} + fixtures = {(a, b): _fixture(g, a, b) for a in CONFIGS for b in CONFIGS if a < b} changed = _changed_after(repo, "utama_core/planning/planner.py", "return 1", "return 2") assert changed == {"base"} g = CodeGraph(repo) - assert all(match_key(g, a, b, duration_seconds=65.0) != k for (a, b), k in keys.items()) + assert all(_fixture(g, a, b) != k for (a, b), k in fixtures.items()) + +def _runner_also_imports(repo: Path, module: str) -> None: + path = repo / "utama_core/run/runner.py" + path.write_text(f"import {module}\n" + path.read_text()) -def test_shared_code_importing_kernel_strategy_puts_every_strategy_module_in_the_base(repo): - rel = "utama_core/planning/planner.py" + +def _add(repo: Path, rel: str, text: str) -> None: path = repo / rel - path.write_text("from utama_core.strategy.kernel_strategy import _shared_helper\n\n\n" + path.read_text()) - assert _changed_after(repo, B_PY, "_ONLY_B = 3", "_ONLY_B = 4") == {"base", "build_b_kernel_strategy"} - assert _changed_after(repo, PICKERS_PY, "_MARGIN = 0.05", "_MARGIN = 0.06") == { - "base", - "build_a_kernel_strategy", - "build_b_kernel_strategy", - } - assert _changed_after(repo, KS, '"""Factories."""', '"""Factories."""\n_EDITED = 1') == {"base"} + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(text) + + +def test_import_time_effects_stay_with_the_strategy_that_imports_them(repo): + # Only the two strategies playing are imported, so nothing else can see them. + rel = "utama_core/tactics/unused.py" + assert _changed_after( + repo, rel, "class UnusedTactic:", "import sys\nsys.path.append('x')\n\n\nclass UnusedTactic:" + ) == {"c"} + + +def test_code_behind_the_process_boundary_is_the_players_even_if_the_runner_imports_it(repo): + # A skills edit must not replay matches between two `.strategy` files, which carry their own. + _runner_also_imports(repo, "utama_core.skills.aim") + assert _changed_after(repo, "utama_core/skills/aim.py", "return 0", "return 1") == {"a"} + + +def test_what_the_match_process_runs_itself_stays_in_the_base(repo): + _add(repo, "utama_core/engine/__init__.py", "") + _add(repo, "utama_core/engine/match_log.py", "LIMIT = 1\n") + _runner_also_imports(repo, "utama_core.engine.match_log") + assert _changed_after(repo, "utama_core/engine/match_log.py", "LIMIT = 1", "LIMIT = 2") == {"base"} + + +def test_a_compiled_planner_counts_for_the_players_that_load_it_and_not_the_base(repo): + _add(repo, "utama_core/skills/_planner.so", "version 1") + _runner_also_imports(repo, "utama_core.skills.aim") + assert _changed_after(repo, "utama_core/skills/_planner.so", "version 1", "version 2") == {"a"} def test_the_rsim_subprocess_script_and_data_files_are_in_the_base(repo): - rel = "utama_core/rsoccer_simulator/src/Simulators/robosim/robosim_subprocess.py" + rel = "utama_core/simulator/simulators/robosim/robosim_subprocess.py" assert _changed_after(repo, rel, "import json", "import json, struct") == {"base"} assert _changed_after(repo, "utama_core/profiles/sim.yaml", "speed: 1", "speed: 2") == {"base"} @@ -267,37 +267,31 @@ def test_a_relative_import_resolves(repo): assert "utama_core.planning.planner" in g.closure(["utama_core.run.runner"]) -def test_match_key_covers_every_setting(repo): +def test_the_fixture_covers_every_setting(repo): g = CodeGraph(repo) a, b = CONFIGS[:2] - ref = match_key(g, a, b, duration_seconds=65.0) + ref = _fixture(g, a, b) variants = [ - match_key(g, b, a, duration_seconds=65.0), - match_key(g, a, b, duration_seconds=20.0), - match_key(g, a, b, duration_seconds=65.0, a_is_right=False), - match_key(g, a, b, duration_seconds=65.0, a_kicks_off=False), - match_key(g, a, b, duration_seconds=65.0, control_scheme="dwa"), - match_key(g, a, b, duration_seconds=65.0, fuzz_seed=1), - match_key(g, a, b, duration_seconds=65.0, recorded=False), - match_key(g, a, b, duration_seconds=65.0, sim_noise={"seed": 1}), - match_key(g, a, b, duration_seconds=65.0, sim_noise={"seed": 2}), + _fixture(g, b, a), + _fixture(g, a, b, duration=20.0), + _fixture(g, a, b, a_is_right=False), + _fixture(g, a, b, a_kicks_off=False), + _fixture(g, a, b, sim_noise={"seed": 1}), + _fixture(g, a, b, sim_noise={"seed": 2}), ] assert len({ref, *variants}) == 1 + len(variants) - # the fuzz interval only matters when fuzzing is on - assert match_key(g, a, b, duration_seconds=65.0, fuzz_interval_s=(1.0, 2.0)) == ref - assert match_key(g, a, b, duration_seconds=65.0, fuzz_seed=1, fuzz_interval_s=(1.0, 2.0)) != variants[5] - # matches without sim noise keep the keys they had before the setting existed - assert match_key(g, a, b, duration_seconds=65.0, sim_noise=None) == ref + # the noise seed is per match, the rest of the noise per environment + assert _fixture(g, a, b, sim_noise={"seed": 1, "kick_speed_sd": 0.2}) != variants[4] def test_numerics_env_vars_change_the_base(repo, monkeypatch): monkeypatch.delenv("UTAMA_EXACT_MATH", raising=False) - before = CodeGraph(repo).base_fingerprint([ROUND_ROBIN_ENTRY]) + before = CodeGraph(repo).base_fingerprint([MATCH_ENTRY]) monkeypatch.setenv("UTAMA_EXACT_MATH", "1") - assert CodeGraph(repo).base_fingerprint([ROUND_ROBIN_ENTRY]) != before - with_exact = CodeGraph(repo).base_fingerprint([ROUND_ROBIN_ENTRY]) + assert CodeGraph(repo).base_fingerprint([MATCH_ENTRY]) != before + with_exact = CodeGraph(repo).base_fingerprint([MATCH_ENTRY]) monkeypatch.setenv("UNRELATED_VAR", "1") - assert CodeGraph(repo).base_fingerprint([ROUND_ROBIN_ENTRY]) == with_exact + assert CodeGraph(repo).base_fingerprint([MATCH_ENTRY]) == with_exact # --- this repo ---------------------------------------------------------------------------- @@ -308,71 +302,88 @@ def graph() -> CodeGraph: return CodeGraph(REPO_ROOT) -def test_configs_found_from_source_match_the_round_robin(graph): - from tools.evaluation import match +def _players() -> list[str]: + return catalog.names() + + +def test_editing_one_real_strategy_does_not_change_another_configs_fingerprint(graph): + """The point of one module per strategy: a strategy's fingerprint reaches its own module and + the shared pickers, never a sibling strategy's module.""" + modules = {c: f"utama_core.strategy.{c}" for c in _players()} + for config, module in modules.items(): + assert graph.strategy_modules(config) & set(modules.values()) == {module}, config + assert graph.strategy_fingerprint("weaver") != graph.strategy_fingerprint("riptide") - assert config_names(graph) == sorted(match._CONFIG_NAMES) +def test_every_tactic_a_strategy_builds_is_in_its_closure(graph): + """Independent of the static analysis: build every `Strategy` and check the module of each + tactic object it holds is in that player's fingerprinted modules.""" + for config in _players(): + strategy = catalog.builder(config, (1, 2, 3, 4, 5))(None) + modules = {type(t).__module__ for t in strategy._tactics.values()} + assert modules <= graph.strategy_modules(config), (config, modules - graph.strategy_modules(config)) -def test_every_factory_defined_in_the_strategy_package_is_re_exported(graph): - """A factory nobody re-exports from `kernel_strategy` is never discovered, so it would silently - never play.""" - import ast - defined = set() - for path in (REPO_ROOT / "utama_core" / "strategy").glob("*.py"): - for stmt in ast.parse(path.read_text()).body: - if ( - isinstance(stmt, ast.FunctionDef) - and stmt.name.startswith("build_") - and stmt.name.endswith("_kernel_strategy") - ): - defined.add(stmt.name) - assert defined == set(graph.factory_modules) +# Imported by the runner only to reset their per-match state, so a strategy that doesn't import +# them isn't affected by them, and the one that does has them in its own closure. +_RUNNER_ONLY_RESETS = { + "utama_core.geometry.pass_and_score_geometry", + "utama_core.skills.shielding", + "utama_core.strategy.pickers", +} -def test_every_factory_is_defined_in_its_own_module_named_after_it(graph): - for config, module in graph.factory_modules.items(): - short = config.removeprefix("build_").removesuffix("_kernel_strategy") - assert module == f"utama_core.strategy.{short}", (config, module) +def test_all_code_taken_out_of_the_base_is_in_every_players_fingerprint(graph): + """Otherwise an edit there would change a match and no fingerprint at all.""" + roots = [MATCH_ENTRY, *fp.SUBPROCESS_SCRIPTS] + resets = graph.closure(_RUNNER_ONLY_RESETS) + taken_out = graph.closure(roots) - graph.base_modules([MATCH_ENTRY]) - resets + for config in _players(): + assert taken_out <= graph.strategy_modules(config), (config, taken_out - graph.strategy_modules(config)) + + +# Every place the match process calls into `PLAYER_SIDE`. A new one fails this test: is it behind +# the boundary (then a `.strategy` file must do it in its own process), or `RUNNER_SIDE`? +_RUNNER_REACHES_INTO_PLAYER_SIDE = { + "tools.evaluation.match": {"utama_core.strategy"}, # the catalog's names + "utama_core.run.sim_setup": {"utama_core.engine", "utama_core.strategy"}, # builds the code-named ones (load_side) + "utama_core.bundle.strategy_file": {"utama_core.engine"}, + "utama_core.run.side_runtime": {"utama_core.engine", "utama_core.motion_planning"}, + "utama_core.run.strategy_runner": { + "utama_core.engine", + "utama_core.motion_planning", # builds a controller; a file's process builds its own + "utama_core.geometry.pass_and_score_geometry", # reset + "utama_core.skills", # reset + "utama_core.strategy", # reset + }, + "utama_core.team_controller.controllers.real.real_robot_controller": {"utama_core.skills"}, # real only + "utama_core.tests.common.abstract_test_manager": {"utama_core.engine"}, # a type +} -def test_editing_one_real_strategy_does_not_change_another_configs_fingerprint(graph): - """The point of one module per strategy: a strategy's fingerprint reaches its own module and - the shared pickers, never a sibling strategy's module.""" - modules = {c: graph.strategy_modules(c) for c in config_names(graph)} - strategy_modules = {m for c in modules for m in (graph.factory_module(c),)} - for config, reached in modules.items(): - assert reached & strategy_modules == {graph.factory_module(config)}, config - for pair_a, pair_b in [("tiki_taka", "counter_press"), ("clear_danger", "overload_flow")]: - a, b = (f"build_{n}_kernel_strategy" for n in (pair_a, pair_b)) - assert graph.strategy_fingerprint(a) != graph.strategy_fingerprint(b) - assert graph.factory_module(a) not in graph.strategy_modules(b) - - -def test_every_tactic_a_factory_builds_is_in_its_closure(graph): - """Independent of the static analysis: build every config's `Strategy` and check the - module of each tactic object it holds is in that config's fingerprinted modules.""" - from utama_core.strategy import kernel_strategy - - for config in config_names(graph): - strategy = getattr(kernel_strategy, config)((1, 2, 3, 4, 5))(None) - modules = {type(t).__module__ for t in strategy._tactics.values()} - allowed = graph.strategy_modules(config) | graph.base_modules([ROUND_ROBIN_ENTRY]) - assert modules <= allowed, (config, modules - allowed) +def test_the_match_process_reaches_into_player_side_code_only_where_listed(graph): + found: dict[str, set[str]] = {} + for module in graph.base_modules([MATCH_ENTRY]): + if module in fp.RUNNER_SIDE: + continue + for target in graph.imports(module): + package = next((p for p in fp.PLAYER_SIDE if target == p or target.startswith(p + ".")), None) + if package is not None and target not in fp.RUNNER_SIDE: + found.setdefault(module, set()).add(package) + assert found == _RUNNER_REACHES_INTO_PLAYER_SIDE -def test_the_tactics_kernel_strategy_imports_are_outside_the_base(graph): - """Otherwise a tactic edit would rerun every match: the per-config split is the point.""" - base = graph.base_modules([ROUND_ROBIN_ENTRY]) +def test_the_tactics_are_outside_the_base(graph): + """Otherwise a tactic edit would rerun every match: the per-player split is the point.""" + base = graph.base_modules([MATCH_ENTRY]) for name in ("give_and_go", "press_and_contain", "shadow_and_mark", "switch_of_play", "defense"): assert f"utama_core.tactics.{name}" not in base def test_the_base_holds_the_sim_script_and_referee_profiles(graph): - base = graph.base_modules([ROUND_ROBIN_ENTRY]) + base = graph.base_modules([MATCH_ENTRY]) assert set(fp.SUBPROCESS_SCRIPTS) <= base - assert any("custom_referee/profiles/simulation.yaml" in row for row in graph.data_files(base)) + assert any("referee/profiles/simulation.yaml" in row for row in graph.data_files(base)) # Every place the code a match runs reaches outside the import graph, and how each is @@ -382,51 +393,58 @@ def test_the_base_holds_the_sim_script_and_referee_profiles(graph): # the environment into the sim subprocess -> ENV_PREFIXES covers the numerics ones. # opens files: profile_loader reads profiles/*.yaml -> data_files. The rest write a # match's outputs (match log, stats, replays, a camera run's game log) or read old ones for -# analysis, never during play. robot_profile reads config/robots/*.json only when an +# analysis, never during play; catalog reads strategy sources to list the names; archive reads +# a .strategy file, which is the fingerprint's own input. robot_profile reads config/robots/*.json only when an # example asks for a real robot's profile (`load_profile`), and profiles act on real robots # only, so no match result depends on them. # subprocess: robosim_wrapper starts robosim_subprocess.py in the robosim pixi env -> # SUBPROCESS_SCRIPTS, and environment_pin's robosim env listing and binary hashes. # game_log_writer asks git for the commit it records, only for a camera run's game log # (never in rsim), so no match result depends on it. -# getattr on a module by computed name: tools.evaluation.match looks a factory up by name -> -# the config names are the fingerprint's own inputs. +# dynamic import: catalog.builder imports the strategy module of a name -> that module is the +# fingerprint's own input. # module-level state: code in the closure, so already hashed; its values must not carry # from one match to the next in a worker, which the cache's replay spot-check verifies. # possession/shield state: reset in StrategyRunner.__init__; the planner's _PERP_ROTATIONS: a memo of # pure values; robosim_wrapper's idle sims: a fresh native world per start. AUDIT = { "environment": [ + "utama_core.bundle.archive", + "utama_core.bundle.strategy_file", "utama_core.config.settings", - "utama_core.rsoccer_simulator.src.Simulators.robosim.robosim_wrapper", + "utama_core.simulator.simulators.robosim.robosim_wrapper", ], - "getattr on a module by computed name": ["tools.evaluation.match"], + "dynamic import": ["utama_core.strategy.catalog"], "module-level state": [ - "utama_core.motion_planning.src.fastpathplanning.planner", - "utama_core.rsoccer_simulator.src.Simulators.robosim.robosim_wrapper", - "utama_core.shared.pass_and_score_geometry", - "utama_core.skills.src.shielding", + "utama_core.geometry.pass_and_score_geometry", + "utama_core.motion_planning.fastpathplanning.planner", + "utama_core.simulator.simulators.robosim.robosim_wrapper", + "utama_core.skills.shielding", "utama_core.strategy.pickers", ], "opens files": [ - "utama_core.custom_referee.profiles.profile_loader", + "utama_core.bundle.archive", + "utama_core.bundle.strategy_file", "utama_core.engine.match_log", "utama_core.engine.match_stats", + "utama_core.referee.profiles.profile_loader", "utama_core.replay.columnar_reader", "utama_core.replay.columnar_writer", "utama_core.replay.game_log_writer", "utama_core.replay.replay_writer", - "utama_core.team_controller.src.controllers.common.robot_profile", + "utama_core.strategy.catalog", + "utama_core.team_controller.controllers.common.robot_profile", ], "subprocess": [ + "utama_core.bundle.strategy_file", "utama_core.replay.game_log_writer", - "utama_core.rsoccer_simulator.src.Simulators.robosim.robosim_wrapper", + "utama_core.simulator.simulators.robosim.robosim_wrapper", ], } def test_every_reach_outside_the_import_graph_is_accounted_for(graph): - everything = graph.base_modules([ROUND_ROBIN_ENTRY]) | graph.closure([KERNEL_STRATEGY]) + everything = graph.base_modules([MATCH_ENTRY]) | {m for c in _players() for m in graph.strategy_modules(c)} assert graph.audit(everything) == AUDIT diff --git a/utama_core/tests/replay/test_match_cache.py b/utama_core/tests/replay/test_match_cache.py deleted file mode 100644 index 14a5b01df..000000000 --- a/utama_core/tests/replay/test_match_cache.py +++ /dev/null @@ -1,70 +0,0 @@ -from utama_core.replay.match_cache import MatchCache, differences, spot_check_sample - -_RECORD = { - "result": {"config_a": "a", "config_b": "b", "score_a": 1, "score_b": 0, "stats": {"shots": (3, 1)}}, - "restarts": [{"match": "a_vs_b", "kind": "kickoff"}], - "losses": {"match": "a_vs_b", "turnovers": []}, -} - - -def test_a_stored_record_reads_back_and_matches_the_one_written(tmp_path): - cache = MatchCache(tmp_path) - cache.put("ab12", _RECORD) - - assert differences(cache.get("ab12"), _RECORD) == [] - - -def test_an_unknown_or_evicted_key_has_no_record(tmp_path): - cache = MatchCache(tmp_path) - assert cache.get("ab12") is None - cache.put("ab12", _RECORD) - cache.evict("ab12") - assert cache.get("ab12") is None - - -def test_a_corrupt_record_is_a_miss_not_an_error(tmp_path): - cache = MatchCache(tmp_path) - cache.path("ab12").parent.mkdir(parents=True) - cache.path("ab12").write_text("{not json") - assert cache.get("ab12") is None - - -def test_differences_names_each_part_that_disagrees(): - fresh = {**_RECORD, "result": {**_RECORD["result"], "score_a": 2}, "losses": {"turnovers": [1]}} - assert differences(_RECORD, fresh) == ["result", "losses"] - - -def test_spot_check_sample_takes_the_fraction_and_at_least_one(): - keys = [f"k{i}" for i in range(200)] - assert len(spot_check_sample(keys, 0.05)) == 10 - assert len(spot_check_sample(keys[:3], 0.05)) == 1 - assert spot_check_sample(keys, 0.0) == set() - assert spot_check_sample([], 0.05) == set() - - -def test_spot_check_sample_is_the_same_every_run_and_independent_of_order(): - keys = [f"k{i}" for i in range(50)] - assert spot_check_sample(keys, 0.1) == spot_check_sample(list(reversed(keys)), 0.1) - - -def test_two_processes_storing_the_same_match_use_different_temp_files(tmp_path, monkeypatch): - # Round-robins on different strategy branches share the cache. With one shared temp file, - # one process could rename away the other's half-written file and fail the other's rename. - import os - from pathlib import Path - - temps = [] - real_replace = Path.replace - - def _recording_replace(self, target): - temps.append(self.name) - return real_replace(self, target) - - monkeypatch.setattr(Path, "replace", _recording_replace) - cache = MatchCache(tmp_path) - for pid in (101, 202): - monkeypatch.setattr(os, "getpid", lambda pid=pid: pid) - cache.put("ab" * 32, {"result": {"score_a": 1}}) - assert len(set(temps)) == 2 - assert cache.get("ab" * 32) == {"result": {"score_a": 1}} - assert not list(tmp_path.rglob("*.tmp")) diff --git a/utama_core/tests/replay/test_match_results.py b/utama_core/tests/replay/test_match_results.py new file mode 100644 index 000000000..f5671b21d --- /dev/null +++ b/utama_core/tests/replay/test_match_results.py @@ -0,0 +1,151 @@ +"""`replay/match_results.py`: the one store of match results, its fixtures and its records.""" + +from __future__ import annotations + +import json + +from utama_core.replay import match_results as mr +from utama_core.replay.match_results import MatchResults + +_FROZEN_EVENT = { + "kind": "COMMITTED_FROZEN", + "sim_time": 12.5, + "tick": 1250, + "referee_command": "NORMAL_START", + "duration_s": 9.0, + "tactic_ids": ["t1"], + "robot_ids": [1, 2], + "diagnosis": "ball held by enemy 3", +} + + +class _Graph: + """Stands in for CodeGraph: the store asks a graph only for the base fingerprint.""" + + def __init__(self, base="base"): + self.base = base + + def base_fingerprint(self, entries): + return self.base + + +def _result(a="a", b="b", score_a=1, score_b=0, stats=None): + return {"config_a": a, "config_b": b, "score_a": score_a, "score_b": score_b, "stats": stats} + + +def _rec(env="e", a_fp="fa", b_fp="fb", seed=None, a="a", b="b", stats=None, **kw): + losses = {"match": "a_vs_b", "turnovers": []} + return mr.record( + env, a_fp, b_fp, _result(a, b, stats=stats), seed=seed, source="run", restarts=[], losses=losses, **kw + ) + + +def test_a_stored_record_reads_back_as_it_was_written(tmp_path): + store = MatchResults(tmp_path) + rec = _rec(stats={"shots": {"friendly": 3, "enemy": 1}, "stall_events": [], "possession_pct": (0.5, 0.5)}) + store.put(rec) + + assert store.get("e", rec["fixture"]) == rec + assert rec["shots_a"] == 3 and rec["shots_b"] == 1 + assert rec["losses"] == {"match": "a_vs_b", "turnovers": []} and rec["restarts"] == [] + + +def test_an_unknown_fixture_and_a_corrupt_file_are_misses_not_errors(tmp_path): + store = MatchResults(tmp_path) + assert store.get("e", "ab12") is None + store.path("e", "ab12").parent.mkdir(parents=True) + store.path("e", "ab12").write_text("{not json") + assert store.get("e", "ab12") is None + + +def test_a_fixture_depends_on_environment_players_order_sides_and_seed(): + f = mr.fixture_id + base = f("e", "1", "2", 1) + assert f("e", "1", "2", 2) != base # the noise seed + assert f("e", "9", "2", 1) != base # config_a's code + assert f("e", "2", "1", 1) != base # who is config_a + assert f("other", "1", "2", 1) != base # the environment + assert f("e", "1", "2", 1, a_is_right=False) != base + assert f("e", "1", "2", 1, a_kicks_off=False) != base + assert f("e", "1", "2", 1) == base + + +def test_the_environment_covers_every_setting_but_the_noise_seed(): + g = _Graph() + noise = {"seed": 1, "latency_s": [0.05, 0.1]} + base = mr.environment(g, duration_seconds=1200.0, sim_noise=noise) + assert mr.environment(g, duration_seconds=1200.0, sim_noise={**noise, "seed": 2}) == base + assert mr.environment(g, duration_seconds=300.0, sim_noise=noise) != base + assert mr.environment(g, duration_seconds=1200.0, sim_noise=None) != base + # shared code edits move the environment + assert mr.environment(_Graph("edited"), duration_seconds=1200.0, sim_noise=noise) != base + + +def test_load_reads_only_the_environment_asked_for(tmp_path): + store = MatchResults(tmp_path) + mine = _rec(env="e", seed=1) + store.put(mine) + store.put(_rec(env="other", seed=1)) + + assert list(store.load("e")) == [mine["fixture"]] + assert store.load("nowhere") == {} + + +def test_load_names_a_player_by_its_fingerprint(tmp_path): + """A frozen file and the same code in the repo are one player, whichever played the match.""" + store = MatchResults(tmp_path) + store.put(_rec(a="pendulum", a_fp="1", b="other", b_fp="2")) + + loaded = store.load("e", fps={"frozen/pendulum@abc.strategy": "1"}) + (rec,) = loaded.values() + assert (rec["a"], rec["b"]) == ("frozen/pendulum@abc.strategy", "other") + + +def test_a_torn_file_is_skipped_and_the_rest_still_load(tmp_path): + store = MatchResults(tmp_path) + good = _rec(seed=1) + store.put(good) + (tmp_path / "e" / "torn.json").write_text('{"env": "e", "fixt') + + assert list(store.load("e")) == [good["fixture"]] + + +def test_stall_events_are_stored_compactly_with_their_diagnosis(): + rec = _rec(stats={"shots": {}, "stall_events": [_FROZEN_EVENT]}) + assert rec["stalls"] == [{"kind": "COMMITTED_FROZEN", "sim_time": 12.5, "diagnosis": "ball held by enemy 3"}] + + +def test_no_stall_events_is_an_empty_list_and_unknown_is_none(): + assert _rec(stats={"stall_events": []})["stalls"] == [] + assert _rec(stats=None)["stalls"] is None # no stats at all: unknown, not "no stalls" + assert _rec(stats={"shots": {}})["stalls"] is None # stats without the stall field: unknown + + +def test_stall_summary_drops_the_detail_a_record_does_not_need(): + rows = mr.stall_summary([{**_FROZEN_EVENT, "diagnosis": ""}]) + assert rows == [{"kind": "COMMITTED_FROZEN", "sim_time": 12.5}] + assert json.loads(json.dumps(rows)) == rows + + +def test_two_processes_storing_the_same_match_use_different_temp_files(tmp_path, monkeypatch): + # Round-robins on different strategy branches share the store. With one shared temp file, + # one process could rename away the other's half-written file and fail the other's rename. + import os + from pathlib import Path + + temps = [] + real_replace = Path.replace + + def _recording_replace(self, target): + temps.append(self.name) + return real_replace(self, target) + + monkeypatch.setattr(Path, "replace", _recording_replace) + store = MatchResults(tmp_path) + rec = _rec(seed=1) + for pid in (101, 202): + monkeypatch.setattr(os, "getpid", lambda pid=pid: pid) + store.put(rec) + assert len(set(temps)) == 2 + assert store.get("e", rec["fixture"]) == rec + assert not list(tmp_path.rglob("*.tmp")) diff --git a/utama_core/tests/replay/test_replay_trace_tool.py b/utama_core/tests/replay/test_replay_trace_tool.py index 21be14011..75bd1b738 100644 --- a/utama_core/tests/replay/test_replay_trace_tool.py +++ b/utama_core/tests/replay/test_replay_trace_tool.py @@ -8,7 +8,7 @@ from utama_core.entities.referee.referee_command import RefereeCommand as C -_TOOL = Path(__file__).resolve().parents[3] / "tools" / "replay_trace.py" +_TOOL = Path(__file__).resolve().parents[3] / "tools" / "debug" / "replay_trace.py" _spec = importlib.util.spec_from_file_location("replay_trace", _TOOL) replay_trace = importlib.util.module_from_spec(_spec) _spec.loader.exec_module(replay_trace) diff --git a/utama_core/tests/replay/test_repro_summary.py b/utama_core/tests/replay/test_repro_summary.py index 08d4d69ed..4bfe2bf42 100644 --- a/utama_core/tests/replay/test_repro_summary.py +++ b/utama_core/tests/replay/test_repro_summary.py @@ -1,4 +1,4 @@ -"""`tools/repro_from_replay.py --summary`: per-robot rows from match_log events, and their text.""" +"""`tools/debug/repro_from_replay.py --summary`: per-robot rows from match_log events, and their text.""" import importlib.util from pathlib import Path @@ -6,7 +6,7 @@ import pytest -_TOOL = Path(__file__).resolve().parents[3] / "tools" / "repro_from_replay.py" +_TOOL = Path(__file__).resolve().parents[3] / "tools" / "debug" / "repro_from_replay.py" _spec = importlib.util.spec_from_file_location("repro_from_replay", _TOOL) repro = importlib.util.module_from_spec(_spec) _spec.loader.exec_module(repro) @@ -79,7 +79,7 @@ def test_format_caps_the_lines_and_counts_the_rest(): def test_resolve_sim_noise_uses_the_replays_own_settings_by_default(): - from utama_core.rsoccer_simulator.src.Utils.sim_noise import SimNoise + from utama_core.simulator.utils.sim_noise import SimNoise settings = SimNoise(seed=2, latency_s=(0.03, 0.15), kick_speed_sd=0.45).to_dict() noise, line = repro.resolve_sim_noise(None, {"settings": settings, "draw": {}}) @@ -109,7 +109,7 @@ def test_the_replays_stored_settings_redraw_the_same_robots(): """The repro's draw is `SimNoise.draw` on the stored settings, so with the same robot counts and time step it is the match's own draw: latency ticks and kick offsets per robot, exactly.""" from utama_core.config.settings import TIMESTEP - from utama_core.rsoccer_simulator.src.Utils.sim_noise import SimNoise + from utama_core.simulator.utils.sim_noise import SimNoise noise = SimNoise(seed=2, latency_s=(0.03, 0.15), kick_speed_offset_sd=0.2, max_accel=(1.5, 3.5)) counts = {"team_blue": 6, "team_yellow": 6} diff --git a/utama_core/tests/replay/test_scenario.py b/utama_core/tests/replay/test_scenario.py index e74a194c0..d385570a2 100644 --- a/utama_core/tests/replay/test_scenario.py +++ b/utama_core/tests/replay/test_scenario.py @@ -1,7 +1,7 @@ """Tests for `utama_core.replay.scenario` (replay-to-repro reconstruction). See `utama_core/replay/scenario.py`'s module docstring for why this module -exists and `docs/STRATEGY_DEVELOPMENT.md`'s Observability section for how it +exists and `docs/strategy.md`'s Observability section for how it fits alongside `MatchLog`/`render_window`/the stall watchdog. """ @@ -18,8 +18,8 @@ from utama_core.entities.game import Game from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.replay.scenario import RobotState, Scenario, apply_scenario -from utama_core.strategy.kernel_strategy import build_default_kernel_strategy -from utama_core.team_controller.src.controllers import AbstractSimController +from utama_core.strategy.catalog import builder +from utama_core.team_controller.controllers import AbstractSimController from utama_core.tests.common.abstract_test_manager import ( AbstractTestManager, TestingStatus, @@ -29,7 +29,7 @@ def _idle_strategy() -> AbstractStrategy: - return AbstractStrategy(build_kernel_strategy=build_default_kernel_strategy(())) + return AbstractStrategy(build=builder("default", ())) class _ApplyScenarioTestManager(AbstractTestManager): @@ -370,7 +370,7 @@ def _replay_runner(frame): """What `apply_scenario` touches of a runner, with the referee `_build_runner` gives it.""" from types import SimpleNamespace - from utama_core.custom_referee import CustomReferee + from utama_core.referee import CustomReferee referee = CustomReferee.from_profile_name("simulation", n_robots_yellow=6, n_robots_blue=6) referee.seed_clock(frame.ts, RefereeCommand.PREPARE_KICKOFF_YELLOW) diff --git a/utama_core/tests/replay/test_ssl_log.py b/utama_core/tests/replay/test_ssl_log.py index d26873aa9..3d713e859 100644 --- a/utama_core/tests/replay/test_ssl_log.py +++ b/utama_core/tests/replay/test_ssl_log.py @@ -28,13 +28,11 @@ log_stem, read_records, ) -from utama_core.team_controller.src.generated_code.ssl_gc_referee_message_pb2 import ( - Referee, -) -from utama_core.team_controller.src.generated_code.ssl_vision_wrapper_pb2 import ( +from utama_core.team_controller.generated_code.ssl_gc_referee_message_pb2 import Referee +from utama_core.team_controller.generated_code.ssl_vision_wrapper_pb2 import ( SSL_WrapperPacket, ) -from utama_core.team_controller.src.generated_code.ssl_vision_wrapper_tracked_pb2 import ( +from utama_core.team_controller.generated_code.ssl_vision_wrapper_tracked_pb2 import ( TrackerWrapperPacket, ) diff --git a/utama_core/tests/replay/test_ssl_log_extras.py b/utama_core/tests/replay/test_ssl_log_extras.py index 284313bad..69bb95ce3 100644 --- a/utama_core/tests/replay/test_ssl_log_extras.py +++ b/utama_core/tests/replay/test_ssl_log_extras.py @@ -1,6 +1,6 @@ """Tests for the official-log converter's sidecars (`replay/ssl_log.py`): the tracker's kicks, visibility and angular velocity, raw camera detections, and adding them to a replay converted -before they existed (`tools/convert_ssl_log.py --backfill-extras`).""" +before they existed (`tools/realism/convert_ssl_log.py --backfill-extras`).""" from __future__ import annotations @@ -11,7 +11,7 @@ import numpy as np import pytest -from tools import convert_ssl_log +from tools.realism import convert_ssl_log from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.entities.referee.stage import Stage from utama_core.replay.ssl_log import ( @@ -24,16 +24,14 @@ _VisionRows, convert_log, ) -from utama_core.team_controller.src.generated_code.ssl_gc_referee_message_pb2 import ( - Referee, -) -from utama_core.team_controller.src.generated_code.ssl_vision_detection_tracked_pb2 import ( +from utama_core.team_controller.generated_code.ssl_gc_referee_message_pb2 import Referee +from utama_core.team_controller.generated_code.ssl_vision_detection_tracked_pb2 import ( KickedBall, ) -from utama_core.team_controller.src.generated_code.ssl_vision_wrapper_pb2 import ( +from utama_core.team_controller.generated_code.ssl_vision_wrapper_pb2 import ( SSL_WrapperPacket, ) -from utama_core.team_controller.src.generated_code.ssl_vision_wrapper_tracked_pb2 import ( +from utama_core.team_controller.generated_code.ssl_vision_wrapper_tracked_pb2 import ( TrackerWrapperPacket, ) diff --git a/utama_core/tests/rsoccer_simulator/test_real_kick.py b/utama_core/tests/rsoccer_simulator/test_real_kick.py deleted file mode 100644 index 573f99599..000000000 --- a/utama_core/tests/rsoccer_simulator/test_real_kick.py +++ /dev/null @@ -1,73 +0,0 @@ -"""rsim kicks a robot with a calibrated kicker (`RealKick`) at its measured ball speed, off its -heading by its bias, bent towards the side the ball sits on the dribbler, scattered by its spread; -a robot without one keeps the sim's kick.""" - -import math - -import numpy as np -import pytest - -from utama_core.config.physical_constants import ROBOT_RADIUS -from utama_core.config.robot_params import RSIM_PARAMS -from utama_core.rsoccer_simulator.src.ssl.envs.standard_ssl import SSLStandardEnv -from utama_core.rsoccer_simulator.src.Utils.real_kick import RealKick, RealKicks -from utama_core.team_controller.src.controllers.common.robot_profile import RobotProfile - -STILL = {"team_yellow": (np.zeros(5, np.float32),), "team_blue": ()} -KICK = {"team_yellow": (np.array([0, 0, 0, 1, 0], np.float32),), "team_blue": ()} - - -@pytest.fixture(scope="module") -def env(): - env = SSLStandardEnv(n_robots_yellow=1, n_robots_blue=0, render_mode=None) - env.reset() - return env - - -def kick(env, real: RealKick = None, ball_left=0.0): - """(direction in degrees anticlockwise of the robot's heading, top speed) of one kick.""" - env.real_kicks = RealKicks({("team_yellow", 0): real}) if real else None - env.teleport_robot(True, 0, 0.0, 0.0, 0.0) - env.teleport_ball(ROBOT_RADIUS + 0.025, ball_left) - env.step(KICK) - speeds = [] - for _ in range(10): - env.step(STILL) - speeds.append(math.hypot(env.frame.ball.v_x, env.frame.ball.v_y)) - b = env.frame.ball # the sim's y is ours mirrored - return math.degrees(math.atan2(-b.v_y, b.v_x)), max(speeds) - - -def test_the_ball_leaves_at_the_robots_measured_speed(env): - assert kick(env, RealKick(speed=2.19))[1] == pytest.approx(2.19, abs=0.03) - assert kick(env)[1] == pytest.approx(RSIM_PARAMS.KICK_SPD, abs=0.3) # no profile: the sim's - - -def test_bias_and_bend_turn_the_kick_anticlockwise_towards_the_balls_side(env): - assert kick(env, RealKick(bias_deg=20.0))[0] == pytest.approx(20.0, abs=1.5) - assert kick(env, RealKick(bend_deg_per_cm=5.0), ball_left=0.02)[0] == pytest.approx(10.0, abs=1.5) - assert kick(env, RealKick(bend_deg_per_cm=5.0), ball_left=-0.02)[0] == pytest.approx(-10.0, abs=1.5) - - -def test_spread_scatters_kicks_by_its_sd_the_same_way_for_a_seed(): - def angles(seed): - kicks = RealKicks({("team_yellow", 0): RealKick(spread_deg=9.0)}, seed=seed) - out = [] - for _ in range(400): - out.append(math.degrees(kicks.angle(("team_yellow", 0), True, 0.0))) - kicks.angle(("team_yellow", 0), False, 0.0) # the kick command ends - return out - - assert np.std(angles(0)) == pytest.approx(9.0, rel=0.15) - assert angles(0) == angles(0) and angles(0) != angles(1) - - -def test_a_kick_held_over_several_ticks_keeps_one_direction(): - kicks = RealKicks({("team_yellow", 0): RealKick(spread_deg=9.0)}) - first = kicks.angle(("team_yellow", 0), True, 0.0) - assert kicks.angle(("team_yellow", 0), True, 0.03) == first - - -def test_only_a_profile_that_measured_its_kick_has_one(): - assert RealKick.of(RobotProfile()) is None - assert RealKick.of(RobotProfile(kick_bias_deg=2.7, kick_speed=2.19)) == RealKick(2.19, 0.0, 2.7, 0.0) diff --git a/utama_core/tests/strategy_runner/strat_runner_test_utils.py b/utama_core/tests/run/strat_runner_test_utils.py similarity index 100% rename from utama_core/tests/strategy_runner/strat_runner_test_utils.py rename to utama_core/tests/run/strat_runner_test_utils.py diff --git a/utama_core/tests/strategy_runner/test_ball_placement_rsim.py b/utama_core/tests/run/test_ball_placement_rsim.py similarity index 98% rename from utama_core/tests/strategy_runner/test_ball_placement_rsim.py rename to utama_core/tests/run/test_ball_placement_rsim.py index ebfc36178..5d4ba222b 100644 --- a/utama_core/tests/strategy_runner/test_ball_placement_rsim.py +++ b/utama_core/tests/run/test_ball_placement_rsim.py @@ -27,7 +27,7 @@ Running ------- - pixi run pytest utama_core/tests/strategy_runner/test_ball_placement_rsim.py -v + pixi run pytest utama_core/tests/run/test_ball_placement_rsim.py -v Known gap --------- @@ -53,13 +53,13 @@ from utama_core.config.field_params import GREAT_EXHIBITION_FIELD_DIMS from utama_core.config.referee_constants import BALL_KEEP_OUT_DISTANCE -from utama_core.custom_referee import CustomReferee from utama_core.engine.abstract_strategy import AbstractStrategy from utama_core.entities.game import Game from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee import CustomReferee from utama_core.run.strategy_runner import StrategyRunner -from utama_core.strategy.kernel_strategy import build_default_kernel_strategy -from utama_core.team_controller.src.controllers import AbstractSimController +from utama_core.strategy.catalog import builder +from utama_core.team_controller.controllers import AbstractSimController from utama_core.tests.common.abstract_test_manager import ( AbstractTestManager, TestingStatus, @@ -100,7 +100,7 @@ def _make_runner(referee: CustomReferee) -> StrategyRunner: `AbstractStrategy`'s goalkeeper pinning is irrelevant to this test. """ return StrategyRunner( - strategy=AbstractStrategy(build_kernel_strategy=build_default_kernel_strategy((0, 1))), + strategy=AbstractStrategy(build=builder("default", (0, 1))), my_team_is_yellow=True, my_team_is_right=True, mode="rsim", diff --git a/utama_core/tests/strategy_runner/test_change_of_ends.py b/utama_core/tests/run/test_change_of_ends.py similarity index 89% rename from utama_core/tests/strategy_runner/test_change_of_ends.py rename to utama_core/tests/run/test_change_of_ends.py index 2c91e017d..78d5db2e2 100644 --- a/utama_core/tests/strategy_runner/test_change_of_ends.py +++ b/utama_core/tests/run/test_change_of_ends.py @@ -7,18 +7,18 @@ import dataclasses -from utama_core.custom_referee import CustomReferee -from utama_core.custom_referee.profiles.profile_loader import load_profile from utama_core.engine.abstract_strategy import AbstractStrategy from utama_core.entities.data.vector import Vector2D from utama_core.entities.game.field import FieldBounds from utama_core.entities.game.robot import Robot from utama_core.entities.referee.referee_command import RefereeCommand from utama_core.entities.referee.stage import Stage -from utama_core.global_utils.math_utils import in_field_bounds +from utama_core.geometry.math_utils import in_field_bounds +from utama_core.referee import CustomReferee +from utama_core.referee.profiles.profile_loader import load_profile from utama_core.run import StrategyRunner from utama_core.run.strategy_runner import _turned -from utama_core.strategy import kernel_strategy +from utama_core.strategy.catalog import builder N_OUTFIELD = 2 HALF_S = 3.0 @@ -27,12 +27,11 @@ def test_the_teams_play_the_second_half_from_the_other_end(headless): - build = kernel_strategy.build_tiki_taka_kernel_strategy profile = load_profile("simulation") profile = dataclasses.replace(profile, game=dataclasses.replace(profile.game, half_duration_seconds=HALF_S)) runner = StrategyRunner( - strategy=AbstractStrategy(build_kernel_strategy=build(tuple(range(1, N_OUTFIELD + 1)))), - opp_strategy=AbstractStrategy(build_kernel_strategy=build(tuple(range(1, N_OUTFIELD + 1)))), + strategy=AbstractStrategy(build=builder("weaver", tuple(range(1, N_OUTFIELD + 1)))), + opp_strategy=AbstractStrategy(build=builder("weaver", tuple(range(1, N_OUTFIELD + 1)))), my_team_is_yellow=True, my_team_is_right=True, mode="rsim", @@ -93,7 +92,7 @@ def _robot(x: float, y: float) -> Robot: def test_a_robot_turned_from_past_the_goal_line_stands_on_the_far_line(): - # A robot in the run-off at x=-4.594 (a real one, clear_danger vs decoy_and_overload) + # A robot in the run-off at x=-4.594 (a real one, firebreak vs decoy_and_overload) # turned to x=+4.594, and the sim refused the teleport: the match crashed at half-time. bounds = FieldBounds(top_left=(-4.5, 3.0), bottom_right=(4.5, -3.0)) turned = _turned(_robot(-4.594, 2.399), bounds) diff --git a/utama_core/tests/strategy_runner/test_close_releases.py b/utama_core/tests/run/test_close_releases.py similarity index 100% rename from utama_core/tests/strategy_runner/test_close_releases.py rename to utama_core/tests/run/test_close_releases.py diff --git a/utama_core/tests/strategy_runner/test_error_handling.py b/utama_core/tests/run/test_error_handling.py similarity index 100% rename from utama_core/tests/strategy_runner/test_error_handling.py rename to utama_core/tests/run/test_error_handling.py diff --git a/utama_core/tests/strategy_runner/test_exp_ball.py b/utama_core/tests/run/test_exp_ball.py similarity index 94% rename from utama_core/tests/strategy_runner/test_exp_ball.py rename to utama_core/tests/run/test_exp_ball.py index 21647dd1d..94eefb241 100644 --- a/utama_core/tests/strategy_runner/test_exp_ball.py +++ b/utama_core/tests/run/test_exp_ball.py @@ -15,13 +15,13 @@ from utama_core.entities.game import Game from utama_core.entities.game.field import FieldBounds from utama_core.run.strategy_runner import StrategyRunner -from utama_core.strategy.kernel_strategy import build_default_kernel_strategy -from utama_core.team_controller.src.controllers import AbstractSimController +from utama_core.strategy.catalog import builder +from utama_core.team_controller.controllers import AbstractSimController from utama_core.tests.common.abstract_test_manager import ( AbstractTestManager, TestingStatus, ) -from utama_core.tests.strategy_runner.strat_runner_test_utils import DummyStrategy +from utama_core.tests.run.strat_runner_test_utils import DummyStrategy os.environ["SDL_VIDEO_WINDOW_POS"] = "100,100" @@ -32,11 +32,11 @@ def _idle_with_ball_strategy() -> AbstractStrategy: - return AbstractStrategy(build_kernel_strategy=build_default_kernel_strategy(()), exp_ball=True) + return AbstractStrategy(build=builder("default", ()), exp_ball=True) def _idle_no_ball_strategy() -> AbstractStrategy: - return AbstractStrategy(build_kernel_strategy=build_default_kernel_strategy(()), exp_ball=False) + return AbstractStrategy(build=builder("default", ()), exp_ball=False) # --------------------------------------------------------------------------- diff --git a/utama_core/tests/strategy_runner/test_field_check.py b/utama_core/tests/run/test_field_check.py similarity index 99% rename from utama_core/tests/strategy_runner/test_field_check.py rename to utama_core/tests/run/test_field_check.py index 84a8059bc..a4a950ca4 100644 --- a/utama_core/tests/strategy_runner/test_field_check.py +++ b/utama_core/tests/run/test_field_check.py @@ -10,9 +10,9 @@ from utama_core.config.enums import Mode from utama_core.config.field_params import FieldBounds, FieldDimensions -from utama_core.custom_referee import CustomReferee from utama_core.entities.data.raw_vision import RawBallData, RawRobotData, RawVisionData from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee import CustomReferee from utama_core.run.field_check import ( CAMERA_SILENT_S, OUT_OF_BOUNDS_MARGIN_M, diff --git a/utama_core/tests/strategy_runner/test_field_fence.py b/utama_core/tests/run/test_field_fence.py similarity index 98% rename from utama_core/tests/strategy_runner/test_field_fence.py rename to utama_core/tests/run/test_field_fence.py index 58853c123..4aa28ff85 100644 --- a/utama_core/tests/strategy_runner/test_field_fence.py +++ b/utama_core/tests/run/test_field_fence.py @@ -23,7 +23,7 @@ inner_edges, ) from utama_core.run.strategy_runner import StrategyRunner -from utama_core.team_controller.src.controllers.common.robot_profile import RobotProfile +from utama_core.team_controller.controllers.common.robot_profile import RobotProfile LEFT_HALF = FieldBounds(top_left=(-2.0, 1.5), bottom_right=(0.0, -1.5)) @@ -141,7 +141,7 @@ def test_no_fence_in_rsim_or_when_the_cameras_see_the_whole_field(mode, bounds): assert _runner(mode, bounds)._fenced(inner, _robot_on_the_half_way_line) is inner -# The lab field's bottom half of its bottom-right quarter (examples/shooting_drill.py, KEEP_OUT). +# The lab field's bottom half of its bottom-right quarter (tools/field/shooting_drill.py, KEEP_OUT). ZONE = FieldBounds(top_left=(0.0, -0.5625), bottom_right=(1.5, -1.125)) diff --git a/utama_core/tests/strategy_runner/test_frame_once.py b/utama_core/tests/run/test_frame_once.py similarity index 100% rename from utama_core/tests/strategy_runner/test_frame_once.py rename to utama_core/tests/run/test_frame_once.py diff --git a/utama_core/tests/strategy_runner/test_frozen_field_watchdog.py b/utama_core/tests/run/test_frozen_field_watchdog.py similarity index 100% rename from utama_core/tests/strategy_runner/test_frozen_field_watchdog.py rename to utama_core/tests/run/test_frozen_field_watchdog.py diff --git a/utama_core/tests/strategy_runner/test_game_log_sides.py b/utama_core/tests/run/test_game_log_sides.py similarity index 100% rename from utama_core/tests/strategy_runner/test_game_log_sides.py rename to utama_core/tests/run/test_game_log_sides.py diff --git a/utama_core/tests/strategy_runner/test_goalkeeper_stability.py b/utama_core/tests/run/test_goalkeeper_stability.py similarity index 87% rename from utama_core/tests/strategy_runner/test_goalkeeper_stability.py rename to utama_core/tests/run/test_goalkeeper_stability.py index 4a946b76b..1381349f2 100644 --- a/utama_core/tests/strategy_runner/test_goalkeeper_stability.py +++ b/utama_core/tests/run/test_goalkeeper_stability.py @@ -22,19 +22,19 @@ import dataclasses -from utama_core.custom_referee import CustomReferee -from utama_core.custom_referee.profiles.profile_loader import load_profile from utama_core.engine.abstract_strategy import AbstractStrategy from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee import CustomReferee +from utama_core.referee.profiles.profile_loader import load_profile from utama_core.run import StrategyRunner -from utama_core.strategy import kernel_strategy +from utama_core.strategy.catalog import builder N_OUTFIELD = 5 OUTFIELD_ROBOT_IDS = tuple(range(1, N_OUTFIELD + 1)) # Same pairing that surfaced the bug live. -_BUILD_A = kernel_strategy.build_counter_flow_kernel_strategy -_BUILD_B = kernel_strategy.build_tiki_taka_kernel_strategy +_NAME_A = "riptide" +_NAME_B = "weaver" def test_goalkeeper_converges_on_static_target_without_oscillating(headless): @@ -42,8 +42,8 @@ def test_goalkeeper_converges_on_static_target_without_oscillating(headless): keeper's target is provably fixed) — the keeper must settle to a steady y-position, not oscillate around it. """ - strategy_a = AbstractStrategy(build_kernel_strategy=_BUILD_A(OUTFIELD_ROBOT_IDS)) - strategy_b = AbstractStrategy(build_kernel_strategy=_BUILD_B(OUTFIELD_ROBOT_IDS)) + strategy_a = AbstractStrategy(build=builder(_NAME_A, OUTFIELD_ROBOT_IDS)) + strategy_b = AbstractStrategy(build=builder(_NAME_B, OUTFIELD_ROBOT_IDS)) profile = load_profile("simulation") profile = dataclasses.replace( diff --git a/utama_core/tests/strategy_runner/test_grsim_sim_setup.py b/utama_core/tests/run/test_grsim_sim_setup.py similarity index 97% rename from utama_core/tests/strategy_runner/test_grsim_sim_setup.py rename to utama_core/tests/run/test_grsim_sim_setup.py index 575aa1d72..8d02f1e19 100644 --- a/utama_core/tests/strategy_runner/test_grsim_sim_setup.py +++ b/utama_core/tests/run/test_grsim_sim_setup.py @@ -2,12 +2,12 @@ from utama_core.config.formations import get_formations from utama_core.entities.game.field import FieldBounds -from utama_core.global_utils.mapping_utils import ( +from utama_core.entities.game.mapping_utils import ( map_friendly_enemy_to_colors, map_left_right_to_colors, ) from utama_core.run.strategy_runner import StrategyRunner -from utama_core.tests.strategy_runner.strat_runner_test_utils import DummyStrategy +from utama_core.tests.run.strat_runner_test_utils import DummyStrategy class _FakeGRSimController: diff --git a/utama_core/tests/strategy_runner/test_kick_bend_wiring.py b/utama_core/tests/run/test_kick_bend_wiring.py similarity index 63% rename from utama_core/tests/strategy_runner/test_kick_bend_wiring.py rename to utama_core/tests/run/test_kick_bend_wiring.py index 72fcb1d34..1eef2c3e0 100644 --- a/utama_core/tests/strategy_runner/test_kick_bend_wiring.py +++ b/utama_core/tests/run/test_kick_bend_wiring.py @@ -1,7 +1,7 @@ """`StrategyRunner` gives a team's motion controller its profiled robots' kick bends, in rad per metre off-centre (`RobotProfile.kick_bend_deg_per_cm`), and biases, in rad (`kick_bias_deg`), on -real robots and in rsim (which kicks them so, `real_kick.py`) but not grSim (which kicks along the -heading); their carry caps in every mode; and on real robots only its vision the tags' offsets.""" +real robots only: the sims (rsim and grSim) keep their own kick. Carry caps apply in every mode, +and real robots alone get the vision tags' offsets.""" import math from types import SimpleNamespace @@ -9,11 +9,11 @@ import pytest from utama_core.config.enums import Mode -from utama_core.motion_planning.src.controllers.fastpathplanning import ( +from utama_core.motion_planning.controllers.fastpathplanning import ( FastPathPlanningController, ) from utama_core.run.strategy_runner import StrategyRunner -from utama_core.team_controller.src.controllers.common.robot_profile import RobotProfile +from utama_core.team_controller.controllers.common.robot_profile import RobotProfile _PROFILES = {1: RobotProfile(kick_bend_deg_per_cm=4.7), 2: RobotProfile(), 3: RobotProfile(kick_bias_deg=2.3)} @@ -21,8 +21,8 @@ _BEND = {1: math.radians(4.7) * 100.0} -@pytest.mark.parametrize("mode, expected", [(Mode.REAL, _BEND), (Mode.RSIM, _BEND), (Mode.GRSIM, {})]) -def test_profiled_robots_get_their_kick_bend_except_in_grsim(mode, expected): +@pytest.mark.parametrize("mode, expected", [(Mode.REAL, _BEND), (Mode.RSIM, {}), (Mode.GRSIM, {})]) +def test_profiled_robots_get_their_kick_bend_on_real_robots_only(mode, expected): runner = SimpleNamespace(mode=mode, rsim_env=None) team = SimpleNamespace(motion_controller=FastPathPlanningController) @@ -34,8 +34,8 @@ def test_profiled_robots_get_their_kick_bend_except_in_grsim(mode, expected): _BIAS = {3: math.radians(2.3)} -@pytest.mark.parametrize("mode, expected", [(Mode.REAL, _BIAS), (Mode.RSIM, _BIAS), (Mode.GRSIM, {})]) -def test_profiled_robots_get_their_kick_bias_except_in_grsim(mode, expected): +@pytest.mark.parametrize("mode, expected", [(Mode.REAL, _BIAS), (Mode.RSIM, {}), (Mode.GRSIM, {})]) +def test_profiled_robots_get_their_kick_bias_on_real_robots_only(mode, expected): runner = SimpleNamespace(mode=mode, rsim_env=None) team = SimpleNamespace(motion_controller=FastPathPlanningController) @@ -61,16 +61,3 @@ def test_profiled_robots_get_their_own_carry_caps_and_the_team_cap_where_unset(m controller = StrategyRunner._motion_controller(runner, team, profiles) assert controller.robot_carry == {0: (0.7, controller.carry_turn), 1: (controller.carry_speed, 3.0)} - - -def test_rsim_kicks_the_profiled_robots_that_measured_their_kick_and_no_others(): - runner = SimpleNamespace( - yellow_robot_profiles={0: RobotProfile(kick_speed=2.19, kick_bias_deg=2.7), 1: RobotProfile()}, - blue_robot_profiles={0: RobotProfile(kick_spread_deg=9.1)}, - ) - kicks = StrategyRunner._real_kicks(runner, None) - assert set(kicks.kicks) == {("team_yellow", 0), ("team_blue", 0)} - assert kicks.kicks[("team_yellow", 0)].speed == 2.19 - - unprofiled = SimpleNamespace(yellow_robot_profiles={}, blue_robot_profiles={0: RobotProfile()}) - assert StrategyRunner._real_kicks(unprofiled, None) is None # the evaluation's matches keep the sim's kick diff --git a/utama_core/tests/strategy_runner/test_match_state_reset.py b/utama_core/tests/run/test_match_state_reset.py similarity index 74% rename from utama_core/tests/strategy_runner/test_match_state_reset.py rename to utama_core/tests/run/test_match_state_reset.py index 445400528..d09f5979b 100644 --- a/utama_core/tests/strategy_runner/test_match_state_reset.py +++ b/utama_core/tests/run/test_match_state_reset.py @@ -2,11 +2,11 @@ must not inherit the last match's per-robot hysteresis.""" from utama_core.engine.abstract_strategy import AbstractStrategy +from utama_core.geometry import pass_and_score_geometry from utama_core.run.strategy_runner import StrategyRunner -from utama_core.shared import pass_and_score_geometry -from utama_core.skills.src import shielding -from utama_core.strategy.kernel_strategy import build_default_kernel_strategy -from utama_core.tests.shared.test_pass_and_score_geometry import _visual_game +from utama_core.skills import shielding +from utama_core.strategy.catalog import builder +from utama_core.tests.geometry.test_pass_and_score_geometry import _visual_game from utama_core.tests.skills.test_shielding import _shielding @@ -15,7 +15,7 @@ def test_a_new_runner_starts_with_no_robot_holding_or_committed(): assert _shielding(shielding.COMMIT_RANGE - 0.005) is False # committed runner = StrategyRunner( - strategy=AbstractStrategy(build_kernel_strategy=build_default_kernel_strategy((1, 2, 3, 4, 5))), + strategy=AbstractStrategy(build=builder("default", (1, 2, 3, 4, 5))), my_team_is_yellow=True, my_team_is_right=True, mode="rsim", diff --git a/utama_core/tests/strategy_runner/test_referee_rsim.py b/utama_core/tests/run/test_referee_rsim.py similarity index 97% rename from utama_core/tests/strategy_runner/test_referee_rsim.py rename to utama_core/tests/run/test_referee_rsim.py index 8569bfd0b..b09723c48 100644 --- a/utama_core/tests/strategy_runner/test_referee_rsim.py +++ b/utama_core/tests/run/test_referee_rsim.py @@ -41,9 +41,7 @@ BALL_KEEP_OUT_DISTANCE, OPPONENT_DEFENSE_AREA_KEEP_DISTANCE, ) -from utama_core.custom_referee import CustomReferee -from utama_core.custom_referee.geometry import RefereeGeometry -from utama_core.custom_referee.rules.out_of_bounds_rule import OutOfBoundsRule +from utama_core.engine import ball_release from utama_core.engine.abstract_strategy import AbstractStrategy from utama_core.engine.context import TickContext from utama_core.engine.strategy import Strategy as KernelSchedulerStrategy @@ -51,12 +49,15 @@ from utama_core.entities.data.command import RobotCommand from utama_core.entities.game import Game from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.motion_planning.src.common.motion_controller import MotionController +from utama_core.motion_planning.common.motion_controller import MotionController +from utama_core.referee import CustomReferee +from utama_core.referee.geometry import RefereeGeometry +from utama_core.referee.rules.out_of_bounds_rule import OutOfBoundsRule from utama_core.run.strategy_runner import StrategyRunner -from utama_core.skills.src.go_to_ball import go_to_ball -from utama_core.skills.src.utils.move_utils import empty_command -from utama_core.strategy.kernel_strategy import build_default_kernel_strategy -from utama_core.team_controller.src.controllers import AbstractSimController +from utama_core.skills.go_to_ball import go_to_ball +from utama_core.skills.utils.move_utils import empty_command +from utama_core.strategy.catalog import builder +from utama_core.team_controller.controllers import AbstractSimController from utama_core.tests.common.abstract_test_manager import ( AbstractTestManager, TestingStatus, @@ -78,7 +79,7 @@ def _idle_strategy() -> AbstractStrategy: """Kernel strategy with an empty outfield pool — does nothing; the referee override layer (`Strategy.tick()`'s `RefereeOverride`) handles all motion during override commands regardless of the tactic roster.""" - return AbstractStrategy(build_kernel_strategy=build_default_kernel_strategy(()), exp_ball=True) + return AbstractStrategy(build=builder("default", ()), exp_ball=True) @dataclass @@ -125,7 +126,7 @@ def _build(motion_controller: MotionController) -> KernelSchedulerStrategy: ctx=ctx, ) - return AbstractStrategy(build_kernel_strategy=_build) + return AbstractStrategy(build=_build) # --------------------------------------------------------------------------- @@ -461,11 +462,12 @@ def eval_status(self, game: Game) -> TestingStatus: return TestingStatus.IN_PROGRESS -def test_no_progress_restart_separates_robots_before_force_start(headless): +def test_no_progress_restart_separates_robots_before_force_start(headless, monkeypatch): """The runner's sim shortcut forced FORCE_START on the STOP's first tick, with the ball teleported to where it already lay. Two robots locked on the ball never separated, so no_progress fired every 10 s for 230 s of tiki_taka_plus_vs_zone_fluid (tournament_20261005_115048). A queued FORCE_START waits for StopStep's clearing.""" + monkeypatch.setattr(ball_release, "HELD_STILL_S", float("inf")) # the robot must keep holding the ball referee = CustomReferee.from_profile_name("simulation") runner = StrategyRunner( strategy=_go_to_ball_strategy(robot_id=0), @@ -554,7 +556,7 @@ def __init__(self, referee: CustomReferee): self.after_halt: list[RefereeCommand] = [] def reset_field(self, sim_controller: AbstractSimController, game: Game): - from utama_core.custom_referee.rules.base_rule import RuleViolation + from utama_core.referee.rules.base_rule import RuleViolation sim_controller.teleport_ball(0.5, 0.5) self._referee.set_command( diff --git a/utama_core/tests/strategy_runner/test_replace_strategy.py b/utama_core/tests/run/test_replace_strategy.py similarity index 96% rename from utama_core/tests/strategy_runner/test_replace_strategy.py rename to utama_core/tests/run/test_replace_strategy.py index 9e5805faf..11de0195f 100644 --- a/utama_core/tests/strategy_runner/test_replace_strategy.py +++ b/utama_core/tests/run/test_replace_strategy.py @@ -5,13 +5,13 @@ import pytest -from utama_core.custom_referee import CustomReferee -from utama_core.custom_referee.profiles.profile_loader import load_profile from utama_core.engine.abstract_strategy import AbstractStrategy from utama_core.engine.context import TickContext from utama_core.engine.match_log import MatchLog from utama_core.engine.strategy import Strategy from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.referee import CustomReferee +from utama_core.referee.profiles.profile_loader import load_profile from utama_core.run import StrategyRunner from utama_core.tactics.defense import DefenseTactic @@ -28,7 +28,7 @@ def build(motion_controller) -> Strategy: kernel.tick = lambda game: ticks.append(game.referee.referee_command) or tick(game) return kernel - return AbstractStrategy(build_kernel_strategy=build) + return AbstractStrategy(build=build) @pytest.fixture diff --git a/utama_core/tests/strategy_runner/test_robot_feedback_snapshot.py b/utama_core/tests/run/test_robot_feedback_snapshot.py similarity index 100% rename from utama_core/tests/strategy_runner/test_robot_feedback_snapshot.py rename to utama_core/tests/run/test_robot_feedback_snapshot.py diff --git a/utama_core/tests/strategy_runner/test_rsim_formations.py b/utama_core/tests/run/test_rsim_formations.py similarity index 95% rename from utama_core/tests/strategy_runner/test_rsim_formations.py rename to utama_core/tests/run/test_rsim_formations.py index d6d23ef55..b8a76e245 100644 --- a/utama_core/tests/strategy_runner/test_rsim_formations.py +++ b/utama_core/tests/run/test_rsim_formations.py @@ -6,9 +6,9 @@ from utama_core.config.formations import get_formations from utama_core.engine.abstract_strategy import AbstractStrategy from utama_core.entities.game.field import FieldBounds -from utama_core.global_utils.mapping_utils import map_left_right_to_colors +from utama_core.entities.game.mapping_utils import map_left_right_to_colors from utama_core.run.strategy_runner import StrategyRunner -from utama_core.strategy.kernel_strategy import build_default_kernel_strategy +from utama_core.strategy.catalog import builder from utama_core.tests.common.abstract_test_manager import ( AbstractTestManager, TestingStatus, @@ -21,7 +21,7 @@ def _idle_strategy() -> AbstractStrategy: """Minimal kernel strategy used only to drive runner lifecycle.""" - return AbstractStrategy(build_kernel_strategy=build_default_kernel_strategy(()), exp_ball=True) + return AbstractStrategy(build=builder("default", ()), exp_ball=True) class _CaptureFirstFrameManager(AbstractTestManager): diff --git a/utama_core/tests/strategy_runner/test_rsim_render_bounds.py b/utama_core/tests/run/test_rsim_render_bounds.py similarity index 100% rename from utama_core/tests/strategy_runner/test_rsim_render_bounds.py rename to utama_core/tests/run/test_rsim_render_bounds.py diff --git a/utama_core/tests/strategy_runner/test_run_test_timeout.py b/utama_core/tests/run/test_run_test_timeout.py similarity index 100% rename from utama_core/tests/strategy_runner/test_run_test_timeout.py rename to utama_core/tests/run/test_run_test_timeout.py diff --git a/utama_core/tests/strategy_runner/test_runner_misconfig.py b/utama_core/tests/run/test_runner_misconfig.py similarity index 99% rename from utama_core/tests/strategy_runner/test_runner_misconfig.py rename to utama_core/tests/run/test_runner_misconfig.py index 7b1a30c1a..522668272 100644 --- a/utama_core/tests/strategy_runner/test_runner_misconfig.py +++ b/utama_core/tests/run/test_runner_misconfig.py @@ -9,11 +9,11 @@ GREAT_EXHIBITION_FIELD_DIMS, STANDARD_FIELD_DIMS, ) -from utama_core.custom_referee import CustomReferee from utama_core.entities.game.field import FieldBounds +from utama_core.referee import CustomReferee from utama_core.run.referee_source import OfficialReferee from utama_core.run.strategy_runner import StrategyRunner -from utama_core.tests.strategy_runner.strat_runner_test_utils import DummyStrategy +from utama_core.tests.run.strat_runner_test_utils import DummyStrategy @pytest.fixture diff --git a/utama_core/tests/strategy_runner/test_scenario_hooks.py b/utama_core/tests/run/test_scenario_hooks.py similarity index 95% rename from utama_core/tests/strategy_runner/test_scenario_hooks.py rename to utama_core/tests/run/test_scenario_hooks.py index 8cf352553..d227f19db 100644 --- a/utama_core/tests/strategy_runner/test_scenario_hooks.py +++ b/utama_core/tests/run/test_scenario_hooks.py @@ -1,10 +1,10 @@ from unittest.mock import Mock -from utama_core.custom_referee import CustomReferee from utama_core.entities.game.game_frame import GameFrame from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.rsoccer_simulator.src.ssl import ssl_gym_base +from utama_core.referee import CustomReferee from utama_core.run.strategy_runner import StrategyRunner +from utama_core.simulator.ssl import ssl_gym_base def test_strategy_runner_step_once_delegates_to_single_step_loop(): diff --git a/utama_core/tests/run/test_sim_pose_ahead.py b/utama_core/tests/run/test_sim_pose_ahead.py new file mode 100644 index 000000000..1ecc61dcf --- /dev/null +++ b/utama_core/tests/run/test_sim_pose_ahead.py @@ -0,0 +1,34 @@ +"""rsim with simulated delay compensates for it the way real robots do; without delay it must not.""" + +from types import SimpleNamespace + +import pytest + +from utama_core.config.enums import Mode +from utama_core.config.robot_params import REAL_PARAMS +from utama_core.motion_planning.controllers.fastpathplanning import ( + FastPathPlanningController, +) +from utama_core.run.strategy_runner import StrategyRunner +from utama_core.simulator.utils.sim_noise import SimNoise + +TEAM = SimpleNamespace(motion_controller=FastPathPlanningController) + + +def latency(mode, rsim_env): + runner = SimpleNamespace(mode=mode, rsim_env=rsim_env) + return StrategyRunner._motion_controller(runner, TEAM, {}).pose_ahead.latency_s + + +def test_rsim_looks_ahead_by_the_middle_of_its_simulated_delay(): + env = SimpleNamespace(sim_noise=SimNoise(latency_s=(0.05, 0.09))) + assert latency(Mode.RSIM, env) == pytest.approx(0.07) + + +@pytest.mark.parametrize("env", [None, SimpleNamespace(sim_noise=None), SimpleNamespace(sim_noise=SimNoise())]) +def test_rsim_without_delay_does_not_look_ahead(env): + assert latency(Mode.RSIM, env) == 0.0 + + +def test_real_robots_keep_their_own_setting(): + assert latency(Mode.REAL, None) == REAL_PARAMS.CONTROL_LATENCY_S diff --git a/utama_core/tests/strategy_runner/test_strategy_control_scheme.py b/utama_core/tests/run/test_strategy_control_scheme.py similarity index 75% rename from utama_core/tests/strategy_runner/test_strategy_control_scheme.py rename to utama_core/tests/run/test_strategy_control_scheme.py index 165547a27..09db0d3e3 100644 --- a/utama_core/tests/strategy_runner/test_strategy_control_scheme.py +++ b/utama_core/tests/run/test_strategy_control_scheme.py @@ -5,19 +5,19 @@ import pytest from utama_core.engine.abstract_strategy import AbstractStrategy -from utama_core.motion_planning.src.controllers import ( +from utama_core.motion_planning.controllers import ( DWAController, FastPathPlanningController, PIDController, TrajectorySamplingController, ) from utama_core.run.strategy_runner import StrategyRunner -from utama_core.strategy.kernel_strategy import build_default_kernel_strategy -from utama_core.tests.strategy_runner.strat_runner_test_utils import DummyStrategy +from utama_core.strategy.catalog import builder +from utama_core.tests.run.strat_runner_test_utils import DummyStrategy def _dummy_factory(motion_controller): - return build_default_kernel_strategy((1, 2))(motion_controller) + return builder("default", (1, 2))(motion_controller) class _CustomSchemeStrategy(AbstractStrategy): @@ -26,27 +26,27 @@ class _CustomSchemeStrategy(AbstractStrategy): def test_abstract_strategy_control_scheme_precedence(): # 1. Default when unset is None - s_default = AbstractStrategy(build_kernel_strategy=_dummy_factory) + s_default = AbstractStrategy(build=_dummy_factory) assert s_default.control_scheme is None # 2. Inherited from factory attribute factory_with_scheme = lambda mc: _dummy_factory(mc) # noqa: E731 factory_with_scheme.control_scheme = "trajsample" - s_factory = AbstractStrategy(build_kernel_strategy=factory_with_scheme) + s_factory = AbstractStrategy(build=factory_with_scheme) assert s_factory.control_scheme == "trajsample" # 3. Inherited from class attribute - s_class = _CustomSchemeStrategy(build_kernel_strategy=_dummy_factory) + s_class = _CustomSchemeStrategy(build=_dummy_factory) assert s_class.control_scheme == "dwa" # 4. Constructor argument overrides class attribute and factory attribute - s_override = _CustomSchemeStrategy(build_kernel_strategy=factory_with_scheme, control_scheme="pid") + s_override = _CustomSchemeStrategy(build=factory_with_scheme, control_scheme="pid") assert s_override.control_scheme == "pid" def test_strategy_runner_resolves_strategy_control_scheme(): # Friendly strategy requests 'trajsample' - strat = AbstractStrategy(build_kernel_strategy=_dummy_factory, control_scheme="trajsample") + strat = AbstractStrategy(build=_dummy_factory, control_scheme="trajsample") runner = StrategyRunner( strategy=strat, my_team_is_yellow=True, @@ -77,7 +77,7 @@ def test_strategy_runner_defaults_to_fpp_when_unspecified(): def test_strategy_runner_explicit_override_takes_precedence(): # Strategy declares 'trajsample', but runner explicitly passes 'dwa' - strat = AbstractStrategy(build_kernel_strategy=_dummy_factory, control_scheme="trajsample") + strat = AbstractStrategy(build=_dummy_factory, control_scheme="trajsample") runner = StrategyRunner( strategy=strat, my_team_is_yellow=True, @@ -94,8 +94,8 @@ def test_strategy_runner_explicit_override_takes_precedence(): def test_strategy_runner_asymmetric_pvp_control_schemes(): # Friendly uses 'trajsample', opponent uses 'dwa' - strat_a = AbstractStrategy(build_kernel_strategy=_dummy_factory, control_scheme="trajsample") - strat_b = AbstractStrategy(build_kernel_strategy=_dummy_factory, control_scheme="dwa") + strat_a = AbstractStrategy(build=_dummy_factory, control_scheme="trajsample") + strat_b = AbstractStrategy(build=_dummy_factory, control_scheme="dwa") runner = StrategyRunner( strategy=strat_a, @@ -114,8 +114,8 @@ def test_strategy_runner_asymmetric_pvp_control_schemes(): def test_strategy_runner_opp_explicit_override(): # Friendly uses 'trajsample', opponent strategy declares 'dwa', but opp_control_scheme overrides to 'pid' - strat_a = AbstractStrategy(build_kernel_strategy=_dummy_factory, control_scheme="trajsample") - strat_b = AbstractStrategy(build_kernel_strategy=_dummy_factory, control_scheme="dwa") + strat_a = AbstractStrategy(build=_dummy_factory, control_scheme="trajsample") + strat_b = AbstractStrategy(build=_dummy_factory, control_scheme="dwa") runner = StrategyRunner( strategy=strat_a, diff --git a/utama_core/tests/strategy_runner/teleport_position_accuracy_test.py b/utama_core/tests/run/test_teleport_position_accuracy.py similarity index 96% rename from utama_core/tests/strategy_runner/teleport_position_accuracy_test.py rename to utama_core/tests/run/test_teleport_position_accuracy.py index 3ca2bae11..2f2f87200 100644 --- a/utama_core/tests/strategy_runner/teleport_position_accuracy_test.py +++ b/utama_core/tests/run/test_teleport_position_accuracy.py @@ -10,8 +10,8 @@ from utama_core.entities.game import Game from utama_core.entities.game.field import FieldBounds from utama_core.run import StrategyRunner -from utama_core.strategy.kernel_strategy import build_default_kernel_strategy -from utama_core.team_controller.src.controllers import AbstractSimController +from utama_core.strategy.catalog import builder +from utama_core.team_controller.controllers import AbstractSimController from utama_core.tests.common.abstract_test_manager import ( AbstractTestManager, TestingStatus, @@ -34,7 +34,7 @@ def _idle_strategy() -> AbstractStrategy: """Minimal kernel strategy that does nothing — used when we only care about game state.""" - return AbstractStrategy(build_kernel_strategy=build_default_kernel_strategy(())) + return AbstractStrategy(build=builder("default", ())) class _TeleportAccuracyTestManager(AbstractTestManager): diff --git a/utama_core/tests/strategy_runner/test_teleport_settle.py b/utama_core/tests/run/test_teleport_settle.py similarity index 100% rename from utama_core/tests/strategy_runner/test_teleport_settle.py rename to utama_core/tests/run/test_teleport_settle.py diff --git a/utama_core/tests/strategy_runner/test_vision_stream_bad_frame.py b/utama_core/tests/run/test_vision_stream_bad_frame.py similarity index 100% rename from utama_core/tests/strategy_runner/test_vision_stream_bad_frame.py rename to utama_core/tests/run/test_vision_stream_bad_frame.py diff --git a/utama_core/tests/rsoccer_simulator/test_dribble_with_friction.py b/utama_core/tests/simulator/test_dribble_with_friction.py similarity index 96% rename from utama_core/tests/rsoccer_simulator/test_dribble_with_friction.py rename to utama_core/tests/simulator/test_dribble_with_friction.py index b3f4d64fb..34fd5f509 100644 --- a/utama_core/tests/rsoccer_simulator/test_dribble_with_friction.py +++ b/utama_core/tests/simulator/test_dribble_with_friction.py @@ -14,8 +14,8 @@ import numpy as np import pytest -from utama_core.rsoccer_simulator.src.ssl.envs import SSLStandardEnv -from utama_core.rsoccer_simulator.src.Utils.sim_noise import SimNoise +from utama_core.simulator.ssl.envs import SSLStandardEnv +from utama_core.simulator.utils.sim_noise import SimNoise TICK = 1 / 60 FRONT = 0.1 # the ball's centre, this far in front of the robot's centre, is in the kicker diff --git a/utama_core/tests/rsoccer_simulator/test_render_overlay.py b/utama_core/tests/simulator/test_render_overlay.py similarity index 96% rename from utama_core/tests/rsoccer_simulator/test_render_overlay.py rename to utama_core/tests/simulator/test_render_overlay.py index a4f32c5ee..98276f775 100644 --- a/utama_core/tests/rsoccer_simulator/test_render_overlay.py +++ b/utama_core/tests/simulator/test_render_overlay.py @@ -1,6 +1,6 @@ from unittest.mock import patch -from utama_core.rsoccer_simulator.src.Render.overlay import ( +from utama_core.simulator.render.overlay import ( OverlayObject, OverlayType, RenderOverlay, diff --git a/utama_core/tests/rsoccer_simulator/test_robosim_wrapper.py b/utama_core/tests/simulator/test_robosim_wrapper.py similarity index 95% rename from utama_core/tests/rsoccer_simulator/test_robosim_wrapper.py rename to utama_core/tests/simulator/test_robosim_wrapper.py index 9214f49ea..b07afab78 100644 --- a/utama_core/tests/rsoccer_simulator/test_robosim_wrapper.py +++ b/utama_core/tests/simulator/test_robosim_wrapper.py @@ -3,7 +3,7 @@ import numpy as np import pytest -from utama_core.rsoccer_simulator.src.Simulators.robosim.robosim_wrapper import ( +from utama_core.simulator.simulators.robosim.robosim_wrapper import ( RSimSubprocessWrapper, ) @@ -131,9 +131,7 @@ def test_reused_sim_plays_exactly_as_a_fresh_one(monkeypatch): """With reuse on, closing a sim parks its subprocess and the next `acquire` hands it back with a new native world: a play after a different, messy play (ball kicked away, robots fast and turned, dribblers spinning) must be bit-identical to the same play in a fresh subprocess.""" - from utama_core.rsoccer_simulator.src.Simulators.robosim import ( - robosim_wrapper as rw, - ) + from utama_core.simulator.simulators.robosim import robosim_wrapper as rw monkeypatch.setattr(rw, "_reuse_sims", True) monkeypatch.setattr(rw, "_idle_sims", {}) @@ -162,9 +160,7 @@ def test_reused_sim_plays_exactly_as_a_fresh_one(monkeypatch): def test_sim_whose_request_failed_is_not_parked_for_reuse(monkeypatch): """A request that failed part-way may have left the pipe out of step, so that sim is terminated.""" - from utama_core.rsoccer_simulator.src.Simulators.robosim import ( - robosim_wrapper as rw, - ) + from utama_core.simulator.simulators.robosim import robosim_wrapper as rw monkeypatch.setattr(rw, "_reuse_sims", True) monkeypatch.setattr(rw, "_idle_sims", {}) diff --git a/utama_core/tests/rsoccer_simulator/test_sim_noise.py b/utama_core/tests/simulator/test_sim_noise.py similarity index 95% rename from utama_core/tests/rsoccer_simulator/test_sim_noise.py rename to utama_core/tests/simulator/test_sim_noise.py index d7c765f2e..bf6463cc9 100644 --- a/utama_core/tests/rsoccer_simulator/test_sim_noise.py +++ b/utama_core/tests/simulator/test_sim_noise.py @@ -3,13 +3,9 @@ import numpy as np import pytest -from utama_core.rsoccer_simulator.src.ssl.envs import SSLStandardEnv -from utama_core.rsoccer_simulator.src.Utils.gaussian_noise import RsimGaussianNoise -from utama_core.rsoccer_simulator.src.Utils.sim_noise import ( - CommandDelay, - KickSpeedNoise, - SimNoise, -) +from utama_core.simulator.ssl.envs import SSLStandardEnv +from utama_core.simulator.utils.gaussian_noise import RsimGaussianNoise +from utama_core.simulator.utils.sim_noise import CommandDelay, KickSpeedNoise, SimNoise N = {"team_blue": 2, "team_yellow": 2} TICK = 1 / 60 diff --git a/utama_core/tests/rsoccer_simulator/test_sim_physics_knobs.py b/utama_core/tests/simulator/test_sim_physics_knobs.py similarity index 98% rename from utama_core/tests/rsoccer_simulator/test_sim_physics_knobs.py rename to utama_core/tests/simulator/test_sim_physics_knobs.py index 66566961d..6e6d9a774 100644 --- a/utama_core/tests/rsoccer_simulator/test_sim_physics_knobs.py +++ b/utama_core/tests/simulator/test_sim_physics_knobs.py @@ -11,9 +11,9 @@ import numpy as np import pytest -from utama_core.rsoccer_simulator.src.Entities import Robot -from utama_core.rsoccer_simulator.src.ssl.envs import SSLStandardEnv -from utama_core.rsoccer_simulator.src.Utils.sim_noise import ( +from utama_core.simulator.entities import Robot +from utama_core.simulator.ssl.envs import SSLStandardEnv +from utama_core.simulator.utils.sim_noise import ( KickAngleNoise, MotionLimits, SimDraw, diff --git a/utama_core/tests/skills/test_defend_parameter.py b/utama_core/tests/skills/test_defend_parameter.py index 4b0e1a813..1e6dcbb87 100644 --- a/utama_core/tests/skills/test_defend_parameter.py +++ b/utama_core/tests/skills/test_defend_parameter.py @@ -3,7 +3,7 @@ import numpy as np import pytest -import utama_core.skills.src.defend_parameter as dp +import utama_core.skills.defend_parameter as dp from utama_core.config.physical_constants import BALL_RADIUS, ROBOT_RADIUS from utama_core.config.referee_constants import OWN_DEFENSE_AREA_STANDOFF_DISTANCE from utama_core.entities.data.vector import Vector2D, Vector3D diff --git a/utama_core/tests/skills/test_defense_utils.py b/utama_core/tests/skills/test_defense_utils.py index 77d207bca..2fe954c14 100644 --- a/utama_core/tests/skills/test_defense_utils.py +++ b/utama_core/tests/skills/test_defense_utils.py @@ -3,7 +3,7 @@ import numpy as np import pytest -from utama_core.skills.src.utils.defense_utils import ( +from utama_core.skills.utils.defense_utils import ( DefenseGeometry, _defense_geometry, calculate_defense_area, diff --git a/utama_core/tests/skills/test_find_best_shot.py b/utama_core/tests/skills/test_find_best_shot.py index 1e72cca30..983265fa1 100644 --- a/utama_core/tests/skills/test_find_best_shot.py +++ b/utama_core/tests/skills/test_find_best_shot.py @@ -6,15 +6,15 @@ from utama_core.entities.data.vector import Vector2D # Stub out heavy simulator dependency before importing the module under test -module = types.ModuleType("rsoccer_simulator.src.ssl.envs.standard_ssl") +module = types.ModuleType("rsoccer_simulator.ssl.envs.standard_ssl") module.SSLStandardEnv = object sys.modules.setdefault("rsoccer_simulator", types.ModuleType("rsoccer_simulator")) -sys.modules.setdefault("rsoccer_simulator.src", types.ModuleType("rsoccer_simulator.src")) -sys.modules.setdefault("rsoccer_simulator.src.ssl", types.ModuleType("rsoccer_simulator.src.ssl")) -sys.modules.setdefault("rsoccer_simulator.src.ssl.envs", types.ModuleType("rsoccer_simulator.src.ssl.envs")) -sys.modules["rsoccer_simulator.src.ssl.envs.standard_ssl"] = module +sys.modules.setdefault("rsoccer_simulator", types.ModuleType("rsoccer_simulator")) +sys.modules.setdefault("rsoccer_simulator.ssl", types.ModuleType("rsoccer_simulator.ssl")) +sys.modules.setdefault("rsoccer_simulator.ssl.envs", types.ModuleType("rsoccer_simulator.ssl.envs")) +sys.modules["rsoccer_simulator.ssl.envs.standard_ssl"] = module -import utama_core.skills.src.score_goal as sg # noqa: E402 +import utama_core.skills.score_goal as sg # noqa: E402 def test_candidate_stays_within_boundary_gap(monkeypatch): diff --git a/utama_core/tests/skills/test_go_to_ball.py b/utama_core/tests/skills/test_go_to_ball.py index ce48c2a5d..d285a96e5 100644 --- a/utama_core/tests/skills/test_go_to_ball.py +++ b/utama_core/tests/skills/test_go_to_ball.py @@ -1,16 +1,20 @@ +import dataclasses import math from unittest.mock import MagicMock import pytest +from utama_core.config.enums import Mode from utama_core.config.field_params import STANDARD_FIELD_DIMS from utama_core.entities.data.vector import Vector2D, Vector3D from utama_core.entities.game import Ball, Field, Game, GameFrame, GameHistory, Robot -from utama_core.motion_planning.src.common.pose_ahead import PoseAhead -from utama_core.shared.pass_and_score_geometry import enemy_defense_area_hold_point -from utama_core.skills.src.go_to_ball import ( +from utama_core.geometry.pass_and_score_geometry import enemy_defense_area_hold_point +from utama_core.motion_planning.common.pose_ahead import PoseAhead +from utama_core.skills.go_to_ball import ( _APPROACH_OVERSHOOT_M, _DRIBBLE_OVERSHOOT_M, + _RACE_ENEMY_RANGE_M, + _RACE_ROBOT_RANGE_M, _target_past_ball, go_to_ball, ) @@ -123,7 +127,7 @@ def test_chases_ball_directly_when_ball_is_not_in_enemy_defense_area(): @pytest.mark.parametrize("robot_xy", [(0.0, 0.0), (2.0, 1.0), (1.0, -1.5)]) def test_approaches_facing_the_ball(monkeypatch, robot_xy): """The kicker and dribbler are on the front: the robot faces the ball on its way in.""" - from utama_core.skills.src import go_to_ball as module + from utama_core.skills import go_to_ball as module captured = {} monkeypatch.setattr(module, "move", lambda **kwargs: captured.update(kwargs)) @@ -132,3 +136,38 @@ def test_approaches_facing_the_ball(monkeypatch, robot_xy): go_to_ball(game=game, motion_controller=_motion_controller(), robot_id=1, shield=False) assert captured["target_oren"] == pytest.approx(math.atan2(0.0 - robot_xy[1], 1.0 - robot_xy[0])) + + +def _race_sprints(robot_x: float, enemy_x: float, monkeypatch, mode=Mode.RSIM, enemy_has_ball=False) -> bool: + from utama_core.skills import go_to_ball as module + + enemy = _robot(0, enemy_x, 0.0, False) + enemy = dataclasses.replace(enemy, has_ball=enemy_has_ball) + game = _game({0: _robot(0, robot_x, 0.0, True)}, {0: enemy}, (0.0, 0.0)) + captured = {} + monkeypatch.setattr(module, "move", lambda **kwargs: captured.update(kwargs)) + motion_controller = _motion_controller() + motion_controller.mode = mode + go_to_ball(game=game, motion_controller=motion_controller, robot_id=0, shield=False) + return captured.get("sprint", False) + + +@pytest.mark.parametrize( + "robot_x, enemy_x, sprints", + [ + (-_RACE_ROBOT_RANGE_M + 0.01, _RACE_ENEMY_RANGE_M - 0.01, True), + (-_RACE_ROBOT_RANGE_M - 0.01, _RACE_ENEMY_RANGE_M - 0.01, False), + (-_RACE_ROBOT_RANGE_M + 0.01, _RACE_ENEMY_RANGE_M + 0.01, False), + ], +) +def test_sprints_only_at_a_ball_an_enemy_is_near(monkeypatch, robot_x, enemy_x, sprints): + assert _race_sprints(robot_x, enemy_x, monkeypatch) is sprints + + +def test_sprints_at_a_ball_an_enemy_holds(monkeypatch): + assert _race_sprints(-0.5, 0.11, monkeypatch, enemy_has_ball=True) is True + + +@pytest.mark.parametrize("mode, sprints", [(Mode.RSIM, True), (Mode.GRSIM, True), (Mode.REAL, False)]) +def test_sprints_for_a_contested_ball_only_in_simulation(monkeypatch, mode, sprints): + assert _race_sprints(-0.5, 0.3, monkeypatch, mode=mode) is sprints diff --git a/utama_core/tests/skills/test_goalkeep.py b/utama_core/tests/skills/test_goalkeep.py index 3614c0c16..25fd1f589 100644 --- a/utama_core/tests/skills/test_goalkeep.py +++ b/utama_core/tests/skills/test_goalkeep.py @@ -4,11 +4,11 @@ import numpy as np import pytest -import utama_core.skills.src.goalkeep as gk -import utama_core.skills.src.kick_upfield as ku +import utama_core.skills.goalkeep as gk +import utama_core.skills.kick_upfield as ku from utama_core.config.physical_constants import BALL_RADIUS, ROBOT_RADIUS from utama_core.entities.data.vector import Vector2D, Vector3D -from utama_core.skills.src.utils.defense_utils import ( +from utama_core.skills.utils.defense_utils import ( intersection_with_x_line, single_defender_stop_y, ) @@ -43,6 +43,7 @@ def _std_field(my_team_is_right: bool): my_goal_line=goal_line, half_goal_width=0.5, my_defense_area=_defense_area(goal_x, depth=0.5, width=1.0), + enemy_goal_line=np.array([[-goal_x, 0.5], [-goal_x, -0.5]]), ) @@ -546,6 +547,7 @@ def test_goalkeep_clears_retrieved_ball_without_dribbling_it_out(monkeypatch): exact carry). Facing its own goal (pi) here, so it must turn on the spot toward upfield (+x for a left-side team).""" game = SimpleNamespace( + enemy_robots={}, my_team_is_yellow=True, my_team_is_right=False, field=_std_field(False), @@ -573,6 +575,7 @@ def test_goalkeep_kicks_held_ball_once_oriented_upfield(monkeypatch): the box too.""" exit_x = -2.93 game = SimpleNamespace( + enemy_robots={}, my_team_is_yellow=True, my_team_is_right=False, field=_std_field(False), @@ -649,6 +652,7 @@ def test_clearance_kicks_within_its_tolerance_of_upfield(monkeypatch, off_rad, k """The real keeper settled ~0.07 rad off upfield and never reached the 0.05 rad shot tolerance, so it never cleared (2026-10-27 field runs).""" game = SimpleNamespace( + enemy_robots={}, my_team_is_yellow=True, my_team_is_right=False, field=_std_field(False), @@ -661,3 +665,40 @@ def test_clearance_kicks_within_its_tolerance_of_upfield(monkeypatch, off_rad, k assert ku.kick_upfield(game, motion_controller=object(), robot_id=0) == ( "sentinel-kick" if kicks else "sentinel-turn" ) + + +def _held_ball_game(teammate, enemy=None, orientation=0.0): + """A left-side keeper holding the ball, one outfield robot upfield.""" + return SimpleNamespace( + enemy_robots={} if enemy is None else {0: SimpleNamespace(p=Vector2D(*enemy))}, + my_team_is_yellow=True, + my_team_is_right=False, + field=_std_field(False), + friendly_robots={ + 0: SimpleNamespace(p=Vector2D(-4.2, 0.0), orientation=orientation, has_ball=True), + 1: SimpleNamespace(p=Vector2D(*teammate), orientation=0.0, has_ball=False), + }, + ball=SimpleNamespace(p=Vector3D(-4.11, 0.0, 0.0), v=Vector3D(0.0, 0.0, 0.0)), + ) + + +def test_keeper_passes_to_a_teammate_standing_free(monkeypatch): + monkeypatch.setattr(gk, "kick", lambda: "pass") + monkeypatch.setattr(gk, "kick_upfield", lambda *a: "clear") + ctx = SimpleNamespace(expected_receivers=set()) + assert gk.goalkeep(_held_ball_game((-1.0, 0.0)), None, 0, ctx) == "pass" + assert ctx.expected_receivers == {1} + + +def test_keeper_turns_to_the_teammate_before_passing(monkeypatch): + monkeypatch.setattr(gk, "turn_on_spot", lambda **kw: kw["target_oren"]) + target = gk.goalkeep(_held_ball_game((-2.0, 2.0), orientation=-0.5), None, 0) + assert target == pytest.approx(math.atan2(2.0, 2.2)) + + +def test_keeper_clears_upfield_when_the_teammate_is_marked(monkeypatch): + monkeypatch.setattr(gk, "kick_upfield", lambda *a: "clear") + # 0.39 m off the lane is inside the keeper's safety margin + assert gk.goalkeep(_held_ball_game((-1.0, 0.0), enemy=(-2.0, 0.39)), None, 0) == "clear" + monkeypatch.setattr(gk, "kick", lambda: "pass") + assert gk.goalkeep(_held_ball_game((-1.0, 0.0), enemy=(-2.0, 0.41)), None, 0) == "pass" diff --git a/utama_core/tests/skills/test_man_mark.py b/utama_core/tests/skills/test_man_mark.py index 8703569aa..a70ce4598 100644 --- a/utama_core/tests/skills/test_man_mark.py +++ b/utama_core/tests/skills/test_man_mark.py @@ -2,7 +2,7 @@ import pytest -import utama_core.skills.src.man_mark as mm +import utama_core.skills.man_mark as mm from utama_core.entities.data.vector import Vector2D, Vector3D diff --git a/utama_core/tests/skills/test_move_utils.py b/utama_core/tests/skills/test_move_utils.py index f899dc852..aba4acead 100644 --- a/utama_core/tests/skills/test_move_utils.py +++ b/utama_core/tests/skills/test_move_utils.py @@ -7,8 +7,8 @@ from utama_core.config.physical_constants import BALL_RADIUS, ROBOT_RADIUS from utama_core.entities.data.vector import Vector2D, Vector3D from utama_core.entities.game import Ball, Field, Game, GameFrame, GameHistory, Robot -from utama_core.motion_planning.src.common.pose_ahead import PoseAhead -from utama_core.skills.src.utils.move_utils import move, turn_on_spot +from utama_core.motion_planning.common.pose_ahead import PoseAhead +from utama_core.skills.utils.move_utils import _sprint_velocity, move, turn_on_spot PIVOT_RADIUS = ROBOT_RADIUS + BALL_RADIUS @@ -221,10 +221,10 @@ def test_a_robot_that_loses_the_ball_ramps_from_the_carry_speed_it_was_sent(cont 0.3 m/s sent: ramping from the 1 m/s never sent lurched the real robot 0.9 m/s sideways (dribble_and_shoot, 2026-10-28).""" from utama_core.config.enums import Mode - from utama_core.motion_planning.src.controllers.fastpathplanning import ( + from utama_core.motion_planning.controllers.fastpathplanning import ( FastPathPlanningController, ) - from utama_core.motion_planning.src.controllers.pid_controller import PIDController + from utama_core.motion_planning.controllers.pid_controller import PIDController mc = {"fpp": FastPathPlanningController, "pid": PIDController}[controller](Mode.REAL) mc.pose_ahead = PoseAhead(0.0) @@ -293,3 +293,59 @@ def test_only_real_robots_have_a_slowest_turn(): assert REAL_PARAMS.MIN_TURN == _MIN_TURN assert RSIM_PARAMS.MIN_TURN is GRSIM_PARAMS.MIN_TURN is None + + +def _head_on(distance: float, ours: float, theirs: float): + enemy = Robot( + id=0, + is_friendly=False, + has_ball=False, + p=Vector2D(distance, 0.0), + v=Vector2D(-theirs, 0.0), + a=Vector2D(0, 0), + orientation=0.0, + ) + game = _game({1: _robot(1, 0.0, 0.0, True)}, {0: enemy}, (3.0, 3.0)) + mc = MagicMock() + mc.min_turn = None + mc.robot_carry = {} + mc.pose_ahead = PoseAhead(0.0) + mc.calculate.return_value = (Vector2D(ours, 0.0), 0.0) + return game, mc + + +def test_move_brakes_for_an_enemy_coming_head_on(): + game, mc = _head_on(2 * ROBOT_RADIUS + 0.02, 1.5, 1.5) + command = move(game, mc, 1, Vector2D(2.0, 0.0), 0.0) + assert command.local_forward_vel == pytest.approx(0.5 + math.sqrt(3.0 * 0.02)) + mc.sent.assert_called_once() + + +def test_move_keeps_a_legal_approach_to_an_enemy_standing_still(): + game, mc = _head_on(2 * ROBOT_RADIUS + 0.02, 1.2, 0.0) + assert move(game, mc, 1, Vector2D(2.0, 0.0), 0.0).local_forward_vel == pytest.approx(1.2) + mc.sent.assert_not_called() + + +def test_move_is_not_capped_outside_braking_range(): + game, mc = _head_on(1.21, 2.0, 2.0) + assert move(game, mc, 1, Vector2D(2.0, 0.0), 0.0).local_forward_vel == pytest.approx(2.0) + + +def test_move_is_not_capped_driving_away_from_an_enemy(): + game, mc = _head_on(0.25, -2.0, 2.0) + assert move(game, mc, 1, Vector2D(-2.0, 0.0), 0.0).local_forward_vel == pytest.approx(-2.0) + + +def test_a_sprint_goes_as_fast_as_it_can_still_stop(): + velocity = _sprint_velocity(Vector2D(0.0, 0.0), Vector2D(0.125, 0.0), max_speed=2.0, max_acceleration=4.0) + assert velocity.x == pytest.approx(1.0) and velocity.y == 0.0 + + +def test_a_sprint_is_capped_at_top_speed(): + velocity = _sprint_velocity(Vector2D(0.0, 0.0), Vector2D(0.0, 1.0), max_speed=2.0, max_acceleration=4.0) + assert velocity.y == pytest.approx(2.0) + + +def test_a_sprint_already_on_the_target_stands_still(): + assert _sprint_velocity(Vector2D(1.0, 1.0), Vector2D(1.0, 1.0), max_speed=2.0, max_acceleration=4.0).mag() == 0.0 diff --git a/utama_core/tests/skills/test_shielding.py b/utama_core/tests/skills/test_shielding.py index ce99dd547..6367c50fd 100644 --- a/utama_core/tests/skills/test_shielding.py +++ b/utama_core/tests/skills/test_shielding.py @@ -1,11 +1,11 @@ -"""Tests for `utama_core.skills.src.shielding`, extracted out of `go_to_ball.py`.""" +"""Tests for `utama_core.skills.shielding`, extracted out of `go_to_ball.py`.""" import pytest from utama_core.config.field_params import STANDARD_FIELD_DIMS from utama_core.entities.data.vector import Vector2D, Vector3D from utama_core.entities.game import Ball, Field, Game, GameFrame, GameHistory, Robot -from utama_core.skills.src.shielding import ( +from utama_core.skills.shielding import ( _RELEASE_RANGE, COMMIT_RANGE, CONTEST_RANGE, diff --git a/utama_core/tests/strategy/test_carrier_allocation.py b/utama_core/tests/strategy/test_carrier_allocation.py index 9ee781331..d862ef67f 100644 --- a/utama_core/tests/strategy/test_carrier_allocation.py +++ b/utama_core/tests/strategy/test_carrier_allocation.py @@ -1,7 +1,7 @@ from types import SimpleNamespace from utama_core.entities.data.object import TeamType -from utama_core.strategy.kernel_strategy import _clear_press_plus_picker +from utama_core.strategy.breakwater import _breakwater_picker def _final_third_game(carrier_id): @@ -21,7 +21,7 @@ def test_the_robot_holding_the_ball_goes_to_the_ball_side_slot(): # clear_press_plus_vs_zone_fluid (2026-09-28): the final-third handoff gave # "overload" the two lowest ids and put carrier 4 in "block", which held the # ball still while the overload decoy waited on it — frozen for 38 s. - partition = _clear_press_plus_picker( + partition = _breakwater_picker( _final_third_game(carrier_id=4), frozenset({1, 2, 3, 4, 5}), {"attack": frozenset({3, 4, 5})}, @@ -49,7 +49,7 @@ def test_a_free_kick_kicker_standing_at_the_ball_goes_first(): # kick the kicker stood 0.11 m from the ball without dribbler contact, went to # "block"/"switch", and the overload decoy had to cross the field to it -- # no kick for 10 s. Within kick reach of a still ball counts as holding it. - from utama_core.strategy.kernel_strategy import carrier_first + from utama_core.strategy.pickers import carrier_first assert carrier_first(_free_kick_game(kicker_dist=0.12), frozenset(range(1, 6)))[0] == 5 @@ -59,7 +59,7 @@ def test_a_kicker_that_nudged_its_own_free_kick_ball_still_goes_first(): # the ball at 0.21 m/s, it lost the carrier spot to the lowest ids, walked off, # and the unkicked ball (moved 4.5 cm, never in play) sat for 10 s. A ball under # the 0.3 m/s dead-ball speed is still one the kicker can simply take. - from utama_core.strategy.kernel_strategy import carrier_first + from utama_core.strategy.pickers import carrier_first assert carrier_first(_free_kick_game(kicker_dist=0.11, ball_speed=0.21), frozenset(range(1, 6)))[0] == 5 assert carrier_first(_free_kick_game(kicker_dist=0.11, ball_speed=0.29), frozenset(range(1, 6)))[0] == 5 @@ -67,7 +67,7 @@ def test_a_kicker_that_nudged_its_own_free_kick_ball_still_goes_first(): def test_a_robot_short_of_kick_reach_or_beaten_to_the_ball_is_not_first(): - from utama_core.strategy.kernel_strategy import carrier_first + from utama_core.strategy.pickers import carrier_first assert carrier_first(_free_kick_game(kicker_dist=0.30), frozenset(range(1, 6)))[0] == 1 assert carrier_first(_free_kick_game(kicker_dist=0.12, enemy_dist=0.11), frozenset(range(1, 6)))[0] == 1 diff --git a/utama_core/tests/strategy/test_catalog.py b/utama_core/tests/strategy/test_catalog.py new file mode 100644 index 000000000..6de2821fb --- /dev/null +++ b/utama_core/tests/strategy/test_catalog.py @@ -0,0 +1,20 @@ +"""`catalog.current_name`: old strategy names (pre-2026-11-12, and the older `build_*_kernel_strategy`) +load today's strategy, while `plain_name` keeps the saved name that replay files are found by.""" + +from utama_core.strategy import catalog + + +def test_every_old_name_maps_to_a_strategy_in_the_catalog(): + names = set(catalog.names()) + assert set(catalog.RENAMED.values()) <= names + assert not set(catalog.RENAMED) & names # an old name is never also a current one + + +def test_old_names_in_both_old_forms_resolve_to_the_new_name(): + assert catalog.current_name("split_shape") == "pendulum" + assert catalog.current_name("build_split_shape_kernel_strategy") == "pendulum" + assert catalog.current_name("pendulum") == "pendulum" + + +def test_plain_name_keeps_the_saved_name_replay_files_are_named_by(): + assert catalog.plain_name("build_split_shape_kernel_strategy") == "split_shape" diff --git a/utama_core/tests/strategy/test_first_strategy_doc.py b/utama_core/tests/strategy/test_first_strategy_doc.py new file mode 100644 index 000000000..115ce3f69 --- /dev/null +++ b/utama_core/tests/strategy/test_first_strategy_doc.py @@ -0,0 +1,17 @@ +"""The tutorial's strategy (tutorials/first_strategy.md) still builds, so a new member's first paste works.""" + +import re +from pathlib import Path +from unittest.mock import MagicMock + +from utama_core.engine.strategy import Strategy + +DOC = Path(__file__).resolve().parents[3] / "tutorials" / "first_strategy.md" + + +def test_the_tutorial_strategy_builds(): + blocks = re.findall(r"```python\n(.*?)```", DOC.read_text(), re.S) + (code,) = [b for b in blocks if b.startswith("# utama_core/strategy/rookie.py")] + module: dict = {} + exec(compile(code, "rookie.py", "exec"), module) + assert isinstance(module["build"]((1, 2, 3, 4, 5), MagicMock()), Strategy) diff --git a/utama_core/tests/strategy/test_friendly_closer_to_ball.py b/utama_core/tests/strategy/test_friendly_closer_to_ball.py index 834e3bef3..a8424911d 100644 --- a/utama_core/tests/strategy/test_friendly_closer_to_ball.py +++ b/utama_core/tests/strategy/test_friendly_closer_to_ball.py @@ -3,7 +3,7 @@ import pytest from utama_core.entities.data.object import TeamType -from utama_core.strategy.kernel_strategy import ( +from utama_core.strategy.pickers import ( friendly_closer_to_ball, reset_closer_to_ball_state, ) diff --git a/utama_core/tests/strategy/test_overload_flow_streak.py b/utama_core/tests/strategy/test_overload_flow_streak.py deleted file mode 100644 index eb2ef9243..000000000 --- a/utama_core/tests/strategy/test_overload_flow_streak.py +++ /dev/null @@ -1,33 +0,0 @@ -"""`overload_flow` adds a 4th give-and-go attacker once its team has held the -possession edge for `_POSSESSION_STREAK_TICKS` ticks. The streak was one -module-level counter, so two `overload_flow` teams in one process (a mirror match, -an A/B against itself) counted each other's possession. -""" - -from unittest.mock import MagicMock - -from utama_core.strategy import overload_flow -from utama_core.strategy.overload_flow import ( - _POSSESSION_STREAK_TICKS, - build_overload_flow_kernel_strategy, -) - -_ROBOTS = frozenset({1, 2, 3, 4, 5}) -_TACTICS = frozenset({"givego", "overload", "defense"}) - - -def _picker(): - return build_overload_flow_kernel_strategy((1, 2, 3, 4, 5))(MagicMock())._partitioner - - -def test_each_strategy_counts_its_own_possession_streak(monkeypatch): - monkeypatch.setattr(overload_flow, "carrier_first", lambda game, free: sorted(free)) - monkeypatch.setattr(overload_flow, "friendly_closer_to_ball", lambda game: True) - monkeypatch.setattr(overload_flow, "ball_zone", lambda game: "middle") - a, b = _picker(), _picker() - - for _ in range(_POSSESSION_STREAK_TICKS - 1): - assert len(a(None, _ROBOTS, None, _TACTICS)["givego"]) == 3 - assert len(a(None, _ROBOTS, None, _TACTICS)["givego"]) == 4 - # b has had the ball for one tick, whatever a's streak. - assert len(b(None, _ROBOTS, None, _TACTICS)["givego"]) == 3 diff --git a/utama_core/tests/strategy/test_split_shape_split.py b/utama_core/tests/strategy/test_split_shape_split.py new file mode 100644 index 000000000..a2d036629 --- /dev/null +++ b/utama_core/tests/strategy/test_split_shape_split.py @@ -0,0 +1,20 @@ +"""`pendulum` keeps a second robot in attack while defending, from four outfield robots up, so a +won ball has someone upfield to go to.""" + +import pytest + +from utama_core.strategy import pendulum + +_TACTICS = frozenset({"attack", "defense"}) + + +@pytest.mark.parametrize("robots, attackers", [(5, 2), (4, 2), (3, 0)]) +def test_defending_keeps_a_second_attacker_from_four_robots(monkeypatch, robots, attackers): + monkeypatch.setattr(pendulum, "carrier_first", lambda game, free: sorted(free)) + monkeypatch.setattr(pendulum, "friendly_closer_to_ball", lambda game: False) + free = frozenset(range(1, robots + 1)) + + partition = pendulum._possession_split_picker(None, free, None, _TACTICS) + + assert len(partition.get("attack", ())) == attackers + assert partition.get("attack", frozenset()) | partition["defense"] == free diff --git a/utama_core/tests/team_controller/__init__.py b/utama_core/tests/team_controller/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/utama_core/tests/controller/test_dribbler_limiter.py b/utama_core/tests/team_controller/test_dribbler_limiter.py similarity index 97% rename from utama_core/tests/controller/test_dribbler_limiter.py rename to utama_core/tests/team_controller/test_dribbler_limiter.py index 38ea62b22..1f1055d58 100644 --- a/utama_core/tests/controller/test_dribbler_limiter.py +++ b/utama_core/tests/team_controller/test_dribbler_limiter.py @@ -4,14 +4,14 @@ import pytest -from utama_core.team_controller.src.controllers.real.real_robot_controller import ( +from utama_core.team_controller.controllers.real.real_robot_controller import ( DRIBBLER_DRAIN_RATE, DRIBBLER_MAX_ON_SECONDS, DRIBBLER_RESUME_SECONDS, RealRobotController, ) -_MONOTONIC = "utama_core.team_controller.src.controllers.real.real_robot_controller.time.monotonic" +_MONOTONIC = "utama_core.team_controller.controllers.real.real_robot_controller.time.monotonic" @pytest.fixture diff --git a/utama_core/tests/controller/test_find_robots.py b/utama_core/tests/team_controller/test_find_robots.py similarity index 89% rename from utama_core/tests/controller/test_find_robots.py rename to utama_core/tests/team_controller/test_find_robots.py index 41422c744..03326418b 100644 --- a/utama_core/tests/controller/test_find_robots.py +++ b/utama_core/tests/team_controller/test_find_robots.py @@ -9,11 +9,11 @@ import pytest from utama_core.entities.data.command import RobotResponse -from utama_core.team_controller.src.controllers.common.robot_profile import ( +from utama_core.team_controller.controllers.common.robot_profile import ( RobotProfile, save_profile, ) -from utama_core.team_controller.src.controllers.real import find_robots as fr +from utama_core.team_controller.controllers.real import find_robots as fr class _Field: @@ -135,3 +135,12 @@ def test_confirm_finds_again_when_a_saved_lid_is_not_in_view_or_it_never_ran(tmp def test_confirm_stops_when_a_radio_is_not_found(tmp_path, field): with pytest.raises(SystemExit, match="Radio 2 not found"): fr.confirm([0, 2], tmp_path / "found.json", look=set, finder=_finder(field)) + + +def test_the_pairing_and_the_profiles_live_inside_the_repo(): + # both paths count folders up from their module, and moving the module once pointed them + # outside the repo (profiles then loaded blank, with no error) + repo = fr.PROFILE_DIR.parents[2] + assert (repo / "pixi.toml").exists() + assert fr.PROFILE_DIR == repo / "utama_core" / "config" / "robots" + assert fr.FOUND_PATH == repo / "replays" / "field" / "robots_found.json" diff --git a/utama_core/tests/controller/test_kicker_charge.py b/utama_core/tests/team_controller/test_kicker_charge.py similarity index 96% rename from utama_core/tests/controller/test_kicker_charge.py rename to utama_core/tests/team_controller/test_kicker_charge.py index 15d37262c..caf76e9a2 100644 --- a/utama_core/tests/controller/test_kicker_charge.py +++ b/utama_core/tests/team_controller/test_kicker_charge.py @@ -8,7 +8,7 @@ from utama_core.entities.data.command import RobotCommand from utama_core.entities.data.vector import Vector2D, Vector3D from utama_core.entities.referee.referee_command import RefereeCommand -from utama_core.team_controller.src.controllers.real.kicker_charge import ( +from utama_core.team_controller.controllers.real.kicker_charge import ( CLEAR_M, KEEP_S, KickerCharge, diff --git a/utama_core/tests/controller/test_robot_profile.py b/utama_core/tests/team_controller/test_robot_profile.py similarity index 98% rename from utama_core/tests/controller/test_robot_profile.py rename to utama_core/tests/team_controller/test_robot_profile.py index 8d6f74f95..cdd9e395e 100644 --- a/utama_core/tests/controller/test_robot_profile.py +++ b/utama_core/tests/team_controller/test_robot_profile.py @@ -10,7 +10,7 @@ from utama_core.config.enums import Mode from utama_core.entities.data.command import RobotCommand from utama_core.run.strategy_runner import StrategyRunner -from utama_core.team_controller.src.controllers.common.robot_profile import ( +from utama_core.team_controller.controllers.common.robot_profile import ( _PUSH_TICKS, CARRY_SPEED, CARRY_TURN, diff --git a/utama_core/tests/controller/test_sim_controller.py b/utama_core/tests/team_controller/test_sim_controller.py similarity index 98% rename from utama_core/tests/controller/test_sim_controller.py rename to utama_core/tests/team_controller/test_sim_controller.py index b0bd48b6c..5ffd398ee 100644 --- a/utama_core/tests/controller/test_sim_controller.py +++ b/utama_core/tests/team_controller/test_sim_controller.py @@ -4,7 +4,7 @@ from utama_core.config.field_params import STANDARD_FIELD_DIMS, FieldBounds from utama_core.config.settings import OFF_PITCH_OFFSET -from utama_core.team_controller.src.controllers.common.sim_controller_abstract import ( +from utama_core.team_controller.controllers.common.sim_controller_abstract import ( AbstractSimController, ) @@ -281,7 +281,7 @@ def test_remove_ball_places_outside_field(self, ctrl): ctrl.remove_ball() x, y, _, _ = ctrl.teleport_ball_calls[0] # The removed position must be outside the controller's own field bounds - from utama_core.global_utils.math_utils import in_field_bounds + from utama_core.geometry.math_utils import in_field_bounds assert not in_field_bounds((x, y), ctrl.field_bounds) diff --git a/utama_core/tests/test_main_entry.py b/utama_core/tests/test_main_entry.py new file mode 100644 index 000000000..d631b165c --- /dev/null +++ b/utama_core/tests/test_main_entry.py @@ -0,0 +1,20 @@ +"""main.py resolves strategy names through the catalog; a bad name must fail with the valid ones listed.""" + +import pytest + +import main +from utama_core.engine.abstract_strategy import AbstractStrategy +from utama_core.strategy import catalog + + +def test_known_strategy_name_builds_an_abstract_strategy(): + assert isinstance(main._strategy("pendulum"), AbstractStrategy) + + +def test_unknown_strategy_name_exits_listing_catalog_names(): + with pytest.raises(SystemExit) as excinfo: + main._strategy("no_such_strategy") + message = str(excinfo.value) + assert "no_such_strategy" in message + assert "pendulum" in message + assert all(name in message for name in catalog.names()) diff --git a/utama_core/tests/tools/test_field_check_tool.py b/utama_core/tests/tools/test_field_check_tool.py index 6581bdfa5..da681911e 100644 --- a/utama_core/tests/tools/test_field_check_tool.py +++ b/utama_core/tests/tools/test_field_check_tool.py @@ -1,14 +1,14 @@ -"""`tools/field_check.py` flags a slow camera, a missing ball or lids, and no vision at all; the +"""`tools/field/field_check.py` flags a slow camera, a missing ball or lids, and no vision at all; the robots part flags a robot answering few of its commands.""" import collections import importlib.util from pathlib import Path -from utama_core.team_controller.src.controllers.real import find_robots as fr +from utama_core.team_controller.controllers.real import find_robots as fr spec = importlib.util.spec_from_file_location( - "field_check", Path(__file__).resolve().parents[3] / "tools" / "field_check.py" + "field_check", Path(__file__).resolve().parents[3] / "tools" / "field" / "field_check.py" ) field_check = importlib.util.module_from_spec(spec) spec.loader.exec_module(field_check) diff --git a/utama_core/tests/tools/test_match_replay_path.py b/utama_core/tests/tools/test_match_replay_path.py new file mode 100644 index 000000000..4203cdff1 --- /dev/null +++ b/utama_core/tests/tools/test_match_replay_path.py @@ -0,0 +1,40 @@ +"""Where `tools/evaluation/match.run_match` writes a match's replay: in its `run_dir`, beside the +match's stats and intentions, however deep `run_dir` sits under REPLAY_BASE_PATH. + +Before 2026-11-12 the replay was named `/`, right only when run_dir sat directly +under replays/: an evaluate.py round folder (eval_/round_/) put every run's replays in +replays/round_/, overwriting each other, and the round folders had none. +""" + +from __future__ import annotations + +import pytest + +from tools.evaluation import match + + +class _Stop(Exception): + pass + + +@pytest.mark.parametrize("depth", [("eval_20261112_120000", "round_1"), ("tournament_x",)]) +def test_the_replay_lands_in_the_run_dir_beside_the_stats(tmp_path, monkeypatch, depth): + base = tmp_path / "replays" + run_dir = base.joinpath(*depth) + seen = {} + + def fake_runner(a, b, **kwargs): + seen.update(kwargs) + raise _Stop + + monkeypatch.setattr(match, "REPLAY_BASE_PATH", base) + monkeypatch.setattr(match, "load_side", lambda name: object()) + monkeypatch.setattr(match, "sim_runner", fake_runner) + monkeypatch.setattr(match, "enable_sim_reuse", lambda: None) + with pytest.raises(_Stop): + match.run_match("pendulum", "breakwater", duration_seconds=1.0, run_dir=run_dir) + + replay = base / f"{seen['replay_writer_config'].replay_name}.npz" + stats = seen["stats_path"] + assert replay == run_dir / "pendulum_vs_breakwater.npz" + assert str(replay.with_suffix("")) + ".stats.json" == stats diff --git a/utama_core/tests/tools/test_package_graph.py b/utama_core/tests/tools/test_package_graph.py index 85dc806aa..1212dfcd4 100644 --- a/utama_core/tests/tools/test_package_graph.py +++ b/utama_core/tests/tools/test_package_graph.py @@ -1,9 +1,9 @@ -"""`tools/package_graph.py` on a synthetic `utama_core/` tree: edges, relative imports, skipped tests, the rule.""" +"""`tools/dev/package_graph.py` on a synthetic `utama_core/` tree: edges, relative imports, skipped tests, the rule.""" from collections import Counter from pathlib import Path -from tools.package_graph import edge_counts, render_mermaid, scan, violations +from tools.dev.package_graph import edge_counts, render_mermaid, scan, violations def _write(root: Path, rel: str, text: str) -> None: diff --git a/utama_core/tests/tools/test_package_logs.py b/utama_core/tests/tools/test_package_logs.py index 5d6ba1d6c..b6ba91864 100644 --- a/utama_core/tests/tools/test_package_logs.py +++ b/utama_core/tests/tools/test_package_logs.py @@ -1,9 +1,9 @@ -"""Tests for tools/package_logs.py: tournament and field logs packaging.""" +"""Tests for tools/field/package_logs.py: tournament and field logs packaging.""" import tarfile from pathlib import Path -from tools.package_logs import ( +from tools.field.package_logs import ( collect_field_files, collect_tournament_files, compress_log_file, diff --git a/utama_core/tests/tools/test_sim_setup.py b/utama_core/tests/tools/test_sim_setup.py new file mode 100644 index 000000000..5ef84b86f --- /dev/null +++ b/utama_core/tests/tools/test_sim_setup.py @@ -0,0 +1,73 @@ +"""`utama_core/run/sim_setup.py`: which names load which strategy, and the runner it sets up.""" + +import pytest + +from utama_core.engine.abstract_strategy import AbstractStrategy +from utama_core.entities.referee.referee_command import RefereeCommand +from utama_core.run import sim_setup + + +@pytest.mark.parametrize( + "name, expected", + [ + ("scratch/try.py:build_x", True), + ("/abs/path/try.py:build", True), + ("pendulum", False), + ("try.py:", False), # no factory named + ("try.txt:build", False), + ("a.strategy", False), + ], +) +def test_is_file_spec_needs_a_py_path_and_a_factory(name, expected): + assert sim_setup.is_file_spec(name) is expected + + +def test_a_catalog_name_loads_an_abstract_strategy(): + assert isinstance(sim_setup.load_side("pendulum"), AbstractStrategy) + + +def test_an_unknown_name_lists_the_catalog(): + with pytest.raises(sim_setup.UnknownStrategy, match="unknown strategy 'nope'; strategies: .*pendulum"): + sim_setup.load_side("nope") + + +def test_a_missing_strategy_file_is_named_not_treated_as_a_catalog_name(tmp_path): + with pytest.raises(sim_setup.UnknownStrategy, match="no such strategy file"): + sim_setup.load_side(str(tmp_path / "gone.strategy")) + + +def test_a_scratch_factory_gets_the_outfield_ids_first(tmp_path): + scratch = tmp_path / "try.py" + scratch.write_text("def build_x(ids, mc):\n return ids, mc\n") + assert sim_setup.factory_for(f"{scratch}:build_x")((1, 2))("mc") == ((1, 2), "mc") + + +def test_a_scratch_file_without_the_factory_is_named(tmp_path): + scratch = tmp_path / "try.py" + scratch.write_text("x = 1\n") + with pytest.raises(sim_setup.UnknownStrategy, match="has no factory 'build_x'"): + sim_setup.factory_for(f"{scratch}:build_x") + + +def test_sim_runner_plays_us_yellow_on_the_right_with_six_a_side(): + runner, referee = sim_setup.sim_runner( + sim_setup.load_side("pendulum"), + sim_setup.load_side("wolfpack"), + initial_command=RefereeCommand.STOP, + ) + try: + assert runner.my_team_is_yellow and runner.my_team_is_right + assert runner.exp_friendly == runner.exp_enemy == sim_setup.N_ROBOTS == 6 + assert runner.referee is referee + finally: + runner.close() + + +def test_sim_referee_gives_the_first_kickoff_to_the_team_asked(monkeypatch): + profiles = [] + monkeypatch.setattr(sim_setup, "CustomReferee", lambda profile, **_kw: profiles.append(profile) or object()) + + sim_setup.sim_referee(kickoff_team="blue") + sim_setup.sim_referee() + + assert [p.game.kickoff_team for p in profiles] == ["blue", "yellow"] diff --git a/utama_core/tests/tools/test_trim_idle_log.py b/utama_core/tests/tools/test_trim_idle_log.py index bd363b8b3..05841ccca 100644 --- a/utama_core/tests/tools/test_trim_idle_log.py +++ b/utama_core/tests/tools/test_trim_idle_log.py @@ -1,14 +1,12 @@ -"""Tests for tools/trim_idle_log.py: trimming dead/idle time sectors from SSL logs.""" +"""Tests for tools/field/trim_idle_log.py: trimming dead/idle time sectors from SSL logs.""" import gzip import struct from pathlib import Path -from tools.trim_idle_log import find_active_intervals, trim_log +from tools.field.trim_idle_log import find_active_intervals, trim_log from utama_core.replay.game_log_writer import LOG_HEADER, REFEREE, RUN_INFO -from utama_core.team_controller.src.generated_code.ssl_gc_referee_message_pb2 import ( - Referee, -) +from utama_core.team_controller.generated_code.ssl_gc_referee_message_pb2 import Referee def _write_synthetic_records(path: Path, records: list[tuple[int, int, bytes]]) -> None: diff --git a/utama_core/tests/tools/test_verdict_sim.py b/utama_core/tests/tools/test_verdict_sim.py new file mode 100644 index 000000000..98191fe89 --- /dev/null +++ b/utama_core/tests/tools/test_verdict_sim.py @@ -0,0 +1,49 @@ +"""The rule's error rate, on simulated results (`tools/evaluation/verdict_sim.py`): the docs claim an +equal strategy is called "better" at most ALPHA of the time. Changing the rule or `ratings` is judged +against this.""" + +from __future__ import annotations + +import pytest + +from tools.evaluation import verdict_sim +from utama_core.analysis import ratings + + +@pytest.mark.parametrize("rho", [0.0, 0.5, 0.9]) +@pytest.mark.parametrize("n_opponents", [4, 5]) +def test_an_equal_strategy_is_called_better_at_most_alpha_of_the_time(rho, n_opponents): + r = verdict_sim.simulate(0.0, rho, n_opponents, trials=1500, seed=1) + # the screen drops about half of them first, so the rate is well under ALPHA; the slack is for 1500 trials + assert r["better"] <= ratings.ALPHA + 0.01 + + +def test_a_clearly_better_small_edit_is_found(): + # one goal per match better, results correlated like a small edit of one strategy + r = verdict_sim.simulate(1.0, 0.9, 5, trials=500, seed=2) + assert r["better"] >= 0.8 + + +def test_a_worse_strategy_is_dropped_in_the_screen(): + r = verdict_sim.simulate(-1.0, 0.9, 5, trials=300, seed=3) + assert r["better"] == 0.0 + assert r["rounds"] < 3 + + +def test_the_screen_never_accepts(): + perfect = ratings.paired_test([1.0, 2.0, 1.0, 3.0] * 10) + assert ratings.decide(perfect, ratings.ROUNDS, confirming=False) == "confirm" + assert ratings.decide(perfect, ratings.ROUNDS, confirming=True) == "better" + + +def test_a_stage_drops_only_from_its_second_round_and_at_a_mean_of_zero(): + zero = ratings.paired_test([1.0, -1.0, 0.0, 0.0]) + assert ratings.decide(zero, 1, confirming=False) is None + assert ratings.decide(zero, 2, confirming=False) == "dropped" + assert ratings.decide(zero, 2, confirming=True) == "dropped" + + +def test_the_confirm_stage_is_undecided_above_alpha(): + weak = ratings.paired_test([1.0, -1.0, 0.0, 0.5]) + assert weak.mean > 0 and weak.p > ratings.ALPHA + assert ratings.decide(weak, ratings.ROUNDS, confirming=True) == "undecided" diff --git a/utama_core/tests/tools/test_vision_check.py b/utama_core/tests/tools/test_vision_check.py index 20466e414..ed1029a56 100644 --- a/utama_core/tests/tools/test_vision_check.py +++ b/utama_core/tests/tools/test_vision_check.py @@ -1,4 +1,4 @@ -"""The guided check of `tools/vision_check.py`: the spots it asks for and which ball it takes.""" +"""The guided check of `tools/field/vision_check.py`: the spots it asks for and which ball it takes.""" import importlib.util import select @@ -6,12 +6,12 @@ import time from pathlib import Path -from utama_core.team_controller.src.generated_code.ssl_vision_wrapper_pb2 import ( +from utama_core.team_controller.generated_code.ssl_vision_wrapper_pb2 import ( SSL_WrapperPacket, ) spec = importlib.util.spec_from_file_location( - "vision_check", Path(__file__).resolve().parents[3] / "tools" / "vision_check.py" + "vision_check", Path(__file__).resolve().parents[3] / "tools" / "field" / "vision_check.py" ) vision_check = importlib.util.module_from_spec(spec) spec.loader.exec_module(vision_check) diff --git a/vendor/rSim/FORK_NOTES.md b/vendor/rSim/FORK_NOTES.md index d4700af91..e745d3184 100644 --- a/vendor/rSim/FORK_NOTES.md +++ b/vendor/rSim/FORK_NOTES.md @@ -5,8 +5,11 @@ Forked at commit: `b413932b7b4bbc0fc399f6a979e4cfcc4f56264f` (tag `v1.2`, the same version this repo's `pixi.toml` pins via `rc-robosim>=1.2,<2` on PyPI). This fork is the physics step of the rsim stack. The diagram of the whole tick, from -`StrategyRunner` through the seeded sim noise to this C++ code and back, is in -[docs/sim_realism.md](../../docs/sim_realism.md#how-one-rsim-tick-is-built). +`StrategyRunner` through the seeded sim noise to this C++ code and back: + +![One rsim tick: the command-side noise, the C++ physics and the vision-side noise](../../docs/img/sim_realism/rsim_tick.png) + +Drawn by `docs/img/sim_realism/make_rsim_tick.py`; rerun it when a name in it changes. ## Why this is here @@ -246,7 +249,7 @@ cmake --build build/rsim-py310 -j2 mkdir -p build/rsim-override/robosim echo "from ._robosim import SSL, VSS" > build/rsim-override/robosim/__init__.py ln -s $(pwd)/build/rsim-py310/_robosim.cpython-310-x86_64-linux-gnu.so build/rsim-override/robosim/ -PYTHONPATH=$(pwd)/build/rsim-override pixi run pytest utama_core/tests/rsoccer_simulator --headless +PYTHONPATH=$(pwd)/build/rsim-override pixi run pytest utama_core/tests/simulator --headless ``` Installing for everyone is then a copy of that `.so` over