From 1f886fb0447054055d7efdf50b0e265d553181cd Mon Sep 17 00:00:00 2001 From: hanzy Date: Mon, 23 Nov 2026 07:17:30 +0000 Subject: [PATCH 1/3] Add SlimeVolleyGym standard benchmark --- .github/workflows/slimevolley.yml | 53 +++++++++++ configs/game_benchmarks.toml | 3 + configs/game_suites/slimevolley.toml | 10 ++ .../benchmarks/slimevolley/SOURCE.json | 8 ++ .../benchmarks/slimevolley/adapter.py | 66 +++++++++++++ .../benchmarks/slimevolley/instance_schema.py | 31 +++++++ .../benchmarks/slimevolley/metric_rules.py | 22 +++++ .../benchmarks/slimevolley/requirements.txt | 9 ++ .../images/slimevolley-files/FILES.json | 10 ++ .../images/slimevolley-files/VERSION | 1 + game_first_exam/tasks/slimevolley/README.md | 9 ++ .../DIGEST | 1 + .../README.md | 35 +++++++ .../environment/Dockerfile | 10 ++ .../environment/docker-compose.yaml | 43 +++++++++ .../environment/rcb_monitor/limits.json | 26 ++++++ .../environment/sim/Dockerfile | 15 +++ .../environment/sim/instance.json | 33 +++++++ .../instruction.md | 41 +++++++++ .../solution/actions.json | 1 + .../solution/solve.sh | 13 +++ .../task.toml | 62 +++++++++++++ .../tests/Dockerfile | 11 +++ .../tests/instance.json | 33 +++++++ .../tests/rcb_limits.json | 26 ++++++ .../tests/test.sh | 6 ++ .../benchmarks/slimevolley/exported.toml | 7 ++ game_first_exam/tests/test_game_harbor.py | 6 +- .../tests/test_slimevolley_native.py | 92 +++++++++++++++++++ scripts/task_conventions.py | 7 ++ scripts/task_resources.toml | 6 ++ 31 files changed, 694 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/slimevolley.yml create mode 100644 configs/game_suites/slimevolley.toml create mode 100644 game_first_exam/benchmarks/slimevolley/SOURCE.json create mode 100644 game_first_exam/benchmarks/slimevolley/adapter.py create mode 100644 game_first_exam/benchmarks/slimevolley/instance_schema.py create mode 100644 game_first_exam/benchmarks/slimevolley/metric_rules.py create mode 100644 game_first_exam/benchmarks/slimevolley/requirements.txt create mode 100644 game_first_exam/images/slimevolley-files/FILES.json create mode 100644 game_first_exam/images/slimevolley-files/VERSION create mode 100644 game_first_exam/tasks/slimevolley/README.md create mode 100644 game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/DIGEST create mode 100644 game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/README.md create mode 100644 game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/Dockerfile create mode 100644 game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/docker-compose.yaml create mode 100644 game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/rcb_monitor/limits.json create mode 100644 game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/sim/Dockerfile create mode 100644 game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/sim/instance.json create mode 100644 game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/instruction.md create mode 100644 game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/solution/actions.json create mode 100755 game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/solution/solve.sh create mode 100644 game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/task.toml create mode 100644 game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/tests/Dockerfile create mode 100644 game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/tests/instance.json create mode 100644 game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/tests/rcb_limits.json create mode 100755 game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/tests/test.sh create mode 100644 game_first_exam/tests/benchmarks/slimevolley/exported.toml create mode 100644 game_first_exam/tests/test_slimevolley_native.py diff --git a/.github/workflows/slimevolley.yml b/.github/workflows/slimevolley.yml new file mode 100644 index 0000000..27ee654 --- /dev/null +++ b/.github/workflows/slimevolley.yml @@ -0,0 +1,53 @@ +name: slimevolley +on: + pull_request: + push: + branches: [main] + workflow_dispatch: +permissions: + contents: read +jobs: + smoke: + runs-on: ubuntu-latest + timeout-minutes: 30 + env: + TASK: game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard + steps: + - uses: actions/checkout@v4 + with: {persist-credentials: false} + - uses: actions/setup-python@v5 + with: {python-version: '3.12'} + - uses: docker/setup-docker-action@v5 + with: + version: v29.5.2 + set-host: true + daemon-config: '{"features":{"containerd-snapshotter":true}}' + - run: python -m pip install -e . + - run: harbor run --game-suite slimevolley --standard --list + - name: Compare against the pinned native simulator + run: | + python scripts/files_image.py build game-files + python scripts/files_image.py build slimevolley-files + docker build -t slimevolley-native "$TASK/environment/sim" + docker run --rm --network none -v "$PWD:/repo:ro" slimevolley-native \ + python /repo/game_first_exam/tests/test_slimevolley_native.py + - name: Run SlimeVolley with a frozen reference + run: | + harbor run --game-suite slimevolley --standard \ + -c configs/harbor/oracle.json --plugin game_harbor:GameRecords \ + --job-name fresh-slimevolley -y + - name: Check the match and decode the replay + run: | + python - <<'PY' + import json + from pathlib import Path + job = Path("jobs/fresh-slimevolley") + summary = json.loads((job / "game-report/summary.json").read_text()) + assert summary["complete"] and summary["valid_trials"] == 1 + episode, = summary["trials"] + assert (episode["primary_score"], episode["success"], episode["steps"]) == (1, 1, 3000) + assert episode["terminal_reason"] == "native_truncated" + assert json.loads((job / "runtime-images.json").read_text())["complete"] + PY + docker run --rm --network none -v "$PWD/jobs:/jobs:ro" slimevolley-native sh -ec \ + '"$(python -c "import imageio_ffmpeg; print(imageio_ffmpeg.get_ffmpeg_exe())")" -v error -xerror -i /jobs/fresh-slimevolley/*/artifacts/data/replay.mp4 -f null -' diff --git a/configs/game_benchmarks.toml b/configs/game_benchmarks.toml index 8f77b59..e95e40f 100644 --- a/configs/game_benchmarks.toml +++ b/configs/game_benchmarks.toml @@ -12,5 +12,8 @@ schema = "game_first_exam/benchmarks/textworld/instance_schema.py" [benchmarks.babaisai] schema = "game_first_exam/benchmarks/babaisai/instance_schema.py" +[benchmarks.slimevolley] +schema = "game_first_exam/benchmarks/slimevolley/instance_schema.py" + [benchmarks.minihack] schema = "game_first_exam/benchmarks/minihack/instance_schema.py" diff --git a/configs/game_suites/slimevolley.toml b/configs/game_suites/slimevolley.toml new file mode 100644 index 0000000..b0e2e6d --- /dev/null +++ b/configs/game_suites/slimevolley.toml @@ -0,0 +1,10 @@ +schema_version = "game-suite/2.1" +version = "1.0.0" +tier = "smoke" +name = "games-slimevolley-v1.0.0" +files_images = ["connection-files", "game-files", "slimevolley-files"] + +[[tasks]] +name = "slimevolley-pixel-vs-baseline-i01-standard" +benchmark = "slimevolley" +family = "pixel-vs-baseline" diff --git a/game_first_exam/benchmarks/slimevolley/SOURCE.json b/game_first_exam/benchmarks/slimevolley/SOURCE.json new file mode 100644 index 0000000..a1d9315 --- /dev/null +++ b/game_first_exam/benchmarks/slimevolley/SOURCE.json @@ -0,0 +1,8 @@ +{ + "repository": "https://github.com/hardmaru/slimevolleygym", + "commit": "8ac22434fc5a587a3395311f7854aeda17d10303", + "archive_url": "https://codeload.github.com/hardmaru/slimevolleygym/tar.gz/8ac22434fc5a587a3395311f7854aeda17d10303", + "archive_sha256": "07e285d85edb443ecd602132f7ed72d42ff2580bca5854431882407b224d5ec8", + "license": "Apache-2.0", + "modifications": "none" +} diff --git a/game_first_exam/benchmarks/slimevolley/adapter.py b/game_first_exam/benchmarks/slimevolley/adapter.py new file mode 100644 index 0000000..acb9d91 --- /dev/null +++ b/game_first_exam/benchmarks/slimevolley/adapter.py @@ -0,0 +1,66 @@ +"""Native SlimeVolley pixel play against the built-in left-side policy.""" + +from importlib.metadata import version + +from slimevolleygym.slimevolley import SlimeVolleyAtariEnv +from contracts import Capabilities, Transition +from encoding import png, state_hash + +ACTIONS = ("idle", "left", "left_jump", "jump", "right_jump", "right") + + +class Adapter: + def __init__(self, instance, assets=None): + for package, expected in instance["engine_versions"].items(): + if version(package) != expected: + raise ValueError(f"SlimeVolley dependency version mismatch: {package}") + self.env = SlimeVolleyAtariEnv() + if self.env.t_limit != instance["native_max_steps"] or self.env.action_space.n != len(ACTIONS): + raise ValueError("SlimeVolley native limits or actions changed") + self.env.seed(instance["seed"]) + self.image = self.env.reset() + self.ended = False + + def spec(self): + return { + "adapter_version": "1.0.0", + "capabilities": Capabilities(images=True, action_mode="enum", native_truncation=True).to_dict(), + "action_schema": {"type": "string", "enum": list(ACTIONS)}, + "observation": "Native 168×84 RGB frame from the right player's match.", + } + + def observe(self): + return {"image_png_base64": png(self.image)} + + def step(self, action): + if self.ended: + raise ValueError("episode closed") + self.image, reward, self.ended, info = self.env.step(ACTIONS.index(action)) + terminated = min(info["ale.lives"], info["ale.otherLives"]) == 0 + return Transition(float(reward), terminated, bool(self.ended and not terminated)) + + def success(self): + game = self.env.game + return self.ended and game.agent_right.life > game.agent_left.life + + def metrics(self): + game = self.env.game + right, left = game.agent_right.life, game.agent_left.life + return {"native_return": right - left, "right_lives": right, "left_lives": left, + "points_for": 5 - left, "points_against": 5 - right, "native_steps": self.env.t} + + def fingerprint(self): + game = self.env.game + players = [vars(player) | {"state": vars(player.state)} + for player in (game.agent_right, game.agent_left)] + return state_hash({ + "players": players, "ball": vars(game.ball), "delay": game.delayScreen.life, + "opponent_rnn": self.env.policy.outputState, "steps": self.env.t, + "rng": game.np_random.bit_generator.state, + }) + + def frame(self): + return self.image + + def close(self): + self.env.close() diff --git a/game_first_exam/benchmarks/slimevolley/instance_schema.py b/game_first_exam/benchmarks/slimevolley/instance_schema.py new file mode 100644 index 0000000..87d430c --- /dev/null +++ b/game_first_exam/benchmarks/slimevolley/instance_schema.py @@ -0,0 +1,31 @@ +"""Frozen native pixel match configuration, shared by preflight, sim and verifier.""" + +from config_schema import validate_engine_versions + +SCHEMA_VERSION = "1.0.0" +BENCHMARK = "slimevolley" +FIELDS = {"engine_versions", "engine_commit", "native_max_steps", "opponent"} +METRICS = {"native_return"} +PROFILES = {"native-rgb-v1"} +REDUCERS = {("family_macro", "1.0.0")} +ENGINE_COMMIT = "8ac22434fc5a587a3395311f7854aeda17d10303" +ENGINE_VERSIONS = { + "slimevolleygym": "0.1.0", + "gym": "0.25.0", + "numpy": "1.26.4", + "opencv-python-headless": "4.11.0.86", +} + + +def validate(value): + validate_engine_versions(value["engine_versions"], ENGINE_VERSIONS) + if value["engine_commit"] != ENGINE_COMMIT or value["opponent"] != "native-baseline": + raise ValueError("unsupported SlimeVolley engine or opponent") + if (value["env_id"] != "SlimeVolleyNoFrameskip-v0" or value["family"] != "pixel-vs-baseline" + or type(value["native_max_steps"]) is not int or value["native_max_steps"] != 3000 + or value["max_steps"] is not None): + raise ValueError("unsupported native SlimeVolley match configuration") + if value["capabilities"] != { + "images": True, "action_mode": "enum", "timing": "action-stepped", "native_truncation": True, + }: + raise ValueError("SlimeVolley requires the native RGB action-stepped profile") diff --git a/game_first_exam/benchmarks/slimevolley/metric_rules.py b/game_first_exam/benchmarks/slimevolley/metric_rules.py new file mode 100644 index 0000000..6512069 --- /dev/null +++ b/game_first_exam/benchmarks/slimevolley/metric_rules.py @@ -0,0 +1,22 @@ +"""Validate the native match result and Game Exam's end flags.""" + + +def validate_metrics(final, instance): + metrics = final["metrics"] + right, left = (metrics[key] for key in ("right_lives", "left_lives")) + if any(type(lives) is not int or not 0 <= lives <= 5 for lives in (right, left)) or right == left == 0: + raise ValueError("invalid SlimeVolley lives") + steps = final["steps"] + if (type(metrics["native_steps"]) is not int or metrics["native_steps"] != steps + or not 5 * 2 - right - left <= steps <= instance["native_max_steps"]): + raise ValueError("invalid SlimeVolley native step count") + terminated = min(right, left) == 0 + truncated = not terminated and steps == instance["native_max_steps"] + if (final["terminated"], final["truncated"]) != (terminated, truncated): + raise ValueError("inconsistent SlimeVolley ending") + if final["success"] != ((terminated or truncated) and right > left): + raise ValueError("inconsistent SlimeVolley success") + expected = {"points_for": 5 - left, "points_against": 5 - right, "native_return": right - left} + if (any(type(metrics[key]) is not int or metrics[key] != value for key, value in expected.items()) + or final["return"] != expected["native_return"]): + raise ValueError("inconsistent SlimeVolley score") diff --git a/game_first_exam/benchmarks/slimevolley/requirements.txt b/game_first_exam/benchmarks/slimevolley/requirements.txt new file mode 100644 index 0000000..7debcbf --- /dev/null +++ b/game_first_exam/benchmarks/slimevolley/requirements.txt @@ -0,0 +1,9 @@ +cloudpickle==3.1.3 +gym==0.25.0 +gym-notices==0.1.0 +imageio==2.37.0 +imageio-ffmpeg==0.6.0 +numpy==1.26.4 +opencv-python-headless==4.11.0.86 +pillow==10.4.0 +slimevolleygym @ https://codeload.github.com/hardmaru/slimevolleygym/tar.gz/8ac22434fc5a587a3395311f7854aeda17d10303#sha256=07e285d85edb443ecd602132f7ed72d42ff2580bca5854431882407b224d5ec8 diff --git a/game_first_exam/images/slimevolley-files/FILES.json b/game_first_exam/images/slimevolley-files/FILES.json new file mode 100644 index 0000000..8a803ef --- /dev/null +++ b/game_first_exam/images/slimevolley-files/FILES.json @@ -0,0 +1,10 @@ +{ + "source": "game_first_exam/benchmarks/slimevolley", + "files": { + "adapter.py": "68e44fe79f3ad5c95b6d4360ee1b7b83cf71f0ad1d8fffb79701abfab594c96b", + "instance_schema.py": "d7d64922091affdac8358788e5d1a75360239e084eff6e7bcda9b8a715f3c6f3", + "metric_rules.py": "71176460c3ed478eace168ca137d99b7573dd07d83d0d36f6a86417fcb27e8ee", + "requirements.txt": "582e1ca4246fd52c08d0adad3df2e34e978e7243ffdc89d9188769049f3c2438" + }, + "image": "ghcr.io/mll-lab-nu/efe:slimevolley-files-1.0.0@sha256:bb15a9bd6fefc604d6961778781bb04e19abcfa6913e289ff743af7ccaab54d5" +} diff --git a/game_first_exam/images/slimevolley-files/VERSION b/game_first_exam/images/slimevolley-files/VERSION new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/game_first_exam/images/slimevolley-files/VERSION @@ -0,0 +1 @@ +1.0.0 diff --git a/game_first_exam/tasks/slimevolley/README.md b/game_first_exam/tasks/slimevolley/README.md new file mode 100644 index 0000000..caa9797 --- /dev/null +++ b/game_first_exam/tasks/slimevolley/README.md @@ -0,0 +1,9 @@ +# SlimeVolleyGym + +One frozen standard match in native `SlimeVolleyNoFrameskip-v0`. The coding agent controls the right player using native 168×84 RGB frames and the six native discrete controls. The unmodified built-in RNN controls the left side. The host records the match through the shared standard service. + +The [pinned Apache-2.0 source](../../benchmarks/slimevolley/SOURCE.json) is installed into the simulator from a hash-checked archive. It uses the native four-value Gym interface and OpenCV headless. The adapter caches native frames, translates the native ending into life exhaustion or the 3000-frame limit, and leaves the separate Harbor wall-clock cutoff to the shared service. + +The primary score is native net points. A completed match with positive net points counts as a success. At an earlier cutoff, net points still count. The offline oracle replays a fixed action list generated using the native state-space baseline on the right. It verifies the match, client and grader without representing a pixel policy. + +Run `harbor run --game-suite slimevolley --standard --list` to view the frozen task. diff --git a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/DIGEST b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/DIGEST new file mode 100644 index 0000000..33d2c7f --- /dev/null +++ b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/DIGEST @@ -0,0 +1 @@ +sha256:a801f829754720af17582337c7534cc24aa2ead38bac6cea25f2e4dd8336f774 diff --git a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/README.md b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/README.md new file mode 100644 index 0000000..abba35a --- /dev/null +++ b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/README.md @@ -0,0 +1,35 @@ +# slimevolley-pixel-vs-baseline-i01-standard + +| | | +|---|---| +| Benchmark | SlimeVolleyGym | +| Mode | standard (`game-standard/2.2`) | +| Twin | — (none: SlimeVolleyGym has no privileged mode, PROTOCOL §2) | +| Simulator / robot | `slimevolley` / `game-agent` | +| Family / instance | `pixel-vs-baseline` / seed 2117382936 | +| Oracle | `full` | +| Agent time budget | 600 s; tokens: protocol default (docs/protocol/running.md "Official runs") | +| Base image | `docker.io/library/python:3.12.10-slim-bookworm@sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db` | + +## Task +Control the right player in one native pixel match against the built-in left player. + +## Difficulty +Continuous motion, pixel-based ball tracking and timed jumps. + +## Reference solution +A frozen offline state-policy trace earns +1 in 3000 frames. The oracle uses the same public action client as the coding agent. + +## Verification +The independent verifier checks the sealed native score, lives, steps and ending against its frozen instance. + +## Resources +Caps per container (PROTOCOL §6). + +| Container | CPUs | Memory | Processes | GPU memory | Disk | +|---|---|---|---|---|---| +| `main` (the agent's) | 1 | 1 GiB | 256 | no GPU | 2 GiB | +| `sim` | 1 | 1 GiB | 128 | no GPU | — | +| verifier (as `main`) | 1 | 1 GiB | no cap | no GPU | 2 GiB | + +- GPU: not needed. diff --git a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/Dockerfile b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/Dockerfile new file mode 100644 index 0000000..05f7280 --- /dev/null +++ b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/Dockerfile @@ -0,0 +1,10 @@ +FROM docker.io/library/python:3.12.10-slim-bookworm@sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db +RUN apt-get update && apt-get install -y --no-install-recommends bash curl git nodejs npm ca-certificates \ + && rm -rf /var/lib/apt/lists/* +RUN npm install -g @openai/codex@0.167.1 && npm cache clean --force +RUN pip install --no-cache-dir pillow==10.4.0 numpy==1.26.4 +COPY --from=ghcr.io/mll-lab-nu/efe:game-files-0.6.0@sha256:bfb708928954d5cc194a614ab772a65b1e56f381b49dfeb2227c3d609e5f2ecc /game_client.py /app/game_client.py +COPY --from=ghcr.io/mll-lab-nu/efe:connection-files-0.1.0@sha256:6d1002dea6ca507b4148d3196e233838e645b33bcfa9a27ae4a43027ae519999 /service_connection.py /app/service_connection.py +ENV PYTHONUNBUFFERED=1 PYTHONPATH=/app +RUN mkdir -p /app/output +WORKDIR /app diff --git a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/docker-compose.yaml b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/docker-compose.yaml new file mode 100644 index 0000000..7fa17b4 --- /dev/null +++ b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/docker-compose.yaml @@ -0,0 +1,43 @@ +services: + main: + pids_limit: 256 # rcb-monitor + volumes: # rcb-monitor + - rcb_limits:/run/rcb-limits:ro # rcb-monitor + depends_on: [sim] + sim: + cpus: 1 # rcb-monitor + mem_limit: 1024m # rcb-monitor + pids_limit: 128 # rcb-monitor + volumes: # rcb-monitor + - rcb_observe:/run/rcb-observe:ro # rcb-monitor + build: + context: sim + dockerfile: Dockerfile + working_dir: /srv + command: python3 /srv/server.py + environment: + RCB_WALL_CLOCK_S: "600" + # >>> rcb_monitor (resource monitor, PROTOCOL §6; generated by images/monitor/rcb_monitor/inject.py) + rcb_monitor: + image: ghcr.io/mll-lab-nu/efe:monitor-0.5.0@sha256:ecc5f24f1516ca11711d7c2d3ac07c89f79cd9220812c1244498ec71e352402a + pid: host + cgroup: host + network_mode: none + cap_add: [SYS_PTRACE] + cpus: 0.5 + mem_limit: 256m + pids_limit: 64 + restart: on-failure + working_dir: /var/rcb-monitor + volumes: + - ./rcb_monitor/limits.json:/opt/rcb_monitor/limits.json:ro + - rcb_limits:/run/rcb-limits + - rcb_observe:/run/rcb-observe + environment: + RCB_LIMITS_ENFORCE: ${RCB_LIMITS_ENFORCE:-0} + RCB_LIMITS_TOLERANCE: ${RCB_LIMITS_TOLERANCE:-0.05} + command: ["python3", "/opt/rcb_monitor/monitor.py", "run"] + # <<< rcb_monitor +volumes: # rcb-monitor + rcb_limits: # rcb-monitor + rcb_observe: # rcb-monitor diff --git a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/rcb_monitor/limits.json b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/rcb_monitor/limits.json new file mode 100644 index 0000000..6d1f86e --- /dev/null +++ b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/rcb_monitor/limits.json @@ -0,0 +1,26 @@ +{ + "agent_timeout_sec": 600, + "caps": { + "main": { + "cpus": 1.0, + "disk_gb": 2.0, + "memory_gb": 1.0, + "pids": 256 + }, + "sim": { + "cpus": 1.0, + "memory_gb": 1.0, + "pids": 128 + } + }, + "disk_gb": 2.0, + "disk_tick_sec": 60, + "format": "rcb-limits/2", + "gpu": false, + "mode": "standard", + "scope_services": [ + "main" + ], + "task": "slimevolley-pixel-vs-baseline-i01-standard", + "tick_sec": 5 +} diff --git a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/sim/Dockerfile b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/sim/Dockerfile new file mode 100644 index 0000000..10e9698 --- /dev/null +++ b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/sim/Dockerfile @@ -0,0 +1,15 @@ +FROM docker.io/library/python:3.12.10-slim-bookworm@sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db +COPY --from=ghcr.io/mll-lab-nu/efe:slimevolley-files-1.0.0@sha256:bb15a9bd6fefc604d6961778781bb04e19abcfa6913e289ff743af7ccaab54d5 /requirements.txt /srv/requirements.txt +RUN pip install --no-cache-dir setuptools==84.2.1 wheel==0.45.1 \ + && pip install --no-cache-dir --no-build-isolation --no-deps -r /srv/requirements.txt +COPY --from=ghcr.io/mll-lab-nu/efe:game-files-0.6.0@sha256:bfb708928954d5cc194a614ab772a65b1e56f381b49dfeb2227c3d609e5f2ecc /server.py /srv/server.py +COPY --from=ghcr.io/mll-lab-nu/efe:game-files-0.6.0@sha256:bfb708928954d5cc194a614ab772a65b1e56f381b49dfeb2227c3d609e5f2ecc /reducers.py /srv/reducers.py +COPY --from=ghcr.io/mll-lab-nu/efe:game-files-0.6.0@sha256:bfb708928954d5cc194a614ab772a65b1e56f381b49dfeb2227c3d609e5f2ecc /config_schema.py /srv/config_schema.py +COPY --from=ghcr.io/mll-lab-nu/efe:game-files-0.6.0@sha256:bfb708928954d5cc194a614ab772a65b1e56f381b49dfeb2227c3d609e5f2ecc /contracts.py /srv/contracts.py +COPY --from=ghcr.io/mll-lab-nu/efe:game-files-0.6.0@sha256:bfb708928954d5cc194a614ab772a65b1e56f381b49dfeb2227c3d609e5f2ecc /encoding.py /srv/encoding.py +COPY --from=ghcr.io/mll-lab-nu/efe:game-files-0.6.0@sha256:bfb708928954d5cc194a614ab772a65b1e56f381b49dfeb2227c3d609e5f2ecc /recording.py /srv/recording.py +COPY --from=ghcr.io/mll-lab-nu/efe:slimevolley-files-1.0.0@sha256:bb15a9bd6fefc604d6961778781bb04e19abcfa6913e289ff743af7ccaab54d5 /adapter.py /srv/adapter.py +COPY --from=ghcr.io/mll-lab-nu/efe:slimevolley-files-1.0.0@sha256:bb15a9bd6fefc604d6961778781bb04e19abcfa6913e289ff743af7ccaab54d5 /instance_schema.py /srv/instance_schema.py +COPY instance.json /srv/instance.json +WORKDIR /srv +CMD ["python3", "/srv/server.py"] diff --git a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/sim/instance.json b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/sim/instance.json new file mode 100644 index 0000000..9ba67b1 --- /dev/null +++ b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/sim/instance.json @@ -0,0 +1,33 @@ +{ + "schema_version": "game-instance/2.2", + "protocol": "game-standard/2.2", + "adapter_version": "1.0.0", + "capabilities": { + "images": true, + "action_mode": "enum", + "timing": "action-stepped", + "native_truncation": true + }, + "benchmark": "slimevolley", + "env_id": "SlimeVolleyNoFrameskip-v0", + "family": "pixel-vs-baseline", + "seed": 2117382936, + "max_steps": null, + "native_max_steps": 3000, + "observation_profile": "native-rgb-v1", + "metric_spec": { + "primary": "native_return", + "reducer": "family_macro", + "reducer_version": "1.0.0", + "success_label": "positive_native_match" + }, + "engine_commit": "8ac22434fc5a587a3395311f7854aeda17d10303", + "engine_versions": { + "slimevolleygym": "0.1.0", + "gym": "0.25.0", + "numpy": "1.26.4", + "opencv-python-headless": "4.11.0.86" + }, + "opponent": "native-baseline", + "initial_state_sha256": "95325587a31c2c6b0344ce17a8367e89bdfc9789f8765ed395928a32967ddff9" +} diff --git a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/instruction.md b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/instruction.md new file mode 100644 index 0000000..1a625c4 --- /dev/null +++ b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/instruction.md @@ -0,0 +1,41 @@ +# SlimeVolleyGym · Pixel match + +You control the player on the right. Make the ball land on the left side of the court. The computer controls the left player. Both start with five lives. + +## Rules +- Play through the Python client. A program may call it in a loop. Save your main control script at `/app/output/gen.py` for the record. +- You get one match, with no reset or undo. A point costs the side where the ball landed one life. The game serves a new ball between points. +- Each accepted action advances one frame. The world waits for your next action. Play ends when either side runs out of lives or you reach 3000 frames. Stop when `done` is true. + +## Scoring +Your score is points won minus points conceded, from −5 to +5. Your current score counts at the time limit. A native match ending with a positive score counts as a win. + +## Client (`/app/game_client.py`) +```python +from game_client import GameClient + +game = GameClient() +print(game.spec()["action_schema"]["enum"]) +obs = game.observe() # current frame, no action spent +game.save_image(obs, "/app/output/view.png") # save the RGB frame for inspection + +# Choose an action from the image. "left" illustrates the call. +# obs = game.step("left", expected_step=obs["step"]) +``` + +`observe()` and `step()` return one 168×84 RGB PNG in `observation["image_png_base64"]`, along with `step`, `done` and `time_left_s`. Use the returned step number in your next call. If the response is lost or your step is stale, call `observe()` to recover the current frame and step. + +Use `left` toward the net or `right` toward the outside wall. `left_jump` and `right_jump` combine movement and jump. `jump` moves vertically, and `idle` advances a frame with no input. + +## External material +You may install packages you need (pip, apt), and you may read anything installed in your container, the simulator's and this benchmark's own source code included. Please solve the task yourself: do not search the web for, or download, a ready-made solution to it, such as published or reference solutions, recorded demonstrations, or policies trained for it. This is an honour rule; trials are reviewed. The network reaches your model's API and the package registries (PyPI, Debian / Ubuntu archives) only. + +Additional rules for this task (stricter than the above): Use only the live match and general-purpose tools. Do not use task-specific controllers, reference trajectories, or pretrained SlimeVolley weights. + +## Resources +Your container: **1 CPUs**, **1 GiB of memory**, **256 processes and threads** and **2 GiB** of disk (new files under `/app`, `/tmp` and `/root`). Your container has no GPU. The simulator runs in its own container and does not count against these. CPU only slows you down; a process that goes over any other cap can be killed. Usage and caps: `/run/rcb-limits/usage.json`. + +## Time limit +You have 600 seconds to complete this task. Do not cheat by using online solutions or hints specific to this task. + +The wall-clock budget starts with your session and includes service startup, waiting and tool execution. At the cutoff, the episode is graded as it stands. Use `deadline_utc` and `time_left_s` in `/run/rcb-limits/usage.json` for the session deadline. The client's `time_left_s` starts on the first `observe()` or accepted action. `spec()` and `status()` do not start that clock. diff --git a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/solution/actions.json b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/solution/actions.json new file mode 100644 index 0000000..d42142d --- /dev/null +++ b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/solution/actions.json @@ -0,0 +1 @@ +["idle","idle","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","idle","idle","idle","idle","idle","idle","idle","idle","idle","jump","left_jump","jump","left_jump","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","jump","left_jump","left_jump","jump","jump","left_jump","jump","right","left","idle","idle","right","idle","right","idle","right","idle","right","idle","left","jump","idle","right","left_jump","jump","left_jump","left","left_jump","idle","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","left","idle","left","idle","left","idle","left","idle","left","idle","left","idle","left","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","idle","idle","left","idle","left","idle","left","idle","left","idle","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","left","idle","left","idle","idle","idle","idle","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","right","idle","right","right","idle","right","right","right","idle","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","jump","jump","jump","left","idle","idle","left","right","idle","idle","left","idle","idle","left","left","idle","idle","idle","left_jump","jump","left","jump","left","jump","idle","left_jump","jump","idle","idle","idle","jump","left_jump","jump","jump","left_jump","jump","left_jump","jump","left_jump","left_jump","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","left","left","left","left","left","left","left","idle","left","idle","left","idle","left","idle","left","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right_jump","jump","left_jump","jump","jump","left_jump","jump","jump","left_jump","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right","jump","jump","jump","right_jump","left_jump","jump","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","left","left","left","left","left","left","jump","left","left_jump","left_jump","left","left_jump","left","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right_jump","left_jump","jump","right_jump","left_jump","jump","jump","left_jump","jump","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","right","idle","idle","right","idle","idle","idle","right","idle","idle","idle","right","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","jump","left_jump","jump","jump","jump","left_jump","jump","jump","left_jump","jump","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","jump","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","idle","right","right","right","idle","right","right","right","idle","right","right","right","right","jump","idle","right_jump","idle","right","idle","idle","right","idle","idle","right","idle","idle","right","idle","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","jump","jump","jump","left_jump","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","jump","left_jump","left_jump","jump","left_jump","left_jump","jump","left_jump","left_jump","jump","left_jump","left_jump","jump","left_jump","left","jump","left","right","idle","jump","left_jump","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","idle","idle","right","idle","right","idle","right","idle","right","right","idle","right","right","idle","right","right","right","idle","right","right","right","idle","right","right","right","idle","right","right","right","idle","right_jump","jump","jump","jump","jump","left","idle","left","idle","left","left","idle","left","left","left","idle","idle","left","left","jump","left","idle","left","idle","jump","left_jump","jump","left","idle","idle","idle","left_jump","jump","left_jump","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","jump","right","right","idle","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","jump","idle","right","right","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right","right","right","right","right","right","right","right","right","right","right","right","idle","left_jump","jump","jump","jump","left_jump","jump","left_jump","left_jump","left_jump","jump","jump","left","right","idle","right","idle","right","idle","right","idle","right","idle","idle","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right_jump","jump","left_jump","jump","idle","idle","left","left","left","idle","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","jump","left_jump","left_jump","left_jump","left_jump","jump","left_jump","jump","left_jump","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","idle","idle","idle","idle","idle","left_jump","left_jump","left_jump","left_jump","left","idle","idle","left","idle","left","idle","left","idle","left","idle","left","idle","idle","idle","idle","idle","idle","idle","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","idle","idle","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right","jump","idle","jump","jump","left_jump","jump","jump","left_jump","jump","jump","left_jump","jump","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","idle","idle","idle","idle","left","idle","left","idle","left","idle","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","right_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","jump","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","idle","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","idle","left_jump","jump","left_jump","left","right","idle","idle","left","idle","idle","left","idle","idle","left_jump","left","left_jump","idle","left_jump","left","jump","idle","left","right_jump","left_jump","jump","left_jump","jump","left","idle","idle","jump","left_jump","jump","left_jump","left_jump","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","left_jump","left","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right","jump","jump","jump","left_jump","jump","jump","left_jump","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","idle","idle","idle","idle","idle","jump","left_jump","left_jump","left_jump","left","idle","idle","left","idle","left","idle","left","idle","left","idle","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","idle","idle","idle","idle","idle","idle","idle","idle","right","jump","jump","idle","right","idle","right","right","idle","jump","jump","right","jump","jump","jump","jump","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","left","left","left","left","left","left","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","idle","idle","idle","idle","idle","right","idle","right","right","idle","right","right","idle","right","right","right","idle","right","right","right","idle","right","right","idle","right","right","jump","jump","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","left","left","left_jump","left","jump","idle","left","jump","left_jump","left","idle","jump","left_jump","idle","idle","idle","left_jump","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","idle","idle","right","idle","right","idle","right","right","idle","right","right","right","right","idle","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","jump","jump","jump","jump","jump","left","idle","idle","left","right","idle","idle","left","right","idle","idle","left","idle","idle","idle","left_jump","idle","idle","idle","left_jump","jump","idle","left","right_jump","idle","jump","left","jump","left_jump","jump","left_jump","jump","left_jump","jump","left_jump","jump","left_jump","jump","left_jump","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","left","left","left","idle","left","idle","idle","idle","idle","idle","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","idle","left","idle","left","idle","left","idle","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","left_jump","left_jump","left_jump","left_jump","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","idle","jump","idle","right","idle","idle","idle","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right","idle","idle","right","idle","idle","right","idle","idle","right_jump","idle","jump","jump","jump","jump","left_jump","jump","jump","left_jump","jump","left_jump","left_jump","left_jump","left","left","idle","idle","idle","left","left","idle","idle","left_jump","left","left","left","left","left","idle","left","idle","left","idle","left","idle","left","jump","left","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right","idle","right_jump","left_jump","jump","jump","right_jump","left_jump","jump","jump","left_jump","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","left","idle","left","idle","left","idle","idle","idle","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","idle","idle","idle","right","idle","right","idle","right","right","idle","right","right","right","right","idle","right","right","right","right","right","right","right","right","right","right","idle","jump","jump","jump","jump","jump","jump","jump","jump","jump","jump","jump","jump","jump","jump","jump","jump","jump","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","right","idle","idle","right","idle","right","idle","right","right","idle","right","right","idle","right","right","right","idle","right","right","right","idle","right","right","right","jump","idle","jump","jump","jump","jump","jump","jump","jump","jump","jump","jump","jump","idle","right","right","idle","left","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","jump","left_jump","jump","left","left","idle","idle","idle","left_jump","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","idle","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","left","left","left","idle","left","idle","left","idle","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","idle","idle","left","idle","left","idle","left","idle","left","idle","left","idle","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","idle","jump","idle","left_jump","left_jump","jump","right","right","right","idle","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","right","idle","right","right","right","right","right","right","right","right","right","right","right","right","idle","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","jump","left_jump","left_jump","left_jump","idle","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","idle","jump","left_jump","jump","left_jump","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","jump","right","idle","right","idle","right","jump","jump","right","right","right","idle","right_jump","right","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","left","idle","idle","idle","idle","idle","idle","idle","idle","idle","right","jump","idle","right_jump","idle","jump","jump","idle","right_jump","left_jump","jump","jump","jump","left_jump","jump","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left","left","idle","left","idle","left","left","left","left","idle","left","idle","idle","jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","left_jump","idle","left","idle","idle","idle","idle","right","idle","right","idle","right","idle","right","idle","right","right","idle","right","right","idle","right","right","idle","right","right","idle","right","right","idle","right","right","idle","right","right_jump","idle","left_jump","jump","jump","jump","jump","left_jump","left","idle","left","idle","idle","left","idle","idle","idle","idle","idle","idle","idle","idle","left","idle","left","idle","jump","left_jump","idle","right","idle","idle","idle","left_jump","jump","left_jump","left_jump","jump","left_jump","left_jump","jump","left_jump","jump","left_jump","jump","left_jump","jump","left_jump","jump","left_jump","left_jump","left_jump","jump","right","right","right","right","right"] diff --git a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/solution/solve.sh b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/solution/solve.sh new file mode 100755 index 0000000..699533b --- /dev/null +++ b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/solution/solve.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -euo pipefail +python3 - <<'PYCODE' +import json +from game_client import GameClient +client=GameClient() +obs=client.observe() +for action in json.load(open("/solution/actions.json")): + if obs["done"]: break + obs=client.step(action,obs["step"]) +assert obs["done"], "reference trajectory did not terminate" +print("Reference episode completed in",obs["step"],"steps") +PYCODE diff --git a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/task.toml b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/task.toml new file mode 100644 index 0000000..84e4b82 --- /dev/null +++ b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/task.toml @@ -0,0 +1,62 @@ +schema_version = "1.3" +artifacts = [{ source = "/var/rcb-monitor/", service = "rcb_monitor" }, { source = "/data/final.json", service = "sim" }, + { source = "/data/episode.jsonl", service = "sim" }, + { source = "/data/recording.json", service = "sim" }, + { source = "/data/replay.mp4", service = "sim" }, + { source = "/data/replay.last.png", service = "sim" }, + "/app/output/", +] + +[task] +name = "embodied-first-exam/slimevolley-pixel-vs-baseline-i01-standard" +description = "Win the native pixel match against the built-in SlimeVolley opponent." +keywords = ["game", "slimevolley", "sports", "pixel", "standard-mode"] + +[metadata] +task_type = "trajectory" +simulator = "slimevolley" +robot = "game-agent" +family = "pixel-vs-baseline" +dynamics = "dynamic" +protocol = "game-standard/2.2" +oracle = "full" +instance_seed = 2117382936 +expert_time_estimate_hours = 0.5 + +[metadata.honour] +stricter = "Use only the live match and general-purpose tools. Do not use task-specific controllers, reference trajectories, or pretrained SlimeVolley weights." + +[verifier] +timeout_sec = 120.0 +environment_mode = "separate" +network_mode = "no-network" + +# Resources (PROTOCOL §6): seal the monitor's record first. +[[verifier.collect]] +service = "rcb_monitor" +command = "python3 /opt/rcb_monitor/monitor.py seal --wait 90" +timeout_sec = 120 + +[[verifier.collect]] +service = "main" +command = "kill -9 -1 2>/dev/null; exit 0" +timeout_sec = 30 + +[[verifier.collect]] +service = "sim" +command = "kill -USR1 $(cat /data/server.pid); i=0; while [ ! -f /data/collection.ready ] && [ $i -lt 30 ]; do sleep 1; i=$((i+1)); done; test -f /data/collection.ready && test -f /data/final.json" +timeout_sec = 40 + +[agent] +timeout_sec = 600.0 +network_mode = "allowlist" # model APIs and package registries (scripts/set_agent_egress.py); PROTOCOL Appendix H.6 +allowed_hosts = ["chatgpt.com", "*.chatgpt.com", "auth.openai.com", "api.openai.com", "*.openai.com", "api.anthropic.com", "*.anthropic.com", "openrouter.ai", "*.openai.azure.com", "*.cognitiveservices.azure.com", "pypi.org", "files.pythonhosted.org", "deb.debian.org", "security.debian.org", "archive.ubuntu.com", "security.ubuntu.com", "snapshot.ubuntu.com"] + +[environment] +build_timeout_sec = 1200.0 +cpus = 1 +memory_mb = 1024 +storage_mb = 2048 + +[verifier.env] +RCB_LIMITS_ENFORCE = "${RCB_LIMITS_ENFORCE:-0}" diff --git a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/tests/Dockerfile b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/tests/Dockerfile new file mode 100644 index 0000000..4a091de --- /dev/null +++ b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/tests/Dockerfile @@ -0,0 +1,11 @@ +FROM docker.io/library/python:3.12.10-slim-bookworm@sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db +COPY test.sh instance.json /tests/ +COPY --from=ghcr.io/mll-lab-nu/efe:game-files-0.6.0@sha256:bfb708928954d5cc194a614ab772a65b1e56f381b49dfeb2227c3d609e5f2ecc /grade.py /tests/grade.py +COPY --from=ghcr.io/mll-lab-nu/efe:game-files-0.6.0@sha256:bfb708928954d5cc194a614ab772a65b1e56f381b49dfeb2227c3d609e5f2ecc /reducers.py /tests/reducers.py +COPY --from=ghcr.io/mll-lab-nu/efe:game-files-0.6.0@sha256:bfb708928954d5cc194a614ab772a65b1e56f381b49dfeb2227c3d609e5f2ecc /config_schema.py /tests/config_schema.py +COPY --from=ghcr.io/mll-lab-nu/efe:slimevolley-files-1.0.0@sha256:bb15a9bd6fefc604d6961778781bb04e19abcfa6913e289ff743af7ccaab54d5 /instance_schema.py /tests/instance_schema.py +COPY --from=ghcr.io/mll-lab-nu/efe:slimevolley-files-1.0.0@sha256:bb15a9bd6fefc604d6961778781bb04e19abcfa6913e289ff743af7ccaab54d5 /metric_rules.py /tests/metric_rules.py +RUN chmod +x /tests/test.sh +# resources (PROTOCOL §6) # rcb-monitor +COPY --from=ghcr.io/mll-lab-nu/efe:monitor-0.5.0@sha256:ecc5f24f1516ca11711d7c2d3ac07c89f79cd9220812c1244498ec71e352402a /opt/rcb_monitor/rcb_limits.py /tests/rcb_limits.py +COPY rcb_limits.json /tests/rcb_limits.json diff --git a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/tests/instance.json b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/tests/instance.json new file mode 100644 index 0000000..9ba67b1 --- /dev/null +++ b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/tests/instance.json @@ -0,0 +1,33 @@ +{ + "schema_version": "game-instance/2.2", + "protocol": "game-standard/2.2", + "adapter_version": "1.0.0", + "capabilities": { + "images": true, + "action_mode": "enum", + "timing": "action-stepped", + "native_truncation": true + }, + "benchmark": "slimevolley", + "env_id": "SlimeVolleyNoFrameskip-v0", + "family": "pixel-vs-baseline", + "seed": 2117382936, + "max_steps": null, + "native_max_steps": 3000, + "observation_profile": "native-rgb-v1", + "metric_spec": { + "primary": "native_return", + "reducer": "family_macro", + "reducer_version": "1.0.0", + "success_label": "positive_native_match" + }, + "engine_commit": "8ac22434fc5a587a3395311f7854aeda17d10303", + "engine_versions": { + "slimevolleygym": "0.1.0", + "gym": "0.25.0", + "numpy": "1.26.4", + "opencv-python-headless": "4.11.0.86" + }, + "opponent": "native-baseline", + "initial_state_sha256": "95325587a31c2c6b0344ce17a8367e89bdfc9789f8765ed395928a32967ddff9" +} diff --git a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/tests/rcb_limits.json b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/tests/rcb_limits.json new file mode 100644 index 0000000..6d1f86e --- /dev/null +++ b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/tests/rcb_limits.json @@ -0,0 +1,26 @@ +{ + "agent_timeout_sec": 600, + "caps": { + "main": { + "cpus": 1.0, + "disk_gb": 2.0, + "memory_gb": 1.0, + "pids": 256 + }, + "sim": { + "cpus": 1.0, + "memory_gb": 1.0, + "pids": 128 + } + }, + "disk_gb": 2.0, + "disk_tick_sec": 60, + "format": "rcb-limits/2", + "gpu": false, + "mode": "standard", + "scope_services": [ + "main" + ], + "task": "slimevolley-pixel-vs-baseline-i01-standard", + "tick_sec": 5 +} diff --git a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/tests/test.sh b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/tests/test.sh new file mode 100755 index 0000000..0cf878a --- /dev/null +++ b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +rm -rf /logs/verifier/* +trap 'p=$(command -v python3 || command -v python); "$p" /tests/rcb_limits.py verify' EXIT # resources, after the grader (PROTOCOL §6) +p=$(command -v python3 || command -v python); "$p" /tests/rcb_limits.py sanitize /app/output || true # untrusted agent files (PROTOCOL H.1) +mkdir -p /logs/verifier +python3 /tests/grade.py 2>/logs/verifier/grade.log diff --git a/game_first_exam/tests/benchmarks/slimevolley/exported.toml b/game_first_exam/tests/benchmarks/slimevolley/exported.toml new file mode 100644 index 0000000..c304eff --- /dev/null +++ b/game_first_exam/tests/benchmarks/slimevolley/exported.toml @@ -0,0 +1,7 @@ +[protocols] +standard = ["game-standard/2.2"] + +[[tasks]] +name = "slimevolley-pixel-vs-baseline-i01-standard" +source_task = "SlimeVolleyNoFrameskip-v0" +protocol = "game-standard/2.2" diff --git a/game_first_exam/tests/test_game_harbor.py b/game_first_exam/tests/test_game_harbor.py index e6e71f6..96347be 100644 --- a/game_first_exam/tests/test_game_harbor.py +++ b/game_first_exam/tests/test_game_harbor.py @@ -27,18 +27,20 @@ from prepare_games import load_suite, prepare, select_tasks import efe import run_games +import task_conventions as tc class GameSelection(unittest.TestCase): def test_game_only_default_and_all_selection_never_launches(self): + all_standard = sum(tc.mode_of(task) == 'standard' for task in tc.iter_tasks()) for flags, expected in ((["--list", "--standard"], 30), - (["--all", "--standard", "--list"], 42)): + (["--all", "--standard", "--list"], all_standard)): with self.subTest(flags=flags), contextlib.redirect_stdout(io.StringIO()) as output, \ patch("efe.harbor") as launch, patch("efe.prepull") as pull: self.assertEqual(efe.run(flags), 0) names = output.getvalue().splitlines() self.assertEqual(len(names), expected) - self.assertTrue(all(name.startswith(("minigrid-", "crafter-", "textworld-", "babaisai-", "minihack-")) + self.assertTrue(all(name.startswith(tuple(prefix for prefix, _ in tc.BENCHMARKS)) for name in names)) launch.assert_not_called() pull.assert_not_called() diff --git a/game_first_exam/tests/test_slimevolley_native.py b/game_first_exam/tests/test_slimevolley_native.py new file mode 100644 index 0000000..824daad --- /dev/null +++ b/game_first_exam/tests/test_slimevolley_native.py @@ -0,0 +1,92 @@ +"""Compare the pixel adapter with the pinned native engine and its verifier.""" + +import json +from pathlib import Path +import sys +import unittest + +import numpy as np +from slimevolleygym.slimevolley import SlimeVolleyAtariEnv + +GAME = Path(__file__).resolve().parents[1] +sys.path[:0] = [str(GAME / "benchmarks/slimevolley"), str(GAME / "runtime")] +from adapter import Adapter +from config_schema import register_instance_schema, validate_instance +import instance_schema +from metric_rules import validate_metrics + +TASK = GAME / "tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard" +ACTION_INDEX = {"idle": 0, "left": 1, "left_jump": 2, "jump": 3, "right_jump": 4, "right": 5} + + +class SlimeVolleyNative(unittest.TestCase): + @classmethod + def setUpClass(cls): + register_instance_schema(instance_schema) + cls.instance = validate_instance(json.loads((TASK / "tests/instance.json").read_text())) + + def compare(self, actions, expected_steps, expected_score, ending): + native = SlimeVolleyAtariEnv() + self.addCleanup(native.close) + native.seed(self.instance["seed"]) + match = Adapter(self.instance) + self.addCleanup(match.close) + initial = match.fingerprint() + self.assertEqual(initial, self.instance["initial_state_sha256"]) + np.testing.assert_array_equal(match.frame(), native.reset()) + self.assertEqual(match.frame().shape, (84, 168, 3)) + self.assertEqual(match.frame().dtype, np.uint8) + self.assertEqual(match.observe(), match.observe()) + self.assertEqual(set(match.observe()), {"image_png_base64"}) + self.assertEqual(match.fingerprint(), initial) + self.assertEqual(match.spec()["action_schema"]["enum"], list(ACTION_INDEX)) + + total = 0 + for step, action in enumerate(actions, 1): + expected, reward, done, info = native.step(ACTION_INDEX[action]) + result = match.step(action) + np.testing.assert_array_equal(match.frame(), expected) + self.assertEqual(result.reward, reward) + self.assertEqual(result.terminated or result.truncated, done) + total += reward + if done: + break + + self.assertEqual((step, total), (expected_steps, expected_score)) + self.assertEqual((result.terminated, result.truncated), ending) + self.assertEqual((match.metrics()["right_lives"], match.metrics()["left_lives"]), + (info["ale.lives"], info["ale.otherLives"])) + final = {"steps": step, "return": total, "metrics": match.metrics(), + "terminated": result.terminated, "truncated": result.truncated, + "success": match.success()} + validate_metrics(final, self.instance) + self.assertEqual(match.success(), expected_score > 0) + with self.assertRaises(ValueError): + validate_metrics({**final, "return": total + 1}, self.instance) + + def test_reference_matches_native_to_frame_limit(self): + actions = json.loads((TASK / "solution/actions.json").read_text()) + self.compare(actions, 3000, 1, (False, True)) + + def test_idle_matches_native_to_life_exhaustion(self): + self.compare(["idle"] * 3000, 557, -5, (True, False)) + + def test_each_discrete_action_matches_native(self): + for action, index in ACTION_INDEX.items(): + with self.subTest(action=action): + native = SlimeVolleyAtariEnv() + match = Adapter(self.instance) + try: + native.seed(self.instance["seed"]) + native.reset() + expected, reward, _, _ = native.step(index) + result = match.step(action) + np.testing.assert_array_equal(match.frame(), expected) + self.assertEqual(result.reward, reward) + finally: + native.close() + match.close() + + +if __name__ == "__main__": + unittest.main() diff --git a/scripts/task_conventions.py b/scripts/task_conventions.py index 36b7e5c..15cf583 100644 --- a/scripts/task_conventions.py +++ b/scripts/task_conventions.py @@ -75,6 +75,7 @@ ("minihack-", "MiniHack", "minihack"), ("babaisai-", "Baba Is AI", "babaisai"), ("crafter-", "Crafter", "crafter"), + ("slimevolley-", "SlimeVolleyGym", "slimevolley"), ("textworld-", "TextWorld", "textworld"), ("minigrid-", "MiniGrid", "minigrid"), ] @@ -212,6 +213,12 @@ "accepted action plan; its `time_left_s` counts from the first request, including `spec()`, so preparation after that " "request counts toward the service budget. Use `/run/rcb-limits/usage.json` for the outer session deadline. " "After the clock starts, waiting and model thinking do not pause the game.") +CUTOFF_NOTE_TASK["slimevolley-pixel-vs-baseline-i01-standard"] = ( + "The wall-clock budget starts with your session and includes service startup, waiting and tool execution. " + "At the cutoff, the episode is graded as it stands. Use `deadline_utc` and `time_left_s` in " + "`/run/rcb-limits/usage.json` for the session deadline. The client's `time_left_s` starts on the first " + "`observe()` or accepted action. `spec()` and `status()` do not start that clock." +) CUTOFF_NOTE_TASK["minihack-room-i01-standard"] = ( "The wall-clock budget starts with your session and includes service startup, waiting and tool execution. " "At the cutoff, the episode is graded as it stands. Use `deadline_utc` and `time_left_s` in " diff --git a/scripts/task_resources.toml b/scripts/task_resources.toml index f5e2106..7f40615 100644 --- a/scripts/task_resources.toml +++ b/scripts/task_resources.toml @@ -14,6 +14,12 @@ main = { cpus = 1, memory_gb = 1, pids = 256, disk_gb = 2 } sim = { cpus = 1, memory_gb = 1, pids = 128 } measured = "Initial integration caps; CPU only, fixed-model evaluation" +[[cap]] +match = "^slimevolley-.*-standard$" +main = { cpus = 1, memory_gb = 1, pids = 256, disk_gb = 2 } +sim = { cpus = 1, memory_gb = 1, pids = 128 } +measured = "CPU-only native RGB match" + # MiniHack native CPU integration; caps are not native game parameters. [[cap]] From 9579a2eef553331f5dbaec067c06797a2787cc6b Mon Sep 17 00:00:00 2001 From: hanzy Date: Tue, 24 Nov 2026 05:30:48 +0000 Subject: [PATCH 2/3] Add isolated SlimeVolley practice and scored rollout --- .github/workflows/slimevolley.yml | 2 + docs/slimevolley_exam.md | 20 ++ .../benchmarks/slimevolley/exam_server.py | 145 ++++++++++ .../benchmarks/slimevolley/practice.md | 56 ++++ .../benchmarks/slimevolley/smoke.sh | 56 ++++ .../DIGEST | 2 +- .../environment/Dockerfile | 10 +- .../instruction.md | 4 +- scripts/run_slimevolley_exam.py | 258 ++++++++++++++++++ 9 files changed, 547 insertions(+), 6 deletions(-) create mode 100644 docs/slimevolley_exam.md create mode 100644 game_first_exam/benchmarks/slimevolley/exam_server.py create mode 100644 game_first_exam/benchmarks/slimevolley/practice.md create mode 100755 game_first_exam/benchmarks/slimevolley/smoke.sh create mode 100644 scripts/run_slimevolley_exam.py diff --git a/.github/workflows/slimevolley.yml b/.github/workflows/slimevolley.yml index 27ee654..60a45a2 100644 --- a/.github/workflows/slimevolley.yml +++ b/.github/workflows/slimevolley.yml @@ -51,3 +51,5 @@ jobs: PY docker run --rm --network none -v "$PWD/jobs:/jobs:ro" slimevolley-native sh -ec \ '"$(python -c "import imageio_ffmpeg; print(imageio_ffmpeg.get_ffmpeg_exe())")" -v error -xerror -i /jobs/fresh-slimevolley/*/artifacts/data/replay.mp4 -f null -' + - name: Verify the practice and scored match isolation + run: python scripts/run_slimevolley_exam.py --smoke --output "$PWD/jobs/slimevolley-exam-smoke" diff --git a/docs/slimevolley_exam.md b/docs/slimevolley_exam.md new file mode 100644 index 0000000..690dc10 --- /dev/null +++ b/docs/slimevolley_exam.md @@ -0,0 +1,20 @@ +# SlimeVolley practice and scored match + +Run from the repository root with the project's Harbor environment and Docker Engine 29. If the SlimeVolley files image is unavailable in your registry or local cache, run `python scripts/files_image.py build slimevolley-files` first. Choose an output directory outside the checkout. A Docker daemon running on another host needs access to that directory through the same filesystem path. + +```sh +# Verify both scenarios and the saved practice controller at a shortened cutoff. +python scripts/run_slimevolley_exam.py --smoke --output /path/to/new-smoke-output + +# Run one coding agent with the full 600-second practice budget. +python scripts/run_slimevolley_exam.py \ + --agent-config configs/harbor/claude-deepseek.json \ + --allow-agent-host api.deepseek.com \ + --output /path/to/new-exam-output +``` + +The agent config supplies exactly one agent. The runner sets the task, resource limits, timeout, and one attempt. Practice ends when the agent finishes or its 600 seconds expire. A fresh container launches the saved `gen.py` for up to 120 seconds with the public pixel client. If that file is missing, the evaluator selects `practice_gen.py` from the same collected output directory. The evaluator freezes the selected file under `official/gen.py`. A deterministic `idle` action completes the remaining frames if there is no usable selected file or the controller stops early. + +Practice slots `A` and `B` are fixed. The runner samples a separate hidden seed before practice and excludes both practice seeds. For experiments comparing multiple agents on the same held-out scenario, pass `--official-seed-file` with a private file containing one integer. Every run needs a new output directory. Keep the seed file and run logs inaccessible to the practice agents. + +Read `exam.json` for the independently verified official score, controller outcome, the original filename in `submission_source`, and controller/idle frame counts. The snapshot and scoring evidence are under `official/`, including `official/evidence/replay.mp4`. The Harbor job under `practice-job/` tracks the rehearsal and submission only. A simulator or evaluation infrastructure failure invalidates the run. The frozen single-match standard task is available separately through the regular SlimeVolley suite. diff --git a/game_first_exam/benchmarks/slimevolley/exam_server.py b/game_first_exam/benchmarks/slimevolley/exam_server.py new file mode 100644 index 0000000..6ab195e --- /dev/null +++ b/game_first_exam/benchmarks/slimevolley/exam_server.py @@ -0,0 +1,145 @@ +"""Trusted service for the SlimeVolley practice and scored phases.""" +import json +import os +import signal +import sys +import tempfile +from http.server import HTTPServer +from pathlib import Path +from uuid import uuid4 + +from adapter import Adapter +from server import EnvironmentFault, Game, Handler + +DATA = Path("/data") +ASSETS = Path("/srv") + + +class PracticeGame(Game): + def record_frame(self): + # The public pixel stream remains available. Only the scored match is recorded. + pass + + +class PracticeServer(HTTPServer): + def __init__(self, instances, scratch): + super().__init__(("0.0.0.0", 8000), PracticeHandler) + self.instances, self.scratch = instances, scratch + self.summary = {slot: {"episodes": 0, "steps": 0, "errors": 0} for slot in instances} + self.game = None + self.start("A") + + def finish_episode(self): + if self.game is not None: + self.game.close() + totals = self.summary[self.slot] + totals["steps"] += self.game.steps + totals["errors"] += int(not self.game.final["result_valid"]) + self.episode_dir.cleanup() + self.game = None + + def start(self, slot): + self.finish_episode() + self.slot = slot + self.episode_dir = tempfile.TemporaryDirectory(dir=self.scratch) + self.game = PracticeGame.open(Adapter, self.instances[slot], ASSETS, self.episode_dir.name) + self.summary[slot]["episodes"] += 1 + return {"slot": slot, **self.game.observe()} + + +class PracticeHandler(Handler): + def do_POST(self): + if self.path != "/practice/start": + return super().do_POST() + try: + length = int(self.headers.get("Content-Length", "0")) + if not 0 < length <= 64: + raise ValueError + body = json.loads(self.rfile.read(length)) + if not isinstance(body, dict) or set(body) != {"slot"} or body["slot"] not in ("A", "B"): + raise ValueError + except ValueError: + return self.reply(400, {"error": "provide exactly one slot: A or B"}) + self.reply(200, self.server.start(body["slot"])) + + +def serve(make_server, seal): + # Keep all simulator work out of the signal handlers. + collecting = False + stopping = False + + def stop(signum, _frame): + nonlocal collecting, stopping + if signum == signal.SIGUSR1: + collecting = True + else: + stopping = True + + DATA.mkdir(parents=True, exist_ok=True) + signal.signal(signal.SIGUSR1, stop) + signal.signal(signal.SIGTERM, stop) + with make_server() as server: + server.timeout = 0.25 + (DATA / "server.pid").write_text(str(os.getpid())) + while not collecting and not stopping: + server.handle_request() + # After collection starts, stop accepting public requests before computing evidence. + if collecting: + seal(server) + (DATA / "collection.ready").touch() + # Harbor still needs to copy the artifacts from this container. + while not stopping: + signal.pause() + + +def practice(): + instances = json.loads((ASSETS / "practice-instances.json").read_text()) + + def seal(server): + server.finish_episode() + (DATA / "practice.json").write_text(json.dumps(server.summary) + "\n") + + with tempfile.TemporaryDirectory() as scratch: + serve(lambda: PracticeServer(instances, scratch), seal) + + +def official(): + instance = json.loads((ASSETS / "instance.json").read_text()) + + def make_server(): + server = HTTPServer(("0.0.0.0", 8000), Handler) + # The host enforces the policy deadline. Keep time available for trusted idle steps. + server.game = Game.open(Adapter, instance, ASSETS, DATA, wall_clock=3600) + return server + + def seal(server): + game = server.game + controller_steps = game.steps + try: + while game.final is None: + game.submit({"action": "idle", "expected_step": game.steps, "request_id": uuid4().hex}) + except EnvironmentFault: + pass # The existing grader rejects the engine's invalid verdict. + finally: + game.close() + result = {"controller_steps": controller_steps, "idle_steps": game.steps - controller_steps} + (DATA / "rollout.json").write_text(json.dumps(result) + "\n") + + serve(make_server, seal) + + +def instances(): + base = json.loads((ASSETS / "instance.json").read_text()) + result = {} + for slot, seed in json.load(sys.stdin).items(): + instance = {**base, "seed": seed} + adapter = Adapter(instance, ASSETS) + try: + result[slot] = {**instance, "initial_state_sha256": adapter.fingerprint()} + finally: + adapter.close() + print(json.dumps(result)) + + +if __name__ == "__main__": + {"practice": practice, "official": official, "instances": instances}[sys.argv[1]]() diff --git a/game_first_exam/benchmarks/slimevolley/practice.md b/game_first_exam/benchmarks/slimevolley/practice.md new file mode 100644 index 0000000..4beaf05 --- /dev/null +++ b/game_first_exam/benchmarks/slimevolley/practice.md @@ -0,0 +1,56 @@ +# SlimeVolleyGym · Pixel match with practice + +You control the slime on the right. The computer controls the left slime. Both players start with five lives. + +**Task.** Use practice matches to learn SlimeVolley and build a controller. Your saved controller plays the scored match after practice. Make the ball land in the left court to score. + +## Rules +- **Drive the player with a program.** Your program may call the client in a loop. +- **Two practice scenarios.** You start in `A`. You may restart either `A` or `B` with the client within the same practice budget. +- **Save a practice controller early.** Save a working script at `/app/output/practice_gen.py` and improve it during practice. Both controller files must run on a fresh match with the public observe and action calls. Restart practice with the client before running a controller. +- **One scored match.** Save your final controller at `/app/output/gen.py`. After practice the evaluator selects `gen.py`, or `practice_gen.py` if the final file is missing. It copies only the selected file into a fresh container and runs it once with `python3 /app/gen.py`. The scored match uses a hidden seed different from both practice seeds, so the serve and ball paths may differ. The scored match cannot be restarted. +- **Match limit.** A match ends when either side runs out of lives or reaches 3,000 frames. Stop when `done` is true. + +## Scoring +When the ball lands in the left court, the computer loses one life and you score +1. When it lands in the right court, you lose one life and score −1. Your score is the sum of those points, from −5 to +5. Only the scored match counts. + +## Client (`/app/game_client.py`) + +```python +from game_client import GameClient + +game = GameClient() +print(game.spec()["action_schema"]["enum"]) # accepted action names +obs = game.observe() # current frame without spending an action +game.save_image(obs, "/app/output/view.png") # save the frame for inspection + +# During practice, restart either "A" or "B" and get its opening frame. +# obs = game.request("/practice/start", {"slot": "B"}) + +# Choose an action from the frame. "left" illustrates the call. +# if not obs["done"]: +# obs = game.step("left", expected_step=obs["step"]) +``` + +### Observations +`observe()` and `step()` return one 168×84 RGB PNG in `observation["image_png_base64"]`. + +The coins in the upper right show **your** remaining lives. The coins in the upper left show the **computer's**. Five lives show four coins. Each life lost removes one coin until none remain. One life and zero lives both show zero coins. + +### Actions and feedback +Use `left` to move toward the net or `right` to move toward the outer wall. `left_jump` and `right_jump` add a jump to those moves. `jump` jumps vertically and `idle` advances a frame without player input. + +Each accepted action advances one frame and returns the updated `step` and `done`. The game waits between actions. Pass the current `step` as `expected_step`. If a response is lost or your step is stale, call `observe()` before choosing your next action. + +## External material +Use the live matches and general-purpose tools. Do not look up or use ready-made controllers, reference trajectories, recorded demonstrations, or pretrained SlimeVolley weights. The practice network reaches model APIs and approved package registries. + +## Resources +Your practice container has **1 CPU**, **1 GiB of memory**, **256 processes and threads**, and **2 GiB of disk** for new files under `/app`, `/tmp`, and `/root`. It has no GPU. The simulator runs separately. Check `/run/rcb-limits/usage.json` for usage and caps. + +The scored container has Python's standard library, NumPy, and Pillow. Each controller file can be up to 256 KiB. Include all helper code and parameters in the file. The script can reach the game service only. + +## Time limit +You have **600 seconds** of wall-clock time to learn in practice and save your controller. Save a working version before long experiments. Waiting and tool execution count. Check `time_left_s` and `deadline_utc` in `/run/rcb-limits/usage.json` for your session deadline. + +Your controller has **120 seconds** in the scored match. If there is no selected script, the selected script is invalid, or it stops early, the game uses `idle` for the remaining frames. diff --git a/game_first_exam/benchmarks/slimevolley/smoke.sh b/game_first_exam/benchmarks/slimevolley/smoke.sh new file mode 100755 index 0000000..555efa7 --- /dev/null +++ b/game_first_exam/benchmarks/slimevolley/smoke.sh @@ -0,0 +1,56 @@ +#!/bin/bash +set -eu +python3 - <<'PY' +from game_client import GameClient + +game = GameClient() + +def frames(state): + result = [] + for _ in range(100): + state = game.step("idle", state["step"]) + result.append(state["observation"]["image_png_base64"]) + return result + +first = frames(game.observe()) +second = frames(game.request("/practice/start", {"slot": "B"})) +assert first != second, "the seeds must yield different practice trajectories" +assert first == frames(game.request("/practice/start", {"slot": "A"})), "reset must reproduce the selected seed" +try: + game.request("/practice/start", {"slot": "official"}) +except ValueError as error: + assert "provide exactly one slot" in str(error), str(error) +else: + raise AssertionError("the practice reset accepted an unknown slot") +PY +mkdir -p /app/output +cat > /app/output/practice_gen.py <<'PY' +import os +from importlib.util import find_spec +from pathlib import Path +from shutil import which +from game_client import GameClient + +assert find_spec("slimevolleygym") is None +assert which("codex") is None +assert not any(Path(name).exists() for name in ( + "/srv/instance.json", "/data/final.json", "/tests/grade.py", "/solution", "/var/run/docker.sock", +)) +assert not any(name.endswith(("API_KEY", "AUTH_TOKEN")) for name in os.environ) +game = GameClient() +assert set(game.spec()) == { + "action_schema", "adapter_version", "capabilities", "max_steps", "observation", + "observation_profile", "protocol", "reset_budget", "timing", +} +try: + game.request("/practice/start", {"slot": "A"}) +except ValueError as error: + assert "unknown endpoint" in str(error), str(error) +else: + raise AssertionError("a reset was possible in the scored match") +state = game.observe() +assert state["step"] == 0 +assert set(state["observation"]) == {"image_png_base64"} +assert game.step("left", state["step"])["step"] == 1 +PY +sleep 60 diff --git a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/DIGEST b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/DIGEST index 33d2c7f..1c97c79 100644 --- a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/DIGEST +++ b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/DIGEST @@ -1 +1 @@ -sha256:a801f829754720af17582337c7534cc24aa2ead38bac6cea25f2e4dd8336f774 +sha256:630ef478f6da6c23a1b95bc190b4889302c6753a43e666e44e52dfa3ed4ac007 diff --git a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/Dockerfile b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/Dockerfile index 05f7280..7cc943f 100644 --- a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/Dockerfile +++ b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/environment/Dockerfile @@ -1,10 +1,12 @@ -FROM docker.io/library/python:3.12.10-slim-bookworm@sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db -RUN apt-get update && apt-get install -y --no-install-recommends bash curl git nodejs npm ca-certificates \ - && rm -rf /var/lib/apt/lists/* -RUN npm install -g @openai/codex@0.167.1 && npm cache clean --force +FROM docker.io/library/python:3.12.10-slim-bookworm@sha256:fd95fa221297a88e1cf49c55ec1828edd7c5a428187e67b5d1805692d11588db AS controller RUN pip install --no-cache-dir pillow==10.4.0 numpy==1.26.4 COPY --from=ghcr.io/mll-lab-nu/efe:game-files-0.6.0@sha256:bfb708928954d5cc194a614ab772a65b1e56f381b49dfeb2227c3d609e5f2ecc /game_client.py /app/game_client.py COPY --from=ghcr.io/mll-lab-nu/efe:connection-files-0.1.0@sha256:6d1002dea6ca507b4148d3196e233838e645b33bcfa9a27ae4a43027ae519999 /service_connection.py /app/service_connection.py ENV PYTHONUNBUFFERED=1 PYTHONPATH=/app RUN mkdir -p /app/output WORKDIR /app + +FROM controller AS agent +RUN apt-get update && apt-get install -y --no-install-recommends bash curl git nodejs npm ca-certificates \ + && rm -rf /var/lib/apt/lists/* +RUN npm install -g @openai/codex@0.167.1 && npm cache clean --force diff --git a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/instruction.md b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/instruction.md index 1a625c4..72474e4 100644 --- a/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/instruction.md +++ b/game_first_exam/tasks/slimevolley/slimevolley-pixel-vs-baseline-i01-standard/instruction.md @@ -8,7 +8,7 @@ You control the player on the right. Make the ball land on the left side of the - Each accepted action advances one frame. The world waits for your next action. Play ends when either side runs out of lives or you reach 3000 frames. Stop when `done` is true. ## Scoring -Your score is points won minus points conceded, from −5 to +5. Your current score counts at the time limit. A native match ending with a positive score counts as a win. +A point won on the left counts as +1. A point conceded on the right counts as −1. Your score is points won minus points conceded, from −5 to +5. Your current score counts at the time limit. A native match ending with a positive score counts as a win. ## Client (`/app/game_client.py`) ```python @@ -25,6 +25,8 @@ game.save_image(obs, "/app/output/view.png") # save the RGB frame for inspectio `observe()` and `step()` return one 168×84 RGB PNG in `observation["image_png_base64"]`, along with `step`, `done` and `time_left_s`. Use the returned step number in your next call. If the response is lost or your step is stale, call `observe()` to recover the current frame and step. +The coins at the upper right show your remaining lives. The coins at the upper left show the computer's. Five lives show four coins. One life and zero lives both show zero coins. + Use `left` toward the net or `right` toward the outside wall. `left_jump` and `right_jump` combine movement and jump. `jump` moves vertically, and `idle` advances a frame with no input. ## External material diff --git a/scripts/run_slimevolley_exam.py b/scripts/run_slimevolley_exam.py new file mode 100644 index 0000000..e956049 --- /dev/null +++ b/scripts/run_slimevolley_exam.py @@ -0,0 +1,258 @@ +#!/usr/bin/env python3 +"""Run one Harbor practice session and one fresh, held-out SlimeVolley match.""" +import argparse +import hashlib +import json +import os +import secrets +import shutil +import stat +import subprocess +import time +from pathlib import Path +from uuid import uuid4 + +ROOT = Path(__file__).resolve().parents[1] +TASKS = ROOT / "game_first_exam/tasks/slimevolley" +STANDARD = TASKS / "slimevolley-pixel-vs-baseline-i01-standard" +EXAM = ROOT / "game_first_exam/benchmarks/slimevolley" +PRACTICE_SEEDS = {"A": 2117382936, "B": 1056882141} +POLICY_SECONDS = 120 +MAX_POLICY_BYTES = 256 * 1024 + + +def docker(*args, **kwargs): + return subprocess.run(["docker", *args], check=True, text=True, **kwargs) + + +def build(context, *options): + return docker("build", "-q", *options, str(context), stdout=subprocess.PIPE).stdout.strip() + + +def read_json(path): + return json.loads(path.read_text()) + + +def write_json(path, value): + path.write_text(json.dumps(value, indent=2, allow_nan=False) + "\n") + + +def official_seed(path): + if path is not None: + seed = int(path.read_text().strip()) + if not 0 <= seed < 2**31 or seed in PRACTICE_SEEDS.values(): + raise ValueError("the official seed must be in [0, 2**31) and distinct from A and B") + return seed + seed = secrets.randbelow(2**31) + while seed in PRACTICE_SEEDS.values(): + seed = secrets.randbelow(2**31) + return seed + + +def stage_task(output, smoke): + task = output / "slimevolley-practice" + shutil.copytree(STANDARD, task, ignore=shutil.ignore_patterns("DIGEST", "README.md", "solution")) + sim = task / "environment/sim" + shutil.copyfile(EXAM / "exam_server.py", sim / "exam_server.py") + with (sim / "Dockerfile").open("a") as file: + file.write("\nCOPY exam_server.py /srv/exam_server.py\n") + shutil.copyfile(EXAM / "practice.md", task / "instruction.md") + config = task / "task.toml" + header, metadata = config.read_text().split("[task]\n", 1) + metadata = metadata.replace("slimevolley-pixel-vs-baseline-i01-standard", "slimevolley-practice") + metadata = metadata.replace("Win the native pixel match against the built-in SlimeVolley opponent.", + "Practice native pixel matches and submit a standalone controller.") + metadata = metadata.replace('protocol = "game-standard/2.2"', 'protocol = "slimevolley-exam/2"') + metadata = metadata.replace("instance_seed = 2117382936\n", "").replace("/data/final.json", "/data/practice.json") + if smoke: + metadata = metadata.replace("timeout_sec = 600.0", "timeout_sec = 18.0") + config.write_text(header.split("artifacts =", 1)[0] + """artifacts = [ + { source = "/var/rcb-monitor/", service = "rcb_monitor" }, + { source = "/data/practice.json", service = "sim" }, + "/app/output/", +] + +[task] +""" + metadata) + compose = task / "environment/docker-compose.yaml" + compose.write_text(compose.read_text().replace("/srv/server.py", "/srv/exam_server.py practice")) + tests = task / "tests/test.sh" + tests.write_text(tests.read_text().split("python3 /tests/grade.py", 1)[0] + + 'printf \'{"practice_collected": 1}\' > /logs/verifier/reward.json\n') + if smoke: + (task / "solution").mkdir() + shutil.copy(EXAM / "smoke.sh", task / "solution/solve.sh") + return task + + +def practice(output, task, config, hosts): + command = ["harbor", "run", "-p", str(task), "-c", str(config), "-y", + "--jobs-dir", str(output), "--job-name", "practice-job"] + for host in hosts: + command.extend(["--allow-agent-host", host]) + completed = subprocess.run(command) + (trial_file,) = (output / "practice-job").glob("*/result.json") + status = read_json(trial_file) + error = status["exception_info"] + timed_out = error is not None and error.get("exception_type") == "AgentTimeoutError" + if (completed.returncode or error) and not timed_out: + raise RuntimeError(f"Harbor practice failed; see {trial_file}") + artifacts = trial_file.parent / "artifacts" + summary = read_json(artifacts / "data/practice.json") + if summary.keys() != PRACTICE_SEEDS.keys() or any(row["errors"] for row in summary.values()): + raise RuntimeError("invalid simulator evidence in practice") + return artifacts, summary, timed_out + + +def freeze_submission(artifacts, destination): + folder = artifacts / "app/output" + if any(path.is_symlink() for path in (artifacts, folder.parent, folder)): + return "invalid", None, None + for name in ("gen.py", "practice_gen.py"): + candidate = folder / name + try: + fd = os.open(candidate, os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK) + except FileNotFoundError: + continue + except OSError: + return "invalid", None, None + break + else: + return "missing", None, None + with os.fdopen(fd, "rb") as file: + if not stat.S_ISREG(os.fstat(file.fileno()).st_mode): + return "invalid", None, None + source = file.read(MAX_POLICY_BYTES + 1) + if not source.strip() or len(source) > MAX_POLICY_BYTES: + return "invalid", None, None + try: + compile(source, "gen.py", "exec") + except (SyntaxError, ValueError, RecursionError): + return "invalid", None, None + destination.write_bytes(source) + destination.chmod(0o444) + return "submitted", hashlib.sha256(source).hexdigest(), name + + +def wait_for_sim(sim, marker, limit): + deadline = time.monotonic() + limit + while not marker.is_file(): + running = docker("inspect", "-f", "{{.State.Running}}", sim, stdout=subprocess.PIPE) + if running.stdout.strip() != "true" or time.monotonic() >= deadline: + docker("logs", "--tail", "40", sim) + raise RuntimeError(f"simulator did not publish {marker.name}") + time.sleep(0.25) + + +def rollout(official, sim_image, policy_image, grader_image, submitted): + name = "slimevolley-exam-" + uuid4().hex[:10] + sim, controller = name + "-sim", name + "-policy" + evidence, grade = official / "evidence", official / "grade" + evidence.mkdir() + grade.mkdir() + instance = official / "instance.json" + docker("network", "create", "--driver", "bridge", "--internal", + "--opt", "com.docker.network.bridge.gateway_mode_ipv4=isolated", name, stdout=subprocess.DEVNULL) + outcome = {"status": submitted} + try: + docker("run", "-d", "--name", sim, "--network", name, "--network-alias", "sim", + "--cpus", "1", "--memory", "1g", "--pids-limit", "128", + "-v", f"{instance}:/srv/instance.json:ro", "-v", f"{evidence}:/data", + sim_image, "python3", "/srv/exam_server.py", "official", stdout=subprocess.DEVNULL) + wait_for_sim(sim, evidence / "server.pid", 30) + if submitted == "submitted": + available_env = ["GAME_URL=http://sim:8000", "HOME=/tmp", "PYTHONDONTWRITEBYTECODE=1"] + available_env += [f"{prefix}_PROXY=" for prefix in ("HTTP", "HTTPS", "ALL", "NO")] + available_env += [item.lower() for item in available_env[3:]] + docker("run", "-d", "--name", controller, "--network", name, "--dns", "127.0.0.1", + "--cap-drop", "ALL", "--security-opt", "no-new-privileges", + "--user", "65534:65534", "--read-only", "--pids-limit", "256", + "--cpus", "1", "--memory", "1g", "--tmpfs", "/tmp:size=64m,mode=1777", + "--tmpfs", "/app/output:size=64m,mode=1777", "--log-opt", "max-size=4m", + *[arg for item in available_env for arg in ("-e", item)], + "-v", f"{official / 'gen.py'}:/app/gen.py:ro", + policy_image, "python3", "/app/gen.py", stdout=subprocess.DEVNULL) + try: + waited = docker("wait", controller, stdout=subprocess.PIPE, timeout=POLICY_SECONDS) + code = int(waited.stdout.strip()) + outcome = {"status": "exited" if code == 0 else "failed", "exit_code": code} + except subprocess.TimeoutExpired: + stopped = subprocess.run(["docker", "kill", controller], capture_output=True) + if stopped.returncode: + # A controller may exit on its own between docker wait and docker kill. + docker("wait", controller, stdout=subprocess.DEVNULL, timeout=10) + outcome = {"status": "timeout"} + with (official / "controller.log").open("w") as log: + docker("logs", "--tail", "200", controller, stdout=log, stderr=log) + + docker("kill", "--signal", "USR1", sim, stdout=subprocess.DEVNULL) + wait_for_sim(sim, evidence / "collection.ready", 90) + docker("run", "--rm", "--network", "none", + "-v", f"{instance}:/tests/instance.json:ro", + "-v", f"{evidence}:/data:ro", "-v", f"{grade}:/logs/verifier", + grader_image, "python3", "/tests/grade.py") + metrics = read_json(grade / "metrics.json") + steps = read_json(evidence / "rollout.json") + if (metrics["reason"] not in {"native_terminated", "native_truncated", "step_limit"} + or metrics["steps"] != steps["controller_steps"] + steps["idle_steps"]): + raise RuntimeError("official match did not reach a valid game ending") + return outcome, metrics, steps + finally: + for args in (("rm", "-f", controller, sim), ("network", "rm", name)): + subprocess.run(["docker", *args], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--output", type=Path, required=True, help="new private exam output directory") + mode = parser.add_mutually_exclusive_group(required=True) + mode.add_argument("--agent-config", type=Path, help="Harbor JSON with one practice agent") + mode.add_argument("--smoke", action="store_true", help="exercise the protocol with a local oracle") + parser.add_argument("--allow-agent-host", action="append", default=[]) + parser.add_argument("--official-seed-file", type=Path, help="host-only file containing one integer") + args = parser.parse_args() + + seed = official_seed(args.official_seed_file) + source = read_json(args.agent_config or ROOT / "configs/harbor/oracle.json") + (agent,) = source["agents"] + output = args.output.resolve() + output.mkdir(mode=0o700, parents=True) + official = output / "official" + official.mkdir(mode=0o700) + config = output / "practice-config.json" + # Keep only the caller's agent. The task owns the timeout, environment, and attempt count. + config.touch(mode=0o600) + write_json(config, {"agents": [agent], "n_attempts": 1, "n_concurrent_trials": 1, + "retry": {"max_retries": 0}}) + task = stage_task(output, args.smoke) + + sim = task / "environment/sim" + sim_image = build(sim) # Build before adding any practice instances. + specs = docker("run", "--rm", "-i", "--network", "none", sim_image, "python3", + "/srv/exam_server.py", "instances", + input=json.dumps({**PRACTICE_SEEDS, "official": seed}), + stdout=subprocess.PIPE) + instances = json.loads(specs.stdout) + write_json(official / "instance.json", instances.pop("official")) + write_json(sim / "practice-instances.json", instances) + with (sim / "Dockerfile").open("a") as file: + file.write("COPY practice-instances.json /srv/practice-instances.json\n") + + artifacts, summary, timed_out = practice(output, task, config, args.allow_agent_host) + submitted, sha, submission_source = freeze_submission(artifacts, official / "gen.py") + policy_image = build(STANDARD / "environment", "--target", "controller") + outcome, metrics, steps = rollout(official, sim_image, policy_image, + build(STANDARD / "tests"), submitted) + if args.smoke and (not timed_out or submission_source != "practice_gen.py" or outcome["status"] != "exited" + or steps["controller_steps"] != 1 or steps["idle_steps"] <= 0 + or summary["A"]["episodes"] != 2 or summary["B"]["episodes"] != 1): + raise RuntimeError("smoke trial did not exercise both slots, the saved practice controller and idle completion") + report = {"practice": summary, "practice_end": "time_limit" if timed_out else "agent_finished", + "submission_source": submission_source, "submission_sha256": sha, "controller": outcome, + "official": {**metrics, **steps}} + write_json(output / "exam.json", report) + print(json.dumps(report, indent=2)) + + +if __name__ == "__main__": + main() From 6816a9a8f430a4359e6e4449e06d514f2baaf77f Mon Sep 17 00:00:00 2001 From: hanzy Date: Tue, 24 Nov 2026 06:26:29 +0000 Subject: [PATCH 3/3] Validate all standard tasks against the registry --- game_first_exam/tests/test_game_harbor.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/game_first_exam/tests/test_game_harbor.py b/game_first_exam/tests/test_game_harbor.py index 96347be..9018e41 100644 --- a/game_first_exam/tests/test_game_harbor.py +++ b/game_first_exam/tests/test_game_harbor.py @@ -32,18 +32,22 @@ class GameSelection(unittest.TestCase): def test_game_only_default_and_all_selection_never_launches(self): - all_standard = sum(tc.mode_of(task) == 'standard' for task in tc.iter_tasks()) for flags, expected in ((["--list", "--standard"], 30), - (["--all", "--standard", "--list"], all_standard)): + (["--all", "--standard", "--list"], 42)): with self.subTest(flags=flags), contextlib.redirect_stdout(io.StringIO()) as output, \ patch("efe.harbor") as launch, patch("efe.prepull") as pull: self.assertEqual(efe.run(flags), 0) + launch.assert_not_called() + pull.assert_not_called() + if "--all" in flags: + registered = [task.name for task in tc.iter_tasks() if tc.mode_of(task) == "standard"] + self.assertGreaterEqual(len(registered), expected) + self.assertCountEqual(output.getvalue().splitlines(), registered) + continue names = output.getvalue().splitlines() self.assertEqual(len(names), expected) - self.assertTrue(all(name.startswith(tuple(prefix for prefix, _ in tc.BENCHMARKS)) + self.assertTrue(all(name.startswith(("minigrid-", "crafter-", "textworld-", "babaisai-", "minihack-")) for name in names)) - launch.assert_not_called() - pull.assert_not_called() def test_checkout_discovery_works_without_upstream_task_tree(self): self.assertTrue(efe.is_tree(ROOT))