{"data":{"kind":"file","path":"README.md","version_id":"dfwib1lgz6ha2fwgi9k7j4t6","entry":{"name":"README.md","path":"README.md","is_directory":false,"size":11113,"modified_at":"2026-11-28T04:32:06.411000","content_hash":"bd4da00a06d43be1399503c569ccc87af6b45fafc702b060c2a8cfa36000bd11"},"entries":[],"content":"![oice: learning to fight with delayed observations](media/oice-banner.svg)\n\n# oice-env\n\n**A FightingICE arena for agents: write a fighter, test it against frozen opponents, and watch the final fight. Or plug your own RL policy straight into the C simulator.**\n\n[Prime Intellect Hub](https://app.primeintellect.ai/dashboard/environments/thehon/oice-env)\n· [Get started](#get-started)\n· [Opponents](#opponents)\n· [Scoring](#scoring)\n· [The research behind it](https://github.com/thehon/oice-public)\n· [Train a policy instead: oice-rl-training](https://app.primeintellect.ai/dashboard/environments/thehon/oice-rl-training)\n\n[![Our trained fighter against MctsAi23i in FightingICE](media/oice-vs-mcts-native50.gif)](media/oice-vs-mcts-native60.mp4)\n\n*Our research agent (P1, policy plus search) against MctsAi23i (P2) in the Java game.\n[Watch the 60 fps video](media/oice-vs-mcts-native60.mp4) ·\n[View the repo on GitHub](https://github.com/thehon/oice-public).\nRuns in this environment use the C simulator and produce HTML replays with debug geometry.*\n\n---\n\noice-env is one half of the harness from [oice](https://github.com/thehon/oice-public), a project that trains a FightingICE agent from scratch with self-play RL. The research agent beats ReiwaThunder (2019 champion) and Thunder2021, and it now beats BlackMamba (2021 champion) too: the current ship, a plain policy with no search, wins about 9 matches in 10, by +409 HP a game with input synced and +387 in real time (400 games each), and wins 800 of 800 matches against the eight real-time competition bots. This package gives you the same simulator and some of the same opponents, so you can try your own approach.\n\nIt is a [Verifiers](https://github.com/PrimeIntellect-ai/verifiers) environment on the [Prime Intellect Environments Hub](https://app.primeintellect.ai/dashboard/environments). You can use it in three ways:\n\n| Approach | What you get |\n| --- | --- |\n| Write a controller | A Bash workspace where a coding model implements, tests and submits a Python fighter |\n| Bring a policy | Native reset, step and close, with delayed observations, legal-action masks and damage rewards |\n| Set the challenge | Frozen opponents, your own pool members and a designated final boss |\n\nThe coding task follows one loop: write, test, select, fight. Development fights give feedback; independent final matches score the version the agent selected. The environment supplies the arena and the scoring. The strategy is up to your agent.\n\n## Get started\n\nYou need Python 3.11 on Linux x86-64 (glibc). Coding episodes also need Docker and verified local game inputs. Native stepping needs no inference key, Docker or Java.\n\n### Install and prepare the arena\n\nWith the [Prime CLI](https://docs.primeintellect.ai/tutorials-environments/environments):\n\n```sh\nuv venv .venv --python 3.11\n. .venv/bin/activate\nprime env install thehon/oice-env --prerelease\n\n# our policy weights (release oice-env-weights-v1) and FightingICE's own character tables\nmkdir -p oice-src/third_party/FightingICE7.1\ncurl -fLO https://github.com/thehon/oice-public/releases/download/oice-env-weights-v1/oice-env-weights-v1.tar.gz\ntar -xzf oice-env-weights-v1.tar.gz -C oice-src && (cd oice-src && sha256sum -c SHA256SUMS)\ncurl -fLO https://github.com/TeamFightingICE/FightingICE/releases/download/v7.1/resource-7.1.zip\nunzip -q resource-7.1.zip 'data/characters/*' -d oice-src/third_party/FightingICE7.1\n\noice-env assets prepare --source \"$PWD/oice-src\" --output \"$PWD/oice-assets\"\nexport OICE_ASSET_ROOT=\"$PWD/oice-assets\"\noice-env doctor --assets \"$OICE_ASSET_ROOT\"\n```\n\nInstallation never downloads anything; these steps do it once, explicitly. The weights release holds the five built-in policies (`policy-ref32`, `policy-s23`, `policy-s32`, `policy-s41c`, `policy-s58`), MIT licensed. The character tables come from FightingICE's own v7.1 release and are not redistributed here. Asset preparation checks every file against the expected hashes and builds a new bundle. Run `oice-env assets manifest` to see the required files, or select a subset with repeated `--opponent ID` flags.\n\n### Try the coding workflow\n\nWith Docker and the solver image ready, run a local fixture without a model key:\n\n```sh\noice-env run --mode mock --runtime docker \\\n  --round-frames 64 --output /path/to/new-report\n```\n\nThis exercises controller development, selection, final fights and replay delivery. For a real model run, the [runner guide](docs/running.md) covers providers, budgets and the matching mock. Prime Intellect inference is optional; OpenRouter and other compatible endpoints work too. Use a new output directory for each run.\n\n### Or use plain `vf-eval`\n\nThe packaged configs give stock Verifiers tooling the same contract as `oice-env run`: the `catalog-v1` profile, 24 responses of up to 4096 tokens, and explicit tested-hash selection.\n\n```sh\nvf-eval @ configs/verifiers-eval.example.toml -m YOUR_MODEL --no-push\n```\n\nThe prompt states the response budget, and setup refuses an agent whose `max_turns`, `max_output_tokens` or `sampling.max_tokens` differ from it, so the model is never told a budget it does not have. Change both sides together, through `env.taskset.task.model_turns` / `reply_tokens` and the agent limits. The evaluator still runs on your machine (assets and Docker); a hosted Prime evaluation or training run cannot reach it.\n\n### Connect your own training loop\n\n```python\nfrom oice_env import FightingEnv\n\nenv = FightingEnv(\"policy-s23\", rounds=1, round_frames=512)\ntry:\n    observation, info = env.reset(seed=123)\n    # Feed observations into your policy and call env.step(action).\nfinally:\n    env.close()\n```\n\nObservations have 264 values and there are 42 actions, with a legal-action mask. Your policy acts on a delayed view of the fight, so timing and memory matter.\n\nFor training, use the batched env. It returns numpy arrays, resets finished matches automatically and reports each finished match in `info[\"episodes\"]`. It matches `FightingEnv` step for step and is about 13 times faster against the scripted bots (34k vs 2.5k steps per second on one core). Install the `vector` extra for numpy.\n\n```python\nimport numpy as np\nfrom oice_env import VecFightingEnv\n\nenv = VecFightingEnv([\"strike\", \"zone_hard\", \"policy-ref32\"] * 4, seats=[0, 1] * 6, seed=1000)\nobs, info = env.reset()                      # obs: (12, 264), info[\"mask\"]: (12, 42)\nactions = np.array([np.flatnonzero(m)[0] for m in info[\"mask\"]])\nobs, reward, terminated, truncated, info = env.step(actions)\nenv.close()\n```\n\nOne process holds at most 32 matches. Policy opponents run in C inside the step, so a 256x4 research policy still costs about 4 ms per step; use several processes for throughput against them.\n\n## Opponents\n\nWeakest first:\n\n| Opponent | Kind |\n| --- | --- |\n| `strike` | Scripted controller |\n| `zone_hard` | Scripted controller |\n| `policy-ref32` | Small learned policy: a short oice-rl-training reference-learner run. Mid-strength; separates controllers that already beat the bots |\n| `policy-s23` | Frozen policy from the oice research (the previous shipped agent, without its search) |\n| `policy-s32` | Another frozen research policy |\n| `policy-s41c` | The current shipped research checkpoint, without its search |\n\nThe [calibration](docs/opponents.md) shows how controllers and trained policies score against each one. After upgrading, run `oice-env assets prepare` again: the bundle now holds `policy-ref32` and `policy-s41c` too.\n\nRun `oice-env opponents --profile catalog-v1` to see the full roster.\n\nYou can also register your own trained checkpoint as a pool member or a final boss. A boss is held out from practice unless you explicitly allow it.\n\n```sh\noice-env opponent export --weights /path/to/checkpoint.bin \\\n  --sidecar /path/to/checkpoint.json --id my-boss --output /path/to/new-opponent\noice-env opponent register --bundle /path/to/new-opponent \\\n  --assets \"$OICE_ASSET_ROOT\" --role boss\n```\n\nThe importer accepts completed native spec-3 PufferLib checkpoints and pins each one by hash. Imported and built-in policies run without the research agent's look-ahead search. See [custom opponents](docs/platform.md) for the format.\n\n## Scoring\n\nThe final reward is the mean match score across the configured opponents and both player positions:\n\n| Win | Draw | Loss |\n| :---: | :---: | :---: |\n| 1 | 0.5 | 0 |\n\nChoose `--evaluation pool`, `boss` or `combined`. Combined runs also report pool and boss scores separately. For native learning, each step's reward is net damage divided by 400.\n\nThe default `catalog-v1` final grid (`final-v2`) is strike, zone_hard, policy-ref32 and policy-s23, both seats, two seeds: 16 matches. The legacy profile keeps `final-v1`, which has policy-s32 in place of policy-ref32. The mean HP margin is also recorded as `hp_margin` (0.5 = even), with weight 0. To count it in the reward:\n\n```toml\n[env.taskset.task.rewards.hp_margin]\nweight = 0.5\n```\n\nYou choose the roster. BlackMamba is not included, so scores here are not comparable with the research results.\n\n## RL on the coding task\n\nBy default the taskset has one row, scored on the frozen grid. For grouped RL, `configs/rl-coding.example.toml` builds 64 rows. Each row draws its own final seeds from a held-out pool (disjoint from the development and frozen final seeds) and cycles through a list of opponent rosters. Rollouts of one row share seeds and roster, so group baselines compare like with like.\n\n```toml\n[env.taskset]\nid = \"oice-coding\"\nnum_tasks = 64\nseeds_per_task = 2\nrosters = [[\"strike\", \"zone_hard\", \"policy-ref32\", \"policy-s23\"], [\"strike\", \"policy-ref32\"]]\n```\n\nThe simulator is deterministic: seeds change a match only through the sampling policies (s23, s32, s41c) and controllers that use their seed. Against the bots and policy-ref32, a deterministic controller plays the same match on every seed.\n\n## Replays\n\nEach coding run keeps the selected controller, development feedback, final scores and HTML replay viewers. Open the recorded fights to see how the agent plays, or render them later with `oice-env replay view`.\n\n## More\n\n| Guide | Contents |\n| --- | --- |\n| [Installation](docs/installation.md) | Platform requirements, assets and the doctor check |\n| [Runner and replays](docs/running.md) | Providers, budgets, mock and live runs, replay files |\n| [Opponents](docs/opponents.md) | Built-in roster, strength calibration, seeds |\n| [Custom opponents](docs/platform.md) | Exporting, validating and registering checkpoints |\n| [Prime solver](docs/remote-coding.md) | Running the coding workspace on Prime Intellect sandboxes |\n\nWant to test whether an agent can train a fighter rather than write one? Use [oice-rl-training](https://app.primeintellect.ai/dashboard/environments/thehon/oice-rl-training).\n\n## Status and license\n\nThe package is MIT licensed. Game inputs are supplied by the operator; third-party terms and provenance are in `NOTICE`. Built on [FightingICE](https://github.com/TeamFightingICE/FightingICE), [PufferLib](https://github.com/PufferAI/PufferLib) and [Verifiers](https://github.com/PrimeIntellect-ai/verifiers).\n","encoding":"utf-8","truncated":false,"total_bytes":11113},"status":null}