File size: 2,548 Bytes
2bc1c6b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
"""Bootstrap: cache all 25 public ARC-AGI-3 games locally (one-time, ~3 MB).

    python ops/fetch_games.py                 # -> ./environment_files/
    python ops/fetch_games.py --dir /data/env # custom cache dir
    python ops/fetch_games.py --list          # live game list from the API

After this every eval/collection run uses OperationMode.OFFLINE (zero
network, unlimited instances). No Kaggle account or competition rules are
required: the arcade API issues an anonymous key automatically. (The
kagglehub competition download needs a KGAT token + accepted rules; this
toolkit path does not.)
"""
from __future__ import annotations

import argparse
import sys
import time
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))

DEFAULT_GAMES = [
    "ar25", "bp35", "cd82", "cn04", "dc22", "ft09", "g50t", "ka59",
    "lf52", "lp85", "ls20", "m0r0", "r11l", "re86", "s5i5", "sb26",
    "sc25", "sk48", "sp80", "su15", "tn36", "tr87", "tu93", "vc33", "wa30",
]


def main() -> None:
    ap = argparse.ArgumentParser(description=__doc__.splitlines()[0])
    ap.add_argument("--dir", default=str(Path(__file__).resolve().parents[1] / "environment_files"))
    ap.add_argument("--list", action="store_true", help="list games and exit")
    args = ap.parse_args()

    import arc_agi
    from arc_agi import OperationMode

    arc = arc_agi.Arcade(operation_mode=OperationMode.NORMAL,
                         environments_dir=args.dir)
    try:
        live = [e.game_id.split("-")[0] for e in arc.get_environments()]
    except Exception as exc:
        print(f"[warn] API listing failed ({exc}); using static list")
        live = DEFAULT_GAMES
    ids = live or DEFAULT_GAMES

    if args.list:
        print("\n".join(ids))
        print(f"-- {len(ids)} games available from the arcade API", file=sys.stderr)
        return

    print(f"cache dir: {args.dir}; {len(ids)} games")
    ok, fail = [], []
    for gid in ids:
        t0 = time.time()
        try:
            env = arc.make(gid)
            if env is None:
                raise RuntimeError("make() returned None")
            ok.append(gid)
            print(f"  {gid}: OK ({time.time() - t0:.1f}s)", flush=True)
        except Exception as exc:
            fail.append(gid)
            print(f"  {gid}: FAIL {type(exc).__name__}: {exc}", flush=True)

    print(f"downloaded={len(ok)} failed={len(fail)}" + (f" {fail}" if fail else ""))
    sys.exit(1 if fail else 0)


if __name__ == "__main__":
    main()