Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 46 additions & 2 deletions .github/workflows/games.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
with: {python-version: '3.12'}
- run: python -m pip install -e .
- run: harbor run --game-suite minihack-balrog --standard --list
- run: harbor run --game-suite rocketleague --standard --list
- run: python game_first_exam/tests/test_game_harbor.py
fresh-clone-smoke:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -77,8 +78,50 @@ jobs:
name: fresh-clone-room-evidence
path: jobs/
retention-days: 7
browser-game-smoke:
runs-on: ubuntu-latest
timeout-minutes: 35
strategy:
fail-fast: false
matrix:
include:
- {suite: rocketleague, control: rocketleague/concede}
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 .
- name: Run the reference solution
env:
SUITE: ${{ matrix.suite }}
run: |
harbor run --game-suite "$SUITE" --standard -c configs/harbor/oracle.json \
--jobs-dir "$PWD/jobs" --job-name browser-reference -y
python ci_checks/check-browser-game-result.py jobs/browser-reference 1
- name: Run the failure control
env:
CONTROL: ${{ matrix.control }}
run: |
python "game_first_exam/tests/benchmarks/$CONTROL/run_harbor.py"
python ci_checks/check-browser-game-result.py jobs 0
- uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ matrix.suite }}-smoke-evidence
path: |
jobs/*/result.json
jobs/*/*/artifacts/data/final.json
jobs/*/*/verifier/reward.json
jobs/*/*/trial.log
retention-days: 7
invariants:
needs: [static, adapters, harbor, fresh-clone-smoke]
needs: [static, adapters, harbor, fresh-clone-smoke, browser-game-smoke]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
Expand All @@ -87,4 +130,5 @@ jobs:
ADAPTERS: ${{ needs.adapters.result }}
HARBOR: ${{ needs.harbor.result }}
SMOKE: ${{ needs.fresh-clone-smoke.result }}
run: test "$STATIC" = success && test "$ADAPTERS" = success && test "$HARBOR" = success && test "$SMOKE" = success
BROWSER_SMOKE: ${{ needs.browser-game-smoke.result }}
run: test "$BROWSER_SMOKE" = success && test "$STATIC" = success && test "$ADAPTERS" = success && test "$HARBOR" = success && test "$SMOKE" = success
25 changes: 25 additions & 0 deletions ci_checks/check-browser-game-result.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Verify the Harbor verdict from a browser game's reference or control run."""
import json
import sys
from pathlib import Path


def check(trial_dir, expected):
paths = (
trial_dir.glob("*/verifier/reward.json") if expected == 1 else
(path for path in trial_dir.glob("*/*/verifier/reward.json")
if path.parents[2].name != "browser-reference")
)
rewards = list(paths)
if len(rewards) != 1:
raise ValueError(f"Expected one verifier result under {trial_dir}, found {len(rewards)}")
reward = json.loads(rewards[0].read_text())
errors = ("infra_error", "sim_error", "environment_error")
if (not reward.get("result_valid") or any(reward.get(key) != 0 for key in errors)
or reward.get("steps", 0) <= 0 or reward.get("success") != expected):
raise ValueError(f"Expected a valid result with success={expected}: {reward}")
print(f"{rewards[0]}: success={expected}, steps={reward['steps']}")


if __name__ == "__main__":
check(Path(sys.argv[1]), int(sys.argv[2]))
3 changes: 3 additions & 0 deletions configs/game_benchmarks.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ schema = "game_first_exam/benchmarks/babaisai/instance_schema.py"

[benchmarks.minihack]
schema = "game_first_exam/benchmarks/minihack/instance_schema.py"

[benchmarks.rocketleague]
schema = "game_first_exam/benchmarks/rocketleague/instance_schema.py"
10 changes: 10 additions & 0 deletions configs/game_suites/rocketleague.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
schema_version = "game-suite/2.1"
version = "1.0.0"
tier = "smoke"
name = "games-rocketleague-minimal-v1.0.0"
files_images = ["connection-files", "game-files", "rocketleague-files"]

[[tasks]]
name = "rocketleague-first-goal-i01-standard"
benchmark = "rocketleague"
family = "first-goal"
Binary file added docs/demos/rocketleague/conceded-goal.mp4
Binary file not shown.
Binary file added docs/demos/rocketleague/first-goal.mp4
Binary file not shown.
125 changes: 125 additions & 0 deletions game_first_exam/benchmarks/rocketleague/adapter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
"""GameWorld 25_01, played against the native single-player opponent."""
from base64 import b64decode
from contextlib import ExitStack
from datetime import datetime, timedelta, timezone
from io import BytesIO
from pathlib import Path
from urllib.parse import unquote, urlsplit

import numpy as np
from PIL import Image
from playwright.sync_api import sync_playwright

from contracts import Capabilities, Transition
from encoding import png, state_hash

MOVES = {"wait": (), "left": ("a",), "right": ("d",), "brake": ("s",),
"jump": ("w",), "jump_left": ("a", "w"), "jump_right": ("d", "w"),
"boost_left": ("a", "Space"), "boost_right": ("d", "Space"),
"jump_boost_right": ("d", "w", "Space"), "jump_boost_left": ("a", "w", "Space")}
ORIGIN = "http://pitch.test"


class Adapter:
def __init__(self, instance, assets=None):
self.stack = ExitStack()
try:
self.load(Path(assets) / "game")
except BaseException:
self.close()
raise

def load(self, root):
root = root.resolve(strict=True)
driver = self.stack.enter_context(sync_playwright())
browser = driver.chromium.launch(args=["--mute-audio"])
self.stack.callback(browser.close)
self.page = browser.new_page(viewport={"width": 1024, "height": 384})

self.cdp = self.page.context.new_cdp_session(self.page)

def serve(route):
url = urlsplit(route.request.url)
path = (root / unquote(url.path).lstrip("/")).resolve()
if url.netloc == "pitch.test" and path.is_relative_to(root) and path.is_file():
route.fulfill(path=path)
else:
route.abort()

self.page.route("**/*", serve)
start = datetime(2026, 1, 1, tzinfo=timezone.utc)
self.page.clock.install(time=start)
self.page.clock.pause_at(start + timedelta(seconds=1))
self.page.goto(ORIGIN + "/index.html?player=1", wait_until="domcontentloaded")
# Stop on the first playable animation frame, including on a cold browser cache.
for _ in range(2500):
self.page.clock.run_for(16)
state = self.page.evaluate("() => window.gameAPI?.getState()")
if state and state["is_actionable"]:
if state["game_state"]["environment"]["room_name"] == "rm_game":
self.state = state
break
else:
raise RuntimeError("Single-player match did not start")
if self.score() != (0, 0) or self.state["seed"] != 42:
raise RuntimeError("Unexpected kickoff")
self.steps = 0
self.capture()

def spec(self):
return {"adapter_version": "1.0.0", "capabilities": Capabilities(True, "enum").to_dict(),
"action_schema": {"type": "string", "enum": list(MOVES)},
"actions": "Hold one movement for 160 milliseconds of match time.",
"goal": "Score the first goal against the native AI."}

def capture(self):
# DevTools captures the composited frame without advancing the paused game clock.
shot = self.cdp.send("Page.captureScreenshot", {"format": "png", "fromSurface": True})
data = b64decode(shot["data"])
with Image.open(BytesIO(data)) as image:
self.rgb = np.array(image.convert("RGB"))

def frame(self):
return self.rgb

def observe(self):
return {"image_png_base64": png(self.rgb)}

def step(self, action):
if action not in MOVES or self.score() != (0, 0):
raise ValueError("Invalid input or finished match")
keys = MOVES[action]
for key in keys:
self.page.keyboard.down(key)
try:
self.page.clock.run_for(160)
finally:
for key in reversed(keys):
self.page.keyboard.up(key)
self.steps += 1
self.state = self.page.evaluate("gameAPI.getState()")
self.capture()
return Transition(float(self.success()), self.score() != (0, 0))

def score(self):
metrics = self.state["metrics"]
score = metrics["goals_for"], metrics["goals_against"]
if any(type(value) is not int for value in score):
raise RuntimeError("Native scoreboard unavailable")
return score

def success(self):
return self.score() == (1, 0)

def metrics(self):
own, opponent = self.score()
return {"goals_for": own, "goals_against": opponent, "success": int(self.success())}

def fingerprint(self):
board = self.state["game_state"]
return state_hash({"seed": self.state["seed"], "room": board["environment"]["room_name"],
"player": board["player"], "entities": board["entities"],
"score": self.score(), "steps": self.steps})

def close(self):
self.stack.close()
13 changes: 13 additions & 0 deletions game_first_exam/benchmarks/rocketleague/instance_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SCHEMA_VERSION = "1.0.0"
BENCHMARK = "rocketleague"
FIELDS = {"engine_commit"}
METRICS = {"success"}
PROFILES = {"native-rgb-v1"}
REDUCERS = {("family_macro", "1.0.0")}


def validate(value):
if value["seed"] != 42 or value["engine_commit"] != "e5ddb16df85b91a1d17bb0577621cc7c5e65d738":
raise ValueError("unknown GameWorld-Games version")
if (value["env_id"], value["family"], value["max_steps"]) != ("rocket-league-2d", "first-goal", 250):
raise ValueError("unknown GameWorld task configuration")
11 changes: 11 additions & 0 deletions game_first_exam/benchmarks/rocketleague/metric_rules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""Grade GameWorld 25_01 at the first goal."""
def validate_metrics(final, instance):
metrics = final["metrics"]
score = metrics["goals_for"], metrics["goals_against"]
if any(type(goals) is not int for goals in score) or score not in {(0, 0), (1, 0), (0, 1)}:
raise ValueError("Invalid first-goal score")
won = score == (1, 0)
if final["terminated"] != (score != (0, 0)):
raise ValueError("Terminal flag disagrees with the scoreboard")
if (final["success"], final["return"], metrics["success"]) != (won, float(won), int(won)):
raise ValueError("Reward disagrees with the scoreboard")
5 changes: 5 additions & 0 deletions game_first_exam/benchmarks/rocketleague/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
playwright==1.55.0
numpy==1.26.4
pillow==10.4.0
imageio-ffmpeg==0.6.0
imageio==2.37.0
10 changes: 10 additions & 0 deletions game_first_exam/images/rocketleague-files/FILES.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"source": "game_first_exam/benchmarks/rocketleague",
"files": {
"adapter.py": "e7cbea18f41b22cb04a21d2f9dec5dfb09a6871162e5f843fd9c76106584dde6",
"instance_schema.py": "71b9f199ea60d7f63cecb7cd19120adbe717eaaf3a683332062392cce9621f74",
"metric_rules.py": "c51413a27a70ad20505cb3e200e61ae0566c0a4e67d6889266d018fb290fdfb0",
"requirements.txt": "f7b63cd5e9d2d806613a620bb7340f27ce6735ba76c9d5a08f77d48e527d4733"
},
"image": "ghcr.io/mll-lab-nu/efe:rocketleague-files-0.1.0@sha256:d3ae7d1cd943106acd92ecfebea6aa43660877adab9b0c2243dfb90eaa4235c2"
}
1 change: 1 addition & 0 deletions game_first_exam/images/rocketleague-files/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
20 changes: 20 additions & 0 deletions game_first_exam/tasks/rocketleague/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Rocket League 2D
GameWorld task 25_01 asks the player to score without conceding. This adapter ends the match at its first goal and checks both native goal counters. The simulator builds the original single-player game from its pinned upstream commit and uses its default AI. Only screenshots and player-one keyboard actions cross the client interface.

Run the reference attack and the early-release control from the repository root.

```sh
harbor run --game-suite rocketleague --standard -a oracle -y
python game_first_exam/tests/benchmarks/rocketleague/concede/run_harbor.py
```

[GameWorld task](https://github.com/gameworld-project/GameWorld/blob/84f624bd1e120d30aeebf2eb42a39410e24d3bd4/catalog/tasks/25_rocket-league-2d/25_01.yaml) · [Game assets and rights](https://github.com/gameworld-project/GameWorld-Games/tree/e5ddb16df85b91a1d17bb0577621cc7c5e65d738/benchmark/25_rocket-league-2d)

## Gameplay demos

| Player input | Score | Steps | Harbor reward |
| --- | --- | ---: | ---: |
| [Hold boost to the right](../../../docs/demos/rocketleague/first-goal.mp4) | 1–0 | 31 | 1 |
| [Release boost after eight steps](../../../docs/demos/rocketleague/conceded-goal.mp4) | 0–1 | 172 | 0 |

Both Harbor trials completed with zero environment errors. Their FFmpeg recording pipes closed early. The linked videos are separate browser runs of the same policies, with matching opening fingerprints, final scores and action counts.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sha256:dc3aa7135cd4562c5d4f019c2235340aee43d76e8cba3480e0ef1e72e9fae911
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# rocketleague-first-goal-i01-standard

| | |
|---|---|
| Benchmark | GameWorld Rocket League 2D |
| Mode | standard (`game-standard/2.2`) |
| Twin | — (none: GameWorld Rocket League 2D has no privileged mode, PROTOCOL §2) |
| Simulator / robot | `rocketleague` / `game-agent` |
| Family / instance | `first-goal` / seed 42 |
| 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
Score first in a single-player match against the native AI. The reference solution drives and boosts through the public client. The verifier checks both teams’ goal counts.

## Difficulty
Start at a fixed kickoff against the default single-player opponent. Releasing boost early gives the opponent time to recover and counterattack.

## Reference solution
See `solution/`.

## Verification
The verifier checks the two native goal counters. A first goal for the player earns one point. Conceding or exhausting the action budget earns zero.

## 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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
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
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
Original file line number Diff line number Diff line change
@@ -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
Loading