Datasets:
Add files using upload-large-folder tool
Browse files- LICENSE +202 -0
- docs/GROUND_TRUTH.md +353 -0
- docs/HARBOR.md +156 -0
- docs/PROTOCOLS.md +198 -0
- tasks/badminton/ATTRIBUTION.md +66 -0
- tasks/badminton/CASE_TYPES.json +678 -0
- tasks/badminton/answer_seed.json +1 -0
- tasks/badminton/cases.json +26 -0
- tasks/badminton/instruction.md +135 -0
- tasks/badminton/judge.py +596 -0
- tasks/chess/CASE_TYPES.json +355 -0
- tasks/chess/answer_seed.json +1 -0
- tasks/chess/cases.json +26 -0
- tasks/chess/instruction.md +115 -0
- tasks/chess/judge.py +359 -0
- tasks/cs2/CASE_TYPES.json +311 -0
- tasks/cs2/answer_seed.json +1 -0
- tasks/cs2/cases.json +26 -0
- tasks/cs2/instruction.md +80 -0
- tasks/cs2/judge.py +409 -0
- tasks/dota2/CASE_TYPES.json +415 -0
- tasks/dota2/answer_seed.json +1 -0
- tasks/dota2/cases.json +26 -0
- tasks/dota2/instruction.md +94 -0
- tasks/dota2/judge.py +395 -0
- tasks/doudizhu/CASE_TYPES.json +563 -0
- tasks/doudizhu/answer_seed.json +1 -0
- tasks/doudizhu/cases.json +26 -0
- tasks/doudizhu/instruction.md +120 -0
- tasks/doudizhu/judge.py +397 -0
- tasks/gfootball/CASE_TYPES.json +315 -0
- tasks/gfootball/answer_seed.json +1 -0
- tasks/gfootball/cases.json +26 -0
- tasks/gfootball/instruction.md +104 -0
- tasks/gfootball/judge.py +473 -0
- tasks/go/CASE_TYPES.json +351 -0
- tasks/go/answer_seed.json +1 -0
- tasks/go/cases.json +26 -0
- tasks/go/instruction.md +170 -0
- tasks/go/judge.py +359 -0
- tasks/gomoku/CASE_TYPES.json +351 -0
- tasks/gomoku/answer_seed.json +1 -0
- tasks/gomoku/cases.json +26 -0
- tasks/gomoku/instruction.md +112 -0
- tasks/gomoku/judge.py +359 -0
- tools/make_harbor.py +413 -0
- tools/run_protocol_a.py +306 -0
- tools/run_protocol_b.py +410 -0
- tools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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Apache License
|
| 3 |
+
Version 2.0, January 2004
|
| 4 |
+
http://www.apache.org/licenses/
|
| 5 |
+
|
| 6 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 7 |
+
|
| 8 |
+
1. Definitions.
|
| 9 |
+
|
| 10 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 11 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 12 |
+
|
| 13 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 14 |
+
the copyright owner that is granting the License.
|
| 15 |
+
|
| 16 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 17 |
+
other entities that control, are controlled by, or are under common
|
| 18 |
+
control with that entity. For the purposes of this definition,
|
| 19 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 20 |
+
direction or management of such entity, whether by contract or
|
| 21 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 22 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 23 |
+
|
| 24 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 25 |
+
exercising permissions granted by this License.
|
| 26 |
+
|
| 27 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 28 |
+
including but not limited to software source code, documentation
|
| 29 |
+
source, and configuration files.
|
| 30 |
+
|
| 31 |
+
"Object" form shall mean any form resulting from mechanical
|
| 32 |
+
transformation or translation of a Source form, including but
|
| 33 |
+
not limited to compiled object code, generated documentation,
|
| 34 |
+
and conversions to other media types.
|
| 35 |
+
|
| 36 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 37 |
+
Object form, made available under the License, as indicated by a
|
| 38 |
+
copyright notice that is included in or attached to the work
|
| 39 |
+
(an example is provided in the Appendix below).
|
| 40 |
+
|
| 41 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 42 |
+
form, that is based on (or derived from) the Work and for which the
|
| 43 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 44 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 45 |
+
of this License, Derivative Works shall not include works that remain
|
| 46 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 47 |
+
the Work and Derivative Works thereof.
|
| 48 |
+
|
| 49 |
+
"Contribution" shall mean any work of authorship, including
|
| 50 |
+
the original version of the Work and any modifications or additions
|
| 51 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 52 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 53 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 54 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 55 |
+
means any form of electronic, verbal, or written communication sent
|
| 56 |
+
to the Licensor or its representatives, including but not limited to
|
| 57 |
+
communication on electronic mailing lists, source code control systems,
|
| 58 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 59 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 60 |
+
excluding communication that is conspicuously marked or otherwise
|
| 61 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 62 |
+
|
| 63 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 64 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 65 |
+
subsequently incorporated within the Work.
|
| 66 |
+
|
| 67 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 68 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 69 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 70 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 71 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 72 |
+
Work and such Derivative Works in Source or Object form.
|
| 73 |
+
|
| 74 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 75 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 76 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 77 |
+
(except as stated in this section) patent license to make, have made,
|
| 78 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 79 |
+
where such license applies only to those patent claims licensable
|
| 80 |
+
by such Contributor that are necessarily infringed by their
|
| 81 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 82 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 83 |
+
institute patent litigation against any entity (including a
|
| 84 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 85 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 86 |
+
or contributory patent infringement, then any patent licenses
|
| 87 |
+
granted to You under this License for that Work shall terminate
|
| 88 |
+
as of the date such litigation is filed.
|
| 89 |
+
|
| 90 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 91 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 92 |
+
modifications, and in Source or Object form, provided that You
|
| 93 |
+
meet the following conditions:
|
| 94 |
+
|
| 95 |
+
(a) You must give any other recipients of the Work or
|
| 96 |
+
Derivative Works a copy of this License; and
|
| 97 |
+
|
| 98 |
+
(b) You must cause any modified files to carry prominent notices
|
| 99 |
+
stating that You changed the files; and
|
| 100 |
+
|
| 101 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 102 |
+
that You distribute, all copyright, patent, trademark, and
|
| 103 |
+
attribution notices from the Source form of the Work,
|
| 104 |
+
excluding those notices that do not pertain to any part of
|
| 105 |
+
the Derivative Works; and
|
| 106 |
+
|
| 107 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 108 |
+
distribution, then any Derivative Works that You distribute must
|
| 109 |
+
include a readable copy of the attribution notices contained
|
| 110 |
+
within such NOTICE file, excluding those notices that do not
|
| 111 |
+
pertain to any part of the Derivative Works, in at least one
|
| 112 |
+
of the following places: within a NOTICE text file distributed
|
| 113 |
+
as part of the Derivative Works; within the Source form or
|
| 114 |
+
documentation, if provided along with the Derivative Works; or,
|
| 115 |
+
within a display generated by the Derivative Works, if and
|
| 116 |
+
wherever such third-party notices normally appear. The contents
|
| 117 |
+
of the NOTICE file are for informational purposes only and
|
| 118 |
+
do not modify the License. You may add Your own attribution
|
| 119 |
+
notices within Derivative Works that You distribute, alongside
|
| 120 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 121 |
+
that such additional attribution notices cannot be construed
|
| 122 |
+
as modifying the License.
|
| 123 |
+
|
| 124 |
+
You may add Your own copyright statement to Your modifications and
|
| 125 |
+
may provide additional or different license terms and conditions
|
| 126 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 127 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 128 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 129 |
+
the conditions stated in this License.
|
| 130 |
+
|
| 131 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 132 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 133 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 134 |
+
this License, without any additional terms or conditions.
|
| 135 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 136 |
+
the terms of any separate license agreement you may have executed
|
| 137 |
+
with Licensor regarding such Contributions.
|
| 138 |
+
|
| 139 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 140 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 141 |
+
except as required for reasonable and customary use in describing the
|
| 142 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 143 |
+
|
| 144 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 145 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 146 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 147 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 148 |
+
implied, including, without limitation, any warranties or conditions
|
| 149 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 150 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 151 |
+
appropriateness of using or redistributing the Work and assume any
|
| 152 |
+
risks associated with Your exercise of permissions under this License.
|
| 153 |
+
|
| 154 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 155 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 156 |
+
unless required by applicable law (such as deliberate and grossly
|
| 157 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 158 |
+
liable to You for damages, including any direct, indirect, special,
|
| 159 |
+
incidental, or consequential damages of any character arising as a
|
| 160 |
+
result of this License or out of the use or inability to use the
|
| 161 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 162 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 163 |
+
other commercial damages or losses), even if such Contributor
|
| 164 |
+
has been advised of the possibility of such damages.
|
| 165 |
+
|
| 166 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 167 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 168 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 169 |
+
or other liability obligations and/or rights consistent with this
|
| 170 |
+
License. However, in accepting such obligations, You may act only
|
| 171 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 172 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 173 |
+
defend, and hold each Contributor harmless for any liability
|
| 174 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 175 |
+
of your accepting any such warranty or additional liability.
|
| 176 |
+
|
| 177 |
+
END OF TERMS AND CONDITIONS
|
| 178 |
+
|
| 179 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 180 |
+
|
| 181 |
+
To apply the Apache License to your work, attach the following
|
| 182 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 183 |
+
replaced with your own identifying information. (Don't include
|
| 184 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 185 |
+
comment syntax for the file format. We also recommend that a
|
| 186 |
+
file or class name and description of purpose be included on the
|
| 187 |
+
same "printed page" as the copyright notice for easier
|
| 188 |
+
identification within third-party archives.
|
| 189 |
+
|
| 190 |
+
Copyright [yyyy] [name of copyright owner]
|
| 191 |
+
|
| 192 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 193 |
+
you may not use this file except in compliance with the License.
|
| 194 |
+
You may obtain a copy of the License at
|
| 195 |
+
|
| 196 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 197 |
+
|
| 198 |
+
Unless required by applicable law or agreed to in writing, software
|
| 199 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 200 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 201 |
+
See the License for the specific language governing permissions and
|
| 202 |
+
limitations under the License.
|
docs/GROUND_TRUTH.md
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ground truth
|
| 2 |
+
|
| 3 |
+
Every reference tuple in this benchmark comes from the game itself — a replay parser or a pinned
|
| 4 |
+
engine — never from a human annotator and never from a model. That is the property that makes the
|
| 5 |
+
corpus extensible: a new held-out case costs compute, not labelling, so the 20 published cases per
|
| 6 |
+
environment can be refreshed without renegotiating what a label means.
|
| 7 |
+
|
| 8 |
+
Two mechanisms:
|
| 9 |
+
|
| 10 |
+
| | How $V_t$ is obtained | Environments |
|
| 11 |
+
|---|---|---|
|
| 12 |
+
| **Parser** | the game already computes the quantity; the adapter reads it out of the replay, demo, trace, or annotation | CS2, DOTA 2, SC2, GFootball, Badminton |
|
| 13 |
+
| **Evaluator** | the game does not define a win probability, so a pinned engine supplies one for every prefix | Go, Chess, Gomoku, Doudizhu |
|
| 14 |
+
|
| 15 |
+
A parser environment has no engine to pin and no evaluator noise — `score_after` in GFootball is
|
| 16 |
+
the engine's own score. An evaluator environment has to pin the engine **and** its search budget,
|
| 17 |
+
because a win probability is only reproducible at a fixed configuration; those pins are listed per
|
| 18 |
+
environment below.
|
| 19 |
+
|
| 20 |
+
Sources were last accessed **2026-09-04**.
|
| 21 |
+
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
## What every GT file contains
|
| 25 |
+
|
| 26 |
+
```
|
| 27 |
+
tasks/<game>/gt/<case_id>_gt.json
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
One file per case. The reference tuples live under `events` — **the same root key in all nine
|
| 31 |
+
games**, and the same key an answer file uses — and each row carries T1's perception fields, T2's
|
| 32 |
+
update label, and T3's resulting state side by side. Everything else in the
|
| 33 |
+
file is provenance and is not scored: engine pins, thresholds, case type, per-class counts, audits.
|
| 34 |
+
|
| 35 |
+
Each file also carries a top-level `_canary` string. Please keep it: it is how contamination gets
|
| 36 |
+
detected later, and it costs a training pipeline nothing to drop these files.
|
| 37 |
+
|
| 38 |
+
Row counts, which are also the strict-F1 denominators:
|
| 39 |
+
|
| 40 |
+
| Game | Cases | Reference tuples | per case |
|
| 41 |
+
|---|---|---|---|
|
| 42 |
+
| Go | 20 | 5,516 | 276 |
|
| 43 |
+
| CS2 | 20 | 3,703 | 185 |
|
| 44 |
+
| Chess | 20 | 1,761 | 88 |
|
| 45 |
+
| SC2 | 20 | 1,358 | 68 |
|
| 46 |
+
| Badminton | 20 | 701 | 35 |
|
| 47 |
+
| Gomoku | 20 | 808 | 40 |
|
| 48 |
+
| DOTA 2 | 20 | 597 | 30 |
|
| 49 |
+
| Doudizhu | 20 | 429 | 21 |
|
| 50 |
+
| GFootball | 20 | 405 | 20 |
|
| 51 |
+
| **Total** | **180** | **15,278** | |
|
| 52 |
+
|
| 53 |
+
### Two conventions that are easy to misread
|
| 54 |
+
|
| 55 |
+
**A T1-only row is not a missing label.** Go and Chess emit `capture` rows alongside `move` rows. A
|
| 56 |
+
capture is a perception event with no $V_t$ update of its own — the move that caused it already
|
| 57 |
+
carries that — so its `wr_swing` and `leader_after` are `null` by design (378 of 5,516 rows in Go,
|
| 58 |
+
331 of 1,761 in Chess). Those rows are scored at T1 and excluded from the T2/T3 denominators.
|
| 59 |
+
|
| 60 |
+
**Doudizhu abstains near a band boundary.** A row whose label sits within 2σ of its band edge
|
| 61 |
+
carries `null` on that tier and `t2_unresolved` / `t3_unresolved` set (79 rows at T2, 47 at T3, out
|
| 62 |
+
of 429). The PIMC estimate cannot separate those from the other side of the band, so scoring them
|
| 63 |
+
would be scoring sampling noise. The model **cannot tell which rows those are** and must answer
|
| 64 |
+
every row — abstention removes undecidable labels from the numerator; it does not make the task
|
| 65 |
+
easier.
|
| 66 |
+
|
| 67 |
+
---
|
| 68 |
+
|
| 69 |
+
## T3 is not one metric
|
| 70 |
+
|
| 71 |
+
T3 asks the same question everywhere — *where does this leave the match* — but what counts as an
|
| 72 |
+
answer follows the $V_t$ of the environment:
|
| 73 |
+
|
| 74 |
+
| T3 answer | Metric | Environments |
|
| 75 |
+
|---|---|---|
|
| 76 |
+
| a three-way class label | macro accuracy | Go, Chess, Gomoku, Doudizhu, DOTA 2, SC2 |
|
| 77 |
+
| an exact integer score pair | exact-pair accuracy | GFootball, Badminton |
|
| 78 |
+
| the cumulative score pair after the round | exact fraction | CS2 |
|
| 79 |
+
|
| 80 |
+
`score.py` prints all three in one T3 column and each judge records which it computed. A class
|
| 81 |
+
label where the score is the state would be a weaker question, and an exact pair where $V_t$ is a
|
| 82 |
+
win probability would be unanswerable.
|
| 83 |
+
|
| 84 |
+
T2's class vocabulary is not uniform either — it is whatever a change in that $V_t$ can be:
|
| 85 |
+
`{A, B, equal}` on a win probability, four classes (`taken` / `extended` / `levelled` / `narrowed`)
|
| 86 |
+
on a score differential, two (`T` / `CT`) on a CS2 round. Chance level therefore differs by game:
|
| 87 |
+
0.333 on three classes, 0.25 on four, 0.5 on two. Every judge macro-averages over per-class recall
|
| 88 |
+
precisely so a constant answer lands on chance instead of on the majority share — which on Go's T2
|
| 89 |
+
would otherwise read **0.87** (4,481 of the 5,138 labelled rows are `equal`).
|
| 90 |
+
|
| 91 |
+
---
|
| 92 |
+
|
| 93 |
+
## Case stratification
|
| 94 |
+
|
| 95 |
+
Cases are not a random sample of matches. Each environment selects 20 from a larger pool so the
|
| 96 |
+
corpus contains matches that are hard for different reasons, and so no single class dominates the
|
| 97 |
+
T2/T3 labels. Eight of the nine environments stratify by **trajectory shape**, derived from the $V_t$
|
| 98 |
+
trajectory itself:
|
| 99 |
+
|
| 100 |
+
- **blowout** — one side ahead essentially throughout
|
| 101 |
+
- **tense** — repeated lead changes
|
| 102 |
+
- **reversal** (CS2 and DOTA 2 call it **comeback**) — the eventual winner trailed
|
| 103 |
+
|
| 104 |
+
| Game | blowout | tense | reversal / comeback |
|
| 105 |
+
|---|---|---|---|
|
| 106 |
+
| Go | 5 | 10 | 5 |
|
| 107 |
+
| Chess | 3 | 11 | 6 |
|
| 108 |
+
| Gomoku | 6 | 10 | 4 |
|
| 109 |
+
| Doudizhu | 7 | 7 | 6 |
|
| 110 |
+
| CS2 | 8 | 5 | 7 |
|
| 111 |
+
| DOTA 2 | 7 | 6 | 7 |
|
| 112 |
+
| GFootball | 7 | 6 | 7 |
|
| 113 |
+
| Badminton | 6 | 7 | 7 |
|
| 114 |
+
|
| 115 |
+
**SC2 is the exception** and its `CASE_TYPES.json` carries no trajectory label: resource-equivalent
|
| 116 |
+
value rarely reverses inside a game, so within one match `leader_after` is effectively two-class
|
| 117 |
+
{leader, equal} and a reversal class would be empty. It balances on **which side led** instead — 10
|
| 118 |
+
A-led and 10 B-led — which is what keeps its dataset-pooled T3 from collapsing onto one class
|
| 119 |
+
(A 568 / B 531 / equal 259 across 1,358 events).
|
| 120 |
+
|
| 121 |
+
**The rule that assigns a trajectory type is per-environment, not shared.** It depends on the shape
|
| 122 |
+
of that $V_t$: a score-difference $V_t$ makes *reversal* nearly impossible to detect from a trough
|
| 123 |
+
(GFootball uses "winner ever trailed" plus a peak threshold), while a win-probability $V_t$ makes
|
| 124 |
+
*blowout* the fragile one (Doudizhu keys on the winner-perspective trough at 0.12 / 0.22). Always
|
| 125 |
+
smooth before taking an extremum.
|
| 126 |
+
|
| 127 |
+
Six `CASE_TYPES.json` files carry numeric thresholds — Go, Chess, Gomoku, CS2, and DOTA 2 the stratification thresholds they used, SC2 its event-segmentation ones. Doudizhu carries the note that its thresholds are *fixed* across the corpus (re-tuning ε per case would stop macro accuracy being comparable between cases), and GFootball and Badminton record only the resulting distribution. All nine carry the per-case label (SC2's is `leading_side`). The $V_t$ definition is in every game's `instruction.md` and in the per-environment sections below; `CASE_TYPES.json` repeats it for Doudizhu, GFootball, Badminton, and SC2.
|
| 128 |
+
|
| 129 |
+
---
|
| 130 |
+
|
| 131 |
+
## Per environment
|
| 132 |
+
|
| 133 |
+
### Go — board · evaluator
|
| 134 |
+
|
| 135 |
+
| | |
|
| 136 |
+
|---|---|
|
| 137 |
+
| **Source** | SGF records via the OGS public API, fixture game 27400000 — <https://online-go.com> |
|
| 138 |
+
| **GT mechanism** | evaluator. The adapter replays each move and evaluates **every prefix** |
|
| 139 |
+
| **Engine pin** | KataGo, network `b18c384nbt`, **1600 visits** per position |
|
| 140 |
+
| **$V_t$** | Black win probability, **±10 pp** dead band around 0.50 |
|
| 141 |
+
| **Render** | plain 19×19 board, 612², 25 fps. No coordinates, move numbers, names, clocks, capture counters, komi, or evaluation bar |
|
| 142 |
+
|
| 143 |
+
T1 is the move or capture with its time, colour, and board coordinate. T2 is the quantized signed
|
| 144 |
+
change in Black's win rate caused by the move (`wr_swing`). T3 is the win-rate leader immediately
|
| 145 |
+
after it (`leader_after`). Selection balances the winning colour 10 B / 10 W.
|
| 146 |
+
|
| 147 |
+
Go is the largest environment by tuples per case (276), so it is where a model's ability to hold a
|
| 148 |
+
whole match in view is most exposed — and where Protocol A's frame grid bites hardest.
|
| 149 |
+
|
| 150 |
+
### Chess — board · evaluator
|
| 151 |
+
|
| 152 |
+
| | |
|
| 153 |
+
|---|---|
|
| 154 |
+
| **Source** | public Lichess game export, fixture `cZWtZEBE` — <https://lichess.org> |
|
| 155 |
+
| **GT mechanism** | evaluator, per-ply, with real per-ply timing |
|
| 156 |
+
| **Engine pin** | **Stockfish 18, depth 20**, value function `white_expected_score_wdl` |
|
| 157 |
+
| **$V_t$** | White-oriented expected score / WDL, **±10 pp** band. Draws map to the neutral label |
|
| 158 |
+
| **Render** | plain 8×8 board, 548², 1 fps. No coordinates, move numbers, names, clocks, result text, captured-piece tray, or evaluation bar |
|
| 159 |
+
|
| 160 |
+
T1 records the **destination square only**, not the origin — the released contract is deliberately
|
| 161 |
+
weaker than full move notation. T2 is the quantized change in the White-oriented value; T3 is the
|
| 162 |
+
post-ply leader.
|
| 163 |
+
|
| 164 |
+
The video is natively 1 fps because a ply is a discrete event; Protocol A's sampler is clamped by
|
| 165 |
+
the container rate, so it never asks ffmpeg to fabricate frames here.
|
| 166 |
+
|
| 167 |
+
### Gomoku — board · evaluator
|
| 168 |
+
|
| 169 |
+
| | |
|
| 170 |
+
|---|---|
|
| 171 |
+
| **Source** | competition PSQ records (Gomocup) |
|
| 172 |
+
| **GT mechanism** | evaluator |
|
| 173 |
+
| **Engine pin** | **Rapfi**, 1000 ms per turn, freestyle rule, `black_winrate_sigmoid_eval` (scaling factor 200) — <https://github.com/dhbloo/rapfi> |
|
| 174 |
+
| **$V_t$** | **tempo-neutral** smoothed Black win probability, ±10 pp band |
|
| 175 |
+
| **Render** | plain 15×15 board, 504², 25 fps. No coordinates, move numbers, names, clocks, or engine annotations |
|
| 176 |
+
|
| 177 |
+
**Why the smoothing matters.** Gomoku is attack-dominant, so a raw side-to-move win rate swings
|
| 178 |
+
back and forth with whose turn it is — a square wave that has nothing to do with who is actually
|
| 179 |
+
ahead. Left alone it turns "who leads" into "who moves next", which is a **move-parity shortcut**,
|
| 180 |
+
readable off the stone count with no understanding of the position. The release applies
|
| 181 |
+
`v_smooth[t] = (v[t] + v[t-1]) / 2` (`trailing2_movepair`) to cancel it, then gates on terminal
|
| 182 |
+
consistency. All 20 cases share that pin.
|
| 183 |
+
|
| 184 |
+
### Doudizhu — card · evaluator
|
| 185 |
+
|
| 186 |
+
| | |
|
| 187 |
+
|---|---|
|
| 188 |
+
| **Source** | DouZero-WP greedy self-play deals (τ=0) — <https://github.com/kwai/DouZero>, weights at <https://huggingface.co/palemoky/douzero-baselines> |
|
| 189 |
+
| **GT mechanism** | evaluator: **hidden-hand PIMC** — determinize, then roll out |
|
| 190 |
+
| **Estimator** | adaptive **400–4000 worlds** per state, greedy rollouts with the released DouZero-WP policy. The PIMC estimator is part of this benchmark, not a DouZero component |
|
| 191 |
+
| **$V_t$** | landlord win probability = fraction of sampled deals the landlord wins. Bands: landlord > 0.55, farmers < 0.45, else equal. T2 impact ε = 0.034, T3 band = 0.05 |
|
| 192 |
+
| **Render** | tabletop, 1280×720, 24 fps. Landlord hand and the three bottom cards face up; **farmer hands face down**, showing only their counts. No numeric score, timer, move counter, or probability display |
|
| 193 |
+
|
| 194 |
+
**Hiding the farmer hands is what makes $V_t$ non-degenerate.** With every hand visible the value is
|
| 195 |
+
close to a deterministic function of the cards, and the task collapses into card counting. The
|
| 196 |
+
evaluator is given exactly the landlord's information set — own hand, the bottom three, all plays
|
| 197 |
+
so far, and both farmer card *counts* — and samples uniformly from the deals consistent with it.
|
| 198 |
+
|
| 199 |
+
That leaves one shortcut worth naming, because it is the one a model will find: *"whoever holds
|
| 200 |
+
fewer cards is ahead."* Card counts are public, so it is tempting. Measured over 9,954 events, it
|
| 201 |
+
buys only **+0.05–0.09** macro accuracy and is at its worst in the endgame — exactly when the
|
| 202 |
+
landlord's hand is also small but the outcome runs the other way. Across this corpus it is capped
|
| 203 |
+
at **macro_acc ≤ 0.45**.
|
| 204 |
+
|
| 205 |
+
T1 is every move that plays ≥1 card, with the player, combination type, and card count; passes are
|
| 206 |
+
shown on screen but never reported. Each play occupies a 6 s display window and `game_clock_s` is
|
| 207 |
+
its midpoint, so the ±3 s tolerance is exactly half a window — any time inside the window pairs up,
|
| 208 |
+
with no ambiguity across plays.
|
| 209 |
+
|
| 210 |
+
### Counter-Strike 2 — FPS · parser
|
| 211 |
+
|
| 212 |
+
| | |
|
| 213 |
+
|---|---|
|
| 214 |
+
| **Source** | public professional-match demo (`.dem`) files published on HLTV; the game is <https://www.counter-strike.net> |
|
| 215 |
+
| **GT mechanism** | parser, our own, at the demo's **native 64 Hz** tick rate; positions resampled to 4 Hz for the render |
|
| 216 |
+
| **$V_t$** | the **cumulative round score**, by persistent team (A / B) across the halftime side swap |
|
| 217 |
+
| **Render** | clean top-down radar, 768², 15 fps, 1:1 real pace. Map geometry, player motion, bomb state, and event-relevant effects preserved; HUD, scoreboard, round counter, kill feed, economy, names, and audio removed |
|
| 218 |
+
|
| 219 |
+
T1 covers six event types — `kill`, `bomb_planted`, `bomb_defused`, `bomb_exploded`, `elimination`,
|
| 220 |
+
`save` — with their time and type-specific attributes. **On a `kill`, the side and the dot number
|
| 221 |
+
1–10 identify the victim, not the killer**, because the death marker is rendered without team colour
|
| 222 |
+
or number. A `kill` row therefore carries `side` and `number`; the four conclusion types carry
|
| 223 |
+
`winner_side` instead, and `bomb_planted` carries the planter's `side`.
|
| 224 |
+
|
| 225 |
+
T2 is the winner of the round containing the event; T3 is the cumulative score right after that
|
| 226 |
+
round. Both are carried **on every event row** and are round-constant, rather than exposed as
|
| 227 |
+
separate per-round fields.
|
| 228 |
+
|
| 229 |
+
The retained bomb/countdown corner clock is the only on-screen number in the whole corpus, and it is
|
| 230 |
+
deliberate: it is the round timer, not the state.
|
| 231 |
+
|
| 232 |
+
> **`score_after` is cumulative, so its errors propagate.** One early round mis-attributed shifts
|
| 233 |
+
> every later row's `score_after`, and because strict F1 voids a tuple on any wrong field, a single
|
| 234 |
+
> early mistake can cost the rest of the match. This is the intended difficulty — tracking means
|
| 235 |
+
> tracking — but read a near-zero CS2 strict F1 against its T1, which is scored independently.
|
| 236 |
+
|
| 237 |
+
**20 cases**: 8 blowout / 5 tense / 7 comeback, listed in `tasks/cs2/CASE_TYPES.json`.
|
| 238 |
+
|
| 239 |
+
### DOTA 2 — MOBA · parser
|
| 240 |
+
|
| 241 |
+
| | |
|
| 242 |
+
|---|---|
|
| 243 |
+
| **Source** | Valve replays plus OpenDota match records — <https://www.opendota.com>, <https://github.com/odota> |
|
| 244 |
+
| **GT mechanism** | parser (manta-based) for events, OpenDota's minute-level gold curve for the state |
|
| 245 |
+
| **$V_t$** | the **parsed net-worth advantage** — explicitly *not* a learned win-probability model. `even` = within **±1000 gold** |
|
| 246 |
+
| **Render** | the real minimap terrain art with GT-anchored coordinates and real game sprites, 768², 15 fps. HUD, scoreboard, clock, net-worth graph, names, and objective counters removed |
|
| 247 |
+
|
| 248 |
+
T1 covers six event types — first blood, teamfight, tower, barracks, Roshan, ancient — each with
|
| 249 |
+
its own attributes (side, killer or winner, death counts, tier, lane, objective type). T2 quantizes
|
| 250 |
+
the change in net-worth advantage over the aligned **minute-level** interval (`minute_gain`); T3 is
|
| 251 |
+
the net-worth leader at that interval's end (`leader_after`).
|
| 252 |
+
|
| 253 |
+
**Time axis.** Every DOTA 2 video starts **8 s before the horn** (`video.preroll_s = 8.0`, speed 1.0, in all 20 cases), so `video_ts = max(0, game_s) + 8` and the event's minute is `m = floor(max(0, video_ts − 8) / 60)` — this reproduces the GT minute for all 597 events, where the older `floor(video_ts / 60)` agreed on only 521. Events the parser dates **before** the horn are clamped to the horn, `video_ts` = 8.0, even when they fall before the video's first frame (game second −8) — eight rows: first blood in dota-02/03/04/05/06/07, plus a pre-game teamfight in dota-04 and dota-06. The dota-04 teamfight (game second −47) carries `deaths: 0` and `winner_side: even`; it is kept as the parser emitted it rather than edited by hand, so read a miss on that one row with this in mind.
|
| 254 |
+
|
| 255 |
+
Using the parsed gold curve rather than a win model is a deliberate choice: a learned win
|
| 256 |
+
probability would make the reference depend on a model, and then the benchmark would be scoring
|
| 257 |
+
agreement with that model rather than with the game.
|
| 258 |
+
|
| 259 |
+
> **Its T2/T3 macro is computed over *matched* events only** (as is SC2's). Low T1 recall therefore
|
| 260 |
+
> shrinks the T2/T3 denominator and can **delete the hard classes — especially `equal` — from it**,
|
| 261 |
+
> so a T3 number backed by one surviving class is not comparable to one backed by three. The other
|
| 262 |
+
> seven judges count an unlocalized event as wrong instead. `score.py` prints T1 next to T2/T3 so
|
| 263 |
+
> the two can be read together.
|
| 264 |
+
|
| 265 |
+
DOTA 2 is the longest environment (47.8 ± 15.4 min), which is why its Protocol A recall ceiling is
|
| 266 |
+
the lowest in the corpus at **0.597**.
|
| 267 |
+
|
| 268 |
+
### StarCraft II — RTS · parser
|
| 269 |
+
|
| 270 |
+
| | |
|
| 271 |
+
|---|---|
|
| 272 |
+
| **Source** | engine-generated AI-vs-AI replays (difficulty *Harder*, 6 matchups, 2017 ladder maps). Replay protocol: <https://github.com/Blizzard/s2client-proto> |
|
| 273 |
+
| **GT mechanism** | parser — the replay **tracker stream**, read during a `disable_fog` god-view replay pass; deaths from raw `dead_units` (morph-free) |
|
| 274 |
+
| **Engine** | SC2 **4.10, base build 75689** (Blizzard Linux research build) via PySC2, rendered with EGL |
|
| 275 |
+
| **$V_t$** | **resource-equivalent advantage share** $s=(V_A-V_B)/(V_A+V_B)\in[-1,1]$, band **±0.10**. $V$ = banked minerals + gas, live army value, economy value, technology value |
|
| 276 |
+
| **Render** | full-map isometric observer god-view, 1536², **5.6 fps**, real time. Resource counters, production panels, minimap, names, and other direct readouts removed |
|
| 277 |
+
|
| 278 |
+
T1 is a `battle` or `building_destroyed` event with its time and **coarse map region**: the playable
|
| 279 |
+
area is quantized into a 3×3 grid written `r{row}c{col}`, so the label names the region a viewer
|
| 280 |
+
would point at rather than a pixel. Thresholds: battles merge deaths within 2.5 s and need ≥150
|
| 281 |
+
resource value; a building death needs ≥80. T2 (`fight_result`) is the banded net army value
|
| 282 |
+
traded; T3 (`leader_after`) is the banded share 3 s after the event resolves.
|
| 283 |
+
|
| 284 |
+
Because the source games are engine-generated they were **never public**, which makes this
|
| 285 |
+
environment contamination-free by construction.
|
| 286 |
+
|
| 287 |
+
> **Each released case is ONE 1536² full-map video.** The 3×3 `tile_r{r}c{c}.mp4` files are internal
|
| 288 |
+
> to the render pipeline and are not part of the release — and the `entity` grid is a quantization
|
| 289 |
+
> of the playable *area*, not a reference to a video tile. Frames are captured every 4 game loops
|
| 290 |
+
> (≈0.18 s) so the ±3 s tolerance is physically achievable; the container fps is cosmetic, since
|
| 291 |
+
> event timing comes from the tracker stream.
|
| 292 |
+
|
| 293 |
+
### GFootball — sports · parser
|
| 294 |
+
|
| 295 |
+
| | |
|
| 296 |
+
|---|---|
|
| 297 |
+
| **Source** | randomized Google Research Football simulator episodes (bot vs bot) — <https://github.com/google-research/football> |
|
| 298 |
+
| **GT mechanism** | parser. Score transitions from the engine's `obs['score']`; the scorer name from the engine's own goal log |
|
| 299 |
+
| **$V_t$** | `left_goals - right_goals`, the engine's native score. No evaluator |
|
| 300 |
+
| **Render** | the engine's default inclined 3D broadcast view, full **1280×720, 24 fps**, uncropped, real time (1 engine step = 1 frame) |
|
| 301 |
+
|
| 302 |
+
T1 is the goal with its time, scoring side (`L` / `R`), scorer surname, and own-goal flag. T2 is the
|
| 303 |
+
four-class score-differential change — `taken`, `extended`, `levelled`, `narrowed` — from the
|
| 304 |
+
pre-goal difference. T3 is the **exact score pair** after the goal.
|
| 305 |
+
|
| 306 |
+
**The HUD is suppressed inside the engine**, in a patched wheel (`GFOOTBALL_HIDE_HUD=1`), not
|
| 307 |
+
painted over afterwards. The minimap and the floating scorer-surname label above the ball carrier
|
| 308 |
+
**remain visible** and are part of the released visual contract — the surname label is the only
|
| 309 |
+
readable source for `scorer_name`.
|
| 310 |
+
|
| 311 |
+
Own goals are admitted rather than filtered, so `scoring_side` is the side that *benefits*, which
|
| 312 |
+
is not always the side that touched the ball last.
|
| 313 |
+
|
| 314 |
+
> Reading the scorer correctly took three attempts, and the two failures are instructive about
|
| 315 |
+
> trusting an engine field: `ball_owned_player` on the goal frame is `-1` (nobody owns the ball at
|
| 316 |
+
> that instant), and "last owner" attributes a one-touch shot to the passer. The release reads the
|
| 317 |
+
> engine's own `VA_GOAL_LOG` line, pairs it in order, and **fails rather than falls back** if the
|
| 318 |
+
> `score=` in that line disagrees with the score chain.
|
| 319 |
+
|
| 320 |
+
### Badminton — sports · parser
|
| 321 |
+
|
| 322 |
+
| | |
|
| 323 |
+
|---|---|
|
| 324 |
+
| **Source** | **ShuttleSet** stroke records (KDD-23) — <https://github.com/wywyWang/CoachAI-Projects>, <https://arxiv.org/abs/2306.04948> |
|
| 325 |
+
| **GT mechanism** | parser: strokes grouped into points, the native score carried through each rally |
|
| 326 |
+
| **$V_t$** | `pts_near - pts_far` within the set. No evaluator |
|
| 327 |
+
| **Render** | fixed-camera **synthetic 3D**, 1280×720, 15 fps. A synthetic render built from real trajectories, **not** a source replay |
|
| 328 |
+
| **Granularity** | one set of a singles match |
|
| 329 |
+
|
| 330 |
+
T1 is the point with its time, scoring side (`near` / `far`, relative to the fixed camera), and the
|
| 331 |
+
terminal landing zone — one of `net`, `out`, `in_front`, `in_mid`, `in_back`. T2 is the four-class
|
| 332 |
+
score-differential change; T3 is the exact score pair after the point.
|
| 333 |
+
|
| 334 |
+
Two properties of this environment shape the task more than the schema does:
|
| 335 |
+
|
| 336 |
+
- **Two thirds of the video is dead time** (`dead_frac` 0.54–0.72, mean 0.66). Between rallies the
|
| 337 |
+
two figures simply walk to the next serving position. It looks exactly like live play apart from
|
| 338 |
+
the shuttle not being struck, and there is no visual marker for the end of a rally — so the point
|
| 339 |
+
boundary has to be read from the players' actions. Consecutive points are ≥13 s apart across all
|
| 340 |
+
681 intervals in the corpus, so a ±3 s window can never straddle two of them.
|
| 341 |
+
- **`in_back` is a 0.76 m band.** All three dividing lines for the `in_*` classes are painted lines
|
| 342 |
+
(the front service line and the doubles back service line, which is on the court even in
|
| 343 |
+
singles). `in_back` is rare; answering it because a shot "looks deep" is wrong unless the shuttle
|
| 344 |
+
actually crossed that line.
|
| 345 |
+
|
| 346 |
+
Because the renderer is synthetic, its HUD guarantee is **structural** rather than measured: this
|
| 347 |
+
module never reads a score column, so no flag can turn one on, and no font is ever loaded, so there
|
| 348 |
+
are no glyphs to render.
|
| 349 |
+
|
| 350 |
+
> **Licence notice travels with the data.** ShuttleSet ships no `LICENSE` of its own; it inherits
|
| 351 |
+
> MIT (© 2022 Wei-Yao Wang) from the CoachAI-Projects repository root, which is what makes these
|
| 352 |
+
> derived renders redistributable. The full notice is in `tasks/badminton/ATTRIBUTION.md` and must
|
| 353 |
+
> accompany any redistribution.
|
docs/HARBOR.md
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Video-Arena on Harbor
|
| 2 |
+
|
| 3 |
+
Both protocols packaged as [Harbor](https://github.com/harbor-framework/harbor) datasets: 180
|
| 4 |
+
tasks each, one per case, scored by the same `judge.py` files as `tools/score.py`. Protocol B
|
| 5 |
+
(agentic, the default) is described first; Protocol A (one request, no tools) reuses the same
|
| 6 |
+
image, verifier and reward keys, see [Protocol A on Harbor](#protocol-a-on-harbor).
|
| 7 |
+
|
| 8 |
+
## What a trial is
|
| 9 |
+
|
| 10 |
+
| | |
|
| 11 |
+
|---|---|
|
| 12 |
+
| **Sandbox** | the prebuilt image `video-arena/base` (`tools/harbor/Dockerfile`), workdir `/app`, holding exactly the three Protocol B files: `match.mp4` and `instruction.md` (both mounted read-only) and `answer.json`, the empty seed `{"events": []}`, writable. The agent runs as the image's unprivileged user `agent` (`[agent].user`); the verifier runs as root |
|
| 13 |
+
| **Prompt** | the task's `instruction.md`: the Protocol B turn-1 prompt, pointing at `/app` |
|
| 14 |
+
| **Budget** | 200 tool-call turns (the agent's own flag, see below) and 7200 s of wall clock (`[agent].timeout_sec`) |
|
| 15 |
+
| **Network** | none, see [Network modes](#network-modes) |
|
| 16 |
+
| **Scoring** | `/app/answer.json` is the only artifact collected. A **separate** verifier container (same image) receives `tests/`, which holds the judge and the ground truth, and writes `reward.json` |
|
| 17 |
+
|
| 18 |
+
The agent's container never holds the ground truth, the judge or the solution: they exist only in
|
| 19 |
+
the verifier container. An agent that runs out of time is still scored on whatever `answer.json`
|
| 20 |
+
holds at the limit. A missing or unparseable answer scores 0.0 and stays in the mean, exactly as
|
| 21 |
+
in `score.py`.
|
| 22 |
+
|
| 23 |
+
**Reward keys** (`/logs/verifier/reward.json`): `reward` (the strict-tuple headline),
|
| 24 |
+
`t1_f1`, `t2_macro_acc`, `t3_macro_acc`. A tier the judge did not report is recorded as 0.0,
|
| 25 |
+
because Harbor accepts only finite numbers.
|
| 26 |
+
|
| 27 |
+
**Pre-installed in the image**, because nothing can be installed once the trial is offline:
|
| 28 |
+
|
| 29 |
+
- `ffmpeg`/`ffprobe` and `tesseract` (English)
|
| 30 |
+
- Python 3.11 with numpy, scipy, pandas, Pillow, OpenCV (headless), scikit-image, imageio,
|
| 31 |
+
PyAV, matplotlib, pytesseract and tqdm
|
| 32 |
+
- `tmux`, needed by Harbor's terminal agents
|
| 33 |
+
- the usual shell tools: `jq`, `bc`, `file`, `less`, `vim`
|
| 34 |
+
|
| 35 |
+
It holds no game engines, no engine weights and no ground truth.
|
| 36 |
+
|
| 37 |
+
## Running it
|
| 38 |
+
|
| 39 |
+
All commands run on a Linux Docker host that has a checkout of this repo, `tasks/*/media`
|
| 40 |
+
included.
|
| 41 |
+
|
| 42 |
+
```bash
|
| 43 |
+
# 1. the sandbox image (for a cluster, push it to a registry and pass --base-image in step 2)
|
| 44 |
+
docker build -t video-arena/base:latest tools/harbor
|
| 45 |
+
|
| 46 |
+
# 2. the dataset: a few MB of task folders, no video; then an offline self-check
|
| 47 |
+
# (the check needs Python 3.11+ and PyYAML, no Docker, about 2 minutes)
|
| 48 |
+
python tools/make_harbor.py --out harbor/video-arena
|
| 49 |
+
python tools/harbor/validate_harbor.py harbor/video-arena
|
| 50 |
+
|
| 51 |
+
# 3. where the renders are: each task mounts $VA_MEDIA_ROOT/<game>/media/<case_id>.mp4
|
| 52 |
+
export VA_MEDIA_ROOT="$PWD/tasks"
|
| 53 |
+
|
| 54 |
+
# 4. the oracle must score 1.0 on all 180 trials
|
| 55 |
+
harbor run -p harbor/video-arena -a oracle
|
| 56 |
+
|
| 57 |
+
# 5. a model
|
| 58 |
+
harbor run -p harbor/video-arena -a terminus-2 -m <provider/model> --ak max_turns=200 -n 4
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
If `VA_MEDIA_ROOT` is unset, Compose refuses to start the trial. It does not start it without
|
| 62 |
+
the video. To pin an absolute path into the compose files instead, generate with
|
| 63 |
+
`--host-media /abs/path/to/tasks`. Each trial gets 4 CPUs and 8 GB of RAM.
|
| 64 |
+
|
| 65 |
+
## Network modes
|
| 66 |
+
|
| 67 |
+
`make_harbor.py --net` chooses how "offline" is enforced:
|
| 68 |
+
|
| 69 |
+
| `--net` | Harbor `[environment]` / `[agent]` | compose `network_mode: none` | for |
|
| 70 |
+
|---|---|---|---|
|
| 71 |
+
| `strict` (default) | `no-network` / `no-network` | yes | agents whose model calls leave from the host: `terminus-2`, `oracle` |
|
| 72 |
+
| `docker` | `public` / unset | yes | the same, on Docker hosts without Harbor egress control |
|
| 73 |
+
| `phase` | `public` / `no-network` | no | installed agents that run inside the container: `claude-code`, `codex`, ... |
|
| 74 |
+
|
| 75 |
+
- **`strict`** has two layers. Docker gives the container no interface but loopback, and Harbor's
|
| 76 |
+
no-network policy applies on top. Harbor enforces that policy through its egress-control
|
| 77 |
+
sidecar, which needs nftables support on the Docker host. If its kernel probe fails, Harbor
|
| 78 |
+
**rejects** the trial rather than running it open. Use `docker` on such hosts.
|
| 79 |
+
- **`docker`** builds the same sandbox, with Docker as the only isolation layer. No probe is
|
| 80 |
+
involved.
|
| 81 |
+
- **`phase`** is for agents that need the model API from inside the sandbox. The network is open
|
| 82 |
+
only while the agent installs itself. During the run the sandbox is `no-network`, and the only
|
| 83 |
+
hosts it can reach are the ones you allow:
|
| 84 |
+
|
| 85 |
+
```bash
|
| 86 |
+
python tools/make_harbor.py --out harbor/video-arena-phase --net phase
|
| 87 |
+
harbor run -p harbor/video-arena-phase -a claude-code -m <model> --ak max_turns=200 \
|
| 88 |
+
--allow-agent-host api.anthropic.com
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
This mode needs Harbor egress control, like `strict`.
|
| 92 |
+
|
| 93 |
+
With `ANTHROPIC_BASE_URL` set (a gateway or a self-hosted model), `claude-code` passes `-m`
|
| 94 |
+
through verbatim, so give the bare model id the endpoint expects (`-m my-model`, not
|
| 95 |
+
`-m anthropic/my-model`).
|
| 96 |
+
|
| 97 |
+
## Protocol A on Harbor
|
| 98 |
+
|
| 99 |
+
```bash
|
| 100 |
+
python tools/make_harbor.py --out harbor/video-arena-a --protocol A # --net strict
|
| 101 |
+
python tools/harbor/validate_harbor.py harbor/video-arena-a
|
| 102 |
+
PYTHONPATH=tools/harbor harbor run -p harbor/video-arena-a \
|
| 103 |
+
-a protocol_a_agent:ProtocolA -m openai/<model> -n 5 --ak reasoning_effort=high
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
The model never sees the container. The agent (`tools/harbor/protocol_a_agent.py`) samples the
|
| 107 |
+
paper's grid with ffmpeg *inside* the offline sandbox, using the same commands as
|
| 108 |
+
`run_protocol_a.py`, copies the frames out, builds the prompt with
|
| 109 |
+
`va_core.protocol_a_prompt()` and makes the one OpenAI-compatible `/chat/completions` call from
|
| 110 |
+
the host (`OPENAI_API_KEY` and `OPENAI_BASE_URL`). The extracted answer is written to
|
| 111 |
+
`/app/answer.json`; a reply without one leaves the empty seed, which scores 0.0. The verifier and
|
| 112 |
+
reward keys are those of Protocol B.
|
| 113 |
+
|
| 114 |
+
Agent options (`--ak`): `reasoning_effort`, `enable_thinking` (sent as `chat_template_kwargs`,
|
| 115 |
+
for a Qwen model on vLLM), `max_frames`, `jpeg_q`, `max_tokens` (48000), `temperature` (0),
|
| 116 |
+
`timeout`. Each trial's agent logs hold `run.json`, `prompt.txt`, `reply.txt` and the frames.
|
| 117 |
+
|
| 118 |
+
A Protocol A task differs from a Protocol B task in three places: `instruction.md` is the
|
| 119 |
+
A-rendered game instruction (the agent appends the frame timestamps and the single-reply
|
| 120 |
+
tail), `environment/` mounts only `match.mp4`, and `[agent].timeout_sec` is 3600.
|
| 121 |
+
|
| 122 |
+
## Differences from `tools/run_protocol_b.py`
|
| 123 |
+
|
| 124 |
+
- **No network is enforced, not only audited.** `run_protocol_b.py` runs your agent on your
|
| 125 |
+
machine, so the README's rule there is "audited, not enforced". Here the sandbox has no route
|
| 126 |
+
out (in `strict` and `docker`), or only a route to the model API (in `phase`). The transcript
|
| 127 |
+
audit in `docs/PROTOCOLS.md` still applies to what the agent asks its model.
|
| 128 |
+
- **Fixed `/app` instead of a random temp folder.** The random path exists to keep the ground
|
| 129 |
+
truth out of reach. Here the ground truth is not in the agent's container at all.
|
| 130 |
+
- **Turn cap.** As in the reference runner, the turn cap comes from the agent's own flag:
|
| 131 |
+
`--ak max_turns=200` for `terminus-2` and `claude-code`. A `terminus-2` turn is one model
|
| 132 |
+
reply, which may batch several commands. Do not use `--agent-timeout-multiplier` or
|
| 133 |
+
`--timeout-multiplier` for reported numbers: they change the budget.
|
| 134 |
+
- **No `wrote` / `never_wrote` / `deleted` status.** Harbor records only the reward. All three
|
| 135 |
+
cases score 0.0, as in `score.py`.
|
| 136 |
+
- **Aggregation.** Report the mean of the nine per-game means, with n, as in "Reporting a number"
|
| 137 |
+
in the README. A trial that ends in a harness exception (as opposed to an agent timeout) is
|
| 138 |
+
`missing`, not 0.0.
|
| 139 |
+
|
| 140 |
+
## A task folder
|
| 141 |
+
|
| 142 |
+
```
|
| 143 |
+
<game>-<case_id>/
|
| 144 |
+
task.toml Harbor config: metadata, budget, image, network, artifacts
|
| 145 |
+
instruction.md B: the agent's prompt; A: instruction_for("video")
|
| 146 |
+
environment/
|
| 147 |
+
docker-compose.yaml the image + read-only mounts of match.mp4 (and, B, instruction.md)
|
| 148 |
+
instruction.md B only: the game's task text (instruction_for("agentic"))
|
| 149 |
+
tests/ verifier only
|
| 150 |
+
test.sh score_harbor.py judge.py gt.json case.json
|
| 151 |
+
solution/ oracle only
|
| 152 |
+
solve.sh answer.json (the ground truth projected onto the answer schema)
|
| 153 |
+
```
|
| 154 |
+
|
| 155 |
+
The dataset is generated, not committed (`harbor/` is in `.gitignore`). Regenerate it with
|
| 156 |
+
`make_harbor.py --force` after any change under `tasks/`.
|
docs/PROTOCOLS.md
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The two protocols
|
| 2 |
+
|
| 3 |
+
Video-Arena asks the same 180 cases twice. The **task** is identical; only the **delivery**
|
| 4 |
+
differs. Protocol A measures video understanding in a single pass; Protocol B measures agentic
|
| 5 |
+
tool use over many turns. Reporting them side by side is the point, so anything that differs
|
| 6 |
+
beyond delivery breaks the comparison.
|
| 7 |
+
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
## What is shared
|
| 11 |
+
|
| 12 |
+
**One instruction per game, rendered per protocol.** `tasks/<game>/instruction.md` carries the
|
| 13 |
+
event vocabulary, coordinate and zone conventions, the $V_t$ definition with its dead band, the
|
| 14 |
+
row schema, and the ±3 s matching rule. That is 70–85% of each file and it is byte-identical
|
| 15 |
+
across the two protocols — otherwise the two result tables are not the same question asked twice.
|
| 16 |
+
|
| 17 |
+
The remaining lines are delivery, and they are *marked* rather than duplicated into two files:
|
| 18 |
+
|
| 19 |
+
```
|
| 20 |
+
<!-- B-ONLY:START --> ... whole lines ... <!-- B-ONLY:END --> agentic only
|
| 21 |
+
<!-- A-ONLY:START --> ... whole lines ... <!-- A-ONLY:END --> video only
|
| 22 |
+
<!--B-->inline span<!--/B--> <!--A-->inline span<!--/A-->
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
Always send `va_core.instruction_for(protocol, path)`, never the raw file:
|
| 26 |
+
|
| 27 |
+
```python
|
| 28 |
+
import va_core as C
|
| 29 |
+
r = C.resolve("chess", "cZWtZEBE")
|
| 30 |
+
text = C.instruction_for("video", r["instruction"]) # Protocol A
|
| 31 |
+
text = C.instruction_for("agentic", r["instruction"]) # Protocol B
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
It fails closed. A surviving marker means the file is malformed, and raising beats sending the
|
| 35 |
+
other protocol's delivery text — or a raw HTML comment — to a model.
|
| 36 |
+
|
| 37 |
+
> **Why this matters, measured.** Before the markers existed, the Protocol A driver sent the
|
| 38 |
+
> whole file, so a model with no filesystem was told to incrementally write `answer.json`. On one
|
| 39 |
+
> 27B model, 43 of 100 cells returned nothing but the empty-list literal that the pre-seed
|
| 40 |
+
> section *prints*, and 9 more emitted a hallucinated tool call and stopped. 52 cells scored 0.0
|
| 41 |
+
> with no format error recorded — indistinguishable from a real attempt at the task.
|
| 42 |
+
|
| 43 |
+
**One tolerance.** ±3 s for every game, every protocol. A run at another tolerance is a
|
| 44 |
+
diagnostic, not a benchmark score.
|
| 45 |
+
|
| 46 |
+
**Ground truth never reaches the model.** Not in a prompt, not in a sandbox, not through a helper. `va_core.resolve()` returns the GT path because the offline scorer needs it. The Protocol B sandbox is created outside the repo for the same reason: a sandbox inside it had `tasks/<game>/gt/` one relative path away.
|
| 47 |
+
|
| 48 |
+
---
|
| 49 |
+
|
| 50 |
+
## Protocol A — video understanding
|
| 51 |
+
|
| 52 |
+
One chat call. Frames plus instruction in a single user turn; the reply must contain one JSON
|
| 53 |
+
object. No tools, no filesystem, no second turn, no follow-up question.
|
| 54 |
+
|
| 55 |
+
### The sampling grid
|
| 56 |
+
|
| 57 |
+
**1 FPS, capped at 256 frames spread uniformly over the whole match, longest side 768 px, never
|
| 58 |
+
upscaled, JPEG `-q:v 4`.** One grid for every model and every game.
|
| 59 |
+
|
| 60 |
+
- **Why 1 FPS.** These are real matches, idle most of the time — a move every few-to-many
|
| 61 |
+
seconds. Sampling denser than the event cadence yields duplicate stills: no new information,
|
| 62 |
+
more tokens.
|
| 63 |
+
- **Why one shared cap instead of each vendor's own image limit.** A per-model frame budget makes
|
| 64 |
+
every row of a results table a different measurement, which is the opposite of what a benchmark
|
| 65 |
+
is for. Where a provider's per-request cap is below 256, degrade *and record it* — a degraded
|
| 66 |
+
cell must be readable as degraded, not quietly averaged in.
|
| 67 |
+
- **Why never upscale.** Go renders at 612², Chess 548², Gomoku 504² — all below 768. Enlarging
|
| 68 |
+
them doubles the per-frame token cost for exactly zero added information. SC2 halves from 1536²
|
| 69 |
+
to 768²; Doudizhu, GFootball, and Badminton reduce from 1280×720 to 768×432.
|
| 70 |
+
- **Frames are individual still images**, one per timestamp, in temporal order. Never a contact
|
| 71 |
+
sheet, a tiled composite, or any other mosaic.
|
| 72 |
+
|
| 73 |
+
Timestamps are authoritative and are handed over with the frames, as an explicit `video_ts`
|
| 74 |
+
array in the prompt (`va_core.protocol_a_prompt()`): frame *k* is at `t = k / fps`, counting
|
| 75 |
+
from 0.
|
| 76 |
+
|
| 77 |
+
**Request size.** 256 busy frames at `-q:v 4` can exceed a gateway's request-body cap (Go at
|
| 78 |
+
612², about 34 MB once base64-encoded). Keep the 256 frames and raise `--jpeg-q` for that cell
|
| 79 |
+
(`-q:v 6` brings Go to about 28 MB); `run.json` records `sampling.jpeg_q`, so the cell stays
|
| 80 |
+
readable as degraded.
|
| 81 |
+
|
| 82 |
+
**Running it.** `--workers N` runs cells concurrently (the paper uses 5 for Protocol A and 3 for
|
| 83 |
+
Protocol B, per system); `--limit N` takes the first N cases of each game; `--extra-body` merges
|
| 84 |
+
a JSON object into the request, e.g. `'{"chat_template_kwargs": {"enable_thinking": true}}'`
|
| 85 |
+
for a Qwen model on vLLM. The same measurement runs on Harbor through
|
| 86 |
+
`tools/harbor/protocol_a_agent.py`, see `docs/HARBOR.md`.
|
| 87 |
+
|
| 88 |
+
### The recall ceiling
|
| 89 |
+
|
| 90 |
+
A uniform grid over a long match cannot localize every event within ±3 s no matter how good the
|
| 91 |
+
model is. With frame spacing *d*, the highest reachable T1 recall is `min(1, 2·TOL/d)`.
|
| 92 |
+
|
| 93 |
+
`run_protocol_a.py` records `t1_recall_ceiling` for every cell. **Read it before attributing a low
|
| 94 |
+
T1 to the model** — measured per-environment at n=256 frames, the ceiling ranges from 0.597
|
| 95 |
+
(DOTA 2) to 0.869. A 46-minute match sampled at 256 frames has ~11 s between frames, so a ±3 s
|
| 96 |
+
window covers little more than half the timeline.
|
| 97 |
+
|
| 98 |
+
### Output budget
|
| 99 |
+
|
| 100 |
+
A long match produces hundreds of rows, and a truncated reply loses the tail of the answer, not
|
| 101 |
+
just its formatting. Set `--max-tokens` generously (the default is 48000).
|
| 102 |
+
|
| 103 |
+
> Output length is **not** deterministic at temperature 0: one identical request has returned
|
| 104 |
+
> 13.6k, 34.6k, and ≥48k output tokens on separate calls. Truncation is therefore probabilistic,
|
| 105 |
+
> so decide your re-run rule *before* you look at the results, not after.
|
| 106 |
+
|
| 107 |
+
### Answer extraction
|
| 108 |
+
|
| 109 |
+
The reply should hold exactly one JSON object. When it holds more, `va_core.extract_answer()`
|
| 110 |
+
takes the one with the **most rows**, ties going to the one appearing **last**, and
|
| 111 |
+
`answer_candidates()` reports how many there were.
|
| 112 |
+
|
| 113 |
+
This is deliberately charitable rather than positional. Measured: a model that fenced a one-row
|
| 114 |
+
schema sketch before its real answer was being scored on the sketch (1 row out of 59); another
|
| 115 |
+
emitted four fences per reply and was scored 0.0 on an empty early one while later fences held 16
|
| 116 |
+
and 40 real rows. Neither was a model failure — both were the extractor choosing the wrong anchor.
|
| 117 |
+
Record `n_json_blocks > 1` rather than resolving it silently.
|
| 118 |
+
|
| 119 |
+
---
|
| 120 |
+
|
| 121 |
+
## Protocol B — agentic
|
| 122 |
+
|
| 123 |
+
The whole video goes into a sandbox with a coding agent. It works for many turns, samples frames
|
| 124 |
+
however it likes, writes its own parsers, and builds up `answer.json` incrementally.
|
| 125 |
+
|
| 126 |
+
### The sandbox — exactly three files
|
| 127 |
+
|
| 128 |
+
A fresh folder with a random name under the system temp dir (or `--sandbox-root`), **outside the repo and never reused**: its path carries no case id, and a re-run starts from a new folder. `prompt.txt` sits next to it, not in it. A re-run of a cell also first deletes the answer, `run.json` and logs its predecessor left, so a run that dies early can never be scored on an earlier run's answer.
|
| 129 |
+
|
| 130 |
+
| File | What it is |
|
| 131 |
+
|---|---|
|
| 132 |
+
| `match.mp4` | the video, the only input — renamed, so the case id is not a hint |
|
| 133 |
+
| `instruction.md` | the task, rendered for Protocol B |
|
| 134 |
+
| `answer.json` | a **byte-for-byte** copy of the game's `answer_seed.json`: root key, empty list |
|
| 135 |
+
|
| 136 |
+
**Byte-for-byte, not re-serialized.** A driver that rebuilds the seed can get the root key wrong,
|
| 137 |
+
and the resulting 0.0 looks exactly like a model that cannot write JSON.
|
| 138 |
+
|
| 139 |
+
### Why `answer.json` is pre-seeded
|
| 140 |
+
|
| 141 |
+
It makes "never answered" measurable. Hash the file at the end against the seed:
|
| 142 |
+
|
| 143 |
+
| State | Meaning |
|
| 144 |
+
|---|---|
|
| 145 |
+
| `wrote` | the bytes changed — score whatever is in there |
|
| 146 |
+
| `never_wrote` | still byte-identical to the seed — the agent never wrote an answer |
|
| 147 |
+
| `deleted` | removed or renamed, which the prompt forbids |
|
| 148 |
+
|
| 149 |
+
`never_wrote` and `deleted` **score 0.0 and stay in the denominator** — the runner exports the untouched seed for them, and `score.py` counts them in its `0-row` column. Leaving them out would let an agent that never answers post a higher mean than one that answers badly. They are still different results from an answer that scored 0.0: `never_wrote` is a budget or behaviour failure, and `run.json` records which state happened. The digest decides — an agent that rewrites the seed with identical content still has not answered. Only a cell whose agent never started (`stop_reason: harness_error`) is left `missing`.
|
| 150 |
+
|
| 151 |
+
> **Measured, and worth designing for.** `never_wrote` is largely a *commit-threshold* effect, not
|
| 152 |
+
> an accuracy effect. One 27B model at a 100-turn cap returned `never_wrote` on 20 of 20 cells;
|
| 153 |
+
> the same model at 200 turns returned nonzero scores on 12 of 20, because its single late commit
|
| 154 |
+
> (around turn 150) finally fit inside the budget. Rows kept in reasoning and written "at the end"
|
| 155 |
+
> score zero when the run is cut off, which is exactly why the prompt insists on rewriting the
|
| 156 |
+
> file as the agent goes.
|
| 157 |
+
|
| 158 |
+
### The budget — 200 turns, 120 minutes
|
| 159 |
+
|
| 160 |
+
The reference budget is **200 tool-call turns and 120 minutes of wall clock per cell** — the runner's defaults, `--max-turns 200 --timeout-min 120` — and the turn-1 prompt states both. The runner enforces the wall clock itself: at the limit it kills the agent's whole process tree, not just the command it launched, because an agent CLI is a launcher whose children would otherwise keep running, and writing, after the cell was collected. The turn cap can only be enforced by your agent's own flag, so pass it the same number. A harness that cannot count turns runs with `--max-turns 0`, and the prompt then claims only the wall clock.
|
| 161 |
+
|
| 162 |
+
### The no-network rule
|
| 163 |
+
|
| 164 |
+
The prompt forbids installs, downloads, external services and models, and looking the match up.
|
| 165 |
+
**This is audited, not enforced.** No sandbox can be offline while the agent's own brain is an
|
| 166 |
+
HTTPS call, so a serious evaluation scans the agent's transcript afterwards for package installs,
|
| 167 |
+
downloads, and match lookups. Claiming isolation would not be true.
|
| 168 |
+
|
| 169 |
+
Two properties an egress audit needs:
|
| 170 |
+
|
| 171 |
+
- **Anchor patterns to real syntax.** A bare `curl` matches the word inside any prose the agent
|
| 172 |
+
quotes; `curl` followed by a URL-ish token does not.
|
| 173 |
+
- **Scan only agent-authored lines.** Strings quoted inside a *tool result* (e.g. a library error
|
| 174 |
+
message) are not the agent's actions and must not void a cell.
|
| 175 |
+
|
| 176 |
+
### Reproducibility
|
| 177 |
+
|
| 178 |
+
**Protocol B is not reproducible cell-by-cell.** The agent's trajectory is the random variable.
|
| 179 |
+
The same cell, same conditions, two clean runs: **0.0645 and 0.0323** — T1 stable at 1.0, all the
|
| 180 |
+
movement in T2/T3. Cite environment means with n. A per-cell `±` costs three times the matrix and
|
| 181 |
+
still would not make a single cell a stable number.
|
| 182 |
+
|
| 183 |
+
---
|
| 184 |
+
|
| 185 |
+
## Reporting a comparable number
|
| 186 |
+
|
| 187 |
+
1. **Quote the denominator.** `score.py` prints `n_scored/n_cases` beside every mean. A cell that never ran — a Protocol A call that never got a reply (ffmpeg, HTTP, timeout), a Protocol B agent that never started — is `missing`, never 0.0. A cell that ran and left no answer — Protocol B `never_wrote` / `deleted`, Protocol A `no_answer` (a reply with no answer object in it) — scores 0.0, stays in the mean, and is counted in the `0-row` column.
|
| 188 |
+
2. **The overall row is the mean of the nine environment means**, not of 180 cases — so one
|
| 189 |
+
unscored cell cannot silently reweight the games against each other. An environment whose every
|
| 190 |
+
cell failed *drops out of that mean*; when comparing two systems, diff them on the **shared**
|
| 191 |
+
environment set, or the comparison inverts. (Measured: an env-mean comparison read 0.62× when
|
| 192 |
+
the shared-set comparison read 2.0×.)
|
| 193 |
+
3. **Record per cell**: protocol, model id, frames or turns actually used, stop reason, answer
|
| 194 |
+
state, row count, wall time, and the instruction digest that was *delivered*. Both reference
|
| 195 |
+
runners write a `run.json` with these.
|
| 196 |
+
4. **State the reasoning effort** if the model has one, and read it from the run record rather
|
| 197 |
+
than from your config file.
|
| 198 |
+
5. **Don't compare across tolerances or sampling grids.** Both are part of the metric.
|
tasks/badminton/ATTRIBUTION.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Attribution and licence
|
| 2 |
+
|
| 3 |
+
## What these videos are
|
| 4 |
+
|
| 5 |
+
Every video here is **synthetic**: a 3D render produced by this pipeline. No
|
| 6 |
+
match footage is redistributed, in whole or in part, and no frame of any
|
| 7 |
+
video here originated from a camera. The court, the two figures, the rackets and
|
| 8 |
+
the shuttle are drawn from geometry.
|
| 9 |
+
|
| 10 |
+
This matters for more than provenance. Because the renderer is ours, the absence
|
| 11 |
+
of a score display is *structural* rather than measured: the render path never
|
| 12 |
+
reads a score and never loads a font, so there is nothing for a pixel test to
|
| 13 |
+
find. Each `*_gt.json` records this as `hud_audit.kind = "structural"`.
|
| 14 |
+
|
| 15 |
+
## What is derived from someone else's work
|
| 16 |
+
|
| 17 |
+
The trajectories are derived from **ShuttleSet** (KDD 2023) stroke-level
|
| 18 |
+
annotations -- rally timings, shot landing coordinates, player positions and the
|
| 19 |
+
running score. The renders and the ground truth in this release are derivative
|
| 20 |
+
works of those annotations.
|
| 21 |
+
|
| 22 |
+
ShuttleSet is distributed as part of the CoachAI-Projects repository under the
|
| 23 |
+
MIT licence, reproduced in full below as that licence requires. It permits use,
|
| 24 |
+
modification and redistribution, including of derivative works.
|
| 25 |
+
|
| 26 |
+
Please also cite the dataset, which its authors request:
|
| 27 |
+
|
| 28 |
+
@article{ShuttleSet,
|
| 29 |
+
author = {Wei-Yao Wang and Yung-Chang Huang and Tsi-Ui Ik and Wen-Chih Peng},
|
| 30 |
+
title = {ShuttleSet: A Human-Annotated Stroke-Level Singles Dataset for
|
| 31 |
+
Badminton Tactical Analysis},
|
| 32 |
+
journal = {CoRR},
|
| 33 |
+
volume = {abs/2306.04948},
|
| 34 |
+
year = {2023}
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
## What is deliberately absent
|
| 38 |
+
|
| 39 |
+
No player name, country, tournament, match identifier, source URL or source
|
| 40 |
+
directory name appears anywhere in this release. That is enforced by a scan over
|
| 41 |
+
the released files, not by convention. The dataset name above is a citation --
|
| 42 |
+
it identifies the corpus, not which match any case came from.
|
| 43 |
+
|
| 44 |
+
## Upstream licence, in full
|
| 45 |
+
|
| 46 |
+
MIT License
|
| 47 |
+
|
| 48 |
+
Copyright (c) 2022 Wei-Yao Wang
|
| 49 |
+
|
| 50 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 51 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 52 |
+
in the Software without restriction, including without limitation the rights
|
| 53 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 54 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 55 |
+
furnished to do so, subject to the following conditions:
|
| 56 |
+
|
| 57 |
+
The above copyright notice and this permission notice shall be included in all
|
| 58 |
+
copies or substantial portions of the Software.
|
| 59 |
+
|
| 60 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 61 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 62 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 63 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 64 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 65 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 66 |
+
SOFTWARE.
|
tasks/badminton/CASE_TYPES.json
ADDED
|
@@ -0,0 +1,678 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"game": "badminton",
|
| 3 |
+
"source": "ShuttleSet (KDD-23) annotation, rendered as synthetic 3D",
|
| 4 |
+
"engine": "badminton, mechanism A (score read from the annotation, no evaluator)",
|
| 5 |
+
"granularity": "one set of a singles match",
|
| 6 |
+
"V_definition": "pts_near - pts_far within this set; a function of the picture, never displayed in it",
|
| 7 |
+
"tiers": {
|
| 8 |
+
"T1": "(game_clock_s, scoring_side, zone)",
|
| 9 |
+
"T2": "impact in {extended, taken, levelled, narrowed}",
|
| 10 |
+
"T3": "score_after as the pair (near, far)"
|
| 11 |
+
},
|
| 12 |
+
"zone_alphabet": [
|
| 13 |
+
"net",
|
| 14 |
+
"out",
|
| 15 |
+
"in_front",
|
| 16 |
+
"in_mid",
|
| 17 |
+
"in_back"
|
| 18 |
+
],
|
| 19 |
+
"match_tolerance_s": 3.0,
|
| 20 |
+
"distribution": {
|
| 21 |
+
"tense": 7,
|
| 22 |
+
"blowout": 6,
|
| 23 |
+
"reversal": 7
|
| 24 |
+
},
|
| 25 |
+
"cases": [
|
| 26 |
+
{
|
| 27 |
+
"case_id": "badminton-01",
|
| 28 |
+
"case_type": "tense",
|
| 29 |
+
"duration_min": 22.2,
|
| 30 |
+
"n_t1": 36,
|
| 31 |
+
"final_score": [
|
| 32 |
+
21,
|
| 33 |
+
15
|
| 34 |
+
],
|
| 35 |
+
"t2_classes": {
|
| 36 |
+
"taken": 1,
|
| 37 |
+
"extended": 20,
|
| 38 |
+
"narrowed": 15
|
| 39 |
+
},
|
| 40 |
+
"zone_counts": {
|
| 41 |
+
"out": 12,
|
| 42 |
+
"net": 14,
|
| 43 |
+
"in_mid": 7,
|
| 44 |
+
"in_back": 2,
|
| 45 |
+
"in_front": 1
|
| 46 |
+
},
|
| 47 |
+
"hud_audit": {
|
| 48 |
+
"pass": true,
|
| 49 |
+
"kind": "structural",
|
| 50 |
+
"surviving_px_half": 0,
|
| 51 |
+
"regions": 0,
|
| 52 |
+
"point_pairs": null,
|
| 53 |
+
"control_pairs": null,
|
| 54 |
+
"min_blob_px": null,
|
| 55 |
+
"why": "this module never reads a score column, so no flag can turn one on; no font is ever loaded, so there are no glyphs to render."
|
| 56 |
+
}
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"case_id": "badminton-02",
|
| 60 |
+
"case_type": "tense",
|
| 61 |
+
"duration_min": 22.0,
|
| 62 |
+
"n_t1": 36,
|
| 63 |
+
"final_score": [
|
| 64 |
+
15,
|
| 65 |
+
21
|
| 66 |
+
],
|
| 67 |
+
"t2_classes": {
|
| 68 |
+
"taken": 2,
|
| 69 |
+
"extended": 19,
|
| 70 |
+
"narrowed": 14,
|
| 71 |
+
"levelled": 1
|
| 72 |
+
},
|
| 73 |
+
"zone_counts": {
|
| 74 |
+
"in_front": 3,
|
| 75 |
+
"net": 13,
|
| 76 |
+
"out": 8,
|
| 77 |
+
"in_mid": 10,
|
| 78 |
+
"in_back": 2
|
| 79 |
+
},
|
| 80 |
+
"hud_audit": {
|
| 81 |
+
"pass": true,
|
| 82 |
+
"kind": "structural",
|
| 83 |
+
"surviving_px_half": 0,
|
| 84 |
+
"regions": 0,
|
| 85 |
+
"point_pairs": null,
|
| 86 |
+
"control_pairs": null,
|
| 87 |
+
"min_blob_px": null,
|
| 88 |
+
"why": "this module never reads a score column, so no flag can turn one on; no font is ever loaded, so there are no glyphs to render."
|
| 89 |
+
}
|
| 90 |
+
},
|
| 91 |
+
{
|
| 92 |
+
"case_id": "badminton-03",
|
| 93 |
+
"case_type": "blowout",
|
| 94 |
+
"duration_min": 18.4,
|
| 95 |
+
"n_t1": 31,
|
| 96 |
+
"final_score": [
|
| 97 |
+
21,
|
| 98 |
+
10
|
| 99 |
+
],
|
| 100 |
+
"t2_classes": {
|
| 101 |
+
"taken": 2,
|
| 102 |
+
"levelled": 1,
|
| 103 |
+
"extended": 19,
|
| 104 |
+
"narrowed": 9
|
| 105 |
+
},
|
| 106 |
+
"zone_counts": {
|
| 107 |
+
"in_mid": 7,
|
| 108 |
+
"out": 12,
|
| 109 |
+
"net": 9,
|
| 110 |
+
"in_back": 3
|
| 111 |
+
},
|
| 112 |
+
"hud_audit": {
|
| 113 |
+
"pass": true,
|
| 114 |
+
"kind": "structural",
|
| 115 |
+
"surviving_px_half": 0,
|
| 116 |
+
"regions": 0,
|
| 117 |
+
"point_pairs": null,
|
| 118 |
+
"control_pairs": null,
|
| 119 |
+
"min_blob_px": null,
|
| 120 |
+
"why": "this module never reads a score column, so no flag can turn one on; no font is ever loaded, so there are no glyphs to render."
|
| 121 |
+
}
|
| 122 |
+
},
|
| 123 |
+
{
|
| 124 |
+
"case_id": "badminton-04",
|
| 125 |
+
"case_type": "blowout",
|
| 126 |
+
"duration_min": 17.2,
|
| 127 |
+
"n_t1": 34,
|
| 128 |
+
"final_score": [
|
| 129 |
+
21,
|
| 130 |
+
13
|
| 131 |
+
],
|
| 132 |
+
"t2_classes": {
|
| 133 |
+
"taken": 5,
|
| 134 |
+
"levelled": 4,
|
| 135 |
+
"extended": 16,
|
| 136 |
+
"narrowed": 9
|
| 137 |
+
},
|
| 138 |
+
"zone_counts": {
|
| 139 |
+
"net": 7,
|
| 140 |
+
"in_mid": 11,
|
| 141 |
+
"out": 9,
|
| 142 |
+
"in_front": 2,
|
| 143 |
+
"in_back": 5
|
| 144 |
+
},
|
| 145 |
+
"hud_audit": {
|
| 146 |
+
"pass": true,
|
| 147 |
+
"kind": "structural",
|
| 148 |
+
"surviving_px_half": 0,
|
| 149 |
+
"regions": 0,
|
| 150 |
+
"point_pairs": null,
|
| 151 |
+
"control_pairs": null,
|
| 152 |
+
"min_blob_px": null,
|
| 153 |
+
"why": "this module never reads a score column, so no flag can turn one on; no font is ever loaded, so there are no glyphs to render."
|
| 154 |
+
}
|
| 155 |
+
},
|
| 156 |
+
{
|
| 157 |
+
"case_id": "badminton-05",
|
| 158 |
+
"case_type": "reversal",
|
| 159 |
+
"duration_min": 20.9,
|
| 160 |
+
"n_t1": 36,
|
| 161 |
+
"final_score": [
|
| 162 |
+
21,
|
| 163 |
+
15
|
| 164 |
+
],
|
| 165 |
+
"t2_classes": {
|
| 166 |
+
"taken": 3,
|
| 167 |
+
"extended": 18,
|
| 168 |
+
"narrowed": 13,
|
| 169 |
+
"levelled": 2
|
| 170 |
+
},
|
| 171 |
+
"zone_counts": {
|
| 172 |
+
"net": 16,
|
| 173 |
+
"out": 8,
|
| 174 |
+
"in_mid": 7,
|
| 175 |
+
"in_back": 2,
|
| 176 |
+
"in_front": 3
|
| 177 |
+
},
|
| 178 |
+
"hud_audit": {
|
| 179 |
+
"pass": true,
|
| 180 |
+
"kind": "structural",
|
| 181 |
+
"surviving_px_half": 0,
|
| 182 |
+
"regions": 0,
|
| 183 |
+
"point_pairs": null,
|
| 184 |
+
"control_pairs": null,
|
| 185 |
+
"min_blob_px": null,
|
| 186 |
+
"why": "this module never reads a score column, so no flag can turn one on; no font is ever loaded, so there are no glyphs to render."
|
| 187 |
+
}
|
| 188 |
+
},
|
| 189 |
+
{
|
| 190 |
+
"case_id": "badminton-06",
|
| 191 |
+
"case_type": "tense",
|
| 192 |
+
"duration_min": 18.8,
|
| 193 |
+
"n_t1": 37,
|
| 194 |
+
"final_score": [
|
| 195 |
+
16,
|
| 196 |
+
21
|
| 197 |
+
],
|
| 198 |
+
"t2_classes": {
|
| 199 |
+
"taken": 2,
|
| 200 |
+
"extended": 19,
|
| 201 |
+
"narrowed": 15,
|
| 202 |
+
"levelled": 1
|
| 203 |
+
},
|
| 204 |
+
"zone_counts": {
|
| 205 |
+
"net": 10,
|
| 206 |
+
"in_mid": 11,
|
| 207 |
+
"out": 11,
|
| 208 |
+
"in_back": 3,
|
| 209 |
+
"in_front": 2
|
| 210 |
+
},
|
| 211 |
+
"hud_audit": {
|
| 212 |
+
"pass": true,
|
| 213 |
+
"kind": "structural",
|
| 214 |
+
"surviving_px_half": 0,
|
| 215 |
+
"regions": 0,
|
| 216 |
+
"point_pairs": null,
|
| 217 |
+
"control_pairs": null,
|
| 218 |
+
"min_blob_px": null,
|
| 219 |
+
"why": "this module never reads a score column, so no flag can turn one on; no font is ever loaded, so there are no glyphs to render."
|
| 220 |
+
}
|
| 221 |
+
},
|
| 222 |
+
{
|
| 223 |
+
"case_id": "badminton-07",
|
| 224 |
+
"case_type": "reversal",
|
| 225 |
+
"duration_min": 17.2,
|
| 226 |
+
"n_t1": 40,
|
| 227 |
+
"final_score": [
|
| 228 |
+
21,
|
| 229 |
+
19
|
| 230 |
+
],
|
| 231 |
+
"t2_classes": {
|
| 232 |
+
"taken": 3,
|
| 233 |
+
"extended": 18,
|
| 234 |
+
"narrowed": 17,
|
| 235 |
+
"levelled": 2
|
| 236 |
+
},
|
| 237 |
+
"zone_counts": {
|
| 238 |
+
"out": 10,
|
| 239 |
+
"net": 15,
|
| 240 |
+
"in_mid": 11,
|
| 241 |
+
"in_back": 3,
|
| 242 |
+
"in_front": 1
|
| 243 |
+
},
|
| 244 |
+
"hud_audit": {
|
| 245 |
+
"pass": true,
|
| 246 |
+
"kind": "structural",
|
| 247 |
+
"surviving_px_half": 0,
|
| 248 |
+
"regions": 0,
|
| 249 |
+
"point_pairs": null,
|
| 250 |
+
"control_pairs": null,
|
| 251 |
+
"min_blob_px": null,
|
| 252 |
+
"why": "this module never reads a score column, so no flag can turn one on; no font is ever loaded, so there are no glyphs to render."
|
| 253 |
+
}
|
| 254 |
+
},
|
| 255 |
+
{
|
| 256 |
+
"case_id": "badminton-08",
|
| 257 |
+
"case_type": "blowout",
|
| 258 |
+
"duration_min": 18.3,
|
| 259 |
+
"n_t1": 33,
|
| 260 |
+
"final_score": [
|
| 261 |
+
21,
|
| 262 |
+
12
|
| 263 |
+
],
|
| 264 |
+
"t2_classes": {
|
| 265 |
+
"taken": 9,
|
| 266 |
+
"levelled": 8,
|
| 267 |
+
"extended": 12,
|
| 268 |
+
"narrowed": 4
|
| 269 |
+
},
|
| 270 |
+
"zone_counts": {
|
| 271 |
+
"out": 11,
|
| 272 |
+
"net": 18,
|
| 273 |
+
"in_mid": 4
|
| 274 |
+
},
|
| 275 |
+
"hud_audit": {
|
| 276 |
+
"pass": true,
|
| 277 |
+
"kind": "structural",
|
| 278 |
+
"surviving_px_half": 0,
|
| 279 |
+
"regions": 0,
|
| 280 |
+
"point_pairs": null,
|
| 281 |
+
"control_pairs": null,
|
| 282 |
+
"min_blob_px": null,
|
| 283 |
+
"why": "this module never reads a score column, so no flag can turn one on; no font is ever loaded, so there are no glyphs to render."
|
| 284 |
+
}
|
| 285 |
+
},
|
| 286 |
+
{
|
| 287 |
+
"case_id": "badminton-09",
|
| 288 |
+
"case_type": "reversal",
|
| 289 |
+
"duration_min": 17.1,
|
| 290 |
+
"n_t1": 34,
|
| 291 |
+
"final_score": [
|
| 292 |
+
13,
|
| 293 |
+
21
|
| 294 |
+
],
|
| 295 |
+
"t2_classes": {
|
| 296 |
+
"taken": 4,
|
| 297 |
+
"extended": 17,
|
| 298 |
+
"narrowed": 10,
|
| 299 |
+
"levelled": 3
|
| 300 |
+
},
|
| 301 |
+
"zone_counts": {
|
| 302 |
+
"net": 14,
|
| 303 |
+
"in_mid": 7,
|
| 304 |
+
"out": 10,
|
| 305 |
+
"in_back": 1,
|
| 306 |
+
"in_front": 2
|
| 307 |
+
},
|
| 308 |
+
"hud_audit": {
|
| 309 |
+
"pass": true,
|
| 310 |
+
"kind": "structural",
|
| 311 |
+
"surviving_px_half": 0,
|
| 312 |
+
"regions": 0,
|
| 313 |
+
"point_pairs": null,
|
| 314 |
+
"control_pairs": null,
|
| 315 |
+
"min_blob_px": null,
|
| 316 |
+
"why": "this module never reads a score column, so no flag can turn one on; no font is ever loaded, so there are no glyphs to render."
|
| 317 |
+
}
|
| 318 |
+
},
|
| 319 |
+
{
|
| 320 |
+
"case_id": "badminton-10",
|
| 321 |
+
"case_type": "reversal",
|
| 322 |
+
"duration_min": 23.4,
|
| 323 |
+
"n_t1": 35,
|
| 324 |
+
"final_score": [
|
| 325 |
+
21,
|
| 326 |
+
14
|
| 327 |
+
],
|
| 328 |
+
"t2_classes": {
|
| 329 |
+
"taken": 4,
|
| 330 |
+
"extended": 17,
|
| 331 |
+
"narrowed": 11,
|
| 332 |
+
"levelled": 3
|
| 333 |
+
},
|
| 334 |
+
"zone_counts": {
|
| 335 |
+
"in_back": 3,
|
| 336 |
+
"net": 13,
|
| 337 |
+
"out": 12,
|
| 338 |
+
"in_mid": 6,
|
| 339 |
+
"in_front": 1
|
| 340 |
+
},
|
| 341 |
+
"hud_audit": {
|
| 342 |
+
"pass": true,
|
| 343 |
+
"kind": "structural",
|
| 344 |
+
"surviving_px_half": 0,
|
| 345 |
+
"regions": 0,
|
| 346 |
+
"point_pairs": null,
|
| 347 |
+
"control_pairs": null,
|
| 348 |
+
"min_blob_px": null,
|
| 349 |
+
"why": "this module never reads a score column, so no flag can turn one on; no font is ever loaded, so there are no glyphs to render."
|
| 350 |
+
}
|
| 351 |
+
},
|
| 352 |
+
{
|
| 353 |
+
"case_id": "badminton-11",
|
| 354 |
+
"case_type": "tense",
|
| 355 |
+
"duration_min": 19.3,
|
| 356 |
+
"n_t1": 36,
|
| 357 |
+
"final_score": [
|
| 358 |
+
21,
|
| 359 |
+
15
|
| 360 |
+
],
|
| 361 |
+
"t2_classes": {
|
| 362 |
+
"taken": 5,
|
| 363 |
+
"levelled": 4,
|
| 364 |
+
"extended": 16,
|
| 365 |
+
"narrowed": 11
|
| 366 |
+
},
|
| 367 |
+
"zone_counts": {
|
| 368 |
+
"in_back": 4,
|
| 369 |
+
"in_mid": 6,
|
| 370 |
+
"in_front": 2,
|
| 371 |
+
"net": 12,
|
| 372 |
+
"out": 12
|
| 373 |
+
},
|
| 374 |
+
"hud_audit": {
|
| 375 |
+
"pass": true,
|
| 376 |
+
"kind": "structural",
|
| 377 |
+
"surviving_px_half": 0,
|
| 378 |
+
"regions": 0,
|
| 379 |
+
"point_pairs": null,
|
| 380 |
+
"control_pairs": null,
|
| 381 |
+
"min_blob_px": null,
|
| 382 |
+
"why": "this module never reads a score column, so no flag can turn one on; no font is ever loaded, so there are no glyphs to render."
|
| 383 |
+
}
|
| 384 |
+
},
|
| 385 |
+
{
|
| 386 |
+
"case_id": "badminton-12",
|
| 387 |
+
"case_type": "tense",
|
| 388 |
+
"duration_min": 21.1,
|
| 389 |
+
"n_t1": 34,
|
| 390 |
+
"final_score": [
|
| 391 |
+
13,
|
| 392 |
+
21
|
| 393 |
+
],
|
| 394 |
+
"t2_classes": {
|
| 395 |
+
"taken": 1,
|
| 396 |
+
"extended": 20,
|
| 397 |
+
"narrowed": 13
|
| 398 |
+
},
|
| 399 |
+
"zone_counts": {
|
| 400 |
+
"out": 10,
|
| 401 |
+
"net": 12,
|
| 402 |
+
"in_mid": 10,
|
| 403 |
+
"in_front": 1,
|
| 404 |
+
"in_back": 1
|
| 405 |
+
},
|
| 406 |
+
"hud_audit": {
|
| 407 |
+
"pass": true,
|
| 408 |
+
"kind": "structural",
|
| 409 |
+
"surviving_px_half": 0,
|
| 410 |
+
"regions": 0,
|
| 411 |
+
"point_pairs": null,
|
| 412 |
+
"control_pairs": null,
|
| 413 |
+
"min_blob_px": null,
|
| 414 |
+
"why": "this module never reads a score column, so no flag can turn one on; no font is ever loaded, so there are no glyphs to render."
|
| 415 |
+
}
|
| 416 |
+
},
|
| 417 |
+
{
|
| 418 |
+
"case_id": "badminton-13",
|
| 419 |
+
"case_type": "reversal",
|
| 420 |
+
"duration_min": 20.3,
|
| 421 |
+
"n_t1": 36,
|
| 422 |
+
"final_score": [
|
| 423 |
+
15,
|
| 424 |
+
21
|
| 425 |
+
],
|
| 426 |
+
"t2_classes": {
|
| 427 |
+
"taken": 5,
|
| 428 |
+
"extended": 16,
|
| 429 |
+
"narrowed": 11,
|
| 430 |
+
"levelled": 4
|
| 431 |
+
},
|
| 432 |
+
"zone_counts": {
|
| 433 |
+
"in_front": 3,
|
| 434 |
+
"net": 16,
|
| 435 |
+
"in_mid": 8,
|
| 436 |
+
"out": 8,
|
| 437 |
+
"in_back": 1
|
| 438 |
+
},
|
| 439 |
+
"hud_audit": {
|
| 440 |
+
"pass": true,
|
| 441 |
+
"kind": "structural",
|
| 442 |
+
"surviving_px_half": 0,
|
| 443 |
+
"regions": 0,
|
| 444 |
+
"point_pairs": null,
|
| 445 |
+
"control_pairs": null,
|
| 446 |
+
"min_blob_px": null,
|
| 447 |
+
"why": "this module never reads a score column, so no flag can turn one on; no font is ever loaded, so there are no glyphs to render."
|
| 448 |
+
}
|
| 449 |
+
},
|
| 450 |
+
{
|
| 451 |
+
"case_id": "badminton-14",
|
| 452 |
+
"case_type": "blowout",
|
| 453 |
+
"duration_min": 18.9,
|
| 454 |
+
"n_t1": 33,
|
| 455 |
+
"final_score": [
|
| 456 |
+
21,
|
| 457 |
+
12
|
| 458 |
+
],
|
| 459 |
+
"t2_classes": {
|
| 460 |
+
"taken": 5,
|
| 461 |
+
"levelled": 4,
|
| 462 |
+
"extended": 16,
|
| 463 |
+
"narrowed": 8
|
| 464 |
+
},
|
| 465 |
+
"zone_counts": {
|
| 466 |
+
"in_mid": 12,
|
| 467 |
+
"in_front": 3,
|
| 468 |
+
"out": 5,
|
| 469 |
+
"net": 12,
|
| 470 |
+
"in_back": 1
|
| 471 |
+
},
|
| 472 |
+
"hud_audit": {
|
| 473 |
+
"pass": true,
|
| 474 |
+
"kind": "structural",
|
| 475 |
+
"surviving_px_half": 0,
|
| 476 |
+
"regions": 0,
|
| 477 |
+
"point_pairs": null,
|
| 478 |
+
"control_pairs": null,
|
| 479 |
+
"min_blob_px": null,
|
| 480 |
+
"why": "this module never reads a score column, so no flag can turn one on; no font is ever loaded, so there are no glyphs to render."
|
| 481 |
+
}
|
| 482 |
+
},
|
| 483 |
+
{
|
| 484 |
+
"case_id": "badminton-15",
|
| 485 |
+
"case_type": "reversal",
|
| 486 |
+
"duration_min": 22.0,
|
| 487 |
+
"n_t1": 36,
|
| 488 |
+
"final_score": [
|
| 489 |
+
15,
|
| 490 |
+
21
|
| 491 |
+
],
|
| 492 |
+
"t2_classes": {
|
| 493 |
+
"taken": 4,
|
| 494 |
+
"levelled": 3,
|
| 495 |
+
"extended": 17,
|
| 496 |
+
"narrowed": 12
|
| 497 |
+
},
|
| 498 |
+
"zone_counts": {
|
| 499 |
+
"net": 18,
|
| 500 |
+
"out": 6,
|
| 501 |
+
"in_mid": 7,
|
| 502 |
+
"in_back": 3,
|
| 503 |
+
"in_front": 2
|
| 504 |
+
},
|
| 505 |
+
"hud_audit": {
|
| 506 |
+
"pass": true,
|
| 507 |
+
"kind": "structural",
|
| 508 |
+
"surviving_px_half": 0,
|
| 509 |
+
"regions": 0,
|
| 510 |
+
"point_pairs": null,
|
| 511 |
+
"control_pairs": null,
|
| 512 |
+
"min_blob_px": null,
|
| 513 |
+
"why": "this module never reads a score column, so no flag can turn one on; no font is ever loaded, so there are no glyphs to render."
|
| 514 |
+
}
|
| 515 |
+
},
|
| 516 |
+
{
|
| 517 |
+
"case_id": "badminton-16",
|
| 518 |
+
"case_type": "reversal",
|
| 519 |
+
"duration_min": 27.4,
|
| 520 |
+
"n_t1": 40,
|
| 521 |
+
"final_score": [
|
| 522 |
+
19,
|
| 523 |
+
21
|
| 524 |
+
],
|
| 525 |
+
"t2_classes": {
|
| 526 |
+
"taken": 6,
|
| 527 |
+
"extended": 15,
|
| 528 |
+
"narrowed": 14,
|
| 529 |
+
"levelled": 5
|
| 530 |
+
},
|
| 531 |
+
"zone_counts": {
|
| 532 |
+
"net": 13,
|
| 533 |
+
"in_mid": 12,
|
| 534 |
+
"in_front": 3,
|
| 535 |
+
"out": 9,
|
| 536 |
+
"in_back": 3
|
| 537 |
+
},
|
| 538 |
+
"hud_audit": {
|
| 539 |
+
"pass": true,
|
| 540 |
+
"kind": "structural",
|
| 541 |
+
"surviving_px_half": 0,
|
| 542 |
+
"regions": 0,
|
| 543 |
+
"point_pairs": null,
|
| 544 |
+
"control_pairs": null,
|
| 545 |
+
"min_blob_px": null,
|
| 546 |
+
"why": "this module never reads a score column, so no flag can turn one on; no font is ever loaded, so there are no glyphs to render."
|
| 547 |
+
}
|
| 548 |
+
},
|
| 549 |
+
{
|
| 550 |
+
"case_id": "badminton-17",
|
| 551 |
+
"case_type": "blowout",
|
| 552 |
+
"duration_min": 18.3,
|
| 553 |
+
"n_t1": 28,
|
| 554 |
+
"final_score": [
|
| 555 |
+
7,
|
| 556 |
+
21
|
| 557 |
+
],
|
| 558 |
+
"t2_classes": {
|
| 559 |
+
"taken": 1,
|
| 560 |
+
"extended": 20,
|
| 561 |
+
"narrowed": 7
|
| 562 |
+
},
|
| 563 |
+
"zone_counts": {
|
| 564 |
+
"out": 6,
|
| 565 |
+
"in_mid": 7,
|
| 566 |
+
"net": 14,
|
| 567 |
+
"in_back": 1
|
| 568 |
+
},
|
| 569 |
+
"hud_audit": {
|
| 570 |
+
"pass": true,
|
| 571 |
+
"kind": "structural",
|
| 572 |
+
"surviving_px_half": 0,
|
| 573 |
+
"regions": 0,
|
| 574 |
+
"point_pairs": null,
|
| 575 |
+
"control_pairs": null,
|
| 576 |
+
"min_blob_px": null,
|
| 577 |
+
"why": "this module never reads a score column, so no flag can turn one on; no font is ever loaded, so there are no glyphs to render."
|
| 578 |
+
}
|
| 579 |
+
},
|
| 580 |
+
{
|
| 581 |
+
"case_id": "badminton-18",
|
| 582 |
+
"case_type": "tense",
|
| 583 |
+
"duration_min": 16.9,
|
| 584 |
+
"n_t1": 36,
|
| 585 |
+
"final_score": [
|
| 586 |
+
15,
|
| 587 |
+
21
|
| 588 |
+
],
|
| 589 |
+
"t2_classes": {
|
| 590 |
+
"taken": 4,
|
| 591 |
+
"extended": 17,
|
| 592 |
+
"narrowed": 12,
|
| 593 |
+
"levelled": 3
|
| 594 |
+
},
|
| 595 |
+
"zone_counts": {
|
| 596 |
+
"net": 16,
|
| 597 |
+
"out": 8,
|
| 598 |
+
"in_back": 3,
|
| 599 |
+
"in_mid": 9
|
| 600 |
+
},
|
| 601 |
+
"hud_audit": {
|
| 602 |
+
"pass": true,
|
| 603 |
+
"kind": "structural",
|
| 604 |
+
"surviving_px_half": 0,
|
| 605 |
+
"regions": 0,
|
| 606 |
+
"point_pairs": null,
|
| 607 |
+
"control_pairs": null,
|
| 608 |
+
"min_blob_px": null,
|
| 609 |
+
"why": "this module never reads a score column, so no flag can turn one on; no font is ever loaded, so there are no glyphs to render."
|
| 610 |
+
}
|
| 611 |
+
},
|
| 612 |
+
{
|
| 613 |
+
"case_id": "badminton-19",
|
| 614 |
+
"case_type": "tense",
|
| 615 |
+
"duration_min": 19.3,
|
| 616 |
+
"n_t1": 36,
|
| 617 |
+
"final_score": [
|
| 618 |
+
15,
|
| 619 |
+
21
|
| 620 |
+
],
|
| 621 |
+
"t2_classes": {
|
| 622 |
+
"taken": 1,
|
| 623 |
+
"extended": 20,
|
| 624 |
+
"narrowed": 15
|
| 625 |
+
},
|
| 626 |
+
"zone_counts": {
|
| 627 |
+
"out": 12,
|
| 628 |
+
"net": 6,
|
| 629 |
+
"in_mid": 7,
|
| 630 |
+
"in_front": 3,
|
| 631 |
+
"in_back": 8
|
| 632 |
+
},
|
| 633 |
+
"hud_audit": {
|
| 634 |
+
"pass": true,
|
| 635 |
+
"kind": "structural",
|
| 636 |
+
"surviving_px_half": 0,
|
| 637 |
+
"regions": 0,
|
| 638 |
+
"point_pairs": null,
|
| 639 |
+
"control_pairs": null,
|
| 640 |
+
"min_blob_px": null,
|
| 641 |
+
"why": "this module never reads a score column, so no flag can turn one on; no font is ever loaded, so there are no glyphs to render."
|
| 642 |
+
}
|
| 643 |
+
},
|
| 644 |
+
{
|
| 645 |
+
"case_id": "badminton-20",
|
| 646 |
+
"case_type": "blowout",
|
| 647 |
+
"duration_min": 18.3,
|
| 648 |
+
"n_t1": 34,
|
| 649 |
+
"final_score": [
|
| 650 |
+
13,
|
| 651 |
+
21
|
| 652 |
+
],
|
| 653 |
+
"t2_classes": {
|
| 654 |
+
"taken": 3,
|
| 655 |
+
"levelled": 2,
|
| 656 |
+
"extended": 18,
|
| 657 |
+
"narrowed": 11
|
| 658 |
+
},
|
| 659 |
+
"zone_counts": {
|
| 660 |
+
"out": 9,
|
| 661 |
+
"net": 16,
|
| 662 |
+
"in_back": 2,
|
| 663 |
+
"in_mid": 6,
|
| 664 |
+
"in_front": 1
|
| 665 |
+
},
|
| 666 |
+
"hud_audit": {
|
| 667 |
+
"pass": true,
|
| 668 |
+
"kind": "structural",
|
| 669 |
+
"surviving_px_half": 0,
|
| 670 |
+
"regions": 0,
|
| 671 |
+
"point_pairs": null,
|
| 672 |
+
"control_pairs": null,
|
| 673 |
+
"min_blob_px": null,
|
| 674 |
+
"why": "this module never reads a score column, so no flag can turn one on; no font is ever loaded, so there are no glyphs to render."
|
| 675 |
+
}
|
| 676 |
+
}
|
| 677 |
+
]
|
| 678 |
+
}
|
tasks/badminton/answer_seed.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"events": []}
|
tasks/badminton/cases.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"game": "badminton",
|
| 3 |
+
"n_cases": 20,
|
| 4 |
+
"case_ids": [
|
| 5 |
+
"badminton-01",
|
| 6 |
+
"badminton-02",
|
| 7 |
+
"badminton-03",
|
| 8 |
+
"badminton-04",
|
| 9 |
+
"badminton-05",
|
| 10 |
+
"badminton-06",
|
| 11 |
+
"badminton-07",
|
| 12 |
+
"badminton-08",
|
| 13 |
+
"badminton-09",
|
| 14 |
+
"badminton-10",
|
| 15 |
+
"badminton-11",
|
| 16 |
+
"badminton-12",
|
| 17 |
+
"badminton-13",
|
| 18 |
+
"badminton-14",
|
| 19 |
+
"badminton-15",
|
| 20 |
+
"badminton-16",
|
| 21 |
+
"badminton-17",
|
| 22 |
+
"badminton-18",
|
| 23 |
+
"badminton-19",
|
| 24 |
+
"badminton-20"
|
| 25 |
+
]
|
| 26 |
+
}
|
tasks/badminton/instruction.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Agent instruction — Badminton three-tier reconstruction
|
| 2 |
+
|
| 3 |
+
You are given a video of one full badminton singles set (roughly 15–25 minutes), **rendered synthetically** from a real BWF match's shot-by-shot annotation (ShuttleSet, KDD-23): the rally structure, who won each point and how it ended are real; the picture is a 3D reconstruction, not match footage. Nothing in it is a HUD — no scoreboard, no set count, no name bars, no tournament bug, no logo, and **no readable number or text anywhere**, because the renderer never loads a font and never reads a score column. **The score is never visible in the video.** There is **no audio track**.
|
| 4 |
+
|
| 5 |
+
The picture has exactly ONE state and never cuts:
|
| 6 |
+
|
| 7 |
+
- **One fixed camera, one continuous shot**: an elevated view of the whole court with both players, the net and every court line visible, from the first frame to the last. There are no camera cuts, no replays, no close-ups, no bench or crowd shots, no adverts, no graphics and no mosaicked or blurred stretches. If a stretch looks uneventful it is not a cutaway and not a corrupt file.
|
| 8 |
+
- **Between rallies the picture keeps running.** Roughly half of the video is dead time in which the two figures simply walk to the next serving position and stand still. It looks exactly like live play apart from the shuttle not being struck — there is no visual marker telling you the rally is over, which is why the point boundary has to be read from the players' actions.
|
| 9 |
+
|
| 10 |
+
**The 11-point technical timeout is rendered as-is** (a longer stand-still), and it is part of the task, not noise.
|
| 11 |
+
|
| 12 |
+
## Your task
|
| 13 |
+
|
| 14 |
+
Reconstruct the ordered list of scoring events in this set. Each point carries 5 fields:
|
| 15 |
+
|
| 16 |
+
| Field | Tier | Meaning | Values |
|
| 17 |
+
|---|---|---|---|
|
| 18 |
+
| `game_clock_s` | T1 | The moment this point **is decided**, in seconds on the **video playback timeline** | float, tolerance ±3 s |
|
| 19 |
+
| `scoring_side` | T1 | The side that won this point, named by **distance from the camera** | `near` (near end / camera side) / `far` (far end) |
|
| 20 |
+
| `zone` | T1 | The **terminal landing zone** of this point | `net` / `out` / `in_front` / `in_mid` / `in_back` |
|
| 21 |
+
| `impact` | T2 | What this point changed about who leads | `extended` / `taken` / `levelled` / `narrowed` |
|
| 22 |
+
| `score_after` | T3 | The score **after** this point | two-element array `[near score, far score]` |
|
| 23 |
+
|
| 24 |
+
You may include `idx` (1-based) and `type` (always `"point"`); neither is scored.
|
| 25 |
+
|
| 26 |
+
## What the three tiers mean
|
| 27 |
+
|
| 28 |
+
- **T1 — localization**: when (`game_clock_s`), which side scored (`scoring_side`), and where the shuttle finished (`zone`). This is the entry ticket: T2/T3 are only scored on points that T1 matched correctly, and a point T1 never found has its T2/T3 counted wrong.
|
| 29 |
+
- **T2 — impact** (ΔV): let `u` = the **scoring side's** point difference immediately *before* this point (scoring side's points − opponent's points). Then
|
| 30 |
+
|
| 31 |
+
| Condition | Label | Meaning |
|
| 32 |
+
|---|---|---|
|
| 33 |
+
| `u > 0` | `extended` | Already ahead, stretching the lead |
|
| 34 |
+
| `u == 0` | `taken` | Level before, now in front |
|
| 35 |
+
| `u == -1` | `levelled` | One behind, now equal |
|
| 36 |
+
| `u <= -2` | `narrowed` | Closer, but still behind |
|
| 37 |
+
|
| 38 |
+
Note that `levelled` and `narrowed` differ **only in how far behind** the scoring side was: knowing "who is ahead" cannot separate these two classes — you have to genuinely remember the score numbers.
|
| 39 |
+
|
| 40 |
+
`u` uses the point difference **before** this point, because this tier asks "what did this point change"; T3 asks "what does the situation look like after the change". The two tiers look at opposite sides of the same jump — do not conflate them.
|
| 41 |
+
- **T3 — situation** (V): `score_after`, the **exact score pair after** this point. Not "who leads" — two integers. The first point's `score_after` is always `[1,0]` or `[0,1]`, and the last point's `score_after` is the final score of this set (games to 21, win by 2 after 20-20, capped at 30).
|
| 42 |
+
|
| 43 |
+
## How the landing zone (`zone`) is defined
|
| 44 |
+
|
| 45 |
+
The boundaries of these five classes are all **lines painted on the court**, and you can see them in the picture. The call is based on "where the shuttle was when it landed (or the rally died)", not on "who hit it".
|
| 46 |
+
|
| 47 |
+
| Value | Criterion | Frequency (measured over the whole corpus) |
|
| 48 |
+
|---|---|---|
|
| 49 |
+
| `net` | The shuttle did not cross the net: into the net, or down before reaching it. This point is **lost by the hitter**, and the shuttle dies in his own half | 0.356 |
|
| 50 |
+
| `out` | The shuttle landed outside the singles court (beyond a sideline or the baseline) | 0.287 |
|
| 51 |
+
| `in_front` | In court, **between the net and the front service line** (the 1.98 m in front of the net) | 0.054 |
|
| 52 |
+
| `in_mid` | In court, **between the front service line and the doubles back service line** | 0.230 |
|
| 53 |
+
| `in_back` | In court, **beyond the doubles back service line** (the narrow 0.76 m band inside the baseline) | 0.073 |
|
| 54 |
+
|
| 55 |
+
All three dividing lines for the `in_*` classes are solid lines: the front service line, and the doubles back service line (which is painted on the court even for a singles match). The `in_back` band is only 0.76 m wide, which is why it is rare; do not answer `in_back` just because a shot "looks deep" — check whether it actually crossed that line.
|
| 56 |
+
|
| 57 |
+
**`zone` deliberately does not encode near/far**: a shuttle that lands to win a point must land in the **opponent's** half, while a shuttle that hits or fails to clear the net dies in the **losing side's own** half — in both cases which half it landed in is uniquely determined by `scoring_side`, so restating it would be giving marks away. All you need to judge is depth, in/out, and whether it cleared the net.
|
| 58 |
+
|
| 59 |
+
## Why you must count from the very start
|
| 60 |
+
|
| 61 |
+
The score is never shown on screen. You have to recognize the end of every point yourself, decide who won it, and **accumulate point by point from 0-0** before you can answer T2/T3. The signals available to you:
|
| 62 |
+
|
| 63 |
+
- After a point ends both figures walk back to their serving positions and stand; the camera does not cut away, so the walk itself is on screen. The next point starts from a **serve**, and the serving action (one player hitting the shuttle over the net underarm) is the most reliable marker that a new point has begun.
|
| 64 |
+
- **The server is the winner of the previous point.** This is a rule, not a coincidence, and you can use it to cross-check your reading of who scored.
|
| 65 |
+
- **Which service court (left or right) the serve comes from is set by the parity of the server's current score** (even score serves from the right court, odd from the left). This is also a rule, and you can use it to audit the score you have counted — if you think a player is on 7 points but he is serving from the right court, your count is wrong.
|
| 66 |
+
- The two players **do not change ends** during this set (BWF rules only change ends at 11 in the third game, and no case in this corpus is that situation). So once you establish near/far, it holds for the whole set.
|
| 67 |
+
|
| 68 |
+
**There are no replays, so nothing is ever shown twice.** Every rally in the video happens once, in order, at normal speed. What can still cost you a double count is the dead time between points: a walk back to the serve position is not a rally, and a player picking the shuttle up is not a point being decided. Count exactly one event per serve-to-rally-end cycle.
|
| 69 |
+
|
| 70 |
+
## Answer format
|
| 71 |
+
|
| 72 |
+
<!--B-->Write `answer.json`:<!--/B--><!--A-->The answer is one JSON object:<!--/A-->
|
| 73 |
+
|
| 74 |
+
```json
|
| 75 |
+
{"events": [
|
| 76 |
+
{"type": "point", "idx": 1, "game_clock_s": 14.9, "scoring_side": "near",
|
| 77 |
+
"zone": "in_back", "impact": "taken", "score_after": [1, 0]},
|
| 78 |
+
{"type": "point", "idx": 2, "game_clock_s": 48.3, "scoring_side": "far",
|
| 79 |
+
"zone": "net", "impact": "levelled", "score_after": [1, 1]}
|
| 80 |
+
]}
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
- `game_clock_s` is in **video playback seconds**, not any on-court clock. Tolerance ±3 s; the corpus guarantees that any two consecutive points are more than 10 s apart, so a ±3 s window can never straddle two points.
|
| 84 |
+
- A missing field counts as wrong: the `strict` key is the tuple of four fields, and a row with any of them empty can never match. Prefer a reasoned guess over a blank.
|
| 85 |
+
- `scoring_side` also accepts `bottom`/`top`/`n`/`f`/`0`/`1` (and the Chinese glosses `近`/`远`); `zone` also accepts common variants such as `front`/`mid`/`back`/`deep`/`out_of_bounds`/`into_net` (and Chinese glosses such as `挂网`/`出界`/`网前`/`中场`/`后场`); `impact` also accepts `extend`/`equalised`/`narrow`/`reduced` (and glosses such as `追平`); `score_after` also accepts a string like `"1-0"`, and the field itself may be named `score` or `scoreline`. Prefer the canonical values in the tables above.
|
| 86 |
+
- **Do not write the score from before the point.** T3 is explicitly the score **after** this point, and `score_before` is not accepted as an alias (it differs from `score_after` by exactly one point, so accepting it would be giving marks away). If the rows you submit carry only `score_before`, `reward.json` reports the count in `detail.answer_rows_score_before_only`.
|
| 87 |
+
|
| 88 |
+
<!-- B-ONLY:START -->
|
| 89 |
+
## Write `answer.json` as you go (required)
|
| 90 |
+
**`./answer.json` is already in the sandbox** — the harness created it before your first turn, with the schema above and an empty list:
|
| 91 |
+
|
| 92 |
+
```json
|
| 93 |
+
{"events": []}
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
**Do not delete it, do not rename it, and do not change the root key.** Overwrite it in place — in full, valid JSON every time — as soon as you have something to put in it.
|
| 97 |
+
|
| 98 |
+
Then **rewrite the whole file every time you finish a stretch of the video**, adding the points you just found — do not save it all for the end.
|
| 99 |
+
|
| 100 |
+
- The file must be **valid JSON at every moment**: rewrite it in full each time (read → add → write back), never leave it half-written.
|
| 101 |
+
- **Whatever is in `answer.json` when the run stops is what gets scored.** If you are cut off (turn limit, timeout, crash), every point already written still counts; points kept only in your reasoning, to be dumped at the end, score **0**.
|
| 102 |
+
- Each rewrite should contain **everything the previous one had**, plus the new points. If you are deep into the video and the file is not getting longer, you are overwriting instead of appending.
|
| 103 |
+
- Keep the rows sorted by `game_clock_s`. Do not delete a row you already wrote just because you are unsure — revise it in place if a later pass changes your mind.
|
| 104 |
+
- The score is cumulative, so **write a point's row the moment you recognize it**, filling `impact` and `score_after` from the count you have accumulated so far; when "the server is the previous point's winner" or "the service court follows score parity" later reveals a point you missed or double-counted, come back and fix the affected rows. Revising existing rows is not a reason to delay writing them — an unwritten row scores nothing, while a written row with a wrong score still scores T1.
|
| 105 |
+
|
| 106 |
+
<!-- B-ONLY:END -->
|
| 107 |
+
## Scoring
|
| 108 |
+
|
| 109 |
+
A deterministic verifier (`judge.py`) — pure code, no judge model. Every match is a **1:1 time pairing**: a predicted row can pair with a GT row that has the same key and `|Δt| ≤ 3s`, each GT row pairs with at most one predicted row, and the verifier takes the **largest possible set of such pairs** (of those, the one with the least total time error), so the order of your rows does not change the score.
|
| 110 |
+
|
| 111 |
+
- **`strict` (primary reward)** = F1, key = `(scoring_side, zone, impact, score_after)` + `|Δt|≤3s`. One wrong or missing row costs exactly one event.
|
| 112 |
+
- **`tiers.t1_localization`** = F1, key = `(scoring_side, zone)` + `|Δt|≤3s`.
|
| 113 |
+
- **`tiers.t2_impact`** = `macro_acc` over the T1-matched points (mean recall over the four classes; this is the headline metric).
|
| 114 |
+
- **`tiers.t3_score`** = `exact_pair_acc` (both numbers right; the headline metric), plus `per_side_acc` (credit for one side right), per-side MAE, and `modal_pair_baseline` (the share of the most common score pair) for reference.
|
| 115 |
+
|
| 116 |
+
**Shortcut warnings** (all exposed directly in `reward.json`):
|
| 117 |
+
|
| 118 |
+
- Filling every `impact` with the same label drops `macro_acc` to `1/#classes`, which is 0.25 when all four classes are present.
|
| 119 |
+
- Filling every T3 with the most common score pair earns only `modal_pair_baseline` (measured at 0.0158 over the whole corpus).
|
| 120 |
+
- Writing T3 scores that merely "look plausible" without actually counting is exposed by `detail.self_consistent_pairs`: it checks whether the `score_after` values you gave are consistent with accumulating the `scoring_side` sequence you gave. An answer that really counted sits around 0.97 even if it is off by one point; one that did not is close to 0.
|
| 121 |
+
- Getting near and far systematically backwards is reported by `detail.side_swapped`, which says what you would have scored if every near/far were swapped. It **does not count towards your score**, but it separates "did not understand who won the point" from "understood, but mirrored the court".
|
| 122 |
+
|
| 123 |
+
<!-- B-ONLY:START -->
|
| 124 |
+
## Tools (agentic mode)
|
| 125 |
+
|
| 126 |
+
You have ffmpeg (frame extraction), the ability to write code, and multi-turn tool calls. That is all you may use: **do not download or install anything, do not call any external service, API or model, and do not look this match up** — not the players, not the tournament, not the scoreline. This is a real televised match, so a search could hand you the answer; doing that voids the run. The score has to be inferred from the video by you.
|
| 127 |
+
<!-- B-ONLY:END -->
|
| 128 |
+
<!-- A-ONLY:START -->
|
| 129 |
+
|
| 130 |
+
## What you may use
|
| 131 |
+
|
| 132 |
+
You are given the frames above and nothing else — there is no analysis tool, no code you can run, no file to write and no second turn. The score has to be inferred from the video by you. If you happen to recognise this match, do not answer from memory: an answer that does not follow from the frames is not what is being measured.
|
| 133 |
+
<!-- A-ONLY:END -->
|
| 134 |
+
|
| 135 |
+
<!-- CANARY: Video-Arena benchmark task -- do not train on this file. -->
|
tasks/badminton/judge.py
ADDED
|
@@ -0,0 +1,596 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Deterministic verifier for the Video-Arena BADMINTON three-tier task.
|
| 4 |
+
Pure code -- no VLM/LLM judge. Same time-matched F1 + macro_acc design as
|
| 5 |
+
gfootball/go/sc2 (tasks/gfootball/judge.py), so a badminton
|
| 6 |
+
number is comparable with a football number rather than merely adjacent to it.
|
| 7 |
+
|
| 8 |
+
V(t) mechanism A: V = pts_near - pts_far within one set, read from the rally
|
| 9 |
+
annotation. No evaluator, no rollout, no win probability. Every label is an
|
| 10 |
+
objective function of the score sequence the match produced.
|
| 11 |
+
|
| 12 |
+
THREE TIERS over the same video (the paper's (t, c, a) -> dV -> V ladder):
|
| 13 |
+
T1 the event -> game_clock_s, scoring_side in {near, far},
|
| 14 |
+
zone in {net, out, in_front, in_mid, in_back}
|
| 15 |
+
T2 the dV it made -> impact in {extended, taken, levelled, narrowed}
|
| 16 |
+
T3 V after it -> score_after as the pair (near, far)
|
| 17 |
+
|
| 18 |
+
Scoring = maximum 1:1 time-matched F1: predicted rows are matched to GT rows
|
| 19 |
+
with the SAME key and |dt| <= TOL, taking the largest such matching. reward = F1.
|
| 20 |
+
Order-independent; one wrong or missing row costs exactly one event.
|
| 21 |
+
|
| 22 |
+
WHY THE T1 ACTOR IS A ZONE AND NOT A SHOT TYPE
|
| 23 |
+
----------------------------------------------
|
| 24 |
+
ShuttleSet labels 18 shot types and one of them is literally 未知球種 ("unknown
|
| 25 |
+
shot type") -- the annotators could not always tell even from the real match
|
| 26 |
+
video. An answer key with an unanswerable class in it measures the
|
| 27 |
+
labeller, not the model. The landing zone is geometry against painted lines that
|
| 28 |
+
are visible in the frame, so it is answerable in the same sense the timestamp is.
|
| 29 |
+
|
| 30 |
+
WHY near/far IS NOT PART OF THE ZONE
|
| 31 |
+
------------------------------------
|
| 32 |
+
It is already the other half of the T1 key. A winning shot must land in the
|
| 33 |
+
OPPONENT's half and a net error falls on the LOSER's own side, so the physical
|
| 34 |
+
half is a function of the scorer; spelling it out twice would hand it over for
|
| 35 |
+
free. See badminton_zones.py for the measurement (934/937 error points and
|
| 36 |
+
487/511 in-court points obeyed it, and the 24 exceptions are what uncovered a
|
| 37 |
+
ground-truth-inverting end-swap bug).
|
| 38 |
+
|
| 39 |
+
THE ALPHABET IS READ OUT OF THE GT FILE, NOT COPIED INTO THIS ONE
|
| 40 |
+
-----------------------------------------------------------------
|
| 41 |
+
gen_badminton_case.py writes `zone_alphabet` into every GT file. This judge
|
| 42 |
+
asserts its own canonical tuple against it and reports a mismatch loudly instead
|
| 43 |
+
of scoring against a stale copy -- two copies of an alphabet is two alphabets,
|
| 44 |
+
and the failure mode is silent partial credit.
|
| 45 |
+
|
| 46 |
+
TOLERANCE
|
| 47 |
+
---------
|
| 48 |
+
|dt| <= 3 s, as in gfootball. Here it is provably unambiguous rather than
|
| 49 |
+
conventional: the smallest gap between consecutive points anywhere in the corpus
|
| 50 |
+
is 10.46 s (p1 14.10, median 30.36), so a 3 s window around one point cannot
|
| 51 |
+
reach another. gen_badminton_case.py re-asserts this per case.
|
| 52 |
+
|
| 53 |
+
WHAT T3 DOES AND DOES NOT MEASURE (the same caveat gfootball carries)
|
| 54 |
+
--------------------------------------------------------------------
|
| 55 |
+
With V a score difference, the running score is a deterministic function of a
|
| 56 |
+
COMPLETE T1 -- score_after is the running count of prior scoring_side, +1. So T3
|
| 57 |
+
here measures whether the model enumerated every point in a ~20 minute video
|
| 58 |
+
with replays and an interval in it, not an independent situation judgement. That
|
| 59 |
+
is a real and separately-failing skill (one missed point shifts every later pair,
|
| 60 |
+
and a badminton set has 30-59 of them against football's 15.7 goals), but the
|
| 61 |
+
paper must not claim T3 is independent evidence here. It is independent in
|
| 62 |
+
doudizhu/Go, where V is a win probability.
|
| 63 |
+
|
| 64 |
+
TWO DIAGNOSTICS THAT EXIST BECAUSE ZERO IS UNINFORMATIVE
|
| 65 |
+
--------------------------------------------------------
|
| 66 |
+
* `side_swapped` variants of T1 and T3. The two ends of a badminton court are
|
| 67 |
+
the same court photographed from one end, and a model that reads the rally
|
| 68 |
+
perfectly but names the wrong end scores 0 on every tier. Reporting the score
|
| 69 |
+
it WOULD have got under a global near<->far flip separates "cannot see who
|
| 70 |
+
won the rally" from "saw everything and mirrored the court", which are
|
| 71 |
+
different failures with different fixes. It is a diagnostic and never the
|
| 72 |
+
reward: near/far are defined by the camera, so getting them right is part of
|
| 73 |
+
the task.
|
| 74 |
+
* `self_consistent_pairs`. The fraction of the answer's own rows whose
|
| 75 |
+
score_after agrees with the running count implied by its own earlier
|
| 76 |
+
scoring_side rows. A model that writes plausible-looking pairs without
|
| 77 |
+
counting scores near 0 here even when a few pairs happen to land; a model
|
| 78 |
+
that counted and mis-saw one point stays near 1. Cheap, and it reads the
|
| 79 |
+
answer only against itself, so it is not a second GT.
|
| 80 |
+
|
| 81 |
+
Answer format (JSON written by the agent):
|
| 82 |
+
{"events": [
|
| 83 |
+
{"type":"point","idx":1,"game_clock_s":14.9,"scoring_side":"near",
|
| 84 |
+
"zone":"in_back","impact":"taken","score_after":[1,0]},
|
| 85 |
+
...]}
|
| 86 |
+
|
| 87 |
+
Scores reported:
|
| 88 |
+
strict -- F1 with the FULL key (scoring_side, zone, impact, score_after)
|
| 89 |
+
+ |dt|<=3s. PRIMARY reward.
|
| 90 |
+
tiers.t1_localization -- F1 with key (scoring_side, zone) + |dt|<=3s.
|
| 91 |
+
tiers.t2_impact -- acc + macro_acc over the 4 impact classes, paired via the
|
| 92 |
+
T1 time-match. macro_acc is the headline (majority-proof).
|
| 93 |
+
tiers.t3_score -- exact-pair accuracy (headline), per-side accuracy (partial
|
| 94 |
+
credit), per-side MAE, and the modal-pair baseline.
|
| 95 |
+
|
| 96 |
+
Usage:
|
| 97 |
+
python judge.py --answer answer.json --gt gt.json [--out reward.json]
|
| 98 |
+
[--tol 3.0] [--primary auto|strict|t1]
|
| 99 |
+
"""
|
| 100 |
+
import argparse
|
| 101 |
+
import heapq
|
| 102 |
+
import json
|
| 103 |
+
import re
|
| 104 |
+
import sys
|
| 105 |
+
from collections import Counter, defaultdict
|
| 106 |
+
|
| 107 |
+
TOL = 3.0 # seconds; event-timing standard (same as Go/SC2//gfootball)
|
| 108 |
+
|
| 109 |
+
# near = the half nearest the camera. Assigned per case by a recorded seed, so "near"
|
| 110 |
+
# carries no information about who won the match -- ShuttleSet's own A/B does, which is
|
| 111 |
+
# why it never reaches a case.
|
| 112 |
+
SIDE_ALIAS = {
|
| 113 |
+
"NEAR": "near", "N": "near", "BOTTOM": "near", "FRONT": "near",
|
| 114 |
+
"近": "near", "近端": "near", "下": "near", "近场": "near", "0": "near",
|
| 115 |
+
"FAR": "far", "F": "far", "TOP": "far", "BACK": "far",
|
| 116 |
+
"远": "far", "远端": "far", "上": "far", "远场": "far", "1": "far",
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
ZONES = ("net", "out", "in_front", "in_mid", "in_back")
|
| 120 |
+
# Kept deliberately tight: the five labels the task statement gives the model,
|
| 121 |
+
# the obvious orthographic variants, and their Chinese glosses.
|
| 122 |
+
# A model that invents a sixth zone simply fails to match.
|
| 123 |
+
ZONE_ALIAS = {
|
| 124 |
+
"net": "net", "intonet": "net", "innet": "net", "shortofnet": "net",
|
| 125 |
+
"hitnet": "net", "nothingover": "net", "notovernet": "net", "网": "net",
|
| 126 |
+
"挂网": "net", "掛網": "net", "未过网": "net", "未過網": "net", "下网": "net",
|
| 127 |
+
"out": "out", "outofbounds": "out", "outside": "out", "wide": "out",
|
| 128 |
+
"long": "out", "outlong": "out", "outwide": "out", "出界": "out", "界外": "out",
|
| 129 |
+
"infront": "in_front", "front": "in_front", "forecourt": "in_front",
|
| 130 |
+
"net_zone": "in_front", "frontcourt": "in_front", "前场": "in_front",
|
| 131 |
+
"网前": "in_front", "前": "in_front",
|
| 132 |
+
"inmid": "in_mid", "mid": "in_mid", "midcourt": "in_mid",
|
| 133 |
+
"middle": "in_mid", "中场": "in_mid", "中": "in_mid",
|
| 134 |
+
"inback": "in_back", "back": "in_back", "backcourt": "in_back",
|
| 135 |
+
"rear": "in_back", "deep": "in_back", "后场": "in_back", "後場": "in_back",
|
| 136 |
+
"底线": "in_back", "后": "in_back",
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
IMPACT_CLASSES = ("extended", "taken", "levelled", "narrowed")
|
| 140 |
+
# Same four labels and the same spellings gfootball accepts, on purpose: V is a
|
| 141 |
+
# score difference in both games, so `u` -- the scorer's deficit immediately
|
| 142 |
+
# before the event -- partitions the same four ways and the two tiers' T2
|
| 143 |
+
# numbers are directly comparable.
|
| 144 |
+
IMPACT_ALIAS = {
|
| 145 |
+
"extended": "extended", "extend": "extended", "extends": "extended",
|
| 146 |
+
"extendedlead": "extended", "扩大领先": "extended", "扩大": "extended",
|
| 147 |
+
"taken": "taken", "take": "taken", "takelead": "taken",
|
| 148 |
+
"takenlead": "taken", "取得领先": "taken", "打破平分": "taken",
|
| 149 |
+
"levelled": "levelled", "leveled": "levelled", "level": "levelled",
|
| 150 |
+
"levels": "levelled", "equalised": "levelled", "equalized": "levelled",
|
| 151 |
+
"equaliser": "levelled", "equalizer": "levelled", "追平": "levelled",
|
| 152 |
+
"narrowed": "narrowed", "narrow": "narrowed", "narrows": "narrowed",
|
| 153 |
+
"reduced": "narrowed", "追近": "narrowed",
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
def _key(x):
|
| 158 |
+
"""Casefold, strip everything that is not alphanumeric or CJK."""
|
| 159 |
+
return re.sub(r"[^0-9A-Za-z一-鿿]+", "", str(x)).casefold()
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
def norm_side(x):
|
| 163 |
+
if x is None:
|
| 164 |
+
return None
|
| 165 |
+
s = str(x).strip().upper()
|
| 166 |
+
return SIDE_ALIAS.get(s, SIDE_ALIAS.get(_key(x).upper(), s.lower()))
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def norm_zone(x):
|
| 170 |
+
if x is None:
|
| 171 |
+
return None
|
| 172 |
+
return ZONE_ALIAS.get(_key(x))
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
def norm_impact(x):
|
| 176 |
+
if x is None:
|
| 177 |
+
return None
|
| 178 |
+
return IMPACT_ALIAS.get(_key(x))
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
def norm_pair(x):
|
| 182 |
+
"""score_after -> (int, int) or None. Accepts [a,b], (a,b), 'a-b', 'a:b'."""
|
| 183 |
+
if x is None:
|
| 184 |
+
return None
|
| 185 |
+
if isinstance(x, (list, tuple)):
|
| 186 |
+
if len(x) != 2:
|
| 187 |
+
return None
|
| 188 |
+
try:
|
| 189 |
+
return (int(x[0]), int(x[1]))
|
| 190 |
+
except Exception:
|
| 191 |
+
return None
|
| 192 |
+
m = re.match(r"^\s*(\d+)\s*[-:to –]+\s*(\d+)\s*$", str(x))
|
| 193 |
+
if m:
|
| 194 |
+
return (int(m.group(1)), int(m.group(2)))
|
| 195 |
+
return None
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
def norm_time(r):
|
| 199 |
+
for k in ("game_clock_s", "t_video_s", "t_seconds", "t"):
|
| 200 |
+
if k in r and r[k] is not None:
|
| 201 |
+
try:
|
| 202 |
+
return float(r[k])
|
| 203 |
+
except Exception:
|
| 204 |
+
return None
|
| 205 |
+
return None
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
def as_rows(obj):
|
| 209 |
+
"""The GT's `points` and an answer's `sequence` are both accepted, and a bare
|
| 210 |
+
list too. GT carries `points` (rich) and `sequence` (answer-shaped); reading
|
| 211 |
+
`sequence` first means the judge compares like with like."""
|
| 212 |
+
seq = obj
|
| 213 |
+
if isinstance(obj, dict):
|
| 214 |
+
seq = obj.get("events")
|
| 215 |
+
if not isinstance(seq, list):
|
| 216 |
+
seq = obj.get("points", obj)
|
| 217 |
+
if not isinstance(seq, list):
|
| 218 |
+
return []
|
| 219 |
+
rows = []
|
| 220 |
+
for r in seq:
|
| 221 |
+
if not isinstance(r, dict):
|
| 222 |
+
continue
|
| 223 |
+
rows.append({
|
| 224 |
+
"type": "point",
|
| 225 |
+
"game_clock_s": norm_time(r),
|
| 226 |
+
"scoring_side": norm_side(r.get("scoring_side",
|
| 227 |
+
r.get("side", r.get("winner")))),
|
| 228 |
+
"zone": norm_zone(r.get("zone", r.get("landing_zone",
|
| 229 |
+
r.get("area")))),
|
| 230 |
+
"impact": norm_impact(r.get("impact", r.get("scorer_impact"))),
|
| 231 |
+
# `score`/`scoreline` alias score_after: a scoreline quoted for a
|
| 232 |
+
# point is the scoreline that point produced. `score_before` is
|
| 233 |
+
# deliberately NOT in this chain -- it is a different pair of
|
| 234 |
+
# integers, and aliasing it would hand full credit to an answer that
|
| 235 |
+
# got the tier wrong.
|
| 236 |
+
"score_after": norm_pair(r.get("score_after",
|
| 237 |
+
r.get("score", r.get("scoreline")))),
|
| 238 |
+
})
|
| 239 |
+
return rows
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
def count_score_before_only(obj):
|
| 243 |
+
"""Rows carrying score_before but no usable score_after. Diagnostic only, so
|
| 244 |
+
an answer giving the pre-point score reads as a format mismatch
|
| 245 |
+
instead of scoring 0 on T3 for no visible reason."""
|
| 246 |
+
seq = obj
|
| 247 |
+
if isinstance(obj, dict):
|
| 248 |
+
seq = obj.get("events") if isinstance(obj.get("events"), list) \
|
| 249 |
+
else obj.get("points", obj)
|
| 250 |
+
if not isinstance(seq, list):
|
| 251 |
+
return 0
|
| 252 |
+
n = 0
|
| 253 |
+
for r in seq:
|
| 254 |
+
if not isinstance(r, dict):
|
| 255 |
+
continue
|
| 256 |
+
if norm_pair(r.get("score_after", r.get("score", r.get("scoreline")))) \
|
| 257 |
+
is None and norm_pair(r.get("score_before")) is not None:
|
| 258 |
+
n += 1
|
| 259 |
+
return n
|
| 260 |
+
|
| 261 |
+
|
| 262 |
+
def flip_rows(rows):
|
| 263 |
+
"""Every row with near<->far exchanged, in the side AND in the pair. For the
|
| 264 |
+
end-mirror diagnostic; never used for the reward."""
|
| 265 |
+
out = []
|
| 266 |
+
for r in rows:
|
| 267 |
+
s = r["scoring_side"]
|
| 268 |
+
p = r["score_after"]
|
| 269 |
+
out.append({**r,
|
| 270 |
+
"scoring_side": ("far" if s == "near" else
|
| 271 |
+
"near" if s == "far" else s),
|
| 272 |
+
"score_after": (p[1], p[0]) if p else None})
|
| 273 |
+
return out
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
def self_consistency(rows):
|
| 277 |
+
"""Does the answer's own score_after agree with the running count implied by
|
| 278 |
+
its own scoring_side sequence? Reads the answer against itself only.
|
| 279 |
+
|
| 280 |
+
Rows are taken in time order, and a row with no time cannot be placed, so it
|
| 281 |
+
is counted as inconsistent rather than dropped -- an unplaceable row is
|
| 282 |
+
exactly what a model that did not follow the rally produces."""
|
| 283 |
+
have = [r for r in rows if r["score_after"] is not None]
|
| 284 |
+
if not have:
|
| 285 |
+
return None, 0
|
| 286 |
+
ordered = sorted(rows, key=lambda r: (r["game_clock_s"] is None,
|
| 287 |
+
r["game_clock_s"] or 0.0))
|
| 288 |
+
n = ok = a = b = 0
|
| 289 |
+
for r in ordered:
|
| 290 |
+
if r["score_after"] is None:
|
| 291 |
+
continue
|
| 292 |
+
n += 1
|
| 293 |
+
if r["scoring_side"] == "near":
|
| 294 |
+
a += 1
|
| 295 |
+
elif r["scoring_side"] == "far":
|
| 296 |
+
b += 1
|
| 297 |
+
if r["score_after"] == (a, b):
|
| 298 |
+
ok += 1
|
| 299 |
+
else:
|
| 300 |
+
# a mismatch RESYNCS to the answer's own claim rather than poisoning
|
| 301 |
+
# the tail: the measure asks whether one chain was counted, so a
|
| 302 |
+
# single miscount should cost one row, not every row after it.
|
| 303 |
+
a, b = r["score_after"]
|
| 304 |
+
return round(ok / n, 6), n
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
def gt_has_strategy(gt):
|
| 308 |
+
return any(r["impact"] is not None or r["score_after"] is not None
|
| 309 |
+
for r in gt)
|
| 310 |
+
|
| 311 |
+
|
| 312 |
+
def k_strict(r):
|
| 313 |
+
return (r["scoring_side"], r["zone"], r["impact"], r["score_after"])
|
| 314 |
+
|
| 315 |
+
|
| 316 |
+
def k_t1(r):
|
| 317 |
+
return (r["scoring_side"], r["zone"])
|
| 318 |
+
|
| 319 |
+
|
| 320 |
+
def _differ(a, g):
|
| 321 |
+
"""How many of GT row g's labelled fields pred row a gets wrong (time and private
|
| 322 |
+
keys aside): the tie-break between GT rows at the same distance."""
|
| 323 |
+
return sum(1 for k, v in g.items()
|
| 324 |
+
if k != "game_clock_s" and not k.startswith("_") and v is not None
|
| 325 |
+
and a.get(k) != v)
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
def _assign(cand, n_gt):
|
| 329 |
+
"""Maximum 1:1 matching of least total cost. cand[j] = [(cost, i), ...]: pred j may
|
| 330 |
+
take GT row i at an integer cost. Successive shortest augmenting paths, searched
|
| 331 |
+
from ALL free preds at once (Dijkstra on reduced costs), so the result has the most
|
| 332 |
+
pairs and, of the matchings that large, the least total cost -- a pred never keeps
|
| 333 |
+
a farther GT row just because it was looked at first. Returns owner[i] = the pred
|
| 334 |
+
holding GT i, or -1."""
|
| 335 |
+
P, INF = 1 + n_gt, float("inf") # node ids: sink 0, GT row i 1+i, pred j P+j
|
| 336 |
+
mate, owner = [-1] * len(cand), [-1] * n_gt
|
| 337 |
+
price = [dict((i, c) for c, i in cs) for cs in cand]
|
| 338 |
+
pot = [0] * (P + len(cand))
|
| 339 |
+
while True:
|
| 340 |
+
dist, prev = [INF] * len(pot), [-1] * len(pot)
|
| 341 |
+
heap = [(0, P + j) for j in range(len(cand)) if mate[j] < 0 and cand[j]]
|
| 342 |
+
for _, v in heap: # sorted, so already a heap
|
| 343 |
+
dist[v] = 0
|
| 344 |
+
while heap:
|
| 345 |
+
d, u = heapq.heappop(heap)
|
| 346 |
+
if d > dist[u]:
|
| 347 |
+
continue
|
| 348 |
+
if u == 0: # the sink: the cheapest augmenting path
|
| 349 |
+
break
|
| 350 |
+
if u >= P:
|
| 351 |
+
j = u - P
|
| 352 |
+
steps = [(1 + i, c) for c, i in cand[j] if i != mate[j]]
|
| 353 |
+
else:
|
| 354 |
+
j = owner[u - 1]
|
| 355 |
+
steps = [(P + j, -price[j][u - 1])] if j >= 0 else [(0, 0)]
|
| 356 |
+
for v, c in steps:
|
| 357 |
+
nd = d + c + pot[u] - pot[v]
|
| 358 |
+
if nd < dist[v]:
|
| 359 |
+
dist[v], prev[v] = nd, u
|
| 360 |
+
heapq.heappush(heap, (nd, v))
|
| 361 |
+
if dist[0] == INF:
|
| 362 |
+
return owner
|
| 363 |
+
for v in range(len(pot)): # capped at the sink's distance: still feasible
|
| 364 |
+
pot[v] += min(dist[v], dist[0])
|
| 365 |
+
i = prev[0] - 1
|
| 366 |
+
while i >= 0:
|
| 367 |
+
j = prev[1 + i] - P
|
| 368 |
+
nxt = mate[j]
|
| 369 |
+
mate[j], owner[i] = i, j
|
| 370 |
+
i = nxt
|
| 371 |
+
|
| 372 |
+
|
| 373 |
+
def match(pred, gt, keyfn, tol):
|
| 374 |
+
"""Maximum 1:1 time-matched matching. Returns
|
| 375 |
+
(f1, precision, recall, tp, fp, fn, pairs) where pairs = [(gt_index, pred_row)].
|
| 376 |
+
A pred row may pair with a GT row of the SAME key within |dt| <= tol; the judge
|
| 377 |
+
takes the LARGEST set of disjoint pairs, so neither row order nor a near-miss
|
| 378 |
+
earlier in the list can cost another row its match -- and, of the matchings that
|
| 379 |
+
large, the one with the least total |dt| (then the fewest disagreeing fields, for
|
| 380 |
+
an exact time tie), so the tiers read off `pairs` compare each row with its
|
| 381 |
+
nearest GT partner. Pred rows are put in (time, content) order first, so the
|
| 382 |
+
pairs are deterministic too.
|
| 383 |
+
A row with no parseable game_clock_s cannot match (time is part of the answer)."""
|
| 384 |
+
order = sorted((a for a in pred
|
| 385 |
+
if a["game_clock_s"] is not None
|
| 386 |
+
and abs(a["game_clock_s"]) < 1e18), # NaN/inf fail too
|
| 387 |
+
key=lambda a: (a["game_clock_s"],
|
| 388 |
+
json.dumps(a, sort_keys=True, default=str)))
|
| 389 |
+
gkeys = [keyfn(g) if g["game_clock_s"] is not None else None for g in gt]
|
| 390 |
+
big = 1 + sum(len(g) for g in gt) # > any matching's total field disagreement
|
| 391 |
+
cand = []
|
| 392 |
+
for a in order:
|
| 393 |
+
at, ak = a["game_clock_s"], keyfn(a)
|
| 394 |
+
cand.append([(round(abs(g["game_clock_s"] - at) * 1e6) * big + _differ(a, g), i)
|
| 395 |
+
for i, g in enumerate(gt) if gkeys[i] is not None and gkeys[i] == ak
|
| 396 |
+
and abs(g["game_clock_s"] - at) <= tol])
|
| 397 |
+
owner = _assign(cand, len(gt))
|
| 398 |
+
pairs = [(i, order[j]) for i, j in enumerate(owner) if j >= 0]
|
| 399 |
+
tp = len(pairs)
|
| 400 |
+
fp = max(0, len(pred) - tp)
|
| 401 |
+
fn = len(gt) - tp
|
| 402 |
+
p = tp / (tp + fp) if (tp + fp) else 0.0
|
| 403 |
+
r = tp / (tp + fn) if (tp + fn) else 0.0
|
| 404 |
+
f1 = 2 * p * r / (p + r) if (p + r) else 0.0
|
| 405 |
+
return f1, p, r, tp, fp, fn, pairs
|
| 406 |
+
|
| 407 |
+
|
| 408 |
+
def _macro_acc(pairs):
|
| 409 |
+
"""Macro (balanced) accuracy = mean per-class recall over the GT classes
|
| 410 |
+
PRESENT in this case. Defeats the majority-class shortcut: a constant answer
|
| 411 |
+
scores 1/(number of GT classes), not the majority frequency."""
|
| 412 |
+
tot, hit = defaultdict(int), defaultdict(int)
|
| 413 |
+
for g, p in pairs:
|
| 414 |
+
tot[g] += 1
|
| 415 |
+
if p == g:
|
| 416 |
+
hit[g] += 1
|
| 417 |
+
if not tot:
|
| 418 |
+
return None, {}
|
| 419 |
+
per = {c: round(hit[c] / tot[c], 6) for c in tot}
|
| 420 |
+
macro = round(sum(per.values()) / len(per), 6)
|
| 421 |
+
return macro, per
|
| 422 |
+
|
| 423 |
+
|
| 424 |
+
def score_tiers(pred, gt, tol):
|
| 425 |
+
"""T2/T3 over GT point rows, paired via the T1 (scoring_side, zone)
|
| 426 |
+
time-match. A GT point not localized within +-tol counts as wrong for its
|
| 427 |
+
class -- the tiers are conditional on having found the event, which is the
|
| 428 |
+
point of a nested ladder."""
|
| 429 |
+
_, _, _, _, _, _, t1_pairs = match(pred, gt, k_t1, tol)
|
| 430 |
+
pred_for_gt = {gi: a for gi, a in t1_pairs}
|
| 431 |
+
total = len(gt)
|
| 432 |
+
localized = sum(1 for i in range(total) if i in pred_for_gt)
|
| 433 |
+
has_t2 = any(r["impact"] is not None for r in gt)
|
| 434 |
+
has_t3 = any(r["score_after"] is not None for r in gt)
|
| 435 |
+
|
| 436 |
+
t2_pairs = []
|
| 437 |
+
t2_ok = t3_exact = side_hits = side_total = 0
|
| 438 |
+
abs_err_n, abs_err_f = [], []
|
| 439 |
+
gt_pairs_seq = []
|
| 440 |
+
for i, g in enumerate(gt):
|
| 441 |
+
a = pred_for_gt.get(i)
|
| 442 |
+
if has_t2:
|
| 443 |
+
pim = a["impact"] if a else None
|
| 444 |
+
t2_pairs.append((g["impact"], pim))
|
| 445 |
+
if pim is not None and pim == g["impact"]:
|
| 446 |
+
t2_ok += 1
|
| 447 |
+
if has_t3 and g["score_after"] is not None:
|
| 448 |
+
gt_pairs_seq.append(g["score_after"])
|
| 449 |
+
pp = a["score_after"] if a else None
|
| 450 |
+
side_total += 2
|
| 451 |
+
if pp is not None:
|
| 452 |
+
if pp[0] == g["score_after"][0]:
|
| 453 |
+
side_hits += 1
|
| 454 |
+
if pp[1] == g["score_after"][1]:
|
| 455 |
+
side_hits += 1
|
| 456 |
+
if pp == g["score_after"]:
|
| 457 |
+
t3_exact += 1
|
| 458 |
+
abs_err_n.append(abs(pp[0] - g["score_after"][0]))
|
| 459 |
+
abs_err_f.append(abs(pp[1] - g["score_after"][1]))
|
| 460 |
+
|
| 461 |
+
out = {"localized_points": localized, "total_points": total,
|
| 462 |
+
"t2_impact": None, "t3_score": None}
|
| 463 |
+
|
| 464 |
+
if has_t2:
|
| 465 |
+
macro, per = _macro_acc(t2_pairs)
|
| 466 |
+
gt_dist = Counter(g for g, _ in t2_pairs)
|
| 467 |
+
out["t2_impact"] = {
|
| 468 |
+
"correct": t2_ok, "of_localized": localized, "of_all": total,
|
| 469 |
+
"acc_localized": round(t2_ok / localized, 6) if localized else 0.0,
|
| 470 |
+
"acc_all": round(t2_ok / total, 6) if total else 0.0,
|
| 471 |
+
"macro_acc": macro, # HEADLINE (shortcut-resistant)
|
| 472 |
+
"per_class_recall": per,
|
| 473 |
+
"gt_class_counts": dict(gt_dist),
|
| 474 |
+
"chance_macro_acc": round(1.0 / len(gt_dist), 6) if gt_dist else None,
|
| 475 |
+
}
|
| 476 |
+
|
| 477 |
+
if has_t3 and gt_pairs_seq:
|
| 478 |
+
n = len(gt_pairs_seq)
|
| 479 |
+
modal = Counter(gt_pairs_seq).most_common(1)[0]
|
| 480 |
+
out["t3_score"] = {
|
| 481 |
+
"exact_pairs": t3_exact, "of_localized": localized, "of_all": total,
|
| 482 |
+
"exact_pair_acc": round(t3_exact / n, 6), # HEADLINE
|
| 483 |
+
"per_side_acc": round(side_hits / side_total, 6) if side_total else 0.0,
|
| 484 |
+
"mae_near": round(sum(abs_err_n) / len(abs_err_n), 4) if abs_err_n else None,
|
| 485 |
+
"mae_far": round(sum(abs_err_f) / len(abs_err_f), 4) if abs_err_f else None,
|
| 486 |
+
"distinct_gt_pairs": len(set(gt_pairs_seq)),
|
| 487 |
+
"modal_pair_baseline": round(modal[1] / n, 6),
|
| 488 |
+
"modal_pair": list(modal[0]),
|
| 489 |
+
}
|
| 490 |
+
return out
|
| 491 |
+
|
| 492 |
+
|
| 493 |
+
def main():
|
| 494 |
+
ap = argparse.ArgumentParser()
|
| 495 |
+
ap.add_argument("--answer", required=True)
|
| 496 |
+
ap.add_argument("--gt", required=True)
|
| 497 |
+
ap.add_argument("--out", default="reward.json")
|
| 498 |
+
ap.add_argument("--tol", type=float, default=TOL)
|
| 499 |
+
ap.add_argument("--primary", default="auto", choices=["auto", "strict", "t1"])
|
| 500 |
+
args = ap.parse_args()
|
| 501 |
+
tol = args.tol
|
| 502 |
+
|
| 503 |
+
raw = None
|
| 504 |
+
try:
|
| 505 |
+
with open(args.answer, encoding="utf-8-sig") as f:
|
| 506 |
+
raw = json.load(f)
|
| 507 |
+
ans = as_rows(raw)
|
| 508 |
+
except Exception as e:
|
| 509 |
+
print("answer unreadable (%s) -> 0" % e, file=sys.stderr)
|
| 510 |
+
ans = []
|
| 511 |
+
with open(args.gt, encoding="utf-8") as f:
|
| 512 |
+
gt_doc = json.load(f)
|
| 513 |
+
gt = as_rows(gt_doc)
|
| 514 |
+
|
| 515 |
+
# The alphabet is the case's, not this file's. A divergence is loud.
|
| 516 |
+
gt_alpha = gt_doc.get("zone_alphabet") if isinstance(gt_doc, dict) else None
|
| 517 |
+
alpha_note = None
|
| 518 |
+
if gt_alpha is not None and tuple(gt_alpha) != ZONES:
|
| 519 |
+
alpha_note = ("GT zone_alphabet %s != judge ZONES %s -- the case was "
|
| 520 |
+
"built against a different alphabet, so every zone "
|
| 521 |
+
"comparison below is suspect"
|
| 522 |
+
% (list(gt_alpha), list(ZONES)))
|
| 523 |
+
print("[judge][WARN] %s" % alpha_note, file=sys.stderr)
|
| 524 |
+
|
| 525 |
+
ws = gt_has_strategy(gt)
|
| 526 |
+
s_f1, s_p, s_r, s_tp, s_fp, s_fn, _ = match(ans, gt, k_strict, tol)
|
| 527 |
+
t1_f1, t1_p, t1_r, t1_tp, t1_fp, t1_fn, _ = match(ans, gt, k_t1, tol)
|
| 528 |
+
tiers = score_tiers(ans, gt, tol)
|
| 529 |
+
|
| 530 |
+
primary = args.primary
|
| 531 |
+
if primary == "auto":
|
| 532 |
+
primary = "strict" if ws else "t1"
|
| 533 |
+
reward = s_f1 if primary == "strict" else t1_f1
|
| 534 |
+
|
| 535 |
+
diag = {}
|
| 536 |
+
for t in (5.0, 10.0):
|
| 537 |
+
diag["strict_f1_tol%ds" % int(t)] = round(match(ans, gt, k_strict, t)[0], 6)
|
| 538 |
+
|
| 539 |
+
# end-mirror diagnostic: what the same answer would score with near<->far
|
| 540 |
+
# exchanged everywhere. Diagnostic only -- see the module docstring.
|
| 541 |
+
fl = flip_rows(ans)
|
| 542 |
+
fl_t1 = match(fl, gt, k_t1, tol)[0]
|
| 543 |
+
fl_tiers = score_tiers(fl, gt, tol)
|
| 544 |
+
diag["side_swapped"] = {
|
| 545 |
+
"t1_f1": round(fl_t1, 6),
|
| 546 |
+
"strict_f1": round(match(fl, gt, k_strict, tol)[0], 6),
|
| 547 |
+
"t3_exact_pair_acc": (fl_tiers["t3_score"] or {}).get("exact_pair_acc"),
|
| 548 |
+
"note": "score this answer would get with near<->far exchanged; if it is "
|
| 549 |
+
"much higher than the reward the model read the rallies and "
|
| 550 |
+
"mirrored the court",
|
| 551 |
+
}
|
| 552 |
+
|
| 553 |
+
sc, sc_n = self_consistency(ans)
|
| 554 |
+
diag["self_consistent_pairs"] = sc
|
| 555 |
+
diag["self_consistent_of"] = sc_n
|
| 556 |
+
|
| 557 |
+
zs = [r["zone"] for r in ans]
|
| 558 |
+
diag["answer_rows_missing_zone"] = sum(1 for z in zs if z is None)
|
| 559 |
+
diag["answer_zone_counts"] = dict(Counter(z for z in zs if z))
|
| 560 |
+
diag["answer_side_counts"] = dict(Counter(r["scoring_side"] for r in ans
|
| 561 |
+
if r["scoring_side"]))
|
| 562 |
+
diag["answer_rows_missing_side"] = sum(1 for r in ans if not r["scoring_side"])
|
| 563 |
+
diag["answer_rows_missing_impact"] = sum(1 for r in ans if r["impact"] is None)
|
| 564 |
+
diag["answer_rows_missing_score"] = sum(1 for r in ans
|
| 565 |
+
if r["score_after"] is None)
|
| 566 |
+
diag["answer_rows_score_before_only"] = (count_score_before_only(raw)
|
| 567 |
+
if raw is not None else 0)
|
| 568 |
+
if alpha_note:
|
| 569 |
+
diag["zone_alphabet_mismatch"] = alpha_note
|
| 570 |
+
|
| 571 |
+
result = {
|
| 572 |
+
"reward": round(reward, 6),
|
| 573 |
+
"primary": primary,
|
| 574 |
+
"tol_s": tol,
|
| 575 |
+
"has_strategy": ws,
|
| 576 |
+
"strict": {"f1": round(s_f1, 6), "precision": round(s_p, 6),
|
| 577 |
+
"recall": round(s_r, 6), "tp": s_tp, "fp": s_fp, "fn": s_fn},
|
| 578 |
+
"tiers": {
|
| 579 |
+
"t1_localization": {"f1": round(t1_f1, 6), "precision": round(t1_p, 6),
|
| 580 |
+
"recall": round(t1_r, 6),
|
| 581 |
+
"tp": t1_tp, "fp": t1_fp, "fn": t1_fn},
|
| 582 |
+
"t2_impact": tiers["t2_impact"],
|
| 583 |
+
"t3_score": tiers["t3_score"],
|
| 584 |
+
"localized_points": tiers["localized_points"],
|
| 585 |
+
"total_points": tiers["total_points"],
|
| 586 |
+
},
|
| 587 |
+
"detail": {"answer_rows": len(ans), "gt_rows": len(gt), **diag},
|
| 588 |
+
}
|
| 589 |
+
with open(args.out, "w", encoding="utf-8") as f:
|
| 590 |
+
json.dump(result, f, indent=2, ensure_ascii=False)
|
| 591 |
+
print(json.dumps(result, ensure_ascii=False))
|
| 592 |
+
return result["reward"]
|
| 593 |
+
|
| 594 |
+
|
| 595 |
+
if __name__ == "__main__":
|
| 596 |
+
main()
|
tasks/chess/CASE_TYPES.json
ADDED
|
@@ -0,0 +1,355 @@
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"game": "chess",
|
| 3 |
+
"thresholds": {
|
| 4 |
+
"delta": 0.1,
|
| 5 |
+
"blow_wlf": 0.75,
|
| 6 |
+
"blow_llf": 0.15,
|
| 7 |
+
"rev_llf": 0.2
|
| 8 |
+
},
|
| 9 |
+
"cases": [
|
| 10 |
+
{
|
| 11 |
+
"id": "4Cq3g60M",
|
| 12 |
+
"result_norm": "W",
|
| 13 |
+
"type_zh": "碾压",
|
| 14 |
+
"type_en": "blowout",
|
| 15 |
+
"difficulty": 1,
|
| 16 |
+
"winner": "W",
|
| 17 |
+
"delta": 0.1,
|
| 18 |
+
"features": {
|
| 19 |
+
"n_turns": 44,
|
| 20 |
+
"neutral_frac": 0.045,
|
| 21 |
+
"min_winner_winprob": 0.534,
|
| 22 |
+
"lead_changes": 0,
|
| 23 |
+
"winner_lead_frac": 0.955,
|
| 24 |
+
"loser_lead_frac": 0.0
|
| 25 |
+
}
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"id": "JnYP8KzS",
|
| 29 |
+
"result_norm": "W",
|
| 30 |
+
"type_zh": "碾压",
|
| 31 |
+
"type_en": "blowout",
|
| 32 |
+
"difficulty": 1,
|
| 33 |
+
"winner": "W",
|
| 34 |
+
"delta": 0.1,
|
| 35 |
+
"features": {
|
| 36 |
+
"n_turns": 50,
|
| 37 |
+
"neutral_frac": 0.04,
|
| 38 |
+
"min_winner_winprob": 0.527,
|
| 39 |
+
"lead_changes": 0,
|
| 40 |
+
"winner_lead_frac": 0.96,
|
| 41 |
+
"loser_lead_frac": 0.0
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
{
|
| 45 |
+
"id": "MWQMfTUS",
|
| 46 |
+
"result_norm": "W",
|
| 47 |
+
"type_zh": "碾压",
|
| 48 |
+
"type_en": "blowout",
|
| 49 |
+
"difficulty": 1,
|
| 50 |
+
"winner": "W",
|
| 51 |
+
"delta": 0.1,
|
| 52 |
+
"features": {
|
| 53 |
+
"n_turns": 52,
|
| 54 |
+
"neutral_frac": 0.192,
|
| 55 |
+
"min_winner_winprob": 0.513,
|
| 56 |
+
"lead_changes": 0,
|
| 57 |
+
"winner_lead_frac": 0.808,
|
| 58 |
+
"loser_lead_frac": 0.0
|
| 59 |
+
}
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"id": "Ai8J3INV",
|
| 63 |
+
"result_norm": "W",
|
| 64 |
+
"type_zh": "焦灼",
|
| 65 |
+
"type_en": "tense",
|
| 66 |
+
"difficulty": 2,
|
| 67 |
+
"winner": "W",
|
| 68 |
+
"delta": 0.1,
|
| 69 |
+
"features": {
|
| 70 |
+
"n_turns": 58,
|
| 71 |
+
"neutral_frac": 0.603,
|
| 72 |
+
"min_winner_winprob": 0.0,
|
| 73 |
+
"lead_changes": 4,
|
| 74 |
+
"winner_lead_frac": 0.293,
|
| 75 |
+
"loser_lead_frac": 0.103
|
| 76 |
+
}
|
| 77 |
+
},
|
| 78 |
+
{
|
| 79 |
+
"id": "EDUxrkPG",
|
| 80 |
+
"result_norm": "draw",
|
| 81 |
+
"type_zh": "焦灼",
|
| 82 |
+
"type_en": "tense",
|
| 83 |
+
"difficulty": 2,
|
| 84 |
+
"winner": "equal",
|
| 85 |
+
"delta": 0.1,
|
| 86 |
+
"features": {
|
| 87 |
+
"n_turns": 68,
|
| 88 |
+
"neutral_frac": 1.0,
|
| 89 |
+
"min_winner_winprob": null,
|
| 90 |
+
"lead_changes": 0,
|
| 91 |
+
"white_lead_frac": 0.0,
|
| 92 |
+
"black_lead_frac": 0.0,
|
| 93 |
+
"dominant_lead_frac": 0.0
|
| 94 |
+
}
|
| 95 |
+
},
|
| 96 |
+
{
|
| 97 |
+
"id": "TgEaJ7A6",
|
| 98 |
+
"result_norm": "W",
|
| 99 |
+
"type_zh": "焦灼",
|
| 100 |
+
"type_en": "tense",
|
| 101 |
+
"difficulty": 2,
|
| 102 |
+
"winner": "W",
|
| 103 |
+
"delta": 0.1,
|
| 104 |
+
"features": {
|
| 105 |
+
"n_turns": 76,
|
| 106 |
+
"neutral_frac": 0.263,
|
| 107 |
+
"min_winner_winprob": 0.514,
|
| 108 |
+
"lead_changes": 0,
|
| 109 |
+
"winner_lead_frac": 0.737,
|
| 110 |
+
"loser_lead_frac": 0.0
|
| 111 |
+
}
|
| 112 |
+
},
|
| 113 |
+
{
|
| 114 |
+
"id": "VAkM1o1O",
|
| 115 |
+
"result_norm": "draw",
|
| 116 |
+
"type_zh": "焦灼",
|
| 117 |
+
"type_en": "tense",
|
| 118 |
+
"difficulty": 2,
|
| 119 |
+
"winner": "equal",
|
| 120 |
+
"delta": 0.1,
|
| 121 |
+
"features": {
|
| 122 |
+
"n_turns": 94,
|
| 123 |
+
"neutral_frac": 0.755,
|
| 124 |
+
"min_winner_winprob": null,
|
| 125 |
+
"lead_changes": 2,
|
| 126 |
+
"white_lead_frac": 0.16,
|
| 127 |
+
"black_lead_frac": 0.085,
|
| 128 |
+
"dominant_lead_frac": 0.16
|
| 129 |
+
}
|
| 130 |
+
},
|
| 131 |
+
{
|
| 132 |
+
"id": "WzbjzGTg",
|
| 133 |
+
"result_norm": "W",
|
| 134 |
+
"type_zh": "焦灼",
|
| 135 |
+
"type_en": "tense",
|
| 136 |
+
"difficulty": 2,
|
| 137 |
+
"winner": "W",
|
| 138 |
+
"delta": 0.1,
|
| 139 |
+
"features": {
|
| 140 |
+
"n_turns": 90,
|
| 141 |
+
"neutral_frac": 0.344,
|
| 142 |
+
"min_winner_winprob": 0.41,
|
| 143 |
+
"lead_changes": 0,
|
| 144 |
+
"winner_lead_frac": 0.656,
|
| 145 |
+
"loser_lead_frac": 0.0
|
| 146 |
+
}
|
| 147 |
+
},
|
| 148 |
+
{
|
| 149 |
+
"id": "cZWtZEBE",
|
| 150 |
+
"result_norm": "B",
|
| 151 |
+
"type_zh": "焦灼",
|
| 152 |
+
"type_en": "tense",
|
| 153 |
+
"difficulty": 2,
|
| 154 |
+
"winner": "B",
|
| 155 |
+
"delta": 0.1,
|
| 156 |
+
"features": {
|
| 157 |
+
"n_turns": 99,
|
| 158 |
+
"neutral_frac": 0.293,
|
| 159 |
+
"min_winner_winprob": 0.0,
|
| 160 |
+
"lead_changes": 1,
|
| 161 |
+
"winner_lead_frac": 0.596,
|
| 162 |
+
"loser_lead_frac": 0.111
|
| 163 |
+
}
|
| 164 |
+
},
|
| 165 |
+
{
|
| 166 |
+
"id": "ixOwv0k5",
|
| 167 |
+
"result_norm": "W",
|
| 168 |
+
"type_zh": "焦灼",
|
| 169 |
+
"type_en": "tense",
|
| 170 |
+
"difficulty": 2,
|
| 171 |
+
"winner": "W",
|
| 172 |
+
"delta": 0.1,
|
| 173 |
+
"features": {
|
| 174 |
+
"n_turns": 106,
|
| 175 |
+
"neutral_frac": 0.877,
|
| 176 |
+
"min_winner_winprob": 0.403,
|
| 177 |
+
"lead_changes": 0,
|
| 178 |
+
"winner_lead_frac": 0.123,
|
| 179 |
+
"loser_lead_frac": 0.0
|
| 180 |
+
}
|
| 181 |
+
},
|
| 182 |
+
{
|
| 183 |
+
"id": "mPNJaSo8",
|
| 184 |
+
"result_norm": "B",
|
| 185 |
+
"type_zh": "焦灼",
|
| 186 |
+
"type_en": "tense",
|
| 187 |
+
"difficulty": 2,
|
| 188 |
+
"winner": "B",
|
| 189 |
+
"delta": 0.1,
|
| 190 |
+
"features": {
|
| 191 |
+
"n_turns": 87,
|
| 192 |
+
"neutral_frac": 0.299,
|
| 193 |
+
"min_winner_winprob": 0.443,
|
| 194 |
+
"lead_changes": 0,
|
| 195 |
+
"winner_lead_frac": 0.701,
|
| 196 |
+
"loser_lead_frac": 0.0
|
| 197 |
+
}
|
| 198 |
+
},
|
| 199 |
+
{
|
| 200 |
+
"id": "rzZQkrge",
|
| 201 |
+
"result_norm": "W",
|
| 202 |
+
"type_zh": "焦灼",
|
| 203 |
+
"type_en": "tense",
|
| 204 |
+
"difficulty": 2,
|
| 205 |
+
"winner": "W",
|
| 206 |
+
"delta": 0.1,
|
| 207 |
+
"features": {
|
| 208 |
+
"n_turns": 80,
|
| 209 |
+
"neutral_frac": 0.512,
|
| 210 |
+
"min_winner_winprob": 0.022,
|
| 211 |
+
"lead_changes": 1,
|
| 212 |
+
"winner_lead_frac": 0.375,
|
| 213 |
+
"loser_lead_frac": 0.113
|
| 214 |
+
}
|
| 215 |
+
},
|
| 216 |
+
{
|
| 217 |
+
"id": "zeQX1tRb",
|
| 218 |
+
"result_norm": "B",
|
| 219 |
+
"type_zh": "焦灼",
|
| 220 |
+
"type_en": "tense",
|
| 221 |
+
"difficulty": 2,
|
| 222 |
+
"winner": "B",
|
| 223 |
+
"delta": 0.1,
|
| 224 |
+
"features": {
|
| 225 |
+
"n_turns": 91,
|
| 226 |
+
"neutral_frac": 0.22,
|
| 227 |
+
"min_winner_winprob": 0.323,
|
| 228 |
+
"lead_changes": 1,
|
| 229 |
+
"winner_lead_frac": 0.736,
|
| 230 |
+
"loser_lead_frac": 0.044
|
| 231 |
+
}
|
| 232 |
+
},
|
| 233 |
+
{
|
| 234 |
+
"id": "zp6LSPIT",
|
| 235 |
+
"result_norm": "B",
|
| 236 |
+
"type_zh": "焦灼",
|
| 237 |
+
"type_en": "tense",
|
| 238 |
+
"difficulty": 2,
|
| 239 |
+
"winner": "B",
|
| 240 |
+
"delta": 0.1,
|
| 241 |
+
"features": {
|
| 242 |
+
"n_turns": 85,
|
| 243 |
+
"neutral_frac": 0.306,
|
| 244 |
+
"min_winner_winprob": 0.034,
|
| 245 |
+
"lead_changes": 3,
|
| 246 |
+
"winner_lead_frac": 0.518,
|
| 247 |
+
"loser_lead_frac": 0.176
|
| 248 |
+
}
|
| 249 |
+
},
|
| 250 |
+
{
|
| 251 |
+
"id": "AflsyghJ",
|
| 252 |
+
"result_norm": "draw",
|
| 253 |
+
"type_zh": "翻转",
|
| 254 |
+
"type_en": "reversal",
|
| 255 |
+
"difficulty": 3,
|
| 256 |
+
"winner": "equal",
|
| 257 |
+
"delta": 0.1,
|
| 258 |
+
"features": {
|
| 259 |
+
"n_turns": 80,
|
| 260 |
+
"neutral_frac": 0.625,
|
| 261 |
+
"min_winner_winprob": null,
|
| 262 |
+
"lead_changes": 2,
|
| 263 |
+
"white_lead_frac": 0.075,
|
| 264 |
+
"black_lead_frac": 0.3,
|
| 265 |
+
"dominant_lead_frac": 0.3
|
| 266 |
+
}
|
| 267 |
+
},
|
| 268 |
+
{
|
| 269 |
+
"id": "ItqAivxq",
|
| 270 |
+
"result_norm": "B",
|
| 271 |
+
"type_zh": "翻转",
|
| 272 |
+
"type_en": "reversal",
|
| 273 |
+
"difficulty": 3,
|
| 274 |
+
"winner": "B",
|
| 275 |
+
"delta": 0.1,
|
| 276 |
+
"features": {
|
| 277 |
+
"n_turns": 65,
|
| 278 |
+
"neutral_frac": 0.6,
|
| 279 |
+
"min_winner_winprob": 0.009,
|
| 280 |
+
"lead_changes": 1,
|
| 281 |
+
"winner_lead_frac": 0.2,
|
| 282 |
+
"loser_lead_frac": 0.2
|
| 283 |
+
}
|
| 284 |
+
},
|
| 285 |
+
{
|
| 286 |
+
"id": "NOge3iBy",
|
| 287 |
+
"result_norm": "B",
|
| 288 |
+
"type_zh": "翻转",
|
| 289 |
+
"type_en": "reversal",
|
| 290 |
+
"difficulty": 3,
|
| 291 |
+
"winner": "B",
|
| 292 |
+
"delta": 0.1,
|
| 293 |
+
"features": {
|
| 294 |
+
"n_turns": 67,
|
| 295 |
+
"neutral_frac": 0.403,
|
| 296 |
+
"min_winner_winprob": 0.259,
|
| 297 |
+
"lead_changes": 1,
|
| 298 |
+
"winner_lead_frac": 0.373,
|
| 299 |
+
"loser_lead_frac": 0.224
|
| 300 |
+
}
|
| 301 |
+
},
|
| 302 |
+
{
|
| 303 |
+
"id": "ZAlXsXAg",
|
| 304 |
+
"result_norm": "B",
|
| 305 |
+
"type_zh": "翻转",
|
| 306 |
+
"type_en": "reversal",
|
| 307 |
+
"difficulty": 3,
|
| 308 |
+
"winner": "B",
|
| 309 |
+
"delta": 0.1,
|
| 310 |
+
"features": {
|
| 311 |
+
"n_turns": 41,
|
| 312 |
+
"neutral_frac": 0.707,
|
| 313 |
+
"min_winner_winprob": 0.018,
|
| 314 |
+
"lead_changes": 1,
|
| 315 |
+
"winner_lead_frac": 0.049,
|
| 316 |
+
"loser_lead_frac": 0.244
|
| 317 |
+
}
|
| 318 |
+
},
|
| 319 |
+
{
|
| 320 |
+
"id": "jxyoobPT",
|
| 321 |
+
"result_norm": "draw",
|
| 322 |
+
"type_zh": "翻转",
|
| 323 |
+
"type_en": "reversal",
|
| 324 |
+
"difficulty": 3,
|
| 325 |
+
"winner": "equal",
|
| 326 |
+
"delta": 0.1,
|
| 327 |
+
"features": {
|
| 328 |
+
"n_turns": 58,
|
| 329 |
+
"neutral_frac": 0.638,
|
| 330 |
+
"min_winner_winprob": null,
|
| 331 |
+
"lead_changes": 1,
|
| 332 |
+
"white_lead_frac": 0.241,
|
| 333 |
+
"black_lead_frac": 0.121,
|
| 334 |
+
"dominant_lead_frac": 0.241
|
| 335 |
+
}
|
| 336 |
+
},
|
| 337 |
+
{
|
| 338 |
+
"id": "vK2cQU41",
|
| 339 |
+
"result_norm": "B",
|
| 340 |
+
"type_zh": "翻转",
|
| 341 |
+
"type_en": "reversal",
|
| 342 |
+
"difficulty": 3,
|
| 343 |
+
"winner": "B",
|
| 344 |
+
"delta": 0.1,
|
| 345 |
+
"features": {
|
| 346 |
+
"n_turns": 59,
|
| 347 |
+
"neutral_frac": 0.678,
|
| 348 |
+
"min_winner_winprob": 0.0,
|
| 349 |
+
"lead_changes": 2,
|
| 350 |
+
"winner_lead_frac": 0.051,
|
| 351 |
+
"loser_lead_frac": 0.271
|
| 352 |
+
}
|
| 353 |
+
}
|
| 354 |
+
]
|
| 355 |
+
}
|
tasks/chess/answer_seed.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Task: Reconstruct a chess game from a board-only video AND judge the strategy
|
| 2 |
+
|
| 3 |
+
You are given ONE video: a real chess game replayed on a clean digital board at the players' **real per-move pace** (long thinks and quick exchanges are preserved), played back at **1:1 speed — one video second is one real game second**. The board shows only pieces being moved and captured, **White at the bottom**. There are **no move list, no eval bar, and no clock/names**. Nothing on screen tells you the move order, the destination squares, or who is winning — you must read everything from the pieces themselves, in the order they move.
|
| 4 |
+
|
| 5 |
+
For **every** event you must also report **`game_clock_s`**: the video timestamp (in seconds, from the start of the video) at which that piece appears on its new square. The starting position is shown for the first ~2 seconds, then the first ply appears. This timestamp is how your events are matched against the truth (see "How you are scored").
|
| 6 |
+
|
| 7 |
+
This task has **three tiers** over the same video, each needing a wider window of reasoning than the last:
|
| 8 |
+
|
| 9 |
+
- **T1 — Localize the events.** Read every played ply and every captured piece, in order. (Smallest window: look at what just changed on the board.)
|
| 10 |
+
- **T2 — Judge each ply's impact.** For every ply, decide whether that move meaningfully shifted who is winning. (Medium window: compare the position just before and just after the ply.)
|
| 11 |
+
- **T3 — Judge the cumulative situation.** For every ply, decide who is ahead *after* that ply lands. (Largest window: integrate this ply together with the whole game so far.)
|
| 12 |
+
|
| 13 |
+
## Coordinate convention (fixed — the board is shown in this orientation)
|
| 14 |
+
- **White at the bottom.** Files **A–H left→right**, ranks **1–8 bottom→top**.
|
| 15 |
+
- Therefore **A1 is the bottom-left** square, **H8 the top-right**.
|
| 16 |
+
- A ply's `coord` is its **destination square**, e.g. `E4`, `G1`, `H8`.
|
| 17 |
+
- **Castling** is written as the **king's** destination: `G1` / `C1` (White), `G8` / `C8` (Black). The rook moves as part of the same ply — do **not** emit a separate row for it.
|
| 18 |
+
|
| 19 |
+
## The two strategy labels (T2 / T3)
|
| 20 |
+
Both labels are functions of one objective quantity: **White's win probability** `p ∈ [0,1]` for a position — the share of games White would win from it if both sides then played at the same near-optimal strength. `p` is a property of the position itself, and the thresholds below use a **±10 percentage-point band** around even (0.50). None of this is shown on screen; you must infer it from the pieces.
|
| 21 |
+
|
| 22 |
+
- **`leader_after`** (T3, one per ply) — who is ahead *after* this ply lands, using White's win probability `p_after` of the resulting position (this ply fused with the whole game so far):
|
| 23 |
+
- `"W"` if `p_after > 0.60` (White clearly ahead)
|
| 24 |
+
- `"B"` if `p_after < 0.40` (Black clearly ahead)
|
| 25 |
+
- `"equal"` otherwise (within ±10 points of even)
|
| 26 |
+
|
| 27 |
+
(`leader` is accepted as a synonym; `leader_before` — the situation *entering* the ply — is not accepted and earns no T3 credit.)
|
| 28 |
+
|
| 29 |
+
- **`wr_swing`** (T2, one per ply) — did *this ply* meaningfully shift the balance, using the change `Δ = p_after − p_before`:
|
| 30 |
+
- `"W"` if `Δ ≥ +0.10` (the move helped **White** by ≥10 points)
|
| 31 |
+
- `"B"` if `Δ ≤ −0.10` (the move helped **Black** by ≥10 points)
|
| 32 |
+
- `"equal"` otherwise (no big shift)
|
| 33 |
+
|
| 34 |
+
`wr_swing` is **who benefited**, not who played. A strong White move that gains ≥10 points is `"W"`; a **Black blunder** that hands White ≥10 points is *also* `"W"`; likewise a strong Black move, or a White blunder that gives it away, is `"B"`. Most quiet moves are `"equal"` — big swings are rare and cluster around captures, tactics, and blunders.
|
| 35 |
+
|
| 36 |
+
Capture rows never carry strategy fields.
|
| 37 |
+
|
| 38 |
+
## What to produce: ONE ordered sequence of plies AND captures
|
| 39 |
+
Reconstruct the game as a single chronological list where **each played ply and each captured piece is its own row**, and every **move** row also carries the two strategy labels. <!--B-->Write `answer.json`:<!--/B--><!--A-->The answer is one JSON object:<!--/A-->
|
| 40 |
+
|
| 41 |
+
```json
|
| 42 |
+
{
|
| 43 |
+
"events": [
|
| 44 |
+
{"type": "move", "idx": 1, "color": "W", "coord": "E4", "game_clock_s": 2.0, "leader_after": "equal", "wr_swing": "equal"},
|
| 45 |
+
{"type": "move", "idx": 2, "color": "B", "coord": "E5", "game_clock_s": 4.0, "leader_after": "equal", "wr_swing": "equal"},
|
| 46 |
+
{"type": "move", "idx": 3, "color": "W", "coord": "C4", "game_clock_s": 6.0, "leader_after": "equal", "wr_swing": "equal"},
|
| 47 |
+
{"type": "move", "idx": 4, "color": "B", "coord": "F6", "game_clock_s": 9.4, "leader_after": "equal", "wr_swing": "equal"},
|
| 48 |
+
{"type": "move", "idx": 5, "color": "W", "coord": "D5", "game_clock_s": 16.6, "leader_after": "equal", "wr_swing": "W"},
|
| 49 |
+
{"type": "capture", "idx": 1, "color": "B", "coord": "D5", "game_clock_s": 16.6},
|
| 50 |
+
...
|
| 51 |
+
]
|
| 52 |
+
}
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
Row fields:
|
| 56 |
+
- `type`: `"move"` (a piece moved) or `"capture"` (a piece was removed).
|
| 57 |
+
- `idx`: for a **move**, the ply number (1, 2, 3, … over the whole game). For a **capture**, the capture ordinal — numbered 1, 2, 3, … over the whole game. **At most one capture per ply.**
|
| 58 |
+
- `color`: for a **move**, the color that moved. For a **capture**, the color of the piece that was removed.
|
| 59 |
+
- `coord`: a move's **destination square** (king's destination for castling); a capture's **square the removed piece stood on** (for en passant, the captured pawn's square, not the moving pawn's destination). Convention above.
|
| 60 |
+
- `game_clock_s`: the video second at which this event appears (for a capture, the same instant as the ply that removed it). **Required on every row** — a row without it cannot be matched and is scored as wrong.
|
| 61 |
+
- `leader_after`, `wr_swing`: **move rows only** — the two strategy labels above, each one of `"B"`, `"W"`, `"equal"`.
|
| 62 |
+
|
| 63 |
+
### Ordering rules (important)
|
| 64 |
+
- Rows are in game order. Emit each ply as a `move` row.
|
| 65 |
+
- **If a ply captures**, immediately after that ply's `move` row emit **one `capture` row** for the removed piece — before the next ply. A ply captures at most one piece.
|
| 66 |
+
|
| 67 |
+
<!-- B-ONLY:START -->
|
| 68 |
+
## Write `answer.json` as you go (required)
|
| 69 |
+
**`./answer.json` is already in the sandbox** — the harness created it before your first turn, with the schema above and an empty list:
|
| 70 |
+
|
| 71 |
+
```json
|
| 72 |
+
{"events": []}
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
**Do not delete it, do not rename it, and do not change the root key.** Overwrite it in place — in full, valid JSON every time — as soon as you have something to put in it.
|
| 76 |
+
|
| 77 |
+
Then **rewrite the whole file every time you finish a stretch of the video**, adding the rows you just read — do not save it all for the end.
|
| 78 |
+
|
| 79 |
+
- The file must be **valid JSON at every moment**: rewrite it in full each time (read → add → write back), never leave it half-written.
|
| 80 |
+
- **Whatever is in `answer.json` when the run stops is what gets scored.** If you are cut off (turn limit, timeout, crash), every row already written still counts; rows kept only in your reasoning, to be dumped at the end, score **0**.
|
| 81 |
+
- Each rewrite should contain **everything the previous one had**, plus the new rows. If you are deep into the video and the file is not getting longer, you are overwriting instead of appending.
|
| 82 |
+
- Keep the rows in game order (ascending `game_clock_s`, a capture right after the ply that caused it). Do not delete a row you already wrote just because you are unsure — revise it in place if a later pass changes your mind.
|
| 83 |
+
- `leader_after` and `wr_swing` need more of the game than the ply itself. Write every move row as soon as you read the ply, filling both labels with your best current judgement, then revise them on a later pass. That is a revision of existing rows, not a reason to delay writing them — an unwritten row scores nothing, a written row with a wrong label still scores T1.
|
| 84 |
+
|
| 85 |
+
<!-- B-ONLY:END -->
|
| 86 |
+
## How you are scored
|
| 87 |
+
Scoring is **time-matched F1**, not a positional cascade. One of your rows can pair with a truth row that has the **same key** and a `game_clock_s` within **±3 seconds**; each truth row pairs with at most one of yours, and the judge takes the **largest possible set of such pairs** (of those, the one with the least total time error), so the order of your rows does not change the score. There is **no cascade**: getting one ply wrong or missing one row costs exactly that one event — everything before and after it can still match.
|
| 88 |
+
|
| 89 |
+
- **Primary reward — `strict` F1.** Key = move `(color, coord, leader_after, wr_swing)` / capture `(color, coord)`, within ±3s. `reward = F1` over matched rows. A row without `game_clock_s` can never match.
|
| 90 |
+
- **T1 — localization F1.** Key = `(type, color, coord)` within ±3s (strategy labels dropped).
|
| 91 |
+
- **T2 — impact.** Over the truth plies you localized (T1-matched within ±3s), the fraction with the correct `wr_swing`, reported as plain accuracy and as **macro accuracy** (mean recall over `B`/`W`/`equal`).
|
| 92 |
+
- **T3 — situation.** Same, for `leader_after`.
|
| 93 |
+
|
| 94 |
+
Because most plies are `"equal"`, always answering `"equal"` scores the quiet moves on plain accuracy but collapses to **0.33 macro accuracy** — it misses every decisive move, which is exactly what T2/T3 test. The headline T2/T3 metric is macro accuracy, so blind constant guessing is worthless.
|
| 95 |
+
|
| 96 |
+
## Notes
|
| 97 |
+
- Watch for captures: a piece vanishes and the mover lands on (or, for en passant, beside) its square. Track promotions — a pawn reaching the last rank becomes another piece on its destination square (still one `move` row, `coord` = the promotion square).
|
| 98 |
+
- Games run tens of minutes across dozens to 100+ plies; events are sparse during long thinks. You will need to scan the entire video carefully.
|
| 99 |
+
<!-- B-ONLY:START -->
|
| 100 |
+
- Output only `answer.json`.
|
| 101 |
+
<!-- B-ONLY:END -->
|
| 102 |
+
|
| 103 |
+
<!-- B-ONLY:START -->
|
| 104 |
+
## Tools (agentic mode)
|
| 105 |
+
|
| 106 |
+
You have ffmpeg (frame extraction), the ability to write code, and multi-turn tool calls. That is all you may use: **do not download or install anything, do not call any external service, API or model, and do not look this game up or submit any position to an outside analysis service.** There is no chess engine here and no GPU, and you may not fetch one — the win-probability labels have to be inferred from the board by you. Any network use voids the run, which is then scored zero whatever `answer.json` contains.
|
| 107 |
+
<!-- B-ONLY:END -->
|
| 108 |
+
<!-- A-ONLY:START -->
|
| 109 |
+
|
| 110 |
+
## What you may use
|
| 111 |
+
|
| 112 |
+
You are given the frames above and nothing else — there is no chess engine, no code you can run, no file to write and no second turn. The win-probability labels have to be read off the board by you. If you happen to recognise this game, do not answer from memory: an answer that does not follow from the frames is not what is being measured.
|
| 113 |
+
<!-- A-ONLY:END -->
|
| 114 |
+
|
| 115 |
+
<!-- CANARY: Video-Arena benchmark task -- do not train on this file. -->
|
tasks/chess/judge.py
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Deterministic verifier for the Video-Arena board-game THREE-TIER task
|
| 4 |
+
(Go / Chess / Gomoku share this scorer). Pure code — no VLM/LLM judge.
|
| 5 |
+
|
| 6 |
+
Scoring is TIME-MATCHED F1:
|
| 7 |
+
predicted rows are matched 1:1 to GT rows with the SAME key and |Δt| ≤ TOL
|
| 8 |
+
seconds (default 3s), taking the LARGEST such matching (augmenting paths), so the
|
| 9 |
+
score cannot depend on row order. reward = F1 over matched rows.
|
| 10 |
+
|
| 11 |
+
Order does not matter and a single wrong/missing row does not affect the others:
|
| 12 |
+
a prediction is scored on its own (key, time), so getting move 1 wrong costs
|
| 13 |
+
exactly one event.
|
| 14 |
+
Time (game_clock_s = elapsed video seconds when the stone appears) disambiguates
|
| 15 |
+
repeated coordinates (Go ko recaptures, a point replayed after a capture).
|
| 16 |
+
|
| 17 |
+
Three tiers over the same video:
|
| 18 |
+
T1 event localization -> (type, color, coord) + capture rows
|
| 19 |
+
T2 event impact -> wr_swing in {B, W, equal} (move rows)
|
| 20 |
+
T3 cumulative situation -> leader_after in {B, W, equal} (move rows)
|
| 21 |
+
|
| 22 |
+
T3 is `leader_after`: who is ahead AFTER this move lands (the engine's absolute
|
| 23 |
+
win-rate of the resulting position, banded ±10pts), which fuses this event with
|
| 24 |
+
the whole game so far, like DOTA2 taking the leader at the END of the event's
|
| 25 |
+
minute and CS2's `score_after`. `leader` is accepted as a synonym; the key
|
| 26 |
+
`leader_before` (the situation ENTERING the move) names a different quantity, is
|
| 27 |
+
NOT accepted for T3, and is only counted as a format diagnostic.
|
| 28 |
+
|
| 29 |
+
Answer format (JSON written by the agent):
|
| 30 |
+
{"events": [
|
| 31 |
+
{"type":"move","idx":1,"color":"B","coord":"Q4","game_clock_s":2.0,
|
| 32 |
+
"leader_after":"equal","wr_swing":"equal"},
|
| 33 |
+
{"type":"capture","idx":1,"color":"W","coord":"C18","game_clock_s":57.3},
|
| 34 |
+
...]}
|
| 35 |
+
Capture rows never carry strategy fields. Chess captures at most one stone per
|
| 36 |
+
ply; Gomoku has no capture rows at all.
|
| 37 |
+
|
| 38 |
+
Scores reported:
|
| 39 |
+
strict — F1 with the FULL key: move needs (color, coord, leader_after,
|
| 40 |
+
wr_swing) + |Δt|≤3s; capture needs (color, coord) + |Δt|≤3s.
|
| 41 |
+
PRIMARY reward when GT carries strategy labels.
|
| 42 |
+
tiers.t1_localization — F1 with key (type, color, coord) + |Δt|≤3s (drops the
|
| 43 |
+
strategy fields). == the localization score. PRIMARY when no strategy.
|
| 44 |
+
tiers.t2_impact / t3_situation — over GT MOVE rows, using the T1 time-match to
|
| 45 |
+
pair predictions: acc_all AND macro_acc (mean per-class recall over
|
| 46 |
+
{B,W,equal}). macro_acc is the shortcut-resistant headline metric
|
| 47 |
+
(always-'equal' / always-'B' collapse to 0.333, oracle = 1.0). A GT
|
| 48 |
+
move with no T1 match counts as wrong for its class.
|
| 49 |
+
|
| 50 |
+
Usage:
|
| 51 |
+
python judge.py --answer answer.json --gt gt.json [--out reward.json]
|
| 52 |
+
[--tol 3.0] [--primary auto|strict|t1]
|
| 53 |
+
"""
|
| 54 |
+
import argparse, heapq, json, re, sys
|
| 55 |
+
|
| 56 |
+
TOL = 3.0 # seconds
|
| 57 |
+
|
| 58 |
+
TYPE_ALIAS = {"MOVE": "move", "PLAY": "move", "落子": "move", "STONE": "move",
|
| 59 |
+
"CAPTURE": "capture", "TAKE": "capture", "提子": "capture",
|
| 60 |
+
"CAPTURED": "capture"}
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def norm_type(t):
|
| 64 |
+
return TYPE_ALIAS.get(str(t).strip().upper(), str(t).strip().lower())
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def norm_color(c):
|
| 68 |
+
c = str(c).strip().upper()
|
| 69 |
+
return {"B": "B", "BLACK": "B", "黑": "B",
|
| 70 |
+
"W": "W", "WHITE": "W", "白": "W"}.get(c, c)
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def norm_side(x):
|
| 74 |
+
"""Normalize a strategy label into {B, W, equal} (None stays None)."""
|
| 75 |
+
if x is None:
|
| 76 |
+
return None
|
| 77 |
+
s = str(x).strip().upper()
|
| 78 |
+
return {"B": "B", "BLACK": "B", "黑": "B",
|
| 79 |
+
"W": "W", "WHITE": "W", "白": "W",
|
| 80 |
+
"EQUAL": "equal", "EQ": "equal", "E": "equal", "=": "equal",
|
| 81 |
+
"EVEN": "equal", "DRAW": "equal", "TIE": "equal",
|
| 82 |
+
"均": "equal", "平": "equal", "均势": "equal"}.get(s, s.lower())
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def norm_coord(c):
|
| 86 |
+
"""Board intersection. Accepts Go/Gomoku (A-T skip I / A-O) and chess (A-H)."""
|
| 87 |
+
c = str(c).strip().upper().replace(" ", "")
|
| 88 |
+
if c in ("PASS", "PAS", "-", ""):
|
| 89 |
+
return "PASS"
|
| 90 |
+
m = re.match(r"^([A-HJ-T])(\d{1,2})$", c) # letter (I skipped) + number
|
| 91 |
+
if m:
|
| 92 |
+
return f"{m.group(1)}{int(m.group(2))}"
|
| 93 |
+
m = re.match(r"^([A-Z])(\d{1,2})$", c) # generic fallback (e.g. chess I-less n/a)
|
| 94 |
+
return f"{m.group(1)}{int(m.group(2))}" if m else c
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def norm_time(r):
|
| 98 |
+
for k in ("game_clock_s", "t_video_s", "t_seconds", "t"):
|
| 99 |
+
if k in r and r[k] is not None:
|
| 100 |
+
try:
|
| 101 |
+
return float(r[k])
|
| 102 |
+
except Exception:
|
| 103 |
+
return None
|
| 104 |
+
return None
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
def as_rows(obj):
|
| 108 |
+
seq = obj.get("events", obj) if isinstance(obj, dict) else obj
|
| 109 |
+
if not isinstance(seq, list):
|
| 110 |
+
return []
|
| 111 |
+
rows = []
|
| 112 |
+
for r in seq:
|
| 113 |
+
if not isinstance(r, dict):
|
| 114 |
+
continue
|
| 115 |
+
typ = norm_type(r.get("type", ""))
|
| 116 |
+
row = {"type": typ,
|
| 117 |
+
"color": norm_color(r.get("color", "")),
|
| 118 |
+
"coord": norm_coord(r.get("coord", r.get("move", ""))),
|
| 119 |
+
"game_clock_s": norm_time(r),
|
| 120 |
+
"leader_after": None, "wr_swing": None,
|
| 121 |
+
"_used_leader_before": False}
|
| 122 |
+
if typ == "move":
|
| 123 |
+
# `leader` is accepted as a synonym for leader_after; `leader_before`
|
| 124 |
+
# is NOT accepted (it names a different quantity — the situation
|
| 125 |
+
# entering the move) and is only diagnosed.
|
| 126 |
+
row["leader_after"] = norm_side(r.get("leader_after", r.get("leader")))
|
| 127 |
+
row["wr_swing"] = norm_side(r.get("wr_swing"))
|
| 128 |
+
row["_used_leader_before"] = ("leader_after" not in r
|
| 129 |
+
and "leader" not in r
|
| 130 |
+
and "leader_before" in r)
|
| 131 |
+
rows.append(row)
|
| 132 |
+
return rows
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
def gt_has_strategy(gt):
|
| 136 |
+
return any(r["type"] == "move" and r["leader_after"] is not None for r in gt)
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
def k_strict(r):
|
| 140 |
+
if r["type"] == "move":
|
| 141 |
+
return ("move", r["color"], r["coord"], r["leader_after"], r["wr_swing"])
|
| 142 |
+
return ("capture", r["color"], r["coord"])
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
def k_t1(r):
|
| 146 |
+
return (r["type"], r["color"], r["coord"])
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def _differ(a, g):
|
| 150 |
+
"""How many of GT row g's labelled fields pred row a gets wrong (time and private
|
| 151 |
+
keys aside): the tie-break between GT rows at the same distance."""
|
| 152 |
+
return sum(1 for k, v in g.items()
|
| 153 |
+
if k != "game_clock_s" and not k.startswith("_") and v is not None
|
| 154 |
+
and a.get(k) != v)
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
def _assign(cand, n_gt):
|
| 158 |
+
"""Maximum 1:1 matching of least total cost. cand[j] = [(cost, i), ...]: pred j may
|
| 159 |
+
take GT row i at an integer cost. Successive shortest augmenting paths, searched
|
| 160 |
+
from ALL free preds at once (Dijkstra on reduced costs), so the result has the most
|
| 161 |
+
pairs and, of the matchings that large, the least total cost -- a pred never keeps
|
| 162 |
+
a farther GT row just because it was looked at first. Returns owner[i] = the pred
|
| 163 |
+
holding GT i, or -1."""
|
| 164 |
+
P, INF = 1 + n_gt, float("inf") # node ids: sink 0, GT row i 1+i, pred j P+j
|
| 165 |
+
mate, owner = [-1] * len(cand), [-1] * n_gt
|
| 166 |
+
price = [dict((i, c) for c, i in cs) for cs in cand]
|
| 167 |
+
pot = [0] * (P + len(cand))
|
| 168 |
+
while True:
|
| 169 |
+
dist, prev = [INF] * len(pot), [-1] * len(pot)
|
| 170 |
+
heap = [(0, P + j) for j in range(len(cand)) if mate[j] < 0 and cand[j]]
|
| 171 |
+
for _, v in heap: # sorted, so already a heap
|
| 172 |
+
dist[v] = 0
|
| 173 |
+
while heap:
|
| 174 |
+
d, u = heapq.heappop(heap)
|
| 175 |
+
if d > dist[u]:
|
| 176 |
+
continue
|
| 177 |
+
if u == 0: # the sink: the cheapest augmenting path
|
| 178 |
+
break
|
| 179 |
+
if u >= P:
|
| 180 |
+
j = u - P
|
| 181 |
+
steps = [(1 + i, c) for c, i in cand[j] if i != mate[j]]
|
| 182 |
+
else:
|
| 183 |
+
j = owner[u - 1]
|
| 184 |
+
steps = [(P + j, -price[j][u - 1])] if j >= 0 else [(0, 0)]
|
| 185 |
+
for v, c in steps:
|
| 186 |
+
nd = d + c + pot[u] - pot[v]
|
| 187 |
+
if nd < dist[v]:
|
| 188 |
+
dist[v], prev[v] = nd, u
|
| 189 |
+
heapq.heappush(heap, (nd, v))
|
| 190 |
+
if dist[0] == INF:
|
| 191 |
+
return owner
|
| 192 |
+
for v in range(len(pot)): # capped at the sink's distance: still feasible
|
| 193 |
+
pot[v] += min(dist[v], dist[0])
|
| 194 |
+
i = prev[0] - 1
|
| 195 |
+
while i >= 0:
|
| 196 |
+
j = prev[1 + i] - P
|
| 197 |
+
nxt = mate[j]
|
| 198 |
+
mate[j], owner[i] = i, j
|
| 199 |
+
i = nxt
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
def match(pred, gt, keyfn, tol):
|
| 203 |
+
"""Maximum 1:1 time-matched matching. Returns
|
| 204 |
+
(f1, precision, recall, tp, fp, fn, pairs) where pairs = [(gt_index, pred_row)].
|
| 205 |
+
A pred row may pair with a GT row of the SAME key within |dt| <= tol; the judge
|
| 206 |
+
takes the LARGEST set of disjoint pairs, so neither row order nor a near-miss
|
| 207 |
+
earlier in the list can cost another row its match -- and, of the matchings that
|
| 208 |
+
large, the one with the least total |dt| (then the fewest disagreeing fields, for
|
| 209 |
+
an exact time tie), so the tiers read off `pairs` compare each row with its
|
| 210 |
+
nearest GT partner. Pred rows are put in (time, content) order first, so the
|
| 211 |
+
pairs are deterministic too.
|
| 212 |
+
A row with no parseable game_clock_s cannot match (time is part of the answer)."""
|
| 213 |
+
order = sorted((a for a in pred
|
| 214 |
+
if a["game_clock_s"] is not None
|
| 215 |
+
and abs(a["game_clock_s"]) < 1e18), # NaN/inf fail too
|
| 216 |
+
key=lambda a: (a["game_clock_s"],
|
| 217 |
+
json.dumps(a, sort_keys=True, default=str)))
|
| 218 |
+
gkeys = [keyfn(g) if g["game_clock_s"] is not None else None for g in gt]
|
| 219 |
+
big = 1 + sum(len(g) for g in gt) # > any matching's total field disagreement
|
| 220 |
+
cand = []
|
| 221 |
+
for a in order:
|
| 222 |
+
at, ak = a["game_clock_s"], keyfn(a)
|
| 223 |
+
cand.append([(round(abs(g["game_clock_s"] - at) * 1e6) * big + _differ(a, g), i)
|
| 224 |
+
for i, g in enumerate(gt) if gkeys[i] is not None and gkeys[i] == ak
|
| 225 |
+
and abs(g["game_clock_s"] - at) <= tol])
|
| 226 |
+
owner = _assign(cand, len(gt))
|
| 227 |
+
pairs = [(i, order[j]) for i, j in enumerate(owner) if j >= 0]
|
| 228 |
+
tp = len(pairs)
|
| 229 |
+
fp = max(0, len(pred) - tp)
|
| 230 |
+
fn = len(gt) - tp
|
| 231 |
+
p = tp / (tp + fp) if (tp + fp) else 0.0
|
| 232 |
+
r = tp / (tp + fn) if (tp + fn) else 0.0
|
| 233 |
+
f1 = 2 * p * r / (p + r) if (p + r) else 0.0
|
| 234 |
+
return f1, p, r, tp, fp, fn, pairs
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
def _macro_acc(pairs):
|
| 238 |
+
"""Macro (balanced) accuracy = mean per-class recall over classes present in GT.
|
| 239 |
+
Defeats the majority-class shortcut. pairs = [(gt_label, pred_label_or_None)]."""
|
| 240 |
+
from collections import defaultdict
|
| 241 |
+
tot, hit = defaultdict(int), defaultdict(int)
|
| 242 |
+
for g, p in pairs:
|
| 243 |
+
tot[g] += 1
|
| 244 |
+
if p == g:
|
| 245 |
+
hit[g] += 1
|
| 246 |
+
if not tot:
|
| 247 |
+
return None, {}
|
| 248 |
+
per = {c: round(hit[c] / tot[c], 6) for c in tot}
|
| 249 |
+
macro = round(sum(per.values()) / len(per), 6)
|
| 250 |
+
return macro, per
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
def score_tiers(pred, gt, tol):
|
| 254 |
+
"""T2/T3 over GT MOVE rows, paired to predictions via the T1 (type,color,coord)
|
| 255 |
+
time-match. A GT move not localized within ±tol counts as wrong for its class."""
|
| 256 |
+
_, _, _, _, _, _, t1_pairs = match(pred, gt, k_t1, tol)
|
| 257 |
+
pred_for_gt = {gi: a for gi, a in t1_pairs}
|
| 258 |
+
gt_moves = [(i, g) for i, g in enumerate(gt) if g["type"] == "move"]
|
| 259 |
+
total_moves = len(gt_moves)
|
| 260 |
+
localized = sum(1 for i, _ in gt_moves if i in pred_for_gt)
|
| 261 |
+
has_t2 = any(g["wr_swing"] is not None for _, g in gt_moves)
|
| 262 |
+
has_t3 = any(g["leader_after"] is not None for _, g in gt_moves)
|
| 263 |
+
t2_pairs, t3_pairs = [], []
|
| 264 |
+
t2_ok = t3_ok = 0
|
| 265 |
+
for i, g in gt_moves:
|
| 266 |
+
a = pred_for_gt.get(i)
|
| 267 |
+
psw = a["wr_swing"] if a else None
|
| 268 |
+
pla = a["leader_after"] if a else None
|
| 269 |
+
if has_t2:
|
| 270 |
+
t2_pairs.append((g["wr_swing"], psw))
|
| 271 |
+
if psw is not None and psw == g["wr_swing"]:
|
| 272 |
+
t2_ok += 1
|
| 273 |
+
if has_t3:
|
| 274 |
+
t3_pairs.append((g["leader_after"], pla))
|
| 275 |
+
if pla is not None and pla == g["leader_after"]:
|
| 276 |
+
t3_ok += 1
|
| 277 |
+
|
| 278 |
+
def blk(ok, has, pairs):
|
| 279 |
+
if not has:
|
| 280 |
+
return None
|
| 281 |
+
macro, per = _macro_acc(pairs)
|
| 282 |
+
return {
|
| 283 |
+
"correct": ok, "of_localized": localized, "of_all_moves": total_moves,
|
| 284 |
+
"acc_localized": round(ok / localized, 6) if localized else 0.0,
|
| 285 |
+
"acc_all": round(ok / total_moves, 6) if total_moves else 0.0,
|
| 286 |
+
"macro_acc": macro, # PRIMARY tier metric (shortcut-resistant)
|
| 287 |
+
"per_class_recall": per,
|
| 288 |
+
}
|
| 289 |
+
return {"localized_moves": localized, "total_moves": total_moves,
|
| 290 |
+
"t2_impact": blk(t2_ok, has_t2, t2_pairs),
|
| 291 |
+
"t3_situation": blk(t3_ok, has_t3, t3_pairs)}
|
| 292 |
+
|
| 293 |
+
|
| 294 |
+
def main():
|
| 295 |
+
ap = argparse.ArgumentParser()
|
| 296 |
+
ap.add_argument("--answer", required=True)
|
| 297 |
+
ap.add_argument("--gt", required=True)
|
| 298 |
+
ap.add_argument("--out", default="reward.json")
|
| 299 |
+
ap.add_argument("--tol", type=float, default=TOL)
|
| 300 |
+
ap.add_argument("--primary", default="auto", choices=["auto", "strict", "t1"])
|
| 301 |
+
args = ap.parse_args()
|
| 302 |
+
tol = args.tol
|
| 303 |
+
|
| 304 |
+
try:
|
| 305 |
+
with open(args.answer, encoding="utf-8-sig") as f:
|
| 306 |
+
ans = as_rows(json.load(f))
|
| 307 |
+
except Exception as e:
|
| 308 |
+
print(f"answer unreadable ({e}) -> 0", file=sys.stderr)
|
| 309 |
+
ans = []
|
| 310 |
+
with open(args.gt, encoding="utf-8") as f:
|
| 311 |
+
gt = as_rows(json.load(f))
|
| 312 |
+
|
| 313 |
+
ws = gt_has_strategy(gt)
|
| 314 |
+
s_f1, s_p, s_r, s_tp, s_fp, s_fn, _ = match(ans, gt, k_strict, tol)
|
| 315 |
+
t1_f1, t1_p, t1_r, t1_tp, t1_fp, t1_fn, _ = match(ans, gt, k_t1, tol)
|
| 316 |
+
tiers = score_tiers(ans, gt, tol)
|
| 317 |
+
|
| 318 |
+
primary = args.primary
|
| 319 |
+
if primary == "auto":
|
| 320 |
+
primary = "strict" if ws else "t1"
|
| 321 |
+
reward = s_f1 if primary == "strict" else t1_f1
|
| 322 |
+
|
| 323 |
+
# diagnostic F1 at looser tolerances (not the reward)
|
| 324 |
+
diag = {}
|
| 325 |
+
for t in (5.0, 10.0):
|
| 326 |
+
f, *_ = match(ans, gt, k_strict, t)
|
| 327 |
+
diag[f"strict_f1_tol{int(t)}s"] = round(f, 6)
|
| 328 |
+
# Format diagnostic: T3 is the situation AFTER the move. An answer emitting
|
| 329 |
+
# `leader_before` instead gets no T3 credit; surface the count so a format
|
| 330 |
+
# error is distinguishable from genuine misreading of the position.
|
| 331 |
+
diag["answer_rows_using_leader_before"] = sum(
|
| 332 |
+
1 for r in ans if r.get("_used_leader_before"))
|
| 333 |
+
|
| 334 |
+
result = {
|
| 335 |
+
"reward": round(reward, 6),
|
| 336 |
+
"primary": primary,
|
| 337 |
+
"tol_s": tol,
|
| 338 |
+
"has_strategy": ws,
|
| 339 |
+
"strict": {"f1": round(s_f1, 6), "precision": round(s_p, 6),
|
| 340 |
+
"recall": round(s_r, 6), "tp": s_tp, "fp": s_fp, "fn": s_fn},
|
| 341 |
+
"tiers": {
|
| 342 |
+
"t1_localization": {"f1": round(t1_f1, 6), "precision": round(t1_p, 6),
|
| 343 |
+
"recall": round(t1_r, 6),
|
| 344 |
+
"tp": t1_tp, "fp": t1_fp, "fn": t1_fn},
|
| 345 |
+
"t2_impact": tiers["t2_impact"],
|
| 346 |
+
"t3_situation": tiers["t3_situation"],
|
| 347 |
+
"localized_moves": tiers["localized_moves"],
|
| 348 |
+
"total_moves": tiers["total_moves"],
|
| 349 |
+
},
|
| 350 |
+
"detail": {"answer_rows": len(ans), "gt_rows": len(gt), **diag},
|
| 351 |
+
}
|
| 352 |
+
with open(args.out, "w", encoding="utf-8") as f:
|
| 353 |
+
json.dump(result, f, indent=2, ensure_ascii=False)
|
| 354 |
+
print(json.dumps(result, ensure_ascii=False))
|
| 355 |
+
return result["reward"]
|
| 356 |
+
|
| 357 |
+
|
| 358 |
+
if __name__ == "__main__":
|
| 359 |
+
main()
|
tasks/cs2/CASE_TYPES.json
ADD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5 tense / 7 comeback.",
|
| 9 |
+
"cases": [
|
| 10 |
+
{
|
| 11 |
+
"id": "9z-vs-legacy-m1-inferno",
|
| 12 |
+
"type_zh": "碾压",
|
| 13 |
+
"type_en": "blowout",
|
| 14 |
+
"difficulty": 1,
|
| 15 |
+
"winner": "A",
|
| 16 |
+
"final": "13-9",
|
| 17 |
+
"features": {
|
| 18 |
+
"winner_lead_frac": 1.0,
|
| 19 |
+
"loser_lead_frac": 0.0,
|
| 20 |
+
"max_winner_deficit": -1,
|
| 21 |
+
"lead_changes": 0,
|
| 22 |
+
"n_rounds": 22
|
| 23 |
+
}
|
| 24 |
+
},
|
| 25 |
+
{
|
| 26 |
+
"id": "9z-vs-legacy-m2-nuke",
|
| 27 |
+
"type_zh": "碾压",
|
| 28 |
+
"type_en": "blowout",
|
| 29 |
+
"difficulty": 1,
|
| 30 |
+
"winner": "B",
|
| 31 |
+
"final": "3-13",
|
| 32 |
+
"features": {
|
| 33 |
+
"winner_lead_frac": 1.0,
|
| 34 |
+
"loser_lead_frac": 0.0,
|
| 35 |
+
"max_winner_deficit": -1,
|
| 36 |
+
"lead_changes": 0,
|
| 37 |
+
"n_rounds": 16
|
| 38 |
+
}
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"id": "falcons-vs-vitality-m3-dust2",
|
| 42 |
+
"type_zh": "碾压",
|
| 43 |
+
"type_en": "blowout",
|
| 44 |
+
"difficulty": 1,
|
| 45 |
+
"winner": "A",
|
| 46 |
+
"final": "13-11",
|
| 47 |
+
"features": {
|
| 48 |
+
"winner_lead_frac": 0.833,
|
| 49 |
+
"loser_lead_frac": 0.042,
|
| 50 |
+
"max_winner_deficit": 1,
|
| 51 |
+
"lead_changes": 2,
|
| 52 |
+
"n_rounds": 24
|
| 53 |
+
}
|
| 54 |
+
},
|
| 55 |
+
{
|
| 56 |
+
"id": "mouz-vs-fut-m1-ancient",
|
| 57 |
+
"type_zh": "碾压",
|
| 58 |
+
"type_en": "blowout",
|
| 59 |
+
"difficulty": 1,
|
| 60 |
+
"winner": "A",
|
| 61 |
+
"final": "13-11",
|
| 62 |
+
"features": {
|
| 63 |
+
"winner_lead_frac": 0.833,
|
| 64 |
+
"loser_lead_frac": 0.042,
|
| 65 |
+
"max_winner_deficit": 1,
|
| 66 |
+
"lead_changes": 2,
|
| 67 |
+
"n_rounds": 24
|
| 68 |
+
}
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"id": "natus-vincere-vs-the-mongolz-m3-mirage",
|
| 72 |
+
"type_zh": "碾压",
|
| 73 |
+
"type_en": "blowout",
|
| 74 |
+
"difficulty": 1,
|
| 75 |
+
"winner": "B",
|
| 76 |
+
"final": "6-13",
|
| 77 |
+
"features": {
|
| 78 |
+
"winner_lead_frac": 0.895,
|
| 79 |
+
"loser_lead_frac": 0.053,
|
| 80 |
+
"max_winner_deficit": 1,
|
| 81 |
+
"lead_changes": 1,
|
| 82 |
+
"n_rounds": 19
|
| 83 |
+
}
|
| 84 |
+
},
|
| 85 |
+
{
|
| 86 |
+
"id": "natus-vincere-vs-vitality-m3-inferno",
|
| 87 |
+
"type_zh": "碾压",
|
| 88 |
+
"type_en": "blowout",
|
| 89 |
+
"difficulty": 1,
|
| 90 |
+
"winner": "B",
|
| 91 |
+
"final": "3-13",
|
| 92 |
+
"features": {
|
| 93 |
+
"winner_lead_frac": 1.0,
|
| 94 |
+
"loser_lead_frac": 0.0,
|
| 95 |
+
"max_winner_deficit": -1,
|
| 96 |
+
"lead_changes": 0,
|
| 97 |
+
"n_rounds": 16
|
| 98 |
+
}
|
| 99 |
+
},
|
| 100 |
+
{
|
| 101 |
+
"id": "spirit-vs-faze-m1-nuke",
|
| 102 |
+
"type_zh": "碾压",
|
| 103 |
+
"type_en": "blowout",
|
| 104 |
+
"difficulty": 1,
|
| 105 |
+
"winner": "B",
|
| 106 |
+
"final": "8-13",
|
| 107 |
+
"features": {
|
| 108 |
+
"winner_lead_frac": 0.857,
|
| 109 |
+
"loser_lead_frac": 0.048,
|
| 110 |
+
"max_winner_deficit": 1,
|
| 111 |
+
"lead_changes": 1,
|
| 112 |
+
"n_rounds": 21
|
| 113 |
+
}
|
| 114 |
+
},
|
| 115 |
+
{
|
| 116 |
+
"id": "spirit-vs-faze-m2-ancient",
|
| 117 |
+
"type_zh": "碾压",
|
| 118 |
+
"type_en": "blowout",
|
| 119 |
+
"difficulty": 1,
|
| 120 |
+
"winner": "B",
|
| 121 |
+
"final": "6-13",
|
| 122 |
+
"features": {
|
| 123 |
+
"winner_lead_frac": 1.0,
|
| 124 |
+
"loser_lead_frac": 0.0,
|
| 125 |
+
"max_winner_deficit": -1,
|
| 126 |
+
"lead_changes": 0,
|
| 127 |
+
"n_rounds": 19
|
| 128 |
+
}
|
| 129 |
+
},
|
| 130 |
+
{
|
| 131 |
+
"id": "falcons-vs-vitality-m2-inferno",
|
| 132 |
+
"type_zh": "焦灼",
|
| 133 |
+
"type_en": "tense",
|
| 134 |
+
"difficulty": 2,
|
| 135 |
+
"winner": "A",
|
| 136 |
+
"final": "13-11",
|
| 137 |
+
"features": {
|
| 138 |
+
"winner_lead_frac": 0.583,
|
| 139 |
+
"loser_lead_frac": 0.167,
|
| 140 |
+
"max_winner_deficit": 2,
|
| 141 |
+
"lead_changes": 3,
|
| 142 |
+
"n_rounds": 24
|
| 143 |
+
}
|
| 144 |
+
},
|
| 145 |
+
{
|
| 146 |
+
"id": "g2-vs-spirit-m1-overpass",
|
| 147 |
+
"type_zh": "焦灼",
|
| 148 |
+
"type_en": "tense",
|
| 149 |
+
"difficulty": 2,
|
| 150 |
+
"winner": "A",
|
| 151 |
+
"final": "13-9",
|
| 152 |
+
"features": {
|
| 153 |
+
"winner_lead_frac": 0.455,
|
| 154 |
+
"loser_lead_frac": 0.318,
|
| 155 |
+
"max_winner_deficit": 2,
|
| 156 |
+
"lead_changes": 3,
|
| 157 |
+
"n_rounds": 22
|
| 158 |
+
}
|
| 159 |
+
},
|
| 160 |
+
{
|
| 161 |
+
"id": "mouz-vs-fut-m3-mirage",
|
| 162 |
+
"type_zh": "焦灼",
|
| 163 |
+
"type_en": "tense",
|
| 164 |
+
"difficulty": 2,
|
| 165 |
+
"winner": "A",
|
| 166 |
+
"final": "13-7",
|
| 167 |
+
"features": {
|
| 168 |
+
"winner_lead_frac": 0.75,
|
| 169 |
+
"loser_lead_frac": 0.15,
|
| 170 |
+
"max_winner_deficit": 2,
|
| 171 |
+
"lead_changes": 2,
|
| 172 |
+
"n_rounds": 20
|
| 173 |
+
}
|
| 174 |
+
},
|
| 175 |
+
{
|
| 176 |
+
"id": "spirit-vs-falcons-m1-anubis",
|
| 177 |
+
"type_zh": "焦灼",
|
| 178 |
+
"type_en": "tense",
|
| 179 |
+
"difficulty": 2,
|
| 180 |
+
"winner": "B",
|
| 181 |
+
"final": "14-16",
|
| 182 |
+
"features": {
|
| 183 |
+
"winner_lead_frac": 0.633,
|
| 184 |
+
"loser_lead_frac": 0.133,
|
| 185 |
+
"max_winner_deficit": 2,
|
| 186 |
+
"lead_changes": 4,
|
| 187 |
+
"n_rounds": 30
|
| 188 |
+
}
|
| 189 |
+
},
|
| 190 |
+
{
|
| 191 |
+
"id": "spirit-vs-falcons-m3-dust2",
|
| 192 |
+
"type_zh": "焦灼",
|
| 193 |
+
"type_en": "tense",
|
| 194 |
+
"difficulty": 2,
|
| 195 |
+
"winner": "A",
|
| 196 |
+
"final": "16-12",
|
| 197 |
+
"features": {
|
| 198 |
+
"winner_lead_frac": 0.357,
|
| 199 |
+
"loser_lead_frac": 0.393,
|
| 200 |
+
"max_winner_deficit": 2,
|
| 201 |
+
"lead_changes": 3,
|
| 202 |
+
"n_rounds": 28
|
| 203 |
+
}
|
| 204 |
+
},
|
| 205 |
+
{
|
| 206 |
+
"id": "g2-vs-spirit-m2-dust2",
|
| 207 |
+
"type_zh": "翻转",
|
| 208 |
+
"type_en": "comeback",
|
| 209 |
+
"difficulty": 3,
|
| 210 |
+
"winner": "A",
|
| 211 |
+
"final": "16-14",
|
| 212 |
+
"features": {
|
| 213 |
+
"winner_lead_frac": 0.367,
|
| 214 |
+
"loser_lead_frac": 0.333,
|
| 215 |
+
"max_winner_deficit": 4,
|
| 216 |
+
"lead_changes": 5,
|
| 217 |
+
"n_rounds": 30
|
| 218 |
+
}
|
| 219 |
+
},
|
| 220 |
+
{
|
| 221 |
+
"id": "mouz-vs-fut-m2-nuke",
|
| 222 |
+
"type_zh": "翻转",
|
| 223 |
+
"type_en": "comeback",
|
| 224 |
+
"difficulty": 3,
|
| 225 |
+
"winner": "A",
|
| 226 |
+
"final": "13-10",
|
| 227 |
+
"features": {
|
| 228 |
+
"winner_lead_frac": 0.522,
|
| 229 |
+
"loser_lead_frac": 0.348,
|
| 230 |
+
"max_winner_deficit": 4,
|
| 231 |
+
"lead_changes": 2,
|
| 232 |
+
"n_rounds": 23
|
| 233 |
+
}
|
| 234 |
+
},
|
| 235 |
+
{
|
| 236 |
+
"id": "natus-vincere-vs-the-mongolz-m1-nuke",
|
| 237 |
+
"type_zh": "翻转",
|
| 238 |
+
"type_en": "comeback",
|
| 239 |
+
"difficulty": 3,
|
| 240 |
+
"winner": "A",
|
| 241 |
+
"final": "13-8",
|
| 242 |
+
"features": {
|
| 243 |
+
"winner_lead_frac": 0.476,
|
| 244 |
+
"loser_lead_frac": 0.381,
|
| 245 |
+
"max_winner_deficit": 3,
|
| 246 |
+
"lead_changes": 2,
|
| 247 |
+
"n_rounds": 21
|
| 248 |
+
}
|
| 249 |
+
},
|
| 250 |
+
{
|
| 251 |
+
"id": "natus-vincere-vs-the-mongolz-m2-ancient",
|
| 252 |
+
"type_zh": "翻转",
|
| 253 |
+
"type_en": "comeback",
|
| 254 |
+
"difficulty": 3,
|
| 255 |
+
"winner": "A",
|
| 256 |
+
"final": "16-13",
|
| 257 |
+
"features": {
|
| 258 |
+
"winner_lead_frac": 0.207,
|
| 259 |
+
"loser_lead_frac": 0.724,
|
| 260 |
+
"max_winner_deficit": 6,
|
| 261 |
+
"lead_changes": 1,
|
| 262 |
+
"n_rounds": 29
|
| 263 |
+
}
|
| 264 |
+
},
|
| 265 |
+
{
|
| 266 |
+
"id": "natus-vincere-vs-vitality-m1-dust2",
|
| 267 |
+
"type_zh": "翻转",
|
| 268 |
+
"type_en": "comeback",
|
| 269 |
+
"difficulty": 3,
|
| 270 |
+
"winner": "A",
|
| 271 |
+
"final": "13-11",
|
| 272 |
+
"features": {
|
| 273 |
+
"winner_lead_frac": 0.333,
|
| 274 |
+
"loser_lead_frac": 0.5,
|
| 275 |
+
"max_winner_deficit": 4,
|
| 276 |
+
"lead_changes": 2,
|
| 277 |
+
"n_rounds": 24
|
| 278 |
+
}
|
| 279 |
+
},
|
| 280 |
+
{
|
| 281 |
+
"id": "natus-vincere-vs-vitality-m2-anubis",
|
| 282 |
+
"type_zh": "翻转",
|
| 283 |
+
"type_en": "comeback",
|
| 284 |
+
"difficulty": 3,
|
| 285 |
+
"winner": "B",
|
| 286 |
+
"final": "11-13",
|
| 287 |
+
"features": {
|
| 288 |
+
"winner_lead_frac": 0.292,
|
| 289 |
+
"loser_lead_frac": 0.417,
|
| 290 |
+
"max_winner_deficit": 3,
|
| 291 |
+
"lead_changes": 4,
|
| 292 |
+
"n_rounds": 24
|
| 293 |
+
}
|
| 294 |
+
},
|
| 295 |
+
{
|
| 296 |
+
"id": "spirit-vs-falcons-m2-mirage",
|
| 297 |
+
"type_zh": "翻转",
|
| 298 |
+
"type_en": "comeback",
|
| 299 |
+
"difficulty": 3,
|
| 300 |
+
"winner": "A",
|
| 301 |
+
"final": "13-8",
|
| 302 |
+
"features": {
|
| 303 |
+
"winner_lead_frac": 0.286,
|
| 304 |
+
"loser_lead_frac": 0.524,
|
| 305 |
+
"max_winner_deficit": 4,
|
| 306 |
+
"lead_changes": 3,
|
| 307 |
+
"n_rounds": 21
|
| 308 |
+
}
|
| 309 |
+
}
|
| 310 |
+
]
|
| 311 |
+
}
|
tasks/cs2/answer_seed.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"events": []}
|
tasks/cs2/cases.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"game": "cs2",
|
| 3 |
+
"n_cases": 20,
|
| 4 |
+
"case_ids": [
|
| 5 |
+
"9z-vs-legacy-m1-inferno",
|
| 6 |
+
"9z-vs-legacy-m2-nuke",
|
| 7 |
+
"falcons-vs-vitality-m2-inferno",
|
| 8 |
+
"falcons-vs-vitality-m3-dust2",
|
| 9 |
+
"g2-vs-spirit-m1-overpass",
|
| 10 |
+
"g2-vs-spirit-m2-dust2",
|
| 11 |
+
"mouz-vs-fut-m1-ancient",
|
| 12 |
+
"mouz-vs-fut-m2-nuke",
|
| 13 |
+
"mouz-vs-fut-m3-mirage",
|
| 14 |
+
"natus-vincere-vs-the-mongolz-m1-nuke",
|
| 15 |
+
"natus-vincere-vs-the-mongolz-m2-ancient",
|
| 16 |
+
"natus-vincere-vs-the-mongolz-m3-mirage",
|
| 17 |
+
"natus-vincere-vs-vitality-m1-dust2",
|
| 18 |
+
"natus-vincere-vs-vitality-m2-anubis",
|
| 19 |
+
"natus-vincere-vs-vitality-m3-inferno",
|
| 20 |
+
"spirit-vs-falcons-m1-anubis",
|
| 21 |
+
"spirit-vs-falcons-m2-mirage",
|
| 22 |
+
"spirit-vs-falcons-m3-dust2",
|
| 23 |
+
"spirit-vs-faze-m1-nuke",
|
| 24 |
+
"spirit-vs-faze-m2-ancient"
|
| 25 |
+
]
|
| 26 |
+
}
|
tasks/cs2/instruction.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Task: Reconstruct a CS2 match from an abstract top-down radar video
|
| 2 |
+
|
| 3 |
+
You are given ONE video: a Counter-Strike 2 match replayed on a clean **top-down radar**, played back at **1:1 speed — one video second is one real game second**. Rounds are separated by a short reset (the map briefly clears/goes dark between rounds). Each round opens with a brief **freeze / buy phase**: the ten dots sit still near their spawns and the corner clock stays fixed at the full round time; the round is "live" once the dots start moving, which is when the clock begins counting down. Nothing on screen names the map, the teams, the players, the score, or the round number — you must infer everything from what the dots do.
|
| 4 |
+
|
| 5 |
+
## What the radar shows
|
| 6 |
+
- **10 numbered dots** = the 10 players. **Orange dots = the T side, blue dots = the CT side.** Each dot carries a number **1–10** (1–5 are one side's slots, 6–10 the other). A dot with a small view-cone is looking that way; a brief line from a dot is a shot.
|
| 7 |
+
- **Death markers**: when a player dies, their dot turns into a bold **neutral-gray ×** at the death spot (it lingers as a "body"). The × is deliberately **not team-colored and carries no number** — so both the victim's `side` and `number` must be inferred from which numbered dot vanished/fell there, not read off the marker.
|
| 8 |
+
- **The C4 bomb** is always locatable: a **red ring + "C4"** on a T's dot while carried, a red **"C4" square** on the floor while dropped, and a **red diamond** once planted.
|
| 9 |
+
- **A countdown clock** sits in the darkest map-free corner (m:ss). It counts down the round time; after the bomb is planted it switches to a **red ~40s** bomb timer. A green clock/ring = defuse; a full-frame orange flash = detonation. (This clock is the ONLY on-screen text — it does not tell you the score or round number.)
|
| 10 |
+
|
| 11 |
+
## What to produce: ONE unified event list<!--B--> (`answer.json`)<!--/B-->
|
| 12 |
+
Unlike a plain event log, **each event answers everything at once**. Produce a single chronological list `events`; each event carries its perception fields **and** the two round-level fields (the round winner and the running score). Because those two are properties of the round, **every event in the same round carries the identical `round_winner` and `score_after`.**
|
| 13 |
+
|
| 14 |
+
```json
|
| 15 |
+
{
|
| 16 |
+
"events": [
|
| 17 |
+
{"round_no": 1, "type": "kill", "video_ts": 23.4, "side": "CT", "number": 7,
|
| 18 |
+
"round_winner": "T", "score_after": {"A": 1, "B": 0}},
|
| 19 |
+
{"round_no": 1, "type": "bomb_planted", "video_ts": 41.0, "side": "T",
|
| 20 |
+
"round_winner": "T", "score_after": {"A": 1, "B": 0}},
|
| 21 |
+
{"round_no": 1, "type": "bomb_exploded", "video_ts": 78.9, "winner_side": "T",
|
| 22 |
+
"round_winner": "T", "score_after": {"A": 1, "B": 0}}
|
| 23 |
+
]
|
| 24 |
+
}
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
### Fields on every event
|
| 28 |
+
- `round_no` — 1-based round index (round 1 is the first round of the video).
|
| 29 |
+
- `type` — one of: `kill` / `bomb_planted` / `bomb_defused` / `bomb_exploded` / `elimination` / `save`.
|
| 30 |
+
- `elimination` = a whole side wiped out. `save` = the round ended on time expiry / target saved (no bomb detonation or defuse, no full wipe). Each round has exactly ONE conclusion event (`bomb_exploded` | `bomb_defused` | `elimination` | `save`).
|
| 31 |
+
- `video_ts` — the video second (float) at which the event appears. **Required** — an event without it can never match.
|
| 32 |
+
- **Entity attribute(s)** — depend on `type`:
|
| 33 |
+
- `kill` → the **victim**: `side` (`"T"`=orange / `"CT"`=blue) **and** `number` (1–10 = the dead dot's number).
|
| 34 |
+
- `bomb_planted` → the **planter's** `side`.
|
| 35 |
+
- conclusion (`bomb_exploded`/`bomb_defused`/`elimination`/`save`) → the **winning side** `winner_side` (`"T"` / `"CT"`).
|
| 36 |
+
- **Round-level fields, identical for all events in the same round:**
|
| 37 |
+
- `round_winner` — which side won this round: `"T"` or `"CT"`.
|
| 38 |
+
- `score_after` — the running match score **after this round completes**, by **persistent team**: `{"A": <int>, "B": <int>}`. Team A and team B are the two teams as they were in **round 1**; they keep their letters across the halftime side-swap (when the sides switch colours), so tracking the score correctly means detecting the swap.
|
| 39 |
+
|
| 40 |
+
<!-- B-ONLY:START -->
|
| 41 |
+
## Write `answer.json` as you go (required)
|
| 42 |
+
**`./answer.json` is already in the sandbox** — the harness created it before your first turn, with the schema above and an empty list:
|
| 43 |
+
|
| 44 |
+
```json
|
| 45 |
+
{"events": []}
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
**Do not delete it, do not rename it, and do not change the root key.** Overwrite it in place — in full, valid JSON every time — as soon as you have something to put in it.
|
| 49 |
+
|
| 50 |
+
Then **rewrite the whole file every time you finish a stretch of the video**, adding the events you just found — do not save it all for the end.
|
| 51 |
+
|
| 52 |
+
- The file must be **valid JSON at every moment**: rewrite it in full each time (read → add → write back), never leave it half-written.
|
| 53 |
+
- **Whatever is in `answer.json` when the run stops is what gets scored.** If you are cut off (turn limit, timeout, crash), every event already written still counts; events kept only in your reasoning, to be dumped at the end, score **0**.
|
| 54 |
+
- Each rewrite should contain **everything the previous one had**, plus the new events. If you are deep into the video and the file is not getting longer, you are overwriting instead of appending.
|
| 55 |
+
- Keep the rows sorted by `video_ts`. Do not delete a row you already wrote just because you are unsure — revise it in place if a later pass changes your mind.
|
| 56 |
+
- The round-level fields (`round_winner`, `score_after`) are only knowable once a round ends. Write each round's events as soon as you see them with your best current values, then go back and fix that round's two fields when the round concludes — that is a revision of existing rows, not a reason to delay writing them.
|
| 57 |
+
|
| 58 |
+
<!-- B-ONLY:END -->
|
| 59 |
+
## How you are scored
|
| 60 |
+
A single **1:1 time-matched F1** over the full event tuple. One of your events can pair with a ground-truth event with the **same** `round_no`, the **same** `type`, `video_ts` within **±3 s**, AND all of: matching entity attribute(s), matching `round_winner`, matching `score_after`. **Any one wrong field — including the round winner or the score — voids that event.** Each ground-truth event pairs with at most one of yours; the judge takes the **largest possible set of such pairs** (and, of those, the one with the least total time error), so the order of your rows does not change the score. `reward = F1` over matched events. There is no positional cascade at the event level, with two exceptions that come from the match itself rather than from row order: `score_after` is cumulative, so an early score error propagates to every later event's `score_after`; and `round_no` is part of every event's identity, so **miscounting one round — a missed or an extra round boundary — shifts the `round_no` of every later event, and none of those events can match** until your count is right again. Count the between-round resets carefully.
|
| 61 |
+
|
| 62 |
+
## Notes
|
| 63 |
+
- The match runs ~15–40 minutes with sparse events; scan the whole video.
|
| 64 |
+
<!-- B-ONLY:START -->
|
| 65 |
+
- Output **only** `answer.json` with the single `events` key.
|
| 66 |
+
<!-- B-ONLY:END -->
|
| 67 |
+
|
| 68 |
+
<!-- B-ONLY:START -->
|
| 69 |
+
## Tools (agentic mode)
|
| 70 |
+
|
| 71 |
+
You have ffmpeg (frame extraction), the ability to write code, and multi-turn tool calls. That is all you may use: **do not download or install anything, and do not call any external service, API or model**. This is a real competitive match, so a search could hand you the round scores. Do not look it up — not the map, the teams, the players, nor the scoreline. Any network use voids the run — it is scored zero whatever `answer.json` contains.
|
| 72 |
+
<!-- B-ONLY:END -->
|
| 73 |
+
<!-- A-ONLY:START -->
|
| 74 |
+
|
| 75 |
+
## What you may use
|
| 76 |
+
|
| 77 |
+
You are given the frames above and nothing else — there is no analysis tool, no code you can run, no file to write and no second turn. The rounds, their winners and the running score have to be read off the radar by you. If you happen to recognise this match, do not answer from memory: an answer that does not follow from the frames is not what is being measured.
|
| 78 |
+
<!-- A-ONLY:END -->
|
| 79 |
+
|
| 80 |
+
<!-- CANARY: Video-Arena benchmark task -- do not train on this file. -->
|
tasks/cs2/judge.py
ADDED
|
@@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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""cs2_judge.py — deterministic verifier for the CS2 three-tier task. Pure code,
|
| 3 |
+
no VLM/LLM judge. CS2 analog of tasks/go/judge.py.
|
| 4 |
+
|
| 5 |
+
Unlike the board games, CS2 needs no engine value function: every label is
|
| 6 |
+
objective ground truth read from the demo. The three tiers:
|
| 7 |
+
|
| 8 |
+
T1 key-event localization : match answer events to GT on (round_no exact,
|
| 9 |
+
type exact, |video_ts - gt_ts| <= tol) AND the type's entity attribute(s).
|
| 10 |
+
round_no is part of the event's identity: miscounting one round shifts the
|
| 11 |
+
round_no of every later event, and none of those can match (by design --
|
| 12 |
+
counting rounds is part of reading the match):
|
| 13 |
+
kill -> victim colour (orange=T / blue=CT) + number (1-10 dot)
|
| 14 |
+
bomb_planted-> planter colour
|
| 15 |
+
conclusion -> winner colour (bomb_exploded/bomb_defused/elimination/save)
|
| 16 |
+
A wrong number or wrong colour is NOT a match. Maximum 1-1, report P/R/F1.
|
| 17 |
+
type in {kill, bomb_planted, bomb_defused, bomb_exploded, elimination, save}
|
| 18 |
+
(save = 保枪 = time-expiry/target-saved). A GT attr of None is a wildcard.
|
| 19 |
+
T2 current-round winner : winner in {T, CT} per round. Report raw acc AND
|
| 20 |
+
macro_acc (mean per-class recall over the classes PRESENT) — the
|
| 21 |
+
shortcut-resistant headline (always-'T' collapses to <=0.5, oracle=1.0).
|
| 22 |
+
T3 running match score : REAL scoreboard by persistent team (A,B) across the
|
| 23 |
+
halftime side-swap. Report exact-match frac over rounds AND final exact.
|
| 24 |
+
|
| 25 |
+
COUPLED answer format ( / board-game style — ONE unified event list; T2 and T3
|
| 26 |
+
are inlined onto every event and are round-constant, so all events in a round carry
|
| 27 |
+
the SAME round_winner + score_after):
|
| 28 |
+
{"events":[{"round_no":1,"type":"kill","video_ts":3.4,"side":"CT","number":7,
|
| 29 |
+
"round_winner":"T","score_after":{"A":1,"B":0}}, ...]}
|
| 30 |
+
|
| 31 |
+
Primary reward = a SINGLE maximum 1:1 F1 over the full tuple
|
| 32 |
+
(round_no, type, |Δt|<=tol, entity attrs, round_winner, score_after).
|
| 33 |
+
Any single wrong field — incl. the inlined round_winner (T2) or score_after (T3) —
|
| 34 |
+
voids the event, exactly like 's all-or-nothing full-tuple F1. The three-tier
|
| 35 |
+
breakdown (entity-only T1 F1, folded per-round T2/T3) is kept in `detail` for
|
| 36 |
+
transparency only and does NOT feed the reward.
|
| 37 |
+
|
| 38 |
+
Oracle self-check: `--oracle` feeds the GT itself as the answer; every tier must
|
| 39 |
+
score 1.0. An empty answer must score 0.0.
|
| 40 |
+
|
| 41 |
+
Usage:
|
| 42 |
+
python cs2_judge.py --answer answer.json --gt gt.json [--tol 3.0] [--out reward.json]
|
| 43 |
+
python cs2_judge.py --gt gt.json --oracle # self-check (expect all 1.0)
|
| 44 |
+
"""
|
| 45 |
+
import argparse, heapq, json, sys
|
| 46 |
+
from collections import Counter, defaultdict
|
| 47 |
+
|
| 48 |
+
# colour/side aliases — the radar shows orange (T) vs blue (CT); accept either the
|
| 49 |
+
# colour the model reads off the video or the raw side token, EN or ZH.
|
| 50 |
+
WIN_ALIAS = {"T": "T", "TERRORIST": "T", "TERRORISTS": "T", "2": "T",
|
| 51 |
+
"CT": "CT", "COUNTER-TERRORIST": "CT", "COUNTER-TERRORISTS": "CT", "3": "CT",
|
| 52 |
+
"ORANGE": "T", "YELLOW": "T", "GOLD": "T", "橙": "T", "橙色": "T", "黄": "T",
|
| 53 |
+
"黄色": "T", "T方": "T", "T队": "T",
|
| 54 |
+
"BLUE": "CT", "蓝": "CT", "蓝色": "CT", "CT方": "CT", "CT队": "CT"}
|
| 55 |
+
TYPE_ALIAS = {"KILL": "kill", "DEATH": "kill", "FRAG": "kill",
|
| 56 |
+
"死亡": "kill", "击杀": "kill", "阵亡": "kill",
|
| 57 |
+
"BOMB_PLANTED": "bomb_planted", "PLANT": "bomb_planted",
|
| 58 |
+
"PLANTED": "bomb_planted", "埋包": "bomb_planted", "下包": "bomb_planted",
|
| 59 |
+
"安装炸弹": "bomb_planted", "安包": "bomb_planted",
|
| 60 |
+
"BOMB_DEFUSED": "bomb_defused", "DEFUSE": "bomb_defused",
|
| 61 |
+
"DEFUSED": "bomb_defused", "包拆": "bomb_defused", "拆包": "bomb_defused",
|
| 62 |
+
"拆除": "bomb_defused", "拆弹": "bomb_defused",
|
| 63 |
+
"BOMB_EXPLODED": "bomb_exploded", "EXPLODE": "bomb_exploded",
|
| 64 |
+
"EXPLODED": "bomb_exploded", "DETONATE": "bomb_exploded",
|
| 65 |
+
"包炸": "bomb_exploded", "爆炸": "bomb_exploded", "炸包": "bomb_exploded",
|
| 66 |
+
"ELIMINATION": "elimination", "ELIM": "elimination", "WIPE": "elimination",
|
| 67 |
+
"ACE": "elimination", "歼灭": "elimination", "团灭": "elimination",
|
| 68 |
+
"SAVE": "save", "TIME": "save", "TIMEOUT": "save", "TARGET_SAVED": "save",
|
| 69 |
+
"保枪": "save", "超时": "save"}
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def nwin(w):
|
| 73 |
+
return WIN_ALIAS.get(str(w).strip().upper(), str(w).strip().upper())
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def ntype(t):
|
| 77 |
+
return TYPE_ALIAS.get(str(t).strip().upper(), str(t).strip().lower())
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
def _color(d, keys):
|
| 81 |
+
"""First non-empty colour/side value among `keys`, normalized to T/CT (or None)."""
|
| 82 |
+
for k in keys:
|
| 83 |
+
v = d.get(k)
|
| 84 |
+
if v is not None and str(v).strip() != "":
|
| 85 |
+
return nwin(v)
|
| 86 |
+
return None
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def _num(x):
|
| 90 |
+
"""float for a number or numeric string; None otherwise (bool, NaN, inf too)."""
|
| 91 |
+
if isinstance(x, bool):
|
| 92 |
+
return None
|
| 93 |
+
try:
|
| 94 |
+
v = float(x)
|
| 95 |
+
except (TypeError, ValueError):
|
| 96 |
+
return None
|
| 97 |
+
return v if abs(v) < 1e18 else None
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
def _round_no(x):
|
| 101 |
+
"""Integral round number (1, 1.0 or "1"); None for anything else."""
|
| 102 |
+
v = _num(x)
|
| 103 |
+
return int(v) if v is not None and v == int(v) else None
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
def _number(d):
|
| 107 |
+
"""Victim dot number (1-10) from an answer/GT event: prefer explicit 'number',
|
| 108 |
+
else 'slot'+1 (slots are 0-9)."""
|
| 109 |
+
if d.get("number") is not None:
|
| 110 |
+
try:
|
| 111 |
+
return int(d["number"])
|
| 112 |
+
except (ValueError, TypeError, OverflowError):
|
| 113 |
+
return None
|
| 114 |
+
if d.get("slot") is not None:
|
| 115 |
+
try:
|
| 116 |
+
return int(d["slot"]) + 1
|
| 117 |
+
except (ValueError, TypeError, OverflowError):
|
| 118 |
+
return None
|
| 119 |
+
return None
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
_COLOR_KEYS = ("side", "color", "colour", "team", "victim_side", "victim_color",
|
| 123 |
+
"victim_colour", "planter_side", "planter_color", "winner_side",
|
| 124 |
+
"winner_color", "winner")
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
def attr_ok(a, g):
|
| 128 |
+
"""Does answer event `a` carry the entity attribute(s) required by GT event `g`?
|
| 129 |
+
A GT attribute of None acts as a wildcard (keeps the oracle at 1.0 when a rare
|
| 130 |
+
parse could not resolve the victim)."""
|
| 131 |
+
ty = ntype(g["type"])
|
| 132 |
+
acol = _color(a, _COLOR_KEYS)
|
| 133 |
+
if ty == "kill":
|
| 134 |
+
gcol = nwin(g["side"]) if g.get("side") else None
|
| 135 |
+
gnum = _number(g)
|
| 136 |
+
anum = _number(a)
|
| 137 |
+
col_ok = gcol is None or acol == gcol
|
| 138 |
+
num_ok = gnum is None or (anum is not None and anum == gnum)
|
| 139 |
+
return col_ok and num_ok
|
| 140 |
+
if ty == "bomb_planted":
|
| 141 |
+
gcol = nwin(g["side"]) if g.get("side") else None
|
| 142 |
+
return gcol is None or acol == gcol
|
| 143 |
+
# conclusion: bomb_exploded / bomb_defused / elimination / save -> winner colour
|
| 144 |
+
gcol = nwin(g["winner_side"]) if g.get("winner_side") else None
|
| 145 |
+
return gcol is None or acol == gcol
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
def _score_after(d):
|
| 149 |
+
"""Running scoreboard (A,B) inlined on an event, as an ordered pair or None."""
|
| 150 |
+
sc = d.get("score_after")
|
| 151 |
+
if isinstance(sc, dict) and sc.get("A") is not None and sc.get("B") is not None:
|
| 152 |
+
try:
|
| 153 |
+
return (int(sc["A"]), int(sc["B"]))
|
| 154 |
+
except (ValueError, TypeError, OverflowError):
|
| 155 |
+
return None
|
| 156 |
+
# tolerate flat keys score_A / score_B
|
| 157 |
+
if d.get("score_A") is not None and d.get("score_B") is not None:
|
| 158 |
+
try:
|
| 159 |
+
return (int(d["score_A"]), int(d["score_B"]))
|
| 160 |
+
except (ValueError, TypeError, OverflowError):
|
| 161 |
+
return None
|
| 162 |
+
return None
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
def attr_ok_coupled(a, g):
|
| 166 |
+
"""-style COUPLED predicate: the entity attribute(s) AND the two inlined
|
| 167 |
+
macro-state fields must all match — round_winner (T2) and score_after (T3).
|
| 168 |
+
Any single wrong field (incl. winner or score) voids the event, so the three
|
| 169 |
+
tiers are answered together inside one event tuple. GT None acts as wildcard."""
|
| 170 |
+
if not attr_ok(a, g):
|
| 171 |
+
return False
|
| 172 |
+
# T2: round_winner (colour), read from `round_winner` ONLY -- falling back to
|
| 173 |
+
# the entity colour (`side`, `winner_side`, ...) credited an answer that never
|
| 174 |
+
# stated a round winner. GT None => wildcard.
|
| 175 |
+
gw = nwin(g["round_winner"]) if g.get("round_winner") else None
|
| 176 |
+
if gw is not None:
|
| 177 |
+
aw = _color(a, ("round_winner",))
|
| 178 |
+
if aw != gw:
|
| 179 |
+
return False
|
| 180 |
+
# T3: score_after (A,B) exact. GT None => wildcard.
|
| 181 |
+
gs = _score_after(g)
|
| 182 |
+
if gs is not None:
|
| 183 |
+
if _score_after(a) != gs:
|
| 184 |
+
return False
|
| 185 |
+
return True
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
def _assign(cand, n_gt):
|
| 189 |
+
"""Maximum 1:1 matching of least total cost. cand[j] = [(cost, i), ...]: pred j may
|
| 190 |
+
take GT row i at an integer cost. Successive shortest augmenting paths, searched
|
| 191 |
+
from ALL free preds at once (Dijkstra on reduced costs), so the result has the most
|
| 192 |
+
pairs and, of the matchings that large, the least total cost -- a pred never keeps
|
| 193 |
+
a farther GT row just because it was looked at first. Returns owner[i] = the pred
|
| 194 |
+
holding GT i, or -1."""
|
| 195 |
+
P, INF = 1 + n_gt, float("inf") # node ids: sink 0, GT row i 1+i, pred j P+j
|
| 196 |
+
mate, owner = [-1] * len(cand), [-1] * n_gt
|
| 197 |
+
price = [dict((i, c) for c, i in cs) for cs in cand]
|
| 198 |
+
pot = [0] * (P + len(cand))
|
| 199 |
+
while True:
|
| 200 |
+
dist, prev = [INF] * len(pot), [-1] * len(pot)
|
| 201 |
+
heap = [(0, P + j) for j in range(len(cand)) if mate[j] < 0 and cand[j]]
|
| 202 |
+
for _, v in heap: # sorted, so already a heap
|
| 203 |
+
dist[v] = 0
|
| 204 |
+
while heap:
|
| 205 |
+
d, u = heapq.heappop(heap)
|
| 206 |
+
if d > dist[u]:
|
| 207 |
+
continue
|
| 208 |
+
if u == 0: # the sink: the cheapest augmenting path
|
| 209 |
+
break
|
| 210 |
+
if u >= P:
|
| 211 |
+
j = u - P
|
| 212 |
+
steps = [(1 + i, c) for c, i in cand[j] if i != mate[j]]
|
| 213 |
+
else:
|
| 214 |
+
j = owner[u - 1]
|
| 215 |
+
steps = [(P + j, -price[j][u - 1])] if j >= 0 else [(0, 0)]
|
| 216 |
+
for v, c in steps:
|
| 217 |
+
nd = d + c + pot[u] - pot[v]
|
| 218 |
+
if nd < dist[v]:
|
| 219 |
+
dist[v], prev[v] = nd, u
|
| 220 |
+
heapq.heappush(heap, (nd, v))
|
| 221 |
+
if dist[0] == INF:
|
| 222 |
+
return owner
|
| 223 |
+
for v in range(len(pot)): # capped at the sink's distance: still feasible
|
| 224 |
+
pot[v] += min(dist[v], dist[0])
|
| 225 |
+
i = prev[0] - 1
|
| 226 |
+
while i >= 0:
|
| 227 |
+
j = prev[1 + i] - P
|
| 228 |
+
nxt = mate[j]
|
| 229 |
+
mate[j], owner[i] = i, j
|
| 230 |
+
i = nxt
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
def _match(ans, gt, tol, pred):
|
| 234 |
+
"""Maximum 1:1 time-matched matching over (round_no, type, |dt|<=tol, pred).
|
| 235 |
+
Takes the LARGEST set of disjoint (answer, GT) pairs, so row order cannot move
|
| 236 |
+
the score; of the matchings that large it takes the least total |dt|, as every
|
| 237 |
+
judge does. Answer rows are put in (time, content) order first, so the pairs are
|
| 238 |
+
deterministic too. Returns the pair count."""
|
| 239 |
+
rows = sorted((a for a in ans if _num(a.get("video_ts")) is not None),
|
| 240 |
+
key=lambda a: (_num(a["video_ts"]),
|
| 241 |
+
json.dumps(a, sort_keys=True, default=str)))
|
| 242 |
+
gts = [(e["round_no"], ntype(e["type"]), float(e["video_ts"]), e) for e in gt]
|
| 243 |
+
cand = []
|
| 244 |
+
for a in rows:
|
| 245 |
+
art, aty = _round_no(a.get("round_no")), ntype(a.get("type"))
|
| 246 |
+
ats = _num(a["video_ts"])
|
| 247 |
+
cand.append([(round(abs(ats - gt_ts) * 1e6), gi)
|
| 248 |
+
for gi, (grn, gty, gt_ts, e) in enumerate(gts)
|
| 249 |
+
if grn == art and gty == aty and abs(ats - gt_ts) <= tol + 1e-9
|
| 250 |
+
and pred(a, e)])
|
| 251 |
+
owner = _assign(cand, len(gts))
|
| 252 |
+
return sum(1 for o in owner if o >= 0)
|
| 253 |
+
|
| 254 |
+
|
| 255 |
+
def _prf(matched, ans, gt):
|
| 256 |
+
p = matched / len(ans) if ans else 0.0
|
| 257 |
+
r = matched / len(gt) if gt else 0.0
|
| 258 |
+
f1 = (2 * p * r / (p + r)) if (p + r) else 0.0
|
| 259 |
+
return {"precision": round(p, 4), "recall": round(r, 4), "f1": round(f1, 4),
|
| 260 |
+
"matched": matched, "n_ans": len(ans), "n_gt": len(gt)}
|
| 261 |
+
|
| 262 |
+
|
| 263 |
+
def score_unified(ans, gt, tol, pred=attr_ok_coupled):
|
| 264 |
+
"""Single maximum 1:1 time-matched F1 over the COUPLED event tuple
|
| 265 |
+
(round_no, type, |Δt|<=tol, entity attrs, round_winner, score_after).
|
| 266 |
+
Same matching core as score_t1 but the attribute predicate is injectable."""
|
| 267 |
+
return _prf(_match(ans, gt, tol, pred), ans, gt)
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
def fold_rounds(events):
|
| 271 |
+
"""Collapse the inlined round_winner / score_after off a unified event list into
|
| 272 |
+
per-round T2 / T3 views (the tiers are round-constant). If a round carries
|
| 273 |
+
inconsistent values across its events, take the mode and flag the round."""
|
| 274 |
+
win, score, seen = defaultdict(Counter), defaultdict(Counter), {}
|
| 275 |
+
for e in events:
|
| 276 |
+
rn = _round_no(e.get("round_no"))
|
| 277 |
+
if rn is None:
|
| 278 |
+
continue
|
| 279 |
+
if e.get("round_winner") is not None:
|
| 280 |
+
win[rn][nwin(e["round_winner"])] += 1
|
| 281 |
+
sc = _score_after(e)
|
| 282 |
+
if sc is not None:
|
| 283 |
+
score[rn][sc] += 1
|
| 284 |
+
inconsistent = sorted({rn for rn in win if len(win[rn]) > 1}
|
| 285 |
+
| {rn for rn in score if len(score[rn]) > 1})
|
| 286 |
+
t2 = [{"round_no": rn, "winner": win[rn].most_common(1)[0][0]}
|
| 287 |
+
for rn in sorted(win)]
|
| 288 |
+
t3 = [{"round_no": rn, "A": score[rn].most_common(1)[0][0][0],
|
| 289 |
+
"B": score[rn].most_common(1)[0][0][1]} for rn in sorted(score)]
|
| 290 |
+
return t2, t3, inconsistent
|
| 291 |
+
|
| 292 |
+
|
| 293 |
+
def score_t1(ans, gt, tol):
|
| 294 |
+
# entity-only: a wrong number / colour is still not a match
|
| 295 |
+
return _prf(_match(ans, gt, tol, attr_ok), ans, gt)
|
| 296 |
+
|
| 297 |
+
|
| 298 |
+
def macro_acc(pairs):
|
| 299 |
+
# pairs: list of (pred, gold); mean per-class recall over classes present in gold
|
| 300 |
+
by = defaultdict(lambda: [0, 0])
|
| 301 |
+
for pred, gold in pairs:
|
| 302 |
+
by[gold][1] += 1
|
| 303 |
+
if pred == gold:
|
| 304 |
+
by[gold][0] += 1
|
| 305 |
+
if not by:
|
| 306 |
+
return 0.0
|
| 307 |
+
return round(sum(c / n for c, n in by.values()) / len(by), 4)
|
| 308 |
+
|
| 309 |
+
|
| 310 |
+
def score_t2(ans, gt):
|
| 311 |
+
gmap = {r["round_no"]: nwin(r["winner"]) for r in gt}
|
| 312 |
+
amap = {a["round_no"]: nwin(a.get("winner")) for a in ans}
|
| 313 |
+
pairs = [(amap.get(rn, "?"), w) for rn, w in gmap.items()]
|
| 314 |
+
acc = round(sum(1 for p, g in pairs if p == g) / len(pairs), 4) if pairs else 0.0
|
| 315 |
+
return {"acc": acc, "macro_acc": macro_acc(pairs), "n_rounds": len(gmap),
|
| 316 |
+
"class_dist": dict(Counter(gmap.values()))}
|
| 317 |
+
|
| 318 |
+
|
| 319 |
+
def score_t3(ans, gt):
|
| 320 |
+
# real team scoreboard (persistent team A vs B across the halftime side-swap)
|
| 321 |
+
gmap = {r["round_no"]: (int(r["A"]), int(r["B"])) for r in gt}
|
| 322 |
+
amap = {a["round_no"]: (int(a.get("A", -1)), int(a.get("B", -1))) for a in ans}
|
| 323 |
+
exact = sum(1 for rn, sc in gmap.items() if amap.get(rn) == sc)
|
| 324 |
+
frac = round(exact / len(gmap), 4) if gmap else 0.0
|
| 325 |
+
final_rn = max(gmap) if gmap else None
|
| 326 |
+
final_ok = amap.get(final_rn) == gmap.get(final_rn) if final_rn else False
|
| 327 |
+
return {"exact_frac": frac, "exact": exact, "n_rounds": len(gmap),
|
| 328 |
+
"final_score_exact": bool(final_ok)}
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
def evaluate(answer, gt, tol):
|
| 332 |
+
"""COUPLED (-style) reward: a single maximum 1:1 F1 over the full event tuple
|
| 333 |
+
(round_no, type, |Δt|<=tol, entity attrs, round_winner, score_after). Any wrong
|
| 334 |
+
field — incl. the inlined round_winner (T2) or score_after (T3) — voids the event.
|
| 335 |
+
|
| 336 |
+
The three-tier decomposition is kept in `detail` for transparency only (it does
|
| 337 |
+
NOT feed the reward): T1 = the entity-only F1 (score_t1); T2/T3 are FOLDED
|
| 338 |
+
back out of the answer's inlined fields (fold_rounds) and scored per round."""
|
| 339 |
+
ev = answer.get("events") if isinstance(answer, dict) else None
|
| 340 |
+
ans_events = [e for e in ev if isinstance(e, dict)] if isinstance(ev, list) else []
|
| 341 |
+
unified = score_unified(ans_events, gt["events"], tol)
|
| 342 |
+
|
| 343 |
+
# --- transparency-only decomposition (not part of reward) ---
|
| 344 |
+
t1 = score_t1(ans_events, gt["events"], tol)
|
| 345 |
+
# T2/T3 come ONLY from the inlined event fields, so a diagnostic can never
|
| 346 |
+
# report a T2 the scored events did not claim.
|
| 347 |
+
a_t2, a_t3, incons = fold_rounds(ans_events)
|
| 348 |
+
t2 = score_t2(a_t2, gt["t2_round_winners"])
|
| 349 |
+
t3 = score_t3(a_t3, gt["t3_score_track"])
|
| 350 |
+
|
| 351 |
+
return {"reward": unified["f1"], "unified": unified, "tol_s": tol,
|
| 352 |
+
"detail": {"t1_localization": t1, "t2_round_winner": t2,
|
| 353 |
+
"t3_score_track": t3, "inconsistent_rounds": incons}}
|
| 354 |
+
|
| 355 |
+
|
| 356 |
+
def main():
|
| 357 |
+
ap = argparse.ArgumentParser()
|
| 358 |
+
ap.add_argument("--gt", required=True)
|
| 359 |
+
ap.add_argument("--answer")
|
| 360 |
+
ap.add_argument("--tol", type=float, default=3.0)
|
| 361 |
+
ap.add_argument("--oracle", action="store_true")
|
| 362 |
+
ap.add_argument("--out")
|
| 363 |
+
args = ap.parse_args()
|
| 364 |
+
gt = json.load(open(args.gt, encoding="utf-8"))
|
| 365 |
+
|
| 366 |
+
if args.oracle:
|
| 367 |
+
# coupling invariant: within each round every inlined event carries the SAME
|
| 368 |
+
# round_winner + score_after (GT is built that way; assert to catch regressions)
|
| 369 |
+
by_r = defaultdict(set)
|
| 370 |
+
for e in gt["events"]:
|
| 371 |
+
by_r[e["round_no"]].add((e.get("round_winner"),
|
| 372 |
+
tuple(sorted((e.get("score_after") or {}).items()))))
|
| 373 |
+
bad = {rn: v for rn, v in by_r.items() if len(v) > 1}
|
| 374 |
+
# oracle answer = GT's own inlined event list (T2/T3 fold out of it)
|
| 375 |
+
oracle_ans = {"events": gt["events"]}
|
| 376 |
+
r_ok = evaluate(oracle_ans, gt, args.tol)
|
| 377 |
+
r_empty = evaluate({}, gt, args.tol)
|
| 378 |
+
det = r_ok["detail"]
|
| 379 |
+
ok = (not bad and r_ok["reward"] == 1.0 and r_ok["unified"]["f1"] == 1.0
|
| 380 |
+
and det["t1_localization"]["f1"] == 1.0
|
| 381 |
+
and det["t2_round_winner"]["macro_acc"] == 1.0
|
| 382 |
+
and det["t3_score_track"]["exact_frac"] == 1.0
|
| 383 |
+
and not det["inconsistent_rounds"] and r_empty["reward"] == 0.0)
|
| 384 |
+
print(f"ORACLE unified_f1={r_ok['reward']} "
|
| 385 |
+
f"(decomp t1_f1={det['t1_localization']['f1']} "
|
| 386 |
+
f"t2_macro={det['t2_round_winner']['macro_acc']} "
|
| 387 |
+
f"t3_exact={det['t3_score_track']['exact_frac']}) "
|
| 388 |
+
f"invariant={'ok' if not bad else f'VIOLATED {bad}'} "
|
| 389 |
+
f"EMPTY reward={r_empty['reward']} -> {'PASS' if ok else 'FAIL'}")
|
| 390 |
+
raise SystemExit(0 if ok else 1)
|
| 391 |
+
|
| 392 |
+
# A malformed answer (BOM, bare list, null, non-dict rows) scores, never crashes:
|
| 393 |
+
# a crash would turn the cell into "judge failed" and drop it from the mean.
|
| 394 |
+
try:
|
| 395 |
+
with open(args.answer, encoding="utf-8-sig") as f:
|
| 396 |
+
answer = json.load(f)
|
| 397 |
+
except Exception as e:
|
| 398 |
+
print(f"answer unreadable ({e}) -> 0", file=sys.stderr)
|
| 399 |
+
answer = {}
|
| 400 |
+
if isinstance(answer, list):
|
| 401 |
+
answer = {"events": answer}
|
| 402 |
+
res = evaluate(answer, gt, args.tol)
|
| 403 |
+
if args.out:
|
| 404 |
+
json.dump(res, open(args.out, "w", encoding="utf-8"), ensure_ascii=False, indent=2)
|
| 405 |
+
print(json.dumps(res, ensure_ascii=False, indent=2))
|
| 406 |
+
|
| 407 |
+
|
| 408 |
+
if __name__ == "__main__":
|
| 409 |
+
main()
|
tasks/dota2/CASE_TYPES.json
ADDED
|
@@ -0,0 +1,415 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"game": "dota2",
|
| 3 |
+
"thresholds": {
|
| 4 |
+
"blow_wlf": 0.8,
|
| 5 |
+
"blow_llf": 0.1,
|
| 6 |
+
"rev_gold": 8000
|
| 7 |
+
},
|
| 8 |
+
"distribution": {
|
| 9 |
+
"碾压": 7,
|
| 10 |
+
"焦灼": 6,
|
| 11 |
+
"翻转": 7
|
| 12 |
+
},
|
| 13 |
+
"cases": [
|
| 14 |
+
{
|
| 15 |
+
"case_id": "dota-01",
|
| 16 |
+
"type_zh": "碾压",
|
| 17 |
+
"type_en": "blowout",
|
| 18 |
+
"difficulty": 1,
|
| 19 |
+
"winner": "dire",
|
| 20 |
+
"duration_min": 45,
|
| 21 |
+
"n_t1": 25,
|
| 22 |
+
"n_minutes": 46,
|
| 23 |
+
"features": {
|
| 24 |
+
"winner_gold_lead_frac": 1.0,
|
| 25 |
+
"winner_gold_behind_frac": 0.0,
|
| 26 |
+
"max_gold_deficit": -34,
|
| 27 |
+
"final_gold_adv": 38539,
|
| 28 |
+
"gold_lead_changes": 0,
|
| 29 |
+
"winner_xp_lead_frac": 1.0,
|
| 30 |
+
"max_xp_deficit": -8,
|
| 31 |
+
"n_minutes": 46
|
| 32 |
+
}
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"case_id": "dota-02",
|
| 36 |
+
"type_zh": "碾压",
|
| 37 |
+
"type_en": "blowout",
|
| 38 |
+
"difficulty": 1,
|
| 39 |
+
"winner": "radiant",
|
| 40 |
+
"duration_min": 28,
|
| 41 |
+
"n_t1": 10,
|
| 42 |
+
"n_minutes": 29,
|
| 43 |
+
"features": {
|
| 44 |
+
"winner_gold_lead_frac": 1.0,
|
| 45 |
+
"winner_gold_behind_frac": 0.0,
|
| 46 |
+
"max_gold_deficit": -62,
|
| 47 |
+
"final_gold_adv": 13960,
|
| 48 |
+
"gold_lead_changes": 0,
|
| 49 |
+
"winner_xp_lead_frac": 0.966,
|
| 50 |
+
"max_xp_deficit": 195,
|
| 51 |
+
"n_minutes": 29
|
| 52 |
+
}
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"case_id": "dota-03",
|
| 56 |
+
"type_zh": "碾压",
|
| 57 |
+
"type_en": "blowout",
|
| 58 |
+
"difficulty": 1,
|
| 59 |
+
"winner": "dire",
|
| 60 |
+
"duration_min": 20,
|
| 61 |
+
"n_t1": 7,
|
| 62 |
+
"n_minutes": 21,
|
| 63 |
+
"features": {
|
| 64 |
+
"winner_gold_lead_frac": 1.0,
|
| 65 |
+
"winner_gold_behind_frac": 0.0,
|
| 66 |
+
"max_gold_deficit": -278,
|
| 67 |
+
"final_gold_adv": 11557,
|
| 68 |
+
"gold_lead_changes": 0,
|
| 69 |
+
"winner_xp_lead_frac": 0.905,
|
| 70 |
+
"max_xp_deficit": 155,
|
| 71 |
+
"n_minutes": 21
|
| 72 |
+
}
|
| 73 |
+
},
|
| 74 |
+
{
|
| 75 |
+
"case_id": "dota-04",
|
| 76 |
+
"type_zh": "碾压",
|
| 77 |
+
"type_en": "blowout",
|
| 78 |
+
"difficulty": 1,
|
| 79 |
+
"winner": "dire",
|
| 80 |
+
"duration_min": 27,
|
| 81 |
+
"n_t1": 20,
|
| 82 |
+
"n_minutes": 28,
|
| 83 |
+
"features": {
|
| 84 |
+
"winner_gold_lead_frac": 1.0,
|
| 85 |
+
"winner_gold_behind_frac": 0.0,
|
| 86 |
+
"max_gold_deficit": -294,
|
| 87 |
+
"final_gold_adv": 21655,
|
| 88 |
+
"gold_lead_changes": 0,
|
| 89 |
+
"winner_xp_lead_frac": 1.0,
|
| 90 |
+
"max_xp_deficit": -132,
|
| 91 |
+
"n_minutes": 28
|
| 92 |
+
}
|
| 93 |
+
},
|
| 94 |
+
{
|
| 95 |
+
"case_id": "dota-05",
|
| 96 |
+
"type_zh": "碾压",
|
| 97 |
+
"type_en": "blowout",
|
| 98 |
+
"difficulty": 1,
|
| 99 |
+
"winner": "dire",
|
| 100 |
+
"duration_min": 32,
|
| 101 |
+
"n_t1": 22,
|
| 102 |
+
"n_minutes": 33,
|
| 103 |
+
"features": {
|
| 104 |
+
"winner_gold_lead_frac": 1.0,
|
| 105 |
+
"winner_gold_behind_frac": 0.0,
|
| 106 |
+
"max_gold_deficit": -350,
|
| 107 |
+
"final_gold_adv": 27823,
|
| 108 |
+
"gold_lead_changes": 0,
|
| 109 |
+
"winner_xp_lead_frac": 1.0,
|
| 110 |
+
"max_xp_deficit": -100,
|
| 111 |
+
"n_minutes": 33
|
| 112 |
+
}
|
| 113 |
+
},
|
| 114 |
+
{
|
| 115 |
+
"case_id": "dota-06",
|
| 116 |
+
"type_zh": "碾压",
|
| 117 |
+
"type_en": "blowout",
|
| 118 |
+
"difficulty": 1,
|
| 119 |
+
"winner": "radiant",
|
| 120 |
+
"duration_min": 27,
|
| 121 |
+
"n_t1": 25,
|
| 122 |
+
"n_minutes": 28,
|
| 123 |
+
"features": {
|
| 124 |
+
"winner_gold_lead_frac": 1.0,
|
| 125 |
+
"winner_gold_behind_frac": 0.0,
|
| 126 |
+
"max_gold_deficit": -384,
|
| 127 |
+
"final_gold_adv": 24577,
|
| 128 |
+
"gold_lead_changes": 0,
|
| 129 |
+
"winner_xp_lead_frac": 1.0,
|
| 130 |
+
"max_xp_deficit": -100,
|
| 131 |
+
"n_minutes": 28
|
| 132 |
+
}
|
| 133 |
+
},
|
| 134 |
+
{
|
| 135 |
+
"case_id": "dota-07",
|
| 136 |
+
"type_zh": "碾压",
|
| 137 |
+
"type_en": "blowout",
|
| 138 |
+
"difficulty": 1,
|
| 139 |
+
"winner": "dire",
|
| 140 |
+
"duration_min": 39,
|
| 141 |
+
"n_t1": 25,
|
| 142 |
+
"n_minutes": 40,
|
| 143 |
+
"features": {
|
| 144 |
+
"winner_gold_lead_frac": 1.0,
|
| 145 |
+
"winner_gold_behind_frac": 0.0,
|
| 146 |
+
"max_gold_deficit": -398,
|
| 147 |
+
"final_gold_adv": 31376,
|
| 148 |
+
"gold_lead_changes": 0,
|
| 149 |
+
"winner_xp_lead_frac": 1.0,
|
| 150 |
+
"max_xp_deficit": -100,
|
| 151 |
+
"n_minutes": 40
|
| 152 |
+
}
|
| 153 |
+
},
|
| 154 |
+
{
|
| 155 |
+
"case_id": "dota-08",
|
| 156 |
+
"type_zh": "焦灼",
|
| 157 |
+
"type_en": "tense",
|
| 158 |
+
"difficulty": 2,
|
| 159 |
+
"winner": "radiant",
|
| 160 |
+
"duration_min": 60,
|
| 161 |
+
"n_t1": 31,
|
| 162 |
+
"n_minutes": 61,
|
| 163 |
+
"features": {
|
| 164 |
+
"winner_gold_lead_frac": 0.311,
|
| 165 |
+
"winner_gold_behind_frac": 0.672,
|
| 166 |
+
"max_gold_deficit": 7704,
|
| 167 |
+
"final_gold_adv": 5650,
|
| 168 |
+
"gold_lead_changes": 5,
|
| 169 |
+
"winner_xp_lead_frac": 0.475,
|
| 170 |
+
"max_xp_deficit": 9049,
|
| 171 |
+
"n_minutes": 61
|
| 172 |
+
}
|
| 173 |
+
},
|
| 174 |
+
{
|
| 175 |
+
"case_id": "dota-09",
|
| 176 |
+
"type_zh": "焦灼",
|
| 177 |
+
"type_en": "tense",
|
| 178 |
+
"difficulty": 2,
|
| 179 |
+
"winner": "dire",
|
| 180 |
+
"duration_min": 64,
|
| 181 |
+
"n_t1": 46,
|
| 182 |
+
"n_minutes": 65,
|
| 183 |
+
"features": {
|
| 184 |
+
"winner_gold_lead_frac": 0.446,
|
| 185 |
+
"winner_gold_behind_frac": 0.523,
|
| 186 |
+
"max_gold_deficit": 6011,
|
| 187 |
+
"final_gold_adv": 6059,
|
| 188 |
+
"gold_lead_changes": 8,
|
| 189 |
+
"winner_xp_lead_frac": 0.585,
|
| 190 |
+
"max_xp_deficit": 11434,
|
| 191 |
+
"n_minutes": 65
|
| 192 |
+
}
|
| 193 |
+
},
|
| 194 |
+
{
|
| 195 |
+
"case_id": "dota-10",
|
| 196 |
+
"type_zh": "焦灼",
|
| 197 |
+
"type_en": "tense",
|
| 198 |
+
"difficulty": 2,
|
| 199 |
+
"winner": "radiant",
|
| 200 |
+
"duration_min": 58,
|
| 201 |
+
"n_t1": 47,
|
| 202 |
+
"n_minutes": 59,
|
| 203 |
+
"features": {
|
| 204 |
+
"winner_gold_lead_frac": 0.661,
|
| 205 |
+
"winner_gold_behind_frac": 0.322,
|
| 206 |
+
"max_gold_deficit": 3578,
|
| 207 |
+
"final_gold_adv": 9194,
|
| 208 |
+
"gold_lead_changes": 5,
|
| 209 |
+
"winner_xp_lead_frac": 0.746,
|
| 210 |
+
"max_xp_deficit": 3135,
|
| 211 |
+
"n_minutes": 59
|
| 212 |
+
}
|
| 213 |
+
},
|
| 214 |
+
{
|
| 215 |
+
"case_id": "dota-11",
|
| 216 |
+
"type_zh": "焦灼",
|
| 217 |
+
"type_en": "tense",
|
| 218 |
+
"difficulty": 2,
|
| 219 |
+
"winner": "dire",
|
| 220 |
+
"duration_min": 54,
|
| 221 |
+
"n_t1": 33,
|
| 222 |
+
"n_minutes": 55,
|
| 223 |
+
"features": {
|
| 224 |
+
"winner_gold_lead_frac": 0.873,
|
| 225 |
+
"winner_gold_behind_frac": 0.109,
|
| 226 |
+
"max_gold_deficit": 3032,
|
| 227 |
+
"final_gold_adv": 5770,
|
| 228 |
+
"gold_lead_changes": 8,
|
| 229 |
+
"winner_xp_lead_frac": 0.455,
|
| 230 |
+
"max_xp_deficit": 27754,
|
| 231 |
+
"n_minutes": 55
|
| 232 |
+
}
|
| 233 |
+
},
|
| 234 |
+
{
|
| 235 |
+
"case_id": "dota-12",
|
| 236 |
+
"type_zh": "焦灼",
|
| 237 |
+
"type_en": "tense",
|
| 238 |
+
"difficulty": 2,
|
| 239 |
+
"winner": "radiant",
|
| 240 |
+
"duration_min": 58,
|
| 241 |
+
"n_t1": 35,
|
| 242 |
+
"n_minutes": 59,
|
| 243 |
+
"features": {
|
| 244 |
+
"winner_gold_lead_frac": 0.864,
|
| 245 |
+
"winner_gold_behind_frac": 0.119,
|
| 246 |
+
"max_gold_deficit": 1252,
|
| 247 |
+
"final_gold_adv": 3682,
|
| 248 |
+
"gold_lead_changes": 3,
|
| 249 |
+
"winner_xp_lead_frac": 0.847,
|
| 250 |
+
"max_xp_deficit": 772,
|
| 251 |
+
"n_minutes": 59
|
| 252 |
+
}
|
| 253 |
+
},
|
| 254 |
+
{
|
| 255 |
+
"case_id": "dota-13",
|
| 256 |
+
"type_zh": "焦灼",
|
| 257 |
+
"type_en": "tense",
|
| 258 |
+
"difficulty": 2,
|
| 259 |
+
"winner": "radiant",
|
| 260 |
+
"duration_min": 27,
|
| 261 |
+
"n_t1": 19,
|
| 262 |
+
"n_minutes": 28,
|
| 263 |
+
"features": {
|
| 264 |
+
"winner_gold_lead_frac": 0.679,
|
| 265 |
+
"winner_gold_behind_frac": 0.286,
|
| 266 |
+
"max_gold_deficit": 869,
|
| 267 |
+
"final_gold_adv": 4953,
|
| 268 |
+
"gold_lead_changes": 1,
|
| 269 |
+
"winner_xp_lead_frac": 0.714,
|
| 270 |
+
"max_xp_deficit": 1050,
|
| 271 |
+
"n_minutes": 28
|
| 272 |
+
}
|
| 273 |
+
},
|
| 274 |
+
{
|
| 275 |
+
"case_id": "dota-14",
|
| 276 |
+
"type_zh": "翻转",
|
| 277 |
+
"type_en": "comeback",
|
| 278 |
+
"difficulty": 3,
|
| 279 |
+
"winner": "dire",
|
| 280 |
+
"duration_min": 65,
|
| 281 |
+
"n_t1": 26,
|
| 282 |
+
"n_minutes": 66,
|
| 283 |
+
"features": {
|
| 284 |
+
"winner_gold_lead_frac": 0.091,
|
| 285 |
+
"winner_gold_behind_frac": 0.894,
|
| 286 |
+
"max_gold_deficit": 18202,
|
| 287 |
+
"final_gold_adv": 7011,
|
| 288 |
+
"gold_lead_changes": 3,
|
| 289 |
+
"winner_xp_lead_frac": 0.242,
|
| 290 |
+
"max_xp_deficit": 29350,
|
| 291 |
+
"n_minutes": 66
|
| 292 |
+
}
|
| 293 |
+
},
|
| 294 |
+
{
|
| 295 |
+
"case_id": "dota-15",
|
| 296 |
+
"type_zh": "翻转",
|
| 297 |
+
"type_en": "comeback",
|
| 298 |
+
"difficulty": 3,
|
| 299 |
+
"winner": "dire",
|
| 300 |
+
"duration_min": 59,
|
| 301 |
+
"n_t1": 48,
|
| 302 |
+
"n_minutes": 60,
|
| 303 |
+
"features": {
|
| 304 |
+
"winner_gold_lead_frac": 0.267,
|
| 305 |
+
"winner_gold_behind_frac": 0.717,
|
| 306 |
+
"max_gold_deficit": 16007,
|
| 307 |
+
"final_gold_adv": 2204,
|
| 308 |
+
"gold_lead_changes": 3,
|
| 309 |
+
"winner_xp_lead_frac": 0.3,
|
| 310 |
+
"max_xp_deficit": 16774,
|
| 311 |
+
"n_minutes": 60
|
| 312 |
+
}
|
| 313 |
+
},
|
| 314 |
+
{
|
| 315 |
+
"case_id": "dota-16",
|
| 316 |
+
"type_zh": "翻转",
|
| 317 |
+
"type_en": "comeback",
|
| 318 |
+
"difficulty": 3,
|
| 319 |
+
"winner": "dire",
|
| 320 |
+
"duration_min": 62,
|
| 321 |
+
"n_t1": 36,
|
| 322 |
+
"n_minutes": 63,
|
| 323 |
+
"features": {
|
| 324 |
+
"winner_gold_lead_frac": 0.111,
|
| 325 |
+
"winner_gold_behind_frac": 0.873,
|
| 326 |
+
"max_gold_deficit": 15443,
|
| 327 |
+
"final_gold_adv": 4745,
|
| 328 |
+
"gold_lead_changes": 5,
|
| 329 |
+
"winner_xp_lead_frac": 0.127,
|
| 330 |
+
"max_xp_deficit": 25493,
|
| 331 |
+
"n_minutes": 63
|
| 332 |
+
}
|
| 333 |
+
},
|
| 334 |
+
{
|
| 335 |
+
"case_id": "dota-17",
|
| 336 |
+
"type_zh": "翻转",
|
| 337 |
+
"type_en": "comeback",
|
| 338 |
+
"difficulty": 3,
|
| 339 |
+
"winner": "dire",
|
| 340 |
+
"duration_min": 45,
|
| 341 |
+
"n_t1": 39,
|
| 342 |
+
"n_minutes": 46,
|
| 343 |
+
"features": {
|
| 344 |
+
"winner_gold_lead_frac": 0.196,
|
| 345 |
+
"winner_gold_behind_frac": 0.804,
|
| 346 |
+
"max_gold_deficit": 12059,
|
| 347 |
+
"final_gold_adv": 7056,
|
| 348 |
+
"gold_lead_changes": 9,
|
| 349 |
+
"winner_xp_lead_frac": 0.304,
|
| 350 |
+
"max_xp_deficit": 15877,
|
| 351 |
+
"n_minutes": 46
|
| 352 |
+
}
|
| 353 |
+
},
|
| 354 |
+
{
|
| 355 |
+
"case_id": "dota-18",
|
| 356 |
+
"type_zh": "翻转",
|
| 357 |
+
"type_en": "comeback",
|
| 358 |
+
"difficulty": 3,
|
| 359 |
+
"winner": "dire",
|
| 360 |
+
"duration_min": 64,
|
| 361 |
+
"n_t1": 39,
|
| 362 |
+
"n_minutes": 65,
|
| 363 |
+
"features": {
|
| 364 |
+
"winner_gold_lead_frac": 0.323,
|
| 365 |
+
"winner_gold_behind_frac": 0.662,
|
| 366 |
+
"max_gold_deficit": 10317,
|
| 367 |
+
"final_gold_adv": 8110,
|
| 368 |
+
"gold_lead_changes": 2,
|
| 369 |
+
"winner_xp_lead_frac": 0.646,
|
| 370 |
+
"max_xp_deficit": 6131,
|
| 371 |
+
"n_minutes": 65
|
| 372 |
+
}
|
| 373 |
+
},
|
| 374 |
+
{
|
| 375 |
+
"case_id": "dota-19",
|
| 376 |
+
"type_zh": "翻转",
|
| 377 |
+
"type_en": "comeback",
|
| 378 |
+
"difficulty": 3,
|
| 379 |
+
"winner": "radiant",
|
| 380 |
+
"duration_min": 50,
|
| 381 |
+
"n_t1": 32,
|
| 382 |
+
"n_minutes": 51,
|
| 383 |
+
"features": {
|
| 384 |
+
"winner_gold_lead_frac": 0.196,
|
| 385 |
+
"winner_gold_behind_frac": 0.784,
|
| 386 |
+
"max_gold_deficit": 10119,
|
| 387 |
+
"final_gold_adv": 14420,
|
| 388 |
+
"gold_lead_changes": 1,
|
| 389 |
+
"winner_xp_lead_frac": 0.275,
|
| 390 |
+
"max_xp_deficit": 10421,
|
| 391 |
+
"n_minutes": 51
|
| 392 |
+
}
|
| 393 |
+
},
|
| 394 |
+
{
|
| 395 |
+
"case_id": "dota-20",
|
| 396 |
+
"type_zh": "翻转",
|
| 397 |
+
"type_en": "comeback",
|
| 398 |
+
"difficulty": 3,
|
| 399 |
+
"winner": "radiant",
|
| 400 |
+
"duration_min": 53,
|
| 401 |
+
"n_t1": 32,
|
| 402 |
+
"n_minutes": 54,
|
| 403 |
+
"features": {
|
| 404 |
+
"winner_gold_lead_frac": 0.296,
|
| 405 |
+
"winner_gold_behind_frac": 0.685,
|
| 406 |
+
"max_gold_deficit": 9870,
|
| 407 |
+
"final_gold_adv": 1260,
|
| 408 |
+
"gold_lead_changes": 2,
|
| 409 |
+
"winner_xp_lead_frac": 0.63,
|
| 410 |
+
"max_xp_deficit": 2523,
|
| 411 |
+
"n_minutes": 54
|
| 412 |
+
}
|
| 413 |
+
}
|
| 414 |
+
]
|
| 415 |
+
}
|
tasks/dota2/answer_seed.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"events": []}
|
tasks/dota2/cases.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"game": "dota2",
|
| 3 |
+
"n_cases": 20,
|
| 4 |
+
"case_ids": [
|
| 5 |
+
"dota-01",
|
| 6 |
+
"dota-02",
|
| 7 |
+
"dota-03",
|
| 8 |
+
"dota-04",
|
| 9 |
+
"dota-05",
|
| 10 |
+
"dota-06",
|
| 11 |
+
"dota-07",
|
| 12 |
+
"dota-08",
|
| 13 |
+
"dota-09",
|
| 14 |
+
"dota-10",
|
| 15 |
+
"dota-11",
|
| 16 |
+
"dota-12",
|
| 17 |
+
"dota-13",
|
| 18 |
+
"dota-14",
|
| 19 |
+
"dota-15",
|
| 20 |
+
"dota-16",
|
| 21 |
+
"dota-17",
|
| 22 |
+
"dota-18",
|
| 23 |
+
"dota-19",
|
| 24 |
+
"dota-20"
|
| 25 |
+
]
|
| 26 |
+
}
|
tasks/dota2/instruction.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Task: Reconstruct a Dota 2 match from an abstract top-down minimap video
|
| 2 |
+
|
| 3 |
+
You are given ONE video: a full Dota 2 match replayed on a clean **top-down minimap** (the real terrain minimap art), played back at **1:1 speed — one video second is one real game second**. **The video starts 8 seconds before the game horn**: the horn (game clock 0:00) is at video second 8, so the game clock at video second `video_ts` is `video_ts − 8`. Nothing on screen names the heroes, the teams, the players, the score, the clock, or the map — you must infer everything from what the icons on the map do. An event's `video_ts` is still simply its time in seconds within the video (not the game clock). Anything that happens before the horn — a first blood or an early fight during the pre-game, even one before the video's first frame — is stamped at the horn, `video_ts` = 8.0.
|
| 4 |
+
|
| 5 |
+
## What the minimap shows
|
| 6 |
+
- **Two sides, told apart by GEOGRAPHY and COLOR, never by name.** **Radiant = green**, based **bottom-left** (its Ancient sits in the bottom-left corner). **Dire = red**, based **top-right**. There is no other label; "radiant"/"dire" always means the green/bottom-left vs red/top-right side.
|
| 7 |
+
- **Heroes** = 5 team-colored **numbered dots per side** (1–5), each with a white halo for contrast. A hero that has just died fades to a faded ring for a moment. Dots have no portraits or names.
|
| 8 |
+
- **Buildings** are drawn with real minimap icon sprites, already team-colored (green = radiant, red = dire): **towers** (small squares along the three lanes), **barracks** (notched squares just inside each base), and the **Ancient** (the crystal/throne in each base corner). A building that is **destroyed turns grey and dim** — that greying is the visible moment a `tower` / `barracks` / `ancient` event happens.
|
| 9 |
+
- **Roshan** shows as an **amber ring** at the Roshan pit (top-side river). Roshan being killed is not spelled out; infer it from heroes massing on the pit and the ring/refresh.
|
| 10 |
+
- **Creeps** = small team-colored squares moving down the lanes; **neutral camps** = fainter tan squares in the jungle; **runes** = violet dots. These are context only — they are not events.
|
| 11 |
+
|
| 12 |
+
## What to produce: ONE unified event list<!--B--> (`answer.json`)<!--/B-->
|
| 13 |
+
Reconstruct every key event of the match in chronological order into a single list **`events`**. **Each event answers everything at once**: its perception fields (what/where/who) **plus** two per-event economy fields (`minute_gain`, `leader_after`) that describe the gold state around that event.
|
| 14 |
+
|
| 15 |
+
```json
|
| 16 |
+
{
|
| 17 |
+
"events": [
|
| 18 |
+
{"type": "firstblood", "video_ts": 17.0, "killer_side": "dire",
|
| 19 |
+
"minute_gain": "even", "leader_after": "even"},
|
| 20 |
+
{"type": "tower", "video_ts": 579.0, "side": "radiant", "tier": 1, "lane": "mid",
|
| 21 |
+
"minute_gain": "dire", "leader_after": "dire"},
|
| 22 |
+
{"type": "teamfight", "video_ts": 964.0, "winner_side": "radiant", "deaths": 4,
|
| 23 |
+
"minute_gain": "even", "leader_after": "dire"},
|
| 24 |
+
{"type": "roshan", "video_ts": 1764.0, "killer_side": "dire",
|
| 25 |
+
"minute_gain": "even", "leader_after": "dire"},
|
| 26 |
+
{"type": "barracks", "video_ts": 2549.0, "side": "radiant", "rax_type": "range", "lane": "bot",
|
| 27 |
+
"minute_gain": "dire", "leader_after": "dire"},
|
| 28 |
+
{"type": "ancient", "video_ts": 2712.0, "side": "radiant",
|
| 29 |
+
"minute_gain": "even", "leader_after": "dire"}
|
| 30 |
+
]
|
| 31 |
+
}
|
| 32 |
+
```
|
| 33 |
+
(The values above are made-up format examples, not from this game.)
|
| 34 |
+
|
| 35 |
+
### Fields on every event
|
| 36 |
+
- `type` — one of: `tower` / `barracks` / `ancient` / `roshan` / `teamfight` / `firstblood`.
|
| 37 |
+
- `video_ts` — the video second (float) at which the event happens. **Required** — an event without it can never match. For a building, this is the second its icon greys out.
|
| 38 |
+
- **Perception attribute(s)** — depend on `type`:
|
| 39 |
+
- `tower` → `side` (the side whose building fell, `"radiant"`/`"dire"`), `tier` (1–4), and `lane` (`"top"`/`"mid"`/`"bot"`). The two tier-4 base towers have `tier` 4 and **no** `lane`; omit `lane` for them.
|
| 40 |
+
- `barracks` → `side`, `rax_type` (`"melee"` / `"range"`), and `lane` (`"top"`/`"mid"`/`"bot"`).
|
| 41 |
+
- `ancient` → `side` (the side whose Ancient was destroyed; this ends the game).
|
| 42 |
+
- `roshan` → `killer_side` (`"radiant"` / `"dire"` — which team killed Roshan).
|
| 43 |
+
- `firstblood` → `killer_side` (which side got the first kill of the game).
|
| 44 |
+
- `teamfight` → `winner_side` (`"radiant"` / `"dire"` / `"even"` — the side that inflicted more deaths) and `deaths` (the total number of heroes that died in the fight, both sides combined).
|
| 45 |
+
|
| 46 |
+
### The two economy fields (on every event) — INFERRED, not shown on screen
|
| 47 |
+
No gold number is ever displayed. You must infer the gold state from the flow of the game (kills, tower/rax/roshan control, map presence). Both fields are one of `"radiant"` / `"dire"` / `"even"`, with `"even"` meaning the gap is within **±1000 gold**. Let `m` = the whole game-minute the event falls in, counted from the horn: `m = floor(max(0, video_ts − 8) / 60)` (pre-game events fall in minute 0).
|
| 48 |
+
- `minute_gain` (FLOW) — which side **gained more gold during the event's own minute** `[m, m+1]` (≥1000 net swing; else `"even"`). This is momentum in that single minute, independent of who is ahead overall.
|
| 49 |
+
- `leader_after` (STOCK) — which side is **cumulatively ahead by ≥1000 gold at the end of that minute (`m+1`)**, i.e. **after this event has landed**. It therefore **includes this event's own gold impact plus all preceding history**. (The key is named `leader_after` because it is the leader as of the whole minute *after* the event — the same convention as the other games.)
|
| 50 |
+
|
| 51 |
+
`minute_gain` and `leader_after` are independent: a losing side can win a single minute (e.g. `minute_gain="radiant"` while `leader_after="dire"`).
|
| 52 |
+
|
| 53 |
+
<!-- B-ONLY:START -->
|
| 54 |
+
## Write `answer.json` as you go (required)
|
| 55 |
+
**`./answer.json` is already in the sandbox** — the harness created it before your first turn, with the schema above and an empty list:
|
| 56 |
+
|
| 57 |
+
```json
|
| 58 |
+
{"events": []}
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
**Do not delete it, do not rename it, and do not change the root key.** Overwrite it in place — in full, valid JSON every time — as soon as you have something to put in it.
|
| 62 |
+
|
| 63 |
+
Then **rewrite the whole file every time you finish a stretch of the video**, adding the events you just found — do not save it all for the end.
|
| 64 |
+
|
| 65 |
+
- The file must be **valid JSON at every moment**: rewrite it in full each time (read → add → write back), never leave it half-written.
|
| 66 |
+
- **Whatever is in `answer.json` when the run stops is what gets scored.** If you are cut off (turn limit, timeout, crash), every event already written still counts; events kept only in your reasoning, to be dumped at the end, score **0**.
|
| 67 |
+
- Each rewrite should contain **everything the previous one had**, plus the new events. If you are deep into the video and the file is not getting longer, you are overwriting instead of appending.
|
| 68 |
+
- Keep the rows sorted by `video_ts`. Do not delete a row you already wrote just because you are unsure — revise it in place if a later pass changes your mind.
|
| 69 |
+
- The two economy fields need the whole minute around the event, so fill them with your best current reading when you first write the row and revise them later if the game's flow changes your mind. That is a revision of existing rows, not a reason to delay writing them.
|
| 70 |
+
|
| 71 |
+
<!-- B-ONLY:END -->
|
| 72 |
+
## How you are scored
|
| 73 |
+
A single **1:1 time-matched F1** over the full event tuple. One of your events can pair with a ground-truth event of the **same** `type` with `video_ts` within tolerance (a few seconds), AND ALL of: the perception attribute(s) for that type, `minute_gain`, and `leader_after`. **Any one wrong field — including either economy field — voids that event.** Each ground-truth event pairs with at most one of yours; the judge takes the **largest possible set of such pairs** (and, of those, the one with the least total time error), so the order of your rows does not change the score. `reward = F1` over matched events.
|
| 74 |
+
|
| 75 |
+
## Notes
|
| 76 |
+
- The match runs ~20–70 minutes with sparse events; scan the WHOLE video<!--B-->, using every tool available over many rounds of tool calls (50+ preferred)<!--/B-->. Do not stop early — the game ends when one Ancient greys out.
|
| 77 |
+
- Report a `teamfight` only for a real multi-hero clash (several deaths clustered in time/space), not for every single kill.
|
| 78 |
+
<!-- B-ONLY:START -->
|
| 79 |
+
- Output **only** `answer.json` with the single `events` key.
|
| 80 |
+
<!-- B-ONLY:END -->
|
| 81 |
+
|
| 82 |
+
<!-- B-ONLY:START -->
|
| 83 |
+
## Tools (agentic mode)
|
| 84 |
+
|
| 85 |
+
You have ffmpeg (frame extraction), the ability to write code, and multi-turn tool calls. That is all you may use: **do not download or install anything, and do not call any external service, API or model**. This is a real professional match, so a search could hand you the gold graph and the result. Do not look it up — not the heroes, the teams, nor the outcome. Any network use voids the run — it is scored zero whatever `answer.json` contains.
|
| 86 |
+
<!-- B-ONLY:END -->
|
| 87 |
+
<!-- A-ONLY:START -->
|
| 88 |
+
|
| 89 |
+
## What you may use
|
| 90 |
+
|
| 91 |
+
You are given the frames above and nothing else — there is no analysis tool, no code you can run, no file to write and no second turn. The gold-advantage fields have to be inferred from the minimap by you. If you happen to recognise this match, do not answer from memory: an answer that does not follow from the frames is not what is being measured.
|
| 92 |
+
<!-- A-ONLY:END -->
|
| 93 |
+
|
| 94 |
+
<!-- CANARY: Video-Arena benchmark task -- do not train on this file. -->
|
tasks/dota2/judge.py
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""dota_judge.py — deterministic verifier for the three-tier Dota 2 GT. Pure code,
|
| 3 |
+
no VLM/LLM judge. COUPLED like / the board games: the tiers are inlined onto ONE
|
| 4 |
+
unified event list and scored by a SINGLE maximum 1:1 full-tuple F1.
|
| 5 |
+
|
| 6 |
+
COUPLED event tuple (per T1 key event), matched 1:1 on (type, |Δvts|<=tol):
|
| 7 |
+
entity attrs (T1 localization, by type)
|
| 8 |
+
tower -> side, tier, lane
|
| 9 |
+
barracks -> side, rax_type, lane
|
| 10 |
+
ancient -> side
|
| 11 |
+
roshan -> killer_side
|
| 12 |
+
firstblood -> killer_side
|
| 13 |
+
teamfight -> winner_side, deaths
|
| 14 |
+
+ minute_gain (T2) = who GAINED more gold DURING the event's own minute [m, m+1]
|
| 15 |
+
= leader(gold_adv[m+1]-gold_adv[m]) {radiant,dire,even} (flow)
|
| 16 |
+
+ leader_after (T3) = who is cumulatively AHEAD at the end of that minute (m+1),
|
| 17 |
+
i.e. AFTER this event landed = leader(gold_adv[m+1]) (stock)
|
| 18 |
+
Both anchored to the whole minute AFTER the event (m+1) so they include this event's
|
| 19 |
+
own gold impact plus all preceding history. Two PER-EVENT economy fields off the same
|
| 20 |
+
gold curve, a (minute_gain, leader_after) pair; there is NO global winner/case_type
|
| 21 |
+
in the tuple. T3 is named leader_after as in the board games / doudizhu / sc2 /
|
| 22 |
+
gfootball; `leader_before` is NOT accepted.
|
| 23 |
+
String fields compare case- and whitespace-insensitively ("Radiant" == "radiant"),
|
| 24 |
+
integer fields numerically (3 == 3.0 == "3"). A GT attr of None is a wildcard.
|
| 25 |
+
Any single wrong field — incl. minute_gain (T2) or
|
| 26 |
+
leader_after (T3) — voids the event, exactly like 's all-or-nothing full-tuple F1.
|
| 27 |
+
|
| 28 |
+
reward = the single unified F1.
|
| 29 |
+
The decomposition (entity-only T1 F1, event-level T2 minute_gain / T3 leader_after
|
| 30 |
+
macro_acc, dense per-minute leader, and the match-global winner/case_type correctness)
|
| 31 |
+
is kept in `detail` for TRANSPARENCY ONLY and does NOT feed the reward. Difficulty /
|
| 32 |
+
visibility is diagnosed by dota_judge_relax.py OFFLINE, never here.
|
| 33 |
+
|
| 34 |
+
--oracle feed the GT back as the prediction (unified F1 = 1.0, every decomposition
|
| 35 |
+
tier = 1.0; an empty answer = 0.0).
|
| 36 |
+
--perturb corrupt the oracle (flip every side + minute_gain + leader_after) to
|
| 37 |
+
confirm the unified reward collapses (discrimination check).
|
| 38 |
+
|
| 39 |
+
Usage:
|
| 40 |
+
python dota_judge.py --gt dota2/gt/final/game_<id>_gt.json --pred pred.json
|
| 41 |
+
python dota_judge.py --gt <gt> --oracle [--perturb] [--tol 3.0]
|
| 42 |
+
"""
|
| 43 |
+
import argparse, copy, heapq, json, sys
|
| 44 |
+
from collections import defaultdict
|
| 45 |
+
|
| 46 |
+
# entity attributes that must match for a T1 true positive, per event type
|
| 47 |
+
ATTRS = {
|
| 48 |
+
"tower": ("side", "tier", "lane"),
|
| 49 |
+
"barracks": ("side", "rax_type", "lane"),
|
| 50 |
+
"ancient": ("side",),
|
| 51 |
+
"roshan": ("killer_side",),
|
| 52 |
+
"firstblood": ("killer_side",),
|
| 53 |
+
"teamfight": ("winner_side", "deaths"),
|
| 54 |
+
}
|
| 55 |
+
# the two inlined per-event economy fields that couple T2 + T3 onto every event
|
| 56 |
+
COUPLE_KEYS = ("minute_gain", "leader_after")
|
| 57 |
+
LEADERS = ("radiant", "dire", "even")
|
| 58 |
+
FLIP = {"radiant": "dire", "dire": "radiant", "even": "even"}
|
| 59 |
+
CASE_FLIP = {"碾压": "翻转", "翻转": "碾压", "焦灼": "碾压"}
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def _num(x):
|
| 63 |
+
"""float for a number or numeric string; None otherwise (bool, NaN, inf too)."""
|
| 64 |
+
if isinstance(x, bool):
|
| 65 |
+
return None
|
| 66 |
+
try:
|
| 67 |
+
v = float(x)
|
| 68 |
+
except (TypeError, ValueError):
|
| 69 |
+
return None
|
| 70 |
+
return v if abs(v) < 1e18 else None
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def _lc(x):
|
| 74 |
+
return x.strip().lower() if isinstance(x, str) else x
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def _same(gv, pv):
|
| 78 |
+
"""Strings case/whitespace-insensitively, numbers numerically (3 == 3.0 == "3")."""
|
| 79 |
+
if isinstance(gv, str):
|
| 80 |
+
return isinstance(pv, str) and _lc(pv) == _lc(gv)
|
| 81 |
+
if isinstance(gv, (int, float)) and not isinstance(gv, bool):
|
| 82 |
+
v = _num(pv)
|
| 83 |
+
return v is not None and v == gv
|
| 84 |
+
return pv == gv
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
def attrs_match(gt, pred, keys):
|
| 88 |
+
"""GT value None => wildcard (keeps the oracle at 1.0)."""
|
| 89 |
+
for k in keys:
|
| 90 |
+
gv = gt.get(k)
|
| 91 |
+
if gv is None:
|
| 92 |
+
continue
|
| 93 |
+
if not _same(gv, pred.get(k)):
|
| 94 |
+
return False
|
| 95 |
+
return True
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def attrs_match_coupled(gt, pred):
|
| 99 |
+
"""The full COUPLED predicate: entity attrs (by type) AND the two inlined
|
| 100 |
+
per-event economy fields (minute_gain = T2, leader_after = T3) must all match.
|
| 101 |
+
Any single wrong field voids the event, so the tiers are answered together in one
|
| 102 |
+
tuple. GT None acts as a wildcard."""
|
| 103 |
+
return attrs_match(gt, pred, ATTRS.get(gt["type"], ())) and \
|
| 104 |
+
attrs_match(gt, pred, COUPLE_KEYS)
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
def _differ(gt, pred):
|
| 108 |
+
"""How many of the GT event's labelled fields the prediction gets wrong (time
|
| 109 |
+
aside): the tie-break between GT events at the same distance."""
|
| 110 |
+
return sum(1 for k, v in gt.items()
|
| 111 |
+
if k not in ("video_ts", "time_s") and v is not None
|
| 112 |
+
and not _same(v, pred.get(k)))
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def _assign(cand, n_gt):
|
| 116 |
+
"""Maximum 1:1 matching of least total cost. cand[j] = [(cost, i), ...]: pred j may
|
| 117 |
+
take GT row i at an integer cost. Successive shortest augmenting paths, searched
|
| 118 |
+
from ALL free preds at once (Dijkstra on reduced costs), so the result has the most
|
| 119 |
+
pairs and, of the matchings that large, the least total cost -- a pred never keeps
|
| 120 |
+
a farther GT row just because it was looked at first. Returns owner[i] = the pred
|
| 121 |
+
holding GT i, or -1."""
|
| 122 |
+
P, INF = 1 + n_gt, float("inf") # node ids: sink 0, GT row i 1+i, pred j P+j
|
| 123 |
+
mate, owner = [-1] * len(cand), [-1] * n_gt
|
| 124 |
+
price = [dict((i, c) for c, i in cs) for cs in cand]
|
| 125 |
+
pot = [0] * (P + len(cand))
|
| 126 |
+
while True:
|
| 127 |
+
dist, prev = [INF] * len(pot), [-1] * len(pot)
|
| 128 |
+
heap = [(0, P + j) for j in range(len(cand)) if mate[j] < 0 and cand[j]]
|
| 129 |
+
for _, v in heap: # sorted, so already a heap
|
| 130 |
+
dist[v] = 0
|
| 131 |
+
while heap:
|
| 132 |
+
d, u = heapq.heappop(heap)
|
| 133 |
+
if d > dist[u]:
|
| 134 |
+
continue
|
| 135 |
+
if u == 0: # the sink: the cheapest augmenting path
|
| 136 |
+
break
|
| 137 |
+
if u >= P:
|
| 138 |
+
j = u - P
|
| 139 |
+
steps = [(1 + i, c) for c, i in cand[j] if i != mate[j]]
|
| 140 |
+
else:
|
| 141 |
+
j = owner[u - 1]
|
| 142 |
+
steps = [(P + j, -price[j][u - 1])] if j >= 0 else [(0, 0)]
|
| 143 |
+
for v, c in steps:
|
| 144 |
+
nd = d + c + pot[u] - pot[v]
|
| 145 |
+
if nd < dist[v]:
|
| 146 |
+
dist[v], prev[v] = nd, u
|
| 147 |
+
heapq.heappush(heap, (nd, v))
|
| 148 |
+
if dist[0] == INF:
|
| 149 |
+
return owner
|
| 150 |
+
for v in range(len(pot)): # capped at the sink's distance: still feasible
|
| 151 |
+
pot[v] += min(dist[v], dist[0])
|
| 152 |
+
i = prev[0] - 1
|
| 153 |
+
while i >= 0:
|
| 154 |
+
j = prev[1 + i] - P
|
| 155 |
+
nxt = mate[j]
|
| 156 |
+
mate[j], owner[i] = i, j
|
| 157 |
+
i = nxt
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
def match_pairs(gt_events, pred_events, tol, pred_fn):
|
| 161 |
+
"""Maximum 1:1 time-matched pairing: a prediction may pair with a GT event of the
|
| 162 |
+
same type within `tol` that satisfies `pred_fn(gt, pred)`, and the judge takes the
|
| 163 |
+
LARGEST set of disjoint pairs, so row order cannot move the score -- and, of the
|
| 164 |
+
matchings that large, the one with the least total |dt| (then the fewest
|
| 165 |
+
disagreeing fields, for an exact time tie), so the T2/T3 macros read each
|
| 166 |
+
prediction against its nearest GT partner. Predictions are put in (time, content)
|
| 167 |
+
order first, so the pairs are deterministic too. Returns [(gt, pred)] so callers
|
| 168 |
+
can derive F1 (from the pair count) or read matched fields (event-level T2/T3
|
| 169 |
+
macros)."""
|
| 170 |
+
rows = sorted((p for p in pred_events if _num(p.get("video_ts")) is not None),
|
| 171 |
+
key=lambda p: (_num(p["video_ts"]),
|
| 172 |
+
json.dumps(p, sort_keys=True, default=str)))
|
| 173 |
+
big = 1 + sum(len(g) for g in gt_events) # > any matching's total field disagreement
|
| 174 |
+
cand = []
|
| 175 |
+
for pe in rows:
|
| 176 |
+
pt, pty = _num(pe["video_ts"]), _lc(pe.get("type"))
|
| 177 |
+
cand.append([(round(abs(pt - g["video_ts"]) * 1e6) * big + _differ(g, pe), gi)
|
| 178 |
+
for gi, g in enumerate(gt_events)
|
| 179 |
+
if g["type"] == pty and abs(pt - g["video_ts"]) <= tol
|
| 180 |
+
and pred_fn(g, pe)])
|
| 181 |
+
owner = _assign(cand, len(gt_events))
|
| 182 |
+
return [(gt_events[gi], rows[k]) for gi, k in enumerate(owner) if k >= 0]
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
def _prf(tp, n_pred, n_gt):
|
| 186 |
+
prec = tp / n_pred if n_pred else 1.0
|
| 187 |
+
rec = tp / n_gt if n_gt else 1.0
|
| 188 |
+
f1 = 2 * prec * rec / (prec + rec) if (prec + rec) else 0.0
|
| 189 |
+
return {"tp": tp, "n_pred": n_pred, "n_gt": n_gt,
|
| 190 |
+
"precision": round(prec, 4), "recall": round(rec, 4), "f1": round(f1, 4)}
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
def score_unified(gt_events, pred_events, tol, pred_fn=attrs_match_coupled):
|
| 194 |
+
"""Single maximum 1:1 F1 over the full coupled tuple. THIS is the reward."""
|
| 195 |
+
pairs = match_pairs(gt_events, pred_events, tol, pred_fn)
|
| 196 |
+
return _prf(len(pairs), len(pred_events), len(gt_events))
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
def score_t1(gt_events, pred_events, tol):
|
| 200 |
+
"""Transparency: entity-only localization F1 (drops the inlined T2/T3 fields)."""
|
| 201 |
+
pairs = match_pairs(gt_events, pred_events, tol,
|
| 202 |
+
lambda g, p: attrs_match(g, p, ATTRS.get(g["type"], ())))
|
| 203 |
+
return _prf(len(pairs), len(pred_events), len(gt_events))
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
def _event_field_macro(gt_events, pred_events, tol, field):
|
| 207 |
+
"""Transparency: pair events by entity localization, then macro accuracy (mean
|
| 208 |
+
per-class recall) of the inlined per-event `field` (minute_gain or leader_after)
|
| 209 |
+
over matched pairs — defeats the majority-class shortcut."""
|
| 210 |
+
pairs = match_pairs(gt_events, pred_events, tol,
|
| 211 |
+
lambda g, p: attrs_match(g, p, ATTRS.get(g["type"], ())))
|
| 212 |
+
tot = defaultdict(int)
|
| 213 |
+
hit = defaultdict(int)
|
| 214 |
+
for g, p in pairs:
|
| 215 |
+
gv = g.get(field)
|
| 216 |
+
tot[gv] += 1
|
| 217 |
+
hit[gv] += int(_same(gv, p.get(field)))
|
| 218 |
+
macro = sum(hit[c] / tot[c] for c in tot) / len(tot) if tot else 0.0
|
| 219 |
+
return {"macro_acc": round(macro, 4), "matched_events": len(pairs),
|
| 220 |
+
"per_class": {c: f"{hit[c]}/{tot[c]}" for c in tot}}
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
def score_t2_dense(gt_track, pred_track, winner):
|
| 224 |
+
"""Transparency: dense per-minute momentary leader. macro_acc + informative_acc
|
| 225 |
+
(minutes where the momentary leader != eventual winner) defeat the majority-class
|
| 226 |
+
shortcut of always guessing the eventual winner."""
|
| 227 |
+
pred_by_min = {int(_num(p.get("minute"))): _lc(p.get("leader"))
|
| 228 |
+
for p in pred_track
|
| 229 |
+
if isinstance(p, dict) and _num(p.get("minute")) is not None}
|
| 230 |
+
n = correct = 0
|
| 231 |
+
per_tot = defaultdict(int)
|
| 232 |
+
per_hit = defaultdict(int)
|
| 233 |
+
inf_tot = inf_hit = 0
|
| 234 |
+
for g in gt_track:
|
| 235 |
+
n += 1
|
| 236 |
+
gl = g["leader"]
|
| 237 |
+
pl = pred_by_min.get(g["minute"])
|
| 238 |
+
ok = (pl == gl)
|
| 239 |
+
correct += ok
|
| 240 |
+
per_tot[gl] += 1
|
| 241 |
+
per_hit[gl] += ok
|
| 242 |
+
if gl != winner:
|
| 243 |
+
inf_tot += 1
|
| 244 |
+
inf_hit += ok
|
| 245 |
+
macro = sum(per_hit[c] / per_tot[c] for c in per_tot) / len(per_tot) if per_tot else 0.0
|
| 246 |
+
return {"acc": round(correct / n, 4) if n else 1.0,
|
| 247 |
+
"macro_acc": round(macro, 4),
|
| 248 |
+
"informative_acc": round(inf_hit / inf_tot, 4) if inf_tot else None,
|
| 249 |
+
"informative_minutes": inf_tot,
|
| 250 |
+
"per_class": {c: f"{per_hit[c]}/{per_tot[c]}" for c in per_tot}}
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
def score_outcome_global(gt_out, pred_out):
|
| 254 |
+
"""Transparency (NOT coupled, NOT in reward): the match-global winner + case_type.
|
| 255 |
+
Reported so we still see whether the model called the game, but it is a global
|
| 256 |
+
label, not a per-event tuple field — mirrors keeping macro outcome out of the
|
| 257 |
+
per-event F1."""
|
| 258 |
+
w = int(_same(gt_out["winner"], pred_out.get("winner")))
|
| 259 |
+
gc = gt_out["case_type"]["type_zh"]
|
| 260 |
+
ct = pred_out.get("case_type")
|
| 261 |
+
pc = ct.get("type_zh") if isinstance(ct, dict) else None
|
| 262 |
+
return {"winner_correct": w, "case_type_correct": int(pc == gc),
|
| 263 |
+
"gt_winner": gt_out["winner"], "gt_case": gc}
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
def evaluate(pred, gt, tol):
|
| 267 |
+
"""COUPLED (-style) reward: a single maximum 1:1 F1 over the full per-event
|
| 268 |
+
tuple (entity attrs + minute_gain + leader_after). The decomposition is kept in
|
| 269 |
+
`detail` for transparency only and does NOT feed the reward."""
|
| 270 |
+
if not isinstance(pred, dict):
|
| 271 |
+
pred = {}
|
| 272 |
+
ev = pred.get("events")
|
| 273 |
+
ans = [e for e in ev if isinstance(e, dict)] if isinstance(ev, list) else []
|
| 274 |
+
unified = score_unified(gt["events"], ans, tol)
|
| 275 |
+
|
| 276 |
+
# --- transparency-only decomposition (not part of reward) ---
|
| 277 |
+
t1 = score_t1(gt["events"], ans, tol)
|
| 278 |
+
t2_gain = _event_field_macro(gt["events"], ans, tol, "minute_gain")
|
| 279 |
+
t3_lead = _event_field_macro(gt["events"], ans, tol, "leader_after")
|
| 280 |
+
t2_dense = None
|
| 281 |
+
if isinstance(pred.get("t2_leader_track"), list) and pred["t2_leader_track"]:
|
| 282 |
+
t2_dense = score_t2_dense(gt["t2_leader_track"], pred["t2_leader_track"],
|
| 283 |
+
gt["winner"])
|
| 284 |
+
outcome = None
|
| 285 |
+
if isinstance(pred.get("t3_outcome"), dict) and pred["t3_outcome"]:
|
| 286 |
+
outcome = score_outcome_global(gt["t3_outcome"], pred["t3_outcome"])
|
| 287 |
+
|
| 288 |
+
# format diagnostic: `leader_before` is NOT accepted as a fallback for T3 (an
|
| 289 |
+
# answer using it scores its leader_after as missing), so surface how many answer
|
| 290 |
+
# rows carry it to flag a format error.
|
| 291 |
+
stale = sum(1 for a in ans if "leader_after" not in a and "leader_before" in a)
|
| 292 |
+
|
| 293 |
+
return {"reward": unified["f1"], "unified": unified, "tol_s": tol,
|
| 294 |
+
"detail": {"gt_rows": len(gt["events"]),
|
| 295 |
+
"t1_localization": t1,
|
| 296 |
+
"t2_minute_gain_event": t2_gain,
|
| 297 |
+
"t3_leader_after_event": t3_lead,
|
| 298 |
+
"t2_leader_dense": t2_dense,
|
| 299 |
+
"outcome_global": outcome,
|
| 300 |
+
"answer_rows_using_leader_before": stale}}
|
| 301 |
+
|
| 302 |
+
|
| 303 |
+
def perturb(pred):
|
| 304 |
+
"""Corrupt the oracle: flip every entity side AND the two inlined economy fields
|
| 305 |
+
(minute_gain, leader_after), plus the dense leader track and (if present) the
|
| 306 |
+
global t3_outcome — to confirm the coupled reward collapses."""
|
| 307 |
+
p = copy.deepcopy(pred)
|
| 308 |
+
for e in p["events"]:
|
| 309 |
+
for k in ("side", "killer_side", "winner_side", "minute_gain", "leader_after"):
|
| 310 |
+
if e.get(k) in FLIP:
|
| 311 |
+
e[k] = FLIP[e[k]]
|
| 312 |
+
for r in p.get("t2_leader_track", []):
|
| 313 |
+
r["leader"] = FLIP.get(r.get("leader"), r.get("leader"))
|
| 314 |
+
if p.get("t3_outcome"):
|
| 315 |
+
p["t3_outcome"]["winner"] = FLIP.get(p["t3_outcome"]["winner"])
|
| 316 |
+
ct = p["t3_outcome"]["case_type"]
|
| 317 |
+
ct["type_zh"] = CASE_FLIP.get(ct["type_zh"], ct["type_zh"])
|
| 318 |
+
return p
|
| 319 |
+
|
| 320 |
+
|
| 321 |
+
def main():
|
| 322 |
+
ap = argparse.ArgumentParser()
|
| 323 |
+
ap.add_argument("--gt", required=True)
|
| 324 |
+
# --pred is the standalone name (run_dota_batch etc.); --answer is the shared driver
|
| 325 |
+
# CLI (eval_registry.run_judge passes --answer/--gt/--out/--tol) — accept either.
|
| 326 |
+
ap.add_argument("--pred")
|
| 327 |
+
ap.add_argument("--answer")
|
| 328 |
+
ap.add_argument("--out", help="write reward.json here (shared-driver CLI)")
|
| 329 |
+
ap.add_argument("--oracle", action="store_true")
|
| 330 |
+
ap.add_argument("--perturb", action="store_true")
|
| 331 |
+
ap.add_argument("--tol", type=float, default=3.0, help="video-second tolerance for T1")
|
| 332 |
+
args = ap.parse_args()
|
| 333 |
+
|
| 334 |
+
gt = json.load(open(args.gt, encoding="utf-8"))
|
| 335 |
+
|
| 336 |
+
if args.oracle:
|
| 337 |
+
oracle_pred = {"events": gt["events"],
|
| 338 |
+
"t2_leader_track": gt["t2_leader_track"],
|
| 339 |
+
"t3_outcome": gt["t3_outcome"]}
|
| 340 |
+
pred = perturb(oracle_pred) if args.perturb else oracle_pred
|
| 341 |
+
res = evaluate(pred, gt, args.tol)
|
| 342 |
+
det = res["detail"]
|
| 343 |
+
if args.perturb:
|
| 344 |
+
ok = res["reward"] < 0.5 # coupled tuple should collapse hard
|
| 345 |
+
print(f"PERTURB unified_f1={res['reward']} "
|
| 346 |
+
f"(t1_f1={det['t1_localization']['f1']} "
|
| 347 |
+
f"t2gain_macro={det['t2_minute_gain_event']['macro_acc']} "
|
| 348 |
+
f"t3lead_macro={det['t3_leader_after_event']['macro_acc']} "
|
| 349 |
+
f"dense_macro={det['t2_leader_dense']['macro_acc']}) "
|
| 350 |
+
f"-> {'PASS' if ok else 'FAIL'}")
|
| 351 |
+
raise SystemExit(0 if ok else 1)
|
| 352 |
+
empty = evaluate({"events": []}, gt, args.tol)
|
| 353 |
+
ok = (res["reward"] == 1.0 and res["unified"]["f1"] == 1.0
|
| 354 |
+
and det["t1_localization"]["f1"] == 1.0
|
| 355 |
+
and det["t2_minute_gain_event"]["macro_acc"] == 1.0
|
| 356 |
+
and det["t3_leader_after_event"]["macro_acc"] == 1.0
|
| 357 |
+
and det["t2_leader_dense"]["macro_acc"] == 1.0
|
| 358 |
+
and det["outcome_global"]["winner_correct"] == 1
|
| 359 |
+
and det["outcome_global"]["case_type_correct"] == 1
|
| 360 |
+
and empty["reward"] == 0.0)
|
| 361 |
+
print(f"ORACLE unified_f1={res['reward']} "
|
| 362 |
+
f"(decomp t1_f1={det['t1_localization']['f1']} "
|
| 363 |
+
f"t2gain_macro={det['t2_minute_gain_event']['macro_acc']} "
|
| 364 |
+
f"t3lead_macro={det['t3_leader_after_event']['macro_acc']} "
|
| 365 |
+
f"dense_macro={det['t2_leader_dense']['macro_acc']} "
|
| 366 |
+
f"dense_inf={det['t2_leader_dense']['informative_acc']} "
|
| 367 |
+
f"winner_ok={det['outcome_global']['winner_correct']} "
|
| 368 |
+
f"case_ok={det['outcome_global']['case_type_correct']}) "
|
| 369 |
+
f"EMPTY reward={empty['reward']} -> {'PASS' if ok else 'FAIL'}")
|
| 370 |
+
raise SystemExit(0 if ok else 1)
|
| 371 |
+
|
| 372 |
+
pred_path = args.answer or args.pred
|
| 373 |
+
if not pred_path:
|
| 374 |
+
ap.error("one of --answer/--pred is required (or use --oracle)")
|
| 375 |
+
# A malformed answer (BOM, bare list, null, non-dict rows, string times) scores,
|
| 376 |
+
# never crashes: a crash turns the cell into "judge failed" and drops it from the mean.
|
| 377 |
+
try:
|
| 378 |
+
with open(pred_path, encoding="utf-8-sig") as f:
|
| 379 |
+
pred = json.load(f)
|
| 380 |
+
except Exception as e:
|
| 381 |
+
print(f"answer unreadable ({e}) -> 0", file=sys.stderr)
|
| 382 |
+
pred = {}
|
| 383 |
+
if isinstance(pred, list):
|
| 384 |
+
pred = {"events": pred}
|
| 385 |
+
res = evaluate(pred, gt, args.tol)
|
| 386 |
+
res["id"] = gt.get("id")
|
| 387 |
+
if args.out:
|
| 388 |
+
json.dump(res, open(args.out, "w", encoding="utf-8"),
|
| 389 |
+
ensure_ascii=False, indent=2)
|
| 390 |
+
print(json.dumps(res, ensure_ascii=False, indent=2))
|
| 391 |
+
return res
|
| 392 |
+
|
| 393 |
+
|
| 394 |
+
if __name__ == "__main__":
|
| 395 |
+
main()
|
tasks/doudizhu/CASE_TYPES.json
ADDED
|
@@ -0,0 +1,563 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"game": "doudizhu",
|
| 3 |
+
"engine": "DouZero-WP released weights, mechanism B, PIMC belief",
|
| 4 |
+
"V_definition": "landlord win probability = fraction of sampled deals won by the landlord, where each deal is drawn uniformly from those CONSISTENT with the landlord information set at that state (real landlord hand, real farmer plays, exact farmer counts) and played out greedily (tau=0.00) by the released DouZero-WP networks; 400..4000 sampled deals per state, adaptively refined to push labels past 2 sigma from their band boundary; any that remain inside it are abstained, not guessed. V is a function of what is on screen and NOT itself on screen. Belief model: uniform over count-consistent deals; the standard PIMC limitation is that this ignores inference from the action history.",
|
| 5 |
+
"information_set": "landlord: own hand + bottom three + all plays + both farmer card counts. The two farmer hands are face DOWN in the video and are never revealed.",
|
| 6 |
+
"tiers": "T1 = the move (player, move_type, num_cards) at its timestamp | T2 = the change in V that move caused (impact) | T3 = the situation AFTER it (leader_after)",
|
| 7 |
+
"t3_definition": "leader_after = band of V immediately AFTER the move (landlord if V>0.55, farmers if V<0.45, else equal). Unified tier semantics: T1 = the event, T2 = the change in V it caused, T3 = the resulting situation.",
|
| 8 |
+
"impact_eps": 0.034,
|
| 9 |
+
"leader_band": 0.05,
|
| 10 |
+
"thresholds": "FIXED across every case: reject or re-select a case, never re-tune eps for it, or macro_acc stops being comparable across the corpus",
|
| 11 |
+
"abstention": "a row whose label is within 2 sigma of its band boundary carries null on that tier and is NOT scored there; it is still a T1 event. The model cannot tell which rows those are, so it must answer every row - abstention removes undecidable labels from the numerator, it does not make the task easier.",
|
| 12 |
+
"event_rule": "every move that plays >=1 card; passes are shown on screen but never reported",
|
| 13 |
+
"move_sec": 6.0,
|
| 14 |
+
"leadin_sec": 12.0,
|
| 15 |
+
"resolution": "1280x720",
|
| 16 |
+
"distribution": {
|
| 17 |
+
"tense": 7,
|
| 18 |
+
"blowout": 7,
|
| 19 |
+
"reversal": 6
|
| 20 |
+
},
|
| 21 |
+
"cases": [
|
| 22 |
+
{
|
| 23 |
+
"case_id": "dzh-01",
|
| 24 |
+
"case_type": "tense",
|
| 25 |
+
"winner_trough_smin": 0.1303,
|
| 26 |
+
"duration_min": 5.3,
|
| 27 |
+
"winner": "farmer",
|
| 28 |
+
"n_events": 27,
|
| 29 |
+
"total_moves": 51,
|
| 30 |
+
"n_passes_shown": 24,
|
| 31 |
+
"v_min": 0.0,
|
| 32 |
+
"v_max": 0.895,
|
| 33 |
+
"lead_crossings": 4,
|
| 34 |
+
"t3_classes": {
|
| 35 |
+
"farmers": 11,
|
| 36 |
+
"landlord": 10,
|
| 37 |
+
"equal": 2
|
| 38 |
+
},
|
| 39 |
+
"t2_classes": {
|
| 40 |
+
"neutral": 10,
|
| 41 |
+
"landlord": 5,
|
| 42 |
+
"farmers": 3
|
| 43 |
+
},
|
| 44 |
+
"scored_t3": 23,
|
| 45 |
+
"scored_t2": 18,
|
| 46 |
+
"abstained_t3": 4,
|
| 47 |
+
"abstained_t2": 9
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"case_id": "dzh-02",
|
| 51 |
+
"case_type": "tense",
|
| 52 |
+
"winner_trough_smin": 0.1666,
|
| 53 |
+
"duration_min": 4.6,
|
| 54 |
+
"winner": "farmer",
|
| 55 |
+
"n_events": 23,
|
| 56 |
+
"total_moves": 44,
|
| 57 |
+
"n_passes_shown": 21,
|
| 58 |
+
"v_min": 0.0,
|
| 59 |
+
"v_max": 0.8625,
|
| 60 |
+
"lead_crossings": 5,
|
| 61 |
+
"t3_classes": {
|
| 62 |
+
"landlord": 9,
|
| 63 |
+
"farmers": 6,
|
| 64 |
+
"equal": 2
|
| 65 |
+
},
|
| 66 |
+
"t2_classes": {
|
| 67 |
+
"neutral": 12,
|
| 68 |
+
"farmers": 6,
|
| 69 |
+
"landlord": 4
|
| 70 |
+
},
|
| 71 |
+
"scored_t3": 17,
|
| 72 |
+
"scored_t2": 22,
|
| 73 |
+
"abstained_t3": 6,
|
| 74 |
+
"abstained_t2": 1
|
| 75 |
+
},
|
| 76 |
+
{
|
| 77 |
+
"case_id": "dzh-03",
|
| 78 |
+
"case_type": "blowout",
|
| 79 |
+
"winner_trough_smin": 0.3861,
|
| 80 |
+
"duration_min": 3.6,
|
| 81 |
+
"winner": "landlord",
|
| 82 |
+
"n_events": 19,
|
| 83 |
+
"total_moves": 34,
|
| 84 |
+
"n_passes_shown": 15,
|
| 85 |
+
"v_min": 0.3375,
|
| 86 |
+
"v_max": 1.0,
|
| 87 |
+
"lead_crossings": 3,
|
| 88 |
+
"t3_classes": {
|
| 89 |
+
"farmers": 5,
|
| 90 |
+
"equal": 1,
|
| 91 |
+
"landlord": 8
|
| 92 |
+
},
|
| 93 |
+
"t2_classes": {
|
| 94 |
+
"neutral": 8,
|
| 95 |
+
"farmers": 2,
|
| 96 |
+
"landlord": 4
|
| 97 |
+
},
|
| 98 |
+
"scored_t3": 14,
|
| 99 |
+
"scored_t2": 14,
|
| 100 |
+
"abstained_t3": 5,
|
| 101 |
+
"abstained_t2": 5
|
| 102 |
+
},
|
| 103 |
+
{
|
| 104 |
+
"case_id": "dzh-04",
|
| 105 |
+
"case_type": "reversal",
|
| 106 |
+
"winner_trough_smin": 0.0166,
|
| 107 |
+
"duration_min": 3.1,
|
| 108 |
+
"winner": "farmer",
|
| 109 |
+
"n_events": 14,
|
| 110 |
+
"total_moves": 29,
|
| 111 |
+
"n_passes_shown": 15,
|
| 112 |
+
"v_min": 0.0,
|
| 113 |
+
"v_max": 0.9868,
|
| 114 |
+
"lead_crossings": 6,
|
| 115 |
+
"t3_classes": {
|
| 116 |
+
"farmers": 3,
|
| 117 |
+
"equal": 7,
|
| 118 |
+
"landlord": 4
|
| 119 |
+
},
|
| 120 |
+
"t2_classes": {
|
| 121 |
+
"neutral": 6,
|
| 122 |
+
"landlord": 4,
|
| 123 |
+
"farmers": 3
|
| 124 |
+
},
|
| 125 |
+
"scored_t3": 14,
|
| 126 |
+
"scored_t2": 13,
|
| 127 |
+
"abstained_t3": 0,
|
| 128 |
+
"abstained_t2": 1
|
| 129 |
+
},
|
| 130 |
+
{
|
| 131 |
+
"case_id": "dzh-05",
|
| 132 |
+
"case_type": "reversal",
|
| 133 |
+
"winner_trough_smin": 0.116,
|
| 134 |
+
"duration_min": 6.3,
|
| 135 |
+
"winner": "landlord",
|
| 136 |
+
"n_events": 31,
|
| 137 |
+
"total_moves": 61,
|
| 138 |
+
"n_passes_shown": 30,
|
| 139 |
+
"v_min": 0.0959,
|
| 140 |
+
"v_max": 1.0,
|
| 141 |
+
"lead_crossings": 1,
|
| 142 |
+
"t3_classes": {
|
| 143 |
+
"farmers": 12,
|
| 144 |
+
"equal": 3,
|
| 145 |
+
"landlord": 14
|
| 146 |
+
},
|
| 147 |
+
"t2_classes": {
|
| 148 |
+
"neutral": 17,
|
| 149 |
+
"landlord": 7,
|
| 150 |
+
"farmers": 2
|
| 151 |
+
},
|
| 152 |
+
"scored_t3": 29,
|
| 153 |
+
"scored_t2": 26,
|
| 154 |
+
"abstained_t3": 2,
|
| 155 |
+
"abstained_t2": 5
|
| 156 |
+
},
|
| 157 |
+
{
|
| 158 |
+
"case_id": "dzh-06",
|
| 159 |
+
"case_type": "reversal",
|
| 160 |
+
"winner_trough_smin": 0.0938,
|
| 161 |
+
"duration_min": 5.8,
|
| 162 |
+
"winner": "farmer",
|
| 163 |
+
"n_events": 27,
|
| 164 |
+
"total_moves": 56,
|
| 165 |
+
"n_passes_shown": 29,
|
| 166 |
+
"v_min": 0.0,
|
| 167 |
+
"v_max": 0.9075,
|
| 168 |
+
"lead_crossings": 3,
|
| 169 |
+
"t3_classes": {
|
| 170 |
+
"equal": 8,
|
| 171 |
+
"landlord": 12,
|
| 172 |
+
"farmers": 3
|
| 173 |
+
},
|
| 174 |
+
"t2_classes": {
|
| 175 |
+
"neutral": 13,
|
| 176 |
+
"landlord": 3,
|
| 177 |
+
"farmers": 4
|
| 178 |
+
},
|
| 179 |
+
"scored_t3": 23,
|
| 180 |
+
"scored_t2": 20,
|
| 181 |
+
"abstained_t3": 4,
|
| 182 |
+
"abstained_t2": 7
|
| 183 |
+
},
|
| 184 |
+
{
|
| 185 |
+
"case_id": "dzh-07",
|
| 186 |
+
"case_type": "blowout",
|
| 187 |
+
"winner_trough_smin": 0.234,
|
| 188 |
+
"duration_min": 3.8,
|
| 189 |
+
"winner": "farmer",
|
| 190 |
+
"n_events": 17,
|
| 191 |
+
"total_moves": 36,
|
| 192 |
+
"n_passes_shown": 19,
|
| 193 |
+
"v_min": 0.0,
|
| 194 |
+
"v_max": 0.895,
|
| 195 |
+
"lead_crossings": 3,
|
| 196 |
+
"t3_classes": {
|
| 197 |
+
"equal": 5,
|
| 198 |
+
"landlord": 3,
|
| 199 |
+
"farmers": 4
|
| 200 |
+
},
|
| 201 |
+
"t2_classes": {
|
| 202 |
+
"neutral": 8,
|
| 203 |
+
"landlord": 3,
|
| 204 |
+
"farmers": 5
|
| 205 |
+
},
|
| 206 |
+
"scored_t3": 12,
|
| 207 |
+
"scored_t2": 16,
|
| 208 |
+
"abstained_t3": 5,
|
| 209 |
+
"abstained_t2": 1
|
| 210 |
+
},
|
| 211 |
+
{
|
| 212 |
+
"case_id": "dzh-08",
|
| 213 |
+
"case_type": "blowout",
|
| 214 |
+
"winner_trough_smin": 0.2341,
|
| 215 |
+
"duration_min": 4.2,
|
| 216 |
+
"winner": "landlord",
|
| 217 |
+
"n_events": 21,
|
| 218 |
+
"total_moves": 40,
|
| 219 |
+
"n_passes_shown": 19,
|
| 220 |
+
"v_min": 0.2318,
|
| 221 |
+
"v_max": 1.0,
|
| 222 |
+
"lead_crossings": 1,
|
| 223 |
+
"t3_classes": {
|
| 224 |
+
"farmers": 7,
|
| 225 |
+
"equal": 1,
|
| 226 |
+
"landlord": 11
|
| 227 |
+
},
|
| 228 |
+
"t2_classes": {
|
| 229 |
+
"neutral": 12,
|
| 230 |
+
"landlord": 7,
|
| 231 |
+
"farmers": 1
|
| 232 |
+
},
|
| 233 |
+
"scored_t3": 19,
|
| 234 |
+
"scored_t2": 20,
|
| 235 |
+
"abstained_t3": 2,
|
| 236 |
+
"abstained_t2": 1
|
| 237 |
+
},
|
| 238 |
+
{
|
| 239 |
+
"case_id": "dzh-09",
|
| 240 |
+
"case_type": "blowout",
|
| 241 |
+
"winner_trough_smin": 0.233,
|
| 242 |
+
"duration_min": 4.6,
|
| 243 |
+
"winner": "farmer",
|
| 244 |
+
"n_events": 25,
|
| 245 |
+
"total_moves": 44,
|
| 246 |
+
"n_passes_shown": 19,
|
| 247 |
+
"v_min": 0.0,
|
| 248 |
+
"v_max": 0.7886,
|
| 249 |
+
"lead_crossings": 2,
|
| 250 |
+
"t3_classes": {
|
| 251 |
+
"farmers": 13,
|
| 252 |
+
"equal": 2,
|
| 253 |
+
"landlord": 5
|
| 254 |
+
},
|
| 255 |
+
"t2_classes": {
|
| 256 |
+
"neutral": 13,
|
| 257 |
+
"landlord": 5,
|
| 258 |
+
"farmers": 3
|
| 259 |
+
},
|
| 260 |
+
"scored_t3": 20,
|
| 261 |
+
"scored_t2": 21,
|
| 262 |
+
"abstained_t3": 5,
|
| 263 |
+
"abstained_t2": 4
|
| 264 |
+
},
|
| 265 |
+
{
|
| 266 |
+
"case_id": "dzh-10",
|
| 267 |
+
"case_type": "blowout",
|
| 268 |
+
"winner_trough_smin": 0.2455,
|
| 269 |
+
"duration_min": 4.4,
|
| 270 |
+
"winner": "farmer",
|
| 271 |
+
"n_events": 18,
|
| 272 |
+
"total_moves": 42,
|
| 273 |
+
"n_passes_shown": 24,
|
| 274 |
+
"v_min": 0.0,
|
| 275 |
+
"v_max": 0.81,
|
| 276 |
+
"lead_crossings": 3,
|
| 277 |
+
"t3_classes": {
|
| 278 |
+
"farmers": 8,
|
| 279 |
+
"landlord": 8,
|
| 280 |
+
"equal": 2
|
| 281 |
+
},
|
| 282 |
+
"t2_classes": {
|
| 283 |
+
"neutral": 7,
|
| 284 |
+
"landlord": 3,
|
| 285 |
+
"farmers": 5
|
| 286 |
+
},
|
| 287 |
+
"scored_t3": 18,
|
| 288 |
+
"scored_t2": 15,
|
| 289 |
+
"abstained_t3": 0,
|
| 290 |
+
"abstained_t2": 3
|
| 291 |
+
},
|
| 292 |
+
{
|
| 293 |
+
"case_id": "dzh-11",
|
| 294 |
+
"case_type": "blowout",
|
| 295 |
+
"winner_trough_smin": 0.3202,
|
| 296 |
+
"duration_min": 2.6,
|
| 297 |
+
"winner": "farmer",
|
| 298 |
+
"n_events": 14,
|
| 299 |
+
"total_moves": 24,
|
| 300 |
+
"n_passes_shown": 10,
|
| 301 |
+
"v_min": 0.0,
|
| 302 |
+
"v_max": 0.6825,
|
| 303 |
+
"lead_crossings": 4,
|
| 304 |
+
"t3_classes": {
|
| 305 |
+
"farmers": 4,
|
| 306 |
+
"landlord": 4,
|
| 307 |
+
"equal": 4
|
| 308 |
+
},
|
| 309 |
+
"t2_classes": {
|
| 310 |
+
"neutral": 6,
|
| 311 |
+
"landlord": 5,
|
| 312 |
+
"farmers": 2
|
| 313 |
+
},
|
| 314 |
+
"scored_t3": 12,
|
| 315 |
+
"scored_t2": 13,
|
| 316 |
+
"abstained_t3": 2,
|
| 317 |
+
"abstained_t2": 1
|
| 318 |
+
},
|
| 319 |
+
{
|
| 320 |
+
"case_id": "dzh-12",
|
| 321 |
+
"case_type": "reversal",
|
| 322 |
+
"winner_trough_smin": 0.0743,
|
| 323 |
+
"duration_min": 3.6,
|
| 324 |
+
"winner": "landlord",
|
| 325 |
+
"n_events": 16,
|
| 326 |
+
"total_moves": 34,
|
| 327 |
+
"n_passes_shown": 18,
|
| 328 |
+
"v_min": 0.0714,
|
| 329 |
+
"v_max": 1.0,
|
| 330 |
+
"lead_crossings": 3,
|
| 331 |
+
"t3_classes": {
|
| 332 |
+
"farmers": 7,
|
| 333 |
+
"equal": 3,
|
| 334 |
+
"landlord": 5
|
| 335 |
+
},
|
| 336 |
+
"t2_classes": {
|
| 337 |
+
"neutral": 10,
|
| 338 |
+
"farmers": 1,
|
| 339 |
+
"landlord": 2
|
| 340 |
+
},
|
| 341 |
+
"scored_t3": 15,
|
| 342 |
+
"scored_t2": 13,
|
| 343 |
+
"abstained_t3": 1,
|
| 344 |
+
"abstained_t2": 3
|
| 345 |
+
},
|
| 346 |
+
{
|
| 347 |
+
"case_id": "dzh-13",
|
| 348 |
+
"case_type": "tense",
|
| 349 |
+
"winner_trough_smin": 0.1301,
|
| 350 |
+
"duration_min": 5.2,
|
| 351 |
+
"winner": "farmer",
|
| 352 |
+
"n_events": 25,
|
| 353 |
+
"total_moves": 50,
|
| 354 |
+
"n_passes_shown": 25,
|
| 355 |
+
"v_min": 0.0,
|
| 356 |
+
"v_max": 0.908,
|
| 357 |
+
"lead_crossings": 2,
|
| 358 |
+
"t3_classes": {
|
| 359 |
+
"farmers": 5,
|
| 360 |
+
"equal": 3,
|
| 361 |
+
"landlord": 17
|
| 362 |
+
},
|
| 363 |
+
"t2_classes": {
|
| 364 |
+
"neutral": 13,
|
| 365 |
+
"landlord": 3,
|
| 366 |
+
"farmers": 2
|
| 367 |
+
},
|
| 368 |
+
"scored_t3": 25,
|
| 369 |
+
"scored_t2": 18,
|
| 370 |
+
"abstained_t3": 0,
|
| 371 |
+
"abstained_t2": 7
|
| 372 |
+
},
|
| 373 |
+
{
|
| 374 |
+
"case_id": "dzh-14",
|
| 375 |
+
"case_type": "reversal",
|
| 376 |
+
"winner_trough_smin": 0.073,
|
| 377 |
+
"duration_min": 4.0,
|
| 378 |
+
"winner": "farmer",
|
| 379 |
+
"n_events": 22,
|
| 380 |
+
"total_moves": 38,
|
| 381 |
+
"n_passes_shown": 16,
|
| 382 |
+
"v_min": 0.0,
|
| 383 |
+
"v_max": 0.935,
|
| 384 |
+
"lead_crossings": 2,
|
| 385 |
+
"t3_classes": {
|
| 386 |
+
"farmers": 9,
|
| 387 |
+
"equal": 1,
|
| 388 |
+
"landlord": 11
|
| 389 |
+
},
|
| 390 |
+
"t2_classes": {
|
| 391 |
+
"neutral": 10,
|
| 392 |
+
"landlord": 6,
|
| 393 |
+
"farmers": 5
|
| 394 |
+
},
|
| 395 |
+
"scored_t3": 21,
|
| 396 |
+
"scored_t2": 21,
|
| 397 |
+
"abstained_t3": 1,
|
| 398 |
+
"abstained_t2": 1
|
| 399 |
+
},
|
| 400 |
+
{
|
| 401 |
+
"case_id": "dzh-15",
|
| 402 |
+
"case_type": "tense",
|
| 403 |
+
"winner_trough_smin": 0.1625,
|
| 404 |
+
"duration_min": 4.4,
|
| 405 |
+
"winner": "farmer",
|
| 406 |
+
"n_events": 22,
|
| 407 |
+
"total_moves": 42,
|
| 408 |
+
"n_passes_shown": 20,
|
| 409 |
+
"v_min": 0.0,
|
| 410 |
+
"v_max": 0.9075,
|
| 411 |
+
"lead_crossings": 2,
|
| 412 |
+
"t3_classes": {
|
| 413 |
+
"farmers": 12,
|
| 414 |
+
"equal": 1,
|
| 415 |
+
"landlord": 9
|
| 416 |
+
},
|
| 417 |
+
"t2_classes": {
|
| 418 |
+
"neutral": 11,
|
| 419 |
+
"landlord": 5,
|
| 420 |
+
"farmers": 2
|
| 421 |
+
},
|
| 422 |
+
"scored_t3": 22,
|
| 423 |
+
"scored_t2": 18,
|
| 424 |
+
"abstained_t3": 0,
|
| 425 |
+
"abstained_t2": 4
|
| 426 |
+
},
|
| 427 |
+
{
|
| 428 |
+
"case_id": "dzh-16",
|
| 429 |
+
"case_type": "reversal",
|
| 430 |
+
"winner_trough_smin": 0.1098,
|
| 431 |
+
"duration_min": 4.6,
|
| 432 |
+
"winner": "farmer",
|
| 433 |
+
"n_events": 21,
|
| 434 |
+
"total_moves": 44,
|
| 435 |
+
"n_passes_shown": 23,
|
| 436 |
+
"v_min": 0.0,
|
| 437 |
+
"v_max": 0.9025,
|
| 438 |
+
"lead_crossings": 6,
|
| 439 |
+
"t3_classes": {
|
| 440 |
+
"farmers": 11,
|
| 441 |
+
"equal": 3,
|
| 442 |
+
"landlord": 6
|
| 443 |
+
},
|
| 444 |
+
"t2_classes": {
|
| 445 |
+
"neutral": 8,
|
| 446 |
+
"landlord": 4,
|
| 447 |
+
"farmers": 4
|
| 448 |
+
},
|
| 449 |
+
"scored_t3": 20,
|
| 450 |
+
"scored_t2": 16,
|
| 451 |
+
"abstained_t3": 1,
|
| 452 |
+
"abstained_t2": 5
|
| 453 |
+
},
|
| 454 |
+
{
|
| 455 |
+
"case_id": "dzh-17",
|
| 456 |
+
"case_type": "tense",
|
| 457 |
+
"winner_trough_smin": 0.2015,
|
| 458 |
+
"duration_min": 5.4,
|
| 459 |
+
"winner": "landlord",
|
| 460 |
+
"n_events": 23,
|
| 461 |
+
"total_moves": 52,
|
| 462 |
+
"n_passes_shown": 29,
|
| 463 |
+
"v_min": 0.14,
|
| 464 |
+
"v_max": 1.0,
|
| 465 |
+
"lead_crossings": 2,
|
| 466 |
+
"t3_classes": {
|
| 467 |
+
"equal": 1,
|
| 468 |
+
"landlord": 13,
|
| 469 |
+
"farmers": 7
|
| 470 |
+
},
|
| 471 |
+
"t2_classes": {
|
| 472 |
+
"neutral": 7,
|
| 473 |
+
"landlord": 5,
|
| 474 |
+
"farmers": 4
|
| 475 |
+
},
|
| 476 |
+
"scored_t3": 21,
|
| 477 |
+
"scored_t2": 16,
|
| 478 |
+
"abstained_t3": 2,
|
| 479 |
+
"abstained_t2": 7
|
| 480 |
+
},
|
| 481 |
+
{
|
| 482 |
+
"case_id": "dzh-18",
|
| 483 |
+
"case_type": "blowout",
|
| 484 |
+
"winner_trough_smin": 0.2591,
|
| 485 |
+
"duration_min": 4.1,
|
| 486 |
+
"winner": "farmer",
|
| 487 |
+
"n_events": 21,
|
| 488 |
+
"total_moves": 39,
|
| 489 |
+
"n_passes_shown": 18,
|
| 490 |
+
"v_min": 0.0,
|
| 491 |
+
"v_max": 0.915,
|
| 492 |
+
"lead_crossings": 4,
|
| 493 |
+
"t3_classes": {
|
| 494 |
+
"equal": 2,
|
| 495 |
+
"landlord": 7,
|
| 496 |
+
"farmers": 11
|
| 497 |
+
},
|
| 498 |
+
"t2_classes": {
|
| 499 |
+
"neutral": 11,
|
| 500 |
+
"landlord": 4,
|
| 501 |
+
"farmers": 3
|
| 502 |
+
},
|
| 503 |
+
"scored_t3": 20,
|
| 504 |
+
"scored_t2": 18,
|
| 505 |
+
"abstained_t3": 1,
|
| 506 |
+
"abstained_t2": 3
|
| 507 |
+
},
|
| 508 |
+
{
|
| 509 |
+
"case_id": "dzh-19",
|
| 510 |
+
"case_type": "tense",
|
| 511 |
+
"winner_trough_smin": 0.2045,
|
| 512 |
+
"duration_min": 4.5,
|
| 513 |
+
"winner": "landlord",
|
| 514 |
+
"n_events": 23,
|
| 515 |
+
"total_moves": 43,
|
| 516 |
+
"n_passes_shown": 20,
|
| 517 |
+
"v_min": 0.1943,
|
| 518 |
+
"v_max": 1.0,
|
| 519 |
+
"lead_crossings": 3,
|
| 520 |
+
"t3_classes": {
|
| 521 |
+
"farmers": 12,
|
| 522 |
+
"landlord": 5,
|
| 523 |
+
"equal": 3
|
| 524 |
+
},
|
| 525 |
+
"t2_classes": {
|
| 526 |
+
"neutral": 10,
|
| 527 |
+
"landlord": 6,
|
| 528 |
+
"farmers": 1
|
| 529 |
+
},
|
| 530 |
+
"scored_t3": 20,
|
| 531 |
+
"scored_t2": 17,
|
| 532 |
+
"abstained_t3": 3,
|
| 533 |
+
"abstained_t2": 6
|
| 534 |
+
},
|
| 535 |
+
{
|
| 536 |
+
"case_id": "dzh-20",
|
| 537 |
+
"case_type": "tense",
|
| 538 |
+
"winner_trough_smin": 0.1402,
|
| 539 |
+
"duration_min": 4.0,
|
| 540 |
+
"winner": "farmer",
|
| 541 |
+
"n_events": 20,
|
| 542 |
+
"total_moves": 38,
|
| 543 |
+
"n_passes_shown": 18,
|
| 544 |
+
"v_min": 0.0,
|
| 545 |
+
"v_max": 0.885,
|
| 546 |
+
"lead_crossings": 2,
|
| 547 |
+
"t3_classes": {
|
| 548 |
+
"farmers": 2,
|
| 549 |
+
"landlord": 14,
|
| 550 |
+
"equal": 1
|
| 551 |
+
},
|
| 552 |
+
"t2_classes": {
|
| 553 |
+
"neutral": 8,
|
| 554 |
+
"landlord": 3,
|
| 555 |
+
"farmers": 4
|
| 556 |
+
},
|
| 557 |
+
"scored_t3": 17,
|
| 558 |
+
"scored_t2": 15,
|
| 559 |
+
"abstained_t3": 3,
|
| 560 |
+
"abstained_t2": 5
|
| 561 |
+
}
|
| 562 |
+
]
|
| 563 |
+
}
|
tasks/doudizhu/answer_seed.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"events": []}
|
tasks/doudizhu/cases.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"game": "doudizhu",
|
| 3 |
+
"n_cases": 20,
|
| 4 |
+
"case_ids": [
|
| 5 |
+
"dzh-01",
|
| 6 |
+
"dzh-02",
|
| 7 |
+
"dzh-03",
|
| 8 |
+
"dzh-04",
|
| 9 |
+
"dzh-05",
|
| 10 |
+
"dzh-06",
|
| 11 |
+
"dzh-07",
|
| 12 |
+
"dzh-08",
|
| 13 |
+
"dzh-09",
|
| 14 |
+
"dzh-10",
|
| 15 |
+
"dzh-11",
|
| 16 |
+
"dzh-12",
|
| 17 |
+
"dzh-13",
|
| 18 |
+
"dzh-14",
|
| 19 |
+
"dzh-15",
|
| 20 |
+
"dzh-16",
|
| 21 |
+
"dzh-17",
|
| 22 |
+
"dzh-18",
|
| 23 |
+
"dzh-19",
|
| 24 |
+
"dzh-20"
|
| 25 |
+
]
|
| 26 |
+
}
|
tasks/doudizhu/instruction.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Agent instruction — Dou Dizhu three-tier reconstruction
|
| 2 |
+
|
| 3 |
+
You will watch a video of a Dou Dizhu (斗地主) game. On screen you can see: **the landlord's entire hand (face up)**, the two farmers' hands (**face-down fans — you can count the cards but cannot see their ranks**), the three bottom cards (face up throughout), the seat labels (`LANDLORD` in gold / `FARMER-L` / `FARMER-R`), the cards already played in the current trick, and the **current player** picked out by a gold highlight frame. Every play (including a pass) is displayed for 6 seconds; the game opens with a 12-second static reveal.
|
| 4 |
+
|
| 5 |
+
How to read the cards: standard English playing-card faces. The rank and suit are printed in the **top-left corner of each card** (rank above, suit below); hearts/diamonds are red, spades/clubs are black. When cards in a hand overlap, only a strip down the left edge of each is visible, so **the top-left rank is the only reliable place to read it**. Fully exposed cards (the last card in each row, the three bottom cards, and the cards played in the centre of the table) also show the complete face — 2–10 in the standard pip layout, A as one large suit symbol, and J/Q/K as face-letter frames.
|
| 6 |
+
|
| 7 |
+
The backs of the farmers' cards keep a fully opaque white border, and the period of the back pattern deliberately does not divide the overlap step — the point being that a 17-card fan is **still countable** and does not blur into a single mass. The farmers' **remaining card counts** are therefore public information, while their **specific ranks** are not.
|
| 8 |
+
|
| 9 |
+
**Suits are irrelevant in Dou Dizhu**; they exist only so that multiples of the same rank can be counted at a glance (four of a rank = four suits = a bomb). The two jokers have neither rank nor suit and are printed with `JOKER` running vertically: **black lettering is the little joker, red lettering is the big joker**.
|
| 10 |
+
|
| 11 |
+
A pass is shown as an empty dark `PASS` panel. When a player acts again within the same trick, that player's panel shows only their **most recent** action.
|
| 12 |
+
|
| 13 |
+
**Not on screen**: the farmers' actual hands, win probability, any score, a timer, a move counter, or numeric remaining-card counts (you have to count those yourself).
|
| 14 |
+
|
| 15 |
+
## Your task
|
| 16 |
+
|
| 17 |
+
Reconstruct the ordered event list of **every play** (passes are not reported). Each event carries:
|
| 18 |
+
|
| 19 |
+
| Field | Meaning | Values |
|
| 20 |
+
|---|---|---|
|
| 21 |
+
| `idx` | Event index (1-based) | integer |
|
| 22 |
+
| `game_clock_s` | The second at which this play appears in the video | float |
|
| 23 |
+
| `player` | Who played | `landlord` / `farmer_left` / `farmer_right` |
|
| 24 |
+
| `move_type` | The combination type | see the table below |
|
| 25 |
+
| `num_cards` | How many cards this play used | integer |
|
| 26 |
+
| `impact` | **T2** which way this play pushed the advantage (ΔV) | `landlord` / `farmers` / `neutral` |
|
| 27 |
+
| `leader_after` | **T3** who is ahead **after** this play (V) | `landlord` / `farmers` / `equal` |
|
| 28 |
+
|
| 29 |
+
### `move_type` values (every play you report must fall into these 14 classes)
|
| 30 |
+
`single`, `pair`, `trio`, `trio_single` (trio plus a single), `trio_pair` (trio plus a pair), `straight` (a run of ≥5 consecutive singles), `pair_chain` (≥3 consecutive pairs), `trio_chain` (consecutive trios with no kickers, ≥2), `plane_single` (consecutive trios with single kickers), `plane_pair` (consecutive trios with pair kickers), `bomb` (four of a rank), `rocket` (both jokers), `quad_two` (four plus two singles), `quad_two_pairs` (four plus two pairs).
|
| 31 |
+
|
| 32 |
+
**The one thing you do not report is a pass.** Reporting a pass as an event counts as a false positive and lowers your precision.
|
| 33 |
+
|
| 34 |
+
## What the three tiers mean
|
| 35 |
+
|
| 36 |
+
The three tiers are one ladder, not three separate things: **T1 is the key event itself, T2 is the change this event caused in V, and T3 is the overall state of V after the event has happened.** Every game in the suite (football / Go / Dou Dizhu / CS2 / DOTA2 …) shares these semantics.
|
| 37 |
+
|
| 38 |
+
- **T1 — localize (t, c, a)**: when, who, which combination type, how many cards. This is the entry ticket, and all of it can be counted directly off the screen.
|
| 39 |
+
- **T2 — impact (ΔV)**: how much this play moved the landlord's win probability. `|ΔV| ≤ 0.034` → `neutral`; `ΔV > +0.034` → `landlord`; `ΔV < −0.034` → `farmers`.
|
| 40 |
+
- **T3 — situation (V)**: which side of the band the landlord's win probability V falls on **after** this play. `V > 0.55` → `landlord`; `V < 0.45` → `farmers`; in between → `equal`.
|
| 41 |
+
|
| 42 |
+
T3 asks about **after**, not before: it is the state that T2's increments accumulate **to**, as in the unified semantics above. Because Dou Dizhu's V is continuous (measured `|ΔV|` spans 0.0005–0.895), the binned T3 is **not** a deterministic function of the binned T2.
|
| 43 |
+
|
| 44 |
+
The thresholds are much smaller than in an open-hand version, and that is by design: when the farmers' hands are invisible, changes in V come from changes in **belief**, and a single play rarely rewrites an entire belief, so a single play's `|ΔV|` is naturally smaller. The 0.034 threshold is the p33 of the measured `|ΔV|` distribution over 60 seeds (after subtracting sampling noise) — it was not picked by hand.
|
| 45 |
+
|
| 46 |
+
## What V(t) is, and why you cannot read it off a single frame
|
| 47 |
+
|
| 48 |
+
V(t) = **the landlord's win probability in the current position** — the share of games the landlord would win from here, averaged over every way the unseen cards could be split between the two farmers, with all three players then playing at the same strong level. It is conditioned on exactly the **landlord's information set**:
|
| 49 |
+
|
| 50 |
+
1. the landlord's own hand and the three bottom cards are known;
|
| 51 |
+
2. every card all three players have already played is known;
|
| 52 |
+
3. the two farmers' remaining **card counts** are known;
|
| 53 |
+
4. only **which specific cards each farmer holds** is unknown, and every split of the unseen stock consistent with 1–3 is weighted equally.
|
| 54 |
+
|
| 55 |
+
**The key point: the information on screen = the landlord's information set = the information set V is conditioned on.** So V remains entirely a function of what is on screen — but it demands that you simultaneously **evaluate hand strength** and **reason about hidden hands**. No single frame yields this number, and it is never displayed.
|
| 56 |
+
|
| 57 |
+
The three bottom cards being face up throughout is not decoration: V is conditioned on them, so if they were invisible, two visually identical positions could carry different V and the labels would depend on something off-screen. Real Dou Dizhu clients display them this way too.
|
| 58 |
+
|
| 59 |
+
## Some cells are "not scored"
|
| 60 |
+
|
| 61 |
+
For a few events, the ΔV or V lands so close to a bin boundary that which side of it they fall on is not decidable — the margin is a fixed number, set in advance and the same for every case. Labels like these **are not scored** (counted neither right nor wrong). You **cannot tell** which ones they are, so **fill in every row as usual**; this only removes the undecidable labels from the denominator, and it does not make the task easier.
|
| 62 |
+
|
| 63 |
+
## Answer format
|
| 64 |
+
|
| 65 |
+
<!--B-->Write `answer.json`:<!--/B--><!--A-->The answer is one JSON object:<!--/A-->
|
| 66 |
+
```json
|
| 67 |
+
{"events": [
|
| 68 |
+
{"idx":1,"game_clock_s":34.0,"player":"landlord","move_type":"straight",
|
| 69 |
+
"num_cards":5,"impact":"landlord","leader_after":"landlord"},
|
| 70 |
+
{"idx":2,"game_clock_s":88.0,"player":"farmer_left","move_type":"bomb",
|
| 71 |
+
"num_cards":4,"impact":"farmers","leader_after":"equal"}
|
| 72 |
+
]}
|
| 73 |
+
```
|
| 74 |
+
- `game_clock_s` is in video playback seconds; use the **midpoint of the play's display window** (each play occupies 6 seconds, and the midpoint is the most robust choice). Tolerance is **±3 s**, exactly half a window: as long as the time you report falls inside the 6 seconds during which that play is actually on screen, it will pair up, with no ambiguity across plays.
|
| 75 |
+
- Per-event all-or-nothing: if any (labelled) field in a row is wrong, that row scores nothing.
|
| 76 |
+
- Value matching is case-insensitive, and spaces and `-` are treated as `_`. A few alternate names are also accepted (for example `king_bomb` for `rocket`, `four_two` for `quad_two`, the `serial_*` family, and the Chinese glosses such as `炸弹`/`顺子`/`地主`/`农民`). Prefer the canonical values in the tables above.
|
| 77 |
+
|
| 78 |
+
<!-- B-ONLY:START -->
|
| 79 |
+
## Write `answer.json` as you go (required)
|
| 80 |
+
|
| 81 |
+
**`./answer.json` is already in the sandbox** — the harness created it before your first turn, with the schema above and an empty list:
|
| 82 |
+
|
| 83 |
+
```json
|
| 84 |
+
{"events": []}
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
**Do not delete it, do not rename it, and do not change the root key.** Overwrite it in place — in full, valid JSON every time — as soon as you have something to put in it.
|
| 88 |
+
|
| 89 |
+
Then **rewrite the whole file every time you finish a stretch of the video**, adding the events you just found — do not save it all for the end.
|
| 90 |
+
|
| 91 |
+
- The file must be **valid JSON at every moment**: rewrite it in full each time (read → add → write back), never leave it half-written.
|
| 92 |
+
- **Whatever is in `answer.json` when the run stops is what gets scored.** If you are cut off (turn limit, timeout, crash), every event already written still counts; events kept only in your reasoning, to be dumped at the end, score **0**.
|
| 93 |
+
- Each rewrite should contain **everything the previous one had**, plus the new events. If you are deep into the video and the file is not getting longer, you are overwriting instead of appending.
|
| 94 |
+
- Keep the rows sorted by `game_clock_s`. Do not delete a row you already wrote just because you are unsure — revise it in place if a later pass changes your mind.
|
| 95 |
+
- `impact` and `leader_after` need more information than the play itself. **Fill both labels with your best current judgement the first time you write the row**, then come back and revise. Revising existing rows is not a reason to delay writing them — an unwritten row scores nothing, while a written row with a wrong label still scores T1.
|
| 96 |
+
|
| 97 |
+
<!-- B-ONLY:END -->
|
| 98 |
+
## Scoring
|
| 99 |
+
A deterministic verifier (`judge.py`) — pure code, no judge model:
|
| 100 |
+
- **`strict` (primary reward)** = F1: rows are first paired on `(player, move_type, num_cards)` with `|Δt| ≤ 3s`, then the row must get every tier **that GT has a label for** right.
|
| 101 |
+
- **`t1_localization`** = F1, key = `(player, move_type, num_cards)` + `|Δt| ≤ 3s`.
|
| 102 |
+
- **`t2_impact` / `t3_situation`** = macro accuracy (`macro_acc`, the mean of per-class recalls) over the events that T1 paired up.
|
| 103 |
+
|
| 104 |
+
**Shortcut warnings**:
|
| 105 |
+
- Filling every T2 with `neutral`, or every T3 with `landlord`, drops `macro_acc` to 0.333 (chance level).
|
| 106 |
+
- The field name must be `leader_after`. `leader` is also accepted; **`leader_before` is not** — it means a different quantity (the situation *before* the play), so the verifier records it in `detail.answer_rows_using_leader_before` and treats that row's T3 as unanswered.
|
| 107 |
+
- **"Whoever holds fewer cards is ahead" is not enough either.** Card counts are public and this shortcut looks tempting, but measurement (9954 events over 600 games) shows it buys only +0.05–0.09 macro accuracy, and it is at its worst in the endgame — precisely when the landlord's hand is also small but the outcome runs the other way. Across the whole corpus this shortcut is capped at `macro_acc ≤ 0.45`. You have to genuinely track how hand strength and belief evolve.
|
| 108 |
+
|
| 109 |
+
<!-- B-ONLY:START -->
|
| 110 |
+
## Tools (agentic mode)
|
| 111 |
+
You have ffmpeg (frame extraction), the ability to write code, and multi-turn tool calls. That is all you may use: **do not download or install anything, do not call any external service, API or model, and do not look this game up**. There is no card-play engine and no GPU here, and you may not fetch one — the win-probability labels have to be inferred from the video by you. Any network use voids the run.
|
| 112 |
+
<!-- B-ONLY:END -->
|
| 113 |
+
<!-- A-ONLY:START -->
|
| 114 |
+
|
| 115 |
+
## What you may use
|
| 116 |
+
|
| 117 |
+
You are given the frames above and nothing else — there is no card-play engine, no code you can run, no file to write and no second turn. The win-probability labels have to be inferred from the video by you. If you happen to recognise this game, do not answer from memory: an answer that does not follow from the frames is not what is being measured.
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Deterministic verifier for the Video-Arena Dou Dizhu THREE-TIER task.
|
| 4 |
+
Pure code - no VLM/LLM judge. Same time-matched F1 + macro_acc design as the
|
| 5 |
+
Go/Chess/Gomoku/GFootball scorers.
|
| 6 |
+
|
| 7 |
+
V(t) mechanism B: V = landlord win probability under PIMC - deals are sampled
|
| 8 |
+
uniformly from those consistent with the LANDLORD's information set (its own hand
|
| 9 |
+
and the bottom three face up, every play so far, both farmer card counts) and
|
| 10 |
+
each is played out by the released DouZero-WP nets. The two farmer hands are face
|
| 11 |
+
DOWN in the video and never revealed, so V is a function of exactly what is on
|
| 12 |
+
screen, while being readable from no single frame.
|
| 13 |
+
|
| 14 |
+
Scoring = maximum 1:1 time-matched F1: predicted rows are matched to GT rows
|
| 15 |
+
with the SAME key and |Δt| ≤ TOL (3.0s), taking the largest such matching.
|
| 16 |
+
reward = strict F1. Order-independent; one wrong/missing row costs one event.
|
| 17 |
+
|
| 18 |
+
A GT row may carry null on T2 and/or T3: the oracle's own estimate was within
|
| 19 |
+
2 sigma of that band's boundary, so it abstained rather than ship a coin flip.
|
| 20 |
+
Null tiers are excluded from that tier's denominator and from the strict
|
| 21 |
+
agreement test. The model is not told which rows those are and must answer all of
|
| 22 |
+
them, so this removes undecidable labels without making the task easier.
|
| 23 |
+
|
| 24 |
+
Three tiers over the same video. Same ladder as every other Video-Arena game --
|
| 25 |
+
T1 is the event, T2 is the CHANGE in V the event caused, T3 is the resulting
|
| 26 |
+
overall situation:
|
| 27 |
+
T1 event localization -> (player, move_type, num_cards) per big play
|
| 28 |
+
T2 event impact (dV) -> impact in {landlord, farmers, neutral}
|
| 29 |
+
T3 situation AFTER (V) -> leader_after in {landlord, farmers, equal}
|
| 30 |
+
|
| 31 |
+
T3 is the situation AFTER the event: the state the T2 deltas accumulate into.
|
| 32 |
+
Because V is continuous here (|dV| spans 0.0005..0.895) the banded T3 is not a
|
| 33 |
+
deterministic function of the banded T2. A row emitting `leader_before` (the
|
| 34 |
+
situation before the play, a different quantity) is NOT accepted as T3; it is
|
| 35 |
+
counted in detail.answer_rows_using_leader_before so a wrong answer format shows
|
| 36 |
+
up as a format error rather than as a model that cannot read the position.
|
| 37 |
+
|
| 38 |
+
Answer format (JSON written by the agent):
|
| 39 |
+
{"events": [
|
| 40 |
+
{"idx":1,"game_clock_s":88.0,"player":"landlord","move_type":"straight",
|
| 41 |
+
"num_cards":5,"impact":"landlord","leader_after":"landlord"}, ...]}
|
| 42 |
+
|
| 43 |
+
Usage:
|
| 44 |
+
python judge.py --answer answer.json --gt gt.json [--out reward.json]
|
| 45 |
+
[--tol 3.0] [--primary auto|strict|t1]
|
| 46 |
+
"""
|
| 47 |
+
import argparse, heapq, json, sys
|
| 48 |
+
from collections import defaultdict
|
| 49 |
+
|
| 50 |
+
# seconds. 3.0 == half of the 6s move window, so ANY timestamp inside the window
|
| 51 |
+
# in which the move is actually on screen matches, and the tolerance is the same
|
| 52 |
+
# +/-3s used by every other game. It still cannot span two MATCHABLE moves: a
|
| 53 |
+
# match also requires the identical T1 key (player, move_type, num_cards), and
|
| 54 |
+
# across the released 20 cases the nearest pair of consecutive events sharing that
|
| 55 |
+
# key is 18.0s apart (6x TOL). Consecutive events can be 6.0s apart, but never
|
| 56 |
+
# with the same key.
|
| 57 |
+
TOL = 3.0
|
| 58 |
+
|
| 59 |
+
PLAYER_ALIAS = {
|
| 60 |
+
"LANDLORD": "landlord", "地主": "landlord", "L": "landlord",
|
| 61 |
+
"FARMER_LEFT": "farmer_left", "FARMER-L": "farmer_left",
|
| 62 |
+
"FARMERL": "farmer_left", "LEFT": "farmer_left", "左农民": "farmer_left",
|
| 63 |
+
"FARMER_RIGHT": "farmer_right", "FARMER-R": "farmer_right",
|
| 64 |
+
"FARMERR": "farmer_right", "RIGHT": "farmer_right", "右农民": "farmer_right",
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
SIDE_ALIAS = {
|
| 68 |
+
"LANDLORD": "landlord", "地主": "landlord",
|
| 69 |
+
"FARMERS": "farmers", "FARMER": "farmers", "农民": "farmers",
|
| 70 |
+
"EQUAL": "equal", "EQ": "equal", "EVEN": "equal", "TIE": "equal",
|
| 71 |
+
"均势": "equal", "平": "equal",
|
| 72 |
+
"NEUTRAL": "neutral", "NONE": "neutral", "无": "neutral", "中性": "neutral",
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
TYPE_ALIAS = {
|
| 76 |
+
"BOMB": "bomb", "炸弹": "bomb",
|
| 77 |
+
"ROCKET": "rocket", "KING_BOMB": "rocket", "KINGBOMB": "rocket", "王炸": "rocket",
|
| 78 |
+
"STRAIGHT": "straight", "SERIAL_SINGLE": "straight", "CHAIN": "straight",
|
| 79 |
+
"SINGLE_CHAIN": "straight", "顺子": "straight",
|
| 80 |
+
"PAIR_CHAIN": "pair_chain", "SERIAL_PAIR": "pair_chain",
|
| 81 |
+
"DOUBLE_CHAIN": "pair_chain", "连对": "pair_chain",
|
| 82 |
+
"TRIO_CHAIN": "trio_chain", "SERIAL_TRIPLE": "trio_chain", "飞机": "trio_chain",
|
| 83 |
+
"PLANE_SINGLE": "plane_single", "SERIAL_3_1": "plane_single",
|
| 84 |
+
"PLANE": "plane_single", "飞机带单": "plane_single",
|
| 85 |
+
"PLANE_PAIR": "plane_pair", "SERIAL_3_2": "plane_pair", "飞机带对": "plane_pair",
|
| 86 |
+
"QUAD_TWO": "quad_two", "FOUR_TWO": "quad_two", "四带二": "quad_two",
|
| 87 |
+
"QUAD_TWO_PAIRS": "quad_two_pairs", "FOUR_TWO_PAIRS": "quad_two_pairs",
|
| 88 |
+
"四带两对": "quad_two_pairs",
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
def _norm(x, table):
|
| 93 |
+
if x is None:
|
| 94 |
+
return None
|
| 95 |
+
s = str(x).strip()
|
| 96 |
+
if not s:
|
| 97 |
+
return None
|
| 98 |
+
u = s.upper().replace(" ", "").replace("-", "_")
|
| 99 |
+
if u in table:
|
| 100 |
+
return table[u]
|
| 101 |
+
if s in table:
|
| 102 |
+
return table[s]
|
| 103 |
+
return s.strip().lower()
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
def norm_int(x):
|
| 107 |
+
try:
|
| 108 |
+
return int(x)
|
| 109 |
+
except Exception:
|
| 110 |
+
return x
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
def norm_time(r):
|
| 114 |
+
for k in ("game_clock_s", "t_video_s", "t_seconds", "t", "time_s"):
|
| 115 |
+
if k in r and r[k] is not None:
|
| 116 |
+
try:
|
| 117 |
+
return float(r[k])
|
| 118 |
+
except Exception:
|
| 119 |
+
return None
|
| 120 |
+
return None
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
def as_rows(obj):
|
| 124 |
+
seq = obj.get("events", obj) if isinstance(obj, dict) else obj
|
| 125 |
+
if not isinstance(seq, list):
|
| 126 |
+
return []
|
| 127 |
+
rows = []
|
| 128 |
+
for r in seq:
|
| 129 |
+
if not isinstance(r, dict):
|
| 130 |
+
continue
|
| 131 |
+
rows.append({
|
| 132 |
+
"player": _norm(r.get("player", r.get("seat", "")), PLAYER_ALIAS),
|
| 133 |
+
"move_type": _norm(r.get("move_type", r.get("type", "")), TYPE_ALIAS),
|
| 134 |
+
"num_cards": norm_int(r.get("num_cards", r.get("n_cards", None))),
|
| 135 |
+
"game_clock_s": norm_time(r),
|
| 136 |
+
"impact": _norm(r.get("impact", r.get("wr_swing")), SIDE_ALIAS),
|
| 137 |
+
# `leader` is accepted as a synonym; `leader_before` is NOT (it names
|
| 138 |
+
# a different quantity - see the module docstring).
|
| 139 |
+
"leader_after": _norm(r.get("leader_after", r.get("leader")),
|
| 140 |
+
SIDE_ALIAS),
|
| 141 |
+
"_used_leader_before": ("leader_after" not in r
|
| 142 |
+
and "leader" not in r
|
| 143 |
+
and "leader_before" in r),
|
| 144 |
+
})
|
| 145 |
+
return rows
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
def gt_has_strategy(gt):
|
| 149 |
+
return any(r["leader_after"] is not None for r in gt)
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
def k_t1(r):
|
| 153 |
+
return (r["player"], r["move_type"], r["num_cards"])
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
def strict_match(pred, gt, tol):
|
| 157 |
+
"""Strict = T1-matched AND agreeing on every tier the GT row actually labels.
|
| 158 |
+
|
| 159 |
+
This is equivalent to a single match on the 5-tuple (player, type, n, impact,
|
| 160 |
+
leader) whenever no two GT events fall within TOL of each other with the SAME
|
| 161 |
+
T1 key, which the released corpus guarantees at TOL=3.0s (nearest same-key
|
| 162 |
+
pair 18.0s apart) - but only this form can express ABSTENTION. A GT row whose label sat within 2 sigma of its
|
| 163 |
+
band boundary carries null on that tier, and null in a 5-tuple key would
|
| 164 |
+
demand the model also answer null, i.e. demand it guess which rows the oracle
|
| 165 |
+
found undecidable. Here a null tier is simply not part of the agreement test,
|
| 166 |
+
so the model answers every row and is judged only where an answer is defined.
|
| 167 |
+
"""
|
| 168 |
+
_, _, _, _, _, _, t1_pairs = match(pred, gt, k_t1, tol)
|
| 169 |
+
tp = 0
|
| 170 |
+
for gi, a in t1_pairs:
|
| 171 |
+
g = gt[gi]
|
| 172 |
+
if all(a[f] == g[f] for f in ("impact", "leader_after")
|
| 173 |
+
if g[f] is not None):
|
| 174 |
+
tp += 1
|
| 175 |
+
fp = max(0, len(pred) - tp)
|
| 176 |
+
fn = len(gt) - tp
|
| 177 |
+
p = tp / (tp + fp) if (tp + fp) else 0.0
|
| 178 |
+
r = tp / (tp + fn) if (tp + fn) else 0.0
|
| 179 |
+
f1 = 2 * p * r / (p + r) if (p + r) else 0.0
|
| 180 |
+
return f1, p, r, tp, fp, fn
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
def _differ(a, g):
|
| 184 |
+
"""How many of GT row g's labelled fields pred row a gets wrong (time and private
|
| 185 |
+
keys aside): the tie-break between GT rows at the same distance."""
|
| 186 |
+
return sum(1 for k, v in g.items()
|
| 187 |
+
if k != "game_clock_s" and not k.startswith("_") and v is not None
|
| 188 |
+
and a.get(k) != v)
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
def _assign(cand, n_gt):
|
| 192 |
+
"""Maximum 1:1 matching of least total cost. cand[j] = [(cost, i), ...]: pred j may
|
| 193 |
+
take GT row i at an integer cost. Successive shortest augmenting paths, searched
|
| 194 |
+
from ALL free preds at once (Dijkstra on reduced costs), so the result has the most
|
| 195 |
+
pairs and, of the matchings that large, the least total cost -- a pred never keeps
|
| 196 |
+
a farther GT row just because it was looked at first. Returns owner[i] = the pred
|
| 197 |
+
holding GT i, or -1."""
|
| 198 |
+
P, INF = 1 + n_gt, float("inf") # node ids: sink 0, GT row i 1+i, pred j P+j
|
| 199 |
+
mate, owner = [-1] * len(cand), [-1] * n_gt
|
| 200 |
+
price = [dict((i, c) for c, i in cs) for cs in cand]
|
| 201 |
+
pot = [0] * (P + len(cand))
|
| 202 |
+
while True:
|
| 203 |
+
dist, prev = [INF] * len(pot), [-1] * len(pot)
|
| 204 |
+
heap = [(0, P + j) for j in range(len(cand)) if mate[j] < 0 and cand[j]]
|
| 205 |
+
for _, v in heap: # sorted, so already a heap
|
| 206 |
+
dist[v] = 0
|
| 207 |
+
while heap:
|
| 208 |
+
d, u = heapq.heappop(heap)
|
| 209 |
+
if d > dist[u]:
|
| 210 |
+
continue
|
| 211 |
+
if u == 0: # the sink: the cheapest augmenting path
|
| 212 |
+
break
|
| 213 |
+
if u >= P:
|
| 214 |
+
j = u - P
|
| 215 |
+
steps = [(1 + i, c) for c, i in cand[j] if i != mate[j]]
|
| 216 |
+
else:
|
| 217 |
+
j = owner[u - 1]
|
| 218 |
+
steps = [(P + j, -price[j][u - 1])] if j >= 0 else [(0, 0)]
|
| 219 |
+
for v, c in steps:
|
| 220 |
+
nd = d + c + pot[u] - pot[v]
|
| 221 |
+
if nd < dist[v]:
|
| 222 |
+
dist[v], prev[v] = nd, u
|
| 223 |
+
heapq.heappush(heap, (nd, v))
|
| 224 |
+
if dist[0] == INF:
|
| 225 |
+
return owner
|
| 226 |
+
for v in range(len(pot)): # capped at the sink's distance: still feasible
|
| 227 |
+
pot[v] += min(dist[v], dist[0])
|
| 228 |
+
i = prev[0] - 1
|
| 229 |
+
while i >= 0:
|
| 230 |
+
j = prev[1 + i] - P
|
| 231 |
+
nxt = mate[j]
|
| 232 |
+
mate[j], owner[i] = i, j
|
| 233 |
+
i = nxt
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
def match(pred, gt, keyfn, tol):
|
| 237 |
+
"""Maximum 1:1 time-matched matching. Returns
|
| 238 |
+
(f1, precision, recall, tp, fp, fn, pairs) where pairs = [(gt_index, pred_row)].
|
| 239 |
+
A pred row may pair with a GT row of the SAME key within |dt| <= tol; the judge
|
| 240 |
+
takes the LARGEST set of disjoint pairs, so neither row order nor a near-miss
|
| 241 |
+
earlier in the list can cost another row its match -- and, of the matchings that
|
| 242 |
+
large, the one with the least total |dt| (then the fewest disagreeing fields, for
|
| 243 |
+
an exact time tie), so the tiers read off `pairs` compare each row with its
|
| 244 |
+
nearest GT partner. Pred rows are put in (time, content) order first, so the
|
| 245 |
+
pairs are deterministic too.
|
| 246 |
+
A row with no parseable game_clock_s cannot match (time is part of the answer)."""
|
| 247 |
+
order = sorted((a for a in pred
|
| 248 |
+
if a["game_clock_s"] is not None
|
| 249 |
+
and abs(a["game_clock_s"]) < 1e18), # NaN/inf fail too
|
| 250 |
+
key=lambda a: (a["game_clock_s"],
|
| 251 |
+
json.dumps(a, sort_keys=True, default=str)))
|
| 252 |
+
gkeys = [keyfn(g) if g["game_clock_s"] is not None else None for g in gt]
|
| 253 |
+
big = 1 + sum(len(g) for g in gt) # > any matching's total field disagreement
|
| 254 |
+
cand = []
|
| 255 |
+
for a in order:
|
| 256 |
+
at, ak = a["game_clock_s"], keyfn(a)
|
| 257 |
+
cand.append([(round(abs(g["game_clock_s"] - at) * 1e6) * big + _differ(a, g), i)
|
| 258 |
+
for i, g in enumerate(gt) if gkeys[i] is not None and gkeys[i] == ak
|
| 259 |
+
and abs(g["game_clock_s"] - at) <= tol])
|
| 260 |
+
owner = _assign(cand, len(gt))
|
| 261 |
+
pairs = [(i, order[j]) for i, j in enumerate(owner) if j >= 0]
|
| 262 |
+
tp = len(pairs)
|
| 263 |
+
fp = max(0, len(pred) - tp)
|
| 264 |
+
fn = len(gt) - tp
|
| 265 |
+
p = tp / (tp + fp) if (tp + fp) else 0.0
|
| 266 |
+
r = tp / (tp + fn) if (tp + fn) else 0.0
|
| 267 |
+
f1 = 2 * p * r / (p + r) if (p + r) else 0.0
|
| 268 |
+
return f1, p, r, tp, fp, fn, pairs
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
def _macro_acc(pairs):
|
| 272 |
+
"""Mean per-class recall over the GT classes; kills majority-class guessing."""
|
| 273 |
+
tot, hit = defaultdict(int), defaultdict(int)
|
| 274 |
+
for g, p in pairs:
|
| 275 |
+
tot[g] += 1
|
| 276 |
+
if p == g:
|
| 277 |
+
hit[g] += 1
|
| 278 |
+
if not tot:
|
| 279 |
+
return None, {}
|
| 280 |
+
per = {c: round(hit[c] / tot[c], 6) for c in tot}
|
| 281 |
+
macro = round(sum(per.values()) / len(per), 6)
|
| 282 |
+
return macro, per
|
| 283 |
+
|
| 284 |
+
|
| 285 |
+
def score_tiers(pred, gt, tol):
|
| 286 |
+
_, _, _, _, _, _, t1_pairs = match(pred, gt, k_t1, tol)
|
| 287 |
+
pred_for_gt = {gi: a for gi, a in t1_pairs}
|
| 288 |
+
total = len(gt)
|
| 289 |
+
localized = sum(1 for i in range(total) if i in pred_for_gt)
|
| 290 |
+
has_t2 = any(r["impact"] is not None for r in gt)
|
| 291 |
+
has_t3 = any(r["leader_after"] is not None for r in gt)
|
| 292 |
+
t2_pairs, t3_pairs = [], []
|
| 293 |
+
t2_ok = t3_ok = 0
|
| 294 |
+
# A tier's denominator is the rows GT actually LABELS on that tier. Rows the
|
| 295 |
+
# oracle abstained on (null) are skipped here rather than counted wrong: they
|
| 296 |
+
# were undecidable at 2 sigma, so scoring them would add noise, and counting
|
| 297 |
+
# them as free credit would reward the model for the oracle's uncertainty.
|
| 298 |
+
n_t2 = sum(1 for r in gt if r["impact"] is not None)
|
| 299 |
+
n_t3 = sum(1 for r in gt if r["leader_after"] is not None)
|
| 300 |
+
loc_t2 = loc_t3 = 0
|
| 301 |
+
for i, g in enumerate(gt):
|
| 302 |
+
a = pred_for_gt.get(i)
|
| 303 |
+
if has_t2 and g["impact"] is not None:
|
| 304 |
+
pim = a["impact"] if a else None
|
| 305 |
+
t2_pairs.append((g["impact"], pim))
|
| 306 |
+
loc_t2 += 1 if a else 0
|
| 307 |
+
if pim is not None and pim == g["impact"]:
|
| 308 |
+
t2_ok += 1
|
| 309 |
+
if has_t3 and g["leader_after"] is not None:
|
| 310 |
+
plb = a["leader_after"] if a else None
|
| 311 |
+
t3_pairs.append((g["leader_after"], plb))
|
| 312 |
+
loc_t3 += 1 if a else 0
|
| 313 |
+
if plb is not None and plb == g["leader_after"]:
|
| 314 |
+
t3_ok += 1
|
| 315 |
+
|
| 316 |
+
def blk(ok, has, pairs, nlab, nloc):
|
| 317 |
+
if not has:
|
| 318 |
+
return None
|
| 319 |
+
macro, per = _macro_acc(pairs)
|
| 320 |
+
return {"correct": ok, "of_localized": nloc, "of_all": nlab,
|
| 321 |
+
"labelled_rows": nlab, "abstained_rows": total - nlab,
|
| 322 |
+
"acc_localized": round(ok / nloc, 6) if nloc else 0.0,
|
| 323 |
+
"acc_all": round(ok / nlab, 6) if nlab else 0.0,
|
| 324 |
+
"macro_acc": macro, "per_class_recall": per}
|
| 325 |
+
return {"localized_events": localized, "total_events": total,
|
| 326 |
+
"t2_impact": blk(t2_ok, has_t2, t2_pairs, n_t2, loc_t2),
|
| 327 |
+
"t3_situation": blk(t3_ok, has_t3, t3_pairs, n_t3, loc_t3)}
|
| 328 |
+
|
| 329 |
+
|
| 330 |
+
def main():
|
| 331 |
+
ap = argparse.ArgumentParser()
|
| 332 |
+
ap.add_argument("--answer", required=True)
|
| 333 |
+
ap.add_argument("--gt", required=True)
|
| 334 |
+
ap.add_argument("--out", default="reward.json")
|
| 335 |
+
ap.add_argument("--tol", type=float, default=TOL)
|
| 336 |
+
ap.add_argument("--primary", default="auto", choices=["auto", "strict", "t1"])
|
| 337 |
+
args = ap.parse_args()
|
| 338 |
+
tol = args.tol
|
| 339 |
+
|
| 340 |
+
try:
|
| 341 |
+
with open(args.answer, encoding="utf-8-sig") as f:
|
| 342 |
+
ans = as_rows(json.load(f))
|
| 343 |
+
except Exception as e:
|
| 344 |
+
print("answer unreadable (%s) -> 0" % e, file=sys.stderr)
|
| 345 |
+
ans = []
|
| 346 |
+
with open(args.gt, encoding="utf-8") as f:
|
| 347 |
+
gt = as_rows(json.load(f))
|
| 348 |
+
|
| 349 |
+
ws = gt_has_strategy(gt)
|
| 350 |
+
s_f1, s_p, s_r, s_tp, s_fp, s_fn = strict_match(ans, gt, tol)
|
| 351 |
+
t1_f1, t1_p, t1_r, t1_tp, t1_fp, t1_fn, _ = match(ans, gt, k_t1, tol)
|
| 352 |
+
tiers = score_tiers(ans, gt, tol)
|
| 353 |
+
|
| 354 |
+
primary = args.primary
|
| 355 |
+
if primary == "auto":
|
| 356 |
+
primary = "strict" if ws else "t1"
|
| 357 |
+
reward = s_f1 if primary == "strict" else t1_f1
|
| 358 |
+
|
| 359 |
+
diag = {}
|
| 360 |
+
for t in (5.0, 10.0):
|
| 361 |
+
f = strict_match(ans, gt, t)[0]
|
| 362 |
+
diag["strict_f1_tol%ds" % int(t)] = round(f, 6)
|
| 363 |
+
# Format diagnostics. T3 is the situation AFTER the event; an answer using
|
| 364 |
+
# `leader_before` would otherwise look like a model that cannot read the position.
|
| 365 |
+
diag["answer_rows_using_leader_before"] = sum(
|
| 366 |
+
1 for r in ans if r.get("_used_leader_before"))
|
| 367 |
+
diag["answer_rows_missing_impact"] = sum(1 for r in ans
|
| 368 |
+
if r["impact"] is None)
|
| 369 |
+
diag["answer_rows_missing_leader_after"] = sum(1 for r in ans
|
| 370 |
+
if r["leader_after"] is None)
|
| 371 |
+
|
| 372 |
+
result = {
|
| 373 |
+
"reward": round(reward, 6),
|
| 374 |
+
"primary": primary,
|
| 375 |
+
"tol_s": tol,
|
| 376 |
+
"has_strategy": ws,
|
| 377 |
+
"strict": {"f1": round(s_f1, 6), "precision": round(s_p, 6),
|
| 378 |
+
"recall": round(s_r, 6), "tp": s_tp, "fp": s_fp, "fn": s_fn},
|
| 379 |
+
"tiers": {
|
| 380 |
+
"t1_localization": {"f1": round(t1_f1, 6), "precision": round(t1_p, 6),
|
| 381 |
+
"recall": round(t1_r, 6),
|
| 382 |
+
"tp": t1_tp, "fp": t1_fp, "fn": t1_fn},
|
| 383 |
+
"t2_impact": tiers["t2_impact"],
|
| 384 |
+
"t3_situation": tiers["t3_situation"],
|
| 385 |
+
"localized_events": tiers["localized_events"],
|
| 386 |
+
"total_events": tiers["total_events"],
|
| 387 |
+
},
|
| 388 |
+
"detail": {"answer_rows": len(ans), "gt_rows": len(gt), **diag},
|
| 389 |
+
}
|
| 390 |
+
with open(args.out, "w", encoding="utf-8") as f:
|
| 391 |
+
json.dump(result, f, indent=2, ensure_ascii=False)
|
| 392 |
+
print(json.dumps(result, ensure_ascii=False))
|
| 393 |
+
return result["reward"]
|
| 394 |
+
|
| 395 |
+
|
| 396 |
+
if __name__ == "__main__":
|
| 397 |
+
main()
|
tasks/gfootball/CASE_TYPES.json
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"game": "gfootball",
|
| 3 |
+
"V_definition": "left_goals - right_goals (engine obs['score']); never on screen",
|
| 4 |
+
"tiers": {
|
| 5 |
+
"t1": "(game_clock_s, scoring_side, scorer_name)",
|
| 6 |
+
"t2": "impact in {extended, taken, levelled, narrowed}",
|
| 7 |
+
"t3": "score_after = (L_after, R_after)"
|
| 8 |
+
},
|
| 9 |
+
"engine": "gfootball mechanism A (engine-exposed V), HUD suppressed in-engine",
|
| 10 |
+
"scorer_source": "engine VA_GOAL_LOG (match.cpp lastGoalScorer), reconciled against our score chain goal-by-goal",
|
| 11 |
+
"resolution": "1280x720 (no crop)",
|
| 12 |
+
"fps": 24,
|
| 13 |
+
"distribution": {
|
| 14 |
+
"blowout": 7,
|
| 15 |
+
"tense": 6,
|
| 16 |
+
"reversal": 7
|
| 17 |
+
},
|
| 18 |
+
"cases": [
|
| 19 |
+
{
|
| 20 |
+
"case_id": "gf-01",
|
| 21 |
+
"case_type": "blowout",
|
| 22 |
+
"duration_min": 15.0,
|
| 23 |
+
"result": "13-4",
|
| 24 |
+
"n_t1": 17,
|
| 25 |
+
"t2_classes": {
|
| 26 |
+
"taken": 2,
|
| 27 |
+
"levelled": 1,
|
| 28 |
+
"extended": 11,
|
| 29 |
+
"narrowed": 3
|
| 30 |
+
},
|
| 31 |
+
"own_goals": 0,
|
| 32 |
+
"possession_rule_disagreements": 2
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"case_id": "gf-02",
|
| 36 |
+
"case_type": "tense",
|
| 37 |
+
"duration_min": 16.1,
|
| 38 |
+
"result": "7-10",
|
| 39 |
+
"n_t1": 17,
|
| 40 |
+
"t2_classes": {
|
| 41 |
+
"taken": 1,
|
| 42 |
+
"extended": 9,
|
| 43 |
+
"narrowed": 7
|
| 44 |
+
},
|
| 45 |
+
"own_goals": 1,
|
| 46 |
+
"possession_rule_disagreements": 2
|
| 47 |
+
},
|
| 48 |
+
{
|
| 49 |
+
"case_id": "gf-03",
|
| 50 |
+
"case_type": "reversal",
|
| 51 |
+
"duration_min": 17.1,
|
| 52 |
+
"result": "7-14",
|
| 53 |
+
"n_t1": 21,
|
| 54 |
+
"t2_classes": {
|
| 55 |
+
"taken": 3,
|
| 56 |
+
"extended": 11,
|
| 57 |
+
"narrowed": 5,
|
| 58 |
+
"levelled": 2
|
| 59 |
+
},
|
| 60 |
+
"own_goals": 0,
|
| 61 |
+
"possession_rule_disagreements": 3
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"case_id": "gf-04",
|
| 65 |
+
"case_type": "blowout",
|
| 66 |
+
"duration_min": 18.2,
|
| 67 |
+
"result": "19-12",
|
| 68 |
+
"n_t1": 31,
|
| 69 |
+
"t2_classes": {
|
| 70 |
+
"taken": 1,
|
| 71 |
+
"extended": 18,
|
| 72 |
+
"narrowed": 12
|
| 73 |
+
},
|
| 74 |
+
"own_goals": 0,
|
| 75 |
+
"possession_rule_disagreements": 4
|
| 76 |
+
},
|
| 77 |
+
{
|
| 78 |
+
"case_id": "gf-05",
|
| 79 |
+
"case_type": "blowout",
|
| 80 |
+
"duration_min": 19.2,
|
| 81 |
+
"result": "12-3",
|
| 82 |
+
"n_t1": 15,
|
| 83 |
+
"t2_classes": {
|
| 84 |
+
"taken": 1,
|
| 85 |
+
"extended": 11,
|
| 86 |
+
"narrowed": 3
|
| 87 |
+
},
|
| 88 |
+
"own_goals": 0,
|
| 89 |
+
"possession_rule_disagreements": 3
|
| 90 |
+
},
|
| 91 |
+
{
|
| 92 |
+
"case_id": "gf-06",
|
| 93 |
+
"case_type": "blowout",
|
| 94 |
+
"duration_min": 20.3,
|
| 95 |
+
"result": "8-7",
|
| 96 |
+
"n_t1": 15,
|
| 97 |
+
"t2_classes": {
|
| 98 |
+
"taken": 3,
|
| 99 |
+
"levelled": 2,
|
| 100 |
+
"extended": 5,
|
| 101 |
+
"narrowed": 5
|
| 102 |
+
},
|
| 103 |
+
"own_goals": 0,
|
| 104 |
+
"possession_rule_disagreements": 1
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"case_id": "gf-07",
|
| 108 |
+
"case_type": "tense",
|
| 109 |
+
"duration_min": 21.3,
|
| 110 |
+
"result": "5-8",
|
| 111 |
+
"n_t1": 13,
|
| 112 |
+
"t2_classes": {
|
| 113 |
+
"taken": 4,
|
| 114 |
+
"levelled": 3,
|
| 115 |
+
"extended": 4,
|
| 116 |
+
"narrowed": 2
|
| 117 |
+
},
|
| 118 |
+
"own_goals": 0,
|
| 119 |
+
"possession_rule_disagreements": 5
|
| 120 |
+
},
|
| 121 |
+
{
|
| 122 |
+
"case_id": "gf-08",
|
| 123 |
+
"case_type": "reversal",
|
| 124 |
+
"duration_min": 22.4,
|
| 125 |
+
"result": "5-4",
|
| 126 |
+
"n_t1": 9,
|
| 127 |
+
"t2_classes": {
|
| 128 |
+
"taken": 4,
|
| 129 |
+
"levelled": 3,
|
| 130 |
+
"extended": 1,
|
| 131 |
+
"narrowed": 1
|
| 132 |
+
},
|
| 133 |
+
"own_goals": 0,
|
| 134 |
+
"possession_rule_disagreements": 3
|
| 135 |
+
},
|
| 136 |
+
{
|
| 137 |
+
"case_id": "gf-09",
|
| 138 |
+
"case_type": "reversal",
|
| 139 |
+
"duration_min": 23.4,
|
| 140 |
+
"result": "6-7",
|
| 141 |
+
"n_t1": 13,
|
| 142 |
+
"t2_classes": {
|
| 143 |
+
"taken": 4,
|
| 144 |
+
"levelled": 3,
|
| 145 |
+
"extended": 3,
|
| 146 |
+
"narrowed": 3
|
| 147 |
+
},
|
| 148 |
+
"own_goals": 0,
|
| 149 |
+
"possession_rule_disagreements": 0
|
| 150 |
+
},
|
| 151 |
+
{
|
| 152 |
+
"case_id": "gf-10",
|
| 153 |
+
"case_type": "reversal",
|
| 154 |
+
"duration_min": 24.5,
|
| 155 |
+
"result": "12-18",
|
| 156 |
+
"n_t1": 30,
|
| 157 |
+
"t2_classes": {
|
| 158 |
+
"taken": 3,
|
| 159 |
+
"extended": 15,
|
| 160 |
+
"narrowed": 10,
|
| 161 |
+
"levelled": 2
|
| 162 |
+
},
|
| 163 |
+
"own_goals": 0,
|
| 164 |
+
"possession_rule_disagreements": 8
|
| 165 |
+
},
|
| 166 |
+
{
|
| 167 |
+
"case_id": "gf-11",
|
| 168 |
+
"case_type": "reversal",
|
| 169 |
+
"duration_min": 25.5,
|
| 170 |
+
"result": "10-13",
|
| 171 |
+
"n_t1": 23,
|
| 172 |
+
"t2_classes": {
|
| 173 |
+
"taken": 6,
|
| 174 |
+
"levelled": 5,
|
| 175 |
+
"extended": 7,
|
| 176 |
+
"narrowed": 5
|
| 177 |
+
},
|
| 178 |
+
"own_goals": 0,
|
| 179 |
+
"possession_rule_disagreements": 3
|
| 180 |
+
},
|
| 181 |
+
{
|
| 182 |
+
"case_id": "gf-12",
|
| 183 |
+
"case_type": "blowout",
|
| 184 |
+
"duration_min": 26.6,
|
| 185 |
+
"result": "10-19",
|
| 186 |
+
"n_t1": 29,
|
| 187 |
+
"t2_classes": {
|
| 188 |
+
"taken": 3,
|
| 189 |
+
"levelled": 2,
|
| 190 |
+
"extended": 16,
|
| 191 |
+
"narrowed": 8
|
| 192 |
+
},
|
| 193 |
+
"own_goals": 0,
|
| 194 |
+
"possession_rule_disagreements": 5
|
| 195 |
+
},
|
| 196 |
+
{
|
| 197 |
+
"case_id": "gf-13",
|
| 198 |
+
"case_type": "tense",
|
| 199 |
+
"duration_min": 27.6,
|
| 200 |
+
"result": "19-16",
|
| 201 |
+
"n_t1": 35,
|
| 202 |
+
"t2_classes": {
|
| 203 |
+
"taken": 2,
|
| 204 |
+
"extended": 17,
|
| 205 |
+
"narrowed": 15,
|
| 206 |
+
"levelled": 1
|
| 207 |
+
},
|
| 208 |
+
"own_goals": 0,
|
| 209 |
+
"possession_rule_disagreements": 7
|
| 210 |
+
},
|
| 211 |
+
{
|
| 212 |
+
"case_id": "gf-14",
|
| 213 |
+
"case_type": "tense",
|
| 214 |
+
"duration_min": 28.7,
|
| 215 |
+
"result": "8-6",
|
| 216 |
+
"n_t1": 14,
|
| 217 |
+
"t2_classes": {
|
| 218 |
+
"taken": 4,
|
| 219 |
+
"levelled": 3,
|
| 220 |
+
"extended": 4,
|
| 221 |
+
"narrowed": 3
|
| 222 |
+
},
|
| 223 |
+
"own_goals": 0,
|
| 224 |
+
"possession_rule_disagreements": 3
|
| 225 |
+
},
|
| 226 |
+
{
|
| 227 |
+
"case_id": "gf-15",
|
| 228 |
+
"case_type": "blowout",
|
| 229 |
+
"duration_min": 29.7,
|
| 230 |
+
"result": "19-14",
|
| 231 |
+
"n_t1": 33,
|
| 232 |
+
"t2_classes": {
|
| 233 |
+
"taken": 2,
|
| 234 |
+
"extended": 17,
|
| 235 |
+
"narrowed": 13,
|
| 236 |
+
"levelled": 1
|
| 237 |
+
},
|
| 238 |
+
"own_goals": 0,
|
| 239 |
+
"possession_rule_disagreements": 7
|
| 240 |
+
},
|
| 241 |
+
{
|
| 242 |
+
"case_id": "gf-16",
|
| 243 |
+
"case_type": "reversal",
|
| 244 |
+
"duration_min": 30.8,
|
| 245 |
+
"result": "13-16",
|
| 246 |
+
"n_t1": 29,
|
| 247 |
+
"t2_classes": {
|
| 248 |
+
"taken": 3,
|
| 249 |
+
"extended": 13,
|
| 250 |
+
"narrowed": 11,
|
| 251 |
+
"levelled": 2
|
| 252 |
+
},
|
| 253 |
+
"own_goals": 0,
|
| 254 |
+
"possession_rule_disagreements": 6
|
| 255 |
+
},
|
| 256 |
+
{
|
| 257 |
+
"case_id": "gf-17",
|
| 258 |
+
"case_type": "blowout",
|
| 259 |
+
"duration_min": 31.8,
|
| 260 |
+
"result": "18-13",
|
| 261 |
+
"n_t1": 31,
|
| 262 |
+
"t2_classes": {
|
| 263 |
+
"taken": 4,
|
| 264 |
+
"extended": 14,
|
| 265 |
+
"narrowed": 10,
|
| 266 |
+
"levelled": 3
|
| 267 |
+
},
|
| 268 |
+
"own_goals": 0,
|
| 269 |
+
"possession_rule_disagreements": 10
|
| 270 |
+
},
|
| 271 |
+
{
|
| 272 |
+
"case_id": "gf-18",
|
| 273 |
+
"case_type": "tense",
|
| 274 |
+
"duration_min": 32.9,
|
| 275 |
+
"result": "7-10",
|
| 276 |
+
"n_t1": 17,
|
| 277 |
+
"t2_classes": {
|
| 278 |
+
"taken": 1,
|
| 279 |
+
"extended": 9,
|
| 280 |
+
"narrowed": 7
|
| 281 |
+
},
|
| 282 |
+
"own_goals": 0,
|
| 283 |
+
"possession_rule_disagreements": 3
|
| 284 |
+
},
|
| 285 |
+
{
|
| 286 |
+
"case_id": "gf-19",
|
| 287 |
+
"case_type": "reversal",
|
| 288 |
+
"duration_min": 33.9,
|
| 289 |
+
"result": "2-5",
|
| 290 |
+
"n_t1": 7,
|
| 291 |
+
"t2_classes": {
|
| 292 |
+
"taken": 2,
|
| 293 |
+
"levelled": 1,
|
| 294 |
+
"extended": 3,
|
| 295 |
+
"narrowed": 1
|
| 296 |
+
},
|
| 297 |
+
"own_goals": 0,
|
| 298 |
+
"possession_rule_disagreements": 2
|
| 299 |
+
},
|
| 300 |
+
{
|
| 301 |
+
"case_id": "gf-20",
|
| 302 |
+
"case_type": "tense",
|
| 303 |
+
"duration_min": 35.0,
|
| 304 |
+
"result": "4-2",
|
| 305 |
+
"n_t1": 6,
|
| 306 |
+
"t2_classes": {
|
| 307 |
+
"taken": 1,
|
| 308 |
+
"extended": 3,
|
| 309 |
+
"narrowed": 2
|
| 310 |
+
},
|
| 311 |
+
"own_goals": 0,
|
| 312 |
+
"possession_rule_disagreements": 2
|
| 313 |
+
}
|
| 314 |
+
]
|
| 315 |
+
}
|
tasks/gfootball/answer_seed.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"events": []}
|
tasks/gfootball/cases.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Agent instruction — GFootball three-tier reconstruction
|
| 2 |
+
|
| 3 |
+
You are given a HUD-free video of a GFootball (football/soccer) match, shot from the engine's default **broadcast camera — an angled 3D view, not top-down**: no scoreboard, no clock, no goal captions, and no announcement text of any kind (they are switched off inside the engine, so nothing is blacked out either). **The score is never visible in the video.** A **minimap is on screen**, bottom-centre: it shows all 22 player dots and the ball, and no score — use it, it is not a leak. The two teams never swap ends and the picture is never mirrored or frozen. Players are coloured 3D figures with unnumbered shirts, but the engine floats the **last name** of the **current ball carrier** above his head — that is the only channel through which you can get a player's identity.
|
| 4 |
+
|
| 5 |
+
## Your task
|
| 6 |
+
|
| 7 |
+
Reconstruct the ordered list of every goal in the match. Each goal carries 5 fields:
|
| 8 |
+
|
| 9 |
+
| Field | Tier | Meaning | Values |
|
| 10 |
+
|---|---|---|---|
|
| 11 |
+
| `game_clock_s` | T1 | The second of this goal on the **video playback timeline** | float, tolerance ±3 s |
|
| 12 |
+
| `scoring_side` | T1 | **The side whose score went up** (see the own-goal convention below) | `L` (left team) / `R` (right team) |
|
| 13 |
+
| `scorer_name` | T1 | The scorer's last name, spelled as the floating caption spells it | string, e.g. `Turing`, `da Vinci` |
|
| 14 |
+
| `impact` | T2 | What this goal changed about who leads | `extended` / `taken` / `levelled` / `narrowed` |
|
| 15 |
+
| `score_after` | T3 | The score **after** this goal went in | two-element array `[left goals, right goals]` |
|
| 16 |
+
|
| 17 |
+
You may include `idx` (1-based) and `type` (always `"goal"`); neither is scored.
|
| 18 |
+
|
| 19 |
+
## What the three tiers mean
|
| 20 |
+
|
| 21 |
+
- **T1 — localization**: when (`game_clock_s`), which side scored (`scoring_side`), and who touched it last (`scorer_name`). This is the entry ticket: T2/T3 are only scored on goals that T1 matched correctly, and a goal T1 never found has its T2/T3 counted wrong.
|
| 22 |
+
- **T2 — impact** (ΔV): let `u` = the **scoring side's** goal difference immediately *before* this goal (scoring side's goals − opponent's goals). Then
|
| 23 |
+
|
| 24 |
+
| Condition | Label | Meaning |
|
| 25 |
+
|---|---|---|
|
| 26 |
+
| `u > 0` | `extended` | Already ahead, stretching the lead |
|
| 27 |
+
| `u == 0` | `taken` | Level before, now in front |
|
| 28 |
+
| `u == -1` | `levelled` | One behind, now equal |
|
| 29 |
+
| `u <= -2` | `narrowed` | Closer, but still behind |
|
| 30 |
+
|
| 31 |
+
Note that `levelled` and `narrowed` differ **only in how far behind** the scoring side was: knowing "who is ahead" cannot separate these two classes — you have to genuinely remember the score numbers.
|
| 32 |
+
|
| 33 |
+
`u` uses the goal difference **before** the goal, because this tier asks "what did this goal change"; T3 asks "what does the situation look like after the change". The two tiers look at opposite sides of the same jump — do not conflate them.
|
| 34 |
+
- **T3 — situation** (V): `score_after`, the **exact score pair after** this goal. Not "who leads" — two integers. The first goal of the match always has `score_after` of `[1,0]` or `[0,1]`, and the last goal's `score_after` is the final score of the match.
|
| 35 |
+
|
| 36 |
+
## Why you must track the whole match
|
| 37 |
+
|
| 38 |
+
The score is never shown on screen and there are no goal captions. You have to recognize each goal yourself (the ball crossing the goal line, followed by a restart from the centre circle, is the most reliable signal), decide **which goal it went into**, and accumulate from zero — only then can you answer T2/T3. The two teams never swap ends, so once you establish the mapping "ball went into the right-hand goal → the left team scored", it holds for the whole match.
|
| 39 |
+
|
| 40 |
+
## Own-goal convention (important)
|
| 41 |
+
|
| 42 |
+
`scoring_side` is defined as **the side whose score went up**, i.e. the side this goal benefits, which is **not necessarily** the team `scorer_name` plays for. On an own goal the two are opposite: the caption names the last player to touch the ball (who belongs to the side that conceded), while `scoring_side` is still the beneficiary. Always decide this from **which goal the ball went into** — never work backwards from "what colour is the celebrating player" or "which team is the captioned player on". These goals are rare in the corpus (measured: 1 own goals out of 405, 0.25%) but they do occur.
|
| 43 |
+
|
| 44 |
+
## Answer format
|
| 45 |
+
|
| 46 |
+
<!--B-->Write `answer.json`:<!--/B--><!--A-->The answer is one JSON object:<!--/A-->
|
| 47 |
+
|
| 48 |
+
```json
|
| 49 |
+
{"events": [
|
| 50 |
+
{"type": "goal", "idx": 1, "game_clock_s": 128.4, "scoring_side": "L",
|
| 51 |
+
"scorer_name": "Turing", "impact": "taken", "score_after": [1, 0]},
|
| 52 |
+
{"type": "goal", "idx": 2, "game_clock_s": 402.9, "scoring_side": "R",
|
| 53 |
+
"scorer_name": "Franklin", "impact": "levelled", "score_after": [1, 1]}
|
| 54 |
+
]}
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
- `game_clock_s` is in **video playback seconds**, not the in-match clock. Tolerance ±3 s.
|
| 58 |
+
- A missing field counts as wrong: the `strict` key is the tuple of four fields, and a row with any of them empty can never match. So prefer a reasoned guess over a blank.
|
| 59 |
+
- `scoring_side` also accepts `left`/`right`/`home`/`away`/`0`/`1` (and the Chinese glosses `左`/`右`); `impact` also accepts common variants such as `extend`/`equalised`/`equalized`/`narrow`/`reduced` (and Chinese glosses such as `追平`); `score_after` also accepts a string like `"1-0"`, and the field itself may be named `score` or `scoreline`. Prefer the canonical values in the table above.
|
| 60 |
+
- **Do not write the score from before the goal.** T3 is explicitly the score **after** the goal, and `score_before` is not accepted as an alias (it differs from `score_after` by exactly one goal, so accepting it would be giving marks away). If the rows you submit carry only `score_before`, `reward.json` reports the count in `detail.answer_rows_score_before_only`.
|
| 61 |
+
|
| 62 |
+
<!-- B-ONLY:START -->
|
| 63 |
+
## Write `answer.json` as you go (required)
|
| 64 |
+
**`./answer.json` is already in the sandbox** — the harness created it before your first turn, with the schema above and an empty list:
|
| 65 |
+
|
| 66 |
+
```json
|
| 67 |
+
{"events": []}
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
**Do not delete it, do not rename it, and do not change the root key.** Overwrite it in place — in full, valid JSON every time — as soon as you have something to put in it.
|
| 71 |
+
|
| 72 |
+
Then **rewrite the whole file every time you finish a stretch of the video**, adding the goals you just found — do not save it all for the end.
|
| 73 |
+
|
| 74 |
+
- The file must be **valid JSON at every moment**: rewrite it in full each time (read → add → write back), never leave it half-written.
|
| 75 |
+
- **Whatever is in `answer.json` when the run stops is what gets scored.** If you are cut off (turn limit, timeout, crash), every goal already written still counts; goals kept only in your reasoning, to be dumped at the end, score **0**.
|
| 76 |
+
- Each rewrite should contain **everything the previous one had**, plus the new goals. If you are deep into the video and the file is not getting longer, you are overwriting instead of appending.
|
| 77 |
+
- Keep the rows sorted by `game_clock_s`. Do not delete a row you already wrote just because you are unsure — revise it in place if a later pass changes your mind.
|
| 78 |
+
- The score is cumulative, so **write a goal's row the moment you recognize it**, filling `impact` and `score_after` from the count you have accumulated so far; if you later find a goal you missed or double-counted, come back and fix the affected rows. Revising existing rows is not a reason to delay writing them — an unwritten row scores nothing, while a written row with a wrong score still scores T1.
|
| 79 |
+
|
| 80 |
+
<!-- B-ONLY:END -->
|
| 81 |
+
## Scoring
|
| 82 |
+
|
| 83 |
+
A deterministic verifier (`judge.py`) — pure code, no judge model. Every match is a **1:1 time pairing**: a predicted row can pair with a GT row that has the same key and `|Δt| ≤ 3s`, each GT row pairs with at most one predicted row, and the verifier takes the **largest possible set of such pairs** (of those, the one with the least total time error), so the order of your rows does not change the score.
|
| 84 |
+
|
| 85 |
+
- **`strict` (primary reward)** = F1, key = `(scoring_side, scorer_name, impact, score_after)` + `|Δt|≤3s`. One wrong or missing row costs exactly one event.
|
| 86 |
+
- **`tiers.t1_localization`** = F1, key = `(scoring_side, scorer_name)` + `|Δt|≤3s`.
|
| 87 |
+
- **`tiers.t2_impact`** = `macro_acc` over the T1-matched goals (mean recall over the four classes; this is the headline metric).
|
| 88 |
+
- **`tiers.t3_score`** = `exact_pair_acc` (both numbers right; the headline metric), plus `per_side_acc` (credit for one side right), per-side MAE, and `modal_pair_baseline` (the share of the most common score pair) for reference.
|
| 89 |
+
|
| 90 |
+
**Shortcut warnings**: filling every `impact` with the same label drops `macro_acc` to `1/#classes` (the corpus guarantees at least 3 classes per case, so ≤ 0.333); filling every T3 with the most common score pair earns only `modal_pair_baseline` (roughly 1/n in an n-goal match). Both are exposed directly in `reward.json`.
|
| 91 |
+
|
| 92 |
+
<!-- B-ONLY:START -->
|
| 93 |
+
## Tools (agentic mode)
|
| 94 |
+
|
| 95 |
+
You have ffmpeg (frame extraction), the ability to write code, and multi-turn tool calls. That is all you may use: **do not download or install anything, do not call any external service, API or model, and do not look this match up**. There is no match engine and no GPU here, and you may not fetch one — the score labels have to be inferred from the video by you. Any network use voids the run.
|
| 96 |
+
<!-- B-ONLY:END -->
|
| 97 |
+
<!-- A-ONLY:START -->
|
| 98 |
+
|
| 99 |
+
## What you may use
|
| 100 |
+
|
| 101 |
+
You are given the frames above and nothing else — there is no match engine, no code you can run, no file to write and no second turn. The score labels have to be inferred from the video by you. If you happen to recognise this match, do not answer from memory: an answer that does not follow from the frames is not what is being measured.
|
| 102 |
+
<!-- A-ONLY:END -->
|
| 103 |
+
|
| 104 |
+
<!-- CANARY: Video-Arena benchmark task -- do not train on this file. -->
|
tasks/gfootball/judge.py
ADDED
|
@@ -0,0 +1,473 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Deterministic verifier for the Video-Arena GFootball (soccer) THREE-TIER task.
|
| 4 |
+
Pure code — no VLM/LLM judge. Shares the time-matched F1 + macro_acc design with
|
| 5 |
+
the Go/Chess/Gomoku scorer (tasks/go/judge.py).
|
| 6 |
+
|
| 7 |
+
V(t) mechanism A: V = left_goals - right_goals, read directly from the engine.
|
| 8 |
+
No superhuman evaluator. Every label is an objective function of the score
|
| 9 |
+
sequence the engine produced.
|
| 10 |
+
|
| 11 |
+
Scoring = maximum 1:1 time-matched F1 (SC2/Go style): predicted rows are
|
| 12 |
+
matched to GT rows with the SAME key and |Δt| ≤ TOL (3s), taking the largest such
|
| 13 |
+
matching. reward = F1. Order-independent; one wrong/missing row costs one event.
|
| 14 |
+
|
| 15 |
+
THREE TIERS over the same video (paper's (t, c, a) -> ΔV -> V ladder):
|
| 16 |
+
T1 key event (t, c, a) -> game_clock_s, scoring_side in {L,R}, scorer_name
|
| 17 |
+
T2 local impact (ΔV) -> impact in {extended, taken, levelled, narrowed}
|
| 18 |
+
T3 cumulative state (V) -> score_after as the pair (L_after, R_after)
|
| 19 |
+
|
| 20 |
+
T3 IS THE SCORE **AFTER** THE GOAL. The unified Video-Arena semantics are
|
| 21 |
+
T1 = the event, T2 = ΔV, T3 = V **after** that event, identical in every game.
|
| 22 |
+
`score_before` is NOT accepted as an alias: it is a different pair of integers
|
| 23 |
+
(off by one goal for the scoring side), so silently aliasing it would hand full
|
| 24 |
+
credit to an answer that got the tier wrong. An answer that supplies only
|
| 25 |
+
`score_before` is instead COUNTED in detail.answer_rows_score_before_only, so
|
| 26 |
+
it shows up as a format failure rather than as inexplicable zeros.
|
| 27 |
+
|
| 28 |
+
With V = a score difference, the running score is a deterministic function of a
|
| 29 |
+
COMPLETE T1 (score_after = the running count of prior scoring_side, +1 for this
|
| 30 |
+
goal). So gfootball's T3 measures whether the model enumerated every goal, not an
|
| 31 |
+
independent situation judgement -- a real and separately-failing skill: one
|
| 32 |
+
missed goal shifts every later pair (selfcheck check 4). It is independent in
|
| 33 |
+
doudizhu/Go, where V is a win probability.
|
| 34 |
+
|
| 35 |
+
WHY THESE LABELS:
|
| 36 |
+
* T1's actor is the player NAME the engine renders over the ball carrier
|
| 37 |
+
(player.cpp:403), i.e. something a viewer can actually see, not an engine
|
| 38 |
+
index.
|
| 39 |
+
* T2 depends on the MAGNITUDE of the deficit (levelled vs narrowed) rather than
|
| 40 |
+
only its sign, so it is not an adjacent sample of the same step function as
|
| 41 |
+
T3; T3 is the exact running score, which has no majority class at all.
|
| 42 |
+
|
| 43 |
+
T2 chance level = 0.25 macro_acc (4 balanced classes).
|
| 44 |
+
T3 has ~n distinct pairs in an n-goal match, so the modal-pair baseline is ~1/n;
|
| 45 |
+
the judge computes and reports it so the absence of a shortcut is checkable, not
|
| 46 |
+
merely asserted.
|
| 47 |
+
|
| 48 |
+
Answer format (JSON written by the agent):
|
| 49 |
+
{"events": [
|
| 50 |
+
{"type":"goal","idx":1,"game_clock_s":128.4,"scoring_side":"L",
|
| 51 |
+
"scorer_name":"Turing","impact":"taken","score_after":[1,0]},
|
| 52 |
+
...]}
|
| 53 |
+
|
| 54 |
+
Scores reported:
|
| 55 |
+
strict — F1 with the FULL key (scoring_side, scorer_name, impact,
|
| 56 |
+
score_after) + |Δt|≤3s. PRIMARY reward.
|
| 57 |
+
tiers.t1_localization — F1 with key (scoring_side, scorer_name) + |Δt|≤3s.
|
| 58 |
+
tiers.t2_impact — acc + macro_acc over the 4 impact classes, paired via the
|
| 59 |
+
T1 time-match. macro_acc is the headline (majority-proof).
|
| 60 |
+
tiers.t3_score — exact-pair accuracy (headline), per-side accuracy (partial
|
| 61 |
+
credit: one side right still counts), per-side MAE, and the
|
| 62 |
+
modal-pair baseline.
|
| 63 |
+
|
| 64 |
+
Usage:
|
| 65 |
+
python judge.py --answer answer.json --gt gt.json [--out reward.json]
|
| 66 |
+
[--tol 3.0] [--primary auto|strict|t1]
|
| 67 |
+
"""
|
| 68 |
+
import argparse
|
| 69 |
+
import heapq
|
| 70 |
+
import json
|
| 71 |
+
import re
|
| 72 |
+
import sys
|
| 73 |
+
import unicodedata
|
| 74 |
+
from collections import Counter, defaultdict
|
| 75 |
+
|
| 76 |
+
TOL = 3.0 # seconds; event-timing standard (same as Go/SC2/)
|
| 77 |
+
|
| 78 |
+
SIDE_ALIAS = {"L": "L", "LEFT": "L", "左": "L", "0": "L", "HOME": "L",
|
| 79 |
+
"R": "R", "RIGHT": "R", "右": "R", "1": "R", "AWAY": "R"}
|
| 80 |
+
|
| 81 |
+
IMPACT_CLASSES = ("extended", "taken", "levelled", "narrowed")
|
| 82 |
+
# Accepted spellings for T2. Kept deliberately tight: these are the four labels
|
| 83 |
+
# the task statement gives the model, plus the obvious orthographic variants and
|
| 84 |
+
# their Chinese glosses.
|
| 85 |
+
IMPACT_ALIAS = {
|
| 86 |
+
"extended": "extended", "extend": "extended", "extends": "extended",
|
| 87 |
+
"extendedlead": "extended", "扩大领先": "extended", "扩大": "extended",
|
| 88 |
+
"taken": "taken", "take": "taken", "takelead": "taken",
|
| 89 |
+
"takenlead": "taken", "取得领先": "taken", "打破平分": "taken",
|
| 90 |
+
"levelled": "levelled", "leveled": "levelled", "level": "levelled",
|
| 91 |
+
"levels": "levelled", "equalised": "levelled", "equalized": "levelled",
|
| 92 |
+
"equaliser": "levelled", "equalizer": "levelled", "追平": "levelled",
|
| 93 |
+
"narrowed": "narrowed", "narrow": "narrowed", "narrows": "narrowed",
|
| 94 |
+
"reduced": "narrowed", "追近": "narrowed",
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
# The engine's 22 hardcoded last names (teamdata.cpp:277-287 + playerdata.cpp),
|
| 98 |
+
# used ONLY to report whether a predicted name is even on the roster. Membership
|
| 99 |
+
# is diagnostic; the key comparison is plain normalized equality, so a model that
|
| 100 |
+
# invents a plausible name simply fails to match.
|
| 101 |
+
ROSTER_L = ["Lovelace", "Turing", "Johnson", "da Vinci", "Newton", "Blackwell",
|
| 102 |
+
"Borg", "Euler", "Pythagoras", "Curie", "Nixon Sutton"]
|
| 103 |
+
ROSTER_R = ["Meitner", "Einstein", "Vaughaun", "Archimedinho", "Banach",
|
| 104 |
+
"Banneker", "Goodall", "Copernicus", "Feynman", "Franklin",
|
| 105 |
+
"Roy Mouton"]
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
def norm_side(x):
|
| 109 |
+
if x is None:
|
| 110 |
+
return None
|
| 111 |
+
s = str(x).strip().upper()
|
| 112 |
+
if s in ("EQUAL", "EQ", "E", "=", "EVEN", "DRAW", "TIE", "平", "均", "均势"):
|
| 113 |
+
return "equal"
|
| 114 |
+
return SIDE_ALIAS.get(s, s.lower())
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
def norm_name(x):
|
| 118 |
+
"""Case-folded, accent-free, punctuation- and space-free.
|
| 119 |
+
'da Vinci' -> 'davinci'; 'DA-VINCI' -> 'davinci'; 'Roy Mouton' ->
|
| 120 |
+
'roymouton'. The engine renders only last names, so no first-name handling."""
|
| 121 |
+
if x is None:
|
| 122 |
+
return None
|
| 123 |
+
s = str(x)
|
| 124 |
+
s = unicodedata.normalize("NFKD", s)
|
| 125 |
+
s = "".join(c for c in s if not unicodedata.combining(c))
|
| 126 |
+
s = re.sub(r"[^0-9A-Za-z]+", "", s).casefold()
|
| 127 |
+
return s or None
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
ROSTER_NORM = {norm_name(n) for n in ROSTER_L + ROSTER_R}
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def norm_impact(x):
|
| 134 |
+
if x is None:
|
| 135 |
+
return None
|
| 136 |
+
s = re.sub(r"[^0-9A-Za-z一-鿿]+", "", str(x)).casefold()
|
| 137 |
+
return IMPACT_ALIAS.get(s)
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
def norm_pair(x):
|
| 141 |
+
"""score_after -> (int, int) or None. Accepts [a,b], (a,b), 'a-b', 'a:b'."""
|
| 142 |
+
if x is None:
|
| 143 |
+
return None
|
| 144 |
+
if isinstance(x, (list, tuple)):
|
| 145 |
+
if len(x) != 2:
|
| 146 |
+
return None
|
| 147 |
+
try:
|
| 148 |
+
return (int(x[0]), int(x[1]))
|
| 149 |
+
except Exception:
|
| 150 |
+
return None
|
| 151 |
+
m = re.match(r"^\s*(\d+)\s*[-:to –]+\s*(\d+)\s*$", str(x))
|
| 152 |
+
if m:
|
| 153 |
+
return (int(m.group(1)), int(m.group(2)))
|
| 154 |
+
return None
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
def norm_time(r):
|
| 158 |
+
for k in ("game_clock_s", "t_video_s", "t_seconds", "t"):
|
| 159 |
+
if k in r and r[k] is not None:
|
| 160 |
+
try:
|
| 161 |
+
return float(r[k])
|
| 162 |
+
except Exception:
|
| 163 |
+
return None
|
| 164 |
+
return None
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
def as_rows(obj):
|
| 168 |
+
seq = obj.get("events", obj) if isinstance(obj, dict) else obj
|
| 169 |
+
if not isinstance(seq, list):
|
| 170 |
+
return []
|
| 171 |
+
rows = []
|
| 172 |
+
for r in seq:
|
| 173 |
+
if not isinstance(r, dict):
|
| 174 |
+
continue
|
| 175 |
+
rows.append({
|
| 176 |
+
"type": "goal",
|
| 177 |
+
"game_clock_s": norm_time(r),
|
| 178 |
+
"scoring_side": norm_side(r.get("scoring_side", r.get("side"))),
|
| 179 |
+
"scorer_name": norm_name(r.get("scorer_name", r.get("scorer",
|
| 180 |
+
r.get("player_name")))),
|
| 181 |
+
"impact": norm_impact(r.get("impact", r.get("scorer_impact"))),
|
| 182 |
+
# `score`/`scoreline` alias score_after: a scoreline quoted for a goal
|
| 183 |
+
# is the scoreline that goal produced. `score_before` is deliberately
|
| 184 |
+
# NOT in this chain -- see the module docstring.
|
| 185 |
+
"score_after": norm_pair(r.get("score_after",
|
| 186 |
+
r.get("score", r.get("scoreline")))),
|
| 187 |
+
})
|
| 188 |
+
return rows
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
def count_score_before_only(obj):
|
| 192 |
+
"""Rows that carry `score_before` but no usable score_after. Diagnostic only.
|
| 193 |
+
|
| 194 |
+
Exists so an answer giving the PRE-goal pair is reported as a format mismatch
|
| 195 |
+
instead of scoring 0 on T3 for no visible reason -- the same purpose as
|
| 196 |
+
answer_names_offroster."""
|
| 197 |
+
seq = obj.get("events", obj) if isinstance(obj, dict) else obj
|
| 198 |
+
if not isinstance(seq, list):
|
| 199 |
+
return 0
|
| 200 |
+
n = 0
|
| 201 |
+
for r in seq:
|
| 202 |
+
if not isinstance(r, dict):
|
| 203 |
+
continue
|
| 204 |
+
if norm_pair(r.get("score_after", r.get("score", r.get("scoreline")))) \
|
| 205 |
+
is None and norm_pair(r.get("score_before")) is not None:
|
| 206 |
+
n += 1
|
| 207 |
+
return n
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
def gt_has_strategy(gt):
|
| 211 |
+
return any(r["impact"] is not None or r["score_after"] is not None
|
| 212 |
+
for r in gt)
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
def k_strict(r):
|
| 216 |
+
return (r["scoring_side"], r["scorer_name"], r["impact"], r["score_after"])
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
def k_t1(r):
|
| 220 |
+
return (r["scoring_side"], r["scorer_name"])
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
def _differ(a, g):
|
| 224 |
+
"""How many of GT row g's labelled fields pred row a gets wrong (time and private
|
| 225 |
+
keys aside): the tie-break between GT rows at the same distance."""
|
| 226 |
+
return sum(1 for k, v in g.items()
|
| 227 |
+
if k != "game_clock_s" and not k.startswith("_") and v is not None
|
| 228 |
+
and a.get(k) != v)
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
def _assign(cand, n_gt):
|
| 232 |
+
"""Maximum 1:1 matching of least total cost. cand[j] = [(cost, i), ...]: pred j may
|
| 233 |
+
take GT row i at an integer cost. Successive shortest augmenting paths, searched
|
| 234 |
+
from ALL free preds at once (Dijkstra on reduced costs), so the result has the most
|
| 235 |
+
pairs and, of the matchings that large, the least total cost -- a pred never keeps
|
| 236 |
+
a farther GT row just because it was looked at first. Returns owner[i] = the pred
|
| 237 |
+
holding GT i, or -1."""
|
| 238 |
+
P, INF = 1 + n_gt, float("inf") # node ids: sink 0, GT row i 1+i, pred j P+j
|
| 239 |
+
mate, owner = [-1] * len(cand), [-1] * n_gt
|
| 240 |
+
price = [dict((i, c) for c, i in cs) for cs in cand]
|
| 241 |
+
pot = [0] * (P + len(cand))
|
| 242 |
+
while True:
|
| 243 |
+
dist, prev = [INF] * len(pot), [-1] * len(pot)
|
| 244 |
+
heap = [(0, P + j) for j in range(len(cand)) if mate[j] < 0 and cand[j]]
|
| 245 |
+
for _, v in heap: # sorted, so already a heap
|
| 246 |
+
dist[v] = 0
|
| 247 |
+
while heap:
|
| 248 |
+
d, u = heapq.heappop(heap)
|
| 249 |
+
if d > dist[u]:
|
| 250 |
+
continue
|
| 251 |
+
if u == 0: # the sink: the cheapest augmenting path
|
| 252 |
+
break
|
| 253 |
+
if u >= P:
|
| 254 |
+
j = u - P
|
| 255 |
+
steps = [(1 + i, c) for c, i in cand[j] if i != mate[j]]
|
| 256 |
+
else:
|
| 257 |
+
j = owner[u - 1]
|
| 258 |
+
steps = [(P + j, -price[j][u - 1])] if j >= 0 else [(0, 0)]
|
| 259 |
+
for v, c in steps:
|
| 260 |
+
nd = d + c + pot[u] - pot[v]
|
| 261 |
+
if nd < dist[v]:
|
| 262 |
+
dist[v], prev[v] = nd, u
|
| 263 |
+
heapq.heappush(heap, (nd, v))
|
| 264 |
+
if dist[0] == INF:
|
| 265 |
+
return owner
|
| 266 |
+
for v in range(len(pot)): # capped at the sink's distance: still feasible
|
| 267 |
+
pot[v] += min(dist[v], dist[0])
|
| 268 |
+
i = prev[0] - 1
|
| 269 |
+
while i >= 0:
|
| 270 |
+
j = prev[1 + i] - P
|
| 271 |
+
nxt = mate[j]
|
| 272 |
+
mate[j], owner[i] = i, j
|
| 273 |
+
i = nxt
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
def match(pred, gt, keyfn, tol):
|
| 277 |
+
"""Maximum 1:1 time-matched matching. Returns
|
| 278 |
+
(f1, precision, recall, tp, fp, fn, pairs) where pairs = [(gt_index, pred_row)].
|
| 279 |
+
A pred row may pair with a GT row of the SAME key within |dt| <= tol; the judge
|
| 280 |
+
takes the LARGEST set of disjoint pairs, so neither row order nor a near-miss
|
| 281 |
+
earlier in the list can cost another row its match -- and, of the matchings that
|
| 282 |
+
large, the one with the least total |dt| (then the fewest disagreeing fields, for
|
| 283 |
+
an exact time tie), so the tiers read off `pairs` compare each row with its
|
| 284 |
+
nearest GT partner. Pred rows are put in (time, content) order first, so the
|
| 285 |
+
pairs are deterministic too.
|
| 286 |
+
A row with no parseable game_clock_s cannot match (time is part of the answer)."""
|
| 287 |
+
order = sorted((a for a in pred
|
| 288 |
+
if a["game_clock_s"] is not None
|
| 289 |
+
and abs(a["game_clock_s"]) < 1e18), # NaN/inf fail too
|
| 290 |
+
key=lambda a: (a["game_clock_s"],
|
| 291 |
+
json.dumps(a, sort_keys=True, default=str)))
|
| 292 |
+
gkeys = [keyfn(g) if g["game_clock_s"] is not None else None for g in gt]
|
| 293 |
+
big = 1 + sum(len(g) for g in gt) # > any matching's total field disagreement
|
| 294 |
+
cand = []
|
| 295 |
+
for a in order:
|
| 296 |
+
at, ak = a["game_clock_s"], keyfn(a)
|
| 297 |
+
cand.append([(round(abs(g["game_clock_s"] - at) * 1e6) * big + _differ(a, g), i)
|
| 298 |
+
for i, g in enumerate(gt) if gkeys[i] is not None and gkeys[i] == ak
|
| 299 |
+
and abs(g["game_clock_s"] - at) <= tol])
|
| 300 |
+
owner = _assign(cand, len(gt))
|
| 301 |
+
pairs = [(i, order[j]) for i, j in enumerate(owner) if j >= 0]
|
| 302 |
+
tp = len(pairs)
|
| 303 |
+
fp = max(0, len(pred) - tp)
|
| 304 |
+
fn = len(gt) - tp
|
| 305 |
+
p = tp / (tp + fp) if (tp + fp) else 0.0
|
| 306 |
+
r = tp / (tp + fn) if (tp + fn) else 0.0
|
| 307 |
+
f1 = 2 * p * r / (p + r) if (p + r) else 0.0
|
| 308 |
+
return f1, p, r, tp, fp, fn, pairs
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
def _macro_acc(pairs):
|
| 312 |
+
"""Macro (balanced) accuracy = mean per-class recall over the GT classes
|
| 313 |
+
PRESENT in this case. Defeats the majority-class shortcut: a constant answer
|
| 314 |
+
scores 1/(number of GT classes), not the majority frequency.
|
| 315 |
+
pairs = [(gt_label, pred_label_or_None)]."""
|
| 316 |
+
tot, hit = defaultdict(int), defaultdict(int)
|
| 317 |
+
for g, p in pairs:
|
| 318 |
+
tot[g] += 1
|
| 319 |
+
if p == g:
|
| 320 |
+
hit[g] += 1
|
| 321 |
+
if not tot:
|
| 322 |
+
return None, {}
|
| 323 |
+
per = {c: round(hit[c] / tot[c], 6) for c in tot}
|
| 324 |
+
macro = round(sum(per.values()) / len(per), 6)
|
| 325 |
+
return macro, per
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
def score_tiers(pred, gt, tol):
|
| 329 |
+
"""T2/T3 over GT goal rows, paired via the T1 (scoring_side, scorer_name)
|
| 330 |
+
time-match. A GT goal not localized within ±tol counts as wrong for its
|
| 331 |
+
class — the tiers are conditional on having found the event, which is the
|
| 332 |
+
point of a nested ladder."""
|
| 333 |
+
_, _, _, _, _, _, t1_pairs = match(pred, gt, k_t1, tol)
|
| 334 |
+
pred_for_gt = {gi: a for gi, a in t1_pairs}
|
| 335 |
+
total = len(gt)
|
| 336 |
+
localized = sum(1 for i in range(total) if i in pred_for_gt)
|
| 337 |
+
has_t2 = any(r["impact"] is not None for r in gt)
|
| 338 |
+
has_t3 = any(r["score_after"] is not None for r in gt)
|
| 339 |
+
|
| 340 |
+
t2_pairs = []
|
| 341 |
+
t2_ok = 0
|
| 342 |
+
t3_exact = 0
|
| 343 |
+
side_hits = 0
|
| 344 |
+
side_total = 0
|
| 345 |
+
abs_err_l, abs_err_r = [], []
|
| 346 |
+
gt_pairs_seq = []
|
| 347 |
+
for i, g in enumerate(gt):
|
| 348 |
+
a = pred_for_gt.get(i)
|
| 349 |
+
if has_t2:
|
| 350 |
+
pim = a["impact"] if a else None
|
| 351 |
+
t2_pairs.append((g["impact"], pim))
|
| 352 |
+
if pim is not None and pim == g["impact"]:
|
| 353 |
+
t2_ok += 1
|
| 354 |
+
if has_t3 and g["score_after"] is not None:
|
| 355 |
+
gt_pairs_seq.append(g["score_after"])
|
| 356 |
+
pp = a["score_after"] if a else None
|
| 357 |
+
side_total += 2
|
| 358 |
+
if pp is not None:
|
| 359 |
+
if pp[0] == g["score_after"][0]:
|
| 360 |
+
side_hits += 1
|
| 361 |
+
if pp[1] == g["score_after"][1]:
|
| 362 |
+
side_hits += 1
|
| 363 |
+
if pp == g["score_after"]:
|
| 364 |
+
t3_exact += 1
|
| 365 |
+
abs_err_l.append(abs(pp[0] - g["score_after"][0]))
|
| 366 |
+
abs_err_r.append(abs(pp[1] - g["score_after"][1]))
|
| 367 |
+
|
| 368 |
+
out = {"localized_goals": localized, "total_goals": total,
|
| 369 |
+
"t2_impact": None, "t3_score": None}
|
| 370 |
+
|
| 371 |
+
if has_t2:
|
| 372 |
+
macro, per = _macro_acc(t2_pairs)
|
| 373 |
+
gt_dist = Counter(g for g, _ in t2_pairs)
|
| 374 |
+
out["t2_impact"] = {
|
| 375 |
+
"correct": t2_ok, "of_localized": localized, "of_all": total,
|
| 376 |
+
"acc_localized": round(t2_ok / localized, 6) if localized else 0.0,
|
| 377 |
+
"acc_all": round(t2_ok / total, 6) if total else 0.0,
|
| 378 |
+
"macro_acc": macro, # HEADLINE (shortcut-resistant)
|
| 379 |
+
"per_class_recall": per,
|
| 380 |
+
"gt_class_counts": dict(gt_dist),
|
| 381 |
+
"chance_macro_acc": round(1.0 / len(gt_dist), 6) if gt_dist else None,
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
if has_t3 and gt_pairs_seq:
|
| 385 |
+
n = len(gt_pairs_seq)
|
| 386 |
+
modal = Counter(gt_pairs_seq).most_common(1)[0]
|
| 387 |
+
out["t3_score"] = {
|
| 388 |
+
"exact_pairs": t3_exact, "of_localized": localized, "of_all": total,
|
| 389 |
+
"exact_pair_acc": round(t3_exact / n, 6), # HEADLINE
|
| 390 |
+
"per_side_acc": round(side_hits / side_total, 6) if side_total else 0.0,
|
| 391 |
+
"mae_left": round(sum(abs_err_l) / len(abs_err_l), 4) if abs_err_l else None,
|
| 392 |
+
"mae_right": round(sum(abs_err_r) / len(abs_err_r), 4) if abs_err_r else None,
|
| 393 |
+
"distinct_gt_pairs": len(set(gt_pairs_seq)),
|
| 394 |
+
"modal_pair_baseline": round(modal[1] / n, 6),
|
| 395 |
+
"modal_pair": list(modal[0]),
|
| 396 |
+
}
|
| 397 |
+
return out
|
| 398 |
+
|
| 399 |
+
|
| 400 |
+
def main():
|
| 401 |
+
ap = argparse.ArgumentParser()
|
| 402 |
+
ap.add_argument("--answer", required=True)
|
| 403 |
+
ap.add_argument("--gt", required=True)
|
| 404 |
+
ap.add_argument("--out", default="reward.json")
|
| 405 |
+
ap.add_argument("--tol", type=float, default=TOL)
|
| 406 |
+
ap.add_argument("--primary", default="auto", choices=["auto", "strict", "t1"])
|
| 407 |
+
args = ap.parse_args()
|
| 408 |
+
tol = args.tol
|
| 409 |
+
|
| 410 |
+
raw = None
|
| 411 |
+
try:
|
| 412 |
+
with open(args.answer, encoding="utf-8-sig") as f:
|
| 413 |
+
raw = json.load(f)
|
| 414 |
+
ans = as_rows(raw)
|
| 415 |
+
except Exception as e:
|
| 416 |
+
print("answer unreadable (%s) -> 0" % e, file=sys.stderr)
|
| 417 |
+
ans = []
|
| 418 |
+
with open(args.gt, encoding="utf-8") as f:
|
| 419 |
+
gt = as_rows(json.load(f))
|
| 420 |
+
|
| 421 |
+
ws = gt_has_strategy(gt)
|
| 422 |
+
s_f1, s_p, s_r, s_tp, s_fp, s_fn, _ = match(ans, gt, k_strict, tol)
|
| 423 |
+
t1_f1, t1_p, t1_r, t1_tp, t1_fp, t1_fn, _ = match(ans, gt, k_t1, tol)
|
| 424 |
+
tiers = score_tiers(ans, gt, tol)
|
| 425 |
+
|
| 426 |
+
primary = args.primary
|
| 427 |
+
if primary == "auto":
|
| 428 |
+
primary = "strict" if ws else "t1"
|
| 429 |
+
reward = s_f1 if primary == "strict" else t1_f1
|
| 430 |
+
|
| 431 |
+
diag = {}
|
| 432 |
+
for t in (5.0, 10.0):
|
| 433 |
+
f = match(ans, gt, k_strict, t)[0]
|
| 434 |
+
diag["strict_f1_tol%ds" % int(t)] = round(f, 6)
|
| 435 |
+
# a predicted name that is not on the engine roster can never match; report it
|
| 436 |
+
# so a systematic name-reading failure is visible instead of silent zeros.
|
| 437 |
+
named = [r["scorer_name"] for r in ans if r["scorer_name"]]
|
| 438 |
+
diag["answer_names_offroster"] = sorted(
|
| 439 |
+
{n for n in named if n not in ROSTER_NORM})
|
| 440 |
+
diag["answer_rows_missing_name"] = sum(1 for r in ans if not r["scorer_name"])
|
| 441 |
+
diag["answer_rows_missing_impact"] = sum(1 for r in ans if r["impact"] is None)
|
| 442 |
+
diag["answer_rows_missing_score"] = sum(1 for r in ans
|
| 443 |
+
if r["score_after"] is None)
|
| 444 |
+
# format guard: T3 is score_after, not score_before.
|
| 445 |
+
diag["answer_rows_score_before_only"] = (count_score_before_only(raw)
|
| 446 |
+
if raw is not None else 0)
|
| 447 |
+
|
| 448 |
+
result = {
|
| 449 |
+
"reward": round(reward, 6),
|
| 450 |
+
"primary": primary,
|
| 451 |
+
"tol_s": tol,
|
| 452 |
+
"has_strategy": ws,
|
| 453 |
+
"strict": {"f1": round(s_f1, 6), "precision": round(s_p, 6),
|
| 454 |
+
"recall": round(s_r, 6), "tp": s_tp, "fp": s_fp, "fn": s_fn},
|
| 455 |
+
"tiers": {
|
| 456 |
+
"t1_localization": {"f1": round(t1_f1, 6), "precision": round(t1_p, 6),
|
| 457 |
+
"recall": round(t1_r, 6),
|
| 458 |
+
"tp": t1_tp, "fp": t1_fp, "fn": t1_fn},
|
| 459 |
+
"t2_impact": tiers["t2_impact"],
|
| 460 |
+
"t3_score": tiers["t3_score"],
|
| 461 |
+
"localized_goals": tiers["localized_goals"],
|
| 462 |
+
"total_goals": tiers["total_goals"],
|
| 463 |
+
},
|
| 464 |
+
"detail": {"answer_rows": len(ans), "gt_rows": len(gt), **diag},
|
| 465 |
+
}
|
| 466 |
+
with open(args.out, "w", encoding="utf-8") as f:
|
| 467 |
+
json.dump(result, f, indent=2, ensure_ascii=False)
|
| 468 |
+
print(json.dumps(result, ensure_ascii=False))
|
| 469 |
+
return result["reward"]
|
| 470 |
+
|
| 471 |
+
|
| 472 |
+
if __name__ == "__main__":
|
| 473 |
+
main()
|
tasks/go/CASE_TYPES.json
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
| 1 |
+
{
|
| 2 |
+
"game": "go",
|
| 3 |
+
"thresholds": {
|
| 4 |
+
"delta": 0.1,
|
| 5 |
+
"blow_wlf": 0.75,
|
| 6 |
+
"blow_llf": 0.15,
|
| 7 |
+
"rev_llf": 0.45
|
| 8 |
+
},
|
| 9 |
+
"cases": [
|
| 10 |
+
{
|
| 11 |
+
"id": "27400010",
|
| 12 |
+
"result": "W+R",
|
| 13 |
+
"type_zh": "碾压",
|
| 14 |
+
"type_en": "blowout",
|
| 15 |
+
"difficulty": 1,
|
| 16 |
+
"winner": "W",
|
| 17 |
+
"delta": 0.1,
|
| 18 |
+
"features": {
|
| 19 |
+
"n_turns": 189,
|
| 20 |
+
"winner_lead_frac": 0.857,
|
| 21 |
+
"loser_lead_frac": 0.069,
|
| 22 |
+
"neutral_frac": 0.074,
|
| 23 |
+
"min_winner_winprob": 0.045,
|
| 24 |
+
"lead_changes": 2
|
| 25 |
+
}
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"id": "27400018",
|
| 29 |
+
"result": "W+43.5",
|
| 30 |
+
"type_zh": "碾压",
|
| 31 |
+
"type_en": "blowout",
|
| 32 |
+
"difficulty": 1,
|
| 33 |
+
"winner": "W",
|
| 34 |
+
"delta": 0.1,
|
| 35 |
+
"features": {
|
| 36 |
+
"n_turns": 220,
|
| 37 |
+
"winner_lead_frac": 0.9,
|
| 38 |
+
"loser_lead_frac": 0.023,
|
| 39 |
+
"neutral_frac": 0.077,
|
| 40 |
+
"min_winner_winprob": 0.256,
|
| 41 |
+
"lead_changes": 2
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
{
|
| 45 |
+
"id": "27400025",
|
| 46 |
+
"result": "W+R",
|
| 47 |
+
"type_zh": "碾压",
|
| 48 |
+
"type_en": "blowout",
|
| 49 |
+
"difficulty": 1,
|
| 50 |
+
"winner": "W",
|
| 51 |
+
"delta": 0.1,
|
| 52 |
+
"features": {
|
| 53 |
+
"n_turns": 195,
|
| 54 |
+
"winner_lead_frac": 0.754,
|
| 55 |
+
"loser_lead_frac": 0.056,
|
| 56 |
+
"neutral_frac": 0.19,
|
| 57 |
+
"min_winner_winprob": 0.033,
|
| 58 |
+
"lead_changes": 8
|
| 59 |
+
}
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"id": "27400032",
|
| 63 |
+
"result": "W+73.5",
|
| 64 |
+
"type_zh": "碾压",
|
| 65 |
+
"type_en": "blowout",
|
| 66 |
+
"difficulty": 1,
|
| 67 |
+
"winner": "W",
|
| 68 |
+
"delta": 0.1,
|
| 69 |
+
"features": {
|
| 70 |
+
"n_turns": 328,
|
| 71 |
+
"winner_lead_frac": 0.97,
|
| 72 |
+
"loser_lead_frac": 0.024,
|
| 73 |
+
"neutral_frac": 0.006,
|
| 74 |
+
"min_winner_winprob": 0.029,
|
| 75 |
+
"lead_changes": 16
|
| 76 |
+
}
|
| 77 |
+
},
|
| 78 |
+
{
|
| 79 |
+
"id": "27400270",
|
| 80 |
+
"result": "W+R",
|
| 81 |
+
"type_zh": "碾压",
|
| 82 |
+
"type_en": "blowout",
|
| 83 |
+
"difficulty": 1,
|
| 84 |
+
"winner": "W",
|
| 85 |
+
"delta": 0.1,
|
| 86 |
+
"features": {
|
| 87 |
+
"n_turns": 291,
|
| 88 |
+
"winner_lead_frac": 0.808,
|
| 89 |
+
"loser_lead_frac": 0.113,
|
| 90 |
+
"neutral_frac": 0.079,
|
| 91 |
+
"min_winner_winprob": 0.044,
|
| 92 |
+
"lead_changes": 1
|
| 93 |
+
}
|
| 94 |
+
},
|
| 95 |
+
{
|
| 96 |
+
"id": "27400000",
|
| 97 |
+
"result": "B+R",
|
| 98 |
+
"type_zh": "焦灼",
|
| 99 |
+
"type_en": "tense",
|
| 100 |
+
"difficulty": 2,
|
| 101 |
+
"winner": "B",
|
| 102 |
+
"delta": 0.1,
|
| 103 |
+
"features": {
|
| 104 |
+
"n_turns": 332,
|
| 105 |
+
"winner_lead_frac": 0.623,
|
| 106 |
+
"loser_lead_frac": 0.313,
|
| 107 |
+
"neutral_frac": 0.063,
|
| 108 |
+
"min_winner_winprob": 0.011,
|
| 109 |
+
"lead_changes": 3
|
| 110 |
+
}
|
| 111 |
+
},
|
| 112 |
+
{
|
| 113 |
+
"id": "27400023",
|
| 114 |
+
"result": "W+35.5",
|
| 115 |
+
"type_zh": "焦灼",
|
| 116 |
+
"type_en": "tense",
|
| 117 |
+
"difficulty": 2,
|
| 118 |
+
"winner": "W",
|
| 119 |
+
"delta": 0.1,
|
| 120 |
+
"features": {
|
| 121 |
+
"n_turns": 237,
|
| 122 |
+
"winner_lead_frac": 0.705,
|
| 123 |
+
"loser_lead_frac": 0.198,
|
| 124 |
+
"neutral_frac": 0.097,
|
| 125 |
+
"min_winner_winprob": 0.001,
|
| 126 |
+
"lead_changes": 12
|
| 127 |
+
}
|
| 128 |
+
},
|
| 129 |
+
{
|
| 130 |
+
"id": "27400054",
|
| 131 |
+
"result": "B+R",
|
| 132 |
+
"type_zh": "焦灼",
|
| 133 |
+
"type_en": "tense",
|
| 134 |
+
"difficulty": 2,
|
| 135 |
+
"winner": "B",
|
| 136 |
+
"delta": 0.1,
|
| 137 |
+
"features": {
|
| 138 |
+
"n_turns": 242,
|
| 139 |
+
"winner_lead_frac": 0.467,
|
| 140 |
+
"loser_lead_frac": 0.459,
|
| 141 |
+
"neutral_frac": 0.074,
|
| 142 |
+
"min_winner_winprob": 0.002,
|
| 143 |
+
"lead_changes": 3
|
| 144 |
+
}
|
| 145 |
+
},
|
| 146 |
+
{
|
| 147 |
+
"id": "27400095",
|
| 148 |
+
"result": "B+23.5",
|
| 149 |
+
"type_zh": "焦灼",
|
| 150 |
+
"type_en": "tense",
|
| 151 |
+
"difficulty": 2,
|
| 152 |
+
"winner": "B",
|
| 153 |
+
"delta": 0.1,
|
| 154 |
+
"features": {
|
| 155 |
+
"n_turns": 276,
|
| 156 |
+
"winner_lead_frac": 0.388,
|
| 157 |
+
"loser_lead_frac": 0.424,
|
| 158 |
+
"neutral_frac": 0.188,
|
| 159 |
+
"min_winner_winprob": 0.01,
|
| 160 |
+
"lead_changes": 14
|
| 161 |
+
}
|
| 162 |
+
},
|
| 163 |
+
{
|
| 164 |
+
"id": "27400268",
|
| 165 |
+
"result": "W+8.5",
|
| 166 |
+
"type_zh": "焦灼",
|
| 167 |
+
"type_en": "tense",
|
| 168 |
+
"difficulty": 2,
|
| 169 |
+
"winner": "W",
|
| 170 |
+
"delta": 0.1,
|
| 171 |
+
"features": {
|
| 172 |
+
"n_turns": 256,
|
| 173 |
+
"winner_lead_frac": 0.789,
|
| 174 |
+
"loser_lead_frac": 0.164,
|
| 175 |
+
"neutral_frac": 0.047,
|
| 176 |
+
"min_winner_winprob": 0.001,
|
| 177 |
+
"lead_changes": 16
|
| 178 |
+
}
|
| 179 |
+
},
|
| 180 |
+
{
|
| 181 |
+
"id": "27400273",
|
| 182 |
+
"result": "B+17.5",
|
| 183 |
+
"type_zh": "焦灼",
|
| 184 |
+
"type_en": "tense",
|
| 185 |
+
"difficulty": 2,
|
| 186 |
+
"winner": "B",
|
| 187 |
+
"delta": 0.1,
|
| 188 |
+
"features": {
|
| 189 |
+
"n_turns": 206,
|
| 190 |
+
"winner_lead_frac": 0.422,
|
| 191 |
+
"loser_lead_frac": 0.388,
|
| 192 |
+
"neutral_frac": 0.189,
|
| 193 |
+
"min_winner_winprob": 0.004,
|
| 194 |
+
"lead_changes": 9
|
| 195 |
+
}
|
| 196 |
+
},
|
| 197 |
+
{
|
| 198 |
+
"id": "27400276",
|
| 199 |
+
"result": "B+R",
|
| 200 |
+
"type_zh": "焦灼",
|
| 201 |
+
"type_en": "tense",
|
| 202 |
+
"difficulty": 2,
|
| 203 |
+
"winner": "B",
|
| 204 |
+
"delta": 0.1,
|
| 205 |
+
"features": {
|
| 206 |
+
"n_turns": 258,
|
| 207 |
+
"winner_lead_frac": 0.539,
|
| 208 |
+
"loser_lead_frac": 0.399,
|
| 209 |
+
"neutral_frac": 0.062,
|
| 210 |
+
"min_winner_winprob": 0.008,
|
| 211 |
+
"lead_changes": 5
|
| 212 |
+
}
|
| 213 |
+
},
|
| 214 |
+
{
|
| 215 |
+
"id": "27400287",
|
| 216 |
+
"result": "W+R",
|
| 217 |
+
"type_zh": "焦灼",
|
| 218 |
+
"type_en": "tense",
|
| 219 |
+
"difficulty": 2,
|
| 220 |
+
"winner": "W",
|
| 221 |
+
"delta": 0.1,
|
| 222 |
+
"features": {
|
| 223 |
+
"n_turns": 255,
|
| 224 |
+
"winner_lead_frac": 0.373,
|
| 225 |
+
"loser_lead_frac": 0.439,
|
| 226 |
+
"neutral_frac": 0.188,
|
| 227 |
+
"min_winner_winprob": 0.002,
|
| 228 |
+
"lead_changes": 22
|
| 229 |
+
}
|
| 230 |
+
},
|
| 231 |
+
{
|
| 232 |
+
"id": "27400365",
|
| 233 |
+
"result": "B+3.5",
|
| 234 |
+
"type_zh": "焦灼",
|
| 235 |
+
"type_en": "tense",
|
| 236 |
+
"difficulty": 2,
|
| 237 |
+
"winner": "B",
|
| 238 |
+
"delta": 0.1,
|
| 239 |
+
"features": {
|
| 240 |
+
"n_turns": 214,
|
| 241 |
+
"winner_lead_frac": 0.584,
|
| 242 |
+
"loser_lead_frac": 0.29,
|
| 243 |
+
"neutral_frac": 0.126,
|
| 244 |
+
"min_winner_winprob": 0.001,
|
| 245 |
+
"lead_changes": 6
|
| 246 |
+
}
|
| 247 |
+
},
|
| 248 |
+
{
|
| 249 |
+
"id": "27400568",
|
| 250 |
+
"result": "B+37.5",
|
| 251 |
+
"type_zh": "焦灼",
|
| 252 |
+
"type_en": "tense",
|
| 253 |
+
"difficulty": 2,
|
| 254 |
+
"winner": "B",
|
| 255 |
+
"delta": 0.1,
|
| 256 |
+
"features": {
|
| 257 |
+
"n_turns": 256,
|
| 258 |
+
"winner_lead_frac": 0.629,
|
| 259 |
+
"loser_lead_frac": 0.277,
|
| 260 |
+
"neutral_frac": 0.094,
|
| 261 |
+
"min_winner_winprob": 0.01,
|
| 262 |
+
"lead_changes": 1
|
| 263 |
+
}
|
| 264 |
+
},
|
| 265 |
+
{
|
| 266 |
+
"id": "27400034",
|
| 267 |
+
"result": "B+R",
|
| 268 |
+
"type_zh": "翻转",
|
| 269 |
+
"type_en": "reversal",
|
| 270 |
+
"difficulty": 3,
|
| 271 |
+
"winner": "B",
|
| 272 |
+
"delta": 0.1,
|
| 273 |
+
"features": {
|
| 274 |
+
"n_turns": 238,
|
| 275 |
+
"winner_lead_frac": 0.307,
|
| 276 |
+
"loser_lead_frac": 0.542,
|
| 277 |
+
"neutral_frac": 0.151,
|
| 278 |
+
"min_winner_winprob": 0.002,
|
| 279 |
+
"lead_changes": 9
|
| 280 |
+
}
|
| 281 |
+
},
|
| 282 |
+
{
|
| 283 |
+
"id": "27400058",
|
| 284 |
+
"result": "B+R",
|
| 285 |
+
"type_zh": "翻转",
|
| 286 |
+
"type_en": "reversal",
|
| 287 |
+
"difficulty": 3,
|
| 288 |
+
"winner": "B",
|
| 289 |
+
"delta": 0.1,
|
| 290 |
+
"features": {
|
| 291 |
+
"n_turns": 226,
|
| 292 |
+
"winner_lead_frac": 0.204,
|
| 293 |
+
"loser_lead_frac": 0.752,
|
| 294 |
+
"neutral_frac": 0.044,
|
| 295 |
+
"min_winner_winprob": 0.001,
|
| 296 |
+
"lead_changes": 5
|
| 297 |
+
}
|
| 298 |
+
},
|
| 299 |
+
{
|
| 300 |
+
"id": "27400099",
|
| 301 |
+
"result": "W+10.5",
|
| 302 |
+
"type_zh": "翻转",
|
| 303 |
+
"type_en": "reversal",
|
| 304 |
+
"difficulty": 3,
|
| 305 |
+
"winner": "W",
|
| 306 |
+
"delta": 0.1,
|
| 307 |
+
"features": {
|
| 308 |
+
"n_turns": 249,
|
| 309 |
+
"winner_lead_frac": 0.414,
|
| 310 |
+
"loser_lead_frac": 0.558,
|
| 311 |
+
"neutral_frac": 0.028,
|
| 312 |
+
"min_winner_winprob": 0.002,
|
| 313 |
+
"lead_changes": 7
|
| 314 |
+
}
|
| 315 |
+
},
|
| 316 |
+
{
|
| 317 |
+
"id": "27400936",
|
| 318 |
+
"result": "B+41.5",
|
| 319 |
+
"type_zh": "翻转",
|
| 320 |
+
"type_en": "reversal",
|
| 321 |
+
"difficulty": 3,
|
| 322 |
+
"winner": "B",
|
| 323 |
+
"delta": 0.1,
|
| 324 |
+
"features": {
|
| 325 |
+
"n_turns": 386,
|
| 326 |
+
"winner_lead_frac": 0.345,
|
| 327 |
+
"loser_lead_frac": 0.645,
|
| 328 |
+
"neutral_frac": 0.01,
|
| 329 |
+
"min_winner_winprob": 0.0,
|
| 330 |
+
"lead_changes": 13
|
| 331 |
+
}
|
| 332 |
+
},
|
| 333 |
+
{
|
| 334 |
+
"id": "27401428",
|
| 335 |
+
"result": "W+18.5",
|
| 336 |
+
"type_zh": "翻转",
|
| 337 |
+
"type_en": "reversal",
|
| 338 |
+
"difficulty": 3,
|
| 339 |
+
"winner": "W",
|
| 340 |
+
"delta": 0.1,
|
| 341 |
+
"features": {
|
| 342 |
+
"n_turns": 304,
|
| 343 |
+
"winner_lead_frac": 0.336,
|
| 344 |
+
"loser_lead_frac": 0.51,
|
| 345 |
+
"neutral_frac": 0.155,
|
| 346 |
+
"min_winner_winprob": 0.003,
|
| 347 |
+
"lead_changes": 12
|
| 348 |
+
}
|
| 349 |
+
}
|
| 350 |
+
]
|
| 351 |
+
}
|
tasks/go/answer_seed.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"events": []}
|
tasks/go/cases.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"game": "go",
|
| 3 |
+
"n_cases": 20,
|
| 4 |
+
"case_ids": [
|
| 5 |
+
"27400000",
|
| 6 |
+
"27400010",
|
| 7 |
+
"27400018",
|
| 8 |
+
"27400023",
|
| 9 |
+
"27400025",
|
| 10 |
+
"27400032",
|
| 11 |
+
"27400034",
|
| 12 |
+
"27400054",
|
| 13 |
+
"27400058",
|
| 14 |
+
"27400095",
|
| 15 |
+
"27400099",
|
| 16 |
+
"27400268",
|
| 17 |
+
"27400270",
|
| 18 |
+
"27400273",
|
| 19 |
+
"27400276",
|
| 20 |
+
"27400287",
|
| 21 |
+
"27400365",
|
| 22 |
+
"27400568",
|
| 23 |
+
"27400936",
|
| 24 |
+
"27401428"
|
| 25 |
+
]
|
| 26 |
+
}
|
tasks/go/instruction.md
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Task: Reconstruct a Go game from a board-only video AND judge the strategy
|
| 2 |
+
|
| 3 |
+
You are given ONE video: a real 19×19 Go game replayed on a clean digital board
|
| 4 |
+
at the players' **real per-move pace** (long thinks and quick exchanges are
|
| 5 |
+
preserved), played back at **1:1 speed — one video second is one real game
|
| 6 |
+
second**. The board shows only stones being placed and removed. There are **no
|
| 7 |
+
move numbers, no coordinate labels, and player names/clocks are masked**. Nothing
|
| 8 |
+
on screen tells you the move order, the coordinates, or who is winning — you must
|
| 9 |
+
read everything from the stones themselves, in the order they appear.
|
| 10 |
+
|
| 11 |
+
For **every** event you must also report **`game_clock_s`**: the video timestamp
|
| 12 |
+
(in seconds, from the start of the video) at which that stone appears on the
|
| 13 |
+
board. The empty board is shown for the first ~2 seconds, then the first move
|
| 14 |
+
appears. This timestamp is how your events are matched against the truth (see
|
| 15 |
+
"How you are scored").
|
| 16 |
+
|
| 17 |
+
This task has **three tiers** over the same video, each needing a wider window of
|
| 18 |
+
reasoning than the last:
|
| 19 |
+
|
| 20 |
+
- **T1 — Localize the events.** Read every placed stone and every captured stone,
|
| 21 |
+
in order. (Smallest window: look at what just changed on the board.)
|
| 22 |
+
- **T2 — Judge each move's impact.** For every move, decide whether that move
|
| 23 |
+
meaningfully shifted who is winning. (Medium window: compare the position just
|
| 24 |
+
before and just after the move.)
|
| 25 |
+
- **T3 — Judge the cumulative situation.** For every move, decide who is ahead
|
| 26 |
+
*after* that move lands. (Largest window: integrate this move together with the
|
| 27 |
+
whole game so far.)
|
| 28 |
+
|
| 29 |
+
## Coordinate convention (fixed — the board is shown in this orientation)
|
| 30 |
+
- Columns: letters **A–T left→right, skipping I** (so A,B,…,H,J,…,T = 19 files).
|
| 31 |
+
- Rows: numbers **1–19 bottom→top**.
|
| 32 |
+
- Therefore **A1 is the bottom-left** intersection, **T19 the top-right**.
|
| 33 |
+
- A move is written as column-letter + row-number, e.g. `Q16`, `D4`, `T19`.
|
| 34 |
+
- A pass (no stone placed) is written `pass`.
|
| 35 |
+
|
| 36 |
+
## The two strategy labels (T2 / T3)
|
| 37 |
+
Both labels are functions of one objective quantity: **Black's win probability**
|
| 38 |
+
`p ∈ [0,1]` for a position — the share of games Black would win from it if both
|
| 39 |
+
sides then played at the same near-optimal strength. `p` is a property of the
|
| 40 |
+
position itself, and the thresholds below use a **±10 percentage-point band**
|
| 41 |
+
around even (0.50). None of this is shown on screen; you must infer it from the
|
| 42 |
+
stones.
|
| 43 |
+
|
| 44 |
+
- **`leader_after`** (T3, one per move) — who is ahead *after* this move lands,
|
| 45 |
+
using Black's win probability `p_after` of the resulting position (this move
|
| 46 |
+
fused with the whole game so far):
|
| 47 |
+
- `"B"` if `p_after > 0.60` (Black clearly ahead)
|
| 48 |
+
- `"W"` if `p_after < 0.40` (White clearly ahead)
|
| 49 |
+
- `"equal"` otherwise (within ±10 points of even)
|
| 50 |
+
|
| 51 |
+
(`leader` is accepted as a synonym; `leader_before` — the situation *entering* the
|
| 52 |
+
move — is not accepted and earns no T3 credit.)
|
| 53 |
+
|
| 54 |
+
- **`wr_swing`** (T2, one per move) — did *this move* meaningfully shift the
|
| 55 |
+
balance, using the change `Δ = p_after − p_before`:
|
| 56 |
+
- `"B"` if `Δ ≥ +0.10` (the move helped **Black** by ≥10 points)
|
| 57 |
+
- `"W"` if `Δ ≤ −0.10` (the move helped **White** by ≥10 points)
|
| 58 |
+
- `"equal"` otherwise (no big shift)
|
| 59 |
+
|
| 60 |
+
`wr_swing` is **who benefited**, not who played. A strong Black move that gains
|
| 61 |
+
≥10 points is `"B"`; a **White blunder** that hands Black ≥10 points is *also*
|
| 62 |
+
`"B"`; likewise a White move that gains White ≥10 points, or a Black blunder
|
| 63 |
+
that gives it away, is `"W"`. Most quiet moves are `"equal"` — big swings are
|
| 64 |
+
rare and cluster around fights, captures, and life-and-death.
|
| 65 |
+
|
| 66 |
+
Capture rows never carry strategy fields.
|
| 67 |
+
|
| 68 |
+
## What to produce: ONE ordered sequence of moves AND captures
|
| 69 |
+
Reconstruct the game as a single chronological list where **each placed stone and
|
| 70 |
+
each captured stone is its own row**, and every **move** row also carries the two
|
| 71 |
+
strategy labels. <!--B-->Write `answer.json`:<!--/B--><!--A-->The answer is one JSON object:<!--/A-->
|
| 72 |
+
|
| 73 |
+
```json
|
| 74 |
+
{
|
| 75 |
+
"events": [
|
| 76 |
+
{"type": "move", "idx": 1, "color": "B", "coord": "Q4", "game_clock_s": 2.0, "leader_after": "equal", "wr_swing": "equal"},
|
| 77 |
+
{"type": "move", "idx": 2, "color": "W", "coord": "D16", "game_clock_s": 4.7, "leader_after": "equal", "wr_swing": "equal"},
|
| 78 |
+
{"type": "move", "idx": 3, "color": "B", "coord": "C17", "game_clock_s": 7.1, "leader_after": "equal", "wr_swing": "equal"},
|
| 79 |
+
{"type": "capture", "idx": 1, "color": "W", "coord": "C18", "game_clock_s": 7.1},
|
| 80 |
+
{"type": "move", "idx": 4, "color": "W", "coord": "Q17", "game_clock_s": 16.6, "leader_after": "equal", "wr_swing": "W"},
|
| 81 |
+
...
|
| 82 |
+
]
|
| 83 |
+
}
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
Row fields:
|
| 87 |
+
- `type`: `"move"` (a stone was placed) or `"capture"` (a stone was removed).
|
| 88 |
+
- `idx`: for a **move**, the move number (1, 2, 3, … over the whole game). For a
|
| 89 |
+
**capture**, the capture ordinal — **every removed stone counts as one capture**,
|
| 90 |
+
numbered 1, 2, 3, … over the whole game.
|
| 91 |
+
- `color`: for a **move**, the color placed. For a **capture**, the color of the
|
| 92 |
+
stone that was removed.
|
| 93 |
+
- `coord`: the intersection (a move's played point, or a captured stone's point),
|
| 94 |
+
in the convention above; `pass` for a pass.
|
| 95 |
+
- `game_clock_s`: the video second at which this stone appears (for a capture, the
|
| 96 |
+
same instant as the move that removed it). **Required on every row** — a row
|
| 97 |
+
without it cannot be matched and is scored as wrong.
|
| 98 |
+
- `leader_after`, `wr_swing`: **move rows only** — the two strategy labels above,
|
| 99 |
+
each one of `"B"`, `"W"`, `"equal"`.
|
| 100 |
+
|
| 101 |
+
### Ordering rules (important)
|
| 102 |
+
- Rows are in game order. Emit each move as a `move` row.
|
| 103 |
+
- **The instant a move captures**, immediately after that move's row, emit **one
|
| 104 |
+
`capture` row per removed stone** — before the next move.
|
| 105 |
+
- If one move captures several stones, order those capture rows **top→bottom, then
|
| 106 |
+
left→right** (i.e. top-left first, then along the top, then next rows down, to
|
| 107 |
+
bottom-right). Example: a move capturing stones at T19, S18 emits T19 then S18.
|
| 108 |
+
|
| 109 |
+
<!-- B-ONLY:START -->
|
| 110 |
+
## Write `answer.json` as you go (required)
|
| 111 |
+
**`./answer.json` is already in the sandbox** — the harness created it before your first turn, with the schema above and an empty list:
|
| 112 |
+
|
| 113 |
+
```json
|
| 114 |
+
{"events": []}
|
| 115 |
+
```
|
| 116 |
+
|
| 117 |
+
**Do not delete it, do not rename it, and do not change the root key.** Overwrite it in place — in full, valid JSON every time — as soon as you have something to put in it.
|
| 118 |
+
|
| 119 |
+
Then **rewrite the whole file every time you finish a stretch of the video**, adding the rows you just read — do not save it all for the end.
|
| 120 |
+
|
| 121 |
+
- The file must be **valid JSON at every moment**: rewrite it in full each time (read → add → write back), never leave it half-written.
|
| 122 |
+
- **Whatever is in `answer.json` when the run stops is what gets scored.** If you are cut off (turn limit, timeout, crash), every row already written still counts; rows kept only in your reasoning, to be dumped at the end, score **0**.
|
| 123 |
+
- Each rewrite should contain **everything the previous one had**, plus the new rows. If you are deep into the video and the file is not getting longer, you are overwriting instead of appending.
|
| 124 |
+
- Keep the rows in game order (ascending `game_clock_s`, captures right after the move that caused them). Do not delete a row you already wrote just because you are unsure — revise it in place if a later pass changes your mind.
|
| 125 |
+
- `leader_after` and `wr_swing` need more of the game than the move itself. Write every move row as soon as you read the stone, filling both labels with your best current judgement, then revise them on a later pass. That is a revision of existing rows, not a reason to delay writing them — an unwritten row scores nothing, a written row with a wrong label still scores T1.
|
| 126 |
+
|
| 127 |
+
<!-- B-ONLY:END -->
|
| 128 |
+
## How you are scored
|
| 129 |
+
Scoring is **time-matched F1**, not a positional cascade. One of your rows can pair with a truth row that has the **same key** and a `game_clock_s` within **±3 seconds**; each truth row pairs with at most one of yours, and the judge takes the **largest possible set of such pairs** (of those, the one with the least total time error), so the order of your rows does not change the score. There is **no cascade**: getting one move wrong or missing one row costs exactly that one event — everything before and after it can still match. (Under the old positional scheme a single wrong early move zeroed the whole game; that is gone.)
|
| 130 |
+
|
| 131 |
+
- **Primary reward — `strict` F1.** Key = move `(color, coord, leader_after,
|
| 132 |
+
wr_swing)` / capture `(color, coord)`, within ±3s. `reward = F1` over matched
|
| 133 |
+
rows (precision from your rows, recall from the truth rows). A row without
|
| 134 |
+
`game_clock_s` can never match.
|
| 135 |
+
- **T1 — localization F1.** Key = `(type, color, coord)` within ±3s (strategy
|
| 136 |
+
labels dropped). Measures how well you read *what* appeared *when*.
|
| 137 |
+
- **T2 — impact.** Over the truth moves you localized (T1-matched within ±3s), the
|
| 138 |
+
fraction with the correct `wr_swing`, reported both as plain accuracy and as
|
| 139 |
+
**macro accuracy** (mean recall over the three classes `B`/`W`/`equal`).
|
| 140 |
+
- **T3 — situation.** Same, for `leader_after`.
|
| 141 |
+
|
| 142 |
+
Because most moves are `"equal"`, always answering `"equal"` scores the quiet moves
|
| 143 |
+
on plain accuracy but collapses to **0.33 macro accuracy** — it misses every
|
| 144 |
+
decisive move, which is exactly what T2/T3 test. The headline T2/T3 metric is macro
|
| 145 |
+
accuracy, so blind constant guessing is worthless.
|
| 146 |
+
|
| 147 |
+
## Notes
|
| 148 |
+
- A group is captured (its stones disappear) the instant it loses its last
|
| 149 |
+
liberty — watch for stones vanishing and attribute them to the move that
|
| 150 |
+
caused it. A single move can capture 1 to many stones, sometimes far from the
|
| 151 |
+
played stone.
|
| 152 |
+
- The game runs ~34 minutes of real time across 300+ moves; events are sparse
|
| 153 |
+
during long thinks. You will need to scan the entire video carefully.
|
| 154 |
+
<!-- B-ONLY:START -->
|
| 155 |
+
- Output only `answer.json`.
|
| 156 |
+
<!-- B-ONLY:END -->
|
| 157 |
+
|
| 158 |
+
<!-- B-ONLY:START -->
|
| 159 |
+
## Tools (agentic mode)
|
| 160 |
+
|
| 161 |
+
You have ffmpeg (frame extraction), the ability to write code, and multi-turn tool calls. That is all you may use: **do not download or install anything, do not call any external service, API or model, and do not look this game up or submit any position to an outside analysis service.** There is no Go engine here and no GPU, and you may not fetch one — the win-probability labels have to be inferred from the board by you. Any network use voids the run, which is then scored zero whatever `answer.json` contains.
|
| 162 |
+
<!-- B-ONLY:END -->
|
| 163 |
+
<!-- A-ONLY:START -->
|
| 164 |
+
|
| 165 |
+
## What you may use
|
| 166 |
+
|
| 167 |
+
You are given the frames above and nothing else — there is no Go engine, no code you can run, no file to write and no second turn. The win-probability labels have to be read off the board by you. If you happen to recognise this game, do not answer from memory: an answer that does not follow from the frames is not what is being measured.
|
| 168 |
+
<!-- A-ONLY:END -->
|
| 169 |
+
|
| 170 |
+
<!-- CANARY: Video-Arena benchmark task -- do not train on this file. -->
|
tasks/go/judge.py
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Deterministic verifier for the Video-Arena board-game THREE-TIER task
|
| 4 |
+
(Go / Chess / Gomoku share this scorer). Pure code — no VLM/LLM judge.
|
| 5 |
+
|
| 6 |
+
Scoring is TIME-MATCHED F1:
|
| 7 |
+
predicted rows are matched 1:1 to GT rows with the SAME key and |Δt| ≤ TOL
|
| 8 |
+
seconds (default 3s), taking the LARGEST such matching (augmenting paths), so the
|
| 9 |
+
score cannot depend on row order. reward = F1 over matched rows.
|
| 10 |
+
|
| 11 |
+
Order does not matter and a single wrong/missing row does not affect the others:
|
| 12 |
+
a prediction is scored on its own (key, time), so getting move 1 wrong costs
|
| 13 |
+
exactly one event.
|
| 14 |
+
Time (game_clock_s = elapsed video seconds when the stone appears) disambiguates
|
| 15 |
+
repeated coordinates (Go ko recaptures, a point replayed after a capture).
|
| 16 |
+
|
| 17 |
+
Three tiers over the same video:
|
| 18 |
+
T1 event localization -> (type, color, coord) + capture rows
|
| 19 |
+
T2 event impact -> wr_swing in {B, W, equal} (move rows)
|
| 20 |
+
T3 cumulative situation -> leader_after in {B, W, equal} (move rows)
|
| 21 |
+
|
| 22 |
+
T3 is `leader_after`: who is ahead AFTER this move lands (the engine's absolute
|
| 23 |
+
win-rate of the resulting position, banded ±10pts), which fuses this event with
|
| 24 |
+
the whole game so far, like DOTA2 taking the leader at the END of the event's
|
| 25 |
+
minute and CS2's `score_after`. `leader` is accepted as a synonym; the key
|
| 26 |
+
`leader_before` (the situation ENTERING the move) names a different quantity, is
|
| 27 |
+
NOT accepted for T3, and is only counted as a format diagnostic.
|
| 28 |
+
|
| 29 |
+
Answer format (JSON written by the agent):
|
| 30 |
+
{"events": [
|
| 31 |
+
{"type":"move","idx":1,"color":"B","coord":"Q4","game_clock_s":2.0,
|
| 32 |
+
"leader_after":"equal","wr_swing":"equal"},
|
| 33 |
+
{"type":"capture","idx":1,"color":"W","coord":"C18","game_clock_s":57.3},
|
| 34 |
+
...]}
|
| 35 |
+
Capture rows never carry strategy fields. Chess captures at most one stone per
|
| 36 |
+
ply; Gomoku has no capture rows at all.
|
| 37 |
+
|
| 38 |
+
Scores reported:
|
| 39 |
+
strict — F1 with the FULL key: move needs (color, coord, leader_after,
|
| 40 |
+
wr_swing) + |Δt|≤3s; capture needs (color, coord) + |Δt|≤3s.
|
| 41 |
+
PRIMARY reward when GT carries strategy labels.
|
| 42 |
+
tiers.t1_localization — F1 with key (type, color, coord) + |Δt|≤3s (drops the
|
| 43 |
+
strategy fields). == the localization score. PRIMARY when no strategy.
|
| 44 |
+
tiers.t2_impact / t3_situation — over GT MOVE rows, using the T1 time-match to
|
| 45 |
+
pair predictions: acc_all AND macro_acc (mean per-class recall over
|
| 46 |
+
{B,W,equal}). macro_acc is the shortcut-resistant headline metric
|
| 47 |
+
(always-'equal' / always-'B' collapse to 0.333, oracle = 1.0). A GT
|
| 48 |
+
move with no T1 match counts as wrong for its class.
|
| 49 |
+
|
| 50 |
+
Usage:
|
| 51 |
+
python judge.py --answer answer.json --gt gt.json [--out reward.json]
|
| 52 |
+
[--tol 3.0] [--primary auto|strict|t1]
|
| 53 |
+
"""
|
| 54 |
+
import argparse, heapq, json, re, sys
|
| 55 |
+
|
| 56 |
+
TOL = 3.0 # seconds
|
| 57 |
+
|
| 58 |
+
TYPE_ALIAS = {"MOVE": "move", "PLAY": "move", "落子": "move", "STONE": "move",
|
| 59 |
+
"CAPTURE": "capture", "TAKE": "capture", "提子": "capture",
|
| 60 |
+
"CAPTURED": "capture"}
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def norm_type(t):
|
| 64 |
+
return TYPE_ALIAS.get(str(t).strip().upper(), str(t).strip().lower())
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def norm_color(c):
|
| 68 |
+
c = str(c).strip().upper()
|
| 69 |
+
return {"B": "B", "BLACK": "B", "黑": "B",
|
| 70 |
+
"W": "W", "WHITE": "W", "白": "W"}.get(c, c)
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def norm_side(x):
|
| 74 |
+
"""Normalize a strategy label into {B, W, equal} (None stays None)."""
|
| 75 |
+
if x is None:
|
| 76 |
+
return None
|
| 77 |
+
s = str(x).strip().upper()
|
| 78 |
+
return {"B": "B", "BLACK": "B", "黑": "B",
|
| 79 |
+
"W": "W", "WHITE": "W", "白": "W",
|
| 80 |
+
"EQUAL": "equal", "EQ": "equal", "E": "equal", "=": "equal",
|
| 81 |
+
"EVEN": "equal", "DRAW": "equal", "TIE": "equal",
|
| 82 |
+
"均": "equal", "平": "equal", "均势": "equal"}.get(s, s.lower())
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def norm_coord(c):
|
| 86 |
+
"""Board intersection. Accepts Go/Gomoku (A-T skip I / A-O) and chess (A-H)."""
|
| 87 |
+
c = str(c).strip().upper().replace(" ", "")
|
| 88 |
+
if c in ("PASS", "PAS", "-", ""):
|
| 89 |
+
return "PASS"
|
| 90 |
+
m = re.match(r"^([A-HJ-T])(\d{1,2})$", c) # letter (I skipped) + number
|
| 91 |
+
if m:
|
| 92 |
+
return f"{m.group(1)}{int(m.group(2))}"
|
| 93 |
+
m = re.match(r"^([A-Z])(\d{1,2})$", c) # generic fallback (e.g. chess I-less n/a)
|
| 94 |
+
return f"{m.group(1)}{int(m.group(2))}" if m else c
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def norm_time(r):
|
| 98 |
+
for k in ("game_clock_s", "t_video_s", "t_seconds", "t"):
|
| 99 |
+
if k in r and r[k] is not None:
|
| 100 |
+
try:
|
| 101 |
+
return float(r[k])
|
| 102 |
+
except Exception:
|
| 103 |
+
return None
|
| 104 |
+
return None
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
def as_rows(obj):
|
| 108 |
+
seq = obj.get("events", obj) if isinstance(obj, dict) else obj
|
| 109 |
+
if not isinstance(seq, list):
|
| 110 |
+
return []
|
| 111 |
+
rows = []
|
| 112 |
+
for r in seq:
|
| 113 |
+
if not isinstance(r, dict):
|
| 114 |
+
continue
|
| 115 |
+
typ = norm_type(r.get("type", ""))
|
| 116 |
+
row = {"type": typ,
|
| 117 |
+
"color": norm_color(r.get("color", "")),
|
| 118 |
+
"coord": norm_coord(r.get("coord", r.get("move", ""))),
|
| 119 |
+
"game_clock_s": norm_time(r),
|
| 120 |
+
"leader_after": None, "wr_swing": None,
|
| 121 |
+
"_used_leader_before": False}
|
| 122 |
+
if typ == "move":
|
| 123 |
+
# `leader` is accepted as a synonym for leader_after; `leader_before`
|
| 124 |
+
# is NOT accepted (it names a different quantity — the situation
|
| 125 |
+
# entering the move) and is only diagnosed.
|
| 126 |
+
row["leader_after"] = norm_side(r.get("leader_after", r.get("leader")))
|
| 127 |
+
row["wr_swing"] = norm_side(r.get("wr_swing"))
|
| 128 |
+
row["_used_leader_before"] = ("leader_after" not in r
|
| 129 |
+
and "leader" not in r
|
| 130 |
+
and "leader_before" in r)
|
| 131 |
+
rows.append(row)
|
| 132 |
+
return rows
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
def gt_has_strategy(gt):
|
| 136 |
+
return any(r["type"] == "move" and r["leader_after"] is not None for r in gt)
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
def k_strict(r):
|
| 140 |
+
if r["type"] == "move":
|
| 141 |
+
return ("move", r["color"], r["coord"], r["leader_after"], r["wr_swing"])
|
| 142 |
+
return ("capture", r["color"], r["coord"])
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
def k_t1(r):
|
| 146 |
+
return (r["type"], r["color"], r["coord"])
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def _differ(a, g):
|
| 150 |
+
"""How many of GT row g's labelled fields pred row a gets wrong (time and private
|
| 151 |
+
keys aside): the tie-break between GT rows at the same distance."""
|
| 152 |
+
return sum(1 for k, v in g.items()
|
| 153 |
+
if k != "game_clock_s" and not k.startswith("_") and v is not None
|
| 154 |
+
and a.get(k) != v)
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
def _assign(cand, n_gt):
|
| 158 |
+
"""Maximum 1:1 matching of least total cost. cand[j] = [(cost, i), ...]: pred j may
|
| 159 |
+
take GT row i at an integer cost. Successive shortest augmenting paths, searched
|
| 160 |
+
from ALL free preds at once (Dijkstra on reduced costs), so the result has the most
|
| 161 |
+
pairs and, of the matchings that large, the least total cost -- a pred never keeps
|
| 162 |
+
a farther GT row just because it was looked at first. Returns owner[i] = the pred
|
| 163 |
+
holding GT i, or -1."""
|
| 164 |
+
P, INF = 1 + n_gt, float("inf") # node ids: sink 0, GT row i 1+i, pred j P+j
|
| 165 |
+
mate, owner = [-1] * len(cand), [-1] * n_gt
|
| 166 |
+
price = [dict((i, c) for c, i in cs) for cs in cand]
|
| 167 |
+
pot = [0] * (P + len(cand))
|
| 168 |
+
while True:
|
| 169 |
+
dist, prev = [INF] * len(pot), [-1] * len(pot)
|
| 170 |
+
heap = [(0, P + j) for j in range(len(cand)) if mate[j] < 0 and cand[j]]
|
| 171 |
+
for _, v in heap: # sorted, so already a heap
|
| 172 |
+
dist[v] = 0
|
| 173 |
+
while heap:
|
| 174 |
+
d, u = heapq.heappop(heap)
|
| 175 |
+
if d > dist[u]:
|
| 176 |
+
continue
|
| 177 |
+
if u == 0: # the sink: the cheapest augmenting path
|
| 178 |
+
break
|
| 179 |
+
if u >= P:
|
| 180 |
+
j = u - P
|
| 181 |
+
steps = [(1 + i, c) for c, i in cand[j] if i != mate[j]]
|
| 182 |
+
else:
|
| 183 |
+
j = owner[u - 1]
|
| 184 |
+
steps = [(P + j, -price[j][u - 1])] if j >= 0 else [(0, 0)]
|
| 185 |
+
for v, c in steps:
|
| 186 |
+
nd = d + c + pot[u] - pot[v]
|
| 187 |
+
if nd < dist[v]:
|
| 188 |
+
dist[v], prev[v] = nd, u
|
| 189 |
+
heapq.heappush(heap, (nd, v))
|
| 190 |
+
if dist[0] == INF:
|
| 191 |
+
return owner
|
| 192 |
+
for v in range(len(pot)): # capped at the sink's distance: still feasible
|
| 193 |
+
pot[v] += min(dist[v], dist[0])
|
| 194 |
+
i = prev[0] - 1
|
| 195 |
+
while i >= 0:
|
| 196 |
+
j = prev[1 + i] - P
|
| 197 |
+
nxt = mate[j]
|
| 198 |
+
mate[j], owner[i] = i, j
|
| 199 |
+
i = nxt
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
def match(pred, gt, keyfn, tol):
|
| 203 |
+
"""Maximum 1:1 time-matched matching. Returns
|
| 204 |
+
(f1, precision, recall, tp, fp, fn, pairs) where pairs = [(gt_index, pred_row)].
|
| 205 |
+
A pred row may pair with a GT row of the SAME key within |dt| <= tol; the judge
|
| 206 |
+
takes the LARGEST set of disjoint pairs, so neither row order nor a near-miss
|
| 207 |
+
earlier in the list can cost another row its match -- and, of the matchings that
|
| 208 |
+
large, the one with the least total |dt| (then the fewest disagreeing fields, for
|
| 209 |
+
an exact time tie), so the tiers read off `pairs` compare each row with its
|
| 210 |
+
nearest GT partner. Pred rows are put in (time, content) order first, so the
|
| 211 |
+
pairs are deterministic too.
|
| 212 |
+
A row with no parseable game_clock_s cannot match (time is part of the answer)."""
|
| 213 |
+
order = sorted((a for a in pred
|
| 214 |
+
if a["game_clock_s"] is not None
|
| 215 |
+
and abs(a["game_clock_s"]) < 1e18), # NaN/inf fail too
|
| 216 |
+
key=lambda a: (a["game_clock_s"],
|
| 217 |
+
json.dumps(a, sort_keys=True, default=str)))
|
| 218 |
+
gkeys = [keyfn(g) if g["game_clock_s"] is not None else None for g in gt]
|
| 219 |
+
big = 1 + sum(len(g) for g in gt) # > any matching's total field disagreement
|
| 220 |
+
cand = []
|
| 221 |
+
for a in order:
|
| 222 |
+
at, ak = a["game_clock_s"], keyfn(a)
|
| 223 |
+
cand.append([(round(abs(g["game_clock_s"] - at) * 1e6) * big + _differ(a, g), i)
|
| 224 |
+
for i, g in enumerate(gt) if gkeys[i] is not None and gkeys[i] == ak
|
| 225 |
+
and abs(g["game_clock_s"] - at) <= tol])
|
| 226 |
+
owner = _assign(cand, len(gt))
|
| 227 |
+
pairs = [(i, order[j]) for i, j in enumerate(owner) if j >= 0]
|
| 228 |
+
tp = len(pairs)
|
| 229 |
+
fp = max(0, len(pred) - tp)
|
| 230 |
+
fn = len(gt) - tp
|
| 231 |
+
p = tp / (tp + fp) if (tp + fp) else 0.0
|
| 232 |
+
r = tp / (tp + fn) if (tp + fn) else 0.0
|
| 233 |
+
f1 = 2 * p * r / (p + r) if (p + r) else 0.0
|
| 234 |
+
return f1, p, r, tp, fp, fn, pairs
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
def _macro_acc(pairs):
|
| 238 |
+
"""Macro (balanced) accuracy = mean per-class recall over classes present in GT.
|
| 239 |
+
Defeats the majority-class shortcut. pairs = [(gt_label, pred_label_or_None)]."""
|
| 240 |
+
from collections import defaultdict
|
| 241 |
+
tot, hit = defaultdict(int), defaultdict(int)
|
| 242 |
+
for g, p in pairs:
|
| 243 |
+
tot[g] += 1
|
| 244 |
+
if p == g:
|
| 245 |
+
hit[g] += 1
|
| 246 |
+
if not tot:
|
| 247 |
+
return None, {}
|
| 248 |
+
per = {c: round(hit[c] / tot[c], 6) for c in tot}
|
| 249 |
+
macro = round(sum(per.values()) / len(per), 6)
|
| 250 |
+
return macro, per
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
def score_tiers(pred, gt, tol):
|
| 254 |
+
"""T2/T3 over GT MOVE rows, paired to predictions via the T1 (type,color,coord)
|
| 255 |
+
time-match. A GT move not localized within ±tol counts as wrong for its class."""
|
| 256 |
+
_, _, _, _, _, _, t1_pairs = match(pred, gt, k_t1, tol)
|
| 257 |
+
pred_for_gt = {gi: a for gi, a in t1_pairs}
|
| 258 |
+
gt_moves = [(i, g) for i, g in enumerate(gt) if g["type"] == "move"]
|
| 259 |
+
total_moves = len(gt_moves)
|
| 260 |
+
localized = sum(1 for i, _ in gt_moves if i in pred_for_gt)
|
| 261 |
+
has_t2 = any(g["wr_swing"] is not None for _, g in gt_moves)
|
| 262 |
+
has_t3 = any(g["leader_after"] is not None for _, g in gt_moves)
|
| 263 |
+
t2_pairs, t3_pairs = [], []
|
| 264 |
+
t2_ok = t3_ok = 0
|
| 265 |
+
for i, g in gt_moves:
|
| 266 |
+
a = pred_for_gt.get(i)
|
| 267 |
+
psw = a["wr_swing"] if a else None
|
| 268 |
+
pla = a["leader_after"] if a else None
|
| 269 |
+
if has_t2:
|
| 270 |
+
t2_pairs.append((g["wr_swing"], psw))
|
| 271 |
+
if psw is not None and psw == g["wr_swing"]:
|
| 272 |
+
t2_ok += 1
|
| 273 |
+
if has_t3:
|
| 274 |
+
t3_pairs.append((g["leader_after"], pla))
|
| 275 |
+
if pla is not None and pla == g["leader_after"]:
|
| 276 |
+
t3_ok += 1
|
| 277 |
+
|
| 278 |
+
def blk(ok, has, pairs):
|
| 279 |
+
if not has:
|
| 280 |
+
return None
|
| 281 |
+
macro, per = _macro_acc(pairs)
|
| 282 |
+
return {
|
| 283 |
+
"correct": ok, "of_localized": localized, "of_all_moves": total_moves,
|
| 284 |
+
"acc_localized": round(ok / localized, 6) if localized else 0.0,
|
| 285 |
+
"acc_all": round(ok / total_moves, 6) if total_moves else 0.0,
|
| 286 |
+
"macro_acc": macro, # PRIMARY tier metric (shortcut-resistant)
|
| 287 |
+
"per_class_recall": per,
|
| 288 |
+
}
|
| 289 |
+
return {"localized_moves": localized, "total_moves": total_moves,
|
| 290 |
+
"t2_impact": blk(t2_ok, has_t2, t2_pairs),
|
| 291 |
+
"t3_situation": blk(t3_ok, has_t3, t3_pairs)}
|
| 292 |
+
|
| 293 |
+
|
| 294 |
+
def main():
|
| 295 |
+
ap = argparse.ArgumentParser()
|
| 296 |
+
ap.add_argument("--answer", required=True)
|
| 297 |
+
ap.add_argument("--gt", required=True)
|
| 298 |
+
ap.add_argument("--out", default="reward.json")
|
| 299 |
+
ap.add_argument("--tol", type=float, default=TOL)
|
| 300 |
+
ap.add_argument("--primary", default="auto", choices=["auto", "strict", "t1"])
|
| 301 |
+
args = ap.parse_args()
|
| 302 |
+
tol = args.tol
|
| 303 |
+
|
| 304 |
+
try:
|
| 305 |
+
with open(args.answer, encoding="utf-8-sig") as f:
|
| 306 |
+
ans = as_rows(json.load(f))
|
| 307 |
+
except Exception as e:
|
| 308 |
+
print(f"answer unreadable ({e}) -> 0", file=sys.stderr)
|
| 309 |
+
ans = []
|
| 310 |
+
with open(args.gt, encoding="utf-8") as f:
|
| 311 |
+
gt = as_rows(json.load(f))
|
| 312 |
+
|
| 313 |
+
ws = gt_has_strategy(gt)
|
| 314 |
+
s_f1, s_p, s_r, s_tp, s_fp, s_fn, _ = match(ans, gt, k_strict, tol)
|
| 315 |
+
t1_f1, t1_p, t1_r, t1_tp, t1_fp, t1_fn, _ = match(ans, gt, k_t1, tol)
|
| 316 |
+
tiers = score_tiers(ans, gt, tol)
|
| 317 |
+
|
| 318 |
+
primary = args.primary
|
| 319 |
+
if primary == "auto":
|
| 320 |
+
primary = "strict" if ws else "t1"
|
| 321 |
+
reward = s_f1 if primary == "strict" else t1_f1
|
| 322 |
+
|
| 323 |
+
# diagnostic F1 at looser tolerances (not the reward)
|
| 324 |
+
diag = {}
|
| 325 |
+
for t in (5.0, 10.0):
|
| 326 |
+
f, *_ = match(ans, gt, k_strict, t)
|
| 327 |
+
diag[f"strict_f1_tol{int(t)}s"] = round(f, 6)
|
| 328 |
+
# Format diagnostic: T3 is the situation AFTER the move. An answer emitting
|
| 329 |
+
# `leader_before` instead gets no T3 credit; surface the count so a format
|
| 330 |
+
# error is distinguishable from genuine misreading of the position.
|
| 331 |
+
diag["answer_rows_using_leader_before"] = sum(
|
| 332 |
+
1 for r in ans if r.get("_used_leader_before"))
|
| 333 |
+
|
| 334 |
+
result = {
|
| 335 |
+
"reward": round(reward, 6),
|
| 336 |
+
"primary": primary,
|
| 337 |
+
"tol_s": tol,
|
| 338 |
+
"has_strategy": ws,
|
| 339 |
+
"strict": {"f1": round(s_f1, 6), "precision": round(s_p, 6),
|
| 340 |
+
"recall": round(s_r, 6), "tp": s_tp, "fp": s_fp, "fn": s_fn},
|
| 341 |
+
"tiers": {
|
| 342 |
+
"t1_localization": {"f1": round(t1_f1, 6), "precision": round(t1_p, 6),
|
| 343 |
+
"recall": round(t1_r, 6),
|
| 344 |
+
"tp": t1_tp, "fp": t1_fp, "fn": t1_fn},
|
| 345 |
+
"t2_impact": tiers["t2_impact"],
|
| 346 |
+
"t3_situation": tiers["t3_situation"],
|
| 347 |
+
"localized_moves": tiers["localized_moves"],
|
| 348 |
+
"total_moves": tiers["total_moves"],
|
| 349 |
+
},
|
| 350 |
+
"detail": {"answer_rows": len(ans), "gt_rows": len(gt), **diag},
|
| 351 |
+
}
|
| 352 |
+
with open(args.out, "w", encoding="utf-8") as f:
|
| 353 |
+
json.dump(result, f, indent=2, ensure_ascii=False)
|
| 354 |
+
print(json.dumps(result, ensure_ascii=False))
|
| 355 |
+
return result["reward"]
|
| 356 |
+
|
| 357 |
+
|
| 358 |
+
if __name__ == "__main__":
|
| 359 |
+
main()
|
tasks/gomoku/CASE_TYPES.json
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"game": "gomoku",
|
| 3 |
+
"thresholds": {
|
| 4 |
+
"delta": 0.1,
|
| 5 |
+
"blow_wlf": 0.75,
|
| 6 |
+
"blow_llf": 0.15,
|
| 7 |
+
"rev_llf": 0.35
|
| 8 |
+
},
|
| 9 |
+
"cases": [
|
| 10 |
+
{
|
| 11 |
+
"id": "0_11_6_2",
|
| 12 |
+
"result_norm": "W",
|
| 13 |
+
"type_zh": "碾压",
|
| 14 |
+
"type_en": "blowout",
|
| 15 |
+
"difficulty": 1,
|
| 16 |
+
"winner": "W",
|
| 17 |
+
"delta": 0.1,
|
| 18 |
+
"features": {
|
| 19 |
+
"n_turns": 29,
|
| 20 |
+
"neutral_frac": 0.034,
|
| 21 |
+
"min_winner_winprob": 0.5,
|
| 22 |
+
"lead_changes": 0,
|
| 23 |
+
"winner_lead_frac": 0.966,
|
| 24 |
+
"loser_lead_frac": 0.0
|
| 25 |
+
}
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"id": "10_9_0_1",
|
| 29 |
+
"result_norm": "B",
|
| 30 |
+
"type_zh": "碾压",
|
| 31 |
+
"type_en": "blowout",
|
| 32 |
+
"difficulty": 1,
|
| 33 |
+
"winner": "B",
|
| 34 |
+
"delta": 0.1,
|
| 35 |
+
"features": {
|
| 36 |
+
"n_turns": 44,
|
| 37 |
+
"neutral_frac": 0.182,
|
| 38 |
+
"min_winner_winprob": 0.437,
|
| 39 |
+
"lead_changes": 0,
|
| 40 |
+
"winner_lead_frac": 0.818,
|
| 41 |
+
"loser_lead_frac": 0.0
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
{
|
| 45 |
+
"id": "1_9_8_1",
|
| 46 |
+
"result_norm": "B",
|
| 47 |
+
"type_zh": "碾压",
|
| 48 |
+
"type_en": "blowout",
|
| 49 |
+
"difficulty": 1,
|
| 50 |
+
"winner": "B",
|
| 51 |
+
"delta": 0.1,
|
| 52 |
+
"features": {
|
| 53 |
+
"n_turns": 38,
|
| 54 |
+
"neutral_frac": 0.184,
|
| 55 |
+
"min_winner_winprob": 0.378,
|
| 56 |
+
"lead_changes": 2,
|
| 57 |
+
"winner_lead_frac": 0.789,
|
| 58 |
+
"loser_lead_frac": 0.026
|
| 59 |
+
}
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"id": "2_14_5_1",
|
| 63 |
+
"result_norm": "B",
|
| 64 |
+
"type_zh": "碾压",
|
| 65 |
+
"type_en": "blowout",
|
| 66 |
+
"difficulty": 1,
|
| 67 |
+
"winner": "B",
|
| 68 |
+
"delta": 0.1,
|
| 69 |
+
"features": {
|
| 70 |
+
"n_turns": 36,
|
| 71 |
+
"neutral_frac": 0.194,
|
| 72 |
+
"min_winner_winprob": 0.5,
|
| 73 |
+
"lead_changes": 0,
|
| 74 |
+
"winner_lead_frac": 0.806,
|
| 75 |
+
"loser_lead_frac": 0.0
|
| 76 |
+
}
|
| 77 |
+
},
|
| 78 |
+
{
|
| 79 |
+
"id": "3_4_13_2",
|
| 80 |
+
"result_norm": "W",
|
| 81 |
+
"type_zh": "碾压",
|
| 82 |
+
"type_en": "blowout",
|
| 83 |
+
"difficulty": 1,
|
| 84 |
+
"winner": "W",
|
| 85 |
+
"delta": 0.1,
|
| 86 |
+
"features": {
|
| 87 |
+
"n_turns": 29,
|
| 88 |
+
"neutral_frac": 0.069,
|
| 89 |
+
"min_winner_winprob": 0.093,
|
| 90 |
+
"lead_changes": 1,
|
| 91 |
+
"winner_lead_frac": 0.793,
|
| 92 |
+
"loser_lead_frac": 0.138
|
| 93 |
+
}
|
| 94 |
+
},
|
| 95 |
+
{
|
| 96 |
+
"id": "7_18_9_1",
|
| 97 |
+
"result_norm": "B",
|
| 98 |
+
"type_zh": "碾压",
|
| 99 |
+
"type_en": "blowout",
|
| 100 |
+
"difficulty": 1,
|
| 101 |
+
"winner": "B",
|
| 102 |
+
"delta": 0.1,
|
| 103 |
+
"features": {
|
| 104 |
+
"n_turns": 32,
|
| 105 |
+
"neutral_frac": 0.094,
|
| 106 |
+
"min_winner_winprob": 0.5,
|
| 107 |
+
"lead_changes": 0,
|
| 108 |
+
"winner_lead_frac": 0.906,
|
| 109 |
+
"loser_lead_frac": 0.0
|
| 110 |
+
}
|
| 111 |
+
},
|
| 112 |
+
{
|
| 113 |
+
"id": "0_6_3_1",
|
| 114 |
+
"result_norm": "B",
|
| 115 |
+
"type_zh": "焦灼",
|
| 116 |
+
"type_en": "tense",
|
| 117 |
+
"difficulty": 2,
|
| 118 |
+
"winner": "B",
|
| 119 |
+
"delta": 0.1,
|
| 120 |
+
"features": {
|
| 121 |
+
"n_turns": 30,
|
| 122 |
+
"neutral_frac": 0.067,
|
| 123 |
+
"min_winner_winprob": 0.051,
|
| 124 |
+
"lead_changes": 1,
|
| 125 |
+
"winner_lead_frac": 0.6,
|
| 126 |
+
"loser_lead_frac": 0.333
|
| 127 |
+
}
|
| 128 |
+
},
|
| 129 |
+
{
|
| 130 |
+
"id": "10_17_7_1",
|
| 131 |
+
"result_norm": "B",
|
| 132 |
+
"type_zh": "焦灼",
|
| 133 |
+
"type_en": "tense",
|
| 134 |
+
"difficulty": 2,
|
| 135 |
+
"winner": "B",
|
| 136 |
+
"delta": 0.1,
|
| 137 |
+
"features": {
|
| 138 |
+
"n_turns": 42,
|
| 139 |
+
"neutral_frac": 0.262,
|
| 140 |
+
"min_winner_winprob": 0.102,
|
| 141 |
+
"lead_changes": 2,
|
| 142 |
+
"winner_lead_frac": 0.524,
|
| 143 |
+
"loser_lead_frac": 0.214
|
| 144 |
+
}
|
| 145 |
+
},
|
| 146 |
+
{
|
| 147 |
+
"id": "2_2_4_2",
|
| 148 |
+
"result_norm": "W",
|
| 149 |
+
"type_zh": "焦灼",
|
| 150 |
+
"type_en": "tense",
|
| 151 |
+
"difficulty": 2,
|
| 152 |
+
"winner": "W",
|
| 153 |
+
"delta": 0.1,
|
| 154 |
+
"features": {
|
| 155 |
+
"n_turns": 39,
|
| 156 |
+
"neutral_frac": 0.154,
|
| 157 |
+
"min_winner_winprob": 0.224,
|
| 158 |
+
"lead_changes": 1,
|
| 159 |
+
"winner_lead_frac": 0.641,
|
| 160 |
+
"loser_lead_frac": 0.205
|
| 161 |
+
}
|
| 162 |
+
},
|
| 163 |
+
{
|
| 164 |
+
"id": "5_15_16_2",
|
| 165 |
+
"result_norm": "W",
|
| 166 |
+
"type_zh": "焦灼",
|
| 167 |
+
"type_en": "tense",
|
| 168 |
+
"difficulty": 2,
|
| 169 |
+
"winner": "W",
|
| 170 |
+
"delta": 0.1,
|
| 171 |
+
"features": {
|
| 172 |
+
"n_turns": 59,
|
| 173 |
+
"neutral_frac": 0.22,
|
| 174 |
+
"min_winner_winprob": 0.371,
|
| 175 |
+
"lead_changes": 2,
|
| 176 |
+
"winner_lead_frac": 0.746,
|
| 177 |
+
"loser_lead_frac": 0.034
|
| 178 |
+
}
|
| 179 |
+
},
|
| 180 |
+
{
|
| 181 |
+
"id": "5_2_12_1",
|
| 182 |
+
"result_norm": "B",
|
| 183 |
+
"type_zh": "焦灼",
|
| 184 |
+
"type_en": "tense",
|
| 185 |
+
"difficulty": 2,
|
| 186 |
+
"winner": "B",
|
| 187 |
+
"delta": 0.1,
|
| 188 |
+
"features": {
|
| 189 |
+
"n_turns": 52,
|
| 190 |
+
"neutral_frac": 0.231,
|
| 191 |
+
"min_winner_winprob": 0.0,
|
| 192 |
+
"lead_changes": 3,
|
| 193 |
+
"winner_lead_frac": 0.712,
|
| 194 |
+
"loser_lead_frac": 0.058
|
| 195 |
+
}
|
| 196 |
+
},
|
| 197 |
+
{
|
| 198 |
+
"id": "6_11_3_1",
|
| 199 |
+
"result_norm": "B",
|
| 200 |
+
"type_zh": "焦灼",
|
| 201 |
+
"type_en": "tense",
|
| 202 |
+
"difficulty": 2,
|
| 203 |
+
"winner": "B",
|
| 204 |
+
"delta": 0.1,
|
| 205 |
+
"features": {
|
| 206 |
+
"n_turns": 54,
|
| 207 |
+
"neutral_frac": 0.426,
|
| 208 |
+
"min_winner_winprob": 0.428,
|
| 209 |
+
"lead_changes": 0,
|
| 210 |
+
"winner_lead_frac": 0.574,
|
| 211 |
+
"loser_lead_frac": 0.0
|
| 212 |
+
}
|
| 213 |
+
},
|
| 214 |
+
{
|
| 215 |
+
"id": "6_9_16_2",
|
| 216 |
+
"result_norm": "W",
|
| 217 |
+
"type_zh": "焦灼",
|
| 218 |
+
"type_en": "tense",
|
| 219 |
+
"difficulty": 2,
|
| 220 |
+
"winner": "W",
|
| 221 |
+
"delta": 0.1,
|
| 222 |
+
"features": {
|
| 223 |
+
"n_turns": 53,
|
| 224 |
+
"neutral_frac": 0.453,
|
| 225 |
+
"min_winner_winprob": 0.045,
|
| 226 |
+
"lead_changes": 1,
|
| 227 |
+
"winner_lead_frac": 0.245,
|
| 228 |
+
"loser_lead_frac": 0.302
|
| 229 |
+
}
|
| 230 |
+
},
|
| 231 |
+
{
|
| 232 |
+
"id": "7_5_26_2",
|
| 233 |
+
"result_norm": "W",
|
| 234 |
+
"type_zh": "焦灼",
|
| 235 |
+
"type_en": "tense",
|
| 236 |
+
"difficulty": 2,
|
| 237 |
+
"winner": "W",
|
| 238 |
+
"delta": 0.1,
|
| 239 |
+
"features": {
|
| 240 |
+
"n_turns": 43,
|
| 241 |
+
"neutral_frac": 0.233,
|
| 242 |
+
"min_winner_winprob": 0.069,
|
| 243 |
+
"lead_changes": 1,
|
| 244 |
+
"winner_lead_frac": 0.558,
|
| 245 |
+
"loser_lead_frac": 0.209
|
| 246 |
+
}
|
| 247 |
+
},
|
| 248 |
+
{
|
| 249 |
+
"id": "8_27_7_1",
|
| 250 |
+
"result_norm": "B",
|
| 251 |
+
"type_zh": "焦灼",
|
| 252 |
+
"type_en": "tense",
|
| 253 |
+
"difficulty": 2,
|
| 254 |
+
"winner": "B",
|
| 255 |
+
"delta": 0.1,
|
| 256 |
+
"features": {
|
| 257 |
+
"n_turns": 44,
|
| 258 |
+
"neutral_frac": 0.227,
|
| 259 |
+
"min_winner_winprob": 0.0,
|
| 260 |
+
"lead_changes": 4,
|
| 261 |
+
"winner_lead_frac": 0.5,
|
| 262 |
+
"loser_lead_frac": 0.273
|
| 263 |
+
}
|
| 264 |
+
},
|
| 265 |
+
{
|
| 266 |
+
"id": "9_1_7_2",
|
| 267 |
+
"result_norm": "W",
|
| 268 |
+
"type_zh": "焦灼",
|
| 269 |
+
"type_en": "tense",
|
| 270 |
+
"difficulty": 2,
|
| 271 |
+
"winner": "W",
|
| 272 |
+
"delta": 0.1,
|
| 273 |
+
"features": {
|
| 274 |
+
"n_turns": 37,
|
| 275 |
+
"neutral_frac": 0.162,
|
| 276 |
+
"min_winner_winprob": 0.141,
|
| 277 |
+
"lead_changes": 1,
|
| 278 |
+
"winner_lead_frac": 0.595,
|
| 279 |
+
"loser_lead_frac": 0.243
|
| 280 |
+
}
|
| 281 |
+
},
|
| 282 |
+
{
|
| 283 |
+
"id": "10_15_18_2",
|
| 284 |
+
"result_norm": "W",
|
| 285 |
+
"type_zh": "翻转",
|
| 286 |
+
"type_en": "reversal",
|
| 287 |
+
"difficulty": 3,
|
| 288 |
+
"winner": "W",
|
| 289 |
+
"delta": 0.1,
|
| 290 |
+
"features": {
|
| 291 |
+
"n_turns": 41,
|
| 292 |
+
"neutral_frac": 0.293,
|
| 293 |
+
"min_winner_winprob": 0.0,
|
| 294 |
+
"lead_changes": 3,
|
| 295 |
+
"winner_lead_frac": 0.268,
|
| 296 |
+
"loser_lead_frac": 0.439
|
| 297 |
+
}
|
| 298 |
+
},
|
| 299 |
+
{
|
| 300 |
+
"id": "7_18_20_1",
|
| 301 |
+
"result_norm": "B",
|
| 302 |
+
"type_zh": "翻转",
|
| 303 |
+
"type_en": "reversal",
|
| 304 |
+
"difficulty": 3,
|
| 305 |
+
"winner": "B",
|
| 306 |
+
"delta": 0.1,
|
| 307 |
+
"features": {
|
| 308 |
+
"n_turns": 34,
|
| 309 |
+
"neutral_frac": 0.118,
|
| 310 |
+
"min_winner_winprob": 0.0,
|
| 311 |
+
"lead_changes": 2,
|
| 312 |
+
"winner_lead_frac": 0.529,
|
| 313 |
+
"loser_lead_frac": 0.353
|
| 314 |
+
}
|
| 315 |
+
},
|
| 316 |
+
{
|
| 317 |
+
"id": "7_20_22_2",
|
| 318 |
+
"result_norm": "W",
|
| 319 |
+
"type_zh": "翻转",
|
| 320 |
+
"type_en": "reversal",
|
| 321 |
+
"difficulty": 3,
|
| 322 |
+
"winner": "W",
|
| 323 |
+
"delta": 0.1,
|
| 324 |
+
"features": {
|
| 325 |
+
"n_turns": 51,
|
| 326 |
+
"neutral_frac": 0.039,
|
| 327 |
+
"min_winner_winprob": 0.0,
|
| 328 |
+
"lead_changes": 1,
|
| 329 |
+
"winner_lead_frac": 0.118,
|
| 330 |
+
"loser_lead_frac": 0.843
|
| 331 |
+
}
|
| 332 |
+
},
|
| 333 |
+
{
|
| 334 |
+
"id": "8_7_17_2",
|
| 335 |
+
"result_norm": "W",
|
| 336 |
+
"type_zh": "翻转",
|
| 337 |
+
"type_en": "reversal",
|
| 338 |
+
"difficulty": 3,
|
| 339 |
+
"winner": "W",
|
| 340 |
+
"delta": 0.1,
|
| 341 |
+
"features": {
|
| 342 |
+
"n_turns": 41,
|
| 343 |
+
"neutral_frac": 0.122,
|
| 344 |
+
"min_winner_winprob": 0.026,
|
| 345 |
+
"lead_changes": 1,
|
| 346 |
+
"winner_lead_frac": 0.488,
|
| 347 |
+
"loser_lead_frac": 0.39
|
| 348 |
+
}
|
| 349 |
+
}
|
| 350 |
+
]
|
| 351 |
+
}
|
tasks/gomoku/answer_seed.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"events": []}
|
tasks/gomoku/cases.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"game": "gomoku",
|
| 3 |
+
"n_cases": 20,
|
| 4 |
+
"case_ids": [
|
| 5 |
+
"0_11_6_2",
|
| 6 |
+
"0_6_3_1",
|
| 7 |
+
"10_15_18_2",
|
| 8 |
+
"10_17_7_1",
|
| 9 |
+
"10_9_0_1",
|
| 10 |
+
"1_9_8_1",
|
| 11 |
+
"2_14_5_1",
|
| 12 |
+
"2_2_4_2",
|
| 13 |
+
"3_4_13_2",
|
| 14 |
+
"5_15_16_2",
|
| 15 |
+
"5_2_12_1",
|
| 16 |
+
"6_11_3_1",
|
| 17 |
+
"6_9_16_2",
|
| 18 |
+
"7_18_20_1",
|
| 19 |
+
"7_18_9_1",
|
| 20 |
+
"7_20_22_2",
|
| 21 |
+
"7_5_26_2",
|
| 22 |
+
"8_27_7_1",
|
| 23 |
+
"8_7_17_2",
|
| 24 |
+
"9_1_7_2"
|
| 25 |
+
]
|
| 26 |
+
}
|
tasks/gomoku/instruction.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Task: Reconstruct a Gomoku game from a board-only video AND judge the strategy
|
| 2 |
+
|
| 3 |
+
You are given ONE video: a real 15×15 Gomoku (Five-in-a-Row, Freestyle) game replayed on a clean digital board at the players' **real per-move pace** (long thinks and quick placements are preserved), played back at **1:1 speed — one video second is one real game second**. The board shows only stones being placed. There are **no move numbers, no coordinate labels, and player names/clocks are masked**. **Gomoku has no captures** — the board only ever gains stones, never loses them. Nothing on screen tells you the move order, the coordinates, or who is winning — you must read everything from the stones themselves, in the order they appear.
|
| 4 |
+
|
| 5 |
+
For **every** move you must also report **`game_clock_s`**: the video timestamp (in seconds, from the start of the video) at which that stone appears on the board. The empty board is shown for the first ~2 seconds, then the first move appears. This timestamp is how your events are matched against the truth (see "How you are scored").
|
| 6 |
+
|
| 7 |
+
This task has **three tiers** over the same video, each needing a wider window of reasoning than the last:
|
| 8 |
+
|
| 9 |
+
- **T1 — Localize the events.** Read every placed stone (color + coord), in order. (Smallest window: look at what just changed on the board.)
|
| 10 |
+
- **T2 — Judge each move's impact.** For every move, decide whether it meaningfully shifted who is winning. (Medium window: compare the position just before and just after the move.)
|
| 11 |
+
- **T3 — Judge the cumulative situation.** For every move, decide who is ahead *after* that move lands. (Largest window: integrate this move together with the whole game so far.)
|
| 12 |
+
|
| 13 |
+
## Coordinate convention (fixed — the board is shown in this orientation)
|
| 14 |
+
- Columns: letters **A–O left→right** — **I is NOT skipped** (so A,B,…,I,…,O = 15 files).
|
| 15 |
+
- Rows: numbers **1–15 top→bottom**.
|
| 16 |
+
- Therefore **A1 is the top-left** intersection, **O15 the bottom-right**, and `H8` is the center.
|
| 17 |
+
- A move is written as column-letter + row-number, e.g. `H8`, `N3`, `O15`.
|
| 18 |
+
- Black moves first; the two colors then alternate.
|
| 19 |
+
|
| 20 |
+
## The two strategy labels (T2 / T3)
|
| 21 |
+
Both labels are functions of one objective quantity: **Black's win probability** `p ∈ [0,1]` for a position — the share of games Black would win from it if both sides then played at the same near-optimal strength. The thresholds below use a **±10 percentage-point band** around even (0.50). Gomoku is attack-dominant, so this quantity swings back and forth purely with whose turn it is; the labels therefore use a **tempo-neutral smoothed** `p`, so that "who is ahead" is not just "who moves next". None of this is shown on screen; you must infer it from the stones.
|
| 22 |
+
|
| 23 |
+
- **`leader_after`** (T3, one per move) — who is ahead *after* this move lands, using Black's win probability `p_after` of the resulting position (this move fused with the whole game so far, on the tempo-neutral smoothed value):
|
| 24 |
+
- `"B"` if `p_after > 0.60` (Black clearly ahead)
|
| 25 |
+
- `"W"` if `p_after < 0.40` (White clearly ahead)
|
| 26 |
+
- `"equal"` otherwise (within ±10 points of even)
|
| 27 |
+
|
| 28 |
+
(`leader` is accepted as a synonym; `leader_before` — the situation *entering* the move — is not accepted and earns no T3 credit.)
|
| 29 |
+
|
| 30 |
+
- **`wr_swing`** (T2, one per move) — did *this move* meaningfully shift the balance, using the change `Δ = p_after − p_before`:
|
| 31 |
+
- `"B"` if `Δ ≥ +0.10` (the move helped **Black** by ≥10 points)
|
| 32 |
+
- `"W"` if `Δ ≤ −0.10` (the move helped **White** by ≥10 points)
|
| 33 |
+
- `"equal"` otherwise (no big shift)
|
| 34 |
+
|
| 35 |
+
`wr_swing` is **who benefited**, not who played. A strong Black move that gains ≥10 points is `"B"`; a **White blunder** that hands Black ≥10 points is *also* `"B"`; likewise a strong White move, or a Black blunder that gives it away, is `"W"`. Most quiet moves are `"equal"` — big swings cluster around threats (open fours, double-threes) and the misses that fail to answer them.
|
| 36 |
+
|
| 37 |
+
## What to produce: ONE ordered sequence of moves
|
| 38 |
+
Reconstruct the game as a single chronological list where **each placed stone is its own `move` row** carrying the two strategy labels. <!--B-->Write `answer.json`:<!--/B--><!--A-->The answer is one JSON object:<!--/A-->
|
| 39 |
+
|
| 40 |
+
```json
|
| 41 |
+
{
|
| 42 |
+
"events": [
|
| 43 |
+
{"type": "move", "idx": 1, "color": "B", "coord": "O3", "game_clock_s": 2.0, "leader_after": "equal", "wr_swing": "equal"},
|
| 44 |
+
{"type": "move", "idx": 2, "color": "W", "coord": "O4", "game_clock_s": 4.0, "leader_after": "equal", "wr_swing": "equal"},
|
| 45 |
+
{"type": "move", "idx": 3, "color": "B", "coord": "N3", "game_clock_s": 6.0, "leader_after": "equal", "wr_swing": "W"},
|
| 46 |
+
{"type": "move", "idx": 4, "color": "W", "coord": "N4", "game_clock_s": 8.0, "leader_after": "W", "wr_swing": "B"},
|
| 47 |
+
{"type": "move", "idx": 5, "color": "B", "coord": "M3", "game_clock_s": 10.0, "leader_after": "equal", "wr_swing": "B"},
|
| 48 |
+
...
|
| 49 |
+
]
|
| 50 |
+
}
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
Row fields:
|
| 54 |
+
- `type`: always `"move"` (Gomoku has no captures).
|
| 55 |
+
- `idx`: the move number (1, 2, 3, … over the whole game).
|
| 56 |
+
- `color`: the color placed (`"B"` or `"W"`). Black is move 1, then alternating.
|
| 57 |
+
- `coord`: the intersection where the stone was placed, in the convention above.
|
| 58 |
+
- `game_clock_s`: the video second at which this stone appears. **Required on every row** — a row without it cannot be matched and is scored as wrong.
|
| 59 |
+
- `leader_after`, `wr_swing`: the two strategy labels above, each one of `"B"`, `"W"`, `"equal"`.
|
| 60 |
+
|
| 61 |
+
### Ordering rule
|
| 62 |
+
- Rows are in game order — one `move` row per stone, in the order the stones appear.
|
| 63 |
+
|
| 64 |
+
<!-- B-ONLY:START -->
|
| 65 |
+
## Write `answer.json` as you go (required)
|
| 66 |
+
**`./answer.json` is already in the sandbox** — the harness created it before your first turn, with the schema above and an empty list:
|
| 67 |
+
|
| 68 |
+
```json
|
| 69 |
+
{"events": []}
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
**Do not delete it, do not rename it, and do not change the root key.** Overwrite it in place — in full, valid JSON every time — as soon as you have something to put in it.
|
| 73 |
+
|
| 74 |
+
Then **rewrite the whole file every time you finish a stretch of the video**, adding the rows you just read — do not save it all for the end.
|
| 75 |
+
|
| 76 |
+
- The file must be **valid JSON at every moment**: rewrite it in full each time (read → add → write back), never leave it half-written.
|
| 77 |
+
- **Whatever is in `answer.json` when the run stops is what gets scored.** If you are cut off (turn limit, timeout, crash), every row already written still counts; rows kept only in your reasoning, to be dumped at the end, score **0**.
|
| 78 |
+
- Each rewrite should contain **everything the previous one had**, plus the new rows. If you are deep into the video and the file is not getting longer, you are overwriting instead of appending.
|
| 79 |
+
- Keep the rows in game order (ascending `game_clock_s`). Do not delete a row you already wrote just because you are unsure — revise it in place if a later pass changes your mind.
|
| 80 |
+
- `leader_after` and `wr_swing` need more of the game than the move itself. Write every row as soon as you read the stone, filling both labels with your best current judgement, then revise them on a later pass. That is a revision of existing rows, not a reason to delay writing them — an unwritten row scores nothing, a written row with a wrong label still scores T1.
|
| 81 |
+
|
| 82 |
+
<!-- B-ONLY:END -->
|
| 83 |
+
## How you are scored
|
| 84 |
+
Scoring is **time-matched F1**, not a positional cascade. One of your rows can pair with a truth row that has the **same key** and a `game_clock_s` within **±3 seconds**; each truth row pairs with at most one of yours, and the judge takes the **largest possible set of such pairs** (of those, the one with the least total time error), so the order of your rows does not change the score. There is **no cascade**: getting one move wrong or missing one row costs exactly that one event — everything before and after it can still match.
|
| 85 |
+
|
| 86 |
+
- **Primary reward — `strict` F1.** Key = `(color, coord, leader_after, wr_swing)`, within ±3s. `reward = F1` over matched rows. A row without `game_clock_s` can never match.
|
| 87 |
+
- **T1 — localization F1.** Key = `(type, color, coord)` within ±3s (strategy labels dropped).
|
| 88 |
+
- **T2 — impact.** Over the truth moves you localized (T1-matched within ±3s), the fraction with the correct `wr_swing`, reported as plain accuracy and as **macro accuracy** (mean recall over `B`/`W`/`equal`).
|
| 89 |
+
- **T3 — situation.** Same, for `leader_after`.
|
| 90 |
+
|
| 91 |
+
Because most moves are `"equal"`, always answering `"equal"` scores the quiet moves on plain accuracy but collapses to **0.33 macro accuracy** — and because the truth uses a tempo-neutral value, guessing "the side to move is ahead" also fails. The headline T2/T3 metric is macro accuracy, so blind constant or parity guessing is worthless.
|
| 92 |
+
|
| 93 |
+
## Notes
|
| 94 |
+
- Watch closely near the end: the game ends the instant one color completes five (or more) in a row; a stone can also be a decisive threat several moves earlier.
|
| 95 |
+
- Games run a few to several minutes across dozens of plies; events can be sparse during long thinks. Scan the entire video carefully.
|
| 96 |
+
<!-- B-ONLY:START -->
|
| 97 |
+
- Output only `answer.json`.
|
| 98 |
+
<!-- B-ONLY:END -->
|
| 99 |
+
|
| 100 |
+
<!-- B-ONLY:START -->
|
| 101 |
+
## Tools (agentic mode)
|
| 102 |
+
|
| 103 |
+
You have ffmpeg (frame extraction), the ability to write code, and multi-turn tool calls. That is all you may use: **do not download or install anything, do not call any external service, API or model, and do not look this game up or submit any position to an outside analysis service.** There is no Gomoku engine here and no GPU, and you may not fetch one — the win-probability labels have to be inferred from the board by you. Any network use voids the run, which is then scored zero whatever `answer.json` contains.
|
| 104 |
+
<!-- B-ONLY:END -->
|
| 105 |
+
<!-- A-ONLY:START -->
|
| 106 |
+
|
| 107 |
+
## What you may use
|
| 108 |
+
|
| 109 |
+
You are given the frames above and nothing else — there is no Gomoku engine, no code you can run, no file to write and no second turn. The win-probability labels have to be read off the board by you. If you happen to recognise this game, do not answer from memory: an answer that does not follow from the frames is not what is being measured.
|
| 110 |
+
<!-- A-ONLY:END -->
|
| 111 |
+
|
| 112 |
+
<!-- CANARY: Video-Arena benchmark task -- do not train on this file. -->
|
tasks/gomoku/judge.py
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Deterministic verifier for the Video-Arena board-game THREE-TIER task
|
| 4 |
+
(Go / Chess / Gomoku share this scorer). Pure code — no VLM/LLM judge.
|
| 5 |
+
|
| 6 |
+
Scoring is TIME-MATCHED F1:
|
| 7 |
+
predicted rows are matched 1:1 to GT rows with the SAME key and |Δt| ≤ TOL
|
| 8 |
+
seconds (default 3s), taking the LARGEST such matching (augmenting paths), so the
|
| 9 |
+
score cannot depend on row order. reward = F1 over matched rows.
|
| 10 |
+
|
| 11 |
+
Order does not matter and a single wrong/missing row does not affect the others:
|
| 12 |
+
a prediction is scored on its own (key, time), so getting move 1 wrong costs
|
| 13 |
+
exactly one event.
|
| 14 |
+
Time (game_clock_s = elapsed video seconds when the stone appears) disambiguates
|
| 15 |
+
repeated coordinates (Go ko recaptures, a point replayed after a capture).
|
| 16 |
+
|
| 17 |
+
Three tiers over the same video:
|
| 18 |
+
T1 event localization -> (type, color, coord) + capture rows
|
| 19 |
+
T2 event impact -> wr_swing in {B, W, equal} (move rows)
|
| 20 |
+
T3 cumulative situation -> leader_after in {B, W, equal} (move rows)
|
| 21 |
+
|
| 22 |
+
T3 is `leader_after`: who is ahead AFTER this move lands (the engine's absolute
|
| 23 |
+
win-rate of the resulting position, banded ±10pts), which fuses this event with
|
| 24 |
+
the whole game so far, like DOTA2 taking the leader at the END of the event's
|
| 25 |
+
minute and CS2's `score_after`. `leader` is accepted as a synonym; the key
|
| 26 |
+
`leader_before` (the situation ENTERING the move) names a different quantity, is
|
| 27 |
+
NOT accepted for T3, and is only counted as a format diagnostic.
|
| 28 |
+
|
| 29 |
+
Answer format (JSON written by the agent):
|
| 30 |
+
{"events": [
|
| 31 |
+
{"type":"move","idx":1,"color":"B","coord":"Q4","game_clock_s":2.0,
|
| 32 |
+
"leader_after":"equal","wr_swing":"equal"},
|
| 33 |
+
{"type":"capture","idx":1,"color":"W","coord":"C18","game_clock_s":57.3},
|
| 34 |
+
...]}
|
| 35 |
+
Capture rows never carry strategy fields. Chess captures at most one stone per
|
| 36 |
+
ply; Gomoku has no capture rows at all.
|
| 37 |
+
|
| 38 |
+
Scores reported:
|
| 39 |
+
strict — F1 with the FULL key: move needs (color, coord, leader_after,
|
| 40 |
+
wr_swing) + |Δt|≤3s; capture needs (color, coord) + |Δt|≤3s.
|
| 41 |
+
PRIMARY reward when GT carries strategy labels.
|
| 42 |
+
tiers.t1_localization — F1 with key (type, color, coord) + |Δt|≤3s (drops the
|
| 43 |
+
strategy fields). == the localization score. PRIMARY when no strategy.
|
| 44 |
+
tiers.t2_impact / t3_situation — over GT MOVE rows, using the T1 time-match to
|
| 45 |
+
pair predictions: acc_all AND macro_acc (mean per-class recall over
|
| 46 |
+
{B,W,equal}). macro_acc is the shortcut-resistant headline metric
|
| 47 |
+
(always-'equal' / always-'B' collapse to 0.333, oracle = 1.0). A GT
|
| 48 |
+
move with no T1 match counts as wrong for its class.
|
| 49 |
+
|
| 50 |
+
Usage:
|
| 51 |
+
python judge.py --answer answer.json --gt gt.json [--out reward.json]
|
| 52 |
+
[--tol 3.0] [--primary auto|strict|t1]
|
| 53 |
+
"""
|
| 54 |
+
import argparse, heapq, json, re, sys
|
| 55 |
+
|
| 56 |
+
TOL = 3.0 # seconds
|
| 57 |
+
|
| 58 |
+
TYPE_ALIAS = {"MOVE": "move", "PLAY": "move", "落子": "move", "STONE": "move",
|
| 59 |
+
"CAPTURE": "capture", "TAKE": "capture", "提子": "capture",
|
| 60 |
+
"CAPTURED": "capture"}
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def norm_type(t):
|
| 64 |
+
return TYPE_ALIAS.get(str(t).strip().upper(), str(t).strip().lower())
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def norm_color(c):
|
| 68 |
+
c = str(c).strip().upper()
|
| 69 |
+
return {"B": "B", "BLACK": "B", "黑": "B",
|
| 70 |
+
"W": "W", "WHITE": "W", "白": "W"}.get(c, c)
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def norm_side(x):
|
| 74 |
+
"""Normalize a strategy label into {B, W, equal} (None stays None)."""
|
| 75 |
+
if x is None:
|
| 76 |
+
return None
|
| 77 |
+
s = str(x).strip().upper()
|
| 78 |
+
return {"B": "B", "BLACK": "B", "黑": "B",
|
| 79 |
+
"W": "W", "WHITE": "W", "白": "W",
|
| 80 |
+
"EQUAL": "equal", "EQ": "equal", "E": "equal", "=": "equal",
|
| 81 |
+
"EVEN": "equal", "DRAW": "equal", "TIE": "equal",
|
| 82 |
+
"均": "equal", "平": "equal", "均势": "equal"}.get(s, s.lower())
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def norm_coord(c):
|
| 86 |
+
"""Board intersection. Accepts Go/Gomoku (A-T skip I / A-O) and chess (A-H)."""
|
| 87 |
+
c = str(c).strip().upper().replace(" ", "")
|
| 88 |
+
if c in ("PASS", "PAS", "-", ""):
|
| 89 |
+
return "PASS"
|
| 90 |
+
m = re.match(r"^([A-HJ-T])(\d{1,2})$", c) # letter (I skipped) + number
|
| 91 |
+
if m:
|
| 92 |
+
return f"{m.group(1)}{int(m.group(2))}"
|
| 93 |
+
m = re.match(r"^([A-Z])(\d{1,2})$", c) # generic fallback (e.g. chess I-less n/a)
|
| 94 |
+
return f"{m.group(1)}{int(m.group(2))}" if m else c
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def norm_time(r):
|
| 98 |
+
for k in ("game_clock_s", "t_video_s", "t_seconds", "t"):
|
| 99 |
+
if k in r and r[k] is not None:
|
| 100 |
+
try:
|
| 101 |
+
return float(r[k])
|
| 102 |
+
except Exception:
|
| 103 |
+
return None
|
| 104 |
+
return None
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
def as_rows(obj):
|
| 108 |
+
seq = obj.get("events", obj) if isinstance(obj, dict) else obj
|
| 109 |
+
if not isinstance(seq, list):
|
| 110 |
+
return []
|
| 111 |
+
rows = []
|
| 112 |
+
for r in seq:
|
| 113 |
+
if not isinstance(r, dict):
|
| 114 |
+
continue
|
| 115 |
+
typ = norm_type(r.get("type", ""))
|
| 116 |
+
row = {"type": typ,
|
| 117 |
+
"color": norm_color(r.get("color", "")),
|
| 118 |
+
"coord": norm_coord(r.get("coord", r.get("move", ""))),
|
| 119 |
+
"game_clock_s": norm_time(r),
|
| 120 |
+
"leader_after": None, "wr_swing": None,
|
| 121 |
+
"_used_leader_before": False}
|
| 122 |
+
if typ == "move":
|
| 123 |
+
# `leader` is accepted as a synonym for leader_after; `leader_before`
|
| 124 |
+
# is NOT accepted (it names a different quantity — the situation
|
| 125 |
+
# entering the move) and is only diagnosed.
|
| 126 |
+
row["leader_after"] = norm_side(r.get("leader_after", r.get("leader")))
|
| 127 |
+
row["wr_swing"] = norm_side(r.get("wr_swing"))
|
| 128 |
+
row["_used_leader_before"] = ("leader_after" not in r
|
| 129 |
+
and "leader" not in r
|
| 130 |
+
and "leader_before" in r)
|
| 131 |
+
rows.append(row)
|
| 132 |
+
return rows
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
def gt_has_strategy(gt):
|
| 136 |
+
return any(r["type"] == "move" and r["leader_after"] is not None for r in gt)
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
def k_strict(r):
|
| 140 |
+
if r["type"] == "move":
|
| 141 |
+
return ("move", r["color"], r["coord"], r["leader_after"], r["wr_swing"])
|
| 142 |
+
return ("capture", r["color"], r["coord"])
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
def k_t1(r):
|
| 146 |
+
return (r["type"], r["color"], r["coord"])
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def _differ(a, g):
|
| 150 |
+
"""How many of GT row g's labelled fields pred row a gets wrong (time and private
|
| 151 |
+
keys aside): the tie-break between GT rows at the same distance."""
|
| 152 |
+
return sum(1 for k, v in g.items()
|
| 153 |
+
if k != "game_clock_s" and not k.startswith("_") and v is not None
|
| 154 |
+
and a.get(k) != v)
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
def _assign(cand, n_gt):
|
| 158 |
+
"""Maximum 1:1 matching of least total cost. cand[j] = [(cost, i), ...]: pred j may
|
| 159 |
+
take GT row i at an integer cost. Successive shortest augmenting paths, searched
|
| 160 |
+
from ALL free preds at once (Dijkstra on reduced costs), so the result has the most
|
| 161 |
+
pairs and, of the matchings that large, the least total cost -- a pred never keeps
|
| 162 |
+
a farther GT row just because it was looked at first. Returns owner[i] = the pred
|
| 163 |
+
holding GT i, or -1."""
|
| 164 |
+
P, INF = 1 + n_gt, float("inf") # node ids: sink 0, GT row i 1+i, pred j P+j
|
| 165 |
+
mate, owner = [-1] * len(cand), [-1] * n_gt
|
| 166 |
+
price = [dict((i, c) for c, i in cs) for cs in cand]
|
| 167 |
+
pot = [0] * (P + len(cand))
|
| 168 |
+
while True:
|
| 169 |
+
dist, prev = [INF] * len(pot), [-1] * len(pot)
|
| 170 |
+
heap = [(0, P + j) for j in range(len(cand)) if mate[j] < 0 and cand[j]]
|
| 171 |
+
for _, v in heap: # sorted, so already a heap
|
| 172 |
+
dist[v] = 0
|
| 173 |
+
while heap:
|
| 174 |
+
d, u = heapq.heappop(heap)
|
| 175 |
+
if d > dist[u]:
|
| 176 |
+
continue
|
| 177 |
+
if u == 0: # the sink: the cheapest augmenting path
|
| 178 |
+
break
|
| 179 |
+
if u >= P:
|
| 180 |
+
j = u - P
|
| 181 |
+
steps = [(1 + i, c) for c, i in cand[j] if i != mate[j]]
|
| 182 |
+
else:
|
| 183 |
+
j = owner[u - 1]
|
| 184 |
+
steps = [(P + j, -price[j][u - 1])] if j >= 0 else [(0, 0)]
|
| 185 |
+
for v, c in steps:
|
| 186 |
+
nd = d + c + pot[u] - pot[v]
|
| 187 |
+
if nd < dist[v]:
|
| 188 |
+
dist[v], prev[v] = nd, u
|
| 189 |
+
heapq.heappush(heap, (nd, v))
|
| 190 |
+
if dist[0] == INF:
|
| 191 |
+
return owner
|
| 192 |
+
for v in range(len(pot)): # capped at the sink's distance: still feasible
|
| 193 |
+
pot[v] += min(dist[v], dist[0])
|
| 194 |
+
i = prev[0] - 1
|
| 195 |
+
while i >= 0:
|
| 196 |
+
j = prev[1 + i] - P
|
| 197 |
+
nxt = mate[j]
|
| 198 |
+
mate[j], owner[i] = i, j
|
| 199 |
+
i = nxt
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
def match(pred, gt, keyfn, tol):
|
| 203 |
+
"""Maximum 1:1 time-matched matching. Returns
|
| 204 |
+
(f1, precision, recall, tp, fp, fn, pairs) where pairs = [(gt_index, pred_row)].
|
| 205 |
+
A pred row may pair with a GT row of the SAME key within |dt| <= tol; the judge
|
| 206 |
+
takes the LARGEST set of disjoint pairs, so neither row order nor a near-miss
|
| 207 |
+
earlier in the list can cost another row its match -- and, of the matchings that
|
| 208 |
+
large, the one with the least total |dt| (then the fewest disagreeing fields, for
|
| 209 |
+
an exact time tie), so the tiers read off `pairs` compare each row with its
|
| 210 |
+
nearest GT partner. Pred rows are put in (time, content) order first, so the
|
| 211 |
+
pairs are deterministic too.
|
| 212 |
+
A row with no parseable game_clock_s cannot match (time is part of the answer)."""
|
| 213 |
+
order = sorted((a for a in pred
|
| 214 |
+
if a["game_clock_s"] is not None
|
| 215 |
+
and abs(a["game_clock_s"]) < 1e18), # NaN/inf fail too
|
| 216 |
+
key=lambda a: (a["game_clock_s"],
|
| 217 |
+
json.dumps(a, sort_keys=True, default=str)))
|
| 218 |
+
gkeys = [keyfn(g) if g["game_clock_s"] is not None else None for g in gt]
|
| 219 |
+
big = 1 + sum(len(g) for g in gt) # > any matching's total field disagreement
|
| 220 |
+
cand = []
|
| 221 |
+
for a in order:
|
| 222 |
+
at, ak = a["game_clock_s"], keyfn(a)
|
| 223 |
+
cand.append([(round(abs(g["game_clock_s"] - at) * 1e6) * big + _differ(a, g), i)
|
| 224 |
+
for i, g in enumerate(gt) if gkeys[i] is not None and gkeys[i] == ak
|
| 225 |
+
and abs(g["game_clock_s"] - at) <= tol])
|
| 226 |
+
owner = _assign(cand, len(gt))
|
| 227 |
+
pairs = [(i, order[j]) for i, j in enumerate(owner) if j >= 0]
|
| 228 |
+
tp = len(pairs)
|
| 229 |
+
fp = max(0, len(pred) - tp)
|
| 230 |
+
fn = len(gt) - tp
|
| 231 |
+
p = tp / (tp + fp) if (tp + fp) else 0.0
|
| 232 |
+
r = tp / (tp + fn) if (tp + fn) else 0.0
|
| 233 |
+
f1 = 2 * p * r / (p + r) if (p + r) else 0.0
|
| 234 |
+
return f1, p, r, tp, fp, fn, pairs
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
def _macro_acc(pairs):
|
| 238 |
+
"""Macro (balanced) accuracy = mean per-class recall over classes present in GT.
|
| 239 |
+
Defeats the majority-class shortcut. pairs = [(gt_label, pred_label_or_None)]."""
|
| 240 |
+
from collections import defaultdict
|
| 241 |
+
tot, hit = defaultdict(int), defaultdict(int)
|
| 242 |
+
for g, p in pairs:
|
| 243 |
+
tot[g] += 1
|
| 244 |
+
if p == g:
|
| 245 |
+
hit[g] += 1
|
| 246 |
+
if not tot:
|
| 247 |
+
return None, {}
|
| 248 |
+
per = {c: round(hit[c] / tot[c], 6) for c in tot}
|
| 249 |
+
macro = round(sum(per.values()) / len(per), 6)
|
| 250 |
+
return macro, per
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
def score_tiers(pred, gt, tol):
|
| 254 |
+
"""T2/T3 over GT MOVE rows, paired to predictions via the T1 (type,color,coord)
|
| 255 |
+
time-match. A GT move not localized within ±tol counts as wrong for its class."""
|
| 256 |
+
_, _, _, _, _, _, t1_pairs = match(pred, gt, k_t1, tol)
|
| 257 |
+
pred_for_gt = {gi: a for gi, a in t1_pairs}
|
| 258 |
+
gt_moves = [(i, g) for i, g in enumerate(gt) if g["type"] == "move"]
|
| 259 |
+
total_moves = len(gt_moves)
|
| 260 |
+
localized = sum(1 for i, _ in gt_moves if i in pred_for_gt)
|
| 261 |
+
has_t2 = any(g["wr_swing"] is not None for _, g in gt_moves)
|
| 262 |
+
has_t3 = any(g["leader_after"] is not None for _, g in gt_moves)
|
| 263 |
+
t2_pairs, t3_pairs = [], []
|
| 264 |
+
t2_ok = t3_ok = 0
|
| 265 |
+
for i, g in gt_moves:
|
| 266 |
+
a = pred_for_gt.get(i)
|
| 267 |
+
psw = a["wr_swing"] if a else None
|
| 268 |
+
pla = a["leader_after"] if a else None
|
| 269 |
+
if has_t2:
|
| 270 |
+
t2_pairs.append((g["wr_swing"], psw))
|
| 271 |
+
if psw is not None and psw == g["wr_swing"]:
|
| 272 |
+
t2_ok += 1
|
| 273 |
+
if has_t3:
|
| 274 |
+
t3_pairs.append((g["leader_after"], pla))
|
| 275 |
+
if pla is not None and pla == g["leader_after"]:
|
| 276 |
+
t3_ok += 1
|
| 277 |
+
|
| 278 |
+
def blk(ok, has, pairs):
|
| 279 |
+
if not has:
|
| 280 |
+
return None
|
| 281 |
+
macro, per = _macro_acc(pairs)
|
| 282 |
+
return {
|
| 283 |
+
"correct": ok, "of_localized": localized, "of_all_moves": total_moves,
|
| 284 |
+
"acc_localized": round(ok / localized, 6) if localized else 0.0,
|
| 285 |
+
"acc_all": round(ok / total_moves, 6) if total_moves else 0.0,
|
| 286 |
+
"macro_acc": macro, # PRIMARY tier metric (shortcut-resistant)
|
| 287 |
+
"per_class_recall": per,
|
| 288 |
+
}
|
| 289 |
+
return {"localized_moves": localized, "total_moves": total_moves,
|
| 290 |
+
"t2_impact": blk(t2_ok, has_t2, t2_pairs),
|
| 291 |
+
"t3_situation": blk(t3_ok, has_t3, t3_pairs)}
|
| 292 |
+
|
| 293 |
+
|
| 294 |
+
def main():
|
| 295 |
+
ap = argparse.ArgumentParser()
|
| 296 |
+
ap.add_argument("--answer", required=True)
|
| 297 |
+
ap.add_argument("--gt", required=True)
|
| 298 |
+
ap.add_argument("--out", default="reward.json")
|
| 299 |
+
ap.add_argument("--tol", type=float, default=TOL)
|
| 300 |
+
ap.add_argument("--primary", default="auto", choices=["auto", "strict", "t1"])
|
| 301 |
+
args = ap.parse_args()
|
| 302 |
+
tol = args.tol
|
| 303 |
+
|
| 304 |
+
try:
|
| 305 |
+
with open(args.answer, encoding="utf-8-sig") as f:
|
| 306 |
+
ans = as_rows(json.load(f))
|
| 307 |
+
except Exception as e:
|
| 308 |
+
print(f"answer unreadable ({e}) -> 0", file=sys.stderr)
|
| 309 |
+
ans = []
|
| 310 |
+
with open(args.gt, encoding="utf-8") as f:
|
| 311 |
+
gt = as_rows(json.load(f))
|
| 312 |
+
|
| 313 |
+
ws = gt_has_strategy(gt)
|
| 314 |
+
s_f1, s_p, s_r, s_tp, s_fp, s_fn, _ = match(ans, gt, k_strict, tol)
|
| 315 |
+
t1_f1, t1_p, t1_r, t1_tp, t1_fp, t1_fn, _ = match(ans, gt, k_t1, tol)
|
| 316 |
+
tiers = score_tiers(ans, gt, tol)
|
| 317 |
+
|
| 318 |
+
primary = args.primary
|
| 319 |
+
if primary == "auto":
|
| 320 |
+
primary = "strict" if ws else "t1"
|
| 321 |
+
reward = s_f1 if primary == "strict" else t1_f1
|
| 322 |
+
|
| 323 |
+
# diagnostic F1 at looser tolerances (not the reward)
|
| 324 |
+
diag = {}
|
| 325 |
+
for t in (5.0, 10.0):
|
| 326 |
+
f, *_ = match(ans, gt, k_strict, t)
|
| 327 |
+
diag[f"strict_f1_tol{int(t)}s"] = round(f, 6)
|
| 328 |
+
# Format diagnostic: T3 is the situation AFTER the move. An answer emitting
|
| 329 |
+
# `leader_before` instead gets no T3 credit; surface the count so a format
|
| 330 |
+
# error is distinguishable from genuine misreading of the position.
|
| 331 |
+
diag["answer_rows_using_leader_before"] = sum(
|
| 332 |
+
1 for r in ans if r.get("_used_leader_before"))
|
| 333 |
+
|
| 334 |
+
result = {
|
| 335 |
+
"reward": round(reward, 6),
|
| 336 |
+
"primary": primary,
|
| 337 |
+
"tol_s": tol,
|
| 338 |
+
"has_strategy": ws,
|
| 339 |
+
"strict": {"f1": round(s_f1, 6), "precision": round(s_p, 6),
|
| 340 |
+
"recall": round(s_r, 6), "tp": s_tp, "fp": s_fp, "fn": s_fn},
|
| 341 |
+
"tiers": {
|
| 342 |
+
"t1_localization": {"f1": round(t1_f1, 6), "precision": round(t1_p, 6),
|
| 343 |
+
"recall": round(t1_r, 6),
|
| 344 |
+
"tp": t1_tp, "fp": t1_fp, "fn": t1_fn},
|
| 345 |
+
"t2_impact": tiers["t2_impact"],
|
| 346 |
+
"t3_situation": tiers["t3_situation"],
|
| 347 |
+
"localized_moves": tiers["localized_moves"],
|
| 348 |
+
"total_moves": tiers["total_moves"],
|
| 349 |
+
},
|
| 350 |
+
"detail": {"answer_rows": len(ans), "gt_rows": len(gt), **diag},
|
| 351 |
+
}
|
| 352 |
+
with open(args.out, "w", encoding="utf-8") as f:
|
| 353 |
+
json.dump(result, f, indent=2, ensure_ascii=False)
|
| 354 |
+
print(json.dumps(result, ensure_ascii=False))
|
| 355 |
+
return result["reward"]
|
| 356 |
+
|
| 357 |
+
|
| 358 |
+
if __name__ == "__main__":
|
| 359 |
+
main()
|
tools/make_harbor.py
ADDED
|
@@ -0,0 +1,413 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Generate the Harbor-compatible Video-Arena benchmark, Protocol B (default) or A.
|
| 3 |
+
|
| 4 |
+
One Harbor task per case: 180 tasks in one dataset directory. See docs/HARBOR.md.
|
| 5 |
+
|
| 6 |
+
python tools/make_harbor.py --out harbor/video-arena [--protocol B|A]
|
| 7 |
+
[--net strict|docker|phase] [--base-image video-arena/base:latest]
|
| 8 |
+
[--games go,chess] [--cases 2] [--host-media /abs/media/root] [--force]
|
| 9 |
+
|
| 10 |
+
Each task:
|
| 11 |
+
task.toml Harbor task config (schema 1.4)
|
| 12 |
+
instruction.md B: the agent's prompt (200 turns / 7200 s), which points at the file below.
|
| 13 |
+
A: the A-rendered instruction itself; the Protocol A agent
|
| 14 |
+
(tools/harbor/protocol_a_agent.py) appends the frames and the single-reply
|
| 15 |
+
tail and makes the one request.
|
| 16 |
+
environment/ docker-compose.yaml -- prebuilt image, no network, the case's render (and,
|
| 17 |
+
for B, its instruction) mounted read-only into /app -- and, for B, that
|
| 18 |
+
instruction.md
|
| 19 |
+
tests/ test.sh, score_harbor.py, judge.py, gt.json, case.json (verifier only)
|
| 20 |
+
solution/ solve.sh, answer.json (GT projected onto the answer schema; oracle only)
|
| 21 |
+
|
| 22 |
+
Protocol A on Harbor: the model never sees the container. The agent samples the paper's grid
|
| 23 |
+
with ffmpeg INSIDE the offline sandbox, then sends the frames in one chat request from the host
|
| 24 |
+
and writes the extracted answer to /app/answer.json. Same verifier, same reward keys as B.
|
| 25 |
+
|
| 26 |
+
Deliberate separations
|
| 27 |
+
* Scoring never runs in the agent's container. /app/answer.json is the collected artifact;
|
| 28 |
+
a separate verifier container re-materializes it and runs the case judge there, so the
|
| 29 |
+
sandbox holds no ground truth, no judge and no solution.
|
| 30 |
+
* The dataset holds no video. Each compose file bind-mounts the render from
|
| 31 |
+
$VA_MEDIA_ROOT/<game>/media/<case_id>.mp4 on the Docker host, so the dataset stays small
|
| 32 |
+
(a few MB) and the 11.8 GB of renders are fetched once per host, not once per task.
|
| 33 |
+
* No network. The base image (tools/harbor/Dockerfile) pre-installs ffmpeg, Python and the
|
| 34 |
+
usual video/numeric libraries, and already holds the empty answer.json seed.
|
| 35 |
+
"""
|
| 36 |
+
|
| 37 |
+
import argparse
|
| 38 |
+
import json
|
| 39 |
+
import os
|
| 40 |
+
import shutil
|
| 41 |
+
import sys
|
| 42 |
+
|
| 43 |
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
| 44 |
+
sys.path.insert(0, HERE)
|
| 45 |
+
import va_core as C # noqa: E402
|
| 46 |
+
import score as S # noqa: E402 (oracle_answer)
|
| 47 |
+
|
| 48 |
+
DEFAULT_BASE_IMAGE = "video-arena/base:latest"
|
| 49 |
+
MEDIA_VAR = "${VA_MEDIA_ROOT}"
|
| 50 |
+
|
| 51 |
+
# --net: ([environment] line, [agent] line, Docker-level network_mode: none in the compose file)
|
| 52 |
+
# strict Harbor no-network for the whole trial, AND no network interface at the Docker level.
|
| 53 |
+
# For host-side agents (terminus-2, oracle). Needs Harbor's egress control, which
|
| 54 |
+
# probes the Docker host for nftables support and rejects no-network tasks without it.
|
| 55 |
+
# docker The same sandbox, offline through Docker alone; Harbor's own policy is left public.
|
| 56 |
+
# For Docker hosts where that probe fails.
|
| 57 |
+
# phase Network while an installed agent (claude-code, codex, ...) installs itself, then
|
| 58 |
+
# Harbor no-network for the run, opened to the model API only via
|
| 59 |
+
# `harbor run --allow-agent-host <host>`. Needs Harbor's egress control.
|
| 60 |
+
NET = {
|
| 61 |
+
"strict": ('network_mode = "no-network"', 'network_mode = "no-network"', True),
|
| 62 |
+
"docker": ('# offline via docker-compose.yaml (network_mode: none); Harbor policy stays public\n'
|
| 63 |
+
'network_mode = "public"', '# offline via docker-compose.yaml', True),
|
| 64 |
+
"phase": ('# public only for agent setup (install); the run itself is no-network\n'
|
| 65 |
+
'network_mode = "public"', 'network_mode = "no-network"', False),
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
TASK_TOML = """# Generated by tools/make_harbor.py -- do not edit; regenerate instead.
|
| 69 |
+
schema_version = "1.4"
|
| 70 |
+
artifacts = ["/app/answer.json"]
|
| 71 |
+
|
| 72 |
+
[task]
|
| 73 |
+
name = "video-arena/{name}"
|
| 74 |
+
version = "1.0.0"
|
| 75 |
+
description = "{desc}"
|
| 76 |
+
keywords = {keywords}
|
| 77 |
+
|
| 78 |
+
[metadata]
|
| 79 |
+
game = "{game}"
|
| 80 |
+
case_id = "{cid}"
|
| 81 |
+
family = "{family}"
|
| 82 |
+
regime = "{regime}"
|
| 83 |
+
root_key = "{root_key}"
|
| 84 |
+
tol = {tol}
|
| 85 |
+
protocol = "{protocol}"
|
| 86 |
+
answer = "/app/answer.json"
|
| 87 |
+
video = "{media}"
|
| 88 |
+
{extra}
|
| 89 |
+
[agent]
|
| 90 |
+
{agent_budget}
|
| 91 |
+
# the image's unprivileged user (tools/harbor/Dockerfile); the verifier runs as root
|
| 92 |
+
user = "agent"
|
| 93 |
+
{agent_net}
|
| 94 |
+
|
| 95 |
+
[verifier]
|
| 96 |
+
environment_mode = "separate"
|
| 97 |
+
timeout_sec = 600.0
|
| 98 |
+
|
| 99 |
+
[environment]
|
| 100 |
+
docker_image = "{base_image}"
|
| 101 |
+
workdir = "/app"
|
| 102 |
+
{env_net}
|
| 103 |
+
cpus = 4
|
| 104 |
+
memory_mb = 8192
|
| 105 |
+
|
| 106 |
+
[solution]
|
| 107 |
+
env = {{}}
|
| 108 |
+
"""
|
| 109 |
+
|
| 110 |
+
# Per protocol: the [agent] budget, the description, and whether the sandbox gets the
|
| 111 |
+
# instruction file (under A the model never sees the sandbox; the prompt is instruction.md).
|
| 112 |
+
AGENT_BUDGET = {
|
| 113 |
+
"B": "# Protocol B: at most 200 tool-call turns inside a 7200 s hard wall clock.\n"
|
| 114 |
+
"timeout_sec = 7200.0",
|
| 115 |
+
"A": "# Protocol A: one request, no tools; frame sampling plus that one call.\n"
|
| 116 |
+
"timeout_sec = 3600.0",
|
| 117 |
+
}
|
| 118 |
+
DESC = {
|
| 119 |
+
"B": "Video-Arena Protocol B case %s/%s: watch the replay and infer event times, "
|
| 120 |
+
"outcomes and impact tiers from the video alone.",
|
| 121 |
+
"A": "Video-Arena Protocol A case %s/%s: one request with the sampled frames and no "
|
| 122 |
+
"tools; infer event times, outcomes and impact tiers from the frames alone.",
|
| 123 |
+
}
|
| 124 |
+
INSTRUCTION_MOUNT = """ - type: bind
|
| 125 |
+
source: ./instruction.md
|
| 126 |
+
target: /app/instruction.md
|
| 127 |
+
read_only: true
|
| 128 |
+
"""
|
| 129 |
+
|
| 130 |
+
COMPOSE_TOML = """# Generated by tools/make_harbor.py -- do not edit.
|
| 131 |
+
#
|
| 132 |
+
# The prebuilt image is the sandbox and already holds the empty /app/answer.json seed; this file
|
| 133 |
+
# only mounts the case's read-only inputs into /app. With --net strict or docker it also
|
| 134 |
+
# sets network_mode: none: Docker gives the sandbox no interface but loopback, and a service
|
| 135 |
+
# that declares its own networking is left out of Harbor's egress-control sidecar. In strict
|
| 136 |
+
# mode Harbor's no-network policy applies on top.
|
| 137 |
+
services:
|
| 138 |
+
main:
|
| 139 |
+
{net_line} working_dir: /app
|
| 140 |
+
# Long syntax on purpose: a missing source fails the start instead of Docker silently
|
| 141 |
+
# creating an empty directory where the file should be.
|
| 142 |
+
volumes:
|
| 143 |
+
{instruction_mount} - type: bind
|
| 144 |
+
source: {media_src}
|
| 145 |
+
target: /app/match.mp4
|
| 146 |
+
read_only: true
|
| 147 |
+
"""
|
| 148 |
+
|
| 149 |
+
TEST_SH = """#!/bin/bash
|
| 150 |
+
# Verifier entrypoint: score the agent's answer.json, then hand Harbor /logs/verifier/reward.json.
|
| 151 |
+
set -euo pipefail
|
| 152 |
+
mkdir -p /logs/verifier
|
| 153 |
+
python3 /tests/score_harbor.py
|
| 154 |
+
"""
|
| 155 |
+
|
| 156 |
+
SOLVE_SH = """#!/bin/bash
|
| 157 |
+
set -euo pipefail
|
| 158 |
+
# Oracle reference: the ground truth projected onto the answer schema (tools/score.py).
|
| 159 |
+
cp /solution/answer.json /app/answer.json
|
| 160 |
+
echo "wrote /app/answer.json"
|
| 161 |
+
"""
|
| 162 |
+
|
| 163 |
+
SCORE_PY = '''#!/usr/bin/env python3
|
| 164 |
+
"""Score the agent's /app/answer.json with this case judge; write /logs/verifier/reward.json.
|
| 165 |
+
|
| 166 |
+
Runs in the VERIFIER container, never in the sandbox: the judge and the ground truth are
|
| 167 |
+
uploaded here for scoring and are absent from the agent container.
|
| 168 |
+
|
| 169 |
+
Reward keys follow the public Video-Arena scorer (tools/score.py):
|
| 170 |
+
|
| 171 |
+
reward the case headline reward (judge reward.reward)
|
| 172 |
+
t1_f1 T1 localization F1
|
| 173 |
+
t2_macro_acc T2 macro accuracy
|
| 174 |
+
t3_macro_acc T3 macro accuracy
|
| 175 |
+
|
| 176 |
+
Any tier the judge did not report is recorded as 0.0: Harbor accepts only finite numbers, and a
|
| 177 |
+
tier the judge declined to score is a tier the answer earned nothing on.
|
| 178 |
+
|
| 179 |
+
A missing or unparseable /app/answer.json is not an exception. It is scored as the pre-seeded
|
| 180 |
+
empty answer -- reward 0.0, every tier 0.0 -- which covers the run that died before writing
|
| 181 |
+
anything, the artifact upload that failed, and the wiped sandbox alike. Those must grade zero
|
| 182 |
+
rather than surface as a harness error. A judge that cannot run at all is a real harness error
|
| 183 |
+
and is graded zero loudly, on stderr, in the verifier log.
|
| 184 |
+
"""
|
| 185 |
+
|
| 186 |
+
import json
|
| 187 |
+
import os
|
| 188 |
+
import subprocess
|
| 189 |
+
import sys
|
| 190 |
+
|
| 191 |
+
TESTS = os.path.dirname(os.path.abspath(__file__))
|
| 192 |
+
ANSWER = "/app/answer.json"
|
| 193 |
+
GT = os.path.join(TESTS, "gt.json")
|
| 194 |
+
JUDGE = os.path.join(TESTS, "judge.py")
|
| 195 |
+
OUT = "/logs/verifier/reward.json"
|
| 196 |
+
TOL = float(os.environ.get("VA_TOL", {tol!r}))
|
| 197 |
+
PRIMARY = {primary!r}
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
def load_answer():
|
| 201 |
+
"""The agent answer, or the pre-seeded empty answer when there is nothing scoreable."""
|
| 202 |
+
try:
|
| 203 |
+
with open(ANSWER, encoding="utf-8") as fh:
|
| 204 |
+
doc = json.load(fh)
|
| 205 |
+
if isinstance(doc, dict):
|
| 206 |
+
return doc
|
| 207 |
+
sys.stderr.write("answer.json is %s, not an object; scoring it as empty\\n"
|
| 208 |
+
% type(doc).__name__)
|
| 209 |
+
except Exception as exc:
|
| 210 |
+
sys.stderr.write("answer.json unreadable (%s); scoring it as empty\\n" % exc)
|
| 211 |
+
return {{"{root_key}": []}}
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
def judge(answer_doc):
|
| 215 |
+
"""Run the case judge exactly as its CLI documents; None if the judge itself failed."""
|
| 216 |
+
staged = "/logs/verifier/answer.scored.json"
|
| 217 |
+
with open(staged, "w", encoding="utf-8") as fh:
|
| 218 |
+
json.dump(answer_doc, fh)
|
| 219 |
+
cmd = [sys.executable, JUDGE, "--answer", staged, "--gt", GT,
|
| 220 |
+
"--out", "/logs/verifier/judge.json", "--tol", str(TOL)]
|
| 221 |
+
if PRIMARY:
|
| 222 |
+
cmd += ["--primary", PRIMARY]
|
| 223 |
+
proc = subprocess.run(cmd, capture_output=True, text=True, encoding="utf-8",
|
| 224 |
+
errors="replace")
|
| 225 |
+
if proc.returncode != 0:
|
| 226 |
+
sys.stderr.write("judge exited %s\\n%s\\n" % (proc.returncode, proc.stderr[-4000:]))
|
| 227 |
+
return None
|
| 228 |
+
with open("/logs/verifier/judge.json", encoding="utf-8") as fh:
|
| 229 |
+
return json.load(fh)
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
def subscores(reward):
|
| 233 |
+
"""The four published numbers, mirroring tools/score.py:subscores (no va_core here).
|
| 234 |
+
The two judge families put the tier block in different places."""
|
| 235 |
+
t = reward.get("tiers")
|
| 236 |
+
if t:
|
| 237 |
+
t3 = t.get("t3_situation") or t.get("t3_score") or {{}}
|
| 238 |
+
t3v = t3.get("macro_acc")
|
| 239 |
+
if t3v is None:
|
| 240 |
+
t3v = t3.get("exact_pair_acc")
|
| 241 |
+
return {{"reward": reward.get("reward"),
|
| 242 |
+
"t1_f1": (t.get("t1_localization") or {{}}).get("f1"),
|
| 243 |
+
"t2_macro_acc": (t.get("t2_impact") or {{}}).get("macro_acc"),
|
| 244 |
+
"t3_macro_acc": t3v}}
|
| 245 |
+
d = reward.get("detail", {{}})
|
| 246 |
+
t2 = d.get("t2_round_winner") or d.get("t2_minute_gain_event") or d.get("t2_impact") or {{}}
|
| 247 |
+
t3 = (d.get("t3_score_track") or d.get("t3_leader_after_event")
|
| 248 |
+
or d.get("t3_situation") or {{}})
|
| 249 |
+
t3v = t3.get("exact_frac")
|
| 250 |
+
if t3v is None:
|
| 251 |
+
t3v = t3.get("macro_acc")
|
| 252 |
+
return {{"reward": reward.get("reward"),
|
| 253 |
+
"t1_f1": (d.get("t1_localization") or {{}}).get("f1"),
|
| 254 |
+
"t2_macro_acc": t2.get("macro_acc"),
|
| 255 |
+
"t3_macro_acc": t3v}}
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
def main():
|
| 259 |
+
os.makedirs(os.path.dirname(OUT), exist_ok=True)
|
| 260 |
+
reward = judge(load_answer())
|
| 261 |
+
scores = {{"reward": 0.0, "t1_f1": 0.0, "t2_macro_acc": 0.0, "t3_macro_acc": 0.0}}
|
| 262 |
+
if reward is not None:
|
| 263 |
+
for key, value in subscores(reward).items():
|
| 264 |
+
if isinstance(value, bool) or not isinstance(value, (int, float)):
|
| 265 |
+
value = 0.0
|
| 266 |
+
scores[key] = float(value)
|
| 267 |
+
with open(OUT, "w", encoding="utf-8") as fh:
|
| 268 |
+
json.dump(scores, fh, indent=2, sort_keys=True)
|
| 269 |
+
fh.write("\\n")
|
| 270 |
+
print(json.dumps(scores, sort_keys=True))
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
if __name__ == "__main__":
|
| 274 |
+
main()
|
| 275 |
+
'''
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
# Build-time diagnostics in CASE_TYPES.json that stay out of the published task metadata.
|
| 279 |
+
_META_SKIP = {"id", "case_id", "features", "t3_classes", "t2_classes", "zone_counts",
|
| 280 |
+
"hud_audit", "result", "type_zh", "winner"}
|
| 281 |
+
|
| 282 |
+
|
| 283 |
+
def meta_extra(extra):
|
| 284 |
+
"""The case's own tags from CASE_TYPES.json as [metadata] lines. Only short scalar fields
|
| 285 |
+
ride along; the long derived dictionaries are build diagnostics, not task metadata."""
|
| 286 |
+
out = []
|
| 287 |
+
for key in sorted(extra):
|
| 288 |
+
value = extra[key]
|
| 289 |
+
if key in _META_SKIP or isinstance(value, (dict, list)):
|
| 290 |
+
continue
|
| 291 |
+
if isinstance(value, bool) or not isinstance(value, (int, float)):
|
| 292 |
+
value = str(value)
|
| 293 |
+
out.append("%s = %s\n" % (key, json.dumps(value, ensure_ascii=False)))
|
| 294 |
+
return "".join(out)
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
def write(path, text, mode=None):
|
| 298 |
+
with open(path, "w", encoding="utf-8", newline="\n") as fh:
|
| 299 |
+
fh.write(text)
|
| 300 |
+
if mode is not None:
|
| 301 |
+
os.chmod(path, mode)
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
def build_task(game, cid, out_dir, args):
|
| 305 |
+
meta = C.resolve(game, cid)
|
| 306 |
+
with open(meta["gt"], encoding="utf-8") as fh:
|
| 307 |
+
gt = json.load(fh)
|
| 308 |
+
answer = S.oracle_answer(game, gt)
|
| 309 |
+
# The oracle answer must be a PROJECTION of the ground truth: every key it carries comes
|
| 310 |
+
# from the GT (dota2's schema has two optional dense blocks beyond the event list), and the
|
| 311 |
+
# event list survives the projection whole.
|
| 312 |
+
bad = [k for k in answer if k not in gt]
|
| 313 |
+
if bad:
|
| 314 |
+
raise SystemExit("%s/%s: oracle answer invents keys not in GT: %s" % (game, cid, bad))
|
| 315 |
+
if len(answer[meta["root_key"]]) != len(gt[meta["root_key"]]):
|
| 316 |
+
raise SystemExit("%s/%s: oracle event count differs from GT" % (game, cid))
|
| 317 |
+
|
| 318 |
+
name = "%s-%s" % (game, cid)
|
| 319 |
+
task_dir = os.path.join(out_dir, name)
|
| 320 |
+
tests = os.path.join(task_dir, "tests")
|
| 321 |
+
env_dir = os.path.join(task_dir, "environment")
|
| 322 |
+
sol_dir = os.path.join(task_dir, "solution")
|
| 323 |
+
for d in (tests, env_dir, sol_dir):
|
| 324 |
+
os.makedirs(d, exist_ok=True)
|
| 325 |
+
|
| 326 |
+
video = "%s/%s/media/%s.mp4" % (args.host_media or MEDIA_VAR, game, cid)
|
| 327 |
+
proto = args.protocol
|
| 328 |
+
|
| 329 |
+
write(os.path.join(task_dir, "task.toml"), TASK_TOML.format(
|
| 330 |
+
name=name, desc=DESC[proto] % (game, cid), game=game, cid=cid,
|
| 331 |
+
family=meta["family"], protocol=proto, agent_budget=AGENT_BUDGET[proto],
|
| 332 |
+
regime=C.REGIME[game], root_key=meta["root_key"], tol=meta["tol"], media=video,
|
| 333 |
+
extra=meta_extra(C.case_meta(game).get(cid, {})), base_image=args.base_image,
|
| 334 |
+
env_net=NET[args.net][0], agent_net=NET[args.net][1],
|
| 335 |
+
keywords=json.dumps(["video-arena", "video-understanding", game, C.REGIME[game],
|
| 336 |
+
"protocol-" + proto.lower()])))
|
| 337 |
+
write(os.path.join(env_dir, "docker-compose.yaml"), COMPOSE_TOML.format(
|
| 338 |
+
net_line=" network_mode: none\n" if NET[args.net][2] else "",
|
| 339 |
+
instruction_mount=INSTRUCTION_MOUNT if proto == "B" else "",
|
| 340 |
+
media_src=video if args.host_media
|
| 341 |
+
else "${VA_MEDIA_ROOT:?set VA_MEDIA_ROOT to the Video-Arena tasks directory}"
|
| 342 |
+
"/%s/media/%s.mp4" % (game, cid)))
|
| 343 |
+
# LF only: some instruction sources carry stray CRLF, which is noise inside a Linux sandbox.
|
| 344 |
+
if proto == "B":
|
| 345 |
+
write(os.path.join(task_dir, "instruction.md"), C.build_harbor_prompt())
|
| 346 |
+
write(os.path.join(env_dir, "instruction.md"),
|
| 347 |
+
C.instruction_for("agentic", meta["instruction"]).replace("\r\n", "\n"))
|
| 348 |
+
else:
|
| 349 |
+
write(os.path.join(task_dir, "instruction.md"),
|
| 350 |
+
C.instruction_for("video", meta["instruction"]).replace("\r\n", "\n"))
|
| 351 |
+
write(os.path.join(tests, "test.sh"), TEST_SH, mode=0o755)
|
| 352 |
+
write(os.path.join(tests, "score_harbor.py"), SCORE_PY.format(
|
| 353 |
+
tol=meta["tol"], primary=meta["primary"], root_key=meta["root_key"]))
|
| 354 |
+
shutil.copyfile(meta["judge"], os.path.join(tests, "judge.py"))
|
| 355 |
+
shutil.copyfile(meta["gt"], os.path.join(tests, "gt.json"))
|
| 356 |
+
write(os.path.join(tests, "case.json"), json.dumps(
|
| 357 |
+
{"game": game, "case_id": cid, "family": meta["family"],
|
| 358 |
+
"root_key": meta["root_key"], "tol": meta["tol"]}, indent=2) + "\n")
|
| 359 |
+
write(os.path.join(sol_dir, "solve.sh"), SOLVE_SH, mode=0o755)
|
| 360 |
+
write(os.path.join(sol_dir, "answer.json"), json.dumps(answer, indent=2) + "\n")
|
| 361 |
+
return name
|
| 362 |
+
|
| 363 |
+
|
| 364 |
+
def main():
|
| 365 |
+
ap = argparse.ArgumentParser(description="Generate the Harbor Video-Arena dataset.")
|
| 366 |
+
ap.add_argument("--out", required=True, help="dataset directory to (re)generate")
|
| 367 |
+
ap.add_argument("--games", default=",".join(C.GAMES),
|
| 368 |
+
help="comma-separated subset of: %s" % ",".join(C.GAMES))
|
| 369 |
+
ap.add_argument("--cases", type=int, default=0,
|
| 370 |
+
help="first N cases per game (0 = all 20)")
|
| 371 |
+
ap.add_argument("--protocol", choices=("B", "A"), default="B",
|
| 372 |
+
help="B (default): the agentic sandbox task. A: the single-request task, "
|
| 373 |
+
"run with -a protocol_a_agent:ProtocolA (see docs/HARBOR.md)")
|
| 374 |
+
ap.add_argument("--base-image", default=DEFAULT_BASE_IMAGE,
|
| 375 |
+
help="prebuilt sandbox/verifier image (tools/harbor/Dockerfile)")
|
| 376 |
+
ap.add_argument("--net", choices=sorted(NET), default="strict",
|
| 377 |
+
help="strict (default): offline for the whole trial, enforced by Harbor and "
|
| 378 |
+
"by Docker, for host-side agents such as terminus-2. docker: the same "
|
| 379 |
+
"sandbox enforced by Docker alone, for hosts where Harbor's "
|
| 380 |
+
"egress-control probe fails. phase: network only while an installed "
|
| 381 |
+
"agent installs itself; run with --allow-agent-host <model API host>.")
|
| 382 |
+
ap.add_argument("--host-media", default=None, metavar="DIR",
|
| 383 |
+
help="absolute host directory to pin in the generated compose files "
|
| 384 |
+
"(default: the literal ${VA_MEDIA_ROOT}, resolved at run time)")
|
| 385 |
+
ap.add_argument("--force", action="store_true",
|
| 386 |
+
help="delete --out first (it may hold tasks from a previous run)")
|
| 387 |
+
args = ap.parse_args()
|
| 388 |
+
|
| 389 |
+
games = [g for g in args.games.split(",") if g]
|
| 390 |
+
unknown = [g for g in games if g not in C.GAMES]
|
| 391 |
+
if unknown:
|
| 392 |
+
raise SystemExit("unknown game(s): %s" % unknown)
|
| 393 |
+
out_dir = os.path.abspath(args.out)
|
| 394 |
+
if os.path.exists(out_dir):
|
| 395 |
+
if not args.force:
|
| 396 |
+
raise SystemExit("%s exists; pass --force to regenerate it" % out_dir)
|
| 397 |
+
shutil.rmtree(out_dir)
|
| 398 |
+
os.makedirs(out_dir)
|
| 399 |
+
|
| 400 |
+
made = []
|
| 401 |
+
for game in games:
|
| 402 |
+
ids = C.case_ids(game)
|
| 403 |
+
for cid in ids[:args.cases] if args.cases else ids:
|
| 404 |
+
made.append(build_task(game, cid, out_dir, args))
|
| 405 |
+
|
| 406 |
+
print("%d Protocol %s tasks -> %s" % (len(made), args.protocol, out_dir))
|
| 407 |
+
print("image: %s net: %s" % (args.base_image, args.net))
|
| 408 |
+
print("media: %s/<game>/media/<case_id>.mp4, mounted read-only at /app/match.mp4"
|
| 409 |
+
% (args.host_media or "$VA_MEDIA_ROOT"))
|
| 410 |
+
|
| 411 |
+
|
| 412 |
+
if __name__ == "__main__":
|
| 413 |
+
main()
|
tools/run_protocol_a.py
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
"""run_protocol_a.py -- minimal Protocol A (video understanding) reference runner.
|
| 4 |
+
|
| 5 |
+
Protocol A is ONE chat call. The video is reduced to a uniform grid of JPEG frames, the
|
| 6 |
+
frames and the instruction go into a single user turn, and the model's reply must contain
|
| 7 |
+
one JSON object. No tools, no filesystem, no second turn.
|
| 8 |
+
|
| 9 |
+
export VA_API_KEY=... # or --api-key
|
| 10 |
+
python tools/run_protocol_a.py --model gpt-5.6 --base-url https://api.example.com/v1 \
|
| 11 |
+
--game chess --case all --out runs/gpt56-A --reasoning-effort high
|
| 12 |
+
python tools/score.py --answers runs/gpt56-A/answers
|
| 13 |
+
|
| 14 |
+
Requires: ffmpeg + ffprobe on PATH (frame sampling), and an OpenAI-compatible
|
| 15 |
+
/chat/completions endpoint that accepts image_url parts. Nothing else -- the HTTP call is
|
| 16 |
+
urllib, so there is no SDK to pin.
|
| 17 |
+
|
| 18 |
+
This is a REFERENCE implementation: it shows the measurement, not our production harness.
|
| 19 |
+
It has no retry policy, no rate limiting and no cost accounting; --workers runs cells
|
| 20 |
+
concurrently (the paper uses 5 per system for Protocol A). What it
|
| 21 |
+
does have is the part that must not vary between systems -- the sampling grid, the single
|
| 22 |
+
turn, and the answer extraction -- because those are the benchmark, and a driver that
|
| 23 |
+
changes them is measuring something else.
|
| 24 |
+
|
| 25 |
+
THE SAMPLING GRID (one grid, every model, every game):
|
| 26 |
+
1 FPS, capped at 256 frames spread uniformly over the whole match, longest side
|
| 27 |
+
768px, never upscaled.
|
| 28 |
+
|
| 29 |
+
1 FPS because the board or map is idle most of the time (denser sampling returns
|
| 30 |
+
duplicate stills); one shared cap so every row of a results table is the same
|
| 31 |
+
measurement. Where a provider's image limit is below 256, degrade and RECORD it
|
| 32 |
+
(run.json carries n_frames). Where its request-size cap is the binding limit (256 busy
|
| 33 |
+
frames at -q:v 4 can exceed 30 MB once base64-encoded), raise --jpeg-q instead and keep
|
| 34 |
+
the 256 frames; run.json carries sampling.jpeg_q. No upscaling: several boards render
|
| 35 |
+
below 768px (go 612, chess 548, gomoku 504).
|
| 36 |
+
|
| 37 |
+
THE PROMPT is va_core.protocol_a_prompt(): the A-rendered instruction, then the paper's
|
| 38 |
+
single-reply tail, which hands over the grid's explicit video_ts array. The Harbor agent
|
| 39 |
+
(tools/harbor/protocol_a_agent.py) builds it with the same function, on the same grid.
|
| 40 |
+
|
| 41 |
+
On a long match the grid itself caps T1 recall at min(1, 2*TOL/spacing), independent of the
|
| 42 |
+
model; run.json carries t1_recall_ceiling for every cell.
|
| 43 |
+
|
| 44 |
+
WHAT A CELL EXPORTS. A reply that arrived but holds no answer object (empty, prose only, or
|
| 45 |
+
cut off before the object closed) is the model's result: the empty answer seed is exported
|
| 46 |
+
for it, so it scores 0.0 and stays in the mean, with status "no_answer" in run.json. A call
|
| 47 |
+
that never produced a reply (ffmpeg, HTTP, timeout) exports nothing and stays missing -- it
|
| 48 |
+
measured the endpoint, not the model. A re-run of a cell first deletes the answer, run.json
|
| 49 |
+
and reply an earlier run left, so a failed re-run is never scored on its predecessor.
|
| 50 |
+
"""
|
| 51 |
+
import argparse
|
| 52 |
+
import base64
|
| 53 |
+
import json
|
| 54 |
+
import os
|
| 55 |
+
import shutil
|
| 56 |
+
import subprocess
|
| 57 |
+
import sys
|
| 58 |
+
import tempfile
|
| 59 |
+
import threading
|
| 60 |
+
import time
|
| 61 |
+
import urllib.error
|
| 62 |
+
from concurrent.futures import ThreadPoolExecutor
|
| 63 |
+
import urllib.request
|
| 64 |
+
|
| 65 |
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 66 |
+
import va_core as C # noqa: E402
|
| 67 |
+
|
| 68 |
+
TARGET_FPS = 1.0
|
| 69 |
+
MAX_FRAMES = 256
|
| 70 |
+
MAX_WIDTH = 768
|
| 71 |
+
JPEG_Q = 4 # ffmpeg -q:v, 2 (best) .. 31 (worst)
|
| 72 |
+
|
| 73 |
+
FFMPEG = os.environ.get("VA_FFMPEG", "ffmpeg")
|
| 74 |
+
FFPROBE = os.environ.get("VA_FFPROBE", "ffprobe")
|
| 75 |
+
|
| 76 |
+
# The grid helpers below are pure argument builders where possible: the Harbor agent runs the
|
| 77 |
+
# same ffprobe/ffmpeg commands inside the task container, so both paths sample identically.
|
| 78 |
+
def probe_args(path, entries, ffprobe=FFPROBE):
|
| 79 |
+
return [ffprobe, "-v", "error", "-select_streams", "v:0", "-show_entries", entries,
|
| 80 |
+
"-of", "csv=p=0", path]
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
def probe(path, entries):
|
| 84 |
+
out = subprocess.check_output(probe_args(path, entries), text=True).strip()
|
| 85 |
+
return out.splitlines()[0] if out else ""
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def video_duration(path):
|
| 89 |
+
return float(probe(path, "format=duration").strip() or 0.0)
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
def parse_rate(rate):
|
| 93 |
+
"""ffprobe's r_frame_rate ("30000/1001") as a float; 0.0 when unreadable."""
|
| 94 |
+
num, _, den = rate.strip().partition("/")
|
| 95 |
+
try:
|
| 96 |
+
d = float(den) if den else 1.0
|
| 97 |
+
return float(num) / d if d else 0.0
|
| 98 |
+
except ValueError:
|
| 99 |
+
return 0.0
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def video_fps(path):
|
| 103 |
+
return parse_rate(probe(path, "stream=r_frame_rate"))
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
def grid_fps(dur, native_fps, max_frames=MAX_FRAMES):
|
| 107 |
+
"""The grid's rate: min(TARGET_FPS, max_frames/duration), additionally bounded by the
|
| 108 |
+
container rate, so ffmpeg is never asked to fabricate frames a source does not present
|
| 109 |
+
(chess renders natively at 1 FPS)."""
|
| 110 |
+
fps = min(TARGET_FPS, max_frames / dur) if dur > 0 else TARGET_FPS
|
| 111 |
+
if native_fps and fps > native_fps:
|
| 112 |
+
fps = native_fps
|
| 113 |
+
return fps
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
def ffmpeg_args(video, pattern, fps, ffmpeg=FFMPEG, jpeg_q=JPEG_Q):
|
| 117 |
+
vf = "fps=%.6f,scale='min(%d,iw)':-1" % (fps, MAX_WIDTH)
|
| 118 |
+
return [ffmpeg, "-y", "-loglevel", "error", "-i", video, "-vf", vf,
|
| 119 |
+
"-q:v", str(jpeg_q), pattern]
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
def grid_ts(n, fps):
|
| 123 |
+
"""video_ts of the n kept frames: frame k is at k / fps."""
|
| 124 |
+
return [round(i / fps, 2) for i in range(n)]
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
def sample_frames(video, out_dir, max_frames=MAX_FRAMES, jpeg_q=JPEG_Q):
|
| 128 |
+
"""Uniform grid -> (paths, timestamps, fps, duration). See the module docstring for the
|
| 129 |
+
policy. The hard clamp after extraction is not redundant: ffmpeg's fps filter overshoots
|
| 130 |
+
by a frame or two on rounding, and providers enforce their image cap inclusively.
|
| 131 |
+
"""
|
| 132 |
+
os.makedirs(out_dir, exist_ok=True)
|
| 133 |
+
dur = video_duration(video)
|
| 134 |
+
fps = grid_fps(dur, video_fps(video), max_frames)
|
| 135 |
+
subprocess.run(ffmpeg_args(video, os.path.join(out_dir, "f_%05d.jpg"), fps,
|
| 136 |
+
jpeg_q=jpeg_q), check=True)
|
| 137 |
+
paths = [os.path.join(out_dir, f) for f in sorted(os.listdir(out_dir))
|
| 138 |
+
if f.startswith("f_") and f.endswith(".jpg")]
|
| 139 |
+
if len(paths) > max_frames:
|
| 140 |
+
paths = paths[:max_frames]
|
| 141 |
+
return paths, grid_ts(len(paths), fps), fps, dur
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
def data_uri(path):
|
| 145 |
+
with open(path, "rb") as fh:
|
| 146 |
+
return "data:image/jpeg;base64," + base64.b64encode(fh.read()).decode()
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def chat(base_url, api_key, model, text, frame_paths, max_tokens, temperature, timeout,
|
| 150 |
+
reasoning_effort=None, extra_body=None):
|
| 151 |
+
"""One OpenAI-compatible /chat/completions call. Returns (reply_text, usage_dict).
|
| 152 |
+
extra_body is merged into the request as-is (e.g. a vLLM server's chat_template_kwargs)."""
|
| 153 |
+
content = [{"type": "text", "text": text}]
|
| 154 |
+
for p in frame_paths:
|
| 155 |
+
content.append({"type": "image_url", "image_url": {"url": data_uri(p)}})
|
| 156 |
+
req = {"model": model, "messages": [{"role": "user", "content": content}],
|
| 157 |
+
"max_tokens": max_tokens, "temperature": temperature}
|
| 158 |
+
if reasoning_effort:
|
| 159 |
+
req["reasoning_effort"] = reasoning_effort
|
| 160 |
+
req.update(extra_body or {})
|
| 161 |
+
body = json.dumps(req).encode()
|
| 162 |
+
req = urllib.request.Request(
|
| 163 |
+
base_url.rstrip("/") + "/chat/completions", data=body,
|
| 164 |
+
headers={"Content-Type": "application/json", "Authorization": "Bearer " + api_key})
|
| 165 |
+
try:
|
| 166 |
+
with urllib.request.urlopen(req, timeout=timeout) as resp:
|
| 167 |
+
out = json.loads(resp.read().decode("utf-8", "replace"))
|
| 168 |
+
except urllib.error.HTTPError as e: # keep the provider's reason, not just the code
|
| 169 |
+
raise RuntimeError("HTTP %s from the endpoint (request %.1f MB): %s"
|
| 170 |
+
% (e.code, len(body) / 1e6,
|
| 171 |
+
e.read()[:300].decode("utf-8", "replace"))) from None
|
| 172 |
+
choice = (out.get("choices") or [{}])[0]
|
| 173 |
+
return (choice.get("message") or {}).get("content") or "", {
|
| 174 |
+
"usage": out.get("usage"), "finish_reason": choice.get("finish_reason")}
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
PRINT_LOCK = threading.Lock()
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
def run_cell(a, g, cid):
|
| 181 |
+
"""One cell: sample, ask, extract, export. Never raises for a model or endpoint failure;
|
| 182 |
+
run.json records it."""
|
| 183 |
+
r = C.resolve(g, cid)
|
| 184 |
+
cell = os.path.join(a.out, "cells", g, cid)
|
| 185 |
+
dst = os.path.join(a.out, "answers", g, cid + ".json")
|
| 186 |
+
# nothing an earlier run of this cell left may be read as this run's result
|
| 187 |
+
for p in (dst, os.path.join(cell, "run.json"), os.path.join(cell, "reply.txt")):
|
| 188 |
+
if os.path.isfile(p):
|
| 189 |
+
os.remove(p)
|
| 190 |
+
os.makedirs(cell, exist_ok=True)
|
| 191 |
+
os.makedirs(os.path.dirname(dst), exist_ok=True)
|
| 192 |
+
fdir = os.path.join(cell, "frames") if a.keep_frames \
|
| 193 |
+
else tempfile.mkdtemp(prefix="va_frames_")
|
| 194 |
+
t0 = time.time()
|
| 195 |
+
rec = {"protocol": "A", "game": g, "case_id": cid, "model": a.model,
|
| 196 |
+
"root_key": r["root_key"], "tol_s": C.TOL,
|
| 197 |
+
"sampling": {"target_fps": TARGET_FPS, "max_frames": a.max_frames,
|
| 198 |
+
"max_width": MAX_WIDTH, "jpeg_q": a.jpeg_q},
|
| 199 |
+
"max_tokens": a.max_tokens, "temperature": a.temperature,
|
| 200 |
+
"reasoning_effort": a.reasoning_effort, "extra_body": a.extra_body}
|
| 201 |
+
try:
|
| 202 |
+
paths, ts, fps, dur = sample_frames(r["video"], fdir, a.max_frames, a.jpeg_q)
|
| 203 |
+
rec.update(n_frames=len(paths), fps=round(fps, 6), duration_s=round(dur, 2),
|
| 204 |
+
t1_recall_ceiling=round(C.t1_recall_ceiling(dur, len(paths)), 4))
|
| 205 |
+
prompt = C.protocol_a_prompt(C.instruction_for("video", r["instruction"]),
|
| 206 |
+
dur, ts, fps, r["root_key"])
|
| 207 |
+
reply, meta = chat(a.base_url, a.api_key, a.model, prompt, paths,
|
| 208 |
+
a.max_tokens, a.temperature, a.timeout,
|
| 209 |
+
a.reasoning_effort, a.extra_body)
|
| 210 |
+
rec.update(meta)
|
| 211 |
+
with open(os.path.join(cell, "reply.txt"), "w", encoding="utf-8") as fh:
|
| 212 |
+
fh.write(reply)
|
| 213 |
+
cands = C.answer_candidates(reply, r["root_key"])
|
| 214 |
+
rec["n_json_blocks"] = len(cands)
|
| 215 |
+
try:
|
| 216 |
+
obj = C.extract_answer(reply, r["root_key"])
|
| 217 |
+
except ValueError as e:
|
| 218 |
+
# The model replied without an answer object: its result, scored 0.0
|
| 219 |
+
# via the empty seed -- not a missing cell.
|
| 220 |
+
shutil.copyfile(r["answer_seed"], dst)
|
| 221 |
+
rec.update(status="no_answer", n_rows=0, answer_exported="seed",
|
| 222 |
+
error="%s: %s" % (type(e).__name__, str(e)[:400]))
|
| 223 |
+
else:
|
| 224 |
+
rows = obj.get(r["root_key"])
|
| 225 |
+
rec["n_rows"] = len(rows) if isinstance(rows, list) else 0
|
| 226 |
+
with open(dst, "w", encoding="utf-8") as fh:
|
| 227 |
+
json.dump(obj, fh, ensure_ascii=False)
|
| 228 |
+
rec.update(status="ok", answer_exported="reply")
|
| 229 |
+
except Exception as e:
|
| 230 |
+
# Record WHY, per cell. A bare 0.0 cannot be told apart from a refusal, a
|
| 231 |
+
# truncation, or a model that answered in prose -- and those call for
|
| 232 |
+
# different fixes.
|
| 233 |
+
rec["status"] = "error"
|
| 234 |
+
rec["error"] = "%s: %s" % (type(e).__name__, str(e)[:400])
|
| 235 |
+
finally:
|
| 236 |
+
if not a.keep_frames:
|
| 237 |
+
shutil.rmtree(fdir, ignore_errors=True)
|
| 238 |
+
rec["wall_s"] = round(time.time() - t0, 1)
|
| 239 |
+
with open(os.path.join(cell, "run.json"), "w", encoding="utf-8") as fh:
|
| 240 |
+
json.dump(rec, fh, ensure_ascii=False, indent=2)
|
| 241 |
+
with PRINT_LOCK:
|
| 242 |
+
print("%-10s %-38s %-9s n_frames=%s n_rows=%s %s"
|
| 243 |
+
% (g, cid, rec["status"], rec.get("n_frames"), rec.get("n_rows"),
|
| 244 |
+
rec.get("error", "")), flush=True)
|
| 245 |
+
return rec
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
def main():
|
| 249 |
+
ap = argparse.ArgumentParser(description=__doc__,
|
| 250 |
+
formatter_class=argparse.RawDescriptionHelpFormatter)
|
| 251 |
+
ap.add_argument("--model", required=True, help="model id the endpoint expects")
|
| 252 |
+
ap.add_argument("--base-url", required=True, help="OpenAI-compatible base, ending in /v1")
|
| 253 |
+
ap.add_argument("--api-key", default=os.environ.get("VA_API_KEY", ""))
|
| 254 |
+
ap.add_argument("--game", action="append", required=True,
|
| 255 |
+
help="game to run (repeatable), or 'all'")
|
| 256 |
+
ap.add_argument("--case", default="all", help="case id, or 'all' (default)")
|
| 257 |
+
ap.add_argument("--limit", type=int, default=0,
|
| 258 |
+
help="with --case all: only the first N cases of each game (frozen order)")
|
| 259 |
+
ap.add_argument("--out", required=True, help="output root; answers land in <out>/answers")
|
| 260 |
+
ap.add_argument("--max-frames", type=int, default=MAX_FRAMES,
|
| 261 |
+
help="degrade the 256-frame cap for a provider that rejects it; "
|
| 262 |
+
"recorded in run.json so the cell is readable as degraded")
|
| 263 |
+
ap.add_argument("--jpeg-q", type=int, default=JPEG_Q,
|
| 264 |
+
help="ffmpeg -q:v for the frames (default %d; higher = smaller). Raise it "
|
| 265 |
+
"for a provider whose request-size cap rejects the 256-frame grid; "
|
| 266 |
+
"recorded in run.json" % JPEG_Q)
|
| 267 |
+
ap.add_argument("--max-tokens", type=int, default=48000,
|
| 268 |
+
help="output budget; a long match needs a large one -- a truncated "
|
| 269 |
+
"reply loses the tail of the answer, not just its formatting")
|
| 270 |
+
ap.add_argument("--temperature", type=float, default=0.0)
|
| 271 |
+
ap.add_argument("--reasoning-effort", default=None,
|
| 272 |
+
help="sent as reasoning_effort when set; the paper uses high for the GPT, "
|
| 273 |
+
"Claude and Gemini models and the provider default otherwise")
|
| 274 |
+
ap.add_argument("--extra-body", type=json.loads, default=None,
|
| 275 |
+
help="JSON object merged into the request, e.g. "
|
| 276 |
+
"'{\"chat_template_kwargs\": {\"enable_thinking\": true}}' for a "
|
| 277 |
+
"Qwen model on vLLM; recorded in run.json")
|
| 278 |
+
ap.add_argument("--timeout", type=int, default=1800)
|
| 279 |
+
ap.add_argument("--workers", type=int, default=1,
|
| 280 |
+
help="cells run concurrently (default 1; the paper uses 5)")
|
| 281 |
+
ap.add_argument("--keep-frames", action="store_true", help="keep the sampled JPEGs")
|
| 282 |
+
a = ap.parse_args()
|
| 283 |
+
|
| 284 |
+
if not a.api_key:
|
| 285 |
+
ap.error("--api-key or VA_API_KEY is required")
|
| 286 |
+
for tool in (FFMPEG, FFPROBE):
|
| 287 |
+
if not shutil.which(tool):
|
| 288 |
+
ap.error("%s not found on PATH (set VA_FFMPEG / VA_FFPROBE)" % tool)
|
| 289 |
+
games = C.GAMES if "all" in a.game else a.game
|
| 290 |
+
for g in games:
|
| 291 |
+
if g not in C.GAMES:
|
| 292 |
+
ap.error("unknown game %r" % g)
|
| 293 |
+
|
| 294 |
+
cells = [(g, cid) for g in games
|
| 295 |
+
for cid in ((C.case_ids(g)[:a.limit or None]) if a.case == "all"
|
| 296 |
+
else [a.case])]
|
| 297 |
+
with ThreadPoolExecutor(max_workers=max(1, a.workers)) as pool:
|
| 298 |
+
list(pool.map(lambda gc: run_cell(a, *gc), cells))
|
| 299 |
+
|
| 300 |
+
print("\nanswers in %s\n python tools/score.py --answers %s"
|
| 301 |
+
% (os.path.join(a.out, "answers"), os.path.join(a.out, "answers")))
|
| 302 |
+
return 0
|
| 303 |
+
|
| 304 |
+
|
| 305 |
+
if __name__ == "__main__":
|
| 306 |
+
sys.exit(main())
|
tools/run_protocol_b.py
ADDED
|
@@ -0,0 +1,410 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
"""run_protocol_b.py -- minimal Protocol B (agentic) reference runner.
|
| 4 |
+
|
| 5 |
+
Protocol B hands the WHOLE video to a coding agent in a sandbox folder and lets it work for
|
| 6 |
+
many turns: sample frames however it likes, write its own parsers, and build up `answer.json`
|
| 7 |
+
incrementally. It is the same task as Protocol A and a different capability -- tool use and
|
| 8 |
+
self-directed sampling instead of a fixed frame grid.
|
| 9 |
+
|
| 10 |
+
This script builds the sandbox and runs YOUR agent in it. It deliberately does not bundle a
|
| 11 |
+
harness: every coding agent has its own CLI, and hardcoding one would make the reference
|
| 12 |
+
implementation useless for the others. You supply the command; this script supplies the part
|
| 13 |
+
that must not vary between systems -- what is in the sandbox, what the agent is told, and
|
| 14 |
+
what gets collected afterwards.
|
| 15 |
+
|
| 16 |
+
python tools/run_protocol_b.py --game chess --case all --out runs/agentX-B \\
|
| 17 |
+
--agent-cmd "claude -p @PROMPT_FILE@ --max-turns 200" [--workers 3]
|
| 18 |
+
python tools/score.py --answers runs/agentX-B/answers
|
| 19 |
+
|
| 20 |
+
Placeholders in --agent-cmd, substituted per cell:
|
| 21 |
+
|
| 22 |
+
@PROMPT_FILE@ path to prompt.txt (the turn-1 user message)
|
| 23 |
+
@PROMPT@ the prompt text itself, for a CLI that takes it inline
|
| 24 |
+
@SANDBOX@ the sandbox folder (also the command's working directory)
|
| 25 |
+
|
| 26 |
+
--agent-cmd is split with POSIX quoting on every OS ("a b" is one argument, the quotes are
|
| 27 |
+
removed); on Windows a backslash is literal, so C:\\tools\\agent.exe needs no escaping.
|
| 28 |
+
|
| 29 |
+
Prefer @PROMPT_FILE@. A multi-line prompt passed as one argv element is truncated at the
|
| 30 |
+
first newline by several shells and batch shims, and a truncated prompt still SCORES -- the
|
| 31 |
+
agent re-derives the task from instruction.md and the cell looks like a valid measurement.
|
| 32 |
+
|
| 33 |
+
THE SANDBOX -- a fresh folder with a random name under the system temp dir (or
|
| 34 |
+
--sandbox-root), outside the repo and never reused, holding exactly these files:
|
| 35 |
+
|
| 36 |
+
match.mp4 the video, the only input (renamed, so the case id is not a hint)
|
| 37 |
+
instruction.md the task, rendered for Protocol B
|
| 38 |
+
answer.json a BYTE-FOR-BYTE copy of answer_seed.json: the root key, empty list
|
| 39 |
+
|
| 40 |
+
The sandbox is outside the repo so the ground truth is not a relative path away and the
|
| 41 |
+
folder name does not spell the case id; prompt.txt sits next to the sandbox, not in it.
|
| 42 |
+
An agent with full-disk access can still go looking for the repo -- that is caught by the
|
| 43 |
+
transcript audit below, not by the folder layout.
|
| 44 |
+
|
| 45 |
+
Pre-seeding rather than letting the agent create the file is what makes "it never answered"
|
| 46 |
+
measurable: if the final bytes still hash to the seed, the agent never wrote an answer, and
|
| 47 |
+
that is a different result from an answer that scored 0.0. It is still SCORED 0.0 -- the
|
| 48 |
+
runner exports the untouched seed for a never_wrote or deleted answer, so the cell stays in
|
| 49 |
+
the mean (leaving it out would let an agent that never answers post a higher mean than one
|
| 50 |
+
that answers badly) -- and run.json records which of the three happened.
|
| 51 |
+
|
| 52 |
+
A re-run of a cell first deletes the answer, run.json and logs an earlier run left, so a run
|
| 53 |
+
that dies early can never be scored on its predecessor's answer. On timeout the agent's whole
|
| 54 |
+
process tree is killed, not just the command you gave: an agent CLI is a launcher, and its
|
| 55 |
+
children would otherwise keep running -- and keep writing -- after the cell was collected.
|
| 56 |
+
|
| 57 |
+
WHAT THIS DOES NOT DO: enforce the no-network rule. The agent's own brain is an HTTPS call,
|
| 58 |
+
so there is no configuration where the sandbox is offline and the run still happens. The
|
| 59 |
+
prompt states the rule, and a serious evaluation AUDITS the agent's transcript afterwards
|
| 60 |
+
for package installs, downloads, and lookups of the match. An audit is the honest mechanism
|
| 61 |
+
here; a claim of isolation would not be true. Your harness's transcript format is your own,
|
| 62 |
+
so the audit lives in your harness -- not here.
|
| 63 |
+
"""
|
| 64 |
+
import argparse
|
| 65 |
+
import hashlib
|
| 66 |
+
import json
|
| 67 |
+
import os
|
| 68 |
+
import shlex
|
| 69 |
+
import shutil
|
| 70 |
+
import signal
|
| 71 |
+
import subprocess
|
| 72 |
+
import sys
|
| 73 |
+
import tempfile
|
| 74 |
+
import threading
|
| 75 |
+
import time
|
| 76 |
+
from concurrent.futures import ThreadPoolExecutor
|
| 77 |
+
|
| 78 |
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 79 |
+
import va_core as C # noqa: E402
|
| 80 |
+
|
| 81 |
+
# The turn-1 message. It carries only the DELIVERY contract -- the task itself is
|
| 82 |
+
# instruction.md, which the agent is told to read. Deliberately identical across systems
|
| 83 |
+
# except for the one budget sentence, which is a harness fact rather than a wording choice:
|
| 84 |
+
# a harness that cannot count turns must not be made to claim a turn cap.
|
| 85 |
+
PROMPT = """You are a HEADLESS autonomous agent -- there is no human to talk to.
|
| 86 |
+
Communicate ONLY by calling tools (running commands, reading and writing files); a text
|
| 87 |
+
reply is not an answer. Your one deliverable is the file `answer.json` in this folder.
|
| 88 |
+
|
| 89 |
+
Read `instruction.md` in this folder for the task and the exact `answer.json` schema. The
|
| 90 |
+
only input is the video `match.mp4` in this folder. The video plays at 1:1 real speed;
|
| 91 |
+
`instruction.md` says exactly which clock each time field you report is on.
|
| 92 |
+
|
| 93 |
+
Solve it yourself, from the video. Do not use the network for anything: no downloading or
|
| 94 |
+
installing packages, models or weights, no calls to any external service, API or model, and
|
| 95 |
+
no looking this match up. The shell, the Python already installed, and the video tools
|
| 96 |
+
already on this machine are your only tools. Any network use voids the run, which is then
|
| 97 |
+
scored zero whatever `answer.json` contains.
|
| 98 |
+
|
| 99 |
+
`answer.json` is already in this folder -- it was created before your first turn, with the
|
| 100 |
+
schema's root key and an empty list. Do not delete it, do not rename it, and do not change
|
| 101 |
+
the root key. Overwrite it in place -- in full, valid JSON every time -- as soon as you have
|
| 102 |
+
something to put in it, and keep overwriting it as you learn more. It must be valid JSON at
|
| 103 |
+
every moment: rewrite it in full each time (read -> add -> write back), never leave it
|
| 104 |
+
half-written. Each rewrite should contain everything the previous one had, plus the new rows;
|
| 105 |
+
if you are deep into the video and the file is not getting longer, you are overwriting
|
| 106 |
+
instead of appending.
|
| 107 |
+
|
| 108 |
+
Whatever is in `answer.json` when the run stops is what gets scored. If you are cut off,
|
| 109 |
+
every row already written still counts; rows kept only in your reasoning, to be written out
|
| 110 |
+
at the end, score zero.
|
| 111 |
+
|
| 112 |
+
{budget} Everything else -- including how you sample the video -- is up to you."""
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def build_prompt(max_turns, timeout_s):
|
| 116 |
+
minutes = round(timeout_s / 60)
|
| 117 |
+
if max_turns:
|
| 118 |
+
budget = ("You have at most %d tool-call turns and about %d minutes of wall-clock "
|
| 119 |
+
"time. When either limit is reached you are stopped immediately."
|
| 120 |
+
% (max_turns, minutes))
|
| 121 |
+
else:
|
| 122 |
+
budget = ("You have about %d minutes of wall-clock time. When that limit is reached "
|
| 123 |
+
"you are stopped immediately." % minutes)
|
| 124 |
+
return PROMPT.format(budget=budget)
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
def seed_answer(sandbox, game, root_key):
|
| 128 |
+
"""Copy answer_seed.json into the sandbox as answer.json, byte for byte.
|
| 129 |
+
|
| 130 |
+
Byte-for-byte rather than json.dump: a driver that re-serializes the seed can get the
|
| 131 |
+
root key wrong, and the resulting 0.0 looks exactly like a model that cannot write JSON.
|
| 132 |
+
Fails closed on a seed that is missing, unparseable, keyed differently from the judge, or
|
| 133 |
+
carries a row -- each of those would be charged to the agent.
|
| 134 |
+
"""
|
| 135 |
+
src = C.resolve(game, "_")["answer_seed"]
|
| 136 |
+
with open(src, "rb") as fh:
|
| 137 |
+
raw = fh.read()
|
| 138 |
+
seed = json.loads(raw.decode("utf-8"))
|
| 139 |
+
if root_key not in seed:
|
| 140 |
+
raise ValueError("%s: seed keys %s do not include the judge's root key %r"
|
| 141 |
+
% (game, list(seed), root_key))
|
| 142 |
+
for k, v in seed.items():
|
| 143 |
+
if isinstance(v, list) and v:
|
| 144 |
+
raise ValueError("%s: seed key %r is not empty -- a seeded row is part of the "
|
| 145 |
+
"answer" % (game, k))
|
| 146 |
+
dst = os.path.join(sandbox, "answer.json")
|
| 147 |
+
shutil.copyfile(src, dst)
|
| 148 |
+
st = os.stat(dst)
|
| 149 |
+
return {"seed_sha256": hashlib.sha256(raw).hexdigest(), "seeded_size": st.st_size}
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
def answer_state(sandbox, baseline):
|
| 153 |
+
"""Three outcomes, told apart by the digest rather than by the score:
|
| 154 |
+
|
| 155 |
+
deleted the agent removed or renamed the file (the prompt says not to)
|
| 156 |
+
never_wrote still byte-identical to the seed: the agent never answered, which is a
|
| 157 |
+
budget or behaviour failure, not "answered and scored 0"
|
| 158 |
+
wrote the bytes changed, so score whatever is in there
|
| 159 |
+
|
| 160 |
+
The first two both score 0.0 (the runner exports the seed for them); this field is what
|
| 161 |
+
tells them apart afterwards. The digest decides, not mtime or size: rewriting the seed
|
| 162 |
+
with identical content is still not an answer.
|
| 163 |
+
"""
|
| 164 |
+
p = os.path.join(sandbox, "answer.json")
|
| 165 |
+
if not os.path.isfile(p):
|
| 166 |
+
return {"state": "deleted", "final_sha256": None, "final_size": None}
|
| 167 |
+
with open(p, "rb") as fh:
|
| 168 |
+
raw = fh.read()
|
| 169 |
+
dig = hashlib.sha256(raw).hexdigest()
|
| 170 |
+
return {"state": "never_wrote" if dig == baseline["seed_sha256"] else "wrote",
|
| 171 |
+
"final_sha256": dig, "final_size": len(raw)}
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
def split_cmd(cmd):
|
| 175 |
+
"""--agent-cmd -> argv, with POSIX quoting on every OS. shlex's Windows mode
|
| 176 |
+
(posix=False) keeps the quote characters INSIDE the token, so `--system "be terse"`
|
| 177 |
+
reached the agent as two arguments `"be` and `terse"`. Backslash is literal on Windows,
|
| 178 |
+
so a path like C:\\tools\\agent.exe survives unescaped."""
|
| 179 |
+
lex = shlex.shlex(cmd, posix=True)
|
| 180 |
+
lex.whitespace_split = True
|
| 181 |
+
lex.commenters = ""
|
| 182 |
+
if os.name == "nt":
|
| 183 |
+
lex.escape = ""
|
| 184 |
+
return list(lex)
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def kill_tree(p):
|
| 188 |
+
"""Kill `p` AND everything it started. subprocess.run(timeout=) kills only the direct
|
| 189 |
+
child, and an agent CLI is a launcher: the model loop, its shell and that shell's ffmpeg
|
| 190 |
+
are descendants, and they kept running -- and kept writing answer.json -- after the cell
|
| 191 |
+
had been collected."""
|
| 192 |
+
if os.name == "nt":
|
| 193 |
+
subprocess.run(["taskkill", "/PID", str(p.pid), "/T", "/F"],
|
| 194 |
+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 195 |
+
else:
|
| 196 |
+
try:
|
| 197 |
+
os.killpg(p.pid, signal.SIGKILL) # start_new_session: pgid == pid
|
| 198 |
+
except (ProcessLookupError, PermissionError):
|
| 199 |
+
pass
|
| 200 |
+
try:
|
| 201 |
+
p.kill()
|
| 202 |
+
except OSError:
|
| 203 |
+
pass
|
| 204 |
+
p.wait()
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
def run_agent(cmd, cwd, stdout, stderr, timeout_s):
|
| 208 |
+
"""Run the agent as the root of its own process tree and return its exit code. On
|
| 209 |
+
timeout -- or anything else that interrupts this script, Ctrl-C included -- the whole
|
| 210 |
+
tree is killed before the exception propagates."""
|
| 211 |
+
kw = {} if os.name == "nt" else {"start_new_session": True}
|
| 212 |
+
p = subprocess.Popen(cmd, cwd=cwd, stdout=stdout, stderr=stderr, **kw)
|
| 213 |
+
try:
|
| 214 |
+
return p.wait(timeout=timeout_s)
|
| 215 |
+
except BaseException:
|
| 216 |
+
kill_tree(p)
|
| 217 |
+
raise
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
def clear_cell(cell, answer):
|
| 221 |
+
"""Delete what an earlier run of this cell left behind, so nothing stale can be read
|
| 222 |
+
as this run's result: a re-run that dies before collecting would otherwise leave the
|
| 223 |
+
PREVIOUS answer in answers/ to be scored, next to a run.json that does not describe it."""
|
| 224 |
+
for p in (answer, os.path.join(cell, "run.json"), os.path.join(cell, "prompt.txt"),
|
| 225 |
+
os.path.join(cell, "agent_stdout.txt"), os.path.join(cell, "agent_stderr.txt")):
|
| 226 |
+
if os.path.isfile(p):
|
| 227 |
+
os.remove(p)
|
| 228 |
+
shutil.rmtree(os.path.join(cell, "sandbox"), ignore_errors=True)
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
def remove_tree(path):
|
| 232 |
+
"""rmtree that waits out Windows releasing a killed process's file handles."""
|
| 233 |
+
for _ in range(10):
|
| 234 |
+
shutil.rmtree(path, ignore_errors=True)
|
| 235 |
+
if not os.path.exists(path):
|
| 236 |
+
return True
|
| 237 |
+
time.sleep(1)
|
| 238 |
+
return False
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
def collect(sandbox, rec, seed_path, dst, root_key):
|
| 242 |
+
"""Export the cell's answer to answers/ and fill rec: exported / n_rows / unparseable.
|
| 243 |
+
|
| 244 |
+
wrote the agent's file, as-is -- even if it does not parse (score.py
|
| 245 |
+
then scores it 0.0 and tallies it as unparseable; withholding
|
| 246 |
+
it would turn "left a broken file" into "missing", which drops
|
| 247 |
+
the cell from the mean)
|
| 248 |
+
never_wrote / deleted the untouched seed -> 0.0, still in the denominator
|
| 249 |
+
the agent never started (stop_reason harness_error, or no sandbox) nothing: the cell
|
| 250 |
+
did not measure the model, so it stays missing
|
| 251 |
+
"""
|
| 252 |
+
rec["exported"] = None
|
| 253 |
+
rec["n_rows"] = None
|
| 254 |
+
state = rec.get("state")
|
| 255 |
+
src = os.path.join(sandbox, "answer.json")
|
| 256 |
+
if state == "wrote":
|
| 257 |
+
shutil.copyfile(src, dst)
|
| 258 |
+
rec["exported"] = "answer"
|
| 259 |
+
try:
|
| 260 |
+
with open(src, encoding="utf-8-sig") as fh:
|
| 261 |
+
obj = json.load(fh)
|
| 262 |
+
rows = obj.get(root_key) if isinstance(obj, dict) else obj
|
| 263 |
+
rec["n_rows"] = len(rows) if isinstance(rows, list) else 0
|
| 264 |
+
except Exception as e:
|
| 265 |
+
rec["unparseable"] = "%s: %s" % (type(e).__name__, str(e)[:200])
|
| 266 |
+
elif state in ("never_wrote", "deleted") and rec.get("stop_reason") != "harness_error":
|
| 267 |
+
shutil.copyfile(seed_path, dst)
|
| 268 |
+
rec["exported"] = "seed"
|
| 269 |
+
rec["n_rows"] = 0
|
| 270 |
+
|
| 271 |
+
|
| 272 |
+
PRINT_LOCK = threading.Lock()
|
| 273 |
+
|
| 274 |
+
|
| 275 |
+
def run_cell(a, g, cid, prompt, argv, sandbox_root, timeout_s):
|
| 276 |
+
"""One cell: build the sandbox, run the agent, collect. Returns the run.json record."""
|
| 277 |
+
r = C.resolve(g, cid)
|
| 278 |
+
cell = os.path.join(a.out, "cells", g, cid)
|
| 279 |
+
dst = os.path.join(a.out, "answers", g, cid + ".json")
|
| 280 |
+
clear_cell(cell, dst)
|
| 281 |
+
os.makedirs(cell, exist_ok=True)
|
| 282 |
+
os.makedirs(os.path.dirname(dst), exist_ok=True)
|
| 283 |
+
# A fresh, randomly named folder per cell, outside the repo: no case id in the
|
| 284 |
+
# agent's working directory, no relative path back to the ground truth, and
|
| 285 |
+
# nothing left over from another cell or an earlier run of this one.
|
| 286 |
+
work = tempfile.mkdtemp(prefix="va_", dir=sandbox_root)
|
| 287 |
+
sandbox = os.path.join(work, "sandbox")
|
| 288 |
+
t0 = time.time()
|
| 289 |
+
# `sandbox` is recorded for the transcript audit: it is the one directory the
|
| 290 |
+
# agent had any business reading.
|
| 291 |
+
rec = {"protocol": "B", "game": g, "case_id": cid, "root_key": r["root_key"],
|
| 292 |
+
"tol_s": C.TOL, "max_turns": a.max_turns or None,
|
| 293 |
+
"timeout_min": a.timeout_min, "agent_cmd": a.agent_cmd,
|
| 294 |
+
"sandbox": sandbox}
|
| 295 |
+
try:
|
| 296 |
+
try:
|
| 297 |
+
# the sandbox: video (renamed), Protocol-B instruction, pre-seeded answer
|
| 298 |
+
os.makedirs(sandbox)
|
| 299 |
+
shutil.copyfile(r["video"], os.path.join(sandbox, "match.mp4"))
|
| 300 |
+
with open(os.path.join(sandbox, "instruction.md"), "w",
|
| 301 |
+
encoding="utf-8", newline="\n") as fh:
|
| 302 |
+
fh.write(C.instruction_for("agentic", r["instruction"]))
|
| 303 |
+
baseline = seed_answer(sandbox, g, r["root_key"])
|
| 304 |
+
rec.update(baseline)
|
| 305 |
+
# next to the sandbox (not in it); a copy stays with the cell's records
|
| 306 |
+
prompt_file = os.path.join(work, "prompt.txt")
|
| 307 |
+
for pf in (prompt_file, os.path.join(cell, "prompt.txt")):
|
| 308 |
+
with open(pf, "w", encoding="utf-8", newline="\n") as fh:
|
| 309 |
+
fh.write(prompt)
|
| 310 |
+
rec["prompt_sha256"] = hashlib.sha256(prompt.encode("utf-8")).hexdigest()
|
| 311 |
+
|
| 312 |
+
cmd = [w.replace("@PROMPT_FILE@", prompt_file)
|
| 313 |
+
.replace("@PROMPT@", prompt)
|
| 314 |
+
.replace("@SANDBOX@", sandbox)
|
| 315 |
+
for w in argv]
|
| 316 |
+
with open(os.path.join(cell, "agent_stdout.txt"), "wb") as so, \
|
| 317 |
+
open(os.path.join(cell, "agent_stderr.txt"), "wb") as se:
|
| 318 |
+
rc = run_agent(cmd, sandbox, so, se, timeout_s)
|
| 319 |
+
rec["exit_code"] = rc
|
| 320 |
+
rec["stop_reason"] = "ok" if rc == 0 else "error"
|
| 321 |
+
except subprocess.TimeoutExpired:
|
| 322 |
+
rec["exit_code"] = None
|
| 323 |
+
rec["stop_reason"] = "timeout"
|
| 324 |
+
except Exception as e:
|
| 325 |
+
rec["stop_reason"] = "harness_error"
|
| 326 |
+
rec["error"] = "%s: %s" % (type(e).__name__, str(e)[:400])
|
| 327 |
+
|
| 328 |
+
# Collect whatever the agent left, whether it finished, timed out, or
|
| 329 |
+
# crashed -- a cut-off run's already-written rows still count.
|
| 330 |
+
st = (answer_state(sandbox, rec) if "seed_sha256" in rec
|
| 331 |
+
else {"state": "no_sandbox"})
|
| 332 |
+
rec.update(st)
|
| 333 |
+
try:
|
| 334 |
+
collect(sandbox, rec, r["answer_seed"], dst, r["root_key"])
|
| 335 |
+
except OSError as e:
|
| 336 |
+
rec["collect_error"] = "%s: %s" % (type(e).__name__, str(e)[:200])
|
| 337 |
+
if a.keep_sandbox and os.path.isdir(sandbox):
|
| 338 |
+
shutil.copytree(sandbox, os.path.join(cell, "sandbox"))
|
| 339 |
+
finally:
|
| 340 |
+
if not remove_tree(work):
|
| 341 |
+
rec["sandbox_not_removed"] = work
|
| 342 |
+
rec["wall_s"] = round(time.time() - t0, 1)
|
| 343 |
+
with open(os.path.join(cell, "run.json"), "w", encoding="utf-8") as fh:
|
| 344 |
+
json.dump(rec, fh, ensure_ascii=False, indent=2)
|
| 345 |
+
with PRINT_LOCK:
|
| 346 |
+
print("%-10s %-38s %-13s %-11s export=%-6s n_rows=%s %s"
|
| 347 |
+
% (g, cid, rec.get("stop_reason"), rec.get("state"), rec.get("exported"),
|
| 348 |
+
rec.get("n_rows"),
|
| 349 |
+
rec.get("error", rec.get("unparseable", rec.get("collect_error", "")))),
|
| 350 |
+
flush=True)
|
| 351 |
+
return rec
|
| 352 |
+
|
| 353 |
+
|
| 354 |
+
def main():
|
| 355 |
+
ap = argparse.ArgumentParser(description=__doc__,
|
| 356 |
+
formatter_class=argparse.RawDescriptionHelpFormatter)
|
| 357 |
+
ap.add_argument("--agent-cmd", required=True,
|
| 358 |
+
help="command to run in the sandbox; see the placeholders above")
|
| 359 |
+
ap.add_argument("--game", action="append", required=True, help="game (repeatable) or 'all'")
|
| 360 |
+
ap.add_argument("--case", default="all", help="case id, or 'all' (default)")
|
| 361 |
+
ap.add_argument("--limit", type=int, default=0,
|
| 362 |
+
help="with --case all: only the first N cases of each game (frozen order)")
|
| 363 |
+
ap.add_argument("--out", required=True, help="output root; answers land in <out>/answers")
|
| 364 |
+
ap.add_argument("--max-turns", type=int, default=200,
|
| 365 |
+
help="turn cap to STATE in the prompt (default 200); pass 0 for a harness "
|
| 366 |
+
"that cannot count turns, so the prompt claims only the wall clock")
|
| 367 |
+
ap.add_argument("--timeout-min", type=int, default=120,
|
| 368 |
+
help="wall-clock cap per cell, in minutes (default 120)")
|
| 369 |
+
ap.add_argument("--sandbox-root",
|
| 370 |
+
help="where the per-cell sandboxes are created (default: the system temp "
|
| 371 |
+
"dir); must be outside the repo")
|
| 372 |
+
ap.add_argument("--workers", type=int, default=1,
|
| 373 |
+
help="cells run concurrently, each in its own sandbox (default 1; the "
|
| 374 |
+
"paper uses 3)")
|
| 375 |
+
ap.add_argument("--keep-sandbox", action="store_true",
|
| 376 |
+
help="copy the sandbox into the cell folder afterwards (video included -- "
|
| 377 |
+
"about 60MB..500MB per cell)")
|
| 378 |
+
a = ap.parse_args()
|
| 379 |
+
|
| 380 |
+
games = C.GAMES if "all" in a.game else a.game
|
| 381 |
+
for g in games:
|
| 382 |
+
if g not in C.GAMES:
|
| 383 |
+
ap.error("unknown game %r" % g)
|
| 384 |
+
sandbox_root = os.path.realpath(a.sandbox_root or tempfile.gettempdir())
|
| 385 |
+
repo = os.path.realpath(C.ROOT)
|
| 386 |
+
try:
|
| 387 |
+
inside = os.path.commonpath([sandbox_root, repo]) == repo
|
| 388 |
+
except ValueError: # different drives
|
| 389 |
+
inside = False
|
| 390 |
+
if inside:
|
| 391 |
+
ap.error("--sandbox-root %s is inside the repo: the agent could reach tasks/*/gt/"
|
| 392 |
+
% sandbox_root)
|
| 393 |
+
timeout_s = a.timeout_min * 60
|
| 394 |
+
prompt = build_prompt(a.max_turns or None, timeout_s)
|
| 395 |
+
argv = split_cmd(a.agent_cmd)
|
| 396 |
+
|
| 397 |
+
cells = [(g, cid) for g in games
|
| 398 |
+
for cid in ((C.case_ids(g)[:a.limit or None]) if a.case == "all"
|
| 399 |
+
else [a.case])]
|
| 400 |
+
with ThreadPoolExecutor(max_workers=max(1, a.workers)) as pool:
|
| 401 |
+
list(pool.map(lambda gc: run_cell(a, gc[0], gc[1], prompt, argv, sandbox_root,
|
| 402 |
+
timeout_s), cells))
|
| 403 |
+
|
| 404 |
+
print("\nanswers in %s\n python tools/score.py --answers %s"
|
| 405 |
+
% (os.path.join(a.out, "answers"), os.path.join(a.out, "answers")))
|
| 406 |
+
return 0
|
| 407 |
+
|
| 408 |
+
|
| 409 |
+
if __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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
"""score.py -- score a directory of answers against Video-Arena and print the table.
|
| 4 |
+
|
| 5 |
+
python tools/score.py --answers runs/my-model
|
| 6 |
+
python tools/score.py --answers runs/my-model --game cs2 --per-case
|
| 7 |
+
python tools/score.py --oracle # feed GT back in: every cell 1.0
|
| 8 |
+
python tools/score.py --empty # empty answers: every cell 0.0
|
| 9 |
+
|
| 10 |
+
The answers directory mirrors the corpus:
|
| 11 |
+
|
| 12 |
+
<answers>/<game>/<case_id>.json one answer per case
|
| 13 |
+
|
| 14 |
+
Each file is the object the instruction asks for -- {"events": [...]}, the same root key in
|
| 15 |
+
every one of the nine games. A MISSING file is reported as missing and left out of the mean:
|
| 16 |
+
"did not run" is not a measurement of the model. A file that EXISTS is always scored, whatever
|
| 17 |
+
is in it -- an answer with no rows (the untouched seed a runner exports for a Protocol B agent
|
| 18 |
+
that never wrote or deleted its answer), or one that is not valid JSON at all, scores 0.0. Those
|
| 19 |
+
are things the model did, and dropping them would let a worse agent post a higher mean. Both are
|
| 20 |
+
tallied per game (`empty`, `unparseable`) so a 0.0 that came from no answer stays visible.
|
| 21 |
+
|
| 22 |
+
Reported per game and overall:
|
| 23 |
+
|
| 24 |
+
F1_strict the headline: fraction of fully-correct event tuples (all non-temporal
|
| 25 |
+
fields exact, |dt| <= 3s, maximum 1:1) -- the mean over scored cases
|
| 26 |
+
T1 event localization F1 (perceive)
|
| 27 |
+
T2 state-update accuracy (interpret)
|
| 28 |
+
T3 resulting-state accuracy (track)
|
| 29 |
+
|
| 30 |
+
Means are over the cases that actually produced a reward, and the denominator is printed
|
| 31 |
+
next to every number. A mean over 17 of 20 cases is a different quantity from a mean over
|
| 32 |
+
20, and the only way to keep that readable is to say n.
|
| 33 |
+
"""
|
| 34 |
+
import argparse
|
| 35 |
+
import json
|
| 36 |
+
import os
|
| 37 |
+
import shutil
|
| 38 |
+
import sys
|
| 39 |
+
import tempfile
|
| 40 |
+
|
| 41 |
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 42 |
+
import va_core as C # noqa: E402
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def mean(xs):
|
| 46 |
+
xs = [x for x in xs if x is not None]
|
| 47 |
+
return (sum(xs) / len(xs)) if xs else None
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def fmt(x, w=6):
|
| 51 |
+
return ("%*.*f" % (w, 4, x)) if isinstance(x, (int, float)) else ("%*s" % (w, "--"))
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def oracle_answer(game, gt):
|
| 55 |
+
"""GT re-expressed as an answer, for --oracle. Answers carry only the fields a model is
|
| 56 |
+
asked for, so this is a projection of GT onto the answer schema -- which is exactly what
|
| 57 |
+
makes it a real end-to-end check of the whole scoring path rather than of the judge alone.
|
| 58 |
+
"""
|
| 59 |
+
rk = C.ROOT_KEY[game]
|
| 60 |
+
if rk not in gt:
|
| 61 |
+
raise KeyError("%s GT has no %r key" % (game, rk))
|
| 62 |
+
out = {rk: gt[rk]}
|
| 63 |
+
# dota2 accepts OPTIONAL dense tier blocks alongside the event list. They are not part of
|
| 64 |
+
# the headline, but --oracle has to exercise the paths that read them, so the projection
|
| 65 |
+
# carries them when the GT has them. (cs2 reads T2/T3 ONLY from the event rows, so its
|
| 66 |
+
# GT-side `t2_round_winners` must not ride along: it would be ignored at best.)
|
| 67 |
+
for k in ("t2_leader_track", "t3_outcome"):
|
| 68 |
+
if k in gt:
|
| 69 |
+
out[k] = gt[k]
|
| 70 |
+
return out
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def answer_state(game, path):
|
| 74 |
+
""""rows" / "empty" (parses, but no rows under the root key) / "unparseable"."""
|
| 75 |
+
try:
|
| 76 |
+
with open(path, encoding="utf-8-sig") as fh:
|
| 77 |
+
obj = json.load(fh)
|
| 78 |
+
except Exception:
|
| 79 |
+
return "unparseable"
|
| 80 |
+
rows = obj.get(C.ROOT_KEY[game]) if isinstance(obj, dict) else obj
|
| 81 |
+
return "rows" if isinstance(rows, list) and rows else "empty"
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def score_case(game, cid, answers_dir, work, mode):
|
| 85 |
+
"""Score one case; return (subscores_dict, status, answer_state). status is "ok" or why
|
| 86 |
+
not; answer_state is "rows" / "empty" / "unparseable" for a scored cell."""
|
| 87 |
+
r = C.resolve(game, cid)
|
| 88 |
+
ans_path = os.path.join(answers_dir, game, cid + ".json") if answers_dir else None
|
| 89 |
+
|
| 90 |
+
if mode == "oracle":
|
| 91 |
+
with open(r["gt"], encoding="utf-8") as fh:
|
| 92 |
+
payload = oracle_answer(game, json.load(fh))
|
| 93 |
+
ans_path = os.path.join(work, "answer.json")
|
| 94 |
+
with open(ans_path, "w", encoding="utf-8") as fh:
|
| 95 |
+
json.dump(payload, fh, ensure_ascii=False)
|
| 96 |
+
elif mode == "empty":
|
| 97 |
+
ans_path = os.path.join(work, "answer.json")
|
| 98 |
+
shutil.copyfile(r["answer_seed"], ans_path)
|
| 99 |
+
else:
|
| 100 |
+
if not os.path.isfile(ans_path):
|
| 101 |
+
return None, "missing", None
|
| 102 |
+
state = answer_state(game, ans_path)
|
| 103 |
+
if state == "unparseable":
|
| 104 |
+
# Scored as the empty seed -- 0.0 by construction -- rather than handed to the judge,
|
| 105 |
+
# so the zero does not depend on each judge's tolerance for garbage input.
|
| 106 |
+
ans_path = os.path.join(work, "answer.json")
|
| 107 |
+
shutil.copyfile(r["answer_seed"], ans_path)
|
| 108 |
+
|
| 109 |
+
out = os.path.join(work, "reward.json")
|
| 110 |
+
try:
|
| 111 |
+
reward = C.run_judge(game, ans_path, r["gt"], out, tol=C.TOL)
|
| 112 |
+
except Exception as e:
|
| 113 |
+
detail = getattr(e, "stderr", "") or str(e)
|
| 114 |
+
return None, "judge failed: %s" % detail.strip().splitlines()[-1][:120], None
|
| 115 |
+
return C.subscores(reward), "ok", state
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
def main():
|
| 119 |
+
ap = argparse.ArgumentParser(description=__doc__,
|
| 120 |
+
formatter_class=argparse.RawDescriptionHelpFormatter)
|
| 121 |
+
ap.add_argument("--answers", help="directory of <game>/<case_id>.json answer files")
|
| 122 |
+
ap.add_argument("--oracle", action="store_true",
|
| 123 |
+
help="score GT against itself; every cell must be 1.0")
|
| 124 |
+
ap.add_argument("--empty", action="store_true",
|
| 125 |
+
help="score the empty answer seeds; every cell must be 0.0")
|
| 126 |
+
ap.add_argument("--game", action="append",
|
| 127 |
+
help="restrict to this game (repeatable); default all nine")
|
| 128 |
+
ap.add_argument("--per-case", action="store_true", help="print every case, not just means")
|
| 129 |
+
ap.add_argument("--json-out", help="write the full result table here")
|
| 130 |
+
a = ap.parse_args()
|
| 131 |
+
|
| 132 |
+
mode = "oracle" if a.oracle else ("empty" if a.empty else "answers")
|
| 133 |
+
if mode == "answers" and not a.answers:
|
| 134 |
+
ap.error("one of --answers / --oracle / --empty is required")
|
| 135 |
+
games = a.game or C.GAMES
|
| 136 |
+
for g in games:
|
| 137 |
+
if g not in C.GAMES:
|
| 138 |
+
ap.error("unknown game %r (known: %s)" % (g, ", ".join(C.GAMES)))
|
| 139 |
+
|
| 140 |
+
work = tempfile.mkdtemp(prefix="va_score_")
|
| 141 |
+
rows = []
|
| 142 |
+
per_game = []
|
| 143 |
+
try:
|
| 144 |
+
for g in games:
|
| 145 |
+
got = []
|
| 146 |
+
notes = []
|
| 147 |
+
states = {"empty": 0, "unparseable": 0}
|
| 148 |
+
for cid in C.case_ids(g):
|
| 149 |
+
s, status, state = score_case(g, cid, a.answers, work, mode)
|
| 150 |
+
rows.append({"game": g, "case_id": cid, "status": status,
|
| 151 |
+
"answer_state": state,
|
| 152 |
+
**(s or {"reward": None, "t1_f1": None,
|
| 153 |
+
"t2_macro_acc": None, "t3_macro_acc": None})})
|
| 154 |
+
if status == "ok":
|
| 155 |
+
got.append(s)
|
| 156 |
+
if state in states:
|
| 157 |
+
states[state] += 1
|
| 158 |
+
else:
|
| 159 |
+
notes.append("%s: %s" % (cid, status))
|
| 160 |
+
if a.per_case:
|
| 161 |
+
print(" %-10s %-38s %s %s %s %s %s"
|
| 162 |
+
% (g, cid, fmt((s or {}).get("reward")),
|
| 163 |
+
fmt((s or {}).get("t1_f1")),
|
| 164 |
+
fmt((s or {}).get("t2_macro_acc")),
|
| 165 |
+
fmt((s or {}).get("t3_macro_acc")),
|
| 166 |
+
status if status != "ok"
|
| 167 |
+
else ("" if state == "rows" else state + " -> 0")))
|
| 168 |
+
per_game.append({
|
| 169 |
+
"game": g, "n_scored": len(got), "n_cases": len(C.case_ids(g)),
|
| 170 |
+
"n_empty": states["empty"], "n_unparseable": states["unparseable"],
|
| 171 |
+
"f1_strict": mean([x["reward"] for x in got]),
|
| 172 |
+
"t1_f1": mean([x["t1_f1"] for x in got]),
|
| 173 |
+
"t2_macro_acc": mean([x["t2_macro_acc"] for x in got]),
|
| 174 |
+
"t3_macro_acc": mean([x["t3_macro_acc"] for x in got]),
|
| 175 |
+
"not_scored": notes,
|
| 176 |
+
})
|
| 177 |
+
finally:
|
| 178 |
+
shutil.rmtree(work, ignore_errors=True)
|
| 179 |
+
|
| 180 |
+
print()
|
| 181 |
+
print("Video-Arena mode=%s tol=%.1fs metric=strict tuple F1" % (mode, C.TOL))
|
| 182 |
+
# `0-row` = scored cells whose answer had no rows or did not parse (both score 0.0 and
|
| 183 |
+
# are IN the mean); the n column's shortfall is the missing / judge-failed cells, which
|
| 184 |
+
# are not.
|
| 185 |
+
print("%-10s %-7s %6s %6s %6s %6s %6s %s"
|
| 186 |
+
% ("game", "n", "F1", "T1", "T2", "T3", "0-row", "regime"))
|
| 187 |
+
print("-" * 69)
|
| 188 |
+
for r in per_game:
|
| 189 |
+
print("%-10s %2d/%-4d %s %s %s %s %6d %s"
|
| 190 |
+
% (r["game"], r["n_scored"], r["n_cases"], fmt(r["f1_strict"]), fmt(r["t1_f1"]),
|
| 191 |
+
fmt(r["t2_macro_acc"]), fmt(r["t3_macro_acc"]),
|
| 192 |
+
r["n_empty"] + r["n_unparseable"], C.REGIME[r["game"]]))
|
| 193 |
+
print("-" * 69)
|
| 194 |
+
ok = [r for r in per_game if r["n_scored"]]
|
| 195 |
+
n_scored = sum(r["n_scored"] for r in per_game)
|
| 196 |
+
n_total = sum(r["n_cases"] for r in per_game)
|
| 197 |
+
n_empty = sum(r["n_empty"] for r in per_game)
|
| 198 |
+
n_unparse = sum(r["n_unparseable"] for r in per_game)
|
| 199 |
+
# The overall number is the mean of the ENVIRONMENT means, not of the 180 cases: the
|
| 200 |
+
# per-game case counts are equal today, but an unscored cell must not silently reweight
|
| 201 |
+
# the games against each other.
|
| 202 |
+
print("%-10s %2d/%-4d %s %s %s %s %6d mean of %d env means"
|
| 203 |
+
% ("ALL", n_scored, n_total,
|
| 204 |
+
fmt(mean([r["f1_strict"] for r in ok])), fmt(mean([r["t1_f1"] for r in ok])),
|
| 205 |
+
fmt(mean([r["t2_macro_acc"] for r in ok])), fmt(mean([r["t3_macro_acc"] for r in ok])),
|
| 206 |
+
n_empty + n_unparse, len(ok)))
|
| 207 |
+
if n_empty or n_unparse:
|
| 208 |
+
print("scored as 0.0 with no usable answer: %d empty, %d unparseable"
|
| 209 |
+
% (n_empty, n_unparse))
|
| 210 |
+
missing = [(r["game"], n) for r in per_game for n in r["not_scored"]]
|
| 211 |
+
if missing:
|
| 212 |
+
print()
|
| 213 |
+
print("not scored (%d):" % len(missing))
|
| 214 |
+
for g, n in missing[:40]:
|
| 215 |
+
print(" %-10s %s" % (g, n))
|
| 216 |
+
if len(missing) > 40:
|
| 217 |
+
print(" ... and %d more" % (len(missing) - 40))
|
| 218 |
+
|
| 219 |
+
if a.json_out:
|
| 220 |
+
with open(a.json_out, "w", encoding="utf-8") as fh:
|
| 221 |
+
json.dump({"mode": mode, "tol": C.TOL, "per_game": per_game, "cases": rows},
|
| 222 |
+
fh, ensure_ascii=False, indent=2)
|
| 223 |
+
print("\nwrote %s" % a.json_out)
|
| 224 |
+
|
| 225 |
+
# --oracle and --empty are assertions, not reports: they must hit their fixed point on
|
| 226 |
+
# every scored cell, and the exit code is what a CI run reads.
|
| 227 |
+
if mode in ("oracle", "empty"):
|
| 228 |
+
want = 1.0 if mode == "oracle" else 0.0
|
| 229 |
+
bad = [r for r in rows if r["status"] != "ok" or r["reward"] != want]
|
| 230 |
+
print("\n%s self-check: %d/%d cells at %.1f -> %s"
|
| 231 |
+
% (mode, len(rows) - len(bad), len(rows), want, "PASS" if not bad else "FAIL"))
|
| 232 |
+
for r in bad[:10]:
|
| 233 |
+
print(" %-10s %-38s reward=%s %s"
|
| 234 |
+
% (r["game"], r["case_id"], r["reward"],
|
| 235 |
+
"" if r["status"] == "ok" else r["status"]))
|
| 236 |
+
return 1 if bad else 0
|
| 237 |
+
return 0
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
if __name__ == "__main__":
|
| 241 |
+
sys.exit(main())
|
tools/va_core.py
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
"""va_core.py -- the Video-Arena corpus contract: what a case is, and how it is scored.
|
| 4 |
+
|
| 5 |
+
Everything a driver needs is here and nothing else is. Four pieces:
|
| 6 |
+
|
| 7 |
+
1. resolve(game, case_id) -- the files that make up a case.
|
| 8 |
+
2. instruction_for(...) -- the task text for ONE protocol (see the marker note below).
|
| 9 |
+
3. extract_answer(...) -- pull the answer object out of a Protocol A chat reply.
|
| 10 |
+
4. run_judge(...) -- invoke the game's judge as a subprocess, read reward.json.
|
| 11 |
+
|
| 12 |
+
Pure standard library. No network, no model, no credentials: this module is about the
|
| 13 |
+
corpus, and it must be importable on a machine that has never seen an API key.
|
| 14 |
+
|
| 15 |
+
GT never reaches the model. resolve() returns the GT path because the OFFLINE scorer needs
|
| 16 |
+
it; a driver that hands r["gt"] to a prompt or into a sandbox has broken the benchmark, not
|
| 17 |
+
this module.
|
| 18 |
+
"""
|
| 19 |
+
import json
|
| 20 |
+
import os
|
| 21 |
+
import re
|
| 22 |
+
import subprocess
|
| 23 |
+
import sys
|
| 24 |
+
|
| 25 |
+
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
| 26 |
+
TASKS = os.path.join(ROOT, "tasks")
|
| 27 |
+
|
| 28 |
+
# ---- the scoring contract ------------------------------------------------------------
|
| 29 |
+
# The nine games share one layout, one headline metric, and ONE answer root key. They differ
|
| 30 |
+
# only in which judge computes it, and the two judges differ only in their CLI and in where
|
| 31 |
+
# they put the tier decomposition:
|
| 32 |
+
#
|
| 33 |
+
# F1 judge.py --answer/--gt/--out/--tol --primary strict
|
| 34 |
+
# tier decomposition under reward["tiers"]
|
| 35 |
+
# F2 the same CLI WITHOUT --primary (its headline is always the single coupled F1)
|
| 36 |
+
# tier decomposition under reward["detail"]
|
| 37 |
+
#
|
| 38 |
+
# TOL is the +/- seconds a predicted event time may differ from the reference and still
|
| 39 |
+
# match. It is 3.0 for every game; a run at another tolerance is a diagnostic, not a
|
| 40 |
+
# benchmark score.
|
| 41 |
+
TOL = 3.0
|
| 42 |
+
|
| 43 |
+
GAMES = ["go", "chess", "gomoku", "doudizhu", "cs2", "dota2", "sc2", "gfootball", "badminton"]
|
| 44 |
+
|
| 45 |
+
# ONE root key, every game: {"events": [ ...one complete tuple per row... ]}. A wrong root key is
|
| 46 |
+
# scored as an empty answer, indistinguishable from a model that saw nothing. Kept as a name
|
| 47 |
+
# rather than inlined because the runners record it per cell.
|
| 48 |
+
ROOT_KEY = {g: "events" for g in GAMES}
|
| 49 |
+
|
| 50 |
+
# The two judge families differ in where the tier block lands in reward.json and whether the
|
| 51 |
+
# judge accepts --primary. This is a property of the SCORER, not of the answer, so it is
|
| 52 |
+
# declared here rather than derived from the root key.
|
| 53 |
+
FAMILY = {"go": "F1", "chess": "F1", "gomoku": "F1", "doudizhu": "F1",
|
| 54 |
+
"gfootball": "F1", "badminton": "F1",
|
| 55 |
+
"cs2": "F2", "dota2": "F2", "sc2": "F2"}
|
| 56 |
+
REGIME = {"go": "board", "chess": "board", "gomoku": "board", "doudizhu": "card",
|
| 57 |
+
"cs2": "fps", "dota2": "moba", "sc2": "rts",
|
| 58 |
+
"gfootball": "sports", "badminton": "sports"}
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def case_ids(game):
|
| 62 |
+
"""The published 20 case ids for `game`, in the frozen order of cases.json."""
|
| 63 |
+
with open(os.path.join(TASKS, game, "cases.json"), encoding="utf-8") as fh:
|
| 64 |
+
return list(json.load(fh)["case_ids"])
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def resolve(game, case_id):
|
| 68 |
+
"""The files of one case. `video` and `instruction` are the ONLY model inputs."""
|
| 69 |
+
d = os.path.join(TASKS, game)
|
| 70 |
+
return {
|
| 71 |
+
"game": game,
|
| 72 |
+
"case_id": case_id,
|
| 73 |
+
"video": os.path.join(d, "media", case_id + ".mp4"),
|
| 74 |
+
"gt": os.path.join(d, "gt", case_id + "_gt.json"), # offline scorer only
|
| 75 |
+
"instruction": os.path.join(d, "instruction.md"),
|
| 76 |
+
"answer_seed": os.path.join(d, "answer_seed.json"),
|
| 77 |
+
"judge": os.path.join(d, "judge.py"),
|
| 78 |
+
"root_key": ROOT_KEY[game],
|
| 79 |
+
"family": FAMILY[game],
|
| 80 |
+
"tol": TOL,
|
| 81 |
+
"primary": None if FAMILY[game] == "F2" else "strict",
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
# ---- protocol-specific instruction text ----------------------------------------------
|
| 86 |
+
# One instruction.md per game serves both protocols, because the TASK is identical and only
|
| 87 |
+
# the DELIVERY differs: Protocol B writes answer.json in a sandbox over many turns, Protocol
|
| 88 |
+
# A returns one JSON object in one chat reply. The parts that differ are marked in the file:
|
| 89 |
+
#
|
| 90 |
+
# <!-- B-ONLY:START --> ... whole lines ... <!-- B-ONLY:END --> agentic only
|
| 91 |
+
# <!-- A-ONLY:START --> ... whole lines ... <!-- A-ONLY:END --> video only
|
| 92 |
+
# <!--B-->inline span<!--/B--> <!--A-->inline span<!--/A-->
|
| 93 |
+
#
|
| 94 |
+
# Marking rather than shipping two files is what keeps the protocols provably the same task:
|
| 95 |
+
# the per-game guidance lives once, and a change to the task reaches both protocols or
|
| 96 |
+
# neither. Always send instruction_for(protocol, path), never the raw file -- the raw file
|
| 97 |
+
# tells a model with no filesystem to write a file, and vice versa.
|
| 98 |
+
_MARK_RE = re.compile(r"<!--\s*/?[AB](?:-ONLY:(?:START|END))?\s*-->")
|
| 99 |
+
_KEEP = {"agentic": ("B", "A"), "video": ("A", "B"), "B": ("B", "A"), "A": ("A", "B")}
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def instruction_for(protocol, path):
|
| 103 |
+
"""Instruction text for ONE protocol: "agentic"/"B" or "video"/"A".
|
| 104 |
+
|
| 105 |
+
Fails closed. A surviving marker means the file is malformed (unbalanced or mistyped),
|
| 106 |
+
and raising is strictly better than sending the other protocol's delivery text -- or a
|
| 107 |
+
raw HTML comment -- to a model.
|
| 108 |
+
"""
|
| 109 |
+
keep, drop = _KEEP[protocol]
|
| 110 |
+
with open(path, "rb") as fh:
|
| 111 |
+
t = fh.read().decode("utf-8")
|
| 112 |
+
t = re.sub(r"(?ms)^<!-- " + drop + r"-ONLY:START -->\r?\n.*?^<!-- " + drop
|
| 113 |
+
+ r"-ONLY:END -->\r?\n?", "", t)
|
| 114 |
+
t = re.sub(r"(?s)<!--" + drop + r"-->.*?<!--/" + drop + r"-->", "", t)
|
| 115 |
+
t = re.sub(r"(?m)^<!-- " + keep + r"-ONLY:(?:START|END) -->\r?\n", "", t)
|
| 116 |
+
t = re.sub(r"<!--" + keep + r"-->|<!--/" + keep + r"-->", "", t)
|
| 117 |
+
left = _MARK_RE.findall(t)
|
| 118 |
+
if left:
|
| 119 |
+
raise ValueError("%s: unbalanced protocol marker(s) survived: %s" % (path, left[:4]))
|
| 120 |
+
return t
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
# ---- answer extraction (Protocol A) --------------------------------------------------
|
| 124 |
+
def _balanced_objects(text):
|
| 125 |
+
"""Yield (offset, source) for every TOP-LEVEL balanced {...}, ignoring braces inside
|
| 126 |
+
strings. Top-level only, so a single answer ROW that happens to carry the root key
|
| 127 |
+
cannot masquerade as the whole answer; an object left unclosed by a truncated response
|
| 128 |
+
is never yielded at all."""
|
| 129 |
+
depth = 0
|
| 130 |
+
start = -1
|
| 131 |
+
in_str = False
|
| 132 |
+
esc = False
|
| 133 |
+
for i, ch in enumerate(text):
|
| 134 |
+
if in_str:
|
| 135 |
+
if esc:
|
| 136 |
+
esc = False
|
| 137 |
+
elif ch == "\\":
|
| 138 |
+
esc = True
|
| 139 |
+
elif ch == '"':
|
| 140 |
+
in_str = False
|
| 141 |
+
continue
|
| 142 |
+
if ch == '"':
|
| 143 |
+
in_str = True
|
| 144 |
+
elif ch == "{":
|
| 145 |
+
if depth == 0:
|
| 146 |
+
start = i
|
| 147 |
+
depth += 1
|
| 148 |
+
elif ch == "}" and depth:
|
| 149 |
+
depth -= 1
|
| 150 |
+
if depth == 0:
|
| 151 |
+
yield start, text[start:i + 1]
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
def answer_candidates(text, root_key="events"):
|
| 155 |
+
"""Every parseable top-level JSON object in `text` carrying `root_key`, in order.
|
| 156 |
+
|
| 157 |
+
More than one is worth recording: the Protocol A prompt asks for exactly one object, so
|
| 158 |
+
a second candidate means the reply held a schema sketch, a per-segment dump, or the same
|
| 159 |
+
answer twice.
|
| 160 |
+
"""
|
| 161 |
+
out = []
|
| 162 |
+
for start, src in _balanced_objects(text or ""):
|
| 163 |
+
try:
|
| 164 |
+
obj = json.loads(src)
|
| 165 |
+
except Exception:
|
| 166 |
+
continue
|
| 167 |
+
if isinstance(obj, dict) and root_key in obj:
|
| 168 |
+
rows = obj[root_key]
|
| 169 |
+
out.append({"start": start, "obj": obj,
|
| 170 |
+
"n_rows": len(rows) if isinstance(rows, (list, dict)) else 0})
|
| 171 |
+
return out
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
def extract_answer(text, root_key="events"):
|
| 175 |
+
"""Pull the answer object out of a chat reply: a fenced json block, a bare object with
|
| 176 |
+
`root_key`, or a bare list (wrapped under it).
|
| 177 |
+
|
| 178 |
+
Among all top-level objects carrying `root_key`, take the one with the MOST rows; ties
|
| 179 |
+
go to the one appearing LAST. A model that prints a one-row schema sketch before its
|
| 180 |
+
real answer must not be scored on the sketch, and a model that emits several fences must
|
| 181 |
+
not be scored on an empty early one.
|
| 182 |
+
"""
|
| 183 |
+
if not text:
|
| 184 |
+
raise ValueError("empty model response")
|
| 185 |
+
cands = answer_candidates(text, root_key)
|
| 186 |
+
if cands:
|
| 187 |
+
return max(cands, key=lambda c: (c["n_rows"], c["start"]))["obj"]
|
| 188 |
+
try:
|
| 189 |
+
obj = json.loads(text)
|
| 190 |
+
if isinstance(obj, dict) and root_key in obj:
|
| 191 |
+
return obj
|
| 192 |
+
if isinstance(obj, list):
|
| 193 |
+
return {root_key: obj}
|
| 194 |
+
except Exception:
|
| 195 |
+
pass
|
| 196 |
+
raise ValueError("no JSON object with a %r key found in response" % root_key)
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
# ---- Protocol A delivery ---------------------------------------------------------------
|
| 200 |
+
# The single-reply tail appended to the A-rendered instruction, verbatim from the paper's
|
| 201 |
+
# Protocol A prompt (appendix, "the frozen prompts"). The native runner and the Harbor agent
|
| 202 |
+
# both build their prompt here, so the two paths send the same text.
|
| 203 |
+
A_TAIL_HEAD = "---\nYou are given the match as "
|
| 204 |
+
_A_TAIL = A_TAIL_HEAD + """{n} frames, uniformly sampled from a {dur}-second video \
|
| 205 |
+
(one frame every {dt} video-seconds). Frame k (0-indexed) is at video_ts[k], in seconds:
|
| 206 |
+
video_ts = [{ts}]. Use these exact values for timestamps; do not recompute them.
|
| 207 |
+
|
| 208 |
+
This is one reply and there are no tools: no sandbox, no file to write, no second turn, \
|
| 209 |
+
and nothing runs after you stop. You may reason here first if it helps.
|
| 210 |
+
|
| 211 |
+
Your answer is the LAST ```json fenced block in this reply. It must hold the COMPLETE JSON
|
| 212 |
+
object with the single `{root_key}` key -- every row you want scored, in that one block.
|
| 213 |
+
Print no other JSON anywhere in the reply: no schema sketch, no partial dump, no repeat of
|
| 214 |
+
the answer. Nothing outside that last block is read.
|
| 215 |
+
"""
|
| 216 |
+
_CANARY_RE = re.compile(r"\n*<!-- CANARY:[^\n]*-->\s*$") # a file marker, not prompt text
|
| 217 |
+
_AGENTIC_TEXT = ("answer.json", "match.mp4", "ffmpeg", "ffprobe", "sandbox")
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
def protocol_a_prompt(instruction, duration_s, ts, fps, root_key="events"):
|
| 221 |
+
"""The whole Protocol A text: the A-rendered instruction (instruction_for("video", ...)),
|
| 222 |
+
then the single-reply tail carrying the grid's explicit video_ts array. It passes
|
| 223 |
+
check_protocol_a_prompt() before it is returned."""
|
| 224 |
+
tail = _A_TAIL.format(n=len(ts), dur="%.1f" % duration_s, dt="%.2f" % (1.0 / fps),
|
| 225 |
+
ts=", ".join("%.2f" % t for t in ts), root_key=root_key)
|
| 226 |
+
body = _CANARY_RE.sub("", instruction.replace("\r\n", "\n")).rstrip("\n")
|
| 227 |
+
prompt = body + "\n\n" + tail
|
| 228 |
+
check_protocol_a_prompt(prompt, root_key)
|
| 229 |
+
return prompt
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
def check_protocol_a_prompt(prompt, root_key="events"):
|
| 233 |
+
"""The pre-flight check, run before any tokens are spent: reject a Protocol A prompt that
|
| 234 |
+
still carries agentic delivery text, lacks the single-reply tail, or whose tail does not
|
| 235 |
+
name the schema's root key."""
|
| 236 |
+
body, head, tail = prompt.rpartition(A_TAIL_HEAD)
|
| 237 |
+
if not head:
|
| 238 |
+
raise ValueError("Protocol A prompt has no single-reply tail")
|
| 239 |
+
leaked = [w for w in _AGENTIC_TEXT if w in body]
|
| 240 |
+
if leaked:
|
| 241 |
+
raise ValueError("Protocol A prompt carries agentic delivery text: %s" % leaked)
|
| 242 |
+
if "This is one reply and there are no tools" not in tail \
|
| 243 |
+
or "`%s`" % root_key not in tail:
|
| 244 |
+
raise ValueError("Protocol A tail is incomplete or does not name the root key %r"
|
| 245 |
+
% root_key)
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
# ---- scoring -------------------------------------------------------------------------
|
| 249 |
+
def run_judge(game, answer_path, gt_path, out_path, tol=TOL):
|
| 250 |
+
"""Score one case: run the game's judge as a SUBPROCESS and return the reward dict.
|
| 251 |
+
|
| 252 |
+
A subprocess, not an import: the judges are nine independent single-file programs that
|
| 253 |
+
share module names, and invoking them exactly the way their CLI documents them is what
|
| 254 |
+
lets anyone reproduce a published number by hand.
|
| 255 |
+
"""
|
| 256 |
+
meta = resolve(game, "_")
|
| 257 |
+
cmd = [sys.executable, meta["judge"], "--answer", answer_path, "--gt", gt_path,
|
| 258 |
+
"--out", out_path, "--tol", str(tol)]
|
| 259 |
+
if meta["primary"]:
|
| 260 |
+
cmd += ["--primary", meta["primary"]]
|
| 261 |
+
subprocess.run(cmd, check=True, capture_output=True, text=True,
|
| 262 |
+
encoding="utf-8", errors="replace")
|
| 263 |
+
with open(out_path, encoding="utf-8") as fh:
|
| 264 |
+
return json.load(fh)
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
def subscores(reward):
|
| 268 |
+
"""Headline + per-tier diagnostics out of a reward.json, across both judge families.
|
| 269 |
+
|
| 270 |
+
The headline is always reward["reward"] (strict tuple F1). The tier keys are NOT
|
| 271 |
+
uniform, and guessing wrong would blank a column -- and a blank reads as "not measured"
|
| 272 |
+
rather than "we looked in the wrong place". So: try F1's `tiers` block, fall back to
|
| 273 |
+
F2's `detail`, and inside each accept every key a shipped judge actually writes.
|
| 274 |
+
|
| 275 |
+
T3's metric varies by game: board / card / MOBA / RTS score a class label (macro
|
| 276 |
+
accuracy over {A, B, equal}); badminton and gfootball score an exact integer score pair
|
| 277 |
+
(exact_pair_acc); cs2 scores the exact cumulative pair (exact_frac). All three live in
|
| 278 |
+
the same column because all three answer "did it track the state".
|
| 279 |
+
"""
|
| 280 |
+
t = reward.get("tiers")
|
| 281 |
+
if t:
|
| 282 |
+
t3 = t.get("t3_situation") or t.get("t3_score") or {}
|
| 283 |
+
t3v = t3.get("macro_acc")
|
| 284 |
+
if t3v is None:
|
| 285 |
+
t3v = t3.get("exact_pair_acc")
|
| 286 |
+
return {"reward": reward.get("reward"),
|
| 287 |
+
"t1_f1": (t.get("t1_localization") or {}).get("f1"),
|
| 288 |
+
"t2_macro_acc": (t.get("t2_impact") or {}).get("macro_acc"),
|
| 289 |
+
"t3_macro_acc": t3v}
|
| 290 |
+
d = reward.get("detail", {})
|
| 291 |
+
t2 = d.get("t2_round_winner") or d.get("t2_minute_gain_event") or d.get("t2_impact") or {}
|
| 292 |
+
t3 = (d.get("t3_score_track") or d.get("t3_leader_after_event")
|
| 293 |
+
or d.get("t3_situation") or {})
|
| 294 |
+
t3v = t3.get("exact_frac")
|
| 295 |
+
if t3v is None:
|
| 296 |
+
t3v = t3.get("macro_acc")
|
| 297 |
+
return {"reward": reward.get("reward"),
|
| 298 |
+
"t1_f1": (d.get("t1_localization") or {}).get("f1"),
|
| 299 |
+
"t2_macro_acc": t2.get("macro_acc"),
|
| 300 |
+
"t3_macro_acc": t3v}
|
| 301 |
+
|
| 302 |
+
|
| 303 |
+
def t1_recall_ceiling(duration_s, n_frames, tol=TOL):
|
| 304 |
+
"""Highest T1 recall a uniform `n_frames` grid can reach on a `duration_s` video.
|
| 305 |
+
|
| 306 |
+
With frame spacing d = duration / n_frames, an event lies within `tol` of some sampled
|
| 307 |
+
frame at most min(1, 2*tol/d) of the time. Protocol A on a long match is therefore
|
| 308 |
+
capped BELOW 1 by its own sampling grid, and recording that alongside the score is what
|
| 309 |
+
separates "the model missed the event" from "no frame was close enough to it".
|
| 310 |
+
"""
|
| 311 |
+
if not n_frames or duration_s <= 0:
|
| 312 |
+
return 0.0
|
| 313 |
+
d = float(duration_s) / float(n_frames)
|
| 314 |
+
return min(1.0, 2.0 * float(tol) / d) if d > 0 else 1.0
|
| 315 |
+
|
| 316 |
+
|
| 317 |
+
def case_meta(game):
|
| 318 |
+
"""The build-time tags of every case of `game`, keyed by case id (CASE_TYPES.json).
|
| 319 |
+
|
| 320 |
+
Read-only passthrough: the generation scripts use it for task metadata and nothing in the
|
| 321 |
+
scoring path touches it. The id key is `id` for the four games whose cases.json carries it
|
| 322 |
+
and `case_id` for the rest.
|
| 323 |
+
"""
|
| 324 |
+
path = os.path.join(TASKS, game, "CASE_TYPES.json")
|
| 325 |
+
if not os.path.isfile(path):
|
| 326 |
+
return {}
|
| 327 |
+
with open(path, encoding="utf-8") as fh:
|
| 328 |
+
doc = json.load(fh)
|
| 329 |
+
out = {}
|
| 330 |
+
for row in doc.get("cases", []):
|
| 331 |
+
key = row.get("id", row.get("case_id"))
|
| 332 |
+
if key:
|
| 333 |
+
out[key] = row
|
| 334 |
+
return out
|
| 335 |
+
|
| 336 |
+
|
| 337 |
+
def build_harbor_prompt(max_turns=200, timeout_s=7200):
|
| 338 |
+
"""Protocol B's turn-1 prompt, written for the Harbor sandbox (working directory /app).
|
| 339 |
+
|
| 340 |
+
Same contract as tools/run_protocol_b.py: one deliverable, `answer.json`, filled in as the
|
| 341 |
+
run goes; a text reply is not an answer. State it with the sandbox's own paths so the agent
|
| 342 |
+
never has to guess where `instruction.md` and `match.mp4` are, and so the no-network rule is
|
| 343 |
+
stated where it can be obeyed.
|
| 344 |
+
"""
|
| 345 |
+
minutes = round(timeout_s / 60)
|
| 346 |
+
budget = ("You have at most %d tool-call turns and about %d minutes of wall-clock time. "
|
| 347 |
+
"When either limit is reached you are stopped immediately." % (max_turns, minutes))
|
| 348 |
+
return """You are a HEADLESS autonomous agent -- there is no human to talk to. Communicate ONLY by
|
| 349 |
+
calling tools (running commands, reading and writing files); a text reply is not an answer. Your
|
| 350 |
+
one deliverable is the file `answer.json` in `/app`.
|
| 351 |
+
|
| 352 |
+
Read `/app/instruction.md` for the task and the exact `answer.json` schema. Your only input is the
|
| 353 |
+
video `/app/match.mp4`. The video plays at 1:1 real speed; `instruction.md` says exactly which
|
| 354 |
+
clock each time field you report is on.
|
| 355 |
+
|
| 356 |
+
Solve it yourself, from the video. Do not use the network for anything, and there is none: no
|
| 357 |
+
downloading or installing packages, models or weights, no calls to any external service, API or
|
| 358 |
+
model, and no looking this match up. Everything you need is already installed -- ffmpeg and
|
| 359 |
+
ffprobe, Python with numpy/OpenCV/Pillow and the usual numeric stack, tesseract for on-screen
|
| 360 |
+
text. The shell, that Python, and those video tools are your only tools.
|
| 361 |
+
|
| 362 |
+
`answer.json` already exists in `/app` -- created before your first turn, holding the schema's
|
| 363 |
+
root key and an empty list. Do not delete it, do not rename it, and do not change the root key.
|
| 364 |
+
Overwrite it in place -- in full, valid JSON every time -- as soon as you have something to put
|
| 365 |
+
in it, and keep overwriting it as you learn more. It must be valid JSON at every moment: rewrite
|
| 366 |
+
it in full each time (read -> add -> write back), never leave it half-written. Each rewrite should
|
| 367 |
+
contain everything the previous one had, plus the new rows; if you are deep into the video and the
|
| 368 |
+
file is not getting longer, you are overwriting instead of appending.
|
| 369 |
+
|
| 370 |
+
Whatever is in `answer.json` when the run stops is what gets scored. If you are cut off, every row
|
| 371 |
+
already written still counts; rows kept only in your reasoning, to be written out at the end,
|
| 372 |
+
score zero.
|
| 373 |
+
|
| 374 |
+
%s Everything else -- including how you sample the video -- is up to you.""" % budget
|
| 375 |
+
|
| 376 |
+
|
| 377 |
+
if __name__ == "__main__":
|
| 378 |
+
# Self-check: enumerate every case and confirm each of its files is on disk.
|
| 379 |
+
missing = 0
|
| 380 |
+
for g in GAMES:
|
| 381 |
+
ids = case_ids(g)
|
| 382 |
+
for cid in ids:
|
| 383 |
+
r = resolve(g, cid)
|
| 384 |
+
for k in ("video", "gt", "instruction", "judge", "answer_seed"):
|
| 385 |
+
if not os.path.isfile(r[k]):
|
| 386 |
+
print("MISSING %s/%s %s: %s" % (g, cid, k, r[k]))
|
| 387 |
+
missing += 1
|
| 388 |
+
print("%-10s %2d cases family=%s root_key=%s" % (g, len(ids), FAMILY[g], ROOT_KEY[g]))
|
| 389 |
+
print("missing files: %d" % missing)
|
| 390 |
+
raise SystemExit(1 if missing else 0)
|