diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..06979780df7fa1f051f156c99471bc088203b31f --- /dev/null +++ b/README.md @@ -0,0 +1,183 @@ +--- +pretty_name: WeightProgramBench +language: +- en +task_categories: +- text-generation +size_categories: +- n<1K +tags: +- reinforcement-learning +- weight-space-programming +- games +- benchmark +configs: +- config_name: default + data_files: + - split: train + path: data/train.jsonl + - split: test + path: data/test.jsonl +--- + +# WeightProgramBench + +Write the weights of a small game-playing neural network in one response, +without tools. Each task provides the game rules, observation layout, game +source, and network format. A CPU scorer reads numeric tensor assignments and +plays the resulting policy; it never executes model-written code or trains the +submitted network. Reinforcement learning can train the language model between +submissions. + +This dataset preserves the expanded MinAtar Synth v4 corpus: **317 training +games and five held-out original MinAtar games**. It contains task prompts, +game implementations, the frozen scorer, and source attribution. It does not +contain reference solutions, model weights, or model-generated trajectories. + +## Splits + +| Split | Games | Family | +| --- | ---: | --- | +| Train | 51 | Atari-style synthetic Python conversions | +| Train | 266 | Crisp-inspired synthetic Python conversions | +| Test | 5 | Original MinAtar: Asterix, Breakout, Freeway, Seaquest, Space Invaders | + +Training environments are compact Python adaptations, not Atari ROM emulation +or native Crisp gameplay. All use `10 × 10 × 6` binary observations. The five +original MinAtar games have their observation channels mapped into the same +six-channel input. The split holds out game identities; it does not establish +that every test mechanic is absent from training. + +## Load the tasks + +```python +from datasets import load_dataset + +tasks = load_dataset("neilkale/WeightProgramBench") +print(len(tasks["train"]), len(tasks["test"])) # 317, 5 +task = tasks["test"][0] +messages = [ + {"role": "system", "content": task["system_prompt"]}, + {"role": "user", "content": task["prompt"]}, +] +``` + +Each row preserves the original fields `name`, `split`, `game`, `source`, +`prompt`, `system_prompt`, and `episodes`. Additional columns are: + +- `task_id`: zero-based index in the original 322-row task file. These IDs are + not renumbered within splits. +- `family`: `atari_synthetic`, `crisp_synthetic`, or `minatar_original`. +- `upstream_source_url` and `upstream_revision`: implementation provenance. +- `native_source_url`: pinned native Crisp source, where applicable. + +For reproducible experiments, pin the same dataset commit using `revision=` +when loading tasks and downloading runtime files. + +## Policy and scoring + +Every task uses a **600 → 32 → 32 → 6** network with **20,486 float32 +parameters**, two tanh hidden layers, and softmax-sampled actions. All parameters +start at zero. The model supplies numeric tensor assignments in a fenced +`edits` block, following the task's format. The scorer validates assignments +with Python's AST and literal parser; it does not execute the response as Python. + +Each submitted policy plays **1,000 episodes**: + +- Environment seed: `1729 + episode_index`, covering `1729–2728`. +- Independent action RNG seed: `7919 + episode_index`, covering `7919–8918`. +- Sticky-action probability: `0.1`. +- Episode limit: termination or **10,000 actions**. +- Original MinAtar difficulty ramping: disabled. + +Seeds are fixed across games and submissions. The reward is +`clip(mean_game_score, 0, game_score_cap) / game_score_cap`. Each synthetic game +declares its own cap. Original MinAtar caps are 1,000, except Freeway's cap of +100. These scales do not make games equally difficult. Invalid submissions +receive zero. Keep raw scores alongside normalized rewards when comparing +policies. + +The frozen runtime uses **NumPy 2.3.4** and **MinAtar 1.0.15**. Policy inference +and replay run on CPU. One policy's 1,000 episodes are one language-model +sample, not 1,000 independent model generations. + +## Score a saved response locally + +Install the replay dependencies; installing MinAtar without dependencies avoids +adding optional visualization and training packages: + +```bash +python -m pip install huggingface_hub 'numpy==2.3.4' +python -m pip install --no-deps 'MinAtar==1.0.15' +``` + +Save the model's complete response, including its `edits` block, in `answer.txt`. +Then evaluate it against the matching game: + +```python +import json +from pathlib import Path +import sys +from huggingface_hub import snapshot_download + +snapshot = Path(snapshot_download("neilkale/WeightProgramBench", repo_type="dataset")) +runtime = snapshot / "runtime" +sys.path.insert(0, str(runtime)) +from verify import apply_edits, evaluate, score_cap + +tasks = [json.loads(line) for line in (runtime / "tasks.jsonl").read_text().splitlines()] +task = next(task for task in tasks if task["game"] == "breakout" and task["source"] == "original") +answer = Path("answer.txt").read_text() +weights, edit_count = apply_edits(answer) +raw_score, mean_episode_length = evaluate(task["game"], task["source"], weights, task["episodes"]) +cap = score_cap(task["game"], task["source"]) +reward = min(max(raw_score, 0.0), cap) / cap +print({"raw_score": raw_score, "reward": reward, "mean_episode_length": mean_episode_length}) +``` + +This example raises on malformed responses so local debugging is explicit. +For the benchmark's invalid-submission handling, use +`verify.grade_answer(game, source, answer, episodes)`, which returns a reward +and grading metadata. Full 1,000-episode replay can take several minutes, +depending on the game and CPU. + +The Trajectory integration lives in the +[WeightProgramBench cookbook PR](https://github.com/Trajectorylabs/trajectory-cookbook/pull/104). +Model inference and training are separate from the local scorer. + +## Files and integrity + +- `data/train.jsonl`, `data/test.jsonl`: Hugging Face task splits with provenance + columns added. +- `runtime/tasks.jsonl`: byte-identical frozen task records in their original + order, without added columns. +- `runtime/minatar_synth/games/`: the 317 frozen Python training environments. +- `runtime/verify.py`: frozen policy parser and CPU scorer. +- `runtime/source.json`: SHA-256 digests for the original task file, scorer, + and all 317 game files. +- `TASK_ORIGINS.json`: per-game source mappings, pinned revisions, and prompt + and implementation digests. +- `THIRD_PARTY_NOTICES.md`, `runtime/NOTICE.txt`, and `runtime/LICENSE-*`: + credits and applicable upstream notices. + +Synthetic source revision: `4038830175c4201ca10e004ed4441985f2acddf2`. +Frozen task-file SHA-256: +`cc2d728fc3c820f217ecf43a4fdc0c9e2a5e292fcdd8b4afb0cb1d34774691e6`. + +## Credits and licensing + +The weight-space programming setup follows +[Rikiya Takehi, Jayden Teoh, Alex Zhang, and Omar Khattab's experiments](https://rikiyat.github.io/blog/weight-space-programming/), +particularly Experiment 5. The expanded training environments come from +[Trajectory Labs, Jerry Chan, and contributors to MinAtar Synth](https://github.com/Trajectorylabs/minatar-synth/tree/4038830175c4201ca10e004ed4441985f2acddf2). +Crisp game designs and sources are credited to **ABA Games** and contributors, +and the portable SDL/C versions to **Joyrider3774** and contributors. +Original **MinAtar** is by **Kenny Young and Tian Tian**. + +Licensing differs by component: original MinAtar source is GPL-3.0, the cited +native Crisp source collections carry MIT notices, and the original experiment's +prompt/log materials are attributed under CC BY 4.0. The pinned MinAtar Synth +repository does not declare a license for its converted implementations. This +dataset does not assert a blanket license for those files. See +[THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for the exact scopes and source +links; the original MinAtar source embedded in prompts retains its GPL scope. diff --git a/TASK_ORIGINS.json b/TASK_ORIGINS.json new file mode 100644 index 0000000000000000000000000000000000000000..67912d8af6954760bfe92dcbebff5072ededac08 --- /dev/null +++ b/TASK_ORIGINS.json @@ -0,0 +1,5600 @@ +{ + "schema_version": 1, + "source_snapshot_sha256": "ec8fe0459090c3c848c18d54cc08acee52d233971b2f196851abf708a643c0a9", + "synthetic_source_repository": "https://github.com/Trajectorylabs/minatar-synth", + "synthetic_source_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "counts": { + "crisp_synthetic": 266, + "atari_synthetic": 51, + "minatar_original": 5 + }, + "tasks": [ + { + "name": "marusansi", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "3f8ea34de6e7e0d90243af84a18d5554bc3e37d0aa0a3f3117aa986c0ea9093e", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/marusansi.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/marusansi.py", + "source_sha256": "e8bd38950ee43da1b23754e52c8100528376804324cef725a5cee1d84da9645c", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/marusansi.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameMarusansi.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameMarusansi.c", + "native_license": "MIT" + }, + { + "name": "thunder", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "92696285e1e191939c97f904cb8ddf1c2261dbd3f05defcea08f229103770595", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/thunder.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/thunder.py", + "source_sha256": "cd13fe200c99ab4e14b2854384c91d7f629238b7a2c368373970c1ba5e15fe5a", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/thunder.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-11-games/blob/6fea4eefe2deaa42706051d96a04ec9e36104696/docs/thunder/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-11-games", + "native_pinned_commit": "6fea4eefe2deaa42706051d96a04ec9e36104696", + "native_source_path": "docs/thunder/main.js", + "native_license": "MIT" + }, + { + "name": "up_shot", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "2a91ecdf8025c5f4985da8e4361d96a511a7201a4b730554c579400e4ffd6080", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/up_shot.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/up_shot.py", + "source_sha256": "f39925a6283256ad3da10f4a02bcd3113cad5df6ac2c7cf02937c04ecd8e6c39", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/up_shot.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/upshot/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/upshot/main.js", + "native_license": "MIT" + }, + { + "name": "ladder_drop", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "e68dccd97c7d269f23e44091813173bb717986969bef703ddd33062d8374a496", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/ladder_drop.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/ladder_drop.py", + "source_sha256": "730fb9a48d6fd00f8588a736a0790c0df56a505a32c5b312dffc950472ba4eeb", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/ladder_drop.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameLadderDrop.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameLadderDrop.c", + "native_license": "MIT" + }, + { + "name": "scrambird", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "93b82a830beebac274ba8f8d6d6256d74c6ea56b34fe4db272bd50993993cabc", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/scrambird.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/scrambird.py", + "source_sha256": "9ab3ddfc3340eeb1ca249b721e8cc26cfaa9014705f3c7e9e1bcf9eca8c2dce7", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/scrambird.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/scrambird/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/scrambird/main.js", + "native_license": "MIT" + }, + { + "name": "battle_zone", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "a1a63a22d837ce0a973eb31276c1cdce7188061ba3f7b40c60efc5ce5aea8f4f", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/battle_zone.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/battle_zone.py", + "source_sha256": "50b3122f943660c04b313b1c2cf18e6d6a1f0d2c3c39216b54ba2bf3280b0e6b", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/battle_zone.md", + "historical_source": "The mechanics, lives, bonus threshold, and target values follow Atari's instruction manual for\nthe Atari 2600 version of *Battlezone*." + }, + { + "name": "b_blast", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "defe4eb8d2c03517b02f9eacc690af858e0cb7d2454736ded2569a455e0534e7", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/b_blast.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/b_blast.py", + "source_sha256": "e53595a6514c8fa9a7c9dccf0cf0051d44aff33662575f7c3fd9bdd3635fa981", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/b_blast.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBBlast.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameBBlast.c", + "native_license": "MIT" + }, + { + "name": "zaxxon", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "34a35716ee86f812d31d2197ad690b6e7f2e6bb7e59e5f123edd64b22b4ee6de", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/zaxxon.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/zaxxon.py", + "source_sha256": "0a2f6a576b6a087a1890892b3dcd80bf8e9c2dd29c57a0e262b647c5ce3e1c26", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/zaxxon.md", + "historical_source": "The inverted altitude controls, energy blasts, four skill levels, fortress-space-fortress sequence,\nfuel drain and tanks, barriers, ground and air enemies, stopped boss encounter, vulnerable missile,\nthree skill-one hits, all target values, five fighters, and reinforcement follow Coleco's Atari\n2600 *Zaxxon* manual as transcribed by AtariAge:\nhttps://www.atariage.com/manual_html_page.php?SoftwareLabelID=606." + }, + { + "name": "cate_p", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "51b9305cf02139f4f3c401dc2ad5d9fbfc130a0938515acf75eaefb2bef9d6fb", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/cate_p.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/cate_p.py", + "source_sha256": "3d0d4afb1a09c2bf9078e1798c357adf8416d56ce31557f66f6f8c6226232eb8", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/cate_p.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/catep/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/catep/main.js", + "native_license": "MIT" + }, + { + "name": "tt_fence", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "ce795703e0d26fe95fbad02d6e52f9752c740733a62f36a95abd444563cba2db", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tt_fence.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/tt_fence.py", + "source_sha256": "2c63e52e4e99764e5e9d1be27f2008fe164da1bba0ff940230a77aa6e99014b2", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/tt_fence.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/ttfence/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/ttfence/main.js", + "native_license": "MIT" + }, + { + "name": "cross_line", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "9efbbb4225cd314ca5703b7a3f2b50d399d6797bbe26c2ae6a16d26ce6720dc8", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/cross_line.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/cross_line.py", + "source_sha256": "759847462a749f09ed8a6a3ba6d0c34541e44b65ad5ac8647125adc8755b4c90", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/cross_line.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/crossline/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/crossline/main.js", + "native_license": "MIT" + }, + { + "name": "geocent", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "fe2a14b53f47678ef59e6a6642e49af5a9faf20ec278a82c01076558c299f055", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/geocent.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/geocent.py", + "source_sha256": "9b46edcf9a1dcaa8fa888087881ec79fe92ab090853e1959866eb3463dda90ac", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/geocent.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/geocent/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/geocent/main.js", + "native_license": "MIT" + }, + { + "name": "skiing", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "fe085bdc5d4a20aa9fc119fb10dc5c2f73ec1ba51f9d6cb8f752b274ffb5231f", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/skiing.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/skiing.py", + "source_sha256": "47ad6779d1f89526e3642868a5be8db3735c6a6fd2657459b634fc000ccfb63a", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/skiing.md", + "historical_source": "The slalom/downhill modes, Game 4's 50 gates, fixed and generated courses, controls, ski angles,\nturn-dependent speed, gates, five-second missed-gate penalty, trees and moguls, recovery after\nfalls, timer, reset button, and racing-line strategy follow Activision's Atari 2600 *Skiing*\nmanual by Bob Whitehead, archived by AtariAge." + }, + { + "name": "monkey_t", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "17197c061a90a68d48b283c83b3b72949a2c188e9e566f6b0d97c0a26fa58aa0", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/monkey_t.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/monkey_t.py", + "source_sha256": "02e19b33738994907e7bb53ce73560a8668ee5ee56248cd0bdd874087b733bab", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/monkey_t.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameMonkeyT.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameMonkeyT.c", + "native_license": "MIT" + }, + { + "name": "zip_fall", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "94cd7f26b766157206ad50cbdc2deda27912671cfd62d30042320d80baf11d6a", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/zip_fall.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/zip_fall.py", + "source_sha256": "e6c793918e5157c68d923dc73b7e116655f75abfdadd96f0a3b1c44da5173b33", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/zip_fall.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameZipFall.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameZipFall.c", + "native_license": "MIT" + }, + { + "name": "hoard_spout", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "09d3ee1f34f31a355db7f16bdaaa4517de6a1dfec49af39c057157c9b5629050", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/hoard_spout.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/hoard_spout.py", + "source_sha256": "0ff518d81a2d76616e0ea91757b14ba7160a19c1b7e1a5b09ea57b15ac63fbd2", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/hoard_spout.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameHoardSpout.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameHoardSpout.c", + "native_license": "MIT" + }, + { + "name": "twin_jumpers", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "01d56f0511ff54cf4a84bdf14dd0cb9f413d341be800ba09bc6ba2e6c1121f86", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/twin_jumpers.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/twin_jumpers.py", + "source_sha256": "20801c80edca50f5502f5fa2fe67bdecacbdbd5de39763db6d0a0e0d220b6bb9", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/twin_jumpers.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameTwinJumpers.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameTwinJumpers.c", + "native_license": "MIT" + }, + { + "name": "block_stacker", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "1099a1a657d3b287b40eec51635cec7c9a2c61de57a1f2f36c047c28264e0372", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/block_stacker.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/block_stacker.py", + "source_sha256": "c5b0795d8844b70e6e7332cd2b880b7dad99b1a22aeebc5713eac9e020cfbdf2", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/block_stacker.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBlockStacker.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameBlockStacker.c", + "native_license": "MIT" + }, + { + "name": "phoenix", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "56f60d4e3d858ecfbab41a8bd93a2a661525ba1db34daa9e8f83a7412a6b2947", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/phoenix.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/phoenix.py", + "source_sha256": "b4c0ad6c6914add983f7d6824f59fda8733ae5b4698b776921b0170ffb4016dc", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/phoenix.md", + "historical_source": "The four bird flocks and mothership cycle, five lives, controls, one-shot rule, force-field timing,\nsmall-bird swoop values, large-bird wing regeneration and proximity values, layered rotating hull,\nand rising mothership award follow Atari's Atari 2600 *Phoenix* manual archived by AtariAge." + }, + { + "name": "graveler", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "2ecc35d522c98476935c0143130c1878dbbf3a77b1720f7cbe9554c49b0e1c98", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/graveler.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/graveler.py", + "source_sha256": "f1ef0d47aece81bb0197ac8ded77bc92d5851767e9bd42c750008f5e533620da", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/graveler.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/graveler/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/graveler/main.js", + "native_license": "MIT" + }, + { + "name": "c_nodes", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "7629285183d6449a7d01c09d42dc7397ab366d3f6dd749ae216ec7f09c8f6e1a", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/c_nodes.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/c_nodes.py", + "source_sha256": "f08aebd0f15c551c2b4fe891c1aea86bf8c3b5babad500a7057fa19c952cad9d", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/c_nodes.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/cnodes/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/cnodes/main.js", + "native_license": "MIT" + }, + { + "name": "teeter", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "1451fd1c26086d4215d970a888339544e0672b6574c0bd4e36c1835b3bb47284", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/teeter.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/teeter.py", + "source_sha256": "e80583a363f3a098bf4ab76fc32291078625f47b431682adacb67e423f09d276", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/teeter.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/teeter/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/teeter/main.js", + "native_license": "MIT" + }, + { + "name": "b_math", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "46775733bd89039da784ce6393f82560ef8062686360d2ffdfd1aea29349628b", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/b_math.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/b_math.py", + "source_sha256": "35c955d6a3ba7dbbaa56a1f997094529fefc4975555bacb45fc53fe39b163356", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/b_math.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBMath.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameBMath.c", + "native_license": "MIT" + }, + { + "name": "timber_test", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "2031c51e9a49c21c0f9aaa58cf87fa157b84134f49d278e6516cc5b2a84536c0", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/timber_test.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/timber_test.py", + "source_sha256": "c60350d451ac8c6a87d94d9ac20826e22c21b1c68051e8af8e6b92092804b12d", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/timber_test.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameTimberTest.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameTimberTest.c", + "native_license": "MIT" + }, + { + "name": "rb_drive", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "57cbe2e8051836316553fceb65ed8e3385e8e232fa54913e9e00c6a9abb7b11b", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/rb_drive.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/rb_drive.py", + "source_sha256": "dff71ae002044a7adc93e8bc3fd176e37e06fbb74ee9f4638c7439ab63c86444", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/rb_drive.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameRbDrive.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameRbDrive.c", + "native_license": "MIT" + }, + { + "name": "montezumas_revenge", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "ec29168cdde79b1b8332a1091285ad70c9d5cdbcdba559c4192e5a90119d6f7c", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/montezumas_revenge.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/montezumas_revenge.py", + "source_sha256": "0018fbf0391415433d741a02f6636c4d4a929e082ad6e15360068eab540c9939", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/montezumas_revenge.md", + "historical_source": "The objective, three difficulty levels, five starting Panama Joes, inventory, tools, rewards,\ncreatures, room fixtures, deaths, extra-life rule, and point values follow Parker Brothers'\nAtari 2600 *Montezuma's Revenge* manual archived in HTML by AtariAge and as a scanned manual by\nRetroGames.cz." + }, + { + "name": "kung_fu_master", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "663007a22805ab346d5b437720a2ab2a23b85bfe030184468f95384e2d40bd08", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/kung_fu_master.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/kung_fu_master.py", + "source_sha256": "0d09d83d0b3b80ae5c77217d6c0e4010f7818eb4142f4f2e2d18fd686de17f7a", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/kung_fu_master.md", + "historical_source": "The five floors and bosses, faster restart, movement and stances, punch/kick distinctions,\nhenchman grabs, knife heights, midgets, dragon balls, baskets/snakes, moths, energy and timer,\nfloor bonuses, enemy and boss values, three lives, and 75,000-point extra life follow Activision's\nAtari 2600 *Kung-Fu Master* manual archived by AtariAge." + }, + { + "name": "blaze_thrust", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "8c30dbc3bc2f945580e690ba297f97449c569143cb357395afbb862140972275", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/blaze_thrust.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/blaze_thrust.py", + "source_sha256": "68378d0df0506963c0fa9407d22c22f3e4beb8618ac48f22ba1743d51db33db0", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/blaze_thrust.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBlazeThrust.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameBlazeThrust.c", + "native_license": "MIT" + }, + { + "name": "catching_wheel", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "2d61043d5cb732d0fc7f322dcb37fab9d61f3682d8732c96e9bacea76ea20015", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/catching_wheel.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/catching_wheel.py", + "source_sha256": "693da4b57887798b146b319f10e24814cc4367371094075ac9e77c4b89dfe342", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/catching_wheel.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameCatchingWheel.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameCatchingWheel.c", + "native_license": "MIT" + }, + { + "name": "d_missile", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "877364e615a1947fe3454a0317fcb299d1fb82f947863bdecf5b98eab1a45f62", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/d_missile.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/d_missile.py", + "source_sha256": "74b78a15db4facb5e291bf44a6ccc79be48622f00954ac5955944714eb66b67d", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/d_missile.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/dmissile/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/dmissile/main.js", + "native_license": "MIT" + }, + { + "name": "p_fit", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "e734ca6089d90dc1c74d0445d64962282efb30809df2312fe6dd56c5a4a42aac", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/p_fit.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/p_fit.py", + "source_sha256": "a12bb3751a20194c1c9f98c9102cd3cb88c6a651f79860e2634bbd55380cf3ae", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/p_fit.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/pfit/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/pfit/main.js", + "native_license": "MIT" + }, + { + "name": "doshin", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "0d38525661777751928c56a958a393f5bf8eb0e2f51258f3a4cff12ac499f93c", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/doshin.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/doshin.py", + "source_sha256": "9fe7e1a6a5252b12f5d9b822d063e6b0bb79c5b20f828caf9971fbecb4e9c1d7", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/doshin.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/doshin/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/doshin/main.js", + "native_license": "MIT" + }, + { + "name": "holes", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "18846ae8d02356320e645f8d72b25cd2429ea9cf090ac04519081a549189a15a", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/holes.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/holes.py", + "source_sha256": "d22c273c32f3a008b519e1d5164b94fa8449b977f15f1da572676b022946a0fd", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/holes.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/holes/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/holes/main.js", + "native_license": "MIT" + }, + { + "name": "turbulent", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "ca8053d469dc3e68993e7a3d73753578bcbedacff4dfb51a703833b8e1dded9a", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/turbulent.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/turbulent.py", + "source_sha256": "39fc7bb0f566d66804823dadb8ae728dde77a517cec09e30557cd83fa55c1acd", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/turbulent.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/turbulent/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/turbulent/main.js", + "native_license": "MIT" + }, + { + "name": "reflector", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "dd140a32f1dc20eacd3399d78413a272494df0485371eaeccfbf22caf72d604b", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/reflector.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/reflector.py", + "source_sha256": "de3a9737462bc0eb4a1e855b20622915e6ea72dadd7816230c03493b5fce1e15", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/reflector.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/reflector/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/reflector/main.js", + "native_license": "MIT" + }, + { + "name": "grenadier", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "4c08496cb330b7a80f9e47bf60f7f1c67a66ee620ba98a14e951d14708302669", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/grenadier.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/grenadier.py", + "source_sha256": "e45371a3165f4944ec14d6e1c6f21b237c91b256849e27b9c80bce68faf69072", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/grenadier.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/grenadier/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/grenadier/main.js", + "native_license": "MIT" + }, + { + "name": "assault", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "214d64558c38fd80452fa34627c74bcf5857b7d12e3be367aca04d3aeff86f71", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/assault.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/assault.py", + "source_sha256": "1f715365bd86d71c93d944f51e712a384c817f2d790b9008c9f251cc07bdd67f", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/assault.md", + "historical_source": "The mechanics mapping follows Bomb/Onbase's Atari 2600 instruction manual for *Assault*." + }, + { + "name": "kelp_climber", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "a1ac4fbe2c906cb1096ce597fad2931d93c5983ff9c84da98ed08a0eb81a98cd", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/kelp_climber.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/kelp_climber.py", + "source_sha256": "622ba8a9f396ce3cbba44cb6f91576031acce5419bd27a38be7fce2a7818a108", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/kelp_climber.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameKelpClimber.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameKelpClimber.c", + "native_license": "MIT" + }, + { + "name": "pileup", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "59dac0126e1bec312c8ed83467c3afc3cf5d71bfd1475380e64ea19a2a2e68bd", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pileup.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/pileup.py", + "source_sha256": "0b963b71ad5701886f9ce945fe67b748c6fa211aa44b000f30f98236a2ddbda1", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/pileup.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/pileup/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/pileup/main.js", + "native_license": "MIT" + }, + { + "name": "zoom_io", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "c07d2036eef7b9c05663ab2311b5177a67e5312b534664287f6ac5ec310610b9", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/zoom_io.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/zoom_io.py", + "source_sha256": "fce181b156d47ea8b63d1c239c1a091cd8dfa5b8472fee100aeae487570ba32d", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/zoom_io.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/zoomio/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/zoomio/main.js", + "native_license": "MIT" + }, + { + "name": "balloon", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "5f6f0ca8d5666e3467ba028b3735fe210cdd5c9bb64695a698846115d46e9319", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/balloon.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/balloon.py", + "source_sha256": "95da133aa430c2e4f59742242ef3d77fce2dff7b468dcdebc71578f21e136772", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/balloon.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBalloon.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameBalloon.c", + "native_license": "MIT" + }, + { + "name": "zartan", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "301cb6e2cb7b6f3b316f8194d168a5262c2533f0d3a516c9e9947f8e5f366c01", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/zartan.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/zartan.py", + "source_sha256": "15c587b50dd9a740a9776e9ef3380d21a000f9003162c57fa5f69c35fd2e601f", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/zartan.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/zartan/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/zartan/main.js", + "native_license": "MIT" + }, + { + "name": "foot_laser", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "56c36d090740bcd2321f9786e4bfc6c053d75fc083d6946b1815dda95d028397", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/foot_laser.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/foot_laser.py", + "source_sha256": "c03c8cc8011efb2a3cdaedd232e4284d618b395296d963427143e5f6d70e57f3", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/foot_laser.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameFootLaser.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameFootLaser.c", + "native_license": "MIT" + }, + { + "name": "snaky", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "aa11775e9deacb61125f3cb7654042249efee4a4ce53233d738a3f9b95213b82", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/snaky.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/snaky.py", + "source_sha256": "709eeb38a3d9b9debedc87cd5d9a60730fbe8f5c5dde08ba4aae72af38a06112", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/snaky.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/snaky/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/snaky/main.js", + "native_license": "MIT" + }, + { + "name": "froooog", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "36bfb8729374b9984f81857f226a335cbb88c400b0016b864811d5695016cdf6", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/froooog.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/froooog.py", + "source_sha256": "ba3c910d87dcf1ebbcfbb8d6046f02ba42964582f08301cfe84034472d04fecb", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/froooog.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameFroooog.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameFroooog.c", + "native_license": "MIT" + }, + { + "name": "trojan_defense", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "6302d1a8941289fd29fa293632a07a238a553e2ccfbd44f23c58ae3985554692", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/trojan_defense.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/trojan_defense.py", + "source_sha256": "6985a44d36ad33ce765511defbda516718d880a7656c16a81463c8cf775d6f25", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/trojan_defense.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameTrojanDefense.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameTrojanDefense.c", + "native_license": "MIT" + }, + { + "name": "balance", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "4103a62b5394d8a30ec71d054fb56e3c22c1eeaa9ffbe36163a05e2e2153c2c6", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/balance.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/balance.py", + "source_sha256": "e507fa0581b739a327a55ee433adab6c17d56d65dd704403e569203c60d68445", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/balance.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBalance.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameBalance.c", + "native_license": "MIT" + }, + { + "name": "video_pinball", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "016de19fb548d54a3557cf781d60da22c0cc731c191093df563579a8a4988441", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/video_pinball.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/video_pinball.py", + "source_sha256": "7d51a30555c2b079b761a14f9be3172f88c53f7dce8e223d47ab4c0099c9c51e", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/video_pinball.md", + "historical_source": "The object, three balls, extra-ball rule, flippers, plunger, nudge/tilt, all devices and exact\nscores, multiplier, 4,000-point left-rollover limit, four-second special, one-extra-ball limit,\ngame-one bumper accumulation, and drain bonus follow Atari's 1981 *Video Pinball* manual:\nhttps://www.digitpress.com/library/manuals/atari2600/video_pinball.pdf." + }, + { + "name": "in_tow", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "09a59f216bd3d36cfb54620712ca0e64dcd3df9fa147a392bfead8abcc42fad4", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/in_tow.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/in_tow.py", + "source_sha256": "6d4d478b95c38d8efe3aa1504cde9a838f03a6c2a57d482a8439a4cef393a6f7", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/in_tow.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameInTow.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameInTow.c", + "native_license": "MIT" + }, + { + "name": "divarr", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "0fe702c902bbbcf9acfff145412f19b55f3d890ba5ad4733b8f23c191c6c4d41", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/divarr.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/divarr.py", + "source_sha256": "4c040e07a2ab1fca3b781b4c381a640f1c8397c816f99eaa0679187481caf20b", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/divarr.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/divarr/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/divarr/main.js", + "native_license": "MIT" + }, + { + "name": "hero", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "e8b291b04c83665a625ac0534ba3b1f99adf4a08793ffb5538ea42ffeb7f295e", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/hero.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/hero.py", + "source_sha256": "ce2dcc8a6cc15b72e730a341e0ea142a5e9773c1c8920844c6fb7a74d106c833", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/hero.md", + "historical_source": "The prop-pack controls, gravity descent, six dynamite sticks, microlaser wall cutting, raft,\nlantern, lava and critter hazards, power loss, 20 rescue levels, four lives, extra-life threshold,\nand scoring follow Activision's Atari 2600 *H.E.R.O.* manual archived by AtariAge." + }, + { + "name": "kite", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "f4c12e36336ca11cec0a09e97a0335b8dc953f91eaadde40e1ae9ed60079f778", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/kite.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/kite.py", + "source_sha256": "cf8d8cdd62f2154226de119efdcdbc90c8dd354945779102f9521463812de3e5", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/kite.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/kite/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/kite/main.js", + "native_license": "MIT" + }, + { + "name": "inf_range", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "6d289021bf3788cf7756bd587082da702fc3a1d46d52dfec268e8ad50ef11976", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/inf_range.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/inf_range.py", + "source_sha256": "5847ac684c20fd4b8d37c75ac0be0d37d62dcbd6be4e4c5b73d7378246bd1883", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/inf_range.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/infrange/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/infrange/main.js", + "native_license": "MIT" + }, + { + "name": "counter_b", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "babd52807c0624c6deb96af70f209211a9f28782b1d478389eb345b6603e7b40", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/counter_b.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/counter_b.py", + "source_sha256": "4049801cbd48289338e8959ad71b5af8e4121e92924b1a7c4a549610248482aa", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/counter_b.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/counterb/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/counterb/main.js", + "native_license": "MIT" + }, + { + "name": "revolve_a", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "1430f546c48a19cbc880ef9683849c6622c171bd5a286a5b49922a6c8b8821ba", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/revolve_a.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/revolve_a.py", + "source_sha256": "7ca10d21afec28eb027169cc61d3a191867131601319b7696982ca4cdfe51101", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/revolve_a.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/revolvea/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/revolvea/main.js", + "native_license": "MIT" + }, + { + "name": "square_bar", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "343064886196a1caa0d12cce7e3b5918d3f2a1fbde8f69c2311bcbaa2f030008", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/square_bar.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/square_bar.py", + "source_sha256": "3fd70a6c2b969161424ce622b01852b2deeed3d7b3bad4728a6c5aa45d3dee2f", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/square_bar.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/squarebar/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/squarebar/main.js", + "native_license": "MIT" + }, + { + "name": "gravity_bubble", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "a0eb97b4d121a131867c42f0e77a2235c032e4089658df43e260395919ed2519", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/gravity_bubble.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/gravity_bubble.py", + "source_sha256": "a383bb282349807d26be0fa542e5769110e3d813c6f234b9ee21e15126320df5", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/gravity_bubble.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameGravityBubble.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameGravityBubble.c", + "native_license": "MIT" + }, + { + "name": "ball_tour", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "6c5cec9391a5b9e2f7e8ea0bffd51e62b1e24888aa72a142ac1dcd617b463c9f", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/ball_tour.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/ball_tour.py", + "source_sha256": "e710d079b10405901e252d07f3897a0314cca8a087fdfdfaba7e5f3403c234a8", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/ball_tour.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBallTour.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameBallTour.c", + "native_license": "MIT" + }, + { + "name": "feeding_frenzy", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "67319f79848f09c3814d3244fcbf7cdbc982a2e5757aea017e085b6a4a511a89", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/feeding_frenzy.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/feeding_frenzy.py", + "source_sha256": "f3f85b7cd64f641853eb252fbdee613ce78bbd3ef99813f56bf616a9d69826be", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/feeding_frenzy.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameFeedingFrenzy.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameFeedingFrenzy.c", + "native_license": "MIT" + }, + { + "name": "kangaroo", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "146be7c520e12488a084af6f859a8551f6d51f2dff2e2670c2d0cfba1131bd99", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/kangaroo.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/kangaroo.py", + "source_sha256": "5b869085ee8fd317066217cf98863db70a34ca18e2dd13481e1c972bb988e1b3", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/kangaroo.md", + "historical_source": "The three-screen rounds, three starting lives, ladders, broken-log super leaps, jump and duck\nresponses, punching, four monkeys, thrown and falling apple values, three fruit, three bell rings,\nfruit value ladder, 2,000-point timer, 20,000-point bonus lives, and rescue rules follow Atari's\nAtari 2600 *Kangaroo* manual archived by AtariAge." + }, + { + "name": "tilted", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "c1003375ddb26014ce9f847a0fdeea7f3fccbbed2ea43d9a60321e765d97ecee", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tilted.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/tilted.py", + "source_sha256": "da4b2de07b1da97da5cb9e0d7897be18161f2a149b582ed4b507ba63ba87b86a", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/tilted.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/tilted/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/tilted/main.js", + "native_license": "MIT" + }, + { + "name": "ant_lion", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "a011a524390289fc62ae0c17b2e23364159bc01c6b533fcaf75ddaaa5e0ac721", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/ant_lion.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/ant_lion.py", + "source_sha256": "25716da19645548402ac16660c2a9d958eaac8c286668f410e9143c9a4ff733c", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/ant_lion.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameAntLion.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameAntLion.c", + "native_license": "MIT" + }, + { + "name": "tr_beam", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "5f10f9864cde4a5a8d27cfb107e305ed630a0f15d4cc7ec47f591ef13e0bdd14", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tr_beam.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/tr_beam.py", + "source_sha256": "7fd080c83f0c613154e9b26980cea1fa412c6bb5de1e788196e4e3fd319813ee", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/tr_beam.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/trbeam/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/trbeam/main.js", + "native_license": "MIT" + }, + { + "name": "golfme", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "28ba976aed3edc9858e02a4f0d273050115eac1f5af7c71e51df3c47167d6ac0", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/golfme.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/golfme.py", + "source_sha256": "9166006acfee764cca3bf696f5b78452bb1d1f1329bda122b5f77441966ec55b", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/golfme.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/golfme/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/golfme/main.js", + "native_license": "MIT" + }, + { + "name": "hexmin", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "04b502ea8131b7f85390b426d51e3aa3af4c775e04188ab9fcf9953595bd0cbe", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/hexmin.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/hexmin.py", + "source_sha256": "890c41fce6deaaca557eb8535daf6394773b793fb8e599d85a27828c86605277", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/hexmin.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameHexmin.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameHexmin.c", + "native_license": "MIT" + }, + { + "name": "catapult", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "e7a2ef61d5f0b5a1df709768a0a72179d2ef203bd04f42dc314e784e3f601607", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/catapult.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/catapult.py", + "source_sha256": "974f80efe17533f6ba251ae6faa024c3a1d3562825ab4f1bed66bd3f03687c4f", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/catapult.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/catapult/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/catapult/main.js", + "native_license": "MIT" + }, + { + "name": "t_lanes", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "ae7c85444c8e6c4b4dd640d8234bae52e6be8d5fc8740f5f82f0f837dff60ee9", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/t_lanes.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/t_lanes.py", + "source_sha256": "2664f0ff9ae1805da972ab2bf1faacc332e2d283731b36e3fa50b01a47da6284", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/t_lanes.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/tlanes/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/tlanes/main.js", + "native_license": "MIT" + }, + { + "name": "invincible_man", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "16e13dc555d8948312ece4cf2d913eb364a99cffe775aadc1fa9ae861e67a0f8", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/invincible_man.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/invincible_man.py", + "source_sha256": "7a5e2fd96d9c3133ac487bfb02d982558a30fed6e5dadf5177f2741a44981714", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/invincible_man.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameInvincibleMan.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameInvincibleMan.c", + "native_license": "MIT" + }, + { + "name": "rotating_tunnel", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "cbe33ce94c97721ce67cf8fb92c7a9d618c2452474bbb2145bdcd4ee11d17ba7", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/rotating_tunnel.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/rotating_tunnel.py", + "source_sha256": "5787eed8c39f92e0fbc45864996361c4e5d5f979644721b72621ad7764e3f64a", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/rotating_tunnel.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameRotatingTunnel.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameRotatingTunnel.c", + "native_license": "MIT" + }, + { + "name": "dark_sort", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "6b6c31d336740a004a6819ce9c0115ca7ccbff9244b5298c41e4ca1c51977dc3", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/dark_sort.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/dark_sort.py", + "source_sha256": "c3d6803e853bf22b3bbc046ecc3e544e90d3edbef82972dc8294b367a28e91a1", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/dark_sort.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameDarkSort.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameDarkSort.c", + "native_license": "MIT" + }, + { + "name": "survivor", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "4dc591ad04e9ad57e285234d19330732d34000533773aa2794cc909783952183", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/survivor.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/survivor.py", + "source_sha256": "f186fb5c81a15abc421977ed5518fc3f821ec9345f5c96d62505a345ea471e73", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/survivor.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameSurvivor.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameSurvivor.c", + "native_license": "MIT" + }, + { + "name": "star_gunner", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "a8beefe3f4b6e3740b2e40475b9551d6a3d0dbb552dc254966739697b3d3c6b3", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/star_gunner.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/star_gunner.py", + "source_sha256": "aceb30a61010951201db9bb4d681cf60ded69719587e339ac39691402912b5eb", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/star_gunner.md", + "historical_source": "The controls and difficulty behavior, single-shot trigger, alien disintegration/rematerialization,\nthree waves, counts and concurrency, endless level escalation, five ships, three loss causes,\n10,000-point reinforcements, scoring, bonuses, Bobo bombs, and game variations follow Telesys's\nAtari 2600 *Star Gunner* manual." + }, + { + "name": "sky_floor", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "7f5f9b5113d70fdd85d54f2d8a822074d882dc33c6f54f5a0f17de79c3ae6113", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/sky_floor.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/sky_floor.py", + "source_sha256": "e6871d57552e208472e21e11ad879a6919439a68dd19ec7420f6af738cfc2469", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/sky_floor.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/skyfloor/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/skyfloor/main.js", + "native_license": "MIT" + }, + { + "name": "yars_revenge", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "4cdba8f343d5f5a30ad9d888381993109143bcd80d31cf0cc00e1cbb08f9b47c", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/yars_revenge.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/yars_revenge.py", + "source_sha256": "edf2f56d8dc7390b37c01a2f9c5f0da7b208246b9f2293c936fe0d94d6798831", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/yars_revenge.md", + "historical_source": "The objective, shield methods, cannon charging and self-danger, Qotile weapons, Neutral Zone,\nfour lives, vertical wrapping, shared fire control, normal-game variation, and exact scoring follow\nAtari's 1982 *Yars' Revenge* manual as transcribed by AtariAge:\nhttps://atariage.com/manual_html_page.php?SoftwareLabelID=603." + }, + { + "name": "screen", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "5174e7ba0692a9c3f05615d8e4d02f34e82004d92ba31b5120da8b2035f5fc3a", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/screen.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/screen.py", + "source_sha256": "b6424fb7d25b7d71f0ac055640cfd7453762ea3011b5b95681206d12f4cd57ac", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/screen.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/screen/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/screen/main.js", + "native_license": "MIT" + }, + { + "name": "pin_climb", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "8fd8db97e96856a464d2a8269cbe1784e535bc83dab9b86979c2828ac0a987d2", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pin_climb.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/pin_climb.py", + "source_sha256": "40597d99cdf0fa05cf9a2d4f6347d1b181dfd46658ef4fcdb38d6f101f984922", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/pin_climb.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePinClimb.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gamePinClimb.c", + "native_license": "MIT" + }, + { + "name": "bore_comet", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "6542677015897ecd94ffbbb00449e42175239844becc6418ba18ae59b3dfe341", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/bore_comet.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/bore_comet.py", + "source_sha256": "cc8f88cb289242ba54fb496292858b9b7368b2532628525819fb6a1eb426b682", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/bore_comet.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBoreComet.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameBoreComet.c", + "native_license": "MIT" + }, + { + "name": "levitation", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "c6dae9d39eacce74c9b16c90c4fe0a7b2bda45027bb3996697fe2ddf762105ba", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/levitation.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/levitation.py", + "source_sha256": "9f5a11aae270317703f6ae634337456363b53cf90228e7bbf6d5145e5e7a0ee0", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/levitation.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameLevitation.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameLevitation.c", + "native_license": "MIT" + }, + { + "name": "geoerase", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "1500c5b95f537b75cb71f494b6738ecb5d036c38344548cc838264dfc01e78ae", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/geoerase.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/geoerase.py", + "source_sha256": "c02e2cce7fd90877c539bf85c9aeeb2273fab2a9e73c56ec7fa740a867efddf7", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/geoerase.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameGeoerase.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameGeoerase.c", + "native_license": "MIT" + }, + { + "name": "magnetic_pendulum", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "bd417d4e261a68134258a3af513c153a6c36c27704e99beb9102c2a200e2fc5b", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/magnetic_pendulum.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/magnetic_pendulum.py", + "source_sha256": "e5ec06ca3b5b1b062921e1dc5d6cf421078751f7cf8e9b45714c879971b8c9aa", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/magnetic_pendulum.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameMagneticPendulum.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameMagneticPendulum.c", + "native_license": "MIT" + }, + { + "name": "boarding", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "8be6c7c7eab9ef22e1e39bb3e044829ffa7f93967e09013826067b1fa9dec839", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/boarding.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/boarding.py", + "source_sha256": "c79bc47f9082704c118de452367c5d34d82eee8dc5b92fe0c359fda9b29a1d5f", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/boarding.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/boarding/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/boarding/main.js", + "native_license": "MIT" + }, + { + "name": "pitfall", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "8903b076ded04751b5f990d349ba3f29be0bccf712050b02067d85c5dd8a719b", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pitfall.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/pitfall.py", + "source_sha256": "7c2c2f8a71ec41afbe150fff57c16b55b88d1355376103b0fd8700bda5ebf425", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/pitfall.md", + "historical_source": "The 32 treasures and values, perfect score, 2,000 starting score, three lives, 20-minute limit,\nsurface/tunnel maze, three-screen shortcuts, controls, vines, ladders, hazards, 100-point holes,\nand log deductions follow Activision's Atari 2600 *Pitfall!* manual archived by AtariAge." + }, + { + "name": "fish_grill", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "627333c2da102a2072a6b036bda4c1d24b653bb17b78b4ff55bda2339abce7c0", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/fish_grill.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/fish_grill.py", + "source_sha256": "521647120bc23073a1972c45699ed8bd277493cb3c506db04f61ec2cdcbbf588", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/fish_grill.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameFishGrill.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameFishGrill.c", + "native_license": "MIT" + }, + { + "name": "knight_vs_pawns", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "c15b4b5572d75a6cd0842c1aedb33d47c2a5d9918d6f79d419be35c51221b5b3", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/knight_vs_pawns.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/knight_vs_pawns.py", + "source_sha256": "f6b9158dbafd7a932cc675128f3fa41fbcd257196da2aed0595cacaebf619926", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/knight_vs_pawns.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameKnightVsPawns.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameKnightVsPawns.c", + "native_license": "MIT" + }, + { + "name": "shiny", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "eb44de9e65a6a75431232564a970c9142ce9678eda6a06d28ba4e08f8a950a4c", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/shiny.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/shiny.py", + "source_sha256": "f98c1ad9afaef6c406648ca6c6df0061e09f9615882487315b6add4b8766a4a5", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/shiny.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameShiny.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameShiny.c", + "native_license": "MIT" + }, + { + "name": "wavy_bird", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "9c6737e87cce3e88c26e03fd29bfb9e64f47e1fcbdbaaf9c5cb5e329a3aadef9", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/wavy_bird.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/wavy_bird.py", + "source_sha256": "250e514b0f0680177c665042d238c7d2400daaaca77d74260382357f8924f5fd", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/wavy_bird.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameWavyBird.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameWavyBird.c", + "native_license": "MIT" + }, + { + "name": "descents", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "327853450a8a84783d335063f51996c884520f01165c286d88162d9fe9a1a62f", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/descents.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/descents.py", + "source_sha256": "1303a1fed9905c3e5b7014bf280466143ee578cca6d6aa772ff0e296a733c325", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/descents.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/descents/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/descents/main.js", + "native_license": "MIT" + }, + { + "name": "throw_m", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "34f78eb6090d648ccdd1d4e0c5f43debbcadee1fb6b1958029a67b7228136020", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/throw_m.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/throw_m.py", + "source_sha256": "96ed12ed67dbc3e0682bf9d237d35833147f6288fbb25bc4554ddbe6578527d4", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/throw_m.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/throwm/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/throwm/main.js", + "native_license": "MIT" + }, + { + "name": "wind_power", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "488208d775fa1274507d3de3326ac8389d85b8dac1463f7ef259bd8c30763992", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/wind_power.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/wind_power.py", + "source_sha256": "68dd904d955fb8a68e822eab6f64005910565d9c972d647ae190e2dbe4ddd273", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/wind_power.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameWindPower.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameWindPower.c", + "native_license": "MIT" + }, + { + "name": "tutankham", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "a109b9aa661251fe5061b3c4d8c22d8d7c789ece90924c4d0333f20284de66d8", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tutankham.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/tutankham.py", + "source_sha256": "dbdaecfaa1b8a22b63b8599af8a3d3913a881e9ed14cca41b1881dbc91446dce", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/tutankham.md", + "historical_source": "The objective, joystick and horizontal-fire controls, fire-plus-up flash, three lives and flashes,\nkeys, nests, treasures, passages, ammunition band, exit condition, four chambers, four difficulty\nlevels, scoring table, and ammunition bonus follow Parker Brothers' 1983 Atari 2600 *Tutankham*\nmanual as transcribed by AtariAge: https://atariage.com/manual_html_page.php?SoftwareLabelID=572." + }, + { + "name": "find_a_star", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "d6f186f13377651b678b6865ff0df5ad09be2f6df7ed2fc888453fe3655fb8e6", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/find_a_star.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/find_a_star.py", + "source_sha256": "e3102e68f75c3bbbb91f80227866a2ef32fce61fc5f485a256a4beadea4a22df", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/find_a_star.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/findastar/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/findastar/main.js", + "native_license": "MIT" + }, + { + "name": "defender", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "fbc0a0c9d2851c0b27ce8fc9193529e64e38d67203074f6e7671e995e6eaeb62", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/defender.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/defender.py", + "source_sha256": "41767cc2f7449196963875b6984043accc60d0aa93c8df6a70d839e0def573c1", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/defender.md", + "historical_source": "The alien roles and values, five Humanoids, rescue awards, survivor bonus, Mutant takeover and\nfifth-wave rebirth, contextual fire controls, smart bombs, safe Atari hyperspace, self-sacrifice,\nand 10,000-point bonuses follow Atari's *Defender* instruction manual archived by AtariAge." + }, + { + "name": "floater", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "8a6f2b28db1394eae234c6bf4ea3fb377efa22f644ed81688539688b56c6ad6d", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/floater.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/floater.py", + "source_sha256": "7dc313308c49fb7eb3a9b53882b4cb609948eb588184761ba0e45404eedd446e", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/floater.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/floater/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/floater/main.js", + "native_license": "MIT" + }, + { + "name": "color_roll", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "885c8de3840be7299c2e2bbb26f6bb2f01139aeda946cccca1a16ef95be66979", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/color_roll.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/color_roll.py", + "source_sha256": "447e85e019d472129797aaf4b49fc7254e6ac338762520aa9f1371ac26778e21", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/color_roll.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameColorRoll.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameColorRoll.c", + "native_license": "MIT" + }, + { + "name": "aerial_bar", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "c6ae933cc49db7fa3203a28e62b88f556b8d1f225e3960550371ae096e40c2f9", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/aerial_bar.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/aerial_bar.py", + "source_sha256": "846a56de12f853fe5d1d9a561feac4dcb3a8840109e2cbe166068f25380ddde0", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/aerial_bar.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameAeralBar.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameAeralBar.c", + "native_license": "MIT" + }, + { + "name": "pillars_3d", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "14811e8ee805c13110f427af432702015bfc76fd8cf71f4c5589603c428e5174", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pillars_3d.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/pillars_3d.py", + "source_sha256": "e59788d36fd70ac1ade91ea42532f4f4db1ff74d70d533f3d76cf7b548fce976", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/pillars_3d.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePillars3d.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gamePillars3d.c", + "native_license": "MIT" + }, + { + "name": "periscope_ping", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "6486e4f1eab1d29ea05526c82777d0da8eb880ad683815a5c08e14502b6aba0e", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/periscope_ping.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/periscope_ping.py", + "source_sha256": "29f6c6ce632beefd56a3a56cb3786e7aae8260f424fe88b8de44f7b5c1c0bdd8", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/periscope_ping.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePeriscopePing.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gamePeriscopePing.c", + "native_license": "MIT" + }, + { + "name": "inkinh", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "5537b506a29d57afcae8624b197d3e9c9f162bc55b391a669ab000f84288be68", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/inkinh.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/inkinh.py", + "source_sha256": "b26a27374df7b22709a3aac9250106c9fc56ea57b2fd2d32a3d9c6a7c5eebf0c", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/inkinh.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameInkinh.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameInkinh.c", + "native_license": "MIT" + }, + { + "name": "smily_angry", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "0afda1edabb151418ff8ffcad2b21fe138dbc72a82b8465083817c19298ead61", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/smily_angry.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/smily_angry.py", + "source_sha256": "019a0d5461517b906efcf0fa18ce0f921285edd7bc80362dcd1188f87dfb754d", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/smily_angry.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/smilyangry/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/smilyangry/main.js", + "native_license": "MIT" + }, + { + "name": "m_rider", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "6002a01d6bb40ca10094720caed89fedaad5e73dc9576d150e4a0c2717a86c60", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/m_rider.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/m_rider.py", + "source_sha256": "ea943a30d7cc03b9af9bfb5391fa20fafb05180b0acfe55eda145e2bb00cf145", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/m_rider.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/mrider/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/mrider/main.js", + "native_license": "MIT" + }, + { + "name": "light_dark", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "8db7e03abd60bb68ced0441238defbd8ce8d69a42d3ec3cd8bc07a86996d56e3", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/light_dark.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/light_dark.py", + "source_sha256": "71fc3517747e804548c6c0e9481cbf75b22a3e0400b13535c6abd878c9e8c47f", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/light_dark.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/lightdark/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/lightdark/main.js", + "native_license": "MIT" + }, + { + "name": "phaserun", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "a54483c6e85f62815aef53b592600118cd31415721c2e867831c355219808d91", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/phaserun.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/phaserun.py", + "source_sha256": "dae6c2585276370a04aaf3fffc8b973d85d856632cf5c23e87e5c53c771d655e", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/phaserun.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePhaserun.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gamePhaserun.c", + "native_license": "MIT" + }, + { + "name": "frostbite", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "384ce9a3a217bc988d651f9530646e8c589fe7f4d14030492d08184b4039128d", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/frostbite.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/frostbite.py", + "source_sha256": "6ea1b8385bbb3e1fdd22314613c483e0611853a69ec96930bbe7ae09215a833f", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/frostbite.md", + "historical_source": "The four-row color cycle, igloo construction, reversal cost, animal and bear hazards, fish value,\n45-degree countdown, four starting lives, 5,000-point reserves, level score table, entry award,\nand temperature formula follow Activision's Atari 2600 *Frostbite* manual archived by AtariAge." + }, + { + "name": "circle_w", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "a85d9f198214cfdae55964af769e02682e3db739a4e1b4116d6979f749acf80e", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/circle_w.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/circle_w.py", + "source_sha256": "e551e4018d3bbc2dd83c9574ab6666714a439427964223211ca05dde42ab96a8", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/circle_w.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/circlew/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/circlew/main.js", + "native_license": "MIT" + }, + { + "name": "james_bond", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "694ef54d3fe1f68a9adf9d7e6b7be084d200d8e0028c134a72c2998f1f0953bb", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/james_bond.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/james_bond.py", + "source_sha256": "cc6688ee1747097cd27a70c69512558bdf840f821a121cfdc5a37beb72364cbf", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/james_bond.md", + "historical_source": "The three missions and objectives, multipurpose craft, jump/dive return, alternating weapons,\ndiamond illumination, oil-rig landing, three spinning satellites, transforming shuttles and\nrockets, submarines, torpedoes, laboratory bombing, timed capsule rescue, target values, 5,000\nmission award, retained craft, and game-over rules follow Parker Brothers' Atari 2600\n*James Bond 007* manual archived by AtariAge." + }, + { + "name": "orbit_man", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "c31abadee84d30d6d26e2e89ab54263cf7902d89c968999e01be21938a963504", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/orbit_man.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/orbit_man.py", + "source_sha256": "388fe75f97d9e6eddfb8d4f633d23625dcdc170986335aca6b98a98a20c63867", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/orbit_man.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/orbitman/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/orbitman/main.js", + "native_license": "MIT" + }, + { + "name": "balls_bombs", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "6ba65001bad825c28e3b6d8477870539567781c3ab458be1ace7a8cd87fdbbbb", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/balls_bombs.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/balls_bombs.py", + "source_sha256": "2878ba7f93d4767ea95a1abbab89772b6fd148b5b54c93b8d160b9b88314fff6", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/balls_bombs.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBallsBombs.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameBallsBombs.c", + "native_license": "MIT" + }, + { + "name": "paint_ball", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "90c04ee33f19ddd41f66f6c93ed3af932cfecaf0a6a4a6a71034c9d5412f94ed", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/paint_ball.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/paint_ball.py", + "source_sha256": "530ed73ee21650c2bf7dbf6541161cfe05e60171f5dc9682080d3a54c0735fbc", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/paint_ball.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePaintBall.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gamePaintBall.c", + "native_license": "MIT" + }, + { + "name": "r_ring", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "94b041d88b2312541155052de3b0e0c1e71ff65bec93469be8b594c5570fb00f", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/r_ring.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/r_ring.py", + "source_sha256": "8f3cf6206dac2b7009b3f6b8c4868643d5af015830098fb0721c8afaae0da58a", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/r_ring.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/rring/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/rring/main.js", + "native_license": "MIT" + }, + { + "name": "gopher", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "a363e6d765b1edf351d3189756eec60bf3b9331aa49c015faedbed778c26eee5", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/gopher.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/gopher.py", + "source_sha256": "194cbdc952a836a016788df2aa8364bfe88f759e271d58bd0967c99cff517b7c", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/gopher.md", + "historical_source": "The three carrots, tunnel-filling score, surface bonk, carrot theft, accelerating gopher, and\nduck-delivered replacement seed follow the Atari 2600 *Gopher* manual archived by AtariAge." + }, + { + "name": "rope_corral", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "8ca503c9ae2e62573f3f9151c7db9c7cbe738469892ce11a6947f59e94024d26", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/rope_corral.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/rope_corral.py", + "source_sha256": "fd0e441707944803b94f9cad69b636374624f437440b7ea8b982b9b9208a05f0", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/rope_corral.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameRopeCorral.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameRopeCorral.c", + "native_license": "MIT" + }, + { + "name": "grappling_h", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "5e23fee2711b2bf7736135cfda8b98ce2f507eef57328e1e7fa99cd815070ac1", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/grappling_h.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/grappling_h.py", + "source_sha256": "0b2e900bb1f4b3efa5382a0ed814f4c0d6fa025e4aacb66b9daadb0c19096509", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/grappling_h.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameGrapplingH.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameGrapplingH.c", + "native_license": "MIT" + }, + { + "name": "cleaner", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "0c8b028730fc2857c1076ff778bac4fc57dac056763e82b9157c94f02f3d1a9e", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/cleaner.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/cleaner.py", + "source_sha256": "c933bf1a1ae297b8f3b6b5f4cdf0403d7b61e479f36e8a57dec4e41dc9d62f27", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/cleaner.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameCleaner.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameCleaner.c", + "native_license": "MIT" + }, + { + "name": "t_hanoi", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "fcb52e8194f413aad32879a94d107a14bb29550ec166184b83e35fc4ac7f33ef", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/t_hanoi.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/t_hanoi.py", + "source_sha256": "33bd9481009fed84ff675526ff9c286323c9e9473df50603ee1a8eeacc6d0afd", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/t_hanoi.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/thanoi/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/thanoi/main.js", + "native_license": "MIT" + }, + { + "name": "c_tower", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "0bdcd90ff90fd64433882b1850d78ea00114389d237f44201533bdb390ca3a00", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/c_tower.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/c_tower.py", + "source_sha256": "1063012fb0a36e011b4125b690ffac03487985511210911350d16a2af6344927", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/c_tower.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/ctower/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/ctower/main.js", + "native_license": "MIT" + }, + { + "name": "gravity_drift", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "08bd73e9f4d107c3bddb6b49cc95b22b94e14152c68fe60e38b8f55fdd4f6f2a", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/gravity_drift.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/gravity_drift.py", + "source_sha256": "7826a290bf19c6a710718b16a50229973dab86c0d0512a56f69d8b711dd3117a", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/gravity_drift.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameGravityDrift.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameGravityDrift.c", + "native_license": "MIT" + }, + { + "name": "venture", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "c926bbc3eeef20d167f88646546cee1eed2e1e3658ff26537130e265a1e7c017", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/venture.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/venture.py", + "source_sha256": "c1600b4187ab0bb6c57b1012e7f78e2dda4540e86c76a51ee5df6d6ecac7bf5c", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/venture.md", + "historical_source": "The two-scale hall/chamber structure, free room order, treasure lockout, arrow controls,\ninvulnerable Hallmonsters, post-treasure monster scoring, lethal corpses, room timeout, Wall Room,\nfour lives, and deeper halls follow Atari's 2600 *Venture* manual and Coleco guide:\nhttps://atariage.com/manual_html_page.php?SoftwareLabelID=576 and\nhttps://www.ataricompendium.com/archives/manuals/vcs/venture.pdf. The score multipliers are\ncorroborated by contemporary cartridge documentation and the Atari 2600 game guide." + }, + { + "name": "embattled", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "4c42db3dc499dad9bc493d05b2b54f27a61a7420b63da7a1ecbf768f89593951", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/embattled.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/embattled.py", + "source_sha256": "51242b06030e11ddfda436f5030d5b073968b3c3bacf21846a0998e4ecc7ce18", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/embattled.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/embattled/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/embattled/main.js", + "native_license": "MIT" + }, + { + "name": "tappump", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "7b12c775e02ac854f942e350d295c2197f6579372bdd12151803d921568f74e5", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tappump.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/tappump.py", + "source_sha256": "76dae936e1cce11b78d0427cb7b51e188e87597f4b963ceae2fff8ed64205823", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/tappump.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/tappump/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/tappump/main.js", + "native_license": "MIT" + }, + { + "name": "turbo_tunnel", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "874fd5db85df55b3f91dcc8e70b28e2c837728f9e95ba4e325702a99d7515f53", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/turbo_tunnel.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/turbo_tunnel.py", + "source_sha256": "63af7705312d511d7fd228b1f27a2a6f9b7fcada96eac3aeb4ce5d3763440317", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/turbo_tunnel.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameTurboTunnel.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameTurboTunnel.c", + "native_license": "MIT" + }, + { + "name": "solaris", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "6679b0e20448252b93ea19464b212b3bc06acae7347a6041ee8e8c4199284f25", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/solaris.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/solaris.py", + "source_sha256": "cc0af9412f766e74f0174b010e5d9709718839b3821ebd91fd470038b48f7667", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/solaris.md", + "historical_source": "The mission, scanner sectors and exits, focus-dependent warp fuel, three fighters, fuel and docking,\nFederation defense timer, Red Zones, controls, targeting computer, Zylon planets, corridors,\nenemy classes and values, 8,000-point bonuses, reinforcements, and terminal conditions follow\nAtari's *Solaris* manual archived by AtariAge." + }, + { + "name": "mole_n", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "ff8a921f1cef27b64a8ff6a3288554ea2980ae045cdea5622317aa8ea32ba120", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/mole_n.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/mole_n.py", + "source_sha256": "e44f25ba928f6910ea3482c27fe520b1e6c5a8212eefa110c36ed80803cea666", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/mole_n.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/molen/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/molen/main.js", + "native_license": "MIT" + }, + { + "name": "bank_heist", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "e7d9dfd66a71c436e07d5eeadd17a914a3a4a5bace94ae05b193e9c489b894fe", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/bank_heist.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/bank_heist.py", + "source_sha256": "52b6abd5e24a0d9c9914fe8e238c73824eb728bd2c4c88a495c0baf9c264ce68", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/bank_heist.md", + "historical_source": "The mechanics, bank values, cop values, and first-level town bonuses follow 20th Century Fox's\nAtari 2600 instruction manual for *Bank Heist*." + }, + { + "name": "zone_b", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "b9226d09a469fae71a828c84a6d6e87a453c46ef3fd9c794592f0cf1a07d6b49", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/zone_b.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/zone_b.py", + "source_sha256": "f923ff3cc7f4704d5d9ea07f425aad0546eb6ee9be9c15735acb827dc185b794", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/zone_b.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/zoneb/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/zoneb/main.js", + "native_license": "MIT" + }, + { + "name": "sunflower_sway", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "a70e5c8f2f063ee97d8f0639f2858d7d7b698c6a9b5251d613e7c6566528bd75", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/sunflower_sway.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/sunflower_sway.py", + "source_sha256": "35bb3971b53e1098f564595c2bdcbc2e9c867f38ea3c2d12cc642dad67f2d231", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/sunflower_sway.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameSunflowerSway.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameSunflowerSway.c", + "native_license": "MIT" + }, + { + "name": "ud_cave", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "cb3bd2780598ea6ae342cc7a77c966a92a273b700e947d45377f50823a17ae72", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/ud_cave.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/ud_cave.py", + "source_sha256": "c821cb2a1a57a8f48d3bc1f27837d90e00bf32a28f1844af02a30c67267c92a7", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/ud_cave.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/udcave/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/udcave/main.js", + "native_license": "MIT" + }, + { + "name": "slalom", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "1d19fdec351997c48710a45353a4d1ece45c778ae598456225cb6d068d42b52b", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/slalom.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/slalom.py", + "source_sha256": "6a3a43eb2038cfdcb7459db85af24b9def4304e942aa7f9458ae91338f6a7df9", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/slalom.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/slalom/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/slalom/main.js", + "native_license": "MIT" + }, + { + "name": "swingby", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "4e7cc862249606e9de36b131811e1980764fd2d9a7cf8944c2e2b9f4e5e6ea79", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/swingby.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/swingby.py", + "source_sha256": "fc09199905aaf8d324adb1d90881ba257aa18d28944e8b2861876ee0623afdfd", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/swingby.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/swingby/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/swingby/main.js", + "native_license": "MIT" + }, + { + "name": "floors5", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "dcb9de3afc4a731aee1d145935f601907232e20e9a4ea0591ff9d5208dab7c46", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/floors5.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/floors5.py", + "source_sha256": "16b986b24ad122dd57ac77e4fba1deefaeea5ff6c9e70b32258ce7de0159f631", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/floors5.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/floors5/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/floors5/main.js", + "native_license": "MIT" + }, + { + "name": "tectonic_tether", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "11bbde944e2a3e8e0bb60b1ba7910b4baef9ea96435bf17da6ba907bb8640099", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tectonic_tether.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/tectonic_tether.py", + "source_sha256": "3b7add00b7a6b38869bce691f2f56f507c2cb057d1076b7aa78fdad6f45102e6", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/tectonic_tether.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameTectonicTether.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameTectonicTether.c", + "native_license": "MIT" + }, + { + "name": "s_lanes", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "fcb1907afbfe988516fa80ea7bb0290752e5315007b4ae03c6df127e2b85ab7d", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/s_lanes.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/s_lanes.py", + "source_sha256": "942bca0aeb01a1e76cc0c35a1c7fc87571f643f17a0e00ea7ef1715c5168eb9e", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/s_lanes.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/slanes/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/slanes/main.js", + "native_license": "MIT" + }, + { + "name": "gravity_well", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "1e58fe9691d7017552fe3c444e55e94fcf87c48552e4f39a7068b28caad06274", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/gravity_well.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/gravity_well.py", + "source_sha256": "fbd293dd2d558def91c3a17d3e96d6f4c5b16c151fff7fa501623b1ff085de0b", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/gravity_well.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameGravityWell.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameGravityWell.c", + "native_license": "MIT" + }, + { + "name": "count", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "1a60a22d52617a0c7cac2665288fce39fbc8e52402c23818f81222d83a87c973", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/count.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/count.py", + "source_sha256": "561b583a1ca1a9db99ffd385cdf42db4752bee9d5fcb9050fd2723bb43317a9b", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/count.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/count/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/count/main.js", + "native_license": "MIT" + }, + { + "name": "baserunner_dash", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "e6bcff0d41fcfdcb44d89de26c80a2ee2dd56d873bb642cf9fa35061c4f2b477", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/baserunner_dash.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/baserunner_dash.py", + "source_sha256": "544b82cada34486556d02b9070a5ebfb325322e9e1038933ee1bf6aeda509753", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/baserunner_dash.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBaserunnerDash.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameBaserunnerDash.c", + "native_license": "MIT" + }, + { + "name": "two_faced", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "d148c5c612cbba4d949d0c759540492713ba5d53b2100821641435b056b038df", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/two_faced.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/two_faced.py", + "source_sha256": "5b1577eb70f91b1f9df8f877a486a712ed067699a41d104800b756ac761319bd", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/two_faced.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/twofaced/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/twofaced/main.js", + "native_license": "MIT" + }, + { + "name": "amidar", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "14413fb145c92c56f13016b754a8fa8fc75eadb499d2b680fea286cd5290df58", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/amidar.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/amidar.py", + "source_sha256": "8ce08cbffc5b55f296989c1a3b69b7ef41147ae3e84df30308a0c8168da754ea", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/amidar.md", + "historical_source": "The mechanics mapping follows the Parker Brothers Atari 2600 instruction manual for *Amidar*." + }, + { + "name": "b_cannon", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "0ef2d564744e8a002b8f66fdaac6335a647cb1439afaff40dbc51be4627450c4", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/b_cannon.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/b_cannon.py", + "source_sha256": "210791552bd7a144b843fa9d6d228dcefa6868f2a1fff62d6915d546730e3a9d", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/b_cannon.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBCannon.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameBCannon.c", + "native_license": "MIT" + }, + { + "name": "bs_fish", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "cc0b95890f03a6894330b44aaa6f6da00b29675d4d91c7c717df93742a5a25b6", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/bs_fish.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/bs_fish.py", + "source_sha256": "c91f6844fa82e46e606911aa98ba1fecad6f9ec2aab092306529175e0884fba3", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/bs_fish.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBSFish.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameBSFish.c", + "native_license": "MIT" + }, + { + "name": "rolfrg", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "f9283edf64ed307f47ae7c72eba639fa68d716e6313469b60ebf55d707b54e1a", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/rolfrg.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/rolfrg.py", + "source_sha256": "820c8996894c22b609d728edd48a08d7415e11a42c47323a23bf4c1e188dc367", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/rolfrg.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/rolfrg/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/rolfrg/main.js", + "native_license": "MIT" + }, + { + "name": "time_pilot", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "048fcf0d47b32121377aa2dd82a42ed5258423fe5437cef1fcac658d5d30de3a", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/time_pilot.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/time_pilot.py", + "source_sha256": "3a59c4522eaf85bbeee1024562b146653cba164134d26cf0fa7adb88a3af6d3d", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/time_pilot.md", + "historical_source": "The flight and fire controls, five time periods and enemy families, 56-aircraft quota, era-specific\nweapons, formations, heavy aircraft, seven-hit mother ships, time travel, and score values follow\nKonami's *Time Pilot* arcade service manual and the Coleco Atari 2600 conversion description. The\n2600 port's omitted parachutists are corroborated by contemporary port documentation and review." + }, + { + "name": "vh_walls", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "f75663c4dbeb5bcdb5fd0a7d71dd421cbc5f40c9b558ca56efdfa2b0209cf8a8", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/vh_walls.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/vh_walls.py", + "source_sha256": "b9c82d86eeef2c1b54b06481f21f05a65a6afa05d1c04b9b69269aa671d39a6d", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/vh_walls.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/vhwalls/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/vhwalls/main.js", + "native_license": "MIT" + }, + { + "name": "gravitar", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "ff9aef68742f3c8a3f67217e6bcebc5bbfd2394187567cd6998c6d2cb19b3ab6", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/gravitar.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/gravitar.py", + "source_sha256": "27c4d9f95894e90bd076c25f0eb7e812a318129d92066b31140b1ffda4d3d862", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/gravitar.md", + "historical_source": "The 12 solar systems, planet-or-reactor completion routes, gravity and reverse-gravity galaxies,\nterrain collision, bunkers, shield, tractor beam, 5,000-unit depots, 10,000 starting fuel, reactor\ncountdown, system awards, scoring values, bonus ships, and game-over rules follow Atari's Atari\n2600 *Gravitar* manual archived by AtariAge." + }, + { + "name": "up_1_way", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "9ba7342e8a82de2972d151b5f67293ebef2ab20a7bb5d25ae9bbcb705eeb0015", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/up_1_way.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/up_1_way.py", + "source_sha256": "6b7be73be5acc934965ec0ff7e2f0e8bb7ffdea2dd584aff8fbae6d08def607c", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/up_1_way.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-11-games/blob/6fea4eefe2deaa42706051d96a04ec9e36104696/docs/up1way/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-11-games", + "native_pinned_commit": "6fea4eefe2deaa42706051d96a04ec9e36104696", + "native_source_path": "docs/up1way/main.js", + "native_license": "MIT" + }, + { + "name": "monjum", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "3bbe33d3a07d4f310fb9f25458fc3964149bc5e279792d0e15448fb3e2d6f9bc", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/monjum.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/monjum.py", + "source_sha256": "38c237911d372c8dcad874bb0d5507710ca37908ac2ede2c5612311603e05c97", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/monjum.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/monjum/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/monjum/main.js", + "native_license": "MIT" + }, + { + "name": "rocket_trail", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "a9308b0e5bf86051d573cc084f23e536cf4db9189b9c4bc6a7054cb31449fb2e", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/rocket_trail.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/rocket_trail.py", + "source_sha256": "7af39618436e76e4964f14c0d1854abf187b239144cfc76386ae206a07c2b86d", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/rocket_trail.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameRocketTrail.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameRocketTrail.c", + "native_license": "MIT" + }, + { + "name": "kite_master", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "3db50116fb07c7c8611bd2a020adc11f65bc6d533d1dd777cc7b932c81d59684", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/kite_master.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/kite_master.py", + "source_sha256": "29e48336f6745da886c5b0c8e4e3325a44a2c528eff82c532e39213ff11c70eb", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/kite_master.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameKiteMaster.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameKiteMaster.c", + "native_license": "MIT" + }, + { + "name": "charge_beam", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "36ade2ff61fa445194f29eb4945a5aee5d4e7b3d77b9abeea57b188ae7134796", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/charge_beam.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/charge_beam.py", + "source_sha256": "3f8df3baaec91c84494c356f0d00ddf29ba2f1c44dc99b50bd6e68f120053b08", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/charge_beam.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-11-games/blob/6fea4eefe2deaa42706051d96a04ec9e36104696/docs/chargebeam/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-11-games", + "native_pinned_commit": "6fea4eefe2deaa42706051d96a04ec9e36104696", + "native_source_path": "docs/chargebeam/main.js", + "native_license": "MIT" + }, + { + "name": "accel_b", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "fa73eda1b56b97e80f70d4fb35fc291b1760ae6f92607b5783a666903f9d7124", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/accel_b.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/accel_b.py", + "source_sha256": "3ca06206077974df7a68da3b467b3e8a450852222cd77afa4928433d0edd64c5", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/accel_b.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameAccelB.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameAccelB.c", + "native_license": "MIT" + }, + { + "name": "wizard_of_wor", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "c41cbbf77f155dafc30255d07cf6902c700f6aa5bd20920a2edd37466468f324", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/wizard_of_wor.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/wizard_of_wor.py", + "source_sha256": "73b5326a084e64cb64e354be31ce7a4e6a91c4aa19f3a0e4722bb53194e32234", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/wizard_of_wor.md", + "historical_source": "The objective, three Worriors, one-shot laser, 10,000-point reinforcement, enemy order and traits,\nWorluk appearance and doubling, Wizard teleport battle, radar, escape doors, and exact point values\nfollow CBS's 1982 Atari 2600 *Wizard of Wor* manual as transcribed by AtariAge:\nhttps://atariage.com/manual_html_page.php?SoftwareLabelID=598." + }, + { + "name": "line_b", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "013ce4e75c45abba8f6295dc04db8521f4123371ec928e5e26b4a1938e20a479", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/line_b.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/line_b.py", + "source_sha256": "b76ae7ddff793b847bd81e01bfd757ac084f9cdc92dac1a824a02e8ef40c7d6b", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/line_b.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/lineb/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/lineb/main.js", + "native_license": "MIT" + }, + { + "name": "photon_line", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "c71cf65e34994ffee1c15b2be641b08fb494a6a19fa13369d200afc16a26873b", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/photon_line.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/photon_line.py", + "source_sha256": "0e280b06a98347c7594a86881b424d78c37a3e70df3c9ca4f60f9193b42f0905", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/photon_line.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/photonline/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/photonline/main.js", + "native_license": "MIT" + }, + { + "name": "attack_chain", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "ea4f88698cdea8e34f4e6c57dd4f8214b0b379d69b2e437e46daaa356978743a", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/attack_chain.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/attack_chain.py", + "source_sha256": "ae956817a32ff6f8a9b11f60bc2b75178b0826f1c7fba2e6e2e472671f13923a", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/attack_chain.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameAttackChain.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameAttackChain.c", + "native_license": "MIT" + }, + { + "name": "hyper_laser", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "ff299aac753464687f8bfe55c0c99cf0218f2bdbb4745685820d02b90abe9265", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/hyper_laser.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/hyper_laser.py", + "source_sha256": "5cef5547bc22c85149aa97bbc41e0302a9725b3ada26451989181fb7ee894151", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/hyper_laser.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/hyperlaser/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/hyperlaser/main.js", + "native_license": "MIT" + }, + { + "name": "bridge_cross", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "cc348bc2d0481591f07bbbfec58b2b59003de29a1c67c33f3fb086e80e8fb7e7", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/bridge_cross.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/bridge_cross.py", + "source_sha256": "17ca128e99b40a0064f93e0d5bc56962f537264d3bfe5872e7d1a26f706152ce", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/bridge_cross.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBridgeCross.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameBridgeCross.c", + "native_license": "MIT" + }, + { + "name": "laser_fortress", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "018a153ffee51449f97a51439236f33dc3a610e61f695e138fc0e08396d39c37", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/laser_fortress.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/laser_fortress.py", + "source_sha256": "58076e9a352d87a5244602fdf44bb461f5f933e7f6931ec167e14c8bb538f0af", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/laser_fortress.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/laserfortress/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/laserfortress/main.js", + "native_license": "MIT" + }, + { + "name": "asteroids", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "9e745cbdd85d206f587cfc83765d93b35c5ff02f58fbb33b456b9f75a38fafac", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/asteroids.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/asteroids.py", + "source_sha256": "c63cdce494c19394d96a02ff665a2d60e1757509bf0213f32e582a4d95930400", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/asteroids.md", + "historical_source": "The mechanics and point values follow Atari's instruction manual for the Atari 2600 version of\n*Asteroids*." + }, + { + "name": "not_turn", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "ecd84f1f9e0e061010e712025189c27271ebe37a4753e062d05eb5120c248e92", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/not_turn.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/not_turn.py", + "source_sha256": "d33024ea8b8faba114c1b57c2d748bf58e870718beb8fbe722c99c3f452872aa", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/not_turn.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/notturn/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/notturn/main.js", + "native_license": "MIT" + }, + { + "name": "double_dunk", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "2171c36bd774f66b34e457ea3093ca9fc68970a9737f9ac55b4f8247af099d5e", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/double_dunk.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/double_dunk.py", + "source_sha256": "95f9ede7380780a676bb33fb4ede329641a79cb130b7df798f8451ac7a4c32ef", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/double_dunk.md", + "historical_source": "The two player roles, play sequencing, jump-release timing, dunks, three-point and foul scoring,\nsteals, blocks, rebounding, clear-the-arc rule, shot clock, lane violation, and game-length option\nfollow Atari's *Double Dunk* instruction manual archived by AtariAge." + }, + { + "name": "tape_j", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "827e78cf354185088b57481ee84641845be59ace5111ec1dc6153111d5b4ba31", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tape_j.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/tape_j.py", + "source_sha256": "9b2229bb34f8525dbf2c486d7a60234b310dcfc25a933462dfe96dde23d7a284", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/tape_j.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/tapej/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/tapej/main.js", + "native_license": "MIT" + }, + { + "name": "centipede", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "bf7b1d7886ba779a772c68a7b31fb34da2db4ec4ee3f54cbc114b659a9b5f7d7", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/centipede.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/centipede.py", + "source_sha256": "b370b151f522bd93b62236d60f8d9365c79e6ef80965f84f59e33f4f28b250d5", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/centipede.md", + "historical_source": "The segment splitting, mushroom durability, insect values, poisoned dives, player zone, wave\ncomposition, and life-loss mushroom scoring follow Atari's *Centipede* Atari 2600 instruction\nmanual archived by AtariAge." + }, + { + "name": "tornado_twister", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "cbbf757f947b544ff1fa8399672c3fa4e55b3677420e3030bc15e796bd420ae6", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tornado_twister.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/tornado_twister.py", + "source_sha256": "cb0f0b172035a6aae6b29d77e1ef2db33523d96196b98c8f78b0413b654b5c4e", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/tornado_twister.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameTornadoTwister.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameTornadoTwister.c", + "native_license": "MIT" + }, + { + "name": "meteo_planet", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "faa349a75f974acce97cf4aa58d1d670e6e7b774a4f20ff7744f535b4f966543", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/meteo_planet.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/meteo_planet.py", + "source_sha256": "3e269c5b3ef54c19e04acdddaf6a5aae0095eb7fc03d341212b5d96e6fcd5007", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/meteo_planet.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameMeteoPlanet.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameMeteoPlanet.c", + "native_license": "MIT" + }, + { + "name": "bamboo", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "f7187bb1fcdb66597aca2dccaeb5f15c9db5d5dee25cb225824504afa3a0d915", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/bamboo.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/bamboo.py", + "source_sha256": "273b1d5ff9620002506d207077c0706eb8fae51d803bcbc602478ade3850862d", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/bamboo.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBamboo.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameBamboo.c", + "native_license": "MIT" + }, + { + "name": "fall_bounce", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "03940632db2bfa13f9f9d2a6963ea0ef5e6d4722b57d43d116787d93f7f6548f", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/fall_bounce.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/fall_bounce.py", + "source_sha256": "3ece3471135153a646485288d2e8b6c2faf9e7fdad631d7be8dcbaa51ff9631b", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/fall_bounce.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameFallBounce.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameFallBounce.c", + "native_license": "MIT" + }, + { + "name": "road_runner", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "ad248bb36601628d9a2415575e3539669bcd19c35e539b038d9900223dc661da", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/road_runner.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/road_runner.py", + "source_sha256": "24793b318da6e393d9400e3ccb21dafdf6199350ec0c18ab6150735411841294", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/road_runner.md", + "historical_source": "The eight levels, controls, three lives, seed escalation/reset, steel shot and magnet behavior,\nhazards, point values, and double-back strategy follow Atari's Atari 2600 *Road Runner* manual\narchived by AtariAge." + }, + { + "name": "neon_pollinator", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "9126175aa0ce6ee1089435bdc6a8db75ecf69fd30026624e09d01a55bf7b9e66", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/neon_pollinator.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/neon_pollinator.py", + "source_sha256": "f9e1cabd36368d8c4baf40cb184a2e761ce9dd6dacf726aec1c58468fb3d5620", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/neon_pollinator.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameNeonPollinator.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameNeonPollinator.c", + "native_license": "MIT" + }, + { + "name": "atlantis", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "001139c0e1fb04b4fdbeff5a78c0008875641a016f8a5d8a19bb46f3ecc0d433", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/atlantis.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/atlantis.py", + "source_sha256": "47c17883d81b5073e8cb7e878047aec702824cba7f3426310ce36085f246f0e1", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/atlantis.md", + "historical_source": "The mechanics and scoring follow Imagic's Atari 2600 instruction manual for *Atlantis*." + }, + { + "name": "unctrl", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "401fd82baa3406a0576895ddacae201f848f18271c0265de55f39dcae2e63ff9", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/unctrl.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/unctrl.py", + "source_sha256": "996355675313809b88b010f0e717eafeb257ed902d0fa2711c704cf4e978f5c0", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/unctrl.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/unctrl/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/unctrl/main.js", + "native_license": "MIT" + }, + { + "name": "recoil_radar", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "3cfead19d0e4c90736a84d1006ac397900b6265d11d401a57ce7ec689a1e89f9", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/recoil_radar.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/recoil_radar.py", + "source_sha256": "a5bff77010a81bce9bb07da87e0ecc413511f1c09f2bc1d0264da62419ac3e2c", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/recoil_radar.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameRecoilRadar.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameRecoilRadar.c", + "native_license": "MIT" + }, + { + "name": "wind_rang", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "c7107696dd4c456ff0f72729090343fb8ade0fdec57d75109a562ba1c100f9c8", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/wind_rang.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/wind_rang.py", + "source_sha256": "0cccd1b69e9bc959a5211026fb9d7bbe8ed4901bf70542bf729ce2c34a098d72", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/wind_rang.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameWindRang.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameWindRang.c", + "native_license": "MIT" + }, + { + "name": "pod_migration", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "6d057ec8be8b48afac2c9a6de1e4864ad568fb2d761da028b07d7dd26f99829f", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pod_migration.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/pod_migration.py", + "source_sha256": "cb61d5985d544829de62b1d608be944aa442974f3a45989b57b05d8d450985b1", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/pod_migration.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePodMigration.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gamePodMigration.c", + "native_license": "MIT" + }, + { + "name": "jpaddle", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "68b079bf1ad05de9a4e002c27889cc3b76873451379acc8ad5a9d4d346a1e5b2", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/jpaddle.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/jpaddle.py", + "source_sha256": "c8378841e09106ed267186ba25be0ce5102be1f71aea49940a2dc639c459340b", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/jpaddle.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameJpaddle.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameJpaddle.c", + "native_license": "MIT" + }, + { + "name": "refbals", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "d5edc47dd8e716fc5eaafb7cd116b9897b439a6da12ba786427533d1832ae0c4", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/refbals.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/refbals.py", + "source_sha256": "52ac13ebc6133b3b64d5d59bee692b8abee2b7a1bc6881377014bb335516495d", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/refbals.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/refbals/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/refbals/main.js", + "native_license": "MIT" + }, + { + "name": "press_m", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "fdbb90ab60c9b7c1ba4fd1a82869f00d23c35f7b90df70c156d8d155134b2323", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/press_m.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/press_m.py", + "source_sha256": "7a5f377ec30ac7a12a3e99bc2b2cab662b9cda2f262760d53a6a5607dd9e5003", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/press_m.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/pressm/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/pressm/main.js", + "native_license": "MIT" + }, + { + "name": "twhols", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "8cce28572ce2213470ce80f3fbaea927a83d18cecab74cf1d43a8b4634828e6a", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/twhols.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/twhols.py", + "source_sha256": "c74a6d2a7fc6b1684f82f64259feba1f380bae02d50830cb96e01e2ded43146b", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/twhols.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/twhols/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/twhols/main.js", + "native_license": "MIT" + }, + { + "name": "missile_guide", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "04f207e4f64d395b9c15d5228bc6b65e55d9e6b90e0d9cb8e45f2694a2ad4c98", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/missile_guide.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/missile_guide.py", + "source_sha256": "b4cc2fb00278ff14967cf9053cedd1781cbd19eed1ca0582cd3174ce57289ddb", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/missile_guide.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameMissileGuide.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameMissileGuide.c", + "native_license": "MIT" + }, + { + "name": "bomb_up", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "0b3574a3c82a8f268b6aea571e9ff95985d9b7c7354c070bbfaae14ad4a19000", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/bomb_up.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/bomb_up.py", + "source_sha256": "c3cbd96f71f58adb830cc1ae493cdd194ccf6cf042a9defd01d8bd2b2d49497d", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/bomb_up.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/bombup/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/bombup/main.js", + "native_license": "MIT" + }, + { + "name": "raid", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "246bd6b067f179a1eff91934fbd9f530b7f19b9b9a70f493d277e14a261808c1", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/raid.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/raid.py", + "source_sha256": "e954a19e929a806d20d166e14d550ad6725e7a2059882ca3bd48d62bb035273a", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/raid.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/raid/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/raid/main.js", + "native_license": "MIT" + }, + { + "name": "lland", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "9901d8d618eaebeeb3099f7f495d93f34e726d1a229c8773fb4dfedc95834be7", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/lland.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/lland.py", + "source_sha256": "2b2b733c19b0fc29e11ee400108b2046b38ad9ceba110804297db9f1fcca92e5", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/lland.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/lland/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/lland/main.js", + "native_license": "MIT" + }, + { + "name": "sub_jump", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "2fb93ab4fa09c42d67df0cb2871c2f39076586dd9c56aa2b6e0c8f009bfc2f1e", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/sub_jump.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/sub_jump.py", + "source_sha256": "a2eb41309ff758d14f6b9197167e6ed471a160f8c4a30f6d9b0cb6f263269dd4", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/sub_jump.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/subjump/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/subjump/main.js", + "native_license": "MIT" + }, + { + "name": "bowling", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "bfa3445b3ebeb1c30b898fef062d445537658ec5edc5639ccf94c423c5387fed", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/bowling.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/bowling.py", + "source_sha256": "f9dde358a201357baf35c9db03355233b3c7ba1050445a591e5d2ef7f7b5df32", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/bowling.md", + "historical_source": "The controls, variations, frame structure, and scoring follow Atari's instruction manual for the\nAtari 2600 version of *Bowling*." + }, + { + "name": "crazy_climber", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "4221be29e5cc4032d8e9bc74a7f1207191b8936a26ab6fc5f60b9c7e3165ed31", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/crazy_climber.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/crazy_climber.py", + "source_sha256": "98e89b5559c0d5921a8c594e683f6815bae41d88aec59a0a68c73ba533a78323", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/crazy_climber.md", + "historical_source": "The five climbers, two-hand window rules, braced-object protection, unavoidable girders,\nelectric-sign shocks, helicopter timer, four-building point values, and maximum bonuses follow\nAtari's *Crazy Climber* instruction manual archived by AtariAge." + }, + { + "name": "turtle_tide", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "90f04242206d541ca30d4dd77339b17953d33b7730ac24f11e10f9e8f1f0db8c", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/turtle_tide.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/turtle_tide.py", + "source_sha256": "c1f60a36b176804e0c4dd11539a7b2c0ffdf37cf7e52982225730b173d304bd2", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/turtle_tide.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameTurtleTide.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameTurtleTide.c", + "native_license": "MIT" + }, + { + "name": "spin_cell", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "3ccb1dd7ee5329d2000e95f2fef033f188a99d2666d5b2630f1e592257319572", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/spin_cell.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/spin_cell.py", + "source_sha256": "9e6152d73d8b6fe72b9bef5164e4c7d461fe90e5351c36441817ac1b2fb1900d", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/spin_cell.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameSpinCell.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameSpinCell.c", + "native_license": "MIT" + }, + { + "name": "boxing", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "c76003a75e5823603e75852fa0e32a3012602991a647dd9336d53e69fb1ffa4d", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/boxing.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/boxing.py", + "source_sha256": "82977decef23f463f41e18cf3b7a8d28000046b56618f32785f02626d9c56d70", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/boxing.md", + "historical_source": "The controls, two-minute bout, jab/power values, and K.O. rule follow Activision's Atari 2600\ninstruction manual for *Boxing*." + }, + { + "name": "space_invaders", + "split": "test", + "family": "minatar_original", + "prompt_sha256": "ad6969d8bae2ce4172b2385472e3557b2de1e40d22ea64b0c88cbf7679d4c533", + "upstream_source_url": "https://pypi.org/project/MinAtar/1.0.15/", + "upstream_repository": "https://github.com/kenjyoung/MinAtar", + "pinned_commit": null, + "pinned_version": "1.0.15", + "upstream_source_path": "minatar/environments/space_invaders.py", + "source_sha256": "1accccac909db675dc6cc9be7af74a2bcc0ec073a1874a99b318c0a93682a1d4", + "upstream_license": "GPL-3.0", + "authors": [ + "Kenny Young", + "Tian Tian" + ] + }, + { + "name": "stillfire_choir", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "2fc2e25ae2572118a1e04e10858166b3805d1b8ebcfbc617a5c98395f5c4074e", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/stillfire_choir.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/stillfire_choir.py", + "source_sha256": "0340b87e2daadb57ffec96d0962d79870f1d3effa8f1b39f7c64b3754f4a6f32", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/stillfire_choir.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameStillfireChoir.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameStillfireChoir.c", + "native_license": "MIT" + }, + { + "name": "mortar", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "c7ee2a1540043c47107bcabb06e2c485947171437b3665eea2c2c2dc31c63c85", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/mortar.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/mortar.py", + "source_sha256": "76c6fe021824c186dbaa7d52a0880bcf1fd898d607af122964bf76ead7401756", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/mortar.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/mortar/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/mortar/main.js", + "native_license": "MIT" + }, + { + "name": "earock", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "fe447dad2a7151c7dd5fc3f05ad90302f17966e97c1c117d4857ac145db1c5c0", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/earock.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/earock.py", + "source_sha256": "bf6dc9ac9a8f1aab84b1804b8d0b7fded774476fcb7136b214bf74b83c5f27bb", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/earock.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/earock/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/earock/main.js", + "native_license": "MIT" + }, + { + "name": "future_wake", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "16d81b52960e43cd0bc3476c46f04c16c1043a74c19c635ee1e1cb0213f2cfdc", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/future_wake.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/future_wake.py", + "source_sha256": "e2d3f43c2fedd4c02e970304d864945a773959df41d7bdf38d954841e3b3a30e", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/future_wake.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/futurewake/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/futurewake/main.js", + "native_license": "MIT" + }, + { + "name": "hoppin_hazards", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "fef9c9f622b1e4f7a48118624d09d7b6e8f0e47aefbeb6067b30a11451fa2d7c", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/hoppin_hazards.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/hoppin_hazards.py", + "source_sha256": "8ca29c6ac727bc519351b22467b84e567b25314754913180b18550d61b37b465", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/hoppin_hazards.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameHoppinHazards.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameHoppinHazards.c", + "native_license": "MIT" + }, + { + "name": "chalkboard", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "693024d1d74eadb93a60c0c0d3936710d82a9fa53c6085a89c2492ab600f473b", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/chalkboard.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/chalkboard.py", + "source_sha256": "777688db7873469c91f5ff9cb5b7da0e7cf43afb3c3bc524a0a3f313fb921056", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/chalkboard.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameChalkboard.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameChalkboard.c", + "native_license": "MIT" + }, + { + "name": "demon_attack", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "e15fc462774113d364047ee45be11eb6cb1f2a704cf20c796da742750e9ca22b", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/demon_attack.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/demon_attack.py", + "source_sha256": "d826180e48ead26bd19da42d7cca3333da4c72be9eb78b20f6873f51d2f17718", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/demon_attack.md", + "historical_source": "The movement controls, unlimited cannon, three starting bunkers, unscathed-wave reserve award,\npost-zero fatal hit, split and diving enemies, asymmetric child fire, and every score tier follow\nImagic's Atari 2600 *Demon Attack* instruction manual archived by AtariAge." + }, + { + "name": "spearain", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "c05348caef9e9a32c997c41dfe3ac4171f6981175e2e05e6b093f86e738a7769", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/spearain.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/spearain.py", + "source_sha256": "7c5f7eab491017da23896cfa68a2deffd987c82a16a44c8dd062735964479ad6", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/spearain.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/spearain/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/spearain/main.js", + "native_license": "MIT" + }, + { + "name": "microbial_focus", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "133aec96d0870b70c6b30852e4ad596f4555ef72d7eaf1fcead7b44592d9d072", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/microbial_focus.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/microbial_focus.py", + "source_sha256": "5888e2e87519f3f09f31b08ce07e8f869d820ee3aec6e99811c5a42fce68e4d8", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/microbial_focus.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameMicrobialFocus.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameMicrobialFocus.c", + "native_license": "MIT" + }, + { + "name": "enduro", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "e1884a08d15a48afe3a43b78bd4b1c2be12c8fae73f7fec238fa9b3a68a80550", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/enduro.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/enduro.py", + "source_sha256": "4ae4271fb76f4aa56fcf469b0a94254ffa011b1696d1418b65539048a0cd9006", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/enduro.md", + "historical_source": "The accelerator/coast/brake controls, collision consequences, first-day 200 and later-day 300\nquotas, post-quota progress, sunrise failure, day/night cues, ice steering, and fog visibility\nfollow Activision's Atari 2600 *Enduro* instruction manual archived by AtariAge." + }, + { + "name": "roll_hold", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "e141b49748c255ebef5652431d71eb3d36ebb9960b81b26a878ca3acf67e0796", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/roll_hold.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/roll_hold.py", + "source_sha256": "decc5ed550af4cf9290041f6a5e03b99a07a256598d8bd6ff96c01d88090cc4f", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/roll_hold.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameRollHold.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameRollHold.c", + "native_license": "MIT" + }, + { + "name": "stompshelter", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "1f984cade9c41613789d4280da5e55845ce809282becf1e1257736324458cf10", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/stompshelter.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/stompshelter.py", + "source_sha256": "2b6bde48a875043efa88cefb6fcd39274b93e8965e4abebe15ccdb659a73f38f", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/stompshelter.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameStompshelter.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameStompshelter.c", + "native_license": "MIT" + }, + { + "name": "portal_j", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "3c9cacd2de2fdae8496a1fcba1ee079845bde6535b1c5dbeadc88528dbd308f6", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/portal_j.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/portal_j.py", + "source_sha256": "82ac25cb5dcec43522aa3241ba6a19ad9273136fdbf937c7c8d6b5a6fa65681b", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/portal_j.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/portalj/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/portalj/main.js", + "native_license": "MIT" + }, + { + "name": "breed_c", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "8237d73a21a35d6725dd4d94c6f5e727fb3d3c655bc021af761d064f248ea1b6", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/breed_c.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/breed_c.py", + "source_sha256": "0fe2091d269fc1b59f8dd773b8093ec09d56d77b7262401ba99efb4d2b536013", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/breed_c.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/breedc/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/breedc/main.js", + "native_license": "MIT" + }, + { + "name": "vine_climber", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "fe13f9dba05f63186a1973f6ac903f707d700d886f357bed37ff09078fb8986b", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/vine_climber.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/vine_climber.py", + "source_sha256": "4823e9f03ffdc626435a29ff88844fb9c1c1246af0230e41d86ffc028c958f18", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/vine_climber.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameVineClimber.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameVineClimber.c", + "native_license": "MIT" + }, + { + "name": "cywall", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "995731d2c38db9514583d919d1569349eacaf08894b0e3087508edfc15050d0f", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/cywall.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/cywall.py", + "source_sha256": "e17bd44c116a53b31de030c21db3bc453a721722da14ad62bc2622434e6bddd0", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/cywall.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/cywall/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/cywall/main.js", + "native_license": "MIT" + }, + { + "name": "twin_p", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "404a48a828763da067cd76ed93b7951012b53d5d235f4470ebb612ae084c0832", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/twin_p.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/twin_p.py", + "source_sha256": "7b678a5d921c4460c816a4e653c3f5f3112febd2cb194b775ff35d2f8551edb4", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/twin_p.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/twinp/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/twinp/main.js", + "native_license": "MIT" + }, + { + "name": "up_down_press", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "9d4e58e45ad1fc046973f173f4ecc295fb77d517ed751f8b75eeeb2da8030f27", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/up_down_press.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/up_down_press.py", + "source_sha256": "27da5b37556bb34abbe7e21332af6722197204fc7d2d5bd37fcd4b55808418df", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/up_down_press.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/updownpress/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/updownpress/main.js", + "native_license": "MIT" + }, + { + "name": "ice_hockey", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "989c78e134094bf65db6c9f733a71c3769c7c737ddd33c995cd59817d3f19e0e", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/ice_hockey.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/ice_hockey.py", + "source_sha256": "9ca7e5285243455a13d849ddfb1061699f00a3cb0a17d80e949397d38411a27e", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/ice_hockey.md", + "historical_source": "The three-minute period, two skaters per team, nearest-skater automatic control, puck capture,\nforward-only timing-based shot angles, passing, bank shots, body checks, faceoffs, goalie defense,\nand one-point goals follow Activision's Atari 2600 *Ice Hockey* manual archived by AtariAge." + }, + { + "name": "tennis", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "12c2566bb5fee880c09ed1020766bc9d0e2c5f46c91cda8b754ede48af477cfd", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tennis.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/tennis.py", + "source_sha256": "63ab5a892453923ea2dc36ed91f3f881564660f34563391b989971f45545507e", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/tennis.md", + "historical_source": "The game variations, controls, movement restrictions, orange opening serve, server and side changes,\nautomatic swings, guaranteed in-bounds serves and shots, net-shot length and angles, racket-edge\nplacement, point/game scoring, deuce/advantage, two-game margin, 6\u20136 reset, and tactical guidance\nfollow Activision's Atari 2600 *Tennis* manual by Alan Miller, archived by AtariAge." + }, + { + "name": "outpost_patrol", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "c73d0ac253891dac9abbb0436e0d509152534e8abf4ada41f7d112b25af06ef2", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/outpost_patrol.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/outpost_patrol.py", + "source_sha256": "a8246c9de774384e0f454dc6d75a45dac3da3e40311716bdd12e32c99c35e7df", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/outpost_patrol.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameOutpostPatrol.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameOutpostPatrol.c", + "native_license": "MIT" + }, + { + "name": "arcfire", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "44a2da8857da76444e99a5c26af2e0756e2a7070cfc667512e788bbb99f2dc24", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/arcfire.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/arcfire.py", + "source_sha256": "f238c61184b4e29bc9e774dcfe2fec6dba1ef5dc21ba00d6c09d87892ef14d5a", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/arcfire.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameArcfire.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameArcfire.c", + "native_license": "MIT" + }, + { + "name": "krull", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "13cb7658cd77d04116524129248f45a86cd9933e18a86dcc2beb9db345cc9f01", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/krull.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/krull.py", + "source_sha256": "f12a9657937c8ff1b4d8b0446c94017c2188bd8e247e5eaa61c6d05427290592", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/krull.md", + "historical_source": "The marriage defense, speed-scaled Slayers, Fire Mare pickups, Glaives and extra lives, Widow's\nweb, strand and cocoon scores, Crystal Spider timer, sunrise-dependent paths, failure costs,\nGlaive steering/rebound/catch rules, prison chunks, Lyssa's fireball, Beast value, harder restart,\nand three starting lives follow Atari's Atari 2600 *Krull* manual archived by AtariAge." + }, + { + "name": "sum_ten", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "a10aa3b2297fdca2300a10ad99650140039b7fe72d64d0979a786605a810d858", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/sum_ten.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/sum_ten.py", + "source_sha256": "29e69e83f263ac6dab710ba238be991094ea2375af8cbc1592bc22019dd6248e", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/sum_ten.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/sumten/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/sumten/main.js", + "native_license": "MIT" + }, + { + "name": "switchboard", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "b82816f88324ff1be60dbdffdc97195a2e2c749253bc29c49bc83c20995a315d", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/switchboard.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/switchboard.py", + "source_sha256": "de51efaaab6b610307c56f0a268daa716e5c6f85c68692eb3a9b24c3a870f7bf", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/switchboard.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameSwitchboard.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameSwitchboard.c", + "native_license": "MIT" + }, + { + "name": "jump_on", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "06847fce59e312f5dabd6ca72518b40dbc4c72ebb6a9178730cd8f810d7df4ef", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/jump_on.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/jump_on.py", + "source_sha256": "43ebcba5ac77729f41e4740533c4b57709cbdaf28c4b2df9b290d372ce2acd72", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/jump_on.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/jumpon/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/jumpon/main.js", + "native_license": "MIT" + }, + { + "name": "bola_thread", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "0e545a76341bb7ab086fc93b8efce4288cec3303cc3b92cb56a1bcaed9e11f15", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/bola_thread.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/bola_thread.py", + "source_sha256": "27c9cc823315535d8ceb77ddc183e0def74f6631313a5cc35d6994c12ce9b8c7", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/bola_thread.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBolaThread.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameBolaThread.c", + "native_license": "MIT" + }, + { + "name": "card_q", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "eafdda757e910380ac9b14091260058af865f76a7ef6495a34752e2716e5614a", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/card_q.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/card_q.py", + "source_sha256": "32870a59197670597a53c4074adefa5c0e87d2ad34996a10506d0a5e004f2d58", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/card_q.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-11-games/blob/6fea4eefe2deaa42706051d96a04ec9e36104696/docs/cardq/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-11-games", + "native_pinned_commit": "6fea4eefe2deaa42706051d96a04ec9e36104696", + "native_source_path": "docs/cardq/main.js", + "native_license": "MIT" + }, + { + "name": "two_lane", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "71cdfe983ce66934767f414db742f5e70e2c16876c302baaefddbfef748f45bf", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/two_lane.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/two_lane.py", + "source_sha256": "7457adb8dd0630df7bd504f27347472cb34e34a22e38a8af8d64e2d942d72c89", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/two_lane.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/twolane/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/twolane/main.js", + "native_license": "MIT" + }, + { + "name": "scaffold", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "d34e60ad3238f8392392f3e94d27299f3e9be977e8bdcfa222a1332d3f56b14c", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/scaffold.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/scaffold.py", + "source_sha256": "3486964ac540321eb629b92823df750bb3d355dbb8dfa2cc83b9d7dc4939bf07", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/scaffold.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/scaffold/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/scaffold/main.js", + "native_license": "MIT" + }, + { + "name": "stage_separation", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "b5edb02b1838e8fdb6d28576b137c54730728f8ee2323f6ae36eea5df22d8454", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/stage_separation.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/stage_separation.py", + "source_sha256": "0ab55f115bf9406b6bf2815f2cf3588aeafb36f8d9ab529132450ffa2b2bf400", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/stage_separation.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameStageSeparation.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameStageSeparation.c", + "native_license": "MIT" + }, + { + "name": "g_press", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "1ad869d1beaee8eda9cfd380be79e9de9b11fde664cfcc9f7d0a220136edd85e", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/g_press.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/g_press.py", + "source_sha256": "378424dad0b1cb5534220f3d91798162ae74f8859e9d04e1e29f2545d1f43b37", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/g_press.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/gpress/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/gpress/main.js", + "native_license": "MIT" + }, + { + "name": "orbit_grazer", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "90f3d6b6c95f2d35fe0a10f9aed839dfb5da4f6bc2221f7d1bfe85e813c602f9", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/orbit_grazer.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/orbit_grazer.py", + "source_sha256": "79cf8e1109c099cf065a55fd14800400256f9b8b917099e17379bc09dfdc4bd6", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/orbit_grazer.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameOrbitGrazer.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameOrbitGrazer.c", + "native_license": "MIT" + }, + { + "name": "m_jamming", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "aa179005d81596b7822c6aabcb91f09ac76f622302e9c694b7bd679369c6ad44", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/m_jamming.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/m_jamming.py", + "source_sha256": "834c5bc5eb6d3ca28ae3daba29923d725dd8878b0de696e868262c45f8f92433", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/m_jamming.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/mjamming/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/mjamming/main.js", + "native_license": "MIT" + }, + { + "name": "clean_robo", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "3eda990f70d553fbea4ac2a12b5821400bcaced8cf44bfe332ec6e75575c7cfd", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/clean_robo.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/clean_robo.py", + "source_sha256": "225dadcfed89856645050da0a7f3ccd1467a8f2bf491eaf11669713079a11a76", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/clean_robo.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-11-games/blob/6fea4eefe2deaa42706051d96a04ec9e36104696/docs/cleanrobo/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-11-games", + "native_pinned_commit": "6fea4eefe2deaa42706051d96a04ec9e36104696", + "native_source_path": "docs/cleanrobo/main.js", + "native_license": "MIT" + }, + { + "name": "splitzig", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "ee9c7b86959798e20c2f638f5e9984e48ef780569c4271c34d7b790e4c68bc12", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/splitzig.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/splitzig.py", + "source_sha256": "994194ef8bd979f2f4782a6371e6e0dfa05533303c97671536658449df658684", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/splitzig.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameSplitzig.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameSplitzig.c", + "native_license": "MIT" + }, + { + "name": "pressbound", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "fc5451662cc0023821bde4a0aa58ba5e09af900e3804cb809704553ec3e93508", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pressbound.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/pressbound.py", + "source_sha256": "edfd2c5cf3c4d36a901d6bf75eb8e8fdd990ddcc4d7819322fc5cc197598d7f5", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/pressbound.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePressbound.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gamePressbound.c", + "native_license": "MIT" + }, + { + "name": "roll_s", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "d0d39fb4cebcdd72bf60716f9b9ee201ff12aca6bf14e76c38485f06fce7d20c", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/roll_s.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/roll_s.py", + "source_sha256": "c19d138512972a3eae77e56093b37350d7b51fde13797d5de960c362e0a76dd4", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/roll_s.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/rolls/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/rolls/main.js", + "native_license": "MIT" + }, + { + "name": "name_this_game", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "0313a3ccd0170d82ea4e9a814e3013a61f38abe4ebb62b4294378ef6d3a7f31b", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/name_this_game.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/name_this_game.py", + "source_sha256": "f53958391e137b60fd60244f00480dc7372608a4d1c5e8e30360739497d885ec", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/name_this_game.md", + "historical_source": "The treasure-defense objective, left/right and fire controls, shark depth scoring, 50-point\ntentacles, moving oxygen line, ten-point full-tank air units, loss conditions, and faster later\nwaves follow U.S. Games' Atari 2600 *Name This Game* manual archived by AtariAge." + }, + { + "name": "m_field", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "5e102ec57f71229313bae91ff31b10134b11396fd10b895960b4b523a7bd6f38", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/m_field.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/m_field.py", + "source_sha256": "1e6c4be24bd4006a2b549df3a707377f0e9f403f25d2cb7989f3d8ecff98264a", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/m_field.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/mfield/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/mfield/main.js", + "native_license": "MIT" + }, + { + "name": "plasma_splitter", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "0dbb47ff3530a3c20d230dfed3138c86c6d819dd59684ef1a4f785232be9f615", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/plasma_splitter.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/plasma_splitter.py", + "source_sha256": "d5e71ee9050aaac97732740a875e4aba68215cbba33782712dec64e5c6030cac", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/plasma_splitter.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePlasmaSplitter.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gamePlasmaSplitter.c", + "native_license": "MIT" + }, + { + "name": "mirror_floor", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "d6d5a7dcfda28343d19ca4f557ab6abff2025924f514563d50a1ac2d00bb2697", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/mirror_floor.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/mirror_floor.py", + "source_sha256": "d32e7ea9dab356f6f435bd7cc7286b3d5254ac57a48f12be6539991cddb294a9", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/mirror_floor.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/mirrorfloor/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/mirrorfloor/main.js", + "native_license": "MIT" + }, + { + "name": "pulse_piper", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "dc8fd12d377507d3e916305550ea3e37958ee1916047aa6527f234e3acd6ce8d", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pulse_piper.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/pulse_piper.py", + "source_sha256": "e4a5490ebed44974702cf24c1d4d41cbddd2addb31ed958691af102242850f0e", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/pulse_piper.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePulsePiper.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gamePulsePiper.c", + "native_license": "MIT" + }, + { + "name": "robot_tank", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "f103e152997f33dd5a24c3560bbc766151f66e00a0b8c43036b4dd3da253bea4", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/robot_tank.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/robot_tank.py", + "source_sha256": "e05d505342bdb9a0b5991258d3592111610e7574de946227a400e9517a947e52", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/robot_tank.md", + "historical_source": "The controls, destroyed-tank scoring, twelve 12-tank squadrons, starting reserves and squadron\nreinforcements, terminal conditions, first-person view, clock, weather, radar, four damage systems,\ntargetable cannon fire, and rocket interception follow Activision's 1983 *Robot Tank* manual by\nAlan Miller, archived by AtariAge." + }, + { + "name": "jujump", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "60ea89e50b721cb609353331aec009b173cfdf6e2d55eab473f279d7c6ceccbb", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/jujump.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/jujump.py", + "source_sha256": "02467ddf09d0f075775ee9622dffd9fab576312c2ae9ce5172d3656409891273", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/jujump.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/jujump/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/jujump/main.js", + "native_license": "MIT" + }, + { + "name": "berzerk", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "97b76d79efad4e5e1039eaa3df4bf59953bb05ae7e9d04a5e83464c7b22a74ed", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/berzerk.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/berzerk.py", + "source_sha256": "6807ad366053d971f27df1f87291b8233ec7b40cd08a4471cc7b4974d6c75e95", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/berzerk.md", + "historical_source": "The mechanics and scoring follow Atari's instruction manual for the Atari 2600 version of\n*Berzerk*." + }, + { + "name": "regene", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "635bc94703ceb724528269a6e76849c48fb247f94f6990304c7346bd6b4fbd2a", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/regene.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/regene.py", + "source_sha256": "6acd84329bdd1b1c8d715c15cac3139f1a4f050cf0b1534a31feb78788db4efa", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/regene.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/regene/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/regene/main.js", + "native_license": "MIT" + }, + { + "name": "quantum_leaper", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "a63b2c151cb9f257eedd46cb2791a191d1c560afb7250558d54a6210f8c774c3", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/quantum_leaper.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/quantum_leaper.py", + "source_sha256": "700a5a7d4b7d46411ac4d4ed13d807271a0c320da9765086f57098ee90a0ae70", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/quantum_leaper.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameQuantumLeaper.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameQuantumLeaper.c", + "native_license": "MIT" + }, + { + "name": "ghost_hop", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "e07aac41a79a067d76a52661a6bb63be63b7abf4c633935e64fdc65b13874236", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/ghost_hop.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/ghost_hop.py", + "source_sha256": "b6f1d6c0ee903550604f2141dc952fb91fbd9211a052bcfbfed756fc5cfb975c", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/ghost_hop.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameGhostHop.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameGhostHop.c", + "native_license": "MIT" + }, + { + "name": "rebirth", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "c8c557dfc2bea8da80c4ae0ec732c0cf46209d2319580044d7e2fb6c1d913255", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/rebirth.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/rebirth.py", + "source_sha256": "5b27988a5ac173aae561d6a2cf8c47eb43e0ac28ceef6591396dbaf804775caa", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/rebirth.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/rebirth/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/rebirth/main.js", + "native_license": "MIT" + }, + { + "name": "ricochet_pins", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "d33971d17abd10925b57f544a98d4ed84e7dbdf2aff3706470007d3e288ff6f8", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/ricochet_pins.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/ricochet_pins.py", + "source_sha256": "b6a1f7cb4a00f53141459e72f578f873ef069d4cba4df5c574b6173e5cf51b81", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/ricochet_pins.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameRicochetPins.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameRicochetPins.c", + "native_license": "MIT" + }, + { + "name": "star_eater", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "5045a0acca3d244668b5a31c7778c121a15999ed423b278e543cb42ef387eefb", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/star_eater.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/star_eater.py", + "source_sha256": "0b415d931f9f016fe55d71fd093ccbb930157a7d2a0b9d93165ade49d3bd9eed", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/star_eater.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameStarEater.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameStarEater.c", + "native_license": "MIT" + }, + { + "name": "rotation_rod", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "cc85094db5af3726a6421116334ce7ebe9e8397319380d575e9cc32e2a8f9e4d", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/rotation_rod.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/rotation_rod.py", + "source_sha256": "035e9e0269fbb84c96dc7c55e6d60354ed39d51c079b8e02364b6541aa7a4b29", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/rotation_rod.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameRotationRod.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameRotationRod.c", + "native_license": "MIT" + }, + { + "name": "make_maze", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "ae5e26630c412facc1a40b324c51ace4b534d154e72c8583e4d205ce9b152d48", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/make_maze.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/make_maze.py", + "source_sha256": "d796c98544f75d6cc901ef5a6bdb597d5c88085d59bfe92e4e77f9a5a48ce524", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/make_maze.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/makemaze/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/makemaze/main.js", + "native_license": "MIT" + }, + { + "name": "beam_rider", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "5770825e72c399e9d532abaaea0cd54d3b2d15b630b3bbc76499c6dcdb6ebb77", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/beam_rider.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/beam_rider.py", + "source_sha256": "305421144d8e783389a3456f51187fd230902af3c85e20b6e07c2de4534bc5f8", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/beam_rider.md", + "historical_source": "The mechanics and sector progression follow Activision's Atari 2600 instruction manual for\n*Beamrider*." + }, + { + "name": "breakout", + "split": "test", + "family": "minatar_original", + "prompt_sha256": "76f612c733d73bbd0cf63d8195460e68e0cd27090435abbd7f8f1fbe26ff8d7d", + "upstream_source_url": "https://pypi.org/project/MinAtar/1.0.15/", + "upstream_repository": "https://github.com/kenjyoung/MinAtar", + "pinned_commit": null, + "pinned_version": "1.0.15", + "upstream_source_path": "minatar/environments/breakout.py", + "source_sha256": "35fd842751f4314a427623da24c3ca36dc07dfcbbd979e9c72c1079b933bcf5d", + "upstream_license": "GPL-3.0", + "authors": [ + "Kenny Young", + "Tian Tian" + ] + }, + { + "name": "t_punch", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "707a299fc8b1b9411a6979a5a92eb8da94373ee46d95d9ecc6bef02f5c869438", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/t_punch.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/t_punch.py", + "source_sha256": "4827efed0187c10d3a656258700d54de21aaf35f65f3773a261ab8dce9124bd5", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/t_punch.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/tpunch/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/tpunch/main.js", + "native_license": "MIT" + }, + { + "name": "dark_cave", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "005e76f46f965bfe5bddda7a417b9b5a4a0013122ad733731996f2ef0c2293dc", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/dark_cave.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/dark_cave.py", + "source_sha256": "6d26be9d03d81f4a3878a1b34cf671da94743491b8f36def86efc95e72d92b6b", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/dark_cave.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/darkcave/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/darkcave/main.js", + "native_license": "MIT" + }, + { + "name": "pizza_arrow", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "c58bf6a242dccba0633a72e57bd6180e2537e2781041bee9baf505e780ed9503", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pizza_arrow.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/pizza_arrow.py", + "source_sha256": "90156da63450b4c01ea08e513e8cba9786489b0c6ce8d16e5b61c7380d4c34d6", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/pizza_arrow.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/pizzaarrow/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/pizzaarrow/main.js", + "native_license": "MIT" + }, + { + "name": "dango", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "9d25bfd64f137bf8fd5e51a96fbd21c0adf6ca35f2d3fbe9b5d907cec412f55b", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/dango.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/dango.py", + "source_sha256": "1be5ca6a071aace2fd88b09961e5621e3168921df154ad9321a53e4790c179b9", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/dango.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-11-games/blob/6fea4eefe2deaa42706051d96a04ec9e36104696/docs/dango/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-11-games", + "native_pinned_commit": "6fea4eefe2deaa42706051d96a04ec9e36104696", + "native_source_path": "docs/dango/main.js", + "native_license": "MIT" + }, + { + "name": "rollnrope", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "a04df3a8c25b9a536afffeef286ddd5d7e289fea5610eb01f9f77b548f6e2717", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/rollnrope.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/rollnrope.py", + "source_sha256": "5df8491f7e078f6c1015d8f019bca5c0787066223e0b12e69f470a5284ba387c", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/rollnrope.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/rollnrope/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/rollnrope/main.js", + "native_license": "MIT" + }, + { + "name": "d_pistols", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "6fb43c68cf6f034959cb9e77c6dec48475399b3d52072a26984ad262bd105d59", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/d_pistols.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/d_pistols.py", + "source_sha256": "9c661cd18c4cea7b6888faa5517eea111cb6bafcb2e174392f74d34ac3d53ab1", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/d_pistols.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/dpistols/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/dpistols/main.js", + "native_license": "MIT" + }, + { + "name": "from_two_sides", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "286bb115c0a212a5151c7acc52b4323e98ef3d6c3dfe70db1a9cbeca01c28c2e", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/from_two_sides.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/from_two_sides.py", + "source_sha256": "42aac9333dd237c870ae688d7526fc3b3210bdaaeb21b7d38963e0e3def615c4", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/from_two_sides.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/fromtwosides/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/fromtwosides/main.js", + "native_license": "MIT" + }, + { + "name": "l_rain", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "bb970160492ebb4577404221f74e1081ac89010f91a887ab867ca2cbe2f25673", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/l_rain.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/l_rain.py", + "source_sha256": "bb873eb4474c9a894a1e0ac1ee0b982bb0a5b485ca245e98ac15ba1a25b03a86", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/l_rain.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/lrain/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/lrain/main.js", + "native_license": "MIT" + }, + { + "name": "echo_bridge", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "70dc5e7098580e54f4b248364e445b4a80bcca7bc2b69d457e500a1354df9808", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/echo_bridge.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/echo_bridge.py", + "source_sha256": "ca76781783cc5ff273a205a9aba7009255ac10df4113be6d9dd60117e7be6b74", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/echo_bridge.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameEchoBridge.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameEchoBridge.c", + "native_license": "MIT" + }, + { + "name": "freeway", + "split": "test", + "family": "minatar_original", + "prompt_sha256": "ee15cf7be6f493da36e943e2aebc7ac223a73cb71905c0f31723cd1eabc53ccf", + "upstream_source_url": "https://pypi.org/project/MinAtar/1.0.15/", + "upstream_repository": "https://github.com/kenjyoung/MinAtar", + "pinned_commit": null, + "pinned_version": "1.0.15", + "upstream_source_path": "minatar/environments/freeway.py", + "source_sha256": "809243630624c429611645b5da183339a4268408df18d0eee76a30081acf4147", + "upstream_license": "GPL-3.0", + "authors": [ + "Kenny Young", + "Tian Tian" + ] + }, + { + "name": "fracave", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "85997c965515e528a89e4273ebd6b668dc539747428c70f1c40b405405965c41", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/fracave.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/fracave.py", + "source_sha256": "1e7f71d844dc20bd3a24577877998c4c6727b4c2fb1aa9676805504cba3048c2", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/fracave.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameFracave.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameFracave.c", + "native_license": "MIT" + }, + { + "name": "rps", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "dc741f2f032cd7ed348427b8a37fef3ee8607173aa1a725c8912ccc18b1d69f9", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/rps.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/rps.py", + "source_sha256": "1fa2758563dff0aac35c9e277e3ba8c3a48453357d7d5e7ec646d253e8a1e22e", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/rps.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/rps/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/rps/main.js", + "native_license": "MIT" + }, + { + "name": "d_fight", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "01d5dfaeca3c0067789c2c881ace4ad9f4d6afca68d8bcf9d12e652f2db91446", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/d_fight.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/d_fight.py", + "source_sha256": "4499029a03401ff05b6d18255e863a4f3d178a0aba790ed8274fbb4bfc76ae37", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/d_fight.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/dfight/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/dfight/main.js", + "native_license": "MIT" + }, + { + "name": "gloop", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "c2e9d959ef2c120131398a6db996ee2ace797c13a6fc2ecaea45aff51a0ec12e", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/gloop.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/gloop.py", + "source_sha256": "09dbb73d1a2f2ef9e9c0d6aa665f61bbf879b73ce7c90e43e6ea3d57bd8af893", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/gloop.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/gloop/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/gloop/main.js", + "native_license": "MIT" + }, + { + "name": "juggling_act", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "ec724e6c2fc472fddcf60a630fa1ec813d6df0d55c5dec6457460a8bc5250597", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/juggling_act.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/juggling_act.py", + "source_sha256": "512e04b8083100ef2bbe3569a3afef934a233aab68a91aed7011c48e91d07fcb", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/juggling_act.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameJugglingAct.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameJugglingAct.c", + "native_license": "MIT" + }, + { + "name": "v_bomb", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "5dc4d0827ef427d00c11e6263402322d9462a2385a2e15125030a5eb010ddc22", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/v_bomb.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/v_bomb.py", + "source_sha256": "75e7305440479c37425088da39cc6e99993dc18ad6f0571488721791ec632a79", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/v_bomb.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/vbomb/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/vbomb/main.js", + "native_license": "MIT" + }, + { + "name": "fishing_derby", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "f44d5c1652e1d41d864d9483e8a66cb1a8691901a3d7af96fcebeb28bf23746a", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/fishing_derby.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/fishing_derby.py", + "source_sha256": "be0ae4b3c1f97ca2b78f7f01ba916a5f4c90dffa563a90d071915e0d3c8e7e65", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/fishing_derby.md", + "historical_source": "The line controls, six fish rows, 2/4/6-pound values, original-side respawn, slow/fast reeling,\nshark interception, two-fisher competition, and 99-pound finish follow Activision's Atari 2600\n*Fishing Derby* instruction manual archived by AtariAge." + }, + { + "name": "stomping_bubbles", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "9672665eb39532a6a00aad4ff7d279d9c8738b023aaefd47cc909b62de022bd1", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/stomping_bubbles.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/stomping_bubbles.py", + "source_sha256": "26642726bf25723ad204e1b781133afdfcc3a505352b89a519ce7b0cc0609e69", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/stomping_bubbles.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameStompingBubbles.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameStompingBubbles.c", + "native_license": "MIT" + }, + { + "name": "jet_stream", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "22d14a214de1b320b5ee6fb2dfae530cca41204cb09651e40ad7ba59a019108e", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/jet_stream.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/jet_stream.py", + "source_sha256": "b01200de4a20376bcb9149479e33428d0ac7d50c4990da9064fbbdf71c10f3ed", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/jet_stream.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameJetStream.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameJetStream.c", + "native_license": "MIT" + }, + { + "name": "cling_hop", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "3464c51f29efb77d59d308320b2df36a747ced1d544bf31214846e10d162e55e", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/cling_hop.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/cling_hop.py", + "source_sha256": "f5a9bcfcf6ef28b21df7eedb917fcab9b78401de11f2e8b7a9f08f31eb0ab902", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/cling_hop.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameClingHop.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameClingHop.c", + "native_license": "MIT" + }, + { + "name": "ns_climb", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "b643dea2cb440c755877a62c037a5cdde21cffaff45638c866e6dd7447c62e97", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/ns_climb.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/ns_climb.py", + "source_sha256": "bfb22e5efb00ec314b15594a97bc205d5456e9e0cd260e3a602ef0b618b9063e", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/ns_climb.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/nsclimb/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/nsclimb/main.js", + "native_license": "MIT" + }, + { + "name": "up_n_down", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "d2459182dcc605a35753f295771eedfa555a903b120df4da4d0cedf1d2f67e95", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/up_n_down.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/up_n_down.py", + "source_sha256": "f07e350927e9dff5460b359a310c6967e3f337ae74966dbbe765fd1dbb858be2", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/up_n_down.md", + "historical_source": "The forward/reverse controls, branch steering, forward-only straight jump, broken-road jumps,\nfive/easy and three/hard lives, eight flags, nine roads, collision rules, opponent types, prizes,\nand every score value follow Sega's 1984 Atari 2600 *Up 'n Down* manual as transcribed by AtariAge:\nhttps://atariage.com/manual_html_page.php?SoftwareID=1423." + }, + { + "name": "flip_o", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "baef29f2f47fe084d92e97fbd995973fb4c62f5dcb527c885e8b23079805db9f", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/flip_o.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/flip_o.py", + "source_sha256": "e0c481ca375190b3356e1bed1213008295fb0b3fbbd321da7980007e898166fe", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/flip_o.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-11-games/blob/6fea4eefe2deaa42706051d96a04ec9e36104696/docs/flipo/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-11-games", + "native_pinned_commit": "6fea4eefe2deaa42706051d96a04ec9e36104696", + "native_source_path": "docs/flipo/main.js", + "native_license": "MIT" + }, + { + "name": "window_washer", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "9b15037c806fe6da208cc95892303bdbf487320addd841455f4baa90e37dc826", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/window_washer.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/window_washer.py", + "source_sha256": "136b756c7dc51d6f120cd192259ef4e9e7fb70d77730e25982288dece15358bb", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/window_washer.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameWindowWasher.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameWindowWasher.c", + "native_license": "MIT" + }, + { + "name": "bottop", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "2e8abd39a48c4ec4a57147c9cbf3a900c3b783caf2987f9e93fe3571d2fae0d7", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/bottop.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/bottop.py", + "source_sha256": "652ce55c95e19eca7c8cf96d46af7be73b2185eb6aaf4ac598f501a19504ec69", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/bottop.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/bottop/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/bottop/main.js", + "native_license": "MIT" + }, + { + "name": "b_walls", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "d332c2637f19bcc8c926397fa1eb180709e025a8a8bb018d6872a8be06b0d878", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/b_walls.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/b_walls.py", + "source_sha256": "f626a2c14e0dcf198e1bb468cb4fda4513286364ff6055d2fba3ee71ebd7caf3", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/b_walls.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBWalls.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameBWalls.c", + "native_license": "MIT" + }, + { + "name": "pulse_stream", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "ca88f7a2258656bc8fff9aea9c07360e1d686a865b1cac2805c915f8108bb859", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pulse_stream.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/pulse_stream.py", + "source_sha256": "07612ca5e6f183aabfc18313a11468af887534c9e7916a9491a40b4e9d75cedf", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/pulse_stream.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePulseStream.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gamePulseStream.c", + "native_license": "MIT" + }, + { + "name": "private_eye", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "6d1d28fc0db4f2f6d4805525c54ffdb34341d6eb811cd094877b22df5d44ca25", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/private_eye.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/private_eye.py", + "source_sha256": "457af432ed0bfe570fa51ba7ded5a423a639fdcf49fca4353d40bbcf288cd3f7", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/private_eye.md", + "historical_source": "The five cases, Case 5 aggregation, city search, one-item rule, evidence/property requirements,\nquestionable characters, Model A controls, passages, obstacles, dagger drops, merit/demerit table,\nand booking sequence follow Activision's Atari 2600 *Private Eye* manual archived by AtariAge and\nDigital Press." + }, + { + "name": "seaquest", + "split": "test", + "family": "minatar_original", + "prompt_sha256": "32034921ebdb1b8e36cf32be3956cea8ce06dbc2ff679e1d7e478cb9ac68366b", + "upstream_source_url": "https://pypi.org/project/MinAtar/1.0.15/", + "upstream_repository": "https://github.com/kenjyoung/MinAtar", + "pinned_commit": null, + "pinned_version": "1.0.15", + "upstream_source_path": "minatar/environments/seaquest.py", + "source_sha256": "79b28b9798c520dc30441dd62d30eb1320e47751f08afd35112cbcbd6b49a685", + "upstream_license": "GPL-3.0", + "authors": [ + "Kenny Young", + "Tian Tian" + ] + }, + { + "name": "slime_stretcher", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "23d1e253f3e2846ab260c06c01f24505425a4433ef51920a5f0021f2dc604dc3", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/slime_stretcher.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/slime_stretcher.py", + "source_sha256": "cc0afbc50c2e5eaa273b5514d0b212c782cfa604317c91d5c757c089a2cb845f", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/slime_stretcher.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameSlimeStretcher.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameSlimeStretcher.c", + "native_license": "MIT" + }, + { + "name": "baroll", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "e30c0e9a1d7264c02a9c6606f680b5b42b2ed3f6ca2a63b72b3785ee88cac88b", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/baroll.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/baroll.py", + "source_sha256": "3a8e27d30743d195aa2120b0489f3b05691ca7925920b9cb50a55e3902e9e81a", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/baroll.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/baroll/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/baroll/main.js", + "native_license": "MIT" + }, + { + "name": "paku_paku", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "3012c578db081dafeb617122c89bf226466e807a8ee660de72e0807989a9893d", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/paku_paku.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/paku_paku.py", + "source_sha256": "4d78d16bb99141c6a7a2e13eb2f6a64d63ea74684ceeed912bea98583be308d7", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/paku_paku.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePakuPaku.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gamePakuPaku.c", + "native_license": "MIT" + }, + { + "name": "r_wheel", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "3785a658148a62744e4d295110fb5c167db33d3b8443a84bf6750b639a50e792", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/r_wheel.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/r_wheel.py", + "source_sha256": "87d6bdf4a8da6c5c4d478706790fee4a2eb43f88d18fbde80b7747be3a3c98bb", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/r_wheel.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/rwheel/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/rwheel/main.js", + "native_license": "MIT" + }, + { + "name": "alien", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "a3fe0b81e9af21258f45df392d1cca7a9e9a5965f4d66dfd299c12a5399950ef", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/alien.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/alien.py", + "source_sha256": "16ab6cd4ef4f175df0d60d28f58d449812fa1cdc88fe0ff5389758368ccaa16b", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/alien.md", + "historical_source": "The maze objective, eggs, three pursuing Aliens, three Pulsars, vulnerability window, collision\nloss, and egg-clear progression follow 20th Century Fox's Atari 2600 *Alien* manual as transcribed\nby AtariAge: https://atariage.com/manual_html_page.php?SoftwareID=815." + }, + { + "name": "flipbomb", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "4582450b48ffbcb3d90cfb18c4c34a8482e6b4f5d663c5478d78ac1347470e0a", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/flipbomb.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/flipbomb.py", + "source_sha256": "c07134f4e25297739e5e7bba3961c3242b0ca8b8f28404b1dac61a788a76f661", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/flipbomb.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/flipbomb/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/flipbomb/main.js", + "native_license": "MIT" + }, + { + "name": "totoge", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "8ca4acdc717d85a464be2afe5af6dc1bbd1da86fe97531d1b24dfb325c6e9da2", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/totoge.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/totoge.py", + "source_sha256": "934e6fea44c7a0843ed21e6e5330a289ffdbf1fc2e081f16b18073a13e873678", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/totoge.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/totoge/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/totoge/main.js", + "native_license": "MIT" + }, + { + "name": "asterix", + "split": "test", + "family": "minatar_original", + "prompt_sha256": "cb1e47ed72c25d5155f643fc248cb8692b81b448ea0deeeddc576b70b2c373f5", + "upstream_source_url": "https://pypi.org/project/MinAtar/1.0.15/", + "upstream_repository": "https://github.com/kenjyoung/MinAtar", + "pinned_commit": null, + "pinned_version": "1.0.15", + "upstream_source_path": "minatar/environments/asterix.py", + "source_sha256": "ce6a4a854bbf6104868644ef364b2bb90a61e0e27ac358f242bc7be91457026a", + "upstream_license": "GPL-3.0", + "authors": [ + "Kenny Young", + "Tian Tian" + ] + }, + { + "name": "slashes", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "05a7b732456f6b7329e7ec20eefaa742201edfa2437e753330dcd22da810d18a", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/slashes.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/slashes.py", + "source_sha256": "4d7b82121b1d332159d01f3a640c4be7ad4d1b9a6c011fd0ba587c51fed836bb", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/slashes.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/slashes/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/slashes/main.js", + "native_license": "MIT" + }, + { + "name": "geyser_hop", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "adc04691c337cce0f13f9c84217c650cf9a82423d5e900c06b507a691da9087a", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/geyser_hop.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/geyser_hop.py", + "source_sha256": "a7e06ea180f0159714412c78966904c42a2402d51094aebad926fb07d02a1191", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/geyser_hop.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameGeyserHop.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameGeyserHop.c", + "native_license": "MIT" + }, + { + "name": "clock_turret", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "750d8a635b42b69548f5fd1a9e7477bffee837b839d790651ef91e845edff567", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/clock_turret.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/clock_turret.py", + "source_sha256": "a6ae6b4f95ad609a67244ad235109763aa4bb0432758451d39696ac9ea103c70", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/clock_turret.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-11-games/blob/6fea4eefe2deaa42706051d96a04ec9e36104696/docs/clockturret/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-11-games", + "native_pinned_commit": "6fea4eefe2deaa42706051d96a04ec9e36104696", + "native_source_path": "docs/clockturret/main.js", + "native_license": "MIT" + }, + { + "name": "ring_blast", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "ea02ed453ed25264319da793a424888d25a05e9be29d9a2bbb078096eafbbb63", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/ring_blast.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/ring_blast.py", + "source_sha256": "3be8acd7a43340a0027e27216ca7c9351c581804273a4cdde13877318c1bad78", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/ring_blast.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameRingBlast.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameRingBlast.c", + "native_license": "MIT" + }, + { + "name": "hit_blow_up", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "669acd1e6864b0f444e4776e40de0b5fe76ed6f070e4bb71e48b1b21efcf02af", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/hit_blow_up.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/hit_blow_up.py", + "source_sha256": "86940d4698f23b924f0cb09309628927bddb4f9c97af0eb2493781ddcf84cd0a", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/hit_blow_up.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/hitblowup/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/hitblowup/main.js", + "native_license": "MIT" + }, + { + "name": "parking", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "364572c64b5bd7b1840ac94c4bb2e79acfb630c7587923af96ad98b683b35944", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/parking.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/parking.py", + "source_sha256": "652ad1621e541f004dfbe08c049b3c496ec6f6509e4fe817b2c3604948296c37", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/parking.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/parking/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/parking/main.js", + "native_license": "MIT" + }, + { + "name": "blade_dancer", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "1f253a333a1f0a24e953a3e5a2bd4815f9c762941d74b2b47af89946ee15e257", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/blade_dancer.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/blade_dancer.py", + "source_sha256": "0fa2b2f66f3f91c2cdf1e0b3669a206df27b29dc9466699b4b9db0a41072c775", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/blade_dancer.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBladeDancer.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameBladeDancer.c", + "native_license": "MIT" + }, + { + "name": "interspace", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "6b54ced659ec14ff5277f073a4f220f86210b88be7fc3910ebe191109f11a3ee", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/interspace.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/interspace.py", + "source_sha256": "7f63cbe4e6a766c468171e10406164d2e06f9659ef13ebfd676afe6b8820d08d", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/interspace.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/interspace/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/interspace/main.js", + "native_license": "MIT" + }, + { + "name": "ms_pac_man", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "c337ccc68faf34cbe73ffa3564af6ef231695fece620142cfb061d2b76ff72b4", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/ms_pac_man.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/ms_pac_man.py", + "source_sha256": "2df457145be75812d34660f0fbf51568b358504cef3030c2a5ac9920299a8b09", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/ms_pac_man.md", + "historical_source": "The maze-clearing objective, three lives, first-10,000 bonus life, four ghosts, dots, energizers,\nfruit sequence, frightened chain, tunnels, multiple mazes, and point values follow Atari's Atari\n2600 *Ms. Pac-Man* manual archived by AtariAge." + }, + { + "name": "growth", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "c096a1ed2cd951c1c4f986314d5a585d1934c8c862d350ae3c7796d169bddd20", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/growth.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/growth.py", + "source_sha256": "a35356686a350532a880918b71a7071f981282f5247cc28ad96a094eb4051f03", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/growth.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameGrowth.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameGrowth.c", + "native_license": "MIT" + }, + { + "name": "number_line", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "2c817fd641bd05c081ea390821eec2c1499c902d996557587f25ff368f903fad", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/number_line.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/number_line.py", + "source_sha256": "38efe05b1104e31dea2a31b47a3e91fa53392cdb9f601c8a20423020758983fe", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/number_line.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/numberline/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/numberline/main.js", + "native_license": "MIT" + }, + { + "name": "sight_on", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "aec2bbb69350ba48130b7b0171d5ec7b638b2d79ff1f783977f47b012155e87e", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/sight_on.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/sight_on.py", + "source_sha256": "83c8cbb3a47189525288c41f566eff893254ddfd4b993580ee32640f9f03fe30", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/sight_on.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/sighton/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/sighton/main.js", + "native_license": "MIT" + }, + { + "name": "pairs_drop", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "87bb90c7dd616ce5922c227b9a5e7b29106eadfd36efd457b7834d622b577ae1", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pairs_drop.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/pairs_drop.py", + "source_sha256": "28543df46953e07dea8cb03d789d2cc9cf3fe4045f83684064acbf5d4d1b3c9b", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/pairs_drop.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/pairsdrop/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/pairsdrop/main.js", + "native_license": "MIT" + }, + { + "name": "chopper_command", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "4e17282a3be50359fb8de584eb1d464aa51fca3cd98f292d477694f125d540b1", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/chopper_command.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/chopper_command.py", + "source_sha256": "0051b89e9db9902706e0384e80045dfaddb18457dd05a335774aa07b4d75f1eb", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/chopper_command.md", + "historical_source": "The convoy objective, scanner, 12-aircraft/12-truck waves, ten-wave progression, split missiles,\nscoring values, wave-bonus formula, ammunition, reserves, and extra-life rule follow Activision's\nAtari 2600 *Chopper Command* instruction manual archived by AtariAge." + }, + { + "name": "snake1", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "a2828a76f87ff8afa900c56cdd4a8d98e55fa071cd3bf825a33238d62b66a833", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/snake1.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/snake1.py", + "source_sha256": "419305f65780e35ab280ee2697ee03911df29edcdb93999bb7f9c83c84b5f9e3", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/snake1.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/snake1/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/snake1/main.js", + "native_license": "MIT" + }, + { + "name": "hopping_p", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "4c94a278f586ad402a93937bfe4ec4cafffb0f7b86063a7e064b3589904c258d", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/hopping_p.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/hopping_p.py", + "source_sha256": "6b82b81d4a5753dc864e3e679c3ecdef5b229e2b8da40cd3481de84924aec17d", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/hopping_p.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/hoppingp/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/hoppingp/main.js", + "native_license": "MIT" + }, + { + "name": "g_tail", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "c8309200611325106e49f7d4de876bbf624ac6fb1d5a4b98425f7bfb1746bbb1", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/g_tail.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/g_tail.py", + "source_sha256": "6bcd8d87eb551ea5589298d6dcc1d042cd7c08693ef6fb7e1cda41826492acdb", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/g_tail.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/gtail/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/gtail/main.js", + "native_license": "MIT" + }, + { + "name": "adventure", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "8c20f5c101fde02d79a7d66f1153b3eb5f8bf0ca0985e143cd0cace2f67caf47", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/adventure.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/adventure.py", + "source_sha256": "1b472bb9f3ee503bc39f9cd0b15257ee28e0ca53d73f119ac323bbe645f71703", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/adventure.md", + "historical_source": "The mechanics mapping follows Atari's instruction manual for the Atari 2600 version of\n*Adventure*." + }, + { + "name": "cast_n", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "8e3adf791d768fd1dc598c6603bf1d31af9844e5732cc013cb00adc7bf2d0404", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/cast_n.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/cast_n.py", + "source_sha256": "b4494fde2fd27504b476a04c8f5e5073a56da7176b07955963543c6256b50c47", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/cast_n.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameCastN.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameCastN.c", + "native_license": "MIT" + }, + { + "name": "number_ball", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "955320c153bd0b32570ac976b5dc2656eb4394d299744415f8e251cfb5b98604", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/number_ball.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/number_ball.py", + "source_sha256": "b3177b625ba7cf1a20b7465e745005a482eb2fc66f721a6f6d9fd58b25ad49cf", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/number_ball.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/numberball/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/numberball/main.js", + "native_license": "MIT" + }, + { + "name": "blast_buoy", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "3e4f29dbd0215b43ea53096df1bfc24ba9812438ccaabadf9370b8c89fbe2ef7", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/blast_buoy.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/blast_buoy.py", + "source_sha256": "a2aa2ed9b95b347697f9897d4b96c15a8a0d5077d198e5c8a01772a7f2d13c9f", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/blast_buoy.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBlastBuoy.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameBlastBuoy.c", + "native_license": "MIT" + }, + { + "name": "thrust_lr", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "fa6795e558864e4b6c8bc018505641749e53c6a15190e8246294e2187b0f761d", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/thrust_lr.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/thrust_lr.py", + "source_sha256": "37da81dfd992b69ed750705b52e3a776cc8a30e67c95ab0ecfb838a29363b937", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/thrust_lr.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/thrustlr/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/thrustlr/main.js", + "native_license": "MIT" + }, + { + "name": "lie_down", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "c45cc581db2a38c268a243fd2fe631560c16dd64c272367e6e20eaea1cce2f5c", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/lie_down.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/lie_down.py", + "source_sha256": "9aa91e9d65c325f0285974530066f72c829d001e7838192dc7e7baca3eca4731", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/lie_down.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/liedown/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/liedown/main.js", + "native_license": "MIT" + }, + { + "name": "s_shake", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "0ba711ad6690521c44db6ebf31240b6b52e8b715b92bea5ae9e9a4090a815a62", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/s_shake.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/s_shake.py", + "source_sha256": "be7a84dadfe5fcd695921466ac4b68f4c823ae04bc01e8cabca4c7d1336c3e3f", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/s_shake.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/sshake/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/sshake/main.js", + "native_license": "MIT" + }, + { + "name": "stormveil", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "04bf4884448a0b0995776735180c1b83f8f0ecd04902e7b878a12e36aa8171ea", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/stormveil.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/stormveil.py", + "source_sha256": "0b13ba30a074c606cd0c4cc7c9cec35ecfa31ccea60c033fa4b9e79cc11a83ed", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/stormveil.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameStormveil.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameStormveil.c", + "native_license": "MIT" + }, + { + "name": "lift_up", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "25385da4ec136b38200e7356c94b1ee026e389a1c42abcf42a22513edd1d242d", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/lift_up.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/lift_up.py", + "source_sha256": "5f691ba1983521dba33d6e45da818a5444cf2add6cb54fc98b524ffd5c23f14c", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/lift_up.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/liftup/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/liftup/main.js", + "native_license": "MIT" + }, + { + "name": "tongue_hunter", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "e9a8a791c6908513d8cc9133d1bef5a2c4cc55f6a4d243f640949b2e378e80b5", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tongue_hunter.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/tongue_hunter.py", + "source_sha256": "943d358a2aa9484dd0ce63cf65415c29899507b5990d8c9f2a4fde3a568125e0", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/tongue_hunter.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameTongueHunter.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameTongueHunter.c", + "native_license": "MIT" + }, + { + "name": "forfour", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "6c112b5f25e1b9211178ecf0dddd874f52ae082e2a599b8eb35a35f1cdaa9571", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/forfour.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/forfour.py", + "source_sha256": "e250e9813dca50134b747b8de1fc3e66061e4763955e89caddc0e71b80156aac", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/forfour.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/forfour/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/forfour/main.js", + "native_license": "MIT" + }, + { + "name": "sky_raftsman", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "6dda1955ddf2fd60c9322f62a0390b9a1df9487f983ed96c9751c64e23f1a4f8", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/sky_raftsman.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/sky_raftsman.py", + "source_sha256": "2abe0585a310fb1fdc57c61e242dc4130b397e89344bddc895985fd7656efea4", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/sky_raftsman.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameSkyRaftsman.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameSkyRaftsman.c", + "native_license": "MIT" + }, + { + "name": "river_raid", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "649328543dacb05f7c545c19afaeb7b9d7a47f72e781f9237c63914eb12ec068", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/river_raid.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/river_raid.py", + "source_sha256": "398e6d78b08b3a87556dc70a994003f7a96fa2cc936f8f3eb6de745ac1285dc3", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/river_raid.md", + "historical_source": "The mission, target values, river sections, bridges, fuel behavior, throttle/refueling tradeoff,\ntraffic, controls, three reserve jets, and 10,000-point reinforcements follow Activision's Atari\n2600 *River Raid* manual archived by AtariAge." + }, + { + "name": "t_laser", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "9869200300aa1246b095af0766a73c5b59da5276e0d6c445808a5ca56ba2817e", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/t_laser.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/t_laser.py", + "source_sha256": "610c34f61866b949efa9b05d6b2abaa4c5cec0fe6ea340d1f6b4a5b9dab263da", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/t_laser.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/tlaser/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/tlaser/main.js", + "native_license": "MIT" + }, + { + "name": "cue_crumb", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "56a6e3970c8f0e024568bba4286442f39e0735bff30ec3c256d86350c95667d5", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/cue_crumb.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/cue_crumb.py", + "source_sha256": "61a3deae709366b21e3c88fee88feb10bbcd8b1626b93a344c5f1c7483f6e719", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/cue_crumb.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameCueCrumb.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameCueCrumb.c", + "native_license": "MIT" + }, + { + "name": "marble_bounce", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "19d4d68d481eb31bd2444381545b5c3ebeaf802f0e4eb4d823b0e9e9ce7d00b6", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/marble_bounce.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/marble_bounce.py", + "source_sha256": "1b2082913c6ac50733aebd4131cac25e1cca5bb0c1f3fa26ad2d623db23ae674", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/marble_bounce.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameMarbleBounce.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameMarbleBounce.c", + "native_license": "MIT" + }, + { + "name": "sky_golf", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "9ff113ab3059c2c55266bdf7f13f23549bf80df65394ea097f5515adad6c0152", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/sky_golf.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/sky_golf.py", + "source_sha256": "bec9e8ee4f87b94e1b8aab1c1f16cb16a737ce1e3840eadc278a50e7653aa70a", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/sky_golf.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameSkyGolf.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameSkyGolf.c", + "native_license": "MIT" + }, + { + "name": "elastic_hero", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "7245f7916f74d3444e9e7f01e9f44a8c701298ed3b9d40af6647515f2490dea1", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/elastic_hero.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/elastic_hero.py", + "source_sha256": "682ee027da22d0f4db49e5cdb524226cb3d593a8c32e68f877ef97523e0e733e", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/elastic_hero.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameElasticHero.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameElasticHero.c", + "native_license": "MIT" + }, + { + "name": "tarutobi", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "7b5f3208808be9e221a2e835b9450cc28bea760d435e48b652ebf784607bc748", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tarutobi.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/tarutobi.py", + "source_sha256": "ab24ecefe939143b28a500000da5e5107445858951d4417c431a783af3ef300b", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/tarutobi.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/tarutobi/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/tarutobi/main.js", + "native_license": "MIT" + }, + { + "name": "qbert", + "split": "train", + "family": "atari_synthetic", + "prompt_sha256": "d37a433e2dc63eadb92cff7b584d7c7426303a59db8025fdbebcc09a3cc9ffd1", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/qbert.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/qbert.py", + "source_sha256": "0e54bda7c39644f1cba81045aacd014650ccfff7d7868b521ca7480028b93963", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/qbert.md", + "historical_source": "The pyramid objective, controls, five-by-four round structure, four lives, five color rules,\ncreatures, discs, bonus-life schedule, 25/300/100/500 values, and 3,100 round bonus follow the\nAtari 2600 *Q*bert* manual archived by AtariAge." + }, + { + "name": "wiper", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "18acc3c428be3e60f667b72e3106c42fe2f8a9a56d71bc4f92183d798a0902f1", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/wiper.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/wiper.py", + "source_sha256": "dbff2deee03524e9289704e150d5bdb146e85817521600acab262b906a794e2e", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/wiper.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/wiper/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/wiper/main.js", + "native_license": "MIT" + }, + { + "name": "pump_press", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "2bca76d87b1fcefe62a33e11b037bdb26cbecaca7f484459782a5fae04b1ec0d", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pump_press.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/pump_press.py", + "source_sha256": "ec4b746cb96323b1a7ce809d1e55c2ddf274f0898eed6cbbbba0864ce2922b74", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/pump_press.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/pumppress/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/pumppress/main.js", + "native_license": "MIT" + }, + { + "name": "barge_hop", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "87b49e3cef659d1f76a1720f0a382aed7385ab900f716441d24076d9644edc4e", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/barge_hop.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/barge_hop.py", + "source_sha256": "68ca707ca199e20fb9dd7de003cc6bbff4d14a597ac7f359911e6247f0f379a4", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/barge_hop.md", + "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBargeHop.c", + "native_repository": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl", + "native_pinned_commit": "04bc2c4cfc2853628eda25a46190bb7ac6fe216a", + "native_source_path": "src/games/gameBargeHop.c", + "native_license": "MIT" + }, + { + "name": "i_slash", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "10383eff9a8e67acf0599d3cd290fa2094b0784ad269ad8e636d490d1e2765a6", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/i_slash.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/i_slash.py", + "source_sha256": "c54e4b3796da7fda69d4ab862e3ac862add53c7a453163a0a54c4d733a9f2f69", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/i_slash.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/islash/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/islash/main.js", + "native_license": "MIT" + }, + { + "name": "smoke_g", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "a2e1b8b5cf302fc2f33e4e6217c43352c053a8a1cb8db17e402111cb8b997ae9", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/smoke_g.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/smoke_g.py", + "source_sha256": "d863fe6b9b5da0b9846ee34826342b0993b0c67efaaa877aa3365a70bc24fa55", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/smoke_g.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/smokeg/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/smokeg/main.js", + "native_license": "MIT" + }, + { + "name": "d_laser", + "split": "train", + "family": "crisp_synthetic", + "prompt_sha256": "79146849e1e210063d1bff81301268d03fc3794a9fa9bc62626fcea092094c80", + "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/d_laser.py", + "upstream_repository": "https://github.com/Trajectorylabs/minatar-synth", + "pinned_commit": "4038830175c4201ca10e004ed4441985f2acddf2", + "upstream_source_path": "minatar_synth/games/d_laser.py", + "source_sha256": "7d4f22ae9a602fb5e9de612367eaf063a372b47de2a481894f38a87b80f02ecb", + "upstream_license": "undeclared", + "documentation_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/docs/games/d_laser.md", + "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/dlaser/main.js", + "native_repository": "https://github.com/abagames/crisp-game-lib-games", + "native_pinned_commit": "cfb39d2f988feb5918eb83697145b5a35adabf58", + "native_source_path": "docs/dlaser/main.js", + "native_license": "MIT" + } + ] +} diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md new file mode 100644 index 0000000000000000000000000000000000000000..65436e46eb31e7566ad7c4c1cdcd39bf9a7131d9 --- /dev/null +++ b/THIRD_PARTY_NOTICES.md @@ -0,0 +1,76 @@ +# Sources and credits + +WeightProgramBench packages the existing MinAtar Synth v4 task corpus without +changing its game implementations, prompts, parser, or scoring contract. Its +322 tasks comprise 51 Atari-style synthetic training games, 266 Crisp-inspired +synthetic training games, and five original MinAtar held-out games. These are +compact Python adaptations, not Atari ROM emulation or native Crisp gameplay. + +[`TASK_ORIGINS.json`](TASK_ORIGINS.json) records every task's family, source, +revision or package version, source digest, and prompt digest. It also retains +the exact pinned native-source link from each Crisp conversion's documentation. + +## MinAtar Synth implementations + +Credit Trajectory Labs, Jerry Chan, and the contributors to +[MinAtar Synth](https://github.com/Trajectorylabs/minatar-synth/tree/4038830175c4201ca10e004ed4441985f2acddf2). +The 317 Python training environments are pinned to commit +`4038830175c4201ca10e004ed4441985f2acddf2`. The five original MinAtar environments +are a separate dependency. The extra `pong.py` in the source repository is not +part of this benchmark's task roster. + +The pinned MinAtar Synth repository does not declare a license. No blanket license +is asserted for the converted implementations; the notices below describe the +respective upstream components and do not supply that missing declaration. + +The 51 Atari-style conversions document mechanics and deliberate simplifications +from historical Atari 2600 games and their manuals. Their documentation's +historical-source notes are retained per task in `TASK_ORIGINS.json`. They use +NumPy and the Python standard library, not Atari ROMs or the original MinAtar +game modules. This describes their implementation and provenance, not a +conclusion about the license of the converted code. + +## Crisp game designs and source + +Credit **ABA Games** and the authors and contributors to its Crisp games, and +**Joyrider3774** and contributors for the portable SDL/C versions. The 266 +conversions cite three pinned source collections: + +| Source | Conversions | Pinned revision | +| --- | ---: | --- | +| [crisp-game-lib-games](https://github.com/abagames/crisp-game-lib-games) | 136 | `cfb39d2f988feb5918eb83697145b5a35adabf58` | +| [crisp-game-lib-11-games](https://github.com/abagames/crisp-game-lib-11-games) | 8 | `6fea4eefe2deaa42706051d96a04ec9e36104696` | +| [crisp-game-lib-portable-sdl](https://github.com/joyrider3774/crisp-game-lib-portable-sdl) | 122 | `04bc2c4cfc2853628eda25a46190bb7ac6fe216a` | + +These source collections carry MIT licenses, Copyright 2021 or 2022 ABA Games. +Their exact license texts and source links are retained in +[`LICENSE-Crisp`](runtime/LICENSE-Crisp). Keep the applicable copyright and permission +notices with redistributed copies or substantial portions of those sources. +These source licenses are distinct from the undeclared license of the converted +MinAtar Synth implementation. + +## Original MinAtar games + +Credit **Kenny Young and Tian Tian**, authors of +[MinAtar](https://github.com/kenjyoung/MinAtar). The five held-out tasks are +`asterix`, `breakout`, `freeway`, `seaquest`, and `space_invaders`, using +**MinAtar 1.0.15**. Their original source is included in their task prompts with +its author headers. The package version, source-file paths, and source digests +are recorded rather than asserting an unverified Git release commit. + +MinAtar is licensed under **GNU GPL version 3**. Its complete license text is +included as [`LICENSE-MinAtar`](runtime/LICENSE-MinAtar); preserve the source notices and +applicable GPL terms when distributing this material. This notice does not +relicense MinAtar under the cookbook's license. + +## Weight-space programming experiment + +Credit **Rikiya Takehi, Jayden Teoh, Alex Zhang, and Omar Khattab** for the +[weight-space programming experiments](https://rikiyat.github.io/blog/weight-space-programming/), +especially [Experiment 5: writing policy weights from scratch](https://github.com/RikiyaT/lm_understand-logs/tree/4d09ba6d6a7e891dd8063974dfe81b3d78e3494f/exp5_write_from_scratch). +The benchmark follows that one-response, no-tools weight-programming setup. +The experiment's prompt/log materials are attributed under +[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), separately from the +GPL-licensed MinAtar source embedded in those prompts. The expanded game corpus +and model-training experiments are subsequent adaptations, not results from +the original experiment. diff --git a/data/test.jsonl b/data/test.jsonl new file mode 100644 index 0000000000000000000000000000000000000000..9c1521fb64c1f8f2ff2a7b23dfde8c72712c55af --- /dev/null +++ b/data/test.jsonl @@ -0,0 +1,5 @@ +{"name": "space_invaders", "split": "test", "game": "space_invaders", "source": "original", "prompt": "Write from scratch the weights of a policy network that plays Space Invaders as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nMove the cannon, shoot alien waves, and avoid aliens and enemy bullets.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact MinAtar 1.0.15 source (`minatar/environments/space_invaders.py`):\n```python\n################################################################################################################\n# Authors: #\n# Kenny Young (kjyoung@ualberta.ca) #\n# Tian Tian (ttian@ualberta.ca) #\n################################################################################################################\nimport numpy as np\n\n\n#####################################################################################################################\n# Constants\n#\n#####################################################################################################################\nshot_cool_down = 5\nenemy_move_interval = 12\nenemy_shot_interval = 10\n\n\n#####################################################################################################################\n# Env\n#\n# The player controls a cannon at the bottom of the screen and can shoot bullets upward at a cluster of aliens above.\n# The aliens move across the screen until one of them hits the edge, at which point they all move down and switch\n# directions. The current alien direction is indicated by 2 channels (one for left and one for right) one of which is\n# active at the location of each alien. A reward of +1 is given each time an alien is shot, and that alien is also\n# removed. The aliens will also shoot bullets back at the player. When few aliens are left, alien speed will begin to\n# increase. When only one alien is left, it will move at one cell per frame. When a wave of aliens is fully cleared a\n# new one will spawn which moves at a slightly faster speed than the last. Termination occurs when an alien or bullet\n# hits the player.\n#\n#####################################################################################################################\nclass Env:\n def __init__(self, ramping=True):\n self.channels ={\n 'cannon':0,\n 'alien':1,\n 'alien_left':2,\n 'alien_right':3,\n 'friendly_bullet':4,\n 'enemy_bullet':5\n }\n self.action_map = ['n','l','u','r','d','f']\n self.ramping = ramping\n self.random = np.random.RandomState()\n self.reset()\n\n # Update environment according to agent action\n def act(self, a):\n r = 0\n if(self.terminal):\n return r, self.terminal\n\n a = self.action_map[a]\n\n # Resolve player action\n if(a=='f' and self.shot_timer == 0):\n self.f_bullet_map[9,self.pos]=1\n self.shot_timer = shot_cool_down\n elif(a=='l'):\n self.pos = max(0, self.pos-1)\n elif(a=='r'):\n self.pos = min(9, self.pos+1)\n\n # Update Friendly Bullets\n self.f_bullet_map = np.roll(self.f_bullet_map, -1, axis=0)\n self.f_bullet_map[9,:] = 0\n\n # Update Enemy Bullets\n self.e_bullet_map = np.roll(self.e_bullet_map, 1, axis=0)\n self.e_bullet_map[0,:] = 0\n if(self.e_bullet_map[9,self.pos]):\n self.terminal = True\n\n # Update aliens\n if(self.alien_map[9,self.pos]):\n self.terminal = True\n if(self.alien_move_timer==0):\n self.alien_move_timer = min(np.count_nonzero(self.alien_map),self.enemy_move_interval)\n if((np.sum(self.alien_map[:,0])>0 and self.alien_dir<0) or (np.sum(self.alien_map[:,9])>0 and self.alien_dir>0)):\n self.alien_dir = -self.alien_dir\n if(np.sum(self.alien_map[9,:])>0):\n self.terminal = True\n self.alien_map = np.roll(self.alien_map, 1, axis=0)\n else:\n self.alien_map = np.roll(self.alien_map, self.alien_dir, axis=1)\n if(self.alien_map[9,self.pos]):\n self.terminal = True\n if(self.alien_shot_timer==0):\n self.alien_shot_timer = enemy_shot_interval\n nearest_alien = self._nearest_alien(self.pos)\n self.e_bullet_map[nearest_alien[0], nearest_alien[1]] = 1\n\n kill_locations = np.logical_and(self.alien_map,self.alien_map==self.f_bullet_map)\n\n r+=np.sum(kill_locations)\n self.alien_map[kill_locations] = self.f_bullet_map[kill_locations] = 0\n\n\n # Update various timers\n self.shot_timer -= self.shot_timer>0\n self.alien_move_timer-=1\n self.alien_shot_timer-=1\n if(np.count_nonzero(self.alien_map)==0):\n if(self.enemy_move_interval>6 and self.ramping):\n self.enemy_move_interval-=1\n self.ramp_index+=1\n self.alien_map[0:4,2:8] = 1\n return r, self.terminal\n\n # Find the alien closest to player in manhattan distance, currently used to decide which alien shoots\n def _nearest_alien(self, pos):\n search_order = [i for i in range(10)]\n search_order.sort(key=lambda x: abs(x-pos))\n for i in search_order:\n if(np.sum(self.alien_map[:,i])>0):\n return [np.max(np.where(self.alien_map[:,i]==1)),i]\n return None\n\n # Query the current level of the difficulty ramp, could be used as additional input to agent for example\n def difficulty_ramp(self):\n return self.ramp_index\n\n # Process the game-state into the 10x10xn state provided to the agent and return\n def state(self):\n state = np.zeros((10,10,len(self.channels)),dtype=bool)\n state[9,self.pos,self.channels['cannon']] = 1\n state[:,:, self.channels['alien']] = self.alien_map\n if(self.alien_dir<0):\n state[:,:, self.channels['alien_left']] = self.alien_map\n else:\n state[:,:, self.channels['alien_right']] = self.alien_map\n state[:,:, self.channels['friendly_bullet']] = self.f_bullet_map\n state[:,:, self.channels['enemy_bullet']] = self.e_bullet_map\n return state\n\n # Reset to start state for new episode\n def reset(self):\n self.pos = 5\n self.f_bullet_map = np.zeros((10,10))\n self.e_bullet_map = np.zeros((10,10))\n self.alien_map = np.zeros((10,10))\n self.alien_map[0:4,2:8] = 1\n self.alien_dir = -1\n self.enemy_move_interval = enemy_move_interval\n self.alien_move_timer = self.enemy_move_interval\n self.alien_shot_timer = enemy_shot_interval\n self.ramp_index = 0\n self.shot_timer = 0\n self.terminal = False\n\n # Dimensionality of the game-state (10x10xn)\n def state_shape(self):\n return [10,10,len(self.channels)]\n\n # Subset of actions that actually have a unique impact in this environment\n def minimal_action_set(self):\n minimal_actions = ['n','l','r','f']\n return [self.action_map.index(x) for x in minimal_actions]\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: player=cannon; danger=alien|enemy_bullet; reward=alien; projectile=friendly_bullet; trail=alien_left|alien_right; gauge=empty.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 185, "family": "minatar_original", "upstream_source_url": "https://pypi.org/project/MinAtar/1.0.15/", "upstream_revision": "MinAtar==1.0.15", "native_source_url": null} +{"name": "breakout", "split": "test", "game": "breakout", "source": "original", "prompt": "Write from scratch the weights of a policy network that plays Breakout as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nMove the bottom-row paddle left or right to bounce the diagonal ball and break bricks.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact MinAtar 1.0.15 source (`minatar/environments/breakout.py`):\n```python\n################################################################################################################\n# Authors: #\n# Kenny Young (kjyoung@ualberta.ca) #\n# Tian Tian (ttian@ualberta.ca) #\n################################################################################################################\nimport numpy as np\n\n\n#####################################################################################################################\n# Env\n#\n# The player controls a paddle on the bottom of the screen and must bounce a ball tobreak 3 rows of bricks along the\n# top of the screen. A reward of +1 is given for each brick broken by the ball. When all bricks are cleared another 3\n# rows are added. The ball travels only along diagonals, when it hits the paddle it is bounced either to the left or\n# right depending on the side of the paddle hit, when it hits a wall or brick it is reflected. Termination occurs when\n# the ball hits the bottom of the screen. The balls direction is indicated by a trail channel.\n#\n#####################################################################################################################\nclass Env:\n def __init__(self, ramping=None):\n self.channels ={\n 'paddle':0,\n 'ball':1,\n 'trail':2,\n 'brick':3,\n }\n self.action_map = ['n','l','u','r','d','f']\n self.random = np.random.RandomState()\n self.reset()\n\n # Update environment according to agent action\n def act(self, a):\n r = 0\n if(self.terminal):\n return r, self.terminal\n\n a = self.action_map[a]\n\n # Resolve player action\n if(a=='l'):\n self.pos = max(0, self.pos-1)\n elif(a=='r'):\n self.pos = min(9,self.pos+1)\n\n # Update ball position\n self.last_x = self.ball_x\n self.last_y = self.ball_y\n if(self.ball_dir == 0):\n new_x = self.ball_x-1\n new_y = self.ball_y-1\n elif(self.ball_dir == 1):\n new_x = self.ball_x+1\n new_y = self.ball_y-1\n elif(self.ball_dir == 2):\n new_x = self.ball_x+1\n new_y = self.ball_y+1\n elif(self.ball_dir == 3):\n new_x = self.ball_x-1\n new_y = self.ball_y+1\n\n strike_toggle = False\n if(new_x<0 or new_x>9):\n if(new_x<0):\n new_x = 0\n if(new_x>9):\n new_x=9\n self.ball_dir=[1,0,3,2][self.ball_dir]\n if(new_y<0):\n new_y = 0\n self.ball_dir=[3,2,1,0][self.ball_dir]\n elif(self.brick_map[new_y,new_x]==1):\n strike_toggle = True\n if(not self.strike):\n r+=1\n self.strike = True\n self.brick_map[new_y,new_x]=0\n new_y = self.last_y\n self.ball_dir=[3,2,1,0][self.ball_dir]\n elif(new_y == 9):\n if(np.count_nonzero(self.brick_map)==0):\n self.brick_map[1:4,:] = 1\n if(self.ball_x == self.pos):\n self.ball_dir=[3,2,1,0][self.ball_dir]\n new_y = self.last_y\n elif(new_x == self.pos):\n self.ball_dir=[2,3,0,1][self.ball_dir]\n new_y = self.last_y\n else:\n self.terminal = True\n\n if(not strike_toggle):\n self.strike = False\n\n self.ball_x = new_x\n self.ball_y = new_y\n return r, self.terminal\n\n # Query the current level of the difficulty ramp, difficulty does not ramp in this game, so return None\n def difficulty_ramp(self):\n return None\n\n # Process the game-state into the 10x10xn state provided to the agent and return\n def state(self):\n state = np.zeros((10,10,len(self.channels)),dtype=bool)\n state[self.ball_y,self.ball_x,self.channels['ball']] = 1\n state[9,self.pos, self.channels['paddle']] = 1\n state[self.last_y,self.last_x,self.channels['trail']] = 1\n state[:,:,self.channels['brick']] = self.brick_map\n return state\n\n # Reset to start state for new episode\n def reset(self):\n self.ball_y = 3\n ball_start = self.random.randint(2)\n self.ball_x, self.ball_dir = [(0,2),(9,3)][ball_start]\n self.pos = 4\n self.brick_map = np.zeros((10,10))\n self.brick_map[1:4,:] = 1\n self.strike = False\n self.last_x = self.ball_x\n self.last_y = self.ball_y\n self.terminal = False\n\n # Dimensionality of the game-state (10x10xn)\n def state_shape(self):\n return [10,10,len(self.channels)]\n\n # Subset of actions that actually have a unique impact in this environment\n def minimal_action_set(self):\n minimal_actions = ['n','l','r']\n return [self.action_map.index(x) for x in minimal_actions]\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: player=paddle; danger=empty; reward=brick; projectile=ball; trail=trail; gauge=empty.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 241, "family": "minatar_original", "upstream_source_url": "https://pypi.org/project/MinAtar/1.0.15/", "upstream_revision": "MinAtar==1.0.15", "native_source_url": null} +{"name": "freeway", "split": "test", "game": "freeway", "source": "original", "prompt": "Write from scratch the weights of a policy network that plays Freeway as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nMove the chicken upward through traffic and score each time it reaches the top.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact MinAtar 1.0.15 source (`minatar/environments/freeway.py`):\n```python\n################################################################################################################\n# Authors: #\n# Kenny Young (kjyoung@ualberta.ca) #\n# Tian Tian (ttian@ualberta.ca) #\n################################################################################################################\nimport numpy as np\n\n\n#####################################################################################################################\n# Constants\n#\n#####################################################################################################################\nplayer_speed = 3\ntime_limit = 2500\n\n\n#####################################################################################################################\n# Env\n#\n# The player begins at the bottom of the screen and motion is restricted to traveling up and down. Player speed is\n# also restricted such that the player can only move every 3 frames. A reward of +1 is given when the player reaches\n# the top of the screen, at which point the player is returned to the bottom. Cars travel horizontally on the screen\n# and teleport to the other side when the edge is reached. When hit by a car, the player is returned to the bottom of\n# the screen. Car direction and speed is indicated by 5 trail channels, the location of the trail gives direction\n# while the specific channel indicates how frequently the car moves (from once every frame to once every 5 frames).\n# Each time the player successfully reaches the top of the screen, the car speeds are randomized. Termination occurs\n# after 2500 frames have elapsed.\n#\n#####################################################################################################################\nclass Env:\n def __init__(self, ramping=None):\n self.channels ={\n 'chicken':0,\n 'car':1,\n 'speed1':2,\n 'speed2':3,\n 'speed3':4,\n 'speed4':5,\n 'speed5':6,\n }\n self.action_map = ['n','l','u','r','d','f']\n self.random = np.random.RandomState()\n self.reset()\n\n # Update environment according to agent action\n def act(self, a):\n r = 0\n if(self.terminal):\n return r, self.terminal\n\n a = self.action_map[a]\n\n if(a=='u' and self.move_timer==0):\n self.move_timer = player_speed\n self.pos = max(0, self.pos-1)\n elif(a=='d' and self.move_timer==0):\n self.move_timer = player_speed\n self.pos = min(9, self.pos+1)\n\n # Win condition\n if(self.pos==0):\n r+=1\n self._randomize_cars(initialize=False)\n self.pos = 9\n\n # Update cars\n for car in self.cars:\n if(car[0:2]==[4,self.pos]):\n self.pos = 9\n if(car[2]==0):\n car[2]=abs(car[3])\n car[0]+=1 if car[3]>0 else -1\n if(car[0]<0):\n car[0]=9\n elif(car[0]>9):\n car[0]=0\n if(car[0:2]==[4,self.pos]):\n self.pos = 9\n else:\n car[2]-=1\n\n # Update various timers\n self.move_timer-=self.move_timer>0\n self.terminate_timer-=1\n if(self.terminate_timer<0):\n self.terminal = True\n return r, self.terminal\n\n # Query the current level of the difficulty ramp, difficulty does not ramp in this game, so return None\n def difficulty_ramp(self):\n return None\n\n # Process the game-state into the 10x10xn state provided to the agent and return\n def state(self):\n state = np.zeros((10,10,len(self.channels)),dtype=bool)\n state[self.pos,4,self.channels['chicken']] = 1\n for car in self.cars:\n state[car[1],car[0], self.channels['car']] = 1\n back_x = car[0]-1 if car[3]>0 else car[0]+1\n if(back_x<0):\n back_x=9\n elif(back_x>9):\n back_x=0\n if(abs(car[3])==1):\n trail = self.channels['speed1']\n elif(abs(car[3])==2):\n trail = self.channels['speed2']\n elif(abs(car[3])==3):\n trail = self.channels['speed3']\n elif(abs(car[3])==4):\n trail = self.channels['speed4']\n elif(abs(car[3])==5):\n trail = self.channels['speed5']\n state[car[1],back_x, trail] = 1\n return state\n\n # Randomize car speeds and directions, also reset their position if initialize=True\n def _randomize_cars(self, initialize=False):\n speeds = self.random.randint(1,6,8)\n directions = np.sign(self.random.rand(8) - 0.5).astype(int)\n speeds*=directions\n if(initialize):\n self.cars = []\n for i in range(8):\n self.cars+=[[0,i+1,abs(speeds[i]),speeds[i]]]\n else:\n for i in range(8):\n self.cars[i][2:4]=[abs(speeds[i]),speeds[i]]\n\n # Reset to start state for new episode\n def reset(self):\n self._randomize_cars(initialize=True)\n self.pos = 9\n self.move_timer = player_speed\n self.terminate_timer = time_limit\n self.terminal = False\n\n # Dimensionality of the game-state (10x10xn)\n def state_shape(self):\n return [10,10,len(self.channels)]\n\n # Subset of actions that actually have a unique impact in this environment\n def minimal_action_set(self):\n minimal_actions = ['n','u','d']\n return [self.action_map.index(x) for x in minimal_actions]\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: player=chicken; danger=car; reward=empty; projectile=empty; trail=speed1|speed2|speed3|speed4|speed5; gauge=empty.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 251, "family": "minatar_original", "upstream_source_url": "https://pypi.org/project/MinAtar/1.0.15/", "upstream_revision": "MinAtar==1.0.15", "native_source_url": null} +{"name": "seaquest", "split": "test", "game": "seaquest", "source": "original", "prompt": "Write from scratch the weights of a policy network that plays Seaquest as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nControl the submarine, shoot enemies, rescue divers, surface with divers, and manage oxygen.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact MinAtar 1.0.15 source (`minatar/environments/seaquest.py`):\n```python\n################################################################################################################\n# Authors: #\n# Kenny Young (kjyoung@ualberta.ca) #\n# Tian Tian (ttian@ualberta.ca) #\n################################################################################################################\nimport numpy as np\n\n\n#####################################################################################################################\n# Constants\n#\n#####################################################################################################################\nramp_interval = 100\nmax_oxygen = 200\ninit_spawn_speed = 20\ndiver_spawn_speed = 30\ninit_move_interval = 5\nshot_cool_down = 5\nenemy_shot_interval = 10\nenemy_move_interval = 5\ndiver_move_interval = 5\n\n\n#####################################################################################################################\n# Env\n#\n# The player controls a submarine consisting of two cells, front and back, to allow direction to be determined. The\n# player can also fire bullets from the front of the submarine. Enemies consist of submarines and fish, distinguished\n# by the fact that submarines shoot bullets and fish do not. A reward of +1 is given each time an enemy is struck by\n# one of the player's bullets, at which point the enemy is also removed. There are also divers which the player can\n# move onto to pick up, doing so increments a bar indicated by another channel along the bottom of the screen. The\n# player also has a limited supply of oxygen indicated by another bar in another channel. Oxygen degrades over time,\n# and is replenished whenever the player moves to the top of the screen as long as the player has at least one rescued\n# diver on board. The player can carry a maximum of 6 divers. When surfacing with less than 6, one diver is removed.\n# When surfacing with 6, all divers are removed and a reward is given for each active cell in the oxygen bar. Each\n# time the player surfaces the difficulty is increased by increasing the spawn rate and movement speed of enemies.\n# Termination occurs when the player is hit by an enemy fish, sub or bullet; or when oxygen reached 0; or when the\n# player attempts to surface with no rescued divers. Enemy and diver directions are indicated by a trail channel\n# active in their previous location to reduce partial observability.\n#\n#####################################################################################################################\nclass Env:\n def __init__(self, ramping=True):\n self.channels ={\n 'sub_front':0,\n 'sub_back':1,\n 'friendly_bullet':2,\n 'trail':3,\n 'enemy_bullet':4,\n 'enemy_fish':5,\n 'enemy_sub':6,\n 'oxygen_guage':7,\n 'diver_guage':8,\n 'diver':9\n }\n self.action_map = ['n','l','u','r','d','f']\n self.ramping = ramping\n self.random = np.random.RandomState()\n self.reset()\n\n # Update environment according to agent action\n def act(self, a):\n r = 0\n if(self.terminal):\n return r, self.terminal\n\n a = self.action_map[a]\n\n # Spawn enemy if timer is up\n if(self.e_spawn_timer==0):\n self._spawn_enemy()\n self.e_spawn_timer = self.e_spawn_speed\n\n if(self.d_spawn_timer==0):\n self._spawn_diver()\n self.d_spawn_timer = diver_spawn_speed\n\n # Resolve player action\n if(a=='f' and self.shot_timer == 0):\n self.f_bullets+=[[self.sub_x, self.sub_y, self.sub_or]]\n self.shot_timer = shot_cool_down\n elif(a=='l'):\n self.sub_x = max(0, self.sub_x-1)\n self.sub_or = False\n elif(a=='r'):\n self.sub_x = min(9, self.sub_x+1)\n self.sub_or = True\n elif(a=='u'):\n self.sub_y = max(0, self.sub_y-1)\n elif(a=='d'):\n self.sub_y = min(8, self.sub_y+1)\n\n # Update friendly Bullets\n for bullet in reversed(self.f_bullets):\n bullet[0]+=1 if bullet[2] else -1\n if(bullet[0]<0 or bullet[0]>9):\n self.f_bullets.remove(bullet)\n else:\n removed = False\n for x in self.e_fish:\n if(bullet[0:2]==x[0:2]):\n self.e_fish.remove(x)\n self.f_bullets.remove(bullet)\n r+=1\n removed = True\n break\n if(not removed):\n for x in self.e_subs:\n if(bullet[0:2]==x[0:2]):\n self.e_subs.remove(x)\n self.f_bullets.remove(bullet)\n r+=1\n break\n\n # Update divers\n for diver in reversed(self.divers):\n if(diver[0:2]==[self.sub_x,self.sub_y] and self.diver_count<6):\n self.divers.remove(diver)\n self.diver_count+=1\n else:\n if(diver[3]==0):\n diver[3]=diver_move_interval\n diver[0]+=1 if diver[2] else -1\n if(diver[0]<0 or diver[0]>9):\n self.divers.remove(diver)\n elif(diver[0:2]==[self.sub_x,self.sub_y] and self.diver_count<6):\n self.divers.remove(diver)\n self.diver_count+=1\n else:\n diver[3]-=1\n\n # Update enemy subs\n for sub in reversed(self.e_subs):\n if(sub[0:2]==[self.sub_x,self.sub_y]):\n self.terminal = True\n if(sub[3]==0):\n sub[3]=self.move_speed\n sub[0]+=1 if sub[2] else -1\n if(sub[0]<0 or sub[0]>9):\n self.e_subs.remove(sub)\n elif(sub[0:2]==[self.sub_x,self.sub_y]):\n self.terminal = True\n else:\n for x in self.f_bullets:\n if(sub[0:2]==x[0:2]):\n self.e_subs.remove(sub)\n self.f_bullets.remove(x)\n r+=1\n break\n else:\n sub[3]-=1\n if(sub[4]==0):\n sub[4]=enemy_shot_interval\n self.e_bullets+=[[sub[0] if sub[2] else sub[0], sub[1], sub[2]]]\n else:\n sub[4]-=1\n\n # Update enemy bullets\n for bullet in reversed(self.e_bullets):\n if(bullet[0:2]==[self.sub_x,self.sub_y]):\n self.terminal = True\n bullet[0]+=1 if bullet[2] else -1\n if(bullet[0]<0 or bullet[0]>9):\n self.e_bullets.remove(bullet)\n else:\n if(bullet[0:2]==[self.sub_x,self.sub_y]):\n self.terminal = True\n\n # Update enemy fish\n for fish in reversed(self.e_fish):\n if(fish[0:2]==[self.sub_x,self.sub_y]):\n self.terminal = True\n if(fish[3]==0):\n fish[3]=self.move_speed\n fish[0]+=1 if fish[2] else -1\n if(fish[0]<0 or fish[0]>9):\n self.e_fish.remove(fish)\n elif(fish[0:2]==[self.sub_x,self.sub_y]):\n self.terminal = True\n else:\n for x in self.f_bullets:\n if(fish[0:2]==x[0:2]):\n self.e_fish.remove(fish)\n self.f_bullets.remove(x)\n r+=1\n break\n else:\n fish[3]-=1\n\n # Update various timers\n self.e_spawn_timer -= self.e_spawn_timer>0\n self.d_spawn_timer -= self.d_spawn_timer>0\n self.shot_timer -= self.shot_timer>0\n if(self.oxygen<=0):\n self.terminal = True\n if(self.sub_y>0):\n self.oxygen-=1\n self.surface = False\n else:\n if(not self.surface):\n if(self.diver_count == 0):\n self.terminal = True\n else:\n r+=self._surface()\n return r, self.terminal\n\n # Called when player hits surface (top row) if they have no divers, this ends the game,\n # if they have 6 divers this gives reward proportional to the remaining oxygen and restores full oxygen\n # otherwise this reduces the number of divers and restores full oxygen\n def _surface(self):\n self.surface = True\n if(self.diver_count == 6):\n self.diver_count = 0\n r = self.oxygen*10//max_oxygen\n else:\n r = 0\n self.oxygen = max_oxygen\n self.diver_count -= 1\n if self.ramping and (self.e_spawn_speed>1 or self.move_speed>2):\n if(self.move_speed>2 and self.ramp_index%2):\n self.move_speed-=1\n if(self.e_spawn_speed>1):\n self.e_spawn_speed-=1\n self.ramp_index+=1\n return r\n\n # Spawn an enemy fish or submarine in random row and random direction,\n # if the resulting row and direction would lead to a collision, do nothing instead\n def _spawn_enemy(self):\n lr = self.random.rand() < 1/2\n is_sub = self.random.rand() < 1/3\n x = 0 if lr else 9\n y = self.random.randint(low=1, high=9)\n\n # Do not spawn in same row an opposite direction as existing\n if(any([z[1]==y and z[2]!=lr for z in self.e_subs+self.e_fish])):\n return\n if(is_sub):\n self.e_subs+=[[x,y,lr,self.move_speed,enemy_shot_interval]]\n else:\n self.e_fish+=[[x,y,lr,self.move_speed]]\n\n # Spawn a diver in random row with random direction\n def _spawn_diver(self):\n lr = self.random.rand() < 1/2\n x = 0 if lr else 9\n y = self.random.randint(low=1, high=9)\n self.divers+=[[x,y,lr,diver_move_interval]]\n\n # Query the current level of the difficulty ramp, could be used as additional input to agent for example\n def difficulty_ramp(self):\n return self.ramp_index\n\n # Process the game-state into the 10x10xn state provided to the agent and return\n def state(self):\n state = np.zeros((10,10,len(self.channels)),dtype=bool)\n state[self.sub_y,self.sub_x,self.channels['sub_front']] = 1\n back_x = self.sub_x-1 if self.sub_or else self.sub_x+1\n state[self.sub_y,back_x,self.channels['sub_back']] = 1\n state[9,0:max(0,self.oxygen)*10//max_oxygen, self.channels['oxygen_guage']] = 1\n state[9,9-self.diver_count:9, self.channels['diver_guage']] = 1\n for bullet in self.f_bullets:\n state[bullet[1],bullet[0], self.channels['friendly_bullet']] = 1\n for bullet in self.e_bullets:\n state[bullet[1],bullet[0], self.channels['enemy_bullet']] = 1\n for fish in self.e_fish:\n state[fish[1],fish[0], self.channels['enemy_fish']] = 1\n back_x = fish[0]-1 if fish[2] else fish[0]+1\n if(back_x>=0 and back_x<=9):\n state[fish[1],back_x, self.channels['trail']] = 1\n for sub in self.e_subs:\n state[sub[1],sub[0], self.channels['enemy_sub']] = 1\n back_x = sub[0]-1 if sub[2] else sub[0]+1\n if(back_x>=0 and back_x<=9):\n state[sub[1],back_x, self.channels['trail']] = 1\n for diver in self.divers:\n state[diver[1],diver[0], self.channels['diver']] = 1\n back_x = diver[0]-1 if diver[2] else diver[0]+1\n if(back_x>=0 and back_x<=9):\n state[diver[1],back_x, self.channels['trail']] = 1\n\n return state\n\n # Reset to start state for new episode\n def reset(self):\n self.oxygen = max_oxygen\n self.diver_count = 0\n self.sub_x = 5\n self.sub_y = 0\n # 0=left, 1=right\n self.sub_or = False\n self.f_bullets = []\n self.e_bullets = []\n self.e_fish = []\n self.e_subs = []\n self.divers = []\n self.e_spawn_speed = init_spawn_speed\n self.e_spawn_timer = self.e_spawn_speed\n self.d_spawn_timer = diver_spawn_speed\n self.move_speed = init_move_interval\n self.ramp_index = 0\n self.shot_timer = 0\n self.surface = True\n self.terminal = False\n\n # Dimensionality of the game-state (10x10xn)\n def state_shape(self):\n return [10,10,len(self.channels)]\n\n # Subset of actions that actually have a unique impact in this environment\n def minimal_action_set(self):\n minimal_actions = ['n','l','u','r','d','f']\n return [self.action_map.index(x) for x in minimal_actions]\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: player=sub_front|sub_back; danger=enemy_fish|enemy_sub|enemy_bullet; reward=enemy_fish|enemy_sub|diver; projectile=friendly_bullet; trail=trail|sub_back; gauge=oxygen_guage|diver_guage.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 270, "family": "minatar_original", "upstream_source_url": "https://pypi.org/project/MinAtar/1.0.15/", "upstream_revision": "MinAtar==1.0.15", "native_source_url": null} +{"name": "asterix", "split": "test", "game": "asterix", "source": "original", "prompt": "Write from scratch the weights of a policy network that plays Asterix as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nMove in four directions to collect treasure while avoiding horizontally moving enemies.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact MinAtar 1.0.15 source (`minatar/environments/asterix.py`):\n```python\n################################################################################################################\n# Authors: #\n# Kenny Young (kjyoung@ualberta.ca) #\n# Tian Tian (ttian@ualberta.ca) #\n################################################################################################################\nimport numpy as np\n\n\n#####################################################################################################################\n# Constants\n#\n#####################################################################################################################\nramp_interval = 100\ninit_spawn_speed = 10\ninit_move_interval = 5\nshot_cool_down = 5\n\n\n#####################################################################################################################\n# Env\n#\n# The player can move freely along the 4 cardinal directions. Enemies and treasure spawn from the sides. A reward of\n# +1 is given for picking up treasure. Termination occurs if the player makes contact with an enemy. Enemy and\n# treasure direction are indicated by a trail channel. Difficulty is periodically increased by increasing the speed\n# and spawn rate of enemies and treasure.\n#\n#####################################################################################################################\nclass Env:\n def __init__(self, ramping=True):\n self.channels ={\n 'player':0,\n 'enemy':1,\n 'trail':2,\n 'gold':3\n }\n self.action_map = ['n','l','u','r','d','f']\n self.ramping = ramping\n self.random = np.random.RandomState()\n self.reset()\n\n # Update environment according to agent action\n def act(self, a):\n r = 0\n if(self.terminal):\n return r, self.terminal\n\n a = self.action_map[a]\n\n # Spawn enemy if timer is up\n if(self.spawn_timer==0):\n self._spawn_entity()\n self.spawn_timer = self.spawn_speed\n\n # Resolve player action\n if(a=='l'):\n self.player_x = max(0, self.player_x-1)\n elif(a=='r'):\n self.player_x = min(9, self.player_x+1)\n elif(a=='u'):\n self.player_y = max(1, self.player_y-1)\n elif(a=='d'):\n self.player_y = min(8, self.player_y+1)\n\n # Update entities\n for i in range(len(self.entities)):\n x = self.entities[i]\n if(x is not None):\n if(x[0:2]==[self.player_x,self.player_y]):\n if(self.entities[i][3]):\n self.entities[i] = None\n r+=1\n else:\n self.terminal = True\n if(self.move_timer==0):\n self.move_timer = self.move_speed\n for i in range(len(self.entities)):\n x = self.entities[i]\n if(x is not None):\n x[0]+=1 if x[2] else -1\n if(x[0]<0 or x[0]>9):\n self.entities[i] = None\n if(x[0:2]==[self.player_x,self.player_y]):\n if(self.entities[i][3]):\n self.entities[i] = None\n r+=1\n else:\n self.terminal = True\n\n # Update various timers\n self.spawn_timer -= 1\n self.move_timer -= 1\n\n\n #Ramp difficulty if interval has elapsed\n if self.ramping and (self.spawn_speed>1 or self.move_speed>1):\n if(self.ramp_timer>=0):\n self.ramp_timer-=1\n else:\n if(self.move_speed>1 and self.ramp_index%2):\n self.move_speed-=1\n if(self.spawn_speed>1):\n self.spawn_speed-=1\n self.ramp_index+=1\n self.ramp_timer=ramp_interval\n return r, self.terminal\n\n # Spawn a new enemy or treasure at a random location with random direction (if all rows are filled do nothing)\n def _spawn_entity(self):\n lr = self.random.rand() < 1/2\n is_gold = self.random.rand() < 1/3\n x = 0 if lr else 9\n slot_options = [i for i in range(len(self.entities)) if self.entities[i]==None]\n if(not slot_options):\n return\n slot = slot_options[self.random.randint(len(slot_options))]\n self.entities[slot] = [x,slot+1,lr,is_gold]\n\n # Query the current level of the difficulty ramp, could be used as additional input to agent for example\n def difficulty_ramp(self):\n return self.ramp_index\n\n # Process the game-state into the 10x10xn state provided to the agent and return\n def state(self):\n state = np.zeros((10,10,len(self.channels)),dtype=bool)\n state[self.player_y,self.player_x,self.channels['player']] = 1\n for x in self.entities:\n if(x is not None):\n c = self.channels['gold'] if x[3] else self.channels['enemy']\n state[x[1], x[0],c] = 1\n back_x = x[0]-1 if x[2] else x[0]+1\n if(back_x>=0 and back_x<=9):\n state[x[1], back_x, self.channels['trail']] = 1\n return state\n\n # Reset to start state for new episode\n def reset(self):\n self.player_x = 5\n self.player_y = 5\n self.entities = [None]*8\n self.shot_timer = 0\n self.spawn_speed = init_spawn_speed\n self.spawn_timer = self.spawn_speed\n self.move_speed = init_move_interval\n self.move_timer = self.move_speed\n self.ramp_timer = ramp_interval\n self.ramp_index = 0\n self.terminal = False\n\n # Dimensionality of the game-state (10x10xn)\n def state_shape(self):\n return [10,10,len(self.channels)]\n\n # Subset of actions that actually have a unique impact in this environment\n def minimal_action_set(self):\n minimal_actions = ['n','l','u','r','d']\n return [self.action_map.index(x) for x in minimal_actions]\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: player=player; danger=enemy; reward=gold; projectile=empty; trail=trail; gauge=empty.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 278, "family": "minatar_original", "upstream_source_url": "https://pypi.org/project/MinAtar/1.0.15/", "upstream_revision": "MinAtar==1.0.15", "native_source_url": null} diff --git a/data/train.jsonl b/data/train.jsonl new file mode 100644 index 0000000000000000000000000000000000000000..7fadbf7c5e79874928d6fca42a9810702b3ff326 --- /dev/null +++ b/data/train.jsonl @@ -0,0 +1,317 @@ +{"name": "marusansi", "split": "train", "game": "marusansi", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Marusansi as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap actions 1 or 3 to move the column cursor, 2 to swap the\npair, 4 to insert the preview row, and 5 to place the pair.\nAction 0 releases. Each command triggers on a change of action.\nThe preview row also rises after 400 idle gameplay frames.\n\nRuns of at least three equal blocks score and recolor into\nthe other two colors. Further matches build the chain\nmultiplier. When the chain ends, marked blocks clear and\nthe remaining blocks compact. The conversion uses a short\nfixed pause for compaction. The game ends when no column can\nfit the pair. Scores are capped at 500 and divided by 500.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels preserve the 12×6 board. Channels 0–2\nencode the three colors in the bottom eight board rows and\nchannels 3–5 encode the upper four. Observation rows 8–9\nshow the preview row, pair, and cursor. Columns 6–9 carry\nthe timer, animation delay, multiplier, and action gauges.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/marusansi.py`):\n```python\nimport numpy as np\n\n\nclass MarusansiEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.grid = np.zeros((12, 6), dtype=np.int8)\n self.blocks = (1, 2)\n self.cursor = self.steps = self.action = self.timer = self.delay = 0\n self.multiplier = 1\n self.terminal = False\n self.marked = np.zeros_like(self.grid, dtype=bool)\n self.pending = None\n self._next_row()\n\n def _next_row(self):\n self.next_row = []\n for col in range(6):\n colors = [c for c in (1, 2, 3)\n if not (self.grid[0, col] == self.grid[1, col] == c)\n and self.next_row[-2:] != [c, c]]\n self.next_row.append(int(self.random.choice(colors)))\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(self.action if frame == 0 and self.action != previous else 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, command):\n if self.delay:\n self.delay -= 1\n if self.delay:\n return 0\n if self.pending is not None:\n changed = self.pending > 0\n self.grid[changed] = self.pending[changed]\n self.marked |= changed\n self.pending = None\n reward = self._match() if self.multiplier < 32 else 0\n if not self.delay:\n self.grid[self.marked] = 0\n self.delay = 5\n return reward\n for col in range(6):\n values = self.grid[:, col]\n remaining = values[values != 0]\n values[:] = 0\n values[:len(remaining)] = remaining\n self.marked[:] = False\n self.timer = 0\n reward = self._match()\n self._next_row()\n return reward\n heights = np.count_nonzero(self.grid, axis=0)\n if np.all(heights >= 11):\n self.terminal = True\n return 0\n self.timer += 1\n if self.timer > 400 or command == 4:\n self.grid[1:] = self.grid[:-1].copy()\n self.grid[0] = self.next_row\n self._next_row()\n self.timer = 0\n elif command in (1, 3):\n self.cursor = (self.cursor + (1 if command == 3 else -1)) % 6\n elif command == 2:\n self.blocks = self.blocks[::-1]\n elif command == 5 and heights[self.cursor] < 11:\n height = heights[self.cursor]\n self.grid[height:height + 2, self.cursor] = self.blocks[::-1]\n pair = tuple(int(c) for c in self.random.integers(1, 4, 2))\n self.blocks = ((pair[0] % 3 + 1, pair[1]) if pair == self.blocks else pair)\n self.multiplier = 1\n return self._match()\n return 0\n\n def _match(self):\n changes = np.zeros_like(self.grid)\n count = 0\n for board, output in ((self.grid.T, changes.T), (self.grid, changes)):\n for line, dest in zip(board, output, strict=True):\n start = 0\n while start < len(line):\n end = start + 1\n while end < len(line) and line[end] == line[start]:\n end += 1\n color = int(line[start])\n if color and end - start >= 3:\n others = [c for c in (1, 2, 3) if c != color]\n others.sort(key=lambda c: (c - color) % 3)\n for index in range(start, end):\n dest[index] = others[(index - start) % 2]\n count += end - start\n start = end\n if not count:\n return 0\n self.pending = changes\n self.delay = 50\n reward = count * self.multiplier\n self.multiplier += 1\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for row, col in np.argwhere(self.grid > 0):\n state[row % 8, col, 3 * (row // 8) + self.grid[row, col] - 1] = True\n for col, color in enumerate(self.next_row):\n state[8, col, color - 1] = True\n for col, color in enumerate(self.blocks):\n state[9, col, color - 1] = True\n state[9, self.cursor, 3] = True\n for col, value in enumerate((self.timer, self.delay, self.multiplier, self.action), 6):\n for bit in range(9):\n state[bit, col, 0] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 0, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/marusansi.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameMarusansi.c"} +{"name": "thunder", "split": "train", "game": "thunder", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Thunder as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe runner moves automatically and reverses at the edges. Press action\n5 to reverse early. Release it with any other action before pressing\nagain. Avoid the energized lightning path and catch falling stars.\nEach catch adds the current multiplier and increases it by one.\nA new strike resets the multiplier to one.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the runner, growing branches, energized\nbranches, stars, ground, and counters. The counters encode steps,\nprevious action, rightward movement, multiplier, and strike timer.\nThe port holds difficulty fixed and uses distance checks for collisions\nin place of sprite overlap. Each action advances up to four frames,\nwith a 400-action horizon. Clip episode scores to [0, 300] and divide by 300.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/thunder.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import ceil, cos, hypot, pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Bolt:\n x: float\n y: float\n angle: float\n speed: float\n ticks: int\n parent: \"Bolt | None\" = None\n active: bool = False\n\n def __post_init__(self):\n self.origin = (self.x, self.y)\n\n\n@dataclass\nclass Star:\n x: float\n y: float\n vy: float\n\n\nclass ThunderEnvironment:\n score_cap = 300\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.bolts = []\n self.stars = []\n self.active_ticks = -1\n self.x, self.vx = 40., 1\n self.multiplier = 1\n self.action = self.steps = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n turn = self.action == 5 and previous != 5\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(turn and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, turn):\n if not self.bolts:\n self.bolts.append(Bolt(self.random.uniform(30, 70), 0, pi / 2, 0.5, 30))\n self.active_ticks -= 1\n remaining = []\n for bolt in self.bolts:\n if bolt.active:\n if self.active_ticks >= 0:\n remaining.append(bolt)\n continue\n bolt.ticks -= 1\n if self.active_ticks > 0:\n if bolt.ticks > 0:\n self.stars.append(Star(bolt.x, bolt.y, -bolt.y * 0.02))\n continue\n remaining.append(bolt)\n if bolt.ticks > 0:\n bolt.x += cos(bolt.angle) * bolt.speed\n bolt.y += sin(bolt.angle) * bolt.speed\n if self.active_ticks < 0 and (bolt.y > 90 or len(self.bolts) > 160):\n self._strike(bolt)\n elif bolt.ticks == 0:\n for _ in range(self.random.integers(1, 4)):\n remaining.append(Bolt(\n bolt.x, bolt.y, bolt.angle + self.random.uniform(-0.7, 0.7),\n self.random.uniform(0.3, 1), ceil(self.random.uniform(20, 40)), bolt,\n ))\n self.bolts = remaining\n if turn or (self.x < 0 and self.vx < 0) or (self.x > 99 and self.vx > 0):\n self.vx *= -1\n self.x += self.vx\n self.terminal = any(\n bolt.active and _segment_distance(self.x, 87, bolt) <= 5\n for bolt in self.bolts\n )\n if self.terminal:\n return 0\n reward = 0\n stars = []\n for star in self.stars:\n star.vy += 0.1\n star.y += star.vy\n if star.y > 89 and star.vy > 0:\n star.vy *= -0.5\n if star.vy > -0.1:\n continue\n if abs(star.x - self.x) <= 5 and abs(star.y - 87) <= 5:\n reward += self.multiplier\n self.multiplier += 1\n else:\n stars.append(star)\n self.stars = stars\n return reward\n\n def _strike(self, bolt):\n self.active_ticks = 20\n self.multiplier = 1\n for _ in range(99):\n bolt.active = True\n bolt = bolt.parent\n if bolt is None:\n break\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[8, int(np.clip(self.x // 10, 0, 9)), 0] = True\n for bolt in self.bolts:\n start_x, start_y = bolt.origin\n samples = ceil(hypot(bolt.x - start_x, bolt.y - start_y) / 3) + 1\n for x, y in zip(np.linspace(start_x, bolt.x, samples),\n np.linspace(start_y, bolt.y, samples), strict=True):\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), 2 if bolt.active else 1] = True\n for star in self.stars:\n if 0 <= star.x < 100 and 0 <= star.y < 100:\n state[int(star.y // 10), int(star.x // 10), 3] = True\n state[9, :, 4] = True\n values = (self.steps, self.action, self.vx > 0, self.multiplier, self.active_ticks + 1)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n\ndef _segment_distance(x, y, bolt):\n start_x, start_y = bolt.origin\n dx, dy = bolt.x - start_x, bolt.y - start_y\n length_squared = dx * dx + dy * dy\n if length_squared == 0:\n return hypot(x - start_x, y - start_y)\n fraction = min(1, max(0, ((x - start_x) * dx + (y - start_y) * dy) / length_squared))\n return hypot(x - start_x - fraction * dx, y - start_y - fraction * dy)\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 1, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/thunder.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-11-games/blob/6fea4eefe2deaa42706051d96a04ec9e36104696/docs/thunder/main.js"} +{"name": "up_shot", "split": "train", "game": "up_shot", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Up Shot as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to stop running and fire upward. Release with any other\naction to resume running. Each fresh press resets the multiplier.\nA shot shrinks a rock. A surviving rock pays the multiplier and\nincreases it by one. A destroyed rock pays ten times the multiplier.\nRock contact or falling behind the left edge ends the run.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the runner, small rocks, large rocks,\nshots, ground, and counters. The port fixes difficulty and uses\nrectangular overlap for collisions. Each action advances up to four\nframes over 400 actions. Clip episode scores to [0, 500] and divide\nby 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/up_shot.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import sqrt\n\nimport numpy as np\n\n\n@dataclass\nclass Spawner:\n x: float\n size: float\n acceleration: float\n interval: float\n variation: float\n timer: float\n\n\n@dataclass\nclass Rock:\n x: float\n y: float\n size: float\n acceleration: float\n vy: float = 0.\n\n\n@dataclass\nclass Shot:\n x: float\n y: float = 87.\n\n\nclass UpShotEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.vx = 10., 0.\n self.spawners, self.rocks, self.shots = [], [], []\n self.spawn_distance = 0.\n self.cooldown = self.steps = self.action = 0\n self.multiplier = 1\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(previous if frame == 0 else self.action)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, previous):\n scroll = 0.1 + max(0, self.x - 30) * 0.05\n self.cooldown -= 1\n if self.action == 5:\n if previous != 5:\n self.vx = 0\n self.multiplier = 1\n if self.cooldown < 0:\n self.shots.append(Shot(self.x))\n self.cooldown = 10\n elif previous == 5:\n self.vx = 1.2\n self.x += self.vx - scroll\n for shot in self.shots:\n shot.x -= scroll\n shot.y -= 2\n self.shots = [shot for shot in self.shots if shot.y >= 0]\n self._spawn_rocks(scroll)\n\n reward = 0\n remaining = []\n for rock in self.rocks:\n rock.vy += rock.acceleration\n rock.x -= scroll\n rock.y += rock.vy\n if any(_hit(shot, rock) for shot in self.shots):\n rock.size *= 0.7\n if rock.size < 5:\n reward += 10 * self.multiplier\n continue\n reward += self.multiplier\n self.multiplier += 1\n if rock.y <= 90 - rock.size / 2:\n remaining.append(rock)\n self.rocks = remaining\n self.terminal = self.x < -2 or any(\n abs(rock.x - self.x) < rock.size / 2 + 3 and abs(rock.y - 87) < rock.size / 2 + 3\n for rock in self.rocks\n )\n self.shots = [shot for shot in self.shots if not any(_hit(shot, rock) for rock in self.rocks)]\n return reward\n\n def _spawn_rocks(self, scroll):\n self.spawn_distance -= scroll\n if self.spawn_distance < 0:\n size = self.random.uniform(5, 15)\n speed = self.random.uniform(5, 10) / sqrt(size)\n interval = self.random.uniform(10, 50) * sqrt(size / speed)\n self.spawners.append(Spawner(200, size, speed * 0.01, interval,\n self.random.uniform(0.3, 0.9), self.random.uniform(0, interval)))\n self.spawn_distance += self.random.uniform(50, 60)\n for spawner in self.spawners:\n spawner.x -= scroll\n spawner.timer -= 1\n if spawner.timer < 0:\n self.rocks.append(Rock(spawner.x, -spawner.size / 2, spawner.size, spawner.acceleration))\n spawner.timer = spawner.interval * (1 + self.random.uniform(-spawner.variation, spawner.variation))\n self.spawners = [spawner for spawner in self.spawners if spawner.x >= 0]\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[8, int(np.clip(self.x // 10, 0, 9)), 0] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for rock in self.rocks:\n mask = (abs(cols - rock.x) < rock.size / 2 + 5) & (abs(rows - rock.y) < rock.size / 2 + 5)\n state[:, :, 1 if rock.size < 8 else 2] |= mask\n for shot in self.shots:\n if 0 <= shot.x < 100:\n state[int(shot.y // 10), int(shot.x // 10), 3] = True\n state[9, :, 4] = True\n values = (self.steps, self.action, self.multiplier, max(0, self.cooldown),\n round(self.vx * 100), round(self.spawn_distance * 4))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n\ndef _hit(shot, rock):\n return abs(shot.x - rock.x) < (5 + rock.size) / 2 and abs(shot.y - rock.y) < (9 + rock.size) / 2\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 2, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/up_shot.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/upshot/main.js"} +{"name": "ladder_drop", "split": "train", "game": "ladder_drop", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Ladder Drop as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe walker moves on its own and climbs ladders in its path. Tap action 5\nto drop the horizontally sweeping panel. Actions 0–4 release the button.\nDropped panels settle against the existing stack. Time their placement\nto build a route upward and keep solid panel cells away from the walker.\nEvery fourth panel carries a row of coins that appears on settlement.\nCoins raise the multiplier when collected and lower it when they scroll\noffscreen. Falling out of view or being crushed ends the run.\n\nINPUT CHANNEL TABLE\nChannels show the walker, settled floors, ladders, coins, active panel,\nand gauges. The gauges encode time, multiplier, coin cadence, active\nladder offset, drop mode, walker and panel direction, button state, and\nwalker row. The tile version uses one ladder per panel, one-row movement,\nand faster downward scroll when the stack is high. The original's\nladder reversals under obstructions are approximated by floor avoidance\nand falling when unsupported.\n\nSCORING, TERMINATION, AND HORIZON\nOver 400 steps, at most one panel can finish per step. At most 100\ncan carry coins, with at most six coins each. Each coin pays once,\nand the multiplier grows by at most one per collection. The sum\nfrom 1 to 600 gives a conservative cap of 180,300. Normalize by clipping\nto [0, cap] and dividing by the cap.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/ladder_drop.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\nHORIZON = 400\nWIDTH = 10\nMAX_PANEL_WIDTH = 6\nMAX_COINS = (HORIZON // 4) * MAX_PANEL_WIDTH\n\n\n@dataclass\nclass Panel:\n row: int\n left: int\n width: int\n ladder: int\n depth: int\n has_coins: bool = False\n\n def floor(self) -> set[tuple[int, int]]:\n return {(self.row, column) for column in range(self.left, self.left + self.width)}\n\n def rungs(self) -> set[tuple[int, int]]:\n return {(row, self.left + self.ladder) for row in range(self.row, self.row + self.depth)}\n\n\nclass LadderDropEnvironment:\n score_cap = MAX_COINS * (MAX_COINS + 1) // 2\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.last_action = self.panel_count = 0\n self.row, self.column = 8, 1\n self.direction = self.panel_direction = self.multiplier = 1\n self.climbing = self.falling = self.terminal = False\n self.panels = [Panel(9, 0, WIDTH, 0, 0)]\n self.coins: set[tuple[int, int]] = set()\n self._new_panel(5)\n\n def _new_panel(self, left: int) -> None:\n self.panel_count += 1\n width = int(self.random.integers(4, MAX_PANEL_WIDTH + 1))\n self.panel = Panel(0, min(left, WIDTH - width), width,\n int(self.random.integers(width)), int(self.random.integers(3, 6)),\n self.panel_count % 4 == 0)\n self.falling = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def _settled_cells(self) -> tuple[set[tuple[int, int]], set[tuple[int, int]]]:\n floors: set[tuple[int, int]] = set()\n ladders: set[tuple[int, int]] = set()\n for panel in self.panels:\n floors.update(panel.floor())\n ladders.update(panel.rungs())\n return floors, ladders\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n pressed = action == 5 and self.last_action != 5\n self.last_action = action\n self.steps += 1\n if self.steps % 16 == 0 or (self.steps % 4 == 0 and min(p.row for p in self.panels) < 3):\n self.row += 1\n for panel in self.panels:\n panel.row += 1\n self.panels = [panel for panel in self.panels if panel.row < 10]\n self.multiplier = max(1, self.multiplier - sum(row == 9 for row, _ in self.coins))\n self.coins = {(row + 1, column) for row, column in self.coins if row < 9}\n\n floors, ladders = self._settled_cells()\n if not self.falling:\n left = self.panel.left + self.panel_direction\n if not 0 <= left <= WIDTH - self.panel.width:\n self.panel_direction *= -1\n else:\n self.panel.left = left\n self.falling = pressed\n if self.falling:\n self.panel.row += 1\n if (self.row, self.column) in self.panel.floor() - self.panel.rungs():\n self.terminal = True\n return 0.0, True\n if (self.panel.floor() | self.panel.rungs()) & (floors | ladders):\n self.panel.row -= 1\n self.panels.append(self.panel)\n if self.panel.has_coins:\n self.coins.update((self.panel.row - 1, column)\n for column in range(self.panel.left, self.panel.left + self.panel.width)\n if self.panel.row > 0)\n self._new_panel(self.panel.left)\n floors, ladders = self._settled_cells()\n elif self.panel.row >= 10:\n self._new_panel(self.panel.left)\n\n self._move_player(floors, ladders)\n reward = 0\n cell = self.row, self.column\n if cell in self.coins:\n self.coins.remove(cell)\n reward = self.multiplier\n self.multiplier += 1\n self.terminal = self.row >= 10 or self.steps >= self.horizon or not self.panels\n return float(reward), self.terminal\n\n def _move_player(self, floors: set, ladders: set) -> None:\n if (self.row, self.column) in ladders:\n self.row -= 1\n self.climbing = True\n return\n if (self.row + 1, self.column) not in floors:\n self.row += 1\n self.climbing = False\n return\n destination = self.column + self.direction\n if not 0 <= destination < WIDTH or (self.row, destination) in floors - ladders:\n self.direction *= -1\n else:\n self.column = destination\n self.climbing = False\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, max(0, self.row)), self.column, 0] = True\n floors, ladders = self._settled_cells()\n for channel, cells in enumerate((floors, ladders, self.coins,\n self.panel.floor() | self.panel.rungs()), start=1):\n for row, column in cells:\n if 0 <= row < 10:\n state[row, column, channel] = True\n gauges = (self.steps, self.multiplier, self.panel_count % 4, self.panel.ladder,\n int(self.falling), int(self.direction > 0), int(self.panel_direction > 0),\n int(self.last_action == 5), self.row + 1)\n for row, value in enumerate(gauges):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 3, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/ladder_drop.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameLadderDrop.c"} +{"name": "scrambird", "split": "train", "game": "scrambird", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Scrambird as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to flap, fire forward, and drop a bomb. Actions 0–4\nrelease. The terrain scrolls automatically. Avoid the ceiling,\nterrain, missiles, and fuel tanks. Destroy missiles to earn the\ncurrent multiplier and raise it by one. Missed missiles reduce it.\nDestroying a fuel tank replenishes fuel, which powers stronger flaps.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the ship, terrain, missiles, fuel tanks,\nplayer projectiles, and counters. The port uses fixed difficulty\nand rectangular collision bounds. Each action advances up to four\nframes over a 400-action horizon. Clip the episode score to [0, 100]\nand divide by 100.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/scrambird.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Target:\n x: float\n y: float\n timer: float = 0\n\n\n@dataclass\nclass Bomb:\n x: float\n y: float\n vx: float = 2\n vy: float = 0\n\n\nclass ScrambirdEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.y, self.vy, self.fuel = 50., 0., 50.\n self.height, self.slope, self.tank_timer = 10, 0, 10\n self.steps = 0\n self.multiplier = 1\n self.held = self.terminal = False\n self.terrain = [(i * 10., 10) for i in range(11)]\n self.shots, self.bombs, self.missiles, self.tanks = [], [], [], []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n for index, (x, height) in enumerate(self.terrain):\n x -= 0.3\n if x < -10:\n x += 110\n next_height = self.height + self.slope\n if not 10 <= next_height <= 50:\n self.slope *= -1\n else:\n self.height = next_height\n if self.random.random() < 0.2:\n self.slope = 0\n elif self.random.random() < 0.3:\n self.slope = self.random.choice((-10, 10))\n height = self.height\n self.tank_timer -= 1\n if self.tank_timer < 0:\n self.tanks.append(Target(x + 5, 87 - height))\n self.tank_timer = self.random.uniform(1, 16)\n elif self.random.random() < 0.5:\n timer = 9999 if self.random.random() < 0.5 else self.random.uniform(200, 300)\n self.missiles.append(Target(x + 5, 87 - height, timer))\n self.terrain[index] = x, height\n if tap:\n self.vy -= 0.5 if self.fuel > 0 else 0.1\n self.shots.append(Target(10, self.y))\n self.bombs.append(Bomb(10, self.y))\n self.vy = (self.vy + 0.015) * 0.98\n self.y += self.vy\n self.terminal = self._wall_hit(10, self.y, 3)\n for shot in self.shots:\n shot.x += 2\n self.shots = [shot for shot in self.shots if shot.x <= 103 and not self._wall_hit(shot.x, shot.y, 1)]\n for bomb in self.bombs:\n bomb.vx *= 0.9\n bomb.vy = (bomb.vy + 0.1) * 0.9\n bomb.x += bomb.vx\n bomb.y += bomb.vy\n self.bombs = [bomb for bomb in self.bombs if bomb.y <= 103 and not self._wall_hit(bomb.x, bomb.y, 1)]\n reward = 0\n spent = set()\n for targets, fuel_tanks in ((self.missiles, False), (self.tanks, True)):\n survivors = []\n for target in targets:\n target.x -= 0.3\n if not fuel_tanks:\n target.timer -= 1\n if target.timer < 0:\n target.y -= 0.5\n hits = [projectile for projectile in (*self.shots, *self.bombs)\n if abs(projectile.x - target.x) < 4 and abs(projectile.y - target.y) < 4]\n if hits:\n spent.update(map(id, hits))\n if fuel_tanks:\n self.fuel = min(50, self.fuel + 10)\n else:\n reward += self.multiplier\n self.multiplier += 1\n continue\n self.terminal |= abs(target.x - 10) < 5 and abs(target.y - self.y) < 5\n if target.x >= -3 and target.y >= -3:\n survivors.append(target)\n elif not fuel_tanks:\n self.multiplier = max(1, self.multiplier - 1)\n targets[:] = survivors\n self.shots = [shot for shot in self.shots if id(shot) not in spent]\n self.bombs = [bomb for bomb in self.bombs if id(bomb) not in spent]\n self.fuel = max(0, self.fuel - 0.025)\n return reward\n\n def _wall_hit(self, x, y, margin):\n return y - margin < 5 or any(\n left - margin < x < left + 9 + margin and y + margin > 90 - height\n and y - margin < 90 for left, height in self.terrain\n )\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(np.clip(self.y // 10, 0, 9)), 1, 0] = True\n state[0, :, 1] = True\n for col in range(10):\n for x, height in self.terrain:\n if x < col * 10 + 10 and x + 9 > col * 10:\n state[(90 - height) // 10:9, col, 1] = True\n for channel, entities in ((2, self.missiles), (3, self.tanks), (4, (*self.shots, *self.bombs))):\n for entity in entities:\n if 0 <= entity.x < 100 and 0 <= entity.y < 100:\n state[int(entity.y // 10), int(entity.x // 10), channel] = True\n values = (self.steps, round(self.fuel * 10), self.multiplier, self.held, round((self.vy + 30) * 16))\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 4, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/scrambird.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/scrambird/main.js"} +{"name": "battle_zone", "split": "train", "game": "battle_zone", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Battle Zone as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves the Atari 2600 game's radar combat loop in a semantic top-down state.\nThe tank rotates in place with actions 1 and 3, drives forward along its heading with action 2,\nreverses with action 4, and fires with action 5. The radar channel shows every enemy while the\ntarget channel marks only enemies within the periscope's forward field of view. Six fixed terrain\nobstacles block both movement and shells, enabling the manual's cover and line-of-fire tactics.\n\nOnly one turret shell may be active, reproducing the manual's reload delay after a miss. Enemy\nshells remain dangerous outside the field of view and can destroy another enemy if the player\nlures it into their path. Tanks move slowly, fighters zigzag and close faster, supertanks move\nevery step, and saucers move laterally without firing. The player begins with five tanks and earns\nthe manual's one reachable bonus tank at 50,000 points. Five finite waves or the 1,500-step\nhorizon end the episode.\n\nACTION MAPPING\n0: wait\n1: rotate left\n2: drive forward\n3: rotate right\n4: drive backward\n5: fire\n\nINPUT CHANNEL TABLE\n0: player tank\n1: all radar enemies and enemy shells\n2: enemies currently inside the forward periscope view\n3: active player shell\n4: previous player and enemy positions\n5: enemy identities, obstacles, heading, lives, and wave\n\nSCORING, TERMINATION, AND HORIZON\nManual values are retained: tank 1,000, fighter 2,000, supertank 3,000, and saucer 5,000. The\nfive fixed rosters total `10,000 + 11,000 + 12,000 + 13,000 + 14,000 = 60,000`, so\n`score_cap = 60,000`. The 50,000-point bonus grants a tank but no reward. Normalization is\n`min(max(raw_score, 0), 60000) / 60000`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/battle_zone.py`):\n```python\nimport numpy as np\n\n\nDIRECTIONS = (\n (-1, 0),\n (-1, 1),\n (0, 1),\n (1, 1),\n (1, 0),\n (1, -1),\n (0, -1),\n (-1, -1),\n)\nPOINTS = {\"tank\": 1_000.0, \"fighter\": 2_000.0, \"supertank\": 3_000.0, \"saucer\": 5_000.0}\nWAVES = (\n (\"tank\", \"tank\", \"tank\", \"fighter\", \"saucer\"),\n (\"tank\", \"tank\", \"fighter\", \"fighter\", \"saucer\"),\n (\"tank\", \"tank\", \"fighter\", \"supertank\", \"saucer\"),\n (\"tank\", \"fighter\", \"fighter\", \"supertank\", \"saucer\"),\n (\"tank\", \"fighter\", \"supertank\", \"supertank\", \"saucer\"),\n)\nOBSTACLES = {(2, 2), (2, 7), (5, 1), (5, 8), (7, 3), (7, 6)}\nSPAWNS = ((0, 1), (0, 5), (0, 9), (4, 0), (4, 9))\n\n\nclass BattleZoneEnvironment:\n \"\"\"Radar combat with oriented movement, cover, shell dodging, and four target classes.\"\"\"\n\n score_cap = 60_000.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 1_500):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.player = [9, 5]\n self.previous_player = self.player.copy()\n self.direction = 0\n self.lives = 5\n self.wave = 0\n self.steps = 0\n self.total_score = 0.0\n self.bonus_awarded = False\n self.player_shell: list[int] | None = None\n self.enemy_shells: list[list[int]] = []\n self.last_action = 0\n self.terminal = False\n self._start_wave()\n\n def _start_wave(self) -> None:\n self.enemies = [\n {\"kind\": kind, \"position\": [*SPAWNS[index]], \"previous\": [*SPAWNS[index]]}\n for index, kind in enumerate(WAVES[self.wave])\n ]\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n if action == 1:\n self.direction = (self.direction - 1) % 8\n elif action == 3:\n self.direction = (self.direction + 1) % 8\n elif action in (2, 4):\n multiplier = 1 if action == 2 else -1\n row_delta, column_delta = DIRECTIONS[self.direction]\n target = [self.player[0] + multiplier * row_delta, self.player[1] + multiplier * column_delta]\n if self._open(target):\n self.player = target\n elif action == 5 and self.player_shell is None:\n row_delta, column_delta = DIRECTIONS[self.direction]\n self.player_shell = [self.player[0], self.player[1], row_delta, column_delta, 9]\n\n self._move_enemies()\n self._move_shells()\n reward = self._resolve_player_shell()\n self._resolve_enemy_shells()\n self._enemy_fire()\n self.steps += 1\n if self.total_score >= 50_000 and not self.bonus_awarded:\n self.lives += 1\n self.bonus_awarded = True\n if not self.enemies:\n self.wave += 1\n if self.wave == len(WAVES):\n self.terminal = True\n else:\n self._start_wave()\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n @staticmethod\n def _open(position: list[int]) -> bool:\n return 0 <= position[0] < 10 and 0 <= position[1] < 10 and tuple(position) not in OBSTACLES\n\n def _move_enemies(self) -> None:\n for enemy in self.enemies:\n enemy[\"previous\"] = list(enemy[\"position\"])\n kind = str(enemy[\"kind\"])\n if kind == \"saucer\":\n enemy[\"position\"][1] = (enemy[\"position\"][1] + 1) % 10\n continue\n interval = {\"tank\": 3, \"fighter\": 2, \"supertank\": 1}[kind]\n if self.steps % interval != 0:\n continue\n position = list(enemy[\"position\"])\n row_delta = int(np.sign(self.player[0] - position[0]))\n column_delta = int(np.sign(self.player[1] - position[1]))\n if kind == \"fighter\" and self.steps % 4 < 2:\n column_delta = -column_delta or 1\n candidates = ([position[0] + row_delta, position[1] + column_delta], [position[0] + row_delta, position[1]])\n for target in candidates:\n if self._open(target) and target != self.player:\n enemy[\"position\"] = target\n break\n\n def _move_shells(self) -> None:\n if self.player_shell is not None:\n self.player_shell[0] += self.player_shell[2]\n self.player_shell[1] += self.player_shell[3]\n self.player_shell[4] -= 1\n if not self._open(self.player_shell[:2]) or self.player_shell[4] <= 0:\n self.player_shell = None\n remaining = []\n for shell in self.enemy_shells:\n shell[0] += shell[2]\n shell[1] += shell[3]\n shell[4] -= 1\n if self._open(shell[:2]) and shell[4] > 0:\n remaining.append(shell)\n self.enemy_shells = remaining\n\n def _resolve_player_shell(self) -> float:\n if self.player_shell is None:\n return 0.0\n hit = next((enemy for enemy in self.enemies if enemy[\"position\"] == self.player_shell[:2]), None)\n if hit is None:\n return 0.0\n self.enemies.remove(hit)\n self.player_shell = None\n reward = POINTS[str(hit[\"kind\"])]\n self.total_score += reward\n return reward\n\n def _resolve_enemy_shells(self) -> None:\n remaining = []\n for shell in self.enemy_shells:\n friendly_hit = next((enemy for enemy in self.enemies if enemy[\"position\"] == shell[:2]), None)\n if friendly_hit is not None:\n self.enemies.remove(friendly_hit)\n elif shell[:2] == self.player:\n self._lose_tank()\n else:\n remaining.append(shell)\n self.enemy_shells = remaining\n\n def _enemy_fire(self) -> None:\n for enemy in self.enemies:\n kind = str(enemy[\"kind\"])\n if kind == \"saucer\":\n continue\n interval = {\"tank\": 12, \"fighter\": 9, \"supertank\": 7}[kind]\n if self.steps % interval != 0:\n continue\n position = list(enemy[\"position\"])\n row_delta = int(np.sign(self.player[0] - position[0]))\n column_delta = int(np.sign(self.player[1] - position[1]))\n self.enemy_shells.append([position[0], position[1], row_delta, column_delta, 10])\n\n def _lose_tank(self) -> None:\n self.lives -= 1\n self.player = [9, 5]\n self.previous_player = self.player.copy()\n self.direction = 0\n self.player_shell = None\n self.enemy_shells.clear()\n if self.lives <= 0:\n self.terminal = True\n\n def _in_view(self, position: list[int]) -> bool:\n row_delta = int(np.sign(position[0] - self.player[0]))\n column_delta = int(np.sign(position[1] - self.player[1]))\n if (row_delta, column_delta) == (0, 0):\n return True\n target_direction = DIRECTIONS.index((row_delta, column_delta))\n return min((target_direction - self.direction) % 8, (self.direction - target_direction) % 8) <= 1\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n for enemy in self.enemies:\n position = list(enemy[\"position\"])\n state[*position, 1] = True\n if self._in_view(position):\n state[*position, 2] = True\n type_marker = {\"tank\": 0, \"fighter\": 1, \"supertank\": 2, \"saucer\": 3}[str(enemy[\"kind\"])]\n state[position[0], type_marker, 5] = True\n state[*list(enemy[\"previous\"]), 4] = True\n for shell in self.enemy_shells:\n state[shell[0], shell[1], 1] = True\n if self.player_shell is not None:\n state[self.player_shell[0], self.player_shell[1], 3] = True\n state[*self.previous_player, 4] = True\n for obstacle in OBSTACLES:\n state[*obstacle, 5] = True\n state[9, : min(10, self.lives), 5] = True\n state[8, : self.wave + 1, 5] = True\n state[7, self.direction, 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 5, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/battle_zone.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "b_blast", "split": "train", "game": "b_blast", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays B Blast as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nActions 1–4 move the cursor left, up, right, and down. Hold 5 to\nanchor and expand a blast. Release with any other action to detonate,\nincluding action 0 to stay in place. Recharging shortly after a blast\nslows expansion. A blast scores 1, 2, and so on for successive hits.\nRed balls split into nine ordinary balls when blasted. Letting a red\nball reach the floor instead pays ten points and makes it ordinary.\nBalls piling up to the top end the episode.\n\nINPUT CHANNEL TABLE\nThe six channels show cursor, red balls, ordinary balls, blast center,\nblast footprint, and gauges. Gauges encode clock, charge, cooldown, and\nlast action. This adaptation replaces continuous disk physics with\ndiscrete gravity and local displacement when cells are occupied.\nMultiple balls can share a cell when the local pile is packed, so the\nbinary occupancy observation can hide multiplicity.\n\nSCORING, TERMINATION, AND HORIZON\nThe 300-step horizon permits 75 ordinary and 25 red spawns. Including\nup to nine fragments per red ball gives at most 325 blast hits across\nthe episode. Putting every hit in one combo gives a conservative\nbound, with an extra 250 points allowed for floor bonuses. The cap is\n53,225. Normalize by clipping raw score to [0, cap] and dividing by it.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/b_blast.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\nHORIZON = 300\nRED_INTERVAL = 12\nORDINARY_INTERVAL = 4\nMAX_RED = (HORIZON + RED_INTERVAL - 1) // RED_INTERVAL\nMAX_BALLS = HORIZON // ORDINARY_INTERVAL + 10 * MAX_RED\nMOVES = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}\n\n\n@dataclass\nclass Ball:\n row: int\n column: int\n red: bool = False\n\n\nclass BBlastEnvironment:\n score_cap = MAX_BALLS * (MAX_BALLS + 1) // 2 + 10 * MAX_RED\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.cursor = (5, 5)\n self.center = self.cursor\n self.steps = self.last_action = self.charge = self.cooldown = 0\n self.balls: list[Ball] = []\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n self.steps += 1\n self.cooldown = max(0, self.cooldown - 1)\n reward = 0\n if action == 5:\n if not self.charge:\n self.center = self.cursor\n self.charge = 1\n elif not self.cooldown or self.steps % 3 == 0:\n self.charge = min(12, self.charge + 1)\n else:\n if self.charge:\n reward += self._blast()\n if action in MOVES:\n dr, dc = MOVES[action]\n row, column = self.cursor\n self.cursor = max(0, min(9, row + dr)), max(0, min(9, column + dc))\n self.last_action = action\n if self.steps % RED_INTERVAL == 1:\n self.balls.append(Ball(1, int(self.random.integers(2, 8)), True))\n if self.steps % ORDINARY_INTERVAL == 0:\n self.balls.append(Ball(int(self.random.integers(2, 8)), int(self.random.integers(1, 9))))\n if self.steps % 2 == 0:\n reward += self._settle()\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _blast(self) -> int:\n row, column = self.center\n hit = [ball for ball in self.balls\n if (ball.row - row) ** 2 + (ball.column - column) ** 2 <= (self.charge / 2 + 0.5) ** 2]\n removed = {id(ball) for ball in hit}\n self.balls = [ball for ball in self.balls if id(ball) not in removed]\n for ball in hit:\n if ball.red:\n self.balls.extend(Ball(max(0, min(9, ball.row + dr)), max(0, min(9, ball.column + dc)))\n for dr in (-1, 0, 1) for dc in (-1, 0, 1))\n self.charge = 0\n self.cooldown = 6\n return len(hit) * (len(hit) + 1) // 2\n\n def _settle(self) -> int:\n reward = 0\n occupied: set[tuple[int, int]] = set()\n for ball in sorted(self.balls, key=lambda item: -item.row):\n options = [(ball.row + 1, ball.column), (ball.row, ball.column),\n (ball.row, ball.column - 1), (ball.row, ball.column + 1),\n (ball.row - 1, ball.column)]\n for row, column in options:\n if 0 <= row < 10 and 0 <= column < 10 and (row, column) not in occupied:\n ball.row, ball.column = row, column\n occupied.add((row, column))\n break\n if ball.red and ball.row == 9:\n reward += 10\n ball.red = False\n if ball.row == 0:\n self.terminal = True\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.cursor, 0] = True\n for ball in self.balls:\n state[ball.row, ball.column, 1 if ball.red else 2] = True\n if self.charge:\n state[*self.center, 3] = True\n rows, columns = np.ogrid[:10, :10]\n state[:, :, 4] = ((rows - self.center[0]) ** 2 + (columns - self.center[1]) ** 2\n <= (self.charge / 2 + 0.5) ** 2)\n for row, value in enumerate((self.steps, self.charge, self.cooldown, self.last_action)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 6, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/b_blast.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBBlast.c"} +{"name": "zaxxon", "split": "train", "game": "zaxxon", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Zaxxon as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves automatic forward flight through two asteroid fortresses separated by a\nsix-plane space battle, independent lateral position and five-level altitude, altitude-dependent\nwalls and electronic barriers, ground and airborne targets, enemy fire, draining fuel replenished\nby shooting tanks, five fighters, a 10,000-point reinforcement, and the stopped-forward-motion\nZaxxon encounter whose vulnerable missile needs three hits at skill one.\n\nACTION MAPPING\n0: maintain lane and altitude while advancing\n1: move left\n2: climb\n3: move right\n4: descend\n5: fire forward\n\nINPUT CHANNEL TABLE\n0: fighter\n1: enemy planes and hostile shots\n2: ground/fortress targets\n3: fighter blasts\n4: altitude shadow\n5: exact round, progress, altitude, lane, fuel, fighters, boss health/timer, boss state\n\nSCORING, TERMINATION, AND HORIZON\nEach fortress contains targets worth `2×300 + 2×400 + 2×400 + 500 + 1,000 = 3,700`; two total\n7,400. Six planes add 1,200. The maximum mutually exclusive boss outcome is 5,000, so one round\ncaps at 13,600 and four cap at `score_cap = 54,400`. Normalization is\n`min(max(raw_score, 0), 54_400) / 54_400`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/zaxxon.py`):\n```python\nimport numpy as np\n\n\nTARGET_SCORES = {\n \"plane\": 200,\n \"fuel\": 300,\n \"turret\": 400,\n \"mobot\": 400,\n \"dodger\": 500,\n \"radar\": 1_000,\n}\nBARRIERS = ((20, 3), (55, 1), (110, 2), (145, 3))\n\n\nclass ZaxxonEnvironment:\n \"\"\"Four finite fortress-space-fortress-boss rounds with altitude and fuel.\"\"\"\n\n score_cap = 54_400.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 4_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.round = 0\n self.lives = 5\n self.score = 0.0\n self.steps = 0\n self.last_action = 0\n self.bonus_fighter_awarded = False\n self.terminal = False\n self._start_round()\n\n def _start_round(self) -> None:\n self.progress = 0\n self.lane = 1\n self.altitude = 3\n self.fuel = 100\n self.bullets: list[list[int]] = []\n self.enemy_shots: list[list[int]] = []\n self.targets = self._targets()\n self.boss_hp = 3\n self.boss_timer = 24\n self.boss_missile = 0\n\n def _targets(self) -> list[dict[str, int | str]]:\n fortress = (\n (8, 0, 0, \"fuel\"),\n (14, 2, 0, \"turret\"),\n (27, 1, 0, \"mobot\"),\n (34, 0, 0, \"fuel\"),\n (41, 2, 1, \"turret\"),\n (47, 1, 2, \"mobot\"),\n (51, 0, 1, \"dodger\"),\n (58, 2, 0, \"radar\"),\n )\n targets = []\n identifier = 0\n for offset in (0, 90):\n for progress, lane, altitude, kind in fortress:\n targets.append({\"id\": identifier, \"progress\": progress + offset, \"lane\": lane, \"altitude\": altitude, \"kind\": kind})\n identifier += 1\n for index in range(6):\n targets.append({\"id\": identifier, \"progress\": 65 + index * 4, \"lane\": index % 3, \"altitude\": 1 + index % 4, \"kind\": \"plane\"})\n identifier += 1\n return targets\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n if action == 1:\n self.lane = max(0, self.lane - 1)\n elif action == 2:\n self.altitude = min(4, self.altitude + 1)\n elif action == 3:\n self.lane = min(2, self.lane + 1)\n elif action == 4:\n self.altitude = max(0, self.altitude - 1)\n elif action == 5:\n self.bullets.append([self.progress, self.lane, self.altitude])\n reward = self._advance_world()\n self.score += reward\n if self.score >= 10_000 and not self.bonus_fighter_awarded:\n self.lives += 1\n self.bonus_fighter_awarded = True\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _advance_world(self) -> float:\n if self.progress >= 150:\n return self._boss_step()\n previous_progress = self.progress\n self.progress += 1\n self.fuel -= 1\n for bullet in self.bullets:\n bullet[0] += 2\n reward = self._resolve_target_hits(previous_progress)\n self._move_enemy_shots()\n if any(self.progress == barrier and self.altitude != opening for barrier, opening in BARRIERS):\n self._lose_fighter()\n collision = any(\n int(target[\"progress\"]) == self.progress\n and int(target[\"lane\"]) == self.lane\n and int(target[\"altitude\"]) == self.altitude\n for target in self.targets\n )\n collision |= any(shot == [self.progress, self.lane, self.altitude] for shot in self.enemy_shots)\n if collision or self.fuel <= 0:\n self._lose_fighter()\n self._spawn_enemy_shot()\n return reward\n\n def _resolve_target_hits(self, previous_progress: int) -> float:\n reward = 0.0\n hit_ids: set[int] = set()\n used_bullets: set[int] = set()\n for bullet_index, bullet in enumerate(self.bullets):\n for target in self.targets:\n target_progress = int(target[\"progress\"])\n if not previous_progress < target_progress <= bullet[0]:\n continue\n if bullet[1] != target[\"lane\"] or bullet[2] != target[\"altitude\"]:\n continue\n hit_ids.add(int(target[\"id\"]))\n used_bullets.add(bullet_index)\n kind = str(target[\"kind\"])\n reward += TARGET_SCORES[kind]\n if kind == \"fuel\":\n self.fuel = min(100, self.fuel + 30)\n break\n self.targets = [target for target in self.targets if int(target[\"id\"]) not in hit_ids]\n self.bullets = [bullet for index, bullet in enumerate(self.bullets) if index not in used_bullets and bullet[0] <= self.progress + 10]\n return float(reward)\n\n def _spawn_enemy_shot(self) -> None:\n shooters = [target for target in self.targets if target[\"kind\"] in (\"turret\", \"mobot\", \"dodger\") and 0 < int(target[\"progress\"]) - self.progress <= 8]\n if shooters and self.steps % 5 == 0:\n source = shooters[0]\n self.enemy_shots.append([int(source[\"progress\"]), int(source[\"lane\"]), int(source[\"altitude\"])])\n\n def _move_enemy_shots(self) -> None:\n for shot in self.enemy_shots:\n shot[0] -= 1\n self.enemy_shots = [shot for shot in self.enemy_shots if shot[0] >= self.progress]\n\n def _boss_step(self) -> float:\n reward = 0.0\n aligned_bullets = [bullet for bullet in self.bullets if bullet[1] == 1 and bullet[2] == 2]\n if aligned_bullets and self.boss_missile == 0:\n self.bullets.remove(aligned_bullets[0])\n self.boss_hp -= 1\n if self.boss_hp == 0:\n reward = 5_000.0\n self._advance_round()\n return reward\n self.boss_timer -= 1\n if self.boss_timer == 0:\n self.boss_missile = 5\n if self.boss_missile:\n if aligned_bullets:\n self.bullets.remove(aligned_bullets[0])\n reward = 1_000.0\n self._advance_round()\n else:\n self.boss_missile -= 1\n if self.boss_missile == 0:\n self._lose_fighter()\n self.boss_timer = 24\n return reward\n\n def _advance_round(self) -> None:\n self.round += 1\n if self.round == 4:\n self.terminal = True\n else:\n self._start_round()\n\n def _lose_fighter(self) -> None:\n self.lives -= 1\n if self.lives <= 0:\n self.terminal = True\n return\n self.lane = 1\n self.altitude = 3\n self.fuel = max(40, self.fuel)\n self.bullets.clear()\n self.enemy_shots.clear()\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[8, 2 + self.lane * 3, 0] = True\n state[9 - self.altitude, 2 + self.lane * 3, 4] = True\n for target in self.targets:\n distance = int(target[\"progress\"]) - self.progress\n if 0 <= distance < 9:\n channel = 1 if target[\"kind\"] == \"plane\" else 2\n state[8 - distance, 2 + int(target[\"lane\"]) * 3, channel] = True\n for bullet in self.bullets:\n distance = bullet[0] - self.progress\n if 0 <= distance < 9:\n state[8 - distance, 2 + bullet[1] * 3, 3] = True\n for shot in self.enemy_shots:\n distance = shot[0] - self.progress\n if 0 <= distance < 9:\n state[8 - distance, 2 + shot[1] * 3, 1] = True\n values = ((self.round, 3), (self.progress, 8), (self.altitude, 3), (self.lane, 2), (self.fuel, 7), (self.lives, 4), (self.boss_hp, 2), (self.boss_timer, 5))\n offset = 0\n for value, width in values:\n for bit in range(width):\n state[offset // 10, offset % 10, 5] = bool(value & (1 << bit))\n offset += 1\n state[4, 0, 5] = self.progress >= 150\n state[4, 1, 5] = self.boss_missile > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 7, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/zaxxon.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "cate_p", "split": "train", "game": "cate_p", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Cate P as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to fire in your current direction and turn clockwise.\nRelease with actions 0–4 before tapping again. Only one shot can\nbe active, but you can turn while it travels. The player also\nturns automatically at the arena boundary.\n\nEnemies arrive in waves and change direction at the walls.\nA shot pierces enemies and scores a rising combo. Each new shot\nresets the combo. Enemy contact ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, enemies, shot, entering\nenemies, arena boundary, and gauges. The conversion advances four\nframes per action at fixed difficulty and uses rectangular hit\nchecks in place of sprite collisions.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 100] and divide by the fixed cap of 100. Across 100 seeds\nwithout sticky actions, idle scored zero, random inputs averaged\n21.37 and reached 78, and tapping every 12 actions averaged\n20.52 and reached 83.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/cate_p.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\nDIRECTIONS = ((1, 0), (0.7, 0.7), (0, 1), (-0.7, 0.7),\n (-1, 0), (-0.7, -0.7), (0, -1), (0.7, -0.7))\n\n\n@dataclass\nclass Mover:\n x: float\n y: float\n direction: int\n\n def move(self, speed: float) -> None:\n dx, dy = DIRECTIONS[self.direction]\n self.x += speed * dx\n self.y += speed * dy\n\n def inside(self, low: float, high: float) -> bool:\n return low <= self.x <= high and low <= self.y <= high\n\n def clamp(self) -> None:\n self.x = min(90, max(9, self.x))\n self.y = min(90, max(9, self.y))\n\n def touches(self, other: \"Mover\") -> bool:\n return abs(self.x - other.x) < 5 and abs(self.y - other.y) < 5\n\n\n@dataclass\nclass Cate(Mover):\n entering: bool = True\n\n\nclass CatePEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.wave_count = self.wave_timer = 0\n self.multiplier = 1\n self.pressed = self.terminal = False\n self.player = Mover(50, 50, 0)\n self.shot: Mover | None = None\n self.entrance: Mover | None = None\n self.newest: Cate | None = None\n self.cates: list[Cate] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(FRAMES_PER_STEP):\n reward += self._advance_frame(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self, tap: bool) -> int:\n player = self.player\n if tap or not player.inside(9, 90):\n if tap and self.shot is None:\n self.shot = Mover(player.x, player.y, player.direction)\n self.multiplier = 1\n player.clamp()\n player.direction = (player.direction + 2) % 8\n player.move(0.2)\n if self.shot is not None:\n if self.shot.inside(9, 91):\n self.shot.move(1.5)\n else:\n self.shot = None\n\n self._spawn()\n survivors = []\n reward = 0\n for cate in self.cates:\n cate.move(0.2)\n if cate.entering:\n cate.entering = not cate.inside(9, 90)\n elif not cate.inside(9, 90):\n corner = not 9 <= cate.x <= 90 and not 9 <= cate.y <= 90\n cate.direction = (cate.direction + (4 if corner else 3)) % 8\n cate.clamp()\n if self.shot is not None and cate.touches(self.shot):\n reward += self.multiplier\n self.multiplier += 1\n if self.newest is cate:\n self.newest = None\n else:\n self.terminal |= cate.touches(player)\n survivors.append(cate)\n self.cates = survivors\n return reward\n\n def _spawn(self) -> None:\n if self.wave_timer <= 0:\n direction = int(self.random.integers(4)) * 2\n offset = self.random.uniform(9, 90)\n x, y = ((-3, offset), (offset, -3), (103, offset), (offset, 103))[direction // 2]\n self.entrance = Mover(x, y, direction)\n self.wave_count = int(self.random.integers(5, 9))\n self.wave_timer = int(self.random.integers(60, 91))\n if self.wave_count == 0:\n self.wave_timer -= 1\n if self.newest is not None and self.newest.inside(3, 97):\n self.newest = None\n if self.wave_count and self.newest is None and self.entrance is not None:\n self.newest = Cate(self.entrance.x, self.entrance.y, self.entrance.direction)\n self.cates.append(self.newest)\n self.wave_count -= 1\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for channel, movers in ((0, [self.player]), (1, self.cates), (2, [self.shot])):\n for mover in movers:\n if mover is not None and mover.inside(0, 99.999):\n row, col = int(mover.y) // 10, int(mover.x) // 10\n state[row, col, channel] = True\n if isinstance(mover, Cate):\n state[row, col, 3] |= mover.entering\n state[(0, 9), :, 4] = True\n state[:, (0, 9), 4] = True\n for row, value in enumerate((self.steps, self.player.direction, self.multiplier,\n self.shot.direction if self.shot is not None else 0)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 8, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/cate_p.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/catep/main.js"} +{"name": "tt_fence", "split": "train", "game": "tt_fence", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Tt Fence as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to place the previewed fence at the tip. Release with\nany other action before placing again. The preview rotates\nautomatically, preferring orientations without overlap. Placement,\noverlap, and time raise damage. Enclose empty space to trigger a\nblast that clears cells, scores points, and reduces damage.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the fence, placement preview, recent\nblast, tip, damage bar, and counters. The board is reduced from\n15×15 to 10×10. The seven four-cell patterns and border flood fill\nare preserved. Difficulty is fixed. Each action advances up to four\nframes over 400 actions. Clip the episode score to [0, 500] and\ndivide by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/tt_fence.py`):\n```python\nfrom collections import deque\nfrom math import ceil, sqrt\n\nimport numpy as np\n\n\n_PATTERNS = ((0, 0, 0), (0, 1, 0), (0, 3, 0), (0, 0, 1), (0, 0, 3), (1, 0, 0), (3, 0, 0))\n_DIRECTIONS = ((0, 1), (1, 0), (0, -1), (-1, 0))\n_BOARD = tuple((row, col) for row in range(10) for col in range(10))\n_BORDER = tuple(cell for cell in _BOARD if 0 in cell or 9 in cell)\n\n\ndef _neighbors(cell):\n row, col = cell\n for dr, dc in _DIRECTIONS:\n neighbor = row + dr, col + dc\n if 0 <= neighbor[0] < 10 and 0 <= neighbor[1] < 10:\n yield neighbor\n\n\nclass TtFenceEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.tip = (4, 4)\n initial = self._path(int(self.random.integers(7)), int(self.random.integers(4)))\n self.fence = set(initial)\n self.tip = initial[-1]\n self.pattern = int(self.random.integers(7))\n self.angle = 0\n self.rotation_timer = 0\n self.blast = set()\n self.blast_timer = 0\n self.damage = self.damage_target = 0.\n self.steps = self.action = 0\n self.terminal = False\n self.preview = self._rotate()\n self.rotation_timer = 30\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n place = self.action == 5 and previous != 5\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(place and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, place):\n self.blast_timer -= 1\n reward = 0\n if place and self.preview:\n self.damage_target += 2 + 9 * sum(cell in self.fence for cell in self.preview)\n self.fence.update(self.preview)\n self.tip = self.preview[-1]\n reward = self._bomb()\n self.pattern = int(self.random.integers(7))\n self.rotation_timer = 0\n self.rotation_timer -= 1\n if self.rotation_timer < 0:\n self.preview = self._rotate()\n self.rotation_timer = 30\n self.damage_target += 0.01\n self.damage += (self.damage_target - self.damage) * 0.1\n self.terminal = self.damage > 99\n return reward\n\n def _path(self, pattern, angle):\n row, col = self.tip\n cells = []\n for offset in (0, *_PATTERNS[pattern]):\n dr, dc = _DIRECTIONS[(angle + offset) % 4]\n row, col = row + dr, col + dc\n cells.append((row, col))\n return cells\n\n def _rotate(self):\n fallback = None\n for turn in range(1, 5):\n angle = (self.angle + turn) % 4\n path = self._path(self.pattern, angle)\n if all(0 <= row < 10 and 0 <= col < 10 for row, col in path):\n if not self.fence.intersection(path):\n self.angle = angle\n return path\n if fallback is None:\n fallback = angle, path\n if fallback is not None:\n self.angle, path = fallback\n return path\n self.damage_target = 100\n return []\n\n def _bomb(self):\n outside = set(_BORDER) - self.fence\n queue = deque(outside)\n while queue:\n for cell in _neighbors(queue.popleft()):\n if cell not in outside and cell not in self.fence:\n outside.add(cell)\n queue.append(cell)\n enclosed = set(_BOARD) - outside - self.fence\n self.blast = {neighbor for cell in enclosed for neighbor in _neighbors(cell)}\n for _ in range(int(sqrt(len(self.blast)) * 0.5)):\n for cell in _BOARD:\n if cell in self.blast:\n self.blast.update(neighbor for neighbor in _neighbors(cell) if neighbor in self.fence)\n self.blast_timer = 30\n self.fence.difference_update(self.blast)\n count = len(self.blast)\n reward = ceil(count * sqrt(count))\n if reward:\n self.damage_target = min(99, max(0, self.damage_target - reward * 0.1))\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for row, col in self.fence:\n state[row, col, 0] = True\n for row, col in self.preview:\n state[row, col, 1] = True\n for row, col in self.blast if self.blast_timer > 0 else ():\n state[row, col, 2] = True\n state[self.tip[0], self.tip[1], 3] = True\n state[9, :min(10, ceil(self.damage / 10)), 4] = True\n values = (self.steps, self.action, self.pattern, self.angle, self.rotation_timer,\n round(self.damage * 4), round(self.damage_target * 4))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 9, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tt_fence.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/ttfence/main.js"} +{"name": "cross_line", "split": "train", "game": "cross_line", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Cross Line as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nMove the cursor with actions 1–4 (left, up, down, right). Tap\naction 5 to connect the selected point to a different point in\nthe cursor cell. Action 0 waits. The new endpoint becomes the\nselected point. Points drift in from opposite edges.\n\nA new connection removes older lines that it crosses. The most\nrecent connection is protected until another connection has been\nmade. Removed lines score 1, 2, 4, and so on within the same move.\nThe run ends when a surviving line endpoint leaves the playfield.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show downward points, upward points,\nthe selected point, lines, eligible lines, and the cursor.\nThe conversion replaces pointer input with cell selection and\nuses strict segment intersections. Each action advances four\nframes at fixed difficulty.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 100] and divide by 100. Across 100 seeds without sticky actions,\nrandom inputs averaged 1.54 points. Selecting nearby points averaged\n7.32. A heuristic that used exact positions to prioritize crossings\naveraged 33.99 and reached 83.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/cross_line.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\nDIRECTIONS = ((0, -1), (-1, 0), (1, 0), (0, 1))\nHORIZON = 400\n\n\n@dataclass(eq=False)\nclass Point:\n x: float\n y: float\n direction: int\n\n def cell(self) -> tuple[int, int]:\n return int(self.y // 10), int(self.x // 10)\n\n\n@dataclass\nclass Line:\n start: Point\n end: Point\n age: int = 0\n\n def crosses(self, other: \"Line\") -> bool:\n def side(a: Point, b: Point, p: Point) -> float:\n return (b.x - a.x) * (p.y - a.y) - (b.y - a.y) * (p.x - a.x)\n\n return (\n side(self.start, self.end, other.start) * side(self.start, self.end, other.end) < 0\n and side(other.start, other.end, self.start) * side(other.start, other.end, self.end) < 0\n )\n\n\nclass CrossLineEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.last_action = self.spawn_count = 0\n self.next_point = 0.0\n self.terminal = False\n self.cursor = (5, 5)\n self.selected = Point(70, 1, 1)\n self.points = [self.selected]\n self.lines = [Line(Point(30, 99, -1), self.selected)]\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n if 1 <= action <= 4:\n dy, dx = DIRECTIONS[action - 1]\n row, col = self.cursor\n self.cursor = min(9, max(0, row + dy)), min(9, max(0, col + dx))\n connect = action == 5 and self.last_action != 5\n self.last_action = action\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance_frame(connect and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self, connect: bool) -> int:\n depth = max((point.y if point.direction > 0 else 100 - point.y for point in self.points), default=0)\n scroll = 0.03 + max(0, 40 - depth) * 0.1\n self.next_point -= scroll\n while self.next_point < 0:\n direction = -1 if self.spawn_count % 2 == 0 else 1\n pair = self.spawn_count // 2 % 7\n lo, hi = {3: (10, 30), 6: (70, 90)}.get(pair, (10, 90))\n y = -19 - self.next_point if direction > 0 else 119 + self.next_point\n self.points.append(Point(self.random.uniform(lo, hi), y, direction))\n self.next_point += 4\n self.spawn_count += 1\n\n endpoints = {point for line in self.lines for point in (line.start, line.end)}\n for point in endpoints.union(self.points):\n point.y += scroll * point.direction\n reward = self._connect() if connect else 0\n self.terminal = any(\n not 0 <= point.y <= 99\n for line in self.lines for point in (line.start, line.end)\n )\n return reward\n\n def _connect(self) -> int:\n candidate = next((point for point in self.points\n if point is not self.selected and point.cell() == self.cursor), None)\n if candidate is None:\n return 0\n new_line = Line(self.selected, candidate)\n self.points.remove(self.selected)\n self.selected = candidate\n reward, multiplier = 0, 1\n survivors = []\n for line in self.lines:\n line.age += 1\n if line.age >= 2 and line.crosses(new_line):\n reward += multiplier\n multiplier *= 2\n else:\n survivors.append(line)\n self.lines = [*survivors, new_line]\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for point in self.points:\n row, col = point.cell()\n if 0 <= row < 10 and 0 <= col < 10:\n channel = 2 if point is self.selected else int(point.direction < 0)\n state[row, col, channel] = True\n for line in self.lines:\n for fraction in np.linspace(0, 1, 20):\n row = int((line.start.y + (line.end.y - line.start.y) * fraction) // 10)\n col = int((line.start.x + (line.end.x - line.start.x) * fraction) // 10)\n if 0 <= row < 10 and 0 <= col < 10:\n state[row, col, 3] = True\n state[row, col, 4] |= line.age >= 1\n row, col = self.cursor\n state[row, col, 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 10, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/cross_line.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/crossline/main.js"} +{"name": "geocent", "split": "train", "game": "geocent", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Geocent as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to speed up and turn inward. Release with actions\n0–4 for a slower approach and a turn in the opposite direction.\nA new press adds a brief speed boost.\n\nDeliver crates to Earth. Passing near other planets or the Sun\ncan destroy trailing crates. A direct hit ends the run. Each\ndelivery scores one point per surviving crate and starts a new\napproach with one more crate than survived the last trip.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the rocket, hazards, Earth, crates,\nan inward heading marker, and gauges. Each action advances four\nframes at fixed difficulty. The conversion uses distance checks\nfor collisions.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action task clips raw scores to [0, 100] and divides by\n100. Across 100 seeds without sticky actions, idle averaged\n1.15, continuous hold averaged 2.74 and reached 28, and random\ninputs averaged 2.54.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/geocent.py`):\n```python\nfrom collections import deque\nimport math\n\nimport numpy as np\n\n\nEARTH = 3\n\n\nclass GeocentEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = 0\n self.pressed = self.terminal = False\n self.phases = self.random.uniform(0, math.tau, 9)\n self.planets = np.zeros((9, 2))\n self.crates: list[int] = []\n self.history: deque[tuple[float, float]] = deque()\n self.turn = 0.0\n self._launch()\n self._locate_planets()\n\n def _launch(self) -> None:\n self.angle = (self.random.integers(4) + self.random.uniform(0.3, 0.7)) * math.pi / 2\n self.distance = abs(math.sin(2 * self.angle)) * 25 + 36\n self.speed = 0.0\n self.crates = list(range(9, 9 * (len(self.crates) + 1) + 1, 9))\n self.history = deque(maxlen=max(self.crates) + 1)\n\n def _locate_planets(self) -> None:\n radii = np.arange(9) * 4\n self.planets[:, 0] = radii * np.cos(self.phases)\n self.planets[:, 1] = radii * np.sin(self.phases)\n self.planets += 50 - self.planets[EARTH].copy()\n\n @property\n def position(self) -> tuple[float, float]:\n return 50 + self.distance * math.cos(self.angle), 50 + self.distance * math.sin(self.angle)\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _hazard(self, x: float, y: float, margin: float) -> bool:\n return any(math.hypot(px - x, py - y) < margin + (3 if index == 0 else 1)\n for index, (px, py) in enumerate(self.planets) if index != EARTH)\n\n def _advance(self, tap: bool) -> int:\n self.phases += 0.03 * 0.7 ** np.arange(1, 10)\n self._locate_planets()\n if tap:\n self.speed += 1\n self.speed += ((0.5 if self.pressed else 0.1) - self.speed) * 0.5\n self.distance -= self.speed\n self.turn += ((0.03 if self.pressed else -0.003) - self.turn) * 0.05\n self.angle = (self.angle + self.turn) % math.tau\n x, y = self.position\n self.history.appendleft((x, y))\n self.crates = [age for age in self.crates\n if not self._hazard(*(self.history[age] if age < len(self.history) else (x, y)), 1)]\n if self.distance < 3.5:\n reward = len(self.crates)\n self._launch()\n return reward\n self.terminal = self._hazard(x, y, 1.5)\n return 0\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n\n def mark(x: float, y: float, channel: int) -> None:\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y) // 10, int(x) // 10, channel] = True\n\n for index, (x, y) in enumerate(self.planets):\n mark(x, y, 2 if index == EARTH else 1)\n x, y = self.position\n mark(min(99, max(0, x)), min(99, max(0, y)), 0)\n for age in self.crates:\n mark(*(self.history[age] if age < len(self.history) else (x, y)), 3)\n mark(50 + (self.distance - 8) * math.cos(self.angle),\n 50 + (self.distance - 8) * math.sin(self.angle), 4)\n for row, value in enumerate((self.steps, len(self.crates), round(self.distance * 4), round(self.angle * 80))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 11, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/geocent.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/geocent/main.js"} +{"name": "skiing", "split": "train", "game": "skiing", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Skiing as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves the Olympic slalom's 50 gates, downhill scrolling, gate pairs,\neight ski orientations, faster straight-line descent, slower carving and stopping traverses,\nlooking ahead for a racing line, trees and moguls, non-terminal falls with time loss, missed-gate\npenalties, a finite finish, and the fire-button restart at the top.\n\nACTION MAPPING\n0: coast at current ski angle\n1: turn skis one position left\n2: straighten skis one position\n3: turn skis one position right\n4: turn fully across the slope\n5: restart at the top\n\nINPUT CHANNEL TABLE\n0: skier\n1: trees and moguls\n2: gate poles\n3: reserved\n4: previous skier position and exact movement/timing metadata\n5: passed and missed gate identities\n\nSCORING, TERMINATION, AND HORIZON\nEach of 50 gates can pay 100 once and the finish can pay 1,000 once, so\n`score_cap = 50 × 100 + 1,000 = 6,000`. Normalization is\n`min(max(raw_score, 0), 6_000) / 6_000`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/skiing.py`):\n```python\nimport numpy as np\n\n\nGATE_OFFSETS = tuple(2 + index * 2 for index in range(50))\nGATE_COLUMNS = tuple(1 + (index * 3 + 2) % 8 for index in range(50))\nOBSTACLES = tuple((3 + index * 4, (index * 5 + 1) % 10) for index in range(24))\n\n\nclass SkiingEnvironment:\n \"\"\"Olympic slalom with ski-angle speed, gates, trees, and timed recovery.\"\"\"\n\n score_cap = 6_000.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 300):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self._restart_run()\n\n def _restart_run(self) -> None:\n self.progress = 0\n self.column = 5\n self.previous_column = self.column\n self.angle = 0\n self.previous_angle = self.angle\n self.recovery = 0\n self.score = 0.0\n self.passed: set[int] = set()\n self.missed: set[int] = set()\n self.crashed: set[int] = set()\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_column = self.column\n self.previous_angle = self.angle\n reward = 0.0\n if action == 5:\n self._restart_run()\n elif self.recovery > 0:\n self.recovery -= 1\n else:\n if action == 1:\n self.angle = max(-3, self.angle - 1)\n elif action == 3:\n self.angle = min(3, self.angle + 1)\n elif action == 2:\n self.angle -= int(np.sign(self.angle))\n elif action == 4:\n self.angle = -3 if self.angle <= 0 else 3\n progress_before = self.progress\n speed = 2 if self.angle == 0 else 1 if abs(self.angle) <= 2 else 0\n self.progress = min(100, self.progress + speed)\n self.column = min(9, max(0, self.column + int(np.sign(self.angle))))\n reward += self._resolve_gates(progress_before)\n self._resolve_obstacles(progress_before)\n if self.progress >= 100:\n reward += 1_000.0\n self.terminal = True\n self.score += reward\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _resolve_gates(self, previous_progress: int) -> float:\n reward = 0.0\n for index, (offset, gate_column) in enumerate(zip(GATE_OFFSETS, GATE_COLUMNS, strict=True)):\n if index in self.passed or index in self.missed or not previous_progress < offset <= self.progress:\n continue\n if abs(self.column - gate_column) <= 1:\n self.passed.add(index)\n reward += 100.0\n else:\n self.missed.add(index)\n return reward\n\n def _resolve_obstacles(self, previous_progress: int) -> None:\n for index, (offset, column) in enumerate(OBSTACLES):\n if index in self.crashed or not previous_progress < offset <= self.progress:\n continue\n if self.column == column:\n self.crashed.add(index)\n self.recovery = 3\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[2, self.column, 0] = True\n state[2, self.previous_column, 4] = True\n for index, (offset, gate_column) in enumerate(zip(GATE_OFFSETS, GATE_COLUMNS, strict=True)):\n row = 2 + offset - self.progress\n if 0 <= row < 10 and index not in self.passed and index not in self.missed:\n state[row, max(0, gate_column - 1), 2] = True\n state[row, min(9, gate_column + 1), 2] = True\n for index, (offset, column) in enumerate(OBSTACLES):\n row = 2 + offset - self.progress\n if 0 <= row < 10 and index not in self.crashed:\n state[row, column, 1] = True\n for index in range(50):\n state[index // 10, index % 10, 5] = index in self.passed\n state[5 + index // 10, index % 10, 5] = index in self.missed\n values = (\n (self.progress, 7),\n (self.column, 4),\n (self.angle + 3, 3),\n (self.previous_angle + 3, 3),\n (self.recovery, 2),\n (self.steps, 9),\n )\n offset = 0\n for value, width in values:\n for bit in range(width):\n index = offset + bit\n state[index // 10, index % 10, 4] = bool(value & (1 << bit))\n offset += width\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 12, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/skiing.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "monkey_t", "split": "train", "game": "monkey_t", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Monkey T as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to compress the trampoline. Release with\nactions 0–4 to charge the next bounce and reset the\nper-launch collection count. The monkey moves sideways\nautomatically. Collect fruit and avoid crossing hazards.\n\nEach pickup adds the current per-launch count to the\nmultiplier, then scores the multiplier. Clearing all five\npickups spawns a new set. Hazard contact ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the monkey, pickups, hazards\nby direction, trampoline, and gauges. The conversion uses\nrectangular collision bounds and four frames per action\nat fixed difficulty. The 400-action task clips scores to\n[0, 500] and divides by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/monkey_t.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Hazard:\n x: float\n y: float\n speed: float\n\n\nclass MonkeyTEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y, self.vx, self.vy = 50.0, 90.0, 0.3, 0.0\n self.count = self.compression = self.power = self.steps = 0\n self.multiplier = 1\n self.pressed = self.terminal = False\n self._spawn_coins()\n self.hazards = [Hazard(self.random.uniform(10, 90), self.random.uniform(10, 70),\n 0.5 + i * 0.1) for i in range(3)]\n\n def _spawn_coins(self):\n self.coins = [(self.random.uniform(30, 70), self.random.uniform(20, 70)) for _ in range(5)]\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed:\n self.power = self.compression = 0\n elif self.pressed and not pressed:\n self.power = self.compression\n self.compression = self.count = 0\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n @property\n def trampoline_y(self):\n return 90 + (self.compression + self.power) * 0.25\n\n def _advance(self):\n if self.pressed:\n self.compression = min(30, self.compression + 1)\n self.vy += 0.1\n self.x += self.vx\n self.y += self.vy\n if (self.x < 25 and self.vx < 0) or (self.x > 75 and self.vx > 0):\n self.vx *= -1\n if self.vy > 0 and abs(self.y - self.trampoline_y) < 4:\n self.y = self.trampoline_y - 5\n self.vy = -self.vy * 0.2 - self.power * 0.13\n if self.power > 1:\n self.power = 0\n if self.y > 99:\n self.y = 80\n remaining = []\n reward = 0\n for x, y in self.coins:\n if abs(x - self.x) < 5 and abs(y - self.y) < 5:\n self.multiplier += self.count\n self.count += 1\n reward += self.multiplier\n else:\n remaining.append((x, y))\n self.coins = remaining\n if not self.coins:\n self._spawn_coins()\n for hazard in self.hazards:\n inward = (hazard.x < 10 and hazard.speed > 0) or (hazard.x > 90 and hazard.speed < 0)\n hazard.x += hazard.speed * (0.5 if inward else 1)\n if (hazard.x < -10 and hazard.speed < 0) or (hazard.x > 110 and hazard.speed > 0):\n hazard.y = self.random.uniform(10, 70)\n hazard.speed *= -1\n self.terminal |= abs(hazard.x - self.x) < 5 and abs(hazard.y - self.y) < 5\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, max(0, int(self.y // 10))), int(self.x // 10), 0] = True\n for x, y in self.coins:\n state[int(y // 10), int(x // 10), 1] = True\n for hazard in self.hazards:\n if 0 <= hazard.x < 100:\n state[int(hazard.y // 10), int(hazard.x // 10), 2 + (hazard.speed < 0)] = True\n state[int(self.trampoline_y // 10), 2:8, 4] = True\n values = (self.steps, self.compression, self.power, self.count, self.multiplier,\n round((self.vy + 10) * 20))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(min(511, max(0, value)) & (1 << bit))\n state[9, :2, 5] = self.pressed, self.vx > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 13, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/monkey_t.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameMonkeyT.c"} +{"name": "zip_fall", "split": "train", "game": "zip_fall", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Zip Fall as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to let go and drop. Release with any other action\nbefore tapping again. Touching a line catches it automatically.\nOn a line, the backpacker moves sideways and reverses at the ends.\nCoins pay the current multiplier and raise it by three. Each\nreversal lowers it by one. Hitting an obstacle or scrolling off\nthe top ends the run.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the backpacker, lines, obstacles, coins,\nattachment status, and counters. The port fixes difficulty and uses\nrectangular overlap for collisions. Each action advances up to four\nframes over 400 actions. Clip episode scores to [0, 500] and divide\nby 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/zip_fall.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Line:\n y: float\n\n\n@dataclass\nclass Object:\n x: float\n y: float\n vx: float\n coin: bool\n\n\nclass ZipFallEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.lines = [Line(y) for y in (20, 50, 75)]\n self.attached = self.lines[0]\n self.x, self.y, self.vx, self.vy = 20., 20., 1, 0.\n self.objects = []\n self.line_distance = self.object_timer = 0.\n self.multiplier = 1\n self.steps = self.action = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n drop = self.action == 5 and previous != 5\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(drop and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, drop):\n scroll = 0.05 + max(0, self.y - 30) * 0.1\n if drop:\n self.y += 5\n self.vy = 1\n self.attached = None\n if self.attached is None:\n self.vy += 0.1\n self.y += self.vy - scroll\n else:\n self.y = self.attached.y + 3\n self.x += self.vx\n if (self.x < 20 and self.vx < 0) or (self.x > 80 and self.vx > 0):\n self.vx *= -1\n self.multiplier = max(1, self.multiplier - 1)\n if self.y < 3:\n self.terminal = True\n return 0\n\n for line in self.lines:\n if self.attached is None and 17 < self.x < 83 and abs(line.y - self.y) < 4:\n self.attached = line\n line.y -= scroll\n self.lines = [line for line in self.lines if line.y >= 0]\n self.line_distance -= scroll\n if self.line_distance < 0:\n self.lines.append(Line(100))\n self.line_distance = self.random.uniform(20, 40)\n\n self.object_timer -= 1\n if self.object_timer <= 0:\n coin = self.random.random() >= 0.6\n vx = self.random.uniform(0.5, 1) * self.random.choice((-1, 1))\n self.objects.append(Object(-3 if vx > 0 else 103, self.random.uniform(0, 120), vx, coin))\n self.object_timer = self.random.uniform(20, 30)\n reward = 0\n remaining = []\n for obj in self.objects:\n obj.y -= scroll\n obj.x += obj.vx\n if abs(obj.x - self.x) < 5 and abs(obj.y - self.y) < 5:\n if obj.coin:\n reward += self.multiplier\n self.multiplier += 3\n continue\n self.terminal = True\n if -5 <= obj.x <= 105:\n remaining.append(obj)\n self.objects = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n row, col = int(np.clip(self.y // 10, 0, 9)), int(self.x // 10)\n state[row, col, 0] = True\n state[row, col, 4] = self.attached is not None\n for line in self.lines:\n state[min(9, int(line.y // 10)), 2:8, 1] = True\n for obj in self.objects:\n if 0 <= obj.x < 100 and 0 <= obj.y < 100:\n state[int(obj.y // 10), int(obj.x // 10), 3 if obj.coin else 2] = True\n values = (self.steps, self.action, self.vx > 0, round(self.vy * 32), self.multiplier,\n round(self.line_distance * 8), round(self.object_timer * 8))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 14, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/zip_fall.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameZipFall.c"} +{"name": "hoard_spout", "split": "train", "game": "hoard_spout", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Hoard Spout as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to accelerate, turn, and emit sparks more often.\nRelease with actions 0–4 to switch between red and blue.\nSparks emerge in the opposite color and mature over time.\nCollecting a mature spark of your color scores your current\nsize rounded down and makes you grow. Mature sparks of the\nother color shrink you. Your size also declines over time.\nThe run ends when it falls below one.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, young and mature\nred sparks, young and mature blue sparks, and gauges.\nThe conversion uses approximate oriented hitboxes and fixed\ndifficulty. Each action advances four frames. The 400-action\ntask clips raw scores to [0, 150] and divides by 150.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/hoard_spout.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Spark:\n x: float\n y: float\n vx: float\n vy: float\n blue: bool\n size: float = 1.0\n\n\nclass HoardSpoutEnvironment:\n score_cap = 150\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x = self.y = 50.0\n self.angle = self.random.uniform(0, math.tau)\n self.speed, self.size = 1.0, 3.0\n self.spawn_timer = 0.0\n self.steps = 0\n self.blue = self.pressed = self.terminal = False\n self.sparks: list[Spark] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n released = self.pressed and not pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(released and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, released: bool) -> int:\n self.x += math.cos(self.angle) * self.speed\n self.y += math.sin(self.angle) * self.speed\n if released:\n self.blue = not self.blue\n if self.pressed:\n if self.speed < 2:\n self.speed += 0.01\n self.angle += 0.01\n else:\n self.speed += (1 - self.speed) * 0.1\n self.spawn_timer -= 1.1 if self.pressed else 0.1\n if self.spawn_timer < 0:\n angle = self.angle + math.pi + self.random.uniform(-0.2, 0.2)\n self.sparks.append(Spark(self.x, self.y, math.cos(angle), math.sin(angle), not self.blue))\n self.spawn_timer = 9\n if not 0 <= self.x <= 100:\n self.x = min(100, max(0, self.x))\n self.angle = math.pi - self.angle\n if not 0 <= self.y <= 100:\n self.y = min(100, max(0, self.y))\n self.angle = -self.angle\n self.size = min(9, self.size - 0.002)\n if self.size < 1:\n self.terminal = True\n return 0\n reward = 0\n remaining = []\n for spark in self.sparks:\n spark.x += spark.vx\n spark.y += spark.vy\n spark.size += 0.2 if spark.size < 5 else 0.01\n if spark.size > 9:\n continue\n if spark.size >= 5 and self._hits_player(spark):\n if spark.blue == self.blue:\n reward += math.floor(self.size)\n self.size += 0.2\n else:\n self.size -= 0.4\n continue\n if not 0 <= spark.x <= 100:\n spark.x = min(100, max(0, spark.x))\n spark.vx *= -1\n if not 0 <= spark.y <= 100:\n spark.y = min(100, max(0, spark.y))\n spark.vy *= -1\n remaining.append(spark)\n self.sparks = remaining\n return reward\n\n def _hits_player(self, spark: Spark) -> bool:\n dx, dy = spark.x - self.x, spark.y - self.y\n cosine, sine = math.cos(self.angle), math.sin(self.angle)\n return (abs(dx * cosine + dy * sine) < (self.size + 3 + spark.size) / 2\n and abs(-dx * sine + dy * cosine) < (self.size + spark.size) / 2)\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, int(self.y) // 10), min(9, int(self.x) // 10), 0] = True\n for spark in self.sparks:\n channel = 1 + 2 * spark.blue + (spark.size >= 5)\n state[min(9, int(spark.y) // 10), min(9, int(spark.x) // 10), channel] = True\n for row, value in enumerate((self.steps, round(self.size * 50),\n round((self.angle % math.tau) * 80), round(self.speed * 100))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.blue\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 15, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/hoard_spout.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameHoardSpout.c"} +{"name": "twin_jumpers", "split": "train", "game": "twin_jumpers", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Twin Jumpers as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to jump with both characters. Each can jump during a\nshort window after landing. The first jumps higher. Holding action 5\nreduces gravity, and each fresh press temporarily reduces shared jump\npower. Both characters move sideways automatically and reverse at\nthe edges. Keeping both high speeds up scrolling and earns more\npoints. The run ends if either falls below the screen.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show each jumper, platforms, each jumper's\njump eligibility, and counters. The port fixes difficulty and uses\nswept geometric landing checks in place of sprite overlap. Each action\nadvances up to four frames over 400 actions. Clip the episode score\nto [0, 1000] and divide by 1000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/twin_jumpers.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Jumper:\n x: float\n y: float = 70.\n vx: int = 1\n vy: float = 0.\n grace: int = 0\n\n\n@dataclass\nclass Platform:\n x: float\n y: float\n width: float\n\n\nclass TwinJumpersEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.jumpers = [Jumper(20), Jumper(80)]\n self.platforms = [Platform(50, 80, 100)]\n for y in (70, 40, 10):\n for low in (0, 60):\n self.platforms.append(Platform(self.random.uniform(low, low + 40), y,\n self.random.uniform(20, 50)))\n self.power = 1.\n self.platform_distance = 0.\n self.steps = self.action = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n jump = self.action == 5 and previous != 5\n self.steps += 1\n reward = 0.\n for frame in range(4):\n reward += self._advance(jump and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _advance(self, jump):\n scroll = 0.1 + max(0, 60 - max(jumper.y for jumper in self.jumpers)) * 0.05\n if jump:\n for jumper, strength in zip(self.jumpers, (3, 2.5), strict=True):\n if jumper.grace > 0:\n jumper.vy = -strength * self.power\n self.power *= 0.8\n else:\n self.power = min(1, self.power + 0.01)\n\n previous_y = [jumper.y for jumper in self.jumpers]\n for jumper in self.jumpers:\n jumper.y += jumper.vy\n jumper.vy += 0.1 if self.action == 5 else 0.2\n jumper.x += jumper.vx * 0.6\n jumper.grace = max(0, jumper.grace - 1)\n if (jumper.x < 3 and jumper.vx < 0) or (jumper.x > 97 and jumper.vx > 0):\n jumper.vx *= -1\n if jumper.y < 0 and jumper.vy < 0:\n jumper.y = 0\n jumper.vy *= -0.5\n\n for platform in self.platforms:\n platform.y += scroll\n self.platforms = [platform for platform in self.platforms if platform.y <= 109]\n self.platform_distance -= scroll\n if self.platform_distance <= 0:\n for low in (0, 50):\n self.platforms.append(Platform(self.random.uniform(low, low + 50),\n -self.random.uniform(5, 25),\n self.random.uniform(30, 50)))\n self.platform_distance = self.random.uniform(20, 30)\n for jumper, old_y, offset in zip(self.jumpers, previous_y, (4, 3), strict=True):\n if jumper.vy <= 0:\n continue\n supports = [\n platform.y - offset for platform in self.platforms\n if abs(platform.x - jumper.x) < platform.width / 2 + 2\n and min(jumper.y - 2, old_y - scroll) <= platform.y - offset <= jumper.y + 1\n ]\n if supports:\n jumper.y = min(supports)\n jumper.vy = 0.\n jumper.grace = 9\n self.terminal = any(jumper.y > 102 for jumper in self.jumpers)\n return scroll\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for index, jumper in enumerate(self.jumpers):\n row = int(np.clip(jumper.y // 10, 0, 9))\n col = int(jumper.x // 10)\n state[row, col, index] = True\n state[row, col, 3 + index] = jumper.grace > 0\n cols = np.arange(5, 100, 10)\n for platform in self.platforms:\n if 0 <= platform.y < 100:\n state[int(platform.y // 10), :, 2] |= abs(cols - platform.x) < platform.width / 2 + 5\n values = (self.steps, self.action, round(self.power * 100), round(self.platform_distance * 10),\n *(value for jumper in self.jumpers for value in\n (jumper.vx > 0, jumper.grace, round((jumper.vy + 4) * 32))))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 16, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/twin_jumpers.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameTwinJumpers.c"} +{"name": "block_stacker", "split": "train", "game": "block_stacker", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Block Stacker as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to release the swinging block. Release with actions\n0–4 before the next tap. The block carries horizontal velocity\nfrom the swing and accelerates downward. Landing on any supported\nblock scores one point. The tower drifts sideways and wraps around\nthe screen. As it grows, the camera scrolls and old blocks leave\nthe bottom. A missed drop or loss of all support ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the tower, hanging block, falling\nblock, pendulum, leftward tower drift, and gauges. Each action\nadvances four frames. The conversion increases difficulty and\ndrift with successful placements and checks landings by crossing\na support block's top.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip the raw score to\n[0, 50] and divide by the fixed cap of 50.\n\nAcross 100 seeds without sticky actions, idle scored zero,\nholding scored one, and random taps averaged 26.66 raw points\nand reached 42.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/block_stacker.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\n\n\n@dataclass\nclass Block:\n x: float\n y: float\n width: float\n\n\nclass BlockStackerEnvironment:\n score_cap = 50\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.stacked = 0\n self.pressed = self.falling = self.terminal = False\n self.angle = self.vx = self.vy = self.drift = 0.0\n self.current = Block(50, 25, self.random.uniform(10, 30))\n self.tower = [Block(50, 99, 99)]\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(FRAMES_PER_STEP):\n reward += self._advance_frame(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self, tap: bool) -> int:\n difficulty = 1 + self.stacked / 50\n self.angle += 0.05 * difficulty\n previous_y = self.current.y\n if self.falling:\n self.current.x += self.vx * difficulty\n self.current.y += self.vy * difficulty\n self.vy += 0.1\n else:\n swing = math.sin(self.angle)\n self.current.x = 50 - 20 * math.sin(swing)\n self.current.y = 5 + 20 * math.cos(swing)\n if tap:\n self.falling = True\n self.vx, self.vy = -math.cos(self.angle), 0.0\n\n for block in self.tower:\n block.x = (block.x + self.drift) % 100\n top = min(block.y for block in self.tower)\n reward = 0\n if self.falling:\n for block in sorted(self.tower, key=lambda block: block.y):\n distance = abs((self.current.x - block.x + 50) % 100 - 50)\n if previous_y <= block.y - 10 <= self.current.y and distance < (self.current.width + block.width) / 2:\n self.current.y = block.y - 10\n self.tower.append(self.current)\n self.current = Block(50, 25, self.random.uniform(10, 30))\n self.falling = False\n self.stacked += 1\n self.drift = self.random.uniform(-1, 1) * self.stacked / 50\n reward = 1\n break\n else:\n self.terminal = self.current.y > 105\n scroll = difficulty * 0.01 + max(0, 70 - top) * 0.1\n for block in self.tower:\n block.y += scroll\n self.tower = [block for block in self.tower if block.y <= 106]\n self.terminal |= not self.tower\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for block in self.tower:\n self._draw_block(state, block, 0, wraps=True)\n self._draw_block(state, self.current, 2 if self.falling else 1, wraps=False)\n if not self.falling:\n for fraction in np.linspace(0, 1, 8):\n x = 50 + (self.current.x - 50) * fraction\n y = (self.current.y - 5) * fraction\n state[int(y) // 10, int(x) // 10, 3] = True\n if self.drift < 0:\n state[:, :, 4] = state[:, :, 0]\n state[9, 0, 5] = self.pressed\n for row, value in enumerate((self.steps, self.stacked)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 1, 5] = (self.vx < 0 if self.falling else math.cos(self.angle) > 0)\n return state\n\n @staticmethod\n def _draw_block(state: np.ndarray, block: Block, channel: int, wraps: bool) -> None:\n for row in range(10):\n if row * 10 < block.y + 5 and (row + 1) * 10 > block.y - 5:\n for column in range(10):\n dx = column * 10 + 5 - block.x\n distance = abs((dx + 50) % 100 - 50) if wraps else abs(dx)\n state[row, column, channel] |= distance < block.width / 2 + 5\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 17, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/block_stacker.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBlockStacker.c"} +{"name": "phoenix", "split": "train", "game": "phoenix", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Phoenix as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves each five-stage cycle: two flocks of small horizontal/swooping birds,\ntwo flocks of large regenerative Phoenixes, then the alien mothership. The cannon moves left and\nright, fires one shot at a time, and can raise a short shield that locks movement and then has a\ncooldown. Small birds pay more while low and swooping. Large birds have wings that regenerate and\na vulnerable center, with proximity scoring. The mothership requires two hits through the hull\nunder its cockpit and a pilot shot timed with the rotating opening.\n\nACTION MAPPING\n0: wait\n1: move left\n2: unused\n3: move right\n4: activate force field\n5: fire\n\nINPUT CHANNEL TABLE\n0: laser cannon\n1: birds, bombs, and alien pilot\n2: laser shot and lives\n3: force field, wing-reward state, hull, and rotating opening\n4: previous cannon, bird, bomb, and shot positions\n5: exact cycle/stage/lives, shield timing, wing identities, step timers, hull health, opening, and rotation direction\n\nSCORING, TERMINATION, AND HORIZON\nPer cycle, the two small waves can pay `2 × 8 × 80 = 1,280`. The two large waves can pay one\n20-point wing hit plus a 500-point close center kill for each of four birds, or\n`2 × 4 × 520 = 4,160`. The pilot maximum begins at 4,000 and rises by 1,000 per cycle, but the\ntwo mandatory hull shots make the reachable awards 3,800, 4,800, and 5,800. Across three cycles,\n`score_cap = 3 × (1,280 + 4,160) + 3,800 + 4,800 + 5,800 = 30,720`. Normalization is\n`min(max(raw_score, 0), 30_720) / 30_720`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/phoenix.py`):\n```python\nimport numpy as np\n\n\nclass PhoenixEnvironment:\n \"\"\"Three five-stage Phoenix cycles with shield and layered mothership.\"\"\"\n\n score_cap = 30_720.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 4_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.cycle = 0\n self.stage = 0\n self.lives = 5\n self.score = 0.0\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self._start_stage()\n\n def _start_stage(self) -> None:\n self.player_column = 5\n self.previous_player_column = 5\n self.shield_timer = 0\n self.shield_cooldown = 0\n self.shot: list[int] | None = None\n self.previous_shot: list[int] | None = None\n self.bombs: list[list[int]] = []\n self.previous_bombs: list[list[int]] = []\n self.stage_steps = 0\n if self.stage < 2:\n self.enemies = [\n {\"id\": index, \"position\": [1 + index // 4, 1 + (index % 4) * 2], \"direction\": 1 if index % 2 == 0 else -1}\n for index in range(8)\n ]\n self.wing_rewarded: set[int] = set()\n elif self.stage < 4:\n self.enemies = [\n {\"id\": index, \"position\": [1 + index // 2, 2 + (index % 2) * 5], \"direction\": 1 if index % 2 == 0 else -1}\n for index in range(4)\n ]\n self.wing_rewarded = set()\n else:\n self.enemies = []\n self.hull_health = [0, 0, 2, 2, 2, 2, 2, 2, 0, 0]\n self.rotating_hole = 2\n self.rotating_direction = 1\n self.mothership_shots = 0\n self.previous_enemies = {int(enemy[\"id\"]): list(enemy[\"position\"]) for enemy in self.enemies}\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player_column = self.player_column\n self.previous_shot = None if self.shot is None else self.shot.copy()\n self.previous_bombs = [bomb.copy() for bomb in self.bombs]\n self.previous_enemies = {int(enemy[\"id\"]): list(enemy[\"position\"]) for enemy in self.enemies}\n if self.shield_timer == 0:\n if action == 1:\n self.player_column = max(0, self.player_column - 1)\n elif action == 3:\n self.player_column = min(9, self.player_column + 1)\n elif action == 4 and self.shield_cooldown == 0:\n self.shield_timer = 3\n self.shield_cooldown = 10\n if action == 5 and self.shot is None:\n self.shot = [7, self.player_column]\n stage_before = (self.cycle, self.stage)\n reward = self._move_shot()\n if (self.cycle, self.stage) == stage_before and not self.terminal:\n if self.stage < 4:\n self._move_birds()\n else:\n self._move_mothership()\n self._move_bombs()\n reward += self._resolve_collisions()\n self.score += reward\n self.steps += 1\n self.stage_steps += 1\n self.shield_timer = max(0, self.shield_timer - 1)\n self.shield_cooldown = max(0, self.shield_cooldown - 1)\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_shot(self) -> float:\n if self.shot is None:\n return 0.0\n self.shot[0] -= 1\n if self.stage < 2:\n for enemy in list(self.enemies):\n if self.shot == enemy[\"position\"]:\n reward = 80.0 if enemy[\"position\"][0] >= 5 else 20.0\n self.enemies.remove(enemy)\n self.shot = None\n self._advance_if_clear()\n return reward\n elif self.stage < 4:\n for enemy in list(self.enemies):\n row, column = enemy[\"position\"]\n if self.shot[0] != row:\n continue\n if self.shot[1] == column:\n reward = float(100 + min(4, row - 1) * 100)\n self.enemies.remove(enemy)\n self.shot = None\n self._advance_if_clear()\n return reward\n if abs(self.shot[1] - column) == 1:\n reward = 0.0\n if enemy[\"id\"] not in self.wing_rewarded:\n self.wing_rewarded.add(enemy[\"id\"])\n reward = 20.0\n self.shot = None\n return reward\n else:\n self.mothership_shots += 1\n row, column = self.shot\n if row == 2 and self.hull_health[column] > 0:\n self.hull_health[column] -= 1\n self.shot = None\n return 0.0\n if row == 1 and column == 5 and self.hull_health[5] == 0 and self.rotating_hole == 5:\n maximum = 4_000 + self.cycle * 1_000\n reward = float(max(1_000, maximum - max(0, self.mothership_shots - 1) * 100))\n self.shot = None\n self._advance_stage()\n return reward\n if self.shot is not None and self.shot[0] < 0:\n self.shot = None\n return 0.0\n\n def _move_birds(self) -> None:\n for enemy in self.enemies:\n row, column = enemy[\"position\"]\n if self.stage_steps % max(1, 3 - self.cycle) == 0:\n column += enemy[\"direction\"]\n if column <= 0 or column >= 9:\n enemy[\"direction\"] *= -1\n column = min(9, max(0, column))\n row = min(7, row + 1)\n enemy[\"position\"] = [row, column]\n if (self.stage_steps + enemy[\"id\"]) % max(5, 12 - self.cycle * 2) == 0:\n self.bombs.append([row + 1, column])\n\n def _move_mothership(self) -> None:\n if self.stage_steps % 2 == 0:\n self.rotating_hole += self.rotating_direction\n if self.rotating_hole in (2, 7):\n self.rotating_direction *= -1\n interval = max(3, 8 - self.cycle * 2)\n if self.stage_steps % interval == 0:\n self.bombs.append([2, int(self.random.randint(2, 8))])\n\n def _move_bombs(self) -> None:\n for bomb in list(self.bombs):\n bomb[0] += 1\n if bomb[0] > 8:\n self.bombs.remove(bomb)\n\n def _resolve_collisions(self) -> float:\n reward = 0.0\n for enemy in list(self.enemies):\n if enemy[\"position\"] != [8, self.player_column]:\n continue\n if self.shield_timer:\n reward += self._shield_bird_value(enemy)\n self.enemies.remove(enemy)\n self._advance_if_clear()\n else:\n self._lose_life()\n break\n for bomb in list(self.bombs):\n if bomb != [8, self.player_column]:\n continue\n self.bombs.remove(bomb)\n if not self.shield_timer:\n self._lose_life()\n break\n return reward\n\n def _shield_bird_value(self, enemy: dict[str, object]) -> float:\n if self.stage < 2:\n return 80.0\n return 500.0\n\n def _advance_if_clear(self) -> None:\n if not self.enemies:\n self._advance_stage()\n\n def _advance_stage(self) -> None:\n self.stage += 1\n if self.stage >= 5:\n self.stage = 0\n self.cycle += 1\n if self.cycle >= 3:\n self.terminal = True\n else:\n self._start_stage()\n\n def _lose_life(self) -> None:\n self.lives -= 1\n if self.lives <= 0:\n self.terminal = True\n else:\n self.player_column = 5\n self.shield_timer = 0\n self.shield_cooldown = 0\n self.shot = None\n self.bombs.clear()\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[8, self.player_column, 0] = True\n state[8, self.previous_player_column, 4] = True\n for enemy in self.enemies:\n row, column = enemy[\"position\"]\n state[row, column, 1] = True\n state[*self.previous_enemies[int(enemy[\"id\"])], 4] = True\n if self.stage >= 2:\n state[row, max(0, column - 1) : min(10, column + 2), 1] = True\n if enemy[\"id\"] in self.wing_rewarded:\n state[row, column, 3] = True\n for bomb in self.bombs:\n state[*bomb, 1] = True\n for bomb in self.previous_bombs:\n state[*bomb, 4] = True\n if self.shot is not None:\n state[*self.shot, 2] = True\n if self.previous_shot is not None:\n state[*self.previous_shot, 4] = True\n if self.stage == 4:\n for column in range(2, 8):\n if self.hull_health[column]:\n state[2, column, 3] = True\n state[1, 5, 1] = True\n state[3, self.rotating_hole, 3] = True\n if self.shield_timer:\n state[7:10, max(0, self.player_column - 1) : min(10, self.player_column + 2), 3] = True\n state[9, : self.lives, 2] = True\n for bit in range(2):\n state[0, bit, 5] = bool(self.cycle & (1 << bit))\n for bit in range(3):\n state[0, 2 + bit, 5] = bool(self.stage & (1 << bit))\n state[0, 5 + bit, 5] = bool(self.lives & (1 << bit))\n for bit in range(4):\n state[1, bit, 5] = bool(self.shield_cooldown & (1 << bit))\n state[1, 4 + bit, 5] = bool(self.shield_timer & (1 << bit))\n for index in self.wing_rewarded:\n state[2, index, 5] = True\n for bit in range(12):\n state[3 + bit // 10, bit % 10, 5] = bool(self.steps & (1 << bit))\n state[5 + bit // 10, bit % 10, 5] = bool(self.stage_steps & (1 << bit))\n if self.stage == 4:\n for column in range(2, 8):\n for bit in range(2):\n state[7 + bit, column, 5] = bool(self.hull_health[column] & (1 << bit))\n state[9, self.rotating_hole, 5] = True\n state[9, 8, 5] = self.rotating_direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 18, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/phoenix.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "graveler", "split": "train", "game": "graveler", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Graveler as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to pull toward the tunnel center. Actions 0–4\nrestore the outward pull. The tunnel scrolls automatically.\nCoins award the current multiplier and raise it by one. A\nmissed coin lowers it by one, to a minimum of one. Wall or\nspike contact ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, walls, coins, spikes,\ntunnel center, and gauges. Each action advances four frames\nat fixed difficulty. Collisions use rectangular approximations.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. The normalized score\nclips the raw total to [0, 300] and divides by 300.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/graveler.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Item:\n x: float\n y: float\n spike: bool = False\n\n\nclass GravelerEnvironment:\n score_cap = 300\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.walls = [(50.0, 60.0)] * 11\n self.center, self.width = 50.0, 60.0\n self.center_speed = self.width_speed = 0.0\n self.offset = 0.0\n self.y, self.vy = 65.0, 0.0\n self.items = [Item(15 + i * 7, 65) for i in range(5)]\n self.object_distance = 10.0\n self.coins_left, self.coin_y = 0, 65.0\n self.steps, self.multiplier = 0, 1\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self) -> int:\n center, width = self.walls[1]\n force = -0.015 if self.y < center else 0.015\n self.vy += force * (-1.5 if self.pressed else 1)\n self.y += self.vy\n self.vy *= 0.99\n self.terminal = abs(self.y - center) + 2 >= width / 2\n reward = 0\n remaining = []\n for item in self.items:\n if abs(item.x - 10) < 5 and abs(item.y - self.y) < 4:\n if item.spike:\n self.terminal = True\n else:\n reward += self.multiplier\n self.multiplier += 1\n continue\n if not item.spike and 0 <= item.x < 100:\n wall = int((item.x + self.offset) // 10)\n item_center, item_width = self.walls[wall]\n if abs(item.y - item_center) + 2 >= item_width / 2:\n self.coin_y += 10 if self.coin_y < 50 else -10\n continue\n item.x -= 0.5\n if item.x >= -3:\n remaining.append(item)\n elif not item.spike:\n self.multiplier = max(1, self.multiplier - 1)\n self.items = remaining\n self.offset += 0.5\n if self.offset >= 10:\n self.offset -= 10\n self._append_wall()\n self.object_distance -= 0.5\n if self.object_distance < 0:\n self._spawn_item()\n return reward\n\n def _append_wall(self) -> None:\n self.center_speed += self.random.uniform(-0.2, 0.2)\n self.width_speed += self.random.uniform(-0.2, 0.2)\n self.center += self.center_speed\n self.width += self.width_speed\n if self.center - self.width / 2 < 20 and self.center_speed < 0:\n self.center_speed += 1\n if self.center + self.width / 2 > 80 and self.center_speed > 0:\n self.center_speed -= 1\n if self.width < 32 and self.width_speed < 0:\n self.width_speed += 1\n if self.width > 60 and self.width_speed > 0:\n self.width_speed -= 1\n self.walls.pop(0)\n self.walls.append((self.center, self.width))\n\n def _spawn_item(self) -> None:\n if self.coins_left:\n self.items.append(Item(103, self.coin_y))\n self.coins_left -= 1\n self.object_distance = 7 if self.coins_left else self.random.uniform(40, 60)\n else:\n self.items.append(Item(103, self.center + self.random.uniform(-10, 10), spike=True))\n self.coins_left = int(self.random.integers(3, 7))\n self.object_distance = self.random.uniform(40, 60)\n side = self.random.choice((-1, 1))\n self.coin_y = self.center + side * self.width * self.random.uniform(0.2, 0.36)\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, max(0, int(self.y) // 10)), 1, 0] = True\n for col in range(10):\n center, width = self.walls[int((col * 10 + 5 + self.offset) // 10)]\n for row in range(10):\n state[row, col, 1] = abs(row * 10 + 5 - center) >= width / 2\n state[min(9, max(0, int(center) // 10)), col, 4] = True\n for item in self.items:\n if 0 <= item.x < 100 and 0 <= item.y < 100:\n state[int(item.y) // 10, int(item.x) // 10, 3 if item.spike else 2] = True\n velocity = min(511, max(0, round((self.vy + 2) * 100)))\n for row, value in enumerate((self.steps, self.multiplier, velocity)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 19, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/graveler.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/graveler/main.js"} +{"name": "c_nodes", "split": "train", "game": "c_nodes", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays C Nodes as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nMove the cursor with actions 1–4 (left, up, down, right). Tap\naction 5 to cut nearby links below the anchor band. Action 0 waits.\nNodes still connected to an anchor must be freed before they fall\npast the bottom. Free nodes score once they fall out of play.\nEach score doubles the multiplier up to 64. Cutting resets it to one\nand briefly speeds up scrolling.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show anchored, tethered, and free nodes,\nlinks, the cursor, and gauges. The conversion replaces pointer input\nwith a cell cursor and checks cuts within five simulation units of\nthe cursor center. It uses fixed difficulty and full connectivity\nchecks to classify tethered nodes. Each action advances four frames.\n\nSCORING, TERMINATION, AND HORIZON\nThe run ends on a tethered node crossing the bottom or after 400\nactions. Clip raw scores to [0, 500] and divide by the fixed cap of 500.\n\nAcross 100 seeds without sticky actions, idle averaged 2.28 raw\npoints, random inputs averaged 3.32, and cutting every eight actions\nat the default cursor position averaged 7.14.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/c_nodes.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\nDIRECTIONS = ((0, -1), (-1, 0), (1, 0), (0, 1))\n\n\n@dataclass(eq=False)\nclass Node:\n x: float\n y: float\n vx: float = 0\n vy: float = 0\n anchored: bool = True\n tethered: bool = False\n\n\n@dataclass\nclass Link:\n a: Node\n b: Node\n length: float\n\n def near(self, x: float, y: float) -> bool:\n dx, dy = self.b.x - self.a.x, self.b.y - self.a.y\n px, py = x - self.a.x, y - self.a.y\n squared = dx * dx + dy * dy\n fraction = min(1, max(0, (px * dx + py * dy) / squared)) if squared else 0\n return math.hypot(px - fraction * dx, py - fraction * dy) <= 5\n\n\nclass CNodesEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.last_action = 0\n self.multiplier = 1\n self.next_node = self.boost = 0.0\n self.cursor = (3, 5)\n self.terminal = False\n self.nodes: list[Node] = []\n self.links: list[Link] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n if 1 <= action <= 4:\n dy, dx = DIRECTIONS[action - 1]\n row, col = self.cursor\n self.cursor = min(9, max(2, row + dy)), min(9, max(0, col + dx))\n if action == 5 and self.last_action != 5:\n row, col = self.cursor\n self.links = [link for link in self.links if not link.near(col * 10 + 5, row * 10 + 5)]\n self.multiplier = 1\n self.boost = 1\n self.last_action = action\n self.steps += 1\n reward = 0\n for _ in range(FRAMES_PER_STEP):\n reward += self._advance_frame()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self) -> int:\n lowest = max((node.y for node in self.nodes), default=0)\n scroll = 0.03 + self.boost + max(0, 29 - lowest) * 0.1\n self.boost *= 0.7\n self.next_node -= scroll\n if self.next_node < 0:\n new = Node(self.random.uniform(10, 90), 0)\n for node in self.nodes:\n if node.anchored and abs(new.x - node.x) / 2 + abs(node.y) < 30 and self.random.random() < 0.7:\n self.links.append(Link(new, node, math.hypot(new.x - node.x, node.y)))\n self.nodes.append(new)\n self.next_node = 4\n for link in self.links:\n dx, dy = link.b.x - link.a.x, link.b.y - link.a.y\n distance = math.hypot(dx, dy)\n if distance:\n force = (distance - link.length) * 0.02 / distance\n link.a.vx += force * dx\n link.a.vy += force * dy\n link.b.vx -= force * dx\n link.b.vy -= force * dy\n for node in self.nodes:\n node.y += scroll\n node.anchored &= node.y <= 20\n if node.anchored:\n node.vx = node.vy = 0\n else:\n node.x += node.vx\n node.y += node.vy\n node.vx *= 0.95\n node.vy = (node.vy + 0.03) * 0.95\n self.links = [link for link in self.links if min(link.a.y, link.b.y) <= 100]\n self._update_tethers()\n reward = 0\n survivors = []\n for node in self.nodes:\n if node.tethered and node.y > 100:\n self.terminal = True\n if node.y > 140:\n reward += self.multiplier\n self.multiplier = min(64, self.multiplier * 2)\n else:\n survivors.append(node)\n self.nodes = survivors\n alive = set(survivors)\n self.links = [link for link in self.links if link.a in alive and link.b in alive]\n return reward\n\n def _update_tethers(self) -> None:\n connected = {node: [] for node in self.nodes}\n for link in self.links:\n connected[link.a].append(link.b)\n connected[link.b].append(link.a)\n pending = [node for node in self.nodes if node.anchored]\n reached = set(pending)\n while pending:\n for neighbor in connected[pending.pop()]:\n if neighbor not in reached:\n reached.add(neighbor)\n pending.append(neighbor)\n for node in self.nodes:\n node.tethered = node in reached and not node.anchored\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for node in self.nodes:\n if 0 <= node.x < 100 and 0 <= node.y < 100:\n channel = 0 if node.anchored else 1 if node.tethered else 2\n state[int(node.y) // 10, int(node.x) // 10, channel] = True\n for link in self.links:\n for fraction in np.linspace(0, 1, 12):\n x = link.a.x + (link.b.x - link.a.x) * fraction\n y = link.a.y + (link.b.y - link.a.y) * fraction\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y) // 10, int(x) // 10, 3] = True\n row, col = self.cursor\n state[row, col, 4] = True\n for row, value in enumerate((self.steps, self.multiplier, self.last_action)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 20, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/c_nodes.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/cnodes/main.js"} +{"name": "teeter", "split": "train", "game": "teeter", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Teeter as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to flip every bar's tilt. Actions 0–4 release.\nGuide the falling ball onto scoring floor tiles or tiles that add\nbars. Red floor tiles remove bars. A new ball drops after the\nprevious one leaves the board. The run ends when a ball falls\nthrough with no bars left.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the ball, bars, scoring tiles, bar gains,\nbar losses, and counters. Floor magnitudes are stored in the first\nrows of channel 5 in left-to-right order. The port uses fixed\ndifficulty and geometric overlap checks for the ball and bars.\nEach action advances up to four frames over 400 actions. Clip\nscores to [0, 100] and divide by 100.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/teeter.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Bar:\n x: float\n y: float\n width: float\n angle: float\n\n\n@dataclass\nclass Floor:\n x: float\n width: float\n score: int\n change: int = 0\n\n\nclass TeeterEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.bars = []\n for _ in range(7):\n self._add_bar()\n self.floors = []\n self.ball = self.target = None\n self.sign, self.steps = 1, 0\n self.held = self.terminal = False\n\n def _add_bar(self):\n for _ in range(99):\n width = self.random.uniform(12, 18)\n angle = self.random.uniform(0.2, 0.8) * self.random.choice((-1, 1))\n margin = 5 + width * cos(angle) / 2\n x, y = self.random.uniform(margin, 100 - margin), self.random.uniform(20, 70)\n if all(abs(x - bar.x) >= (width + bar.width) / 2 + 5 or\n abs(y - bar.y) >= 6 + (width * abs(sin(angle)) +\n bar.width * abs(sin(bar.angle))) / 2 for bar in self.bars):\n self.bars.append(Bar(x, y, width, angle))\n return True\n return False\n\n def _drop(self):\n for _ in range(99):\n x = self.random.uniform(20, 80)\n if any(abs(bar.x - x) < bar.width * cos(bar.angle) / 2 for bar in self.bars):\n break\n self.target = np.array([x, -4.])\n self.ball = self.target.copy()\n self.floors = []\n edge = 0.\n while edge < 100:\n width = self.random.uniform(20, 30)\n score = int(np.prod(self.random.uniform(1, 3.1, 2)))\n self.floors.append(Floor(edge + width / 2, width, score))\n edge += width\n for sign in (1, -1):\n floor = self.floors[self.random.integers(len(self.floors))]\n floor.score = 0\n floor.change = sign * int(np.prod(self.random.uniform(1, 2.2, 2)))\n for floor in self.floors:\n floor.x -= (edge - 100) / 2\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n if held and not self.held:\n self.sign *= -1\n self.held = held\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n if self.ball is None:\n self._drop()\n self.target[1] += 0.5\n self.ball += (self.target - self.ball) * 0.5\n x, y = self.ball\n for bar in self.bars:\n angle = bar.angle * self.sign\n dx, dy = cos(angle), sin(angle)\n ox, oy = x - bar.x, y - bar.y\n if abs(ox * dx + oy * dy) < bar.width / 2 + 3 and abs(oy * dx - ox * dy) < 4.5:\n reach = (bar.width / 2 + 7) * (1 if angle > 0 else -1)\n self.target[:] = bar.x + reach * dx, bar.y + reach * dy\n reward = change = 0\n remaining = []\n for floor in self.floors:\n if abs(floor.x - x) < floor.width / 2 + 2.5 and abs(y - 95) < 8:\n reward += floor.score\n change += floor.change\n else:\n remaining.append(floor)\n self.floors = remaining\n if change > 0:\n for _ in range(change):\n reward += int(not self._add_bar())\n elif change < 0:\n for _ in range(min(-change, len(self.bars))):\n self.bars.pop(self.random.integers(len(self.bars)))\n if y > 99:\n self.terminal = not self.bars\n self.ball = self.target = None\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n if self.ball is not None:\n x, y = np.clip(self.ball // 10, 0, 9).astype(int)\n state[y, x, 0] = True\n for bar in self.bars:\n angle = bar.angle * self.sign\n offset = np.linspace(-bar.width / 2, bar.width / 2, 20)\n cols = ((bar.x + offset * cos(angle)) // 10).astype(int)\n rows = ((bar.y + offset * sin(angle)) // 10).astype(int)\n state[rows, cols, 1] = True\n columns = np.arange(5, 100, 10)\n for floor in self.floors:\n channel = 2 if floor.score else 3 if floor.change > 0 else 4\n state[9, :, channel] |= abs(columns - floor.x) < floor.width / 2\n for index, floor in enumerate(sorted(self.floors, key=lambda floor: floor.x)):\n value = floor.score or abs(floor.change)\n for bit in range(4):\n state[index, bit, 5] = bool(value & (1 << bit))\n for row, value in enumerate((self.steps, self.sign > 0, len(self.bars), self.held)):\n for bit in range(9):\n state[6 + row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 21, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/teeter.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/teeter/main.js"} +{"name": "b_math", "split": "train", "game": "b_math", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays B Math as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nActions 1–5 select the corresponding answer. Action 0 waits.\nSubmitting any answer pays based on remaining time and multiplier.\nCorrect answers restore half the clock and increase the multiplier\nwhen they refill it. Wrong answers remove a quarter of the clock and\nreduce the multiplier, with a floor of one. The clock also drains on\nevery step. Addition starts the run, with subtraction, multiplication,\nand exact division entering the question pool as play progresses.\n\nINPUT CHANNEL TABLE\nThe grid encodes the operator, binary operands and answer choices,\nselected answer, feedback, a reserved channel, and gauges. There is\none correct choice and four distinct nearby distractors. The adaptation\nreplaces pointer clicks with direct selection, uses an integer clock,\nand applies time changes immediately with three feedback steps.\n\nSCORING, TERMINATION, AND HORIZON\nThe episode ends when time expires or after 400 steps. A submission\ncan pay at most 57 times its multiplier, and the multiplier increases\nby at most one per answer. With at most 100 submissions, the resulting\ncap is 287,850. Clip raw score to [0, 287850] and divide by 287850.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/b_math.py`):\n```python\nimport numpy as np\n\n\nHORIZON = 400\nFULL_TIME = 60\nFEEDBACK_STEPS = 3\nMAX_ANSWERS = (HORIZON + FEEDBACK_STEPS) // (FEEDBACK_STEPS + 1)\n\n\nclass BMathEnvironment:\n score_cap = 57 * MAX_ANSWERS * (MAX_ANSWERS + 1) // 2\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.questions = self.feedback = self.last_action = 0\n self.time = FULL_TIME\n self.multiplier = 1\n self.correct = False\n self.selected = 0\n self.terminal = False\n self._question()\n\n def _question(self) -> None:\n self.operation = int(self.random.integers(min(4, 1 + self.questions // 5)))\n if self.operation < 2:\n total = int(self.random.integers(10, 100))\n part = int(self.random.integers(1, total))\n self.left, self.right, self.answer = (\n (part, total - part, total) if self.operation == 0 else (total, part, total - part)\n )\n else:\n factor = int(self.random.integers(2, 10))\n quotient = int(self.random.integers(2, 99 // factor + 1))\n product = factor * quotient\n self.left, self.right, self.answer = (\n (quotient, factor, product) if self.operation == 2 else (product, factor, quotient)\n )\n distractors = [value for value in range(max(1, self.answer - 7), min(99, self.answer + 7) + 1)\n if value != self.answer]\n choices = self.random.choice(distractors, size=4, replace=False)\n self.options = self.random.permutation([self.answer, *choices]).tolist()\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.steps += 1\n reward = 0\n if self.feedback:\n self.feedback -= 1\n if not self.feedback:\n self._question()\n elif 1 <= action <= 5:\n reward = (57 * self.time * self.multiplier + FULL_TIME - 1) // FULL_TIME\n self.correct = self.options[action - 1] == self.answer\n self.selected = action\n if self.correct:\n self.time += 30\n if self.time >= FULL_TIME:\n self.multiplier += 1\n else:\n self.time -= 15\n self.multiplier = max(1, self.multiplier - 1)\n self.time = min(FULL_TIME, self.time)\n self.feedback = FEEDBACK_STEPS\n self.questions += 1\n self.time = max(0, self.time - 1)\n self.terminal = self.time == 0 or self.steps >= self.horizon\n return float(reward), self.terminal\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[self.operation, 0, 0] = True\n for row, value in enumerate((self.left, self.right, *self.options)):\n for bit in range(8):\n state[row, bit, 1] = bool(value & (1 << bit))\n if self.feedback:\n state[0, self.selected, 2] = True\n state[int(self.correct), 0, 3] = True\n for row, value in enumerate((self.time, self.multiplier, self.questions,\n self.feedback, self.steps, self.last_action)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 22, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/b_math.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBMath.c"} +{"name": "timber_test", "split": "train", "game": "timber_test", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Timber Test as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nA saw sweeps automatically across each log. Tap action 5 to cut, and\nuse actions 0–4 to release. The far edge automatically closes the last\npiece. Each log requests two to four equal pieces. Its grade starts\nat 100 times the target count minus one, then loses points for relative\nsize differences between adjacent pieces and for missing or extra\npieces. A negative grade ends the run. Other grades are paid once\nand advance the player to the next log.\n\nINPUT CHANNEL TABLE\nChannels show the saw, remaining timber, early-round cut hints, completed\ncut coordinates, a reserved channel, and gauges. The gauges record the\nclock, round, target count, log boundaries, saw position, and button state.\nThis adaptation uses eight subunits per cell, increases saw speed by\nround, and settles the grade immediately at the end of the sweep.\n\nSCORING, TERMINATION, AND HORIZON\nEach log takes at least ten steps, including the saw's approach, and\npays at most 300 points. The 400-step horizon gives a conservative cap\nof 12,000. Normalize by clipping to [0, 12000] and dividing by 12000.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/timber_test.py`):\n```python\nimport numpy as np\n\n\nHORIZON = 400\nUNIT = 8\nMIN_WIDTH = 32\nMAX_PIECES = 4\nMAX_SPEED = 4\nSAW_LEAD = 6\n\n\nclass TimberTestEnvironment:\n score_cap = HORIZON // ((MIN_WIDTH + SAW_LEAD + MAX_SPEED - 1) // MAX_SPEED) * (MAX_PIECES - 1) * 100\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.round = self.last_action = 0\n self.terminal = False\n self._new_log()\n\n def _new_log(self) -> None:\n self.round += 1\n width = int(self.random.integers(MIN_WIDTH, 65))\n slack = 80 - width\n self.start = slack // 2 + int(self.random.integers(slack // 3 + 1))\n self.end = self.start + width\n self.remaining = self.start\n self.target = int(self.random.integers(2, MAX_PIECES + 1))\n self.saw = self.start - SAW_LEAD\n self.pieces: list[int] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def _grade(self) -> int:\n score = (self.target - 1) * 100\n widths = self.pieces + [0] * max(0, self.target - len(self.pieces))\n for index, (left, right) in enumerate(zip(widths, widths[1:]), 1):\n if index > self.target or left + right == 0:\n score -= 100\n else:\n score -= abs(left - right) * 300 // (left + right)\n return score\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n pressed = action == 5 and self.last_action != 5\n self.last_action = action\n self.steps += 1\n self.saw = min(self.end, self.saw + min(MAX_SPEED, 1 + (self.round - 1) // 3))\n reward = 0\n if self.saw == self.end:\n self.pieces.append(self.end - self.remaining)\n score = self._grade()\n if score < 0:\n self.terminal = True\n else:\n reward = score\n if self.steps < self.horizon:\n self._new_log()\n elif pressed and self.saw > self.remaining:\n self.pieces.append(self.saw - self.remaining)\n self.remaining = self.saw\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[1, max(0, min(9, self.saw // UNIT)), 0] = True\n state[2, self.remaining // UNIT:(self.end - 1) // UNIT + 1, 1] = True\n if self.round <= 3 and not self.pieces:\n for index in range(1, self.target):\n cut = self.start + round((self.end - self.start) * index / self.target)\n state[3, cut // UNIT, 2] = True\n cut = self.start\n for width in self.pieces:\n cut += width\n index = cut - 1\n state[index // 10, index % 10, 3] = True\n values = (self.steps, self.round, self.target, self.start, self.end,\n self.remaining, self.saw + SAW_LEAD, int(self.last_action == 5))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 23, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/timber_test.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameTimberTest.c"} +{"name": "rb_drive", "split": "train", "game": "rb_drive", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Rb Drive as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to rotate the selected exit clockwise. Actions 0–4\nrelease. Cars choose their route as they reach the intersection.\nA car entering from the selected exit goes straight through.\n\nINPUT CHANNEL TABLE\nRed cars (channel 0) score on vertical exits. Dark cars (channel 1)\nscore on horizontal exits. A correct delivery earns one point and\nrestores that lane's health. A wrong delivery cuts the exit's health\nto 66% of its current value. All four lanes slowly drain, and the\nepisode ends when any lane drops below 1%.\n\nSCORING, TERMINATION, AND HORIZON\nThe remaining channels show the selected exit, lane health,\ncars already routed, and counters. The port uses fixed difficulty\nand projects car paths onto a 10×10 grid. Each action advances up\nto four frames over a 400-action horizon. Clip the episode score\nto [0, 16] and divide by 16.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/rb_drive.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\nDIRECTIONS = np.array(((1, 0), (0, 1), (-1, 0), (0, -1)))\n\n\n@dataclass\nclass Car:\n lane: int\n color: int\n phase: float = 0\n entry: int = 0\n\n def position(self):\n direction = DIRECTIONS[self.lane]\n shoulder = DIRECTIONS[(self.lane + 1) % 4] * 5\n if self.phase < 1:\n offset = direction * (50 - 40 * self.phase) + shoulder\n elif self.phase < 2:\n start = DIRECTIONS[self.entry] * 10 + DIRECTIONS[(self.entry + 1) % 4] * 5\n end = direction * 10 - shoulder\n offset = start + (end - start) * (self.phase - 1)\n else:\n offset = direction * (10 + 40 * (self.phase - 2)) - shoulder\n return 50 + offset\n\n\nclass RBDriveEnvironment:\n score_cap = 16\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.lane = 3\n self.health = np.full(4, 0.7)\n self.cars = []\n self.spawn_timer = self.color_count = self.steps = 0\n self.color = int(self.random.integers(2))\n self.held = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n if held and not self.held:\n self.lane = (self.lane + 1) % 4\n self.held = held\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n self.spawn_timer -= 1\n if self.spawn_timer < 0:\n self.color_count -= 1\n if self.color_count < 0:\n self.color = 1 - self.color\n self.color_count = int(self.random.integers(1, 4))\n self.cars.append(Car(int(self.random.integers(4)), self.color))\n self.spawn_timer += self.random.uniform(80, 99)\n reward = 0\n remaining = []\n for car in self.cars:\n previous = car.phase\n car.phase += 0.05 if 1 < previous < 2 else 0.01\n if previous < 1 <= car.phase:\n car.entry = car.lane\n car.lane = self.lane if self.lane != car.entry else (car.entry + 2) % 4\n if car.phase <= 3:\n remaining.append(car)\n elif car.lane % 2 == car.color:\n self.health[car.lane] *= 0.66\n else:\n self.health[car.lane] = min(1, self.health[car.lane] + 0.3)\n reward += 1\n self.cars = remaining\n self.health -= 0.0006\n self.terminal = bool(np.any(self.health < 0.01))\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for car in self.cars:\n x, y = np.clip(car.position() // 10, 0, 9).astype(int)\n state[y, x, car.color] = True\n if car.phase >= 1:\n state[y, x, 4] = True\n for lane, (dx, dy) in enumerate(DIRECTIONS):\n for distance in range(1, 5):\n row, col = 5 + dy * distance, 5 + dx * distance\n state[row, col, 2] = lane == self.lane\n state[row, col, 3] = self.health[lane] > (distance - 1) / 4\n gauges = (self.steps, self.held, *(round(value * 100) for value in self.health))\n for row, value in enumerate(gauges):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 24, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/rb_drive.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameRbDrive.c"} +{"name": "montezumas_revenge", "split": "train", "game": "montezumas_revenge", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Montezumas Revenge as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves Panama Joe's room-to-room fortress exploration, horizontal platform\nmovement, jumps, ladders, keys and locked doors, a four-item inventory, dark rooms and the torch,\ntemporary amulet protection, swords, jewels, fire pits, intermittent laser gates, moving skulls\nand spiders, lives, and three successive difficulty levels. Skulls and spiders accelerate with\nlevel. Reaching the treasure chamber advances the level; reaching it on level three wins.\n\nACTION MAPPING\n0: wait\n1: move left\n2: jump, or climb up at a ladder\n3: move right\n4: climb down at a ladder\n5: use a sword in the facing direction\n\nINPUT CHANNEL TABLE\n0: Panama Joe\n1: active skull or spider\n2: uncollected tools and jewels\n3: floors, ladders, and fire gaps\n4: previous player position\n5: room, level, lives, ordered inventory, exact step count, jump and amulet timers, facing, and darkness\n\nSCORING, TERMINATION, AND HORIZON\nEach level has three keys (300), four swords (400), one amulet (200), two jewels (2,000), one\ntorch (3,000), three doors (900), two skulls (4,000), and two spiders (6,000): 16,800 points.\nAcross three levels, `score_cap = 50,400`. Normalization is\n`min(max(raw_score, 0), 50_400) / 50_400`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/montezumas_revenge.py`):\n```python\nimport numpy as np\n\n\nITEM_VALUES = {\"key\": 100, \"sword\": 100, \"amulet\": 200, \"jewel\": 1_000, \"torch\": 3_000}\nITEM_LAYOUT = {\n 0: ((\"key\", 2), (\"sword\", 7)),\n 1: ((\"jewel\", 4),),\n 2: ((\"amulet\", 7), (\"sword\", 2)),\n 3: ((\"key\", 2), (\"jewel\", 7)),\n 4: ((\"torch\", 4), (\"sword\", 8)),\n 5: ((\"key\", 7),),\n 6: ((\"sword\", 2),),\n}\nDOORS = frozenset({(0, 1), (3, 4), (7, 8)})\nROOM_NEIGHBORS = {\n 0: {3: 1, 4: 3},\n 1: {1: 0, 3: 2, 4: 4},\n 2: {1: 1, 4: 5},\n 3: {2: 0, 3: 4, 4: 6},\n 4: {2: 1, 1: 3, 3: 5, 4: 7},\n 5: {2: 2, 1: 4, 4: 8},\n 6: {2: 3, 3: 7},\n 7: {2: 4, 1: 6, 3: 8},\n 8: {2: 5, 1: 7},\n}\n\n\nclass MontezumasRevengeEnvironment:\n \"\"\"Three compact fortress levels with inventory-gated exploration.\"\"\"\n\n score_cap = 50_400.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 3_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.level = 0\n self.lives = 5\n self.score = 0.0\n self.next_bonus_life = 10_000\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self.claimed: set[tuple[int, str, int, int]] = set()\n self.open_doors: set[tuple[int, int, int]] = set()\n self.defeated: set[tuple[int, str, int]] = set()\n self.inventory: list[str] = []\n self._start_level()\n\n def _start_level(self) -> None:\n self.room = 0\n self.player = [8, 1]\n self.previous_player = self.player.copy()\n self.jump_timer = 0\n self.amulet_timer = 0\n self.facing = 1\n self.room_steps = 0\n self.skull_column = 8\n self.skull_direction = -1\n self.spider_column = 1\n self.spider_direction = 1\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n level_before = self.level\n room_before = self.room\n self.transition_reward = 0.0\n self._move_player(action)\n reward = self.transition_reward + self._collect_item()\n if action == 5:\n reward += self._use_sword()\n if self.level == level_before and self.room == room_before:\n self._move_creatures()\n self._resolve_hazards()\n self.score += reward\n while self.score >= self.next_bonus_life:\n self.lives = min(6, self.lives + 1)\n self.next_bonus_life += 10_000\n self.steps += 1\n self.room_steps += 1\n self.jump_timer = max(0, self.jump_timer - 1)\n self.amulet_timer = max(0, self.amulet_timer - 1)\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_player(self, action: int) -> None:\n if action == 1:\n self.player[1] -= 1\n self.facing = -1\n elif action == 3:\n self.player[1] += 1\n self.facing = 1\n elif action == 2:\n if self.player[1] == 5 and 2 in ROOM_NEIGHBORS[self.room]:\n self._change_room(2)\n return\n self.jump_timer = 3\n self.player[0] = 6\n elif action == 4 and self.player[1] == 5 and 4 in ROOM_NEIGHBORS[self.room]:\n self._change_room(4)\n return\n if self.jump_timer == 0:\n self.player[0] = 8\n if self.player[1] < 0:\n self._change_room(1)\n elif self.player[1] > 9:\n self._change_room(3)\n\n def _change_room(self, direction: int) -> None:\n destination = ROOM_NEIGHBORS[self.room].get(direction)\n if destination is None:\n self.player[1] = min(9, max(0, self.player[1]))\n return\n edge = tuple(sorted((self.room, destination)))\n door = (self.level, *edge)\n if edge in DOORS and door not in self.open_doors:\n if \"key\" not in self.inventory:\n self.player[1] = min(9, max(0, self.player[1]))\n return\n self.inventory.remove(\"key\")\n self.open_doors.add(door)\n self.transition_reward += 300.0\n self.room = destination\n if direction == 1:\n self.player = [8, 9]\n elif direction == 3:\n self.player = [8, 0]\n else:\n self.player = [8, 5]\n self.previous_player = self.player.copy()\n self.room_steps = 0\n self.skull_column = 8\n self.skull_direction = -1\n self.spider_column = 1\n self.spider_direction = 1\n if self.room == 8 and (self.level, 7, 8) in self.open_doors:\n self.level += 1\n if self.level >= 3:\n self.terminal = True\n else:\n self.inventory.clear()\n self._start_level()\n\n def _collect_item(self) -> float:\n for index, (kind, column) in enumerate(ITEM_LAYOUT.get(self.room, ())):\n identity = (self.level, kind, self.room, index)\n if identity in self.claimed or self.player != [8, column]:\n continue\n if kind != \"jewel\" and len(self.inventory) >= 4:\n return 0.0\n self.claimed.add(identity)\n if kind != \"jewel\":\n self.inventory.append(kind)\n if kind == \"amulet\":\n self.amulet_timer = 20\n return float(ITEM_VALUES[kind])\n return 0.0\n\n def _use_sword(self) -> float:\n if \"sword\" not in self.inventory:\n return 0.0\n target = self.player[1] + self.facing\n if self.room in (2, 6):\n identity = (self.level, \"skull\", self.room)\n if identity not in self.defeated and self.skull_column == target:\n self.defeated.add(identity)\n self.inventory.remove(\"sword\")\n return 2_000.0\n if self.room in (5, 7):\n identity = (self.level, \"spider\", self.room)\n if identity not in self.defeated and self.spider_column == target:\n self.defeated.add(identity)\n self.inventory.remove(\"sword\")\n return 3_000.0\n return 0.0\n\n def _move_creatures(self) -> None:\n speed = max(1, 3 - self.level)\n if self.room_steps % speed:\n return\n if self.room in (2, 6) and (self.level, \"skull\", self.room) not in self.defeated:\n self.skull_column += self.skull_direction\n if self.skull_column in (1, 8):\n self.skull_direction *= -1\n if self.room in (5, 7) and (self.level, \"spider\", self.room) not in self.defeated:\n self.spider_column += self.spider_direction\n if self.spider_column in (1, 8):\n self.spider_direction *= -1\n\n def _resolve_hazards(self) -> None:\n if self.amulet_timer > 0:\n return\n creature_hit = (\n self.room in (2, 6)\n and (self.level, \"skull\", self.room) not in self.defeated\n and self.skull_column == self.player[1]\n ) or (\n self.room in (5, 7)\n and (self.level, \"spider\", self.room) not in self.defeated\n and self.spider_column == self.player[1]\n )\n fire_hit = self.room in (3, 6) and self.player[1] in (3, 7) and self.jump_timer == 0\n laser_hit = self.room == 4 and self.player[1] == 6 and self.room_steps % 6 < 3\n dark_fall = self.room >= 6 and \"torch\" not in self.inventory and self.player[1] in (4, 8)\n if creature_hit or fire_hit or laser_hit or dark_fall:\n self._lose_life()\n\n def _lose_life(self) -> None:\n self.lives -= 1\n if self.lives <= 0:\n self.terminal = True\n return\n room = self.room\n self.player = [8, 1]\n self.previous_player = self.player.copy()\n self.jump_timer = 0\n self.amulet_timer = 0\n self.room_steps = 0\n self.skull_column = 8\n self.skull_direction = -1\n self.spider_column = 1\n self.spider_direction = 1\n self.room = room\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n state[*self.previous_player, 4] = True\n for _kind, column in ITEM_LAYOUT.get(self.room, ()):\n index = list(ITEM_LAYOUT[self.room]).index((_kind, column))\n if (self.level, _kind, self.room, index) not in self.claimed:\n state[8, column, 2] = True\n if self.room in (2, 6) and (self.level, \"skull\", self.room) not in self.defeated:\n state[8, self.skull_column, 1] = True\n if self.room in (5, 7) and (self.level, \"spider\", self.room) not in self.defeated:\n state[8, self.spider_column, 1] = True\n state[8, :, 3] = True\n if self.room in (3, 6):\n state[8, (3, 7), 3] = False\n state[:, 5, 3] = True\n item_identities = []\n for level in range(3):\n for room, items in ITEM_LAYOUT.items():\n for index, (kind, _column) in enumerate(items):\n item_identities.append((level, kind, room, index))\n for index, identity in enumerate(item_identities):\n state[index // 10, index % 10, 5] = identity in self.claimed\n door_edges = sorted(DOORS)\n for level in range(3):\n for edge_index, edge in enumerate(door_edges):\n index = 33 + level * 3 + edge_index\n state[index // 10, index % 10, 5] = (level, *edge) in self.open_doors\n creature_identities = []\n for level in range(3):\n for kind, room in ((\"skull\", 2), (\"skull\", 6), (\"spider\", 5), (\"spider\", 7)):\n creature_identities.append((level, kind, room))\n for offset, identity in enumerate(creature_identities):\n index = 42 + offset\n state[index // 10, index % 10, 5] = identity in self.defeated\n inventory_codes = {\"key\": 1, \"sword\": 2, \"amulet\": 3, \"torch\": 4}\n for slot, kind in enumerate(self.inventory):\n code = inventory_codes[kind]\n for bit in range(3):\n index = 54 + slot * 3 + bit\n state[index // 10, index % 10, 5] = bool(code & (1 << bit))\n for bit in range(2):\n index = 66 + bit\n state[index // 10, index % 10, 5] = bool(self.level & (1 << bit))\n for bit in range(4):\n index = 68 + bit\n state[index // 10, index % 10, 5] = bool(self.room & (1 << bit))\n for bit in range(3):\n index = 72 + bit\n state[index // 10, index % 10, 5] = bool(self.lives & (1 << bit))\n for bit in range(12):\n index = 75 + bit\n state[index // 10, index % 10, 5] = bool(self.steps & (1 << bit))\n for bit in range(2):\n index = 87 + bit\n state[index // 10, index % 10, 5] = bool(self.jump_timer & (1 << bit))\n for bit in range(5):\n index = 89 + bit\n state[index // 10, index % 10, 5] = bool(self.amulet_timer & (1 << bit))\n state[9, 4, 5] = self.facing > 0\n state[9, 5, 5] = self.room >= 6 and \"torch\" not in self.inventory\n for bit in range(3):\n state[9, 6 + bit, 5] = bool((self.room_steps % 6) & (1 << bit))\n state[9, 9, 5] = self.skull_direction > 0 if self.room in (2, 6) else self.spider_direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 25, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/montezumas_revenge.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "kung_fu_master", "split": "train", "game": "kung_fu_master", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Kung Fu Master as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves the five-floor temple climb and its faster repeat after Princess\nVictoria's rescue. Thomas moves left and right, jumps over low attacks, squats under high attacks,\nand uses action 5 to strike in his current stance and facing direction. Adjacent attacks are\npunches; two-cell attacks are kicks, retaining the manual's different punch/kick values. Midgets\nrequire low attacks, knife throwers require two hits, dragon balls and moths have their distinct\nvalues, and snakes remain indestructible and must be jumped.\n\nHenchmen can grab Thomas and drain energy until alternating left/right inputs break the hold.\nKnife throwers alternate high and low projectiles. Each floor ends with its energy-bearing boss:\nFist Fighter, Boomerang Thrower, Giant Kicker, Lightning Magician, then Gang Master. A floor reset\nrestores the 300-unit timer and ten energy. Boss defeat awards its listed value plus\n`remaining timer × 10` and `remaining energy × 100`. Timer or energy exhaustion costs one of three\nlives; reaching 75,000 points awards one extra life.\n\nACTION MAPPING\n0: hold/stand\n1: move left or shake grab left\n2: jump\n3: move right or shake grab right\n4: squat/prepare low attack\n5: punch or kick in current stance/facing\n\nINPUT CHANNEL TABLE\n0: Thomas\n1: enemies, low knives, bosses, and boss projectiles\n2: knife throwers, dragon balls, and high knives\n3: midgets and dragon balls\n4: previous Thomas/knife positions, moths, and snakes\n5: current-floor reward identities, enemy/boss cooldowns, floor, climb, lives, energy, exact timer, exact episode/floor steps, stance, facing, grab identity, boss health, and extra-life state\n\nSCORING, TERMINATION, AND HORIZON\nUsing each regular enemy's higher attack value, floors one through five contain at most 2,000,\n2,000, 7,200, 3,600, and 2,600 points, totaling 17,400 per climb. The five bosses total 23,000.\nEach floor can additionally award at most `300 × 10 + 10 × 100 = 4,000`, or 20,000 per climb.\nThus one climb is bounded by 60,400 and two climbs give `score_cap = 120,800`. Normalization is\n`min(max(raw_score, 0), 120_800) / 120_800`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/kung_fu_master.py`):\n```python\nimport numpy as np\n\n\nBOSS_NAMES = (\"fist_fighter\", \"boomerang_thrower\", \"giant_kicker\", \"lightning_magician\", \"gang_master\")\nBOSS_VALUES = (2_000, 3_000, 3_000, 5_000, 10_000)\nREGULAR_ROSTERS = (\n (\"henchman\",) * 4 + (\"knife_thrower\",) * 2,\n (\"henchman\",) * 3 + (\"midget\",) * 3 + (\"knife_thrower\",),\n (\"dragon_ball\",) * 3 + (\"snake\",) * 2 + (\"moth\",) * 2,\n (\"moth\",) * 3 + (\"knife_thrower\",) * 2 + (\"henchman\",) * 2,\n (\"henchman\",) * 4 + (\"knife_thrower\",) * 2 + (\"midget\",) * 2,\n)\nENEMY_VALUES = {\n \"henchman\": (100, 100),\n \"knife_thrower\": (500, 800),\n \"midget\": (200, 300),\n \"dragon_ball\": (2_000, 2_000),\n \"moth\": (500, 600),\n \"snake\": (0, 0),\n}\nENEMY_HEALTH = {\"henchman\": 1, \"knife_thrower\": 2, \"midget\": 1, \"dragon_ball\": 1, \"moth\": 1, \"snake\": 99}\n\n\nclass KungFuMasterEnvironment:\n \"\"\"Two five-floor temple climbs with stance-sensitive combat.\"\"\"\n\n score_cap = 120_800.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 4_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.climb = 0\n self.floor = 0\n self.lives = 3\n self.score = 0.0\n self.bonus_life_awarded = False\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self.claimed: set[tuple[int, int, int]] = set()\n self._start_floor()\n\n def _start_floor(self) -> None:\n self.player = [5, 5]\n self.previous_player = self.player.copy()\n self.facing = 1\n self.energy = 10\n self.timer = 300\n self.jump_timer = 0\n self.squat_timer = 0\n self.grabbed_by: int | None = None\n self.last_escape_direction = 0\n self.enemies: dict[int, dict[str, object]] = {}\n for index, kind in enumerate(REGULAR_ROSTERS[self.floor]):\n if (self.climb, self.floor, index) not in self.claimed:\n side = 9 if index % 2 == 0 else 0\n row = 4 if kind == \"moth\" else 5\n self.enemies[index] = {\n \"kind\": kind,\n \"position\": [row, side],\n \"health\": ENEMY_HEALTH[kind],\n \"cooldown\": index % 4,\n \"direction\": -1 if side == 9 else 1,\n }\n self.knives: list[dict[str, object]] = []\n self.previous_knives: list[list[int]] = []\n self.boss: dict[str, object] | None = None\n self.boss_projectiles: list[list[int]] = []\n self.floor_steps = 0\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n floor_before = (self.climb, self.floor)\n lives_before = self.lives\n self._apply_stance_and_movement(action)\n reward = self._attack() if action == 5 else 0.0\n self._move_regular_enemies()\n self._move_knives()\n self._move_boss()\n self._resolve_damage()\n if self.lives != lives_before or self.terminal:\n return self._finish_step(reward, consume_timer=False)\n if not self.enemies and self.boss is None:\n self._spawn_boss()\n transitioned = (self.climb, self.floor) != floor_before\n return self._finish_step(reward, consume_timer=not transitioned)\n\n def _finish_step(self, reward: float, consume_timer: bool = True) -> tuple[float, bool]:\n self.score += reward\n if self.score >= 75_000 and not self.bonus_life_awarded:\n self.lives = min(9, self.lives + 1)\n self.bonus_life_awarded = True\n if consume_timer:\n self.timer -= 1\n self.floor_steps += 1\n self.jump_timer = max(0, self.jump_timer - 1)\n self.squat_timer = max(0, self.squat_timer - 1)\n if self.timer <= 0:\n self._lose_life()\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _apply_stance_and_movement(self, action: int) -> None:\n if self.grabbed_by is not None:\n direction = -1 if action == 1 else 1 if action == 3 else 0\n if direction and direction != self.last_escape_direction:\n self.last_escape_direction = direction\n enemy = self.enemies.get(self.grabbed_by)\n if enemy is not None:\n enemy[\"health\"] = int(enemy[\"health\"]) - 1\n if enemy[\"health\"] <= -2:\n self.grabbed_by = None\n return\n if action == 1:\n self.player[1] = max(0, self.player[1] - 1)\n self.facing = -1\n elif action == 3:\n self.player[1] = min(9, self.player[1] + 1)\n self.facing = 1\n elif action == 2:\n self.jump_timer = 2\n self.player[0] = 3\n elif action == 4:\n self.squat_timer = 2\n self.player[0] = 6\n elif self.jump_timer == 0 and self.squat_timer == 0:\n self.player[0] = 5\n\n def _attack(self) -> float:\n if self.jump_timer > 0:\n return 0.0\n low = self.squat_timer > 0\n candidates = []\n for index, enemy in self.enemies.items():\n position = enemy[\"position\"]\n distance = abs(position[1] - self.player[1])\n correct_side = int(np.sign(position[1] - self.player[1])) == self.facing\n height_ok = low if enemy[\"kind\"] == \"midget\" else not low\n if correct_side and distance <= 2 and height_ok:\n candidates.append((distance, index, enemy))\n if candidates:\n distance, index, enemy = min(candidates)\n if enemy[\"kind\"] == \"snake\":\n return 0.0\n enemy[\"health\"] = int(enemy[\"health\"]) - 1\n if enemy[\"health\"] <= 0:\n del self.enemies[index]\n self.claimed.add((self.climb, self.floor, index))\n kick_value, punch_value = ENEMY_VALUES[str(enemy[\"kind\"])]\n return float(kick_value if distance == 2 else punch_value)\n return 0.0\n if self.boss is not None:\n distance = abs(self.boss[\"position\"][1] - self.player[1])\n correct_side = int(np.sign(self.boss[\"position\"][1] - self.player[1])) == self.facing\n if correct_side and distance <= 2:\n self.boss[\"health\"] = int(self.boss[\"health\"]) - 1\n if self.boss[\"health\"] <= 0:\n return self._complete_floor()\n return 0.0\n\n def _move_regular_enemies(self) -> None:\n interval = max(1, 3 - self.climb)\n for index, enemy in list(self.enemies.items()):\n kind = str(enemy[\"kind\"])\n position = enemy[\"position\"]\n if kind == \"snake\":\n position[1] += int(enemy[\"direction\"])\n if not 0 <= position[1] < 10:\n del self.enemies[index]\n continue\n enemy[\"cooldown\"] = int(enemy[\"cooldown\"]) - 1\n if kind == \"knife_thrower\" and enemy[\"cooldown\"] <= 0:\n height = \"high\" if (index + self.floor_steps) % 2 else \"low\"\n self.knives.append(\n {\"position\": position.copy(), \"direction\": int(np.sign(self.player[1] - position[1])) or -1, \"height\": height}\n )\n enemy[\"cooldown\"] = max(3, 7 - self.climb)\n if self.floor_steps % interval:\n continue\n if kind == \"moth\":\n position[0] = 4 if position[0] == 5 else 5\n position[1] += int(np.sign(self.player[1] - position[1]))\n if kind == \"snake\" and position[1] == self.player[1]:\n direction = -1 if position[1] > 0 else 1\n position[1] += direction\n\n def _move_knives(self) -> None:\n self.previous_knives = [list(knife[\"position\"]) for knife in self.knives]\n for knife in list(self.knives):\n knife[\"position\"][1] += int(knife[\"direction\"])\n if not 0 <= knife[\"position\"][1] < 10:\n self.knives.remove(knife)\n\n def _spawn_boss(self) -> None:\n self.boss = {\n \"kind\": BOSS_NAMES[self.floor],\n \"position\": [5, 8],\n \"health\": 4 + self.floor + self.climb,\n \"cooldown\": 3,\n }\n\n def _move_boss(self) -> None:\n if self.boss is None:\n return\n self.boss[\"cooldown\"] = int(self.boss[\"cooldown\"]) - 1\n if self.boss[\"cooldown\"] <= 0:\n self.boss_projectiles.append(self.boss[\"position\"].copy())\n self.boss[\"cooldown\"] = max(2, 6 - self.floor // 2 - self.climb)\n if self.floor_steps % 2 == 0:\n self.boss[\"position\"][1] += int(np.sign(self.player[1] - self.boss[\"position\"][1]))\n for projectile in list(self.boss_projectiles):\n projectile[1] += int(np.sign(self.player[1] - projectile[1]))\n if not 0 <= projectile[1] < 10:\n self.boss_projectiles.remove(projectile)\n\n def _resolve_damage(self) -> None:\n for index, enemy in self.enemies.items():\n if enemy[\"position\"] != self.player:\n continue\n if enemy[\"kind\"] == \"henchman\" and self.grabbed_by is None:\n self.grabbed_by = index\n self.energy -= 1\n break\n for knife in list(self.knives):\n if knife[\"position\"][1] != self.player[1]:\n continue\n avoided = (knife[\"height\"] == \"low\" and self.jump_timer > 0) or (\n knife[\"height\"] == \"high\" and self.squat_timer > 0\n )\n if not avoided:\n self.energy -= 2\n self.knives.remove(knife)\n if self.boss is not None and self.boss[\"position\"] == self.player:\n self.energy -= 3\n for projectile in list(self.boss_projectiles):\n if projectile[1] == self.player[1]:\n self.energy -= 2\n self.boss_projectiles.remove(projectile)\n if self.grabbed_by is not None:\n self.energy -= 1\n if self.energy <= 0:\n self._lose_life()\n\n def _complete_floor(self) -> float:\n reward = float(BOSS_VALUES[self.floor] + self.timer * 10 + self.energy * 100)\n self.floor += 1\n if self.floor >= 5:\n self.floor = 0\n self.climb += 1\n if self.climb >= 2:\n self.terminal = True\n else:\n self._start_floor()\n return reward\n\n def _lose_life(self) -> None:\n self.lives -= 1\n if self.lives <= 0:\n self.terminal = True\n else:\n self._start_floor()\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n for enemy in self.enemies.values():\n state[*enemy[\"position\"], 1] = True\n kind = str(enemy[\"kind\"])\n if kind in (\"knife_thrower\", \"dragon_ball\"):\n state[*enemy[\"position\"], 2] = True\n if kind in (\"midget\", \"dragon_ball\"):\n state[*enemy[\"position\"], 3] = True\n if kind in (\"moth\", \"snake\"):\n state[*enemy[\"position\"], 4] = True\n if self.boss is not None:\n state[*self.boss[\"position\"], 1] = True\n for knife in self.knives:\n state[*knife[\"position\"], 2 if knife[\"height\"] == \"high\" else 1] = True\n for projectile in self.boss_projectiles:\n state[*projectile, 1] = True\n state[*self.previous_player, 4] = True\n for knife in self.previous_knives:\n state[*knife, 4] = True\n for index in range(len(REGULAR_ROSTERS[self.floor])):\n state[index // 10, index % 10, 5] = (self.climb, self.floor, index) in self.claimed\n state[2, self.floor, 5] = True\n state[2, 5 + self.climb, 5] = True\n for bit in range(4):\n state[3, bit, 5] = bool(self.lives & (1 << bit))\n state[3, 4 + bit, 5] = bool(self.energy & (1 << bit))\n for bit in range(9):\n state[4, bit, 5] = bool(self.timer & (1 << bit))\n for bit in range(12):\n state[5 + bit // 10, bit % 10, 5] = bool(self.steps & (1 << bit))\n state[7, 0, 5] = self.facing > 0\n state[7, 1 : 1 + self.jump_timer, 5] = True\n state[7, 3 : 3 + self.squat_timer, 5] = True\n state[7, 5, 5] = self.grabbed_by is not None\n if self.grabbed_by is not None:\n for bit in range(4):\n state[7, 6 + bit, 5] = bool(self.grabbed_by & (1 << bit))\n if self.boss is not None:\n for bit in range(4):\n state[8, bit, 5] = bool(int(self.boss[\"health\"]) & (1 << bit))\n for bit in range(3):\n state[8, 4 + bit, 5] = bool(int(self.boss[\"cooldown\"]) & (1 << bit))\n state[8, 7, 5] = self.bonus_life_awarded\n knife_throwers = [enemy for enemy in self.enemies.values() if enemy[\"kind\"] == \"knife_thrower\"]\n for index, enemy in enumerate(knife_throwers[:2]):\n for bit in range(3):\n state[1, index * 3 + bit, 5] = bool(int(enemy[\"cooldown\"]) & (1 << bit))\n for bit in range(10):\n state[9, bit, 5] = bool(self.floor_steps & (1 << bit))\n for bit in range(2):\n state[8, 8 + bit, 5] = bool(self.floor_steps & (1 << (10 + bit)))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 26, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/kung_fu_master.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "blaze_thrust", "split": "train", "game": "blaze_thrust", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Blaze Thrust as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to thrust upward. Release with actions 0–4 to fall\nand slow the rate at which the flame shrinks. Wind bands push the\nflame and oxygen bubbles sideways. Rising scrolls the world and\nspawns bubbles. Collect bubbles to restore flame size and score\nthe current multiplier. Each pickup raises the multiplier up to\n16. A missed bubble resets it to one. The run ends when flame\nsize falls to two.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the flame, left wind, right wind,\nbubbles, upward motion, and gauges. Each action advances four\nframes at fixed difficulty. The conversion uses circular pickup\nchecks and allows pickups regardless of the flame's warning blink.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends on depletion or after 400 actions. Clip the raw\nscore to [0, 250] and divide by the fixed cap of 250.\n\nAcross 100 seeds without sticky actions, idle scored zero,\ncontinuous thrust averaged 11.59 raw points, and random inputs\naveraged 2.26. A repeating six-action thrust and two-action release\ncycle averaged 103.88 and reached 441 before clipping.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/blaze_thrust.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\n\n\n@dataclass\nclass Bubble:\n x: float\n y: float\n size: float\n\n\nclass BlazeThrustEnvironment:\n score_cap = 250\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.hold_time = 0\n self.pressed = self.terminal = False\n self.x, self.y = 50.0, 90.0\n self.vx = self.vy = 0.0\n self.size = 9.0\n self.multiplier = 1\n self.next_bubble = self.random.uniform(10, 40)\n self.winds = [(0.0, self.random.uniform(20, 40))]\n self.bubbles: list[Bubble] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(FRAMES_PER_STEP):\n reward += self._advance_frame()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _wind_left(self, y: float) -> bool:\n return any(top <= y <= bottom for top, bottom in self.winds)\n\n def _advance_frame(self) -> int:\n self.vy += -0.1 if self.pressed else 0.1\n self.hold_time = self.hold_time + 1 if self.pressed else max(0, self.hold_time - 3)\n scroll = max(0, (60 - self.y) * 0.1)\n self.x += self.vx\n self.y += self.vy + scroll\n self.vx *= 0.95\n self.vy *= 0.95\n if self.x < 5:\n self.x, self.vx = 10, abs(self.vx) * 0.5\n elif self.x > 95:\n self.x, self.vx = 90, -abs(self.vx) * 0.5\n if self.y > 95:\n self.y, self.vy = 90, -abs(self.vy) * 0.3\n\n if scroll:\n self.winds = [(top + scroll, bottom + scroll) for top, bottom in self.winds if top + scroll < 120]\n top = self.winds[0][0]\n if top >= 0:\n bottom = top - self.random.uniform(20, 40)\n self.winds.insert(0, (bottom - self.random.uniform(20, 40), bottom))\n self.vx += self.size * (-0.02 if self._wind_left(self.y) else 0.02)\n self.size *= 1 - 0.0016 * (1 + self.hold_time * 0.01)\n if self.size <= 2:\n self.terminal = True\n return 0\n\n reward = self._advance_bubbles(scroll)\n if scroll and len(self.bubbles) < 15:\n self.next_bubble -= scroll\n if self.next_bubble <= 0:\n size = self.random.uniform(3, 9)\n self.bubbles.append(Bubble(self.random.uniform(10, 90), -size, size))\n self.next_bubble = self.random.uniform(5, 55)\n return reward\n\n def _advance_bubbles(self, scroll: float) -> int:\n reward = 0\n remaining = []\n for bubble in self.bubbles:\n bubble.y += scroll + 0.3 - (bubble.size - 3) * 0.015\n bubble.x += bubble.size * (-0.02 if self._wind_left(bubble.y) else 0.02)\n bubble.x = min(95, max(5, bubble.x))\n if math.hypot(bubble.x - self.x, bubble.y - self.y) <= bubble.size + self.size:\n reward += self.multiplier\n self.multiplier = min(16, self.multiplier + 1)\n self.size = min(25, self.size + bubble.size * 0.2)\n elif bubble.y > 120:\n self.multiplier = 1\n else:\n remaining.append(bubble)\n self.bubbles = remaining\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row, column = int(self.y) // 10, int(self.x) // 10\n state[row, column, 0] = True\n state[row, column, 4] = self.vy < 0\n for row in range(10):\n state[row, :, 1 if self._wind_left(10 * row + 5) else 2] = True\n for bubble in self.bubbles:\n if 0 <= bubble.y < 100:\n state[int(bubble.y) // 10, int(bubble.x) // 10, 3] = True\n for row, value in enumerate((round(self.size * 10), self.multiplier, self.hold_time, self.steps)):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[row + 4, 0, 5] = bool(value & 1024)\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 27, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/blaze_thrust.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBlazeThrust.c"} +{"name": "catching_wheel", "split": "train", "game": "catching_wheel", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Catching Wheel as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to rotate the six-basket wheel. Release with actions\n0–4 to stop it. Catch a falling person to score the current multiplier,\nincrease it, and restore one broken basket. A missed person or an\nobstacle hitting a basket destroys a basket and resets the multiplier.\nAn obstacle that hits a person removes them before they can be caught.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the hub, intact baskets, broken baskets,\npeople, obstacles, and gauges. Each action advances four frames at\nfixed difficulty. The conversion uses distance checks for catches\nand collisions.\n\nSCORING, TERMINATION, AND HORIZON\nThe run ends when all baskets break or after 400 actions. Clip raw\nscores to [0, 150] and divide by the fixed cap of 150. Across 100\nseeds without sticky actions, idle averaged 3.87 raw points, holding\naveraged 7.49, and random inputs averaged 6.46.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/catching_wheel.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\nSPOKES = 6\n\n\n@dataclass\nclass Falling:\n x: float\n y: float = 0\n vy: float = 0\n\n def advance(self) -> None:\n self.vy += 0.02\n self.y += self.vy\n\n def near(self, x: float, y: float, radius: float) -> bool:\n return math.hypot(self.x - x, self.y - y) < radius\n\n\nclass CatchingWheelEnvironment:\n score_cap = 150\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = 0\n self.angle = 0.0\n self.human_timer, self.obstacle_timer = 40.0, 99.0\n self.multiplier = 1\n self.pressed = self.terminal = False\n self.baskets = [True] * SPOKES\n self.humans: list[Falling] = []\n self.obstacles: list[Falling] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(FRAMES_PER_STEP):\n reward += self._advance_frame()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _positions(self) -> list[tuple[float, float]]:\n angles = (self.angle + index * math.tau / SPOKES for index in range(SPOKES))\n return [(50 + 40 * math.cos(angle), 90 + 40 * math.sin(angle)) for angle in angles]\n\n def _change_basket(self, restore: bool) -> None:\n start = int(self.random.integers(SPOKES))\n for offset in range(SPOKES):\n index = (start + offset) % SPOKES\n if self.baskets[index] != restore:\n self.baskets[index] = restore\n if not restore:\n self.multiplier = 1\n break\n\n def _advance_frame(self) -> int:\n self.obstacle_timer -= 1\n if self.obstacle_timer <= 0:\n self.obstacles.append(Falling(self.random.uniform(20, 80)))\n self.obstacle_timer = self.random.uniform(79.2, 118.8)\n for obstacle in self.obstacles:\n obstacle.advance()\n self.obstacles = [obstacle for obstacle in self.obstacles if obstacle.y <= 95]\n\n if self.pressed:\n self.angle = (self.angle + 0.05) % math.tau\n positions = self._positions()\n for index, (x, y) in enumerate(positions):\n if self.baskets[index] and any(obstacle.near(x, y, 9) for obstacle in self.obstacles):\n self.baskets[index] = False\n self.multiplier = 1\n catchable = [point for point, live in zip(positions, self.baskets) if live]\n\n self.human_timer -= 1\n if self.human_timer <= 0:\n self.humans.append(Falling(self.random.uniform(10, 90)))\n self.human_timer = self.random.uniform(28, 40)\n reward = 0\n remaining = []\n for human in self.humans:\n human.advance()\n if any(obstacle.near(human.x, human.y, 5) for obstacle in self.obstacles):\n continue\n if any(human.near(x, y, 6) for x, y in catchable):\n reward += self.multiplier\n self.multiplier += 1\n self._change_basket(restore=True)\n elif human.y > 100:\n self._change_basket(restore=False)\n else:\n remaining.append(human)\n self.humans = remaining\n self.terminal = not any(self.baskets)\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[9, 5, 0] = True\n for live, (x, y) in zip(self.baskets, self._positions()):\n if 0 <= y < 100:\n state[int(y) // 10, int(x) // 10, 1 if live else 2] = True\n for channel, objects in ((3, self.humans), (4, self.obstacles)):\n for obj in objects:\n if obj.y < 100:\n state[int(obj.y) // 10, int(obj.x) // 10, channel] = True\n for row, value in enumerate((self.steps, self.multiplier, round(self.angle * 80))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :SPOKES, 5] = self.baskets\n state[9, SPOKES, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 28, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/catching_wheel.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameCatchingWheel.c"} +{"name": "d_missile", "split": "train", "game": "d_missile", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays D Missile as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 and release with actions 0–4 to launch. Hold to turn\nall active missiles clockwise. Missiles accelerate and can hit\nmultiple enemies. Up to three missiles can be active at a time.\nThe first launch allows a longer press than subsequent launches.\n\nEnemies descend toward the ground and can split in flight. A hit\nscores the current multiplier rounded down and increases it by\none divided by the active missile count. Launching reduces the\nmultiplier by 10 percent, with a floor of one. An enemy reaching\nthe ground ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show missiles and the launcher, missile\nheadings, enemies, split warnings, ground, and gauges. Each action\nadvances four frames at fixed difficulty. The conversion uses\nrectangular collision checks and replaces a splitting parent\nwith its fragments.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 100] and divide by 100. Across 100 seeds without sticky\nactions, idle scored zero, random hold and release averaged\n43.11 and reached 115 before clipping, and a repeating launch\nand turn pattern averaged 10.90.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/d_missile.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nLAUNCH_ANGLE = -8 * math.pi / 9\n\n\n@dataclass\nclass Missile:\n x: float = 60\n y: float = 90\n angle: float = LAUNCH_ANGLE\n speed: float = 0.5\n\n\n@dataclass\nclass Enemy:\n x: float\n y: float\n vx: float\n vy: float\n timer: int\n\n\nclass DMissileEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.tap_timer = self.spawn_timer = 0\n self.pressed = self.terminal = False\n self.multiplier = 1.0\n self.missiles: list[Missile] = []\n self.enemies: list[Enemy] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed:\n count = len(self.missiles)\n self.tap_timer = 99 if count == 0 else 9 if count < 3 else 0\n released = self.pressed and not pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance_frame(released and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _enemy(self, x: float, y: float, timer: int) -> Enemy:\n angle = math.atan2(90 - y, self.random.uniform(10, 90) - x)\n return Enemy(x, y, math.cos(angle) * 0.1, math.sin(angle) * 0.1, timer)\n\n def _advance_frame(self, released: bool) -> int:\n self.tap_timer = max(0, self.tap_timer - 1)\n if released and self.tap_timer:\n self.missiles.append(Missile())\n self.multiplier = max(1, self.multiplier * 0.9)\n for missile in self.missiles:\n missile.x += math.cos(missile.angle) * missile.speed\n missile.y += math.sin(missile.angle) * missile.speed\n missile.speed *= 1.002\n if self.pressed:\n missile.angle = (missile.angle + missile.speed * (0.1 if missile.speed < 3 else 0.01)) % math.tau\n self.missiles = [missile for missile in self.missiles\n if -3 <= missile.x < 103 and -3 <= missile.y < 90]\n self.spawn_timer = self.spawn_timer - 1 if self.enemies else -1\n if self.spawn_timer < 0:\n count = int(self.random.integers(3, 6))\n for _ in range(count):\n self.enemies.append(self._enemy(self.random.uniform(10, 90), -self.random.uniform(5, 25),\n int(self.random.integers(300, 401))))\n self.spawn_timer = 150 * count\n\n reward = 0\n survivors = []\n for enemy in self.enemies:\n enemy.x += enemy.vx\n enemy.y += enemy.vy\n enemy.timer -= 1\n if enemy.timer == 0:\n for _ in range(int(self.random.integers(2, 5))):\n survivors.append(self._enemy(enemy.x, enemy.y, 999))\n elif any(abs(missile.x - enemy.x) < 3.5 and abs(missile.y - enemy.y) < 3.5\n for missile in self.missiles):\n reward += math.floor(self.multiplier)\n self.multiplier += 1 / len(self.missiles)\n else:\n survivors.append(enemy)\n self.terminal |= enemy.y > 90\n self.enemies = survivors\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[9, :, 4] = True\n state[9, 6, 0] = len(self.missiles) < 3\n for missile in self.missiles:\n if 0 <= missile.x < 100 and 0 <= missile.y < 100:\n state[int(missile.y) // 10, int(missile.x) // 10, 0] = True\n x = missile.x + 8 * math.cos(missile.angle)\n y = missile.y + 8 * math.sin(missile.angle)\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y) // 10, int(x) // 10, 1] = True\n for enemy in self.enemies:\n if 0 <= enemy.x < 100 and 0 <= enemy.y < 100:\n row, col = int(enemy.y) // 10, int(enemy.x) // 10\n state[row, col, 2] = True\n state[row, col, 3] |= enemy.timer <= 40\n for row, value in enumerate((self.steps, round(self.multiplier * 8), self.tap_timer, len(self.missiles))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 29, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/d_missile.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/dmissile/main.js"} +{"name": "p_fit", "split": "train", "game": "p_fit", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays P Fit as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nUse action 1 to slide left and action 3 to slide right.\nOther actions hold position. Directional actions replace\npointer input and move four source pixels at a time.\n\nAlign the two complementary profiles as they approach.\nStaying within three pixels of alignment for 31 frames\nscores the remaining time bonus. If the profiles overlap\nbefore the match, the run ends.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the fixed profile, moving\nprofile, aligned preview, cursor, alignment target, and\ngauges. The conversion uses rectangular contact checks\nand starts the next puzzle after the match delay. The\n400-action task clips scores to [0, 2400] and divides by 2400.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/p_fit.py`):\n```python\nimport numpy as np\n\n\nclass PFitEnvironment:\n score_cap = 2400\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.cursor = 50\n self.steps = self.action = 0\n self.terminal = False\n self._new_pair()\n\n def _new_pair(self):\n start = self.random.uniform(22, 32)\n heights = start + np.cumsum(self.random.uniform(10, 50, 6) / 6)\n self.heights = self.random.permutation(heights)\n for _ in range(9):\n self.target = self.random.uniform(10, 90)\n if abs(self.offset) > 20:\n break\n self.fixed_y, self.moving_y = 75.0, 225.0\n self.fixed_target, self.moving_target = -25.0, 125.0\n self.match_ticks = 0\n self.points = 300\n\n @property\n def offset(self):\n return (self.cursor - self.target + 60) % 120 - 60\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n if self.match_ticks <= 30:\n self.cursor = min(99, max(0, self.cursor + 4 * ((self.action == 3) - (self.action == 1))))\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n self.fixed_y += (self.fixed_target - self.fixed_y) * 0.1\n self.moving_y += (self.moving_target - self.moving_y) * 0.1\n if self.match_ticks > 30:\n self.match_ticks += 1\n if self.match_ticks == 60:\n self._new_pair()\n return 0\n self.fixed_target += 0.02\n self.moving_target -= 0.02\n if self.match_ticks < 30 and self._collision():\n self.terminal = True\n return 0\n self.match_ticks = self.match_ticks + 1 if abs(self.offset) < 3 else 0\n if self.match_ticks > 30:\n self.fixed_target, self.moving_target = 1, 99\n return self.points\n self.points = max(0, self.points - 1)\n return 0\n\n def _collision(self):\n for i, height in enumerate(self.heights):\n left = 20 * i - 10\n fixed_bottom = self.fixed_y + height\n for j, moving_height in enumerate(self.heights):\n moving_left = (20 * j - 10 + self.offset + 20) % 120 - 20\n if abs(left - moving_left) < 20 and self.moving_y + moving_height - 99 < fixed_bottom:\n return True\n return False\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n fixed = self.heights[((cols + 10) // 20) % 6]\n moving = self.heights[(((cols - self.offset + 10) % 120) // 20).astype(int)]\n state[:, :, 0] = (rows >= self.fixed_y) & (rows < self.fixed_y + fixed)\n state[:, :, 1] = (rows <= self.moving_y) & (rows > self.moving_y + moving - 99)\n state[:, :, 2] = (rows <= self.moving_y) & (rows > self.moving_y + fixed - 99)\n state[9, self.cursor // 10, 3] = True\n state[9, int(self.target // 10), 4] = True\n values = (self.steps, self.points, self.match_ticks, round((self.offset + 60) * 4))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 30, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/p_fit.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/pfit/main.js"} +{"name": "doshin", "split": "train", "game": "doshin", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Doshin as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nActions 1–4 activate the four presses from left to right. Actions\n0 and 5 wait. Switch actions before using the same press again.\nEach press strikes for one frame, then retracts before it can fire\nagain.\n\nLet friendly walkers cross for 10 points each. Crush enemies\nbefore they escape. Enemies falling offscreen in the same frame\nscore 1, 2, 3, and so on. Striking a friendly walker or allowing\nan enemy to escape ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show presses, ready indicators, friends,\nenemies, struck walkers, and gauges. The conversion maps pointer\nselection to direct press actions and uses fixed difficulty and\nhorizontal strike checks. Each action advances four frames.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 200] and divide by 200. Across 100 seeds without sticky actions,\nidle averaged 8.60 and random inputs averaged 2.33. A policy that\naimed at enemies using exact positions averaged 102.26 and reached 160.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/doshin.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\nCENTERS = (25, 75, 125, 175)\n\n\n@dataclass\nclass Walker:\n x: float\n speed: float\n friendly: bool\n y: float = 87\n vy: float = 0\n struck: bool = False\n\n\nclass DoshinEnvironment:\n score_cap = 200\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.last_action = self.until_friend = 0\n self.terminal = False\n self.cooldowns = [0] * len(CENTERS)\n self.walkers: list[Walker] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n press = action - 1 if 1 <= action <= 4 and action != self.last_action else None\n self.last_action = action\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance_frame(press if frame == 0 else None)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self, press: int | None) -> int:\n if self.random.random() < 0.03:\n self.until_friend -= 1\n friendly = self.until_friend < 0\n if friendly:\n speed = 0.6 + 0.2 * int(self.random.integers(2))\n self.until_friend = int(self.random.integers(10, 20))\n else:\n speed = 0.1 + 0.2 * int(self.random.integers(4))\n self.walkers.append(Walker(0, speed, friendly))\n active = press is not None and self.cooldowns[press] == 0\n self.cooldowns = [max(0, timer - 1) for timer in self.cooldowns]\n if active:\n self.cooldowns[press] = 60\n\n survivors = []\n reward, combo = 0, 1\n for walker in self.walkers:\n walker.x += walker.speed\n walker.y += walker.vy\n if walker.struck:\n walker.vy += 0.1\n if walker.y > 99:\n if walker.friendly:\n self.terminal = True\n else:\n reward += combo\n combo += 1\n continue\n else:\n if active and abs(walker.x - CENTERS[press]) < 18:\n walker.struck = True\n walker.vy = -1\n if walker.x > 199:\n if walker.friendly:\n reward += 10\n else:\n self.terminal = True\n continue\n survivors.append(walker)\n self.walkers = survivors\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for index, (center, timer) in enumerate(zip(CENTERS, self.cooldowns)):\n column = center // 20\n row = min(9, (30 + timer) // 10)\n state[:row, column, 0] = True\n state[0, column, 1] = timer == 0\n for bit in range(6):\n state[index, bit, 5] = bool(timer & (1 << bit))\n for walker in self.walkers:\n if 0 <= walker.x < 200 and 0 <= walker.y < 100:\n row, col = int(walker.y) // 10, int(walker.x) // 20\n state[row, col, 2 if walker.friendly else 3] = True\n state[row, col, 4] |= walker.struck\n for bit in range(9):\n state[8, bit, 5] = bool(self.steps & (1 << bit))\n state[9, self.last_action, 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 31, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/doshin.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/doshin/main.js"} +{"name": "holes", "split": "train", "game": "holes", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Holes as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to switch which set of ramp sections is solid.\nActions 0–4 release the button. Balls roll down alternating\nramps. Collecting a coin adds a ball, up to nine, and extends\nthe course toward the opposite side. The run ends when all\nballs are lost.\n\nEach coin scores ten points per active ball. Downward scrolling\nalso scores distance times the active ball count. The task\nclips the raw total to [0, 2000] and divides by 2000.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show balls, permanent ramp sections,\nthe two switchable section sets, the coin, and gauges. The\nconversion uses fixed difficulty and geometric ramp collisions\nwith four frames per action and a 400-action horizon.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/holes.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nSLOPE = math.tan(0.2)\n\n\n@dataclass\nclass Ball:\n x: float\n y: float\n vx: float = 0.0\n vy: float = 0.0\n\n def reflect(self, nx: float, ny: float) -> None:\n approach = min(0, self.vx * nx + self.vy * ny)\n self.vx -= 1.7 * approach * nx\n self.vy -= 1.7 * approach * ny\n\n\n@dataclass\nclass Ramp:\n x: float\n y: float\n direction: int\n length: float\n gate: int = -1\n\n def height_at(self, distance: float) -> float:\n return self.y + distance * SLOPE\n\n\nclass HolesEnvironment:\n score_cap = 2000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.balls = [Ball(10, 0)]\n self.ramps: list[Ramp] = []\n self.gate = self.next_gate = self.steps = 0\n self.scroll, self.scroll_line = 0.0, 60.0\n self.pressed = self.terminal = False\n self._place_coin(20, 1)\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed:\n self.gate ^= 1\n self.scroll_line -= 9\n self.pressed = pressed\n self.steps += 1\n reward = 0.0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _place_coin(self, y: float, direction: int) -> None:\n self.coin_x = 10 if direction == 1 else 89\n self.coin_y = y\n self.coin_ramp = Ramp(7 if direction == 1 else 93, y + 9, direction, 9)\n self.ramps.append(self.coin_ramp)\n\n def _extend(self) -> None:\n ramp = self.coin_ramp\n self.ramps.remove(ramp)\n holes = []\n for x in self.random.uniform(15, 64.5, 5):\n if all(abs(x - other) >= 21 for other in holes):\n holes.append(x)\n start = 0.0\n for x in sorted(holes):\n edge = x - 6\n self._segment(ramp, start, edge - start - 5)\n self._segment(ramp, edge, 7, self.next_gate)\n if self.random.random() < 0.7:\n self.next_gate ^= 1\n start = x + 6\n self._segment(ramp, start, 80 - start - 5)\n self._place_coin(ramp.y + 80 * math.sin(0.2) + 9, -ramp.direction)\n\n def _segment(self, ramp: Ramp, start: float, length: float, gate: int = -1) -> None:\n self.ramps.append(Ramp(ramp.x + start * ramp.direction, ramp.height_at(start),\n ramp.direction, length, gate))\n\n def _advance(self) -> float:\n reward = self.scroll * len(self.balls)\n self.coin_y -= self.scroll\n for ramp in self.ramps:\n ramp.y -= self.scroll\n if ramp.y < 9:\n ramp.y -= 1\n self.ramps = [ramp for ramp in self.ramps if ramp is self.coin_ramp or ramp.height_at(ramp.length) >= 0]\n deepest = 0.0\n for ball in tuple(self.balls):\n ball.vy = (ball.vy + 0.2) * 0.98\n ball.vx *= 0.98\n ball.x += ball.vx * 0.5\n ball.y += ball.vy * 0.5 - self.scroll\n if ball.y < self.scroll_line + 20:\n deepest = max(deepest, ball.y)\n if math.hypot(ball.x - self.coin_x, ball.y - self.coin_y) < 5:\n reward += 10 * len(self.balls)\n if len(self.balls) < 9:\n self.balls.append(Ball(self.random.uniform(30, 70), 0, vy=1))\n self._extend()\n if ball.x < 6 or ball.x > 94:\n ball.reflect(1 if ball.x < 6 else -1, 0)\n ball.x = min(94, max(6, ball.x))\n for ramp in self.ramps:\n distance = (ball.x - ramp.x) * ramp.direction\n height = ramp.height_at(distance)\n if ramp.gate in (-1, self.gate) and -1 < distance < ramp.length + 1 and abs(ball.y - height) < 3:\n ball.reflect(math.sin(0.2) * ramp.direction, -math.cos(0.2))\n ball.y = height - 3\n self.balls = [ball for ball in self.balls if -1 <= ball.y <= 100]\n for ball in self.balls:\n for other in self.balls:\n dx, dy = ball.x - other.x, ball.y - other.y\n distance = math.hypot(dx, dy)\n if 0 < distance <= 2:\n ball.reflect(dx / distance, dy / distance)\n self.scroll = max(0, deepest - self.scroll_line) * 0.1\n self.scroll_line += (60 - self.scroll_line) * 0.01\n self.terminal = not self.balls\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for ball in self.balls:\n state[min(9, max(0, int(ball.y) // 10)), int(ball.x) // 10, 0] = True\n for ramp in self.ramps:\n channel = 1 if ramp.gate < 0 else 2 + ramp.gate\n for distance in range(0, math.ceil(ramp.length) + 1, 2):\n x, y = ramp.x + distance * ramp.direction, ramp.height_at(distance)\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y) // 10, int(x) // 10, channel] = True\n if 0 <= self.coin_y < 100:\n state[int(self.coin_y) // 10, self.coin_x // 10, 4] = True\n for row, value in enumerate((self.steps, len(self.balls), round(self.scroll_line) + 256)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, bool(self.gate)\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 32, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/holes.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/holes/main.js"} +{"name": "turbulent", "split": "train", "game": "turbulent", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Turbulent as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nRide the waves and tap action 5 to jump. Hold it to reduce gravity\nin the air. Release with any other action before jumping again.\nLanding pays the forward distance traveled in the jump, rounded up.\nHitting a floating mine ends the episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the ship, wave surface, mines, airborne\nship, jump origin, and counters. The port uses fixed difficulty,\nsorts wave anchors before interpolating across the wrap, and\napproximates hull contact using the ship's nose. Each action\nadvances up to four frames over 400 actions. Clip episode scores\nto [0, 500] and divide by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/turbulent.py`):\n```python\nfrom bisect import bisect_right\nfrom dataclasses import dataclass\nfrom math import atan2, ceil, cos, hypot, pi, remainder, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Wave:\n x: float\n height: float\n phase: float\n speed: float\n\n\n@dataclass\nclass Mine:\n x: float\n vx: float = 0.\n\n\nclass TurbulentEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.waves = [\n Wave(i * 20 - 20, self.random.uniform(10, 30),\n (i % 2) * pi + self.random.uniform(-pi / 4, pi / 4),\n self.random.uniform(0.01, 0.02))\n for i in range(7)\n ]\n self.mines = []\n self.mine_distance = 0.\n self.x, self.y = 40., 60.\n self.vx = self.vy = self.angle = self.jump_x = 0.\n self.airborne = self.terminal = False\n self.steps = self.action = 0\n self._surface_points()\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n jump = self.action == 5 and previous != 5\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(jump and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _surface_points(self):\n peaks = sorted((w.x, 60 + sin(w.phase) * w.height) for w in self.waves)\n points = [peaks[0]]\n for (x, y), (right, next_y) in zip(peaks, peaks[1:]):\n points.extend((x + 5 * i, y + (next_y - y) * ratio)\n for i, ratio in enumerate((0.2, 0.5, 0.8), 1))\n points.append((right, next_y))\n self.surface_x, self.surface_y = zip(*points, strict=True)\n\n def _surface(self, x):\n index = min(len(self.surface_x) - 2, max(0, bisect_right(self.surface_x, x) - 1))\n width = self.surface_x[index + 1] - self.surface_x[index]\n rise = self.surface_y[index + 1] - self.surface_y[index]\n height = self.surface_y[index] + rise * (x - self.surface_x[index]) / width\n return height, rise, width\n\n def _advance(self, jump):\n scroll = 0.1 + max(0, self.x - 50) * 0.1\n for wave in self.waves:\n wave.x -= scroll\n if wave.x < -20:\n wave.x += 140\n wave.height = self.random.uniform(10, 30)\n wave.phase = self.random.uniform(0, 2 * pi)\n wave.speed = self.random.uniform(0.01, 0.02)\n wave.phase += wave.speed\n self._surface_points()\n\n self.mine_distance -= scroll\n if self.mine_distance < 0:\n self.mines.append(Mine(103))\n self.mine_distance = self.random.uniform(100, 120)\n mine_positions = []\n remaining = []\n for mine in self.mines:\n mine.x -= scroll\n if not self.surface_x[0] <= mine.x < self.surface_x[-1]:\n continue\n height, rise, width = self._surface(mine.x)\n mine.vx = (mine.vx + rise * 0.001) * 0.9\n mine.x += mine.vx\n if mine.x >= -3:\n remaining.append(mine)\n mine_positions.append((mine.x, height + rise * mine.vx / width - 5))\n self.mines = remaining\n\n if self.airborne:\n self.jump_x -= scroll\n self.vx = (self.vx + 0.005) * 0.98\n self.vy = (self.vy + (0.02 if self.action == 5 else 0.1)) * 0.98\n self.x += self.vx\n self.y += self.vy\n angle = atan2(self.vy, self.vx)\n else:\n previous_x, previous_y = self.x, self.y\n height, rise, width = self._surface(self.x)\n self.vx = (self.vx + rise * 0.002) * 0.925 + 0.025\n self.x += self.vx\n self.y = height + rise * self.vx / width\n angle = atan2(rise, width)\n if jump:\n self.jump_x = self.x\n self.vx = (self.x - previous_x) * 2 + sin(angle)\n self.vy = min(-1, (self.y - previous_y) * 5 - cos(angle))\n self.x += self.vx\n self.y += self.vy\n self.airborne = True\n\n self.x = min(95, max(5, self.x - scroll))\n self.y = min(95, max(5, self.y))\n self.angle += remainder(angle - self.angle, 2 * pi) * 0.1\n nose_x = self.x + 5.8 * sin(self.angle)\n nose_y = self.y - 5.8 * cos(self.angle)\n reward = 0\n if self.airborne and nose_y >= self._surface(nose_x)[0] - 2:\n reward = max(0, ceil(self.x - self.jump_x))\n self.airborne = False\n self.vx *= 0.5\n self.terminal = any(hypot(x - nose_x, y - nose_y) <= 4 for x, y in mine_positions)\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(self.y // 10), int(self.x // 10), 0] = True\n for col in range(10):\n heights = [self._surface(col * 10 + offset)[0] for offset in (0, 5, 10)]\n state[int(min(heights) // 10):int(max(heights) // 10) + 1, col, 1] = True\n for mine in self.mines:\n row = int((self._surface(mine.x)[0] - 5) // 10)\n state[row, int(np.clip(mine.x // 10, 0, 9)), 2] = True\n if self.airborne:\n state[int(self.y // 10), int(self.x // 10), 3] = True\n state[9, int(np.clip(self.jump_x // 10, 0, 9)), 4] = True\n values = (self.steps, self.action, round((self.vx + 8) * 16),\n round((self.vy + 16) * 8), round((self.angle + pi) * 64))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 33, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/turbulent.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/turbulent/main.js"} +{"name": "reflector", "split": "train", "game": "reflector", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Reflector as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to turn. Hold it to slow down and strengthen the\nreflector, making it narrower and boosting reflected shots. Actions\n0–4 release. The UFO moves automatically, and the reflector tilts\nwhile released. Reflect tank fire back toward the ground. Blasts\ndestroy tanks for increasing points until all blasts expire.\nAn upward shot that hits the UFO ends the episode.\n\nINPUT CHANNEL TABLE\nThe six channels show the UFO, tanks, upward shots, downward shots,\nblasts, and counters. The port uses fixed difficulty and approximates\nsprite and blast collision shapes with geometric bounds. Each action\nadvances up to four frames over a 400-action horizon. Clip episode\nscores to [0, 100] and divide by 100.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/reflector.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import atan2, cos, hypot, pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Tank:\n x: float\n speed: float\n turn: float\n interval: float\n timer: float\n shot_speed: float\n angle: float = -pi / 2\n\n\n@dataclass\nclass Bullet:\n x: float\n y: float\n vx: float\n vy: float\n\n\n@dataclass\nclass Blast:\n x: float\n y: float\n radius: float\n duration: float\n age: int = 0\n\n def reach(self):\n return self.radius * sin(pi * self.age / self.duration)\n\n\nclass ReflectorEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.direction = 40.0, 1\n self.angle = self.power = 0.0\n self.timer = self.steps = 0\n self.multiplier = 1\n self.held = self.terminal = False\n self.tanks = []\n self.bullets = []\n self.blasts = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n if tap or (self.x < 3 and self.direction < 0) or (self.x > 97 and self.direction > 0):\n self.direction *= -1\n if self.held:\n self.power += (1 - self.power) * 0.05\n else:\n self.power *= 0.9\n self.angle = min(pi / 4, max(-pi / 4, self.angle - self.direction * 0.07))\n self.x += self.direction * (0.25 if self.held else 0.5)\n if not self.tanks:\n self.timer = 0\n self.timer -= 1\n if self.timer < 0:\n direction = self.random.choice((-1, 1))\n interval = self.random.uniform(200, 300)\n agility = self.random.uniform(1, 5)\n self.tanks.append(Tank(-3 if direction > 0 else 103, direction * 0.1 / agility ** 0.5,\n agility * 0.002, interval, interval, self.random.uniform(1, 1.5)))\n self.timer = self.random.uniform(60, 80)\n if not self.blasts:\n self.multiplier = 1\n for blast in self.blasts:\n blast.age += 1\n self.blasts = [blast for blast in self.blasts if blast.age <= blast.duration]\n reward = 0\n tanks = []\n for tank in self.tanks:\n tank.x += tank.speed\n aim = atan2(-78, self.x - tank.x)\n tank.angle += min(tank.turn, max(-tank.turn, aim - tank.angle))\n if any(hypot(tank.x - blast.x, 87 - blast.y) <= blast.reach() + 3 for blast in self.blasts):\n reward += self.multiplier\n self.multiplier += 1\n continue\n tank.timer -= 1\n if tank.timer < 0:\n self.bullets.append(Bullet(tank.x, 87, cos(tank.angle) * tank.shot_speed,\n sin(tank.angle) * tank.shot_speed))\n tank.timer = tank.interval\n if -3 <= tank.x <= 103:\n tanks.append(tank)\n self.tanks = tanks\n bullets = []\n for bullet in self.bullets:\n bullet.x += bullet.vx\n bullet.y += bullet.vy\n if bullet.vy < 0:\n if self._shield_hit(bullet):\n angle = 2 * self.angle - atan2(bullet.vy, bullet.vx)\n speed = hypot(bullet.vx, bullet.vy) * (1 + 4 * self.power)\n bullet.vx, bullet.vy = speed * cos(angle), speed * sin(angle)\n bullet.x += bullet.vx * 2\n bullet.y = max(20, bullet.y + bullet.vy * 2)\n elif abs(bullet.x - self.x) < 5 and abs(bullet.y - 9) < 5:\n self.terminal = True\n if bullet.vy > 0 and (bullet.y >= 88 or any(\n abs(bullet.x - tank.x) < 5 and abs(bullet.y - 87) < 5 for tank in self.tanks\n )):\n speed = hypot(bullet.vx, bullet.vy)\n self.blasts.append(Blast(bullet.x, bullet.y, speed ** 2, speed * 9))\n elif -3 <= bullet.x <= 103 and -3 <= bullet.y <= 103:\n bullets.append(bullet)\n self.bullets = bullets\n return reward\n\n def _shield_hit(self, bullet):\n dx = bullet.x - (self.x - 6 * sin(self.angle))\n dy = bullet.y - (9 + 6 * cos(self.angle))\n parallel = dx * cos(self.angle) + dy * sin(self.angle)\n normal = -dx * sin(self.angle) + dy * cos(self.angle)\n return abs(parallel) < (9 - self.power * 9) / 2 + 2 and abs(normal) < (3 + self.power * 3) / 2 + 2\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[0, int(self.x // 10), 0] = True\n for tank in self.tanks:\n if 0 <= tank.x < 100:\n state[8, int(tank.x // 10), 1] = True\n for bullet in self.bullets:\n if 0 <= bullet.x < 100 and 0 <= bullet.y < 100:\n state[int(bullet.y // 10), int(bullet.x // 10), 2 + int(bullet.vy >= 0)] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for blast in self.blasts:\n state[:, :, 4] |= np.hypot(cols - blast.x, rows - blast.y) <= blast.reach() + 5\n gauges = (self.steps, self.multiplier, round(self.power * 100),\n round((self.angle + pi / 4) * 100), self.direction > 0, self.held)\n for row, value in enumerate(gauges):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 34, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/reflector.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/reflector/main.js"} +{"name": "grenadier", "split": "train", "game": "grenadier", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Grenadier as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to climb out of cover. Press it again while running\nto aim, then release with actions 0–4 to throw. Holding rotates\nthe aim upward and eventually triggers an automatic throw.\n\nGrenades that hit a tank score its horizontal position. Grenades\nthat hit the ground dig cover. Tanks can destroy cover, and\ntheir bullets threaten the player above ground.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, cover, tanks, bullets,\ngrenades, and gauges. Each action advances four frames at fixed\ndifficulty. Collisions use proximity checks in place of sprite\noverlap. The task lasts up to 400 actions and clips raw scores\nto [0, 2000] before dividing by 2000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/grenadier.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Tank:\n x: float\n timer: float\n interval: float\n\n\n@dataclass\nclass Grenade:\n x: float\n y: float\n vx: float\n vy: float\n\n\nclass GrenadierEnvironment:\n score_cap = 2000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x = 10.0\n self.mode = \"cover\"\n self.angle = 0.0\n self.speed = 1.0\n self.spawn_timer = 0.0\n self.steps = 0\n self.pressed = self.terminal = False\n self.holes = [10.0]\n self.tanks: list[Tank] = []\n self.bullets: list[float] = []\n self.grenades: list[Grenade] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap, release = pressed and not self.pressed, self.pressed and not pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0.0\n for frame in range(4):\n reward += self._advance(tap and frame == 0, release and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _advance(self, tap: bool, release: bool) -> float:\n scroll = (self.x - 10) * 0.05\n self.spawn_timer -= 1\n if self.spawn_timer < 0:\n interval = 300 / (1 + self.random.random())\n self.tanks.append(Tank(203, self.random.uniform(0, interval), interval))\n self.spawn_timer = 200 / (1 + self.random.random())\n for tank in self.tanks:\n tank.x -= 0.08 * self.speed + scroll\n self.holes = [x - scroll for x in self.holes if x - scroll > -4]\n reward = 0.0\n airborne = []\n for grenade in self.grenades:\n grenade.x += grenade.vx\n grenade.y += grenade.vy\n grenade.vy += 0.1\n hit = next((tank for tank in self.tanks\n if abs(tank.x - grenade.x) < 4 and abs(67 - grenade.y) < 4), None)\n if hit is not None:\n reward += max(0, hit.x)\n self.tanks.remove(hit)\n elif grenade.y > 68:\n self.holes.append(grenade.x)\n else:\n airborne.append(grenade)\n self.grenades = airborne\n self.tanks = [tank for tank in self.tanks if tank.x > -4]\n if not self.tanks:\n self.spawn_timer *= 0.7\n for tank in self.tanks:\n tank.timer -= 1\n if tank.x > 150 and self.mode != \"cover\" and tank.timer < 0:\n self.bullets.append(tank.x - 5)\n tank.timer = tank.interval\n self.bullets = [x - 0.4 * self.speed - scroll for x in self.bullets\n if x - 0.4 * self.speed - scroll > -4]\n self.holes = [x for x in self.holes if all(abs(tank.x - x) >= 6 for tank in self.tanks)]\n self.x -= scroll\n if self.mode == \"cover\":\n self.speed += 0.05\n if tap:\n self.mode = \"run\"\n self.x += 6\n else:\n self.terminal = any(abs(tank.x - self.x) < 5 for tank in self.tanks)\n if any(abs(x - self.x - 5) < 6 for x in self.holes):\n self.x += 1\n else:\n self.speed += (1 - self.speed) * 0.1\n if self.mode == \"run\":\n self.x += 0.8\n if any(abs(x - self.x) < 5 for x in self.holes):\n self.mode = \"cover\"\n elif tap:\n self.mode = \"aim\"\n self.angle = 0.0\n elif release or self.angle < -1:\n speed = 4 - self.angle * 0.5\n self.grenades.append(Grenade(self.x, 67, speed * math.cos(self.angle),\n speed * math.sin(self.angle)))\n self.mode = \"run\"\n else:\n self.angle -= 0.02\n self.terminal = any(abs(tank.x - self.x) < 5 for tank in self.tanks) or any(\n abs(x - self.x) < 4 for x in self.bullets\n )\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[9 if self.mode == \"cover\" else 8, int(self.x) // 20, 0] = True\n for channel, positions in ((1, self.holes), (2, [tank.x for tank in self.tanks]), (3, self.bullets)):\n for x in positions:\n if 0 <= x < 200:\n state[8, int(x) // 20, channel] = True\n for grenade in self.grenades:\n if 0 <= grenade.x < 200 and 0 <= grenade.y < 80:\n state[int(grenade.y) // 8, int(grenade.x) // 20, 4] = True\n for row, value in enumerate((self.steps, round(-100 * self.angle))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :3, 5] = self.pressed, self.mode == \"cover\", self.mode == \"aim\"\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 35, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/grenadier.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/grenadier/main.js"} +{"name": "assault", "split": "train", "game": "assault", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Assault as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves *Assault*'s fixed-cannon defense loop. An indestructible mothership\ncrosses the top of the screen and lays ten aliens per wave. The cannon moves along the base,\nfires upward with action 2 (the original joystick-up shot), and fires laterally in its last faced\ndirection with action 5 (the original fire-plus-left/right shot). Firing builds heat; pausing to\ncool is necessary because overheating costs a cannon.\n\nAliens use the manual's three broad movement patterns across successive waves: horizontal patrol,\ndescending patrol, and intermittent relocation. The lowest alien launches an indestructible\ndownward weapon. A weapon reaching the base becomes a horizontally moving fireball, which is the\none hostile projectile the cannon can destroy. Half the deployed aliens split into two smaller\ntargets when hit. The episode ends after five waves, three cannon losses, or 1,500 steps.\n\nACTION MAPPING\n0: wait\n1: move left\n2: fire upward\n3: move right\n4: wait\n5: fire laterally toward facing\n\nINPUT CHANNEL TABLE\n0: cannon\n1: mothership and hostile weapons\n2: alien targets\n3: friendly vertical and lateral shots\n4: previous alien and hostile-projectile positions\n5: heat, remaining cannons, and wave\n\nSCORING, TERMINATION, AND HORIZON\nEach wave contains five ordinary aliens worth one point and five splitting aliens that produce two\none-point small aliens. Therefore each wave has 15 reward and five waves have `score_cap = 75`.\nNo object respawns within a wave. Normalization is `min(max(raw_score, 0), 75) / 75`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/assault.py`):\n```python\nimport numpy as np\n\n\nclass AssaultEnvironment:\n \"\"\"Fixed-cannon wave defense with vertical/lateral fire and weapon heat.\"\"\"\n\n score_cap = 75.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 1_500):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.player_column = 5\n self.facing = 1\n self.mothership_column = 0\n self.mothership_direction = 1\n self.aliens: list[dict[str, int | bool]] = []\n self.friendly_shots: list[list[int]] = []\n self.hostile_shots: list[list[int]] = []\n self.fireballs: list[list[int]] = []\n self.previous_aliens: list[list[int]] = []\n self.previous_hostiles: list[list[int]] = []\n self.wave = 0\n self.spawned = 0\n self.lives = 3\n self.heat = 0\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n fired = False\n if action == 1:\n self.player_column = max(0, self.player_column - 1)\n self.facing = -1\n elif action == 3:\n self.player_column = min(9, self.player_column + 1)\n self.facing = 1\n elif action == 2 and self.heat < 9:\n self.friendly_shots.append([8, self.player_column, -1, 0])\n fired = True\n elif action == 5 and self.heat < 9:\n self.friendly_shots.append([9, self.player_column, 0, self.facing])\n fired = True\n self.heat = min(10, self.heat + 2) if fired else max(0, self.heat - 1)\n if self.heat >= 10:\n self._lose_life()\n\n self._move_mothership()\n self._spawn_alien()\n self.previous_aliens = [[int(alien[\"row\"]), int(alien[\"column\"])] for alien in self.aliens]\n self.previous_hostiles = [shot[:2] for shot in self.hostile_shots + self.fireballs]\n self._move_aliens()\n self._move_projectiles()\n reward = self._resolve_friendly_hits()\n self._resolve_hostile_hits()\n self._launch_hostile_weapon()\n self.steps += 1\n if self.spawned == 10 and not self.aliens:\n self.wave += 1\n if self.wave == 5:\n self.terminal = True\n else:\n self.spawned = 0\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_mothership(self) -> None:\n self.mothership_column += self.mothership_direction\n if self.mothership_column in (0, 9):\n self.mothership_direction *= -1\n\n def _spawn_alien(self) -> None:\n if self.spawned >= 10 or self.steps % 4 != 0:\n return\n self.aliens.append({\n \"row\": 1,\n \"column\": self.mothership_column,\n \"direction\": self.mothership_direction,\n \"split\": self.spawned % 2 == 1,\n })\n self.spawned += 1\n\n def _move_aliens(self) -> None:\n for alien in self.aliens:\n direction = int(alien[\"direction\"])\n column = int(alien[\"column\"]) + direction\n if column < 0 or column > 9:\n direction *= -1\n column = min(9, max(0, column))\n alien[\"column\"] = column\n alien[\"direction\"] = direction\n if self.wave % 3 == 1 and self.steps % 3 == 0:\n alien[\"row\"] = min(7, int(alien[\"row\"]) + 1)\n elif self.wave % 3 == 2 and self.random.rand() < 0.2:\n alien[\"row\"] = int(self.random.randint(1, 7))\n alien[\"column\"] = int(self.random.randint(10))\n\n def _move_projectiles(self) -> None:\n for shot in self.friendly_shots:\n shot[0] += shot[2]\n shot[1] += shot[3]\n self.friendly_shots = [shot for shot in self.friendly_shots if 0 <= shot[0] < 10 and 0 <= shot[1] < 10]\n for shot in self.hostile_shots:\n shot[0] += 1\n reached_base = [shot for shot in self.hostile_shots if shot[0] >= 9]\n self.hostile_shots = [shot for shot in self.hostile_shots if shot[0] < 9]\n for shot in reached_base:\n direction = int(np.sign(self.player_column - shot[1])) or 1\n self.fireballs.append([9, shot[1], 0, direction])\n for fireball in self.fireballs:\n fireball[1] += fireball[3]\n self.fireballs = [shot for shot in self.fireballs if 0 <= shot[1] < 10]\n\n def _resolve_friendly_hits(self) -> float:\n reward = 0.0\n remaining_shots = []\n for shot in self.friendly_shots:\n hit_fireball = next((fireball for fireball in self.fireballs if fireball[:2] == shot[:2]), None)\n if hit_fireball is not None:\n self.fireballs.remove(hit_fireball)\n continue\n hit = next((alien for alien in self.aliens if [alien[\"row\"], alien[\"column\"]] == shot[:2]), None)\n if hit is None:\n remaining_shots.append(shot)\n continue\n self.aliens.remove(hit)\n if bool(hit[\"split\"]):\n column = int(hit[\"column\"])\n row = int(hit[\"row\"])\n for direction in (-1, 1):\n self.aliens.append({\"row\": row, \"column\": column, \"direction\": direction, \"split\": False})\n else:\n reward += 1.0\n self.friendly_shots = remaining_shots\n return reward\n\n def _resolve_hostile_hits(self) -> None:\n if any(shot[:2] == [9, self.player_column] for shot in self.fireballs):\n self.fireballs = [shot for shot in self.fireballs if shot[:2] != [9, self.player_column]]\n self._lose_life()\n\n def _launch_hostile_weapon(self) -> None:\n if self.steps % 12 != 0 or not self.aliens:\n return\n lowest = max(self.aliens, key=lambda alien: int(alien[\"row\"]))\n self.hostile_shots.append([int(lowest[\"row\"]) + 1, int(lowest[\"column\"])])\n\n def _lose_life(self) -> None:\n self.lives -= 1\n self.heat = 0\n self.friendly_shots.clear()\n self.hostile_shots.clear()\n self.fireballs.clear()\n if self.lives <= 0:\n self.terminal = True\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[9, self.player_column, 0] = True\n state[0, self.mothership_column, 1] = True\n for shot in self.hostile_shots + self.fireballs:\n state[shot[0], shot[1], 1] = True\n for alien in self.aliens:\n state[int(alien[\"row\"]), int(alien[\"column\"]), 2] = True\n for shot in self.friendly_shots:\n state[shot[0], shot[1], 3] = True\n for row, column in self.previous_aliens + self.previous_hostiles:\n state[row, column, 4] = True\n state[9, : self.heat, 5] = True\n state[8, : self.lives, 5] = True\n state[7, : self.wave + 1, 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 36, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/assault.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "kelp_climber", "split": "train", "game": "kelp_climber", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Kelp Climber as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to grab the nearest eligible kelp strand.\nActions 0–4 release the button. Switching strands scores\nthe horizontal distance rounded up and discards the old\nstrand. Kelp and obstacles scroll downward. Contact with\nan obstacle ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the otter, other kelp, eligible\nkelp, obstacles, the current jump target, and gauges. The\nconversion uses fixed difficulty and advances four frames per\naction. The task runs for at most 400 actions, clips the raw\nscore to [0, 500], and divides by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/kelp_climber.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Kelp:\n x: float\n y: float\n\n\n@dataclass\nclass Obstacle:\n x: float\n y: float\n width: float\n height: float\n\n\nclass KelpClimberEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x = 50.0\n self.kelp = [Kelp(25, 40), Kelp(50, 50), Kelp(75, 45)]\n self.grabbed = self.kelp[1]\n self.obstacles: list[Obstacle] = []\n self.kelp_distance = self.obstacle_distance = 0.0\n self.steps = 0\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _nearest(self) -> Kelp | None:\n return min((strand for strand in self.kelp if strand is not self.grabbed and strand.y > 40),\n key=lambda strand: abs(strand.x - self.x), default=None)\n\n def _advance(self, tap: bool) -> int:\n reward = 0\n if tap:\n target = self._nearest()\n if target is not None:\n reward = math.ceil(abs(target.x - self.x))\n self.grabbed.y = 199\n self.grabbed = target\n self.x = target.x\n for strand in self.kelp:\n strand.y += 0.5\n self.kelp = [strand for strand in self.kelp if strand.y <= 150]\n self.kelp_distance -= 0.5\n if self.kelp_distance < 0:\n self.kelp.append(Kelp(self.random.uniform(10, 90), -50))\n self.kelp_distance += self.random.uniform(30, 50)\n for obstacle in self.obstacles:\n obstacle.y += 0.5\n self.obstacles = [obstacle for obstacle in self.obstacles if obstacle.y <= 110]\n self.obstacle_distance -= 0.5\n if self.obstacle_distance < 0:\n x = self.random.uniform(10, 90)\n width, height = self.random.uniform(5, 15, 2)\n self.obstacles.append(Obstacle(x, -10, width, height))\n self.obstacle_distance += self.random.uniform(40, 50)\n self.terminal = any(abs(o.x - self.x) < (o.width + 5) / 2\n and abs(o.y - 90) < (o.height + 5) / 2 for o in self.obstacles)\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[9, int(self.x) // 10, 0] = True\n for strand in self.kelp:\n top = max(0, int((strand.y - 50) // 10))\n bottom = min(9, int((strand.y + 50) // 10))\n state[top:bottom + 1, int(strand.x) // 10, 1 + (strand.y > 40 and strand is not self.grabbed)] = True\n for o in self.obstacles:\n top = max(0, int((o.y - o.height / 2) // 10))\n bottom = min(9, int((o.y + o.height / 2) // 10))\n left = max(0, int((o.x - o.width / 2) // 10))\n right = min(9, int((o.x + o.width / 2) // 10))\n if top <= bottom:\n state[top:bottom + 1, left:right + 1, 3] = True\n target = self._nearest()\n if target is not None:\n state[9, int(target.x) // 10, 4] = True\n for row, value in enumerate((self.steps, round(self.x * 4))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 37, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/kelp_climber.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameKelpClimber.c"} +{"name": "pileup", "split": "train", "game": "pileup", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Pileup as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nUse action 1 to move left and action 3 to move right.\nOther actions hold position. These controls replace pointer\nsliding. Blocks spawn beneath you and settle on the ground\nor on earlier blocks. The highest fixed block determines\nyour height. Falling red boards erase blocks and end the\nrun if they touch you. Each board that passes the bottom\nscores 99 minus your previous vertical position.\n\nINPUT CHANNEL TABLE\nSix 10×10 channels show the player, fixed blocks, falling\nblocks, red board, ground, and gauges. Each action advances\nfour frames at fixed difficulty. The 400-action task clips\nscores to [0, 2500] and divides by 2500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/pileup.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Block:\n x: float\n y: float\n fixed: bool = False\n\n\nclass PileupEnvironment:\n score_cap = 2500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 50.0, 80.0\n self.board: Block | None = None\n self.board_speed = 0.0\n self.blocks: list[Block] = []\n self.timer = self.steps = self.action = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0.0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _board_hits(self, x, y):\n return self.board is not None and abs(self.board.x - x) < 13.5 and abs(self.board.y - y) < 6\n\n def _advance(self):\n reward = 0.0\n if self.board is None:\n self.board = Block(self.random.uniform(0, 99), 0)\n self.board_speed = 0.0\n else:\n self.board_speed += 0.1\n self.board.y += self.board_speed\n if self.board.y > 99:\n self.board = None\n reward = 99 - self.y\n y = 80\n remaining = []\n for block in self.blocks:\n if block.fixed:\n y = min(y, block.y - 9)\n else:\n block.y += 1\n block.fixed = block.y + 3.5 > 95 or any(\n other.fixed and abs(block.x - other.x) < 7 and abs(block.y - other.y) < 7\n for other in remaining\n )\n if not self._board_hits(block.x, block.y):\n remaining.append(block)\n self.blocks = remaining\n movement = (self.action == 3) - (self.action == 1)\n self.x = min(99, max(0, self.x + 2 * movement))\n self.y = y\n self.terminal = y < 0 or self._board_hits(self.x, y)\n self.timer -= 1\n if self.timer < 0:\n self.blocks.append(Block(self.x, y))\n self.timer += 10\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, max(0, int(self.y // 10))), int(self.x // 10), 0] = True\n for block in self.blocks:\n if 0 <= block.y < 100:\n state[int(block.y // 10), int(block.x // 10), 1 if block.fixed else 2] = True\n if self.board is not None:\n left = max(0, int((self.board.x - 10) // 10))\n right = min(9, int((self.board.x + 10) // 10))\n state[int(self.board.y // 10), left:right + 1, 3] = True\n state[9, :, 4] = True\n for row, value in enumerate((self.steps, self.timer, round(self.board_speed * 100), round(self.x * 4))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 38, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pileup.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/pileup/main.js"} +{"name": "zoom_io", "split": "train", "game": "zoom_io", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Zoom Io as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to zoom in, build the multiplier, and accelerate\nforward. Release with any other action to turn automatically and\nzoom out. Collect bonus arrows for the rounded-up multiplier.\nHitting an enemy arrow ends the episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the player and heading, visible bonuses,\nvisible enemies, bonus bearings, enemy bearings, and counters.\nThe original draws offscreen bearings in one color. This port\nseparates them by arrow type, uses fixed difficulty, and uses a\ndistance threshold for arrow collisions. Each action advances up\nto four frames over 400 actions. Clip the episode score to\n[0, 1000] and divide by 1000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/zoom_io.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import atan2, ceil, cos, hypot, pi, sin, sqrt\n\nimport numpy as np\n\n\n@dataclass\nclass Arrow:\n x: float\n y: float\n vx: float\n vy: float\n enemy: bool\n\n\nclass ZoomIoEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.angle, self.speed, self.zoom = -pi / 2, 0., 1.\n self.multiplier = 1.\n self.arrows = []\n self.timer = self.count = 0\n self.spawn_angles = self.random.uniform(0, 2 * pi, 2)\n self.action = self.steps = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n self.timer -= 1\n if self.timer < 0:\n self._spawn()\n if self.action == 5:\n self.zoom = min(9, self.zoom + 0.05)\n self.multiplier += self.zoom * 0.1\n else:\n self.zoom += (1 - self.zoom) * 0.03\n self.angle = (self.angle + 0.1 / self.zoom) % (2 * pi)\n if self.zoom < 2:\n self.multiplier += (0.5 - self.multiplier) * 0.02\n self.speed += ((self.zoom - 1) * 0.1 - self.speed) * 0.05\n dx, dy = self.speed * cos(self.angle), self.speed * sin(self.angle)\n reward = 0\n remaining = []\n for arrow in self.arrows:\n arrow.x += arrow.vx - dx\n arrow.y += arrow.vy - dy\n if hypot(arrow.x, arrow.y) < 4.5:\n if arrow.enemy:\n self.terminal = True\n else:\n reward += ceil(self.multiplier)\n continue\n if hypot(arrow.x, arrow.y) <= 70:\n remaining.append(arrow)\n self.arrows = remaining\n return reward\n\n def _spawn(self):\n side = self.count % 2\n if self.random.random() < 0.1:\n angle = self.random.uniform(0, 2 * pi)\n self.spawn_angles[side] = self.angle if side and self.zoom > 5 else angle\n angle = self.spawn_angles[side]\n x, y = 70 * cos(angle), 70 * sin(angle)\n angle = self.random.uniform(0, 2 * pi)\n radius = self.random.uniform(20, 40)\n heading = atan2(radius * sin(angle) - y, radius * cos(angle) - x)\n speed = self.random.uniform(0.1, 0.11)\n self.arrows.append(Arrow(x, y, speed * cos(heading), speed * sin(heading), bool(side)))\n self.timer = 20\n self.count += 1\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[5, 5, 0] = True\n _mark(state, cos(self.angle) * 2 * self.zoom, sin(self.angle) * 2 * self.zoom, 0)\n for arrow in self.arrows:\n distance = hypot(arrow.x, arrow.y)\n x, y = arrow.x * self.zoom, arrow.y * self.zoom\n if sqrt(self.zoom) > 0.5 + distance * 0.03 and -50 <= x < 49 and -50 <= y < 49:\n _mark(state, x, y, 2 if arrow.enemy else 1)\n elif distance:\n for radius in (10, 20, 30):\n _mark(state, radius * arrow.x / distance, radius * arrow.y / distance,\n 4 if arrow.enemy else 3)\n values = (self.steps, self.action, round(self.zoom * 100), round(self.speed * 100),\n ceil(self.multiplier), round((self.angle % (2 * pi)) * 128), self.timer)\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n for row, value in enumerate(values):\n state[8, row, 5] = bool(value & (1 << 10))\n return state\n\n\ndef _mark(state, x, y, channel):\n state[int(np.clip((y + 50) // 10, 0, 9)), int(np.clip((x + 50) // 10, 0, 9)), channel] = True\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 39, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/zoom_io.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/zoomio/main.js"} +{"name": "balloon", "split": "train", "game": "balloon", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Balloon as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nActions 1–4 move the wind cursor left, up, right, and down.\nActions 0 and 5 stay put. Cursor motion builds directional wind\nthat pushes nearby rising balloons. Falling bonuses attach to a\nballoon within reach. A balloon pops near the ceiling or when it\nshrinks enough. Its attached bonuses score on that step, with\nsimultaneous deliveries paying 1, 2, and so on. An uncaught bonus\nreaching the bottom ends the run.\n\nINPUT CHANNEL TABLE\nChannels show the cursor, balloon footprints, free bonuses, carried\nbonuses, next-position cues, and wind and clock gauges. The adaptation\nuses incremental cursor steering and subcell balloon drift, and places\nattached bonuses at the carrier center in place of a spring tether.\n\nSCORING, TERMINATION, AND HORIZON\nAt most 50 bonuses spawn during the 400-step horizon. Each scores\nonce, and putting all deliveries on one step bounds the episode\nscore at 1,275. Normalize by clipping to [0, 1275] and dividing by 1275.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/balloon.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import hypot\n\nimport numpy as np\n\n\nHORIZON = 400\nBONUS_INTERVAL = 8\nBALLOON_INTERVAL = 28\nMAX_BONUSES = (HORIZON + BONUS_INTERVAL - 1) // BONUS_INTERVAL\nMOVES = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}\n\n\n@dataclass\nclass Balloon:\n row: float\n column: float\n drift: float\n rise: float = -0.24\n radius: float = 1.8\n\n\n@dataclass\nclass Bonus:\n row: float\n column: float\n balloon: Balloon | None = None\n\n\nclass BalloonEnvironment:\n score_cap = MAX_BONUSES * (MAX_BONUSES + 1) // 2\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.last_action = 0\n self.cursor = (5, 5)\n self.wind = (0.0, 0.0)\n self.balloons: list[Balloon] = []\n self.bonuses: list[Bonus] = []\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.steps += 1\n row, column = self.cursor\n dr, dc = MOVES.get(action, (0, 0))\n self.cursor = max(0, min(9, row + dr)), max(0, min(9, column + dc))\n self.wind = (0.5 * self.wind[0] + 0.25 * (self.cursor[0] - row),\n 0.5 * self.wind[1] + 0.25 * (self.cursor[1] - column))\n if self.steps % BALLOON_INTERVAL == 1:\n self.balloons.append(Balloon(9.5, float(self.random.uniform(2, 7)),\n float(self.random.uniform(-0.12, 0.12))))\n if self.steps % BONUS_INTERVAL == 1:\n self.bonuses.append(Bonus(0.0, float(self.random.uniform(1, 8))))\n for balloon in self.balloons:\n if hypot(balloon.row - self.cursor[0], balloon.column - self.cursor[1]) < balloon.radius:\n balloon.rise += self.wind[0]\n balloon.drift += self.wind[1]\n balloon.row += balloon.rise\n balloon.column += balloon.drift\n if not balloon.radius <= balloon.column <= 9 - balloon.radius:\n balloon.column = max(balloon.radius, min(9 - balloon.radius, balloon.column))\n balloon.drift *= -0.7\n if balloon.row > 10 - balloon.radius and balloon.rise > 0:\n balloon.rise *= -0.7\n balloon.drift *= 0.9\n balloon.rise += 0.15 * (-0.24 - balloon.rise)\n balloon.radius -= 0.015 * hypot(balloon.drift, balloon.rise)\n self.balloons = [balloon for balloon in self.balloons\n if balloon.row >= balloon.radius and balloon.radius >= 0.8]\n alive = {id(balloon) for balloon in self.balloons}\n collected = 0\n remaining = []\n for bonus in self.bonuses:\n if bonus.balloon is None:\n bonus.row += 0.22\n for balloon in self.balloons:\n if hypot(balloon.row - bonus.row, balloon.column - bonus.column) < 1.3 * balloon.radius:\n bonus.balloon = balloon\n break\n if bonus.balloon is None and bonus.row >= 10:\n self.terminal = True\n if bonus.balloon is not None:\n if id(bonus.balloon) not in alive:\n collected += 1\n continue\n bonus.row, bonus.column = bonus.balloon.row, bonus.balloon.column\n remaining.append(bonus)\n self.bonuses = remaining\n self.terminal |= self.steps >= self.horizon\n return float(collected * (collected + 1) // 2), self.terminal\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.cursor, 0] = True\n rows, columns = np.ogrid[:10, :10]\n for balloon in self.balloons:\n state[:, :, 1] |= (rows - balloon.row) ** 2 + (columns - balloon.column) ** 2 <= balloon.radius ** 2\n state[max(0, min(9, round(balloon.row + balloon.rise))),\n max(0, min(9, round(balloon.column + balloon.drift))), 4] = True\n for bonus in self.bonuses:\n state[max(0, min(9, round(bonus.row))), round(bonus.column), 3 if bonus.balloon else 2] = True\n values = (self.steps, round(self.wind[0] * 64) + 32,\n round(self.wind[1] * 64) + 32, self.last_action)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 40, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/balloon.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBalloon.c"} +{"name": "zartan", "split": "train", "game": "zartan", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Zartan as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nPress action 5 to grab the highlighted anchor. Hold to pull toward\nit and release with any other action to let go. The game highlights\nthe forward anchor closest in height and keeps the last highlight\nwhen no new anchor qualifies. The run scores the scroll distance\neach frame and ends when the player falls below the screen.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the player, piles, highlighted anchor,\nattached anchor, rope, and counters. Offscreen positions project\nto the nearest edge. The port fixes difficulty and keeps the\noriginal spring-like pull. Each action advances up to four frames\nover 400 actions. Clip episode scores to [0, 500] and divide by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/zartan.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Pile:\n x: float\n y: float\n\n\nclass ZartanEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 99., 9.\n self.vx = self.vy = 0.\n self.piles = []\n self.anchor = self.nearest = None\n self.distance = 9.\n self.steps = self.action = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n pressed = self.action == 5 and previous != 5\n self.steps += 1\n reward = 0.\n for frame in range(4):\n reward += self._advance(pressed and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _advance(self, pressed):\n scroll = 0.1 + max(0, self.x - 30) * 0.1\n self.x -= scroll\n self.vy += 0.02\n if self.y < 0 and self.vy < 0:\n self.vy *= -1\n if self.y > 99:\n self.terminal = True\n return scroll\n self.vx *= 0.99\n self.vy *= 0.99\n self.x += self.vx\n self.y += self.vy\n\n self.nearest = min(\n (pile for pile in self.piles if pile.x > self.x and abs(pile.y - self.y) < 99),\n key=lambda pile: abs(pile.y - self.y),\n default=self.nearest,\n )\n if pressed:\n self.anchor = self.nearest\n if self.action != 5:\n self.anchor = None\n elif self.anchor is not None:\n self.vx += (self.anchor.x - self.x) / 199\n self.vy += (self.anchor.y - self.y) / 199\n if self.anchor.x < 0:\n self.anchor = None\n\n self.distance -= scroll\n if self.distance < 0:\n self.distance += self.random.uniform(9, 66)\n self.piles.append(Pile(99, self.random.uniform(0, 66)))\n for pile in self.piles:\n pile.x -= scroll\n self.piles = [pile for pile in self.piles if pile.x > 0]\n return scroll\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n _mark(state, self.x, self.y, 0)\n for pile in self.piles:\n _mark(state, pile.x, pile.y, 1)\n if self.nearest is not None:\n _mark(state, self.nearest.x, self.nearest.y, 2)\n if self.anchor is not None:\n _mark(state, self.anchor.x, self.anchor.y, 3)\n for x, y in zip(np.linspace(self.x, self.anchor.x, 41),\n np.linspace(self.y, self.anchor.y, 41), strict=True):\n _mark(state, x, y, 4)\n values = (self.steps, self.action, round((self.vx + 8) * 16),\n round((self.vy + 8) * 16), round(self.distance * 4))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n\ndef _mark(state, x, y, channel):\n state[int(np.clip(y // 10, 0, 9)), int(np.clip(x // 10, 0, 9)), channel] = True\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 41, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/zartan.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/zartan/main.js"} +{"name": "foot_laser", "split": "train", "game": "foot_laser", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Foot Laser as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to jump, tap again to double jump, and tap a third\ntime to dive. Release with actions 0–4 between taps. Holding slows\nthe fall. The downward laser destroys enemies beneath you while\nairborne. Each kill raises the multiplier, and landing resets it.\n\nINPUT CHANNEL TABLE\nGround enemies, stacked formations, and flying enemies approach\nfrom the right. Body contact ends the run, following the native C\nport. The six 10×10 channels show the player, ground enemies,\nflying enemies, laser, floor, and gauges. The conversion uses\ngeometric hit checks and four frames per action at fixed difficulty.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action task clips raw scores to [0, 250] and divides by\n250. Across 100 seeds without sticky actions, idle scored zero\nand random inputs averaged 2.89. A policy that jumped whenever\ngrounded and held through the jump averaged 11.72 and reached 88.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/foot_laser.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\nGROUND = 90\nPLAYER_X = 20\n\n\n@dataclass\nclass Enemy:\n x: float\n y: float\n vx: float\n flying: bool = False\n\n\nclass FootLaserEnvironment:\n score_cap = 250\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.enemy_timer = 0\n self.wall_timer = self.random.uniform(300, 400)\n self.flying_timer = self.random.uniform(200, 300)\n self.y, self.vy = 50.0, 0.0\n self.jumps, self.multiplier = 9, 1\n self.pressed = self.grounded = self.terminal = False\n self.enemies: list[Enemy] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap: bool) -> int:\n if not self.grounded:\n self.vy += 0.1 if self.pressed else 0.3\n self.y += self.vy\n if self.y > GROUND:\n self.y, self.vy = GROUND, 0\n self.grounded = True\n self.jumps, self.multiplier = 0, 1\n if tap:\n if self.jumps < 2:\n self.vy, self.grounded = -3, False\n elif self.jumps == 2:\n self.vy += 9\n self.jumps = min(9, self.jumps + 1)\n\n self._spawn()\n reward = 0\n survivors = []\n for enemy in self.enemies:\n enemy.x += enemy.vx\n distance = abs(enemy.x - PLAYER_X)\n if not self.grounded and distance < 4 and enemy.y > self.y + 2:\n reward += self.multiplier\n self.multiplier += 1\n else:\n self.terminal |= distance < 5 and abs(enemy.y - self.y) < 5\n if enemy.x >= -6:\n survivors.append(enemy)\n self.enemies = survivors\n return reward\n\n def _spawn(self) -> None:\n self.enemy_timer -= 1\n self.wall_timer -= 1\n self.flying_timer -= 1\n if self.enemy_timer < 0:\n self.enemies.append(Enemy(200, GROUND, -self.random.uniform(1, 2)))\n self.enemy_timer = self.random.uniform(30, 60)\n if self.wall_timer < 0:\n vx = -self.random.uniform(1, 2)\n for index in range(int(self.random.integers(3, 6))):\n self.enemies.append(Enemy(200, GROUND - 6 * index, vx))\n self.wall_timer = self.random.uniform(100, 600)\n self.enemy_timer += 9\n if self.flying_timer < 0:\n vx, y = -self.random.uniform(1, 2), self.random.uniform(50, 80)\n for index in range(int(self.random.integers(1, 5))):\n self.enemies.append(Enemy(206 + 7 * index, y, vx, flying=True))\n self.flying_timer = self.random.uniform(100, 400)\n self.enemy_timer += 9\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row = max(0, int(self.y) // 10)\n state[row, 1, 0] = True\n if not self.grounded:\n state[row:, 1, 3] = True\n state[9, :, 4] = True\n for enemy in self.enemies:\n if 0 <= enemy.x < 200:\n state[int(enemy.y) // 10, int(enemy.x) // 20, 2 if enemy.flying else 1] = True\n for row, value in enumerate((self.steps, self.jumps, self.multiplier, round(self.vy * 10) + 128)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.grounded\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 42, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/foot_laser.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameFootLaser.c"} +{"name": "snaky", "split": "train", "game": "snaky", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Snaky as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to bend the snake up. Actions 0–4 bend it down.\nCatch red items with the tip to grow and score the squared length.\nRed items hitting the body shrink the snake and subtract its length.\nOrdinary items score the length at the tip or one point on the body.\nAn item reaching the left edge ends the episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the body, tip, ordinary items, red items,\nnext spawn height, and counters. The port uses fixed difficulty,\ndistance-based contacts, and a minimum of one segment. Each action\nadvances up to four frames over 400 actions. Clip the accumulated\nscore to [0, 400] and divide by 400.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/snaky.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, pi, sin, sqrt\n\nimport numpy as np\n\n\n@dataclass\nclass Item:\n x: float\n y: float\n red: bool\n vx: float = -0.1\n\n\nclass SnakyEnvironment:\n score_cap = 400\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.angles = [0., 0.]\n self.velocities = [0., 0.]\n self.items = []\n self.timer = self.steps = 0\n self.red_count = 2\n self.next_y = 50.\n self.held = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n if self.random.random() >= self.sticky_action_prob:\n self.held = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _segments(self):\n length = 50 / len(self.angles) + 3\n x, y = 0., 50.\n for angle in self.angles:\n end_x, end_y = x + length * cos(angle), y + length * sin(angle)\n yield x, y, end_x, end_y\n x, y = end_x, end_y\n\n def _advance(self):\n limit = pi / (sqrt(len(self.angles) - 1) + 3)\n for index, angle in enumerate(self.angles):\n velocity = self.velocities[index]\n if index == 0:\n updated = min(limit, max(-limit, angle + (-0.03 if self.held else 0.03)))\n velocity = updated - angle\n else:\n updated = angle + velocity\n difference = updated - self.angles[index - 1]\n if abs(difference) > limit and difference * velocity > 0:\n velocity *= -0.2\n self.angles[index] = updated\n self.velocities[index] = velocity * 0.95\n if index + 1 < len(self.angles):\n self.velocities[index + 1] += velocity * 0.95 * 0.07\n if index:\n self.velocities[index - 1] += velocity * 0.95 * 0.01\n segments = list(self._segments())\n self.timer -= 1\n if self.timer < 0:\n self.red_count -= 1\n red = self.red_count < 0\n if red:\n self.red_count = 7\n self.items.append(Item(103, self.next_y, red))\n y = self.random.uniform(20, 80)\n self.timer = 4 * abs(self.next_y - y + 10)\n self.next_y = y\n reward = 0\n remaining = []\n for item in self.items:\n item.vx *= 1.005\n item.x += item.vx\n size = len(self.angles)\n if self._touches(item, segments[-1]):\n reward += size ** 2 if item.red else size\n if item.red and size < 10:\n self.angles.append(0.)\n self.velocities.append(0.)\n elif any(self._touches(item, segment) for segment in segments[:-1]):\n reward += -size if item.red else 1\n if item.red and size > 1:\n self.angles.pop()\n self.velocities.pop()\n else:\n self.terminal |= item.x < 0\n remaining.append(item)\n self.items = remaining\n return reward\n\n @staticmethod\n def _touches(item, segment):\n x, y, end_x, end_y = segment\n dx, dy = end_x - x, end_y - y\n t = ((item.x - x) * dx + (item.y - y) * dy) / (dx * dx + dy * dy)\n t = min(1, max(0, t))\n return (item.x - x - t * dx) ** 2 + (item.y - y - t * dy) ** 2 < 4.5 ** 2\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n segments = list(self._segments())\n for index, (x, y, end_x, end_y) in enumerate(segments):\n points = np.linspace((x, y), (end_x, end_y), 32)\n visible = points[np.all((points >= 0) & (points < 100), axis=1)]\n cols, rows = (visible // 10).astype(int).T\n state[rows, cols, int(index == len(segments) - 1)] = True\n for item in self.items:\n if 0 <= item.x < 100:\n state[int(item.y // 10), int(item.x // 10), 2 + int(item.red)] = True\n state[int(self.next_y // 10), 9, 4] = True\n for row, value in enumerate((self.steps, len(self.angles), self.held,\n min(511, round(max(0, self.timer))), self.red_count)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 43, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/snaky.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/snaky/main.js"} +{"name": "froooog", "split": "train", "game": "froooog", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Froooog as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe frog stays in the center column while traffic crosses horizontally.\nHold action 5 to charge a longer jump and release with actions 0–4. At\nmaximum charge the frog jumps automatically. It can pass over traffic\nwhile airborne, but cars kill on landing or while grounded. Road-to-road\njumps score the square of the lanes crossed. Jumps from or to grass\nscore zero. Falling behind the scrolling view also ends the run.\n\nINPUT CHANNEL TABLE\nThe six binary channels show the frog, current traffic, safe rows,\nprojected landing, next-step traffic, and gauges. The gauges record the\nclock, charge, airborne status, and distance traveled in the current jump.\nThis tile adaptation uses periodic cars, up to eight lanes per jump,\ntwo lanes of airborne movement per step, and discrete camera scrolling.\nIt replaces continuous timing and sprite collision with tile occupancy.\n\nSCORING, TERMINATION, AND HORIZON\nThe horizon is 400 steps. Each lane of jump distance costs at least one\ncharge step. For a jump of distance d ≤ 8, the reward d² is at most 8d.\nThis gives a conservative cap of 3,200. Every reward advances the frog\npermanently. Normalize by clipping raw score to [0, 3200] and dividing by 3200.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/froooog.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\nHORIZON = 400\nMAX_JUMP = 8\nCENTER = 5\n\n\n@dataclass(frozen=True)\nclass Lane:\n direction: int\n period: int\n phase: int\n width: int\n\n def traffic(self, tick: int) -> np.ndarray:\n if self.direction == 0:\n return np.zeros(10, dtype=bool)\n return (np.arange(10) - self.phase - self.direction * tick) % self.period < self.width\n\n\nclass FroooogEnvironment:\n score_cap = HORIZON * MAX_JUMP\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.position = self.bottom = self.charge = self.last_action = 0\n self.destination: int | None = None\n self.launch_position = 0\n self.terminal = False\n self.lanes = [Lane(0, 1, 0, 0) for _ in range(3)]\n self.next_safe = int(self.random.integers(9, 16))\n self._extend()\n\n def _extend(self) -> None:\n while len(self.lanes) < self.bottom + 10:\n if len(self.lanes) == self.next_safe:\n self.lanes.append(Lane(0, 1, 0, 0))\n self.next_safe += int(self.random.integers(9, 16))\n else:\n period = int(self.random.integers(5, 11))\n self.lanes.append(Lane(int(self.random.choice((-1, 1))), period,\n int(self.random.integers(period)), int(self.random.integers(1, 3))))\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.steps += 1\n reward = 0\n if self.destination is None:\n if self.lanes[self.position].traffic(self.steps)[CENTER]:\n self.terminal = True\n return 0.0, True\n if action == 5:\n self.charge += 1\n if self.charge and (action != 5 or self.charge == MAX_JUMP):\n self.launch_position = self.position\n self.destination = self.position + min(self.charge, self.bottom + 9 - self.position)\n self.charge = 0\n if self.destination is not None:\n self.position = min(self.position + 2, self.destination)\n if self.position == self.destination:\n landing = self.lanes[self.position]\n self.terminal = bool(landing.traffic(self.steps)[CENTER])\n if not self.terminal and landing.direction and self.lanes[self.launch_position].direction:\n reward = (self.position - self.launch_position) ** 2\n self.destination = None\n self.bottom = max(self.bottom, self.position - 1)\n if self.steps % 8 == 0:\n self.bottom += 1\n self._extend()\n self.terminal |= self.position < self.bottom or self.steps >= self.horizon\n return float(reward), self.terminal\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n if self.position >= self.bottom:\n state[9 - (self.position - self.bottom), CENTER, 0] = True\n for row, lane in enumerate(reversed(self.lanes[self.bottom:self.bottom + 10])):\n state[row, :, 1] = lane.traffic(self.steps)\n state[row, :, 2] = lane.direction == 0\n state[row, :, 4] = lane.traffic(self.steps + 1)\n if self.destination is not None and self.destination >= self.bottom:\n state[9 - (self.destination - self.bottom), CENTER, 3] = True\n elif self.charge:\n preview = min(9, self.position - self.bottom + self.charge)\n state[9 - preview, CENTER, 3] = True\n values = (self.steps, self.charge, int(self.destination is not None),\n self.position - self.launch_position if self.destination is not None else 0)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 44, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/froooog.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameFroooog.c"} +{"name": "trojan_defense", "split": "train", "game": "trojan_defense", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Trojan Defense as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nProtect the horse with a rotating shield. Tap action 5 to reverse\nrotation and reset the score multiplier. Hold it to widen and extend\nthe shield while slowing rotation. Release with any other action to\nshrink the shield and speed it up. Deflect shots back at the enemies.\nEach defeated enemy scores ten times its one-based type times the\ncurrent multiplier, then increases the multiplier. An incoming shot\nthat reaches the horse ends the episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the horse, shield, enemies, incoming shots,\nreflected shots, and counters. The port fixes difficulty and uses\nradial motion and geometric collision checks for the shield, horse,\nand enemies. Each action advances up to four frames over 400 actions.\nClip the episode score to [0, 500] and divide by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/trojan_defense.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, hypot, pi, remainder, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Enemy:\n angle: float\n kind: int\n rate: float\n timer: float\n speed: float\n\n\n@dataclass\nclass Shot:\n angle: float\n radius: float\n speed: float\n\n\nclass TrojanDefenseEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.angle, self.length, self.arc = 0., 10., pi / 8\n self.direction = self.multiplier = 1\n self.enemies, self.shots = [], []\n self.wave_timer = 60.\n self.wave = self.action = self.steps = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n if self.action == 5 and previous != 5:\n self.direction *= -1\n self.multiplier = 1\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n if self.action == 5:\n self.arc = min(pi / 3, self.arc + 0.02)\n self.length = min(20, self.length + 0.5)\n speed_factor = 1 - (self.arc - pi / 8) / (pi / 3 - pi / 8) * 0.7\n else:\n self.arc = max(pi / 8, self.arc - 0.015)\n self.length = max(10, self.length - 0.3)\n speed_factor = 1.2\n self.angle = (self.angle + self.direction * 0.06 * speed_factor) % (2 * pi)\n self.wave_timer -= 1\n if self.wave_timer < 0:\n self._spawn_wave()\n\n remaining = []\n reward = 0\n for shot in self.shots:\n shot.radius += shot.speed\n if shot.speed < 0:\n offset = abs(remainder(shot.angle - self.angle, 2 * pi))\n if 4 <= shot.radius <= 6.5 + self.length and offset <= self.arc / 2 + 1.5 / shot.radius:\n shot.speed *= -1.5\n elif shot.radius <= 5:\n self.terminal = True\n return reward\n else:\n hit = next((enemy for enemy in self.enemies if _enemy_distance(shot, enemy) <= 4), None)\n if hit is not None:\n self.enemies.remove(hit)\n reward += self.multiplier * (hit.kind + 1) * 10\n self.multiplier += 1\n continue\n if shot.radius <= 55:\n remaining.append(shot)\n self.shots = remaining\n\n for enemy in self.enemies:\n enemy.timer -= 1\n if enemy.timer <= 0:\n self.shots.append(Shot(enemy.angle, 50, -enemy.speed))\n enemy.timer = enemy.rate * self.random.uniform(0.8, 1.2)\n return reward\n\n def _spawn_wave(self):\n self.wave += 1\n base = self.random.uniform(0, 2 * pi)\n for _ in range(min(5, 1 + self.wave // 3)):\n angle = base + self.random.uniform(-pi / 4, pi / 4)\n kind = 0 if self.random.random() < 0.7 else int(self.random.integers(1, 3))\n low, high, speed = ((120, 180, 0.5), (80, 120, 0.8), (150, 200, 0.4))[kind]\n self.enemies.append(Enemy(angle, kind, self.random.uniform(low, high),\n self.random.uniform(30, 60), speed))\n self.wave_timer = self.random.uniform(180, 300)\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[5, 5, 0] = True\n for angle in np.linspace(self.angle - self.arc / 2, self.angle + self.arc / 2, 9):\n for radius in np.linspace(5, 5 + self.length, 9):\n _mark(state, angle, radius, 1)\n for enemy in self.enemies:\n _mark(state, enemy.angle, 50, 2)\n for shot in self.shots:\n _mark(state, shot.angle, shot.radius, 3 if shot.speed < 0 else 4)\n values = (self.steps, self.action, self.direction > 0, round(self.angle * 64),\n round(self.length * 16), round(self.arc * 128), self.multiplier, self.wave)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n\ndef _enemy_distance(shot, enemy):\n return hypot(shot.radius * cos(shot.angle) - 50 * cos(enemy.angle),\n shot.radius * sin(shot.angle) - 50 * sin(enemy.angle))\n\n\ndef _mark(state, angle, radius, channel):\n x, y = 50 + radius * cos(angle), 50 + radius * sin(angle)\n state[int(np.clip(y // 10, 0, 9)), int(np.clip(x // 10, 0, 9)), channel] = True\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 45, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/trojan_defense.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameTrojanDefense.c"} +{"name": "balance", "split": "train", "game": "balance", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Balance as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nActions 1 and 3 move the horizontal steering cursor. Actions 0, 2,\n4, and 5 leave it in place. The pillar base follows the cursor with\ninertia. Steering and wind affect the pillar's tilt. The camera\ntracks the tip as coins fall. Catching a coin on the shaft pays\nthe current length and grows the pillar by one. A tip catch does\nthis three times. Growth is capped at 64. A ground strike halves\nthe length, and dropping below 20 ends the run.\n\nINPUT CHANNEL TABLE\nThe six channels show tip, floor, coins, shaft, cursor, and gauges.\nThe gauges encode clock, length, tilt, angular and horizontal\nvelocity, wind, and last action. The adaptation quantizes the\nobservation to a 10×10 grid, uses incremental cursor controls,\nand keeps subcell motion with simplified gravity and collision.\n\nSCORING, TERMINATION, AND HORIZON\nAt most 67 coins enter during the 400-step horizon. Each coin can\nscore once, with at most three payouts of 64. This gives a conservative\ncap of 12,864. Normalize by clipping to [0, cap] and dividing by it.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/balance.py`):\n```python\nfrom math import ceil, cos, sin\n\nimport numpy as np\n\n\nHORIZON = 400\nSPAWN_INTERVAL = 6\nFLOOR = 9\nMIN_LENGTH = 20\nMAX_LENGTH = 64\n\n\nclass BalanceEnvironment:\n score_cap = ((HORIZON + SPAWN_INTERVAL - 1) // SPAWN_INTERVAL) * 3 * MAX_LENGTH\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.last_action = 0\n self.base = self.cursor = 4.5\n self.velocity = self.angle = self.angular_velocity = self.wind = 0.0\n self.length = MIN_LENGTH\n self.coin_column = float(self.random.choice((2, 7)))\n self.coins: list[tuple[float, float, float]] = []\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n @property\n def tip(self) -> tuple[float, float]:\n return FLOOR - cos(self.angle) * self.length / 8, self.base + sin(self.angle) * self.length / 8\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.steps += 1\n self.cursor = max(0.0, min(9.0, self.cursor + (1 if action == 3 else -1 if action == 1 else 0)))\n self.wind = 0.94 * (self.wind + float(self.random.uniform(-0.025, 0.025)))\n self.velocity = 0.90 * (self.velocity + 0.08 * (self.cursor - self.base) - self.wind)\n self.base += self.velocity\n self.angular_velocity = 0.88 * (self.angular_velocity - 0.16 * self.velocity\n + self.angle * self.length / 800)\n self.angle += self.angular_velocity\n row, column = self.tip\n shift = (4.5 - column) * 0.18\n self.base += shift\n self.cursor = max(0.0, min(9.0, self.cursor + shift))\n if row >= FLOOR - 0.25:\n self.length /= 2\n self.angular_velocity *= -0.5\n if self.length < MIN_LENGTH:\n self.terminal = True\n return 0.0, True\n self.angle /= 2\n if self.steps % SPAWN_INTERVAL == 1:\n self.coins.append((0.0, self.coin_column, float(self.random.uniform(-0.15, 0.15))))\n self.coin_column = (self.coin_column + shift + float(self.random.uniform(-0.6, 0.6))) % 10\n\n row, column = self.tip\n reward = 0\n remaining = []\n for y, x, drift in self.coins:\n y += 0.5\n drift = 0.96 * (drift + self.wind / 2)\n x += drift + shift\n tip_hit = abs(y - row) <= 0.45 and abs(x - column) <= 0.55\n fraction = (FLOOR - y) / max(0.01, FLOOR - row)\n shaft_x = self.base + (column - self.base) * fraction\n if tip_hit or (0 <= fraction <= 1 and abs(x - shaft_x) <= 0.45):\n for _ in range(3 if tip_hit else 1):\n reward += ceil(self.length)\n self.length = min(MAX_LENGTH, self.length + 1)\n elif y < FLOOR:\n remaining.append((y, x, drift))\n self.coins = remaining\n self.terminal = self.steps >= self.horizon\n return float(reward), self.terminal\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row, column = self.tip\n state[min(9, max(0, round(row))), min(9, max(0, round(column))), 0] = True\n state[FLOOR, :, 1] = True\n for y, x, _ in self.coins:\n if 0 <= round(x) < 10:\n state[round(y), round(x), 2] = True\n for fraction in np.linspace(0, 1, 16):\n x = round(self.base + fraction * (column - self.base))\n y = round(FLOOR + fraction * (row - FLOOR))\n if 0 <= x < 10 and 0 <= y < 10:\n state[y, x, 3] = True\n state[FLOOR, round(self.cursor), 4] = True\n values = (self.steps, round(self.length * 4), round(self.angle * 64) + 256,\n round(self.angular_velocity * 128) + 256, round(self.velocity * 32) + 256,\n round(self.wind * 512) + 256, self.last_action)\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 46, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/balance.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBalance.c"} +{"name": "video_pinball", "split": "train", "game": "video_pinball", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Video Pinball as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves a spring plunger, independently controlled and simultaneous flippers,\nthree starting balls, ball drains, nudge and tilt, one forfeitable extra ball, spinners, four\nbumpers with game-long rising values, a resetting four-target drop bank, ATARI and left rollovers,\nthe four-transition special target, rollover multiplier, and end-of-ball bonus tally.\n\nACTION MAPPING\n0: let the ball travel\n1: raise left flipper\n2: raise both flippers\n3: raise right flipper\n4: pull plunger while serving\n5: release plunger or nudge ball upward\n\nINPUT CHANNEL TABLE\n0: ball\n1: bumpers\n2: live targets, rollovers, spinner, and special\n3: flippers\n4: previous ball position/velocity cue\n5: balls, bumper value, rollovers, multiplier, plunger, nudge, special, serve, tilt, extra ball\n\nSCORING, TERMINATION, AND HORIZON\nThe largest single playfield event is a 500-point bumper. Across 2,000 transitions, playfield\nevents therefore contribute at most 1,000,000. Three starting balls plus the manual's one extra\nball can each drain with at most a four-hit left rollover (`4,000`) times the maximum fourfold\nATARI multiplier, adding at most `4 × 16,000 = 64,000`. Thus `score_cap = 1,064,000`, and\nnormalization is `min(max(raw_score, 0), 1_064_000) / 1_064_000`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/video_pinball.py`):\n```python\nimport numpy as np\n\n\nBUMPER_POSITIONS = ((3, 3), (3, 6), (5, 3), (5, 6))\nDROP_TARGETS = ((2, 2), (2, 4), (2, 6), (2, 7))\nSPINNER = (4, 5)\nATARI_ROLLOVER = (1, 8)\nLEFT_ROLLOVER = (1, 1)\nSPECIAL_TARGET = (6, 5)\n\n\nclass VideoPinballEnvironment:\n \"\"\"Finite game-one table with flippers, nudge, tilt, and scoring devices.\"\"\"\n\n score_cap = 1_064_000.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 2_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.balls = 3\n self.extra_ball_available = True\n self.score = 0.0\n self.steps = 0\n self.last_action = 0\n self.bumper_value = 1\n self.terminal = False\n self._serve_ball()\n\n def _serve_ball(self) -> None:\n self.ball = [8, 8]\n self.velocity = [0, 0]\n self.in_plunger = True\n self.plunger = 0\n self.tilted = False\n self.nudges = 0\n self.atari_rollovers = 0\n self.left_rollovers = 0\n self.multiplier = 1\n self.drop_targets: set[int] = set()\n self.special_timer = 0\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n left_flipper = action in (1, 2)\n right_flipper = action in (2, 3)\n if self.in_plunger:\n if action == 4:\n self.plunger = min(3, self.plunger + 1)\n elif action == 5:\n self.in_plunger = False\n self.velocity = [-1, -1 if self.plunger <= 1 else 0]\n reward = 0.0\n else:\n if action == 5:\n self.nudges += 1\n self.velocity[0] = -1\n if self.nudges >= 4:\n self.tilted = True\n else:\n self.nudges = max(0, self.nudges - 1)\n reward = self._advance_ball(left_flipper, right_flipper)\n if self.special_timer > 0:\n self.special_timer -= 1\n self.score += reward\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _advance_ball(self, left_flipper: bool, right_flipper: bool) -> float:\n self.ball[0] += self.velocity[0]\n self.ball[1] += self.velocity[1]\n if self.ball[1] <= 0:\n self.ball[1] = 1\n self.velocity[1] = 1\n elif self.ball[1] >= 9:\n self.ball[1] = 8\n self.velocity[1] = -1\n if self.ball[0] <= 0:\n self.ball[0] = 1\n self.velocity[0] = 1\n if self.ball[0] >= 8:\n if left_flipper and 1 <= self.ball[1] <= 4:\n self.ball[0] = 7\n self.velocity = [-1, 1]\n elif right_flipper and 5 <= self.ball[1] <= 8:\n self.ball[0] = 7\n self.velocity = [-1, -1]\n elif self.ball[0] >= 9:\n return self._drain()\n if self.tilted:\n self.velocity[0] = 1\n return 0.0\n return self._score_device()\n\n def _score_device(self) -> float:\n position = tuple(self.ball)\n reward = 0.0\n if position in BUMPER_POSITIONS:\n reward = 100.0 * self.bumper_value\n self.velocity[0] *= -1\n self.velocity[1] = -self.velocity[1] or 1\n elif position in DROP_TARGETS:\n target = DROP_TARGETS.index(position)\n if target not in self.drop_targets:\n self.drop_targets.add(target)\n reward = 100.0\n if len(self.drop_targets) == 4:\n self.drop_targets.clear()\n self.bumper_value = min(5, self.bumper_value + 1)\n self.special_timer = 4\n elif position == SPINNER:\n reward = 1.0\n elif position == ATARI_ROLLOVER:\n reward = 100.0\n self.atari_rollovers = min(4, self.atari_rollovers + 1)\n self.multiplier = min(4, self.multiplier + 1)\n if self.atari_rollovers == 4 and self.extra_ball_available:\n self.balls += 1\n self.extra_ball_available = False\n elif position == LEFT_ROLLOVER:\n reward = 100.0\n self.left_rollovers = min(4, self.left_rollovers + 1)\n elif position == SPECIAL_TARGET and self.special_timer > 0:\n reward = 100.0\n self.special_timer = 0\n return reward\n\n def _drain(self) -> float:\n reward = float(self.left_rollovers * 1_000 * self.multiplier)\n self.balls -= 1\n if self.tilted:\n self.balls = min(self.balls, 2)\n if self.balls <= 0:\n self.terminal = True\n else:\n self._serve_ball()\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[self.ball[0], self.ball[1], 0] = True\n for row, column in BUMPER_POSITIONS:\n state[row, column, 1] = True\n for index, (row, column) in enumerate(DROP_TARGETS):\n if index not in self.drop_targets:\n state[row, column, 2] = True\n for row, column in (SPINNER, ATARI_ROLLOVER, LEFT_ROLLOVER, SPECIAL_TARGET):\n state[row, column, 2] = True\n state[8, 3, 3] = True\n state[8, 6, 3] = True\n state[max(0, min(9, self.ball[0] - self.velocity[0])), max(0, min(9, self.ball[1] - self.velocity[1])), 4] = True\n values = (\n (self.balls, 3),\n (self.bumper_value, 3),\n (self.atari_rollovers, 3),\n (self.left_rollovers, 3),\n (self.multiplier, 3),\n (self.plunger, 2),\n (self.nudges, 3),\n (self.special_timer, 3),\n )\n offset = 0\n for value, width in values:\n for bit in range(width):\n state[offset // 10, offset % 10, 5] = bool(value & (1 << bit))\n offset += 1\n state[3, 0, 5] = self.in_plunger\n state[3, 1, 5] = self.tilted\n state[3, 2, 5] = self.extra_ball_available\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 47, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/video_pinball.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "in_tow", "split": "train", "game": "in_tow", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays In Tow as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe bird flies along scrolling platforms. Press action 5 to jump from\na platform or spend a chick for an airborne boost. Holding the button\nslows gravity. Actions 0–4 release it. Picking up a chick pays the new\ntrain length. A bullet through the train removes the hit chick and\neverything behind it. A head hit removes the whole train and forces a\nfall, or ends the run immediately if the bird has no chicks.\n\nINPUT CHANNEL TABLE\nChannels show the bird, bullets, recruitable chicks, platforms, trailing\nchicks, and gauges. Gauges record subcell height, vertical velocity, clock,\ntrain length, ground and button state, spawn countdowns, and recent height\nhistory. The adaptation limits the train to four visible chicks, uses a\none-step lag per chick, and uses tile collision with subcell vertical motion.\nThe scroll accelerates halfway through the 400-step horizon. Falling\nbelow the screen also terminates the episode.\n\nSCORING, TERMINATION, AND HORIZON\nEach platform contributes at most one pickup and the player advances at\nmost one column per step. Generated platforms are at least four columns\napart. Allowing two initial platforms gives at most 102 opportunities at\nfour points each, for a conservative cap of 408. A collected chick cannot\npay again. Normalize by clipping the raw score to [0, 408] and dividing by 408.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/in_tow.py`):\n```python\nimport numpy as np\n\n\nHORIZON = 400\nUNIT = 4\nBIRD_COLUMN = 4\nMAX_CHICKS = BIRD_COLUMN\nMIN_PLATFORM_SPACING = 4\n\n\nclass InTowEnvironment:\n score_cap = MAX_CHICKS * (2 + HORIZON // MIN_PLATFORM_SPACING)\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.y = 3 * UNIT\n self.velocity = 0\n self.steps = self.distance = self.last_action = self.chicks = 0\n self.grounded = False\n self.terminal = False\n self.platforms = [(7, 1, 7), (5, 8, 11)]\n self.pickups = {(4, 9)}\n self.bullets: set[tuple[int, int]] = set()\n self.history = [self.y] * MAX_CHICKS\n self.next_platform = 4\n self.next_bullet = 12\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def _scroll(self) -> None:\n self.distance += 1\n self.platforms = [(row, left - 1, right - 1)\n for row, left, right in self.platforms if right > 0]\n self.pickups = {(row, column - 1) for row, column in self.pickups if column > 0}\n if self.distance == self.next_platform:\n row = int(self.random.integers(3, 9))\n width = int(self.random.integers(3, 5))\n self.platforms.append((row, 9, 8 + width))\n self.pickups.add((row - 1, 9 + width // 2))\n self.next_platform += width + int(self.random.integers(1, 4))\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n pressed = action == 5 and self.last_action != 5\n self.last_action = action\n self.steps += 1\n self.history = [self.y, *self.history[:-1]]\n if self.steps % 2 == 0 or self.steps >= 200:\n self._scroll()\n if self.grounded:\n self.grounded = any(left <= BIRD_COLUMN <= right and (row - 1) * UNIT == self.y\n for row, left, right in self.platforms)\n if pressed and (self.grounded or self.chicks):\n if not self.grounded:\n self.chicks -= 1\n self.grounded = False\n self.velocity = -5\n previous_y = self.y\n if not self.grounded:\n gravity = int(action != 5 or self.steps % 2 == 0)\n self.velocity = min(7, self.velocity + gravity)\n self.y = max(0, self.y + self.velocity)\n if self.velocity > 0:\n landings = [(row - 1) * UNIT for row, left, right in self.platforms\n if left <= BIRD_COLUMN <= right and previous_y <= (row - 1) * UNIT <= self.y]\n if landings:\n self.y = min(landings)\n self.velocity = 0\n self.grounded = True\n self.bullets = {(row, column - 1) for row, column in self.bullets if column > 0}\n if self.steps == self.next_bullet:\n self.bullets.add((int(self.random.integers(1, 9)), 9))\n self.next_bullet += int(self.random.integers(6, 11))\n reward = 0\n for row, column in sorted(self.pickups):\n if column == BIRD_COLUMN and min(previous_y, self.y) // UNIT <= row <= max(previous_y, self.y) // UNIT:\n self.pickups.remove((row, column))\n self.chicks = min(MAX_CHICKS, self.chicks + 1)\n reward += self.chicks\n head = (self.y // UNIT, BIRD_COLUMN)\n if head in self.bullets:\n self.bullets.remove(head)\n if self.chicks:\n self.chicks = 0\n self.grounded = False\n self.velocity = 7\n else:\n self.terminal = True\n for index in range(self.chicks):\n tail = (self.history[index] // UNIT, BIRD_COLUMN - index - 1)\n if tail in self.bullets:\n self.chicks = index\n break\n self.terminal |= self.y >= 10 * UNIT or self.steps >= self.horizon\n return float(reward), self.terminal\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, self.y // UNIT), BIRD_COLUMN, 0] = True\n for row, column in self.bullets:\n state[row, column, 1] = True\n for row, column in self.pickups:\n if column < 10:\n state[row, column, 2] = True\n for row, left, right in self.platforms:\n state[row, max(0, left): min(10, right + 1)] = True\n for index in range(self.chicks):\n state[self.history[index] // UNIT, BIRD_COLUMN - index - 1, 4] = True\n values = (self.y, self.velocity + 5, self.steps, self.chicks, int(self.grounded),\n int(self.last_action == 5), self.next_platform - self.distance,\n self.next_bullet - self.steps, *self.history)\n for index, value in enumerate(values):\n for bit in range(7 if index != 2 else 9):\n offset = index * 7 + bit + (2 if index > 2 else 0)\n state[offset // 10, offset % 10, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 48, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/in_tow.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameInTow.c"} +{"name": "divarr", "split": "train", "game": "divarr", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Divarr as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to launch upward. If shots are already active, a tap\nsplits each into two perpendicular shots. At 16 active shots or\nmore, a tap turns each shot instead. Release with actions 0–4\nbefore tapping again.\n\nDestroy bombs before they land. Each bomb pays the current number\nof active shots. Let people land safely for 100 points. Hitting\na person below the protected entry zone or letting a bomb land\nends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the launcher, shots, bombs, people,\nground, and gauges. Each action advances four frames at fixed\ndifficulty. The conversion uses rectangular hit checks.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 500] and divide by 500. Across 100 seeds without sticky actions,\nidle averaged 42 raw points, random hold and release averaged\n65.78 and reached 306, and a repeating tap pattern averaged 65.34.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/divarr.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nDIRECTIONS = ((1, 0), (0, 1), (-1, 0), (0, -1))\n\n\n@dataclass\nclass Shot:\n x: float = 50\n y: float = 85\n heading: int = 3\n overlap: int = 0\n\n\n@dataclass\nclass Falling:\n x: float\n y: float\n vx: float\n vy: float\n human: bool\n\n\nclass DivarrEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.spawn_timer = 0\n self.until_human = 3\n self.first_human = True\n self.pressed = self.terminal = False\n self.shots: list[Shot] = []\n self.falling: list[Falling] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed:\n self._fire_or_split()\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance_frame()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _fire_or_split(self) -> None:\n if not self.shots:\n self.shots = [Shot()]\n return\n offsets = (-1, 1) if len(self.shots) < 16 else (1,)\n self.shots = [Shot(shot.x, shot.y, (shot.heading + offset) % 4)\n for shot in self.shots for offset in offsets]\n\n def _advance_frame(self) -> int:\n visible = []\n for shot in self.shots:\n dx, dy = DIRECTIONS[shot.heading]\n shot.x += dx\n shot.y += dy\n if -2 <= shot.x < 102 and -2 <= shot.y < 88:\n touches = any(abs(other.x - shot.x) < 3 and abs(other.y - shot.y) < 3 for other in visible)\n shot.overlap = shot.overlap + 1 if touches else 0\n if shot.overlap <= 8:\n visible.append(shot)\n self.shots = visible\n\n self.spawn_timer -= 1\n if self.spawn_timer < 0:\n self._spawn()\n reward = 0\n remaining = []\n for obj in self.falling:\n obj.x += obj.vx\n obj.y += obj.vy\n hittable = not obj.human or obj.y >= 20\n if hittable and any(abs(obj.x - shot.x) < 4 and abs(obj.y - shot.y) < 4 for shot in self.shots):\n if obj.human:\n self.terminal = True\n else:\n reward += len(self.shots)\n elif obj.y > 88:\n if obj.human:\n reward += 100\n else:\n self.terminal = True\n else:\n remaining.append(obj)\n self.falling = remaining\n return reward\n\n def _spawn(self) -> None:\n self.until_human -= 1\n human = self.until_human < 0\n x = self.random.uniform(9, 90)\n if human:\n if self.first_human:\n x = 25\n self.first_human = False\n self.until_human = int(self.random.integers(3, 15))\n dx = min(90, max(9, x + self.random.uniform(-10, 10))) - x\n speed = self.random.uniform(0.1, 0.2) * (1.6 if human else 1)\n distance = math.hypot(dx, 93)\n self.falling.append(Falling(x, -3, dx * speed / distance, 93 * speed / distance, human))\n self.spawn_timer = int(self.random.integers(60, 81))\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[8, 5, 0] = True\n state[9, :, 4] = True\n for shot in self.shots:\n if 0 <= shot.x < 100 and 0 <= shot.y < 100:\n state[int(shot.y) // 10, int(shot.x) // 10, 1] = True\n for obj in self.falling:\n if 0 <= obj.y < 100:\n state[int(obj.y) // 10, int(obj.x) // 10, 3 if obj.human else 2] = True\n for row, value in enumerate((self.steps, len(self.shots), self.spawn_timer, self.until_human + 1)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 49, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/divarr.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/divarr/main.js"} +{"name": "hero", "split": "train", "game": "hero", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Hero as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves Roderick Hero's 20-level mine-rescue loop. The prop-pack flies upward\nwith action 2, moves laterally with actions 1 and 3, and otherwise descends under gravity. Each\nlevel begins with six dynamite sticks and a finite power supply. Action 4 places a three-step-fuse\ncharge; action 5 fires the helmet laser in the facing direction. Dynamite destroys nearby walls\nfor 75 points but can kill R. Hero, while repeated laser shots cut walls without the wall award.\nLaser or blast kills on spiders, bats, snakes, and moths award 50 points.\n\nLater levels add a lava river and moving heat-resistant raft. Touching a critter or unprotected\nlava, standing too near a blast, or exhausting power costs one of four lives. Reaching the trapped\nminer awards 1,000 points, 50 per unused dynamite stick, and `remaining power × level`. A new life\nis earned every 20,000 points. Rescue on level 20 completes the finite campaign.\n\nACTION MAPPING\n0: hover/coast, then descend\n1: move/fly left\n2: prop-pack flight upward\n3: move/fly right\n4: place dynamite\n5: fire microlaser\n\nINPUT CHANNEL TABLE\n0: R. Hero\n1: critters and lava\n2: miner, raft, and lit lantern\n3: walls, laser, and dynamite\n4: previous R. Hero position\n5: exact level, dynamite, power, lives, facing, lantern, and bomb fuse\n\nSCORING, TERMINATION, AND HORIZON\nThe largest non-power reward on one level is 1,500: miner 1,000, three critters 150, two\ndynamited walls 150, and four remaining sticks 200. The starting power on level `l` is\n`305 - 5l`; therefore all power bonuses sum to\n`Σ(l × (305 - 5l), l=1..20) = 49,700`. The structural maximum is\n`20 × 1,500 + 49,700 = 79,700`. Normalization is\n`min(max(raw_score, 0), 79_700) / 79_700`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/hero.py`):\n```python\nimport numpy as np\n\n\nclass HeroEnvironment:\n \"\"\"Twenty-level prop-pack mine rescue with finite reward identities.\"\"\"\n\n score_cap = 79_700.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 6_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.level = 1\n self.lives = 4\n self.score = 0.0\n self.next_bonus_life = 20_000.0\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self.claimed_enemies: set[tuple[int, int]] = set()\n self.claimed_walls: set[tuple[int, int]] = set()\n self._start_level()\n\n def _start_level(self) -> None:\n self.player = [0, 1]\n self.previous_player = self.player.copy()\n self.facing = 1\n self.power = max(140, 300 - 5 * (self.level - 1))\n self.dynamite = 6\n self.laser: list[int] | None = None\n self.laser_direction = 1\n self.bomb: dict[str, object] | None = None\n wall_columns = (3, 6)\n wall_rows = (3 + self.level % 2, 6 - self.level % 2)\n self.walls = {\n (row, column): 3\n for row, column in zip(wall_rows, wall_columns, strict=True)\n if (self.level, row * 10 + column) not in self.claimed_walls\n }\n enemy_positions = ((2, 7), (5, 2), (7, 7))\n self.enemies = {\n index: [row, (column + self.level) % 9]\n for index, (row, column) in enumerate(enemy_positions)\n if (self.level, index) not in self.claimed_enemies\n }\n self.enemy_directions = {index: 1 if (index + self.level) % 2 else -1 for index in self.enemies}\n self.miner = [8, 8]\n self.lava_columns = set(range(2, 8)) if self.level >= 5 else set()\n self.raft = [8, 2 + self.level % 6]\n self.raft_direction = 1\n self.lantern = [1, 8]\n self.lantern_lit = True\n self.level_steps = 0\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n level_before = self.level\n lives_before = self.lives\n reward = self._apply_action(action)\n reward += self._move_laser()\n reward += self._tick_bomb()\n if self.level != level_before or self.lives != lives_before:\n return self._finish_step(reward, consume_power=False)\n if self.terminal:\n return self._finish_step(reward)\n self._apply_gravity(action)\n if self.terminal:\n return self._finish_step(reward)\n self._move_enemies()\n self._move_raft()\n self._resolve_contacts()\n if not self.terminal and self.player == self.miner:\n reward += self._rescue_miner()\n transitioned = self.level != level_before or self.lives != lives_before\n return self._finish_step(reward, consume_power=not transitioned)\n\n def _finish_step(self, reward: float, consume_power: bool = True) -> tuple[float, bool]:\n self.score += reward\n while self.score >= self.next_bonus_life:\n self.lives = min(20, self.lives + 1)\n self.next_bonus_life += 20_000.0\n if consume_power:\n self.power -= 1\n self.level_steps += 1\n self.steps += 1\n if self.power <= 0 and not self.terminal:\n self._lose_life()\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _apply_action(self, action: int) -> float:\n if action == 1:\n self.player[1] = max(0, self.player[1] - 1)\n self.facing = -1\n elif action == 2:\n self.player[0] = max(0, self.player[0] - 1)\n elif action == 3:\n self.player[1] = min(9, self.player[1] + 1)\n self.facing = 1\n elif action == 4 and self.dynamite > 0 and self.bomb is None:\n self.dynamite -= 1\n self.bomb = {\"position\": self.player.copy(), \"fuse\": 3}\n elif action == 5 and self.laser is None:\n self.laser = self.player.copy()\n self.laser_direction = self.facing\n return 0.0\n\n def _move_laser(self) -> float:\n if self.laser is None:\n return 0.0\n self.laser[1] += self.laser_direction\n position = tuple(self.laser)\n for index, enemy in list(self.enemies.items()):\n if enemy == self.laser:\n del self.enemies[index]\n self.claimed_enemies.add((self.level, index))\n self.laser = None\n return 50.0\n if position in self.walls:\n self.walls[position] -= 1\n if self.walls[position] <= 0:\n del self.walls[position]\n self.claimed_walls.add((self.level, position[0] * 10 + position[1]))\n self.laser = None\n elif self.laser == self.lantern:\n self.lantern_lit = False\n self.laser = None\n elif not 0 <= self.laser[1] < 10:\n self.laser = None\n return 0.0\n\n def _tick_bomb(self) -> float:\n if self.bomb is None:\n return 0.0\n self.bomb[\"fuse\"] = int(self.bomb[\"fuse\"]) - 1\n if self.bomb[\"fuse\"]:\n return 0.0\n bomb_position = list(self.bomb[\"position\"])\n self.bomb = None\n reward = 0.0\n for position in list(self.walls):\n if abs(position[0] - bomb_position[0]) + abs(position[1] - bomb_position[1]) <= 2:\n del self.walls[position]\n identity = (self.level, position[0] * 10 + position[1])\n if identity not in self.claimed_walls:\n self.claimed_walls.add(identity)\n reward += 75.0\n for index, enemy in list(self.enemies.items()):\n if abs(enemy[0] - bomb_position[0]) + abs(enemy[1] - bomb_position[1]) <= 2:\n del self.enemies[index]\n identity = (self.level, index)\n if identity not in self.claimed_enemies:\n self.claimed_enemies.add(identity)\n reward += 50.0\n if abs(self.player[0] - bomb_position[0]) + abs(self.player[1] - bomb_position[1]) <= 1:\n self._lose_life()\n return reward\n\n def _apply_gravity(self, action: int) -> None:\n if action != 2:\n target = [min(8, self.player[0] + 1), self.player[1]]\n if tuple(target) not in self.walls:\n self.player = target\n if tuple(self.player) in self.walls:\n self.player = self.previous_player.copy()\n\n def _move_enemies(self) -> None:\n if self.level_steps % 2:\n return\n for index, enemy in self.enemies.items():\n next_column = enemy[1] + self.enemy_directions[index]\n if next_column < 0 or next_column > 9 or (enemy[0], next_column) in self.walls:\n self.enemy_directions[index] *= -1\n else:\n enemy[1] = next_column\n\n def _move_raft(self) -> None:\n if not self.lava_columns:\n return\n carried = self.player == self.raft\n self.raft[1] += self.raft_direction\n if self.raft[1] <= min(self.lava_columns) or self.raft[1] >= max(self.lava_columns):\n self.raft_direction *= -1\n if carried:\n self.player = self.raft.copy()\n\n def _resolve_contacts(self) -> None:\n if any(enemy == self.player for enemy in self.enemies.values()):\n self._lose_life()\n return\n if self.player[0] == 8 and self.player[1] in self.lava_columns and self.player != self.raft:\n self._lose_life()\n\n def _rescue_miner(self) -> float:\n reward = 1_000.0 + 50.0 * self.dynamite + float(self.power * self.level)\n self.level += 1\n if self.level > 20:\n self.terminal = True\n else:\n self._start_level()\n return reward\n\n def _lose_life(self) -> None:\n self.lives -= 1\n if self.lives <= 0:\n self.terminal = True\n else:\n self._start_level()\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n for enemy in self.enemies.values():\n state[*enemy, 1] = True\n for column in self.lava_columns:\n state[8, column, 1] = True\n state[*self.miner, 2] = True\n state[*self.raft, 2] = True\n if self.lantern_lit:\n state[*self.lantern, 2] = True\n for wall in self.walls:\n state[*wall, 3] = True\n if self.laser is not None:\n state[*self.laser, 3] = True\n if self.bomb is not None:\n state[*self.bomb[\"position\"], 3] = True\n state[*self.previous_player, 4] = True\n for bit in range(5):\n state[9, bit, 5] = bool(self.level & (1 << bit))\n for bit in range(3):\n state[7, bit, 5] = bool(self.dynamite & (1 << bit))\n for bit in range(9):\n state[6, bit, 5] = bool(self.power & (1 << bit))\n for bit in range(5):\n state[5, bit, 5] = bool(self.lives & (1 << bit))\n state[4, 0, 5] = self.facing > 0\n state[4, 1, 5] = self.lantern_lit\n if self.bomb is not None:\n state[4, 2 + int(self.bomb[\"fuse\"]), 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 50, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/hero.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "kite", "split": "train", "game": "kite", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Kite as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to drive the kite forward and upward and emit\nmore wind gusts. Actions 0–4 release the button. The kite\npulls the runner when the tether goes taut. Spikes bounce\nthe kite away but end the run if they hit the runner.\n\nScrolling scores one point per spike generation interval.\nThe runner attracts nearby coins. Collecting one scores at\nleast 50 points, with higher awards at higher runner speeds.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the runner, kite, wind, coins,\nspikes, and gauges. The conversion approximates sprite and\nspike collisions geometrically. At fixed difficulty each action\nadvances four frames. The 400-action task clips scores to\n[0, 3000] and divides by 3000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/kite.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Body:\n x: float\n y: float\n vx: float = 0\n vy: float = 0\n\n def move(self, scroll: float = 0) -> None:\n self.x += self.vx - scroll\n self.y += self.vy\n\n\n@dataclass\nclass Spike:\n x: float\n base: float\n height: float\n\n def hits(self, body: Body) -> bool:\n depth = (body.y - self.base) * (1 if self.height > 0 else -1)\n height = abs(self.height)\n width = 5 * (1 - max(0, depth - 3) / height)\n return -3 < depth < height + 3 and abs(body.x - self.x) < width + 3\n\n\nclass KiteEnvironment:\n score_cap = 3000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.kite, self.player = Body(40, 50), Body(20, 87)\n self.winds: list[Body] = []\n self.coins: list[Body] = []\n self.spikes: list[Spike] = []\n self.spike_angles = [(0.0, 0.0), (math.pi / 2, math.pi)]\n self.spike_distance = self.coin_distance = self.wind_timer = 0.0\n self.steps = 0\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self) -> int:\n kite, player = self.kite, self.player\n scroll = max(0, kite.x - 60) * 0.1\n reward = self._move_spikes(scroll)\n kite.vx = (kite.vx + 0.2 * self.pressed) * 0.95\n kite.vy = (kite.vy + 0.01 - 0.2 * self.pressed) * 0.95\n kite.move(scroll)\n if not 0 <= kite.y <= 87:\n kite.y = min(87, max(0, kite.y))\n kite.vy = 0\n direction = 1 if kite.y < 50 else -1\n bumps = 0\n while bumps < 9 and any(spike.hits(kite) for spike in self.spikes):\n kite.y += 3 * direction\n bumps += 1\n if bumps:\n kite.vy = math.sqrt(bumps) * direction * 2\n player.move(scroll)\n if player.y < 87:\n player.vy += math.sqrt(99 - player.y) * 0.01\n player.vx *= 0.95\n else:\n player.y, player.vy = 87, 0\n player.vx *= 0.9\n if any(spike.hits(player) for spike in self.spikes):\n self.terminal = True\n return reward\n dx, dy = kite.x - player.x, kite.y - player.y\n distance = math.hypot(dx, dy)\n if distance > 50:\n pull = (distance - 50) / distance\n player.vx += dx * pull * 0.05\n player.vy += dy * pull * 0.05\n kite.vx -= dx * pull * 0.01\n kite.vy -= dy * pull * 0.01\n kite.x -= dx * pull\n kite.y -= dy * pull\n self.wind_timer -= 3 if self.pressed else 1\n if self.wind_timer < 0:\n speed = self.random.uniform(1, 2) * (2 if self.pressed else 1)\n self.winds.append(Body(-3, self.random.uniform(0, 87), vx=speed))\n self.wind_timer += 30\n surviving = []\n for wind in self.winds:\n wind.move()\n if abs(wind.x - kite.x) < 6 and abs(wind.y - kite.y) < 6:\n kite.vx += wind.vx\n elif wind.x <= 203:\n surviving.append(wind)\n self.winds = surviving\n return reward + self._move_coins(scroll)\n\n def _move_spikes(self, scroll: float) -> int:\n self.spike_distance -= scroll\n spawn = self.spike_distance < 0\n if spawn:\n self.spike_distance += 10\n for index, (a, b) in enumerate(self.spike_angles):\n height = math.sin(a) * 9 + math.sin(b) * 20 - 10\n self.spike_angles[index] = (a + self.random.uniform(0, 0.2), b + self.random.uniform(0, 0.4))\n if height > 0:\n self.spikes.append(Spike(205, 90 if index else 0, -height if index else height))\n for spike in self.spikes:\n spike.x -= scroll\n self.spikes = [spike for spike in self.spikes if spike.x >= -5]\n return int(spawn)\n\n def _move_coins(self, scroll: float) -> int:\n self.coin_distance -= scroll\n if self.coin_distance < 0:\n self.coins.append(Body(203, self.random.uniform(30, 80), vx=-0.5))\n self.coin_distance += self.random.uniform(199, 299)\n player = self.player\n reward = 0\n remaining = []\n for coin in self.coins:\n coin.move(scroll)\n if any(spike.hits(coin) for spike in self.spikes):\n continue\n dx, dy = player.x - coin.x, player.y - coin.y\n distance = math.hypot(dx, dy)\n if abs(dx) < 6 and abs(dy) < 6:\n reward += min(99, max(1, math.ceil(player.vx * 5))) * 50\n continue\n if any(abs(w.x - coin.x) < 6 and abs(w.y - coin.y) < 6 for w in self.winds):\n coin.x += 1\n if 0 < distance < 24:\n coin.vx = (coin.vx + dx / distance) * 0.9\n coin.vy = (coin.vy + dy / distance) * 0.9\n if -3 <= coin.x <= 207 and -3 <= coin.y <= 90:\n remaining.append(coin)\n self.coins = remaining\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for channel, objects in enumerate(([self.player], [self.kite], self.winds, self.coins)):\n for body in objects:\n if 0 <= body.x < 200 and 0 <= body.y < 100:\n state[int(body.y // 10), int(body.x // 20), channel] = True\n for spike in self.spikes:\n if 0 <= spike.x < 200:\n start, end = sorted((spike.base, spike.base + spike.height))\n state[int(start // 10):int(end // 10) + 1, int(spike.x // 20), 4] = True\n for row, value in enumerate((self.steps, round((self.kite.vy + 10) * 20),\n round((self.kite.vx + 5) * 20))):\n for bit in range(9):\n state[row, bit, 5] = bool(min(511, max(0, value)) & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 51, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/kite.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/kite/main.js"} +{"name": "inf_range", "split": "train", "game": "inf_range", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Inf Range as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to turn slowly. Release with actions 0–4.\nReleasing after fewer than nine frames turns 90 degrees\nfrom the heading at the start of the press.\n\nStrike an arrow's body to score. A head-on clash reverses\nboth arrows. An enemy tip striking your body from another\nangle ends the run. Successful strikes raise the next\naward, which decays gradually toward its starting value.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, player heading,\nenemy bodies, enemy tips, projected enemy positions, and\ngauges. The conversion uses proximity checks for collisions\nand four frames per action at fixed difficulty. The 400-action\ntask clips raw scores to [0, 200] and divides by 200.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/inf_range.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Arrow:\n x: float\n y: float\n angle: float\n\n\nclass InfRangeEnvironment:\n score_cap = 200\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x, self.y = 50.0, 80.0\n self.angle = self.tap_angle = -math.pi / 2\n self.scroll_x = self.scroll_y = 0.0\n self.steps = self.frames = 0\n self.tap_frame = -99\n self.spawn_timer = 200.0\n self.multiplier = 10.9\n self.pressed = self.terminal = False\n self.arrows: list[Arrow] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap, release = pressed and not self.pressed, self.pressed and not pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0, release and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap: bool, release: bool) -> int:\n self.x += math.cos(self.angle)\n self.y += math.sin(self.angle)\n if not 40 <= self.x <= 60:\n self.scroll_x = (min(60, max(40, self.x)) - self.x) * 0.2\n if not 40 <= self.y <= 60:\n self.scroll_y = (min(60, max(40, self.y)) - self.y) * 0.2\n self.x += self.scroll_x\n self.y += self.scroll_y\n drawn_angle = self.angle\n if tap:\n self.tap_angle, self.tap_frame = self.angle, self.frames\n if self.pressed:\n self.angle += 0.02\n if release and self.frames - self.tap_frame < 9:\n self.angle = self.tap_angle + math.pi / 2\n self.frames += 1\n reward = 0\n remaining = []\n for arrow in self.arrows:\n arrow.x = (arrow.x + math.cos(arrow.angle) * 0.5 + self.scroll_x + 3) % 106 - 3\n arrow.y = (arrow.y + math.sin(arrow.angle) * 0.5 + self.scroll_y + 3) % 106 - 3\n dx, dy = arrow.x - self.x, arrow.y - self.y\n arrow_tip = (dx + 4 * math.cos(arrow.angle), dy + 4 * math.sin(arrow.angle))\n player_tip = (4 * math.cos(drawn_angle), 4 * math.sin(drawn_angle))\n body_hit = math.hypot(dx, dy) < 3 or math.dist((dx, dy), player_tip) < 3\n tip_hit = math.hypot(*arrow_tip) < 3\n if body_hit or tip_hit:\n facing = abs((self.angle - arrow.angle) % math.tau - math.pi) < 0.7\n if facing:\n arrow.angle += math.pi\n arrow.x += math.cos(arrow.angle)\n arrow.y += math.sin(arrow.angle)\n self.angle += math.pi\n elif body_hit:\n reward += int(self.multiplier)\n self.multiplier += 10\n continue\n else:\n self.terminal = True\n remaining.append(arrow)\n self.arrows = remaining\n self.spawn_timer = self.spawn_timer - 1 if remaining else -1\n if self.spawn_timer < 0:\n self._spawn()\n self.multiplier = max(10.9, self.multiplier - 0.02)\n return reward\n\n def _spawn(self) -> None:\n for _ in range(9):\n x, y = self.random.uniform(10, 90, 2)\n dx, dy = (self.x - x + 50) % 100 - 50, (self.y - y + 50) % 100 - 50\n if abs(dx) + abs(dy) > 36:\n self.arrows.append(Arrow(x, y, self.random.uniform(0, math.tau)))\n self.spawn_timer = self.random.uniform(150, 250)\n break\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for x, y, channel in ((self.x, self.y, 0),\n (self.x + 8 * math.cos(self.angle), self.y + 8 * math.sin(self.angle), 1)):\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y) // 10, int(x) // 10, channel] = True\n for arrow in self.arrows:\n for x, y, channel in ((arrow.x, arrow.y, 2),\n (arrow.x + 4 * math.cos(arrow.angle), arrow.y + 4 * math.sin(arrow.angle), 3),\n (arrow.x + 10 * math.cos(arrow.angle), arrow.y + 10 * math.sin(arrow.angle), 4)):\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y) // 10, int(x) // 10, channel] = True\n values = (self.steps, min(511, int(self.multiplier)), round(self.angle % math.tau * 80),\n min(9, self.frames - self.tap_frame))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 52, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/inf_range.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/infrange/main.js"} +{"name": "counter_b", "split": "train", "game": "counter_b", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Counter B as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to extend your beam. Release with actions 0–4 to move\nforward faster. Meeting an enemy beam tip creates a counter ring.\nHold to grow the ring or release to shrink it. Ring kills award a\nmultiplier that doubles up to 64 and resets when a new counter begins.\nDirect beam kills score zero.\n\nEnemy beams knock the player backward unless the counter shields them\nor temporary invulnerability is active. The run ends if the player\nis pushed off the left edge or reaches 400 actions.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, friendly beam, enemies, enemy\nbeams, counter ring, and gauges. Each action advances four frames at\nfixed difficulty. The conversion uses geometric hit tests.\n\nSCORING, TERMINATION, AND HORIZON\nClip raw scores to [0, 500] and divide by 500. Across 100 seeds\nwithout sticky actions, idle scored zero, random inputs averaged\n0.76, and holding averaged 32.72 and reached 708 before clipping.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/counter_b.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nY = 60\n\n\n@dataclass(eq=False)\nclass Enemy:\n x: float\n y: float\n angle: float\n speed: float\n beam: float = 0\n\n def tip(self) -> tuple[float, float]:\n return self.x + math.cos(self.angle) * self.beam, self.y + math.sin(self.angle) * self.beam\n\n\n@dataclass\nclass Counter:\n x: float\n radius: float\n enemy: Enemy | None\n\n\nclass CounterBEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.shield = 0\n self.spawn_timer = 9\n self.multiplier = 1\n self.x, self.base_x = 20.0, 30.0\n self.speed = self.beam = 0.0\n self.pressed = self.terminal = False\n self.counter: Counter | None = None\n self.enemies = [Enemy(205, Y, math.pi, 0.5)]\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance_frame()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self) -> int:\n scroll = (self.x - self.base_x) * 0.1\n self.base_x += (30 - self.base_x) * 0.001\n self.speed += ((0.2 if self.pressed else 2) - self.speed) * 0.2\n self.x += self.speed - scroll\n if self.counter is None:\n self.beam = min(300, self.beam + 4) if self.pressed else 0\n else:\n self.counter.x -= scroll\n self.beam = max(0, self.counter.x - self.x)\n if not self.beam and self.counter.enemy is not None:\n self.counter.enemy.beam = -9999\n self.counter.enemy = None\n growth = 1 if self.pressed and self.counter.enemy is not None else -2\n self.counter.radius = min(30, self.counter.radius + growth)\n if self.counter.radius < 1:\n if self.counter.enemy is not None:\n self.counter.enemy.beam = -9999\n self.counter = None\n\n self.spawn_timer -= 1\n if self.spawn_timer < 0:\n self._spawn()\n reward = 0\n incoming = False\n survivors = []\n for enemy in self.enemies:\n enemy.x += math.cos(enemy.angle) * enemy.speed - scroll\n enemy.y += math.sin(enemy.angle) * enemy.speed\n if self.counter is not None and self.counter.enemy is enemy:\n enemy.beam = math.hypot(enemy.x - self.counter.x, enemy.y - Y)\n enemy.speed *= 0.8\n else:\n enemy.beam += 0.8\n if enemy.beam > 0:\n tx, ty = enemy.tip()\n if self.counter is None and self.beam and abs(tx - self.x - self.beam) < 5 and abs(ty - Y) < 5:\n self.counter = Counter(self.x + self.beam, 1, enemy)\n self.multiplier = 1\n if (self.counter is None or self.counter.enemy is not enemy) and (\n ty > 90 or tx < -99 or self._counter_hits(tx, ty)\n ):\n enemy.beam = -9999\n if self._counter_hits(enemy.x, enemy.y):\n reward += self.multiplier\n self.multiplier = min(64, self.multiplier * 2)\n if self.counter is not None and self.counter.enemy is enemy:\n self.counter.enemy = None\n elif self.beam and self.x <= enemy.x <= self.x + self.beam and abs(enemy.y - Y) < 3:\n if self.counter is not None and self.counter.enemy is enemy:\n self.counter.enemy = None\n elif enemy.x >= -5:\n incoming |= self._beam_hits_player(enemy)\n if enemy.beam < -999:\n enemy.speed += (1 - enemy.speed) * 0.1\n enemy.angle += (math.pi - enemy.angle) * 0.05\n survivors.append(enemy)\n self.enemies = survivors\n self.shield = max(0, self.shield - 1)\n if incoming and not self.shield and (\n self.counter is None or abs(self.x - self.counter.x) >= self.counter.radius + 9\n ):\n self.x -= 10\n self.base_x -= 10\n self.shield = 60\n self.terminal = self.x < 0\n return reward\n\n def _counter_hits(self, x: float, y: float) -> bool:\n return self.counter is not None and abs(\n math.hypot(x - self.counter.x, y - Y) - self.counter.radius\n ) < 4\n\n def _beam_hits_player(self, enemy: Enemy) -> bool:\n if enemy.beam <= 0:\n return False\n dx, dy = self.x - enemy.x, Y - enemy.y\n cos, sin = math.cos(enemy.angle), math.sin(enemy.angle)\n distance = min(enemy.beam, max(0, dx * cos + dy * sin))\n return math.hypot(dx - distance * cos, dy - distance * sin) < 3\n\n def _spawn(self) -> None:\n if self.random.random() < 0.6:\n x, y = self.random.uniform(150, 300), -5\n else:\n x, y = 205, self.random.uniform(0, 85)\n target = self.x + 9 if self.random.random() < 0.05 else x - self.random.uniform(30, 150)\n self.enemies.append(Enemy(x, y, math.atan2(Y - y, target - x) % math.tau,\n 1, -self.random.uniform(0, 20)))\n self.spawn_timer = int(self.random.integers(30, 41))\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n column = min(9, max(0, int(self.x) // 20))\n state[6, column, 0] = True\n if self.beam:\n state[6, column:min(10, int(self.x + self.beam) // 20 + 1), 1] = True\n for enemy in self.enemies:\n if 0 <= enemy.x < 200 and 0 <= enemy.y < 100:\n state[int(enemy.y) // 10, int(enemy.x) // 20, 2] = True\n if enemy.beam > 0:\n tx, ty = enemy.tip()\n for fraction in np.linspace(0, 1, 16):\n x = enemy.x + (tx - enemy.x) * fraction\n y = enemy.y + (ty - enemy.y) * fraction\n if 0 <= x < 200 and 0 <= y < 100:\n state[int(y) // 10, int(x) // 20, 3] = True\n for row in range(10):\n for column in range(10):\n state[row, column, 4] = self._counter_hits(column * 20 + 10, row * 10 + 5)\n for row, value in enumerate((self.steps, self.multiplier, round(self.beam), self.shield)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 53, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/counter_b.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/counterb/main.js"} +{"name": "revolve_a", "split": "train", "game": "revolve_a", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Revolve A as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to steer in the direction of the rotating arrow.\nActions 0–4 release. The arrow keeps moving and bounces off the edges.\nTouch a green link between enemies to clear the nearby chain.\nThe first enemy cleared scores one point, the second scores two,\nand so on. Hitting an enemy directly ends the run.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the arrow, enemies, links, aim,\nenemies queued for removal, and counters. The port uses fixed\ndifficulty and approximates arrow collisions with a rectangular\nenemy hitbox and a distance threshold for links. Each action advances\nup to four frames over a 400-action horizon. Clip the episode score\nto [0, 200] and divide by 200.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/revolve_a.py`):\n```python\nfrom math import cos, pi, sin\n\nimport numpy as np\n\n\nclass RevolveAEnvironment:\n score_cap = 200\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.position = np.array([50.0, 50.0])\n self.velocity = np.full(2, 2 ** -0.5)\n self.angle = -pi / 2\n self.steps = self.timer = 0\n self.held = self.terminal = False\n self.enemies = np.empty((0, 2))\n self.velocities = np.empty((0, 2))\n self.removed = np.empty(0, dtype=bool)\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _spawn(self):\n position = np.array([self.random.uniform(0, 99), self.random.choice((-3, 103))])\n if self.random.random() < 0.5:\n position = position[::-1]\n delta = self.random.uniform(10, 90, 2) - position\n self.enemies = np.vstack((self.enemies, position))\n self.velocities = np.vstack((self.velocities, 0.3 * delta / np.linalg.norm(delta)))\n self.removed = np.append(self.removed, False)\n\n def _advance(self, tap):\n self.timer -= 1\n if self.timer < 0:\n self._spawn()\n self.timer = self.random.uniform(30, 40)\n count = int(self.removed.sum())\n self.enemies[~self.removed] += self.velocities[~self.removed]\n keep = ~self.removed & np.all((self.enemies >= -5) & (self.enemies <= 105), axis=1)\n self.enemies = self.enemies[keep]\n self.velocities = self.velocities[keep]\n self.removed = np.zeros(len(self.enemies), dtype=bool)\n if tap:\n self.velocity[:] = cos(self.angle), sin(self.angle)\n bounce = ((self.position < 3) & (self.velocity < 0)) | ((self.position > 97) & (self.velocity > 0))\n self.velocity[bounce] *= -1\n self.position += self.velocity * 0.4\n self.angle = (self.angle + 0.08) % (2 * pi)\n delta = self.enemies - self.position\n self.terminal = bool(np.any(np.all(abs(delta) < 4.5, axis=1)))\n if not self.terminal:\n links = self._links()\n if len(links):\n starts, ends = self.enemies[links[:, 0]], self.enemies[links[:, 1]]\n vectors = ends - starts\n lengths = np.sum(vectors ** 2, axis=1)\n projected = np.divide(np.sum((self.position - starts) * vectors, axis=1),\n lengths, out=np.zeros_like(lengths), where=lengths > 0)\n closest = starts + np.clip(projected, 0, 1)[:, None] * vectors\n if np.any(np.linalg.norm(closest - self.position, axis=1) < 3):\n self.removed = np.linalg.norm(delta, axis=1) < 30\n while True:\n touching = self.removed[links].any(axis=1)\n linked = links[touching].ravel()\n if self.removed[linked].all():\n break\n self.removed[linked] = True\n return count * (count + 1) // 2\n\n def _links(self):\n left, right = np.triu_indices(len(self.enemies), 1)\n near = np.linalg.norm(self.enemies[left] - self.enemies[right], axis=1) < 30\n return np.column_stack((left[near], right[near]))\n\n @staticmethod\n def _mark(state, points, channel):\n visible = np.all((points >= 0) & (points < 100), axis=1)\n cols, rows = (points[visible] // 10).astype(int).T\n state[rows, cols, channel] = True\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n self._mark(state, self.position[None], 0)\n self._mark(state, self.enemies[~self.removed], 1)\n for left, right in self._links():\n if not (self.removed[left] or self.removed[right]):\n self._mark(state, np.linspace(self.enemies[left], self.enemies[right], 31), 2)\n aim = self.position + 10 * np.array([cos(self.angle), sin(self.angle)])\n self._mark(state, np.clip(aim, 0, 99)[None], 3)\n self._mark(state, self.enemies[self.removed], 4)\n for row, value in enumerate((self.steps, self.held, round(self.angle * 50),\n round((self.velocity[0] + 1) * 100),\n round((self.velocity[1] + 1) * 100))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 54, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/revolve_a.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/revolvea/main.js"} +{"name": "square_bar", "split": "train", "game": "square_bar", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Square Bar as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to grow the bar. Actions 0–4 release. Both bars pivot\nclockwise around the square. Catch the opposing bar from behind for\nten times the multiplier, then increase it. Being caught ends the\nrun. Gold scores the current multiplier. Fully grown spikes are lethal.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the player bar, opposing bar, gold,\nactive spikes, inactive spikes, and counters. The port uses fixed\ndifficulty and sampled bar collisions. Items respawn on collection\nor expiry. Each action advances up to four frames over 400 actions.\nClip episode scores to [0, 300] and divide by 300.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/square_bar.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import atan2, cos, hypot, pi, sin\n\nimport numpy as np\n\n\nDIRECTIONS = ((1, 0), (0, 1), (-1, 0), (0, -1))\nSTARTS = ((50, 29), (71, 50), (50, 71), (29, 50))\n\n\n@dataclass\nclass Bar:\n x: float\n y: float\n length: float\n angle: float\n side: int\n pivot: float = 0\n\n def advance(self):\n self.angle = (self.angle + 0.03) % 4\n if not self.side <= self.angle < self.side + pi / 4:\n return\n self.angle = self.side\n dx, dy = DIRECTIONS[self.side]\n distance = self.length * (1 - self.pivot)\n room = (71 - self.x, 71 - self.y, self.x - 29, self.y - 29)[self.side]\n if distance > room:\n self.x += room * dx\n self.y += room * dy\n self.pivot = 1 - (distance - room) / self.length\n self.side = (self.side + 1) % 4\n else:\n self.x += distance * dx\n self.y += distance * dy\n self.angle = (self.angle + 2) % 4\n self.pivot = 0\n\n def points(self):\n distance = np.linspace(-self.pivot, 1 - self.pivot, 32) * self.length\n angle = self.angle * pi / 2\n return self.x + distance * cos(angle), self.y + distance * sin(angle)\n\n\n@dataclass\nclass Item:\n x: float\n y: float\n spike: bool\n timer: int\n size: int = 0\n\n\nclass SquareBarEnvironment:\n score_cap = 300\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.player = Bar(50, 29, 9, 3, 0)\n self.enemy = Bar(50, 71, 12, 1, 2)\n self.items = [self._item(i < 3) for i in range(10)]\n self.steps = 0\n self.multiplier = 1\n self.held = self.terminal = False\n\n def _item(self, spike):\n for _ in range(99):\n x = self.random.uniform(9, 70) - 50\n y = self.random.uniform(9, 15 if spike else 26) - 50\n dx, dy = DIRECTIONS[self.random.integers(4)]\n px, py = 50 + dx * x - dy * y, 50 + dy * x + dx * y\n if hypot(px - self.player.x, py - self.player.y) > 36:\n break\n return Item(px, py, spike, int(self.random.integers(777, 999)))\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n if self.random.random() >= self.sticky_action_prob:\n self.held = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _chased(self):\n difference = atan2(self.player.y - 50, self.player.x - 50) - atan2(\n self.enemy.y - 50, self.enemy.x - 50)\n return (difference + pi) % (2 * pi) - pi > 0\n\n def _advance(self):\n chased = self._chased()\n target, rate = (29, 0.1) if self.held else (9, 0.2)\n self.player.length += (target - self.player.length) * rate\n self.enemy.length = 15\n self.player.advance()\n self.enemy.advance()\n px, py = self.player.points()\n ex, ey = self.enemy.points()\n reward = 0\n if np.any(np.hypot(px[:, None] - ex, py[:, None] - ey) < 3):\n if chased:\n self.terminal = True\n else:\n reward += 10 * self.multiplier\n self.multiplier += 1\n side = (self.player.side + 2) % 4\n self.enemy = Bar(*STARTS[side], 12, (side - 1) % 4, side)\n for index, item in enumerate(self.items):\n if item.timer % 15 == 0:\n item.size = max(0, item.size - 1) if item.timer < 60 else min(4, item.size + 1)\n reach = item.size / 2 + 1.5\n hit = item.size > 0 and np.any((abs(px - item.x) < reach) & (abs(py - item.y) < reach))\n if hit and not item.spike:\n reward += self.multiplier\n self.items[index] = self._item(False)\n else:\n self.terminal |= bool(hit and item.size == 4)\n item.timer -= 1\n if item.timer < 0:\n self.items[index] = self._item(item.spike)\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for channel, bar in ((0, self.player), (1, self.enemy)):\n x, y = bar.points()\n cols = np.clip(x // 10, 0, 9).astype(int)\n rows = np.clip(y // 10, 0, 9).astype(int)\n state[rows, cols, channel] = True\n for item in self.items:\n if item.size:\n channel = 2 if not item.spike else 3 if item.size == 4 else 4\n state[int(item.y // 10), int(item.x // 10), channel] = True\n values = (self.steps, self.multiplier, self.held, self._chased(),\n round(self.player.length * 10), self.player.side, self.enemy.side)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 55, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/square_bar.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/squarebar/main.js"} +{"name": "gravity_bubble", "split": "train", "game": "gravity_bubble", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Gravity Bubble as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to preview a bubble along the player's projected\npath. Longer holds grow the bubble and project farther ahead.\nRelease with actions 0–4 to place it. Bubbles lift the player\nand enemies, then shrink and expire. The player bounces off\nwalls and loses the run by falling below the screen.\n\nEach new altitude record scores the increase in whole pixels.\nEnemy contact scores 100 points and transfers vertical momentum.\nThe task advances four frames per action for up to 400 actions.\nIt clips the raw total to [0, 2000] and divides by 2000.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, enemies, walls, active\nbubble areas, the bubble preview, and gauges. The conversion\nuses seeded NumPy randomness and omits cosmetic effects.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/gravity_bubble.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Body:\n x: float\n y: float\n vx: float\n vy: float\n size: float\n\n def move(self) -> None:\n self.x += self.vx\n self.y += self.vy\n if self.x > 95 or self.x < 5:\n self.vx *= -1\n\n\n@dataclass\nclass Bubble:\n x: float\n y: float\n size: float\n life: int = 180\n\n\n@dataclass\nclass Wall:\n x: float\n y: float\n width: float\n\n def bounce(self, body: Body, damping: float) -> None:\n clearance = (body.size + 4) / 2\n if abs(body.x - self.x) < (self.width + body.size) / 2 and abs(body.y - self.y) < clearance:\n body.vy *= -damping\n body.y = self.y + (clearance + 1) * (-1 if body.y < self.y else 1)\n\n\nclass GravityBubbleEnvironment:\n score_cap = 2000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.player = Body(50, 50, 1, 0, 6)\n self.height = 0.0\n self.steps = self.frames = self.best_height = self.hold = 0\n self.next_wall = 150.0\n self.next_enemy = 60.0\n self.pressed = self.terminal = False\n self.preview = Bubble(50, 50, 8)\n self.bubbles: list[Bubble] = []\n self.enemies: list[Body] = []\n self.walls: list[Wall] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n released = self.pressed and not pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(released and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, released: bool) -> int:\n player = self.player\n player.vy = (player.vy + 0.025) * 0.995\n player.move()\n scroll = max(0, (60 - player.y) * 0.5)\n player.y += scroll\n self.height += scroll\n for objects in (self.bubbles, self.enemies, self.walls):\n for obj in objects:\n obj.y += scroll\n if self.pressed:\n self.hold += 1\n x = player.x\n vx = player.vx\n for _ in range(self.hold):\n x += vx\n if x > 95 or x < 5:\n vx *= -1\n self.preview = Bubble(x, player.y + player.vy * self.hold, 8 + min(25, self.hold * 0.2))\n else:\n if released:\n self.bubbles.append(self.preview)\n self.hold = 0\n altitude = self.height + max(0, 100 - player.y)\n self._spawn(altitude)\n self.frames += 1\n for bubble in self.bubbles:\n bubble.life -= 1\n radius = bubble.size * min(1, bubble.life / 150)\n if math.hypot(player.x - bubble.x, player.y - bubble.y) < radius + 9:\n player.vy -= 0.05\n reward = max(0, int(altitude) - self.best_height)\n self.best_height = max(self.best_height, int(altitude))\n surviving = []\n for enemy in self.enemies:\n inside = False\n for bubble in self.bubbles:\n radius = bubble.size * min(1, bubble.life / 150)\n inside = math.hypot(enemy.x - bubble.x, enemy.y - bubble.y) < radius + enemy.size / 2\n if inside:\n enemy.vy -= 0.08\n if not inside:\n enemy.vy += 0.02\n enemy.move()\n for wall in self.walls:\n wall.bounce(enemy, 0.6)\n if math.hypot(player.x - enemy.x, player.y - enemy.y) < (6 + enemy.size) / 2 + 2:\n player.vy += enemy.vy * 1.5\n reward += 100\n elif enemy.y <= 110:\n surviving.append(enemy)\n self.enemies = surviving\n self.bubbles = [bubble for bubble in self.bubbles if bubble.life]\n for wall in self.walls:\n wall.bounce(player, 0.8)\n self.walls = [wall for wall in self.walls if wall.y <= 110]\n self.terminal = player.y > 105\n return reward\n\n def _spawn(self, altitude: float) -> None:\n level = int(altitude // 100) + 1\n if self.frames >= self.next_enemy:\n speed = self.random.uniform(0.2, 0.25 + math.sqrt(level) * 0.08)\n self.enemies.append(Body(self.random.uniform(15, 85), -5, self.random.uniform(-0.6, 0.6),\n speed, 7 + min(3, level // 2)))\n interval = max(45, 120 - level * 10)\n self.next_enemy = self.frames + interval * self.random.uniform(0.7, 1.3)\n if level > 2 and altitude >= self.next_wall:\n width = self.random.uniform(25, 50)\n self.walls.append(Wall(self.random.uniform(width / 2, 100 - width / 2), -5, width))\n self.next_wall = altitude + self.random.uniform(70, 150)\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n player = self.player\n state[min(9, max(0, int(player.y) // 10)), int(player.x) // 10, 0] = True\n for enemy in self.enemies:\n if 0 <= enemy.y < 100:\n state[int(enemy.y) // 10, int(enemy.x) // 10, 1] = True\n for wall in self.walls:\n if 0 <= wall.y < 100:\n state[int(wall.y) // 10, int(wall.x - wall.width / 2) // 10:\n int(wall.x + wall.width / 2) // 10 + 1, 2] = True\n for channel, bubbles in ((3, self.bubbles), (4, [self.preview] if self.pressed else [])):\n for bubble in bubbles:\n radius = bubble.size * min(1, bubble.life / 150)\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n state[:, :, channel] |= (cols - bubble.x) ** 2 + (rows - bubble.y) ** 2 < radius ** 2\n velocity = min(511, max(0, round((player.vy + 5) * 50)))\n for row, value in enumerate((self.steps, min(511, self.hold), velocity)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, player.vx > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 56, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/gravity_bubble.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameGravityBubble.c"} +{"name": "ball_tour", "split": "train", "game": "ball_tour", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Ball Tour as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe rider bobs automatically. Hold action 5 to scroll one column per step. Other\nactions scroll one column every ten steps. Time the approach to collect balls with\nthe rider or carried ball, and avoid hitting spikes with the carried ball.\nSome spikes drift vertically and bounce. Ball and spike generation is seeded\nand tied to travel distance. Collecting a ball pays the current multiplier and\nadds ten to it. The multiplier decays toward one between collections.\n\nINPUT CHANNEL TABLE\nThe binary channels represent the rider, spikes, balls, carried ball and gauges,\nnext rider row and downward spike motion, and upward spike motion, respectively.\nGauges carry the clock, fractional scroll, multiplier, spawn distances, and previous\nhold state. The grid approximation uses a fixed 16-step orbit, discrete spike motion,\nand tile collisions in place of continuous animation and sprite overlap.\n\nSCORING, TERMINATION, AND HORIZON\nThe episode ends at the first spike collision or at 500 steps. At most 167 balls\ncan spawn because there are at most 500 columns of travel and at least three columns\nbetween balls. Each ball can score once and pays at most 999, so the conservative\nscore cap is 166,833. Normalize by clipping the raw score to [0, cap] and dividing\nby the cap. Waiting can change approach timing but cannot spawn or replenish balls.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/ball_tour.py`):\n```python\nimport numpy as np\n\n\nORBIT = (5, 6, 7, 8, 8, 8, 7, 6, 5, 4, 3, 2, 2, 2, 3, 4)\nHORIZON = 500\n\n\nclass BallTourEnvironment:\n # A ball is spawned no more often than every three columns of travel.\n score_cap = 999 * ((HORIZON + 2) // 3)\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.distance = self.scroll_fraction = self.last_action = 0\n self.next_spike = 1\n self.next_ball = 2\n self.multiplier = 100\n self.spikes: list[tuple[int, int, int]] = []\n self.balls: list[tuple[int, int]] = []\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n @property\n def row(self) -> int:\n return ORBIT[self.steps % len(ORBIT)]\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.steps += 1\n self.scroll_fraction += 10 if action == 5 else 1\n advance, self.scroll_fraction = divmod(self.scroll_fraction, 10)\n self.distance += advance\n moved_spikes = []\n for row, column, velocity in self.spikes:\n column += advance\n if column > 9:\n continue\n if velocity and self.steps % 4 == 0:\n if not 1 <= row + velocity <= 8:\n velocity = -velocity\n row += velocity\n moved_spikes.append((row, column, velocity))\n self.spikes = moved_spikes\n if self.distance == self.next_spike:\n row = int(self.random.integers(1, 9))\n velocity = int(self.random.choice((-1, 1))) if self.random.random() < 0.2 else 0\n self.spikes.append((row, 0, velocity))\n self.next_spike += int(self.random.integers(1, 6))\n self.terminal = any(column == 9 and row == self.row - 1 for row, column, _ in self.spikes)\n if self.terminal:\n return 0.0, True\n reward = 0\n remaining = []\n for row, column in self.balls:\n column += advance\n if column == 9 and row in (self.row - 1, self.row):\n reward += self.multiplier // 100\n self.multiplier = min(99_900, self.multiplier + 1_000)\n elif column <= 9:\n remaining.append((row, column))\n self.balls = remaining\n if self.distance == self.next_ball:\n row = int(self.random.integers(2, 8))\n if any(spike_row == row and column == 0 for spike_row, column, _ in self.spikes):\n self.next_ball += 1\n else:\n self.balls.append((row, 0))\n self.next_ball += int(self.random.integers(3, 8))\n self.multiplier = max(100, self.multiplier - 2)\n self.terminal = self.steps >= self.horizon\n return float(reward), self.terminal\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[self.row, 9, 0] = True\n state[self.row - 1, 9, 3] = True\n state[ORBIT[(self.steps + 1) % len(ORBIT)], 9, 4] = True\n for row, column in self.balls:\n state[row, column, 2] = True\n for row, column, velocity in self.spikes:\n state[row, column, 1] = True\n state[row, column, 4] = velocity == 1\n state[row, column, 5] = velocity == -1\n gauges = ((self.steps, 9), (self.scroll_fraction, 4), (self.multiplier, 17),\n (self.next_spike - self.distance, 3), (self.next_ball - self.distance, 3),\n (int(self.last_action == 5), 1))\n offset = 0\n for value, width in gauges:\n for bit in range(width):\n index = offset + bit\n state[index // 9, index % 9, 3] = bool(value & (1 << bit))\n offset += width\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 57, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/ball_tour.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBallTour.c"} +{"name": "feeding_frenzy", "split": "train", "game": "feeding_frenzy", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Feeding Frenzy as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe shark circles the edge automatically. Tap action 5 to dart\ninward and hold it to turn during the dart. Release with actions\n0–4 to coast straight. The dart ends at the circular boundary.\n\nCatching fish scores the current multiplier and increases it.\nA new dart resets the multiplier. Fish move faster while the shark\ndarts. A fish leaving the screen ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the shark, fish, circular boundary,\nheading, dart status, and gauges. The conversion uses fixed\ndifficulty and distance-based catches. Each action advances four\nsimulation frames.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action task clips raw scores to [0, 500] and divides by\n500. Across 100 seeds without sticky actions, idle averaged 7.95,\ncontinuous hold averaged 11.03, and random inputs averaged 46.43.\nRepeating four held actions and eleven released actions averaged\n81.79 and reached 110.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/feeding_frenzy.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nRADIUS = 45\nHORIZON = 400\n\n\n@dataclass\nclass Fish:\n x: float\n y: float\n angle: float\n speed: float\n\n\nclass FeedingFrenzyEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = 0\n self.spawn_timer = 0.0\n self.multiplier = 1\n self.x, self.y, self.angle = 95.0, 50.0, 0.0\n self.pressed = self.darting = self.terminal = False\n self.fish: list[Fish] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap: bool) -> int:\n if self.darting:\n if self.pressed:\n self.angle = (self.angle - 0.1) % math.tau\n self.x += 3.9 * math.cos(self.angle)\n self.y += 3.9 * math.sin(self.angle)\n distance = math.hypot(self.x - 50, self.y - 50)\n if distance > RADIUS:\n self.darting = False\n self.x = 50 + (self.x - 50) * RADIUS / distance\n self.y = 50 + (self.y - 50) * RADIUS / distance\n else:\n radial = math.atan2(self.y - 50, self.x - 50) - 0.7 / RADIUS\n self.x = 50 + RADIUS * math.cos(radial)\n self.y = 50 + RADIUS * math.sin(radial)\n self.angle = (radial - math.pi / 2) % math.tau\n if tap:\n self.darting = True\n self.angle = (self.angle - 0.5) % math.tau\n self.multiplier = 1\n\n self.spawn_timer -= 1\n if self.spawn_timer < 0:\n angle = self.random.uniform(0, math.tau)\n radius = self.random.uniform(0, 36)\n self.fish.append(Fish(50 + radius * math.cos(angle), 50 + radius * math.sin(angle),\n angle + math.pi + self.random.uniform(-1, 1),\n self.random.uniform(0.03, 0.05)))\n self.spawn_timer = 10 * math.sqrt(len(self.fish))\n reward = 0\n remaining = []\n for fish in self.fish:\n speed = fish.speed * (2.5 if self.darting else 1)\n if math.hypot(fish.x - 50, fish.y - 50) > RADIUS * 1.1:\n speed *= 4\n fish.x += speed * math.cos(fish.angle)\n fish.y += speed * math.sin(fish.angle)\n if math.hypot(fish.x - self.x, fish.y - self.y) < 6:\n reward += self.multiplier\n self.multiplier += 1\n elif 0 <= fish.x < 100 and 0 <= fish.y < 100:\n remaining.append(fish)\n else:\n self.terminal = True\n self.fish = remaining\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row, col = int(self.y) // 10, int(self.x) // 10\n state[row, col, 0] = True\n state[row, col, 4] = self.darting\n for fish in self.fish:\n state[int(fish.y) // 10, int(fish.x) // 10, 1] = True\n for row in range(10):\n for col in range(10):\n state[row, col, 2] = abs(math.hypot(10 * col - 45, 10 * row - 45) - RADIUS) < 6\n x = min(99, max(0, self.x + 8 * math.cos(self.angle)))\n y = min(99, max(0, self.y + 8 * math.sin(self.angle)))\n state[int(y) // 10, int(x) // 10, 3] = True\n for row, value in enumerate((self.steps, self.multiplier, round(self.angle * 80))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 58, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/feeding_frenzy.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameFeedingFrenzy.c"} +{"name": "kangaroo", "split": "train", "game": "kangaroo", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Kangaroo as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves the Atari 2600 port's three-screen rescue round. Mother Kangaroo crosses\nbranches, climbs each screen's ladder layout, and uses a prepared super leap to cross broken-log\ngaps before reaching Baby Kangaroo. The three screens repeat for three increasingly fast rounds.\nThe 2,000-point bonus timer falls by 20 per action; its remainder pays on rescue, while expiration\ncosts one of three lives.\n\nFour monkeys chase Mother and generate eight finite apple attacks per screen. Low throws can be\njumped, high throws ducked, middle throws punched or jumped, and falling apples avoided or\npunched. Action 5 punches adjacent monkeys for 200 points, thrown apples for 100, and falling\napples for 200. Three strawberries begin each screen at 100 points. A bell can be rung up to three\ntimes; only fruit already collected is restored at the next value—tomato 200, cherries 400, then\npineapple 800—while uncollected fruit remains. Every 20,000 points awards a bonus life.\n\nACTION MAPPING\n0: hold position\n1: hop left\n2: climb, jump, or prepare super leap\n3: hop right\n4: climb down or duck\n5: punch\n\nINPUT CHANNEL TABLE\n0: Mother Kangaroo\n1: monkeys and apples\n2: Baby, fruit, bell, and high/middle attack marker\n3: platforms, ladders, monkeys, and middle attack marker\n4: previous Mother/apple positions and falling attack marker\n5: current-screen reward identities, spawned apples, fruit tiers, round, screen, lives, exact timer, bell rings, leap, and duck state\n\nSCORING, TERMINATION, AND HORIZON\nEach screen contains three fruit identities across four values, worth\n`3 × (100 + 200 + 400 + 800) = 4,500`; four monkeys worth 800; and an attack pattern with two\nfalling and six thrown apples worth `2 × 200 + 6 × 100 = 1,000`. Adding the maximum 2,000 rescue\ntimer gives 8,300 per screen. Across three screens and three rounds,\n`score_cap = 9 × 8,300 = 74,700`. Normalization is\n`min(max(raw_score, 0), 74_700) / 74_700`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/kangaroo.py`):\n```python\nimport numpy as np\n\n\nFRUIT_VALUES = (100, 200, 400, 800)\nFRUIT_POSITIONS = ((7, 2), (4, 5), (1, 7))\n\n\nclass KangarooEnvironment:\n \"\"\"Three-screen rescue cycle with ladders, leaps, bells, and boxing.\"\"\"\n\n score_cap = 74_700.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 1_800):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.round = 0\n self.screen = 0\n self.lives = 3\n self.score = 0.0\n self.next_bonus_life = 20_000.0\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self.claimed_monkeys: set[tuple[int, int, int]] = set()\n self.claimed_apples: set[tuple[int, int, int]] = set()\n self.claimed_fruit: set[tuple[int, int, int, int]] = set()\n self._start_screen()\n\n def _start_screen(self) -> None:\n self.player = [8, 0]\n self.previous_player = self.player.copy()\n self.baby = [1, 9]\n self.ladders = ({2, 6, 8}, {1, 5, 8}, {3, 6, 9})[self.screen]\n self.gaps = set()\n if self.screen == 1:\n self.gaps = {(8, 3), (8, 4), (5, 6), (5, 7)}\n elif self.screen == 2:\n self.gaps = {(8, 4), (5, 2), (5, 3)}\n monkey_positions = ((8, 8), (5, 3), (2, 8), (5, 8))\n self.monkeys = {\n index: list(position)\n for index, position in enumerate(monkey_positions)\n if (self.round, self.screen, index) not in self.claimed_monkeys\n }\n self.monkey_directions = {index: -1 for index in self.monkeys}\n self.apples: list[dict[str, object]] = []\n self.spawned_apples: set[int] = set()\n self.fruit_tiers = {index: 0 for index in range(3)}\n self.available_fruit = {\n index for index in range(3) if (self.round, self.screen, 0, index) not in self.claimed_fruit\n }\n self.collected_for_bell: set[int] = set()\n self.bell_rings = 0\n self.bell = [1, 5]\n self.timer = 2_000\n self.screen_steps = 0\n self.jump_timer = 0\n self.ducking = False\n self.previous_apples: list[list[int]] = []\n\n @property\n def fruit_tier(self) -> int:\n return max(self.fruit_tiers.values())\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n lives_before = self.lives\n screen_before = (self.round, self.screen)\n self.ducking = action == 4\n self._move_player(action)\n if self.lives != lives_before or self.terminal:\n return self._finish_step(0.0, consume_timer=False)\n reward = self._collect_fruit_and_ring_bell()\n if action == 5:\n reward += self._punch()\n self._spawn_apples()\n self._move_monkeys()\n self._move_apples()\n self._resolve_contacts(action)\n if self.lives != lives_before or self.terminal:\n return self._finish_step(reward, consume_timer=False)\n if self.player == self.baby:\n reward += self._rescue_baby()\n transitioned = (self.round, self.screen) != screen_before\n return self._finish_step(reward, consume_timer=not transitioned)\n\n def _finish_step(self, reward: float, consume_timer: bool = True) -> tuple[float, bool]:\n self.score += reward\n while self.score >= self.next_bonus_life:\n self.lives = min(20, self.lives + 1)\n self.next_bonus_life += 20_000.0\n if consume_timer:\n self.timer -= 20\n self.screen_steps += 1\n self.jump_timer = max(0, self.jump_timer - 1)\n if self.timer <= 0:\n self._lose_life()\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_player(self, action: int) -> None:\n if action in (1, 3):\n delta = -1 if action == 1 else 1\n distance = 2 if self.jump_timer > 0 else 1\n target_column = int(np.clip(self.player[1] + delta * distance, 0, 9))\n crossed = range(min(self.player[1], target_column), max(self.player[1], target_column) + 1)\n if self.player[0] in (5, 8) and any((self.player[0], column) in self.gaps for column in crossed):\n if self.jump_timer == 0:\n self._lose_life()\n return\n self.player[1] = target_column\n elif action == 2:\n if self.player[1] in self.ladders and self.player[0] > 1:\n self.player[0] -= 1\n else:\n self.jump_timer = 2\n self.player[0] = max(0, self.player[0] - 1)\n elif action == 4 and self.player[1] in self.ladders and self.player[0] < 8:\n self.player[0] += 1\n elif self.jump_timer == 0 and self.player[0] not in (1, 2, 5, 8):\n self.player[0] = min(8, self.player[0] + 1)\n\n def _collect_fruit_and_ring_bell(self) -> float:\n reward = 0.0\n for index in list(self.available_fruit):\n if self.player == list(FRUIT_POSITIONS[index]):\n tier = self.fruit_tiers[index]\n identity = (self.round, self.screen, tier, index)\n self.available_fruit.remove(index)\n self.collected_for_bell.add(index)\n if identity not in self.claimed_fruit:\n self.claimed_fruit.add(identity)\n reward += float(FRUIT_VALUES[tier])\n if self.player == self.bell and self.collected_for_bell and self.bell_rings < 3:\n self.bell_rings += 1\n for index in self.collected_for_bell:\n self.fruit_tiers[index] = min(3, self.fruit_tiers[index] + 1)\n identity = (self.round, self.screen, self.fruit_tiers[index], index)\n if identity not in self.claimed_fruit:\n self.available_fruit.add(index)\n self.collected_for_bell = set()\n return reward\n\n def _punch(self) -> float:\n reward = 0.0\n for index, monkey in list(self.monkeys.items()):\n if abs(monkey[0] - self.player[0]) + abs(monkey[1] - self.player[1]) <= 1:\n del self.monkeys[index]\n identity = (self.round, self.screen, index)\n if identity not in self.claimed_monkeys:\n self.claimed_monkeys.add(identity)\n reward += 200.0\n return reward\n for apple in list(self.apples):\n position = apple[\"position\"]\n if abs(position[0] - self.player[0]) + abs(position[1] - self.player[1]) <= 1:\n self.apples.remove(apple)\n identity = (self.round, self.screen, int(apple[\"identity\"]))\n if identity not in self.claimed_apples:\n self.claimed_apples.add(identity)\n reward += 200.0 if apple[\"kind\"] == \"falling\" else 100.0\n return reward\n return reward\n\n def _spawn_apples(self) -> None:\n interval = max(5, 10 - self.round)\n if self.screen_steps % interval or len(self.spawned_apples) >= 8 or not self.monkeys:\n return\n identity = len(self.spawned_apples)\n self.spawned_apples.add(identity)\n monkey = self.monkeys[min(self.monkeys)]\n kinds = (\"low\", \"high\", \"middle\", \"falling\")\n kind = kinds[(identity + self.round) % len(kinds)]\n position = [max(0, monkey[0] - 2), monkey[1]] if kind == \"falling\" else monkey.copy()\n self.apples.append(\n {\n \"identity\": identity,\n \"kind\": kind,\n \"position\": position,\n \"direction\": int(np.sign(self.player[1] - monkey[1])) or -1,\n }\n )\n\n def _move_monkeys(self) -> None:\n if self.screen_steps % max(2, 4 - self.round // 2):\n return\n for index, monkey in self.monkeys.items():\n direction = int(np.sign(self.player[1] - monkey[1]))\n monkey[1] = int(np.clip(monkey[1] + direction, 0, 9))\n self.monkey_directions[index] = direction\n\n def _move_apples(self) -> None:\n self.previous_apples = [list(apple[\"position\"]) for apple in self.apples]\n for apple in list(self.apples):\n if apple[\"kind\"] == \"falling\":\n apple[\"position\"][0] += 1\n else:\n apple[\"position\"][1] += int(apple[\"direction\"])\n position = apple[\"position\"]\n if not (0 <= position[0] < 10 and 0 <= position[1] < 10):\n self.apples.remove(apple)\n\n def _resolve_contacts(self, action: int) -> None:\n if any(monkey == self.player for monkey in self.monkeys.values()):\n self._lose_life()\n return\n for apple in self.apples:\n if apple[\"position\"] != self.player:\n continue\n avoided = (apple[\"kind\"] == \"low\" and action == 2) or (apple[\"kind\"] == \"high\" and self.ducking)\n if not avoided:\n self._lose_life()\n return\n\n def _rescue_baby(self) -> float:\n reward = float(self.timer)\n self.screen += 1\n if self.screen >= 3:\n self.screen = 0\n self.round += 1\n if self.round >= 3:\n self.terminal = True\n else:\n self._start_screen()\n return reward\n\n def _lose_life(self) -> None:\n self.lives -= 1\n if self.lives <= 0:\n self.terminal = True\n else:\n self._start_screen()\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n for monkey in self.monkeys.values():\n state[*monkey, 1] = True\n state[*monkey, 3] = True\n for apple in self.apples:\n state[*apple[\"position\"], 1] = True\n if apple[\"kind\"] in (\"high\", \"middle\"):\n state[*apple[\"position\"], 2] = True\n if apple[\"kind\"] == \"middle\":\n state[*apple[\"position\"], 3] = True\n if apple[\"kind\"] == \"falling\":\n state[*apple[\"position\"], 4] = True\n state[*self.baby, 2] = True\n for index in self.available_fruit:\n state[*FRUIT_POSITIONS[index], 2] = True\n state[*self.bell, 2] = True\n for row in (2, 5, 8):\n for column in range(10):\n if (row, column) not in self.gaps:\n state[row, column, 3] = True\n for column in self.ladders:\n state[1:9, column, 3] = True\n state[*self.previous_player, 4] = True\n for apple in self.previous_apples:\n state[*apple, 4] = True\n current_claims = []\n current_claims.extend(\n (self.round, self.screen, index) in self.claimed_monkeys for index in range(4)\n )\n current_claims.extend(\n (self.round, self.screen, index) in self.claimed_apples for index in range(8)\n )\n current_claims.extend(\n (self.round, self.screen, tier, index) in self.claimed_fruit\n for tier in range(4)\n for index in range(3)\n )\n for index, claimed in enumerate(current_claims):\n state[index // 10, index % 10, 5] = claimed\n for index in self.spawned_apples:\n state[3, index, 5] = True\n for index, tier in self.fruit_tiers.items():\n state[4, index * 2, 5] = bool(tier & 1)\n state[4, index * 2 + 1, 5] = bool(tier & 2)\n state[9, self.round, 5] = True\n state[9, 3 + self.screen, 5] = True\n for bit in range(5):\n state[8, bit, 5] = bool(self.lives & (1 << bit))\n for bit in range(7):\n state[7, bit, 5] = bool((self.timer // 20) & (1 << bit))\n state[6, 4 + self.bell_rings, 5] = True\n state[5, : self.jump_timer, 5] = True\n state[5, 2, 5] = self.ducking\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 59, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/kangaroo.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "tilted", "split": "train", "game": "tilted", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Tilted as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe runner moves sideways automatically. Press action 5 to jump,\nand release with any other action before pressing again. Repeated\nmidair jumps reverse direction and lose power. Holding action 5\nreduces gravity. Land on platforms to climb and avoid bouncing balls.\nA ball hit destroys the platform under a supported runner or knocks\nan airborne runner downward. Falling below the screen ends the episode.\n\nINPUT CHANNEL TABLE\nThe six channels show the runner, platforms, current support, balls,\nside walls, and counters. Counters show elapsed actions, previous\naction, heading, jump count, and quantized vertical velocity.\nDifficulty is fixed, and geometric collision checks approximate\nthe original sprite overlaps. Height determines both scroll speed\nand raw reward per frame. Each action advances up to four frames\nover 400 actions. Clip the total to [0, 1000] and divide by 1000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/tilted.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, hypot, pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Bar:\n x: float\n y: float\n angle: float\n length: float\n\n def coordinates(self, x, y):\n dx, dy = x - self.x, y - self.y\n return dx * cos(self.angle) + dy * sin(self.angle), dy * cos(self.angle) - dx * sin(self.angle)\n\n\n@dataclass\nclass Ball:\n x: float\n y: float\n vx: float\n vy: float = 0\n age: int = 0\n\n\nclass TiltedEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.bar = Bar(50, 0, 0, 90)\n self.bars = [self.bar]\n self.balls = []\n self.bar_distance, self.bar_count, self.ball_timer = 10, 0, 60\n self.x, self.y, self.vx, self.vy = 50., -6., 1., 0.\n self.jumps = self.action = self.steps = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n pressed = self.action == 5 and previous != 5\n self.steps += 1\n reward = 0.\n for frame in range(4):\n reward += self._advance(pressed and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _advance(self, pressed):\n scroll = 0.02 + max(0, 60 - self.y) * 0.1\n if self.bar is not None:\n bar = self.bar\n distance = hypot(self.x - bar.x, self.y + 5 - bar.y)\n distance = (-distance if self.x < bar.x else distance) + self.vx / 2\n self.x = bar.x + cos(bar.angle) * distance\n self.y = bar.y + sin(bar.angle) * distance - 5\n if abs(distance) > bar.length / 2 + 6:\n self.bar = None\n self.jumps = 0\n if pressed:\n self.bar = None\n self.vy, self.jumps = -2, 1\n self.y -= 2\n else:\n if pressed:\n if self.jumps:\n self.vx *= -1\n self.jumps = max(1, self.jumps)\n self.vy = -2 / self.jumps ** 2\n self.jumps += 1\n self.vy += 0.05 if self.action == 5 else 0.1\n self.x += self.vx / 2\n self.y += scroll + self.vy / 2\n if (self.x < 8 and self.vx < 0) or (self.x > 92 and self.vx > 0):\n self.vx *= -1\n if self.y > 99:\n self.terminal = True\n return scroll\n self._advance_balls(scroll)\n for bar in self.bars:\n bar.y += scroll\n along, normal = bar.coordinates(self.x, self.y + 3)\n if self.bar is None and abs(along) <= bar.length / 2 + 2 and abs(normal) <= 4:\n if self.vy <= 0:\n self.vy *= -0.5\n self.y += 3 * self.vy\n else:\n self.bar = bar\n for ball in self.balls:\n along, normal = bar.coordinates(ball.x, ball.y)\n if abs(along) <= bar.length / 2 + 3 and abs(normal) <= 4:\n tangent_x, tangent_y = cos(bar.angle), sin(bar.angle)\n projection = ball.vx * tangent_x + ball.vy * tangent_y\n ball.vx = 2 * projection * tangent_x - ball.vx\n ball.vy = 2 * projection * tangent_y - ball.vy\n ball.x += ball.vx\n ball.y += ball.vy\n ball.age += 30\n break\n self.bars = [bar for bar in self.bars if bar.y <= 120]\n self.bar_distance -= scroll\n while self.bar_distance < 0:\n self._spawn_bar()\n return scroll\n\n def _advance_balls(self, scroll):\n self.ball_timer -= 1\n if self.ball_timer < 0:\n speed = self.random.choice((-1, 1)) * self.random.uniform(0.5, 1)\n self.balls.append(Ball(self.random.uniform(20, 80), -40, speed))\n self.ball_timer += self.random.uniform(60, 80)\n for ball in self.balls:\n ball.vx *= 0.995\n ball.vy = (ball.vy + 0.05) * 0.995\n ball.x += ball.vx / 2\n ball.y += scroll + ball.vy / 2\n if (ball.x < 8 and ball.vx < 0) or (ball.x > 92 and ball.vx > 0):\n ball.vx *= -1\n ball.age += 1\n if hypot(ball.x - self.x, ball.y - self.y) <= 5:\n if self.bar is not None:\n self.bar.y = 999\n self.bar = None\n self.vy += 1\n else:\n self.vy += 4\n ball.age = 999\n for index, ball in enumerate(self.balls):\n for other in self.balls[index + 1:]:\n if ball.age <= 500 and other.age <= 500 and hypot(ball.x - other.x, ball.y - other.y) <= 5:\n ball.age = other.age = 999\n self.balls = [ball for ball in self.balls if ball.age <= 500 and ball.y <= 103]\n\n def _spawn_bar(self):\n side = self.bar_count % 2\n length = self.random.uniform(15, 22)\n x = (50 + self.random.choice((-1, 1)) * self.random.uniform(25, 50 - length / 2)\n if side else self.random.uniform(35, 65))\n angle = 0. if self.random.random() < (0.2 if side else 0.7) else (\n self.random.choice((-1, 1)) * self.random.uniform(0, pi / 5)\n )\n y = -9 - self.bar_distance\n self.bars.append(Bar(x, y, angle, length))\n if side:\n self.bars.append(Bar(100 - x, y, -angle, length))\n self.bar_distance += self.random.uniform(15, 20)\n self.bar_count += 1\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(np.clip(self.y // 10, 0, 9)), int(np.clip(self.x // 10, 0, 9)), 0] = True\n for bar in self.bars:\n for offset in np.linspace(-bar.length / 2, bar.length / 2, int(bar.length / 3) + 2):\n x = bar.x + offset * cos(bar.angle)\n y = bar.y + offset * sin(bar.angle)\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), 2 if bar is self.bar else 1] = True\n for ball in self.balls:\n if 0 <= ball.y < 100:\n state[int(ball.y // 10), int(ball.x // 10), 3] = True\n state[:, (0, 9), 4] = True\n gauges = (self.steps, self.action, self.vx > 0, self.jumps, round((self.vy + 8) * 16))\n for row, value in enumerate(gauges):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 60, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tilted.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/tilted/main.js"} +{"name": "ant_lion", "split": "train", "game": "ant_lion", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Ant Lion as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe ant spirals inward toward the pit. Holding action 5 turns it\nclockwise, and releasing with actions 0–4 turns it counterclockwise.\nAngular momentum carries over between inputs. Catch an inward-drifting\nbar to climb outward along it and score. The ant detaches at the outer\nend, while the bar continues toward the center. Each catch raises the\nmultiplier by two before paying it. Expiring bars reduce the multiplier.\n\nINPUT CHANNEL TABLE\nThe grid adaptation uses 32 angular positions, integer radial motion,\nand a one-sector catch tolerance. Channels show the ant, pit, available\nbars, attached bar, a reserved channel, and gauges. The gauges include\nradius, angle, angular velocity, ride offset, score multiplier, clock,\nspawn countdown, and last action. Offscreen ant positions are clamped to\nthe observation edge.\n\nSCORING, TERMINATION, AND HORIZON\nThe episode ends in the pit or after 400 steps. At most one catch\nscores per step, and the multiplier increases by at most two per\ncatch. The sum of the first 400 positive even numbers gives a\nconservative cap of 160,400. Clip to [0, 160400] and divide by 160400.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/ant_lion.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, pi, sin\n\nimport numpy as np\n\n\nHORIZON = 400\nANGLES = 32\n\n\n@dataclass\nclass EscapeBar:\n angle: int\n inner: int\n outer: int\n speed: int = 2\n\n\nclass AntLionEnvironment:\n score_cap = HORIZON * (HORIZON + 1)\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.angle, self.radius = 8, 32\n self.steps = self.last_action = self.velocity = self.multiplier = 0\n self.spawn_in = 1\n self.bars: list[EscapeBar] = []\n self.attached: EscapeBar | None = None\n self.offset = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.steps += 1\n if self.attached is None:\n self.velocity = max(-2, min(2, self.velocity + (1 if action == 5 else -1)))\n self.angle = (self.angle + self.velocity) % ANGLES\n self.radius -= 2 if self.radius > 40 else 1\n if self.radius <= 3:\n self.terminal = True\n return 0.0, True\n self.spawn_in -= 1\n if not self.spawn_in:\n self.bars.append(EscapeBar(int(self.random.integers(ANGLES)), 42,\n 42 + int(self.random.integers(8, 17))))\n self.spawn_in = max(8, int(self.random.integers(14, 20)) - self.steps // 80)\n remaining = []\n for bar in self.bars:\n if self.steps % 4 == 0:\n bar.angle = (bar.angle - 1) % ANGLES\n movement = bar.speed + int(bar.inner > 40)\n bar.inner = max(0, bar.inner - movement)\n bar.outer -= movement\n if bar.outer >= 0:\n remaining.append(bar)\n else:\n self.multiplier = max(1, self.multiplier - 1) if self.multiplier else 0\n if self.attached is bar:\n self.attached = None\n self.bars = remaining\n if self.attached is not None:\n bar = self.attached\n self.offset += 3\n if self.steps % 5 == 0:\n bar.speed = min(3, bar.speed + 1)\n self.angle, self.radius = bar.angle, bar.inner + self.offset\n if self.radius > bar.outer + 3:\n self.attached = None\n reward = 0\n if self.attached is None and self.radius > 3:\n for bar in self.bars:\n separation = (self.angle - bar.angle) % ANGLES\n if min(separation, ANGLES - separation) <= 1 and bar.inner <= self.radius <= bar.outer:\n self.attached = bar\n self.offset = self.radius - bar.inner\n self.multiplier += 2\n reward = self.multiplier\n break\n self.terminal = self.radius <= 3 or self.steps >= self.horizon\n return float(reward), self.terminal\n\n @staticmethod\n def _cell(angle: int, radius: int) -> tuple[int, int]:\n radians = angle * 2 * pi / ANGLES\n return round(4.5 + sin(radians) * radius / 9), round(4.5 + cos(radians) * radius / 9)\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row, column = self._cell(self.angle, self.radius)\n state[max(0, min(9, row)), max(0, min(9, column)), 0] = True\n state[4:6, 4:6, 1] = True\n for bar in self.bars:\n for radius in range(bar.inner, bar.outer + 1):\n row, column = self._cell(bar.angle, radius)\n if 0 <= row < 10 and 0 <= column < 10:\n state[row, column, 3 if bar is self.attached else 2] = True\n values = (self.angle, self.radius, self.velocity + 2, self.offset,\n self.multiplier, self.steps, self.spawn_in, self.last_action)\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 61, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/ant_lion.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameAntLion.c"} +{"name": "tr_beam", "split": "train", "game": "tr_beam", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Tr Beam as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe UFO sweeps across the top. Hold action 5 to extend the tractor\nbeam and lift balls. Release with any other action to shorten it.\nEach new press resets the multiplier to one. Catching a normal ball\npays the multiplier and increases it by one. Red balls end the run\non contact. Let red balls leave the beam near a side to clear their\nred status. Dropped balls can turn red just below the UFO.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the UFO, beam, normal balls, red balls,\nballs caught in the beam, and counters. The counters encode elapsed\nactions, effective action, beam length, multiplier, UFO phase, and\nthe countdown in spawns to the next red ball. The port fixes difficulty\nand approximates sprite and ring collisions geometrically. Each action\nadvances up to four frames over 400 actions. Clip the episode score to\n[0, 500] and divide by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/tr_beam.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, hypot, pi, sin, sqrt\n\nimport numpy as np\n\n\n@dataclass\nclass Ball:\n x: float\n y: float\n radius: float\n red: bool = False\n vx: float = 0.\n vy: float = 0.\n beamed: bool = False\n\n\nclass TrBeamEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.phase = -pi * 0.3\n self.x = 50 + sin(self.phase) * 40\n self.length = 0.\n self.balls = []\n self.spawn_timer = 0.\n self.until_red = 9\n self.multiplier = 1\n self.action = self.steps = self.frames = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n if self.action == 5 and previous != 5:\n self.multiplier = 1\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n self.phase += 0.03\n self.x = 50 + sin(self.phase) * 40\n self.length = min(82, self.length + 2) if self.action == 5 else self.length * 0.8\n beams = self._beams()\n self.frames += 1\n self.spawn_timer -= 1\n if self.spawn_timer < 0:\n self.until_red -= 1\n red = self.until_red < 0\n if red:\n self.until_red = int(self.random.integers(9, 12))\n radius = self.random.uniform(6, 12)\n self.balls.append(Ball(self.random.uniform(10, 90), 105 + radius, radius, red))\n self.spawn_timer = self.random.uniform(20, 25)\n reward = 0\n remaining = []\n for ball in self.balls:\n self._move(ball)\n dx, dy = self.x - ball.x, 9 - ball.y\n distance = hypot(dx, dy)\n if abs(distance - ball.radius) <= 4:\n if ball.red:\n self.terminal = True\n break\n reward += self.multiplier\n self.multiplier += 1\n continue\n if any(_crosses_ring(ball, *beam) for beam in beams):\n strength = 1 / (max(distance, 1e-9) * sqrt(ball.radius))\n ball.vx += dx * (strength + 0.01)\n ball.vy += dy * strength\n ball.beamed = True\n elif ball.beamed:\n ball.vy *= 0.1\n ball.vx *= 5\n ball.beamed = False\n if not ball.beamed:\n if ball.red and (ball.x < ball.radius or ball.x > 99 - ball.radius):\n ball.red = False\n elif 10 <= ball.x < 90 and 12 <= ball.y - ball.radius < 17 and ball.vy > 0:\n ball.red = True\n if -20 <= ball.x <= 120:\n remaining.append(ball)\n if not self.terminal:\n self.balls = remaining\n return reward\n\n def _move(self, ball):\n if ball.y > 99:\n ball.vy -= 1\n drag = 0.5\n elif ball.x < 0 or ball.x > 99:\n drag = 0.1\n else:\n drag = 0.9\n if ball.red:\n ball.vy *= 0.9\n ball.vx *= drag\n ball.vy = ball.vy * drag + 0.1\n ball.x += ball.vx\n ball.y += ball.vy\n for other in self.balls:\n if other is ball:\n continue\n dx, dy = ball.x - other.x, ball.y - other.y\n distance = hypot(dx, dy)\n overlap = ball.radius + other.radius - distance\n if overlap > 0 and distance > 0:\n scale = overlap / (distance * sqrt(ball.radius))\n ball.vx += dx * scale\n ball.vy += dy * scale\n\n def _beams(self):\n if self.length <= 1:\n return []\n angle = (self.frames % 10) * pi / 40\n offsets = [cos(angle + index * pi / 4) for index in range(4)]\n return [(self.x + 4 * offset, 14, self.x + 9 * offset, 14 + self.length)\n for offset in offsets]\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[0, int(self.x // 10), 0] = True\n for x1, y1, x2, y2 in self._beams():\n for x, y in zip(np.linspace(x1, x2, 33), np.linspace(y1, y2, 33), strict=True):\n state[int(y // 10), int(x // 10), 1] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for ball in self.balls:\n ring = abs(np.hypot(cols - ball.x, rows - ball.y) - ball.radius) <= 6\n state[:, :, 3 if ball.red else 2] |= ring\n if ball.beamed:\n state[:, :, 4] |= ring\n values = (self.steps, self.action, round(self.length * 4), self.multiplier,\n round((self.phase % (2 * pi)) * 64), self.until_red + 1)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n\ndef _crosses_ring(ball, x1, y1, x2, y2):\n dx, dy = x2 - x1, y2 - y1\n fraction = ((ball.x - x1) * dx + (ball.y - y1) * dy) / (dx * dx + dy * dy)\n fraction = min(1, max(0, fraction))\n near = hypot(ball.x - x1 - fraction * dx, ball.y - y1 - fraction * dy)\n far = max(hypot(ball.x - x1, ball.y - y1), hypot(ball.x - x2, ball.y - y2))\n return near <= ball.radius + 2 and far >= ball.radius - 2\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 62, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tr_beam.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/trbeam/main.js"} +{"name": "golfme", "split": "train", "game": "golfme", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Golfme as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to rotate the aim upward. Release with actions\n0–4 to jump. Land on the scrolling platforms and time jumps\nto clear the gaps. Falling below the screen or scrolling off\nthe left edge ends the run. Score is the distance scrolled.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, platforms, gaps, aim,\nprojected jump position, and gauges. Each action advances four\nframes at fixed difficulty. The conversion resolves platform\ncontact after movement during descent.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action task clips raw scores to [0, 2400] and divides\nby 2400. The cap is a normalization parameter.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/golfme.py`):\n```python\nimport math\n\nimport numpy as np\n\n\nclass GolfmeEnvironment:\n score_cap = 2400\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x, self.y = 50.0, 85.0\n self.vx = self.vy = self.angle = 0.0\n self.platform_end = self.gap = 0.0\n self.steps = 0\n self.pressed = self.airborne = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n released = self.pressed and not pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0.0\n for frame in range(4):\n reward += self._advance(released and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _advance(self, released: bool) -> float:\n next_start = self.platform_end + self.gap\n if next_start < 0:\n self.platform_end = 200\n self.gap = self.random.uniform(50, 150)\n next_start = self.platform_end + self.gap\n if self.x < 0 or self.y > 99:\n self.terminal = True\n return 0.0\n if self.airborne:\n self.x += self.vx\n self.y += self.vy\n self.vy += 0.1\n on_platform = self.x - 4.5 < self.platform_end or self.x + 4.5 > next_start\n if self.vy > 0 and 85.5 < self.y < 103.5 and on_platform:\n self.airborne = False\n self.angle = 0\n self.y = 85\n else:\n if self.pressed:\n self.angle -= 0.05\n if released:\n self.airborne = True\n self.vx = 4 * math.cos(self.angle)\n self.vy = 4 * math.sin(self.angle)\n scroll = 1 + min(99, max(0, self.x - 50)) * 0.1\n self.x -= scroll\n self.platform_end -= scroll\n return scroll\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row = min(9, max(0, int(self.y) // 10))\n col = min(9, max(0, int(self.x) // 20))\n state[row, col, 0] = True\n next_start = self.platform_end + self.gap\n for column in range(10):\n left, right = 20 * column, 20 * (column + 1)\n state[9, column, 1] = left < self.platform_end or right > next_start\n state[9, column, 2] = left < next_start and right > self.platform_end\n if not self.airborne:\n for distance in range(5, 25, 5):\n x = self.x + distance * math.cos(self.angle)\n y = self.y + distance * math.sin(self.angle)\n if 0 <= x < 200 and 0 <= y < 100:\n state[int(y) // 10, int(x) // 20, 3] = True\n else:\n x = self.x + 4 * self.vx\n y = self.y + 4 * self.vy\n if 0 <= x < 200 and 0 <= y < 100:\n state[int(y) // 10, int(x) // 20, 4] = True\n for row, value in enumerate((self.steps, round((-self.angle % math.tau) * 70))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.airborne\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 63, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/golfme.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/golfme/main.js"} +{"name": "hexmin", "split": "train", "game": "hexmin", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Hexmin as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nPackets advance toward the center on six radial lanes. Rotate the two\ngates so a packet is caught at depth four. A packet that reaches depth\nfive ends the run. Each catch pays the current multiplier and raises it\nby six. Rotating reduces the multiplier to 90% rounded up minus one,\nwith a floor of one. This rewards waiting when the gates are aligned.\n\nINPUT CHANNEL TABLE\nAction 1 rotates counterclockwise. Actions 3 and 5 rotate clockwise.\nActions 0, 2, and 4 wait. Held rotation repeats every two steps.\nThe six binary channels mark the center, incoming packet segments,\ncatch-ready cells, gates, a reserved channel, and gauges. The gauges\nencode orientation, clock, pulse and spawn countdowns, button repeat,\nmultiplier, and previous action.\n\nSCORING, TERMINATION, AND HORIZON\nThis adaptation uses discrete pulses and accelerates them from four\nsteps to two over the episode. Seeded spawn countdowns shorten as\nthe clock advances. At most one packet spawns per pulse, so a 300-step\nepisode can contain at most 150 packets. Even with no rotation penalty,\nthe sum of their catch rewards is at most 67,200. A catch removes its\npacket permanently. Normalize by clipping to [0, 67200] and dividing by 67200.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/hexmin.py`):\n```python\nimport numpy as np\n\n\nHORIZON = 300\nMIN_PULSE_INTERVAL = 2\nMAX_SPAWNS = (HORIZON + MIN_PULSE_INTERVAL - 1) // MIN_PULSE_INTERVAL\nRAYS = (\n ((4, 6), (4, 7), (4, 8), (4, 9)),\n ((6, 5), (7, 6), (8, 7), (9, 8)),\n ((6, 3), (7, 2), (8, 1), (9, 0)),\n ((4, 3), (4, 2), (4, 1), (4, 0)),\n ((3, 3), (2, 2), (1, 1), (0, 0)),\n ((3, 5), (2, 6), (1, 7), (0, 8)),\n)\n\n\nclass HexminEnvironment:\n score_cap = MAX_SPAWNS * (1 + 3 * (MAX_SPAWNS - 1))\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.lanes = [0] * len(RAYS)\n self.orientation = self.steps = self.last_action = self.repeat = self.spawn_wait = 0\n self.pulse = 1\n self.multiplier = 1\n self.terminal = False\n\n @property\n def gates(self) -> tuple[int, int]:\n return self.orientation, (self.orientation + 2) % len(RAYS)\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n self.steps += 1\n self.repeat = max(0, self.repeat - 1)\n if action in (1, 3, 5) and (action != self.last_action or self.repeat == 0):\n self.orientation = (self.orientation + (-1 if action == 1 else 1)) % len(RAYS)\n self.multiplier = max(1, (9 * self.multiplier + 9) // 10 - 1)\n self.repeat = 2\n self.last_action = action\n\n self.pulse -= 1\n if self.pulse == 0:\n self.lanes = [age + 1 if age else 0 for age in self.lanes]\n if max(self.lanes) > 4:\n self.terminal = True\n return 0.0, True\n if self.spawn_wait == 0:\n start = int(self.random.integers(len(RAYS)))\n for offset in range(len(RAYS)):\n lane = (start + offset) % len(RAYS)\n if self.lanes[lane] == 0:\n self.lanes[lane] = 1\n break\n self.spawn_wait = int(self.random.integers(max(1, 4 - self.steps // 100)))\n else:\n self.spawn_wait -= 1\n self.pulse = max(MIN_PULSE_INTERVAL, 4 - self.steps // 100)\n\n reward = 0\n for lane in range(len(RAYS)):\n if self.lanes[lane] == 4 and lane in self.gates:\n reward += self.multiplier\n self.multiplier += 6\n self.lanes[lane] = 0\n self.terminal = self.steps >= self.horizon\n return float(reward), self.terminal\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[4, 4, 0] = True\n for lane, cells in enumerate(RAYS):\n row, column = cells[0]\n state[row, column, 3] = lane in self.gates\n for row, column in cells[4 - min(self.lanes[lane], 4):]:\n state[row, column, 1] = True\n if self.lanes[lane] >= 4:\n row, column = cells[0]\n state[row, column, 2] = True\n gauges = (self.orientation, self.steps, self.pulse, self.spawn_wait,\n self.repeat, self.multiplier, self.last_action)\n for row, value in enumerate(gauges):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 64, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/hexmin.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameHexmin.c"} +{"name": "catapult", "split": "train", "game": "catapult", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Catapult as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nRelease the button to let the ball slide and build launch power.\nTap action 5 once the ball is loaded to launch upward and right.\nHolding 5 tilts the bars and reverses sliding. Release with\nactions 0–4 before the next tap.\n\nPassing bars in flight scores increasing bonuses and raises the\nlanding payout. Landing on a bar earns that payout. The payout\ndecays while the ball rests on a bar. Sliding too far drops the\nball, and falling out of view ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the ball, passed bars, upcoming bars,\nsupport status, control flags, and gauges. The conversion uses\nfixed difficulty and geometric collision checks against the\ntilted bars. Each action advances four frames.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 500] and divide by the fixed cap of 500.\n\nAcross 100 seeds without sticky actions, idle averaged 4 raw\npoints and random hold and release averaged 0.28. A policy that\ntapped when the exact bar position reached 10 averaged 150.13\nand reached 519 before clipping.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/catapult.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\nDIAGONAL = math.sqrt(0.5)\n\n\n@dataclass\nclass Bar:\n x: float\n y: float\n width: float\n passed: bool = False\n\n\nclass CatapultEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.passed_count = 0\n self.pressed = self.terminal = False\n self.x, self.y, self.vx, self.vy = 200.0, 60.0, 0.0, 0.0\n self.bar_position, self.base_score, self.next_bar = -10.0, 1.0, 50.0\n self.support: Bar | None = Bar(200, 60, 20, passed=True)\n self.bars = [self.support]\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(FRAMES_PER_STEP):\n reward += self._advance_frame(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self, tap: bool) -> int:\n scroll = 0.05 + max(0, self.x - 30) * 0.1\n slope = 1 if self.pressed else -1\n self.x -= scroll\n if self.support is not None:\n self.bar_position -= slope * 0.2\n self.base_score = max(1, self.base_score - 0.5)\n self.x = self.support.x + slope * (4 - self.bar_position) * DIAGONAL\n self.y = self.support.y - (4 + self.bar_position) * DIAGONAL\n if abs(self.bar_position) > self.support.width * 0.65:\n self.support = None\n self.vx = self.vy = 0.0\n elif tap and self.bar_position > 0:\n self.vx = math.sqrt(self.bar_position) * DIAGONAL\n self.vy = -self.vx\n self.x += self.vx\n self.y += self.vy\n self.support = None\n self.passed_count = 0\n else:\n self.x += self.vx\n self.y += self.vy\n self.vy += 0.1\n self.base_score += self.vx * 0.1\n\n if self.y > 99 or self.x < 0:\n self.terminal = True\n return 0\n\n reward = 0\n for bar in self.bars:\n bar.x -= scroll\n dx, dy = self.x - bar.x, self.y - bar.y\n if self.support is None and abs(dy - slope * dx) * DIAGONAL < 4 and abs(dx + slope * dy) * DIAGONAL < bar.width / 2 + 2:\n self.support = bar\n offset = math.hypot(dx - slope * 4 * DIAGONAL, dy + 4 * DIAGONAL)\n self.bar_position = max(-bar.width * 0.4, min(bar.width * 0.4, offset if dx <= slope * 4 * DIAGONAL else -offset))\n reward += math.ceil(self.base_score)\n bar.passed = True\n if not bar.passed and bar.x + bar.width / 2 < self.x:\n bar.passed = True\n self.passed_count += 1\n bonus = 10 * self.passed_count\n reward += bonus\n self.base_score += bonus\n self.bars = [bar for bar in self.bars if bar.x >= -bar.width / 2]\n\n self.next_bar -= scroll\n if self.next_bar < 0:\n width = self.random.uniform(20, 30)\n self.bars.append(Bar(200 + width / 2, self.random.uniform(50, 90), width))\n self.next_bar += width / 2 + self.random.uniform(30, 50)\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row = min(9, max(0, int(self.y) // 10))\n column = min(9, max(0, int(self.x) // 20))\n state[row, column, 0] = True\n state[row, column, 3] = self.support is not None\n slope = 1 if self.pressed else -1\n for bar in self.bars:\n for distance in np.linspace(-bar.width / 2, bar.width / 2, 9):\n x = bar.x + distance * DIAGONAL\n y = bar.y + slope * distance * DIAGONAL\n if 0 <= x < 200 and 0 <= y < 100:\n state[int(y) // 10, int(x) // 20, 1 if bar.passed else 2] = True\n for row, value in enumerate((self.steps, round((self.bar_position + 32) * 4), math.ceil(self.base_score), self.passed_count)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :3, 4] = self.pressed, self.vy < 0, self.bar_position > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 65, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/catapult.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/catapult/main.js"} +{"name": "t_lanes", "split": "train", "game": "t_lanes", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays T Lanes as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to toggle all junctions. Actions 0–4 release. Cars\ndrive automatically and change lanes at enabled junctions. Passing\ncars activate stationary cars in the same lane for a convoy bonus.\nNew junctions score one point per moving car. Stop signs remove\ncars, and losing the entire moving convoy ends the episode.\n\nINPUT CHANNEL TABLE\nThe six channels show moving cars, stationary cars, disabled\njunctions, enabled junctions, stop signs, and counters plus\ndownward-junction markers. Each downward marker appears one row\nabove its junction in channel 5. The port fixes difficulty and\napproximates sprite contacts with lane and distance checks.\nEach action advances up to four frames over 400 actions. Clip\nepisode scores to [0, 2000] and divide by 2000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/t_lanes.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import sqrt\n\nimport numpy as np\n\n\n@dataclass\nclass Car:\n x: float\n y: float\n speed: float = 0\n turn: int = 0\n target: float = 0\n cooldown: int = 0\n junction: object = None\n\n\n@dataclass(eq=False)\nclass Junction:\n x: float\n y: float\n turn: int\n enabled: bool\n\n\nclass TLanesEnvironment:\n score_cap = 2000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.cars = [Car(20, 50, 0.1), Car(99, 50)]\n self.junctions, self.stops, self.routes = [], [], []\n self.scroll = self.car_dist = self.cross_dist = 0.\n self.stop_dist = 199.\n self.steps = 0\n self.held = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n moving = sum(car.speed > 0 for car in self.cars)\n if not moving:\n self.terminal = True\n return 0\n reward = 0\n scroll = self.scroll\n self.cross_dist -= scroll\n if self.cross_dist < 0:\n reward += moving\n if not self.routes:\n self.routes = list(self.random.permutation((0, 1, 2, 3, 6, 7, 8, 9)))\n route = self.routes.pop()\n self.junctions.append(Junction(200, 10 + 20 * (route % 5),\n 1 if route < 5 else -1, self.random.random() < 0.5))\n self.cross_dist = 24\n for junction in self.junctions:\n junction.x -= scroll\n if tap:\n junction.enabled = not junction.enabled\n self.junctions = [junction for junction in self.junctions if junction.x >= -20]\n self.stop_dist -= scroll\n if self.stop_dist < 0:\n self.stops.append((205, 10 + 20 * self.random.integers(5)))\n self.stop_dist += self.random.uniform(99, 120)\n self.stops = [(x - scroll, y) for x, y in self.stops if x - scroll >= -3 and not any(\n y == junction.y and abs(x - scroll - junction.x - 3) < 5 for junction in self.junctions)]\n self.car_dist -= scroll\n if self.car_dist < 0:\n self.cars.append(Car(203, 10 + 20 * self.random.integers(5)))\n self.car_dist += self.random.uniform(40, 60)\n survivors = []\n for car in self.cars:\n car.x -= scroll\n if tap and car.x < 50:\n car.x -= (50 - car.x) * 0.1\n if car.speed:\n car.speed += (1 - car.speed) * 0.05\n if car.turn:\n car.x += car.speed / sqrt(2)\n car.y += car.turn * car.speed / sqrt(2)\n if (car.y - car.target) * car.turn > 0:\n car.y, car.turn, car.cooldown = car.target, 0, 5\n else:\n car.x += car.speed\n car.cooldown -= 1\n if not car.turn and car.cooldown < 0 and any(\n y == car.y and abs(x - car.x) < 5 for x, y in self.stops\n ):\n continue\n if not car.speed and any(other.speed > 0 and not other.turn and\n abs(other.x - scroll - car.x) < 5 and other.y == car.y\n for other in self.cars if other is not car):\n reward += moving * 10\n car.speed = self.random.uniform(0.01, 0.3)\n if car.speed and not car.turn:\n junction = next((j for j in self.junctions if j.y == car.y and abs(j.x + 3 - car.x) < 5), None)\n if junction is not None and junction is not car.junction and junction.enabled:\n car.turn = junction.turn\n car.target = car.y + 20 * car.turn\n car.x = junction.x - 2\n car.junction = junction\n if car.x >= -3:\n survivors.append(car)\n self.cars = survivors\n self.terminal = not self.cars\n front = max((car.x for car in self.cars if car.speed), default=0)\n self.scroll = max(0, (front - 50) * 0.1)\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for car in self.cars:\n if 0 <= car.x < 200:\n state[int(car.y // 10), int(car.x // 20), int(not car.speed)] = True\n for junction in self.junctions:\n if 0 <= junction.x + 3 < 200:\n state[int(junction.y // 10), int((junction.x + 3) // 20),\n 2 + int(junction.enabled)] = True\n for x, y in self.stops:\n if 0 <= x < 200:\n state[int(y // 10), int(x // 20), 4] = True\n for row, value in enumerate((self.steps, self.held, round(self.scroll * 100),\n sum(car.speed > 0 for car in self.cars))):\n for bit in range(9):\n state[2 * row + 1, bit, 5] = bool(value & (1 << bit))\n for junction in self.junctions:\n if 0 <= junction.x + 3 < 200 and junction.turn > 0:\n state[max(0, int(junction.y // 10) - 1), int((junction.x + 3) // 20), 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 66, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/t_lanes.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/tlanes/main.js"} +{"name": "invincible_man", "split": "train", "game": "invincible_man", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Invincible Man as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to move outward from the center. Release with\nactions 0–4 to orbit. Each new press reverses the orbit direction.\n\nEnemies pursue civilians. Contact with the player, a civilian,\nor an explosion destroys an enemy and starts another explosion.\nEach kill scores the current multiplier and raises it by one.\nThe multiplier resets when all explosions fade. Explosions can\nkill civilians, and the run ends when none survive.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, civilians, enemies,\ngrowing blasts, shrinking blasts, and gauges. The conversion\nuses distance-based hitboxes and four frames per action at\nfixed difficulty. The 400-action task clips raw scores to\n[0, 300] and divides by 300.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/invincible_man.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Actor:\n x: float\n y: float\n vx: float = 0.0\n vy: float = 0.0\n target_x: float = 50.0\n target_y: float = 50.0\n\n def distance(self, other: \"Actor\") -> float:\n return math.hypot(self.x - other.x, self.y - other.y)\n\n def steer(self, angle: float, force: float, damping: float) -> None:\n self.vx = (self.vx + math.cos(angle) * force) * damping\n self.vy = (self.vy + math.sin(angle) * force) * damping\n self.x += self.vx\n self.y += self.vy\n\n\n@dataclass\nclass Explosion:\n x: float\n y: float\n radius: float = 1.0\n growing: bool = True\n\n def hits(self, actor: Actor) -> bool:\n return abs(math.hypot(self.x - actor.x, self.y - actor.y) - self.radius) < 4\n\n\nclass InvincibleManEnvironment:\n score_cap = 300\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.player = Actor(50, 40)\n self.direction = -1\n self.humans = [self._human(*self.random.uniform(40, 60, 2)) for _ in range(10)]\n self.enemies: list[Actor] = []\n self.explosions: list[Explosion] = []\n self.human_timer = self.enemy_timer = 0.0\n self.steps = 0\n self.multiplier = 1\n self.pressed = self.terminal = False\n\n def _human(self, x: float, y: float) -> Actor:\n tx, ty = self.random.uniform(40, 60, 2)\n return Actor(x, y, target_x=tx, target_y=ty)\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed:\n self.direction *= -1\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self) -> int:\n player = self.player\n toward = math.atan2(50 - player.y, 50 - player.x)\n angle, speed = (toward, -1) if self.pressed else (toward + math.pi / 2 * self.direction, 0.7)\n player.x += math.cos(angle) * speed\n player.y += math.sin(angle) * speed\n pull = (math.hypot(player.x - 50, player.y - 50) + 9) * 0.005\n player.x = min(100, max(0, player.x + math.cos(toward) * pull))\n player.y = min(100, max(0, player.y + math.sin(toward) * pull))\n for blast in self.explosions:\n blast.radius += 0.6 if blast.growing else -0.6\n if blast.radius > 12:\n blast.growing = False\n self.explosions = [blast for blast in self.explosions if blast.radius >= 1]\n self.human_timer -= 1\n if self.human_timer < 0:\n if len(self.humans) < 9:\n count = len(self.humans) + 1\n self.humans.append(self._human((50 + sum(h.x for h in self.humans)) / count,\n (50 + sum(h.y for h in self.humans)) / count))\n self.human_timer = 600\n self._move_humans()\n self.enemy_timer -= 1\n if self.enemy_timer < 0:\n angle = self.random.uniform(0, math.tau)\n x, y = 50 + 80 * math.cos(angle), 50 + 80 * math.sin(angle)\n count = int(self.random.integers(3, 9))\n for _ in range(count):\n dx, dy = self.random.uniform(-9, 9, 2)\n vx, vy = self.random.uniform(-1, 1, 2)\n self.enemies.append(Actor(x + dx, y + dy, vx, vy))\n self.enemies = self.enemies[-64:]\n self.enemy_timer = self.random.uniform(70, 99) * math.sqrt(count)\n reward = self._move_enemies()\n if not self.explosions:\n self.multiplier = 1\n self.terminal = not self.humans\n return reward\n\n def _move_humans(self) -> None:\n alive = []\n for human in self.humans:\n enemy = min(self.enemies, key=human.distance, default=None)\n if enemy is not None and human.distance(enemy) < 25:\n angle = math.atan2(human.y - enemy.y, human.x - enemy.x)\n else:\n if math.hypot(human.x - human.target_x, human.y - human.target_y) < 1:\n human.target_x, human.target_y = self.random.uniform(40, 60, 2)\n angle = math.atan2(human.target_y - human.y, human.target_x - human.x)\n human.steer(angle, 0.01, 0.9)\n human.x = min(90, max(10, human.x))\n human.y = min(90, max(10, human.y))\n if not any(blast.hits(human) for blast in self.explosions):\n alive.append(human)\n self.humans = alive\n\n def _move_enemies(self) -> int:\n reward = 0\n alive = []\n for enemy in self.enemies:\n human = min(self.humans, key=enemy.distance, default=None)\n if human is not None:\n enemy.steer(math.atan2(human.y - enemy.y, human.x - enemy.x), 0.005, 0.95)\n if (enemy.distance(self.player) < 5 or any(enemy.distance(h) < 5 for h in self.humans)\n or any(blast.hits(enemy) for blast in self.explosions)):\n self.explosions.append(Explosion(enemy.x, enemy.y))\n self.explosions = self.explosions[-16:]\n reward += self.multiplier\n self.multiplier += 1\n else:\n alive.append(enemy)\n self.enemies = alive\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for channel, actors in ((0, [self.player]), (1, self.humans), (2, self.enemies)):\n for actor in actors:\n if 0 <= actor.x <= 100 and 0 <= actor.y <= 100:\n state[min(9, int(actor.y) // 10), min(9, int(actor.x) // 10), channel] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for blast in self.explosions:\n distance = np.hypot(cols - blast.x, rows - blast.y)\n state[:, :, 3 if blast.growing else 4] |= abs(distance - blast.radius) < 6\n for row, value in enumerate((self.steps, len(self.humans), min(511, self.multiplier))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 67, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/invincible_man.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameInvincibleMan.c"} +{"name": "rotating_tunnel", "split": "train", "game": "rotating_tunnel", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Rotating Tunnel as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to move outward and release with actions 0–4 to move\ninward. The ship revolves automatically. Purple arcs drift inward\nand end the run on contact. Staying in contact with gold arcs\nawards points every five contact frames. Each award raises the\nmultiplier, which decays continuously between awards.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the ship, purple arcs, gold arcs, radial\nlimits, the projected ship position, and counters. The port fixes\ndifficulty and approximates triangle-to-arc collision with radial\nand angular tolerances. Each action advances up to four frames over\na 400-action horizon. Clip episode scores to [0, 300] and divide\nby 300.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/rotating_tunnel.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import ceil, cos, pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Arc:\n radius: float\n start: float\n width: float\n gold: bool\n\n\nclass RotatingTunnelEnvironment:\n score_cap = 300\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.angle = 0.\n self.radius = 20.\n self.multiplier = 0.\n self.steps = self.spawn_timer = self.score_timer = 0\n self.held = self.terminal = False\n self.arcs = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.held = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n self.angle = (self.angle + 0.025) % (2 * pi)\n self.radius = min(50, max(10, self.radius + (0.65 if self.held else -0.65)))\n self.spawn_timer -= 1\n if self.spawn_timer < 0:\n gold = self.random.random() < 0.3\n self.arcs.append(Arc(50, self.random.uniform(0, 2 * pi),\n self.random.uniform(pi / 4, pi / 3), gold))\n self.spawn_timer += 80\n reward = 0\n for arc in self.arcs:\n arc.radius -= 0.25\n if arc.radius <= 10 or abs(self.radius - arc.radius) > 2.5:\n continue\n angle = (self.angle - arc.start) % (2 * pi)\n margin = 2.5 / arc.radius\n if angle > arc.width + margin and angle < 2 * pi - margin:\n continue\n if arc.gold:\n self.score_timer -= 1\n if self.score_timer < 0:\n self.multiplier += 1\n reward += ceil(self.multiplier)\n self.score_timer += 5\n else:\n self.terminal = True\n self.arcs = [arc for arc in self.arcs if arc.radius > 10]\n self.multiplier *= 0.99\n return reward\n\n @staticmethod\n def _mark(state, x, y, channel):\n cols = np.clip(np.asarray(x) // 10, 0, 9).astype(int)\n rows = np.clip(np.asarray(y) // 10, 0, 9).astype(int)\n state[rows, cols, channel] = True\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n dx, dy = cos(self.angle), sin(self.angle)\n self._mark(state, 50 + self.radius * dx, 50 + self.radius * dy, 0)\n for arc in self.arcs:\n angles = np.linspace(arc.start, arc.start + arc.width, 40)\n self._mark(state, 50 + arc.radius * np.cos(angles), 50 + arc.radius * np.sin(angles),\n 2 if arc.gold else 1)\n angles = np.linspace(0, 2 * pi, 96)\n for radius in (10, 50):\n self._mark(state, 50 + radius * np.cos(angles), 50 + radius * np.sin(angles), 3)\n future = self.angle + 0.1\n self._mark(state, 50 + self.radius * cos(future), 50 + self.radius * sin(future), 4)\n values = (self.steps, self.held, self.spawn_timer, self.score_timer,\n round(self.radius * 10), round(self.angle * 100),\n min(1023, round(self.multiplier * 100)))\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 68, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/rotating_tunnel.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameRotatingTunnel.c"} +{"name": "dark_sort", "split": "train", "game": "dark_sort", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Dark Sort as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe gate moves automatically. Hold action 5 to make it light.\nRelease with actions 0–4 to make it dark. Catch matching orbs\nto build a combo. A miss resets the combo, and a wrong-color\ncatch ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the gate, its light state, visible\nlight and dark orbs, the visibility area, and gauges. Each action\nadvances four frames at fixed difficulty. One orb spawns every\n29 frames, and orbs outside the visibility radius stay hidden.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 100] and divide by 100. Across 100 seeds without sticky\nactions, idle averaged 1.26, random inputs averaged 0.97, and\na policy predicting catches from exact positions averaged\n30.22 and reached 53.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/dark_sort.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Orb:\n x: float\n y: float\n light: bool\n\n\nclass DarkSortEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.combo = self.spawn_timer = 0\n self.x, self.direction = 50, 1\n self.light = self.terminal = False\n self.orbs: list[Orb] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.light = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance_frame()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self) -> int:\n self.spawn_timer -= 1\n if self.spawn_timer <= 0:\n self.orbs.append(Orb(self.random.uniform(12, 88), -5, self.random.random() < 0.5))\n self.spawn_timer = 29\n self.x += self.direction\n if self.x > 90 or self.x < 10:\n self.direction *= -1\n\n reward = 0\n survivors = []\n for orb in self.orbs:\n orb.y += 0.8\n if 90 <= orb.y <= 95 and abs(orb.x - self.x) < 14:\n if orb.light == self.light:\n self.combo += 1\n reward += self.combo\n continue\n self.terminal = True\n if orb.y > 100:\n self.combo = 0\n else:\n survivors.append(orb)\n self.orbs = survivors\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n gate = slice(max(0, (self.x - 12) // 10), min(10, (self.x + 12) // 10 + 1))\n state[9, gate, 0] = True\n state[9, gate, 1] = self.light\n for row in range(10):\n for col in range(10):\n state[row, col, 4] = math.hypot(10 * col + 5 - self.x, 10 * row + 5 - 67) < 55\n for orb in self.orbs:\n if 0 <= orb.y < 100 and math.hypot(orb.x - self.x, orb.y - 67) < 55:\n state[int(orb.y) // 10, int(orb.x) // 10, 2 if orb.light else 3] = True\n for row, value in enumerate((self.steps, self.combo, self.x, self.spawn_timer)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 69, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/dark_sort.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameDarkSort.c"} +{"name": "survivor", "split": "train", "game": "survivor", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Survivor as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to jump. Actions 0–4 release. Grounded runners can\njump, as can a runner whose support has already jumped. Runners\nstack when they meet. Jump over rolling barrels. Each barrel that\nleaves the screen scores one point per surviving runner and the\nnext wave refills the group. Losing every runner ends the episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show grounded runners, airborne runners,\nstacked runners, the barrel, downed runners, and counters. The port\nfixes difficulty and approximates barrel contact with a radial test.\nEach action advances up to four frames over 400 actions. Clip the\nepisode score to [0, 100] and divide by 100.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/survivor.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import hypot, sqrt\n\nimport numpy as np\n\n\n@dataclass(eq=False)\nclass Runner:\n x: float\n y: float\n vx: float = 0\n vy: float = 0\n grounded: bool = False\n jumped: bool = False\n below: \"Runner | None\" = None\n above: \"Runner | None\" = None\n\n\nclass SurvivorEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.runners, self.downed = [], []\n self.steps = 0\n self.held = self.terminal = False\n self._wave()\n\n def _runner(self):\n return Runner(self.random.uniform(10, 40), self.random.uniform(-9, 9))\n\n def _wave(self):\n self.runners.extend(self._runner() for _ in range(9 - len(self.runners)))\n self.radius = self.random.uniform(5, 25)\n self.barrel_x = 120 + self.radius\n self.barrel_speed = self.random.uniform(1, 2) / sqrt(1 + self.radius * 0.3)\n self.next_wave = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n if self.next_wave:\n self._wave()\n self.barrel_x -= self.barrel_speed\n jumped = []\n replacements = 0\n for runner in tuple(self.runners):\n if runner.grounded and runner.below is None:\n self._stack(runner)\n if tap and (runner.grounded or (runner.below is not None and runner.below.jumped)):\n self._detach(runner)\n runner.vx, runner.vy, runner.grounded = 0, -1.5, False\n jumped.append(runner)\n if runner.below is not None:\n runner.x, runner.y = runner.below.x, runner.below.y - 6\n runner.vx = runner.vy = 0\n else:\n self._move(runner)\n distance = hypot(runner.x - self.barrel_x, runner.y - (93 - self.radius))\n hit = abs(distance - self.radius) < 4.5 + self.radius * 0.05\n escaped = not (0 <= runner.x <= 100 and -50 <= runner.y <= 100)\n if hit or escaped:\n self._detach(runner)\n if runner.above is not None:\n jumped.append(runner.above)\n self._detach(runner.above)\n self.runners.remove(runner)\n if hit:\n self.downed.append(Runner(runner.x, runner.y, runner.vx - 2 * self.barrel_speed, runner.vy))\n else:\n replacements += 1\n self.runners.extend(self._runner() for _ in range(replacements))\n for runner in jumped:\n runner.jumped = True\n for runner in self.downed:\n runner.x += runner.vx\n runner.y += runner.vy\n runner.vy += 0.2\n self.downed = [runner for runner in self.downed if runner.y < 105]\n self.terminal = not self.runners\n self.next_wave = self.barrel_x < -self.radius\n return len(self.runners) if self.next_wave else 0\n\n @staticmethod\n def _detach(runner):\n if runner.below is not None:\n runner.below.above = None\n runner.below = None\n\n def _stack(self, runner):\n own = {runner}\n top = runner\n while top.above is not None:\n top = top.above\n own.add(top)\n for other in self.runners:\n if other in own or hypot(runner.x - other.x, runner.y - other.y) >= 4:\n continue\n while other.above is not None:\n other = other.above\n runner.below = other\n other.above = runner\n member = top\n while member is not None:\n member.jumped = member.grounded = False\n member = member.below\n break\n\n def _move(self, runner):\n runner.x += runner.vx\n runner.y += runner.vy\n runner.vx *= 0.95\n if (runner.x < 7 and runner.vx < 0) or (runner.x >= 77 and runner.vx > 0):\n runner.vx *= -0.5\n runner.vx += (0.01 if runner.x < 50 else -0.01) * sqrt(abs(50 - runner.x) + 1)\n if runner.grounded:\n if runner.x < self.barrel_x:\n runner.vx -= 0.1 * sqrt(self.radius) / sqrt(self.barrel_x - runner.x + 1)\n else:\n runner.vy += 0.1\n if runner.y > 90:\n runner.y, runner.vy = 90, 0\n runner.grounded, runner.jumped = True, False\n if runner.y < 0 and runner.vy < 0:\n runner.vy *= -0.5\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for runner in self.runners:\n if 0 <= runner.x < 100 and 0 <= runner.y < 100:\n channel = 2 if runner.below is not None else int(not runner.grounded)\n state[int(runner.y // 10), int(runner.x // 10), channel] = True\n for runner in self.downed:\n if 0 <= runner.x < 100 and 0 <= runner.y < 100:\n state[int(runner.y // 10), int(runner.x // 10), 4] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n state[:, :, 3] = abs(np.hypot(cols - self.barrel_x, rows - (93 - self.radius)) - self.radius) < 7\n for row, value in enumerate((self.steps, self.held, len(self.runners), round(self.radius * 10))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 70, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/survivor.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameSurvivor.c"} +{"name": "star_gunner", "split": "train", "game": "star_gunner", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Star Gunner as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves free four-direction movement, left/right ship facing, firing in the\nfacing direction, one shot per button press, direct-hit alien destruction, hazardous alien\nrematerialization, Bobo's indestructible falling bombs, five starting ships, collision and bomb\nlosses, 10,000-point reinforcements, the 10/20/30-enemy wave structure with one/two/three active\naliens, wave-specific values, wave bonuses, and faster successive levels.\n\nACTION MAPPING\n0: hold position and release fire button\n1: move and face left\n2: move up\n3: move and face right\n4: move down\n5: fire one P-laser if the button was released\n\nINPUT CHANNEL TABLE\n0: StarGunner ship\n1: active aliens and Bobo bombs\n2: assembling aliens\n3: P-laser shots\n4: previous ship and alien positions\n5: exact level, wave, counts, lives, pose, direction, clock, threshold, and trigger state\n\nSCORING, TERMINATION, AND HORIZON\nEach level's aliens are worth `10 × 100 + 20 × 200 + 30 × 300 = 14,000`. Eight levels pay\n112,000 in alien points. The manual's per-wave bonuses for levels one through eight are 400, 600,\n1,000, 1,100, 1,400, 1,600, 2,000, and 2,100; paid across three waves each, they total 30,600.\nThus `score_cap = 112,000 + 30,600 = 142,600`, and normalization is\n`min(max(raw_score, 0), 142_600) / 142_600`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/star_gunner.py`):\n```python\nimport numpy as np\n\n\nWAVE_QUOTAS = (10, 20, 30)\nWAVE_VALUES = (100, 200, 300)\nLEVEL_BONUSES = (400, 600, 1_000, 1_100, 1_400, 1_600, 2_000, 2_100)\n\n\nclass StarGunnerEnvironment:\n \"\"\"Eight escalating three-wave invasions with bidirectional single-shot fire.\"\"\"\n\n score_cap = 142_600.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 5_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.row = 5\n self.column = 5\n self.previous_row = self.row\n self.previous_column = self.column\n self.facing = 1\n self.lives = 5\n self.level = 0\n self.wave = 0\n self.spawned = 0\n self.killed = 0\n self.next_enemy_id = 0\n self.enemies: list[dict[str, int]] = []\n self.lasers: list[list[int]] = []\n self.bombs: list[list[int]] = []\n self.previous_enemies: list[tuple[int, int]] = []\n self.fire_ready = True\n self.score = 0.0\n self.next_extra_life = 10_000\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self._fill_formation()\n\n @property\n def active_limit(self) -> int:\n return self.wave + 1\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_row = self.row\n self.previous_column = self.column\n self.previous_enemies = [(enemy[\"row\"], enemy[\"column\"]) for enemy in self.enemies]\n if action != 5:\n self.fire_ready = True\n if action == 1:\n self.column = max(0, self.column - 1)\n self.facing = -1\n elif action == 2:\n self.row = max(0, self.row - 1)\n elif action == 3:\n self.column = min(9, self.column + 1)\n self.facing = 1\n elif action == 4:\n self.row = min(9, self.row + 1)\n elif action == 5 and self.fire_ready:\n self.lasers.append([self.row, self.column, self.facing])\n self.fire_ready = False\n self._move_lasers()\n self._move_enemies()\n self._move_bombs()\n reward = self._resolve_hits()\n self._resolve_player_collisions()\n if not self.terminal:\n self._fill_formation()\n if self.killed >= WAVE_QUOTAS[self.wave] and not self.enemies:\n reward += float(LEVEL_BONUSES[self.level])\n self._advance_wave()\n future_score = self.score + reward\n while future_score >= self.next_extra_life:\n self.lives = min(255, self.lives + 1)\n self.next_extra_life += 10_000\n self.score = future_score\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _fill_formation(self) -> None:\n quota = WAVE_QUOTAS[self.wave]\n while len(self.enemies) < self.active_limit and self.spawned < quota:\n enemy_id = self.next_enemy_id\n self.next_enemy_id += 1\n self.spawned += 1\n self.enemies.append(\n {\n \"id\": enemy_id,\n \"row\": int(self.random.randint(1, 9)),\n \"column\": 0 if self.random.rand() < 0.5 else 9,\n \"forming\": 2,\n }\n )\n\n def _move_lasers(self) -> None:\n for laser in self.lasers:\n laser[1] += laser[2]\n self.lasers = [laser for laser in self.lasers if 0 <= laser[1] < 10]\n\n def _move_enemies(self) -> None:\n interval = max(1, 4 - self.level // 2)\n for enemy in self.enemies:\n if enemy[\"forming\"] > 0:\n enemy[\"forming\"] -= 1\n continue\n if self.steps % interval == 0:\n enemy[\"column\"] += int(np.sign(self.column - enemy[\"column\"]))\n if self.steps % 2 == 0:\n enemy[\"row\"] += int(np.sign(self.row - enemy[\"row\"]))\n\n def _move_bombs(self) -> None:\n if self.steps % max(5, 11 - self.level) == 0:\n self.bombs.append([0, int(self.random.randint(10))])\n for bomb in self.bombs:\n bomb[0] += 1\n self.bombs = [bomb for bomb in self.bombs if bomb[0] < 10]\n\n def _resolve_hits(self) -> float:\n reward = 0.0\n hit_enemy_ids: set[int] = set()\n hit_lasers: set[int] = set()\n for laser_index, laser in enumerate(self.lasers):\n for enemy in self.enemies:\n if enemy[\"forming\"] > 0 or laser[:2] != [enemy[\"row\"], enemy[\"column\"]]:\n continue\n hit_enemy_ids.add(enemy[\"id\"])\n hit_lasers.add(laser_index)\n reward += float(WAVE_VALUES[self.wave])\n break\n self.enemies = [enemy for enemy in self.enemies if enemy[\"id\"] not in hit_enemy_ids]\n self.lasers = [laser for index, laser in enumerate(self.lasers) if index not in hit_lasers]\n self.killed += len(hit_enemy_ids)\n return reward\n\n def _resolve_player_collisions(self) -> None:\n colliding_enemy_ids = {\n enemy[\"id\"]\n for enemy in self.enemies\n if enemy[\"row\"] == self.row and enemy[\"column\"] == self.column\n }\n collision = bool(colliding_enemy_ids) or any(bomb == [self.row, self.column] for bomb in self.bombs)\n if not collision:\n return\n self.lives -= 1\n self.row = 5\n self.column = 5\n self.lasers.clear()\n self.bombs.clear()\n self.enemies = [enemy for enemy in self.enemies if enemy[\"id\"] not in colliding_enemy_ids]\n self.spawned -= len(colliding_enemy_ids)\n if self.lives <= 0:\n self.terminal = True\n\n def _advance_wave(self) -> None:\n self.wave += 1\n if self.wave >= 3:\n self.wave = 0\n self.level += 1\n if self.level >= 8:\n self.terminal = True\n return\n self.spawned = 0\n self.killed = 0\n self._fill_formation()\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[self.row, self.column, 0] = True\n state[self.previous_row, self.previous_column, 4] = True\n for enemy in self.enemies:\n channel = 2 if enemy[\"forming\"] > 0 else 1\n state[enemy[\"row\"], enemy[\"column\"], channel] = True\n for row, column in self.previous_enemies:\n state[row, column, 4] = True\n for row, column, _ in self.lasers:\n state[row, column, 3] = True\n for row, column in self.bombs:\n state[row, column, 1] = True\n values = (\n (self.level, 4),\n (self.wave, 2),\n (self.spawned, 5),\n (self.killed, 5),\n (self.lives, 8),\n (self.row, 4),\n (self.column, 4),\n (self.facing + 1, 2),\n (self.steps, 13),\n (self.next_extra_life // 10_000, 5),\n )\n offset = 0\n for value, width in values:\n for bit in range(width):\n index = offset + bit\n state[index // 10, index % 10, 5] = bool(value & (1 << bit))\n offset += width\n state[6, 0, 5] = self.fire_ready\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 71, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/star_gunner.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "sky_floor", "split": "train", "game": "sky_floor", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Sky Floor as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nSteer left with action 1 and right with action 3. Other actions\napply no steering. The ball climbs automatically. Stay over the\nfloating floors while fans push the ball sideways. Leaving the\nfloor shrinks the ball until it disappears and ends the episode.\nCoins score the current multiplier and raise it. Missed coins\nlower the multiplier.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the ball, floors, coins, fans, the\noff-floor ball, and counters. The port replaces pointer input\nwith fixed relative steering offsets, fixes difficulty, and uses\nrectangular overlap for floor contact. Each action advances up to\nfour frames over a 400-action horizon. Clip episode scores to\n[0, 150] and divide by 150.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/sky_floor.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import atan2, ceil, cos, hypot, pi, sin, sqrt\n\nimport numpy as np\n\n\n@dataclass\nclass Floor:\n x: float\n y: float\n width: float\n height: float\n\n\n@dataclass\nclass Fan:\n x: float\n y: float\n speed: float\n angle: float\n\n\nclass SkyFloorEnvironment:\n score_cap = 150\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 50., 90.\n self.vx = self.vy = self.distance = 0.\n self.radius = 2.\n self.steps = self.action = 0\n self.multiplier = 1\n self.outside = self.terminal = False\n self.floors = [Floor(50, 50, 80, 150)]\n self.fans, self.coins = [], []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _spawn(self):\n last = self.floors[-1]\n for _ in range(9):\n x, width = self.random.uniform(0, 99), self.random.uniform(30, 80)\n if abs(x - last.x) < (width + last.width) / 2:\n break\n else:\n x, width = last.x, last.width\n height = self.random.uniform(30, 99)\n y = -height / 2 - 20\n self.floors.append(Floor(x, y, width, height))\n for _ in range(self.random.integers(ceil(height / 30))):\n side = self.random.choice((-1, 1))\n self.fans.append(Fan(x + side * width * self.random.uniform(0.6, 0.7),\n y + height * self.random.uniform(-0.4, 0.4),\n self.random.uniform(1, 2),\n (0 if side < 0 else pi) + self.random.uniform(-pi / 8, pi / 8)))\n count = self.random.integers(ceil(height / 10))\n start = self.random.uniform(-0.5, 0.5) * height - count * 5\n coin_x = x + width * self.random.uniform(-0.2, 0.2)\n for i in range(count):\n offset = start + i * 10\n if abs(offset) < height * 0.3:\n self.coins.append((coin_x, y + offset))\n self.distance = self.random.uniform(0.6, 0.8) * height\n\n def _advance(self):\n sx = (min(55, max(45, self.x)) - self.x) * 0.1\n sy = max(0, 80 - self.y) * 0.1\n self.distance -= sy\n if self.distance < 0:\n self._spawn()\n for floor in self.floors:\n floor.x += sx\n floor.y += sy\n self.floors = [floor for floor in self.floors if floor.y - floor.height / 2 <= 99]\n for fan in self.fans:\n fan.x += sx\n fan.y += sy\n dx, dy = self.x - fan.x, self.y - fan.y\n offset = abs((atan2(dy, dx) - fan.angle + pi) % (2 * pi) - pi)\n force = 3 * fan.speed * max(0, pi / 4 - offset) / (hypot(dx, dy) + 1)\n self.vx += force * cos(fan.angle)\n self.vy += force * sin(fan.angle)\n self.fans = [fan for fan in self.fans if fan.y <= 105]\n offset = 35 * ((self.action == 3) - (self.action == 1))\n self.vx = (self.vx + offset * abs(offset) * 0.0001) * 0.95\n self.vy = (self.vy - 0.1) * 0.95 * (1 - 0.03 * sqrt(abs(offset)))\n self.x += self.vx + sx\n self.y += self.vy + sy - 0.1\n if any(abs(floor.x - self.x) < floor.width / 2 + self.radius and\n abs(floor.y - self.y) < floor.height / 2 + self.radius for floor in self.floors):\n self.outside = False\n self.radius += (2 - self.radius) * 0.1\n else:\n if not self.outside:\n self.vx *= 0.5\n self.outside = True\n self.radius *= 0.925\n self.terminal = self.radius < 0.1\n reward = 0\n remaining = []\n for x, y in self.coins:\n x, y = x + sx, y + sy\n if abs(x - self.x) < 4 + self.radius and abs(y - self.y) < 4 + self.radius:\n reward += self.multiplier\n self.multiplier += 1\n elif y > 105:\n self.multiplier = max(1, self.multiplier - 1)\n else:\n remaining.append((x, y))\n self.coins = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n row, col = np.clip(np.array([self.y, self.x]) // 10, 0, 9).astype(int)\n state[row, col, 0] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for floor in self.floors:\n state[:, :, 1] |= (abs(rows - floor.y) < floor.height / 2 + 5) & (\n abs(cols - floor.x) < floor.width / 2 + 5)\n for channel, points in ((2, self.coins), (3, [(fan.x, fan.y) for fan in self.fans])):\n for x, y in points:\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), channel] = True\n state[row, col, 4] = self.outside\n values = (self.steps, self.action, self.multiplier, round(self.radius * 100),\n round((self.vx + 20) * 20), round((self.vy + 20) * 20))\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 72, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/sky_floor.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/skyfloor/main.js"} +{"name": "yars_revenge", "split": "train", "game": "yars_revenge", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Yars Revenge as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves free four-way Yar flight with vertical wrapping, shield cells destroyed\nby lower-value energy missiles or higher-value contact devouring, the central Neutral Zone's fire\nban and Destroyer immunity, a homing Destroyer Missile, four Yars, a charged left-side Zorlon\nCannon whose line of fire is dangerous to its owner, Qotile windup and flying Swirl attacks,\nmid-air Swirl bonuses, and progressively faster stages.\n\nACTION MAPPING\n0: hover\n1: fly/face left\n2: fly/face up, wrapping vertically\n3: fly/face right\n4: fly/face down, wrapping vertically\n5: fire energy missile or charged Zorlon Cannon; disabled in Neutral Zone\n\nINPUT CHANNEL TABLE\n0: Yar\n1: Qotile/Swirl and Destroyer Missile\n2: shield cells\n3: energy missile and Zorlon Cannon\n4: Neutral Zone\n5: exact stage, lives, shield count, Swirl timing, clock, cannon charge, and Qotile state\n\nSCORING, TERMINATION, AND HORIZON\nThe manual awards 69 for a shot cell and 169 total for a devoured cell (69 plus 100 bonus), so the\nmaximum for 24 cells is `24×169 = 4,056`. A mid-air Swirl kill is the maximum one-time stage kill\nat 6,000. Across four stages, `score_cap = 4×(4,056+6,000) = 40,224`, and normalization is\n`min(max(raw_score, 0), 40_224) / 40_224`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/yars_revenge.py`):\n```python\nimport numpy as np\n\n\nDIRECTIONS = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}\nNEUTRAL_COLUMNS = frozenset((4, 5))\n\n\nclass YarsRevengeEnvironment:\n \"\"\"Four-Qotile normal-game campaign with shield, neutral zone, and Zorlon cannon.\"\"\"\n\n score_cap = 40_224.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 4_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.stage = 0\n self.lives = 4\n self.score = 0.0\n self.steps = 0\n self.last_action = 0\n self.facing = 3\n self.terminal = False\n self._start_stage()\n\n def _start_stage(self) -> None:\n self.yar = [5, 2]\n self.qotile = [5, 9]\n self.qotile_state = \"base\"\n self.swirl_timer = 0\n self.shield = {(row, column) for row in range(1, 9) for column in range(6, 9)}\n self.cannon_ready = False\n self.energy_missile: list[int] | None = None\n self.zorlon: list[int] | None = None\n self.destroyer = [1, 1]\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n reward = 0.0\n if action in DIRECTIONS:\n self.facing = action\n reward += self._move_yar(action)\n elif action == 5:\n self._fire()\n self._move_energy_missile()\n reward += self._resolve_energy_hit()\n self._move_zorlon()\n reward += self._resolve_zorlon_hit()\n self._move_destroyer()\n self._move_swirl()\n self._resolve_hazards()\n self.score += reward\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_yar(self, action: int) -> float:\n row_delta, column_delta = DIRECTIONS[action]\n destination = [(self.yar[0] + row_delta) % 10, self.yar[1] + column_delta]\n if not 0 <= destination[1] < 10:\n return 0.0\n self.yar = destination\n position = tuple(self.yar)\n if position in self.shield:\n self.shield.remove(position)\n self.cannon_ready = True\n return 169.0\n if self.yar == self.qotile:\n self.cannon_ready = True\n return 0.0\n\n def _fire(self) -> None:\n if self.yar[1] in NEUTRAL_COLUMNS:\n return\n if self.cannon_ready and self.zorlon is None:\n self.zorlon = [self.yar[0], 0, 0, 1]\n self.cannon_ready = False\n return\n if self.energy_missile is None:\n row_delta, column_delta = DIRECTIONS[self.facing]\n self.energy_missile = [self.yar[0], self.yar[1], row_delta, column_delta]\n\n def _move_energy_missile(self) -> None:\n if self.energy_missile is None:\n return\n self.energy_missile[0] = (self.energy_missile[0] + self.energy_missile[2]) % 10\n self.energy_missile[1] += self.energy_missile[3]\n if not 0 <= self.energy_missile[1] < 10:\n self.energy_missile = None\n\n def _resolve_energy_hit(self) -> float:\n if self.energy_missile is None or tuple(self.energy_missile[:2]) not in self.shield:\n return 0.0\n self.shield.remove(tuple(self.energy_missile[:2]))\n self.energy_missile = None\n return 69.0\n\n def _move_zorlon(self) -> None:\n if self.zorlon is None:\n return\n self.zorlon[1] += 1\n if self.zorlon[1] >= 10:\n self.zorlon = None\n\n def _resolve_zorlon_hit(self) -> float:\n if self.zorlon is None:\n return 0.0\n position = tuple(self.zorlon[:2])\n if position in self.shield:\n self.shield.remove(position)\n self.zorlon = None\n return 69.0\n if self.zorlon[:2] != self.qotile:\n return 0.0\n reward = 6_000.0 if self.qotile_state == \"flying\" else 2_000.0 if self.qotile_state == \"windup\" else 1_000.0\n if reward == 6_000:\n self.lives += 1\n self.zorlon = None\n self.stage += 1\n if self.stage == 4:\n self.terminal = True\n else:\n self._start_stage()\n return reward\n\n def _move_destroyer(self) -> None:\n interval = max(1, 4 - self.stage)\n if self.steps % interval:\n return\n self.destroyer[0] += int(np.sign(self.yar[0] - self.destroyer[0]))\n self.destroyer[1] += int(np.sign(self.yar[1] - self.destroyer[1]))\n\n def _move_swirl(self) -> None:\n phase = self.steps % max(20, 40 - 5 * self.stage)\n if phase == 12:\n self.qotile_state = \"windup\"\n self.swirl_timer = 4\n elif self.qotile_state == \"windup\":\n self.swirl_timer -= 1\n if self.swirl_timer == 0:\n self.qotile_state = \"flying\"\n elif self.qotile_state == \"flying\":\n self.qotile[0] += int(np.sign(self.yar[0] - self.qotile[0]))\n self.qotile[1] += int(np.sign(self.yar[1] - self.qotile[1]))\n\n def _resolve_hazards(self) -> None:\n destroyer_hit = self.destroyer == self.yar and self.yar[1] not in NEUTRAL_COLUMNS\n swirl_hit = self.qotile_state == \"flying\" and self.qotile == self.yar\n own_cannon_hit = self.zorlon is not None and self.zorlon[:2] == self.yar\n if not (destroyer_hit or swirl_hit or own_cannon_hit):\n return\n self.lives -= 1\n if self.lives <= 0:\n self.terminal = True\n else:\n self.yar = [5, 2]\n self.destroyer = [1, 1]\n self.energy_missile = None\n self.zorlon = None\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[self.yar[0], self.yar[1], 0] = True\n state[self.destroyer[0], self.destroyer[1], 1] = True\n state[self.qotile[0], self.qotile[1], 1] = True\n for row, column in self.shield:\n state[row, column, 2] = True\n if self.energy_missile is not None:\n state[self.energy_missile[0], self.energy_missile[1], 3] = True\n if self.zorlon is not None:\n state[self.zorlon[0], self.zorlon[1], 3] = True\n for row in range(10):\n for column in NEUTRAL_COLUMNS:\n state[row, column, 4] = True\n values = ((self.stage, 3), (self.lives, 4), (len(self.shield), 5), (self.swirl_timer, 3), (self.steps, 12))\n offset = 0\n for value, width in values:\n for bit in range(width):\n state[offset // 10, offset % 10, 5] = bool(value & (1 << bit))\n offset += 1\n state[3, 0, 5] = self.cannon_ready\n state[3, 1, 5] = self.qotile_state == \"windup\"\n state[3, 2, 5] = self.qotile_state == \"flying\"\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 73, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/yars_revenge.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "screen", "split": "train", "game": "screen", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Screen as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to fire along the sweeping aim line. Actions 0–4\nrelease. After three shots the player crosses the divider and\nreloads. Each enemy hit scores the current multiplier and raises it\nby one. A shot that leaves the screen lowers the multiplier.\nAn enemy reaching the bottom ends the episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the player, enemies, shots, aim line,\ninactive side, and counters. The port uses fixed difficulty,\nrectangular collision bounds, and a latched side change after\nthe third shot. Each action advances up to four frames over a\n400-action horizon. Clip episode scores to [0, 150] and divide by 150.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/screen.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Shot:\n x: float\n y: float\n angle: float\n\n\n@dataclass\nclass Enemy:\n x: float\n y: float = -3\n\n\nclass ScreenEnvironment:\n score_cap = 150\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x = self.target = 55.0\n self.angle = 0.0\n self.ammo = 3\n self.multiplier = 1\n self.steps = self.timer = 0\n self.held = self.terminal = False\n self.shots = []\n self.enemies = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _aim(self):\n return -self.angle if self.x > 50 else pi + self.angle\n\n def _advance(self, tap):\n self.angle = (self.angle + 0.01) % (pi / 2)\n if tap and self.ammo and abs(self.x - self.target) < 1:\n self.shots.append(Shot(self.x, 95, self._aim()))\n self.ammo -= 1\n if self.ammo == 0 and self.x == self.target:\n self.target = 100 - self.target\n previous = self.x\n self.x += (self.target - self.x) * 0.2\n if abs(self.target - self.x) < 1:\n self.x = self.target\n if (previous - 50) * (self.x - 50) <= 0:\n self.ammo = 3\n shots = []\n for shot in self.shots:\n shot.x += cos(shot.angle)\n shot.y += sin(shot.angle)\n if -5 <= shot.x <= 105 and -5 <= shot.y <= 105:\n shots.append(shot)\n else:\n self.multiplier = max(1, self.multiplier - 1)\n self.timer -= 1\n if self.timer < 0:\n x = 50 + self.random.choice((-1, 1)) * self.random.uniform(15, 40)\n self.enemies.append(Enemy(x))\n self.timer = self.random.uniform(60, 90)\n spent = set()\n remaining = []\n reward = 0\n for enemy in self.enemies:\n enemy.y += 0.1\n hits = [index for index, shot in enumerate(shots)\n if abs(shot.x - enemy.x) < 4 and abs(shot.y - enemy.y) < 4]\n if hits:\n spent.update(hits)\n reward += self.multiplier\n self.multiplier += 1\n else:\n self.terminal |= enemy.y > 99\n remaining.append(enemy)\n self.enemies = remaining\n self.shots = [shot for index, shot in enumerate(shots) if index not in spent]\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[9, int(self.x // 10), 0] = True\n for channel, entities in ((1, self.enemies), (2, self.shots)):\n for entity in entities:\n if 0 <= entity.x < 100 and 0 <= entity.y < 100:\n state[int(entity.y // 10), int(entity.x // 10), channel] = True\n distance = np.arange(100)\n x = self.x + cos(self._aim()) * distance\n y = 95 + sin(self._aim()) * distance\n visible = (x >= 0) & (x < 100) & (y >= 0) & (y < 100)\n state[(y[visible] // 10).astype(int), (x[visible] // 10).astype(int), 3] = True\n if self.x > 50:\n state[:, :5, 4] = True\n else:\n state[:, 5:, 4] = True\n for row, value in enumerate((self.steps, self.ammo, self.multiplier, self.held,\n round(self.angle * 100), self.target > 50)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 74, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/screen.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/screen/main.js"} +{"name": "pin_climb", "split": "train", "game": "pin_climb", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Pin Climb as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nA cord rotates around its attached pin. Hold action 5 to lengthen the\ncord. Actions 0–4 let it contract toward its resting length. Contact\nwith another pin transfers the pivot, resets the length, and pays the\nrounded-up distance between pins. Pins scroll downward, faster when the\npivot is high. The episode ends when the pivot leaves the bottom or\nafter 400 steps.\n\nINPUT CHANNEL TABLE\nChannels mark the pivot, a reserved channel, visible pins, the cord,\na reserved channel, and gauges. Gauges encode the clock, angle, cord\nlength, spawn distance, last button state, and exact pivot coordinates.\nThe grid approximation uses eight subunits per cell and 32 angles.\nThe rotation rate increases halfway through the episode. Contacts use\na radius around each pin and are resolved once per step. Pin locations\nare sampled at subcell resolution and projected into the observation.\n\nSCORING, TERMINATION, AND HORIZON\nRevisiting pins is allowed. At most one transfer can score per step,\nand the maximum distance is bounded by the diagonal between subcell\ncoordinates (0, 0) and (79, 79). Rounding up gives 112 per step, so\nthe 400-step cap is 44,800. Normalize by clipping to [0, 44800] and\ndividing by 44800.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/pin_climb.py`):\n```python\nfrom math import ceil, cos, hypot, pi, sin\n\nimport numpy as np\n\n\nHORIZON = 400\nUNIT = 8\nEDGE = 10 * UNIT\nREST_LENGTH = 6\nANGLE_COUNT = 32\nPIN_RADIUS = 2\n\n\nclass PinClimbEnvironment:\n score_cap = HORIZON * ceil(hypot(EDGE - 1, EDGE - 1))\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.angle = self.last_action = self.scroll = 0\n self.length = REST_LENGTH\n self.anchor = (40, 4)\n self.pins = [self.anchor]\n self.next_pin = 4\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def _catch(self) -> float:\n angle = self.angle * 2 * pi / ANGLE_COUNT\n horizontal, vertical = cos(angle), sin(angle)\n x, y = self.anchor\n target = None\n for pin in self.pins:\n if pin == self.anchor:\n continue\n dx, dy = pin[0] - x, pin[1] - y\n along = dx * horizontal + dy * vertical\n across = dx * vertical - dy * horizontal\n if 0 < along <= self.length and abs(across) <= PIN_RADIUS:\n target = pin\n if target is None:\n return 0.0\n self.anchor = target\n self.length = REST_LENGTH\n return float(ceil(hypot(target[0] - x, target[1] - y)))\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.steps += 1\n self.angle = (self.angle + (2 if self.steps >= 200 else 1)) % ANGLE_COUNT\n if action == 5:\n self.length = min(EDGE * 2, self.length + 2)\n else:\n self.length -= (self.length - REST_LENGTH + 3) // 4\n advance = max(1, (64 - self.anchor[1]) // 8)\n self.scroll += advance\n x, y = self.anchor\n self.anchor = x, y + advance\n self.pins = [(x, y + advance) for x, y in self.pins if y + advance < EDGE]\n while self.next_pin <= self.scroll:\n pin = int(self.random.integers(UNIT, EDGE - UNIT)), self.scroll - self.next_pin\n self.pins.append(pin)\n self.next_pin += int(self.random.integers(4, 13))\n if self.anchor[1] >= EDGE:\n self.terminal = True\n return 0.0, True\n reward = self._catch()\n self.terminal = self.steps >= self.horizon\n return reward, self.terminal\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n x, y = self.anchor\n state[min(9, y // UNIT), x // UNIT, 0] = True\n for px, py in self.pins:\n state[py // UNIT, px // UNIT, 2] = True\n angle = self.angle * 2 * pi / ANGLE_COUNT\n for distance in range(self.length + 1):\n px = round(x + cos(angle) * distance)\n py = round(y + sin(angle) * distance)\n if 0 <= px < EDGE and 0 <= py < EDGE:\n state[py // UNIT, px // UNIT, 3] = True\n values = (self.steps, self.angle, self.length, self.next_pin - self.scroll,\n int(self.last_action == 5), x, y)\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 75, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pin_climb.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePinClimb.c"} +{"name": "bore_comet", "split": "train", "game": "bore_comet", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Bore Comet as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to thrust upward and drill. Release with actions\n0–4 to fall. Drilling inside a rock scores one point per simulation\nframe and slows vertical movement. Once enough progress accumulates,\nthe rock breaks for a bonus. Breaking a rock or leaving it while\nstill drilling can blast nearby enemies. A blast that kills multiple\nenemies awards three times the square of the kill count.\n\nINPUT CHANNEL TABLE\nReleasing inside a rock, touching an enemy outside a rock, or\nfalling into the sea ends the run. The six 10×10 channels show the\nplayer, rocks, enemies, sea, drill status, and gauges. Each action\nadvances four frames at fixed difficulty. Blasts briefly freeze\nsimulation and use distance to the player to determine hits.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 500] and divide by the fixed cap of 500.\n\nAcross 100 seeds without sticky actions, idle and always held\nscored zero. Random inputs averaged 1.15 raw points. A heuristic\nusing exact rock positions averaged 38.12 and reached 197.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/bore_comet.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\nPLAYER_X = 35\nSCROLL = 0.6\n\n\n@dataclass\nclass Rock:\n x: float\n y: float\n width: float\n height: float\n bore: int = 0\n\n @property\n def threshold(self) -> int:\n return round(math.sqrt(self.width * self.height) / (SCROLL / 0.5))\n\n def contains(self, y: float) -> bool:\n return abs(self.x - PLAYER_X) < self.width / 2 + 2 and abs(self.y - y) < self.height / 2 + 2\n\n\n@dataclass\nclass Enemy:\n x: float\n y: float\n vx: float\n\n\nclass BoreCometEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.freeze = 0\n self.pressed = self.terminal = self.was_in_rock = False\n self.y, self.vy = 30.0, 0.0\n self.next_rock, self.next_enemy = 20.0, 60\n self.rocks: list[Rock] = []\n self.enemies: list[Enemy] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(FRAMES_PER_STEP):\n reward += self._advance_frame()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self) -> int:\n if self.freeze:\n self.freeze -= 1\n return 0\n rock = next((rock for rock in reversed(self.rocks) if rock.contains(self.y)), None)\n if rock is not None and not self.pressed:\n self.terminal = True\n return 0\n\n reward = 0\n if self.pressed:\n self.vy -= 0.06 if rock is not None else 0.11\n if rock is not None:\n rock.bore += 1\n reward += 1\n if rock.bore >= rock.threshold:\n reward += rock.threshold + self._blast(15 + (rock.width + rock.height) / 4, 3)\n self.rocks.remove(rock)\n rock = None\n self.vy = min(1.8, max(-1.5, self.vy + 0.05))\n self.y += self.vy * (0.45 if rock is not None else 1)\n if self.y < 10:\n self.y, self.vy = 10, 0\n if self.was_in_rock and rock is None and self.pressed:\n reward += self._blast(22, 2)\n self.was_in_rock = rock is not None\n\n self._spawn()\n for obstacle in self.rocks:\n obstacle.x -= SCROLL\n self.rocks = [obstacle for obstacle in self.rocks if obstacle.x >= -20]\n for enemy in self.enemies:\n enemy.x += enemy.vx\n if rock is None and math.hypot(enemy.x - PLAYER_X, enemy.y - self.y) < 5:\n self.terminal = True\n self.enemies = [enemy for enemy in self.enemies if enemy.x >= -8]\n self.terminal |= self.y > 91\n return reward\n\n def _blast(self, radius: float, freeze: int) -> int:\n survivors = [enemy for enemy in self.enemies if math.hypot(enemy.x - PLAYER_X, enemy.y - self.y) >= radius]\n kills = len(self.enemies) - len(survivors)\n self.enemies = survivors\n if kills or freeze == 3:\n self.freeze = max(self.freeze, min(8, freeze + kills))\n return 3 * kills**2\n\n def _spawn(self) -> None:\n self.next_rock -= SCROLL\n if self.next_rock < 0:\n self.rocks.append(Rock(112, self.random.uniform(25, 75), self.random.uniform(14, 30), self.random.uniform(10, 22)))\n self.next_rock = self.random.uniform(30, 55)\n self.next_enemy -= 1\n if self.next_enemy < 0:\n self.enemies.append(Enemy(105, self.random.uniform(8, 84), -SCROLL - self.random.uniform(0.2, 0.5)))\n self.next_enemy = int(self.random.integers(50, 91))\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row = int(self.y) // 10\n state[row, 3, 0] = True\n state[row, 3, 4] = self.pressed\n state[9, :, 3] = True\n for rock in self.rocks:\n for row in range(10):\n if abs(row * 10 + 5 - rock.y) < rock.height / 2 + 5:\n for column in range(10):\n state[row, column, 1] |= abs(column * 10 + 5 - rock.x) < rock.width / 2 + 5\n for enemy in self.enemies:\n if 0 <= enemy.x < 100:\n state[int(enemy.y) // 10, int(enemy.x) // 10, 2] = True\n active_rock = next((rock for rock in reversed(self.rocks) if rock.contains(self.y)), None)\n for row, value in enumerate((self.steps, self.freeze, active_rock.bore if active_rock else 0)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.vy < 0, self.was_in_rock\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 76, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/bore_comet.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBoreComet.c"} +{"name": "levitation", "split": "train", "game": "levitation", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Levitation as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to toggle between levitating left and rolling\nright under gravity. Actions 0–4 release the button. A\ndescending roll bounces off platforms and scores the current\nmultiplier. Each bounce raises it, and toggling resets it.\nLeaving through either side or the bottom ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the two player modes, platforms,\nprojected height, side limits, and gauges. The conversion\nuses rectangular contact bounds and fixed difficulty. Each\naction advances four frames. The 400-action task clips raw\nscores to [0, 100] and divides by 100.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/levitation.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Platform:\n x: float\n y: float\n width: float\n\n\nclass LevitationEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x = self.y = 40.0\n self.vy = self.spawn_distance = 0.0\n self.platforms = [Platform(0, 60, 99)]\n self.steps = 0\n self.multiplier = 1\n self.rolling = self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed:\n self.rolling = not self.rolling\n self.multiplier = 1\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self) -> int:\n self.x += 0.2 if self.rolling else -0.4\n self.vy = (self.vy + 0.2) * 0.99 if self.rolling else 0\n self.y += self.vy\n if self.y < 0 and self.vy < 0:\n self.y = 0\n self.vy *= -0.3\n self.spawn_distance -= 0.5\n if self.spawn_distance < 0:\n width = self.random.uniform(30, 50)\n self.platforms.append(Platform(100, self.random.uniform(30, 90), width))\n self.spawn_distance = width + self.random.uniform(0, 9)\n self.terminal = self.y > 100 or not -3 <= self.x <= 103\n if self.terminal:\n return 0\n reward = 0\n for platform in self.platforms:\n if (self.rolling and self.vy >= 0 and platform.x - 3 < self.x < platform.x + platform.width + 3\n and platform.y - 3 < self.y < platform.y + 8):\n reward += self.multiplier\n self.multiplier += 1\n self.y = platform.y - 3\n self.vy *= -1.5\n platform.x -= 0.5\n self.platforms = [p for p in self.platforms if p.x + p.width >= 0]\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n col = min(9, max(0, int(self.x // 10)))\n row = min(9, max(0, int(self.y // 10)))\n state[row, col, int(self.rolling)] = True\n for platform in self.platforms:\n left = max(0, int(platform.x // 10))\n right = min(9, int((platform.x + platform.width) // 10))\n state[int(platform.y // 10), left:right + 1, 2] = True\n future_row = min(9, max(0, int((self.y + 4 * self.vy) // 10)))\n state[future_row, col, 3] = True\n state[:, (0, 9), 4] = True\n gauges = (self.steps, min(511, self.multiplier), min(511, max(0, round((self.vy + 25) * 10))))\n for row, value in enumerate(gauges):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 77, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/levitation.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameLevitation.c"} +{"name": "geoerase", "split": "train", "game": "geoerase", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Geoerase as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to mark enemies with the rotating beam. Release\nwith actions 0–4 to erase marked enemies. Squares move faster\nand score two base points. Other enemies score one. Erasing\nmultiple enemies together raises the multiplier, while smaller\nclears reduce it. Enemy contact ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, triangles, squares, marks,\nbeam, and gauges. Each action advances four frames at fixed\ndifficulty. The conversion uses rectangular body collision checks.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action task clips raw scores to [0, 100] and divides by\n100. Across 100 seeds without sticky actions, idle scored zero\nand random inputs averaged 6.93. Holding for 34 actions and\nreleasing for one averaged 8.54 and reached 112 before clipping.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/geoerase.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Enemy:\n x: float\n y: float\n vx: float\n vy: float\n square: bool\n marked: bool = False\n\n\nclass GeoeraseEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.spawn_timer = 0\n self.angle = 0.0\n self.combo = 1\n self.pressed = self.terminal = False\n self.enemies: list[Enemy] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n release = self.pressed and not pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(release and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, release: bool) -> int:\n self.spawn_timer -= 1\n if self.spawn_timer <= 0:\n self._spawn()\n self.spawn_timer = 60\n self.angle = (self.angle + (0.04 if self.pressed else 0.08)) % math.tau\n reward = 0\n if release:\n marked = [enemy for enemy in self.enemies if enemy.marked]\n reward = self.combo * sum(2 if enemy.square else 1 for enemy in marked)\n self.combo = min(16, self.combo + len(marked) - 1) if len(marked) > 1 else max(1, self.combo - 1)\n self.enemies = [enemy for enemy in self.enemies if not enemy.marked]\n for enemy in self.enemies:\n if self.pressed:\n dx, dy = enemy.x - 50, enemy.y - 50\n difference = (math.atan2(dy, dx) - self.angle + math.pi) % math.tau - math.pi\n enemy.marked |= 3 < math.hypot(dx, dy) < 60 and abs(difference) < 0.2\n enemy.x += enemy.vx\n enemy.y += enemy.vy\n self.terminal |= abs(enemy.x - 50) < 5.5 and abs(enemy.y - 50) < 5.5\n return reward\n\n def _spawn(self) -> None:\n offset = self.random.uniform(0, 100)\n side = int(self.random.integers(4))\n x, y = ((offset, -5), (offset, 105), (-5, offset), (105, offset))[side]\n square = self.random.random() < 0.3\n speed = 0.4 if square else 0.25\n angle = math.atan2(50 - y, 50 - x)\n self.enemies.append(Enemy(x, y, speed * math.cos(angle), speed * math.sin(angle), square))\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[5, 5, 0] = True\n for enemy in self.enemies:\n if 0 <= enemy.x < 100 and 0 <= enemy.y < 100:\n row, col = int(enemy.y) // 10, int(enemy.x) // 10\n state[row, col, 2 if enemy.square else 1] = True\n state[row, col, 3] |= enemy.marked\n for distance in range(0, 61, 4):\n x = 50 + math.cos(self.angle) * distance\n y = 50 + math.sin(self.angle) * distance\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y) // 10, int(x) // 10, 4] = True\n for row, value in enumerate((self.steps, self.combo, round(self.angle * 80))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 78, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/geoerase.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameGeoerase.c"} +{"name": "magnetic_pendulum", "split": "train", "game": "magnetic_pendulum", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Magnetic Pendulum as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to shorten the rope. Actions 0–4 let it extend.\nNearby magnets pull the swinging bob. Catch a magnet to\nscore the current multiplier, raise it up to nine, and lower\nthe floor. Missing a magnet raises the floor and resets the\nmultiplier. The run ends when the bob touches the floor.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the bob, rope, magnets, magnets\nwithin attraction range, floor, and gauges. The conversion\nuses rectangular catch bounds and four frames per action at\nfixed difficulty. Over 400 actions there can be at most 22\nmagnets. Catching all in sequence would score 162, the cap\nused to normalize raw scores to 0–1.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/magnetic_pendulum.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Magnet:\n x: float\n y: float = 0\n\n\nclass MagneticPendulumEnvironment:\n score_cap = 162\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 50.0, 71.0\n self.length, self.angle, self.angular_velocity = 66.0, 0.0, 0.024\n self.floor = self.target_floor = 100.0\n self.spawn_timer = 70\n self.steps = 0\n self.multiplier = 1\n self.pressed = self.terminal = False\n self.magnets: list[Magnet] = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n self.target_floor = min(100, self.target_floor + 0.01)\n self.floor += (self.target_floor - self.floor) * 0.5\n self.length = min(66, max(10, self.length + (-1 if self.pressed else 1)))\n self.spawn_timer -= 1\n if self.spawn_timer == 0:\n self.magnets.append(Magnet(self.random.uniform(15, 85)))\n self.spawn_timer = 70\n sine, cosine = math.sin(self.angle), math.cos(self.angle)\n tangent = 0.0\n for magnet in self.magnets:\n dx, dy = magnet.x - self.x, magnet.y - self.y\n distance = math.hypot(dx, dy)\n if 0 < distance < 30:\n tangent += 0.15 * (1 - distance / 30) * (dx * cosine - dy * sine) / distance\n self.angular_velocity = (self.angular_velocity + (tangent - 0.13 * sine) / self.length) * 0.99\n self.angle += self.angular_velocity\n self.x = 50 + math.sin(self.angle) * self.length\n self.y = 5 + math.cos(self.angle) * self.length\n self.terminal = self.y + 3 > self.floor\n if self.terminal:\n return 0\n reward = 0\n remaining = []\n for magnet in self.magnets:\n magnet.y += 0.45\n if abs(magnet.x - self.x) < 6 and abs(magnet.y - self.y) < 6:\n reward += self.multiplier\n self.multiplier = min(9, self.multiplier + 1)\n self.target_floor = min(100, self.target_floor + 2)\n elif magnet.y + 4 > self.floor:\n self.target_floor = max(0, self.target_floor - 10)\n self.multiplier = 1\n else:\n remaining.append(magnet)\n self.magnets = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for fraction in np.linspace(0, 1, 16):\n x = 50 + fraction * (self.x - 50)\n y = 5 + fraction * (self.y - 5)\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), 1] = True\n state[min(9, max(0, int(self.y // 10))), min(9, max(0, int(self.x // 10))), 0] = True\n for magnet in self.magnets:\n row, col = int(magnet.y // 10), int(magnet.x // 10)\n state[row, col, 2] = True\n state[row, col, 3] |= math.hypot(magnet.x - self.x, magnet.y - self.y) < 30\n state[math.floor(self.floor / 10):, :, 4] = True\n values = (self.steps, int(self.length), self.multiplier, round(self.floor * 4),\n round((self.angular_velocity + 0.25) * 1000))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(min(511, max(0, value)) & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 79, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/magnetic_pendulum.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameMagneticPendulum.c"} +{"name": "boarding", "split": "train", "game": "boarding", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Boarding as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nPress and release action 5 once to activate boarding. After that,\nhold 5 to dispatch passengers and slow the moving launcher. Release\nwith actions 0–4 to switch passenger color and resume normal launcher\nspeed. Left and right gates accept their matching colors.\n\nDiagonal boards deflect passengers. A correct arrival scores one\npoint per bounce and pushes the gates down, buying time. An incorrect\narrival loses one point plus the bounce count and moves the gates up.\nThe run ends when the gates reach the top or after 400 actions.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the launcher, gates and launcher status,\nthe two board slopes, and the two passenger colors. Each action\nadvances four frames at fixed difficulty. The conversion uses\ndiagonal line crossings for deflections in place of sprite collisions.\n\nSCORING, TERMINATION, AND HORIZON\nSum signed scoring events within each episode. Clip the mean across\nepisodes to\n[0, 250], and divide by the fixed cap of 250.\n\nAcross 100 seeds without sticky actions, idle averaged zero and\nrandom inputs averaged −27.11 raw points. A heuristic that simulated\npassenger paths using exact board positions averaged 126.54 and\nreached 207.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/boarding.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\n\n\n@dataclass\nclass Board:\n x: float\n y: float\n slope: int\n\n\n@dataclass\nclass Passenger:\n x: float\n y: float\n kind: int\n vx: float = 0\n vy: float = 0\n bounces: int = 0\n\n\nclass BoardingEnvironment:\n score_cap = 250\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.cooldown = 0\n self.pressed = self.ready = self.terminal = False\n self.x, self.direction, self.kind = 50.0, -1, -1\n self.gate = self.gate_target = 91.0\n self.board_credit = 0\n self.boards: list[Board] = []\n self.passengers: list[Passenger] = []\n for y in range(47, 88, 2):\n self._add_board(y)\n\n def _add_board(self, y: float) -> None:\n x = self.random.uniform(9, 90)\n if all(math.hypot(board.x - x, board.y - y) >= 16 for board in self.boards):\n self.boards.append(Board(x, y, int(self.random.choice((-1, 1)))))\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n released = self.pressed and not pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(FRAMES_PER_STEP):\n reward += self._advance_frame(released and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self, released: bool) -> int:\n for board in self.boards:\n board.y -= 0.1\n self.boards = [board for board in self.boards if 15 < board.y < self.gate]\n self.gate_target = max(11, self.gate_target - 0.1)\n self.gate += (self.gate_target - self.gate) * 0.1\n if self.gate <= 12:\n self.terminal = True\n return 0\n if self.board_credit >= 2:\n self._add_board(self.gate - 3)\n self.board_credit -= 2\n\n self.cooldown = max(0, self.cooldown - 1)\n boarding = self.pressed and self.ready\n if boarding and not self.cooldown:\n self.passengers.append(Passenger(self.x, 9, self.kind))\n self.cooldown = 10\n self.x += self.direction * (0.1 if boarding else 1)\n if self.x < 10 or self.x > 90:\n self.direction = 1 if self.x < 10 else -1\n if released:\n if self.ready:\n self.kind *= -1\n self.ready = True\n\n reward = 0\n survivors = []\n for passenger in self.passengers:\n self._move_passenger(passenger)\n if passenger.y <= self.gate:\n survivors.append(passenger)\n elif (passenger.x - 50) * passenger.kind > 0:\n reward += passenger.bounces\n self.gate_target = min(91, self.gate_target + 2 * passenger.bounces)\n self.board_credit += passenger.bounces\n else:\n reward -= 1 + passenger.bounces\n self.gate_target -= min(20, math.sqrt(1 + passenger.bounces))\n self.passengers = survivors\n return reward\n\n def _move_passenger(self, passenger: Passenger) -> None:\n old_x, old_y = passenger.x, passenger.y\n passenger.vx *= 0.9\n passenger.vy = (passenger.vy + 0.2) * 0.9\n passenger.x += passenger.vx\n passenger.y += passenger.vy\n for board in self.boards:\n previous = old_y - board.y - board.slope * (old_x - board.x)\n current = passenger.y - board.y - board.slope * (passenger.x - board.x)\n if previous > 0 or current < 0 or current == previous:\n continue\n crossing_x = old_x + (passenger.x - old_x) * (-previous / (current - previous))\n if abs(crossing_x - board.x) <= 4:\n impulse = math.hypot(passenger.vx, passenger.vy) * math.sqrt(2)\n passenger.vx += board.slope * impulse\n passenger.vy += impulse\n passenger.x += 2 * passenger.vx\n passenger.y += 2 * passenger.vy\n passenger.bounces += 1\n break\n if passenger.x < 0 or passenger.x > 99:\n passenger.x = min(99, max(0, passenger.x))\n passenger.vx *= -1\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[0, int(self.x) // 10, 0] = True\n state[int(self.gate) // 10, :, 1] = True\n for board in self.boards:\n state[int(board.y) // 10, int(board.x) // 10, 2 if board.slope < 0 else 3] = True\n for passenger in self.passengers:\n state[int(passenger.y) // 10, int(passenger.x) // 10, 4 if passenger.kind < 0 else 5] = True\n state[0, :4, 1] = self.kind > 0, self.direction > 0, self.ready, self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 80, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/boarding.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/boarding/main.js"} +{"name": "pitfall", "split": "train", "game": "pitfall", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Pitfall as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves the fixed jungle map, 32 treasures, three lives, 20-minute pressure,\nsurface and underground routes, ladders, three-scene tunnel shortcuts, dead-space routing, rolling\nlogs, open holes, lethal pits, crocodiles, snakes, fire, scorpions, jumping, and vine swinging.\nThe treasure distribution has eight each of money bags, silver bars, gold bars, and diamond rings.\n\nACTION MAPPING\n0: wait\n1: run left\n2: climb up a ladder\n3: run right\n4: climb down or release vine\n5: jump or grab vine\n\nINPUT CHANNEL TABLE\n0: Pitfall Harry\n1: logs, pits, crocodiles, snakes, fire, and scorpion\n2: treasure and remaining lives\n3: ground, tunnel, ladders, gaps, and vine\n4: previous Harry, log, scorpion, and vine positions\n5: all 32 treasure identities, exact scene/level/lives/steps, stance timers, and hazard directions\n\nSCORING, TERMINATION, AND HORIZON\nHarry begins with 2,000 points. Eight each of the 2,000-point money bag, 3,000-point silver bar,\n4,000-point gold bar, and 5,000-point diamond ring total 112,000. With no deductions, the exact\nperfect score and `score_cap` are 114,000. Normalization is\n`min(max(raw_score, 0), 114_000) / 114_000`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/pitfall.py`):\n```python\nimport numpy as np\n\n\nTREASURE_VALUES = (2_000, 3_000, 4_000, 5_000)\nTREASURE_SCENES = tuple(range(16)) + tuple(range(32, 48))\n\n\nclass PitfallEnvironment:\n \"\"\"Mapped surface-and-tunnel treasure hunt across a 64-scene ring.\"\"\"\n\n score_cap = 114_000.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 500):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.scene = 0\n self.player = [4, 1]\n self.previous_player = self.player.copy()\n self.level = 0\n self.lives = 3\n self.score = 2_000.0\n self.steps = 0\n self.last_action = 0\n self.jump_timer = 0\n self.swing_timer = 0\n self.terminal = False\n self.claimed: set[int] = set()\n self.log_column = 8\n self.scorpion_column = 8\n self.scorpion_direction = -1\n self.vine_column = 4\n self.vine_direction = 1\n self.previous_log_column = self.log_column\n self.previous_scorpion_column = self.scorpion_column\n self.previous_vine_column = self.vine_column\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n self.previous_log_column = self.log_column\n self.previous_scorpion_column = self.scorpion_column\n self.previous_vine_column = self.vine_column\n scene_before = self.scene\n self._move_player(action)\n reward = self._collect_treasure()\n if self.scene == scene_before and not self.terminal:\n self._move_hazards()\n reward += self._resolve_hazards()\n self.score = max(0.0, self.score + reward)\n self.steps += 1\n self.jump_timer = max(0, self.jump_timer - 1)\n self.swing_timer = max(0, self.swing_timer - 1)\n if self.steps >= self.horizon or len(self.claimed) == 32:\n self.terminal = True\n return reward, self.terminal\n\n def _move_player(self, action: int) -> None:\n if self.swing_timer:\n self.player[1] = self.vine_column\n if action == 4:\n self.swing_timer = 0\n self.jump_timer = 2\n return\n if action == 5:\n if self.level == 0 and abs(self.player[1] - self.vine_column) <= 1 and self._hazard_kind() == \"pit\":\n self.swing_timer = 4\n self.player[1] = self.vine_column\n else:\n self.jump_timer = 3\n self.player[0] = 2 if self.level == 0 else 6\n return\n if action == 1:\n self.player[1] -= 1\n elif action == 3:\n self.player[1] += 1\n elif action == 4 and self.level == 0 and self._has_ladder() and self.player[1] == 5:\n self.level = 1\n self.player = [8, 5]\n elif action == 2 and self.level == 1 and self._has_ladder() and self.player[1] == 5:\n self.level = 0\n self.player = [4, 5]\n if self.jump_timer == 0:\n self.player[0] = 4 if self.level == 0 else 8\n if self.player[1] < 0:\n self._change_scene(-1)\n elif self.player[1] > 9:\n self._change_scene(1)\n\n def _change_scene(self, direction: int) -> None:\n distance = 1 if self.level == 0 else 3\n self.scene = (self.scene + direction * distance) % 64\n self.player = [4 if self.level == 0 else 8, 9 if direction < 0 else 0]\n self.previous_player = self.player.copy()\n self.log_column = 8\n self.scorpion_column = 8\n self.scorpion_direction = -1\n self.vine_column = 4\n self.vine_direction = 1\n self.previous_log_column = self.log_column\n self.previous_scorpion_column = self.scorpion_column\n self.previous_vine_column = self.vine_column\n\n def _has_ladder(self) -> bool:\n return self.scene % 4 == 0\n\n def _hazard_kind(self) -> str:\n kinds = (\"logs\", \"pit\", \"crocodiles\", \"snake\", \"fire\", \"hole\", \"clear\")\n return kinds[self.scene % len(kinds)]\n\n def _collect_treasure(self) -> float:\n if self.level or self.scene not in TREASURE_SCENES or self.scene in self.claimed:\n return 0.0\n if self.player != [4, 8]:\n return 0.0\n self.claimed.add(self.scene)\n treasure_index = TREASURE_SCENES.index(self.scene)\n return float(TREASURE_VALUES[treasure_index % 4])\n\n def _move_hazards(self) -> None:\n if self.level == 0:\n if self._hazard_kind() == \"logs\":\n self.log_column -= 1\n if self.log_column < 0:\n self.log_column = 9\n if self._hazard_kind() == \"pit\":\n self.vine_column += self.vine_direction\n if self.vine_column in (3, 7):\n self.vine_direction *= -1\n else:\n self.scorpion_column += self.scorpion_direction\n if self.scorpion_column in (1, 8):\n self.scorpion_direction *= -1\n\n def _resolve_hazards(self) -> float:\n if self.level == 1:\n if self.player == [8, self.scorpion_column] and self.jump_timer == 0:\n self._lose_life()\n return 0.0\n kind = self._hazard_kind()\n if kind == \"logs\" and self.player[1] == self.log_column and self.jump_timer == 0:\n return -10.0\n if kind == \"hole\" and self.player[1] in (4, 5) and self.jump_timer == 0:\n self.level = 1\n self.player = [8, 5]\n return -100.0\n dangerous = (\n kind == \"pit\" and self.player[1] in (4, 5, 6) and self.jump_timer == 0 and self.swing_timer == 0\n ) or (kind == \"crocodiles\" and self.player[1] in (4, 5, 6) and self.jump_timer == 0) or (\n kind in (\"snake\", \"fire\") and self.player[1] == 6 and self.jump_timer == 0\n )\n if dangerous:\n self._lose_life()\n return 0.0\n\n def _lose_life(self) -> None:\n self.lives -= 1\n if self.lives <= 0:\n self.terminal = True\n return\n self.player = [4 if self.level == 0 else 8, 1]\n self.previous_player = self.player.copy()\n self.jump_timer = 0\n self.swing_timer = 0\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n state[*self.previous_player, 4] = True\n if self.scene in TREASURE_SCENES and self.scene not in self.claimed:\n state[4, 8, 2] = True\n state[4, :, 3] = True\n state[8, :, 3] = True\n if self._has_ladder():\n state[4:9, 5, 3] = True\n kind = self._hazard_kind()\n if self.level == 0:\n if kind == \"logs\":\n state[4, self.log_column, 1] = True\n state[4, self.previous_log_column, 4] = True\n elif kind in (\"pit\", \"crocodiles\", \"hole\"):\n state[4, 4:7, 3] = False\n state[5, 4:7, 1] = True\n elif kind in (\"snake\", \"fire\"):\n state[4, 6, 1] = True\n if kind == \"pit\":\n state[1:5, self.vine_column, 3] = True\n state[1:5, self.previous_vine_column, 4] = True\n else:\n state[8, self.scorpion_column, 1] = True\n state[8, self.previous_scorpion_column, 4] = True\n for index, scene in enumerate(TREASURE_SCENES):\n state[index // 10, index % 10, 5] = scene in self.claimed\n for bit in range(6):\n index = 32 + bit\n state[index // 10, index % 10, 5] = bool(self.scene & (1 << bit))\n state[3, 8, 5] = bool(self.level)\n for bit in range(2):\n index = 39 + bit\n state[index // 10, index % 10, 5] = bool(self.lives & (1 << bit))\n for bit in range(9):\n index = 41 + bit\n state[index // 10, index % 10, 5] = bool(self.steps & (1 << bit))\n for bit in range(2):\n state[5, bit, 5] = bool(self.jump_timer & (1 << bit))\n state[5, 2 + bit, 5] = bool(self.swing_timer & (1 << bit))\n state[5, 4, 5] = self.scorpion_direction > 0\n state[5, 5, 5] = self.vine_direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 81, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pitfall.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "fish_grill", "split": "train", "game": "fish_grill", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Fish Grill as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to rise and leave a short-lived hot updraft beneath\nthe ember. Release with actions 0–4 to fall. Cook passing fish\nwith the updraft. Heating a fish restores energy and scores\nmore on the first contact than on subsequent frames. Touching\na fish with the ember or leaving the screen ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the ember, raw fish, cooked fish,\nupdrafts, upward motion, and gauges. Each action advances four\nframes. The conversion approximates the original particle\ncollisions with a fixed updraft hit area and uses a distance\ncheck for the ember.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action task clips raw scores to [0, 500] and divides by\n500. Across 100 seeds without sticky actions, idle scored zero\nand random inputs averaged 1.51. A heuristic using exact fish\npositions averaged 121.53 and reached 754 before clipping.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/fish_grill.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nEMBER_X = 20\n\n\n@dataclass\nclass Fish:\n x: float\n y: float\n width: float\n burned: bool = False\n\n\n@dataclass\nclass Updraft:\n y: float\n timer: int = 10\n\n\nclass FishGrillEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = 0\n self.pressed = self.terminal = False\n self.y, self.velocity = 50.0, 0.0\n self.energy = self.base_energy = 100.0\n self.fish = [Fish(100, 50, 15)]\n self.updrafts: list[Updraft] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self) -> int:\n self.velocity += 0.1\n self.y += self.velocity\n self.base_energy += 0.1\n self.energy += (self.base_energy - self.energy) * 0.01\n radius = 1 + self.energy / 50\n if self.pressed:\n self.velocity = -1\n self.updrafts.append(Updraft(self.y + radius))\n for updraft in self.updrafts:\n updraft.timer -= 1\n self.updrafts = [updraft for updraft in self.updrafts if updraft.timer > 0]\n\n reward = 0\n for fish in self.fish:\n fish.x -= 1\n horizontal_gap = abs(fish.x - EMBER_X) - fish.width / 2\n if horizontal_gap <= 3 and any(abs(fish.y - updraft.y - 2.5) <= 6 for updraft in self.updrafts):\n self.energy += 5\n reward += math.floor(self.energy / (100 if fish.burned else 10))\n fish.burned = True\n distance = math.hypot(max(0, horizontal_gap), max(0, abs(fish.y - self.y) - 3))\n self.terminal |= distance <= radius + 1.5\n self.fish = [fish for fish in self.fish if fish.x + fish.width >= 0]\n if self.fish[-1].x < 100:\n self.fish.append(Fish(self.fish[-1].x + self.random.uniform(50, 80),\n self.random.uniform(10, 90), self.random.uniform(10, 20)))\n self.terminal |= not -radius <= self.y <= 100 + radius\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row = min(9, max(0, int(self.y) // 10))\n state[row, 2, 0] = True\n state[row, 2, 4] = self.velocity < 0\n for fish in self.fish:\n left = max(0, math.floor((fish.x - fish.width / 2) / 10))\n right = min(10, math.ceil((fish.x + fish.width / 2) / 10))\n if left < right:\n state[int(fish.y) // 10, left:right, 2 if fish.burned else 1] = True\n for updraft in self.updrafts:\n if 0 <= updraft.y < 100:\n state[int(updraft.y) // 10, 2, 3] = True\n for row, value in enumerate((self.steps, round(self.energy), round(self.velocity * 10) + 128)):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 82, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/fish_grill.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameFishGrill.c"} +{"name": "knight_vs_pawns", "split": "train", "game": "knight_vs_pawns", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Knight Vs Pawns as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to move the knight to the ghost marker. Actions\n0–4 release the button. The ghost cycles through legal moves\nevery 30 frames and advances after each accepted move.\nMoving scores eight minus the destination row, counted from\nzero at the top. Sharing a square with a pawn ends the run.\n\nINPUT CHANNEL TABLE\nPawns spawn at the top every 120 frames and move down one\nrow every 60 frames. The six 10×10 channels show the knight,\nghost, pawns, next pawn squares, board, and gauges. Each\naction advances four frames at fixed difficulty. The 400-action\ntask clips raw scores to [0, 1200] and divides by 1200.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/knight_vs_pawns.py`):\n```python\nimport numpy as np\n\n\nMOVES = ((1, -2), (2, -1), (2, 1), (1, 2), (-1, 2), (-2, 1), (-2, -1), (-1, -2))\n\n\nclass KnightVsPawnsEnvironment:\n score_cap = 1200\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.knight = (3, 7)\n self.ghost = (5, 6)\n self.move_index = self.steps = self.frames = 0\n self.pressed = self.terminal = False\n self.pawns: list[tuple[int, int]] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap: bool) -> int:\n if self.frames % 30 == 0:\n self._cycle_ghost()\n reward = 0\n if tap:\n self.knight = self.ghost\n self._cycle_ghost()\n reward = 8 - self.knight[1]\n if self.frames % 60 == 0:\n self.pawns = [(x, y + 1) for x, y in self.pawns if y < 7]\n if self.frames % 120 == 0:\n self.pawns.append((int(self.random.integers(8)), 0))\n self.frames += 1\n self.terminal = self.knight in self.pawns\n return reward\n\n def _cycle_ghost(self) -> None:\n x, y = self.knight\n for _ in MOVES:\n dx, dy = MOVES[self.move_index]\n self.move_index = (self.move_index + 1) % len(MOVES)\n if 0 <= x + dx < 8 and 0 <= y + dy < 8:\n self.ghost = (x + dx, y + dy)\n return\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n x, y = self.knight\n state[y + 1, x + 1, 0] = True\n x, y = self.ghost\n state[y + 1, x + 1, 1] = True\n for x, y in self.pawns:\n state[y + 1, x + 1, 2] = True\n if y < 7:\n state[y + 2, x + 1, 3] = True\n state[1:9, 1:9, 4] = True\n values = (self.steps, self.frames % 120, self.move_index)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 83, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/knight_vs_pawns.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameKnightVsPawns.c"} +{"name": "shiny", "split": "train", "game": "shiny", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Shiny as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to bring in rain. Actions 0–4 release. Walkers switch\nbetween walking and running at their next gait update. Heavy drops\ncan break ground tiles, which recover over time. The final tile\nerodes as time passes and with each new rain press. Walkers who\nreach the far edge score the remaining final tile size times the\nnumber alive at the start of that frame, rounded down.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show walkers, falling walkers, ground\ngaps, heavy drops, clouds, and counters. The port fixes difficulty\nand approximates sprite contacts with rectangular bounds. Each\naction advances up to four frames over a 400-action horizon.\nClip episode scores to [0, 300] and divide by 300.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/shiny.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import floor\n\nimport numpy as np\n\n\n@dataclass\nclass Human:\n speed: float\n phase: int\n x: float = -4\n y: float = 89\n running: bool = False\n falling: bool = False\n\n\n@dataclass\nclass Drop:\n x: float\n y: float\n vx: float\n strong: bool\n\n\nclass ShinyEnvironment:\n score_cap = 300\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.ground = np.full(22, 8.0)\n self.cloud_x = np.arange(1, 31) * 199 / 31 + self.random.uniform(-3, 3, 30)\n self.cloud_y = self.random.uniform(5, 15, 30)\n self.cloud_radius = self.random.uniform(5, 10, 30)\n self.weak_timer = self.random.uniform(0, 99, 30)\n self.strong_timer = self.random.uniform(100, 900, 30)\n self.rain = self.steps = self.population = 0\n self.wind = 0.\n self.held = self.terminal = False\n self.humans, self.drops = [], []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _cloud_positions(self):\n clear = np.where(self.cloud_x < 99, -20, 220)\n return clear + (self.cloud_x - clear) * self.rain / 10\n\n def _advance(self, tap):\n if not self.humans:\n self.population = min(9, self.population + 1)\n self.humans = [Human(self.random.uniform(0.1, 0.15), self.random.integers(999))\n for _ in range(self.population)]\n self.ground[20] = 8\n if tap:\n self.wind = self.random.uniform(-0.5, 0.5)\n self.ground[20] -= 0.1\n self.rain = min(10, max(0, self.rain + (1 if self.held else -1)))\n cloud_positions = self._cloud_positions()\n for timer, strong, bounds in ((self.weak_timer, False, (100, 200)),\n (self.strong_timer, True, (500, 999))):\n timer -= 1\n for index in np.flatnonzero(timer < 0):\n if self.held:\n self.drops.append(Drop(cloud_positions[index], self.cloud_y[index] + self.cloud_radius[index],\n self.wind + self.random.uniform(-0.2, 0.2), strong))\n timer[index] = self.random.uniform(*bounds)\n support = self.ground >= 8\n support[20] = self.ground[20] >= 1\n self.ground[:20] = np.minimum(self.ground[:20] + 0.12, 8)\n self.ground[21] = min(8, self.ground[21] + 0.12)\n if support[20]:\n self.ground[20] -= 0.005\n count = len(self.humans)\n reward = 0\n survivors = []\n for human in self.humans:\n if not human.falling:\n human.x += human.speed * (5 if human.running else 1)\n on_ground = human.y < 102 and any(\n intact and abs(human.x - (index * 10 - 5)) < 7\n for index, intact in enumerate(support)\n )\n human.falling = not on_ground\n human.y = 89 if on_ground else human.y + 1\n if human.y > 103:\n self.population -= 1\n self.terminal |= self.population <= 0\n continue\n human.phase += 1\n if human.phase % 30 == 0:\n human.running = self.held\n if human.x > 203:\n reward += max(0, floor(self.ground[20] * count))\n else:\n survivors.append(human)\n self.humans = survivors\n drops = []\n for drop in self.drops:\n drop.x += drop.vx\n drop.y += 1\n if drop.strong and any(not h.falling and abs(h.x - drop.x) < 4\n and abs(h.y - drop.y - 2) < 5 for h in self.humans):\n continue\n if drop.y <= 90:\n drops.append(drop)\n elif drop.strong:\n index = floor(drop.x / 10) + 1\n if 2 <= index < 20:\n self.ground[index] = 0\n self.drops = drops[-128:]\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for human in self.humans:\n col = int(np.clip(human.x // 20, 0, 9))\n state[min(9, int(human.y // 10)), col, int(human.falling)] = True\n for index in range(1, 21):\n size = self.ground[index]\n if (index == 20 and size < 1) or (index != 20 and size < 8):\n state[9, (index - 1) // 2, 2] = True\n for drop in self.drops:\n if drop.strong and 0 <= drop.x < 200:\n state[int(drop.y // 10), int(drop.x // 20), 3] = True\n for x, y in zip(self._cloud_positions(), self.cloud_y):\n if 0 <= x < 200:\n state[int(y // 10), int(x // 20), 4] = True\n values = (self.steps, self.population, self.rain, self.held, round(max(0, self.ground[20]) * 50))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 84, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/shiny.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameShiny.c"} +{"name": "wavy_bird", "split": "train", "game": "wavy_bird", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Wavy Bird as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to flap and emit an angled shockwave. Release with any\nother action before flapping again. Shockwaves break pillar blocks\nfor points. Each block pays the rounded-down multiplier and raises\nit by one. The multiplier decays over time. Hitting an intact block\nor leaving the screen vertically ends the run.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the bird, blocks, shockwaves, upward\nmovement, projected shockwave reach, and counters. The port fixes\ndifficulty and samples the bird and wave arcs for collision checks.\nEach action advances up to four frames over 400 actions. Clip\nepisode scores to [0, 500] and divide by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/wavy_bird.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, floor, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Wave:\n y: float\n angle: float\n radius: int = 0\n\n def points(self):\n for offset in (-0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3):\n angle = self.angle + offset\n yield 20 + self.radius * cos(angle), self.y + self.radius * sin(angle)\n\n\nclass WavyBirdEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.y, self.vy, self.angle = 50., 0., 0.\n self.blocks, self.waves = [], []\n self.distance = 0.\n self.multiplier = 1.\n self.steps = self.action = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n flap = self.action == 5 and previous != 5\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(flap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, flap):\n points = []\n for wave in self.waves:\n wave.radius += 2\n points.extend(wave.points())\n self.waves = [wave for wave in self.waves if wave.radius < 30]\n self.y += self.vy\n self.vy += 0.1\n self.angle += (1.2 - self.angle) * 0.02\n if flap:\n self.waves.append(Wave(self.y, self.angle - 0.4))\n self.vy = -1.5\n self.angle -= 0.6\n self.angle = min(1.2, max(-1.2, self.angle))\n self.terminal = not 0 <= self.y <= 99\n\n reward = 0\n remaining = []\n bird_points = [(20 + offset * cos(self.angle), self.y + offset * sin(self.angle))\n for offset in (-2.5, 0, 2.5)]\n for x, y in self.blocks:\n x -= 1\n if any(abs(x - wx) <= 5.5 and abs(y - wy) <= 5.5 for wx, wy in points):\n reward += floor(self.multiplier)\n self.multiplier += 1\n continue\n if any(abs(x - bx) <= 5.5 and abs(y - by) <= 5.5 for bx, by in bird_points):\n self.terminal = True\n if x >= -8:\n remaining.append((x, y))\n self.blocks = remaining\n\n self.distance -= 1\n if self.distance < 0:\n height = self.random.uniform(20, 60)\n y = self.random.uniform(0, 110 - height)\n self.blocks.extend((108, y + 8 * index) for index in range(int(height // 8)))\n self.distance += self.random.uniform(10, 40)\n self.multiplier = min(99, max(1, self.multiplier - 0.03))\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n row = int(np.clip(self.y // 10, 0, 9))\n state[row, 2, 0] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for x, y in self.blocks:\n state[:, :, 1] |= (abs(cols - x) < 9) & (abs(rows - y) < 9)\n for wave in self.waves:\n for x, y in wave.points():\n if 0 <= y < 100:\n state[int(y // 10), int(x // 10), 2] = True\n state[row, 2, 3] = self.vy < 0\n for x, y in Wave(self.y, self.angle - 0.4, 28).points():\n if 0 <= y < 100:\n state[int(y // 10), int(x // 10), 4] = True\n values = (self.steps, self.action, round((self.vy + 2) * 32),\n round((self.angle + 1.2) * 128), round(self.multiplier * 4),\n round(self.distance * 8))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 85, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/wavy_bird.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameWavyBird.c"} +{"name": "descents", "split": "train", "game": "descents", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Descents as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to thrust up. Release with actions 0–4 to descend.\nThe ship moves horizontally relative to the decks. Land on the\nnext deck at a downward speed of one or less. A hard landing,\nmissing the deck, or flying off the top ends the run.\n\nINPUT CHANNEL TABLE\nA landing scores the remaining distance to the far edge of the\ndeck and resets vertical speed. The next thrust and fall rates\ntake effect after each landing. The six 10×10 channels show the\nship, active deck, future decks, hazard boundary, speed flags,\nand gauges. The conversion uses fixed difficulty and geometric\nlanding checks. Each action advances four frames.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 500] and divide by 500. Across 100 seeds without sticky\nactions, idle scored 43 and random inputs averaged 5.17. A policy\nthat adjusted descent using exact deck positions averaged 326.89\nand reached 400.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/descents.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nSHIP_X = 9\n\n\n@dataclass\nclass Deck:\n x: float\n y: float\n width: float\n\n\nclass DescentsEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = 0\n self.pressed = self.terminal = False\n self.y, self.vy = 9.0, 0.0\n self.up, self.down, self.next_up, self.next_down = -2, 2, -3, 3\n self.decks = [Deck(30, 50, 40), Deck(50, 75, 35), Deck(70, 99, 30)]\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance_frame()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self) -> int:\n self.vy += (self.up if self.pressed else self.down) * 0.005\n self.y += self.vy\n scroll = (min(19, max(9, self.y)) - self.y) * 0.2\n self.y += scroll\n for deck in self.decks:\n deck.x -= 0.2\n deck.y += scroll\n first = self.decks[0]\n edge = first.x + first.width\n if self.y < 0 or edge < SHIP_X - 3:\n self.terminal = True\n return 0\n if first.x - 3 <= SHIP_X <= edge + 3 and abs(first.y - self.y) <= 2:\n if self.vy > 1:\n self.terminal = True\n return 0\n self.decks.pop(0)\n last = self.decks[-1]\n self.decks.append(Deck(last.x + last.width * 0.7 + self.random.uniform(0, 30),\n last.y + self.random.uniform(20, 40), self.random.uniform(25, 50)))\n self.up, self.down = self.next_up, self.next_down\n self.next_up = math.floor(-4 + self.random.uniform(-3, 3))\n self.next_down = math.floor(4 + self.random.uniform(-2, 2))\n self.vy = 0\n return max(0, math.floor(edge - SHIP_X + 1))\n if self.y >= first.y + 1:\n self.terminal = True\n return 0\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, max(0, int(self.y) // 10)), 0, 0] = True\n for index, deck in enumerate(self.decks):\n if 0 <= deck.y < 100:\n row = int(deck.y) // 10\n for col in range(10):\n state[row, col, 1 if index == 0 else 2] |= col * 10 < deck.x + deck.width and (col + 1) * 10 > deck.x\n first = self.decks[0]\n if 0 <= first.y + 3 < 100:\n state[int(first.y + 3) // 10, :min(10, max(0, int((first.x + first.width) / 10) + 1)), 3] = True\n state[0, :3, 4] = self.pressed, self.vy > 0.6, self.vy > 1\n for row, value in enumerate((self.steps, round(self.vy * 20) + 256, -self.up,\n self.down, -self.next_up, self.next_down)):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 86, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/descents.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/descents/main.js"} +{"name": "throw_m", "split": "train", "game": "throw_m", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Throw M as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to sweep the throwing angle. Release with actions\n0–4 to throw. Holding to the end of the sweep throws automatically.\nThe player moves up and down along the right edge. A throw resets\nthe multiplier to one. Hitting an enemy scores the multiplier\nand doubles it. Intercepting an enemy bullet scores the multiplier\nand adds one to it. An enemy bullet hitting the player ends the run.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the player, active enemies, falling\nenemies, enemy bullets, thrown shots, and counters. The port fixes\ndifficulty and approximates sprite contacts with rectangles. Each\naction advances up to four frames over 400 actions. Clip scores to\n[0, 1000] and divide by 1000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/throw_m.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Shot:\n x: float\n y: float\n vx: float = 0.5\n vy: float = 0.\n\n\n@dataclass\nclass Enemy:\n x: float\n y: float\n vy: float\n timer: float\n interval: float\n falling: bool = False\n\n\nclass ThrowMEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.y, self.vy = 50., -0.5\n self.angle = None\n self.steps = self.timer = 0\n self.multiplier = 1\n self.held = self.terminal = False\n self.enemies, self.bullets, self.shots = [], [], []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n press, release = held and not self.held, self.held and not held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(press and frame == 0, release and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _hit(self, x, y):\n return any(abs(shot.x - x) < 5 and abs(shot.y - y) < 5 for shot in self.shots)\n\n def _advance(self, press, release):\n for shot in self.shots:\n shot.x += shot.vx\n shot.y += shot.vy\n shot.vy += 0.07\n self.shots = [shot for shot in self.shots if shot.y <= 103]\n self.timer -= 1\n if self.timer < 0:\n interval = self.random.uniform(200, 300)\n self.enemies.append(Enemy(self.random.uniform(3, 50), -5, self.random.uniform(0.1, 0.4),\n self.random.uniform(0, interval), interval))\n self.timer = self.random.uniform(50, 60)\n reward = 0\n for enemy in self.enemies:\n enemy.y += enemy.vy\n if enemy.falling:\n enemy.vy += 0.1\n continue\n enemy.timer -= 1\n if enemy.timer < 0:\n self.bullets.append(Shot(enemy.x, enemy.y))\n enemy.timer = enemy.interval\n if self._hit(enemy.x, enemy.y) or self._hit(enemy.x, enemy.y - 6):\n enemy.falling = True\n reward += self.multiplier\n self.multiplier *= 2\n self.enemies = [enemy for enemy in self.enemies if enemy.y <= 105]\n bullets = []\n for bullet in self.bullets:\n bullet.x += bullet.vx\n if self._hit(bullet.x, bullet.y):\n reward += self.multiplier\n self.multiplier += 1\n elif bullet.x <= 103 and not (bullet.x > 83 and (bullet.y < 12 or bullet.y > 90)):\n bullets.append(bullet)\n self.bullets = bullets\n self.y += self.vy\n if (self.y < 19 and self.vy < 0) or (self.y > 90 and self.vy > 0):\n self.vy *= -1\n self.terminal = any(abs(bullet.x - 90) < 5 and abs(bullet.y - self.y + 6) < 4\n for bullet in bullets)\n if self.angle is None and press:\n self.angle = 3 * pi / 4\n if self.angle is not None:\n self.angle += 0.1\n if release or self.angle > 11 * pi / 8:\n self.shots.append(Shot(90, self.y, 3 * cos(self.angle), 3 * sin(self.angle)))\n self.angle = None\n self.multiplier = 1\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(self.y // 10), 9, 0] = True\n for channel, objects in ((1, self.enemies), (3, self.bullets), (4, self.shots)):\n for obj in objects:\n if 0 <= obj.x < 100 and 0 <= obj.y < 100:\n layer = 2 if channel == 1 and obj.falling else channel\n state[int(obj.y // 10), int(obj.x // 10), layer] = True\n values = (self.steps, self.held, self.vy > 0, round((self.angle or 0) * 100),\n min(1023, self.multiplier))\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 87, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/throw_m.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/throwm/main.js"} +{"name": "wind_power", "split": "train", "game": "wind_power", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Wind Power as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to build wind. Release with any other action to let\nit decay. Wind spins the scoring turbine and pushes falling blocks\nto the right below the top fifth of the screen. Each frame pays\nthe turbine's rotation speed. A block touching a blade ends the run.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the fan, turbine blades, blocks, blocks\nwithin the wind zone, wind gauge, and counters. The port fixes\ndifficulty and samples the blades for collision checks. Each\naction advances up to four frames over 400 actions. Clip episode\nscores to [0, 1500] and divide by 1500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/wind_power.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Obstacle:\n x: float\n y: float\n size: float\n vx: float = 0.\n\n\nclass WindPowerEnvironment:\n score_cap = 1500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.wind = self.speed = self.angle = self.fan_angle = 0.\n self.obstacles = []\n self.timer = 0.\n self.action = self.steps = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0.\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _advance(self):\n self.wind = min(1, self.wind + 0.02) if self.action == 5 else self.wind * 0.9\n self.fan_angle = (self.fan_angle + self.wind * 0.4) % (2 * pi)\n self.speed = min(10, self.speed + self.wind * 0.02) * 0.98\n self.angle = (self.angle + self.speed * 0.2) % (2 * pi)\n self.timer -= 1\n if self.timer < 0:\n size = self.random.uniform(5, 10)\n self.obstacles.append(Obstacle(self.random.uniform(20, 99), -size, size))\n self.timer = self.random.uniform(75, 250)\n blades = list(self._blades())\n for obstacle in self.obstacles:\n obstacle.y += 0.5\n if 20 < obstacle.y < 100:\n obstacle.vx += self.wind / obstacle.size\n obstacle.vx *= 0.9\n obstacle.x += obstacle.vx\n radius = obstacle.size / 2 + 2\n if any(abs(x - obstacle.x) < radius and abs(y - obstacle.y) < radius for x, y in blades):\n self.terminal = True\n self.obstacles = [obstacle for obstacle in self.obstacles if obstacle.y <= 100]\n return self.speed\n\n def _blades(self):\n for index in range(3):\n angle = self.angle + index * 2 * pi / 3\n for radius in range(11):\n yield 85 + radius * cos(angle), 60 + radius * sin(angle)\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[6, 1, 0] = True\n tip = 60 + sin(self.fan_angle) * 20\n state[int(min(60, tip) // 10):int(max(60, tip) // 10) + 1, 1, 0] = True\n for x, y in self._blades():\n state[int(y // 10), int(x // 10), 1] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for obstacle in self.obstacles:\n mask = ((abs(cols - obstacle.x) < obstacle.size / 2 + 5)\n & (abs(rows - obstacle.y) < obstacle.size / 2 + 5))\n state[:, :, 2] |= mask\n if 20 < obstacle.y < 100:\n state[:, :, 3] |= mask\n state[9, :round(self.wind * 10), 4] = True\n values = (self.steps, self.action, round(self.wind * 100), round(self.speed * 100),\n round(self.angle * 64), round(self.timer))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 88, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/wind_power.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameWindPower.c"} +{"name": "tutankham", "split": "train", "game": "tutankham", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Tutankham as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves four distinct scrolling tomb chambers, four rising difficulty levels,\nfour-way maze movement, a single required key in every Atari 2600 chamber, optional treasures,\nlocked exits, three lives, three emergency laser flashes, horizontally constrained gunfire,\nthree guardian species per chamber, creature nests, ammunition that drains with time, chamber\nrefills, remaining-ammunition bonuses, and side-to-side secret passages.\n\nACTION MAPPING\n0: wait\n1: move/facing left\n2: move up\n3: move/facing right\n4: move down\n5: horizontal laser; consecutive use activates a flash\n\nINPUT CHANNEL TABLE\n0: archeologist\n1: guardians\n2: key and locked exit\n3: optional treasures\n4: tomb walls\n5: laser plus exact stage, lives, flashes, ammunition, quotas, key, and facing state\n\nSCORING, TERMINATION, AND HORIZON\nThe manual's one-time treasure totals are 150, 175, 185, and 295 points, or 805 per four-chamber\nlevel and 3,220 across four levels. Six guardians at each 1/2/3-point value produce 36 per chamber,\nor 576 across 16 chambers. A chamber can award at most its initial 100 ammunition as an exit\nbonus, totaling 1,600. Therefore `score_cap = 3,220 + 576 + 1,600 = 5,396`, and normalization is\n`min(max(raw_score, 0), 5_396) / 5_396`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/tutankham.py`):\n```python\nimport numpy as np\n\n\nTREASURE_VALUES = (\n (20, 15, 25, 25, 20, 45),\n (40, 30, 25, 40, 20, 20),\n (60, 35, 30, 25, 30, 5),\n (55, 40, 25, 80, 20, 40, 35),\n)\nCREATURE_VALUES = (1, 2, 3)\nSTART = (8, 1)\nEXIT = (1, 8)\nWARP_LEFT = (5, 0)\nWARP_RIGHT = (5, 9)\n\n\ndef _walls(chamber: int) -> set[tuple[int, int]]:\n walls = {(0, column) for column in range(10)} | {(9, column) for column in range(10)}\n walls |= {(row, 0) for row in range(1, 9) if row != 5}\n walls |= {(row, 9) for row in range(1, 9) if row != 5}\n patterns = (\n {(2, column) for column in range(1, 7)} | {(6, column) for column in range(3, 9)},\n {(row, 3) for row in range(1, 7)} | {(row, 6) for row in range(3, 9)},\n {(2, column) for column in range(3, 9)} | {(7, column) for column in range(1, 7)},\n {(row, 2) for row in range(2, 8)} | {(row, 7) for row in range(2, 8)},\n )\n return walls | patterns[chamber]\n\n\nclass TutankhamEnvironment:\n \"\"\"Finite Atari 2600 Tutankham campaign through all sixteen chambers.\"\"\"\n\n score_cap = 5_396.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 6_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.stage = 0\n self.lives = 3\n self.flashes = 3\n self.score = 0.0\n self.steps = 0\n self.last_action = 0\n self.facing = 1\n self.terminal = False\n self._start_chamber()\n\n def _start_chamber(self) -> None:\n self.chamber = self.stage % 4\n self.level = self.stage // 4\n self.player = list(START)\n self.ammunition = 100\n self.has_key = False\n self.walls = _walls(self.chamber)\n open_cells = [\n (row, column)\n for row in range(1, 9)\n for column in range(1, 9)\n if (row, column) not in self.walls and (row, column) not in (START, EXIT)\n ]\n treasure_count = len(TREASURE_VALUES[self.chamber])\n treasure_cells = open_cells[2 : 2 + treasure_count]\n self.treasures = {\n cell: (index, value)\n for index, (cell, value) in enumerate(zip(treasure_cells, TREASURE_VALUES[self.chamber]))\n }\n self.key_position = treasure_cells[0]\n self.nests = (open_cells[-1], open_cells[-2], open_cells[-3])\n self.enemies: list[dict[str, int]] = []\n self.spawned = 0\n self.killed = 0\n self.bullets: list[list[int]] = []\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n previous_action = self.last_action\n self.last_action = action\n reward = 0.0\n if action in (1, 2, 3, 4):\n reward += self._move_player(action)\n elif action == 5:\n if previous_action == 5 and self.flashes > 0:\n self.flashes -= 1\n self._flash_guardians()\n elif self.ammunition > 0:\n self.ammunition -= 1\n self.bullets.append([self.player[0], self.player[1], self.facing])\n self.ammunition = max(0, self.ammunition - 1)\n self._move_bullets()\n reward += self._resolve_bullet_hits()\n self._spawn_guardian()\n self._move_guardians()\n self._resolve_guardian_collision()\n self.score += reward\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_player(self, action: int) -> float:\n deltas = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}\n row_delta, column_delta = deltas[action]\n if action == 1:\n self.facing = -1\n elif action == 3:\n self.facing = 1\n destination = (self.player[0] + row_delta, self.player[1] + column_delta)\n if destination == WARP_LEFT:\n destination = WARP_RIGHT\n elif destination == WARP_RIGHT:\n destination = WARP_LEFT\n if destination in self.walls:\n return 0.0\n if destination == EXIT:\n if not self.has_key:\n return 0.0\n reward = float(self.ammunition)\n self.stage += 1\n if self.stage == 16:\n self.terminal = True\n else:\n self._start_chamber()\n return reward\n self.player[:] = destination\n treasure = self.treasures.pop(destination, None)\n if treasure is None:\n return 0.0\n index, value = treasure\n if index == 0:\n self.has_key = True\n return float(value)\n\n def _spawn_guardian(self) -> None:\n if self.spawned >= 18 or len(self.enemies) >= 3 or self.steps % 4:\n return\n kind = self.spawned % 3\n row, column = self.nests[kind]\n self.enemies.append({\"id\": self.spawned, \"kind\": kind, \"row\": row, \"column\": column})\n self.spawned += 1\n\n def _move_guardians(self) -> None:\n interval = max(1, 4 - self.level)\n if self.steps % interval:\n return\n for enemy in self.enemies:\n row_delta = int(np.sign(self.player[0] - enemy[\"row\"]))\n column_delta = int(np.sign(self.player[1] - enemy[\"column\"]))\n candidates = ((enemy[\"row\"] + row_delta, enemy[\"column\"]), (enemy[\"row\"], enemy[\"column\"] + column_delta))\n for destination in candidates:\n if destination not in self.walls:\n enemy[\"row\"], enemy[\"column\"] = destination\n break\n\n def _move_bullets(self) -> None:\n for bullet in self.bullets:\n bullet[1] += bullet[2]\n self.bullets = [\n bullet for bullet in self.bullets if 0 <= bullet[1] < 10 and tuple(bullet[:2]) not in self.walls\n ]\n\n def _resolve_bullet_hits(self) -> float:\n hit_bullets: set[int] = set()\n hit_enemies: set[int] = set()\n reward = 0.0\n for bullet_index, bullet in enumerate(self.bullets):\n for enemy in self.enemies:\n if bullet[:2] == [enemy[\"row\"], enemy[\"column\"]]:\n hit_bullets.add(bullet_index)\n hit_enemies.add(enemy[\"id\"])\n reward += CREATURE_VALUES[enemy[\"kind\"]]\n self.killed += 1\n break\n self.bullets = [bullet for index, bullet in enumerate(self.bullets) if index not in hit_bullets]\n self.enemies = [enemy for enemy in self.enemies if enemy[\"id\"] not in hit_enemies]\n return float(reward)\n\n def _flash_guardians(self) -> None:\n for enemy in self.enemies:\n enemy[\"row\"], enemy[\"column\"] = self.nests[enemy[\"kind\"]]\n\n def _resolve_guardian_collision(self) -> None:\n if not any([enemy[\"row\"], enemy[\"column\"]] == self.player for enemy in self.enemies):\n return\n self.lives -= 1\n self.player[:] = START\n self.enemies.clear()\n self.bullets.clear()\n if self.lives == 0:\n self.terminal = True\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[self.player[0], self.player[1], 0] = True\n for enemy in self.enemies:\n state[enemy[\"row\"], enemy[\"column\"], 1] = True\n for position, (index, _value) in self.treasures.items():\n state[position[0], position[1], 2 if index == 0 else 3] = True\n state[EXIT[0], EXIT[1], 2] = True\n for row, column in self.walls:\n state[row, column, 4] = True\n for bullet in self.bullets:\n state[bullet[0], bullet[1], 5] = True\n values = ((self.stage, 4), (self.lives, 2), (self.flashes, 2), (self.ammunition, 7), (self.spawned, 5), (self.killed, 5))\n offset = 0\n for value, width in values:\n for bit in range(width):\n state[8 - offset // 10, offset % 10, 5] = bool(value & (1 << bit))\n offset += 1\n state[6, 0, 5] = self.has_key\n state[6, 1, 5] = self.facing > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 89, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tutankham.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "find_a_star", "split": "train", "game": "find_a_star", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Find A Star as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nMove the column cursor left with action 1 or right with action 4.\nTap action 5 to open that column in every eligible row. Misses\nreveal which side can still contain the star. Each tap pushes\nthe rows downward, and a row reaching the bottom ends the run.\n\nA found star pays after a short delay. Its score is the square\nof its row's one-based position in arrival order, times the\nnumber of stars found so far on that tap.\n\nINPUT CHANNEL TABLE\nThe 10×10 observation keeps all 16 columns by storing the left\nand right halves in separate channel pairs for possible and\nruled-out boxes. The other channels show found stars and the\ncursor and gauges. The conversion replaces pointer input with\na directional cursor and uses fixed difficulty and four frames\nper action.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action task clips raw scores to [0, 500] and divides by\n500. Across 100 seeds without sticky actions, idle scored zero,\nrandom inputs averaged 46.74 and reached 179, and binary search\non the oldest row averaged 34.60.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/find_a_star.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass BoxLine:\n y: float\n secret: int\n low: int = 0\n high: int = 15\n\n\n@dataclass\nclass Star:\n y: float\n column: int\n score: int\n timer: int = 32\n velocity: float = 1\n\n\nclass FindAStarEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.last_action = 0\n self.cursor = 7\n self.scroll_boost = self.spawn_distance = 0.0\n self.terminal = False\n self.lines: list[BoxLine] = []\n self.stars: list[Star] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n tap = action == 5 and self.last_action != 5\n self.last_action = action\n self.steps += 1\n if action in (1, 4):\n self.cursor = min(15, max(0, self.cursor + (-1 if action == 1 else 1)))\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap: bool) -> int:\n if tap:\n self.scroll_boost += 2\n scroll = 0.06 + self.scroll_boost\n self.scroll_boost *= 0.07\n self.spawn_distance -= scroll\n if self.spawn_distance < 0:\n self.lines.append(BoxLine(-3, int(self.random.integers(16))))\n self.spawn_distance += 10\n\n remaining = []\n combo = 1\n for index, line in enumerate(self.lines, 1):\n if line.y < 9:\n line.y += (9 - line.y) * 0.2\n elif tap:\n if self.cursor == line.secret:\n self.stars.append(Star(line.y, self.cursor, index**2 * combo))\n combo += 1\n continue\n if self.cursor < line.secret:\n line.low = max(line.low, self.cursor + 1)\n else:\n line.high = min(line.high, self.cursor - 1)\n line.y += scroll\n self.terminal |= line.y > 97\n remaining.append(line)\n self.lines = remaining\n if not self.lines:\n self.spawn_distance = 0\n\n reward = 0\n active = []\n for star in self.stars:\n star.y += star.velocity\n star.velocity *= 0.9\n star.timer -= 1\n if star.timer:\n active.append(star)\n else:\n reward += star.score\n self.stars = active\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for line in self.lines:\n if 0 <= line.y < 100:\n row = int(line.y) // 10\n for column in range(16):\n half, slot = divmod(column, 8)\n state[row, slot, 2 * half + int(not line.low <= column <= line.high)] = True\n for star in self.stars:\n if 0 <= star.y < 100:\n state[int(star.y) // 10, star.column // 2, 4] = True\n half, slot = divmod(self.cursor, 8)\n state[half, slot, 5] = True\n for bit in range(9):\n state[9, bit, 5] = bool(self.steps & (1 << bit))\n state[8, 9, 5] = self.last_action == 5\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 90, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/find_a_star.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/findastar/main.js"} +{"name": "defender", "split": "train", "game": "defender", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Defender as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves Atari's scanner-scale planetary defense and its central humanoid rescue\nloop. Five Humanoids wait on the city surface while Landers seek them one at a time, lift them,\nand transform into pursuing Mutants if they reach space. Destroying an abductor releases its\nHumanoid. A low free-fall landing awards 250, catching and returning one awards 1,000, and every\nsurvivor awards 100 at wave end. A deliberate collision destroys a Lander for its 150 points but\ncosts a Defender ship, preserving the manual's self-sacrifice option.\n\nThe full ten-column grid acts as the wraparound scanner. Bombers, Baiters, Pods, Swarmers,\nLanders, and Mutants retain their native point values and broad movement roles. Laser-destroyed\nPods release four 500-point Swarmers; smart-bombed Pods do not. Three starting smart bombs clear\nthe full visible scanner, while enemy contact or fire consumes one of three ships. Every 10,000\npoints grants another ship and smart bomb.\n\nThe Atari port's contextual fire button is preserved: action 5 fires a horizontal laser in rows\n1–7, detonates a smart bomb behind the city in row 8, and performs safe random hyperspace from row\n0. Actions 1–4 move left, up, right, and down and left/right set firing direction.\n\nACTION MAPPING\n0: wait\n1: move left\n2: move up\n3: move right\n4: move down\n5: contextual fire, smart bomb, or hyperspace\n\nINPUT CHANNEL TABLE\n0: Defender ship\n1: aliens and hostile projectiles\n2: score-bearing aliens and live Humanoids\n3: player lasers and non-ground Humanoids\n4: previous Defender and threat positions\n5: key alien identities, lives, smart bombs, and wave gauge\n\nSCORING, TERMINATION, AND HORIZON\nEach wave has five Landers (750), one Bomber (250), one Baiter (200), and one Pod plus its four\nlaser-released Swarmers (3,000), totaling 4,200 alien points. At most five Landers can each yield\none full 1,000-point rescue, and five surviving Humanoids add 500. Thus each wave is bounded by\n9,700 and the five-wave structural maximum is `score_cap = 48,500`. Normalization is\n`min(max(raw_score, 0), 48_500) / 48_500`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/defender.py`):\n```python\nimport numpy as np\n\n\nALIEN_VALUES = {\n \"pod\": 1_000.0,\n \"swarmer\": 500.0,\n \"bomber\": 250.0,\n \"baiter\": 200.0,\n \"lander\": 150.0,\n \"mutant\": 150.0,\n}\n\n\nclass DefenderEnvironment:\n \"\"\"Five-wave scanner shooter centered on humanoid abduction and rescue.\"\"\"\n\n score_cap = 48_500.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 4_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.player = [4, 1]\n self.previous_player = self.player.copy()\n self.facing = 1\n self.lives = 3\n self.smart_bombs = 3\n self.score = 0.0\n self.next_bonus_score = 10_000.0\n self.wave = 1\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self.shots: list[dict[str, object]] = []\n self.hostile_shots: list[list[int]] = []\n self.humanoids = [\n {\"position\": [8, column], \"state\": \"ground\"} for column in (0, 2, 4, 6, 8)\n ]\n self.carried_humanoid: dict[str, object] | None = None\n self.previous_threats: list[list[int]] = []\n self._start_wave()\n\n def _start_wave(self) -> None:\n kinds = [\"lander\"] * 5 + [\"bomber\", \"baiter\", \"pod\"]\n self.enemies = [\n {\"kind\": kind, \"position\": [1 + index % 5, (index * 3 + self.wave) % 10]}\n for index, kind in enumerate(kinds)\n ]\n self.hostile_shots = []\n self.wave_steps = 0\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n self.previous_threats = self._threat_positions()\n reward = self._apply_action(action)\n self._move_world()\n reward += self._resolve_player_shots()\n reward += self._resolve_humanoids()\n reward += self._resolve_player_contact()\n self.score += reward\n if not self.enemies:\n reward += self._complete_wave()\n while self.score >= self.next_bonus_score:\n self.lives += 1\n self.smart_bombs += 1\n self.next_bonus_score += 10_000.0\n self.wave_steps += 1\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _apply_action(self, action: int) -> float:\n if action == 1:\n self.player[1] = (self.player[1] - 1) % 10\n self.facing = -1\n elif action == 2:\n self.player[0] = max(0, self.player[0] - 1)\n elif action == 3:\n self.player[1] = (self.player[1] + 1) % 10\n self.facing = 1\n elif action == 4:\n self.player[0] = min(8, self.player[0] + 1)\n elif action == 5:\n if self.player[0] == 0:\n self.player = [int(self.random.randint(1, 8)), int(self.random.randint(10))]\n elif self.player[0] == 8 and self.smart_bombs > 0:\n self.smart_bombs -= 1\n reward = sum(ALIEN_VALUES[str(enemy[\"kind\"])] for enemy in self.enemies)\n destroyed_ids = {id(enemy) for enemy in self.enemies}\n for humanoid in self.humanoids:\n if humanoid[\"state\"] == \"abducted\" and id(humanoid.get(\"lander\")) in destroyed_ids:\n humanoid[\"state\"] = \"falling\"\n humanoid.pop(\"lander\", None)\n self.enemies = []\n return reward\n elif len(self.shots) < 3:\n self.shots.append({\"position\": self.player.copy(), \"direction\": self.facing})\n return 0.0\n\n def _move_world(self) -> None:\n for shot in self.shots:\n shot[\"position\"][1] = (shot[\"position\"][1] + int(shot[\"direction\"])) % 10\n shot[\"distance\"] = int(shot.get(\"distance\", 0)) + 1\n self.shots = [shot for shot in self.shots if int(shot[\"distance\"]) < 10]\n for enemy in self.enemies:\n kind = str(enemy[\"kind\"])\n position = enemy[\"position\"]\n if kind == \"lander\":\n self._move_lander(enemy)\n elif kind in (\"baiter\", \"mutant\", \"swarmer\"):\n position[0] += int(np.sign(self.player[0] - position[0]))\n position[1] = (position[1] + int(np.sign(self.player[1] - position[1]))) % 10\n else:\n position[1] = (position[1] - 1) % 10\n if self.random.rand() < min(0.2, 0.015 * self.wave):\n self.hostile_shots.append(list(position))\n for hostile_shot in self.hostile_shots:\n hostile_shot[0] += int(np.sign(self.player[0] - hostile_shot[0]))\n hostile_shot[1] = (hostile_shot[1] + int(np.sign(self.player[1] - hostile_shot[1]))) % 10\n self.hostile_shots = [shot for shot in self.hostile_shots if 0 <= shot[0] < 9]\n for humanoid in self.humanoids:\n if humanoid[\"state\"] == \"falling\":\n humanoid[\"position\"][0] += 1\n\n def _move_lander(self, lander: dict[str, object]) -> None:\n carried = next(\n (\n humanoid\n for humanoid in self.humanoids\n if humanoid[\"state\"] == \"abducted\" and humanoid.get(\"lander\") is lander\n ),\n None,\n )\n position = lander[\"position\"]\n if carried is not None:\n position[0] -= 1\n carried[\"position\"] = [position[0] + 1, position[1]]\n if position[0] <= 0:\n carried[\"state\"] = \"lost\"\n lander[\"kind\"] = \"mutant\"\n lander[\"position\"] = [1, position[1]]\n return\n if self.carried_humanoid is not None or any(\n humanoid[\"state\"] == \"abducted\" for humanoid in self.humanoids\n ):\n position[1] = (position[1] - 1) % 10\n return\n ground = [humanoid for humanoid in self.humanoids if humanoid[\"state\"] == \"ground\"]\n if not ground:\n position[1] = (position[1] - 1) % 10\n return\n target = min(ground, key=lambda humanoid: abs(humanoid[\"position\"][1] - position[1]))\n if position[1] != target[\"position\"][1]:\n position[1] = (position[1] + int(np.sign(target[\"position\"][1] - position[1]))) % 10\n elif position[0] < 7:\n position[0] += 1\n else:\n target[\"state\"] = \"abducted\"\n target[\"lander\"] = lander\n\n def _resolve_player_shots(self) -> float:\n reward = 0.0\n remaining_shots = []\n destroyed_ids: set[int] = set()\n spawned: list[dict[str, object]] = []\n for shot in self.shots:\n enemy = next(\n (\n candidate\n for candidate in self.enemies\n if id(candidate) not in destroyed_ids and candidate[\"position\"] == shot[\"position\"]\n ),\n None,\n )\n if enemy is None:\n remaining_shots.append(shot)\n continue\n destroyed_ids.add(id(enemy))\n reward += ALIEN_VALUES[str(enemy[\"kind\"])]\n if enemy[\"kind\"] == \"pod\":\n for offset in (-1, 0, 1, 2):\n spawned.append(\n {\"kind\": \"swarmer\", \"position\": [enemy[\"position\"][0], (enemy[\"position\"][1] + offset) % 10]}\n )\n for humanoid in self.humanoids:\n if humanoid[\"state\"] == \"abducted\" and humanoid.get(\"lander\") is enemy:\n humanoid[\"state\"] = \"falling\"\n humanoid.pop(\"lander\", None)\n self.shots = remaining_shots\n self.enemies = [enemy for enemy in self.enemies if id(enemy) not in destroyed_ids] + spawned\n return reward\n\n def _resolve_humanoids(self) -> float:\n reward = 0.0\n if self.carried_humanoid is None:\n caught = next(\n (\n humanoid\n for humanoid in self.humanoids\n if humanoid[\"state\"] == \"falling\" and humanoid[\"position\"] == self.player\n ),\n None,\n )\n if caught is not None:\n caught[\"state\"] = \"carried\"\n self.carried_humanoid = caught\n if self.carried_humanoid is not None:\n self.carried_humanoid[\"position\"] = self.player.copy()\n if self.player[0] == 8:\n self.carried_humanoid[\"state\"] = \"ground\"\n self.carried_humanoid[\"position\"] = [8, self.player[1]]\n self.carried_humanoid = None\n reward += 1_000.0\n for humanoid in self.humanoids:\n if humanoid[\"state\"] != \"falling\" or humanoid[\"position\"][0] < 8:\n continue\n if humanoid[\"position\"][0] == 8:\n humanoid[\"state\"] = \"ground\"\n reward += 250.0\n else:\n humanoid[\"state\"] = \"lost\"\n return reward\n\n def _resolve_player_contact(self) -> float:\n collided_enemy = next(\n (enemy for enemy in self.enemies if enemy[\"position\"] == self.player),\n None,\n )\n if collided_enemy is None and self.player not in self.hostile_shots:\n return 0.0\n reward = 0.0\n if collided_enemy is not None:\n reward = ALIEN_VALUES[str(collided_enemy[\"kind\"])]\n self.enemies = [enemy for enemy in self.enemies if enemy is not collided_enemy]\n for humanoid in self.humanoids:\n if humanoid[\"state\"] == \"abducted\" and humanoid.get(\"lander\") is collided_enemy:\n humanoid[\"state\"] = \"falling\"\n humanoid.pop(\"lander\", None)\n self.lives -= 1\n self.player = [4, 1]\n self.previous_player = self.player.copy()\n self.shots = []\n self.hostile_shots = []\n if self.carried_humanoid is not None:\n self.carried_humanoid[\"state\"] = \"ground\"\n self.carried_humanoid[\"position\"] = [8, self.player[1]]\n self.carried_humanoid = None\n if self.lives <= 0:\n self.terminal = True\n return reward\n\n def _complete_wave(self) -> float:\n survivors = sum(humanoid[\"state\"] in (\"ground\", \"carried\") for humanoid in self.humanoids)\n reward = survivors * 100.0\n if self.carried_humanoid is not None:\n self.carried_humanoid[\"state\"] = \"ground\"\n self.carried_humanoid[\"position\"] = [8, self.player[1]]\n self.carried_humanoid = None\n self.score += reward\n self.wave += 1\n if self.wave > 5:\n self.terminal = True\n else:\n if self.wave == 5 and survivors == 0:\n self.humanoids = [\n {\"position\": [8, column], \"state\": \"ground\"} for column in (0, 2, 4, 6, 8)\n ]\n self._start_wave()\n return reward\n\n def _threat_positions(self) -> list[list[int]]:\n return [list(enemy[\"position\"]) for enemy in self.enemies] + [\n shot.copy() for shot in self.hostile_shots\n ]\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n for enemy in self.enemies:\n position = enemy[\"position\"]\n state[*position, 1] = True\n state[*position, 2] = True\n if enemy[\"kind\"] in (\"lander\", \"mutant\", \"pod\"):\n state[*position, 5] = True\n for hostile_shot in self.hostile_shots:\n state[*hostile_shot, 1] = True\n for shot in self.shots:\n state[*shot[\"position\"], 3] = True\n for humanoid in self.humanoids:\n if humanoid[\"state\"] != \"lost\":\n state[*humanoid[\"position\"], 2] = True\n if humanoid[\"state\"] != \"ground\":\n state[*humanoid[\"position\"], 3] = True\n state[*self.previous_player, 4] = True\n for position in self.previous_threats:\n state[*position, 4] = True\n state[9, : min(10, self.lives), 5] = True\n state[8, : min(10, self.smart_bombs), 5] = True\n state[7, : self.wave, 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 91, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/defender.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "floater", "split": "train", "game": "floater", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Floater as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 while riding a platform to jump. Hold to reduce\ngravity in flight. Release with actions 0–4 before the next tap.\nPlatforms oscillate vertically, and their motion affects launch\nvelocity. Jumping uses up that platform for future landings.\n\nINPUT CHANNEL TABLE\nScore is the distance scrolled. Falling below the screen or\ndrifting off the left edge ends the run. The six 10×10 channels\nshow the player, unused platforms, used platforms, support\nstatus, upward motion, and gauges. The conversion uses fixed\ndifficulty and rectangular platform contact checks. Each\naction advances four frames.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action task clips raw scores to [0, 1000] and divides by\n1,000. Across 100 seeds without sticky actions, idle scored 105.08\nand random inputs averaged 135.96. A policy that held in flight\nand jumped when a platform moved left averaged 215.44 and\nreached 821.30.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/floater.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Platform:\n x: float\n center: float\n angle: float\n radius: float\n speed: float\n used: bool = False\n\n @property\n def y(self) -> float:\n return self.center + math.sin(self.angle) * self.radius\n\n\nclass FloaterEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = 0\n self.x, self.y, self.vx, self.vy = 105.0, 10.0, 0.0, 0.0\n self.pressed = self.terminal = False\n self.next_platform = 0.0\n self.center = 50.0\n self.support: Platform | None = None\n self.platforms: list[Platform] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0.0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _advance(self, tap: bool) -> float:\n if self.next_platform <= 0:\n radius = self.random.uniform(10, 20)\n low, high = 30 + radius, 80 - radius\n if self.center < low:\n self.center = 2 * low - self.center\n elif self.center > high:\n self.center = 2 * high - self.center\n self.platforms.append(Platform(105, self.center, self.random.uniform(0, math.tau),\n radius, self.random.uniform(0.05, 0.1)))\n self.center += self.random.uniform(-20, 20)\n self.next_platform += self.random.uniform(20, 40)\n\n scroll = 0.1 + max(0, self.x - 30) * 0.05\n self.next_platform -= scroll\n for platform in self.platforms:\n platform.x -= scroll\n platform.angle = (platform.angle + platform.speed) % math.tau\n self.platforms = [platform for platform in self.platforms if platform.x >= -10]\n self.x -= scroll\n if self.support is not None:\n self.y = self.support.y - 6\n if tap:\n self.vx = 1\n self.vy = math.cos(self.support.angle) * self.support.speed * 20 - 1\n self.support.used = True\n self.support = None\n else:\n self.vy += 0.05 if self.pressed else 0.2\n self.x += self.vx\n self.y += self.vy\n if self.y < 8 and self.vy < 0:\n self.vy *= -0.25\n for platform in self.platforms:\n if not platform.used and abs(platform.x - self.x) < 11 and abs(platform.y - self.y) < 6:\n self.support = platform\n break\n self.terminal = self.y > 99 or self.x < 0\n return scroll\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row = min(9, max(0, int(self.y) // 10))\n col = min(9, max(0, int(self.x) // 10))\n state[row, col, 0] = True\n state[row, col, 3] = self.support is not None\n state[row, col, 4] = self.vy < 0\n for platform in self.platforms:\n if 0 <= platform.y < 100:\n left = max(0, math.floor((platform.x - 7.5) / 10))\n right = min(10, math.ceil((platform.x + 7.5) / 10))\n state[int(platform.y) // 10, left:right, 2 if platform.used else 1] = True\n for row, value in enumerate((self.steps, round(self.vy * 16) + 128)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 92, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/floater.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/floater/main.js"} +{"name": "color_roll", "split": "train", "game": "color_roll", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Color Roll as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to fire from the fixed center column. Actions 0–4 release the\nbutton and wait. The first lane hit sets the beam color. Matching lanes above\nit are removed and double the next hit's value. A different color stops the\nbeam and adjusts the pressure cost of the next shot. Clearing the whole stack\nincreases the target lane count, and completing a tier raises the base multiplier.\nShooting and waiting both let the lanes advance toward the loss threshold.\n\nINPUT CHANNEL TABLE\nChannels 0–3 mark the four lane colors, channel 4 marks rightward lane motion,\nand channel 5 encodes pressure, shot cost, tier, target stack size, chain, shot\ntravel delay and color, last button state, and clock. The adaptation uses ten\ncolumns with integer wrapping, uniform-width color segments, one-cell-per-step\nlane motion, and a scalar descent meter. Beam contacts resolve one per step.\n\nSCORING, TERMINATION, AND HORIZON\nOnly a removed lane scores. Replacements arrive when the beam ends. Each\n400-step episode can remove at most one lane per step. Base exponent nine and\nat most ten lanes bound the largest hit by 2^18, giving a conservative score cap\nof 104,857,600. Normalize by clipping to [0, cap] and dividing by the cap.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/color_roll.py`):\n```python\nimport numpy as np\n\n\nHORIZON = 400\nCENTER = 5\nWIDTH = 10\n\n\nclass ColorRollEnvironment:\n score_cap = HORIZON * 2 ** 18\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = 0\n self.last_action = 0\n self.pressure = 0\n self.penalty = 1\n self.base = 0\n self.target_count = 2\n self.chain = 0\n self.shot_color: int | None = None\n self.shot_delay = 0\n self.terminal = False\n self.lanes: list[tuple[np.ndarray, int]] = []\n self.previous_palette: list[int] = []\n self._refill()\n\n def _refill(self) -> None:\n while len(self.lanes) < self.target_count:\n palette = self.previous_palette.copy()\n if not palette:\n palette.append(int(self.random.integers(4)))\n if len(palette) == 1 or (len(palette) < 4 and self.random.random() < 0.5):\n palette.append(int(self.random.integers(4)))\n else:\n palette.pop(int(self.random.integers(len(palette))))\n self.previous_palette = palette\n colors = np.resize(np.repeat(palette, (WIDTH + len(palette) - 1) // len(palette)), WIDTH)\n colors = np.roll(colors, int(self.random.integers(WIDTH)))\n self.lanes.append((colors, int(self.random.choice((-1, 1)))))\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n pressed = action == 5 and self.last_action != 5\n self.last_action = action\n self.steps += 1\n self.pressure += 1\n self.lanes = [(np.roll(colors, velocity), velocity) for colors, velocity in self.lanes]\n reward = 0\n if self.shot_delay:\n self.shot_delay -= 1\n if self.shot_delay == 0:\n reward = self._contact()\n elif pressed:\n self.shot_color = None\n self.chain = 0\n self.shot_delay = 2\n self.pressure += 4 * self.penalty\n if not self.shot_delay:\n self.terminal = self.pressure + 4 * len(self.lanes) >= 48\n if not self.terminal:\n self._refill()\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _contact(self) -> int:\n color = int(self.lanes[0][0][CENTER])\n if self.shot_color is not None and color != self.shot_color:\n self.penalty = max(1, min(4, self.penalty * (3 // (2 ** self.chain))))\n self.shot_color = None\n return 0\n self.shot_color = color\n self.lanes.pop(0)\n self.pressure = max(0, self.pressure - 2 ** self.chain)\n reward = 2 ** (self.base + self.chain)\n self.chain += 1\n if self.lanes:\n self.shot_delay = 1\n else:\n self.shot_color = None\n self.target_count += 1\n if self.target_count > min(10, 5 + self.base):\n self.base = min(9, self.base + 1)\n self.target_count = 2\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for row, (colors, velocity) in enumerate(reversed(self.lanes), 10 - len(self.lanes)):\n state[row, np.arange(WIDTH), colors] = True\n state[row, 0, 4] = velocity == 1\n values = (self.pressure, self.penalty, self.base, self.target_count,\n self.chain, self.shot_delay, 0 if self.shot_color is None else self.shot_color + 1,\n int(self.last_action == 5), self.steps)\n for row, value in enumerate(values):\n for bit in range(WIDTH):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 93, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/color_roll.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameColorRoll.c"} +{"name": "aerial_bar", "split": "train", "game": "aerial_bar", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Aerial Bar as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe catalog lists this game under the source ID AeralBar. Tap action 5\nto launch from a swinging bar. Holding slows gravity and preserves\nhorizontal momentum. Actions 0–4 release the button. Catch an unused\nbar to score the time spent airborne. Water bounces the player, lowers\nthe ceiling, reopens used bars, and cancels flight points until the next\nlaunch. Catching a bar raises the ceiling. The run ends if the player\nfalls behind the view or a bar reaches the water.\n\nINPUT CHANNEL TABLE\nThe six channels show the player, water, available bar tips, used bar\ntips, ceiling, and gauges for flight and movement. The adaptation uses\neight subunits per cell, a fixed pendulum period, rectangular catch\nproximity, and discrete ceiling changes. A seeded second bar is visible\nat reset so the first catch can be timed from the initial observation.\n\nSCORING, TERMINATION, AND HORIZON\nThe default horizon is 400 steps. Each rewarded catch pays only for the\nsteps since its own launch. Those intervals cannot overlap, which bounds\nthe episode score at 400. Clip to [0, 400] and divide by 400.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/aerial_bar.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, pi, sin\n\nimport numpy as np\n\n\nHORIZON = 400\nUNIT = 8\nWATER = 72\nPERIOD = 32\n\n\n@dataclass\nclass Bar:\n anchor: int\n length: int\n phase: int\n used: bool = False\n\n def tip(self, ceiling: int) -> tuple[int, int]:\n angle = 0.85 * sin(self.phase * 2 * pi / PERIOD)\n return self.anchor + round(self.length * sin(angle)), ceiling + round(self.length * cos(angle))\n\n\nclass AerialBarEnvironment:\n score_cap = HORIZON\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.last_action = self.flight = 0\n self.ceiling = 8\n self.attached: Bar | None = Bar(32, 38, 0, True)\n self.bars = [self.attached, Bar(66, int(self.random.integers(25, 34)), 0)]\n self.x, self.y = self.attached.tip(self.ceiling)\n self.vx = self.vy = 0\n self.bounced = False\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n pressed = action == 5 and self.last_action != 5\n self.last_action = action\n self.steps += 1\n scroll = int(self.steps % 8 == 0) + max(0, (self.x - 40) // 8)\n self.x -= scroll\n for bar in self.bars:\n bar.anchor -= scroll\n bar.phase = (bar.phase + 1) % PERIOD\n if self.bars[-1].anchor < 55:\n self.bars.append(Bar(self.bars[-1].anchor + int(self.random.integers(26, 42)),\n int(self.random.integers(18, 39)), int(self.random.integers(PERIOD))))\n\n reward = 0\n if self.attached is not None:\n bar = self.attached\n self.x, self.y = bar.tip(self.ceiling)\n if pressed:\n future = Bar(bar.anchor, bar.length, (bar.phase + 1) % PERIOD)\n next_x, next_y = future.tip(self.ceiling)\n self.vx, self.vy = next_x - self.x, next_y - self.y - 1\n self.attached = None\n self.flight = 0\n self.bounced = False\n else:\n self.flight += 1\n self.x += self.vx\n self.y += self.vy\n if action != 5 or self.steps % 5 == 0:\n self.vy += 1\n if action != 5 and self.steps % 4 == 0:\n self.vx -= int(np.sign(self.vx))\n if self.y >= WATER:\n self.y = WATER - 1\n self.vy = -max(1, self.vy * 3 // 2)\n self.ceiling += 8\n self.bounced = True\n for bar in self.bars:\n bar.used = False\n if self.y <= self.ceiling:\n self.y = self.ceiling\n self.vy = max(0, -self.vy // 2)\n for bar in self.bars:\n x, y = bar.tip(self.ceiling)\n if not bar.used and abs(self.x - x) <= 5 and abs(self.y - y) <= 5:\n self.attached = bar\n bar.used = True\n reward = 0 if self.bounced else self.flight\n self.ceiling = max(8, self.ceiling - 4)\n self.x, self.y = bar.tip(self.ceiling)\n break\n self.bars = [bar for bar in self.bars if bar.anchor >= -24 or bar is self.attached]\n self.terminal = (\n (self.attached.anchor < 0 if self.attached is not None else self.x < 0)\n or any(bar.tip(self.ceiling)[1] >= WATER for bar in self.bars)\n or self.steps >= self.horizon\n )\n return float(reward), self.terminal\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, self.y // UNIT), max(0, min(9, self.x // UNIT)), 0] = True\n state[WATER // UNIT:, :, 1] = True\n for bar in self.bars:\n x, y = bar.tip(self.ceiling)\n if 0 <= x < 80 and 0 <= y < 80:\n state[y // UNIT, x // UNIT, 3 if bar.used else 2] = True\n state[:min(10, self.ceiling // UNIT), :, 4] = True\n values = (self.steps, self.flight, self.ceiling, self.x + 32, self.y,\n self.vx + 16, self.vy + 64, int(self.attached is not None),\n int(self.bounced), int(self.last_action == 5))\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 94, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/aerial_bar.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameAeralBar.c"} +{"name": "pillars_3d", "split": "train", "game": "pillars_3d", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Pillars 3D as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nMove left with action 1 and right with action 3. Other\nactions hold position. The conversion replaces pointer\nmovement with six source pixels of movement per action.\n\nPillars grow and move outward as they approach in depth.\nTouch a pillar to score and remove it. Contact while falling\nbounces you upward. Yellow pillars raise the score multiplier.\nFalling below the screen ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, normal pillars,\nyellow pillars, nearby pillars, projected player height,\nand gauges. The simulation retains perspective projection\nand approximates the player glyph with a rectangular hitbox.\nAt fixed difficulty the task advances four frames per action,\nup to 400 actions. Scores are clipped to [0, 250] and divided\nby 250.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/pillars_3d.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Pillar:\n x: float\n depth: float\n width: float\n height: float\n bonus: bool = False\n\n def bounds(self):\n x = 50 + self.x / self.depth\n half_width = self.width / (2 * self.depth)\n return (x - half_width, x + half_width,\n 60 - self.height / (6 * self.depth), 60 + 5 * self.height / (6 * self.depth))\n\n\nclass Pillars3dEnvironment:\n score_cap = 250\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y, self.vy = 50.0, 10.0, 0.0\n self.pillars = [Pillar(0, 20, 100, 100, True)]\n self.timer = self.bonus_timer = 9\n self.steps = self.action = 0\n self.multiplier = 1\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n self.timer -= 1\n if self.timer < 0:\n self.bonus_timer -= 1\n bonus = self.bonus_timer < 0\n x = self.random.uniform(60, 160) * self.random.choice((-1, 1))\n self.pillars.append(Pillar(x, 20, self.random.uniform(50, 100),\n self.random.uniform(70, 180), bonus))\n self.timer = 20\n if bonus:\n self.bonus_timer = 9\n self.x = min(93, max(6, self.x + 1.5 * ((self.action == 3) - (self.action == 1))))\n self.y += self.vy\n self.vy += 0.1\n if self.y > 95:\n self.terminal = True\n return 0\n reward = 0\n remaining = []\n collision_y = self.y\n for pillar in self.pillars:\n left, right, top, bottom = pillar.bounds()\n if left < self.x + 3 and right > self.x - 5 and top < collision_y + 3 and bottom > collision_y - 3:\n if self.vy > 0:\n self.vy = -2.5\n self.y = min(self.y, top)\n reward += self.multiplier\n self.multiplier += int(pillar.bonus)\n else:\n pillar.depth -= 0.2\n if pillar.depth > 1:\n remaining.append(pillar)\n self.pillars = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n col = int(self.x // 10)\n state[min(9, max(0, int(self.y // 10))), col, 0] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for pillar in self.pillars:\n left, right, top, bottom = pillar.bounds()\n visible = ((cols + 5 > left) & (cols - 5 < right) &\n (rows + 5 > top) & (rows - 5 < bottom))\n state[:, :, 2 if pillar.bonus else 1] |= visible\n state[:, :, 3] |= visible & (pillar.depth < 6)\n state[min(9, max(0, int((self.y + 4 * self.vy) // 10))), col, 4] = True\n values = (self.steps, self.multiplier, round(self.x * 4), round((self.vy + 4) * 40), self.action)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(min(511, max(0, value)) & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 95, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pillars_3d.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePillars3d.c"} +{"name": "periscope_ping", "split": "train", "game": "periscope_ping", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Periscope Ping as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to fire outward and reverse the periscope.\nHold to expand a sonar ring that reveals incoming contacts.\nActions 0–4 release the button. Hitting a contact scores\nits distance from the tower rounded down. Contact with the\ntower or periscope ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the periscope, visible circles,\nvisible triangles, shots, sonar ring, and gauges. The conversion\nuses geometric sonar checks and rectangular hitboxes. It\nadvances four frames per action at fixed difficulty. The\n400-action task clips scores to [0, 350] and divides by 350.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/periscope_ping.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Contact:\n x: float\n y: float\n heading: float\n triangle: bool = False\n visible: bool = False\n\n def move(self, speed: float) -> None:\n self.x += math.cos(self.heading) * speed\n self.y += math.sin(self.heading) * speed\n\n\nclass PeriscopePingEnvironment:\n score_cap = 350\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.angle = self.radius = 0.0\n self.direction = 1\n self.steps = self.timer = 0\n self.pressed = self.terminal = False\n self.targets: list[Contact] = []\n self.shots: list[Contact] = []\n\n @property\n def scope(self):\n return 50 + 10 * math.cos(self.angle), 50 + 10 * math.sin(self.angle)\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n self.angle = (self.angle + 0.04 * self.direction) % math.tau\n sx, sy = self.scope\n if tap:\n self.radius = 0\n self.direction *= -1\n self.shots.append(Contact(sx, sy, self.angle))\n if self.pressed:\n self.radius += 1\n for shot in self.shots:\n shot.move(1)\n self.shots = [shot for shot in self.shots if math.hypot(shot.x - 50, shot.y - 50) <= 50]\n reward = 0\n remaining = []\n for target in self.targets:\n target.move(0.1)\n distance = math.hypot(target.x - 50, target.y - 50)\n if distance < 5:\n continue\n extent = 2.5 if target.triangle else 3\n if any(abs(shot.x - target.x) < extent + 1.5 and abs(shot.y - target.y) < extent + 1.5\n for shot in self.shots):\n reward += int(distance)\n continue\n scope_hit = abs(target.x - sx) < extent + 1.5 and abs(target.y - sy) < extent + 1.5\n tower_hit = abs(target.x - 50) < extent + 5 and abs(target.y - 50) < extent + 5\n sonar_hit = self.pressed and abs(math.hypot(target.x - sx, target.y - sy) - self.radius) < extent + 2.5\n target.visible = scope_hit or tower_hit or sonar_hit\n self.terminal |= scope_hit or tower_hit\n remaining.append(target)\n self.targets = remaining\n self.timer += 1\n if not self.targets or self.timer >= 200:\n self.timer = 0\n angle = self.random.uniform(0, math.tau)\n triangle = bool(self.random.integers(2))\n heading = angle + math.pi + self.random.uniform(-0.5, 0.5)\n self.targets.append(Contact(50 + 50 * math.cos(angle), 50 + 50 * math.sin(angle), heading, triangle))\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n sx, sy = self.scope\n state[int(sy // 10), int(sx // 10), 0] = True\n for target in self.targets:\n if target.visible and 0 <= target.x < 100 and 0 <= target.y < 100:\n state[int(target.y // 10), int(target.x // 10), 1 + target.triangle] = True\n for shot in self.shots:\n if 0 <= shot.x < 100 and 0 <= shot.y < 100:\n state[int(shot.y // 10), int(shot.x // 10), 3] = True\n if self.pressed:\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n state[:, :, 4] = abs(np.hypot(cols - sx, rows - sy) - self.radius) < 5\n for row, value in enumerate((self.steps, round(self.angle * 80), min(511, int(self.radius)))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 96, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/periscope_ping.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePeriscopePing.c"} +{"name": "inkinh", "split": "train", "game": "inkinh", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Inkinh as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to thrust forward and pull nearby orbs toward\nyou. Actions 0–4 release the thrust and rotate the heading\nfaster. Collecting an orb scores the new combo count. The\ncombo expires after 60 frames without a collection. Contact\nwith a falling obstacle ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, orbs, obstacles,\nheading, active pull area, and gauges. The conversion uses\nfixed difficulty, rectangular hitboxes, and four frames per\naction. The 400-action task clips the raw total to [0, 150]\nand divides by 150.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/inkinh.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Orb:\n x: float\n y: float\n life: int = 300\n phase: float = 0.0\n\n\n@dataclass\nclass Obstacle:\n x: float\n y: float\n vx: float\n\n\nclass InkinhEnvironment:\n score_cap = 150\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x, self.y = 50.0, 80.0\n self.vx = self.vy = 0.0\n self.angle = -math.pi / 2\n self.stretch = 1.0\n self.combo = self.combo_timer = self.steps = self.frames = 0\n self.pressed = self.terminal = False\n self.orbs: list[Orb] = []\n self.obstacles: list[Obstacle] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self) -> int:\n self.combo_timer = max(0, self.combo_timer - 1)\n if not self.combo_timer:\n self.combo = 0\n if self.frames % 72 == 0:\n self.obstacles.append(Obstacle(self.random.uniform(10, 90), -8, self.random.uniform(-0.2, 0.2)))\n if self.frames % 30 == 0 and len(self.orbs) < 8:\n for _ in range(9):\n x, y = self.random.uniform(15, 85), self.random.uniform(20, 90)\n if math.hypot(x - self.x, y - self.y) > 20:\n break\n self.orbs.append(Orb(x, y, phase=self.random.uniform(0, math.tau)))\n self.frames += 1\n self.angle += 0.02 if self.pressed else 0.05\n if self.pressed:\n self.vx += 0.15 * math.cos(self.angle)\n self.vy += 0.15 * math.sin(self.angle)\n for orb in self.orbs:\n dx, dy = self.x - orb.x, self.y - orb.y\n distance = math.hypot(dx, dy)\n if 0 < distance < 30:\n orb.x += 0.6 * dx / distance\n orb.y += 0.6 * dy / distance\n self.vx *= 0.96\n self.vy *= 0.96\n self.x = min(95, max(5, self.x + self.vx))\n self.y = min(95, max(5, self.y + self.vy))\n self.stretch += (1 + math.hypot(self.vx, self.vy) * 0.3 - self.stretch) * 0.2\n reward = 0\n remaining = []\n for orb in self.orbs:\n orb.life -= 1\n orb.phase += 0.1\n size = (4 + 2 * min(1, orb.life / 60)) * (1 + 0.15 * math.sin(orb.phase))\n if self._hits(orb.x, orb.y, size):\n self.combo += 1\n self.combo_timer = 60\n reward += self.combo\n elif orb.life:\n remaining.append(orb)\n self.orbs = remaining\n for obstacle in self.obstacles:\n obstacle.x += obstacle.vx\n obstacle.y += 0.5\n self.terminal |= self._hits(obstacle.x, obstacle.y, 7)\n self.obstacles = [obstacle for obstacle in self.obstacles if obstacle.y < 110]\n return reward\n\n def _hits(self, x: float, y: float, size: float) -> bool:\n return (abs(self.x - x) < size / 2 + 3 / self.stretch\n and abs(self.y - y) < size / 2 + 3 * self.stretch)\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(self.y) // 10, int(self.x) // 10, 0] = True\n for orb in self.orbs:\n state[int(orb.y) // 10, int(orb.x) // 10, 1] = True\n for obstacle in self.obstacles:\n if 0 <= obstacle.x < 100 and 0 <= obstacle.y < 100:\n state[int(obstacle.y) // 10, int(obstacle.x) // 10, 2] = True\n x, y = self.x + 10 * math.cos(self.angle), self.y + 10 * math.sin(self.angle)\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y) // 10, int(x) // 10, 3] = True\n if self.pressed:\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n state[:, :, 4] = (cols - self.x) ** 2 + (rows - self.y) ** 2 < 30 ** 2\n gauges = (self.steps, self.combo, self.combo_timer, round(self.angle % math.tau * 80),\n round((self.vx + 4) * 60), round((self.vy + 4) * 60))\n for row, value in enumerate(gauges):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 97, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/inkinh.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameInkinh.c"} +{"name": "smily_angry", "split": "train", "game": "smily_angry", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Smily Angry as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to reverse direction. Actions 0–4 release. The player\nkeeps moving and wraps at the edges. Smiling faces fire bonuses.\nAngry faces fire lethal shots. Some faces aim ahead of the player.\nBonuses score the current multiplier and raise it by one. Missing\na bonus reduces the multiplier to a minimum of one.\n\nINPUT CHANNEL TABLE\nThe six channels show the player, smiling faces, angry faces,\nbonuses, lethal shots, and counters. The port uses fixed difficulty\nand rectangular collision bounds. Each action advances up to four\nframes over 400 actions. Clip episode scores to [0, 300] and\ndivide by 300.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/smily_angry.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import atan2, cos, hypot, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Face:\n x: float\n timer: float\n smile: bool\n lead: bool\n target_x: float\n y: float = 20\n target_y: float = 20\n interval: float = 30\n speed: float = 1\n\n\n@dataclass\nclass Projectile:\n x: float\n y: float\n vx: float\n vy: float\n bonus: bool\n\n\nclass SmilyAngryEnvironment:\n score_cap = 300\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x = 50.\n self.direction = self.multiplier = 1\n self.steps = 0\n self.held = self.terminal = False\n self.faces = [Face(30, 20, True, True, 30), Face(70, 50, False, False, 70)]\n self.projectiles = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _fire(self, face):\n dx, dy = self.x - face.x, 90 - face.y\n if face.lead:\n vx = self.direction * 0.5\n first = hypot(dx, dy) / face.speed\n second = hypot(dx + vx * first, dy) / face.speed\n dx += vx * second\n angle = atan2(dy, dx)\n self.projectiles.append(Projectile(face.x, face.y, cos(angle) * face.speed,\n sin(angle) * face.speed, face.smile))\n\n def _advance(self, tap):\n for face in self.faces:\n face.x += (face.target_x - face.x) * 0.1\n face.y += (face.target_y - face.y) * 0.1\n face.timer -= 1\n if face.timer < 0:\n self._fire(face)\n face.timer = face.interval\n if self.random.random() < 0.002:\n face.target_x = self.random.uniform(10, 90)\n face.target_y = self.random.uniform(10, 40)\n if self.random.random() < 0.002:\n face.smile = not face.smile\n if self.random.random() < 0.002:\n face.lead = not face.lead\n if self.random.random() < 0.002:\n face.interval = self.random.uniform(30, 40)\n face.speed = self.random.uniform(0.9, 1.2)\n if tap:\n self.direction *= -1\n self.x = (self.x + self.direction * 0.5 + 3) % 106 - 3\n reward = 0\n remaining = []\n for projectile in self.projectiles:\n projectile.x = (projectile.x + projectile.vx + 3) % 106 - 3\n projectile.y += projectile.vy\n reach = 5.5 if projectile.bonus else 4\n if abs(projectile.x - self.x) < reach and abs(projectile.y - 90) < reach:\n if projectile.bonus:\n reward += self.multiplier\n self.multiplier += 1\n continue\n self.terminal = True\n if projectile.y < 93 - (3 if projectile.bonus else 1):\n remaining.append(projectile)\n elif projectile.bonus:\n self.multiplier = max(1, self.multiplier - 1)\n self.projectiles = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[9, int(np.clip(self.x // 10, 0, 9)), 0] = True\n for face in self.faces:\n state[int(face.y // 10), int(face.x // 10), 1 if face.smile else 2] = True\n for projectile in self.projectiles:\n if 0 <= projectile.x < 100 and 0 <= projectile.y < 100:\n state[int(projectile.y // 10), int(projectile.x // 10), 3 if projectile.bonus else 4] = True\n values = (self.steps, self.multiplier, self.direction > 0, self.held,\n *(face.lead for face in self.faces), *(round(face.timer) for face in self.faces))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 98, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/smily_angry.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/smilyangry/main.js"} +{"name": "m_rider", "split": "train", "game": "m_rider", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays M Rider as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to steer a ridden missile up. Actions 0–4\nlet it descend. A collision with a plane ejects the rider\nand starts a fuse. When the plane explodes, it scores the\ncurrent multiplier, raises it, and can trigger nearby planes.\n\nWhile airborne, hold to move forward and fall more slowly.\nTouch another missile to remount and halve the multiplier,\nrounding up. Falling below the screen or riding above it\nends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the rider, unmounted missiles,\nthe ridden missile, intact planes, armed planes, and gauges.\nThe conversion uses rectangular collision bounds and four\nframes per action at fixed difficulty. The 400-action task\nclips raw scores to [0, 150] and divides by 150.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/m_rider.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Body:\n x: float\n y: float\n vx: float = 0\n vy: float = 0\n\n def move(self, scroll=0):\n self.x += self.vx - scroll\n self.y += self.vy\n\n\n@dataclass\nclass Plane(Body):\n fuse: float = 0\n base_fuse: float = 0\n\n\nclass MRiderEnvironment:\n score_cap = 150\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.rider = Body(30, 46)\n self.mount = Body(30, 50, 1)\n self.missiles = [self.mount]\n self.planes: list[Plane] = []\n self.missile_timer, self.plane_timer = 9, 0\n self.steps = 0\n self.multiplier = 1\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n rider, mount = self.rider, self.mount\n if mount is None:\n rider.vx = (rider.vx + (0.04 if self.pressed else -0.02)) * 0.99\n rider.vy = (rider.vy + (0.01 if self.pressed else 0.05)) * 0.99\n rider.move()\n else:\n mount.vy = (mount.vy + (-0.05 if self.pressed else 0.05)) * 0.99\n mount.vx += (1 - mount.vx) * 0.1\n rider.x, rider.y = mount.x, mount.y - 4\n rider.vx, rider.vy = mount.vx, mount.vy\n scroll = max(0, rider.x - 50) * 0.1\n rider.x -= scroll\n if rider.y > 99 or (mount is not None and rider.y < -1):\n self.terminal = True\n return 0\n self._move_missiles(scroll)\n return self._move_planes(scroll)\n\n def _move_missiles(self, scroll):\n self.missile_timer -= 1\n if self.missile_timer < 0:\n y = self.random.uniform(40, 70)\n angle = math.atan2(y - self.random.uniform(50, 60), 210)\n speed = self.random.uniform(0.4, 0.5)\n self.missiles.append(Body(210, y, speed * math.cos(angle), speed * math.sin(angle)))\n self.missile_timer = self.random.uniform(60, 300)\n airborne = self.mount is None\n for missile in self.missiles:\n missile.move(scroll)\n if airborne and abs(missile.x - self.rider.x) < 12 and abs(missile.y - self.rider.y) < 5:\n self.multiplier = (self.multiplier + 1) // 2\n self.mount = missile\n self.missiles = [m for m in self.missiles if -9 <= m.x < 221 and -3 <= m.y < 113]\n\n def _move_planes(self, scroll):\n self.plane_timer -= 1\n if self.plane_timer < 0:\n y = self.random.uniform(30, 90)\n angle = math.atan2(y - self.random.uniform(40, 90), 203)\n speed = self.random.uniform(0.05, 0.3)\n self.planes.append(Plane(203, y, speed * math.cos(angle), speed * math.sin(angle)))\n self.plane_timer = self.random.uniform(20, 24)\n reward = 0\n remaining = []\n for plane in self.planes:\n plane.move(scroll)\n if plane.fuse > 0:\n plane.fuse -= 1\n if plane.fuse <= 0:\n reward += self.multiplier\n self.multiplier += 1\n delay = plane.base_fuse * 0.9\n if delay > 2:\n for other in self.planes:\n if other is not plane and math.hypot(other.x - plane.x, other.y - plane.y) < 36:\n other.fuse = other.base_fuse = delay\n continue\n if self.mount is not None and abs(self.mount.x - plane.x) < 12 and abs(self.mount.y - plane.y) < 5:\n self.rider.vy = -2\n self.mount.x = -99\n self.mount = None\n plane.fuse = plane.base_fuse = 9\n if -3 <= plane.x < 203 and -3 <= plane.y < 103:\n remaining.append(plane)\n self.planes = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n rider = self.rider\n state[min(9, max(0, int(rider.y // 10))), min(9, max(0, int(rider.x // 20))), 0] = True\n for missile in self.missiles:\n if 0 <= missile.x < 200 and 0 <= missile.y < 100:\n state[int(missile.y // 10), int(missile.x // 20), 2 if missile is self.mount else 1] = True\n for plane in self.planes:\n if 0 <= plane.x < 200 and 0 <= plane.y < 100:\n state[int(plane.y // 10), int(plane.x // 20), 4 if plane.fuse else 3] = True\n for row, value in enumerate((self.steps, self.multiplier, round((rider.vy + 6) * 35),\n round((rider.vx + 4) * 50))):\n for bit in range(9):\n state[row, bit, 5] = bool(min(511, max(0, value)) & (1 << bit))\n state[9, :2, 5] = self.pressed, self.mount is not None\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 99, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/m_rider.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/mrider/main.js"} +{"name": "light_dark", "split": "train", "game": "light_dark", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Light Dark as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to switch sides. A tap on the ground also\nstarts a jump. Holding slows the fall, and actions 0–4\nrelease. Coins build the multiplier and missed coins lower\nit. Contact with a spike ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, coins, spikes,\nthe dark half, the active side, and gauges. The conversion\nuses approximate rectangular hitboxes and fixed difficulty.\nEach action advances four frames, up to 400 actions. Raw\nscores are clipped to [0, 500] and divided by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/light_dark.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Item:\n x: float\n dark: bool\n spike: bool = False\n\n\nclass LightDarkEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.height = self.velocity = 0.0\n self.dark = self.airborne = self.pressed = self.terminal = False\n self.steps = 0\n self.multiplier = 1\n self.items = [Item(25 + i * 9 if i < 5 else 99 + i * 9, i >= 5) for i in range(10)]\n self.distances = [200.0, 300.0]\n self.next_spike = [False, True]\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tapped = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tapped and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tapped: bool) -> int:\n if tapped:\n self.dark = not self.dark\n if self.airborne:\n self.velocity -= 0.1 if self.pressed else 0.5\n self.height += self.velocity\n if self.height < 0:\n self.height = 0\n self.airborne = False\n elif tapped:\n self.velocity, self.height = 3, 7\n self.airborne = True\n reward = 0\n remaining = []\n for item in self.items:\n extent = 6 if item.spike else 5\n if item.dark == self.dark and abs(item.x - 9) < extent and abs(self.height - 1) < extent:\n if item.spike:\n self.terminal = True\n break\n reward += self.multiplier\n self.multiplier += 1\n continue\n item.x -= 2\n if item.x >= -3:\n remaining.append(item)\n elif not item.spike:\n self.multiplier = max(1, self.multiplier - 1)\n self.items = remaining\n for side in range(2):\n self.distances[side] -= 2\n if self.distances[side] < 0:\n spike = self.next_spike[side]\n spacing = 6 if spike else 9\n count = int(self.random.integers(5, 15) if spike else self.random.integers(4, 8))\n self.items.extend(Item(200 + i * spacing, bool(side), spike) for i in range(count))\n self.distances[side] = count * spacing + self.random.uniform(40, 120)\n self.next_spike[side] = not spike\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n y = 53 + self.height if self.dark else 47 - self.height\n state[min(9, max(0, int(y // 10))), 0, 0] = True\n for item in self.items:\n if 0 <= item.x < 200:\n state[5 if item.dark else 4, int(item.x // 20), 1 + item.spike] = True\n state[5:, :, 3] = True\n state[5 if self.dark else 4, :, 4] = True\n values = (self.steps, min(511, self.multiplier), round(self.height * 8),\n min(511, max(0, round((self.velocity + 8) * 30))))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.airborne\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 100, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/light_dark.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/lightdark/main.js"} +{"name": "phaserun", "split": "train", "game": "phaserun", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Phaserun as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to switch between solid and ghost. Hold to\ngrow and release with actions 0–4 to shrink. Only the solid\nplayer collects coins or collides with obstacles. Coins\nscore the player's current size rounded up. A solid hit\nends the run.\n\nINPUT CHANNEL TABLE\nSix 10×10 channels show the solid player, ghost player,\nobstacles, coins, travel lane, and gauges. The conversion\nuses rectangular contact checks at fixed difficulty. Each\naction advances four frames, up to 400 actions. Raw scores\nare clipped to [0, 5000] and divided by 5000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/phaserun.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Coin:\n x: float\n phase: float = 0\n\n @property\n def y(self):\n return 50 + 3 * math.sin(self.phase)\n\n\nclass PhaserunEnvironment:\n score_cap = 5000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.size = self.target_size = 8.0\n self.scale_x = 1.0\n self.animation = self.steps = self.frames = 0\n self.obstacle_timer, self.coin_timer = 60, 0\n self.solid = True\n self.pressed = self.terminal = False\n self.obstacles: list[float] = []\n self.coins: list[Coin] = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed:\n self.solid = not self.solid\n self.scale_x = 1.3\n self.animation = 10\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n self.frames += 1\n if self.animation:\n self.animation -= 1\n self.scale_x += (1 - self.scale_x) * 0.3\n else:\n self.scale_x = 1 + math.sin(self.frames * 0.08) * 0.03\n self.obstacle_timer -= 1\n if self.obstacle_timer <= 0:\n self.obstacles.append(105)\n self.obstacle_timer = int(self.random.integers(88, 111))\n self.coin_timer -= 1\n if self.coin_timer <= 0:\n self.coins.append(Coin(105, self.random.uniform(0, math.tau)))\n self.coin_timer = int(self.random.integers(11, 77))\n self.target_size += 3 if self.pressed else (8 - self.target_size) * 0.5\n self.size += (self.target_size - self.size) * 0.3\n half_width = self.size * self.scale_x / 2\n half_height = self.size * (2 - self.scale_x) / 2\n reward = 0\n remaining = []\n for coin in self.coins:\n coin.x -= 1\n coin.phase += 0.15\n if self.solid and abs(coin.x - 20) < half_width + 3 and abs(coin.y - 50) < half_height + 3:\n reward += math.ceil(self.size)\n elif coin.x >= -10:\n remaining.append(coin)\n self.coins = remaining\n self.obstacles = [x - 1 for x in self.obstacles if x - 1 >= -10]\n self.terminal = self.solid and any(abs(x - 20) < half_width + 5 for x in self.obstacles)\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n state[:, :, 0 if self.solid else 1] = (\n (abs(cols - 20) <= max(5, self.size * self.scale_x / 2))\n & (abs(rows - 50) <= max(5, self.size * (2 - self.scale_x) / 2))\n )\n for x in self.obstacles:\n if 0 <= x < 100:\n state[5, int(x // 10), 2] = True\n for coin in self.coins:\n if 0 <= coin.x < 100:\n state[int(coin.y // 10), int(coin.x // 10), 3] = True\n state[5, :, 4] = True\n for row, value in enumerate((self.steps, round(self.size), round(self.target_size), self.animation)):\n for bit in range(13):\n gauge_row, col = 2 * row + bit // 10, bit % 10\n state[gauge_row, col, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 101, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/phaserun.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePhaserun.c"} +{"name": "frostbite", "split": "train", "game": "frostbite", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Frostbite as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves Activision's four-row ice-floe construction loop. Frostbite Bailey\nstarts on the lower shore and jumps with actions 1–4. Each row has moving floes and open water.\nLanding on a white row turns it blue, adds one block to the igloo, and awards ten times the level.\nAfter all four rows are blue they reset to white; four cycles build the 16-block igloo. Bailey must\nthen reach its door on the upper shore.\n\nAction 5 reverses every floe's direction and removes one incomplete igloo block. Rebuilding a\nremoved block restores construction but cannot duplicate a previously claimed construction-score\nidentity. Bailey standing still on a floe is carried with it. Water, clams, snow geese, crabs, and\nthe level-four-and-later polar bear cost a life. Four finite fish per level award 200 each.\n\nTemperature starts at 45 and falls one degree every five steps. Reaching zero costs a life;\nreplacement Bailey returns with 45 degrees while construction remains, matching the original's\nrisk/recovery behavior. Igloo entry awards 160 times the level plus\n`10 × remaining degrees × level`. The player starts with four lives and earns another each 5,000\npoints up to ten total active-plus-reserve lives.\n\nACTION MAPPING\n0: wait\n1: move left\n2: move up\n3: move right\n4: move down\n5: reverse floes or remove incomplete igloo block\n\nINPUT CHANNEL TABLE\n0: Frostbite Bailey\n1: clams, crabs, geese, and polar bear\n2: floes, fish, and completed igloo door\n3: currently white construction rows and igloo door\n4: previous Bailey, animal, and fish positions\n5: lives, exact binary igloo progress, level, and exact binary temperature\n\nSCORING, TERMINATION, AND HORIZON\nAcross levels 1–9, 16 unique construction rewards contribute\n`16 × 10 × (1 + ... + 9) = 7,200`; igloo entry contributes `160 × 45 = 7,200`; maximum\ntemperature bonuses contribute `10 × 45 × 45 = 20,250`; and 36 fish contribute 7,200. The\nstructural maximum is therefore `score_cap = 41,850`. Normalization is\n`min(max(raw_score, 0), 41_850) / 41_850`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/frostbite.py`):\n```python\nimport numpy as np\n\n\nICE_ROWS = (3, 4, 5, 6)\n\n\nclass FrostbiteEnvironment:\n \"\"\"Nine-level ice-floe construction game with temperature pressure.\"\"\"\n\n score_cap = 41_850.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 2_025):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.player = [7, 5]\n self.previous_player = self.player.copy()\n self.level = 1\n self.lives = 4\n self.score = 0.0\n self.next_life_score = 5_000.0\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self.life_lost_this_step = False\n self._start_level()\n\n def _start_level(self) -> None:\n self.player = [7, 5]\n self.previous_player = self.player.copy()\n self.life_lost_this_step = False\n self.floes = {row: {(row + offset * 3) % 10 for offset in range(4)} for row in ICE_ROWS}\n self.floe_directions = {row: 1 if row % 2 else -1 for row in ICE_ROWS}\n self.white_rows = set(ICE_ROWS)\n self.igloo_blocks = 0\n self.scored_blocks = 0\n self.temperature = 45\n self.level_steps = 0\n self.fish_remaining = 4\n self.fish: list[dict[str, object]] = []\n self.hazards = [\n {\n \"position\": [row, (row * 2 + self.level) % 10],\n \"direction\": -self.floe_directions[row],\n \"kind\": (\"clam\", \"crab\", \"goose\")[(row - 3) % 3],\n }\n for row in ICE_ROWS\n ]\n self.bear = [2, 9] if self.level >= 4 else None\n self.previous_objects: list[list[int]] = []\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n self.previous_objects = [list(hazard[\"position\"]) for hazard in self.hazards]\n self.previous_objects.extend(list(fish[\"position\"]) for fish in self.fish)\n level_before_action = self.level\n reward = self._apply_action(action)\n if self.level != level_before_action or self.terminal:\n self.score += reward\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n self._move_world()\n reward += self._resolve_landing()\n reward += self._resolve_fish()\n self._resolve_hazards()\n self.level_steps += 1\n self.steps += 1\n if self.level_steps % 5 == 0 and not self.life_lost_this_step:\n self.temperature -= 1\n if self.temperature <= 0:\n self._lose_life()\n self.score += reward\n while self.score >= self.next_life_score and self.lives < 10:\n self.lives += 1\n self.next_life_score += 5_000.0\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _apply_action(self, action: int) -> float:\n if action == 5:\n for row in ICE_ROWS:\n self.floe_directions[row] *= -1\n if self.igloo_blocks < 16 and self.igloo_blocks > 0:\n self.igloo_blocks -= 1\n return 0.0\n if action in (1, 2, 3, 4):\n row_delta, column_delta = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}[action]\n target = [self.player[0] + row_delta, self.player[1] + column_delta]\n if 1 <= target[0] <= 7 and 0 <= target[1] < 10:\n self.player = target\n if self.igloo_blocks >= 16 and self.player == [1, 9]:\n return self._enter_igloo()\n return 0.0\n\n def _move_world(self) -> None:\n standing_row = self.previous_player[0]\n carried = standing_row in ICE_ROWS and self.previous_player[1] in self.floes[standing_row]\n for row in ICE_ROWS:\n direction = self.floe_directions[row]\n self.floes[row] = {(column + direction) % 10 for column in self.floes[row]}\n if carried and self.player == self.previous_player:\n self.player[1] = (self.player[1] + self.floe_directions[standing_row]) % 10\n for hazard in self.hazards:\n hazard[\"position\"][1] = (hazard[\"position\"][1] + int(hazard[\"direction\"])) % 10\n for fish in self.fish:\n fish[\"position\"][1] = (fish[\"position\"][1] + int(fish[\"direction\"])) % 10\n if self.fish_remaining > 0 and self.level_steps % 12 == 0:\n row = ICE_ROWS[self.fish_remaining % 4]\n self.fish.append(\n {\"position\": [row, int(self.random.randint(10))], \"direction\": self.floe_directions[row]}\n )\n self.fish_remaining -= 1\n if self.bear is not None:\n self.bear[1] += int(np.sign(self.player[1] - self.bear[1]))\n\n def _resolve_landing(self) -> float:\n row, column = self.player\n if row in ICE_ROWS and column not in self.floes[row]:\n self._lose_life()\n return 0.0\n if row not in self.white_rows or row not in ICE_ROWS:\n return 0.0\n self.white_rows.remove(row)\n self.igloo_blocks += 1\n reward = 0.0\n if self.scored_blocks < 16:\n self.scored_blocks += 1\n reward = float(min(self.level, 9) * 10)\n if not self.white_rows and self.igloo_blocks < 16:\n self.white_rows = set(ICE_ROWS)\n return reward\n\n def _resolve_fish(self) -> float:\n caught = [fish for fish in self.fish if fish[\"position\"] == self.player]\n if not caught:\n return 0.0\n caught_ids = {id(fish) for fish in caught}\n self.fish = [fish for fish in self.fish if id(fish) not in caught_ids]\n return 200.0 * len(caught)\n\n def _resolve_hazards(self) -> None:\n if self.life_lost_this_step:\n return\n if any(hazard[\"position\"] == self.player for hazard in self.hazards):\n self._lose_life()\n return\n if self.bear is not None and self.bear == self.player:\n self._lose_life()\n\n def _lose_life(self) -> None:\n if self.life_lost_this_step:\n return\n self.life_lost_this_step = True\n self.lives -= 1\n self.player = [7, 5]\n self.previous_player = self.player.copy()\n self.temperature = 45\n if self.lives <= 0:\n self.terminal = True\n\n def _enter_igloo(self) -> float:\n level_value = min(self.level, 9)\n reward = float(160 * level_value + 10 * self.temperature * level_value)\n self.level += 1\n if self.level > 9:\n self.terminal = True\n else:\n self._start_level()\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n for row in ICE_ROWS:\n for column in self.floes[row]:\n state[row, column, 2] = True\n if row in self.white_rows:\n state[row, column, 3] = True\n for hazard in self.hazards:\n state[*hazard[\"position\"], 1] = True\n if self.bear is not None:\n state[*self.bear, 1] = True\n for fish in self.fish:\n state[*fish[\"position\"], 2] = True\n if self.igloo_blocks >= 16:\n state[1, 9, 2] = True\n state[1, 9, 3] = True\n state[*self.previous_player, 4] = True\n for position in self.previous_objects:\n state[*position, 4] = True\n state[9, : self.lives, 5] = True\n for bit in range(5):\n if self.igloo_blocks & (1 << bit):\n state[8, bit, 5] = True\n state[7, : self.level, 5] = True\n for bit in range(6):\n if self.temperature & (1 << bit):\n state[2, bit, 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 102, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/frostbite.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "circle_w", "split": "train", "game": "circle_w", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Circle W as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to expand your ring and release with actions 0–4 to\nshrink it. When its outline touches a blue ring, you transfer to\nthat ring and adopt its radius. Each transfer adds the old radius,\nrounded up, to the multiplier and awards that multiplier in points.\nThe multiplier decays while the radius is below nine. Touching a\nred ring ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show your ring, blue rings, red rings, your\ncenter, target centers, and gauges. Each action advances four frames\nat fixed difficulty. The conversion checks outline contact using\ncenter distances and radii.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 25000] and divide by the fixed cap of 25,000. Across 100 seeds\nwithout sticky actions, idle averaged 45.24 raw points, random\ninputs averaged 1,175.80, and holding averaged 16,487.04 and\nreached 104,433 before clipping.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/circle_w.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Ring:\n x: float\n y: float\n radius: float\n danger: bool = False\n\n\nclass CircleWEnvironment:\n score_cap = 25000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = 0\n self.pressed = self.terminal = False\n self.player = Ring(200, 50, 1)\n self.scroll_x = self.scroll_y = self.next_ring = 0.0\n self.danger_count = 30\n self.multiplier = 1\n self.rings: list[Ring] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance_frame()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n @staticmethod\n def _touches(first: Ring, second: Ring) -> bool:\n distance = math.hypot(first.x - second.x, first.y - second.y)\n return abs(first.radius - second.radius) - 2 <= distance <= first.radius + second.radius + 2\n\n def _advance_frame(self) -> int:\n player = self.player\n if player.radius < 9:\n self.multiplier = max(1, self.multiplier - 1)\n player.radius = max(1, player.radius + (0.5 if self.pressed else -0.5))\n for ring in [player, *self.rings]:\n ring.x += self.scroll_x\n ring.y = (ring.y + self.scroll_y + 15) % 130 - 15\n player.x = max(20, player.x)\n self.rings = [ring for ring in self.rings if ring.x >= -ring.radius]\n destination = None\n for ring in self.rings:\n if self._touches(player, ring):\n if ring.danger:\n self.terminal = True\n return 0\n if destination is None:\n destination = ring\n reward = 0\n if destination is not None:\n self.multiplier += math.ceil(player.radius)\n reward = self.multiplier\n self.player = destination\n self.rings.remove(destination)\n\n self.next_ring += self.scroll_x\n if self.next_ring < 0:\n self._spawn()\n self.scroll_x = -1 - max(0, player.x - 20) * 0.1\n self.scroll_y = (50 - player.y) * 0.1\n return reward\n\n def _spawn(self) -> None:\n danger = self.danger_count == 0\n for _ in range(9):\n radius = self.random.uniform(8, 15)\n x, y = 200 + radius, int(self.random.integers(99))\n half_width = radius * (4 if danger else 2.5)\n if any(abs(x - ring.x) < half_width + ring.radius and abs(y - ring.y) < radius * 1.25 + ring.radius\n for ring in self.rings):\n continue\n self.rings.append(Ring(x, y, radius, danger))\n self.danger_count = int(self.random.integers(24, 30)) if danger else self.danger_count - 1\n self.next_ring = 5\n break\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for ring, channel in [(self.player, 0), *((ring, 2 if ring.danger else 1) for ring in self.rings)]:\n for row in range(10):\n for col in range(10):\n distance = math.hypot(col * 20 + 10 - ring.x, row * 10 + 5 - ring.y)\n state[row, col, channel] |= abs(distance - ring.radius) <= 9\n row = min(9, max(0, int(self.player.y) // 10))\n col = min(9, int(self.player.x) // 20)\n state[row, col, 3] = True\n for ring in self.rings:\n if 0 <= ring.x < 200 and 0 <= ring.y < 100:\n state[int(ring.y) // 10, int(ring.x) // 20, 4] = True\n for row, value in enumerate((self.steps, round(self.player.radius * 2), self.multiplier, self.danger_count)):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n for bit in range(6):\n state[4, bit, 5] = bool(self.multiplier & (1 << (bit + 10)))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 103, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/circle_w.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/circlew/main.js"} +{"name": "james_bond", "split": "train", "game": "james_bond", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays James Bond as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves the cartridge's three-film itinerary and multipurpose craft. Left and\nright adjust forward position; up jumps or rises; down dives; otherwise gravity or buoyancy\nreturns Bond to the surface line. Every action-5 press alternates the manual's upward fixed-angle\nshot and downward lobbed bomb.\n\nIn *Diamonds Are Forever*, Bond shoots diamonds for 50 points to illuminate an otherwise hidden\noil rig, destroys 200-point mechanical frogmen, and must land on the lit helipad. In *Moonraker*,\nhe destroys three 500-point spinning satellites while dealing with 200-point rising shuttles that\nturn into 100-point falling poison bombs, submarines, and torpedoes. In *The Spy Who Loved Me*,\nrapid rockets become fire bombs, submarines and torpedoes patrol, and a bomb must hit Stromberg's\nundersea laboratory. Bond then has eight steps to touch Anya's released capsule. Each mission\nawards 5,000 points and carries remaining craft forward; losing all six craft ends the game.\n\nACTION MAPPING\n0: coast toward surface\n1: move slightly back\n2: jump/rise\n3: move forward\n4: dive\n5: alternate fixed-angle shot and lobbed bomb\n\nINPUT CHANNEL TABLE\n0: Bond's craft\n1: ordinary enemies and targets\n2: falling bombs, lit rig, laboratory, and rescue capsule\n3: Bond's shot and bomb\n4: previous craft position\n5: consumed target identities, mission, weapon phase, lives, timers, recurring encounter phase, and exact episode step\n\nSCORING, TERMINATION, AND HORIZON\nMission one contains four diamonds and four frogmen for 1,000 target points. Mission two contains\nthree satellites, four shuttle/poison identities, three submarines, and three torpedoes for 3,200.\nMission three contains four rocket/fire-bomb identities, three submarines, and three torpedoes for\n1,300. A transforming shuttle or rocket retains one identity and can pay only its higher applicable\nvalue. Adding three 5,000-point mission awards gives\n`score_cap = 1,000 + 3,200 + 1,300 + 15,000 = 20,500`. Normalization is\n`min(max(raw_score, 0), 20_500) / 20_500`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/james_bond.py`):\n```python\nimport numpy as np\n\n\nMISSION_NAMES = (\"diamonds\", \"moonraker\", \"spy\")\n\n\nclass JamesBondEnvironment:\n \"\"\"Three-mission multipurpose-craft campaign with alternating weapons.\"\"\"\n\n score_cap = 20_500.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 1_800):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.mission = 0\n self.lives = 6\n self.score = 0.0\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self.destroyed: set[tuple[int, str, int]] = set()\n self._start_mission()\n\n def _start_mission(self) -> None:\n self.player = [5, 1]\n self.previous_player = self.player.copy()\n self.entities: list[dict[str, object]] = []\n self.projectiles: list[dict[str, object]] = []\n self.mission_steps = 0\n self.next_weapon = \"shot\"\n self.light_timer = 0\n self.rig: list[int] | None = None\n self.lab: list[int] | None = None\n self.capsule: list[int] | None = None\n self.capsule_timer = 0\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n mission_before = self.mission\n lives_before = self.lives\n self._move_player(action)\n if action == 5:\n self._fire_weapon()\n self._spawn_entities()\n reward = self._move_projectiles()\n if self.terminal or self.mission >= 3:\n return self._finish_step(reward)\n self._move_entities()\n self._resolve_player_contacts()\n if self.terminal or self.lives != lives_before:\n return self._finish_step(reward, advance_mission=False)\n reward += self._resolve_objectives()\n return self._finish_step(reward, advance_mission=self.mission == mission_before)\n\n def _finish_step(self, reward: float, advance_mission: bool = True) -> tuple[float, bool]:\n self.score += reward\n self.steps += 1\n if self.mission < 3 and advance_mission:\n self.mission_steps += 1\n self.light_timer = max(0, self.light_timer - 1)\n if self.capsule is not None:\n self.capsule_timer -= 1\n if self.capsule_timer <= 0:\n self.capsule = None\n self.lab = None\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_player(self, action: int) -> None:\n if action == 1:\n self.player[1] = max(0, self.player[1] - 1)\n elif action == 2:\n self.player[0] = max(0, self.player[0] - 1)\n elif action == 3:\n self.player[1] = min(9, self.player[1] + 1)\n elif action == 4:\n self.player[0] = min(9, self.player[0] + 1)\n elif self.player[0] < 5:\n self.player[0] += 1\n elif self.player[0] > 5:\n self.player[0] -= 1\n\n def _fire_weapon(self) -> None:\n if len(self.projectiles) >= 2:\n return\n if self.next_weapon == \"shot\":\n self.projectiles.append({\"position\": self.player.copy(), \"direction\": [-1, 1], \"kind\": \"shot\"})\n self.next_weapon = \"bomb\"\n else:\n self.projectiles.append({\"position\": self.player.copy(), \"direction\": [1, 1], \"kind\": \"bomb\"})\n self.next_weapon = \"shot\"\n\n def _mission_schedule(self) -> list[tuple[int, str, int, int, int]]:\n if self.mission == 0:\n return [\n (5, \"diamond\", 1, 50, 4),\n (18, \"frogman\", 7, 200, 4),\n (32, \"diamond\", 1, 50, 4),\n (46, \"frogman\", 7, 200, 4),\n ]\n if self.mission == 1:\n return [\n (5, \"satellite\", 1, 500, 3),\n (15, \"shuttle\", 8, 200, 4),\n (28, \"submarine\", 7, 200, 3),\n (40, \"torpedo\", 6, 100, 3),\n ]\n return [\n (8, \"rocket\", 8, 100, 4),\n (24, \"submarine\", 7, 200, 3),\n (38, \"torpedo\", 6, 100, 3),\n ]\n\n def _spawn_entities(self) -> None:\n cycle_step = self.mission_steps % 60\n cycle = self.mission_steps // 60\n for spawn_step, kind, row, value, count in self._mission_schedule():\n index = cycle % count\n identity = (self.mission, kind, index)\n present = any(entity[\"identity\"] == identity for entity in self.entities)\n if cycle_step == spawn_step and identity not in self.destroyed and not present:\n self.entities.append(\n {\n \"identity\": identity,\n \"kind\": kind,\n \"position\": [row, 9],\n \"value\": value,\n \"age\": 0,\n }\n )\n if self.mission == 0 and self.mission_steps >= 120 and self.rig is None:\n self.rig = [3, 8]\n if self.mission == 2 and self.mission_steps >= 120 and self.lab is None and self.capsule is None:\n self.lab = [8, 8]\n\n def _move_projectiles(self) -> float:\n reward = 0.0\n remaining = []\n for projectile in self.projectiles:\n position = projectile[\"position\"]\n direction = projectile[\"direction\"]\n position[0] += direction[0]\n position[1] += direction[1]\n hit = False\n for entity in list(self.entities):\n if entity[\"position\"] == position:\n self.entities.remove(entity)\n identity = entity[\"identity\"]\n if identity not in self.destroyed:\n self.destroyed.add(identity)\n reward += float(entity[\"value\"])\n if entity[\"kind\"] == \"diamond\":\n self.light_timer = 30\n hit = True\n break\n if self.lab == position and projectile[\"kind\"] == \"bomb\":\n self.lab = None\n self.capsule = [6, 8]\n self.capsule_timer = 8\n hit = True\n elif self.capsule == position and projectile[\"kind\"] == \"bomb\":\n self.capsule[0] = min(8, self.capsule[0] + 1)\n self.capsule_timer = 8\n hit = True\n if not hit and 0 <= position[0] < 10 and 0 <= position[1] < 10:\n remaining.append(projectile)\n self.projectiles = remaining\n return reward\n\n def _move_entities(self) -> None:\n for entity in list(self.entities):\n entity[\"age\"] = int(entity[\"age\"]) + 1\n position = entity[\"position\"]\n position[1] -= 1\n if entity[\"kind\"] in (\"shuttle\", \"rocket\") and position[0] <= 1:\n entity[\"kind\"] = \"poison\" if entity[\"kind\"] == \"shuttle\" else \"fire_bomb\"\n entity[\"value\"] = 100\n position[0] = 1\n elif entity[\"kind\"] in (\"shuttle\", \"rocket\"):\n position[0] -= 1\n elif entity[\"kind\"] in (\"poison\", \"fire_bomb\"):\n position[0] += 1\n if position[1] < 0 or position[0] > 9:\n self.entities.remove(entity)\n\n def _resolve_player_contacts(self) -> None:\n if any(entity[\"position\"] == self.player for entity in self.entities):\n self._lose_life()\n\n def _resolve_objectives(self) -> float:\n if self.mission == 0 and self.rig is not None and self.player == self.rig and self.light_timer > 0:\n return self._complete_mission()\n satellites = sum(1 for mission, kind, _ in self.destroyed if mission == 1 and kind == \"satellite\")\n if self.mission == 1 and satellites >= 3:\n return self._complete_mission()\n if self.mission == 2 and self.capsule is not None and self.player == self.capsule:\n return self._complete_mission()\n return 0.0\n\n def _complete_mission(self) -> float:\n self.mission += 1\n if self.mission >= 3:\n self.terminal = True\n else:\n self._start_mission()\n return 5_000.0\n\n def _lose_life(self) -> None:\n self.lives -= 1\n if self.lives <= 0:\n self.terminal = True\n else:\n self._start_mission()\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n for entity in self.entities:\n channel = 2 if entity[\"kind\"] in (\"poison\", \"fire_bomb\") else 1\n state[*entity[\"position\"], channel] = True\n if self.rig is not None and self.light_timer > 0:\n state[*self.rig, 2] = True\n if self.lab is not None:\n state[*self.lab, 2] = True\n if self.capsule is not None:\n state[*self.capsule, 2] = True\n for projectile in self.projectiles:\n state[*projectile[\"position\"], 3] = True\n state[*self.previous_player, 4] = True\n reward_identities = []\n for mission in range(3):\n old_mission = self.mission\n self.mission = mission\n for _, kind, _, _, count in self._mission_schedule():\n reward_identities.extend((mission, kind, index) for index in range(count))\n self.mission = old_mission\n for index, identity in enumerate(reward_identities):\n state[index // 10, index % 10, 5] = identity in self.destroyed\n for bit in range(2):\n state[4, 4 + bit, 5] = bool(self.mission & (1 << bit))\n state[4, 6, 5] = self.next_weapon == \"shot\"\n state[4, 7, 5] = self.next_weapon == \"bomb\"\n for bit in range(3):\n state[5, bit, 5] = bool(self.lives & (1 << bit))\n for bit in range(4):\n state[5, 3 + bit, 5] = bool(self.capsule_timer & (1 << bit))\n for bit in range(5):\n state[6, bit, 5] = bool(self.light_timer & (1 << bit))\n cycle_step = self.mission_steps % 60\n cycle = (self.mission_steps // 60) % 12\n for bit in range(6):\n state[7, bit, 5] = bool(cycle_step & (1 << bit))\n state[7, 6, 5] = self.mission_steps >= 120\n for bit in range(4):\n state[9, 3 + bit, 5] = bool(cycle & (1 << bit))\n for bit in range(10):\n state[8, bit, 5] = bool(self.steps & (1 << bit))\n state[9, 9, 5] = bool(self.steps & (1 << 10))\n for index, name in enumerate(MISSION_NAMES):\n state[4, index, 5] = self.mission < 3 and MISSION_NAMES[self.mission] == name\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 104, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/james_bond.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "orbit_man", "split": "train", "game": "orbit_man", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Orbit Man as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to launch along the rotating aim line.\nActions 0–4 release. A successful launch reaches the\nfarthest aligned planet and destroys the departure planet\nand any intervening aligned planets. Each destroyed planet\nscores the current multiplier and raises it. Launching\nreduces the multiplier by one before scoring. A launch with\nno target or a home planet leaving the screen ends the run.\n\nINPUT CHANNEL TABLE\nSix 10×10 channels show the traveler, home planet, other\nplanets, aligned destinations, aim line, and gauges. The\nconversion uses geometric ray contact and fixed difficulty.\nEach action advances four frames. The 400-action task clips\nscores to [0, 120] and divides by 120.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/orbit_man.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Planet:\n x: float\n y: float\n radius: float\n\n\nclass OrbitManEnvironment:\n score_cap = 120\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.home = Planet(50, 0, 5)\n self.planets = [self.home]\n self.x, self.y = 50.0, 0.0\n self.angle = math.pi / 2\n self.distance = 20.0\n self.direction = self.multiplier = 1\n self.flight = self.steps = 0\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _aligned(self):\n cosine, sine = math.cos(self.angle), math.sin(self.angle)\n aligned = []\n for planet in self.planets:\n if planet is self.home or planet.y <= -planet.radius - 4:\n continue\n dx, dy = planet.x - self.home.x, planet.y - self.home.y\n along = dx * cosine + dy * sine\n across = -dx * sine + dy * cosine\n end = min(99 + self.home.radius * 1.485, max(self.home.radius * 1.485, along))\n if math.hypot(along - end, across) < planet.radius + 2:\n aligned.append(planet)\n return aligned\n\n def _advance(self, tap):\n self.flight = max(1, self.flight - 1)\n scroll = 0.05 + max(0, 80 - self.home.y) * 0.1 / self.flight\n self.distance -= scroll\n while self.distance < 0:\n radius = self.random.uniform(4, 9)\n self.planets.append(Planet(self.random.uniform(10 + radius, 90 - radius), self.distance - 30, radius))\n self.distance += radius * self.random.uniform(1, 2)\n self.angle += 0.03 * self.direction\n for planet in self.planets:\n planet.y += scroll\n self.planets = [p for p in self.planets if p is self.home or p.y <= 100 + p.radius * 2]\n reward = 0\n if tap:\n aligned = self._aligned()\n if not aligned:\n self.terminal = True\n return 0\n target = max(aligned, key=lambda p: math.hypot(p.x - self.home.x, p.y - self.home.y))\n destroyed = [self.home, *(p for p in aligned if p is not target)]\n self.multiplier = max(1, self.multiplier - 1)\n reward = len(destroyed) * (2 * self.multiplier + len(destroyed) - 1) // 2\n self.multiplier += len(destroyed)\n self.planets = [p for p in self.planets if all(p is not old for old in destroyed)]\n self.home = target\n self.angle += math.pi\n self.direction *= -1\n self.flight = 20\n self.x += (self.home.x + self.home.radius * math.cos(self.angle) - self.x) * 0.1\n self.y += (self.home.y + self.home.radius * math.sin(self.angle) - self.y) * 0.1\n self.terminal = self.home.y - self.home.radius > 99\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n if 0 <= self.y < 100:\n state[int(self.y // 10), int(self.x // 10), 0] = True\n aligned = self._aligned()\n for planet in self.planets:\n if 0 <= planet.y < 100:\n row, col = int(planet.y // 10), int(planet.x // 10)\n state[row, col, 1 if planet is self.home else 2] = True\n state[row, col, 3] |= planet in aligned\n for distance in range(0, 100, 4):\n x = self.home.x + distance * math.cos(self.angle)\n y = self.home.y + distance * math.sin(self.angle)\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), 4] = True\n values = (self.steps, min(511, self.multiplier), self.flight, round(self.angle % math.tau * 80))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 105, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/orbit_man.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/orbitman/main.js"} +{"name": "balls_bombs", "split": "train", "game": "balls_bombs", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Balls Bombs as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to advance. Actions 0–4 stop walking. Balls bounce\nacross the route, and contact is lethal unless the player is carrying\na bomb. Picking up a bomb arms it. The next contact consumes it,\nremoves the triggering ball, and creates an expanding blast ring.\nOther balls hit by the ring score a rising combo that resets when\nthe blast expires.\n\nINPUT CHANNEL TABLE\nChannels show the player, balls, bomb pickup, blast ring, upward\nball motion, and gauges. The adaptation uses discrete walking,\nsubcell vertical bounce, viewport-relative horizontal rebound,\nand a six-radius blast. Ball spawning uses a fixed clock.\n\nSCORING, TERMINATION, AND HORIZON\nAt most 80 balls spawn over 400 steps. Each can score once.\nPutting all hits in a single combo bounds the score at 3,240.\nNormalize by clipping to [0, 3240] and dividing by 3240.\n\nSmoke test over 100 seeds with sticky actions disabled: idle and\ncontinuous hold both averaged 0. Random hold/release averaged 5.22\nand reached 56.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/balls_bombs.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\nHORIZON = 400\nGROUND = 32\nUNIT = 4\nSPAWN_INTERVAL = 5\nMAX_BALLS = (HORIZON + SPAWN_INTERVAL - 1) // SPAWN_INTERVAL\n\n\n@dataclass\nclass Ball:\n x: int\n y: int\n vx: int\n vy: int = 0\n\n\nclass BallsBombsEnvironment:\n score_cap = MAX_BALLS * (MAX_BALLS + 1) // 2\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.last_action = self.scroll = 0\n self.player = 2\n self.next_bomb = 6\n self.bomb: int | None = None\n self.armed = False\n self.blast: tuple[int, int] | None = None\n self.multiplier = 1\n self.balls: list[Ball] = []\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.steps += 1\n if action == 5:\n self.player += 1\n self.scroll = max(0, self.player - 4)\n if not self.armed and self.bomb is None and self.player >= self.next_bomb:\n self.bomb = self.scroll + 9\n if self.bomb == self.player:\n self.armed = True\n self.bomb = None\n self.next_bomb = self.player + int(self.random.integers(9, 13))\n if self.blast is not None:\n center, radius = self.blast\n self.blast = (center, radius + 1) if radius < 6 else None\n if self.blast is None:\n self.multiplier = 1\n if self.steps % SPAWN_INTERVAL == 1:\n from_left = self.random.random() < 0.1\n self.balls.append(Ball(self.scroll + (0 if from_left else 9),\n int(self.random.integers(5, 17)), 1 if from_left else -1))\n reward = 0\n survivors = []\n for ball in self.balls:\n ball.vy += 1\n ball.y += ball.vy\n if ball.y >= GROUND:\n ball.y = GROUND\n ball.vy = -ball.vy\n if self.steps % 2 == 0:\n ball.x += ball.vx\n if ball.x <= self.scroll and ball.vx < 0:\n ball.vx = 2\n elif ball.x >= self.scroll + 9 and ball.vx > 0:\n ball.vx = -1\n if self._in_blast(ball.y // UNIT, ball.x):\n reward += self.multiplier\n self.multiplier += 1\n elif ball.x == self.player and ball.y // UNIT == GROUND // UNIT:\n if self.armed:\n self.armed = False\n self.blast = self.player, 1\n else:\n self.terminal = True\n elif ball.x >= self.scroll - 2:\n survivors.append(ball)\n self.balls = survivors\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _in_blast(self, row: int, x: int) -> bool:\n if self.blast is None:\n return False\n center, radius = self.blast\n distance_squared = (x - center) ** 2 + (GROUND // UNIT - row) ** 2\n return (radius - 0.75) ** 2 <= distance_squared <= (radius + 0.75) ** 2\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[GROUND // UNIT, self.player - self.scroll, 0] = True\n for ball in self.balls:\n column = ball.x - self.scroll\n if 0 <= column < 10:\n row = max(0, ball.y // UNIT)\n state[row, column, 1] = True\n state[row, column, 4] |= ball.vy < 0\n if self.bomb is not None and 0 <= self.bomb - self.scroll < 10:\n state[GROUND // UNIT, self.bomb - self.scroll, 2] = True\n if self.blast is not None:\n for row in range(9):\n for column in range(10):\n state[row, column, 3] = self._in_blast(row, column + self.scroll)\n values = (self.steps, self.multiplier, int(self.armed), self.player,\n self.next_bomb, self.last_action, 0 if self.blast is None else self.blast[1])\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 106, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/balls_bombs.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBallsBombs.c"} +{"name": "paint_ball", "split": "train", "game": "paint_ball", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Paint Ball as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to throw along the oscillating aim. Actions 0–4\nrelease. The yellow ball paints cells as it travels and can\nbe thrown again from the opposite wall. Repainting blue\ncells or hitting blue balls raises the multiplier. Yellow\ncells slow blue balls. A blue ball reaching the bottom ends\nthe run.\n\nINPUT CHANNEL TABLE\nThe observation preserves all 180 paint cells. Flatten the\n15×12 board in row order and group consecutive cells in pairs.\nEach pair is stored as first + 3 × second in channels 0–3\nacross the first nine observation rows. The last row holds\ngauges. Channels 4 and 5 show yellow and blue balls.\n\nSCORING, TERMINATION, AND HORIZON\nThe conversion uses approximate rectangular ball contact,\nfixed difficulty, and four frames per action. The 400-action\ntask clips scores to [0, 500] and divides by 500.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/paint_ball.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Ball:\n x: float\n y: float\n vx: float\n vy: float\n color: int\n paint: int = 0\n\n\nclass PaintBallEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.grid = np.zeros((15, 12), dtype=np.uint8)\n self.offset = 0.0\n self.x, self.y, self.angle = 9.0, 70.0, 0.0\n self.direction = -1\n self.timer = self.steps = 0\n self.multiplier = 1\n self.ready = True\n self.pressed = self.terminal = False\n self.balls: list[Ball] = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n self.offset += 0.03\n if self.offset > 4:\n self.offset -= 7\n self.grid[1:] = self.grid[:-1].copy()\n self.grid[0] = 0\n if self.ready:\n self.y = min(95, self.y + 0.03)\n self.angle += self.direction * 0.02\n if self.angle * self.direction > math.pi / 4:\n self.direction *= -1\n if tap:\n angle = self.angle if self.x < 50 else math.pi - self.angle\n self.balls.append(Ball(self.x, self.y, 2 * math.cos(angle), 2 * math.sin(angle), 1))\n self.ready = False\n self.multiplier = 1\n self.timer -= 1\n if self.timer < 0:\n angle = self.random.uniform(math.pi / 8, math.pi * 7 / 8)\n self.balls.append(Ball(self.random.uniform(20, 80), -3,\n 0.1 * math.cos(angle), 0.1 * math.sin(angle), 2))\n self.timer = 150\n reward = 0\n remaining = []\n for ball in self.balls:\n col = math.floor((ball.x - 8.5) / 7)\n row = math.floor((ball.y + 2 - self.offset) / 7)\n inside = 0 <= row < 15 and 0 <= col < 12\n tile = self.grid[row, col] if inside else 0\n slow = ball.color == 2 and tile == 1\n ball.paint = ball.paint + 1 if slow else 999\n speed = 0.1 if slow else 1\n ball.x += ball.vx * speed\n ball.y += ball.vy * speed + 0.03\n if (ball.x <= 9 and ball.vx < 0) or (ball.x >= 90 and ball.vx > 0):\n if ball.color == 1:\n self.x, self.y, self.angle = ball.x, ball.y, 0\n self.direction, self.multiplier, self.ready = -1, 1, True\n continue\n ball.vx *= -1\n self.terminal |= ball.color == 2 and ball.y > 99\n if (ball.y < 3 and ball.vy < 0) or (ball.y > 99 and ball.vy > 0):\n ball.vy *= -1\n if inside and (ball.color == 1 or ball.paint > 99):\n if ball.color == 1 and tile != 1:\n self.multiplier += tile == 2\n reward += self.multiplier\n self.grid[row, col] = ball.color\n ball.paint = 0\n remaining.append(ball)\n player = [b for b in remaining if b.color == 1]\n targets = [(b.x, b.y) for b in player]\n if self.ready:\n targets.append((self.x, self.y))\n self.balls = []\n for ball in remaining:\n if ball.color == 2 and any(abs(ball.x - x) < 5 and abs(ball.y - y) < 5 for x, y in targets):\n self.multiplier += 1\n reward += self.multiplier\n else:\n self.balls.append(ball)\n if not self.balls:\n self.timer = 0\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n pairs = self.grid.reshape(9, 10, 2)\n packed = pairs[:, :, 0] + 3 * pairs[:, :, 1]\n for bit in range(4):\n state[:9, :, bit] = (packed & (1 << bit)) != 0\n for ball in self.balls:\n if 0 <= ball.y < 100 and 0 <= ball.x < 100:\n state[int(ball.y // 10), int(ball.x // 10), 3 + ball.color] = True\n if self.ready:\n state[min(9, max(0, int(self.y // 10))), int(self.x // 10), 4] = True\n values = (self.steps, min(511, self.multiplier), round((self.angle + 1) * 100), round((self.offset + 3) * 30))\n for channel, value in enumerate(values):\n for bit in range(9):\n state[9, bit, channel] = bool(value & (1 << bit))\n state[9, 9, :3] = self.pressed, self.ready, self.direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 107, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/paint_ball.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePaintBall.c"} +{"name": "r_ring", "split": "train", "game": "r_ring", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays R Ring as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nMove left with action 1 and right with action 3. The other actions\nhold position. Catch the center of a descending ring and avoid its\nred sides. A catch scores the current multiplier and raises it by\none. A ring that passes uncollected lowers the multiplier by one.\nThe wandering ship and its trailing satellites fire automatically.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the player, emitters, lethal arcs,\ncollectible arcs, collected arcs, and counters. The conversion uses\nfixed difficulty, substitutes fixed-speed movement for the pointer,\nand samples arcs against a rectangular player hitbox. Each action\nadvances up to four frames over 400 actions. Clip episode scores to\n[0, 200] and divide by 200.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/r_ring.py`):\n```python\nfrom collections import deque\nfrom dataclasses import dataclass\nfrom math import atan2, cos, hypot, pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Ring:\n x: float\n y: float\n radius: float = 1\n hit: bool = False\n\n def arcs(self):\n r = self.radius\n return (\n self._arc(self.x - r * 0.32, self.y, r * 0.2, 5 * pi / 6, 7 * pi / 6),\n self._arc(self.x + r * 0.32, self.y, r * 0.2, -pi / 6, pi / 6),\n self._arc(self.x, self.y + r * 0.3, r * 0.6, -3 * pi / 4, -pi / 4),\n )\n\n @staticmethod\n def _arc(x, y, radius, start, end):\n angles = np.linspace(start, end, max(2, int(radius * (end - start)) + 2))\n return x + radius * np.cos(angles), y + radius * np.sin(angles)\n\n\nclass RRingEnvironment:\n score_cap = 200\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x = 50.0\n self.ship_x = self.ship_y = 20.0\n self.target_x = self.target_y = 20.0\n self.angle = 0.0\n self.move_ticks = self.stop_ticks = self.fire_ticks = 0\n self.power_ticks = 60\n self.options = self.action = self.steps = 0\n self.max_options = self.multiplier = 1\n self.history = deque(maxlen=99)\n self.followers = []\n self.rings = []\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n self.x = min(99, max(0, self.x + 3 * ((self.action == 3) - (self.action == 1))))\n self.stop_ticks -= 1\n if self.stop_ticks < 0:\n self.move_ticks = self.random.uniform(120, 180)\n self.stop_ticks = self.move_ticks + self.random.uniform(40, 60)\n self.move_ticks -= 1\n if self.move_ticks > 0:\n if hypot(self.target_x - self.ship_x, self.target_y - self.ship_y) < 5:\n self.target_x = self.random.uniform(10, 90)\n self.target_y = self.random.uniform(3, 30)\n target = atan2(self.target_y - self.ship_y, self.target_x - self.ship_x)\n turn = (target - self.angle + pi) % (2 * pi) - pi\n self.angle += min(0.1, max(-0.1, turn))\n self.ship_x = min(99, max(0, self.ship_x + 0.5 * cos(self.angle)))\n self.ship_y = min(50, max(0, self.ship_y + 0.5 * sin(self.angle)))\n self.history.appendleft((self.ship_x, self.ship_y))\n self.power_ticks -= 1\n if self.power_ticks < 0:\n self.options += 1\n if self.options > self.max_options:\n self.options = 0\n self.max_options = min(4, self.max_options + 1)\n self.power_ticks = 300 / self.options if self.options else 60\n self.followers = [self.history[i * 24] for i in range(1, self.options + 1)\n if i * 24 < len(self.history)]\n self.fire_ticks -= 1\n if self.fire_ticks < 0:\n self.rings.append(Ring(self.ship_x, self.ship_y))\n self.rings.extend(Ring(x, y) for x, y in self.followers)\n self.fire_ticks = 60\n reward = 0\n remaining = []\n for ring in self.rings:\n ring.y += 1\n ring.radius += 0.5\n left, right, center = ring.arcs()\n self.terminal |= self._touches(left) or self._touches(right)\n if not ring.hit and self._touches(center):\n reward += self.multiplier\n self.multiplier += 1\n ring.hit = True\n if ring.y <= 110:\n remaining.append(ring)\n elif not ring.hit:\n self.multiplier = max(1, self.multiplier - 1)\n self.rings = remaining\n return reward\n\n def _touches(self, arc):\n x, y = arc\n return bool(np.any((abs(x - self.x) < 4) & (abs(y - 95) < 4)))\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[9, int(self.x // 10), 0] = True\n for x, y in [(self.ship_x, self.ship_y), *self.followers]:\n state[int(y // 10), int(x // 10), 1] = True\n for ring in self.rings:\n for channel, (xs, ys) in zip((2, 2, 4 if ring.hit else 3), ring.arcs()):\n visible = (0 <= xs) & (xs < 100) & (0 <= ys) & (ys < 100)\n state[(ys[visible] // 10).astype(int), (xs[visible] // 10).astype(int), channel] = True\n for row, value in enumerate((self.steps, self.multiplier, self.fire_ticks, self.options)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 108, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/r_ring.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/rring/main.js"} +{"name": "gopher", "split": "train", "game": "gopher", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Gopher as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves the original carrot-defense loop. The farmer moves along the surface\nand fills visible tunnel sections with action 5 for 20 points. A gopher alternates entry sides,\ndigs horizontally and then upward toward one of three carrots, and steals it if it reaches the\nsurface. When exposed directly beneath the farmer, action 5 bonks the gopher for 100 points and\nstarts the next raid. The gopher accelerates every three raids.\n\nAfter a carrot is lost, a duck crosses the top row and drops a seed. The farmer can catch the\nfalling seed, carry it to a vacant carrot column, and plant it with action 5. Losing the final\ncarrot ends the episode.\n\nACTION MAPPING\n0: noop\n1: move left\n2: unused\n3: move right\n4: unused\n5: fill tunnel, bonk gopher, or plant carried seed\n\nINPUT CHANNEL TABLE\n0: farmer\n1: gopher\n2: carrots, duck, and falling seed\n3: open tunnel sections\n4: previous farmer and gopher positions\n5: carrot count, exact binary raid, tunnel count, and carried-seed flag\n\nSCORING, TERMINATION, AND HORIZON\nAt most 14 route sections occur in one raid. Each of the 12 raids can therefore award at most\n`14 × 20 = 280` tunnel points and one 100-point bonk. The structural maximum is\n`score_cap = 12 × (280 + 100) = 4,560`. Normalization is\n`min(max(raw_score, 0), 4_560) / 4_560`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/gopher.py`):\n```python\nimport numpy as np\n\n\nCARROT_COLUMNS = (3, 5, 7)\n\n\nclass GopherEnvironment:\n \"\"\"Twelve-raid carrot defense with tunnel repair and seed recovery.\"\"\"\n\n score_cap = 4_560.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 1_200):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.farmer = [2, 5]\n self.previous_farmer = self.farmer.copy()\n self.carrots = set(CARROT_COLUMNS)\n self.carrying_seed = False\n self.seed_position: list[int] | None = None\n self.duck: list[int] | None = None\n self.raid = 0\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self.previous_gopher: list[int] | None = None\n self._start_raid()\n\n def _start_raid(self) -> None:\n if self.raid >= 12 or not self.carrots:\n self.terminal = True\n return\n target_column = sorted(self.carrots)[self.raid % len(self.carrots)]\n start_column = 0 if self.raid % 2 == 0 else 9\n step = 1 if target_column > start_column else -1\n horizontal = [[8, column] for column in range(start_column, target_column + step, step)]\n vertical = [[row, target_column] for row in range(7, 1, -1)]\n self.gopher_path = horizontal + vertical\n self.gopher_index = 0\n self.gopher = self.gopher_path[0].copy()\n self.tunnels: set[tuple[int, int]] = {tuple(self.gopher)}\n self.scored_sections: set[tuple[int, int]] = set()\n self.raid_steps = 0\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_farmer = self.farmer.copy()\n self.previous_gopher = self.gopher.copy()\n raid_before_action = self.raid\n reward = self._apply_action(action)\n if self.raid == raid_before_action and not self.terminal:\n self._move_gopher()\n self._move_duck_and_seed()\n self._resolve_seed_catch()\n self.raid_steps += 1\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _apply_action(self, action: int) -> float:\n if action == 1:\n self.farmer[1] = max(0, self.farmer[1] - 1)\n elif action == 3:\n self.farmer[1] = min(9, self.farmer[1] + 1)\n elif action == 5:\n if self.carrying_seed and self.farmer[1] in CARROT_COLUMNS and self.farmer[1] not in self.carrots:\n self.carrots.add(self.farmer[1])\n self.carrying_seed = False\n return 0.0\n if self.gopher[0] == 2 and self.gopher[1] == self.farmer[1]:\n self.raid += 1\n self._start_raid()\n return 100.0\n column_sections = [section for section in self.tunnels if section[1] == self.farmer[1]]\n if column_sections:\n section = min(column_sections)\n self.tunnels.remove(section)\n self.gopher_index = max(0, self.gopher_index - 1)\n self.gopher = self.gopher_path[self.gopher_index].copy()\n if section not in self.scored_sections:\n self.scored_sections.add(section)\n return 20.0\n return 0.0\n\n def _move_gopher(self) -> None:\n interval = max(1, 5 - self.raid // 3)\n if self.raid_steps % interval:\n return\n if self.gopher_index < len(self.gopher_path) - 1:\n self.gopher_index += 1\n self.gopher = self.gopher_path[self.gopher_index].copy()\n self.tunnels.add(tuple(self.gopher))\n return\n target_column = self.gopher[1]\n self.carrots.discard(target_column)\n self.raid += 1\n self._start_raid()\n\n def _move_duck_and_seed(self) -> None:\n missing = [column for column in CARROT_COLUMNS if column not in self.carrots]\n if missing and self.duck is None and self.seed_position is None and not self.carrying_seed:\n if self.steps % 24 == 0:\n self.duck = [0, 0]\n if self.duck is not None:\n self.duck[1] += 1\n if self.duck[1] == 5 and self.seed_position is None:\n self.seed_position = [0, 5]\n if self.duck[1] > 9:\n self.duck = None\n if self.seed_position is not None:\n self.seed_position[0] += 1\n if self.seed_position[0] > 2:\n self.seed_position = None\n\n def _resolve_seed_catch(self) -> None:\n if self.seed_position == self.farmer:\n self.seed_position = None\n self.carrying_seed = True\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.farmer, 0] = True\n state[*self.gopher, 1] = True\n for column in self.carrots:\n state[1, column, 2] = True\n if self.seed_position is not None:\n state[*self.seed_position, 2] = True\n if self.duck is not None:\n state[*self.duck, 2] = True\n for section in self.tunnels:\n state[*section, 3] = True\n state[*self.previous_farmer, 4] = True\n if self.previous_gopher is not None:\n state[*self.previous_gopher, 4] = True\n state[9, : len(self.carrots), 5] = True\n for bit in range(4):\n state[8, bit, 5] = bool(self.raid & (1 << bit))\n for bit in range(4):\n state[7, bit, 5] = bool(len(self.tunnels) & (1 << bit))\n if self.carrying_seed:\n state[6, :3, 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 109, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/gopher.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "rope_corral", "split": "train", "game": "rope_corral", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Rope Corral as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to anchor the buddy and swing around it. Actions 0–4\nrelease, sending the player rolling along the tangent. A full turn\ncaptures critters and spikes inside the circle, scoring four times\nthe square of the number captured. Directly touching a critter\nscores one point. Touching an active spike ends the episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the player, buddy, critters, active spikes,\nwarming spikes, and counters. The port uses fixed difficulty and\ndistance-based collisions. Each action advances up to four frames\nover a 400-action horizon. Clip the episode score to [0, 500] and\ndivide by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/rope_corral.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import atan2, cos, hypot, pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Critter:\n x: float\n y: float\n angle: float\n\n\n@dataclass\nclass Spike:\n x: float\n y: float\n warm: int\n\n\nclass RopeCorralEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 30., 50.\n self.bx, self.by = 20., 50.\n self.vx, self.vy = 0.75, 0.32\n self.angle = self.swept = 0.\n self.steps = self.frame = self.hitstop = 0\n self.timer = 200\n self.held = self.terminal = False\n self.critters = [self._critter() for _ in range(5)]\n for critter in self.critters:\n if hypot(critter.x - self.x, critter.y - self.y) < 18:\n critter.x = 15 + (critter.x + 25) % 70\n self.spikes = []\n for _ in range(3):\n self._spawn_spike(0)\n\n def _critter(self):\n x, y = self.random.uniform(15, 85, 2)\n return Critter(x, y, self.random.uniform(0, 2 * pi))\n\n def _spawn_spike(self, warm):\n for _ in range(8):\n x, y = self.random.uniform(10, 90, 2)\n if hypot(x - self.x, y - self.y) >= 20 and all(\n hypot(x - spike.x, y - spike.y) >= 24 for spike in self.spikes\n ):\n break\n self.spikes.append(Spike(x, y, warm))\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n frozen = self.hitstop > 0\n self.hitstop = max(0, self.hitstop - 1)\n reward = 0\n if self.held:\n if tap:\n self.angle = atan2(self.y - self.by, self.x - self.bx)\n self.swept = 0\n if not frozen:\n self.angle += 0.075\n self.swept += 0.075\n dx, dy = cos(self.angle), sin(self.angle)\n self.x, self.y = self.bx + 22 * dx, self.by + 22 * dy\n self.vx, self.vy = -1.32 * dy, 1.32 * dx\n if self.swept >= 2 * pi:\n self.swept = 0\n count = len(self.critters) + len(self.spikes)\n self.critters = [c for c in self.critters if hypot(c.x - self.bx, c.y - self.by) >= 20]\n self.spikes = [s for s in self.spikes if hypot(s.x - self.bx, s.y - self.by) >= 20]\n caught = count - len(self.critters) - len(self.spikes)\n if caught:\n reward += 4 * caught ** 2\n self.hitstop = min(8, 2 + caught)\n self.critters.extend(self._critter() for _ in range(caught))\n elif not frozen:\n self.x += self.vx\n self.y += self.vy\n if not 6 <= self.x <= 94:\n self.vx *= -1\n self.x = min(94, max(6, self.x))\n if not 6 <= self.y <= 94:\n self.vy *= -1\n self.y = min(94, max(6, self.y))\n dx, dy = self.x - self.bx, self.y - self.by\n distance = hypot(dx, dy)\n if distance > 22:\n self.bx, self.by = self.x - 22 * dx / distance, self.y - 22 * dy / distance\n if not frozen:\n self.timer -= 1\n if self.timer < 0 and len(self.critters) < 8:\n self.critters.append(self._critter())\n self.timer = self.random.uniform(140, 220)\n if self.frame % 700 == 699 and len(self.spikes) < 6:\n self._spawn_spike(60)\n remaining = []\n for critter in self.critters:\n critter.angle += self.random.uniform(-0.2, 0.2)\n critter.x = min(92, max(8, critter.x + 0.28 * cos(critter.angle)))\n critter.y = min(92, max(8, critter.y + 0.28 * sin(critter.angle)))\n if critter.x in (8, 92):\n critter.angle = pi - critter.angle\n if critter.y in (8, 92):\n critter.angle *= -1\n if hypot(critter.x - self.x, critter.y - self.y) >= 4.5:\n remaining.append(critter)\n collected = len(self.critters) - len(remaining)\n self.critters = remaining + [self._critter() for _ in range(collected)]\n for spike in self.spikes:\n if spike.warm:\n spike.warm -= 1\n elif hypot(spike.x - self.x, spike.y - self.y) < 4:\n self.terminal = True\n self.frame += 1\n return reward + collected\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n positions = [(self.x, self.y, 0), (self.bx, self.by, 1)]\n positions.extend((c.x, c.y, 2) for c in self.critters)\n positions.extend((s.x, s.y, 4 if s.warm else 3) for s in self.spikes)\n for x, y, channel in positions:\n state[int(np.clip(y // 10, 0, 9)), int(np.clip(x // 10, 0, 9)), channel] = True\n values = (self.steps, self.held, round(self.swept * 50), self.hitstop,\n round((self.vx + 2) * 50), round((self.vy + 2) * 50))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 110, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/rope_corral.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameRopeCorral.c"} +{"name": "grappling_h", "split": "train", "game": "grappling_h", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Grappling H as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to release the attached anchor and launch toward it. Release\nthe button with actions 0–4 to rearm, then hold 5 to grab the nearest\nanchor when it comes into range. Anchors pull the player while attached.\nGravity acts throughout and side walls bounce the player. The screen\nscrolls faster near the top. Falling below the view or holding an anchor\nuntil it exits ends the run. Released anchors are consumed.\n\nINPUT CHANNEL TABLE\nThe binary channels show the player, a reserved channel, anchors, attached\nanchor, nearest reachable anchor, and gauges. The gauges store integer\nposition and velocity, scroll phase, distance since release, clock and\nbutton state. The 10×10 adaptation uses eight subunits per cell,\ndiscretized spring force, capped velocity, and anchors on fixed vertical\nintervals with seeded horizontal positions. A second anchor is visible\nat the start so an early launch has a reachable target.\n\nSCORING, TERMINATION, AND HORIZON\nA catch pays the distance scrolled since release divided by eight,\nrounded up. Scroll is at most four subunits per step, and each catch\nrequires a fresh release, so the rewarded distance intervals cannot\noverlap. Over 500 steps, the distance contribution is at most 250\npoints and rounding adds at most 500. The conservative normalization\ncap is 750. Raw scores are clipped to [0, cap] and divided by the cap.\n\nOn seeds 1729–1828 without sticky actions, no-op averaged 0 points,\nrandom press/release averaged 1.04, and repeating 5, 0, 5, 5, 0 averaged\n1.0. These smoke policies establish that catches are reachable from reset.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/grappling_h.py`):\n```python\nimport numpy as np\n\n\nHORIZON = 500\nUNIT = 8\nANCHOR_SPACING = 16\nBOTTOM = 80\nREACH = 16\n\n\nclass GrapplingHEnvironment:\n # At most four scroll units per step, plus one rounding point per catch.\n score_cap = HORIZON + HORIZON * 4 // UNIT\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x, self.y = 24, 16\n self.vx = self.vy = 0\n self.steps = self.scroll = self.since_release = self.last_action = 0\n self.anchors = [(40, 0), (48, 8)]\n self.attached: tuple[int, int] | None = self.anchors[0]\n self.rearmed = False\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def _nearby(self) -> tuple[int, int] | None:\n candidates = [(dx * dx + dy * dy, anchor)\n for anchor in self.anchors\n for dx, dy in [(anchor[0] - self.x, anchor[1] + self.scroll - self.y)]]\n distance, anchor = min(candidates, default=(REACH ** 2, None))\n return anchor if distance < REACH ** 2 else None\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n pressed = action == 5 and self.last_action != 5\n self.last_action = action\n self.steps += 1\n reward = 0\n if self.attached is None and action == 5 and self.rearmed:\n self.attached = self._nearby()\n if self.attached is not None:\n reward = (self.since_release + UNIT - 1) // UNIT\n pressed = False\n\n advance = max(1, min(4, (40 - self.y) // 8))\n previous_scroll = self.scroll\n self.scroll += advance\n self.since_release += advance\n self.y += advance\n if self.scroll // ANCHOR_SPACING > previous_scroll // ANCHOR_SPACING:\n self.anchors.append((UNIT * int(self.random.integers(1, 9)),\n -(self.scroll // ANCHOR_SPACING) * ANCHOR_SPACING))\n\n self.vy += 1\n if self.attached is not None:\n dx = self.attached[0] - self.x\n dy = self.attached[1] + self.scroll - self.y\n divisor = 4 if pressed else 12\n self.vx += round(dx / divisor)\n self.vy += round(dy / divisor)\n if pressed:\n self.anchors.remove(self.attached)\n self.attached = None\n self.since_release = 0\n self.rearmed = False\n self.vx = max(-12, min(12, self.vx))\n self.vy = max(-12, min(12, self.vy))\n self.x += self.vx\n self.y = max(0, self.y + self.vy)\n if not 0 <= self.x < BOTTOM:\n self.x = max(0, min(BOTTOM - 1, self.x))\n self.vx = -round(self.vx * 0.8)\n expired = self.attached is not None and self.attached[1] + self.scroll >= BOTTOM\n self.anchors = [anchor for anchor in self.anchors if anchor[1] + self.scroll < BOTTOM]\n if action != 5:\n self.rearmed = True\n self.terminal = expired or self.y >= BOTTOM or self.steps >= self.horizon\n return float(reward), self.terminal\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, self.y // UNIT), self.x // UNIT, 0] = True\n nearby = self._nearby() if self.attached is None else None\n for anchor in self.anchors:\n x, y = anchor\n row, column = (y + self.scroll) // UNIT, x // UNIT\n state[row, column, 2] = True\n if anchor == self.attached:\n state[row, column, 3] = True\n if anchor == nearby:\n state[row, column, 4] = True\n values = (self.x, self.y, self.vx + 12, self.vy + 12, self.scroll % ANCHOR_SPACING,\n self.since_release, self.steps, int(self.rearmed), int(self.last_action == 5))\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = bool(self.since_release & 1024)\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 111, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/grappling_h.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameGrapplingH.c"} +{"name": "cleaner", "split": "train", "game": "cleaner", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Cleaner as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to extend the swinging sweeper. Release with actions\n0–4 to retract it and pull the base toward the head. Dust touching\nthe head or shaft scores the current multiplier and increases it.\nStarting a new hold resets the multiplier. A hole touching the\nbase ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the base, shaft, dust, holes, head,\nand gauges. Each action advances four frames at fixed difficulty.\nThe conversion models dust as circles and checks contact against\nthe sweeper geometry.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 1000] and divide by the fixed cap of 1,000. Across 100 seeds\nwithout sticky actions, idle averaged 26.37 raw points, random\ninputs averaged 8.83, and continuous hold averaged 529.14 and\nreached 4,278 before clipping.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/cleaner.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\n\n\n@dataclass\nclass Particle:\n x: float\n y: float\n radius: float\n\n\nclass CleanerEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.frame = 0\n self.pressed = self.terminal = False\n self.x = self.head_x = 50.0\n self.head_y = 130.0\n self.length = 0.0\n self.dust_timer, self.hole_timer = 0, 99\n self.multiplier = 1\n self.dust: list[Particle] = []\n self.holes: list[Particle] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed:\n self.multiplier = 1\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for _ in range(FRAMES_PER_STEP):\n reward += self._advance_frame()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self) -> int:\n angle = math.sin(self.frame * 0.1)\n self.frame += 1\n self.head_x = self.x + math.sin(angle) * self.length\n self.head_y = 130 - math.cos(angle) * self.length\n if self.pressed:\n self.length += (150 - self.length) * 0.005\n else:\n self.x = min(100, max(0, self.x + (self.head_x - self.x) * 0.005 * self.length))\n self.length *= 0.9\n\n self.dust_timer -= 1\n if self.dust_timer < 0:\n self.dust.append(Particle(self.random.uniform(10, 90), -20, self.random.uniform(1.5, 4.5)))\n self.dust_timer = int(self.random.integers(10, 21))\n reward = 0\n remaining = []\n for dust in self.dust:\n dust.y += 1\n if self._sweeps(dust):\n reward += self.multiplier\n self.multiplier += 1\n elif dust.y <= 170:\n remaining.append(dust)\n self.dust = remaining\n\n self.hole_timer -= 1\n if self.hole_timer < 0:\n self.holes.append(Particle(self.random.uniform(0, 100), -20, self.random.uniform(5, 12)))\n self.hole_timer = int(self.random.integers(99, 121))\n for hole in self.holes:\n hole.y += 1\n if abs(math.hypot(hole.x - self.x, hole.y - 139) - hole.radius) <= 7:\n self.terminal = True\n self.holes = [hole for hole in self.holes if hole.y <= 170]\n return reward\n\n def _sweeps(self, dust: Particle) -> bool:\n if abs(dust.x - self.head_x) < 7.5 + dust.radius and abs(dust.y - self.head_y) < 5 + dust.radius:\n return True\n dx, dy = self.head_x - self.x, self.head_y - 130\n px, py = dust.x - self.x, dust.y - 130\n squared = dx * dx + dy * dy\n fraction = min(1, max(0, (px * dx + py * dy) / squared)) if squared else 0\n return math.hypot(px - fraction * dx, py - fraction * dy) < 3.5 + dust.radius\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[9, min(9, int(self.x) // 10), 0] = True\n for fraction in np.linspace(0, 1, 12):\n x = self.x + (self.head_x - self.x) * fraction\n y = 130 + (self.head_y - 130) * fraction\n if 0 <= x <= 100 and 0 <= y < 150:\n state[int(y) // 15, min(9, int(x) // 10), 1] = True\n if 0 <= self.head_x <= 100 and 0 <= self.head_y < 150:\n state[int(self.head_y) // 15, min(9, int(self.head_x) // 10), 4] = True\n for channel, particles in ((2, self.dust), (3, self.holes)):\n for particle in particles:\n if 0 <= particle.y < 150:\n state[int(particle.y) // 15, int(particle.x) // 10, channel] = True\n for row, value in enumerate((self.steps, round(self.length), self.multiplier, self.frame % 63)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 112, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/cleaner.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameCleaner.c"} +{"name": "t_hanoi", "split": "train", "game": "t_hanoi", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays T Hanoi as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nActions 1, 2, and 3 press the source, middle, and right rods.\nActions 0, 4, and 5 release. Release between presses to take\nor place a disk. The source accepts any disk. On the other rods,\na disk can sit on one of equal or greater size. Holding a press\nshortens the middle or right rod. When it gets shorter than its\nstack, the stack clears for its squared size times the integer\nmultiplier. The source fills automatically and ends the episode\nif its disks exceed the rod height.\n\nINPUT CHANNEL TABLE\nChannels 0–2 encode disk sizes in binary. Rods use column pairs\n0–1, 2–3, and 4–5, filling each column bottom-up. Channels 3–4\nmark the selected and pressed rods. Channel 5 holds counters.\nThe port maps pointer regions to direct rod actions and fixes\ndifficulty. Each action advances up to four frames over 400\nactions. Clip scores to [0, 1000] and divide by 1000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/t_hanoi.py`):\n```python\nfrom math import floor, sqrt\n\nimport numpy as np\n\n\nclass THanoiEnvironment:\n score_cap = 1000\n action_rods = {1: 0, 2: 1, 3: 2}\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(400, horizon)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.rods = [[], [], []]\n self.heights = [90.] * 3\n self.selected = None\n self.steps = self.action = self.timer = self.hold = 0\n self.multiplier = 100\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n rod = self.action_rods.get(self.action)\n tap = rod is not None and previous not in self.action_rods\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(rod, tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, rod, tap):\n if not self.rods[0]:\n self.timer = 0\n self.timer -= 1\n if self.timer < 0:\n self.rods[0].insert(0, int(self.random.integers(1, 5)))\n self.timer = 99 * sqrt(len(self.rods[0]))\n if tap:\n if self.selected is None:\n if self.rods[rod]:\n self.selected = rod\n else:\n source = self.rods[self.selected]\n target = self.rods[rod]\n if rod != self.selected and (rod == 0 or not target or source[-1] <= target[-1]):\n target.append(source.pop())\n self.selected = None\n if rod is None:\n self.hold = 0\n else:\n self.hold += 1\n if rod:\n self.heights[rod] -= self.hold ** 2 / 10000\n reward = 0\n for index, disks in enumerate(self.rods):\n self.heights[index] -= 0.01\n if self.heights[index] >= 6 * len(disks):\n continue\n if index == 0:\n self.terminal = True\n else:\n points = len(disks) ** 2\n reward += points * (self.multiplier // 100)\n self.multiplier += points\n disks.clear()\n self.heights[index] = 90.\n self.heights[0] = min(90, max(0, self.heights[0] + points / 4))\n if self.selected == index:\n self.selected = None\n self.hold = 0\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for rod, disks in enumerate(self.rods):\n for index, disk in enumerate(disks):\n row, col = 9 - index % 10, 2 * rod + index // 10\n for bit in range(3):\n state[row, col, bit] = bool(disk & (1 << bit))\n state[9, 2 * rod, 3] = self.selected == rod\n state[9, 2 * rod, 4] = self.action_rods.get(self.action) == rod\n values = (self.steps, floor(max(0, self.timer)), self.hold, self.multiplier,\n *(round(max(0, height) * 10) for height in self.heights))\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 113, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/t_hanoi.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/thanoi/main.js"} +{"name": "c_tower", "split": "train", "game": "c_tower", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays C Tower as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to climb faster. Release with actions 0–4 to slow\ndown as the climber circles the tower. Solid walls reverse the\nrotation and knock the climber downward. Floating walls can be\npassed through. Bonus pickups increase the multiplier, and each\nframe scores the distance climbed times that multiplier. Falling\ntoo low ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the climber, solid walls, floating\nwalls, bonuses, far-side walls, and gauges. The conversion uses\nfixed difficulty and checks collision against projected wall\nintervals. Each action advances four frames.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 5000] and divide by the fixed cap of 5,000.\n\nAcross 100 seeds without sticky actions, always released averaged\n573.94 raw points, always held averaged 1,652.81, and random inputs\naveraged 1,702.28. Their respective maxima before clipping were\n867.30, 9,874.80, and 6,748.27.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/c_tower.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\nHALF_PI = math.pi / 2\n\n\ndef wrap(angle: float) -> float:\n return (angle + math.pi) % math.tau - math.pi\n\n\n@dataclass\nclass Wall:\n angle: float\n width: float\n y: float\n floating: bool\n bonus: bool\n\n def projection(self, player_angle: float, rear: bool = False) -> tuple[float, float]:\n relative = player_angle - self.angle + (math.pi if rear else 0)\n start = max(-HALF_PI, min(HALF_PI, wrap(relative - self.width / 2)))\n end = max(-HALF_PI, min(HALF_PI, wrap(relative + self.width / 2)))\n radius = 48 if self.floating else 44\n return 50 + math.sin(start) * radius, 50 + math.sin(end) * radius\n\n\nclass CTowerEnvironment:\n score_cap = 5000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = 0\n self.pressed = self.terminal = False\n self.angle, self.y, self.speed = 0.0, 80.0, 3.0\n self.angular_velocity = -1.0\n self.direction = -1\n self.next_wall = 0.0\n self.next_bonus = self.multiplier = 1\n self.walls: list[Wall] = []\n\n @property\n def player_x(self) -> float:\n return 50 + 30 * self.angular_velocity\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0.0\n for _ in range(FRAMES_PER_STEP):\n reward += self._advance_frame()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _advance_frame(self) -> float:\n self.speed += ((9 if self.pressed else 1) - self.speed) * 0.2\n self.angular_velocity += (self.direction - self.angular_velocity) * 0.2\n self.y = max(80, self.y - 0.01)\n self.angle = wrap(self.angle + self.angular_velocity * 0.05)\n scroll = self.speed * 0.3\n self.next_wall -= scroll\n if self.next_wall < 0:\n self.next_bonus -= 1\n bonus = self.next_bonus < 0\n if bonus:\n self.next_bonus = int(self.random.integers(9, 13))\n self.walls.append(Wall(self.random.uniform(0, math.tau),\n self.random.uniform(math.pi / 4, HALF_PI),\n -5, bonus or self.random.random() < 0.3, bonus))\n self.next_wall += self.random.uniform(30, 40)\n\n for wall in self.walls:\n wall.y += scroll\n left, right = wall.projection(self.angle)\n if left >= right or not (left - 3 < self.player_x < right + 3 and self.y - 3 < wall.y < self.y + 8):\n continue\n if wall.bonus:\n self.multiplier += 1\n wall.bonus = False\n elif not wall.floating:\n self.angle = wrap(wall.angle - self.direction * (wall.width / 2 + 0.7))\n self.direction *= -1\n self.y = min(99, wall.y + 6)\n self.walls = [wall for wall in self.walls if wall.y <= 105]\n self.terminal = self.y > 97\n return scroll * self.multiplier\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(self.y) // 10, int(self.player_x) // 10, 0] = True\n for wall in self.walls:\n if 0 <= wall.y < 100:\n row = int(wall.y) // 10\n for rear in (False, True):\n left, right = wall.projection(self.angle, rear)\n if left < right:\n channel = 4 if rear else 3 if wall.bonus else 2 if wall.floating else 1\n state[row, int(left) // 10:int(right) // 10 + 1, channel] = True\n for row, value in enumerate((self.steps, self.multiplier, round(self.speed * 10))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 114, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/c_tower.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/ctower/main.js"} +{"name": "gravity_drift", "split": "train", "game": "gravity_drift", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Gravity Drift as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to thrust upward. Actions 0–4 let gravity pull\nthe ship down. Dodge asteroids and stay inside the screen.\nCollecting a star reverses the flow of objects, moves the ship\ntoward the opposite side, and increases the score multiplier.\nEach surviving frame scores the current multiplier.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the ship, asteroids, stars,\nthe target column, the projected ship height, and gauges.\nThe conversion uses fixed difficulty and rectangular hitboxes.\nEach action advances four frames, up to 400 actions. The raw\ntotal is clipped to [0, 4000] and divided by 4000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/gravity_drift.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Object:\n x: float\n y: float\n size: float\n\n\nclass GravityDriftEnvironment:\n score_cap = 4000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x, self.y, self.vy = 20.0, 50.0, 0.0\n self.steps = self.frames = 0\n self.multiplier = 1\n self.reversed = self.pressed = self.terminal = False\n self.stars: list[Object] = []\n self.asteroids: list[Object] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self) -> int:\n self.x += ((80 if self.reversed else 20) - self.x) * 0.05\n self.vy = (self.vy + 0.12 - 0.25 * self.pressed) * 0.95\n self.y += self.vy\n if not 0 <= self.y <= 100:\n self.terminal = True\n return 0\n spawn_x = -5 if self.reversed else 105\n if self.frames % 25 == 0:\n target = min(100, max(0, self.y + self.random.uniform(-9, 9)))\n self.asteroids.append(Object(spawn_x, target, self.random.uniform(5, 10)))\n if self.frames % 120 == 0:\n self.stars.append(Object(spawn_x, self.random.uniform(20, 80), 4))\n self.frames += 1\n remaining = []\n for star in self.stars:\n star.x += 0.5 if self.reversed else -0.5\n if self._hits_player(star):\n self.reversed = not self.reversed\n self.multiplier += 1\n elif -10 < star.x < 110:\n remaining.append(star)\n self.stars = remaining\n for asteroid in self.asteroids:\n asteroid.x += 1 if self.reversed else -1\n if self._hits_player(asteroid):\n self.terminal = True\n self.asteroids = [asteroid for asteroid in self.asteroids if -10 < asteroid.x < 110]\n return 0 if self.terminal else self.multiplier\n\n def _hits_player(self, obj: Object) -> bool:\n extent = obj.size / 2 + 2.5\n return abs(obj.x - self.x) < extent and abs(obj.y - self.y) < extent\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, max(0, int(self.y) // 10)), int(self.x) // 10, 0] = True\n for channel, objects in ((1, self.asteroids), (2, self.stars)):\n for obj in objects:\n if 0 <= obj.x < 100:\n state[min(9, int(obj.y) // 10), int(obj.x) // 10, channel] = True\n state[:, 8 if self.reversed else 2, 3] = True\n state[min(9, max(0, int(self.y + 4 * self.vy) // 10)), int(self.x) // 10, 4] = True\n for row, value in enumerate((self.steps, self.multiplier, round((self.vy + 3) * 80))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.reversed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 115, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/gravity_drift.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameGravityDrift.c"} +{"name": "venture", "split": "train", "game": "venture", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Venture as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves the two-scale dungeon: a small Winky evades arrow-proof Hallmonsters\nand chooses among four chambers, then expands inside a room to seize treasure and fight pursuing\nmonsters with directional arrows. It also preserves treasure-then-kill scoring, lethal temporary\ncorpses, the timed Hallmonster incursion, the non-shootable electrified Wall Room, permanently\nclosed looted chambers, four total lives, and progressively faster deeper halls.\n\nACTION MAPPING\n0: wait\n1: move/aim left\n2: move/aim up\n3: move/aim right\n4: move/aim down\n5: fire cardinally toward the nearest aligned monster; ineffective in halls and the Wall Room\n\nINPUT CHANNEL TABLE\n0: Winky\n1: room monsters, invading Hallmonster, or hall Hallmonsters\n2: treasure or available chamber entrances\n3: arrows\n4: lethal corpses and electrified walls\n5: exact depth, lives, completed rooms, room timer, scale, and carried treasure\n\nSCORING, TERMINATION, AND HORIZON\nAt depth `d`, four treasures pay `4 × 200d = 800d`, while twelve finite post-treasure monster\nkills pay `12 × 100d = 1,200d`. Across depths one through four the structural maximum is\n`(800 + 1,200) × (1 + 2 + 3 + 4) = 20,000`. Normalization is\n`min(max(raw_score, 0), 20_000) / 20_000`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/venture.py`):\n```python\nimport numpy as np\n\n\nROOM_ENTRANCES = ((2, 2), (2, 7), (7, 2), (7, 7))\nDIRECTIONS = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}\n\n\nclass VentureEnvironment:\n \"\"\"Four-depth Venture expedition with hall and chamber scales.\"\"\"\n\n score_cap = 20_000.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 4_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.depth = 1\n self.lives = 4\n self.score = 0.0\n self.steps = 0\n self.last_action = 0\n self.facing = 2\n self.terminal = False\n self._start_hall()\n\n def _start_hall(self) -> None:\n self.mode = \"hall\"\n self.player = [9, 5]\n self.completed_rooms: set[int] = set()\n self.hallmonsters = [[0, 0], [0, 9]]\n self.current_room: int | None = None\n self.bullets: list[list[int]] = []\n\n def _enter_room(self, room: int) -> None:\n self.mode = \"room\"\n self.current_room = room\n self.player = [8, 5]\n self.has_treasure = False\n self.room_clock = 0\n self.treasure = [2, 5]\n self.monsters = [\n {\"id\": 0, \"row\": 2, \"column\": 2},\n {\"id\": 1, \"row\": 2, \"column\": 7},\n {\"id\": 2, \"row\": 5, \"column\": 2},\n ]\n self.corpses: list[dict[str, int]] = []\n self.intruder: list[int] | None = None\n self.bullets.clear()\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n reward = 0.0\n if action in DIRECTIONS:\n self.facing = action\n self._move_player(action)\n elif action == 5 and self.mode == \"room\" and self.current_room != 3:\n shot_direction = self._shot_direction()\n self.facing = shot_direction\n row_delta, column_delta = DIRECTIONS[shot_direction]\n self.bullets.append([self.player[0], self.player[1], row_delta, column_delta])\n if self.mode == \"hall\":\n self._move_hallmonsters()\n self._resolve_hall()\n else:\n self.room_clock += 1\n self._move_bullets()\n reward += self._resolve_shots()\n self._move_room_hazards()\n reward += self._resolve_room()\n self.score += reward\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _shot_direction(self) -> int:\n aligned = []\n for monster in self.monsters:\n if monster[\"row\"] == self.player[0]:\n direction = 1 if monster[\"column\"] < self.player[1] else 3\n aligned.append((abs(monster[\"column\"] - self.player[1]), direction))\n elif monster[\"column\"] == self.player[1]:\n direction = 2 if monster[\"row\"] < self.player[0] else 4\n aligned.append((abs(monster[\"row\"] - self.player[0]), direction))\n return min(aligned)[1] if aligned else self.facing\n\n def _move_player(self, action: int) -> None:\n row_delta, column_delta = DIRECTIONS[action]\n destination = [self.player[0] + row_delta, self.player[1] + column_delta]\n if not (0 <= destination[0] < 10 and 0 <= destination[1] < 10):\n return\n if self.mode == \"room\" and (destination[0] in (0, 9) or destination[1] in (0, 9)):\n if destination == [9, 5]:\n self._leave_room()\n return\n self.player = destination\n\n def _leave_room(self) -> None:\n room = self.current_room\n assert room is not None\n if self.has_treasure:\n self.completed_rooms.add(room)\n self.mode = \"hall\"\n self.player = list(ROOM_ENTRANCES[room])\n self.current_room = None\n self.bullets.clear()\n if len(self.completed_rooms) == 4:\n self.depth += 1\n if self.depth == 5:\n self.terminal = True\n else:\n self._start_hall()\n\n def _move_hallmonsters(self) -> None:\n if self.steps % max(2, 6 - self.depth):\n return\n for monster in self.hallmonsters:\n if abs(self.player[0] - monster[0]) >= abs(self.player[1] - monster[1]):\n monster[0] += int(np.sign(self.player[0] - monster[0]))\n else:\n monster[1] += int(np.sign(self.player[1] - monster[1]))\n\n def _resolve_hall(self) -> None:\n if self.player in self.hallmonsters:\n self._lose_life()\n return\n for room, entrance in enumerate(ROOM_ENTRANCES):\n if tuple(self.player) == entrance and room not in self.completed_rooms:\n self._enter_room(room)\n return\n\n def _move_bullets(self) -> None:\n for bullet in self.bullets:\n bullet[0] += bullet[2]\n bullet[1] += bullet[3]\n self.bullets = [bullet for bullet in self.bullets if 0 < bullet[0] < 9 and 0 < bullet[1] < 9]\n\n def _resolve_shots(self) -> float:\n hit_bullets: set[int] = set()\n hit_monsters: set[int] = set()\n reward = 0.0\n for bullet_index, bullet in enumerate(self.bullets):\n for monster in self.monsters:\n if bullet[:2] == [monster[\"row\"], monster[\"column\"]]:\n hit_bullets.add(bullet_index)\n hit_monsters.add(monster[\"id\"])\n self.corpses.append({\"row\": monster[\"row\"], \"column\": monster[\"column\"], \"timer\": 6})\n if self.has_treasure:\n reward += 100 * self.depth\n break\n self.bullets = [bullet for index, bullet in enumerate(self.bullets) if index not in hit_bullets]\n self.monsters = [monster for monster in self.monsters if monster[\"id\"] not in hit_monsters]\n return float(reward)\n\n def _move_room_hazards(self) -> None:\n if self.current_room == 3:\n return\n interval = max(2, 6 - self.depth)\n if self.room_clock % interval == 0:\n for monster in self.monsters:\n monster[\"row\"] += int(np.sign(self.player[0] - monster[\"row\"]))\n monster[\"column\"] += int(np.sign(self.player[1] - monster[\"column\"]))\n for corpse in self.corpses:\n corpse[\"timer\"] -= 1\n self.corpses = [corpse for corpse in self.corpses if corpse[\"timer\"] > 0]\n if self.room_clock >= 60 and self.intruder is None:\n self.intruder = [1, 5]\n if self.intruder is not None:\n self.intruder[0] += int(np.sign(self.player[0] - self.intruder[0]))\n self.intruder[1] += int(np.sign(self.player[1] - self.intruder[1]))\n\n def _wall_cells(self) -> set[tuple[int, int]]:\n phase = (self.room_clock // 3) % 4\n return {(3 + phase, column) for column in range(2, 8)} if self.current_room == 3 else set()\n\n def _resolve_room(self) -> float:\n reward = 0.0\n if self.player == self.treasure and not self.has_treasure:\n self.has_treasure = True\n reward += 200 * self.depth\n lethal = any([monster[\"row\"], monster[\"column\"]] == self.player for monster in self.monsters)\n lethal |= any([corpse[\"row\"], corpse[\"column\"]] == self.player for corpse in self.corpses)\n lethal |= self.intruder == self.player\n lethal |= tuple(self.player) in self._wall_cells()\n if lethal:\n self._lose_life()\n return float(reward)\n\n def _lose_life(self) -> None:\n self.lives -= 1\n if self.lives == 0:\n self.terminal = True\n return\n if self.mode == \"hall\":\n self.player = [9, 5]\n self.hallmonsters = [[0, 0], [0, 9]]\n else:\n room = self.current_room\n assert room is not None\n self._enter_room(room)\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[self.player[0], self.player[1], 0] = True\n if self.mode == \"hall\":\n for monster in self.hallmonsters:\n state[monster[0], monster[1], 1] = True\n for room, entrance in enumerate(ROOM_ENTRANCES):\n if room not in self.completed_rooms:\n state[entrance[0], entrance[1], 2] = True\n else:\n for monster in self.monsters:\n state[monster[\"row\"], monster[\"column\"], 1] = True\n for corpse in self.corpses:\n state[corpse[\"row\"], corpse[\"column\"], 4] = True\n if self.intruder is not None:\n state[self.intruder[0], self.intruder[1], 1] = True\n if not self.has_treasure:\n state[self.treasure[0], self.treasure[1], 2] = True\n for bullet in self.bullets:\n state[bullet[0], bullet[1], 3] = True\n for row, column in self._wall_cells():\n state[row, column, 4] = True\n values = ((self.depth, 3), (self.lives, 3), (len(self.completed_rooms), 3), (self.room_clock if self.mode == \"room\" else 0, 6))\n offset = 0\n for value, width in values:\n for bit in range(width):\n state[offset // 10, offset % 10, 5] = bool(value & (1 << bit))\n offset += 1\n state[2, 0, 5] = self.mode == \"room\"\n state[2, 1, 5] = getattr(self, \"has_treasure\", False)\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 116, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/venture.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "embattled", "split": "train", "game": "embattled", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Embattled as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to reverse direction. Hold to stop and deploy a\nshield after ten frames. Release with actions 0–4 to resume\nmoving. While shielded, combat speeds up and tanks can target\nyou as well as the opposing faction.\n\nOpposing tanks score points for you when they destroy each other.\nKills raise the multiplier, which falls by one every 60 frames\nto a minimum of one. An unblocked bullet or tank touching the\nplayer ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, shield, both tank factions,\nbullets, and gauges. Each action advances four frames at fixed\ndifficulty. The conversion uses geometric collisions and removes\nbullets once they leave the arena.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 250] and divide by 250. Across 100 seeds without sticky actions,\nidle averaged 2.70 and reached 45, continuous hold scored zero,\nand random hold and release averaged 0.15.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/embattled.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Tank:\n x: float\n y: float\n side: int\n heading: float\n turret: float\n timer: float\n interval: float\n\n\n@dataclass\nclass Bullet:\n x: float\n y: float\n angle: float\n side: int\n\n\ndef turn(angle: float, target: float, rate: float) -> float:\n offset = (target - angle + math.pi) % math.tau - math.pi\n return angle + min(rate, max(-rate, offset))\n\n\nclass EmbattledEnvironment:\n score_cap = 250\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.frame = self.held = self.side = self.side_count = 0\n self.pressed = self.terminal = False\n self.y, self.direction, self.multiplier = 30.0, 1, 1\n self.spawn_timer = 0.0\n self.tanks: list[Tank] = []\n self.bullets: list[Bullet] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap: bool) -> int:\n if tap or self.y < 3 and self.direction < 0 or self.y > 97 and self.direction > 0:\n self.direction *= -1\n self.held = self.held + 1 if self.pressed else 0\n if not self.pressed:\n self.y += self.direction * 0.5\n shield = self.held > 10\n pace = 2 if shield else 1\n live_bullets = []\n for bullet in self.bullets:\n bullet.x += math.cos(bullet.angle) * 0.5 * pace\n bullet.y += math.sin(bullet.angle) * 0.5 * pace\n dx, dy = abs(bullet.x - 50), abs(bullet.y - self.y)\n if shield and dx < 8 and dy < 9:\n continue\n self.terminal |= dx < 4 and dy < 4\n if -5 <= bullet.x <= 105 and -5 <= bullet.y <= 105:\n live_bullets.append(bullet)\n self.bullets = live_bullets\n\n self.spawn_timer = self.spawn_timer - pace if self.tanks else -1\n if self.spawn_timer < 0:\n self._spawn()\n for tank in self.tanks:\n self._move_tank(tank, shield, pace)\n\n reward = 0\n survivors = []\n for tank in self.tanks:\n hit = next((bullet for bullet in self.bullets if bullet.side != tank.side\n and math.hypot(bullet.x - tank.x, bullet.y - tank.y) < 4), None)\n if hit is not None:\n self.bullets.remove(hit)\n reward += self.multiplier\n self.multiplier += 1\n else:\n self.terminal |= abs(tank.x - 50) < 4 and abs(tank.y - self.y) < 4\n if -5 <= tank.x <= 105 and -5 <= tank.y <= 105:\n survivors.append(tank)\n self.tanks = survivors\n if self.frame % 60 == 0:\n self.multiplier = max(1, self.multiplier - 1)\n self.frame += 1\n return reward\n\n def _spawn(self) -> None:\n side = self.side\n self.side_count -= 1\n if self.side_count <= 0:\n self.side = 1 - self.side\n self.side_count = int(self.random.integers(1, 4))\n x, y = (-5 if side == 0 else 105), self.random.uniform(0, 99)\n angle = math.atan2(self.y - y, 50 - x)\n interval = self.random.uniform(300, 400)\n self.tanks.append(Tank(x, y, side, angle, angle, self.random.uniform(0, interval), interval))\n self.spawn_timer = self.random.uniform(60, 80)\n\n def _move_tank(self, tank: Tank, shield: bool, pace: int) -> None:\n target = (50, self.y) if shield else None\n distance = math.hypot(50 - tank.x, self.y - tank.y) if shield else 99\n for other in self.tanks:\n if tank.side != other.side:\n candidate = math.hypot(other.x - tank.x, other.y - tank.y)\n if candidate < distance:\n target, distance = (other.x, other.y), candidate\n if target is not None:\n angle = math.atan2(target[1] - tank.y, target[0] - tank.x)\n tank.heading = turn(tank.heading, angle, 0.02)\n tank.turret = turn(tank.turret, angle, 0.03 * pace)\n tank.x += math.cos(tank.heading) * 0.02 * pace\n tank.y += math.sin(tank.heading) * 0.02 * pace\n tank.timer -= pace\n if tank.timer < 0:\n self.bullets.append(Bullet(tank.x, tank.y, tank.turret, tank.side))\n tank.timer = tank.interval\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row = int(self.y) // 10\n state[row, 5, 0] = True\n if self.held > 10:\n state[max(0, row - 1):row + 2, 4:6, 1] = True\n for tank in self.tanks:\n if 0 <= tank.x < 100 and 0 <= tank.y < 100:\n state[int(tank.y) // 10, int(tank.x) // 10, 2 + tank.side] = True\n for bullet in self.bullets:\n if 0 <= bullet.x < 100 and 0 <= bullet.y < 100:\n state[int(bullet.y) // 10, int(bullet.x) // 10, 4] = True\n for row, value in enumerate((self.steps, self.multiplier, min(self.held, 11))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 117, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/embattled.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/embattled/main.js"} +{"name": "tappump", "split": "train", "game": "tappump", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Tappump as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to jump and hold it to inflate the ring. Actions 0–4\nrelease, letting gravity pull the player down as the ring shrinks.\nCoins touching the ring score its radius rounded up. A spike hit\nor drifting too far above or below the playfield ends the episode.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the player center, ring, spikes,\ncoins, projected vertical position, and counters. The port uses\nfixed difficulty and approximates ring-to-sprite contacts with\nrectangle geometry. Each action advances up to four frames over\n400 actions. Clip scores to [0, 1000] and divide by 1000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/tappump.py`):\n```python\nfrom math import ceil, hypot\n\nimport numpy as np\n\n\nclass TappumpEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 10., 20.\n self.vy = self.radial_speed = self.coin_vy = 0.\n self.radius = 1.\n self.coin_y = 50.\n self.spike_distance, self.coin_distance = 40., 0.\n self.steps = 0\n self.held = self.terminal = False\n self.spikes, self.coins = [], []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n scroll = max(0, self.x - 20) * 0.2\n self.spike_distance -= scroll\n if self.spike_distance < 0:\n self.spikes.append((103, self.random.uniform(0, 99)))\n self.spike_distance += self.random.uniform(40, 140)\n self.spikes = [(x - scroll, y) for x, y in self.spikes if x - scroll >= -2]\n if tap:\n self.vy -= 2\n self.vy += -0.03 if self.held else 0.12\n if self.held:\n self.radial_speed += 0.08\n self.radius += self.radial_speed\n else:\n self.radius += (1 - self.radius) * 0.04\n self.radial_speed = 0.\n self.x += 1 - scroll\n self.y += self.vy\n self.terminal = not -5 - self.radius <= self.y <= 105 + self.radius\n self.terminal |= any(self._touches(x, y, 2.5) for x, y in self.spikes)\n self.coin_distance -= scroll\n self.coin_vy = (self.coin_vy + self.random.uniform(-0.1, 0.1)) * 0.98\n self.coin_y += self.coin_vy\n if (self.coin_y < 10 and self.coin_vy < 0) or (self.coin_y > 90 and self.coin_vy > 0):\n self.coin_vy *= -1\n if self.coin_distance < 0:\n self.coins.append((103, self.coin_y + self.random.uniform(-9, 9)))\n self.coin_distance += self.random.uniform(6, 9)\n reward = 0\n remaining = []\n for x, y in self.coins:\n x -= scroll\n if self._touches(x, y, 3):\n reward += ceil(self.radius)\n elif x >= -3 and not any(abs(x - sx) < 5.5 and abs(y - sy) < 5.5 for sx, sy in self.spikes):\n remaining.append((x, y))\n self.coins = remaining\n return reward\n\n def _touches(self, x, y, half_size):\n dx, dy = abs(x - self.x), abs(y - self.y)\n near = hypot(max(0, dx - half_size), max(0, dy - half_size))\n far = hypot(dx + half_size, dy + half_size)\n return near <= self.radius + 2.5 and far >= self.radius - 2.5\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n row = int(np.clip(self.y // 10, 0, 9))\n col = int(self.x // 10)\n state[row, col, 0] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n state[:, :, 1] = abs(np.hypot(cols - self.x, rows - self.y) - self.radius) < 8\n for channel, objects in ((2, self.spikes), (3, self.coins)):\n for x, y in objects:\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), channel] = True\n ahead = int(np.clip((self.y + 4 * self.vy) // 10, 0, 9))\n state[ahead, col, 4] = True\n values = (self.steps, self.held, round(self.radius * 4),\n round((self.vy + 20) * 20), round(self.radial_speed * 40))\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(int(np.clip(value, 0, 1023)) & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 118, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tappump.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/tappump/main.js"} +{"name": "turbo_tunnel", "split": "train", "game": "turbo_tunnel", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Turbo Tunnel as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe car circles automatically. Tap action 5 to reverse its radial\nmovement. Release with any other action before tapping again.\nTaps and bounces at the tunnel walls can leave obstacles moving in\nthe opposite direction. A collision with a live obstacle ends the\nrun. Overlapping obstacles arm a fuse that can spread to neighbors.\nEach completed fuse pays the multiplier and increases it by one.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the car, live obstacles, armed obstacles,\ntunnel walls, projected car position, and counters. The port fixes\ndifficulty and uses distance checks to approximate sprite overlap.\nEach action advances up to four frames over 400 actions. Clip the\nepisode score to [0, 300] and divide by 300.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/turbo_tunnel.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, hypot, pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Obstacle:\n angle: float\n radius: float\n speed: float\n fuse: int = -1\n\n def position(self):\n return _position(self.angle, self.radius)\n\n\nclass TurboTunnelEnvironment:\n score_cap = 300\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.angle, self.radius, self.direction = pi / 2, 30., 1\n self.obstacles = []\n self.multiplier = 1\n self.steps = self.action = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n turn = self.action == 5 and previous != 5\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(turn and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, turn):\n spawn = turn\n if turn:\n self.direction *= -1\n self.angle = (self.angle + 0.5 / self.radius) % (2 * pi)\n self.radius += self.direction * 0.4\n if (self.radius > 50 and self.direction > 0) or (self.radius < 10 and self.direction < 0):\n self.direction *= -1\n spawn = True\n\n player = _position(self.angle, self.radius)\n armed = []\n loose = []\n remaining = []\n reward = 0\n had_fuse = False\n for obstacle in self.obstacles:\n obstacle.angle += obstacle.speed / (obstacle.radius * 0.03)\n point = obstacle.position()\n if obstacle.fuse > 0:\n had_fuse = True\n obstacle.fuse -= 1\n if obstacle.fuse == 0:\n reward += self.multiplier\n self.multiplier += 1\n continue\n armed.append(point)\n elif any(_distance(point, other) <= 3.5 for other in loose):\n obstacle.fuse = 30\n armed.append(point)\n else:\n loose.append(point)\n if _distance(point, player) <= 2.5:\n self.terminal = True\n remaining.append(obstacle)\n self.obstacles = remaining\n for obstacle in self.obstacles:\n if obstacle.fuse < 0 and any(_distance(obstacle.position(), point) <= 4.5 for point in armed):\n obstacle.fuse = 30\n armed.append(obstacle.position())\n had_fuse = True\n if not had_fuse:\n self.multiplier = 1\n\n if spawn and not self.terminal:\n obstacle = Obstacle(self.angle - 3 / self.radius, self.radius, -self.random.uniform(0.01, 0.03))\n x, y = obstacle.position()\n if not any(abs(x - ox) < 6.5 and abs(y - oy) < 6.5\n for ox, oy in (other.position() for other in self.obstacles)):\n self.obstacles.append(obstacle)\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n _mark(state, _position(self.angle, self.radius), 0)\n for obstacle in self.obstacles:\n _mark(state, obstacle.position(), 2 if obstacle.fuse > 0 else 1)\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n radius = np.hypot(cols - 50, rows - 50)\n state[:, :, 3] = (abs(radius - 10) < 6) | (abs(radius - 50) < 6)\n _mark(state, _position(self.angle + 2 / self.radius, self.radius + self.direction * 1.6), 4)\n values = (self.steps, self.action, self.direction > 0, self.multiplier,\n round(self.radius * 8), round(self.angle * 64))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n\ndef _position(angle, radius):\n return 50 + cos(angle) * radius, 50 + sin(angle) * radius\n\n\ndef _distance(first, second):\n return hypot(first[0] - second[0], first[1] - second[1])\n\n\ndef _mark(state, point, channel):\n x, y = point\n state[int(np.clip(y // 10, 0, 9)), int(np.clip(x // 10, 0, 9)), channel] = True\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 119, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/turbo_tunnel.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameTurboTunnel.c"} +{"name": "solaris", "split": "train", "game": "solaris", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Solaris as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves the two-layer campaign: select sectors on the Galactic Scanner, align\nthe StarCruiser during hyperwarp, manage finite fuel, fight through first-person targeting\nencounters, dock at Federation planets to refuel and repair, defend a threatened planet before its\nquadrant becomes a reversed-control Red Zone, rescue a Zylon planet, clear a guarded corridor,\nearn an extra fighter, and ultimately reach the blinking planet Solaris. All eleven manual scoring\nevents and their original values appear in finite encounters.\n\nACTION MAPPING\n0: wait / hold focus / hold reticle\n1: cursor left / correct focus right / reticle left\n2: cursor up / hold focus / reticle up\n3: cursor right / correct focus left / reticle right\n4: cursor down / hold focus / reticle down\n5: begin warp / commit warp / fire torpedo\n\nINPUT CHANNEL TABLE\n0: StarCruiser or combat reticle\n1: hostile sectors, Red Zones, or current enemy\n2: Federation planets and Solaris\n3: scanner cursor\n4: cleared sectors\n5: cleared/defeated identities and exact mode, position, focus, fuel, lives, targeting, and time\n\nSCORING, TERMINATION, AND HORIZON\nThe finite maze contains one of each 500, 400, 320, 320, 320, 300, 260, 80, 60, and 20-point\nenemy, plus an Attack Group worth `500 + 300 + 320`, a second 60-point Guardian, one 8,000-point\nZylon-planet rescue, and one 8,000-point Corridor. The exact total is\n`3,760 + 16,000 = 19,760`, so normalization is\n`min(max(raw_score, 0), 19_760) / 19_760`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/solaris.py`):\n```python\nimport numpy as np\n\n\nENEMY_VALUES = {\n \"flagship\": 500,\n \"raider\": 400,\n \"pirate\": 320,\n \"targeter\": 320,\n \"glider\": 320,\n \"mechnoid\": 300,\n \"blockader\": 260,\n \"cobra\": 80,\n \"guardian\": 60,\n \"distractor\": 20,\n}\nSECTORS = {\n (0, 1): (\"enemies\", (\"flagship\",)),\n (0, 2): (\"enemies\", (\"raider\",)),\n (0, 3): (\"federation\", ()),\n (1, 0): (\"enemies\", (\"pirate\",)),\n (1, 1): (\"enemies\", (\"targeter\",)),\n (1, 2): (\"planet\", (\"guardian\",)),\n (1, 3): (\"enemies\", (\"glider\",)),\n (2, 0): (\"enemies\", (\"mechnoid\",)),\n (2, 1): (\"corridor\", (\"guardian\",)),\n (2, 2): (\"enemies\", (\"blockader\",)),\n (2, 3): (\"enemies\", (\"cobra\",)),\n (3, 0): (\"enemies\", (\"distractor\",)),\n (3, 1): (\"federation\", ()),\n (3, 2): (\"enemies\", (\"flagship\", \"mechnoid\", \"pirate\")),\n (3, 3): (\"solaris\", ()),\n}\n\n\nclass SolarisEnvironment:\n \"\"\"Scanner navigation and targeting combat on a finite route to Solaris.\"\"\"\n\n score_cap = 19_760.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 2_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.mode = \"scanner\"\n self.ship_row = 0\n self.ship_column = 0\n self.cursor_row = 0\n self.cursor_column = 0\n self.warp_target = (0, 0)\n self.focus_offset = 0\n self.fuel = 100\n self.lives = 3\n self.targeting_damaged = False\n self.score = 0.0\n self.steps = 0\n self.last_action = 0\n self.cleared: set[tuple[int, int]] = set()\n self.defeated: set[tuple[int, int, int]] = set()\n self.red_rows: set[int] = set()\n self.crosshair_row = 5\n self.crosshair_column = 5\n self.enemies: list[dict[str, int | str]] = []\n self.combat_steps = 0\n self.terminal = False\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n if self.mode == \"scanner\":\n reward = self._act_scanner(action)\n elif self.mode == \"warp\":\n reward = self._act_warp(action)\n else:\n reward = self._act_combat(action)\n self.score += reward\n self.steps += 1\n if self.steps >= 40 and (0, 2) not in self.cleared:\n self.red_rows.add(0)\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _act_scanner(self, action: int) -> float:\n if action == 5:\n self.warp_target = (self.cursor_row, self.cursor_column)\n self.focus_offset = int(self.random.randint(-3, 4))\n self.mode = \"warp\"\n return 0.0\n if self.ship_row in self.red_rows:\n action = {1: 3, 2: 4, 3: 1, 4: 2}.get(action, action)\n if action == 1:\n self.cursor_column = max(0, self.cursor_column - 1)\n elif action == 2:\n self.cursor_row = max(0, self.cursor_row - 1)\n elif action == 3:\n self.cursor_column = min(3, self.cursor_column + 1)\n elif action == 4:\n self.cursor_row = min(3, self.cursor_row + 1)\n return 0.0\n\n def _act_warp(self, action: int) -> float:\n if action == 1:\n self.focus_offset = min(3, self.focus_offset + 1)\n return 0.0\n if action == 3:\n self.focus_offset = max(-3, self.focus_offset - 1)\n return 0.0\n if action != 5:\n return 0.0\n distance = abs(self.warp_target[0] - self.ship_row) + abs(self.warp_target[1] - self.ship_column)\n self.fuel -= 4 + distance * 3 + abs(self.focus_offset) * 2\n self.ship_row, self.ship_column = self.warp_target\n self.cursor_row, self.cursor_column = self.warp_target\n if self.fuel <= 0:\n self._lose_ship()\n return 0.0\n sector_kind, enemy_kinds = SECTORS.get(self.warp_target, (\"empty\", ()))\n if sector_kind == \"solaris\":\n self.terminal = True\n self.mode = \"scanner\"\n elif sector_kind == \"federation\":\n self.fuel = 100\n self.targeting_damaged = False\n self.mode = \"scanner\"\n elif self.warp_target in self.cleared or not enemy_kinds:\n self.mode = \"scanner\"\n else:\n self._start_combat(enemy_kinds)\n return 0.0\n\n def _start_combat(self, enemy_kinds: tuple[str, ...]) -> None:\n self.mode = \"combat\"\n self.crosshair_row = 5\n self.crosshair_column = 5\n self.combat_steps = 0\n self.enemies = []\n for index, kind in enumerate(enemy_kinds):\n identity = (self.ship_row, self.ship_column, index)\n if identity in self.defeated:\n continue\n code = list(ENEMY_VALUES).index(kind)\n self.enemies.append(\n {\n \"kind\": kind,\n \"index\": index,\n \"row\": 1 + (code * 3 + index * 2) % 8,\n \"column\": 1 + (code * 5 + index * 3) % 8,\n }\n )\n\n def _act_combat(self, action: int) -> float:\n if action == 1:\n self.crosshair_column = max(0, self.crosshair_column - 1)\n elif action == 2:\n self.crosshair_row = max(0, self.crosshair_row - 1)\n elif action == 3:\n self.crosshair_column = min(9, self.crosshair_column + 1)\n elif action == 4:\n self.crosshair_row = min(9, self.crosshair_row + 1)\n reward = 0.0\n if action == 5 and self.enemies:\n enemy = self.enemies[0]\n if self.crosshair_row == enemy[\"row\"] and self.crosshair_column == enemy[\"column\"]:\n reward += float(ENEMY_VALUES[str(enemy[\"kind\"])])\n self.defeated.add((self.ship_row, self.ship_column, int(enemy[\"index\"])))\n self.enemies.pop(0)\n if not self.enemies:\n reward += self._clear_sector()\n return reward\n self.combat_steps += 1\n self.fuel -= 1\n if self.combat_steps % 10 == 0:\n self._enemy_hit()\n if self.fuel <= 0:\n self._lose_ship()\n return reward\n\n def _clear_sector(self) -> float:\n position = (self.ship_row, self.ship_column)\n self.cleared.add(position)\n kind = SECTORS[position][0]\n reward = 0.0\n if kind in {\"planet\", \"corridor\"}:\n reward = 8_000.0\n if kind == \"planet\":\n self.lives = min(9, self.lives + 1)\n self.mode = \"scanner\"\n self.combat_steps = 0\n return reward\n\n def _enemy_hit(self) -> None:\n if self.enemies and self.enemies[0][\"kind\"] == \"flagship\":\n self._lose_ship()\n return\n if not self.targeting_damaged:\n self.targeting_damaged = True\n else:\n self.fuel -= 15\n\n def _lose_ship(self) -> None:\n self.lives -= 1\n if self.lives <= 0:\n self.terminal = True\n return\n self.fuel = 100\n self.targeting_damaged = False\n self.mode = \"scanner\"\n self.enemies = []\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n if self.mode in {\"scanner\", \"warp\"}:\n state[self.ship_row * 2 + 1, self.ship_column * 2 + 1, 0] = True\n state[self.cursor_row * 2 + 1, self.cursor_column * 2 + 1, 3] = True\n for (row, column), (kind, _) in SECTORS.items():\n screen_row = row * 2 + 1\n screen_column = column * 2 + 1\n channel = 2 if kind in {\"federation\", \"solaris\"} else 1\n state[screen_row, screen_column, channel] = True\n if (row, column) in self.cleared:\n state[screen_row, screen_column, 4] = True\n for row in self.red_rows:\n state[row * 2 : row * 2 + 2, :8, 1] = True\n else:\n state[self.crosshair_row, self.crosshair_column, 0] = True\n if self.enemies:\n enemy = self.enemies[0]\n state[int(enemy[\"row\"]), int(enemy[\"column\"]), 1] = True\n for index, position in enumerate(SECTORS):\n state[index // 10, index % 10, 5] = position in self.cleared\n for row, column, enemy_index in self.defeated:\n index = 72 + (row * 4 + column + enemy_index) % 28\n state[index // 10, index % 10, 5] = True\n values = (\n (self.ship_row, 2),\n (self.ship_column, 2),\n (self.cursor_row, 2),\n (self.cursor_column, 2),\n (self.fuel, 7),\n (self.lives, 4),\n (self.focus_offset + 3, 3),\n ((\"scanner\", \"warp\", \"combat\").index(self.mode), 2),\n (self.crosshair_row, 4),\n (self.crosshair_column, 4),\n (self.combat_steps, 8),\n (self.steps, 11),\n )\n offset = 16\n for value, width in values:\n for bit in range(width):\n index = offset + bit\n state[index // 10, index % 10, 5] = bool(value & (1 << bit))\n offset += width\n state[7, 0, 5] = self.targeting_damaged\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 120, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/solaris.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "mole_n", "split": "train", "game": "mole_n", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Mole N as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nMove the cursor with actions 1–4 (left, up, right, down) and\ntap action 5 to whack the selected cell. Action 0 holds\nposition. This replaces pointer selection. Moles change\nthe visible digit relative to the scrolling background.\nWhacking the target clears all moles for their values.\nWhacking a different mole costs points, and each whack\naccelerates the scroll. A target reaching the bottom ends\nthe run.\n\nINPUT CHANNEL TABLE\nFour channels encode the visible digits in binary. The\nremaining two mark clearing moles and the cursor. The outer\nrow and column hold the target and timing gauges. Fixed\ndifficulty and four frames per action apply. The 400-action\ntask clips raw scores to [0, 40] and divides by 40.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/mole_n.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Mole:\n x: int\n y: int\n value: int\n timer: int = 0\n award: int = 0\n\n\nclass MoleNEnvironment:\n score_cap = 40\n moves = ((0, 0), (-1, 0), (0, -1), (1, 0), (0, 1), (0, 0))\n mole_moves = ((1, 0), (0, 1), (-1, 0), (0, -1))\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.numbers = self.random.integers(0, 10, (9, 9))\n self.x, self.y = 4, 4\n self.target = 1\n self.scroll = self.penalty = self.spawn_distance = 0.0\n self.target_count = self.move_timer = self.steps = self.action = 0\n self.moles: list[Mole] = []\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n dx, dy = self.moves[self.action]\n self.x = min(8, max(0, self.x + dx))\n self.y = min(8, max(0, self.y + dy))\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(frame == 0 and self.action == 5 and previous != 5)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _random_number(self):\n return int(self.random.uniform(1, 2.5))\n\n def _whack(self):\n for mole in self.moles:\n if not mole.timer and (mole.x, mole.y) == (self.x, self.y):\n if mole.value == self.target:\n self.target = self._random_number()\n for other in self.moles:\n other.timer, other.award = 60, other.value\n else:\n mole.timer, mole.award = 60, -mole.value\n self.penalty += 1\n break\n self.penalty += 1\n\n def _advance(self, whack):\n scroll = 0.02 + self.penalty\n self.penalty *= 0.9\n self.scroll += scroll\n if self.scroll > 0:\n self.numbers[1:] = self.numbers[:-1].copy()\n self.numbers[0] = self.random.integers(0, 10, 9)\n for mole in self.moles:\n mole.y += 1\n self.scroll -= 11\n if whack:\n self._whack()\n self.spawn_distance = self.spawn_distance - scroll if self.moles else -scroll\n if self.spawn_distance < 0:\n occupied = {m.x for m in self.moles if m.y == 0}\n for _ in range(9):\n x = int(self.random.integers(9))\n if x not in occupied:\n self.target_count -= 1\n value = self._random_number()\n if self.target_count <= 0:\n value = self.target\n self.target_count = int(self.random.integers(4, 7))\n self.moles.append(Mole(x, 0, value))\n break\n self.spawn_distance += self.random.uniform(9, 12)\n self.move_timer -= 1\n if self.move_timer < 0:\n self._move_moles()\n self.move_timer += 99\n remaining = []\n reward = 0\n for mole in self.moles:\n if mole.timer:\n mole.timer -= 1\n if not mole.timer:\n reward += mole.award\n continue\n elif mole.y >= 8:\n mole.timer = 60\n self.terminal |= mole.value == self.target\n remaining.append(mole)\n self.moles = remaining\n return reward\n\n def _move_moles(self):\n occupied = {(m.x, m.y) for m in self.moles}\n for mole in self.moles:\n if mole.timer:\n continue\n start = int(self.random.integers(4))\n for offset in range(4):\n dx, dy = self.mole_moves[(start + offset) % 4]\n x, y = mole.x + dx, mole.y + dy\n if 0 <= x < 9 and 0 < y < 9 and (x, y) not in occupied:\n occupied.remove((mole.x, mole.y))\n occupied.add((x, y))\n mole.x, mole.y = x, y\n break\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n visible = self.numbers.copy()\n for mole in self.moles:\n if mole.y < 9:\n if mole.timer:\n visible[mole.y, mole.x] = mole.value\n state[mole.y, mole.x, 4] = True\n else:\n visible[mole.y, mole.x] = (visible[mole.y, mole.x] + mole.value) % 10\n for bit in range(4):\n state[:9, :9, bit] = (visible & (1 << bit)) != 0\n state[self.y, self.x, 5] = True\n for col, value in enumerate((self.target, round(-self.scroll * 4), self.move_timer, self.action)):\n for bit in range(6):\n state[bit, 9, col] = bool(value & (1 << bit))\n state[9, col, 0] = bool(value & 64)\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 121, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/mole_n.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/molen/main.js"} +{"name": "bank_heist", "split": "train", "game": "bank_heist", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Bank Heist as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves *Bank Heist*'s city-routing and risk-management loop. The getaway car\ndrives on a fixed street maze, with paired wraparound passages and an upper-right exit that\nirreversibly advances to the next town. Running over a bank robs it and spawns a pursuing cop, up\nto three at once. Cops choose chase routes but cannot immediately U-turn. Action 5 releases\ndynamite behind the car, consumes extra fuel, and can destroy the getaway car if mistimed.\n\nEach town begins with three visible banks. Disabling a cop reveals the next bank until all nine\nopportunities have appeared. Bank rewards retain the manual's $10 through $90 sequence. Cop\nrewards retain the $10/$30/$50 values based on one, two, or three active pursuers. Fuel drains\nwith time and dynamite; collision, self-dynamiting, or an empty tank costs a car. The player has\none active car plus the manual's four spares. Robbing all nine banks before exiting grants the\ntown bonus, a bonus car, and a full refuel. Four towns comprise the finite level.\n\nACTION MAPPING\n0: wait\n1: move left\n2: move up\n3: move right\n4: move down\n5: drop dynamite\n\nINPUT CHANNEL TABLE\n0: getaway car\n1: pursuing cops and imminent blast danger\n2: available banks and the next-town exit\n3: dropped dynamite\n4: previous getaway and cop positions\n5: fuel, cars, town, and robbery count\n\nSCORING, TERMINATION, AND HORIZON\nNine banks total `$10 + … + $90 = $450` per town. At most one cop is created per robbery and\neach cop is worth at most $50, giving another $450 per town. The four level-one town bonuses sum\nto `$93 + $186 + $279 + $372 = $930`. Thus `score_cap = 4×($450 + $450) + $930 = $4,530`.\nNormalization is `min(max(raw_score, 0), 4530) / 4530`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/bank_heist.py`):\n```python\nimport numpy as np\n\n\nROADS = np.array([\n [1, 1, 1, 0, 0, 0, 1, 1, 1, 1],\n [1, 0, 1, 1, 1, 1, 1, 0, 1, 0],\n [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],\n [1, 1, 1, 0, 1, 1, 1, 1, 1, 1],\n [0, 0, 1, 0, 0, 0, 1, 0, 1, 0],\n [1, 1, 1, 1, 1, 0, 1, 0, 1, 0],\n [1, 0, 0, 0, 1, 0, 1, 1, 1, 0],\n [1, 1, 1, 1, 1, 1, 1, 0, 1, 1],\n [1, 0, 1, 0, 0, 0, 1, 0, 1, 0],\n [1, 1, 1, 1, 1, 1, 1, 0, 1, 0],\n], dtype=bool)\nBANK_LOCATIONS = ((1, 2), (1, 6), (3, 4), (3, 8), (5, 2), (5, 6), (7, 4), (7, 8), (9, 2))\nTOWN_BONUSES = (93.0, 186.0, 279.0, 372.0)\nDELTAS = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}\n\n\nclass BankHeistEnvironment:\n \"\"\"Four-town robbery route with fuel, pursuing cops, and tailpipe dynamite.\"\"\"\n\n score_cap = 4_530.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 1_500):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.town = 0\n self.cars = 5\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self._start_town(full_fuel=True)\n\n def _start_town(self, full_fuel: bool) -> None:\n previous_fuel = getattr(self, \"fuel\", 100)\n self.fuel = 100 if full_fuel else max(previous_fuel, 50)\n self.player = [9, 0]\n self.previous_player = self.player.copy()\n self.direction = 3\n self.cops: list[dict[str, object]] = []\n self.previous_cops: list[list[int]] = []\n self.dynamite: list[dict[str, int]] = []\n self.robbed = 0\n self.spawned_banks = 3\n self.banks = set(BANK_LOCATIONS[:3])\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n if action in DELTAS:\n self.direction = action\n self._move_player(action)\n elif action == 5 and self.fuel > 5:\n row_delta, column_delta = DELTAS[self.direction]\n self.dynamite.append({\n \"row\": (self.player[0] - row_delta) % 10,\n \"column\": (self.player[1] - column_delta) % 10,\n \"timer\": 2,\n })\n self.fuel -= 5\n\n reward = self._rob_bank()\n self.previous_cops = [list(cop[\"position\"]) for cop in self.cops]\n self._move_cops()\n reward += self._detonate_dynamite()\n if any(list(cop[\"position\"]) == self.player for cop in self.cops):\n self._lose_car()\n self.fuel -= 1\n if self.fuel <= 0:\n self._lose_car()\n if self.player == [0, 9]:\n reward += self._leave_town()\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_player(self, action: int) -> None:\n row_delta, column_delta = DELTAS[action]\n target = [self.player[0] + row_delta, self.player[1] + column_delta]\n if self.player[0] in (3, 7) and target[1] < 0:\n target[1] = 9\n elif self.player[0] in (3, 7) and target[1] > 9:\n target[1] = 0\n if 0 <= target[0] < 10 and 0 <= target[1] < 10 and ROADS[*target]:\n self.player = target\n\n def _rob_bank(self) -> float:\n position = tuple(self.player)\n if position not in self.banks:\n return 0.0\n self.banks.remove(position)\n self.robbed += 1\n if len(self.cops) < 3:\n self.cops.append({\"position\": [*position], \"previous\": [*position]})\n return float(self.robbed * 10)\n\n def _move_cops(self) -> None:\n for cop in self.cops:\n position = list(cop[\"position\"])\n previous = list(cop[\"previous\"])\n candidates = []\n for action in DELTAS:\n row_delta, column_delta = DELTAS[action]\n target = [position[0] + row_delta, position[1] + column_delta]\n if position[0] in (3, 7) and target[1] < 0:\n target[1] = 9\n elif position[0] in (3, 7) and target[1] > 9:\n target[1] = 0\n if 0 <= target[0] < 10 and 0 <= target[1] < 10 and ROADS[*target] and target != previous:\n distance = abs(target[0] - self.player[0]) + abs(target[1] - self.player[1])\n candidates.append((distance, action, target))\n if candidates:\n cop[\"previous\"] = position\n cop[\"position\"] = min(candidates)[2]\n\n def _detonate_dynamite(self) -> float:\n reward = 0.0\n remaining = []\n for stick in self.dynamite:\n stick[\"timer\"] -= 1\n if stick[\"timer\"] > 0:\n remaining.append(stick)\n continue\n blast = [stick[\"row\"], stick[\"column\"]]\n if blast == self.player:\n self._lose_car()\n pursuit_count = len(self.cops)\n value = {1: 10.0, 2: 30.0, 3: 50.0}.get(pursuit_count, 0.0)\n destroyed = [cop for cop in self.cops if list(cop[\"position\"]) == blast]\n for cop in destroyed:\n self.cops.remove(cop)\n reward += value\n if self.spawned_banks < 9:\n self.banks.add(BANK_LOCATIONS[self.spawned_banks])\n self.spawned_banks += 1\n self.dynamite = remaining\n return reward\n\n def _lose_car(self) -> None:\n self.cars -= 1\n self.player = [9, 0]\n self.previous_player = self.player.copy()\n self.fuel = 100\n self.cops.clear()\n self.dynamite.clear()\n if self.cars <= 0:\n self.terminal = True\n\n def _leave_town(self) -> float:\n reward = TOWN_BONUSES[self.town] if self.robbed >= 9 else 0.0\n full_fuel = self.robbed >= 9\n if full_fuel:\n self.cars += 1\n self.town += 1\n if self.town == 4:\n self.terminal = True\n else:\n self._start_town(full_fuel=full_fuel)\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n for cop in self.cops:\n state[*list(cop[\"position\"]), 1] = True\n for bank in self.banks:\n state[*bank, 2] = True\n state[0, 9, 2] = True\n for stick in self.dynamite:\n state[stick[\"row\"], stick[\"column\"], 3] = True\n state[*self.previous_player, 4] = True\n for position in self.previous_cops:\n state[*position, 4] = True\n state[9, : min(10, (self.fuel + 9) // 10), 5] = True\n state[8, : min(10, self.cars), 5] = True\n state[7, : self.town + 1, 5] = True\n state[6, : min(9, self.robbed), 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 122, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/bank_heist.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "zone_b", "split": "train", "game": "zone_b", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Zone B as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to brake and fire once the tank slows down. Release\nwith any other action to move. A quick release while still moving\nturns the tank clockwise. Destroying an enemy scores the current\nmultiplier and increases it. Clear the enemies to advance. Enemy\nfire and leaving the shrinking safe zone end the run.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the tank, walls and unsafe area, nearby\nenemies, friendly shots, nearby enemy shots, and counters. Walls\nand the unsafe area share a channel. The port uses geometric\ncollision checks and updates the preview radius at the end of\neach transition. Each action advances up to four frames over 400\nactions. Clip episode scores to [0, 200] and divide by 200.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/zone_b.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import hypot\n\nimport numpy as np\n\n\n_DIRECTIONS = ((1, 0), (0, 1), (-1, 0), (0, -1))\n\n\n@dataclass\nclass Tank:\n x: float\n y: float\n heading: int\n shot: float = 0\n speed: float = 0\n burst: int = 0\n turn: float = 0\n reflecting: bool = False\n\n\n@dataclass\nclass Bullet:\n x: float\n y: float\n heading: int\n friendly: bool\n life: int = 20\n\n\nclass ZoneBEnvironment:\n score_cap = 200\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.action = self.steps = self.level = 0\n self.terminal = False\n self._start_level()\n\n def _start_level(self):\n self.enemies = [\n Tank(*self.random.uniform(0, 99, 2), int(self.random.integers(4)),\n self.random.uniform(200, 300))\n for _ in range(9 + self.level * 7)\n ]\n self.walls = []\n for _ in range(19):\n x, y = self.random.uniform(9, 89, 2)\n width = self.random.uniform(2.5, 7.5)\n self.walls.append((x, y, width, 1) if self.random.integers(2) else (x, y, 1, width))\n self.player = Tank(50, 80, 3)\n self.bullets = []\n self.center = np.array([50., 50.])\n self.radius = 120.\n self.next_center = self.center.copy()\n self.next_radius = 60.\n self.timer = 99\n self.multiplier = 1\n self.clear = 60\n self.level += 1\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n release = previous == 5 and self.action != 5\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(release and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, release):\n self._zone()\n for bullet in self.bullets:\n dx, dy = _DIRECTIONS[bullet.heading]\n bullet.x += dx\n bullet.y += dy\n bullet.life -= 1\n self.bullets = [b for b in self.bullets if b.life >= 0 and _inside(b) and not self._wall(b, 1)]\n reward = 0\n remaining = []\n for enemy in self.enemies:\n dx, dy = _DIRECTIONS[enemy.heading]\n enemy.x += dx * enemy.speed\n enemy.y += dy * enemy.speed\n if any(b.friendly and _distance(enemy, b) < 3.5 for b in self.bullets):\n reward += self.multiplier\n self.multiplier += 1\n continue\n self._reflect(enemy)\n if enemy.shot > 7:\n enemy.turn -= 1\n if enemy.turn < 0:\n enemy.heading = (enemy.heading + 1) % 4\n enemy.turn = self.random.uniform(200, 300)\n enemy.shot -= 1\n if enemy.shot < 0:\n enemy.burst -= 1\n if enemy.burst < 0:\n enemy.shot = self.random.uniform(100, 200)\n enemy.burst = int(self.random.integers(3, 7))\n else:\n self._shoot(enemy, False)\n enemy.shot += 7\n enemy.speed += ((0 if enemy.shot < 7 else 0.2) - enemy.speed) * 0.1\n remaining.append(enemy)\n self.enemies = remaining\n p = self.player\n dx, dy = _DIRECTIONS[p.heading]\n p.speed += ((0 if self.action == 5 else 0.2) - p.speed) * 0.1\n if release and p.speed > 0.04:\n p.heading = (p.heading + 1) % 4\n p.shot -= 1\n if self.action == 5 and p.speed < 0.04 and p.shot < 0:\n self._shoot(p, True)\n p.shot = 7\n p.x += dx * p.speed\n p.y += dy * p.speed\n self.terminal = (self.radius < 1 or hypot(p.x - self.center[0], p.y - self.center[1]) > self.radius * 1.05\n or any(not b.friendly and _distance(p, b) < 3.5 for b in self.bullets))\n self._reflect(p)\n if not self.enemies and not self.terminal:\n self.clear -= 1\n if self.clear == 0:\n self._start_level()\n return reward\n\n def _zone(self):\n self.timer -= 1\n if self.timer == 9:\n for _ in range(99):\n candidate = self.random.uniform(10, 90, 2)\n if np.linalg.norm(candidate - self.next_center) < 10:\n break\n self.zone_target = candidate\n if self.timer < 0:\n self.timer = 600\n if self.timer < 9:\n self.next_center += (self.zone_target - self.next_center) / (self.timer + 1)\n if self.timer == 0:\n self.next_radius -= 10\n if self.next_radius < 60 and self.timer > 9:\n self.center += (self.next_center - self.center) / self.timer\n self.radius += (self.next_radius - self.radius) / self.timer\n self.walls = [(x, y, w, h) for x, y, w, h in self.walls\n if abs(hypot(x - self.center[0], y - self.center[1]) - self.radius) > hypot(w, h)]\n\n def _wall(self, obj, margin):\n return any(abs(x - obj.x) < w + margin and abs(y - obj.y) < h + margin\n for x, y, w, h in self.walls)\n\n def _reflect(self, tank):\n blocked = not _inside(tank) or self._wall(tank, 2)\n if blocked and not tank.reflecting:\n tank.heading = (tank.heading + 2) % 4\n tank.reflecting = blocked\n dx, dy = self.center - (tank.x, tank.y)\n if hypot(dx, dy) >= self.radius:\n tank.heading = (0 if dx > 0 else 2) if abs(dx) > abs(dy) else (1 if dy > 0 else 3)\n tank.x = min(99, max(0, tank.x))\n tank.y = min(99, max(0, tank.y))\n\n def _shoot(self, tank, friendly):\n dx, dy = _DIRECTIONS[tank.heading]\n self.bullets.append(Bullet(tank.x + 5 * dx, tank.y + 5 * dy, tank.heading, friendly))\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n _mark(state, self.player, 0)\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for x, y, w, h in self.walls:\n state[:, :, 1] |= (abs(cols - x) < w + 5) & (abs(rows - y) < h + 5)\n state[:, :, 1] |= np.hypot(cols - self.center[0], rows - self.center[1]) >= self.radius\n for enemy in self.enemies:\n if _distance(enemy, self.player) < 30:\n _mark(state, enemy, 2)\n for bullet in self.bullets:\n if bullet.friendly or _distance(bullet, self.player) < 30:\n _mark(state, bullet, 3 if bullet.friendly else 4)\n values = (self.steps, self.action, self.player.heading, round(self.player.speed * 100),\n self.multiplier, self.level, self.timer, round(self.radius * 4))\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n\ndef _inside(obj):\n return 0 <= obj.x < 99 and 0 <= obj.y < 99\n\n\ndef _distance(first, second):\n return hypot(first.x - second.x, first.y - second.y)\n\n\ndef _mark(state, obj, channel):\n if 0 <= obj.x < 100 and 0 <= obj.y < 100:\n state[int(obj.y // 10), int(obj.x // 10), channel] = True\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 123, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/zone_b.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/zoneb/main.js"} +{"name": "sunflower_sway", "split": "train", "game": "sunflower_sway", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Sunflower Sway as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to bring out the sun and sway right. Actions 0–4\nrelease and let the stem swing back. Catch dew with the flower head\nto score its current height and grow by seven units. Insects cost\n15 units of height. The flower gradually shrinks and the run ends\nwhen its height drops below nine.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the flower head, stem, dew, insects, sun,\nand counters. The port uses fixed difficulty and rectangular sprite\ncontact. Each action advances up to four frames over 400 actions.\nClip episode scores to [0, 500] and divide by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/sunflower_sway.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Falling:\n x: float\n y: float\n speed: float\n\n\nclass SunflowerSwayEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.height, self.angle, self.velocity = 40., 0., 0.001\n self.sun = 120.\n self.drop_timer, self.insect_timer = 30., 60.\n self.steps = 0\n self.held = self.terminal = False\n self.drops, self.insects = [], []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n if self.random.random() >= self.sticky_action_prob:\n self.held = action == 5\n self.steps += 1\n reward = 0.\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _head(self):\n return 30 + self.height * sin(self.angle), 95 - self.height * cos(self.angle)\n\n def _advance(self):\n if self.held:\n self.velocity += 0.005\n self.sun += ((80 if self.held else 120) - self.sun) * 0.1\n self.velocity *= 0.97\n self.angle += self.velocity\n self.velocity -= self.angle * 0.01\n self.height = min(70, self.height - 0.045)\n self.terminal = self.height < 9\n x, y = self._head()\n self.drop_timer -= 1\n if self.drop_timer <= 0:\n self.drops.append(Falling(self.random.uniform(0, 99), -3, self.random.uniform(0.5, 1)))\n self.drop_timer = self.random.uniform(30, 40)\n reward = 0.\n remaining = []\n for drop in self.drops:\n drop.y += drop.speed\n if abs(drop.x - x) < 5.5 and abs(drop.y - y) < 5.5:\n reward += self.height\n self.height += 7\n elif drop.y <= 90:\n remaining.append(drop)\n self.drops = remaining\n self.insect_timer -= 1\n if self.insect_timer <= 0:\n bounds = (0, 20) if self.random.random() < 0.25 else (40, 99)\n self.insects.append(Falling(self.random.uniform(*bounds), -3, self.random.uniform(0.3, 0.8)))\n self.insect_timer = self.random.uniform(60, 70)\n remaining = []\n for insect in self.insects:\n insect.y += insect.speed\n if abs(insect.x - x) < 6 and abs(insect.y - y) < 6:\n self.height -= 15\n elif insect.y <= 90:\n remaining.append(insect)\n self.insects = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n x, y = self._head()\n row, col = np.clip(np.array([y, x]) // 10, 0, 9).astype(int)\n state[row, col, 0] = True\n stem = np.linspace((30, 95), (x, y), 24)\n cols, rows = np.clip(stem // 10, 0, 9).astype(int).T\n state[rows, cols, 1] = True\n for channel, objects in ((2, self.drops), (3, self.insects)):\n for obj in objects:\n if 0 <= obj.y < 100:\n state[int(obj.y // 10), int(obj.x // 10), channel] = True\n if self.sun < 100:\n state[1, int(self.sun // 10), 4] = True\n values = (self.steps, round(self.height * 5), self.held, round((self.angle + 2) * 100),\n round((self.velocity + 1) * 100), round(self.drop_timer), round(self.insect_timer))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 124, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/sunflower_sway.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameSunflowerSway.c"} +{"name": "ud_cave", "split": "train", "game": "ud_cave", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Ud Cave as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to move the lower runner right and the upper runner\nleft. Release with any other action to move both the opposite way.\nThe caves scroll in opposite directions. Both runners must avoid\nthe walls. Each new cave slice pays the current multiplier, and\neither runner can collect gold to raise it.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the two runners, walls from each cave,\ngold, and counters. The port fixes difficulty and uses rectangle\noverlap in place of sprite collisions. Each action advances up to\nfour frames over 400 actions. Clip episode scores to [0, 1000] and\ndivide by 1000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/ud_cave.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Cave:\n width: float\n x: float = 0.\n vx: float = 0.\n vw: float = 0.\n\n\n@dataclass\nclass Wall:\n left: float\n right: float\n y: float\n direction: int\n\n\n@dataclass\nclass Gold:\n x: float\n y: float\n direction: int\n\n\nclass UdCaveEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x = 0.\n self.wall_distance, self.gold_distance = -50., 5.\n self.caves = [Cave(20), Cave(15), Cave(15)]\n self.walls, self.gold = [], []\n self.multiplier = 1\n self.steps = self.action = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n self.wall_distance -= 1\n reward = 0\n if self.wall_distance < 0:\n reward = self.multiplier\n self._spawn()\n self.wall_distance += 10\n for wall in self.walls:\n wall.y += wall.direction\n self.walls = [wall for wall in self.walls if -10 <= wall.y <= 110]\n\n self.x = min(25, max(-25, self.x + (0.5 if self.action == 5 else -0.5)))\n players = ((25 + self.x, 90), (75 - self.x, 10))\n if any(self._hits_wall(x, y, 1.5, 2) for x, y in players):\n self.terminal = True\n return reward\n\n remaining = []\n for gold in self.gold:\n gold.y += gold.direction\n if self._hits_wall(gold.x, gold.y, 2, 2):\n continue\n if any(abs(x - gold.x) <= 4 and abs(y - gold.y) <= 4 for x, y in players):\n self.multiplier += 1\n elif -3 <= gold.y <= 103:\n remaining.append(gold)\n self.gold = remaining\n return reward\n\n def _spawn(self):\n center = self.caves[0]\n for index, cave in enumerate(self.caves):\n cave.vx += self.random.uniform(-2, 2)\n cave.vw += self.random.uniform(-1, 1)\n cave.x += cave.vx\n cave.width += cave.vw\n low, high = (-10, 10) if index == 0 else (center.x - center.width, center.x + center.width)\n if (cave.x - cave.width < low and cave.vx < 0) or (\n cave.x + cave.width > high and cave.vx > 0\n ):\n cave.vx *= -0.5\n cave.x += cave.vx\n minimum, maximum = (10, 14) if index == 0 else (center.width, 18)\n if (cave.width < minimum and cave.vw < 0) or (cave.width > maximum and cave.vw > 0):\n cave.vw *= -0.5\n cave.width += cave.vw\n\n for cave, mid, direction in zip(self.caves[1:], (25, 75), (1, -1), strict=True):\n y = -self.wall_distance if direction == 1 else 100 + self.wall_distance\n x = mid + direction * cave.x\n if x - cave.width > mid - 25:\n self.walls.append(Wall(mid - 25, x - cave.width, y, direction))\n if x + cave.width < mid + 25:\n self.walls.append(Wall(x + cave.width, mid + 25, y, direction))\n\n self.gold_distance -= 1\n if self.gold_distance < 0:\n left = self.random.random() < 0.5\n cave = self.caves[1 if left else 2]\n offset = self.random.uniform(-0.8, 0.8) * cave.width\n if left:\n self.gold.append(Gold(25 + cave.x + offset, -self.wall_distance - 5, 1))\n else:\n self.gold.append(Gold(75 - cave.x + offset, 105 + self.wall_distance, -1))\n self.gold_distance = self.random.uniform(3, 9)\n\n def _hits_wall(self, x, y, half_width, half_height):\n return any(\n wall.left - half_width < x < wall.right + half_width\n and abs(y - (wall.y - 4.5 * wall.direction)) < 4.5 + half_height\n for wall in self.walls\n )\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[9, min(9, int((25 + self.x) // 10)), 0] = True\n state[1, min(9, int((75 - self.x) // 10)), 1] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for wall in self.walls:\n state[:, :, 2 if wall.direction == 1 else 3] |= (\n (cols + 5 > wall.left) & (cols - 5 < wall.right)\n & (abs(rows - (wall.y - 4.5 * wall.direction)) < 9.5)\n )\n for gold in self.gold:\n if 0 <= gold.x < 100 and 0 <= gold.y < 100:\n state[int(gold.y // 10), int(gold.x // 10), 4] = True\n values = (self.steps, self.action, round((self.x + 25) * 2), self.multiplier,\n round(self.wall_distance + 51), round(self.gold_distance * 16))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 125, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/ud_cave.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/udcave/main.js"} +{"name": "slalom", "split": "train", "game": "slalom", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Slalom as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to turn in the direction set by the next wall. Actions\n0–4 release. The skier keeps moving with inertia. Pass close to each\nwall tip to earn points based on your closest approach. Walls\nalternate sides. Hitting a wall or rock, or leaving the playfield,\nends the episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the skier, walls, rocks, target wall tip,\nheading, and counters. The port uses fixed difficulty and rectangular\ncollision bounds. Each action advances up to four frames over a\n400-action horizon. Clip the episode score to [0, 300] and divide by 300.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/slalom.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, floor, hypot, pi, sin, sqrt\n\nimport numpy as np\n\n\n@dataclass\nclass Wall:\n y: float\n side: int\n length: int\n\n @property\n def tip(self):\n return 99 - self.length if self.side > 0 else self.length\n\n\n@dataclass\nclass Rock:\n x: float\n y: float\n width: int\n height: int\n\n\nclass SlalomEnvironment:\n score_cap = 300\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x = self.y = 90.0\n self.angle = -3 * pi / 4\n self.vx, self.vy = cos(self.angle), sin(self.angle)\n self.scroll = self.wall_distance = self.rock_distance = 0.\n self.side = 1\n self.closest = 99.\n self.steps = 0\n self.held = self.terminal = False\n self.walls, self.rocks = [], []\n self.target = None\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.held = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n self.rock_distance -= self.scroll\n if self.rock_distance < 0:\n x = self.random.integers(-5, 5) + 100 * self.random.integers(2)\n self.rocks.append(Rock(x, -9, self.random.integers(9, 19), 2 * self.random.integers(5, 9)))\n self.rock_distance += 10\n for rock in self.rocks:\n rock.y += self.scroll\n self.rocks = [rock for rock in self.rocks if rock.y < 109]\n self.wall_distance -= self.scroll\n if self.wall_distance < 0:\n self.walls.append(Wall(-5, self.side, self.random.integers(40, 60)))\n self.side *= -1\n self.wall_distance += self.random.integers(80, 90)\n for wall in self.walls:\n wall.y += self.scroll\n target = next((wall for wall in self.walls if wall.y < self.y + 9), None)\n self.walls = [wall for wall in self.walls if wall.y < 105]\n reward = 0\n if target is not self.target:\n reward = max(0, floor(100 / (sqrt(self.closest) + 1)) - 15)\n self.target = target\n self.closest = 99\n if self.held and target is not None:\n self.angle += target.side * 0.07\n self.vx = self.vx * 0.98 + 0.03 * cos(self.angle)\n self.vy = self.vy * 0.98 + 0.03 * sin(self.angle)\n self.x += self.vx\n self.y += self.vy\n self.scroll = max(0, 88 - self.y) * 0.5\n self.y += self.scroll\n self.terminal = not (0 <= self.x <= 99 and 0 <= self.y <= 99)\n self.terminal |= any(\n abs(wall.y - self.y) < 4 and (self.x > wall.tip - 2 if wall.side > 0 else self.x < wall.tip + 2)\n for wall in self.walls\n )\n self.terminal |= any(abs(rock.x - self.x) < rock.width / 2 + 2\n and abs(rock.y - self.y) < rock.height / 2 + 2 for rock in self.rocks)\n if target is not None:\n self.closest = min(self.closest, hypot(target.tip - self.x, target.y - self.y))\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n row, col = np.clip(np.array([self.y, self.x]) // 10, 0, 9).astype(int)\n state[row, col, 0] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for wall in self.walls:\n state[:, :, 1] |= (abs(rows - wall.y) < 7) & (\n cols >= wall.tip - 5 if wall.side > 0 else cols <= wall.tip + 5)\n for rock in self.rocks:\n state[:, :, 2] |= (abs(rows - rock.y) < rock.height / 2 + 5) & (\n abs(cols - rock.x) < rock.width / 2 + 5)\n if self.target is not None and 0 <= self.target.y < 100:\n state[int(self.target.y // 10), self.target.tip // 10, 3] = True\n x, y = self.x + 10 * cos(self.angle), self.y + 10 * sin(self.angle)\n row, col = np.clip(np.array([y, x]) // 10, 0, 9).astype(int)\n state[row, col, 4] = True\n for row, value in enumerate((self.steps, self.held, round(self.closest * 5),\n round((self.vx + 2) * 100), round((self.vy + 2) * 100))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 126, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/slalom.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/slalom/main.js"} +{"name": "swingby", "split": "train", "game": "swingby", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Swingby as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to thrust right relative to your heading. Actions 0–4\nrelease. Stars pull the ship toward them. Crossing a star ring\nbuilds damage, which recovers when clear. Damage above 99 ends\nthe episode. Score is the floored distance from the starting point.\nEach action returns the change in that score, so backtracking\nreduces the episode total.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the ship, star rings, origin direction,\nheading, damage marker, and counters. The port fixes difficulty\nand approximates ring contact with a radial tolerance. Each action\nadvances up to four frames over 400 actions. Clip the final score\nto [0, 1000] and divide by 1000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/swingby.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import atan2, cos, floor, hypot, pi, sin, sqrt\n\nimport numpy as np\n\n\n@dataclass\nclass Star:\n x: float\n y: float\n radius: float\n\n\nclass SwingbyEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x = self.y = self.vx = self.vy = self.anchor_x = self.anchor_y = 0.\n self.screen_x = self.screen_y = 50.\n self.damage = self.steps = self.score = 0\n self.held = self.terminal = False\n self.stars = [Star(0, 0, 20)]\n for _ in range(20):\n self._spawn(0, 0, 150, -pi, pi)\n self.stars.pop(0)\n self.display = []\n\n def _spawn(self, x, y, reach, start, stop):\n for _ in range(99):\n angle = self.random.uniform(start, stop)\n distance = self.random.uniform(0, reach)\n px, py = x + distance * cos(angle), y + distance * sin(angle)\n radius = self.random.uniform(5, 15)\n if all(hypot(px - star.x, py - star.y) >= radius + star.radius + 30 for star in self.stars):\n self.stars.append(Star(px, py, radius))\n break\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n if self.random.random() >= self.sticky_action_prob:\n self.held = action == 5\n self.steps += 1\n previous = self.score\n for _ in range(4):\n self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(self.score - previous), self.terminal\n\n def _advance(self):\n remaining = []\n self.display = []\n collision = False\n for star in self.stars:\n dx, dy = star.x - self.x, star.y - self.y\n distance = hypot(dx, dy)\n force = star.radius * 0.01 / min(99, max(2, distance - star.radius))\n angle = atan2(dy, dx)\n self.vx += force * cos(angle)\n self.vy += force * sin(angle)\n if distance < 99 + star.radius:\n self.display.append((dx, dy, star.radius))\n collision |= abs(distance - (star.radius - 2)) < 4.5\n if distance <= 150:\n remaining.append(star)\n self.stars = remaining\n dx, dy = self.x - self.anchor_x, self.y - self.anchor_y\n if hypot(dx, dy) > 50:\n angle = atan2(dy, dx)\n self.anchor_x, self.anchor_y = self.x, self.y\n for _ in range(5):\n self._spawn(self.x + 100 * cos(angle), self.y + 100 * sin(angle),\n 70, angle - pi / 2, angle + pi / 2)\n self.vx *= 0.99\n self.vy *= 0.99\n angle = atan2(self.vy, self.vx)\n lead = min(30, max(1, sqrt(hypot(self.vx, self.vy)) * 19))\n self.screen_x, self.screen_y = 50 - lead * cos(angle), 50 - lead * sin(angle)\n if self.held:\n self.vx -= 0.05 * sin(angle)\n self.vy += 0.05 * cos(angle)\n angle = atan2(self.vy, self.vx)\n self.vx += 0.01 * cos(angle)\n self.vy += 0.01 * sin(angle)\n self.x += self.vx\n self.y += self.vy\n if collision:\n self.vx *= 0.99\n self.vy *= 0.99\n self.damage += 4\n else:\n self.damage = max(0, self.damage - 1)\n self.terminal = self.damage > 99\n self.score = floor(hypot(self.x, self.y))\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n x, y = self.screen_x, self.screen_y\n state[int(y // 10), int(x // 10), 0] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for dx, dy, radius in self.display:\n state[:, :, 1] |= abs(np.hypot(cols - x - dx, rows - y - dy) - (radius - 2)) < 8\n origin = np.clip(np.array([x - self.x, y - self.y]) // 10, 0, 9).astype(int)\n state[origin[1], origin[0], 2] = True\n angle = atan2(self.vy, self.vx)\n state[int((y + 10 * sin(angle)) // 10), int((x + 10 * cos(angle)) // 10), 3] = True\n state[int(y // 10), int(x // 10), 4] = self.damage > 0\n values = (self.steps, self.damage, self.held, min(2047, self.score),\n round((self.vx + 10) * 50), round((self.vy + 10) * 50))\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit % 10, 5] = bool(value & (1 << bit))\n state[6, 0, 5] = self.score >= 1024\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 127, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/swingby.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/swingby/main.js"} +{"name": "floors5", "split": "train", "game": "floors5", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Floors5 as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to jump or double jump. Hold to slow the fall.\nRelease with actions 0–4 before tapping again. The car moves\nforward automatically and paints the floor beneath it. Leaving\na floor pays for the painted width. Painting the full floor\ntriples the payout. Landing on all five colors increases the\nmultiplier. Falling offscreen ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the car, three bits of floor color,\npaint, and gauges. The conversion uses fixed difficulty and\ndetects platform contact by crossing a floor surface. Each action\nadvances four simulation frames.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action task clips raw scores to [0, 1000] and divides by\n1,000. Across 100 seeds without sticky actions, idle scored 225,\ncontinuous hold averaged 39.45, and random inputs averaged 28.70.\nA repeating eight-action hold and four-action release pattern\naveraged 79.68 and reached 307.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/floors5.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nCAR_X = 10\n\n\n@dataclass(eq=False)\nclass Floor:\n x: float\n y: float\n width: float\n color: int\n paint_from: float = 0\n paint_to: float = 0\n\n\nclass Floors5Environment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.jumps = self.grace = 0\n self.pressed = self.terminal = False\n self.y, self.vy, self.speed = 10.0, 0.0, 1.0\n self.support: Floor | None = None\n self.visited: set[int] = set()\n self.multiplier = 1\n self.floors = [Floor(x, y, width, color) for color, (x, y, width) in enumerate(\n ((25, 30, 10), (52, 50, 35), (105, 70, 30), (160, 60, 30), (220, 40, 50))\n )]\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap: bool) -> int:\n for floor in self.floors:\n if floor.x + floor.width < 0:\n floor.x, floor.y = self.random.uniform(200, 250), self.random.uniform(30, 90)\n floor.width = self.random.uniform(20, 60)\n floor.paint_from = floor.paint_to = 0\n floor.x -= self.speed\n self.speed += 0.02\n self.grace = max(0, self.grace - 1)\n reward = 0\n if self.support is not None:\n floor = self.support\n floor.paint_to = min(floor.width, max(0, CAR_X + 5 - floor.x))\n if tap or floor.x + floor.width < CAR_X - 3:\n width = floor.paint_to - floor.paint_from\n reward = min(999, max(0, math.floor(width) * self.multiplier))\n if width >= floor.width:\n reward *= 3\n floor.x = -999\n self.support = None\n self.speed = 1\n if tap:\n self.vy = -2\n self.jumps += 1\n else:\n self.jumps = 0\n self.grace = 9\n else:\n old_y = self.y\n self.vy += 0.03 if self.pressed else 0.18\n self.y += self.vy\n for floor in self.floors:\n if not floor.x - 3 <= CAR_X <= floor.x + floor.width + 3:\n continue\n if self.vy >= 0 and old_y <= floor.y - 3 <= self.y:\n self.y, self.vy, self.speed = floor.y - 3, 0, 1\n self.support = floor\n floor.paint_from = max(0, CAR_X - 5 - floor.x)\n floor.paint_to = min(floor.width, max(0, CAR_X + 5 - floor.x))\n self.jumps = 0\n self.visited.add(floor.color)\n if len(self.visited) == 5:\n self.multiplier += 1\n self.visited.clear()\n break\n if self.vy < 0 and self.y <= floor.y + 9 <= old_y:\n self.y = floor.y + 9\n self.vy *= -0.7\n break\n if tap and self.support is None and (self.grace or self.jumps < 2):\n self.vy, self.speed = -2, 1\n self.jumps += 1\n self.terminal = self.y > 99\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, max(0, int(self.y) // 10)), 0, 0] = True\n for floor in self.floors:\n row = int(floor.y) // 10\n for col in range(10):\n if col * 20 < floor.x + floor.width and (col + 1) * 20 > floor.x:\n for bit in range(3):\n state[row, col, bit + 1] |= bool((floor.color + 1) & (1 << bit))\n state[row, col, 4] |= floor.paint_to > floor.paint_from and (\n col * 20 < floor.x + floor.paint_to and (col + 1) * 20 > floor.x + floor.paint_from\n )\n for row, value in enumerate((self.steps, self.multiplier, self.jumps, self.grace,\n round(self.vy * 16) + 128)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[8, :5, 5] = [color in self.visited for color in range(5)]\n state[9, :2, 5] = self.pressed, self.support is not None\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 128, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/floors5.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/floors5/main.js"} +{"name": "tectonic_tether", "split": "train", "game": "tectonic_tether", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Tectonic Tether as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to retract the tether and charge it near the center.\nRelease with actions 0–4 to extend and spend the stored boost.\nStrike asteroids to scatter geodes. Asteroids driven into a wall\nscore ten points and respawn. Mature geodes are attracted to the\nshard and score one point each, restoring absorption power.\nRunning out of power ends the episode.\n\nINPUT CHANNEL TABLE\nSix channels show the shard, asteroids, mature geodes, growing\ngeodes, tether, and counters. The port uses fixed difficulty and\nrectangular contact bounds. Each action advances up to four frames\nover a 400-action horizon. Clip scores to [0, 200] and divide by 200.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/tectonic_tether.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import atan2, cos, pi, sin\n\nimport numpy as np\n\n\nCENTER = np.array([50., 50.])\n\n\n@dataclass\nclass Rock:\n position: np.ndarray\n velocity: np.ndarray\n size: float\n\n\n@dataclass\nclass Geode:\n position: np.ndarray\n velocity: np.ndarray\n age: int\n\n\nclass TectonicTetherEnvironment:\n score_cap = 200\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.position = np.array([50., 10.])\n self.angle, self.angular_speed, self.length = 0., 0.01, 35.\n self.charge = self.boost = 0.\n self.power = 30.\n self.steps = 0\n self.held = self.terminal = False\n self.rocks = [Rock(self.random.uniform(20, 80, 2), np.zeros(2),\n self.random.uniform(8, 12)) for _ in range(5)]\n self.geodes = [Geode(self.random.uniform(10, 90, 2), np.zeros(2), 60) for _ in range(7)]\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n if self.held and not held:\n self.boost, self.charge = self.charge, 0.\n self.held = held\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n if self.held:\n self.length -= 0.7\n self.angular_speed = min(0.05, self.angular_speed + 0.001)\n if self.length <= 10:\n self.charge = min(5, self.charge + 0.1)\n else:\n self.length += 0.7 + self.boost\n self.angular_speed = max(0.01, self.angular_speed - 0.0005)\n self.boost *= 0.92\n self.angle = (self.angle + self.angular_speed) % (2 * pi)\n self.position = np.clip(CENTER + self.length * np.array([cos(self.angle), sin(self.angle)]), 3, 97)\n self.length = max(10, float(np.linalg.norm(self.position - CENTER)))\n self.power -= 0.05\n self.terminal = self.power <= 0\n reward = 0\n remaining = []\n for geode in self.geodes:\n geode.age = min(60, geode.age + 1)\n if geode.age < 60:\n geode.position += geode.velocity\n geode.velocity *= 0.96\n else:\n delta = self.position - geode.position\n distance = np.linalg.norm(delta)\n if 0 < distance < 15 + self.power:\n geode.position += delta / distance * (0.3 + self.power * 0.05)\n np.clip(geode.position, 5, 95, out=geode.position)\n if geode.age == 60 and np.all(abs(geode.position - self.position) < 5.5):\n self.power = min(30, self.power + 1.5)\n reward += 1\n else:\n remaining.append(geode)\n self.geodes = remaining\n for index, rock in enumerate(self.rocks):\n rock.position += rock.velocity\n rock.velocity *= 0.95\n delta = rock.position - self.position\n if np.all(abs(delta) < rock.size / 2 + 3):\n count = int(self.angular_speed * self.length)\n outside = np.linalg.norm(rock.position - CENTER) > np.linalg.norm(self.position - CENTER)\n self.length += -5 if outside else 5\n distance = np.linalg.norm(delta)\n if distance:\n rock.velocity += delta / distance * 0.8\n angle = atan2(-delta[1], -delta[0])\n self._scatter(rock, count, angle, pi / 3, 3, 0.45, 1.05)\n edge = rock.size / 2 + 2\n if np.any((rock.position < edge) | (rock.position > 100 - edge)):\n reward += 10\n self._scatter(rock, int(rock.size / 2 + 1), pi, pi, 8, 1, 1.5)\n rock.position = self.random.uniform(20, 80, 2)\n rock.velocity[:] = 0\n for other in self.rocks[index + 1:]:\n offset = rock.position - other.position\n distance = np.linalg.norm(offset)\n limit = (rock.size + other.size) / 2\n if 0 < distance < limit:\n normal = offset / distance\n separation = normal * (limit - distance) / 2\n rock.position += separation\n other.position -= separation\n rock.velocity += normal * 0.4\n other.velocity -= normal * 0.4\n return reward\n\n def _scatter(self, rock, count, angle, spread, jitter, low, high):\n for _ in range(count):\n heading = angle + self.random.uniform(-spread, spread)\n position = np.clip(rock.position + self.random.uniform(-jitter, jitter, 2), 10, 90)\n speed = self.random.uniform(low, high)\n self.geodes.append(Geode(position, speed * np.array([cos(heading), sin(heading)]), 0))\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n x, y = (self.position // 10).astype(int)\n state[y, x, 0] = True\n for rock in self.rocks:\n x, y = np.clip(rock.position // 10, 0, 9).astype(int)\n state[y, x, 1] = True\n for geode in self.geodes:\n x, y = (geode.position // 10).astype(int)\n state[y, x, 2 if geode.age == 60 else 3] = True\n cols, rows = (np.linspace(CENTER, self.position, 20) // 10).astype(int).T\n state[rows, cols, 4] = True\n values = (self.steps, round(max(0, self.power) * 10), round(self.charge * 20),\n self.held, round(self.length * 5), round(self.angular_speed * 1000))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 129, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tectonic_tether.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameTectonicTether.c"} +{"name": "s_lanes", "split": "train", "game": "s_lanes", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays S Lanes as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to lock onto the selected lane, advance, and fire.\nActions 0–4 release, sending the ship back toward the left while\ncycling lanes. Shots turn enemies into coins. Collect coins to score\nthe current multiplier and raise it by one. Missing a coin lowers\nthe multiplier and temporarily speeds up its lane. An enemy reaching\nthe left edge ends the episode.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the ship, enemies, coins, shots, selected\nlane, and counters. The port fixes difficulty and approximates sprite\ncollisions with rectangular bounds. Each action advances up to four\nframes over a 400-action horizon. Clip episode scores to [0, 150]\nand divide by 150.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/s_lanes.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\nLANES = (22, 42, 62, 82)\n\n\n@dataclass\nclass Target:\n x: float\n lane: int\n\n\nclass SLanesEnvironment:\n score_cap = 150\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y, self.target_y = 3.0, 22.0, 22.0\n self.lane = self.steps = self.lane_timer = self.shot_timer = self.spawn_timer = 0\n self.multiplier = 1\n self.held = self.terminal = False\n self.enemies, self.coins, self.shots = [], [], []\n self.speeds = np.ones(4)\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n self.spawn_timer -= 1\n if self.spawn_timer < 0:\n self.enemies.append(Target(103, int(self.random.integers(4))))\n self.spawn_timer = self.random.uniform(60, 90)\n if self.held:\n self.x = 3 if tap else min(50, self.x + 0.3)\n self.y = self.target_y = LANES[self.lane]\n self.shot_timer -= 1\n if self.shot_timer < 0:\n self.shots.append(Target(self.x, self.lane))\n self.shot_timer = self.lane_timer = 20\n else:\n self.lane_timer -= 1\n if self.lane_timer < 0:\n self.lane = (self.lane + 1) % 4\n self.target_y = LANES[self.lane] + (100 if self.lane == 0 else 0)\n self.y %= 100\n self.lane_timer = 20\n self.x += (3 - self.x) * 0.3\n self.y += (self.target_y - self.y) * 0.3\n self.speeds += (0.9 - self.speeds) * 0.02\n reward = 0\n coins = []\n for coin in self.coins:\n coin.x -= 0.2\n if abs(coin.x - self.x) < 5.5 and abs(LANES[coin.lane] - self.y % 100) < 4.5:\n reward += self.multiplier\n self.multiplier += 1\n elif coin.x < -3:\n self.speeds[coin.lane] += 1\n self.multiplier = max(1, self.multiplier - 1)\n else:\n coins.append(coin)\n for shot in self.shots:\n shot.x += 2\n enemies = []\n for enemy in self.enemies:\n enemy.x -= 0.2 * self.speeds[enemy.lane]\n if any(shot.lane == enemy.lane and abs(shot.x - enemy.x) < 6 for shot in self.shots):\n coins.append(enemy)\n else:\n self.terminal |= enemy.x < 9\n enemies.append(enemy)\n self.coins, self.enemies = coins, enemies\n self.shots = [\n shot for shot in self.shots if shot.x <= 103 and not any(\n shot.lane == enemy.lane and abs(shot.x - enemy.x) < 6 for enemy in enemies\n )\n ]\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(self.y % 100 // 10), int(self.x // 10), 0] = True\n for channel, entities in ((1, self.enemies), (2, self.coins), (3, self.shots)):\n for entity in entities:\n if 0 <= entity.x < 100:\n state[LANES[entity.lane] // 10, int(entity.x // 10), channel] = True\n state[LANES[self.lane] // 10, :, 4] = True\n gauges = (self.steps, self.multiplier, self.lane_timer, self.shot_timer,\n self.held, *(round(speed * 100) for speed in self.speeds))\n for row, value in enumerate(gauges):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 130, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/s_lanes.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/slanes/main.js"} +{"name": "gravity_well", "split": "train", "game": "gravity_well", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Gravity Well as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to spend one unit of planet radius and emit a\nrepulsion pulse. Actions 0–4 release the button. Black holes\npull the planet inward and drain its radius on contact.\nThe planet slowly regrows away from contact and the episode\nends when its radius drops below one.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the planet, black hole areas,\nblack hole centers, pulses, projected position, and gauges.\nThe conversion approximates arc collisions with circular\noverlap and clamps the edge force near its singularities.\n\nSCORING, TERMINATION, AND HORIZON\nAt fixed difficulty the game scores the integer planet radius\nevery 60 frames, including the first. Four frames per action\nand 400 actions allow at most 27 awards of 9 points. The task\nclips raw scores to [0, 243] and divides by 243.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/gravity_well.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass BlackHole:\n x: float\n y: float\n radius: float\n\n\nclass GravityWellEnvironment:\n score_cap = 243\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x = self.y = 50.0\n self.vx = self.vy = 0.0\n self.radius = 9.0\n self.spawn_distance = 0.0\n self.steps = self.frames = 0\n self.pressed = self.terminal = False\n self.holes: list[BlackHole] = []\n self.pulses: list[int] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tapped = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tapped and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap: bool) -> int:\n reward = int(self.radius) if self.frames % 60 == 0 else 0\n self.frames += 1\n for hole in self.holes:\n hole.x -= 0.5\n self.holes = [hole for hole in self.holes if hole.x >= -10]\n self.spawn_distance -= 0.5\n if self.spawn_distance < 0:\n radius = self.random.uniform(5, 9)\n self.holes.append(BlackHole(100 + radius, self.random.uniform(10, 90), radius))\n self.spawn_distance += self.random.uniform(30, 40)\n self.x += self.vx\n self.y += self.vy\n self.vx = (self.vx + self._edge_force(self.x, 110)) * 0.99\n self.vy = (self.vy + self._edge_force(self.y, 105)) * 0.99\n for hole in self.holes:\n dx, dy = hole.x - self.x, hole.y - self.y\n distance_squared = dx * dx + dy * dy\n if distance_squared > 0:\n self.vx += 0.1 * dx / distance_squared\n self.vy += 0.1 * dy / distance_squared\n if tap and self.radius > 2:\n self.radius -= 1\n self.pulses.append(0)\n for radius in self.pulses:\n for hole in self.holes:\n dx, dy = hole.x - self.x, hole.y - self.y\n distance = math.hypot(dx, dy)\n if 0 < distance < radius + 1 + hole.radius:\n force = 0.5 / distance ** 1.5\n self.vx -= dx * force\n self.vy -= dy * force\n hole.x += dx * force\n hole.y += dy * force\n self.pulses = [radius + 1 for radius in self.pulses if radius < 20]\n if any(math.hypot(h.x - self.x, h.y - self.y) < self.radius + h.radius for h in self.holes):\n self.radius -= 0.2\n else:\n self.radius = min(9, self.radius + 0.05)\n self.terminal = self.radius < 1\n if (self.x < 0 and self.vx < 0) or (self.x > 100 and self.vx > 0):\n self.vx *= -1\n if (self.y < 0 and self.vy < 0) or (self.y > 100 and self.vy > 0):\n self.vy *= -1\n return reward\n\n @staticmethod\n def _edge_force(position: float, far_edge: int) -> float:\n return 1 / max(1, position + 10) ** 2 - 1 / max(1, far_edge - position) ** 2\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row = min(9, max(0, int(self.y) // 10))\n col = min(9, max(0, int(self.x) // 10))\n state[row, col, 0] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for hole in self.holes:\n state[:, :, 1] |= (cols - hole.x) ** 2 + (rows - hole.y) ** 2 < hole.radius ** 2\n if 0 <= hole.x < 100 and 0 <= hole.y < 100:\n state[int(hole.y) // 10, int(hole.x) // 10, 2] = True\n distance = np.hypot(cols - self.x, rows - self.y)\n for radius in self.pulses:\n state[:, :, 3] |= abs(distance - radius) < 5\n future_row = min(9, max(0, int(self.y + 4 * self.vy) // 10))\n future_col = min(9, max(0, int(self.x + 4 * self.vx) // 10))\n state[future_row, future_col, 4] = True\n for gauge_row, value in enumerate((self.steps, round(self.radius * 50))):\n for bit in range(9):\n state[gauge_row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 131, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/gravity_well.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameGravityWell.c"} +{"name": "count", "split": "train", "game": "count", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Count as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nCount the objects matching the displayed shape or color. Wait with\nactions 0–4 as the counter increases, then tap action 5 when it shows\nthe answer. Correct answers score one point and advance after a short\nfeedback period. A wrong answer or an overshoot ends the run after\nfeedback.\n\nINPUT CHANNEL TABLE\nThe 10×10 observation assigns one object per cell. Channels 0–2 encode\ncolor and channels 3–4 encode shape in binary. Channel 5 encodes the\ntarget, matching rule, counter, and timers. The conversion uses fixed\ndifficulty and cell placement in place of overlapping sprites and\nvariable sizes. Each action advances four frames of the counter.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action horizon permits at most nine correct answers. Clip the\nraw score to [0, 9] and divide by nine. Across 100 seeds without sticky\nactions, idle and random hold/release scored zero. A policy that counted\nmatches directly from the observation averaged 5.72 and reached seven.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/count.py`):\n```python\nimport math\n\nimport numpy as np\n\n\nclass CountEnvironment:\n score_cap = 9\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = 0\n self.turn = 1\n self.pressed = self.terminal = False\n self._new_round()\n\n def _new_round(self) -> None:\n self.count, self.timer, self.feedback = 0, 80, 0\n self.correct = False\n chance = 0.5 + (math.sqrt(self.turn) * 0.2 - 0.5) % 0.5\n vary_shape, vary_color = self.random.random(2) < chance\n if not (vary_shape or vary_color):\n vary_shape = bool(self.random.integers(2))\n vary_color = not vary_shape\n self.by_shape = bool(vary_shape and (not vary_color or self.random.integers(2)))\n size = min(70, 3 + int(math.sqrt(self.turn)) + int(self.random.integers(self.turn)))\n shapes = self.random.integers(3, size=size) if vary_shape else [int(self.random.integers(3))] * size\n colors = self.random.integers(3, size=size) if vary_color else [int(self.random.integers(3))] * size\n self.objects = [(int(cell), int(shape), int(color)) for cell, shape, color in\n zip(self.random.choice(70, size, replace=False), shapes, colors)]\n _, shape, color = self.objects[int(self.random.integers(size))]\n self.target = shape if self.by_shape else color\n self.target_count = sum(self._matches(shape, color) for _, shape, color in self.objects)\n\n def _matches(self, shape: int, color: int) -> bool:\n return (shape if self.by_shape else color) == self.target\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n if self.feedback:\n self.feedback -= 4\n if not self.feedback:\n if self.correct:\n self.turn += 1\n self._new_round()\n else:\n self.terminal = True\n elif tap or self.count > self.target_count:\n self.correct = self.count == self.target_count\n self.feedback = 92\n reward = int(self.correct)\n else:\n self.timer -= 4\n if self.timer <= 0:\n self.count += 1\n self.timer = 60\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for cell, shape, color in self.objects:\n if not self.feedback or self._matches(shape, color):\n row, col = divmod(cell, 10)\n state[row + 3, col, color] = True\n state[row + 3, col, 3:5] = bool(shape & 1), bool(shape & 2)\n state[0, self.target, 5] = True\n state[0, 3:7, 5] = self.by_shape, bool(self.feedback), self.correct, self.pressed\n for row, value in enumerate((self.count, self.timer, self.feedback, self.turn, self.steps), 1):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 132, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/count.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/count/main.js"} +{"name": "baserunner_dash", "split": "train", "game": "baserunner_dash", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Baserunner Dash as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to run toward the next base. Release with actions 0–4\nto retreat to the last base. Reaching a new base scores one point.\nThe ball alternates between slow pursuit and faster throws. A slow\nball tags the runner on contact between bases. The runner is safe\non a base or while the ball is in flight.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the bases, runner, thrown ball, slow\nball, ball target and last base, and the runner target and gauges.\nEach action advances eight frames at fixed difficulty. Movement\nsnaps to the exact base when the runner or ball reaches it.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action horizon permits at most 33 base advances by distance\nalone. Clip the raw score to [0, 33] and divide by 33.\n\nAcross 100 seeds without sticky actions, always holding and always\nreleasing both scored zero. Random hold and release averaged 0.07\npoints. Waiting 10 actions before holding averaged 2.05 and reached 7.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/baserunner_dash.py`):\n```python\nimport math\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 8\nBASES = ((50, 90), (90, 50), (50, 10), (10, 50))\nLEG_LENGTH = math.dist(BASES[0], BASES[1])\nRUNNER_SPEED = 0.6\nBALL_SPEED = 0.3\n\n\nclass BaserunnerDashEnvironment:\n score_cap = HORIZON * FRAMES_PER_STEP // math.ceil(LEG_LENGTH / RUNNER_SPEED)\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = 0\n self.pressed = self.terminal = False\n self.runner_base = 1\n self.progress = 0.0\n self.ball = BASES[0]\n self.ball_base = 0\n self.ball_target = 2\n self.thrown = True\n\n @property\n def runner_target(self) -> int:\n return (self.runner_base + 1) % len(BASES)\n\n @property\n def runner_position(self) -> tuple[float, float]:\n x, y = BASES[self.runner_base]\n target_x, target_y = BASES[self.runner_target]\n fraction = self.progress / LEG_LENGTH\n return x + (target_x - x) * fraction, y + (target_y - y) * fraction\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(FRAMES_PER_STEP):\n reward += self._advance_runner()\n self._advance_ball()\n runner_x, runner_y = self.runner_position\n ball_x, ball_y = self.ball\n if self.progress > 0 and not self.thrown and abs(runner_x - ball_x) < 6 and abs(runner_y - ball_y) < 6:\n self.terminal = True\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_runner(self) -> int:\n if not self.pressed:\n self.progress = max(0, self.progress - RUNNER_SPEED)\n return 0\n self.progress += RUNNER_SPEED\n if self.progress < LEG_LENGTH:\n return 0\n self.runner_base = self.runner_target\n self.progress = 0.0\n return 1\n\n def _advance_ball(self) -> None:\n x, y = self.ball\n target = BASES[self.ball_target]\n dx, dy = target[0] - x, target[1] - y\n distance = math.hypot(dx, dy)\n speed = BALL_SPEED * (3 if self.thrown else 1)\n if distance <= speed:\n self.ball = target\n self.ball_base = self.ball_target\n self.thrown = False\n self.ball_target = self.runner_target if self.ball_base == self.runner_base else self.runner_base\n return\n self.ball = x + dx * speed / distance, y + dy * speed / distance\n if not self.thrown and self.random.random() < 0.05:\n self.thrown = True\n if self.ball_base not in (self.runner_base, self.runner_target):\n self.ball_target = self.runner_target\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for x, y in BASES:\n state[y // 10, x // 10, 0] = True\n runner_x, runner_y = self.runner_position\n state[int(runner_y) // 10, int(runner_x) // 10, 1] = True\n ball_x, ball_y = self.ball\n state[int(ball_y) // 10, int(ball_x) // 10, 2 if self.thrown else 3] = True\n target_x, target_y = BASES[self.ball_target]\n state[target_y // 10, target_x // 10, 4] = True\n for index, channel in ((self.runner_base, 4), (self.runner_target, 5)):\n state[0, index, channel] = True\n for bit in range(9):\n state[9, bit, 5] = bool(self.steps & (1 << bit))\n state[9, 9, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 133, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/baserunner_dash.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBaserunnerDash.c"} +{"name": "two_faced", "split": "train", "game": "two_faced", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Two Faced as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to reverse the direction of curvature. Hold it to go\nstraight and accelerate. Release with any other action to resume\nturning. Crossing an edge reflects movement and switches faces.\nCollect the item with the head or tail on the same face to lengthen\nthe tail and increase the multiplier. The multiplier decays over\ntime. Contact with the older tail on the current face ends the run.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the head, item on the current face,\nitem on the opposite face, dangerous tail on the current face,\nsafe tail on the current face, and counters. Both faces share grid\ncoordinates. Opposite-face tail segments are hidden until the next\nface switch. Difficulty is fixed, and distance checks approximate\nsprite overlap. Each action advances up to four frames over 400\nactions. Clip the episode score to [0, 500] and divide by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/two_faced.py`):\n```python\nfrom collections import deque\nfrom dataclasses import dataclass\nfrom math import atan2, ceil, cos, hypot, pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Piece:\n x: float\n y: float\n angle: float\n side: int = -1\n\n\nclass TwoFacedEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.head = Piece(0, 20, -pi / 2)\n self.item = Piece(0, 0, 0)\n self.turn = 1\n self.speed = self.base_speed = 1.\n self.history = deque(maxlen=256)\n self.tail_count = 3\n self.safe_tail = 2.\n self.multiplier = 3.\n self.action = self.steps = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n if self.action == 5 and previous != 5:\n self.turn *= -1\n self.speed += 0.1\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n if self.action == 5:\n self.speed += 0.01\n else:\n self.speed += (1 - self.speed) * 0.1\n self.head.angle += self.turn * 0.03 * self.speed * self.base_speed\n self.base_speed *= 1.002\n flips = _move(self.head, 0.5 * self.speed * self.base_speed)\n self.turn *= (-1) ** flips\n self.safe_tail = min(self.tail_count - 1, self.safe_tail + 2 * flips)\n self.history.appendleft(Piece(self.head.x, self.head.y, self.head.angle, self.head.side))\n _move(self.item, 0.2)\n\n self.safe_tail += (2 - self.safe_tail) * 0.03\n tail = self._tail()\n reward = 0\n if any(_near(segment, self.item, 5) for segment in tail):\n reward = ceil(self.multiplier)\n self.base_speed = 1.\n self.tail_count = min(25, self.tail_count + 1)\n self.multiplier += self.tail_count\n x, y = self.random.uniform(-35, 35, 2)\n self.item = Piece(x, y, self.random.uniform(-pi, pi), -self.head.side)\n self.terminal = any(\n index >= self.safe_tail and _near(self.head, segment, 4)\n for index, segment in enumerate(tail)\n )\n self.multiplier = max(1, self.multiplier - 0.01)\n return reward\n\n def _tail(self):\n return [self.history[index] for index in range(0, min(len(self.history), 9 * self.tail_count), 9)]\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n _mark(state, self.head, 0)\n _mark(state, self.item, 1 if self.item.side == self.head.side else 2)\n for index, segment in enumerate(self._tail()):\n if segment.side == self.head.side:\n _mark(state, segment, 3 if index >= self.safe_tail else 4)\n values = (self.steps, self.action, self.head.side > 0, self.turn > 0,\n round((self.head.angle % (2 * pi)) * 64),\n round(self.speed * 32), round(self.base_speed * 16),\n self.tail_count, ceil(self.multiplier), round(self.safe_tail * 16))\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n\ndef _move(piece, speed):\n vx, vy = cos(piece.angle), sin(piece.angle)\n piece.x += vx * speed\n piece.y += vy * speed\n flips = 0\n if abs(piece.x) > 40 and piece.x * vx > 0:\n vx *= -1\n flips += 1\n if abs(piece.y) > 40 and piece.y * vy > 0:\n vy *= -1\n flips += 1\n piece.side *= (-1) ** flips\n piece.angle = atan2(vy, vx)\n return flips\n\n\ndef _near(first, second, radius):\n return first.side == second.side and hypot(first.x - second.x, first.y - second.y) <= radius\n\n\ndef _cell(piece):\n return tuple(int(np.clip((value + 40) // 8, 0, 9)) for value in (piece.y, piece.x))\n\n\ndef _mark(state, piece, channel):\n row, col = _cell(piece)\n state[row, col, channel] = True\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 134, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/two_faced.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/twofaced/main.js"} +{"name": "amidar", "split": "train", "game": "amidar", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Amidar as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves the Atari 2600 game's central loop: the player travels only on a\nrectilinear maze, paints an edge by traversing it, scores when all four sides of a box have been\npainted, and must avoid enemies patrolling the same paths. The fire action spends one of three\nuses to turn every enemy into a stationary, harmless shadow for a short interval.\n\nThe finite 10 by 10 board contains a 3 by 3 arrangement of boxes. Three enemies patrol with a\ndeterministic wall-following rule. A round ends on contact with a live enemy, when all boxes are\ncomplete, or at the 600-step horizon.\n\nACTION MAPPING\n0: wait\n1: move left\n2: move up\n3: move right\n4: move down\n5: activate shadow/freeze\n\nINPUT CHANNEL TABLE\n0: player\n1: live patrol enemies\n2: centers of incomplete boxes\n3: harmless shadow enemies\n4: painted path vertices\n5: remaining shadow uses and active shadow timer\n\nSCORING, TERMINATION, AND HORIZON\nThere are exactly 9 boxes and each can score once, so `score_cap = 9`. Enemy contact never\nscores and painted boxes cannot be reclaimed. Normalization is\n`min(max(raw_score, 0), 9) / 9`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/amidar.py`):\n```python\nimport numpy as np\n\n\nACTIONS = {\n 1: (0, -1),\n 2: (-1, 0),\n 3: (0, 1),\n 4: (1, 0),\n}\n\n\nclass AmidarEnvironment:\n \"\"\"Trace a rectilinear maze while avoiding deterministic patrol enemies.\"\"\"\n\n score_cap = 9.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 600):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.player = [9, 0]\n self.previous_player = self.player.copy()\n self.enemies = [[0, 0], [0, 9], [9, 9]]\n self.previous_enemies = [position.copy() for position in self.enemies]\n self.enemy_directions = [4, 1, 2]\n self.painted_edges: set[tuple[tuple[int, int], tuple[int, int]]] = set()\n self.completed_boxes: set[tuple[int, int]] = set()\n self.shadow_timer = 0\n self.shadow_uses = 3\n self.last_action = 0\n self.steps = 0\n self.terminal = False\n\n @staticmethod\n def _on_path(position: list[int] | tuple[int, int]) -> bool:\n row, column = position\n return 0 <= row < 10 and 0 <= column < 10 and (row % 3 == 0 or column % 3 == 0)\n\n @staticmethod\n def _edge(first: list[int], second: list[int]) -> tuple[tuple[int, int], tuple[int, int]]:\n return tuple(sorted((tuple(first), tuple(second))))\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n if action == 5 and self.shadow_uses > 0 and self.shadow_timer == 0:\n self.shadow_uses -= 1\n self.shadow_timer = 12\n elif action in ACTIONS:\n row_delta, column_delta = ACTIONS[action]\n target = [self.player[0] + row_delta, self.player[1] + column_delta]\n if self._on_path(target):\n self.player = target\n if self.player != self.previous_player:\n self.painted_edges.add(self._edge(self.previous_player, self.player))\n\n reward = self._complete_boxes()\n self.previous_enemies = [position.copy() for position in self.enemies]\n if self.shadow_timer == 0:\n for index in range(len(self.enemies)):\n self._move_enemy(index)\n if self.shadow_timer == 0 and any(enemy == self.player for enemy in self.enemies):\n self.terminal = True\n self.shadow_timer = max(0, self.shadow_timer - 1)\n self.steps += 1\n if len(self.completed_boxes) == 9 or self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_enemy(self, index: int) -> None:\n direction = self.enemy_directions[index]\n preferences = (direction, {1: 2, 2: 3, 3: 4, 4: 1}[direction], {1: 4, 2: 1, 3: 2, 4: 3}[direction])\n for candidate_direction in preferences:\n row_delta, column_delta = ACTIONS[candidate_direction]\n target = [self.enemies[index][0] + row_delta, self.enemies[index][1] + column_delta]\n if self._on_path(target):\n self.enemies[index] = target\n self.enemy_directions[index] = candidate_direction\n return\n\n def _complete_boxes(self) -> float:\n reward = 0.0\n for box_row in range(3):\n for box_column in range(3):\n box = (box_row, box_column)\n if box in self.completed_boxes:\n continue\n top = box_row * 3\n left = box_column * 3\n required = set()\n for offset in range(3):\n required.add(self._edge([top, left + offset], [top, left + offset + 1]))\n required.add(self._edge([top + 3, left + offset], [top + 3, left + offset + 1]))\n required.add(self._edge([top + offset, left], [top + offset + 1, left]))\n required.add(self._edge([top + offset, left + 3], [top + offset + 1, left + 3]))\n if required <= self.painted_edges:\n self.completed_boxes.add(box)\n reward += 1.0\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n for enemy in self.enemies:\n channel = 3 if self.shadow_timer > 0 else 1\n state[*enemy, channel] = True\n for box_row in range(3):\n for box_column in range(3):\n center = (min(9, box_row * 3 + 1), min(9, box_column * 3 + 1))\n if (box_row, box_column) not in self.completed_boxes:\n state[*center, 2] = True\n for first, second in self.painted_edges:\n state[*first, 4] = True\n state[*second, 4] = True\n state[9, : self.shadow_uses, 5] = True\n if self.shadow_timer > 0:\n state[8, : min(10, self.shadow_timer), 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 135, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/amidar.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "b_cannon", "split": "train", "game": "b_cannon", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays B Cannon as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe cannon travels around the arena perimeter. A fresh press of action\n5 reverses its direction. Holding stops the cannon and fires one\nextending rope toward the nearest ball's predicted position after\nthree held steps. Actions 0–4 release and resume travel. A rope hit\nsplits a ball into two smaller balls with brief immunity. A hit on\nthe smallest size removes the ball and pays the rolling spawn index.\nBall contact with the cannon ends the game.\n\nINPUT CHANNEL TABLE\nChannels show the cannon, balls, immune balls, extended rope, aim point,\nand gauges. The gauges include the clock, hold duration, wave counters,\nball speed, rolling index, and movement and button state. The grid\nversion replaces circular collision with tile occupancy, uses discrete\nsize tiers and bounce vectors, and predicts aim one ball move ahead.\nWaves advance only after the last ball is destroyed.\n\nSCORING, TERMINATION, AND HORIZON\nEach full-size ball has at most eight scoring descendants. The\n400-step horizon and eight-step inter-wave delay allow at most 50 waves\nof at most four full-size balls. The rolling index ranges from 0 to 99,\ngiving a conservative cap of 158,400. Every scored descendant is\nremoved. Normalize by clipping to [0, cap] and dividing by the cap.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/b_cannon.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\nHORIZON = 400\nWAVE_DELAY = 8\nMAX_WAVE = 4\nPERIMETER = (\n tuple((9, x) for x in range(10))\n + tuple((y, 9) for y in range(8, -1, -1))\n + tuple((0, x) for x in range(8, -1, -1))\n + tuple((y, 0) for y in range(1, 9))\n)\n\n\n@dataclass\nclass Ball:\n row: int\n column: int\n dy: int\n dx: int\n size: int = 3\n immunity: int = 0\n\n\nclass BCannonEnvironment:\n score_cap = HORIZON // WAVE_DELAY * MAX_WAVE * 8 * 99\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.last_action = self.held = self.wave_size = self.ball_index = 0\n self.perimeter_index, self.direction = 5, 1\n self.wave_max, self.ball_period, self.wave_wait = 2, 3, WAVE_DELAY\n self.balls: list[Ball] = []\n self.rope: list[tuple[int, int]] = []\n self.rope_length = 0\n self.terminal = False\n\n @property\n def player(self) -> tuple[int, int]:\n return PERIMETER[self.perimeter_index]\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def _aim(self) -> tuple[int, int] | None:\n if not self.balls:\n return None\n row, column = self.player\n ball = min(self.balls, key=lambda item: (item.row - row) ** 2 + (item.column - column) ** 2)\n return max(1, min(8, ball.row + ball.dy)), max(1, min(8, ball.column + ball.dx))\n\n def _fire(self, target: tuple[int, int]) -> None:\n row, column = self.player\n dy, dx = target[0] - row, target[1] - column\n scale = max(abs(dy), abs(dx))\n self.rope = []\n for distance in range(1, 11):\n cell = row + round(dy * distance / scale), column + round(dx * distance / scale)\n if not all(0 < coordinate < 9 for coordinate in cell):\n break\n self.rope.append(cell)\n self.rope_length = 1\n\n def _spawn_wave(self) -> None:\n self.wave_size += 1\n if self.wave_size > self.wave_max:\n self.wave_size = 1\n self.wave_max = min(MAX_WAVE, self.wave_max + 1)\n self.ball_period = max(1, self.ball_period - 1)\n start = int(self.random.integers(1, 3))\n self.balls = [Ball(3, start + 2 * index, 1, 0) for index in range(self.wave_size)]\n self.ball_index = (self.ball_index + self.wave_size) % 100\n self.wave_wait = WAVE_DELAY\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n if action == 5 and self.last_action != 5:\n self.direction *= -1\n self.last_action = action\n self.steps += 1\n if action == 5:\n if self.balls:\n self.held += 1\n target = self._aim()\n if self.held == 3 and target is not None:\n self._fire(target)\n else:\n self.held = 0\n self.perimeter_index = (self.perimeter_index + self.direction) % len(PERIMETER)\n reward = self._advance_balls()\n if self.rope:\n self.rope_length += 1\n if self.rope_length > len(self.rope) + 1:\n self.rope.clear()\n self.rope_length = 0\n if not self.balls:\n self.wave_wait -= 1\n if self.wave_wait == 0:\n self._spawn_wave()\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_balls(self) -> int:\n reward = 0\n remaining = []\n rope = set(self.rope[:self.rope_length])\n for ball in self.balls:\n if self.steps % self.ball_period == 0:\n if not 0 <= ball.row + ball.dy < 10:\n ball.dy *= -1\n if not 0 <= ball.column + ball.dx < 10:\n ball.dx *= -1\n ball.row += ball.dy\n ball.column += ball.dx\n ball.immunity = max(0, ball.immunity - 1)\n cell = ball.row, ball.column\n if cell in rope and not ball.immunity:\n if ball.size == 0:\n reward += self.ball_index\n else:\n remaining.extend(Ball(*cell, -ball.dy or 1, dx, ball.size - 1, 3) for dx in (-1, 1))\n self.ball_index = (self.ball_index + 2) % 100\n else:\n self.terminal |= cell == self.player\n remaining.append(ball)\n self.balls = remaining\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n for ball in self.balls:\n state[ball.row, ball.column, 1] = True\n state[ball.row, ball.column, 2] |= ball.immunity > 0\n for cell in self.rope[:self.rope_length]:\n state[*cell, 3] = True\n target = self._aim()\n if target is not None:\n state[*target, 4] = True\n values = (self.steps, self.held, self.wave_size, self.wave_max, self.wave_wait,\n self.ball_period, self.ball_index, int(self.direction > 0), int(self.last_action == 5))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 136, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/b_cannon.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBCannon.c"} +{"name": "bs_fish", "split": "train", "game": "bs_fish", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Bs Fish as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to accelerate the bird. Actions 0–4 release and slow it.\nFish leap from the water. Eat small fish to build the multiplier,\nand avoid large fish. A fake large fish breaks into 13 pieces at the\nsurface, including a bonus eye. A catch pays the current multiplier\nand raises it by one, or by ten for an eye. Missed edible fish reduce\nthe multiplier by one, with a floor of one.\n\nINPUT CHANNEL TABLE\nThe channels show the bird, large and fake fish, edible fish, eyes,\nnext vertical fish positions, and gauges. The grid uses a shared\ndiscrete flight arc with fragment offsets and speed-dependent\nhorizontal scrolling. Large fish use a wider collision footprint.\n\nSCORING, TERMINATION, AND HORIZON\nThe horizon is 400 steps, with at most 50 spawns and 13 edible pieces\nper spawn. Each catch removes one piece. Even allowing every one of\nthe 650 pieces to raise the multiplier by ten gives an upper bound\nof 2,109,900 points. Normalize by clipping to [0, cap] and dividing\nby the cap.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/bs_fish.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\nHORIZON = 400\nSPAWN_INTERVAL = 8\nMAX_FISH = (HORIZON // SPAWN_INTERVAL) * 13\nBIRD_ROW = 2\nNORMAL, BIG, FAKE, EYE = range(4)\nFLIGHT = (8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9)\nFRAGMENTS = ((0, 2), (0, 3), (0, 4), (1, 0), (1, 1), (1, 2), (1, 3),\n (1, 4), (1, 5), (2, 1), (2, 2), (2, 3), (2, 5))\n\n\n@dataclass\nclass Fish:\n column: int\n kind: int = NORMAL\n age: int = 0\n row_offset: int = 0\n\n @property\n def row(self) -> int:\n return max(0, min(9, FLIGHT[self.age] + self.row_offset))\n\n\nclass BSFishEnvironment:\n score_cap = MAX_FISH * (1 + 5 * (MAX_FISH - 1))\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.last_action = self.speed = 0\n self.multiplier = 1\n self.special_in = 3\n self.fish: list[Fish] = []\n self.terminal = False\n\n @property\n def bird_column(self) -> int:\n return 1 + self.speed // 2\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.steps += 1\n self.speed = min(6, self.speed + 1) if action == 5 else max(0, self.speed - 1)\n if self.steps % SPAWN_INTERVAL == 1:\n if self.special_in == 0:\n kind = int(self.random.choice((BIG, FAKE)))\n self.special_in = int(self.random.integers(3, 9))\n else:\n kind = NORMAL\n self.special_in -= 1\n self.fish.append(Fish(int(self.random.integers(7, 10)), kind))\n reward = 0\n remaining = []\n for fish in self.fish:\n fish.age += 1\n if self.speed >= 4 or self.steps % 3 == 0:\n fish.column -= 1\n if fish.age == len(FLIGHT) or fish.column < -1:\n if fish.kind != BIG:\n self.multiplier = max(1, self.multiplier - 1)\n continue\n if fish.kind == FAKE and fish.row <= 5:\n remaining.extend(Fish(fish.column + column - 2, EYE if (row, column) == (1, 2) else NORMAL,\n fish.age, row - 1) for row, column in FRAGMENTS)\n elif fish.kind == BIG:\n if abs(fish.row - BIRD_ROW) <= 1 and abs(fish.column - self.bird_column) <= 1:\n self.terminal = True\n remaining.append(fish)\n elif fish.row == BIRD_ROW and fish.column == self.bird_column:\n reward += self.multiplier\n self.multiplier += 10 if fish.kind == EYE else 1\n else:\n remaining.append(fish)\n self.fish = remaining\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[BIRD_ROW, self.bird_column, 0] = True\n for fish in self.fish:\n if 0 <= fish.column < 10:\n channel = (2, 1, 1, 3)[fish.kind]\n state[fish.row, fish.column, channel] = True\n next_row = FLIGHT[min(fish.age + 1, len(FLIGHT) - 1)] + fish.row_offset\n if 0 <= next_row < 10:\n state[next_row, fish.column, 4] = True\n for row, value in enumerate((self.steps, self.speed, self.multiplier, self.special_in, self.last_action)):\n for bit in range(13):\n index = row * 13 + bit\n state[index // 10, index % 10, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 137, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/bs_fish.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBSFish.c"} +{"name": "rolfrg", "split": "train", "game": "rolfrg", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Rolfrg as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to reverse direction. Actions 0–4 release. The player\nmoves automatically and reverses at the edges. Avoid the rotating\nfrogs, which extend and leap every 30 frames. Each frame scores one\npoint, including the frame in which a collision ends the episode.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the player, short bars, extended bars,\nfrog positions, frog headings, and counters. The port uses fixed\ndifficulty and samples each bar for collision checks. Each action\nadvances up to four frames over a 400-action horizon. Clip the\nepisode score to [0, 1600] and divide by 1600.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/rolfrg.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Frog:\n x: float\n y: float\n angle: float\n\n\nclass RolfrgEnvironment:\n score_cap = 1600\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.direction = 50, 1\n self.frame = self.steps = 0\n self.held = self.terminal = False\n self.frogs = [Frog(0, -index * 9, self.random.uniform(0, 9)) for index in range(5)]\n self.bars = []\n self.long_bar = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n self._advance(tap and frame == 0)\n reward += 1\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n self.long_bar = self.frame % 30 == 0\n length = 30 if self.long_bar else 4\n self.bars = []\n for frog in self.frogs:\n if frog.y < 0:\n frog.x = self.random.uniform(0, 99)\n frog.y += self.random.uniform(99, 120)\n points = np.arange(length + 1)\n xs = frog.x + points * cos(frog.angle)\n ys = frog.y + points * sin(frog.angle)\n self.bars.append((xs, ys))\n frog.angle += 1 / 9\n frog.y -= 0.5\n if self.long_bar:\n frog.x += 30 * cos(frog.angle)\n frog.y += 30 * sin(frog.angle)\n self.x += self.direction\n if tap or self.x < 0 or self.x > 99:\n self.direction *= -1\n self.terminal = any(np.any((abs(xs - self.x) < 3) & (abs(ys - 36) < 3))\n for xs, ys in self.bars)\n self.frame += 1\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[3, min(9, max(0, self.x // 10)), 0] = True\n for xs, ys in self.bars:\n visible = (xs >= 0) & (xs < 100) & (ys >= 0) & (ys < 100)\n state[(ys[visible] // 10).astype(int), (xs[visible] // 10).astype(int),\n 2 if self.long_bar else 1] = True\n for frog in self.frogs:\n if 0 <= frog.x < 100 and 0 <= frog.y < 100:\n state[int(frog.y // 10), int(frog.x // 10), 3] = True\n x = frog.x + 12 * cos(frog.angle)\n y = frog.y + 12 * sin(frog.angle)\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), 4] = True\n for row, value in enumerate((self.steps, self.frame % 30, self.direction > 0, self.held)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 138, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/rolfrg.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/rolfrg/main.js"} +{"name": "time_pilot", "split": "train", "game": "time_pilot", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Time Pilot as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves free eight-direction time-ship flight around a centered craft, scrolling\nrelative motion, forward gunfire, enemy attacks from every direction, a fixed aircraft quota before\neach mother ship, complete-formation bonuses, heavy aircraft beginning in 1940, bombs and homing\nweapons that vary by era, seven-hit bosses, the 1910/1940/1970/1983/2001 progression, lives,\nscore-threshold reinforcements, and time travel after each boss.\n\nACTION MAPPING\n0: coast on current heading\n1: rotate 45 degrees counterclockwise\n2: thrust forward through the world\n3: rotate 45 degrees clockwise\n4: turn 180 degrees\n5: fire forward\n\nINPUT CHANNEL TABLE\n0: centered time ship\n1: quota aircraft and enemy weapons\n2: heavy aircraft and boss\n3: player bullets\n4: previous enemy/boss positions\n5: exact era, heading, lives, quotas, clock, boss health, and finite bonus state\n\nSCORING, TERMINATION, AND HORIZON\nFive eras contain `5 × 56 × 100 = 28,000` quota-aircraft points, five finite 2,000-point\nformation bonuses (10,000), four 1,500-point heavy aircraft (6,000), and five 3,000-point bosses\n(15,000). Thus `score_cap = 28,000 + 10,000 + 6,000 + 15,000 = 59,000`, and normalization is\n`min(max(raw_score, 0), 59_000) / 59_000`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/time_pilot.py`):\n```python\nimport numpy as np\n\n\nDIRECTIONS = ((-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1))\nERAS = (1910, 1940, 1970, 1983, 2001)\nFORMATION_IDS = frozenset(range(20, 25))\n\n\nclass TimePilotEnvironment:\n \"\"\"One five-era loop with scrolling flight, formations, and bosses.\"\"\"\n\n score_cap = 59_000.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 5_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.era = 0\n self.heading = 0\n self.previous_heading = self.heading\n self.lives = 3\n self.score = 0.0\n self.steps = 0\n self.last_action = 0\n self.next_extra_life = 10_000\n self.terminal = False\n self._start_era()\n\n def _start_era(self) -> None:\n self.spawned = 0\n self.killed = 0\n self.special_spawned = self.era == 0\n self.special_destroyed = self.era == 0\n self.formation_destroyed: set[int] = set()\n self.formation_failed = False\n self.enemies: list[dict[str, int | str]] = []\n self.bullets: list[list[int]] = []\n self.enemy_shots: list[list[int]] = []\n self.boss: dict[str, int] | None = None\n self.previous_objects: list[tuple[int, int]] = []\n self._spawn_enemies()\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_heading = self.heading\n self.previous_objects = [(int(enemy[\"row\"]), int(enemy[\"column\"])) for enemy in self.enemies]\n if self.boss is not None:\n self.previous_objects.append((self.boss[\"row\"], self.boss[\"column\"]))\n if action == 1:\n self.heading = (self.heading - 1) % 8\n elif action == 2:\n self._scroll_world(1)\n elif action == 3:\n self.heading = (self.heading + 1) % 8\n elif action == 4:\n self.heading = (self.heading + 4) % 8\n elif action == 5:\n row_delta, column_delta = DIRECTIONS[self.heading]\n self.bullets.append([5 + row_delta, 5 + column_delta, row_delta, column_delta])\n self._move_bullets()\n self._move_enemies()\n self._move_enemy_shots()\n reward = self._resolve_hits()\n self._resolve_collisions()\n if not self.terminal:\n self._spawn_enemies()\n self._spawn_boss_if_ready()\n future_score = self.score + reward\n while future_score >= self.next_extra_life:\n self.lives += 1\n self.next_extra_life += 50_000 if self.next_extra_life >= 10_000 else 10_000\n self.score = future_score\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _scroll_world(self, distance: int) -> None:\n row_delta, column_delta = DIRECTIONS[self.heading]\n for enemy in self.enemies:\n enemy[\"row\"] -= row_delta * distance\n enemy[\"column\"] -= column_delta * distance\n if self.boss is not None:\n self.boss[\"row\"] -= row_delta * distance\n self.boss[\"column\"] -= column_delta * distance\n\n def _spawn_enemies(self) -> None:\n if self.killed >= 56:\n return\n active_normal = sum(enemy[\"kind\"] == \"normal\" for enemy in self.enemies)\n target_active = 3 + self.era // 2\n if self.spawned == 20 and not FORMATION_IDS.intersection(\n int(enemy[\"id\"]) for enemy in self.enemies\n ):\n for enemy_id in FORMATION_IDS:\n self.enemies.append(self._new_enemy(enemy_id, \"normal\"))\n self.spawned = 25\n return\n while active_normal < target_active and self.spawned < 56 and self.spawned not in FORMATION_IDS:\n self.enemies.append(self._new_enemy(self.spawned, \"normal\"))\n self.spawned += 1\n active_normal += 1\n if self.era > 0 and not self.special_spawned and self.killed >= 10:\n self.enemies.append(self._new_enemy(100 + self.era, \"special\"))\n self.special_spawned = True\n\n def _new_enemy(self, enemy_id: int, kind: str) -> dict[str, int | str]:\n edge = int(self.random.randint(4))\n coordinate = int(self.random.randint(1, 9))\n row, column = ((0, coordinate), (9, coordinate), (coordinate, 0), (coordinate, 9))[edge]\n return {\"id\": enemy_id, \"kind\": kind, \"row\": row, \"column\": column}\n\n def _move_bullets(self) -> None:\n for bullet in self.bullets:\n bullet[0] += bullet[2]\n bullet[1] += bullet[3]\n self.bullets = [bullet for bullet in self.bullets if 0 <= bullet[0] < 10 and 0 <= bullet[1] < 10]\n\n def _move_enemies(self) -> None:\n interval = max(1, 4 - self.era // 2)\n if self.steps % interval == 0:\n for enemy in self.enemies:\n enemy[\"row\"] += int(np.sign(5 - int(enemy[\"row\"])))\n enemy[\"column\"] += int(np.sign(5 - int(enemy[\"column\"])))\n if self.boss is not None:\n self.boss[\"row\"] += int(np.sign(5 - self.boss[\"row\"]))\n self.boss[\"column\"] += int(np.sign(5 - self.boss[\"column\"]))\n if self.steps % max(5, 12 - self.era) == 0 and (self.enemies or self.boss is not None):\n source = self.enemies[0] if self.enemies else self.boss\n row = int(source[\"row\"])\n column = int(source[\"column\"])\n self.enemy_shots.append([row, column, int(np.sign(5 - row)), int(np.sign(5 - column))])\n\n def _move_enemy_shots(self) -> None:\n for shot in self.enemy_shots:\n if self.era >= 2:\n shot[2] = int(np.sign(5 - shot[0]))\n shot[3] = int(np.sign(5 - shot[1]))\n shot[0] += shot[2]\n shot[1] += shot[3]\n self.enemy_shots = [shot for shot in self.enemy_shots if 0 <= shot[0] < 10 and 0 <= shot[1] < 10]\n\n def _resolve_hits(self) -> float:\n reward = 0.0\n hit_bullets: set[int] = set()\n hit_enemy_ids: set[int] = set()\n for bullet_index, bullet in enumerate(self.bullets):\n for enemy in self.enemies:\n if bullet[:2] != [enemy[\"row\"], enemy[\"column\"]]:\n continue\n hit_bullets.add(bullet_index)\n hit_enemy_ids.add(int(enemy[\"id\"]))\n if enemy[\"kind\"] == \"normal\":\n reward += 100.0\n self.killed += 1\n if int(enemy[\"id\"]) in FORMATION_IDS:\n self.formation_destroyed.add(int(enemy[\"id\"]))\n else:\n reward += 1_500.0\n self.special_destroyed = True\n break\n if self.boss is not None and bullet[:2] == [self.boss[\"row\"], self.boss[\"column\"]]:\n hit_bullets.add(bullet_index)\n self.boss[\"hp\"] -= 1\n if self.boss[\"hp\"] == 0:\n reward += 3_000.0\n self.boss = None\n self.era += 1\n if self.era >= 5:\n self.terminal = True\n else:\n self._start_era()\n break\n self.enemies = [enemy for enemy in self.enemies if int(enemy[\"id\"]) not in hit_enemy_ids]\n self.bullets = [bullet for index, bullet in enumerate(self.bullets) if index not in hit_bullets]\n if not self.formation_failed and self.formation_destroyed == FORMATION_IDS:\n reward += 2_000.0\n self.formation_failed = True\n return reward\n\n def _resolve_collisions(self) -> None:\n colliding_ids = {\n int(enemy[\"id\"])\n for enemy in self.enemies\n if int(enemy[\"row\"]) == 5 and int(enemy[\"column\"]) == 5\n }\n collision = bool(colliding_ids) or any(shot[:2] == [5, 5] for shot in self.enemy_shots)\n if self.boss is not None and [self.boss[\"row\"], self.boss[\"column\"]] == [5, 5]:\n collision = True\n if not collision:\n return\n if colliding_ids.intersection(FORMATION_IDS):\n self.formation_failed = True\n for enemy in self.enemies:\n if int(enemy[\"id\"]) in colliding_ids:\n enemy[\"row\"] = 0\n enemy[\"column\"] = 1 + int(enemy[\"id\"]) % 8\n if self.boss is not None and [self.boss[\"row\"], self.boss[\"column\"]] == [5, 5]:\n self.boss[\"row\"] = 0\n self.boss[\"column\"] = 5\n self.bullets.clear()\n self.enemy_shots.clear()\n self.lives -= 1\n if self.lives <= 0:\n self.terminal = True\n\n def _spawn_boss_if_ready(self) -> None:\n if self.killed < 56 or self.enemies or not self.special_destroyed or self.boss is not None:\n return\n self.boss = {\"row\": 0, \"column\": 5, \"hp\": 7}\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[5, 5, 0] = True\n for enemy in self.enemies:\n channel = 2 if enemy[\"kind\"] == \"special\" else 1\n state[int(enemy[\"row\"]), int(enemy[\"column\"]), channel] = True\n if self.boss is not None:\n state[self.boss[\"row\"], self.boss[\"column\"], 2] = True\n for bullet in self.bullets:\n state[bullet[0], bullet[1], 3] = True\n for shot in self.enemy_shots:\n state[shot[0], shot[1], 1] = True\n for row, column in self.previous_objects:\n if 0 <= row < 10 and 0 <= column < 10:\n state[row, column, 4] = True\n values = (\n (self.era, 3),\n (self.heading, 3),\n (self.previous_heading, 3),\n (self.lives, 5),\n (self.spawned, 6),\n (self.killed, 6),\n (self.steps, 13),\n (0 if self.boss is None else self.boss[\"hp\"], 3),\n )\n offset = 0\n for value, width in values:\n for bit in range(width):\n index = offset + bit\n state[index // 10, index % 10, 5] = bool(value & (1 << bit))\n offset += width\n for enemy_id in self.formation_destroyed:\n state[5, enemy_id - 20, 5] = True\n state[5, 5, 5] = self.formation_failed\n state[5, 6, 5] = self.special_spawned\n state[5, 7, 5] = self.special_destroyed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 139, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/time_pilot.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "vh_walls", "split": "train", "game": "vh_walls", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Vh Walls as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nMove the cursor with actions 1–4 (left, up, right, down). Tap\naction 5 to place a wall and alternate between vertical and\nhorizontal. Release with any other action before placing again.\nUse walls to bounce the ball into the target ring. A hit scores\none point per placed wall still on the board. A wall intersecting\nan active ring ends the run. A newly forming ring or a newer wall\ncan remove a placed wall on overlap.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the ball, vertical walls, horizontal walls,\ntarget, cursor, and counters. The cursor moves five units per action\nin place of pointer input. The port fixes difficulty and uses\ngeometric collision checks. Each action advances up to four frames\nover 400 actions. Clip episode scores to [0, 100] and divide by 100.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/vh_walls.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import hypot\n\nimport numpy as np\n\n\n@dataclass\nclass Wall:\n x: float\n y: float\n horizontal: bool\n fixed: bool = False\n\n def bounds(self):\n length = 50 if self.fixed else 10\n return (length, 1) if self.horizontal else (1, length)\n\n\nclass VhWallsEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.walls = [Wall(1, 50, False, True), Wall(99, 50, False, True),\n Wall(50, 1, True, True), Wall(50, 99, True, True)]\n self.x = self.y = self.cursor_x = self.cursor_y = 50.\n self.vx = self.vy = 1\n self.horizontal = False\n self.target_x = self.target_y = 50.\n self._new_target()\n self.steps = self.action = 0\n self.terminal = False\n\n def _new_target(self):\n previous = self.target_x, self.target_y\n for _ in range(9):\n self.target_x, self.target_y = self.random.uniform(20, 80, 2)\n if hypot(self.target_x - previous[0], self.target_y - previous[1]) > 40:\n break\n self.radius = 20.\n self.warmup = 16\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n dx, dy = {1: (-5, 0), 2: (0, -5), 3: (5, 0), 4: (0, 5)}.get(self.action, (0, 0))\n self.cursor_x = min(98, max(1, self.cursor_x + dx))\n self.cursor_y = min(98, max(1, self.cursor_y + dy))\n place = self.action == 5 and previous != 5\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(place and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, place):\n self.x = min(99, max(1, self.x + self.vx))\n self.y = min(99, max(1, self.y + self.vy))\n if place:\n self.walls.insert(0, Wall(self.cursor_x, self.cursor_y, self.horizontal))\n self.horizontal = not self.horizontal\n warming = self.warmup > 0\n target = self.target_x, self.target_y, self.radius\n reward = 0\n if warming:\n self.warmup -= 1\n self.radius += (5 - self.radius) * 0.2\n elif _hits_ring(target, self.x, self.y, 2.5, 2.5):\n reward = len(self.walls) - 4\n self._new_target()\n self.radius += 0.02\n else:\n self.radius += 0.02\n\n remaining = []\n ball_x, ball_y = self.x, self.y\n for wall in self.walls:\n width, height = wall.bounds()\n hits_target = _hits_ring(target, wall.x, wall.y, width, height)\n if not wall.fixed and ((warming and hits_target) or any(\n _walls_overlap(wall, other) for other in remaining if not other.fixed\n )):\n continue\n if not warming and hits_target:\n self.terminal = True\n if abs(wall.x - ball_x) < width + 2.5 and abs(wall.y - ball_y) < height + 2.5:\n if wall.horizontal:\n self.vy *= -1\n self.y = wall.y + self.vy * 4\n else:\n self.vx *= -1\n self.x = wall.x + self.vx * 4\n remaining.append(wall)\n self.walls = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n _mark(state, self.x, self.y, 0)\n for wall in self.walls:\n width, height = wall.bounds()\n state[:, :, 2 if wall.horizontal else 1] |= (\n (abs(cols - wall.x) < width + 5) & (abs(rows - wall.y) < height + 5)\n )\n ring = abs(np.hypot(cols - self.target_x, rows - self.target_y) - self.radius) <= 6\n state[:, :, 3] = ring\n _mark(state, self.cursor_x, self.cursor_y, 4)\n values = (self.steps, self.action, self.horizontal, self.vx > 0, self.vy > 0,\n self.warmup, round(self.radius * 16), len(self.walls) - 4)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n\ndef _hits_ring(target, x, y, width, height):\n tx, ty, radius = target\n dx, dy = abs(x - tx), abs(y - ty)\n near = hypot(max(0, dx - width), max(0, dy - height))\n far = hypot(dx + width, dy + height)\n return near <= radius + 1 and far >= radius - 1\n\n\ndef _walls_overlap(first, second):\n aw, ah = first.bounds()\n bw, bh = second.bounds()\n return abs(first.x - second.x) < aw + bw and abs(first.y - second.y) < ah + bh\n\n\ndef _mark(state, x, y, channel):\n state[int(np.clip(y // 10, 0, 9)), int(np.clip(x // 10, 0, 9)), channel] = True\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 140, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/vh_walls.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/vhwalls/main.js"} +{"name": "gravitar", "split": "train", "game": "gravitar", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Gravitar as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves Gravitar's two-layer campaign. On the solar-system map, the pilot\nselects one of three blockaded planets or the alien reactor base. Planet missions use rotational\nsteering, thrust, persistent velocity, and gravity. The ship destroys three firing bunkers per\nplanet, uses its tractor beam to recover finite 5,000-unit fuel depots, and must avoid terrain and\nenemy shots. Clearing all three planets advances the solar system. Alternatively, the pilot can\nenter the spiral-like reactor basin, shoot the core, and escape through the top before its\ncountdown expires.\n\nThe campaign contains the manual's four galaxies of three solar systems. Gravity reverses in the\nsecond and fourth galaxies. The ship begins with six lives and 10,000 fuel; thrust costs 25 fuel,\nand the combined shield/tractor action costs 10. Each cleared system grants 4,000 points, 7,000\nfuel, and two ships. Score thresholds grant another ship every 10,000 points. Running out of fuel\nor ships ends the episode.\n\nACTION MAPPING\n0: noop / coast\n1: previous destination / rotate left\n2: enter destination / thrust\n3: next destination / rotate right\n4: enter destination / shield and tractor beam\n5: enter destination / fire missile\n\nINPUT CHANNEL TABLE\n0: ship\n1: bunkers and hostile shots\n2: fuel depots and inactive reactor core\n3: player missile and active shield\n4: previous ship position and terrain\n5: exact system, lives, fuel bucket, heading, selected destination, completed planets, velocity, mode, gravity direction, and reactor state\n\nSCORING, TERMINATION, AND HORIZON\nEach planet has three 250-point bunkers and at most a 2,000-point completion bonus, for 2,750.\nClearing all three planets and the system therefore yields at most\n`3 × 2,750 + 4,000 = 12,250`. The reactor shortcut cannot add more: even after partially clearing\nthe planets, its two persistent bunkers and 4,000 system award remain below the all-planets path.\nAcross 12 systems, `score_cap = 12 × 12,250 = 147,000`. Normalization is\n`min(max(raw_score, 0), 147_000) / 147_000`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/gravitar.py`):\n```python\nimport numpy as np\n\n\nHEADINGS = ((-1, 0), (0, 1), (1, 0), (0, -1))\nPLANET_LAYOUTS = (\n (7, 7, 6, 6, 7, 8, 8, 7, 7, 6),\n (8, 7, 7, 6, 5, 5, 6, 7, 8, 8),\n (6, 6, 7, 8, 8, 7, 6, 5, 5, 6),\n)\n\n\nclass GravitarEnvironment:\n \"\"\"Finite twelve-system gravity, fuel, bunker, and reactor campaign.\"\"\"\n\n score_cap = 147_000.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 10_800):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.mode = \"map\"\n self.system = 0\n self.completed_planets: set[int] = set()\n self.selected_destination = 0\n self.lives = 6\n self.fuel = 10_000\n self.score = 0.0\n self.next_bonus_score = 10_000.0\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self.player = [5, 5]\n self.previous_player = self.player.copy()\n self.heading = 0\n self.velocity = [0, 0]\n self.projectile: list[int] | None = None\n self.projectile_heading = 0\n self.shield_active = False\n self.enemy_projectiles: list[list[int]] = []\n self.bunkers: set[tuple[int, int]] = set()\n self.fuel_depots: set[tuple[int, int]] = set()\n self.terrain = PLANET_LAYOUTS[0]\n self.mission_steps = 0\n self.reactor_activated = False\n self.reactor_countdown = 0\n self.destroyed_bunkers: set[tuple[int, int, int, int]] = set()\n self.collected_depots: set[tuple[int, int, int, int]] = set()\n\n @property\n def reverse_gravity(self) -> bool:\n return (self.system // 3) % 2 == 1\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n reward = self._act_map(action) if self.mode == \"map\" else self._act_flight(action)\n self.score += reward\n while self.score >= self.next_bonus_score:\n self.lives = min(30, self.lives + 1)\n self.next_bonus_score += 10_000.0\n self.steps += 1\n if self.steps >= self.horizon or self.fuel <= 0 or self.lives <= 0:\n self.terminal = True\n return reward, self.terminal\n\n def _act_map(self, action: int) -> float:\n if action == 1:\n self.selected_destination = (self.selected_destination - 1) % 4\n elif action == 3:\n self.selected_destination = (self.selected_destination + 1) % 4\n elif action in (2, 4, 5):\n if self.selected_destination == 3:\n self._enter_reactor()\n elif self.selected_destination not in self.completed_planets:\n self._enter_planet(self.selected_destination)\n return 0.0\n\n def _enter_planet(self, planet: int) -> None:\n self.mode = \"planet\"\n self.terrain = PLANET_LAYOUTS[planet]\n bunker_columns = ((1, 5, 8), (0, 4, 9), (2, 6, 8))[planet]\n bunkers = {(self.terrain[column] - 1, column) for column in bunker_columns}\n self.bunkers = {\n bunker for bunker in bunkers if (self.system, planet, *bunker) not in self.destroyed_bunkers\n }\n depot_columns = ((3, 7), (2, 7), (1, 6))[planet]\n depots = {(self.terrain[column] - 1, column) for column in depot_columns}\n self.fuel_depots = {\n depot for depot in depots if (self.system, planet, *depot) not in self.collected_depots\n }\n self._reset_ship()\n\n def _enter_reactor(self) -> None:\n self.mode = \"reactor\"\n self.terrain = (9, 8, 7, 6, 5, 5, 6, 7, 8, 9)\n bunkers = {(6, 2), (6, 7)}\n self.bunkers = {\n bunker for bunker in bunkers if (self.system, 3, *bunker) not in self.destroyed_bunkers\n }\n self.fuel_depots = set()\n self.reactor_activated = False\n self.reactor_countdown = max(20, 60 - 3 * self.system)\n self._reset_ship()\n\n def _reset_ship(self) -> None:\n self.player = [1, 5]\n self.previous_player = self.player.copy()\n self.heading = 2\n self.velocity = [0, 0]\n self.projectile = None\n self.shield_active = False\n self.enemy_projectiles = []\n self.mission_steps = 0\n\n def _act_flight(self, action: int) -> float:\n self.previous_player = self.player.copy()\n self.shield_active = False\n if action == 1:\n self.heading = (self.heading - 1) % 4\n elif action == 3:\n self.heading = (self.heading + 1) % 4\n elif action == 2:\n self._thrust()\n elif action == 4:\n self.shield_active = self.fuel >= 10\n self._tractor()\n elif action == 5 and self.projectile is None:\n self.projectile = self.player.copy()\n self.projectile_heading = self.heading\n reward = self._move_projectiles()\n if self.mode == \"map\":\n return reward\n if self.mode == \"reactor\" and self.reactor_activated and self.player[0] == 0:\n return reward + self._advance_system()\n self._apply_gravity_and_move()\n if self.mode == \"map\":\n return reward\n reward += self._move_enemy_projectiles()\n if self.mode == \"map\":\n return reward\n self._fire_bunkers()\n self.mission_steps += 1\n if self.mode == \"reactor\" and self.reactor_activated:\n self.reactor_countdown -= 1\n if self.reactor_countdown <= 0:\n self._lose_ship()\n return reward\n\n def _thrust(self) -> None:\n if self.fuel < 25:\n return\n direction = HEADINGS[self.heading]\n self.velocity[0] = int(np.clip(self.velocity[0] + direction[0], -2, 2))\n self.velocity[1] = int(np.clip(self.velocity[1] + direction[1], -2, 2))\n self.fuel -= 25\n\n def _tractor(self) -> None:\n if self.fuel < 10:\n return\n self.fuel -= 10\n nearby = [depot for depot in self.fuel_depots if abs(depot[0] - self.player[0]) + abs(depot[1] - self.player[1]) <= 2]\n if nearby:\n depot = min(nearby)\n self.fuel_depots.remove(depot)\n self.collected_depots.add((self.system, self.selected_destination, *depot))\n self.fuel = min(20_000, self.fuel + 5_000)\n\n def _move_projectiles(self) -> float:\n if self.projectile is None:\n return 0.0\n direction = HEADINGS[self.projectile_heading]\n self.projectile[0] += direction[0]\n self.projectile[1] += direction[1]\n position = tuple(self.projectile)\n if position in self.bunkers:\n self.bunkers.remove(position)\n destination = self.selected_destination if self.mode == \"planet\" else 3\n self.destroyed_bunkers.add((self.system, destination, *position))\n self.projectile = None\n reward = 250.0\n if self.mode == \"planet\" and not self.bunkers:\n reward += self._complete_planet()\n return reward\n if self.mode == \"reactor\" and position == (4, 5):\n self.reactor_activated = True\n self.projectile = None\n return 0.0\n if not (0 <= position[0] < 10 and 0 <= position[1] < 10):\n self.projectile = None\n elif position[0] >= self.terrain[position[1]]:\n self.projectile = None\n return 0.0\n\n def _apply_gravity_and_move(self) -> None:\n gravity = -1 if self.reverse_gravity else 1\n if self.mission_steps % 2 == 0:\n self.velocity[0] = int(np.clip(self.velocity[0] + gravity, -2, 2))\n self.player[0] += int(np.sign(self.velocity[0]))\n self.player[1] += int(np.sign(self.velocity[1]))\n if self.player[0] < 0:\n if self.mode == \"planet\":\n self.player[0] = 0\n self.velocity[0] = 0\n else:\n self.player[0] = 0\n return\n if self.player[1] < 0 or self.player[1] > 9 or self.player[0] > 9:\n self._lose_ship()\n return\n if self.player[0] >= self.terrain[self.player[1]]:\n self._lose_ship()\n\n def _move_enemy_projectiles(self) -> float:\n moved = []\n for projectile in self.enemy_projectiles:\n projectile[0] += int(np.sign(self.player[0] - projectile[0]))\n projectile[1] += int(np.sign(self.player[1] - projectile[1]))\n if projectile == self.player:\n if self.shield_active:\n continue\n self._lose_ship()\n return 0.0\n if 0 <= projectile[0] < 10 and 0 <= projectile[1] < 10:\n moved.append(projectile)\n self.enemy_projectiles = moved\n return 0.0\n\n def _fire_bunkers(self) -> None:\n if self.mission_steps % 12 or not self.bunkers:\n return\n bunker = min(self.bunkers, key=lambda item: abs(item[1] - self.player[1]))\n self.enemy_projectiles.append(list(bunker))\n\n def _complete_planet(self) -> float:\n planet = self.selected_destination\n self.completed_planets.add(planet)\n bonus = float(max(0, 2_000 - 10 * self.mission_steps))\n self.mode = \"map\"\n self.player = [5, 5]\n if len(self.completed_planets) == 3:\n bonus += self._advance_system()\n return bonus\n\n def _advance_system(self) -> float:\n self.system += 1\n self.completed_planets = set()\n self.mode = \"map\"\n self.player = [5, 5]\n self.selected_destination = 0\n self.fuel = min(20_000, self.fuel + 7_000)\n self.lives = min(30, self.lives + 2)\n if self.system >= 12:\n self.terminal = True\n return 4_000.0\n\n def _lose_ship(self) -> None:\n self.lives -= 1\n self.mode = \"map\"\n self.player = [5, 5]\n self.velocity = [0, 0]\n self.projectile = None\n self.enemy_projectiles = []\n if self.lives <= 0:\n self.terminal = True\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n for bunker in self.bunkers:\n state[*bunker, 1] = True\n for projectile in self.enemy_projectiles:\n state[*projectile, 1] = True\n for depot in self.fuel_depots:\n state[*depot, 2] = True\n if self.mode == \"reactor\" and not self.reactor_activated:\n state[4, 5, 2] = True\n if self.projectile is not None:\n state[*self.projectile, 3] = True\n if self.shield_active:\n state[*self.player, 3] = True\n state[*self.previous_player, 4] = True\n if self.mode != \"map\":\n for column, floor in enumerate(self.terrain):\n state[floor:, column, 4] = True\n for bit in range(4):\n state[9, bit, 5] = bool(self.system & (1 << bit))\n for bit in range(5):\n state[8, bit, 5] = bool(self.lives & (1 << bit))\n fuel_bucket = min(31, self.fuel // 625)\n for bit in range(5):\n state[7, bit, 5] = bool(fuel_bucket & (1 << bit))\n state[6, self.heading, 5] = True\n state[5, self.selected_destination, 5] = True\n for planet in self.completed_planets:\n state[4, planet, 5] = True\n state[3, self.velocity[0] + 2, 5] = True\n state[2, self.velocity[1] + 2, 5] = True\n state[1, 0, 5] = self.mode == \"map\"\n state[1, 1, 5] = self.mode == \"planet\"\n state[1, 2, 5] = self.mode == \"reactor\"\n state[1, 3, 5] = self.reverse_gravity\n state[1, 4, 5] = self.reactor_activated\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 141, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/gravitar.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "up_1_way", "split": "train", "game": "up_1_way", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Up 1 Way as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to climb one floor. Release with any other action\nbefore tapping again. The stage scrolls automatically. Gaps drop\nthe runner one floor, bamboo scores one point, and skulls end the\nrun. A power-up turns all current skulls into bamboo.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the runner, gaps, bamboo, skulls, power-ups,\nand counters. The 200×100 stage is represented by 20×10-unit cells.\nDifficulty is fixed, and distance checks approximate sprite overlap.\nEach action advances up to four frames over 400 actions. Clip the\nepisode score to [0, 100] and divide by 100.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/up_1_way.py`):\n```python\nfrom dataclasses import dataclass, field\n\nimport numpy as np\n\n\n@dataclass\nclass Floor:\n holes: list[float] = field(default_factory=list)\n timer: float = float(\"inf\")\n bamboo: list[float] = field(default_factory=list)\n skulls: list[float] = field(default_factory=list)\n powerups: list[float] = field(default_factory=list)\n\n\ndef _height(index):\n return 16 + 15 * index\n\n\nclass Up1WayEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.floors = [Floor([self.random.uniform(99, 180)], self.random.uniform(0, 99))\n for _ in range(5)] + [Floor()]\n self.floor = 5\n self.target = None\n self.y = _height(5)\n self.bamboo_timer = 0.\n self.bamboo_floor = int(self.random.integers(6))\n self.skull_timer = self.random.uniform(49, 99)\n self.power_timer = 999\n self.action = self.steps = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n jump = self.action == 5 and previous != 5\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(jump and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, jump):\n if self.target is not None:\n height = _height(self.target)\n if abs(height - self.y) < 3:\n self.floor, self.target = self.target, None\n self.y = height\n else:\n self.y += 3 if height > self.y else -3\n if self.target is None:\n if jump and self.floor > 0:\n self.target = self.floor - 1\n elif any(14 < hole < 17 for hole in self.floors[self.floor].holes):\n self.target = self.floor + 1\n self._spawn_items()\n reward = 0\n for index, floor in enumerate(self.floors):\n floor.timer -= 1\n if floor.timer < 0:\n floor.holes.append(200)\n floor.timer = self.random.uniform(32, 99)\n floor.holes = [x - 1 for x in floor.holes if x >= -8]\n near_player = abs(self.y - _height(index)) < 5\n if near_player:\n reward += sum(abs(x - 20) < 5 for x in floor.bamboo)\n floor.bamboo = [x for x in floor.bamboo if abs(x - 20) >= 5]\n if any(abs(x - 20) < 5 for x in floor.powerups):\n floor.powerups = [x for x in floor.powerups if abs(x - 20) >= 5]\n for level in self.floors:\n level.bamboo.extend(level.skulls)\n level.skulls.clear()\n self.terminal |= any(abs(x - 20) < 5 for x in floor.skulls)\n floor.bamboo = [x - 1 for x in floor.bamboo if x >= -2]\n floor.powerups = [x - 1 for x in floor.powerups if x >= -2]\n floor.skulls = [x - 1 for x in floor.skulls if x >= -2 and\n all(abs(x - item - 1) >= 5 for item in floor.bamboo + floor.powerups)]\n return reward\n\n def _spawn_items(self):\n self.bamboo_timer -= 1\n if self.bamboo_timer < 0:\n floor = self.floors[self.bamboo_floor]\n if floor.timer < 9:\n self.bamboo_floor = int(self.random.integers(6))\n else:\n floor.bamboo.append(209)\n if self.random.random() < 0.3:\n self.bamboo_timer = 6\n else:\n self.bamboo_timer = self.random.uniform(200, 300)\n self.bamboo_floor = int(self.random.integers(6))\n self.skull_timer -= 1\n if self.skull_timer < 0:\n floor = self.floors[int(self.random.integers(6))]\n if floor.timer > 9 and self.bamboo_timer > 9:\n floor.skulls.append(209)\n self.skull_timer += self.random.uniform(30, 50)\n self.power_timer -= 1\n if self.power_timer < 0:\n self.floors[int(self.random.integers(6))].powerups.append(209)\n self.power_timer = 999\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[(self.y - 5) // 10, 1, 0] = True\n for index, floor in enumerate(self.floors):\n row = (_height(index) - 5) // 10\n for channel, items in enumerate((floor.holes, floor.bamboo, floor.skulls, floor.powerups), 1):\n for x in items:\n if 0 <= x < 200:\n state[row, int(x // 20), channel] = True\n values = (self.steps, self.action, self.floor, 0 if self.target is None else self.target + 1,\n self.y, round(self.bamboo_timer), round(self.skull_timer), self.power_timer)\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 142, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/up_1_way.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-11-games/blob/6fea4eefe2deaa42706051d96a04ec9e36104696/docs/up1way/main.js"} +{"name": "monjum", "split": "train", "game": "monjum", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Monjum as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to move back on the ground. Release with\nactions 0–4 to jump. Clear gaps, pass monsters, and collect\ncoins during a jump. Landing scores 1, 5, or 20 points\nfor one, two, or three distinct categories. Touching a\nmonster or falling below the screen ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, floor, monsters,\ncoins, projected height, and gauges. The conversion uses\nrectangular collision bounds and four frames per action at\nfixed difficulty. The 400-action task clips raw scores to\n[0, 200] and divides by 200.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/monjum.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Monster:\n x: float = 99\n y: float = 87\n vy: float = 0\n jumping: bool = False\n\n\nclass MonjumEnvironment:\n score_cap = 200\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 50.0, 87.0\n self.vx = self.vy = 0.0\n self.floor_timer = self.monster_timer = self.coin_timer = 0.0\n self.floors = [(0.0, 99.0)]\n self.monsters: list[Monster] = []\n self.coins: list[float] = []\n self.steps = self.frames = self.items = 0\n self.pressed = self.jumping = self.falling = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n release = self.pressed and not pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(release and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _ground(self, x):\n return any(start - 3 < x < start + width + 3 for start, width in self.floors)\n\n def _advance(self, release):\n self.floor_timer -= 0.5\n if self.floor_timer < 0:\n width = int(self.random.integers(50, 90))\n self.floors.append((110, width))\n self.floor_timer += 10 + width\n self.floors = [(x - 0.5, w) for x, w in self.floors if x - 0.5 + w > 0]\n self.monster_timer -= 1\n if self.monster_timer < 0:\n self.monsters.append(Monster())\n self.monster_timer += self.random.uniform(200, 300)\n for monster in self.monsters:\n monster.x -= 0.75\n monster.y += monster.vy\n if monster.jumping:\n monster.vy += 0.09\n if monster.y > 87:\n monster.y, monster.vy, monster.jumping = 87, 0, False\n elif not self._ground(monster.x - 4):\n monster.jumping, monster.vy = True, -1.4\n if abs(monster.x - self.x) < 5:\n self.terminal |= abs(monster.y - self.y) < 5\n self.items |= 2 if abs(monster.y - self.y) < 27 else 0\n self.monsters = [monster for monster in self.monsters if monster.x > -3]\n self.coin_timer -= 1\n if self.coin_timer < 0:\n self.coins.append(99)\n self.coin_timer += self.random.uniform(50, 100)\n remaining = []\n for x in self.coins:\n x -= 1\n if abs(x - self.x) < 5 and abs(self.y - 60) < 5:\n self.items |= 4\n elif x > -3:\n remaining.append(x)\n self.coins = remaining\n gap = not self._ground(self.x)\n if gap:\n self.items |= 1\n reward = 0\n if self.falling:\n self.vy += 0.14\n self.terminal |= self.y > 99\n elif self.jumping:\n self.vy += 0.12\n if self.y > 87:\n self.y, self.vy = 87, 0\n if gap:\n self.falling = True\n else:\n self.jumping = False\n reward = (0, 1, 5, 20)[self.items.bit_count()]\n else:\n self.falling = gap\n self.vx = -0.5 if self.pressed else 0\n if not self.pressed:\n self.x += (50 - self.x) * 0.02\n if release and self.frames > 5:\n self.vy, self.jumping, self.items = -2.5, True, 0\n self.x = min(50, max(0, self.x + self.vx))\n self.y += self.vy\n self.frames += 1\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, int(self.y // 10)), int(self.x // 10), 0] = True\n for x, width in self.floors:\n state[9, max(0, int(x // 10)):min(9, int((x + width) // 10)) + 1, 1] = True\n for monster in self.monsters:\n if 0 <= monster.x < 100:\n state[int(monster.y // 10), int(monster.x // 10), 2] = True\n for x in self.coins:\n if 0 <= x < 100:\n state[6, int(x // 10), 3] = True\n state[min(9, max(0, int((self.y + 4 * self.vy) // 10))), int(self.x // 10), 4] = True\n for row, value in enumerate((self.steps, self.items, round((self.vy + 3) * 60))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :3, 5] = self.pressed, self.jumping, self.falling\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 143, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/monjum.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/monjum/main.js"} +{"name": "rocket_trail", "split": "train", "game": "rocket_trail", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Rocket Trail as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to thrust. Actions 0–4 release. The rocket tilts\nautomatically as it moves between the center bounds. Destroy\nasteroids with the flame trail or fuel particles to score the\ncurrent multiplier and raise it by one, up to 16. A body hit\nknocks the rocket down and resets the multiplier. A missed\nasteroid reduces it by one. Leaving the top or bottom ends play.\n\nINPUT CHANNEL TABLE\nThe six channels show the rocket, flame trail, fuel particles,\nasteroids, thrust direction, and counters. The port uses fixed\ndifficulty, samples the rocket body for collisions, and omits\ndecorative stars. Each action advances up to four frames over a\n400-action horizon. Clip episode scores to [0, 200] and divide\nby 200.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/rocket_trail.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import atan2, cos, pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Particle:\n x: float\n y: float\n vx: float\n vy: float\n life: int = 0\n\n def move(self):\n self.x += self.vx\n self.y += self.vy\n self.life -= 1\n\n\nclass RocketTrailEnvironment:\n score_cap = 200\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 50., 65.\n self.vx = self.vy = 0.\n self.angle = pi / 2\n self.direction = self.multiplier = 1\n self.steps = self.timer = 0\n self.interval = 60\n self.held = self.terminal = False\n self.flames = []\n self.fuel = []\n self.asteroids = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.held = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n self.vx *= 0.95\n self.vy = (self.vy + 0.1) * 0.98\n if self.x <= 45:\n self.direction = 1\n elif self.x >= 55:\n self.direction = -1\n self.angle += (pi / 2 + self.direction - self.angle) * 0.05\n dx, dy = cos(self.angle), sin(self.angle)\n if self.held:\n self.vx -= 0.3 * dx\n self.vy -= 0.3 * dy\n if self.random.random() < 0.3:\n angle = self.angle + self.random.uniform(-0.5, 0.5)\n self.fuel.append(Particle(self.x, self.y, 1.8 * cos(angle), 1.8 * sin(angle), 20))\n self.x += self.vx\n self.y += self.vy\n self.flames.append(Particle(self.x, self.y, 2.1 * dx, 2.1 * dy, 25))\n self.x = min(99, max(1, self.x))\n self.terminal = self.y < 0 or self.y > 105\n for particle in (*self.flames, *self.fuel):\n particle.move()\n self.flames = [particle for particle in self.flames if particle.life > 0]\n self.fuel = [particle for particle in self.fuel if particle.life > 0]\n self.timer += 1\n if not self.asteroids or self.timer >= self.interval:\n x = self.random.uniform(5, 95)\n angle = atan2(104, self.random.uniform(20, 80) - x)\n speed = self.random.uniform(0.3, 0.5)\n self.asteroids.append(Particle(x, -5, speed * cos(angle), speed * sin(angle)))\n self.timer = 0\n self.interval = 80 - self.random.uniform(-30, 30)\n reward = 0\n remaining = []\n for asteroid in self.asteroids:\n asteroid.move()\n if any(self._overlap(asteroid, flame, 3.5 - (25 - flame.life) / 40)\n for flame in self.flames) or any(\n self._overlap(asteroid, fuel, 2.5) for fuel in self.fuel\n ):\n reward += self.multiplier\n self.multiplier = min(16, self.multiplier + 1)\n elif any(abs(asteroid.x - (self.x - offset * dx)) < 3\n and abs(asteroid.y - (self.y - offset * dy)) < 3 for offset in range(6)):\n self.vy += 2\n self.multiplier = 1\n elif asteroid.y > 105:\n self.multiplier = max(1, self.multiplier - 1)\n else:\n remaining.append(asteroid)\n self.asteroids = remaining\n return reward\n\n @staticmethod\n def _overlap(asteroid, particle, reach):\n return abs(asteroid.x - particle.x) < reach and abs(asteroid.y - particle.y) < reach\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(np.clip(self.y // 10, 0, 9)), int(self.x // 10), 0] = True\n for channel, particles in ((1, self.flames), (2, self.fuel), (3, self.asteroids)):\n for particle in particles:\n if 0 <= particle.x < 100 and 0 <= particle.y < 100:\n state[int(particle.y // 10), int(particle.x // 10), channel] = True\n x = self.x - 12 * cos(self.angle)\n y = self.y - 12 * sin(self.angle)\n state[int(np.clip(y // 10, 0, 9)), int(np.clip(x // 10, 0, 9)), 4] = True\n for row, value in enumerate((self.steps, self.multiplier, self.held,\n round(self.angle * 100), round((self.vy + 16) * 16))):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 144, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/rocket_trail.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameRocketTrail.c"} +{"name": "kite_master", "split": "train", "game": "kite_master", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Kite Master as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to reel in the line and lift the kite. Release\nwith actions 0–4 to let wind and tension move it. Intercept\ndescending clouds with the kite or the player. A cloud\nscores 100 minus its vertical position, so earlier catches\nscore more. A missed cloud or a kite dropping too low ends\nthe run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, kite, cloud, line,\nground, and gauges. The conversion omits the cosmetic tail\nand approximates sprite collisions geometrically. It uses\nfixed difficulty and four frames per action. The 400-action\ntask clips raw scores to [0, 500] and divides by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/kite_master.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Cloud:\n x: float\n y: float\n vx: float\n\n\nclass KiteMasterEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x, self.y = 35.0, 70.0\n self.vx = self.vy = 0.0\n self.line_length = 20.0\n self.wind = 1.0\n self.steps = self.frames = 0\n self.pressed = self.terminal = False\n self.cloud: Cloud | None = None\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0.0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _advance(self) -> float:\n self.wind = 1 + 0.5 * math.sin(self.frames * 0.01)\n self.frames += 1\n dx, dy = self.x - 20, self.y - 87\n distance = math.hypot(dx, dy)\n if self.pressed:\n self.line_length = max(5, self.line_length - 0.2)\n if distance > self.line_length:\n self.line_length = min(120, self.line_length + self.wind * 0.1)\n tension = max(0, distance - self.line_length) * 0.1\n radial_force = (self.wind * 0.81 - tension) / distance if distance else 0\n fx = dx * radial_force + self.wind * 0.19\n fy = dy * radial_force + 0.3 - self.pressed\n self.vx = (self.vx + fx * 0.02) * 0.98\n self.vy = (self.vy + fy * 0.02) * 0.98\n self.x = min(95, max(5, self.x + self.vx))\n self.y = min(95, max(5, self.y + self.vy))\n if self.cloud is None:\n self.cloud = Cloud(self.random.uniform(25, 75), -5, self.random.uniform(-0.1, 0.1))\n cloud = self.cloud\n cloud.x += cloud.vx\n cloud.y += 0.15\n if (cloud.x <= 20 and cloud.vx < 0) or (cloud.x >= 80 and cloud.vx > 0):\n cloud.vx *= -1\n if cloud.y > 90:\n self.terminal = True\n return 0.0\n reward = 0.0\n if self._collects(cloud):\n reward = 100 - cloud.y\n self.cloud = None\n self.terminal = self.y > 85\n return reward\n\n def _collects(self, cloud: Cloud) -> bool:\n angle = math.atan2(self.y - 87, self.x - 20) + self.wind * 0.3 + math.pi / 2\n cosine, sine = math.cos(angle), math.sin(angle)\n for offset in (-3, 3):\n cx = cloud.x + offset\n dx, dy = cx - self.x, cloud.y - self.y\n along = min(6, max(-6, dx * cosine + dy * sine))\n if math.hypot(dx - along * cosine, dy - along * sine) < 6:\n return True\n if abs(cx - 20) < 7 and abs(cloud.y - 87) < 7:\n return True\n return False\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[8, 2, 0] = True\n state[int(self.y) // 10, int(self.x) // 10, 1] = True\n if self.cloud is not None and 0 <= self.cloud.y < 100:\n state[int(self.cloud.y) // 10, int(self.cloud.x) // 10, 2] = True\n for fraction in np.linspace(0, 1, 12):\n x = 20 + fraction * (self.x - 20)\n y = 87 + fraction * (self.y - 87)\n state[int(y) // 10, int(x) // 10, 3] = True\n state[9, :, 4] = True\n values = (self.steps, round(self.line_length * 4), round(self.wind * 100),\n round((self.vx + 3) * 80), round((self.vy + 3) * 80))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(min(511, max(0, value)) & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 145, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/kite_master.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameKiteMaster.c"} +{"name": "charge_beam", "split": "train", "game": "charge_beam", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Charge Beam as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to charge and release with actions 0–4 to fire.\nA full charge fires automatically. Small shots stop on contact.\nCharged shots can pierce targets, but large enemies consume beam\npower or survive a weak hit. An enemy reaching the ship ends the run.\n\nDestroy enemies for rising combo rewards. Coins ahead of the first\nenemy drift toward the ship and build a doubling pickup bonus.\nShooting coins subtracts points and speeds up approaching targets.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the ship, enemy sizes, coins, incoming\ncoins under suction, the beam, and gauges. Each action advances\nfour frames at fixed difficulty. The conversion uses a single lane\nwith interval collisions in place of staggered sprites.\n\nSCORING, TERMINATION, AND HORIZON\nThe benchmark sums signed points within each episode, clips the mean\nepisode score to [0, 500], and divides by 500. Across 100 seeds without\nsticky actions, idle averaged zero, random inputs averaged 33.72,\nand continuous charge averaged −126.60. A policy that sized the shot\nfor the nearest enemy averaged 263.84 and reached 804 before clipping.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/charge_beam.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Target:\n x: float\n size: int = 1\n coin: bool = False\n suction: float = 0\n\n\nclass ChargeBeamEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.power = 0\n self.pressed = self.terminal = self.last_coin = False\n self.charge = self.penalty = 0.0\n self.spawn_distance = 30.0\n self.shot: float | None = None\n self.coin_combo = self.enemy_combo = self.penalty_combo = 1\n self.targets = [Target(150)] + [Target(x, coin=True) for x in (160, 170, 180)]\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance_frame()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self) -> int:\n if self.shot is None:\n if self.pressed and self.charge < 99:\n self.charge += 1.5\n elif self.charge:\n self.power = 1 + math.ceil(max(0, self.charge - 25) / 9)\n self.shot, self.charge = 10.0, 0.0\n self.coin_combo = self.enemy_combo = self.penalty_combo = 1\n if self.shot is not None:\n self.shot += 2.5\n if self.shot > 203:\n self.shot = None\n\n self.penalty = max(0, self.penalty - 0.02)\n speed = (1 + self.penalty) * 0.5\n self.spawn_distance -= speed\n if self.spawn_distance < 0:\n self._spawn_wave()\n\n for target in self.targets:\n target.x -= target.suction or speed\n if target.suction:\n target.suction += 0.1\n first_enemy = min((target.x for target in self.targets if not target.coin), default=math.inf)\n\n reward = 0\n survivors = []\n for target in self.targets:\n if self._shot_hits(target):\n spent = self.power == 1\n if target.coin:\n reward -= self.penalty_combo\n self.penalty_combo = min(64, self.penalty_combo * 2)\n self.penalty += 0.5\n if spent:\n self.shot = None\n continue\n if target.size <= self.power:\n reward += target.size * self.enemy_combo\n self.enemy_combo += 1\n if target.size > 1:\n self.power -= target.size\n if spent or not self.power:\n self.shot = None\n continue\n target.size -= self.power\n self.shot = None\n if target.coin:\n if target.suction and target.x < 10:\n reward += self.coin_combo\n self.coin_combo = min(64, self.coin_combo * 2)\n continue\n if not target.suction and target.x < first_enemy:\n target.suction = 1\n elif target.x < 15:\n self.terminal = True\n survivors.append(target)\n self.targets = survivors\n if not any(target.x <= 200 and not target.suction for target in self.targets):\n self.spawn_distance = 0\n return reward\n\n def _shot_hits(self, target: Target) -> bool:\n return self.shot is not None and (\n self.shot - 5 <= target.x + 3 * (target.size - 1)\n and target.x - 5 <= self.shot + 3 * (self.power - 1)\n )\n\n def _spawn_wave(self) -> None:\n self.last_coin = not self.last_coin and self.random.random() < 0.5\n x = 200\n for _ in range(int(self.random.integers(3, 9))):\n size = 1\n if not self.last_coin and self.random.random() < 0.3:\n size = int(self.random.integers(2, 6))\n self.targets.append(Target(x, size, self.last_coin))\n x += 10 + math.ceil((size - 1) / 2) * 6\n self.spawn_distance = x - 190\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[5, 0, 0] = True\n for target in self.targets:\n if 0 <= target.x < 200:\n col = int(target.x) // 20\n if target.coin:\n state[5, col, 3 if target.suction else 2] = True\n else:\n state[6 - target.size:6, col, 1] = True\n if self.shot is not None and self.shot < 200:\n start = int(self.shot) // 20\n end = int(self.shot + 3 * (self.power - 1)) // 20\n state[5, start:end + 1, 4] = True\n for row, value in enumerate((self.steps, round(self.charge), self.power, round(self.penalty * 10),\n self.coin_combo, self.enemy_combo, self.penalty_combo)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 146, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/charge_beam.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-11-games/blob/6fea4eefe2deaa42706051d96a04ec9e36104696/docs/chargebeam/main.js"} +{"name": "accel_b", "split": "train", "game": "accel_b", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Accel B as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 when the launcher is ready to fire one homing missile at\neach visible enemy or hostile missile. Holding 5 accelerates the craft\nand the scrolling field. Actions 0–4 release and slow it. A fresh salvo\nresets the multiplier. Each target destroyed by a blast doubles it up\nto 64. The launcher reloads after every shot and blast has expired.\nAn incoming missile hitting the craft ends the run.\n\nINPUT CHANNEL TABLE\nChannels show the craft, hostile missiles, enemy craft, homing shots,\nblast footprints, and gauges. Gauges encode the clock, throttle, spawn\ncountdown, multiplier, last button state, and reload readiness. The\ngrid version uses discrete homing, a one-step launch phase, three-step\nblasts, and one missile per enemy. Throttle changes enemy scroll and\nspawn cadence. Decorative terrain and smoke are omitted.\n\nSCORING, TERMINATION, AND HORIZON\nAt most 100 enemies spawn over 400 steps, each with one possible missile.\nEach target can pay once, with a maximum reward of 64 per target. This\ngives a conservative cap of 12,800. Normalize by clipping the sum of\nrewards to [0, 12800] and dividing by 12800.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/accel_b.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\nHORIZON = 400\nMIN_SPAWN_STEPS = 4\nMAX_MULTIPLIER = 64\nPLAYER_ROW = 4\n\n\n@dataclass\nclass Target:\n row: int\n column: int\n fire_in: int = 0\n\n\n@dataclass\nclass HomingShot:\n row: int\n column: int\n target: Target\n age: int = 0\n\n\nclass AccelBEnvironment:\n score_cap = (HORIZON // MIN_SPAWN_STEPS) * 2 * MAX_MULTIPLIER\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.last_action = self.throttle = 0\n self.spawn_in = MIN_SPAWN_STEPS\n self.multiplier = 1\n self.enemies: list[Target] = []\n self.hostile: list[Target] = []\n self.shots: list[HomingShot] = []\n self.blasts: list[tuple[int, int, int]] = []\n self.terminal = False\n\n @property\n def column(self) -> int:\n return 1 + self.throttle // 2\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n self.steps += 1\n pressed = action == 5 and self.last_action != 5\n self.last_action = action\n self.throttle = min(6, self.throttle + 1) if action == 5 else max(0, self.throttle - 1)\n if pressed and not (self.shots or self.blasts):\n self.multiplier = 1\n self.shots = [HomingShot(PLAYER_ROW, self.column, target)\n for target in (*self.enemies, *self.hostile)]\n self._advance_targets()\n self._advance_salvo()\n reward = 0\n for targets in (self.enemies, self.hostile):\n remaining = []\n for target in targets:\n if any(abs(target.row - row) <= 1 and abs(target.column - column) <= 1\n for row, column, _ in self.blasts):\n reward += self.multiplier\n self.multiplier = min(MAX_MULTIPLIER, 2 * self.multiplier)\n elif target.column >= 0:\n remaining.append(target)\n targets[:] = remaining\n self.terminal = any((missile.row, missile.column) == (PLAYER_ROW, self.column)\n for missile in self.hostile) or self.steps >= self.horizon\n self.spawn_in -= 1\n if self.spawn_in == 0 and not self.terminal:\n self.enemies.append(Target(int(self.random.choice((1, 2, 3, 5, 6, 7, 8))), 9, 3))\n self.spawn_in = max(MIN_SPAWN_STEPS, 10 - self.throttle)\n return float(reward), self.terminal\n\n def _advance_targets(self) -> None:\n for enemy in self.enemies:\n if self.throttle >= 3 or self.steps % 3 == 0:\n enemy.column -= 1\n enemy.fire_in -= 1\n if enemy.fire_in == 0 and enemy.column >= 0:\n self.hostile.append(Target(enemy.row, enemy.column))\n for missile in self.hostile:\n missile.column -= 1\n if self.steps % 2 == 0:\n missile.row += int(np.sign(PLAYER_ROW - missile.row))\n\n def _advance_salvo(self) -> None:\n self.blasts = [(row, column, timer - 1)\n for row, column, timer in self.blasts if timer > 1]\n remaining = []\n for shot in self.shots:\n shot.age += 1\n shot.column += 1 if shot.age == 1 else int(np.sign(shot.target.column - shot.column))\n if shot.age > 1:\n shot.row += int(np.sign(shot.target.row - shot.row))\n distance = max(abs(shot.row - shot.target.row), abs(shot.column - shot.target.column))\n if distance <= 1 or shot.age >= 12:\n self.blasts.append((shot.row, max(0, min(9, shot.column)), 3))\n else:\n remaining.append(shot)\n self.shots = remaining\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[PLAYER_ROW, self.column, 0] = True\n for channel, targets in ((1, self.hostile), (2, self.enemies), (3, self.shots)):\n for target in targets:\n if 0 <= target.column < 10:\n state[target.row, target.column, channel] = True\n for row, column, _ in self.blasts:\n state[max(0, row - 1):row + 2, max(0, column - 1):column + 2, 4] = True\n values = (self.steps, self.throttle, self.spawn_in, self.multiplier,\n int(self.last_action == 5), int(not (self.shots or self.blasts)))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 147, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/accel_b.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameAccelB.c"} +{"name": "wizard_of_wor", "split": "train", "game": "wizard_of_wor", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Wizard Of Wor as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves corridor-constrained four-way movement, facing-direction lasers with one\nshot in flight, enemy shots, three Worriors, score-threshold reinforcements, six Burwors followed by\nGarwors and Thorwors, intermittently invisible enemies exposed by radar, opening escape doors,\nthe dungeon-two-and-later Worluk, next-dungeon double scoring, a teleporting Wizard, and faster\nsuccessive dungeons.\n\nACTION MAPPING\n0: wait\n1: move/face left\n2: move/face up\n3: move/face right\n4: move/face down\n5: fire if no laser is already in flight\n\nINPUT CHANNEL TABLE\n0: Worrior\n1: visible Worlings, Wizard, and hostile shots\n2: radar locations for every visible or invisible enemy\n3: Worrior laser\n4: dungeon walls\n5: exact dungeon, lives, enemy count, clock, double-score, and door state\n\nSCORING, TERMINATION, AND HORIZON\nEach dungeon's ordinary Worlings total `6×100 + 2×200 + 2×500 = 2,000`. Dungeon one adds a\n2,500-point Wizard (4,500). Dungeon two adds a 1,000-point Worluk and Wizard (5,500). Killing each\nWorluk doubles Worlings—but not the Wizard—in the next dungeon, so dungeons three and four each\ncap at `2×(2,000+1,000)+2,500 = 8,500`. Thus `score_cap = 4,500+5,500+8,500+8,500 = 27,000`, and\nnormalization is `min(max(raw_score, 0), 27_000) / 27_000`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/wizard_of_wor.py`):\n```python\nimport numpy as np\n\n\nDIRECTIONS = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}\nSCORES = {\"burwor\": 100, \"garwor\": 200, \"thorwor\": 500, \"worluk\": 1_000, \"wizard\": 2_500}\n\n\ndef maze_walls(dungeon: int) -> set[tuple[int, int]]:\n walls = {(0, column) for column in range(10)} | {(9, column) for column in range(10)}\n walls |= {(row, 0) for row in range(1, 9) if row != 5}\n walls |= {(row, 9) for row in range(1, 9) if row != 5}\n patterns = (\n {(2, column) for column in (2, 3, 6, 7)} | {(6, column) for column in (2, 3, 6, 7)},\n {(row, 3) for row in (2, 3, 6, 7)} | {(row, 6) for row in (2, 3, 6, 7)},\n {(3, column) for column in (1, 2, 7, 8)} | {(6, column) for column in (1, 2, 7, 8)},\n {(row, 2) for row in (2, 3, 6, 7)} | {(row, 7) for row in (2, 3, 6, 7)},\n )\n return walls | patterns[dungeon]\n\n\nclass WizardOfWorEnvironment:\n \"\"\"Four finite dungeons with radar, Worluk, and Wizard battles.\"\"\"\n\n score_cap = 27_000.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 4_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.dungeon = 0\n self.lives = 3\n self.score = 0.0\n self.steps = 0\n self.last_action = 0\n self.facing = 2\n self.double_score = False\n self.extra_lives_awarded = 0\n self.terminal = False\n self._start_dungeon()\n\n def _start_dungeon(self) -> None:\n self.player = [8, 5]\n self.walls = maze_walls(self.dungeon)\n self.phase = \"worlings\"\n self.enemies = [self._enemy(index, \"burwor\") for index in range(6)]\n self.bullet: list[int] | None = None\n self.enemy_shots: list[list[int]] = []\n self.worluk_killed = False\n\n def _enemy(self, identifier: int, kind: str) -> dict[str, int | str]:\n cells = ((1, 1), (1, 4), (1, 8), (4, 1), (4, 8), (7, 8))\n row, column = cells[identifier % len(cells)]\n return {\"id\": identifier, \"kind\": kind, \"row\": row, \"column\": column}\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n if action in DIRECTIONS:\n self.facing = action\n self._move_player(action)\n elif action == 5 and self.bullet is None:\n row_delta, column_delta = DIRECTIONS[self.facing]\n self.bullet = [self.player[0], self.player[1], row_delta, column_delta]\n self._move_bullet()\n reward = self._resolve_hits()\n self._move_enemies()\n self._move_enemy_shots()\n self._resolve_player_collision()\n self._advance_phase()\n self.score += reward\n while self.score >= 10_000 * (1 + getattr(self, \"extra_lives_awarded\", 0)):\n self.lives += 1\n self.extra_lives_awarded = getattr(self, \"extra_lives_awarded\", 0) + 1\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_player(self, action: int) -> None:\n row_delta, column_delta = DIRECTIONS[action]\n destination = [self.player[0] + row_delta, self.player[1] + column_delta]\n if destination == [5, 0] and self._doors_open():\n destination = [5, 8]\n elif destination == [5, 9] and self._doors_open():\n destination = [5, 1]\n if tuple(destination) not in self.walls:\n self.player = destination\n\n def _doors_open(self) -> bool:\n return self.steps % 6 < 3\n\n def _move_bullet(self) -> None:\n if self.bullet is None:\n return\n self.bullet[0] += self.bullet[2]\n self.bullet[1] += self.bullet[3]\n if tuple(self.bullet[:2]) in self.walls or not (0 <= self.bullet[0] < 10 and 0 <= self.bullet[1] < 10):\n self.bullet = None\n\n def _resolve_hits(self) -> float:\n if self.bullet is None:\n return 0.0\n for enemy in self.enemies:\n if self.bullet[:2] != [enemy[\"row\"], enemy[\"column\"]]:\n continue\n self.enemies.remove(enemy)\n self.bullet = None\n kind = str(enemy[\"kind\"])\n multiplier = 2 if self.double_score and kind != \"wizard\" else 1\n if kind == \"worluk\":\n self.worluk_killed = True\n return float(SCORES[kind] * multiplier)\n return 0.0\n\n def _move_enemies(self) -> None:\n interval = max(1, 4 - self.dungeon)\n if self.steps % interval:\n return\n for enemy in self.enemies:\n kind = str(enemy[\"kind\"])\n if kind == \"wizard\" and self.steps % 4 == 0:\n cells = [(row, column) for row in range(1, 9) for column in range(1, 9) if (row, column) not in self.walls]\n enemy[\"row\"], enemy[\"column\"] = cells[int(self.random.randint(len(cells)))]\n elif kind == \"worluk\":\n enemy[\"column\"] += 1\n else:\n enemy[\"row\"] += int(np.sign(self.player[0] - int(enemy[\"row\"])))\n enemy[\"column\"] += int(np.sign(self.player[1] - int(enemy[\"column\"])))\n if kind in (\"garwor\", \"thorwor\", \"wizard\") and self.steps % 7 == 0:\n self.enemy_shots.append([\n int(enemy[\"row\"]), int(enemy[\"column\"]),\n int(np.sign(self.player[0] - int(enemy[\"row\"]))),\n int(np.sign(self.player[1] - int(enemy[\"column\"]))),\n ])\n\n def _move_enemy_shots(self) -> None:\n for shot in self.enemy_shots:\n shot[0] += shot[2]\n shot[1] += shot[3]\n self.enemy_shots = [shot for shot in self.enemy_shots if 0 <= shot[0] < 10 and 0 <= shot[1] < 10 and tuple(shot[:2]) not in self.walls]\n\n def _resolve_player_collision(self) -> None:\n collision = any([enemy[\"row\"], enemy[\"column\"]] == self.player for enemy in self.enemies)\n collision |= any(shot[:2] == self.player for shot in self.enemy_shots)\n if not collision:\n return\n self.lives -= 1\n self.player = [8, 5]\n self.bullet = None\n self.enemy_shots.clear()\n if self.lives <= 0:\n self.terminal = True\n\n def _advance_phase(self) -> None:\n self.enemies = [enemy for enemy in self.enemies if not (enemy[\"kind\"] == \"worluk\" and int(enemy[\"column\"]) >= 9)]\n if self.enemies or self.terminal:\n return\n if self.phase == \"worlings\":\n self.phase = \"garwors\"\n self.enemies = [self._enemy(index, \"garwor\") for index in range(2)]\n elif self.phase == \"garwors\":\n self.phase = \"thorwors\"\n self.enemies = [self._enemy(index, \"thorwor\") for index in range(2)]\n elif self.phase == \"thorwors\" and self.dungeon > 0:\n self.phase = \"worluk\"\n self.enemies = [self._enemy(0, \"worluk\")]\n elif self.phase in (\"thorwors\", \"worluk\"):\n self.phase = \"wizard\"\n self.enemies = [self._enemy(0, \"wizard\")]\n else:\n next_double = self.worluk_killed\n self.dungeon += 1\n if self.dungeon == 4:\n self.terminal = True\n else:\n self.double_score = next_double\n self._start_dungeon()\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[self.player[0], self.player[1], 0] = True\n for enemy in self.enemies:\n visible = enemy[\"kind\"] not in (\"garwor\", \"worluk\") or self.steps % 4 == 0\n if visible:\n state[int(enemy[\"row\"]), int(enemy[\"column\"]), 1] = True\n state[int(enemy[\"row\"]), int(enemy[\"column\"]), 2] = True\n for shot in self.enemy_shots:\n state[shot[0], shot[1], 1] = True\n if self.bullet is not None:\n state[self.bullet[0], self.bullet[1], 3] = True\n for row, column in self.walls:\n state[row, column, 4] = True\n values = ((self.dungeon, 3), (self.lives, 4), (len(self.enemies), 4), (self.steps, 12))\n offset = 0\n for value, width in values:\n for bit in range(width):\n state[offset // 10, offset % 10, 5] = bool(value & (1 << bit))\n offset += 1\n state[3, 0, 5] = self.double_score\n state[3, 1, 5] = self._doors_open()\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 148, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/wizard_of_wor.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "line_b", "split": "train", "game": "line_b", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Line B as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to accelerate both endpoints toward their\nmidpoint. Actions 0–4 release the button. The endpoints\nbounce off the walls. Intersect the expanding gold ring\nwith the line before the ring hits a wall. A larger ring\nscores more, using the radius to the power of 1.5 rounded up.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the two endpoints, their line,\nthe gold center, ring, and gauges. The conversion uses\ngeometric collision checks and omits cosmetic trails.\nEach action advances four frames at fixed difficulty.\nThe 400-action task clips scores to [0, 350] and divides by 350.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/line_b.py`):\n```python\nimport math\n\nimport numpy as np\n\n\nclass LineBEnvironment:\n score_cap = 350\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n angles = self.random.uniform(-math.pi / 3, math.pi / 3, 2) + np.array([0, math.pi])\n self.points = np.full((2, 2), 50.0)\n self.velocity = np.column_stack((np.cos(angles), np.sin(angles)))\n self.gold = None\n self.radius = 1.0\n self.steps = 0\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tapped = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tapped and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _distance(self, point: np.ndarray) -> float:\n start, end = self.points\n segment = end - start\n length_squared = float(segment @ segment)\n fraction = float((point - start) @ segment) / length_squared if length_squared else 0\n return float(np.linalg.norm(point - (start + min(1, max(0, fraction)) * segment)))\n\n def _advance(self, tapped: bool) -> int:\n if self.gold is None:\n for _ in range(99):\n self.gold = self.random.uniform(20, 80, 2)\n if self._distance(self.gold) > 22:\n break\n self.radius = 1\n ring = self.radius\n hits_wall = ring + 1.5 >= min(*self.gold - 3, *(97 - self.gold))\n self.radius += 0.05\n if tapped:\n for index, delta in enumerate(self.points.mean(axis=0) - self.points):\n angle = math.atan2(delta[1], delta[0])\n self.velocity[index] += (9 * math.cos(angle), 9 * math.sin(angle))\n self.points += self.velocity\n for point, velocity in zip(self.points, self.velocity, strict=True):\n for axis, low in enumerate((4, 5)):\n if (point[axis] < low and velocity[axis] < 0) or (point[axis] > 96 and velocity[axis] > 0):\n velocity[axis] *= -1\n other = 1 - axis\n jitter = self.random.uniform(0.1, 0.2) * self.random.choice((-1, 1))\n velocity[other] += jitter / (abs(velocity[other]) + 1)\n if np.linalg.norm(velocity) > 1:\n velocity *= 0.9\n velocity *= 0.999\n farthest = max(np.linalg.norm(point - self.gold) for point in self.points)\n if self._distance(self.gold) <= ring + 2 and farthest >= ring - 2:\n self.gold = None\n return math.ceil(self.radius ** 1.5)\n self.terminal = hits_wall\n return 0\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for channel, (x, y) in enumerate(self.points):\n state[min(9, max(0, int(y // 10))), min(9, max(0, int(x // 10))), channel] = True\n for x, y in np.linspace(*self.points, 30):\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), 2] = True\n if self.gold is not None:\n x, y = self.gold\n state[int(y // 10), int(x // 10), 3] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n state[:, :, 4] = abs(np.hypot(cols - x, rows - y) - self.radius) < 6\n for row, value in enumerate((self.steps, round(self.radius * 10))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 149, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/line_b.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/lineb/main.js"} +{"name": "photon_line", "split": "train", "game": "photon_line", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Photon Line as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to turn the hands. Hold to keep turning and\nreflect incoming photons. Actions 0–4 release. A stationary\nhand adds incoming colors in order. A remover photon\npops the last color. Match both target sequences to advance.\nEither hand order can satisfy the target.\n\nINPUT CHANNEL TABLE\nRows 0–3 of the six-channel 10×10 observation encode target\nsequences and hands. Rows 4–7 show photons by direction and\nreflection status. The last rows hold timing and angle gauges.\nThe conversion resolves photon contact along the horizontal\ntrack and uses four frames per action at fixed difficulty.\nThe 400-action task clips scores to [0, 200] and divides by 200.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/photon_line.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Photon:\n x: float\n direction: int\n color: int\n reflected: bool = False\n\n\nclass PhotonLineEnvironment:\n score_cap = 200\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.angle = self.turn_target = 0.0\n self.rotating = self.pressed = self.terminal = False\n self.hands = [[0], [1]]\n self.target = [[0], [1]]\n self.photons: list[Photon] = []\n self.world, self.stage, self.colors = 1, 0, 2\n self.steps = self.transition = 0\n self._next_stage()\n\n def _next_stage(self):\n if self.stage >= min(5, self.world + 1):\n self.world += 1\n self.stage = 0\n self.colors = min(4, int(self.random.integers(2, self.world + 2)))\n self.target = [[int(self.random.integers(self.colors))] for _ in range(2)]\n self.hands = [hand.copy() for hand in self.target]\n previous = [hand.copy() for hand in self.target]\n self.target = [hand[:4] for hand in self.target]\n ratio = 3 / self.colors\n additions = round(self.random.uniform(1, self.world) * ratio)\n removals = round(min(2, max(0, self.random.uniform(0, self.world) - 1)) * ratio)\n if additions == removals:\n removals -= 1\n for _ in range(removals):\n hand = self.target[self.random.integers(2)]\n if hand:\n hand.pop()\n for _ in range(additions + removals):\n self.target[self.random.integers(2)].append(int(self.random.integers(self.colors)))\n self.target = [hand[:5] for hand in self.target]\n if self.target == previous:\n hand = next((h for h in self.target if h), self.target[0])\n if hand:\n hand[-1] = (hand[-1] + 1) % self.colors\n else:\n hand.append(0)\n self.stage += 1\n self.timer, self.width = 60.0, 30.0\n self.bag = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n reward = 0\n if self.transition:\n self.transition -= 1\n if self.width > -3:\n reward = self.world\n self.width -= 1\n if not self.transition:\n self._next_stage()\n else:\n self.timer -= 1\n if self.timer < 0:\n if not self.bag:\n self.bag = self.random.permutation(list(range(self.colors)) * 2\n + [4] * math.ceil(self.colors * 0.4)).tolist()\n direction = 1 if self.random.random() < 0.5 else -1\n self.photons.append(Photon(self.width if direction == 1 else 200 - self.width,\n direction, self.bag.pop()))\n self.timer = self.random.uniform(60, 90)\n self._move_photons()\n if tap and not self.rotating and not self.transition:\n self.rotating = True\n self.turn_target += math.pi\n if self.rotating:\n self.angle += 0.2\n if self.angle >= self.turn_target:\n if self.pressed:\n self.turn_target += math.pi\n else:\n self.angle = self.turn_target\n self.rotating = False\n if self.angle >= math.tau:\n self.angle -= math.tau\n self.turn_target -= math.tau\n self.width -= 0.02\n self.terminal = not self.transition and self.width < -3\n return reward\n\n def _move_photons(self):\n remaining = []\n swapped = math.pi / 2 <= self.angle <= 3 * math.pi / 2\n for photon in self.photons:\n direction = photon.direction\n photon.x += direction * (-2 if photon.reflected else 0.4)\n if photon.reflected:\n if self.width <= photon.x <= 200 - self.width:\n remaining.append(photon)\n continue\n hand = self.hands[(direction < 0) ^ swapped]\n edge = 100 - (7 * len(hand) + 6) * direction\n if (photon.x - edge) * direction <= 0:\n remaining.append(photon)\n elif self.rotating:\n photon.reflected = True\n remaining.append(photon)\n else:\n if photon.color == 4:\n if hand:\n hand.pop()\n else:\n hand.append(photon.color)\n if len(hand) > 9:\n self.width /= 2\n direct = self.hands == self.target\n reverse = self.hands[::-1] == self.target\n if direct or reverse:\n if (direct and swapped) or (not direct and reverse and not swapped):\n self.rotating = True\n self.turn_target += math.pi\n self.transition = 60\n self.photons = []\n return\n self.photons = remaining\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for row, hand in enumerate((*self.target, *self.hands)):\n for col, color in enumerate(hand[:10]):\n state[row, col, color] = True\n for photon in self.photons:\n col = min(9, max(0, int(photon.x // 20)))\n row = 4 + 2 * (photon.direction < 0) + photon.reflected\n state[row, col, photon.color] = True\n values = (self.steps, round(self.angle * 80), self.world, self.stage,\n self.transition, round((self.width + 4) * 10))\n for channel, value in enumerate(values):\n for bit in range(9):\n state[8, bit, channel] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.rotating\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 150, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/photon_line.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/photonline/main.js"} +{"name": "attack_chain", "split": "train", "game": "attack_chain", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Attack Chain as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nActions 0–5 select one of six cards, replacing the original pointer.\nAn unavailable card waits. Each play has one resolution step, during\nwhich selections are ignored. Red cards get a 25% opener bonus. Green\ncards cap accumulated damage at 99. Blue finishers return the strongest\nspent card first. Played cards grow stronger if they return.\n\nChains settle at 100 damage or when the hand runs out. The payout is\ndamage times the current multiplier. Thresholds at 100, 150, and 200\nreturn cards. Damage above 115 reduces the advancing pressure meter.\nA fresh hand increases the multiplier after seven chains or when no\ncards are available. The episode ends when pressure reaches the limit\nwhile ready to play, or after 400 steps.\n\nINPUT CHANNEL TABLE\nThe observation uses three channels for card colors, one for availability,\none for binary card values, and one for pressure, damage, chain counters,\nmultiplier, and the resolution state. This adaptation compresses the\ndamage and settlement animations into one step and uses integer pressure.\n\nSCORING, TERMINATION, AND HORIZON\nA dealt card starts at no more than 50 and cannot be played more than\nonce per chain. Its value stays below 200 during a seven-chain deal,\nso even a red bonus adds at most 250 damage. A chain starts its last\nplay below 100. At most 200 chains settle in 400 steps, and the multiplier\nnever exceeds 201. This gives a conservative cap of 14,029,800.\nNormalize by clipping to [0, cap] and dividing by the cap.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/attack_chain.py`):\n```python\nfrom math import sqrt\n\nimport numpy as np\n\n\nHORIZON = 400\nCARDS = 6\nCHAINS_PER_DEAL = 7\nRED, GREEN, BLUE = range(3)\nPRESSURE_LIMIT = 300\n\n\nclass AttackChainEnvironment:\n # One chain per two steps at most, and no card reaches 200 damage.\n score_cap = (HORIZON // 2) * (99 + 250) * (1 + HORIZON // 2)\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.pressure = self.total = self.turn = self.chains = 0\n self.cooldown = self.pending = 0\n self.last_type = -1\n self.last_action = 0\n self.multiplier = 1\n self.terminal = False\n self._deal()\n\n def _deal(self) -> None:\n green_left = 2\n self.types = []\n for _ in range(CARDS):\n if green_left and self.random.random() < 0.2:\n self.types.append(GREEN)\n green_left -= 1\n else:\n self.types.append(int(self.random.choice((RED, BLUE))))\n scale = 4 + sqrt(min(20, self.multiplier))\n self.values = [int(value * scale) for value in self.random.integers(3, 7, size=CARDS)]\n self.available = [True] * CARDS\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.steps += 1\n self.pressure += 1\n reward = 0\n if self.cooldown:\n self.cooldown = 0\n self.total += self.pending\n self.pending = 0\n if self.total >= 100 or not any(self.available):\n reward = self._settle()\n elif self.pressure >= PRESSURE_LIMIT:\n self.terminal = True\n elif self.available[action]:\n self.pressure += 4\n self.available[action] = False\n value, color = self.values[action], self.types[action]\n if color == RED and self.turn == 0:\n value = value * 5 // 4\n elif color == GREEN:\n value = min(value, 99 - self.total)\n self.pending = value\n self.cooldown = 1\n self.last_type = color\n self.turn += 1\n self.values[action] = self.values[action] * 11 // 10 + 10\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _settle(self) -> int:\n reward = self.total * self.multiplier\n excess = max(0, self.total - 115)\n self.pressure = max(0, self.pressure - int(excess * sqrt(excess / self.multiplier)))\n returns = sum(self.total >= threshold for threshold in (100, 150, 200))\n unavailable = [index for index, ready in enumerate(self.available) if not ready]\n if returns and unavailable and self.last_type == BLUE:\n best = max(unavailable, key=self.values.__getitem__)\n self.available[best] = True\n unavailable.remove(best)\n returns -= 1\n for index in self.random.permutation(unavailable)[:returns]:\n self.available[index] = True\n self.chains += 1\n if not any(self.available) or self.chains == CHAINS_PER_DEAL:\n self.chains = 0\n self.multiplier += 1\n self._deal()\n self.total = self.turn = 0\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for index, (color, value, ready) in enumerate(zip(self.types, self.values, self.available, strict=True)):\n state[9, index, color] = True\n state[9, index, 3] = ready\n for bit in range(8):\n state[bit, index, 4] = bool(value & (1 << bit))\n values = (self.pressure, self.total, self.turn, self.chains, self.multiplier,\n self.pending, self.cooldown, self.last_type + 1, self.steps, self.last_action)\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 151, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/attack_chain.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameAttackChain.c"} +{"name": "hyper_laser", "split": "train", "game": "hyper_laser", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Hyper Laser as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nUse actions 1 and 3 to move left and right. Actions 2 and 4\nrotate the aim in 15-degree increments. Hold action 5 to\nfire while stationary. Any other action raises the shield.\nThese controls replace pointer movement and aiming.\n\nLasers bounce off blocks and side walls. Destroy unshielded\nenemies for ten times the multiplier. Absorb enemy shots\nwith your shield to score the current multiplier and raise it.\nA shot hitting the unshielded player or an enemy reaching\nthe bottom ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player and gauges, blocks,\nenemies, enemy shields, enemy shots, and lasers. The conversion\nuses proximity hitboxes and fixed difficulty, with four frames\nper action and a 400-action horizon. Raw scores are clipped to\n[0, 150] and divided by 150.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/hyper_laser.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Projectile:\n x: float\n y: float\n vx: float\n vy: float\n age: int = 0\n\n\n@dataclass\nclass Enemy:\n x: float\n y: float\n interval: float\n charge: float\n burst_size: int\n heading: float = math.pi / 2\n target: float = math.pi / 2\n turret: float = math.pi / 2\n turn_timer: float = 0\n burst_timer: int = 0\n remaining: int = 0\n\n @property\n def shielded(self) -> bool:\n return self.charge > 0 and self.y < 70\n\n\nclass HyperLaserEnvironment:\n score_cap = 150\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x, self.y = 50.0, 95.0\n self.aim = self.steps = self.action = self.laser_timer = 0\n self.block_timer = self.enemy_timer = 0.0\n self.multiplier = 1\n self.terminal = False\n self.blocks: list[tuple[float, float]] = []\n self.enemies: list[Enemy] = []\n self.lasers: list[Projectile] = []\n self.shots: list[Projectile] = []\n\n @property\n def angle(self) -> float:\n return -math.pi / 2 + self.aim * math.pi / 12\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n self.aim = min(5, max(-5, self.aim + (self.action == 4) - (self.action == 2)))\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _blocked(self, x: float, y: float) -> bool:\n return any(abs(x - bx) < 4 and abs(y - by) < 4 for bx, by in self.blocks)\n\n def _advance(self) -> int:\n shielded = self.action != 5\n if shielded:\n self.x = min(93, max(7, self.x + 0.3 * ((self.action == 3) - (self.action == 1))))\n else:\n self.laser_timer -= 1\n if self.laser_timer < 0:\n self.lasers.append(Projectile(self.x, self.y, 3 * math.cos(self.angle), 3 * math.sin(self.angle)))\n self.laser_timer = 9\n self.block_timer -= 0.1\n if self.block_timer < 0:\n x = self.random.uniform(8, 92)\n if not self._blocked(x, -9):\n self.blocks.append((x, -9))\n self.block_timer = self.random.uniform(0, 16)\n self.blocks = [(x, y + 0.1) for x, y in self.blocks\n if y < 103 and (abs(x - self.x) >= 5 or abs(y - self.y) >= 5)]\n self._move_lasers()\n if not self.enemies:\n self.block_timer = 0\n self.enemy_timer -= 1\n if self.enemy_timer < 0:\n interval = self.random.uniform(60, 120)\n self.enemies.append(Enemy(self.random.uniform(10, 90), -9, interval,\n self.random.uniform(0, interval), int(self.random.integers(3, 9))))\n self.enemy_timer = self.random.uniform(150, 200)\n reward = self._move_enemies()\n remaining = []\n for shot in self.shots:\n shot.x += shot.vx\n shot.y += shot.vy + 0.1\n if abs(shot.x - self.x) < (6 if shielded else 4) and abs(shot.y - self.y) < (6 if shielded else 4):\n if shielded:\n reward += self.multiplier\n self.multiplier += 1\n else:\n self.terminal = True\n elif 5 <= shot.x <= 95 and -9 <= shot.y <= 100 and not self._blocked(shot.x, shot.y):\n remaining.append(shot)\n self.shots = remaining\n return reward\n\n def _move_lasers(self) -> None:\n surviving = []\n for laser in self.lasers:\n laser.y += 0.1\n x, y = laser.x + laser.vx, laser.y + laser.vy\n hit_x = not 5 <= x <= 95 or self._blocked(x, laser.y)\n hit_y = self._blocked(laser.x, y)\n corner = not (hit_x or hit_y) and self._blocked(x, y)\n if hit_x or corner:\n laser.vx *= -1\n if hit_y or corner:\n laser.vy *= -1\n laser.x += laser.vx\n laser.y += laser.vy\n laser.age += 1\n if -5 <= laser.y <= 105 and laser.age <= 120 and not self._blocked(laser.x, laser.y):\n surviving.append(laser)\n self.lasers = surviving\n\n def _move_enemies(self) -> int:\n reward = 0\n remaining = []\n for enemy in self.enemies:\n enemy.y += 0.1\n delta = (enemy.target - enemy.heading + math.pi) % math.tau - math.pi\n if abs(delta) >= 0.1:\n enemy.heading += delta * 0.1\n else:\n enemy.heading = enemy.target\n x = enemy.x + 0.1 * math.cos(enemy.heading)\n y = enemy.y + 0.1 * math.sin(enemy.heading)\n enemy.turn_timer -= 1\n if enemy.turn_timer < 0 or not 9 <= x <= 90 or self._blocked(x, y):\n enemy.target += math.pi / 2 * self.random.choice((-1, 1))\n enemy.turn_timer = self.random.uniform(200, 300)\n else:\n enemy.x, enemy.y = x, y\n enemy.charge -= 1\n shielded = enemy.shielded\n if shielded:\n angle = math.atan2(self.y - enemy.y, self.x - enemy.x)\n enemy.turret = round(angle / (math.pi / 4)) * math.pi / 4\n if enemy.charge < 0:\n if not enemy.remaining:\n enemy.remaining = enemy.burst_size\n enemy.burst_timer = 0\n enemy.burst_timer -= 1\n if enemy.burst_timer < 0:\n self.shots.append(Projectile(enemy.x, enemy.y, 2 * math.cos(enemy.turret),\n 2 * math.sin(enemy.turret)))\n enemy.remaining -= 1\n enemy.burst_timer = 20\n if not enemy.remaining:\n enemy.charge = enemy.interval\n hit = [laser for laser in self.lasers if abs(laser.x - enemy.x) < 5 and abs(laser.y - enemy.y) < 5]\n if hit:\n self.lasers = [laser for laser in self.lasers if laser not in hit]\n if hit and not shielded:\n reward += self.multiplier * 10\n else:\n self.terminal |= enemy.y > 99\n remaining.append(enemy)\n self.enemies = remaining\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[9, int(self.x) // 10, 0] = True\n for x, y in self.blocks:\n if 0 <= y < 100:\n state[int(y) // 10, int(x) // 10, 1] = True\n for enemy in self.enemies:\n if 0 <= enemy.y < 100:\n row, col = int(enemy.y) // 10, int(enemy.x) // 10\n state[row, col, 2] = True\n state[row, col, 3] |= enemy.shielded\n for channel, projectiles in ((4, self.shots), (5, self.lasers)):\n for p in projectiles:\n if 0 <= p.x < 100 and 0 <= p.y < 100:\n state[int(p.y) // 10, int(p.x) // 10, channel] = True\n for row, value in enumerate((self.aim + 5, min(self.multiplier, 31))):\n for bit in range(5):\n state[bit, 0 if row == 0 else 9, 0] = bool(value & (1 << bit))\n state[5, 9, 0] = self.action != 5\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 152, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/hyper_laser.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/hyperlaser/main.js"} +{"name": "bridge_cross", "split": "train", "game": "bridge_cross", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Bridge Cross as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to jump onto an approaching bridge. Hold it to reduce\ngravity and release with actions 0–4 before jumping again. Walking\ninto the side of a bridge ends the run. Walking off a bridge drops\nthe brigade back to the ground.\n\nINPUT CHANNEL TABLE\nTime spent on bridges earns points at the current multiplier, which\nincreases after each payout. Jumping halves the multiplier, rounding\nup. The six 10×10 channels show the brigade, bridges, ground, support\nstatus, jump status, and gauges. Each action advances four frames at\nfixed scroll speed.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends on collision or after 400 actions. Clip raw scores to\n[0, 500] and divide by the fixed cap of 500.\n\nAcross 100 seeds without sticky actions, idle and continuous hold\nscored zero. Random inputs averaged 10.86 raw points. A heuristic\nthat tapped just before a bridge arrived averaged 406.22 and reached\n489.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/bridge_cross.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\nBRIGADE_LEFT = 10\nBRIGADE_RIGHT = 40\nBRIDGE_TOP = 32\nGROUND = 37\n\n\n@dataclass\nclass Bridge:\n x: float\n length: float\n\n def overlaps_brigade(self) -> bool:\n return self.x <= BRIGADE_RIGHT and self.x + self.length >= BRIGADE_LEFT\n\n\nclass BridgeCrossEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.score_timer = 0\n self.spawn_timer = 0.0\n self.multiplier = 1\n self.y, self.vy = float(GROUND), 0.0\n self.pressed = self.jumping = self.falling = self.on_bridge = self.terminal = False\n self.bridges: list[Bridge] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(FRAMES_PER_STEP):\n reward += self._advance_frame(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self, tap: bool) -> int:\n if self.spawn_timer <= 0:\n self.bridges.append(Bridge(153, self.random.uniform(20, 40)))\n self.spawn_timer = self.random.uniform(50, 100)\n self.spawn_timer -= 1\n for bridge in self.bridges:\n bridge.x -= 1\n self.bridges = [bridge for bridge in self.bridges if bridge.x + bridge.length > 0]\n above_bridge = any(bridge.overlaps_brigade() for bridge in self.bridges)\n\n if self.y < 35 and not above_bridge:\n self.falling, self.on_bridge = True, False\n if self.jumping or self.falling:\n self.y += self.vy\n self.vy += 0.1 if self.pressed else 0.2\n surface = BRIDGE_TOP if above_bridge else GROUND\n if self.y > surface and self.vy > 0:\n self.y, self.vy = float(surface), 0.0\n self.jumping = self.falling = False\n self.on_bridge = above_bridge\n\n if tap and not self.jumping:\n self.jumping, self.on_bridge = True, False\n self.vy = -2\n self.multiplier = math.ceil(self.multiplier / 2)\n if not self.jumping and self.y > BRIDGE_TOP and above_bridge:\n self.terminal = True\n\n if self.on_bridge:\n self.score_timer -= 1\n if self.score_timer < 0:\n reward = self.multiplier\n self.multiplier += 1\n self.score_timer = 10\n return reward\n return 0\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row = int(self.y) // 5\n state[row, :3, 0] = True\n state[row, :3, 3] = self.on_bridge\n state[8:, :, 2] = True\n for bridge in self.bridges:\n for column in range(10):\n state[7, column, 1] |= column * 15 < bridge.x + bridge.length and (column + 1) * 15 > bridge.x\n state[0, :3, 4] = self.pressed, self.jumping, self.vy < 0\n for row, value in enumerate((self.steps, self.multiplier, self.score_timer)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 153, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/bridge_cross.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBridgeCross.c"} +{"name": "laser_fortress", "split": "train", "game": "laser_fortress", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Laser Fortress as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to sweep the laser right from the tracking\nsight. Release with actions 0–4 to stop the beam. Each new\nsweep resets its multiplier. Destroying enemies scores the\ncurrent multiplier and raises it by one. Hitting an ally or\nletting an enemy reach the fortress ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the fortress, enemies, allies,\nsight, beam, and gauges. The conversion approximates sprite\ncontact with a horizontal hit window and runs at fixed\ndifficulty for four frames per action. The 400-action task\nclips raw scores to [0, 400] and divides by 400.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/laser_fortress.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Unit:\n x: float\n speed: int\n ally: bool\n\n\nclass LaserFortressEnvironment:\n score_cap = 400\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.units: list[Unit] = []\n self.timer = 0.0\n self.group_remaining = 6\n self.fast_index = -1\n self.ally_group = False\n self.sight = 40.0\n self.beam = 0.0\n self.multiplier = 1\n self.steps = 0\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed:\n self.beam = self.sight\n self.multiplier = 1\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self) -> int:\n beam_x = self.beam\n if self.pressed:\n self.beam += 2\n self.timer -= 1\n if self.timer < 0:\n self._spawn()\n reward = 0\n nearest = 200.0\n remaining = []\n for unit in self.units:\n unit.x -= unit.speed\n if not unit.ally:\n nearest = min(nearest, unit.x)\n if self.pressed and abs(beam_x - unit.x) < 5:\n if unit.ally:\n self.terminal = True\n else:\n reward += self.multiplier\n self.multiplier += 1\n elif unit.x < 0:\n self.terminal |= not unit.ally\n else:\n remaining.append(unit)\n self.units = remaining\n if nearest < 200:\n self.sight += (nearest - 8 - self.sight) * 0.3\n return reward\n\n def _spawn(self) -> None:\n speed = 2 if self.group_remaining - 1 == self.fast_index else 1\n self.units.append(Unit(163, speed, self.ally_group))\n self.group_remaining -= 1\n if self.group_remaining:\n self.timer = self.random.uniform(5, 8)\n else:\n self.group_remaining = 10 - math.floor(math.sqrt(self.random.uniform(0, 50)))\n self.timer = self.random.uniform(20, 30)\n self.ally_group = not self.ally_group and self.random.random() < 0.3\n self.fast_index = -1 if self.random.random() < 0.5 else int(self.random.integers(2))\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[1:5, 0, 0] = True\n for unit in self.units:\n if 0 <= unit.x < 160:\n state[7, int(unit.x) // 16, 2 if unit.ally else 1] = True\n if 0 <= self.sight < 160:\n state[7, int(self.sight) // 16, 3] = True\n if self.pressed:\n for fraction in np.linspace(0, 1, 20):\n x = 20 + (self.beam - 2 - 20) * fraction\n y = 8 + 42 * fraction\n if 0 <= x < 160:\n state[int(y) // 6, int(x) // 16, 4] = True\n values = (self.steps, min(511, self.multiplier), min(511, max(0, round(self.sight * 3))),\n min(511, max(0, round(self.beam * 3))))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 154, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/laser_fortress.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/laserfortress/main.js"} +{"name": "asteroids", "split": "train", "game": "asteroids", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Asteroids as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion implements the Atari 2600 manual's normal one-player hyperspace variation. The\nship rotates counterclockwise or clockwise, thrusts only along its current heading, retains\nmomentum, fires photon torpedoes, and wraps across every edge. Action 4 invokes hyperspace: the\nship reappears at a seeded random location with zero momentum and can immediately emerge into an\nasteroid.\n\nEach belt begins with four large asteroids. A hit splits a large asteroid into two medium ones,\nand a medium into two small ones; only a small asteroid is completely vaporized. Every size is\nequally lethal on contact. The player has the manual's four ships. Three finite belts or the\n1,500-step horizon end the episode.\n\nACTION MAPPING\n0: wait\n1: rotate left\n2: thrust\n3: rotate right\n4: hyperspace\n5: fire photon torpedo\n\nINPUT CHANNEL TABLE\n0: ship\n1: lethal asteroids\n2: asteroid reward targets\n3: photon torpedoes\n4: previous ship and asteroid positions\n5: asteroid sizes, velocity, heading, lives, and belt\n\nSCORING, TERMINATION, AND HORIZON\nThe manual awards 20, 50, and 100 points for large, medium, and small asteroids. A complete\nfragmentation tree is `20 + 2×50 + 4×100 = 520`. Four trees per belt across three belts give\n`score_cap = 6,240`. Every fragment is finite and each object scores once. Normalization is\n`min(max(raw_score, 0), 6240) / 6240`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/asteroids.py`):\n```python\nimport numpy as np\n\n\nDIRECTIONS = (\n (-1, 0),\n (-1, 1),\n (0, 1),\n (1, 1),\n (1, 0),\n (1, -1),\n (0, -1),\n (-1, -1),\n)\nPOINTS = {3: 20.0, 2: 50.0, 1: 100.0}\n\n\nclass AsteroidsEnvironment:\n \"\"\"Momentum, wraparound, fragmentation, and risky hyperspace on a torus.\"\"\"\n\n score_cap = 6_240.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 1_500):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.ship = [5, 5]\n self.previous_ship = self.ship.copy()\n self.velocity = [0, 0]\n self.direction = 0\n self.shots: list[list[int]] = []\n self.wave = 0\n self.lives = 4\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self._start_wave()\n\n def _start_wave(self) -> None:\n starts = ((0, 0, 1, 1), (0, 9, 1, -1), (9, 0, -1, 1), (9, 9, -1, -1))\n self.asteroids = [\n {\"row\": row, \"column\": column, \"dr\": dr, \"dc\": dc, \"size\": 3}\n for row, column, dr, dc in starts\n ]\n self.previous_asteroids = [[int(asteroid[\"row\"]), int(asteroid[\"column\"])] for asteroid in self.asteroids]\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_ship = self.ship.copy()\n if action == 1:\n self.direction = (self.direction - 1) % 8\n elif action == 3:\n self.direction = (self.direction + 1) % 8\n elif action == 2:\n thrust = DIRECTIONS[self.direction]\n self.velocity[0] = int(np.clip(self.velocity[0] + thrust[0], -1, 1))\n self.velocity[1] = int(np.clip(self.velocity[1] + thrust[1], -1, 1))\n elif action == 4:\n self.ship = [int(self.random.randint(10)), int(self.random.randint(10))]\n self.velocity = [0, 0]\n elif action == 5:\n dr, dc = DIRECTIONS[self.direction]\n self.shots.append([self.ship[0], self.ship[1], dr, dc, 12])\n\n if action != 4:\n self.ship[0] = (self.ship[0] + self.velocity[0]) % 10\n self.ship[1] = (self.ship[1] + self.velocity[1]) % 10\n self.previous_asteroids = [[int(asteroid[\"row\"]), int(asteroid[\"column\"])] for asteroid in self.asteroids]\n self._move_asteroids()\n self._move_shots()\n reward = self._resolve_shots()\n if any([asteroid[\"row\"], asteroid[\"column\"]] == self.ship for asteroid in self.asteroids):\n self._lose_ship()\n self.steps += 1\n if not self.asteroids:\n self.wave += 1\n if self.wave == 3:\n self.terminal = True\n else:\n self._start_wave()\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_asteroids(self) -> None:\n for asteroid in self.asteroids:\n asteroid[\"row\"] = (int(asteroid[\"row\"]) + int(asteroid[\"dr\"])) % 10\n asteroid[\"column\"] = (int(asteroid[\"column\"]) + int(asteroid[\"dc\"])) % 10\n\n def _move_shots(self) -> None:\n for shot in self.shots:\n shot[0] = (shot[0] + shot[2]) % 10\n shot[1] = (shot[1] + shot[3]) % 10\n shot[4] -= 1\n self.shots = [shot for shot in self.shots if shot[4] > 0]\n\n def _resolve_shots(self) -> float:\n reward = 0.0\n remaining_shots = []\n for shot in self.shots:\n hit = next(\n (asteroid for asteroid in self.asteroids if [asteroid[\"row\"], asteroid[\"column\"]] == shot[:2]),\n None,\n )\n if hit is None:\n remaining_shots.append(shot)\n continue\n self.asteroids.remove(hit)\n size = int(hit[\"size\"])\n reward += POINTS[size]\n if size > 1:\n for turn in (-1, 1):\n direction = DIRECTIONS.index((int(hit[\"dr\"]), int(hit[\"dc\"])))\n dr, dc = DIRECTIONS[(direction + turn) % 8]\n self.asteroids.append({\n \"row\": int(hit[\"row\"]),\n \"column\": int(hit[\"column\"]),\n \"dr\": dr,\n \"dc\": dc,\n \"size\": size - 1,\n })\n self.shots = remaining_shots\n return reward\n\n def _lose_ship(self) -> None:\n self.lives -= 1\n self.ship = [5, 5]\n self.previous_ship = self.ship.copy()\n self.velocity = [0, 0]\n self.shots.clear()\n if self.lives <= 0:\n self.terminal = True\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.ship, 0] = True\n for asteroid in self.asteroids:\n row, column = int(asteroid[\"row\"]), int(asteroid[\"column\"])\n state[row, column, 1] = True\n state[row, column, 2] = True\n size = int(asteroid[\"size\"])\n state[row, (column + size - 1) % 10, 5] = True\n for shot in self.shots:\n state[shot[0], shot[1], 3] = True\n for row, column in self.previous_asteroids:\n state[row, column, 4] = True\n state[*self.previous_ship, 4] = True\n state[9, : self.lives, 5] = True\n state[8, : self.wave + 1, 5] = True\n velocity_marker = (self.velocity[0] + 1) * 3 + self.velocity[1] + 1\n state[7, velocity_marker, 5] = True\n state[6, self.direction, 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 155, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/asteroids.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "not_turn", "split": "train", "game": "not_turn", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Not Turn as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to speed up and automatically turn onto\navailable crossbars. Actions 0–4 release and slow down.\nEnemies turn automatically and leave trails of dots.\nCollecting a dot scores the multiplier and raises it.\nAn enemy leaving the screen lowers it. Enemy contact\nends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, rails, crossbars,\nenemies, dots, and gauges. The conversion uses approximate\nrectangular contact checks and four frames per action at\nfixed difficulty. The 400-action task clips scores to\n[0, 200] and divides by 200.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/not_turn.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Walker:\n x: float\n y: float\n lane: int\n dx: int = 0\n cooldown: float = 0\n dot_distance: float = 0\n\n\nclass NotTurnEnvironment:\n score_cap = 200\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.player = Walker(50, 99, 2, cooldown=5)\n self.speed = 1.0\n self.enemy_timer = 20.0\n self.bar_distance = 0.0\n self.steps = 0\n self.multiplier = 1\n self.pressed = self.terminal = False\n self.bars = []\n self.enemies = []\n self.dots = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _move(self, walker, speed, vertical, turn):\n if walker.dx:\n walker.x += walker.dx * speed\n target = 10 + walker.lane * 20\n if (walker.x - target) * walker.dx >= 0:\n walker.x, walker.dx = target, 0\n return\n walker.y += vertical * speed\n walker.cooldown -= speed\n if turn and walker.cooldown < 0:\n for direction in (1, -1):\n lane = walker.lane + direction\n if 0 <= lane < 5 and any(\n abs(x - walker.x - 6 * direction) < 9 and abs(y - walker.y - 3) < 2\n for x, y in self.bars):\n walker.dx, walker.lane, walker.cooldown = direction, lane, 5\n break\n\n def _advance(self):\n player = self.player\n scroll = max(0, player.y - 20) * 0.1\n self.bar_distance -= scroll\n if self.bar_distance < 0:\n a, b = self.random.integers(4, size=2)\n self.bars.append((20 + a * 20, 102))\n if abs(a - b) > 1:\n self.bars.append((20 + b * 20, 102))\n self.bar_distance += self.random.uniform(9, 12)\n self.bars = [(x, y - scroll) for x, y in self.bars if y - scroll >= -1]\n self._move(player, self.speed * 0.2, 1, self.pressed)\n self.speed += ((4 if self.pressed else 1) - self.speed) * 0.2\n self.enemy_timer -= 1\n if self.enemy_timer < 0:\n lane = int(self.random.integers(5))\n self.enemies.append(Walker(10 + lane * 20, 103, lane))\n self.enemy_timer = self.random.uniform(100, 150)\n remaining = []\n for enemy in self.enemies:\n self._move(enemy, 0.3, -1, True)\n self.terminal |= abs(enemy.x - player.x) < 5 and abs(enemy.y - player.y) < 5\n enemy.y -= scroll\n enemy.dot_distance -= 0.3\n if enemy.dot_distance < 0:\n enemy.dot_distance += 6\n self.dots.append((enemy.x, enemy.y))\n if enemy.y >= -3:\n remaining.append(enemy)\n else:\n self.multiplier = max(1, self.multiplier - 1)\n self.enemies = remaining\n reward = 0\n remaining = []\n for x, y in self.dots:\n if abs(x - player.x) < 4 and abs(y - player.y) < 4:\n reward += self.multiplier\n self.multiplier += 1\n elif y - scroll >= -3:\n remaining.append((x, y - scroll))\n self.dots = remaining\n player.y -= scroll\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, max(0, int(self.player.y // 10))), int(self.player.x // 10), 0] = True\n state[:, 1::2, 1] = True\n for channel, points in ((2, self.bars), (3, [(e.x, e.y) for e in self.enemies]), (4, self.dots)):\n for x, y in points:\n if 0 <= y < 100:\n state[int(y // 10), int(x // 10), channel] = True\n values = (self.steps, min(511, self.multiplier), round(self.speed * 100),\n self.player.lane, self.player.dx + 1)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 156, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/not_turn.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/notturn/main.js"} +{"name": "double_dunk", "split": "train", "game": "double_dunk", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Double Dunk as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves Atari's two-on-two, half-court possession game. Each team has a smaller\nMr. Outside and larger Mr. Inside. The controlled player is the ball carrier on offense and the\nmatching on-ball defender on defense. Mr. Outside has the stronger long shot and steal chance;\nMr. Inside has the stronger close shot and rebound weight.\n\nOn offense, the first action-5 press advances the selected play with a pass; the next begins a\njump, and a press during the rising phase releases the shot. Very close releases become dunks.\nShots behind the curved arc score three, normal baskets two, and foul shots one. A close defender\nreduces shot probability. On defense, action 5 attempts a steal against a dribbler or times a\nblock once the shooter jumps. Actions 1–4 move left, up, right, and down.\n\nMisses resolve through the two inside players' basket position. After a defensive rebound, the\nnew offense must move the ball behind the three-point line before shooting. Possessions also\nenforce the manual's ten-step shot clock and three-step lane limit. Poorly positioned steal\nattempts can produce a defensive foul and free throw.\n\nACTION MAPPING\n0: wait\n1: move left\n2: move up\n3: move right\n4: move down\n5: contextual shoot, pass, steal, or block\n\nINPUT CHANNEL TABLE\n0: both player-team athletes\n1: both computer-team athletes\n2: basket\n3: ball carrier\n4: previous positions of all four athletes\n5: scores, shot clock, lane count, jump phase, and clear-ball requirement\n\nSCORING, TERMINATION, AND HORIZON\nThe selected game ends when either team reaches 24. A made basket is clipped to the remaining\nplayer points, so cumulative player reward cannot exceed `score_cap = 24`. Normalization is\n`min(max(raw_score, 0), 24) / 24`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/double_dunk.py`):\n```python\nimport numpy as np\n\n\nBASKET = [1, 5]\nMOVE_DELTAS = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}\n\n\nclass DoubleDunkEnvironment:\n \"\"\"First-to-24 two-on-two half-court basketball game.\"\"\"\n\n score_cap = 24.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 300):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.player_team = [[7, 3], [4, 5]]\n self.opponent_team = [[7, 7], [3, 5]]\n self.previous_positions = [position.copy() for position in self.player_team + self.opponent_team]\n self.possession = \"player\"\n self.ball_handler = 0\n self.player_score = 0\n self.opponent_score = 0\n self.phase = \"live\"\n self.jump_age = 0\n self.pass_used = False\n self.shot_clock = 10\n self.lane_steps = 0\n self.cleared = True\n self.block_attempt = False\n self.steps = 0\n self.last_action = 0\n self.last_ball_position: list[int] | None = None\n self.terminal = False\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_positions = [position.copy() for position in self.player_team + self.opponent_team]\n self.last_ball_position = self._ball_position().copy()\n reward = 0.0\n if self.possession == \"player\":\n reward += self._player_offense(action)\n self._computer_defense()\n else:\n self._player_defense(action)\n self._computer_offense()\n if self.phase == \"jumping\":\n self.jump_age += 1\n self._update_violations()\n self.steps += 1\n if self.steps >= self.horizon or self.player_score >= 24 or self.opponent_score >= 24:\n self.terminal = True\n return reward, self.terminal\n\n def _player_offense(self, action: int) -> float:\n handler = self.player_team[self.ball_handler]\n if self.phase == \"jumping\":\n if action == 5:\n return self._resolve_shot(\"player\")\n return 0.0\n if action in MOVE_DELTAS:\n self._move(handler, action)\n if not self.cleared and self._outside_arc(handler):\n self.cleared = True\n elif action == 5:\n if not self.pass_used and self._distance(handler, BASKET) > 1:\n self.ball_handler = 1 - self.ball_handler\n self.pass_used = True\n else:\n self.phase = \"jumping\"\n self.jump_age = 0\n return 0.0\n\n def _player_defense(self, action: int) -> None:\n defender = self.player_team[self.ball_handler]\n if action in MOVE_DELTAS:\n self._move(defender, action)\n elif action == 5:\n if self.phase == \"jumping\":\n self.block_attempt = True\n else:\n self._attempt_steal()\n\n def _computer_defense(self) -> None:\n handler = self.player_team[self.ball_handler]\n defender = self.opponent_team[self.ball_handler]\n if self.phase == \"jumping\":\n return\n self._step_toward(defender, handler)\n\n def _computer_offense(self) -> None:\n handler = self.opponent_team[self.ball_handler]\n defender = self.player_team[self.ball_handler]\n if self.phase == \"jumping\":\n if self.jump_age >= 1:\n self._resolve_shot(\"opponent\")\n return\n if not self.cleared:\n target = [7, 2 if handler[1] < 5 else 8]\n self._step_toward(handler, target)\n if self._outside_arc(handler):\n self.cleared = True\n return\n distance = self._distance(handler, BASKET)\n if distance <= 2 or self.shot_clock <= 3:\n self.phase = \"jumping\"\n self.jump_age = 0\n else:\n self._step_toward(handler, BASKET)\n if self.phase == \"live\" and self._distance(handler, defender) == 0:\n handler[1] = int(np.clip(handler[1] + (1 if handler[1] <= 5 else -1), 0, 9))\n\n def _resolve_shot(self, team: str) -> float:\n offense = self.player_team if team == \"player\" else self.opponent_team\n defense = self.opponent_team if team == \"player\" else self.player_team\n handler = offense[self.ball_handler]\n defender = defense[self.ball_handler]\n distance = self._distance(handler, BASKET)\n if not self.cleared:\n self._change_possession()\n return 0.0\n points = 3 if self._outside_arc(handler) else 2\n dunk = distance <= 1\n skill = 0.82 if (self.ball_handler == 1 and distance <= 3) else 0.72 if (\n self.ball_handler == 0 and self._outside_arc(handler)\n ) else 0.58\n if dunk:\n skill = 0.96\n if self.jump_age > 2:\n skill -= 0.35\n guard_distance = self._distance(handler, defender)\n if guard_distance <= 1:\n skill -= 0.25\n if self.block_attempt and guard_distance <= 2:\n skill -= 0.4\n made = self.random.rand() < max(0.05, skill)\n self.phase = \"live\"\n self.jump_age = 0\n self.block_attempt = False\n if made:\n reward = 0.0\n if team == \"player\":\n awarded = min(points, 24 - self.player_score)\n self.player_score += awarded\n reward = float(awarded)\n else:\n self.opponent_score = min(24, self.opponent_score + points)\n self._change_possession()\n return reward\n self._resolve_rebound(team)\n return 0.0\n\n def _resolve_rebound(self, shooting_team: str) -> None:\n player_inside_distance = self._distance(self.player_team[1], BASKET)\n opponent_inside_distance = self._distance(self.opponent_team[1], BASKET)\n player_weight = 0.65 if player_inside_distance <= opponent_inside_distance else 0.35\n player_rebound = self.random.rand() < player_weight\n rebound_team = \"player\" if player_rebound else \"opponent\"\n self.possession = rebound_team\n self.ball_handler = 1\n self.phase = \"live\"\n self.pass_used = True\n self.shot_clock = 10\n self.lane_steps = 0\n self.cleared = rebound_team == shooting_team\n\n def _attempt_steal(self) -> None:\n ball_carrier = self.opponent_team[self.ball_handler]\n defender = self.player_team[self.ball_handler]\n distance = self._distance(ball_carrier, defender)\n if distance <= 1:\n chance = 0.6 if self.ball_handler == 0 else 0.35\n if self.random.rand() < chance:\n self._change_possession(\"player\")\n return\n if distance > 1 and self.random.rand() < 0.25:\n self._free_throw(\"opponent\")\n\n def _free_throw(self, team: str) -> None:\n made = self.random.rand() < 0.7\n if made and team == \"player\":\n self.player_score = min(24, self.player_score + 1)\n elif made:\n self.opponent_score = min(24, self.opponent_score + 1)\n self._change_possession(\"player\" if team == \"opponent\" else \"opponent\")\n\n def _update_violations(self) -> None:\n if self.phase != \"live\":\n return\n self.shot_clock -= 1\n handler = self._ball_position()\n in_lane = handler[0] <= 4 and 4 <= handler[1] <= 6\n self.lane_steps = self.lane_steps + 1 if in_lane else 0\n if self.shot_clock <= 0 or self.lane_steps > 3:\n self._change_possession()\n\n def _change_possession(self, possession: str | None = None) -> None:\n self.possession = possession or (\"opponent\" if self.possession == \"player\" else \"player\")\n self.ball_handler = 0\n self.phase = \"live\"\n self.jump_age = 0\n self.pass_used = False\n self.shot_clock = 10\n self.lane_steps = 0\n self.cleared = True\n self.block_attempt = False\n\n def _ball_position(self) -> list[int]:\n team = self.player_team if self.possession == \"player\" else self.opponent_team\n return team[self.ball_handler]\n\n @staticmethod\n def _move(position: list[int], action: int) -> None:\n row_delta, column_delta = MOVE_DELTAS[action]\n position[0] = int(np.clip(position[0] + row_delta, 1, 9))\n position[1] = int(np.clip(position[1] + column_delta, 0, 9))\n\n def _step_toward(self, position: list[int], target: list[int]) -> None:\n if position[0] != target[0]:\n position[0] += int(np.sign(target[0] - position[0]))\n elif position[1] != target[1]:\n position[1] += int(np.sign(target[1] - position[1]))\n\n @staticmethod\n def _distance(first: list[int], second: list[int]) -> int:\n return abs(first[0] - second[0]) + abs(first[1] - second[1])\n\n def _outside_arc(self, position: list[int]) -> bool:\n return self._distance(position, BASKET) >= 6\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for position in self.player_team:\n state[*position, 0] = True\n for position in self.opponent_team:\n state[*position, 1] = True\n state[*BASKET, 2] = True\n state[*self._ball_position(), 3] = True\n for position in self.previous_positions:\n state[*position, 4] = True\n state[9 - self.player_score // 10, self.player_score % 10, 5] = True\n state[6 - self.opponent_score // 10, self.opponent_score % 10, 5] = True\n state[3, : self.shot_clock, 5] = True\n state[2, : self.lane_steps, 5] = True\n if self.phase == \"jumping\":\n state[1, : min(10, self.jump_age + 1), 5] = True\n if not self.cleared:\n state[0, :3, 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 157, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/double_dunk.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "tape_j", "split": "train", "game": "tape_j", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Tape J as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to pull tape along the ground and over blocks.\nRelease with actions 0–4 to retract and bank\n`floor(distance × sqrt(distance) / 10 + 1)` points for the pull.\nFire touching the tape ends the episode, as does the tip scrolling\npast the left edge.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the tip, tape, ground and blocks, fire,\nretraction point, and counters. The port uses fixed difficulty and\nsamples tape segments against fire rectangles. Each action advances\nup to four frames over 400 actions. Clip scores to [0, 4000] and\ndivide by 4000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/tape_j.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import floor, hypot, sqrt\n\nimport numpy as np\n\n\n@dataclass\nclass Block:\n x: float\n width: float\n height: float\n\n\n@dataclass\nclass Fire:\n x: float\n y: float\n vx: float\n vy: float\n size: float\n\n\nclass TapeJEnvironment:\n score_cap = 4000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.tip = np.array([100., 89.])\n self.base = self.tip.copy()\n self.mode = \"ground\"\n self.block = None\n self.scroll = self.distance = self.block_timer = 0.\n self.fire_timer = 100.\n self.steps = 0\n self.held = self.terminal = False\n self.blocks, self.tapes, self.fires = [], [], []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n if self.random.random() >= self.sticky_action_prob:\n self.held = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _corner(self, mode):\n self.tapes.append((self.base.copy(), self.tip.copy()))\n self.base = self.tip.copy()\n self.mode = mode\n\n def _pull(self):\n self.distance += 1\n if self.mode in (\"ground\", \"top\"):\n self.tip[0] += 1\n if self.mode == \"up\":\n self.tip[1] -= 1\n height = 90 - self.block.height\n if self.tip[1] < height:\n self.tip[1] = height\n self._corner(\"top\")\n elif self.mode == \"top\" and self.tip[0] > self.block.x + self.block.width + 1:\n self.tip[0] = self.block.x + self.block.width + 1\n self._corner(\"down\")\n elif self.mode == \"down\":\n self.tip[1] += 1\n if self.tip[1] > 89:\n self.tip[1] = 89\n self._corner(\"ground\")\n self.tip[0] += 3\n self.block = None\n\n def _advance(self):\n reward = 0\n if self.held:\n self._pull()\n else:\n if self.distance:\n reward = floor(sqrt(self.distance) * self.distance * 0.1 + 1)\n self.distance = 0\n start, end = self.tapes[0] if self.tapes else (self.base, self.tip)\n start += (end - start) * 0.2\n if self.tapes and np.linalg.norm(end - start) < 3:\n self.tapes.pop(0)\n self.terminal = self.tip[0] < 0\n for start, end in [*self.tapes, (self.base, self.tip)]:\n start[0] = max(0, start[0] - self.scroll)\n end[0] -= self.scroll\n self.tapes = [(start, end) for start, end in self.tapes if end[0] >= 0]\n self.scroll = 0.1 + max(0, self.tip[0] - 50) * 0.1\n self.block_timer -= self.scroll\n if self.block_timer < 0:\n width = self.random.uniform(20, 40)\n self.blocks.append(Block(200, width, self.random.uniform(10, 50)))\n self.block_timer = width + self.random.uniform(20, 70)\n for block in self.blocks:\n if self.mode == \"ground\" and block.x - 1.5 < self.tip[0] < block.x + block.width + 1.5:\n self.tip[:] = block.x - 1, 89\n self._corner(\"up\")\n self.block = block\n block.x -= self.scroll\n self.blocks = [block for block in self.blocks if block.x + block.width >= 0]\n self.fire_timer -= 1\n if self.fire_timer < 0:\n size = self.random.uniform(5, 15)\n self.fires.append(Fire(self.random.uniform(150, 220), -size,\n -self.random.uniform(0.5, 1), self.random.uniform(0.8, 1.2), size))\n self.fire_timer = self.random.uniform(40, 60)\n points = self._tape_points()\n for fire in self.fires:\n fire.x += fire.vx - self.scroll\n fire.y += fire.vy\n self.terminal |= bool(np.any((abs(points[:, 0] - fire.x) < fire.size / 2 + 1.5)\n & (abs(points[:, 1] - fire.y) < fire.size / 2 + 1.5)))\n self.fires = [fire for fire in self.fires if fire.y <= 90]\n return reward\n\n def _tape_points(self):\n segments = [*self.tapes, (self.base, self.tip)]\n return np.concatenate([np.linspace(start, end, max(2, int(hypot(*(end - start))) + 1))\n for start, end in segments])\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for channel, points in ((0, self.tip[None]), (1, self._tape_points()),\n (4, (self.tapes[0][0] if self.tapes else self.base)[None])):\n visible = points[(points[:, 0] >= 0) & (points[:, 0] < 200)]\n cols, rows = (visible // (20, 10)).astype(int).T\n state[rows, cols, channel] = True\n rows, cols = np.ogrid[:100:10, :200:20]\n state[9, :, 2] = True\n for block in self.blocks:\n state[:, :, 2] |= (cols < block.x + block.width) & (cols + 20 > block.x) & (rows + 10 > 90 - block.height)\n for fire in self.fires:\n state[:, :, 3] |= (abs(cols + 10 - fire.x) < fire.size / 2 + 10) & (\n abs(rows + 5 - fire.y) < fire.size / 2 + 5)\n values = (self.steps, int(self.distance), self.held, (\"ground\", \"up\", \"top\", \"down\").index(self.mode))\n for row, value in enumerate(values):\n for bit in range(11):\n state[row + bit // 10 * 4, bit % 10, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 158, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tape_j.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/tapej/main.js"} +{"name": "centipede", "split": "train", "game": "centipede", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Centipede as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves Atari's mushroom-field shooter loop. A nine-segment centipede crosses\nthe screen, descends when it reaches an edge or mushroom, and splits into independent chains when\na body segment is shot. The destroyed segment becomes a three-hit mushroom and the segment behind\nit becomes a new head. The player moves within the bottom quarter and fires one upward shot at a\ntime.\n\nFour waves progressively replace body segments with detached heads. Spiders cross the player\nzone and score 300, 600, or 900 according to shooting distance. Fleas need two hits, accelerate\nafter the first, drop mushrooms, and score 200. The fourth wave includes a scorpion worth 1,000;\nit poisons mushrooms, making an encountering centipede dive. Destroying it cures the field. A\ncollision costs one of three lives, restores mushroom health, cures poison, and awards five points\nfor each pair of mushrooms, matching the manual's life-loss mushroom tally.\n\nACTION MAPPING\n0: wait\n1: move left\n2: move up\n3: move right\n4: move down\n5: fire\n\nINPUT CHANNEL TABLE\n0: player blaster\n1: centipede and specialist-insect hazards; poisoned mushrooms\n2: shootable segments, insects, and mushrooms\n3: player shot\n4: previous player and insect positions\n5: heads, mushrooms, lives, and wave gauge\n\nSCORING, TERMINATION, AND HORIZON\nThe structural maximum is `score_cap = 9,528`:\n\n- 36 segment identities across four waves, each maximally destroyed as a head: 3,600.\n- Four spiders at the closest 900-point range: 3,600.\n- Four fleas at 200: 800.\n- One scorpion at 1,000: 1,000.\n- At most 63 distinct mushrooms (15 initial, 36 segment, 12 flea) destroyed: 63.\n- Three life-loss tallies over at most 63 mushrooms: `3 * floor(63 / 2) * 5 = 465`.\n\nThe environment normalizes with `min(max(raw_score, 0), 9_528) / 9_528`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/centipede.py`):\n```python\nimport numpy as np\n\n\nINITIAL_MUSHROOMS = (\n (1, 1), (1, 5), (1, 8), (2, 3), (2, 7),\n (3, 1), (3, 5), (3, 9), (4, 2), (4, 6),\n (5, 0), (5, 4), (5, 8), (6, 2), (6, 7),\n)\n\n\nclass CentipedeEnvironment:\n \"\"\"Four-wave mushroom-field shooter with splitting chains and specialist insects.\"\"\"\n\n score_cap = 9_528.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 2_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.player = [9, 5]\n self.previous_player = self.player.copy()\n self.shot: list[int] | None = None\n self.mushrooms = {position: {\"health\": 3, \"poisoned\": False} for position in INITIAL_MUSHROOMS}\n self.lives = 3\n self.wave = 0\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self._start_wave()\n\n def _start_wave(self) -> None:\n head_count = self.wave + 1\n main_length = 10 - head_count\n self.chains = [self._make_chain(main_length, 0, 1)]\n for index in range(head_count - 1):\n self.chains.append(self._make_chain(1, index + 1, -1 if index % 2 else 1))\n self.spider: list[int] | None = [8, 9]\n self.flea: dict[str, object] | None = {\"position\": [0, int(self.random.randint(10))], \"health\": 2}\n self.scorpion: list[int] | None = [3, 0] if self.wave >= 3 else None\n self.previous_insects: list[list[int]] = []\n self.wave_steps = 0\n\n @staticmethod\n def _make_chain(length: int, row: int, direction: int) -> dict[str, object]:\n start = 0 if direction > 0 else 9\n segments = [[row, (start - direction * index) % 10] for index in range(length)]\n return {\"segments\": segments, \"direction\": direction, \"diving\": False}\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n if action in (1, 2, 3, 4):\n row_delta, column_delta = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}[action]\n target = [self.player[0] + row_delta, self.player[1] + column_delta]\n if 7 <= target[0] <= 9 and 0 <= target[1] < 10:\n self.player = target\n elif action == 5 and self.shot is None:\n self.shot = [self.player[0] - 1, self.player[1]]\n\n self.previous_insects = self._insect_positions()\n self._move_centipedes()\n self._move_specials()\n if self.shot is not None:\n self.shot[0] -= 1\n if self.shot[0] < 0:\n self.shot = None\n reward = self._resolve_shot()\n reward += self._resolve_contacts()\n self.wave_steps += 1\n self.steps += 1\n if not self.chains:\n self.wave += 1\n if self.wave == 4:\n self.terminal = True\n else:\n self._start_wave()\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_centipedes(self) -> None:\n for chain in self.chains:\n segments = chain[\"segments\"]\n previous = [segment.copy() for segment in segments]\n head = segments[0]\n if bool(chain[\"diving\"]):\n head[0] = min(9, head[0] + 1)\n if head[0] >= 8:\n chain[\"diving\"] = False\n chain[\"direction\"] = -int(chain[\"direction\"])\n else:\n target_column = head[1] + int(chain[\"direction\"])\n target = (head[0], target_column)\n if target_column < 0 or target_column > 9 or target in self.mushrooms:\n mushroom = self.mushrooms.get(target)\n if mushroom is not None and bool(mushroom[\"poisoned\"]):\n chain[\"diving\"] = True\n head[0] = min(9, head[0] + 1)\n chain[\"direction\"] = -int(chain[\"direction\"])\n else:\n head[1] = target_column\n for index in range(1, len(segments)):\n segments[index][:] = previous[index - 1]\n\n def _move_specials(self) -> None:\n if self.spider is not None:\n self.spider[1] += -1 if self.wave_steps % 4 < 2 else 1\n self.spider[0] = int(np.clip(self.spider[0] + (-1 if self.wave_steps % 3 == 0 else 1), 7, 9))\n if self.spider[1] < 0 or self.spider[1] > 9:\n self.spider[1] %= 10\n if self.flea is not None:\n position = self.flea[\"position\"]\n position[0] += 2 if int(self.flea[\"health\"]) == 1 else 1\n if position[0] in (2, 4, 6) and tuple(position) not in self.mushrooms:\n self.mushrooms[tuple(position)] = {\"health\": 3, \"poisoned\": False}\n if position[0] > 9:\n self.flea = None\n if self.scorpion is not None:\n self.scorpion[1] += 1\n position = tuple(self.scorpion)\n if position in self.mushrooms:\n self.mushrooms[position][\"poisoned\"] = True\n if self.scorpion[1] > 9:\n self.scorpion = None\n\n def _resolve_shot(self) -> float:\n if self.shot is None:\n return 0.0\n for chain in self.chains.copy():\n segments = chain[\"segments\"]\n hit_index = next((index for index, segment in enumerate(segments) if segment == self.shot), None)\n if hit_index is None:\n continue\n position = tuple(segments[hit_index])\n reward = 100.0 if hit_index == 0 else 10.0\n before = segments[:hit_index]\n after = segments[hit_index + 1:]\n self.chains.remove(chain)\n if before:\n self.chains.append({\"segments\": before, \"direction\": chain[\"direction\"], \"diving\": chain[\"diving\"]})\n if after:\n self.chains.append({\"segments\": after, \"direction\": -int(chain[\"direction\"]), \"diving\": False})\n self.mushrooms.setdefault(position, {\"health\": 3, \"poisoned\": False})\n self.shot = None\n return reward\n if self.spider == self.shot:\n distance = abs(self.spider[0] - self.player[0]) + abs(self.spider[1] - self.player[1])\n self.spider = None\n self.shot = None\n return 900.0 if distance <= 2 else 600.0 if distance <= 4 else 300.0\n if self.flea is not None and self.flea[\"position\"] == self.shot:\n self.flea[\"health\"] = int(self.flea[\"health\"]) - 1\n self.shot = None\n if int(self.flea[\"health\"]) == 0:\n self.flea = None\n return 200.0\n return 0.0\n if self.scorpion == self.shot:\n self.scorpion = None\n self.shot = None\n for mushroom in self.mushrooms.values():\n mushroom[\"poisoned\"] = False\n return 1_000.0\n shot_position = tuple(self.shot)\n mushroom = self.mushrooms.get(shot_position)\n if mushroom is not None:\n mushroom[\"health\"] = int(mushroom[\"health\"]) - 1\n self.shot = None\n if int(mushroom[\"health\"]) == 0:\n del self.mushrooms[shot_position]\n return 1.0\n return 0.0\n\n def _resolve_contacts(self) -> float:\n hazards = self._insect_positions()\n if self.player not in hazards:\n return 0.0\n bonus = float((len(self.mushrooms) // 2) * 5)\n self.lives -= 1\n self.player = [9, 5]\n self.previous_player = self.player.copy()\n self.shot = None\n for mushroom in self.mushrooms.values():\n mushroom[\"poisoned\"] = False\n mushroom[\"health\"] = 3\n if self.lives <= 0:\n self.terminal = True\n return bonus\n\n def _insect_positions(self) -> list[list[int]]:\n positions = [segment.copy() for chain in self.chains for segment in chain[\"segments\"]]\n if self.spider is not None:\n positions.append(self.spider.copy())\n if self.flea is not None:\n positions.append(list(self.flea[\"position\"]))\n if self.scorpion is not None:\n positions.append(self.scorpion.copy())\n return positions\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n for chain in self.chains:\n for index, segment in enumerate(chain[\"segments\"]):\n state[*segment, 1] = True\n state[*segment, 2] = True\n if index == 0:\n state[segment[0], segment[1], 5] = True\n for position in (self.spider, None if self.flea is None else self.flea[\"position\"], self.scorpion):\n if position is not None:\n state[*position, 1] = True\n state[*position, 2] = True\n for position, mushroom in self.mushrooms.items():\n state[*position, 2] = True\n state[*position, 5] = True\n if bool(mushroom[\"poisoned\"]):\n state[*position, 1] = True\n if self.shot is not None:\n state[*self.shot, 3] = True\n state[*self.previous_player, 4] = True\n for position in self.previous_insects:\n if 0 <= position[0] < 10 and 0 <= position[1] < 10:\n state[*position, 4] = True\n state[9, : self.lives, 5] = True\n state[8, : self.wave + 1, 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 159, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/centipede.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "tornado_twister", "split": "train", "game": "tornado_twister", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Tornado Twister as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to reverse vertical direction. Hold it to shrink and slow\ndown. Release with any other action to recover size and speed. The\ntornado bounces at the edges. Touch debris to pull it into an orbit.\nWhen it reaches the center it increases the tornado's full size and\nscores its size times the tornado's current size, rounded down.\nTouching an obstacle ends the episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the tornado, loose debris, larger loose\ndebris, captured debris, obstacles, and counters. The counters encode\nelapsed actions, effective action, direction, speed, current size, and\nfull size. The original 150×100 field uses 15×10-unit cells.\nDifficulty is fixed and a capture starts with at least one unit of\norbit radius. Each action advances up to four frames over 400 actions.\nClip the episode score to [0, 1000] and divide by 1000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/tornado_twister.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import atan2, cos, floor, hypot, sin, sqrt\n\nimport numpy as np\n\n\n@dataclass\nclass Debris:\n x: float\n y: float\n size: int\n distance: float = 0.\n angle: float = 0.\n\n\n@dataclass\nclass Obstacle:\n x: float\n y: float\n width: float\n height: float\n\n\nclass TornadoTwisterEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.y, self.direction, self.speed = 75., 1, 1.\n self.size = self.current_size = 7.\n points = self.random.uniform(-10, 10, (20, 2))\n self.radii = np.hypot(points[:, 0], points[:, 1])\n self.angles = np.arctan2(points[:, 1], points[:, 0])\n self.debris, self.obstacles = [], []\n self.debris_timer = self.obstacle_timer = 0.\n self.steps = self.frames = self.action = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n if self.action == 5 and previous != 5:\n self.direction *= -1\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _cloud(self):\n angles = self.angles + self.frames * 0.15 * (1 - np.arange(20) / 20)\n radius = self.radii * self.current_size / 10\n return 20 + radius * np.cos(angles), self.y + radius * np.sin(angles)\n\n def _advance(self):\n if self.action == 5:\n self.current_size += (3 - self.current_size) * 0.1\n self.speed += (0.1 - self.speed) * 0.1\n else:\n self.current_size += (self.size - self.current_size) * 0.03\n self.speed += (1 - self.speed) * 0.1\n self.y += self.direction * self.speed\n if self.y <= self.current_size:\n self.direction = 1\n if self.y >= 100 - self.current_size:\n self.direction = -1\n\n self.frames += 1\n cloud_x, cloud_y = self._cloud()\n padding = sqrt(self.current_size)\n\n def touches(x, y, width, height):\n return np.any((abs(cloud_x - x) <= (width + padding) / 2)\n & (abs(cloud_y - y) <= (height + padding) / 2))\n\n self.debris_timer -= 1\n if self.debris_timer <= 0:\n size = 3 if self.random.random() < 0.5 else (5 if self.random.random() < 0.7 else 4)\n self.debris.append(Debris(160, self.random.uniform(10, 90), size))\n self.debris_timer = self.random.uniform(30, 50)\n reward = 0\n remaining = []\n for item in self.debris:\n if item.distance > 0:\n item.distance -= 1\n item.angle += 0.2\n if item.distance <= 0:\n self.size += item.size * 0.05\n reward += floor(item.size * self.current_size)\n continue\n item.x = 20 + item.distance * cos(item.angle)\n item.y = self.y + item.distance * sin(item.angle)\n else:\n item.x -= 1\n if touches(item.x, item.y, item.size, item.size):\n dx, dy = item.x - 20, item.y - self.y\n item.distance = max(1, hypot(dx, dy) * 1.5)\n item.angle = atan2(dy, dx)\n if item.x >= -item.size:\n remaining.append(item)\n self.debris = remaining\n\n self.obstacle_timer -= 1\n if self.obstacle_timer < 0:\n width = self.random.uniform(20, 30)\n self.obstacles.append(Obstacle(150 + width / 2, self.random.uniform(10, 90),\n width, self.random.uniform(10, 20)))\n self.obstacle_timer += self.random.uniform(50, 150)\n for obstacle in self.obstacles:\n obstacle.x -= 1\n self.terminal = any(touches(o.x, o.y, o.width, o.height) for o in self.obstacles)\n self.obstacles = [o for o in self.obstacles if o.x > -o.width]\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n cloud_x, cloud_y = self._cloud()\n for x, y in zip(cloud_x, cloud_y, strict=True):\n if 0 <= x < 150 and 0 <= y < 100:\n state[int(y // 10), int(x // 15), 0] = True\n for item in self.debris:\n if 0 <= item.x < 150 and 0 <= item.y < 100:\n state[int(item.y // 10), int(item.x // 15), 3 if item.distance else 1] = True\n if item.size >= 4 and not item.distance:\n state[int(item.y // 10), int(item.x // 15), 2] = True\n rows, cols = np.ogrid[0:100:10, 0:150:15]\n for obstacle in self.obstacles:\n state[:, :, 4] |= ((abs(cols + 7.5 - obstacle.x) < obstacle.width / 2 + 7.5)\n & (abs(rows + 5 - obstacle.y) < obstacle.height / 2 + 5))\n values = (self.steps, self.action, self.direction > 0, round(self.speed * 100),\n round(self.current_size * 16), round(self.size * 16))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 160, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tornado_twister.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameTornadoTwister.c"} +{"name": "meteo_planet", "split": "train", "game": "meteo_planet", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Meteo Planet as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to rotate the planet a quarter turn. Actions\n0–4 release the button. Incoming waves contain a meteor\nflanked by collectibles. Catch collectibles to score their\nvalue and rotate out of the path of meteors. A meteor\nhitting the player ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, planet, meteors,\ncollectibles, nearby meteors, and gauges. The conversion\nuses rectangular hitboxes and fixed difficulty. Each action\nadvances four frames. The 400-action task clips scores to\n[0, 350] and divides by 350.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/meteo_planet.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Falling:\n distance: float\n lane: int\n value: int = 0\n\n\nclass MeteoPlanetEnvironment:\n score_cap = 350\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.fallings = [Falling(53, int(self.random.integers(4)))]\n self.next_lane = int(self.random.integers(1, 4))\n self.angle = self.timer = 0.0\n self.target_lane = self.steps = 0\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed:\n self.target_lane += 1\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _position(self, falling):\n angle = falling.lane * math.pi / 2 - self.angle\n return 50 + math.cos(angle) * falling.distance, 50 + math.sin(angle) * falling.distance\n\n def _advance(self):\n self.angle = min(self.target_lane * math.pi / 2, self.angle + 0.3)\n self.timer -= 1\n if self.timer < 0:\n count = int(self.random.integers(6))\n for index in range(-count, count + 1):\n value = count - abs(index) + 1 if index else 0\n self.fallings.append(Falling(100 + 6 * index, self.next_lane, value))\n self.next_lane = (self.next_lane + int(self.random.integers(1, 4))) % 4\n self.timer = self.random.uniform(30, 50)\n reward = 0\n remaining = []\n for falling in self.fallings:\n falling.distance -= 0.5\n x, y = self._position(falling)\n extent = 3 + (falling.value / 2 if falling.value else 3)\n if abs(x - 50) < extent and abs(y - 42) < extent:\n if falling.value:\n reward += falling.value\n continue\n self.terminal = True\n if falling.distance >= 5:\n remaining.append(falling)\n self.fallings = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[4, 5, 0] = True\n state[5, 5, 1] = True\n for falling in self.fallings:\n x, y = self._position(falling)\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), 2 if not falling.value else 3] = True\n if falling.distance < 25 and not falling.value and 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), 4] = True\n gauges = (self.steps, self.target_lane % 4, round(self.angle % math.tau * 80))\n for row, value in enumerate(gauges):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 161, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/meteo_planet.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameMeteoPlanet.c"} +{"name": "bamboo", "split": "train", "game": "bamboo", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Bamboo as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe runner moves automatically around a wrapping track. Press action 5\nto reverse direction and hold it to pass through stalks. Release it\n(actions 0–4) to harvest. Stalks below height 5 are ignored. Heights\n5 through 25 score the square of the harvest grade, with a 100-point\nbonus harvest above height 23. Hitting a taller stalk reverses and\nbriefly accelerates the runner, shortens and slows the stalk, and can\ndestroy it without scoring. A stalk reaching height 89 ends the run.\n\nINPUT CHANNEL TABLE\nThe 10×10 observation has six channels for the runner, leftward\nheading, stalks, harvestable tips, bonus tips, and a held-button and\nepisode-step gauge. Each action covers four simulation frames. The\nconversion uses a fixed difficulty and a horizontal collision radius\nin place of sprite collisions.\n\nSCORING, TERMINATION, AND HORIZON\nOver 400 actions, at most 23 stalks can spawn with at least 70\nsimulation frames between spawns. Each scores at most 100, so the\nraw-score cap is 2,300. Clip to [0, 2300] and divide by 2300.\n\nIn a 100-seed smoke test without sticky actions, always released\naveraged 227.24 raw points and reached 506. Always held scored zero.\nRandom hold and release averaged 38.69 and reached 160.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/bamboo.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\nMIN_SPAWN_INTERVAL = 70\nMAX_HARVEST = 100\nTRACK_WIDTH = 200\n\n\n@dataclass\nclass Stalk:\n x: int\n height: float = 0\n speed: float = 1\n\n\nclass BambooEnvironment:\n score_cap = math.ceil(HORIZON * FRAMES_PER_STEP / MIN_SPAWN_INTERVAL) * MAX_HARVEST\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.spawn_timer = 0\n self.pressed = self.terminal = False\n self.x = 190.0\n self.direction = 1\n self.boost = 0.0\n self.stalks: list[Stalk] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed:\n self.direction *= -1\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for _ in range(FRAMES_PER_STEP):\n reward += self._advance_frame()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self) -> int:\n self.x = (self.x + self.direction * (1 + self.boost)) % TRACK_WIDTH\n self.boost *= 0.9\n if self.spawn_timer == 0:\n self.stalks.append(Stalk(int(self.random.integers(5, 195))))\n self.spawn_timer = int(self.random.integers(MIN_SPAWN_INTERVAL, 101))\n self.spawn_timer -= 1\n\n reward = 0\n survivors = []\n for stalk in self.stalks:\n stalk.height += 0.14 * stalk.speed\n distance = abs(self.x - stalk.x)\n if not self.pressed and min(distance, TRACK_WIDTH - distance) <= 6:\n if 5 <= stalk.height <= 25:\n grade = math.ceil((stalk.height - 5) / 3)\n reward += MAX_HARVEST if grade == 7 else grade**2\n continue\n if stalk.height > 25:\n stalk.height *= 0.7\n stalk.speed *= 0.6\n self.direction *= -1\n self.boost = min(5, self.boost + 1)\n if stalk.height <= 25:\n continue\n if stalk.height > 50:\n stalk.speed *= 0.997\n if stalk.height >= 89:\n self.terminal = True\n survivors.append(stalk)\n self.stalks = survivors\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n column = int(self.x) // 20\n state[8, column, 0] = True\n state[8, column, 1] = self.direction < 0\n for stalk in self.stalks:\n column = stalk.x // 20\n height = max(1, math.ceil(stalk.height / 10))\n state[9 - height:9, column, 2] = True\n state[9 - height, column, 3] |= 5 <= stalk.height <= 25\n state[9 - height, column, 4] |= 23 < stalk.height <= 25\n state[9, 0, 5] = self.pressed\n for bit in range(9):\n state[9, bit + 1, 5] = bool(self.steps & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 162, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/bamboo.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBamboo.c"} +{"name": "fall_bounce", "split": "train", "game": "fall_bounce", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Fall Bounce as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe whale moves right automatically and wraps around the screen.\nHold action 5 to descend quickly and bounce off platforms.\nRelease with actions 0–4 to descend slowly and pass through them.\nA bounce scores the whale's depth below its starting height and\nreturns it toward the top. Falling below the arena ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the whale, platforms, bounce status,\nheld input, the bottom boundary, and gauges. Each action advances\nfour frames at fixed difficulty. The conversion uses rectangular\noverlap checks for bounces.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action task clips raw scores to [0, 1000] and divides by\n1,000. Across 100 seeds without sticky actions, idle and continuous\nhold scored zero. Random hold and release averaged 50.55 and\nreached 334.16.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/fall_bounce.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\n\n\n@dataclass\nclass Platform:\n x: float\n y: float\n width: float\n\n\nclass FallBounceEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.spawn_timer = 0\n self.pressed = self.bouncing = self.terminal = False\n self.x, self.y = 50.0, 10.0\n self.platforms: list[Platform] = []\n self._spawn_pair()\n\n def _spawn_pair(self) -> None:\n for _ in range(2):\n self.platforms.append(Platform(self.random.uniform(0, 85), -5, self.random.uniform(15, 35)))\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0.0\n for _ in range(FRAMES_PER_STEP):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _advance(self) -> float:\n if self.bouncing:\n self.y += (10 - self.y) * 0.2\n self.bouncing = abs(10 - self.y) >= 1\n else:\n self.y += 1.5 if self.pressed else 0.25\n self.x = (self.x + 1) % 100\n if self.y > 103:\n self.terminal = True\n return 0.0\n\n self.spawn_timer -= 1\n if self.spawn_timer < 0:\n self._spawn_pair()\n self.spawn_timer = math.ceil(self.random.uniform(40, 60))\n reward = 0.0\n for platform in self.platforms:\n platform.y += 1\n if (self.pressed and not self.bouncing and abs(platform.y - self.y) < 4\n and abs(platform.x - self.x) < platform.width / 2 + 5):\n self.bouncing = True\n reward = self.y - 10\n self.platforms = [platform for platform in self.platforms if platform.y < 103]\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row, col = min(9, int(self.y) // 10), int(self.x) // 10\n state[row, col, 0] = True\n state[row, col, 2] = self.bouncing\n state[row, col, 3] = self.pressed\n for platform in self.platforms:\n if 0 <= platform.y < 100:\n left = max(0, math.floor((platform.x - platform.width / 2) / 10))\n right = min(10, math.ceil((platform.x + platform.width / 2) / 10))\n state[int(platform.y) // 10, left:right, 1] = True\n state[9, :, 4] = True\n for row, value in enumerate((self.steps, self.spawn_timer, round(self.y * 4))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 163, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/fall_bounce.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameFallBounce.c"} +{"name": "road_runner", "split": "train", "game": "road_runner", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Road Runner as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves eight desert chases, four-direction road movement, jumping, the\nthree-life structure, increasingly valuable consecutive seed piles, 100-point steel shot and\nits magnetic Coyote penalty, Wile E. Coyote's pursuit, mines, trucks, cannon fire, falling rocks,\ncliffs, and the strategy of doubling back to lead Coyote into hazards. Coyote awards 200 points\nfor a mine, cannonball, or rock collision and 1,000 for a truck collision.\n\nACTION MAPPING\n0: wait\n1: run forward\n2: move up one road lane\n3: double back\n4: move down one road lane\n5: jump\n\nINPUT CHANNEL TABLE\n0: Road Runner\n1: Coyote, physical hazards, and projectiles\n2: seed piles and steel shot\n3: steel-shot marker and cliff extent\n4: previous Road Runner, Coyote, and projectile positions\n5: claimed rewards and exact level, lives, progress, streak, timers, and Coyote distance\n\nSCORING, TERMINATION, AND HORIZON\nA perfect course collects ten consecutive seed piles worth `100 + 200 + ... + 1,000 = 5,500`,\none 100-point steel shot, three 200-point Coyote collisions, and one 1,000-point truck collision,\nfor 7,200 points. Across eight courses, `score_cap = 8 × 7,200 = 57,600`. Normalization is\n`min(max(raw_score, 0), 57_600) / 57_600`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/road_runner.py`):\n```python\nimport numpy as np\n\n\nSEED_OFFSETS = tuple(3 + index * 3 for index in range(10))\nHAZARDS = {8: \"mine\", 16: \"truck\", 24: \"cannon\", 34: \"rock\", 38: \"cliff\"}\n\n\nclass RoadRunnerEnvironment:\n \"\"\"Eight desert chases with seed streaks and Coyote hazard baiting.\"\"\"\n\n score_cap = 57_600.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 2_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.level = 0\n self.lives = 3\n self.score = 0.0\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self.claimed: set[tuple[int, str, int]] = set()\n self._start_level()\n\n def _start_level(self) -> None:\n self.progress = 0\n self.lane = 5\n self.previous_lane = self.lane\n self.jump_timer = 0\n self.magnet_timer = 0\n self.seed_streak = 0\n self.coyote_distance = 8\n self.previous_coyote_distance = self.coyote_distance\n self.projectile: list[int] | None = None\n self.previous_projectile: list[int] | None = None\n self.level_steps = 0\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_lane = self.lane\n self.previous_coyote_distance = self.coyote_distance\n self.previous_projectile = None if self.projectile is None else self.projectile.copy()\n progress_before = self.progress\n if action == 1:\n self.progress += 1\n self.coyote_distance = min(9, self.coyote_distance + 2)\n elif action == 3:\n self.progress = max(0, self.progress - 1)\n self.coyote_distance -= 1\n elif action == 2:\n self.lane = max(3, self.lane - 1)\n elif action == 4:\n self.lane = min(7, self.lane + 1)\n elif action == 5:\n self.jump_timer = 3\n reward = self._resolve_course(progress_before)\n self._move_projectile()\n self.coyote_distance -= 1 + int(self.magnet_timer > 0)\n reward += self._resolve_coyote_hazard()\n self._resolve_player_hazards()\n self.score += reward\n self.steps += 1\n self.level_steps += 1\n self.jump_timer = max(0, self.jump_timer - 1)\n self.magnet_timer = max(0, self.magnet_timer - 1)\n if self.progress >= 40 and not self.terminal:\n self.level += 1\n if self.level >= 8:\n self.terminal = True\n else:\n self._start_level()\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _resolve_course(self, previous_progress: int) -> float:\n reward = 0.0\n for index, offset in enumerate(SEED_OFFSETS):\n identity = (self.level, \"seed\", index)\n if identity in self.claimed or not previous_progress < offset <= self.progress:\n continue\n self.claimed.add(identity)\n seed_lane = 4 + (index + self.level) % 4\n if self.lane == seed_lane:\n self.seed_streak = min(10, self.seed_streak + 1)\n reward += float(self.seed_streak * 100)\n else:\n self.seed_streak = 0\n steel_identity = (self.level, \"steel\", 0)\n if steel_identity not in self.claimed and previous_progress < 32 <= self.progress:\n self.claimed.add(steel_identity)\n if self.lane == 5:\n self.magnet_timer = 20\n reward += 100.0\n return reward\n\n def _move_projectile(self) -> None:\n if self.progress >= 23 and self.progress <= 28 and self.projectile is None:\n self.projectile = [self.lane, 9]\n if self.projectile is not None:\n self.projectile[1] -= 1 + self.level // 3\n if self.projectile[1] < 0:\n self.projectile = None\n\n def _resolve_coyote_hazard(self) -> float:\n if self.coyote_distance > 2:\n return 0.0\n for offset, kind in HAZARDS.items():\n if kind == \"cliff\" or abs(self.progress - offset) > 1:\n continue\n identity = (self.level, \"coyote\", offset)\n if identity in self.claimed:\n continue\n hazard_lane = 4 + (offset // 8 + self.level) % 4\n if self.lane == hazard_lane and self.jump_timer == 0:\n continue\n self.claimed.add(identity)\n self.coyote_distance = 8\n return 1_000.0 if kind == \"truck\" else 200.0\n return 0.0\n\n def _resolve_player_hazards(self) -> None:\n if self.coyote_distance <= 0:\n self._lose_life()\n return\n for offset, kind in HAZARDS.items():\n if abs(self.progress - offset) > 0:\n continue\n hazard_lane = 4 + (offset // 8 + self.level) % 4\n if self.lane != hazard_lane or self.jump_timer > 0:\n continue\n self._lose_life()\n return\n if self.projectile is not None and self.projectile == [self.lane, 5] and self.jump_timer == 0:\n self._lose_life()\n\n def _lose_life(self) -> None:\n self.lives -= 1\n if self.lives <= 0:\n self.terminal = True\n return\n self.lane = 5\n self.jump_timer = 0\n self.magnet_timer = 0\n self.coyote_distance = 8\n self.projectile = None\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[self.lane, 5, 0] = True\n state[self.previous_lane, 5, 4] = True\n coyote_column = max(0, 5 - self.coyote_distance)\n previous_coyote_column = max(0, 5 - self.previous_coyote_distance)\n state[self.lane, coyote_column, 1] = True\n state[self.previous_lane, previous_coyote_column, 4] = True\n for index, offset in enumerate(SEED_OFFSETS):\n screen_column = 5 + offset - self.progress\n if 0 <= screen_column < 10 and (self.level, \"seed\", index) not in self.claimed:\n lane = 4 + (index + self.level) % 4\n state[lane, screen_column, 2] = True\n steel_column = 5 + 32 - self.progress\n if 0 <= steel_column < 10 and (self.level, \"steel\", 0) not in self.claimed:\n state[5, steel_column, 2] = True\n state[5, steel_column, 3] = True\n for offset, kind in HAZARDS.items():\n screen_column = 5 + offset - self.progress\n if 0 <= screen_column < 10:\n lane = 4 + (offset // 8 + self.level) % 4\n state[lane, screen_column, 1] = True\n if kind == \"cliff\":\n state[3:8, screen_column, 3] = True\n if self.projectile is not None:\n state[*self.projectile, 1] = True\n if self.previous_projectile is not None:\n state[*self.previous_projectile, 4] = True\n for index in range(10):\n state[0, index, 5] = (self.level, \"seed\", index) in self.claimed\n state[1, 0, 5] = (self.level, \"steel\", 0) in self.claimed\n for index, offset in enumerate(HAZARDS):\n if HAZARDS[offset] != \"cliff\":\n state[1, 1 + index, 5] = (self.level, \"coyote\", offset) in self.claimed\n for bit in range(3):\n state[2, bit, 5] = bool(self.level & (1 << bit))\n state[2, 3 + bit, 5] = bool(self.lives & (1 << bit))\n for bit in range(6):\n state[3, bit, 5] = bool(self.progress & (1 << bit))\n for bit in range(4):\n state[3, 6 + bit, 5] = bool(self.seed_streak & (1 << bit))\n for bit in range(5):\n state[4, bit, 5] = bool(self.magnet_timer & (1 << bit))\n for bit in range(2):\n state[4, 5 + bit, 5] = bool(self.jump_timer & (1 << bit))\n for bit in range(4):\n index = 47 + bit\n state[index // 10, index % 10, 5] = bool(self.coyote_distance & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 164, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/road_runner.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "neon_pollinator", "split": "train", "game": "neon_pollinator", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Neon Pollinator as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to rise and grow your glow while spending\nenergy. Release with actions 0–4 to fall and shrink the\nglow. A new press resets the scoring multiplier. Flowers\npollinate when they touch a glow ring, earn the current\nmultiplier, and emit a fading glow that can pollinate others.\nCollect energy orbs to refuel. Leaving the screen ends the run.\n\nINPUT CHANNEL TABLE\nSix 10×10 channels show the player, unpollinated flowers,\npollinated flowers, glow rings, visible energy orbs, and\ngauges. The conversion approximates ring collisions\ngeometrically. It advances four frames per action at fixed\ndifficulty. The 400-action task clips scores to [0, 100]\nand divides by 100.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/neon_pollinator.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Flower:\n x: float\n y: float\n size: float\n pollinated: bool = False\n glow: float = 0\n\n\nclass NeonPollinatorEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.y, self.energy, self.glow = 50.0, 100.0, 5.0\n self.flower_distance = self.orb_distance = 0.0\n self.steps = 0\n self.multiplier = 1\n self.pressed = self.terminal = False\n self.flowers: list[Flower] = []\n self.orbs: list[tuple[float, float]] = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed:\n self.multiplier = 1\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n if self.pressed and self.energy > 0:\n self.y -= 1\n self.glow = min(25, self.glow + 0.25)\n self.energy -= 0.5\n else:\n self.y += 0.7\n self.glow = max(3, self.glow - 0.5)\n self.energy -= 0.1\n self.energy = max(0, self.energy)\n if not 0 <= self.y <= 100:\n self.terminal = True\n return 0\n self.flower_distance -= 0.5\n if self.flower_distance < 0:\n self.flowers.append(Flower(115, self.random.uniform(10, 90), self.random.uniform(5, 15)))\n self.flower_distance += 20\n for flower in self.flowers:\n flower.x -= 0.5\n self.flowers = [flower for flower in self.flowers if flower.x >= -10]\n lights = [(f.x, f.y, f.glow) for f in self.flowers if f.glow > 0]\n if self.glow > 3:\n lights.append((20, self.y, self.glow))\n reward = 0\n for flower in self.flowers:\n if not flower.pollinated and any(\n abs(radius - flower.size) - 2 < math.hypot(x - flower.x, y - flower.y)\n < radius + flower.size + 2 for x, y, radius in lights):\n flower.pollinated = True\n flower.glow = flower.size * 3\n reward += self.multiplier\n self.multiplier += 1\n flower.glow = max(0, flower.glow - 0.2)\n self.orb_distance -= 0.5\n if self.orb_distance < 0:\n self.orbs.append((100, self.random.uniform(10, 90)))\n self.orb_distance += self.random.uniform(16, 20)\n remaining = []\n for x, y in self.orbs:\n if abs(x - 20) < 7 and abs(y - self.y) < 7:\n self.energy = min(100, self.energy + 20)\n elif x >= -9.5:\n remaining.append((x - 0.5, y))\n self.orbs = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, max(0, int(self.y // 10))), 2, 0] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n if self.glow > 3:\n state[:, :, 3] = abs(np.hypot(cols - 20, rows - self.y) - self.glow) < 6\n for flower in self.flowers:\n distance = np.hypot(cols - flower.x, rows - flower.y)\n state[:, :, 2 if flower.pollinated else 1] |= abs(distance - flower.size) < 6\n if flower.glow:\n state[:, :, 3] |= abs(distance - flower.glow) < 6\n for x, y in self.orbs:\n visible = math.hypot(x - 20, y - self.y) < self.glow or any(\n math.hypot(x - f.x, y - f.y) < f.glow for f in self.flowers\n )\n if visible and 0 <= x < 100:\n state[int(y // 10), int(x // 10), 4] = True\n for row, value in enumerate((self.steps, round(self.energy * 4), round(self.glow * 10), self.multiplier)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 165, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/neon_pollinator.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameNeonPollinator.c"} +{"name": "atlantis", "split": "train", "game": "atlantis", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Atlantis as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves the Atari 2600 game's three-post defense. Action 1 fires the\nindestructible left sentry diagonally up and right, action 3 fires the right sentry diagonally up\nand left, and action 5 fires the central Acropolis Command Post straight up. The Acropolis force\nfield makes it the first installation destroyed; once it falls, the other six city installations\nbecome vulnerable and the center shot is unavailable.\n\nNine Gorgon vessels circle in formation and descend through approach lanes. Eight large vessels\nscore on direct hits. The ninth is a Bandit Bomber: destroying it awards its larger value, clears\nthe remaining formation, and awards no points for those collateral kills. Vessels reaching the\nlowest lane fire a deathray and leave the formation. A wave awards 500 points per surviving city\npart, and each accumulated 10,000 points restores one destroyed part after a wave. Five waves,\ntotal city destruction, or the 1,500-step horizon ends the episode; city destruction records the\nmanual's final survivor escape.\n\nACTION MAPPING\n0: wait\n1: fire left sentry diagonally right\n2: wait\n3: fire right sentry diagonally left\n4: wait\n5: fire central cannon upward\n\nINPUT CHANNEL TABLE\n0: left, right, and available central defense posts\n1: descending Gorgon threats\n2: directly hittable Gorgon reward targets\n3: all three friendly shot trajectories\n4: previous Gorgon positions\n5: Bandit identity, intact installations, and wave\n\nSCORING, TERMINATION, AND HORIZON\nManual values are retained. A perfect sentry-shot wave scores `8×200 + 2000 = 3600`; seven\nsurviving installations add `7×500 = 3500`. Across five waves, `score_cap = 5×7100 = 35,500`.\nCentral shots cannot exceed that sentry-shot bound, collateral Bandit kills never score, and\nrestoration changes survival state rather than adding reward. Normalization is\n`min(max(raw_score, 0), 35500) / 35500`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/atlantis.py`):\n```python\nimport numpy as np\n\n\nclass AtlantisEnvironment:\n \"\"\"Three fixed defense posts protect seven installations from descending formations.\"\"\"\n\n score_cap = 35_500.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 1_500):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.installations = [True] * 7\n self.shots: list[list[int | str]] = []\n self.wave = 0\n self.wave_step = 0\n self.steps = 0\n self.total_score = 0.0\n self.restorations_used = 0\n self.last_action = 0\n self.terminal = False\n self.escaped = False\n self._start_wave()\n\n def _start_wave(self) -> None:\n self.enemies = [\n {\"row\": index // 5, \"column\": (index * 2) % 10, \"direction\": 1, \"bandit\": index == 8}\n for index in range(9)\n ]\n self.previous_enemies = [[int(enemy[\"row\"]), int(enemy[\"column\"])] for enemy in self.enemies]\n self.wave_step = 0\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n if action == 1:\n self.shots.append([8, 1, -1, 1, \"sentry\"])\n elif action == 3:\n self.shots.append([8, 8, -1, -1, \"sentry\"])\n elif action == 5 and self.installations[0]:\n self.shots.append([8, 5, -1, 0, \"command\"])\n\n self.previous_enemies = [[int(enemy[\"row\"]), int(enemy[\"column\"])] for enemy in self.enemies]\n self._move_enemies()\n self._move_shots()\n reward = self._resolve_hits()\n self._resolve_deathrays()\n self.wave_step += 1\n self.steps += 1\n if not any(self.installations):\n self.escaped = True\n self.terminal = True\n elif not self.enemies:\n bonus = 500.0 * sum(self.installations)\n reward += bonus\n self.total_score += bonus\n self._restore_installations()\n self.wave += 1\n if self.wave == 5:\n self.terminal = True\n else:\n self._start_wave()\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_enemies(self) -> None:\n if self.wave_step % max(1, 4 - min(self.wave, 2)) != 0:\n return\n for enemy in self.enemies:\n column = int(enemy[\"column\"]) + int(enemy[\"direction\"])\n if column < 0 or column > 9:\n enemy[\"direction\"] = -int(enemy[\"direction\"])\n enemy[\"row\"] = int(enemy[\"row\"]) + 1\n column = min(9, max(0, column))\n enemy[\"column\"] = column\n\n def _move_shots(self) -> None:\n for shot in self.shots:\n shot[0] = int(shot[0]) + int(shot[2])\n shot[1] = int(shot[1]) + int(shot[3])\n self.shots = [shot for shot in self.shots if 0 <= int(shot[0]) < 10 and 0 <= int(shot[1]) < 10]\n\n def _resolve_hits(self) -> float:\n reward = 0.0\n remaining_shots = []\n for shot in self.shots:\n hit = next(\n (enemy for enemy in self.enemies if [enemy[\"row\"], enemy[\"column\"]] == shot[:2]),\n None,\n )\n if hit is None:\n remaining_shots.append(shot)\n continue\n sentry = shot[4] == \"sentry\"\n if bool(hit[\"bandit\"]):\n reward += 2_000.0 if sentry else 1_000.0\n self.enemies.clear()\n remaining_shots = []\n break\n reward += 200.0 if sentry else 100.0\n self.enemies.remove(hit)\n self.shots = remaining_shots\n self.total_score += reward\n return reward\n\n def _resolve_deathrays(self) -> None:\n attackers = [enemy for enemy in self.enemies if int(enemy[\"row\"]) >= 8]\n for enemy in attackers:\n live = [index for index, intact in enumerate(self.installations) if intact]\n if live:\n target = 0 if self.installations[0] else live[int(self.random.randint(len(live)))]\n self.installations[target] = False\n self.enemies.remove(enemy)\n\n def _restore_installations(self) -> None:\n available = int(self.total_score // 10_000) - self.restorations_used\n while available > 0 and not all(self.installations):\n target = next(index for index, intact in enumerate(self.installations) if not intact)\n self.installations[target] = True\n self.restorations_used += 1\n available -= 1\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[9, 0, 0] = True\n state[9, 9, 0] = True\n if self.installations[0]:\n state[9, 5, 0] = True\n for enemy in self.enemies:\n row, column = int(enemy[\"row\"]), int(enemy[\"column\"])\n state[row, column, 1] = True\n state[row, column, 2] = True\n if bool(enemy[\"bandit\"]):\n state[row, column, 5] = True\n for shot in self.shots:\n state[int(shot[0]), int(shot[1]), 3] = True\n for row, column in self.previous_enemies:\n if 0 <= row < 10 and 0 <= column < 10:\n state[row, column, 4] = True\n for index, intact in enumerate(self.installations):\n state[9, index + 1, 5] = intact\n state[8, : self.wave + 1, 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 166, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/atlantis.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "unctrl", "split": "train", "game": "unctrl", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Unctrl as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to fire the ready shot. Hold it to steer upward.\nRelease with any other action to steer downward. Intercept enemy\nbullets to score the multiplier and double it, up to 64. Destroy\na tank to score ten times the multiplier. A tank hit or a shot\nleaving the field reloads and resets the multiplier. An enemy\nbullet reaching your tank ends the run.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the player tank, fired shot, enemy tanks,\nenemy bullets, ready shot, and counters. The 150×100 field uses\n15×10-unit cells. Difficulty is fixed, and axis-aligned overlap\napproximates the original sprite and angled projectile collisions.\nEach action advances up to four frames over 400 actions. Clip the\nepisode score to [0, 500] and divide by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/unctrl.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Tank:\n x: float\n y: float\n angle: float\n timer: float\n\n\n@dataclass\nclass Bullet:\n x: float\n y: float\n vx: float\n vy: float\n\n\nclass UnctrlEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.tanks, self.bullets = [], []\n self.timer = 0.\n self.steps = self.action = 0\n self.terminal = False\n self._reload()\n\n def _reload(self):\n self.shot = Bullet(8, 50, 0.5, 0.2)\n self.fired = False\n self.multiplier = 1\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n fire = self.action == 5 and previous != 5\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(fire and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, fire):\n if self.fired:\n self.shot.vy += -0.1 if self.action == 5 else 0.1\n self.shot.x += self.shot.vx\n self.shot.y += self.shot.vy\n if not _inside(self.shot):\n self._reload()\n elif fire:\n self.fired = True\n\n self.timer = self.timer - 1 if self.tanks else -1\n if self.timer < 0:\n y = 50 + self.random.choice((-1, 1)) * self.random.uniform(20, 40)\n self.tanks.append(Tank(153, y, self._angle(), self.random.uniform(0, 60)))\n self.timer = 200\n\n reward = 0\n tanks = []\n for tank in self.tanks:\n tank.x -= 0.4 if tank.x < 70 else 0.1\n if self._hit(tank, 5):\n reward += self.multiplier * 10\n self._reload()\n continue\n tank.timer -= 1\n if tank.x > 70 and tank.timer < 0:\n self.bullets.append(Bullet(tank.x - 3, tank.y, cos(tank.angle) * 0.3,\n sin(tank.angle) * 0.3))\n tank.timer = 60\n tank.angle = self._angle()\n if tank.x >= -3:\n tanks.append(tank)\n self.tanks = tanks\n\n bullets = []\n for bullet in self.bullets:\n bullet.x += bullet.vx\n bullet.y += bullet.vy\n if self._hit(bullet, 4):\n reward += self.multiplier\n self.multiplier = min(64, self.multiplier * 2)\n else:\n if abs(bullet.x - 10) <= 4 and abs(bullet.y - 50) <= 4:\n self.terminal = True\n if _inside(bullet):\n bullets.append(bullet)\n self.bullets = bullets\n return reward\n\n def _hit(self, target, radius):\n return (self.fired and abs(self.shot.x + 1.5 - target.x) <= radius\n and abs(self.shot.y - target.y) <= radius)\n\n def _angle(self):\n return pi + self.random.uniform(-0.3 * pi, 0.3 * pi)\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[5, 0, 0] = True\n _mark(state, self.shot, 1 if self.fired else 4)\n for tank in self.tanks:\n _mark(state, tank, 2)\n for bullet in self.bullets:\n _mark(state, bullet, 3)\n values = (self.steps, self.action, self.multiplier, round((self.shot.vy + 16) * 16),\n round(self.timer))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n\ndef _inside(obj):\n return 0 <= obj.x < 150 and 0 <= obj.y < 100\n\n\ndef _mark(state, obj, channel):\n if _inside(obj):\n state[int(obj.y // 10), int(obj.x // 15), channel] = True\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 167, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/unctrl.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/unctrl/main.js"} +{"name": "recoil_radar", "split": "train", "game": "recoil_radar", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Recoil Radar as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to charge and expand the scan. Actions 0–4 release.\nA scan charged for at least ten frames fires at the nearest hazard\nin range on release. The shot scores the rounded value of\n`55 − distance` and kicks you away from the target. Hazards spawn at\nthe edges and drift toward you. Contact ends the episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the player, unscanned hazards, scanned\nhazards, scan area, shot trace, and counters. The port fixes\ndifficulty at one and samples the player's directional bar for\ncollisions. Each action advances up to four frames over a 400-action\nhorizon. Clip the episode score to [0, 500] and divide by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/recoil_radar.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import atan2, cos, floor, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Hazard:\n position: np.ndarray\n velocity: np.ndarray\n size: float\n\n\nclass RecoilRadarEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.position = np.array([50.0, 50.0])\n self.velocity = np.zeros(2)\n self.charge = self.steps = self.shot_ticks = 0\n self.radius = 8.0\n self.timer = 45\n self.held = self.terminal = False\n self.hazards = []\n self.shot = None\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance(held)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, held):\n reward = 0\n if held:\n self.charge += 1\n self.radius = min(46, 8 + self.charge * 0.55)\n elif self.held:\n target_index = None\n distance = self.radius\n if self.charge >= 10:\n for index, hazard in enumerate(self.hazards):\n candidate = np.linalg.norm(self.position - hazard.position)\n if candidate <= distance:\n target_index, distance = index, candidate\n if target_index is not None:\n target = self.hazards.pop(target_index)\n delta = self.position - target.position\n angle = atan2(delta[1], delta[0])\n self.velocity += (1.2 + (46 - distance) * 0.025) * np.array([cos(angle), sin(angle)])\n self.shot = (self.position.copy(), target.position.copy())\n self.shot_ticks = 5\n reward = floor(55 - distance + 0.5)\n self.charge, self.radius = 0, 8.0\n self.held = held\n self.position += self.velocity\n self.velocity *= 0.985\n lower = np.array([8, 9])\n self.velocity = np.where(self.position < lower, abs(self.velocity) * 0.8, self.velocity)\n self.velocity = np.where(self.position > 92, -abs(self.velocity) * 0.8, self.velocity)\n np.clip(self.position, lower, 92, out=self.position)\n self.timer -= 1\n if self.timer < 0:\n self._spawn()\n self.timer += 72\n angle = atan2(self.velocity[1], self.velocity[0])\n direction = np.array([cos(angle), sin(angle)])\n bar = self.position + np.linspace(-4.5, 4.5, 10)[:, None] * direction\n remaining = []\n for hazard in self.hazards:\n hazard.position += hazard.velocity * 0.63\n half = hazard.size / 2\n body_hit = np.all(abs(self.position - hazard.position) < half + 3)\n bar_hit = np.any(np.all(abs(bar - hazard.position) < half + 1, axis=1))\n self.terminal |= bool(body_hit or bar_hit)\n if np.all((-12 <= hazard.position) & (hazard.position <= 112)):\n remaining.append(hazard)\n self.hazards = remaining\n self.shot_ticks = max(0, self.shot_ticks - 1)\n return reward\n\n def _spawn(self):\n offset = self.random.uniform(10, 90)\n edge = self.random.integers(4)\n position = np.array(((offset, -5), (105, offset), (offset, 105), (-5, offset))[edge])\n delta = self.position - position\n angle = atan2(delta[1], delta[0]) + self.random.uniform(-0.45, 0.45)\n self.hazards.append(Hazard(position, np.array([cos(angle), sin(angle)]), self.random.uniform(5, 8)))\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n x, y = (self.position // 10).astype(int)\n state[y, x, 0] = True\n for hazard in self.hazards:\n hx, hy = (hazard.position // 10).astype(int)\n if 0 <= hx < 10 and 0 <= hy < 10:\n revealed = self.charge >= 10 and np.linalg.norm(hazard.position - self.position) <= self.radius\n state[hy, hx, 1 + int(revealed)] = True\n if self.held:\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n state[:, :, 3] = np.hypot(cols - self.position[0], rows - self.position[1]) <= self.radius\n if self.shot_ticks:\n points = np.linspace(*self.shot, 50)\n xs, ys = np.clip(points // 10, 0, 9).astype(int).T\n state[ys, xs, 4] = True\n gauges = (self.steps, min(511, self.charge), self.timer, self.held,\n int(round(self.velocity[0] * 16)) + 256, int(round(self.velocity[1] * 16)) + 256)\n for row, value in enumerate(gauges):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 168, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/recoil_radar.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameRecoilRadar.c"} +{"name": "wind_rang", "split": "train", "game": "wind_rang", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Wind Rang as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to reverse the wind. Release with any other action before\ntapping again. Boomerangs launch automatically and turn near the top.\nCatch a returning boomerang to increase the multiplier and earn ten\ntimes the new multiplier. A boomerang hitting an enemy earns the\ncurrent multiplier. An enemy reaching the bottom or the player ends\nthe run.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the player, outbound boomerangs, returning\nboomerangs, enemies, wind direction, and counters. The port uses fixed\ndifficulty and rectangular overlap for projectile hits. Each action\nadvances up to four frames over 400 actions. Clip episode scores to\n[0, 1000] and divide by 1000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/wind_rang.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Flyer:\n x: float\n y: float\n vy: float\n vx: float = 0.\n\n\nclass WindRangEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.boomerangs, self.enemies = [], []\n self.throw_timer, self.enemy_timer = 18, 77.\n self.wind = self.multiplier = 1\n self.action = self.steps = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n if self.action == 5 and previous != 5:\n self.wind *= -1\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n self.throw_timer -= 1\n if self.throw_timer <= 0:\n self.boomerangs.append(Flyer(50, 98, -1.5))\n self.throw_timer = 18\n reward = 0\n visible = []\n remaining = []\n for flyer in self.boomerangs:\n flyer.vx += self.wind * 0.08\n flyer.x += flyer.vx\n flyer.y += flyer.vy\n if flyer.y < 10:\n flyer.vy = 1.5\n visible.append(flyer)\n if flyer.vy > 0 and flyer.y > 93 and abs(flyer.x - 50) < 8:\n self.multiplier += 1\n reward += 10 * self.multiplier\n elif -5 <= flyer.x <= 105 and flyer.y <= 105:\n remaining.append(flyer)\n self.boomerangs = remaining\n\n self.enemy_timer -= 1\n if self.enemy_timer <= 0:\n self.enemies.append(Flyer(self.random.uniform(10, 90), 0, 0.25))\n self.enemy_timer = 77 * self.random.uniform(0.5, 2)\n remaining = []\n for enemy in self.enemies:\n enemy.vx += self.wind * 0.02\n enemy.x += enemy.vx\n if enemy.x < 0:\n enemy.x = 100\n elif enemy.x > 100:\n enemy.x = 0\n enemy.y += enemy.vy\n self.terminal |= enemy.y > 100\n if any(abs(enemy.x - b.x) < 5 and abs(enemy.y - b.y) < 5 for b in visible):\n reward += self.multiplier\n else:\n self.terminal |= enemy.y > 93 and abs(enemy.x - 50) < 5\n remaining.append(enemy)\n self.enemies = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[9, 5, 0] = True\n for flyer in self.boomerangs:\n _mark(state, flyer, 1 if flyer.vy < 0 else 2)\n for enemy in self.enemies:\n _mark(state, enemy, 3)\n state[0, 9 if self.wind > 0 else 0, 4] = True\n values = (self.steps, self.action, self.multiplier, self.throw_timer, round(self.enemy_timer))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n\ndef _mark(state, flyer, channel):\n if 0 <= flyer.x < 100 and 0 <= flyer.y < 100:\n state[int(flyer.y // 10), int(flyer.x // 10), channel] = True\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 169, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/wind_rang.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameWindRang.c"} +{"name": "pod_migration", "split": "train", "game": "pod_migration", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Pod Migration as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to turn clockwise. Actions 0–4 release.\nThe lead whale moves automatically and the pod follows.\nFollowers break ice for points, raising a multiplier\nthat decays over time. Mature ice knocks the leader back.\nTurning into followers can destroy them. Lost followers\ncan return after 300 frames, but losing all three ends the run.\n\nINPUT CHANNEL TABLE\nSix 10×10 channels show the leader, active and lost followers,\nmature and transitioning ice, and gauges. The conversion\napproximates ice and sprite collisions with rectangular bounds.\nAt fixed difficulty each action advances four frames. The\n400-action task clips scores to [0, 200] and divides by 200.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/pod_migration.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Whale:\n x: float\n y: float\n lost: bool = False\n\n\n@dataclass\nclass Ice:\n x: float\n y: float\n width: float\n height: float\n life: float\n age: int = 0\n\n def geometry(self):\n scale = 1 - (1 - min(1, self.age / 150)) ** 3\n if self.age > self.life - 120:\n scale *= max(0, 1 - ((self.age - self.life + 120) / 120) ** 2)\n height = self.height * scale\n return self.y + self.height - height, height\n\n\nclass PodMigrationEnvironment:\n score_cap = 200\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.lead = Whale(20, 50)\n self.pod = [Whale(10, 45), Whale(10, 55), Whale(5, 50)]\n self.ice: list[Ice] = []\n self.direction = self.steps = self.respawn = self.knockback = 0\n self.kx = self.ky = 0.0\n self.multiplier = 1.0\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed:\n self.direction = (self.direction + 1) % 4\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n self.multiplier = max(1, self.multiplier * 0.998)\n self.respawn += 1\n if self.respawn >= 300:\n whale = next((w for w in self.pod if w.lost), None)\n if whale is not None:\n whale.lost = False\n self.respawn = 0\n previous = self.lead\n for whale in self.pod:\n whale.x += (previous.x - whale.x) * 0.05\n whale.y += (previous.y - whale.y) * 0.05\n previous = whale\n if not whale.lost and abs(whale.x - self.lead.x) < 5 and abs(whale.y - self.lead.y) < 3:\n whale.lost = True\n self.respawn = 0\n chance = 0.03 if len(self.ice) < 3 else 0.02 if len(self.ice) < 5 else 0.01\n if self.random.random() < chance:\n x, y = self.random.uniform(10, 90, 2)\n if all(math.hypot(w.x - x, w.y - y) >= 20 for w in self.pod):\n self.ice.append(Ice(x, y, self.random.uniform(9, 16),\n self.random.uniform(6, 10), self.random.uniform(500, 600)))\n blocked = False\n reward = 0\n remaining = []\n for ice in self.ice:\n if ice.age < ice.life:\n y, height = ice.geometry()\n if height and any(not w.lost and self._hits(w, ice, y, height) for w in self.pod):\n reward += math.floor(self.multiplier + 0.5)\n self.multiplier += 1\n continue\n if 150 <= ice.age < ice.life - 120:\n blocked |= self._hits(self.lead, ice, y, height)\n ice.age += 1\n remaining.append(ice)\n self.ice = remaining\n dx, dy = ((1, 0), (0, 1), (-1, 0), (0, -1))[self.direction]\n if self.knockback:\n self.lead.x += self.kx\n self.lead.y += self.ky\n self.kx *= 0.88\n self.ky *= 0.88\n self.knockback -= 1\n if blocked:\n self.kx, self.ky, self.knockback = -1.8 * dx, -1.8 * dy, 25\n else:\n self.lead.x += dx\n self.lead.y += dy\n self.lead.x = min(97, max(3, self.lead.x))\n self.lead.y = min(97, max(3, self.lead.y))\n self.terminal = all(whale.lost for whale in self.pod)\n return reward\n\n @staticmethod\n def _hits(whale, ice, y, height):\n return abs(whale.x - ice.x) < ice.width / 2 + 3 and abs(whale.y - y) < height / 2 + 2\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(self.lead.y // 10), int(self.lead.x // 10), 0] = True\n for whale in self.pod:\n state[int(whale.y // 10), int(whale.x // 10), 2 if whale.lost else 1] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for ice in self.ice:\n y, height = ice.geometry()\n if height:\n channel = 3 if 150 <= ice.age < ice.life - 120 else 4\n state[:, :, channel] |= (abs(cols - ice.x) < ice.width / 2 + 5) & (abs(rows - y) < height / 2 + 5)\n gauges = (self.steps, self.direction, min(511, self.respawn), self.knockback,\n min(511, round(self.multiplier * 10)))\n for row, value in enumerate(gauges):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 170, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pod_migration.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePodMigration.c"} +{"name": "jpaddle", "split": "train", "game": "jpaddle", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Jpaddle as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to jump and reverse the paddle's movement\ndirection. Hold to move in that direction. Actions 0–4\nrelease the button. Jumps get smaller until you bounce a\nball. Each bounce restores up to nine jumps and scores\nmore at higher positions. Missed balls disappear. The\nepisode ends if the paddle sinks below the screen.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the paddle, falling balls,\nrising balls, projected ball positions, the loss line,\nand gauges. The conversion uses rectangular collision\nbounds and fixed difficulty, with four frames per action.\nThe 400-action task clips raw scores to [0, 600] and divides\nby 600.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/jpaddle.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Ball:\n x: float\n y: float\n vx: float\n vy: float\n\n\nclass JpaddleEnvironment:\n score_cap = 600\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x, self.y = 50.0, 90.0\n self.jumps = self.steps = self.frames = 0\n self.direction = -1\n self.pressed = self.terminal = False\n self.balls: list[Ball] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0.0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _advance(self, tap: bool) -> float:\n if tap and self.jumps < 99:\n self.jumps += 1\n self.y -= 12 // self.jumps\n self.direction *= -1\n else:\n self.y += 0.1\n if self.pressed and self.jumps:\n self.x += 0.5 * self.direction\n self.x = min(97, max(3, self.x))\n self.y = min(110, max(30, self.y))\n reward = 0.0\n remaining = []\n for ball in self.balls:\n ball.x += ball.vx\n ball.y += ball.vy\n if ball.x < 0 or ball.x > 97:\n ball.vx *= -1\n if ball.vy > 0 and abs(ball.x - self.x) < 7.5 and abs(ball.y - self.y) < 6.5:\n ball.y = self.y - 3\n ball.vy *= -1\n reward += 99 - ball.y\n self.jumps = max(0, self.jumps - 9)\n if ball.y <= 100:\n remaining.append(ball)\n self.balls = remaining\n if self.frames % 60 == 0:\n x = self.random.uniform(10, 90)\n vx = self.random.uniform(-1, 1)\n length = math.hypot(vx, 1)\n self.balls.append(Ball(x, 0, vx / length, 1 / length))\n self.frames += 1\n self.terminal = self.y > 99\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row, col = min(9, int(self.y // 10)), int(self.x // 10)\n state[row, col, 0] = True\n for ball in self.balls:\n if 0 <= ball.y < 100 and 0 <= ball.x < 100:\n state[int(ball.y // 10), int(ball.x // 10), 1 if ball.vy > 0 else 2] = True\n x, y = ball.x + 8 * ball.vx, ball.y + 8 * ball.vy\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), 3] = True\n state[9, :, 4] = True\n for row, value in enumerate((self.steps, self.jumps, round(self.x * 4), round(self.y * 4))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 171, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/jpaddle.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameJpaddle.c"} +{"name": "refbals", "split": "train", "game": "refbals", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Refbals as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to move all platforms left twice as fast. Actions 0–4\nreturn them to normal speed. Balls fall under gravity and score one\npoint each time they bounce off a platform. A ball falling past the\nbottom ends the episode. A new ball appears every 99 frames.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show descending balls, rising balls,\nplatforms, balls above the screen, descending balls near the bottom,\nand counters. The port keeps the source's rectangular collisions\nand uses NumPy for seeded randomness. Each action advances up to\nfour frames for up to 400 actions. Clip the episode score to\n[0, 100] and divide by 100.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/refbals.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Ball:\n x: float\n y: float = 0\n velocity: float = 0\n\n\nclass RefbalsEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.steps = self.frame = 0\n self.held = self.terminal = False\n self.balls = []\n self.walls = [(-29 * i, -9) for i in range(5)]\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.held = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n if self.frame % 99 == 0:\n self.balls.append(Ball(self.random.uniform(0, 50)))\n moving_walls = [(x - (2 if self.held else 1), y) for x, y in self.walls]\n self.walls = [\n (x + self.random.uniform(130, 150), self.random.uniform(50, 90))\n if x < -19 else (x, y)\n for x, y in moving_walls\n ]\n reward = 0\n for ball in self.balls:\n ball.velocity += 0.03\n ball.y += ball.velocity\n self.terminal |= ball.y > 99\n if any(abs(ball.x - x) < 20.5 and abs(ball.y - y) < 4 for x, y in moving_walls):\n reward += 1\n ball.velocity *= -1\n ball.y += ball.velocity * 2\n self.frame += 1\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n rows, cols = np.ogrid[:100:10, :100:10]\n for x, y in self.walls:\n state[:, :, 2] |= (cols < x + 18) & (cols + 10 > x - 18) & (rows < y + 1.5) & (rows + 10 > y - 1.5)\n for ball in self.balls:\n row, col = int(np.clip(ball.y // 10, 0, 9)), int(ball.x // 10)\n state[row, col, int(ball.velocity < 0)] = True\n if ball.y < 0:\n state[0, col, 3] = True\n if ball.y >= 80 and ball.velocity > 0:\n state[row, col, 4] = True\n for row, value in enumerate((self.steps, self.frame % 99, self.held)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 172, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/refbals.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/refbals/main.js"} +{"name": "press_m", "split": "train", "game": "press_m", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Press M as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nMove left with action 1 and right with action 3. The other actions hold\nposition. Find a gap before the two walls snap shut. Nearby coins home\nin on you as the walls close. Each coin scores the current multiplier\nand raises it by one. The multiplier drops by one after each press,\nto a minimum of one.\n\nINPUT CHANNEL TABLE\nThe 10×10 Boolean observation shows the player, upper wall, lower wall,\nattached coins, homing coins, and counters. The conversion replaces\npointer input with fixed-speed movement and uses rectangular sprite\ncollisions. At fixed difficulty a cycle lasts 80 frames. Each action\nadvances up to four frames, with a 400-action horizon. Clip the episode\nscore to [0, 1000] and divide by 1000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/press_m.py`):\n```python\nfrom math import hypot, pi, sin\n\nimport numpy as np\n\n\nclass PressMEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(400, horizon)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x = 50\n self.steps = self.action = self.frame = 0\n self.multiplier = 1\n self.terminal = False\n self.ends = np.repeat([[40.0], [60.0]], 10, axis=1)\n self.walls = self.ends.copy()\n self.flying = []\n self._new_cycle()\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def _new_cycle(self):\n self.multiplier = max(1, self.multiplier - 1)\n self.starts = np.empty((2, 10))\n for side, center in enumerate((20, 80)):\n angle = self.random.uniform(0, 2 * pi)\n velocity = self.random.uniform(0.4, 1) * self.random.choice((-1, 1))\n radius = self.random.uniform(10, 20)\n y = center + self.random.uniform(-5, 5)\n for col in range(10):\n self.starts[side, col] = np.clip(y + sin(angle) * radius, 2, 97)\n velocity += self.random.uniform(-0.1, 0.1)\n radius += self.random.uniform(-1, 1)\n angle += velocity\n y += self.random.uniform(-1, 1)\n gaps = self.starts[1] - self.starts[0]\n narrowest = np.argmin(gaps)\n self.targets = self.starts + np.array([[1], [-1]]) * gaps[narrowest] / 2\n if not np.any((self.targets[0] < 40) & (self.targets[1] > 60)):\n for col in range(10):\n if col != narrowest:\n adjustment = np.array([min(0, 40 - self.targets[0, col]),\n max(0, 60 - self.targets[1, col])])\n self.starts[:, col] += adjustment\n self.targets[:, col] += adjustment\n self.attached = list(zip(*np.where(self.random.random((2, 10)) < 0.2)))\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n self.x = min(96, max(3, self.x + 3 * ((self.action == 3) - (self.action == 1))))\n if self.frame < 60:\n self.walls = self.ends + (self.starts - self.ends) * (self.frame / 60)\n else:\n remaining = 79 - self.frame\n amount = 1 - remaining / 5 if remaining < 5 else (1 - remaining / 20) * 0.2\n self.walls = self.starts + (self.targets - self.starts) * amount\n if remaining < 5:\n self.terminal = any(\n col * 10 + 9 > self.x - 3 and col * 10 < self.x + 3\n and (self.walls[0, col] > 47.5 or self.walls[1, col] < 52.5)\n for col in range(10)\n )\n attached = []\n for side, col in self.attached:\n x = col * 10 + 5\n y = self.walls[side, col] + (4 if side == 0 else -4)\n if self.frame >= 60 and hypot(self.x - x, 50 - y) < 30:\n self.flying.append((x, y, self.random.uniform(0.1, 0.3)))\n else:\n attached.append((side, col))\n self.attached = attached\n reward = 0\n flying = []\n for x, y, speed in self.flying:\n x += (self.x - x) * speed\n y += (50 - y) * speed\n if abs(x - self.x) < 5 and abs(y - 50) < 5:\n reward += self.multiplier\n self.multiplier += 1\n else:\n flying.append((x, y, speed))\n self.flying = flying\n self.frame += 1\n if self.frame == 80:\n self.frame = 0\n self.ends = self.targets\n self._new_cycle()\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[5, int(self.x // 10), 0] = True\n rows = np.arange(10)[:, None] * 10\n state[:, :, 1] = rows < self.walls[0]\n state[:, :, 2] = rows + 10 > self.walls[1]\n for side, col in self.attached:\n y = self.walls[side, col] + (4 if side == 0 else -4)\n state[int(np.clip(y // 10, 0, 9)), col, 3] = True\n for x, y, _ in self.flying:\n state[int(np.clip(y // 10, 0, 9)), int(x // 10), 4] = True\n for row, value in enumerate((self.frame, self.multiplier, self.steps, self.action)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 173, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/press_m.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/pressm/main.js"} +{"name": "twhols", "split": "train", "game": "twhols", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Twhols as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe square moves diagonally and reverses horizontally at the side\nedges. Tap action 5 to reverse horizontally early. Release with any\nother action before tapping again. Touch the moving walls to bounce\nback toward the center and score one point per contact frame.\nPassing through a gap can take the square beyond the top or bottom,\nending the run.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the square, walls, gaps, rightward movement,\ndownward movement, and counters. The port fixes difficulty and uses\nrectangle overlap for wall contact. Each action advances up to four\nframes over 400 actions. Clip scores to [0, 100] and divide by 100.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/twhols.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import floor\n\nimport numpy as np\n\n\n@dataclass\nclass Wall:\n y: int\n gap: float = 0.\n speed: float = 1.\n\n\nclass TwholsEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x = self.y = 50.\n self.vx = self.vy = 1\n self.walls = [Wall(9), Wall(79)]\n self.action = self.steps = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n turn = self.action == 5 and previous != 5\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(turn and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, turn):\n self.x += self.vx\n self.y += self.vy\n reward = 0\n for wall in self.walls:\n if wall.y - 2.5 < self.y < wall.y + 7.5 and (\n self.x - 2.5 < wall.gap or self.x + 2.5 > wall.gap + 40\n ):\n self.vy = 1 if self.y < 50 else -1\n reward = 1\n wall.gap -= wall.speed\n if wall.gap < -40:\n wall.gap = 99\n wall.speed = self.random.uniform(1, 2)\n if turn or self.x < 0 or self.x > 99:\n self.vx *= -1\n self.terminal = self.y < 0 or self.y > 99\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n row, col = (min(9, max(0, floor(value / 10))) for value in (self.y, self.x))\n state[row, col, 0] = True\n cols = np.arange(5, 100, 10)\n for wall in self.walls:\n wall_row = (wall.y + 2) // 10\n gap = (cols >= wall.gap) & (cols < wall.gap + 40)\n state[wall_row, :, 1] = ~gap\n state[wall_row, :, 2] = gap\n state[row, col, 3] = self.vx > 0\n state[row, col, 4] = self.vy > 0\n values = (self.steps, self.action, round((self.walls[0].gap + 40) * 3),\n round((self.walls[1].gap + 40) * 3),\n *(round(wall.speed * 100) for wall in self.walls))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 174, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/twhols.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/twhols/main.js"} +{"name": "missile_guide", "split": "train", "game": "missile_guide", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Missile Guide as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to freeze the missile in place. While frozen,\nit passes through walls but uses fuel and cannot collect\noutposts. Actions 0–4 release it to home toward nearby\noutposts and slowly regenerate fuel. Wall contact while\nunfrozen or running out of fuel ends the run.\n\nINPUT CHANNEL TABLE\nCollecting an outpost restores fuel and scores one point\nplus one for every three outposts in the current combo.\nMissed outposts reset the combo. Six 10×10 channels show\nthe missile, outposts, walls, gaps, target, and gauges.\n\nSCORING, TERMINATION, AND HORIZON\nThe conversion uses fixed difficulty and rectangular\nhitboxes. Each action advances four frames, up to 400\nactions. Scores are clipped to [0, 120] and divided by 120.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/missile_guide.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Outpost:\n x: float\n y: float = -5\n phase: float = 0\n\n\n@dataclass\nclass Wall:\n x: float\n y: float = -10\n\n\nclass MissileGuideEnvironment:\n score_cap = 120\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 50.0, 65.0\n self.last_x = 50.0\n self.fuel = 1000\n self.frames = self.steps = self.combo = 0\n self.timer = 30\n self.frozen = self.terminal = False\n self.outposts: list[Outpost] = []\n self.walls: list[Wall] = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.frozen = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _target(self):\n return min((o for o in self.outposts if -60 < o.y - self.y < 40),\n key=lambda o: abs(o.y - self.y), default=None)\n\n def _advance(self):\n self.fuel = self.fuel - 4 if self.frozen else min(1000, self.fuel + 1)\n if self.fuel <= 0:\n self.terminal = True\n return 0\n self.timer -= 1\n if not self.timer:\n x = min(88, max(12, self.last_x + self.random.uniform(-40, 40)))\n if self.random.random() < 0.8:\n self.outposts.append(Outpost(x, phase=self.random.uniform(0, math.tau)))\n self.last_x = x\n if self.frames > 60 and self.random.random() < 0.6:\n self.walls.append(Wall(min(80, max(20, x + self.random.uniform(-20, 20)))))\n self.timer = 50\n self.frames += 1\n if not self.frozen:\n target = self._target()\n if target is not None:\n self.x += min(0.8, max(-0.8, (target.x - self.x) * 0.03))\n self.y += min(0.8, max(-0.8, (target.y - self.y) * 0.01))\n self.x = min(94, max(6, self.x))\n self.y = min(90, max(60, self.y))\n reward = 0\n remaining = []\n for outpost in self.outposts:\n outpost.y += 0.6\n outpost.phase += 0.15\n radius = 3 * (1 + math.sin(outpost.phase) * 0.15)\n if not self.frozen and abs(outpost.x - self.x) < radius + 2 and abs(outpost.y - self.y) < radius + 3.5:\n self.combo += 1\n reward += 1 + self.combo // 3\n self.fuel = min(1000, self.fuel + 120)\n elif outpost.y > 105:\n self.combo = 0\n else:\n remaining.append(outpost)\n self.outposts = remaining\n for wall in self.walls:\n wall.y += 0.6\n if not self.frozen and abs(wall.y - self.y) < 6 and abs(wall.x - self.x) > 13:\n self.terminal = True\n self.walls = [wall for wall in self.walls if wall.y <= 105]\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, int(self.y // 10)), int(self.x // 10), 0] = True\n for outpost in self.outposts:\n if 0 <= outpost.y < 100:\n state[int(outpost.y // 10), int(outpost.x // 10), 1] = True\n for wall in self.walls:\n if 0 <= wall.y < 100:\n row = int(wall.y // 10)\n state[row, :, 2] |= abs(np.arange(5, 100, 10) - wall.x) >= 15\n state[row, int(wall.x // 10), 3] = True\n target = self._target()\n if target is not None and 0 <= target.y < 100:\n state[int(target.y // 10), int(target.x // 10), 4] = True\n for row, value in enumerate((self.steps, self.fuel // 2, self.combo, round(self.x * 4))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.frozen\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 175, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/missile_guide.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameMissileGuide.c"} +{"name": "bomb_up", "split": "train", "game": "bomb_up", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Bomb Up as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to throw a bomb, release with actions 0–4, then tap\nagain to detonate it. The blast pushes the player away from the\nbomb. Use that recoil to dodge rocks and reposition. The blast\nring destroys rocks for a rising combo. Throwing a new bomb\nresets the combo. Rock contact ends the run.\n\nINPUT CHANNEL TABLE\nThe 10×10 observation uses six channels for the player, bomb,\nrocks, blast ring, upward motion, and gauges. Each action advances\nfour frames at fixed difficulty. The conversion tests rock hits\nby distance to the blast ring and limits recoil at very close\nrange.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends on collision or after 400 actions. Clip raw scores\nto [0, 250] and divide by the fixed cap of 250.\n\nAcross 100 seeds without sticky actions, idle scored zero.\nRandom hold and release averaged 43.64 raw points and reached 208.\nTapping every four actions averaged 5.68 and reached 13.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/bomb_up.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\n\n\n@dataclass\nclass Body:\n x: float\n y: float\n vx: float = 0\n vy: float = 0\n\n\n@dataclass\nclass Blast:\n x: float\n y: float\n age: int = 0\n\n @property\n def radius(self) -> float:\n return 25 * math.sin(self.age * 0.15)\n\n def hits(self, x: float, y: float, tolerance: float) -> bool:\n return abs(math.hypot(x - self.x, y - self.y) - self.radius) <= tolerance\n\n\nclass BombUpEnvironment:\n score_cap = 250\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.spawn_timer = 0\n self.multiplier = 1\n self.pressed = self.terminal = False\n self.player = Body(50, 50)\n self.spawner = Body(80, 0)\n self.bomb: Body | None = None\n self.blast: Blast | None = None\n self.rocks: list[Body] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(FRAMES_PER_STEP):\n reward += self._advance_frame(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n @staticmethod\n def _bounce(body: Body) -> None:\n if (body.x < 7 and body.vx < 0) or (body.x > 93 and body.vx > 0):\n body.x = min(93, max(7, body.x))\n body.vx *= -0.7\n\n def _tap(self) -> None:\n player = self.player\n if self.bomb is None:\n direction = -1 if player.vx < 0 else 1\n self.bomb = Body(player.x + 2 * direction, player.y, player.vx + 0.5 * direction, player.vy)\n self.multiplier = 1\n return\n self.blast = Blast(self.bomb.x, self.bomb.y)\n dx, dy = player.x - self.bomb.x, player.y - self.bomb.y\n distance_squared = max(1, dx * dx + dy * dy)\n player.vx += 20 * dx / distance_squared\n player.vy += 20 * dy / distance_squared\n self.bomb = None\n\n def _advance_frame(self, tap: bool) -> int:\n player = self.player\n scroll = (40 - player.y) * 0.3 if player.y < 40 else min(0, (60 - player.y) * 0.2)\n self._bounce(player)\n player.vx *= 0.99\n player.vy = (player.vy + 0.02) * 0.99\n player.x += player.vx\n player.y += player.vy + scroll\n if tap:\n self._tap()\n if self.bomb is not None:\n bomb = self.bomb\n self._bounce(bomb)\n bomb.vx *= 0.98\n bomb.vy = (bomb.vy + 0.15) * 0.98\n bomb.x += bomb.vx\n bomb.y += bomb.vy + scroll\n if bomb.y > 103:\n self.bomb = None\n if self.blast is not None:\n self.blast.age += 1\n if self.blast.radius < 0:\n self.blast = None\n\n self.spawner.vx = (self.spawner.vx + self.random.uniform(-0.1, 0.1)) * 0.99\n self.spawner.x += self.spawner.vx\n self._bounce(self.spawner)\n if self.spawn_timer == 0:\n bottom = self.random.random() > (0.05 if player.y > 30 else 0.9)\n y = 103 if bottom else -3\n vy = -self.random.uniform(0.5, 1) if bottom else player.vy / 2\n self.rocks.append(Body(self.spawner.x, y, vy=vy))\n self.spawn_timer = int(self.random.integers(8, 11))\n self.spawn_timer -= 1\n\n reward = 0\n remaining = []\n for rock in self.rocks:\n rock.y += rock.vy\n rock.vy = (rock.vy + 0.01) * 0.99\n rock.y += rock.vy + scroll\n if self.blast is not None and self.blast.hits(rock.x, rock.y, 3.5):\n reward += self.multiplier\n self.multiplier += 1\n continue\n if abs(rock.x - player.x) < 5.5 and abs(rock.y - player.y) < 5.5:\n self.terminal = True\n if -50 <= rock.y <= 150:\n remaining.append(rock)\n self.rocks = remaining\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row = min(9, max(0, int(self.player.y) // 10))\n column = min(9, max(0, int(self.player.x) // 10))\n state[row, column, 0] = True\n state[row, column, 4] = self.player.vy < 0\n if self.bomb is not None and 0 <= self.bomb.x < 100 and 0 <= self.bomb.y < 100:\n state[int(self.bomb.y) // 10, int(self.bomb.x) // 10, 1] = True\n for rock in self.rocks:\n if 0 <= rock.y < 100:\n state[int(rock.y) // 10, int(rock.x) // 10, 2] = True\n if self.blast is not None:\n for y in range(10):\n for x in range(10):\n state[y, x, 3] = self.blast.hits(x * 10 + 5, y * 10 + 5, 7)\n for row, value in enumerate((self.steps, self.multiplier)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :3, 5] = self.pressed, self.bomb is not None, self.player.vx < 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 176, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/bomb_up.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/bombup/main.js"} +{"name": "raid", "split": "train", "game": "raid", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Raid as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to accelerate. Actions 0–4 release. Releasing drops a\nbomb if one is available, after the opening 31 frames. The plane\nautomatically turns and descends at each end of the screen. Clear\nbuildings before the plane reaches them. A bomb scores one point\nfor the block it hits, two for the next block above it, and so on.\nFalling debris can damage buildings without awarding points.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the plane, bomb, buildings, debris,\nflight direction, and counters. The port fixes difficulty at one,\nomits decorative clouds, and approximates collisions with rectangles.\nEach action advances up to four frames over a 400-action horizon.\nClip episode scores to [0, 300] and divide by 300.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/raid.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import ceil\n\nimport numpy as np\n\n\n@dataclass\nclass Bomb:\n x: float\n y: float\n vx: float\n vy: float\n\n\n@dataclass\nclass Debris:\n x: float\n y: float\n vy: float\n\n\nclass RaidEnvironment:\n score_cap = 300\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 50.0, 15.0\n self.vx, self.vy, self.speed = 1.0, 0.0, 1.0\n self.down_distance = self.recoil = 0.0\n self.steps = self.frame = 0\n self.held = self.terminal = False\n self.bomb = None\n self.heights = self.random.uniform(10, 60, 8)\n self.debris = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n released = self.held and not held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(released and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, released):\n scroll = max(0, self.y - 15) * 0.05\n if self.held:\n self.speed += 0.01\n else:\n self.speed += (1 - self.speed) * 0.2\n if released and self.bomb is None and self.frame > 30:\n self.bomb = Bomb(self.x, self.y, self.vx * self.speed, self.vy * self.speed)\n self.recoil = 0.33\n self.x += self.vx * self.speed\n self.y += self.vy * self.speed + self.recoil - scroll\n self.recoil *= 0.8\n if self.vy == 0:\n if (self.x < 10 and self.vx < 0) or (self.x > 90 and self.vx > 0):\n self.vy = 0.1\n self.down_distance = 1\n else:\n direction = 1 if self.x < 50 else -1\n self.vx += (direction - self.vx) * 0.05\n self.down_distance -= self.vy * self.speed\n if self.down_distance < 0:\n self.vx, self.vy = direction, 0\n bomb = self.bomb\n if bomb is not None:\n bomb.vy = (bomb.vy + 0.1) * 0.99\n bomb.vx *= 0.99\n bomb.x += bomb.vx\n bomb.y += bomb.vy - scroll\n if (bomb.x < 0 and bomb.vx < 0) or (bomb.x > 99 and bomb.vx > 0):\n bomb.vx *= -1\n if bomb.y > 99:\n self.bomb = bomb = None\n for fragment in self.debris:\n fragment.vy += 0.1\n fragment.y += fragment.vy - scroll\n self.debris = [fragment for fragment in self.debris if fragment.y <= 110]\n old_debris = tuple(self.debris)\n self.heights += scroll\n reward = 0\n for index, height in enumerate(self.heights):\n x = 10 + index * 10\n blocks = ceil(height / 10)\n base = 100 - height + blocks * 10\n for block in range(blocks):\n y = base - block * 10\n if bomb is not None and self._touches(x, y, bomb.x, bomb.y, 1.5, 1.5):\n removed = blocks - block\n reward += removed * (removed + 1) // 2\n self.heights[index] = max(0, 100 - y)\n self.bomb = bomb = None\n for offset in range(1, removed):\n self.debris.append(Debris(x, y - 10 * offset, -(offset + 1) * 0.5))\n break\n if any(abs(fragment.x - x) < 9 and abs(fragment.y - y) < 10 for fragment in old_debris):\n self.heights[index] = max(0, 100 - y)\n if self._touches(x, y, self.x, self.y, 3, 2.5):\n self.terminal = True\n self.frame += 1\n return reward\n\n @staticmethod\n def _touches(x, y, px, py, half_width, half_height):\n return x - half_width < px < x + 9 + half_width and y - half_height < py < y + 10 + half_height\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(np.clip(self.y // 10, 0, 9)), int(np.clip(self.x // 10, 0, 9)), 0] = True\n if self.bomb is not None and 0 <= self.bomb.x < 100 and 0 <= self.bomb.y < 100:\n state[int(self.bomb.y // 10), int(self.bomb.x // 10), 1] = True\n rows = np.arange(10) * 10\n for index, height in enumerate(self.heights):\n if height > 0:\n state[rows + 10 > 110 - height, index + 1, 2] = True\n for fragment in self.debris:\n state[(rows < fragment.y + 10) & (rows + 10 > fragment.y), int(fragment.x // 10), 3] = True\n ahead = self.x + self.vx * 10\n state[int(np.clip((self.y + self.vy * 10) // 10, 0, 9)),\n int(np.clip(ahead // 10, 0, 9)), 4] = True\n for row, value in enumerate((self.steps, round(self.speed * 100), self.held, self.vy > 0)):\n for bit in range(11):\n state[row + bit // 10 * 4, bit % 10, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 177, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/raid.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/raid/main.js"} +{"name": "lland", "split": "train", "game": "lland", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Lland as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe ship descends automatically for its first landing. After\nthat, hold action 5 to thrust upward and release with actions\n0–4 to descend. Each landing scores one point and pauses the\nterrain until the next press. Hitting a mountain or letting\na landing pad scroll past ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the ship, mountains, landing\npads, projected height, ship column, and gauges. The conversion\nuses rectangular contact bounds and four frames per action\nat fixed difficulty. The 400-action task clips scores to\n[0, 10] and divides by 10.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/lland.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Terrain:\n y: float\n pad: bool = False\n\n\nclass LlandEnvironment:\n score_cap = 10\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.terrain = [Terrain(49, True) if i == 4 else Terrain(90 - i) for i in range(9)]\n self.y, self.velocity = 30.0, 0.0\n self.offset = self.distance = self.index = self.steps = 0\n self.pad_countdown = 7\n self.landed = self.unlocked = self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _positions(self):\n for i, tile in enumerate(self.terrain):\n yield (i * 13 + self.offset) % 117 - 13, tile\n\n def _advance(self, tap: bool) -> int:\n if self.landed and not tap:\n return 0\n self.landed = False\n positions = list(self._positions())\n contacts = [tile for x, tile in positions if x < 28 and x + 13 > 22 and self.y + 3 > tile.y]\n missed_pad = any(tile.pad and x <= 0 < x + 13 for x, tile in positions)\n self.offset -= 1\n self.distance -= 1\n if self.distance < 0:\n pad = self.pad_countdown == 0\n low, high = (40, 70) if pad else (70 if self.pad_countdown > 7 or self.pad_countdown == 1 else 40, 90)\n self.terrain[self.index] = Terrain(self.random.uniform(low, high), pad)\n self.index = (self.index + 1) % 9\n self.distance += 13\n self.pad_countdown = 9 if pad else self.pad_countdown - 1\n if self.unlocked:\n self.velocity -= 0.4 * tap + 0.2 * self.pressed\n self.velocity = (self.velocity + 0.1) * 0.99\n if self.y < 0 and self.velocity < 0:\n self.velocity *= -1\n self.y += self.velocity\n self.terminal = missed_pad or any(not tile.pad for tile in contacts)\n for tile in contacts:\n if tile.pad:\n self.y, self.velocity = tile.y - 3, 0\n self.landed = self.unlocked = True\n for terrain in self.terrain:\n terrain.pad = False\n return 1\n return 0\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, max(0, int(self.y // 10))), 2, 0] = True\n for x, tile in self._positions():\n left, right = max(0, int(x // 10)), min(9, int((x + 13) // 10))\n state[int(tile.y // 10):, left:right + 1, 2 if tile.pad else 1] = True\n future = min(9, max(0, int((self.y + 4 * self.velocity) // 10)))\n state[future, 2, 3] = True\n state[:, 2, 4] = True\n values = (self.steps, round((self.velocity + 12) * 16), round(self.y * 4))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(min(511, max(0, value)) & (1 << bit))\n state[9, :3, 5] = self.pressed, self.landed, self.unlocked\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 178, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/lland.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/lland/main.js"} +{"name": "sub_jump", "split": "train", "game": "sub_jump", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Sub Jump as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to rise underwater and speed up. Actions 0–4 release,\nslowing the sub and letting it sink. Momentum carries the sub above\nthe waterline to clear land. Coins score the current multiplier and\nraise it. Missing a coin lowers the multiplier. Terrain contact ends\nthe episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the sub, land, underwater terrain, the\nwaterline, coins, and counters. The port uses fixed difficulty and\ninterpolates terrain at the sub's center for collision checks.\nEach action advances up to four frames over a 400-action horizon.\nClip episode scores to [0, 300] and divide by 300.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/sub_jump.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Point:\n x: float\n y: float\n\n\nclass SubJumpEnvironment:\n score_cap = 300\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 5., 60.\n self.vx = self.vy = self.terrain_velocity = 0.\n self.terrain_distance, self.coin_distance = 50., 0.\n self.steps = 0\n self.multiplier = 1\n self.land = self.held = self.terminal = False\n self.points = [Point(i * 10 - 10, self.random.uniform(75, 85)) for i in range(12)]\n self.coins = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n if self.random.random() >= self.sticky_action_prob:\n self.held = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _scroll_terrain(self, scroll):\n self.terrain_distance -= scroll\n for index, point in enumerate(self.points):\n point.x -= scroll\n if point.x >= -10:\n continue\n if self.terrain_distance < 0:\n self.land = not self.land\n self.terrain_distance = self.random.uniform(200, 300) / (7 if self.land else 1)\n point.x += 120\n previous = self.points[index - 1].y\n self.terrain_velocity = (self.terrain_velocity + self.random.uniform(-2, 2)) * 0.95\n if self.land:\n if previous > 50:\n self.terrain_velocity -= 5\n elif (previous < 40 and self.terrain_velocity < 0) or (previous > 45 and self.terrain_velocity > 0):\n self.terrain_velocity *= -0.5\n y = previous + self.terrain_velocity / 3\n else:\n if previous < 65:\n self.terrain_velocity += 5 if previous < 55 else 3\n elif previous > 90 and self.terrain_velocity > 0:\n self.terrain_velocity *= -0.5\n y = previous + self.terrain_velocity\n if self.terrain_distance < 60:\n self.terrain_velocity += 4\n point.y = min(95, max(35, y)) + self.random.uniform(-5, 5)\n\n def _advance(self):\n scroll = max(0, self.x - 10) * 0.2\n self._scroll_terrain(scroll)\n submerged = self.y > 50\n if self.held:\n self.vy += -0.06 if submerged else 0.01\n else:\n self.vy += 0.03 if submerged else 0.05\n self.vx += ((1 if self.held else 0.5) - self.vx) * 0.1\n drag = 0.95 if submerged else 0.99\n self.vx *= drag\n self.vy *= drag\n self.x += self.vx - scroll\n self.y += self.vy\n ordered = sorted(self.points, key=lambda point: point.x)\n terrain_y = np.interp(self.x, [point.x for point in ordered], [point.y for point in ordered])\n self.terminal = bool(abs(self.y - terrain_y) < 4)\n self.coin_distance -= scroll\n if self.coin_distance < 0:\n edge = ordered[-1]\n offset = self.random.uniform(5, 10) if edge.y < 50 else self.random.uniform(10, 20)\n self.coins.append(Point(edge.x, edge.y - offset))\n self.coin_distance = self.random.uniform(10, 40)\n reward = 0\n remaining = []\n for coin in self.coins:\n coin.x -= scroll\n if abs(coin.x - self.x) < 5 and abs(coin.y - self.y) < 5:\n reward += self.multiplier\n self.multiplier += 1\n elif coin.x < -3:\n self.multiplier = max(1, self.multiplier - 1)\n else:\n remaining.append(coin)\n self.coins = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(np.clip(self.y // 10, 0, 9)), int(self.x // 10), 0] = True\n ordered = sorted(self.points, key=lambda point: point.x)\n heights = np.interp(np.arange(5, 100, 10), [point.x for point in ordered],\n [point.y for point in ordered])\n for col, y in enumerate(heights):\n state[min(9, int(y // 10)), col, 1 if y < 50 else 2] = True\n state[5, :, 3] = True\n for coin in self.coins:\n if 0 <= coin.x < 100 and 0 <= coin.y < 100:\n state[int(coin.y // 10), int(coin.x // 10), 4] = True\n values = (self.steps, self.multiplier, self.held, round((self.vy + 5) * 40), round(self.vx * 100))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 179, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/sub_jump.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/subjump/main.js"} +{"name": "bowling", "split": "train", "game": "bowling", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Bowling as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion selects the Atari 2600 manual's steerable-ball variation. Before release, actions\n2 and 4 position the bowler vertically on the approach. Action 5 releases the ball. During its\nnine-cell trip down the lane, actions 2 and 4 steer it upward or downward and establish hook; the\nball's final row and hook determine a deterministic collision footprint over the triangular ten-pin\nrack. A correctly placed pocket hook produces a strike, while remaining pins persist for a second\nroll and can be targeted for a spare.\n\nThe task implements all ten frames with standard ten-pin scoring. Frames 1–9 allow two rolls unless\nthe first is a strike. A spare adds the next ball, a strike adds the next two balls, and the tenth\nframe grants one bonus ball after a spare or two after a strike. Score reward is emitted only as\npoints become determined, so delayed bonuses cannot be counted twice. The episode ends after the\ntenth frame or the 500-step safety horizon.\n\nACTION MAPPING\n0: wait\n1: wait\n2: move/steer up\n3: wait\n4: move/steer down\n5: release ball\n\nINPUT CHANNEL TABLE\n0: bowler\n1: gutter boundaries\n2: standing pins\n3: rolling ball\n4: previous ball position\n5: hook, roll, frame, and confirmed-score progress\n\nSCORING, TERMINATION, AND HORIZON\nNative ten-pin scoring has an exact maximum of 300: twelve consecutive strikes, including the two\ntenth-frame bonus balls. The scorer delays bonuses until their required future rolls exist and\nemits only the increase in confirmed score. Therefore `score_cap = 300` and normalization is\n`min(max(raw_score, 0), 300) / 300`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/bowling.py`):\n```python\nimport numpy as np\n\n\nPIN_POSITIONS = ((4, 6), (3, 7), (5, 7), (2, 8), (4, 8), (6, 8), (1, 9), (3, 9), (5, 9), (7, 9))\n\n\nclass BowlingEnvironment:\n \"\"\"Ten-frame steerable bowling with standard strike, spare, and tenth-frame scoring.\"\"\"\n\n score_cap = 300.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 500):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.bowler_row = 4\n self.ball: list[int] | None = None\n self.previous_ball: list[int] | None = None\n self.hook = 0\n self.standing = set(range(10))\n self.frames: list[list[int]] = [[] for _ in range(10)]\n self.frame = 0\n self.confirmed_score = 0\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n if self.ball is None:\n if action == 2:\n self.bowler_row = max(1, self.bowler_row - 1)\n elif action == 4:\n self.bowler_row = min(7, self.bowler_row + 1)\n elif action == 5:\n self.ball = [self.bowler_row, 0]\n self.previous_ball = self.ball.copy()\n self.hook = 0\n else:\n self.previous_ball = self.ball.copy()\n if action == 2:\n self.ball[0] = max(1, self.ball[0] - 1)\n self.hook = max(-1, self.hook - 1)\n elif action == 4:\n self.ball[0] = min(7, self.ball[0] + 1)\n self.hook = min(1, self.hook + 1)\n self.ball[1] += 1\n if self.ball[1] >= 9:\n previous_score = self.confirmed_score\n self._finish_roll()\n self.confirmed_score = self._score_available()\n reward = float(self.confirmed_score - previous_score)\n self.steps += 1\n return reward, self.terminal\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return 0.0, self.terminal\n\n def _finish_roll(self) -> None:\n knocked = self._knocked_pins()\n self.standing -= knocked\n pinfall = len(knocked)\n frame_rolls = self.frames[self.frame]\n frame_rolls.append(pinfall)\n self.ball = None\n self.previous_ball = None\n self.hook = 0\n if self.frame < 9:\n if pinfall == 10 or len(frame_rolls) == 2:\n self.frame += 1\n self.standing = set(range(10))\n return\n if len(frame_rolls) == 1:\n if pinfall == 10:\n self.standing = set(range(10))\n elif len(frame_rolls) == 2:\n if frame_rolls[0] == 10:\n if pinfall == 10:\n self.standing = set(range(10))\n elif sum(frame_rolls) == 10:\n self.standing = set(range(10))\n else:\n self.terminal = True\n else:\n self.terminal = True\n\n def _knocked_pins(self) -> set[int]:\n if not self.standing or self.ball is None:\n return set()\n entry_row = self.ball[0]\n if self.standing == set(range(10)) and entry_row == 4 and self.hook != 0:\n return self.standing.copy()\n knocked = {\n index\n for index in self.standing\n if abs(PIN_POSITIONS[index][0] - entry_row) <= 1\n }\n if self.hook < 0:\n knocked |= {index for index in self.standing if PIN_POSITIONS[index][0] < entry_row and abs(PIN_POSITIONS[index][0] - entry_row) <= 2}\n elif self.hook > 0:\n knocked |= {index for index in self.standing if PIN_POSITIONS[index][0] > entry_row and abs(PIN_POSITIONS[index][0] - entry_row) <= 2}\n return knocked\n\n def _score_available(self) -> int:\n flattened = [roll for frame in self.frames for roll in frame]\n score = 0\n cursor = 0\n for frame_index in range(9):\n frame = self.frames[frame_index]\n if not frame:\n break\n if frame[0] == 10:\n if cursor + 2 >= len(flattened):\n break\n score += 10 + flattened[cursor + 1] + flattened[cursor + 2]\n cursor += 1\n elif len(frame) == 2 and sum(frame) == 10:\n if cursor + 2 >= len(flattened):\n break\n score += 10 + flattened[cursor + 2]\n cursor += 2\n elif len(frame) == 2:\n score += sum(frame)\n cursor += 2\n else:\n break\n tenth = self.frames[9]\n if self.frame == 9 or self.terminal:\n score += sum(tenth)\n return score\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[self.bowler_row, 0, 0] = True\n state[0, :, 1] = True\n state[9, :, 1] = True\n for index in self.standing:\n state[*PIN_POSITIONS[index], 2] = True\n if self.ball is not None:\n state[*self.ball, 3] = True\n if self.previous_ball is not None:\n state[*self.previous_ball, 4] = True\n state[9, : self.frame + 1, 5] = True\n state[8, : min(10, len(self.frames[self.frame]) + 1), 5] = True\n score_bucket = min(9, self.confirmed_score // 30)\n state[7, : score_bucket + 1, 5] = True\n state[6, self.hook + 1, 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 180, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/bowling.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "crazy_climber", "split": "train", "game": "crazy_climber", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Crazy Climber as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves Atari's one-joystick climbing rhythm and four-building progression.\nAction 2 first raises the climber's hands to the next ledge, leaving the climber vulnerable, and\nthen pulls the body up for the building's 100, 200, 300, or 400 points per row. The climber can\nmove sideways only while braced with straight arms and cannot climb down. Two adjacent window\ncells represent the climber's hands: two closed windows cause a fall, while one closed window is\nsafe only if the player stays still.\n\nMad Doctor objects and condor eggs knock down a climber only during a reach; while braced they\nbounce off but subtract 100 from the building bonus. Girders always cause a fall. Buildings three\nand four include an electric sign whose shocks each remove 100 bonus points and whose eleventh\nshock causes a fall. At the roof, the player has 30 steps to align with and grab the moving\nhelicopter using action 5. The remaining time bonus is then awarded and the next building begins.\n\nACTION MAPPING\n0: wait\n1: move left while braced\n2: alternate raising/pulling the climber\n3: move right while braced\n4: return from reach to braced\n5: grab rescue helicopter\n\nINPUT CHANNEL TABLE\n0: climber\n1: closed windows, falling hazards, and live sign\n2: open windows and helicopter runner\n3: helicopter runner and electric-sign location\n4: previous climber and hazard positions\n5: girder identity, lives, building, reach phase, and shock gauge\n\nSCORING, TERMINATION, AND HORIZON\nThe finite four-building tour has eight scored rows per building, giving\n`8 × (100 + 200 + 300 + 400) = 8,000` climbing points. The manual's maximum building bonuses sum\nto `100,000 + 200,000 + 300,000 + 400,000 = 1,000,000`. Therefore\n`score_cap = 1,008,000`, with normalization\n`min(max(raw_score, 0), 1_008_000) / 1_008_000`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/crazy_climber.py`):\n```python\nimport numpy as np\n\n\nclass CrazyClimberEnvironment:\n \"\"\"Four-building two-phase climbing task with windows and falling hazards.\"\"\"\n\n score_cap = 1_008_000.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 2_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.building = 1\n self.lives = 5\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self.previous_player = [8, 4]\n self._start_building()\n\n def _start_building(self) -> None:\n self.player = [8, 4]\n self.previous_player = self.player.copy()\n self.reaching = False\n self.at_roof = False\n self.pickup_steps = 30\n self.helicopter_column = 0\n self.bonus = self.building * 100_000.0\n self.building_steps = 0\n self.electric_shocks = 0\n self.hazards: list[dict[str, object]] = []\n self.previous_hazards: list[list[int]] = []\n self._update_windows()\n\n def _update_windows(self) -> None:\n period = max(4, 9 - self.building)\n closed_span = 1 + self.building // 3\n self.windows = np.ones((8, 10), dtype=bool)\n for row in range(8):\n for column in range(10):\n phase = (self.building_steps + row * 3 + column * 5) % period\n self.windows[row, column] = phase >= closed_span\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n self.previous_hazards = [list(hazard[\"position\"]) for hazard in self.hazards]\n building_before_action = self.building\n reward = 0.0\n if self.at_roof:\n reward += self._act_on_roof(action)\n else:\n reward += self._act_on_wall(action)\n if self.building != building_before_action or self.terminal:\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n self._move_hazards()\n self._update_windows()\n if not self.at_roof:\n self._resolve_window_grip(action)\n self._resolve_hazard_contact()\n self._resolve_electric_sign()\n self.building_steps += 1\n self.steps += 1\n if self.building_steps % 10 == 0:\n self.bonus = max(0.0, self.bonus - 100.0)\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _act_on_wall(self, action: int) -> float:\n if action in (1, 3) and not self.reaching:\n delta = -1 if action == 1 else 1\n self.player[1] = int(np.clip(self.player[1] + delta, 0, 8))\n elif action == 2:\n if self.reaching:\n self.player[0] -= 1\n self.reaching = False\n if self.player[0] == 0:\n self.at_roof = True\n self.pickup_steps = 30\n return self.building * 100.0\n self.reaching = True\n elif action == 4:\n self.reaching = False\n return 0.0\n\n def _act_on_roof(self, action: int) -> float:\n if action == 1:\n self.player[1] = max(0, self.player[1] - 1)\n elif action == 3:\n self.player[1] = min(9, self.player[1] + 1)\n self.helicopter_column = (self.helicopter_column + 1) % 10\n self.pickup_steps -= 1\n if self.pickup_steps <= 0:\n self.bonus = 0.0\n if action != 5 or abs(self.player[1] - self.helicopter_column) > 1:\n return 0.0\n reward = self.bonus\n self.building += 1\n if self.building > 4:\n self.terminal = True\n else:\n self._start_building()\n return reward\n\n def _move_hazards(self) -> None:\n spawn_period = max(5, 13 - 2 * self.building)\n if self.building_steps % spawn_period == 0:\n kinds = [\"doctor\", \"egg\"]\n if self.building >= 2:\n kinds.append(\"girder\")\n kind = kinds[int(self.random.randint(len(kinds)))]\n self.hazards.append(\n {\"position\": [0, int(self.random.randint(10))], \"kind\": kind}\n )\n for hazard in self.hazards:\n hazard[\"position\"][0] += 1\n self.hazards = [hazard for hazard in self.hazards if hazard[\"position\"][0] <= 8]\n\n def _hand_positions(self) -> tuple[tuple[int, int], tuple[int, int]]:\n row = max(0, self.player[0] - 1) if self.reaching else min(7, self.player[0])\n return (row, self.player[1]), (row, self.player[1] + 1)\n\n def _resolve_window_grip(self, action: int) -> None:\n hands = self._hand_positions()\n closed = sum(not self.windows[position] for position in hands)\n if closed == 2 or (closed == 1 and action in (1, 2, 3, 4)):\n self._fall()\n\n def _resolve_hazard_contact(self) -> None:\n contacts = [hazard for hazard in self.hazards if hazard[\"position\"] == self.player]\n for hazard in contacts:\n self.bonus = max(0.0, self.bonus - 100.0)\n if self.reaching or hazard[\"kind\"] == \"girder\":\n self._fall()\n break\n self.hazards = [hazard for hazard in self.hazards if hazard not in contacts]\n\n def _resolve_electric_sign(self) -> None:\n if self.building < 3 or self.player[0] != 3 or self.player[1] not in (7, 8):\n return\n self.electric_shocks += 1\n self.bonus = max(0.0, self.bonus - 100.0)\n if self.electric_shocks >= 11:\n self._fall()\n\n def _fall(self) -> None:\n self.lives -= 1\n self.reaching = False\n self.hazards = []\n self.electric_shocks = 0\n if self.lives <= 0:\n self.terminal = True\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n for row in range(8):\n for column in range(10):\n if not self.windows[row, column]:\n state[row, column, 1] = True\n else:\n state[row, column, 2] = True\n for hazard in self.hazards:\n state[*hazard[\"position\"], 1] = True\n if hazard[\"kind\"] == \"girder\":\n state[*hazard[\"position\"], 5] = True\n if self.at_roof:\n state[0, self.helicopter_column, 2] = True\n state[0, self.helicopter_column, 3] = True\n state[*self.previous_player, 4] = True\n for position in self.previous_hazards:\n state[*position, 4] = True\n if self.building >= 3:\n state[3, 7:9, 1] = True\n state[3, 7:9, 3] = True\n state[9, : self.lives, 5] = True\n state[8, : self.building, 5] = True\n if self.reaching:\n state[7, :2, 5] = True\n state[6, : min(10, self.electric_shocks), 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 181, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/crazy_climber.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "turtle_tide", "split": "train", "game": "turtle_tide", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Turtle Tide as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to dive and build speed. Release with any other action\nto surface and slow down. Speed controls both scroll rate and points\nearned per frame. Dodge obstacles above and below the changing\nwaterline. Contact ends the episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the turtle, water, above-water obstacles,\nunderwater obstacles, target depth, and counters. The port fixes\ndifficulty and uses rectangular collision checks. Each action\nadvances up to four frames over 400 actions. Clip episode scores\nto [0, 600] and divide by 600.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/turtle_tide.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import sin\n\nimport numpy as np\n\n\n@dataclass\nclass Obstacle:\n x: float\n y: float\n width: float\n height: float\n underwater: bool\n\n\nclass TurtleTideEnvironment:\n score_cap = 600\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.y = self.water = 50.\n self.speed, self.frequency, self.amplitude = 1., 0.05, 10.\n self.obstacles = []\n self.obstacle_distance = 60.\n self.action = self.steps = self.frames = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0.\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _advance(self):\n self.frequency = min(0.05, max(0, self.frequency + self.random.uniform(-0.0001, 0.0001)))\n self.amplitude = min(10, max(0, self.amplitude + self.random.uniform(-0.01, 0.01)))\n target_water = 50 + sin(self.frames * self.frequency) * self.amplitude\n self.water += (target_water - self.water) * 0.1\n self.frames += 1\n if self.action == 5:\n self.speed = min(9, self.speed + 0.01)\n self.y += (self.water + 15 - self.y) * 0.1\n else:\n self.speed += (1 - self.speed) * 0.1\n self.y += (self.water - 5 - self.y) * 0.1\n if self.y + 1 > self.water:\n self.y = self.water - 1\n\n for obstacle in self.obstacles:\n obstacle.x -= self.speed\n self.obstacles = [obstacle for obstacle in self.obstacles if obstacle.x >= -10]\n self.obstacle_distance -= self.speed\n if self.obstacle_distance < 0:\n underwater = self.random.random() < 0.5\n low, high = (self.water + 5, 95) if underwater else (5, self.water - 5)\n self.obstacles.append(Obstacle(110, self.random.uniform(low, high),\n self.random.uniform(5, 10), self.random.uniform(5, 10),\n underwater))\n self.obstacle_distance = self.random.uniform(99, 120)\n self.terminal = any(\n abs(obstacle.x - 20) < obstacle.width / 2 + self.speed\n and abs(obstacle.y - self.y) < obstacle.height / 2 + 1\n for obstacle in self.obstacles\n )\n return self.speed * 0.1\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n state[int(self.y // 10), 2, 0] = True\n state[:, :, 1] = rows + 5 > self.water\n for obstacle in self.obstacles:\n mask = ((abs(cols - obstacle.x) < obstacle.width / 2 + 5)\n & (abs(rows - obstacle.y) < obstacle.height / 2 + 5))\n state[:, :, 3 if obstacle.underwater else 2] |= mask\n target = self.water + (15 if self.action == 5 else -5)\n state[int(target // 10), 2, 4] = True\n values = (self.steps, self.action, round(self.speed * 50), round(self.water * 8) - 256,\n round(self.obstacle_distance * 4), round(self.frequency * 10000),\n round(self.amplitude * 40))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 182, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/turtle_tide.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameTurtleTide.c"} +{"name": "spin_cell", "split": "train", "game": "spin_cell", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Spin Cell as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to rotate the perimeter spikes and any warning one\nsegment clockwise. Actions 0–4 release. A tap near the bottom also\nnudges the ball left. The ball moves and bounces automatically.\nCollect corner gems to score the square of the active spike count,\nwith a minimum of one point. Each gem removes a random spike.\nTouching an active spike ends the episode after a short delay.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the ball, gem, spikes, warnings,\nsafe wall segments, and counters. The port uses fixed difficulty.\nEach action advances up to four frames over a 400-action horizon.\nClip scores to [0, 100] and divide by 100.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/spin_cell.py`):\n```python\nfrom math import floor, hypot, sqrt\n\nimport numpy as np\n\n\nCORNERS = ((14, 14), (86, 14), (86, 86), (14, 86))\n\n\nclass SpinCellEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 50., 40.\n self.vx, self.vy = self.random.uniform(0.4, 0.8), 0.\n self.spikes = {1, 7}\n self.gem = int(self.random.integers(4))\n self.timer, self.warning = 400, -1\n self.steps = self.death = 0\n self.held = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n if self.death:\n self.death -= 1\n self.terminal = self.death == 0\n return 0\n if tap:\n self.spikes = {(segment + 1) % 12 for segment in self.spikes}\n if self.warning >= 0:\n self.warning = (self.warning + 1) % 12\n if self.y > 87:\n self.vx = max(-1.4, min(1.4, self.vx - 0.6))\n self.timer -= 1\n if self.timer < 0:\n if self.warning >= 0:\n self.spikes.add(self.warning)\n self.warning = -1\n self.timer = 200 * sqrt(len(self.spikes) + 1)\n elif len(self.spikes) < 8:\n self.warning = int(self.random.choice(sorted(set(range(12)) - self.spikes)))\n self.timer = 90\n else:\n self.timer = 500\n self.vy += 0.06\n self.x += self.vx\n self.y += self.vy\n segment = self._bounce()\n if segment in self.spikes:\n self.death = 7\n return 0\n x, y = CORNERS[self.gem]\n if hypot(self.x - x, self.y - y) < 8:\n reward = max(1, len(self.spikes)) ** 2\n if self.spikes:\n self.spikes.remove(int(self.random.choice(sorted(self.spikes))))\n self.gem = (self.gem + int(self.random.integers(1, 4))) % 4\n return reward\n return 0\n\n def _bounce(self):\n if self.y < 9:\n side, offset = 0, self.x\n self.y, self.vy = 9, abs(self.vy) * 0.9\n elif self.x > 91:\n side, offset = 1, self.y\n self.x, self.vx = 91, -abs(self.vx) * 0.95\n elif self.y > 91:\n side, offset = 2, self.x\n self.y, self.vy = 91, -3.1\n self.vx = min(1.2, max(-1.2, self.vx + self.random.uniform(-0.25, 0.25)))\n elif self.x < 9:\n side, offset = 3, self.y\n self.x, self.vx = 9, abs(self.vx) * 0.95\n else:\n return -1\n index = min(2, max(0, floor((offset - 7) * 3 / 86)))\n return side * 3 + (2 - index if side >= 2 else index)\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(self.y // 10), int(self.x // 10), 0] = True\n gx, gy = CORNERS[self.gem]\n state[gy // 10, gx // 10, 1] = True\n for side in range(4):\n for index in range(3):\n segment = side * 3 + index\n channel = 2 if segment in self.spikes else 3 if segment == self.warning else 4\n span = slice(1 + 3 * index, min(9, 4 + 3 * index))\n reverse = slice(10 - span.stop, 10 - span.start)\n if side == 0:\n state[0, span, channel] = True\n elif side == 1:\n state[span, 9, channel] = True\n elif side == 2:\n state[9, reverse, channel] = True\n else:\n state[reverse, 0, channel] = True\n values = (self.steps, self.held, self.death, round(self.timer),\n round((self.vx + 2) * 100), round((self.vy + 8) * 40))\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 183, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/spin_cell.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameSpinCell.c"} +{"name": "boxing", "split": "train", "game": "boxing", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Boxing as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves Activision *Boxing*'s one-player, top-down positioning duel. The player\nmoves freely inside an eight-by-eight ring with actions 1–4 and punches with action 5. The computer\nboxer closes distance, seeks angled attacks, and—as described by designer Bob Whitehead—slows after\nthe first minute of the two-minute bout.\n\nPunches at two-cell range are long jabs worth one point; adjacent punches are close power punches\nworth two. A guarded boxer blocks a straight head-on attack, so the player must create a vertical\nand horizontal angle or counter while the opponent is recovering from a punch. A landed hit pushes\nthe defender backward, enabling combinations and rope pressure. Both boxers have short recovery\nwindows. A bout ends after 120 discrete seconds, when the opponent reaches 100, or immediately when\nthe player reaches the manual's 100-point K.O. threshold.\n\nACTION MAPPING\n0: wait\n1: move left\n2: move up\n3: move right\n4: move down\n5: punch toward opponent\n\nINPUT CHANNEL TABLE\n0: player boxer\n1: opponent threat\n2: opponent scoring target\n3: the player's landed punch cell\n4: previous positions of both boxers\n5: both scores, time remaining, and player recovery\n\nSCORING, TERMINATION, AND HORIZON\nThe native player score is the reward: one point per long jab and two per close power punch. The\nbout terminates at 100, and a two-point hit from 99 is clipped to the one remaining K.O. point.\nTherefore `score_cap = 100` independent of the timer. Normalization is\n`min(max(raw_score, 0), 100) / 100`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/boxing.py`):\n```python\nimport numpy as np\n\n\nDELTAS = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}\n\n\nclass BoxingEnvironment:\n \"\"\"Two-minute top-down bout with guarded jabs, power punches, and counter windows.\"\"\"\n\n score_cap = 100.0\n\n def __init__(self, sticky_action_prob: float = 0.1, round_steps: int = 120):\n self.sticky_action_prob = sticky_action_prob\n self.round_steps = round_steps\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.player = [5, 2]\n self.opponent = [5, 7]\n self.previous_player = self.player.copy()\n self.previous_opponent = self.opponent.copy()\n self.player_score = 0\n self.opponent_score = 0\n self.player_recovery = 0\n self.opponent_recovery = 0\n self.player_punch: list[int] | None = None\n self.opponent_punch: list[int] | None = None\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n self.previous_opponent = self.opponent.copy()\n self.player_punch = None\n self.opponent_punch = None\n reward = 0.0\n if action in DELTAS:\n self._move(self.player, self.opponent, action)\n elif action == 5 and self.player_recovery == 0:\n scored = self._punch(self.player, self.opponent, defender_is_player=False)\n reward = float(min(scored, 100 - self.player_score))\n self.player_score += int(reward)\n self.player_recovery = 2\n if self.player_score >= 100:\n self.player_score = 100\n self.terminal = True\n return reward, True\n\n if self.steps < 60 or self.steps % 2 == 0:\n self._opponent_action()\n self.player_recovery = max(0, self.player_recovery - 1)\n self.opponent_recovery = max(0, self.opponent_recovery - 1)\n self.steps += 1\n if self.opponent_score >= 100 or self.steps >= self.round_steps:\n self.opponent_score = min(100, self.opponent_score)\n self.terminal = True\n return reward, self.terminal\n\n @staticmethod\n def _move(boxer: list[int], other: list[int], action: int) -> None:\n row_delta, column_delta = DELTAS[action]\n target = [boxer[0] + row_delta, boxer[1] + column_delta]\n if 1 <= target[0] <= 8 and 1 <= target[1] <= 8 and target != other:\n boxer[:] = target\n\n def _punch(self, attacker: list[int], defender: list[int], defender_is_player: bool) -> int:\n row_distance = abs(attacker[0] - defender[0])\n column_distance = abs(attacker[1] - defender[1])\n distance = max(row_distance, column_distance)\n if distance > 2:\n return 0\n recovery = self.player_recovery if defender_is_player else self.opponent_recovery\n angled = row_distance > 0 and column_distance > 0\n if not angled and recovery == 0:\n return 0\n points = 2 if distance == 1 else 1\n punch_cell = [\n attacker[0] + int(np.sign(defender[0] - attacker[0])),\n attacker[1] + int(np.sign(defender[1] - attacker[1])),\n ]\n if defender_is_player:\n self.opponent_punch = punch_cell\n else:\n self.player_punch = punch_cell\n self._push(attacker, defender)\n return points\n\n @staticmethod\n def _push(attacker: list[int], defender: list[int]) -> None:\n row_delta = int(np.sign(defender[0] - attacker[0]))\n column_delta = int(np.sign(defender[1] - attacker[1]))\n target = [\n int(np.clip(defender[0] + row_delta, 1, 8)),\n int(np.clip(defender[1] + column_delta, 1, 8)),\n ]\n if target != attacker:\n defender[:] = target\n\n def _opponent_action(self) -> None:\n row_distance = abs(self.opponent[0] - self.player[0])\n column_distance = abs(self.opponent[1] - self.player[1])\n if max(row_distance, column_distance) <= 2 and self.opponent_recovery == 0:\n self.opponent_score += self._punch(self.opponent, self.player, defender_is_player=True)\n self.opponent_recovery = 2\n return\n candidates = []\n for action in DELTAS:\n row_delta, column_delta = DELTAS[action]\n target = [self.opponent[0] + row_delta, self.opponent[1] + column_delta]\n if not (1 <= target[0] <= 8 and 1 <= target[1] <= 8) or target == self.player:\n continue\n distance = max(abs(target[0] - self.player[0]), abs(target[1] - self.player[1]))\n angled_bonus = -1 if target[0] != self.player[0] and target[1] != self.player[1] else 0\n candidates.append((distance + angled_bonus, self.random.rand(), action))\n if candidates:\n self._move(self.opponent, self.player, min(candidates)[2])\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n state[*self.opponent, 1] = True\n state[*self.opponent, 2] = True\n if self.player_punch is not None:\n state[*self.player_punch, 3] = True\n state[*self.previous_player, 4] = True\n state[*self.previous_opponent, 4] = True\n state[9, : min(10, (self.player_score + 9) // 10), 5] = True\n state[8, : min(10, (self.opponent_score + 9) // 10), 5] = True\n remaining = max(0, self.round_steps - self.steps)\n state[7, : min(10, (remaining + 11) // 12), 5] = True\n state[6, : self.player_recovery, 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 184, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/boxing.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "stillfire_choir", "split": "train", "game": "stillfire_choir", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Stillfire Choir as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to stop the choir's horizontal movement. Actions\n0–4 release. Every 62 frames all voices fire a synchronized ray\nupward. Catch items for five points and a new voice. Each enemy\ndestroyed scores ten points plus two per ally. An enemy hitting\nthe player or an ally ends the episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the player, allies, enemies, items,\nrays and their afterglow, and counters. The port uses fixed\ndifficulty and rectangular collision bounds. Each action advances\nup to four frames over a 400-action horizon. Clip the episode\nscore to [0, 400] and divide by 400.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/stillfire_choir.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Voice:\n x: float\n y: float\n vx: float\n size: float\n\n def move(self, edge):\n self.x += self.vx\n if not edge <= self.x <= 100 - edge:\n self.x = min(100 - edge, max(edge, self.x))\n self.vx *= -1\n\n\n@dataclass\nclass Falling:\n x: float\n y: float\n speed: float\n size: float = 5\n\n def touches(self, voice):\n reach = (self.size + voice.size) / 2\n return abs(self.x - voice.x) < reach and abs(self.y - voice.y) < reach\n\n\nclass StillfireChoirEnvironment:\n score_cap = 400\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.player = Voice(50, 88, 0.72, 7)\n self.allies, self.enemies, self.items = [], [], []\n self.beams = []\n self.volley, self.enemy_timer, self.item_timer = 62, 25, 75\n self.steps = self.glow = 0\n self.held = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n if self.random.random() >= self.sticky_action_prob:\n self.held = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n voices = [self.player, *self.allies]\n if not self.held:\n self.player.move(5)\n for ally in self.allies:\n ally.move(4)\n self.volley -= 1\n firing = self.volley <= 0\n if firing:\n self.volley = 62\n self.glow = 4\n self.beams = [(voice.x, voice.y) for voice in voices] if self.glow else []\n self.glow = max(0, self.glow - 1)\n self.enemy_timer -= 1\n if self.enemy_timer <= 0:\n self.enemies.append(Falling(self.random.uniform(5, 95), -4,\n self.random.uniform(0.45, 0.78), self.random.uniform(5, 9)))\n self.enemy_timer = self.random.uniform(31, 49)\n self.item_timer -= 1\n if self.item_timer <= 0:\n self.items.append(Falling(self.random.uniform(7, 93), -3, self.random.uniform(0.36, 0.52)))\n self.item_timer = self.random.uniform(125, 175)\n reward = 0\n remaining = []\n for item in self.items:\n item.y += item.speed\n if any(item.touches(voice) for voice in voices):\n speed = self.random.uniform(0.48, 0.9) * self.random.choice((-1, 1))\n self.allies.append(Voice(item.x, item.y, speed, 5))\n reward += 5\n elif item.y <= 105:\n remaining.append(item)\n self.items = remaining\n remaining = []\n for enemy in self.enemies:\n enemy.y += enemy.speed\n half = enemy.size / 2\n if firing and any(abs(enemy.x - x) < half + 1 and\n enemy.y + half > 6 and enemy.y - half < y - 2\n for x, y in self.beams):\n reward += 10 + 2 * len(self.allies)\n else:\n self.terminal |= any(enemy.touches(voice) for voice in voices)\n if enemy.y <= 105:\n remaining.append(enemy)\n self.enemies = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n groups = ((self.player,), self.allies, self.enemies, self.items)\n for channel, entities in enumerate(groups):\n for entity in entities:\n if 0 <= entity.y < 100:\n state[int(entity.y // 10), int(entity.x // 10), channel] = True\n for x, y in self.beams:\n state[:int(y // 10) + 1, int(x // 10), 4] = True\n values = (self.steps, self.volley, self.held, len(self.allies), self.player.vx > 0, self.glow)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 186, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/stillfire_choir.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameStillfireChoir.c"} +{"name": "mortar", "split": "train", "game": "mortar", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Mortar as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to stop the sweeping mortar and move its sight\nupward. Release with actions 0–4 to fire. Releasing before\nthe sight reaches the top fires a rising shot. A longer hold\nmoves the camera upward and sets up an expanding blast.\n\nEnemy hits score the current multiplier and raise it.\nStarting a new aim resets the multiplier. Enemies reaching\nthe bottom trigger the loss countdown.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the mortar, enemies, sight,\nshot, blast, and gauges. The conversion approximates contact\nwith rectangular shot bounds and a circular blast ring.\nIt runs at fixed difficulty for four frames per action.\nThe 400-action task clips scores to [0, 500] and divides by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/mortar.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Enemy:\n x: float\n y: float\n speed: float\n\n\n@dataclass\nclass Shot:\n x: float\n y: float\n width: float\n\n\n@dataclass\nclass Blast:\n x: float\n y: float\n target_radius: float\n radius: float = 0\n\n\nclass MortarEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.enemies = [Enemy(self.random.uniform(49, 60), self.random.uniform(-149, -140), 0.1)\n for _ in range(5)]\n self.x, self.direction = 30.0, 1\n self.sight = self.shot = self.blast = None\n self.offset = self.timer = self.max_enemy_y = 0.0\n self.sight_speed = 3\n self.multiplier = 1\n self.steps = self.breach = 0\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap, release = pressed and not self.pressed, self.pressed and not pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0, release and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap, release):\n if self.blast is not None:\n self.blast.radius += (self.blast.target_radius - self.blast.radius) * 0.1\n if self.blast.target_radius - self.blast.radius < 1:\n self.blast = None\n elif self.sight is not None:\n self.sight -= 2 * self.sight_speed\n if self.sight < 0:\n self.offset += (90 - self.sight - self.offset) * 0.05 * self.sight_speed\n if release or self.sight < -200:\n if self.sight >= 0:\n if self.shot is None:\n self.shot = Shot(self.x, 95, math.ceil((91 - self.sight) * 0.2))\n else:\n self.blast = Blast(self.x, self.sight, 2 + min(30, -self.sight * 0.3))\n self.sight = None\n self.sight_speed = max(1, self.sight_speed - 1)\n else:\n self.offset *= 0.8\n self.x += self.direction\n if (self.x < 3 and self.direction < 0) or (self.x > 96 and self.direction > 0):\n self.direction *= -1\n if tap:\n self.sight = 90\n self.multiplier = 1\n if self.shot is not None:\n self.shot.y -= 3\n if self.shot.y < -3:\n self.shot = None\n if self.breach:\n self.offset *= 0.5\n if self.breach > 9:\n self.terminal = True\n return 0\n self.timer = self.timer - 1 if self.enemies else -1\n if self.timer < 0:\n speed = self.random.uniform(0.5, 2) * 0.1\n center = self.random.uniform(20, 80)\n for _ in range(int(self.random.integers(5, 9))):\n x, y = self.random.uniform(-9, 9, 2)\n self.enemies.append(Enemy(center + x, -280 + y, speed * self.random.uniform(0.9, 1.1)))\n self.timer = 99 * math.sqrt(len(self.enemies))\n return self._move_enemies()\n\n def _move_enemies(self):\n reward = 0\n remaining = []\n rate = math.sqrt(120 - self.max_enemy_y) / 4\n if self.sight is not None:\n rate *= 0.3\n top_progress = -200\n for enemy in self.enemies:\n if enemy.y > 99:\n self.breach += 1\n else:\n shot = self.shot\n blast = self.blast\n hit = shot is not None and abs(shot.x - enemy.x) < shot.width / 2 + 3 and abs(shot.y - enemy.y) < 6\n if blast is not None:\n distance = math.hypot(blast.x - enemy.x, blast.y - enemy.y)\n hit |= abs(distance - blast.radius) < 5.5\n if hit:\n reward += self.multiplier\n self.multiplier += 1\n continue\n enemy.y += enemy.speed * rate\n top_progress = max(top_progress, enemy.y)\n remaining.append(enemy)\n self.enemies = remaining\n self.max_enemy_y = top_progress\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n points = [(self.x, 95, 0)]\n if self.sight is not None:\n points.append((self.x, self.sight, 2))\n if self.shot is not None:\n points.append((self.shot.x, self.shot.y, 3))\n points.extend((e.x, e.y, 1) for e in self.enemies)\n for x, y, channel in points:\n y += self.offset\n if 0 <= y < 100:\n state[int(y // 10), int(x // 10), channel] = True\n if self.blast is not None:\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n state[:, :, 4] = abs(np.hypot(cols - self.blast.x,\n rows - self.blast.y - self.offset) - self.blast.radius) < 6\n values = (self.steps, min(511, self.multiplier), self.sight_speed, round(self.offset),\n round(200 + self.sight) if self.sight is not None else 0)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(max(0, value) & (1 << bit))\n state[9, :2, 5] = self.pressed, self.direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 187, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/mortar.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/mortar/main.js"} +{"name": "earock", "split": "train", "game": "earock", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Earock as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to thrust along the current heading. Release with\nactions 0–4 to turn toward Earth. A new press briefly brakes\nbefore applying thrust. Wall and planet bounces reset the combo.\n\nIntercept incoming stars before they reach Earth. Each catch\nscores the current combo and increases it by one. The run ends\nwhen a star reaches Earth or after 400 actions.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the ship, heading, Earth, visible\nstars, offscreen star cues, and gauges. The conversion uses fixed\ndifficulty and distance-based star catches. Each action advances\nfour simulation frames.\n\nSCORING, TERMINATION, AND HORIZON\nClip raw scores to [0, 15] and divide by 15. Across 100 seeds\nwithout sticky actions, idle averaged 0.21, holding averaged 1.39,\nand random inputs averaged 0.93 and reached six.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/earock.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Body:\n x: float\n y: float\n vx: float = 0\n vy: float = 0\n\n def accelerate(self, angle: float, amount: float) -> None:\n self.vx += math.cos(angle) * amount\n self.vy += math.sin(angle) * amount\n\n def move(self, scale: float = 1) -> None:\n self.x += self.vx * scale\n self.y += self.vy * scale\n\n def drag(self, scale: float) -> None:\n self.vx *= scale\n self.vy *= scale\n\n def toward_earth(self) -> float:\n return math.atan2(50 - self.y, 50 - self.x)\n\n\ndef wrap_angle(angle: float) -> float:\n return (angle + math.pi) % math.tau - math.pi\n\n\nclass EarockEnvironment:\n score_cap = 15\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.spawn_timer = 0\n self.combo = 1\n self.pressed = self.terminal = False\n self.angle = 0.0\n self.ship = Body(50, 20, 0.1)\n self.stars: list[Body] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n changed = pressed != self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance_frame(changed and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _turn(self, speed: float) -> None:\n offset = wrap_angle(self.ship.toward_earth() - self.angle)\n self.angle = wrap_angle(self.angle + min(speed, max(-speed, offset)))\n\n def _reflect(self, normal: float) -> None:\n offset = wrap_angle(self.angle + math.pi - normal)\n if abs(offset) < math.pi / 2:\n self.angle = wrap_angle(self.angle + math.pi - 2 * offset)\n speed = math.hypot(self.ship.vx, self.ship.vy) / 2\n self.ship.vx = self.ship.vy = 0\n self.ship.accelerate(self.angle, speed)\n self.combo = 1\n\n def _advance_frame(self, changed: bool) -> int:\n ship = self.ship\n if self.pressed:\n if changed:\n ship.drag(0.5)\n ship.accelerate(self.angle, 0.1)\n ship.accelerate(self.angle, 0.01)\n else:\n self._turn(0.01)\n if changed:\n self._turn(0.2)\n ship.drag(0.98)\n ship.move()\n if ship.x < 0 or ship.x > 99:\n self._reflect(0 if ship.x < 0 else math.pi)\n if ship.y < 0 or ship.y > 99:\n self._reflect(math.pi / 2 if ship.y < 0 else -math.pi / 2)\n if math.hypot(ship.x - 50, ship.y - 50) < 16.5:\n self._reflect(ship.toward_earth() + math.pi)\n\n self.spawn_timer = self.spawn_timer - 1 if self.stars else -1\n if self.spawn_timer < 0:\n angle = self.random.uniform(0, math.tau)\n star = Body(50 + 70 * math.cos(angle), 50 + 70 * math.sin(angle))\n star.accelerate(angle + math.pi + self.random.uniform(-1, 1), 0.1)\n self.stars.append(star)\n self.spawn_timer = 300\n\n reward = 0\n remaining = []\n for star in self.stars:\n star.move()\n star.drag(0.99)\n star.accelerate(star.toward_earth(), 0.0002)\n if math.hypot(star.x - ship.x, star.y - ship.y) < 5:\n reward += self.combo\n self.combo += 1\n continue\n if not (-3 <= star.x < 100 and -3 <= star.y < 100):\n star.move(9)\n if -50 <= star.x < 100 and -50 <= star.y < 100:\n self.terminal |= math.hypot(star.x - 50, star.y - 50) < 15\n remaining.append(star)\n self.stars = remaining\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n ship = self.ship\n points = ((ship.x, ship.y, 0),\n (ship.x + 8 * math.cos(self.angle), ship.y + 8 * math.sin(self.angle), 1))\n for x, y, channel in points:\n state[min(9, max(0, int(y) // 10)), min(9, max(0, int(x) // 10)), channel] = True\n for row in range(10):\n for col in range(10):\n state[row, col, 2] = math.hypot(col * 10 + 5 - 50, row * 10 + 5 - 50) < 16.5\n for star in self.stars:\n if 0 <= star.x < 100 and 0 <= star.y < 100:\n state[int(star.y) // 10, int(star.x) // 10, 3] = True\n else:\n state[min(9, max(0, int(star.y) // 10)), min(9, max(0, int(star.x) // 10)), 4] = True\n for row, value in enumerate((self.steps, self.combo, round((self.angle + math.pi) * 80))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 188, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/earock.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/earock/main.js"} +{"name": "future_wake", "split": "train", "game": "future_wake", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Future Wake as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nMove both paddles left with action 1 or right with action 4. Other\nactions wait. The ball rebounds off the side walls. Align the\npaddles with the projected impact point to accelerate the ball\nand return it. Paddle edges change the return angle.\n\nEach return scores the current multiplier and adds ten to it.\nThe multiplier decays over time. A ball leaving the top or bottom\nends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the ball, paddles, predicted path,\nimpact point, walls, and gauges. The conversion replaces pointer\ninput with directional movement and uses analytic wall reflections\ninstead of replaying the predicted trajectory frame by frame.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action task clips scores to [0, 2500] and divides by 2,500.\nAcross 100 seeds without sticky actions, idle scored zero and random\nmovement averaged 1.53. Tracking the exact projected impact scored\n2,425 on every seed.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/future_wake.py`):\n```python\nimport math\n\nimport numpy as np\n\n\nclass FutureWakeEnvironment:\n score_cap = 2500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.last_action = 0\n self.paddle = self.x = self.y = 50.0\n self.vx = self.vy = math.sqrt(0.5)\n self.speed = self.multiplier = 1.0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def _position(self, distance: float) -> tuple[float, float, float]:\n offset = (self.x + self.vx * distance - 8.5) % 166\n if offset <= 83:\n x, vx = 8.5 + offset, self.vx\n else:\n x, vx = 174.5 - offset, -self.vx\n return x, self.y + self.vy * distance, vx\n\n def _impact(self) -> tuple[float, float, float]:\n edge = 91 if self.vy > 0 else 9\n distance = max(0, (edge - self.y) / self.vy)\n x, _, vx = self._position(distance)\n return distance, x, vx\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.steps += 1\n direction = -1 if action == 1 else 1 if action == 4 else 0\n reward = 0\n for _ in range(4):\n self.paddle = min(83, max(17, self.paddle + direction * 2))\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self) -> int:\n distance, impact_x, impact_vx = self._impact()\n offset = (impact_x - self.paddle) / 10\n ready = abs(offset) <= 1.15\n reward = 0\n if ready and self.speed >= distance:\n self.x = impact_x\n self.y = 91 if self.vy > 0 else 9\n if abs(offset) < 0.6:\n self.vx, self.vy = impact_vx, -self.vy\n else:\n angle = math.pi / 4 + 1 - offset if offset > 0 else 3 * math.pi / 4 - 1 - offset\n self.vx, self.vy = math.cos(angle), math.copysign(math.sin(angle), -self.vy)\n reward = math.floor(self.multiplier)\n self.multiplier += 10\n if self.multiplier > 100:\n self.vx += self.random.uniform(-1, 1) / 3\n length = math.hypot(self.vx, self.vy)\n self.vx /= length\n self.vy /= length\n else:\n self.x, self.y, self.vx = self._position(self.speed)\n self.speed = self.speed + 1 if ready else 1\n self.multiplier = min(100.99, max(1, self.multiplier * 0.99))\n self.terminal = not 0 <= self.y <= 99\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n if 0 <= self.y < 100:\n state[int(self.y) // 10, int(self.x) // 10, 0] = True\n left, right = int(self.paddle - 10) // 10, int(self.paddle + 10) // 10\n state[(0, 9), left:right + 1, 1] = True\n distance, impact_x, _ = self._impact()\n for offset in np.linspace(0, distance, 20):\n x, y, _ = self._position(offset)\n if 0 <= y < 100:\n state[int(y) // 10, int(x) // 10, 2] = True\n state[9 if self.vy > 0 else 0, int(impact_x) // 10, 3] = True\n state[:, (0, 9), 4] = True\n for row, value in enumerate((self.steps, round(self.speed), math.floor(self.multiplier))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 189, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/future_wake.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/futurewake/main.js"} +{"name": "hoppin_hazards", "split": "train", "game": "hoppin_hazards", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Hoppin Hazards as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to rise and grow. Actions 0–4 make the frog\ndescend and shrink twice as fast. Birds and snakes cross\nfrom both sides and end the run on contact. Each frame\nscores one hundredth of the frog's size above ten.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the frog, birds moving in each\ndirection, snakes moving in each direction, and gauges.\nThe conversion uses rectangular collision bounds, including\na box around the snake's leading semicircle.\n\nSCORING, TERMINATION, AND HORIZON\nThe task runs at fixed difficulty for four frames per action\nand up to 400 actions. Holding for all 1,600 frames gives an\nupper bound of 318.1 points before accounting for collisions.\nThe task clips the raw total to [0, 318.1] and divides by 318.1.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/hoppin_hazards.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Hazard:\n x: float\n y: float\n direction: int\n snake: bool\n\n\nclass HoppinHazardsEnvironment:\n score_cap = 318.1\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.y, self.size = 90, 10\n self.spawn_timer = 0.0\n self.steps = 0\n self.pressed = self.terminal = False\n self.hazards: list[Hazard] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n cents = 0\n for _ in range(4):\n cents += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return cents / 100, self.terminal\n\n def _advance(self) -> int:\n rise = 1 if self.pressed else -2\n self.y = min(90, max(10, self.y - rise))\n self.size = min(30, max(10, self.size + rise))\n self.spawn_timer -= 1\n if self.spawn_timer < 0:\n direction = 1 if self.random.integers(2) == 0 else -1\n snake = bool(self.random.integers(2))\n self.hazards.append(Hazard(-10 if direction == 1 else 110,\n self.random.uniform(10, 90), direction, snake))\n self.spawn_timer = self.random.uniform(45, 120)\n half_size = self.size / 2\n for hazard in self.hazards:\n hazard.x += hazard.direction\n if hazard.snake:\n # Use the bounding box of the leading semicircle.\n center = hazard.x + 2.5 * hazard.direction\n hit = abs(center - 50) < half_size + 4 and abs(hazard.y - self.y) < half_size + 6.5\n else:\n hit = abs(hazard.x - 50) < half_size + 5 and abs(hazard.y - self.y) < half_size + 1.5\n self.terminal |= hit\n self.hazards = [hazard for hazard in self.hazards if -10 <= hazard.x <= 110]\n return self.size - 10\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n top = max(0, int((self.y - self.size / 2) // 10))\n bottom = min(9, int((self.y + self.size / 2) // 10))\n left = int((50 - self.size / 2) // 10)\n right = int((50 + self.size / 2) // 10)\n state[top:bottom + 1, left:right + 1, 0] = True\n for hazard in self.hazards:\n if 0 <= hazard.x < 100:\n row, col = int(hazard.y // 10), int(hazard.x // 10)\n state[row, col, 1 + 2 * hazard.snake + (hazard.direction < 0)] = True\n for row, value in enumerate((self.steps, self.y, self.size)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 190, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/hoppin_hazards.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameHoppinHazards.c"} +{"name": "chalkboard", "split": "train", "game": "chalkboard", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Chalkboard as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to write and release with actions 0–4 to lift the\nchalk. The chalk moves automatically and turns clockwise at\nseeded intervals. Writing on blank space earns points and restores\nenergy. Writing over a mature line costs 10 energy per frame.\nLifting the chalk avoids that penalty but gradually drains energy.\nBoth writing gain and idle drain ramp up with uninterrupted input.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the centered chalk, mature lines, fresh\nlines, current heading, upcoming turn, and gauges. Each action\nadvances four frames at fixed speed. The conversion checks overlap\nby distance to the line segment and keeps the four-frame grace period\nfor fresh chalk.\n\nSCORING, TERMINATION, AND HORIZON\nThe episode ends on energy depletion or after 400 actions. At most\n0.3 raw points accrue per frame, giving an upper bound of 480.\nClip raw scores to [0, 480] and divide by 480.\n\nAcross 100 seeds without sticky actions, idle scored zero,\ncontinuous writing scored four, and random inputs averaged 0.48.\nA heuristic that lifted the chalk before crossing exact line\npositions averaged 83.93 and reached 143.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/chalkboard.py`):\n```python\nfrom collections import deque\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\nHEADINGS = ((1, 0), (0, 1), (-1, 0), (0, -1))\n\n\n@dataclass\nclass Segment:\n x: float\n y: float\n dx: float\n dy: float\n born: int\n\n def overlaps(self, x: float, y: float) -> bool:\n if abs(x - self.x) > abs(self.dx) + 3 or abs(y - self.y) > abs(self.dy) + 3:\n return False\n length_squared = self.dx**2 + self.dy**2\n fraction = ((x - self.x) * self.dx + (y - self.y) * self.dy) / length_squared\n fraction = min(1, max(0, fraction))\n return math.hypot(x - self.x - fraction * self.dx, y - self.y - fraction * self.dy) < 3\n\n\nclass ChalkboardEnvironment:\n score_cap = HORIZON * FRAMES_PER_STEP * 3 // 10\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.frame = self.heading = self.streak = 0\n self.turn_timer = 120\n self.pressed = self.terminal = False\n self.x = self.y = self.score_carry = 0.0\n self.write_x = self.write_y = 0.0\n self.energy = 60.0\n self.segments = deque(\n (Segment(70, y, 0, 10, -4) for y in range(-40, 40, 10)),\n maxlen=1000,\n )\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n changed = pressed != self.pressed\n self.pressed = pressed\n if changed:\n self.streak = 0\n self.steps += 1\n reward = 0\n for frame in range(FRAMES_PER_STEP):\n reward += self._advance_frame(changed and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self, changed: bool) -> int:\n self.frame += 1\n self.turn_timer -= 1\n if not self.turn_timer:\n self.heading = (self.heading + 1) % 4\n self.turn_timer = int(self.random.integers(30, 150))\n dx, dy = HEADINGS[self.heading]\n self.x += 0.9 * dx\n self.y += 0.9 * dy\n self.streak = min(120, self.streak + 1)\n amount = 0.3 * (self.streak / 120)**1.5\n reward = 0\n if self.pressed:\n if changed:\n self.write_x, self.write_y = self.x, self.y\n if any(self.frame - line.born >= 4 and line.overlaps(self.x, self.y) for line in self.segments):\n self.energy -= 10\n else:\n self.energy += amount\n self.score_carry += amount\n reward = int(self.score_carry)\n self.score_carry -= reward\n dx, dy = self.x - self.write_x, self.y - self.write_y\n if dx * dx + dy * dy >= 4:\n self.segments.append(Segment(self.write_x, self.write_y, dx, dy, self.frame))\n self.write_x, self.write_y = self.x, self.y\n else:\n self.energy -= amount\n self.energy = min(100, max(0, self.energy))\n self.terminal = self.energy <= 0\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[5, 5, 0] = True\n for line in self.segments:\n x, y = line.x - self.x + 50, line.y - self.y + 50\n if not (-12 <= x < 112 and -12 <= y < 112):\n continue\n channel = 2 if self.frame - line.born < 4 else 1\n for fraction in (0, 0.5, 1):\n px, py = x + line.dx * fraction, y + line.dy * fraction\n if 0 <= px < 100 and 0 <= py < 100:\n state[int(py) // 10, int(px) // 10, channel] = True\n dx, dy = HEADINGS[self.heading]\n state[5 + dy, 5 + dx, 3] = True\n if self.turn_timer <= 30:\n dx, dy = HEADINGS[(self.heading + 1) % 4]\n state[5 + dy, 5 + dx, 4] = True\n for row, value in enumerate((self.steps, round(self.energy), self.turn_timer, self.streak)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 191, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/chalkboard.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameChalkboard.c"} +{"name": "demon_attack", "split": "train", "game": "demon_attack", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Demon Attack as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves Imagic's horizontal cannon defense, twelve-wave score progression,\nreserve-bunker rule, and the risk/reward transition from whole to split to diving demons. The\nplayer cannon stays on the bottom row, moves with actions 1 and 3, and fires one of up to three\nunlimited vertical laser shots with action 5. Actions 0, 2, and 4 are inert.\n\nEach wave contains six primary demon identities that hover and reverse near the side boundaries.\nIn waves one through four a hit removes the demon. Starting in wave five, a primary hit creates\ntwo independently moving split demons; exactly one child fires, matching the asymmetric pair in\nthe original. After eight steps, surviving children dive toward the cannon. A split child is worth\ntwice its primary's points, while the more dangerous diving state is worth twice the split value,\nusing the manual's complete scoring table through waves 11–12.\n\nEnemy shots and diving contact consume one reserve bunker. The player begins with three; after the\nlast bunker is gone, the next hit ends the game. Clearing a wave without any hit adds one bunker,\nup to six.\n\nACTION MAPPING\n0: wait\n1: move left\n2: wait\n3: move right\n4: wait\n5: fire\n\nINPUT CHANNEL TABLE\n0: player laser cannon\n1: demons and hostile shots\n2: score-bearing demon targets\n3: player laser shots\n4: previous cannon and demon positions\n5: split/diving identity, reserve bunkers, and wave gauge\n\nSCORING, TERMINATION, AND HORIZON\nWith six primaries per wave, waves 1–4 contribute\n`6 × (10 + 10 + 15 + 15) = 300`. Waves 5–12 contribute 1,320 primary points. Their 12 children\nper wave are maximally destroyed after diving, contributing\n`12 × (80 + 80 + 100 + 100 + 120 + 120 + 140 + 140) = 10,560`. Therefore the structural maximum\nis `score_cap = 12,180`.\n\nThe environment uses `min(max(raw_score, 0), score_cap) / score_cap`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/demon_attack.py`):\n```python\nimport numpy as np\n\n\nPRIMARY_VALUES = (10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35)\nSPLIT_VALUES = (0, 0, 0, 0, 40, 40, 50, 50, 60, 60, 70, 70)\nDIVING_VALUES = (0, 0, 0, 0, 80, 80, 100, 100, 120, 120, 140, 140)\n\n\nclass DemonAttackEnvironment:\n \"\"\"Twelve-wave fixed shooter with splitting and diving demon states.\"\"\"\n\n score_cap = 12_180.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 4_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.player = [9, 4]\n self.previous_player = self.player.copy()\n self.bunkers = 3\n self.wave = 1\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self.player_shots: list[list[int]] = []\n self.enemy_shots: list[list[int]] = []\n self.previous_enemies: list[list[int]] = []\n self._start_wave()\n\n def _start_wave(self) -> None:\n self.enemies = [\n {\n \"position\": [1 + index % 3, 1 + (index * 2) % 9],\n \"state\": \"primary\",\n \"direction\": 1 if index % 2 == 0 else -1,\n \"age\": 0,\n \"shooter\": True,\n }\n for index in range(6)\n ]\n self.wave_steps = 0\n self.wave_hit = False\n self.enemy_shots = []\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n self.previous_enemies = [list(enemy[\"position\"]) for enemy in self.enemies]\n if action == 1:\n self.player[1] = max(0, self.player[1] - 1)\n elif action == 3:\n self.player[1] = min(9, self.player[1] + 1)\n elif action == 5 and len(self.player_shots) < 3:\n self.player_shots.append([8, self.player[1]])\n self._move_world()\n reward = self._resolve_player_shots()\n self._resolve_player_hits()\n if not self.enemies:\n if not self.wave_hit:\n self.bunkers = min(6, self.bunkers + 1)\n self.wave += 1\n if self.wave > 12:\n self.terminal = True\n else:\n self._start_wave()\n self.wave_steps += 1\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_world(self) -> None:\n for shot in self.player_shots:\n shot[0] -= 1\n self.player_shots = [shot for shot in self.player_shots if shot[0] >= 0]\n for enemy in self.enemies:\n position = enemy[\"position\"]\n enemy[\"age\"] = int(enemy[\"age\"]) + 1\n if enemy[\"state\"] == \"diving\":\n position[0] += 1\n position[1] += int(np.sign(self.player[1] - position[1]))\n if position[0] > 9:\n position[0] = 1\n else:\n position[1] += int(enemy[\"direction\"])\n if position[1] <= 0 or position[1] >= 9:\n enemy[\"direction\"] = -int(enemy[\"direction\"])\n position[1] = int(np.clip(position[1], 0, 9))\n if enemy[\"state\"] == \"split\" and int(enemy[\"age\"]) >= 8:\n enemy[\"state\"] = \"diving\"\n if bool(enemy[\"shooter\"]) and self.random.rand() < min(0.25, 0.015 + self.wave * 0.008):\n self.enemy_shots.append([position[0] + 1, position[1]])\n for shot in self.enemy_shots:\n shot[0] += 1\n self.enemy_shots = [shot for shot in self.enemy_shots if shot[0] <= 9]\n\n def _resolve_player_shots(self) -> float:\n reward = 0.0\n surviving_shots = []\n destroyed_ids: set[int] = set()\n spawned: list[dict[str, object]] = []\n for shot in self.player_shots:\n enemy = next(\n (\n candidate\n for candidate in self.enemies\n if id(candidate) not in destroyed_ids and candidate[\"position\"] == shot\n ),\n None,\n )\n if enemy is None:\n surviving_shots.append(shot)\n continue\n destroyed_ids.add(id(enemy))\n state = str(enemy[\"state\"])\n if state == \"primary\":\n reward += PRIMARY_VALUES[self.wave - 1]\n if self.wave >= 5:\n for direction in (-1, 1):\n spawned.append(\n {\n \"position\": list(enemy[\"position\"]),\n \"state\": \"split\",\n \"direction\": direction,\n \"age\": 0,\n \"shooter\": direction == 1,\n }\n )\n elif state == \"split\":\n reward += SPLIT_VALUES[self.wave - 1]\n else:\n reward += DIVING_VALUES[self.wave - 1]\n self.player_shots = surviving_shots\n self.enemies = [enemy for enemy in self.enemies if id(enemy) not in destroyed_ids] + spawned\n return reward\n\n def _resolve_player_hits(self) -> None:\n enemy_contact = any(enemy[\"position\"] == self.player for enemy in self.enemies)\n shot_contact = self.player in self.enemy_shots\n if not enemy_contact and not shot_contact:\n return\n self.wave_hit = True\n self.enemy_shots = [shot for shot in self.enemy_shots if shot != self.player]\n if self.bunkers > 0:\n self.bunkers -= 1\n else:\n self.terminal = True\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n for enemy in self.enemies:\n position = enemy[\"position\"]\n state[*position, 1] = True\n state[*position, 2] = True\n if enemy[\"state\"] != \"primary\":\n state[*position, 5] = True\n for shot in self.enemy_shots:\n state[*shot, 1] = True\n for shot in self.player_shots:\n state[*shot, 3] = True\n state[*self.previous_player, 4] = True\n for position in self.previous_enemies:\n state[*position, 4] = True\n state[9, : self.bunkers, 5] = True\n state[8, : min(10, self.wave), 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 192, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/demon_attack.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "spearain", "split": "train", "game": "spearain", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Spearain as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to slow the falling drops and speed up the runner.\nActions 0–4 release, briefly accelerating the drops. The runner\nreverses automatically at each wall and earns one point. Catching\na bonus clears the screen and scores the number of drops still\nin play. A spear hit ends the episode.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the runner, spears, bonuses, arena\nedges, heading, and counters. The port uses fixed difficulty and\nrectangular collision bounds. Each action advances up to four\nframes over 400 actions. Clip scores to [0, 150] and divide by 150.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/spearain.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import sqrt\n\nimport numpy as np\n\n\n@dataclass\nclass Drop:\n x: float\n speed: float\n bonus: bool\n y: float = 2\n\n\nclass SpearainEnvironment:\n score_cap = 150\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x = 50.\n self.direction = 1\n self.speed = self.spawn_rate = 1.\n self.timer = self.steps = self.bonus_count = 0\n self.held = self.terminal = False\n self.drops = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n press, release = held and not self.held, self.held and not held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(press and frame == 0, release and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, press, release):\n self.timer -= 1\n if self.timer < 0:\n self.bonus_count -= 1\n bonus = self.bonus_count < 0\n self.drops.append(Drop(self.random.uniform(12, 88),\n self.random.uniform(1, 2) / (3 if bonus else 1), bonus))\n if bonus:\n self.bonus_count = 12\n self.timer += self.random.uniform(40, 60) / self.spawn_rate\n if press:\n self.speed *= 0.5\n if self.speed < 1 and self.held:\n self.speed *= 0.98\n self.spawn_rate *= 1.05\n else:\n self.speed += (1 - self.speed) * 0.05\n self.spawn_rate = 1\n if self.speed < 0.03 or release:\n self.speed = 1 / sqrt(self.speed)\n # Collision uses the pre-movement position, where the source draws the drop.\n visible = [(drop.x, drop.y, drop.bonus) for drop in self.drops]\n for drop in self.drops:\n velocity = drop.speed * self.speed\n if drop.bonus and velocity > 78:\n velocity *= 0.2\n elif not drop.bonus and velocity > 74:\n velocity *= 1.5\n drop.y += velocity\n self.drops = [drop for drop in self.drops if drop.y < 87]\n self.x += self.direction / sqrt(self.speed)\n reward = 0\n if (self.x < 12 and self.direction < 0) or (self.x > 88 and self.direction > 0):\n self.direction *= -1\n reward = 1\n hits = [bonus for x, y, bonus in visible if abs(x - self.x) < 4 and abs(y - 87) < 5]\n if any(hits):\n reward += len(self.drops)\n self.drops.clear()\n self.spawn_rate = 1\n self.timer = 60\n elif hits:\n self.terminal = True\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[8, int(np.clip(self.x // 10, 0, 9)), 0] = True\n for drop in self.drops:\n state[int(drop.y // 10), int(drop.x // 10), 2 if drop.bonus else 1] = True\n state[9, :, 3] = True\n state[:, [0, 9], 3] = True\n x = self.x + 10 * self.direction\n state[8, int(np.clip(x // 10, 0, 9)), 4] = True\n values = (self.steps, self.held, round(self.speed * 100),\n self.bonus_count, round(max(0, self.timer)))\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 193, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/spearain.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/spearain/main.js"} +{"name": "microbial_focus", "split": "train", "game": "microbial_focus", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Microbial Focus as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to move the focus depth. Each new press\nreverses the adjustment direction. Actions 0–4 release and\nhold the current depth. Microbes within 0.1 of the focus\naccelerate away from the center. When they leave the field,\nthey score the rounded multiplier and raise it by one.\nThe multiplier decays each frame and resets if you push\npast a focus limit. A microbe reaching age 600 ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show four depth bands, microbes at\nage 360 or older, and gauges. The gauges include the oldest\nmicrobe's depth and age. The conversion uses fixed difficulty\nand four frames per action. The 400-action task clips scores\nto [0, 250] and divides by 250.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/microbial_focus.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Microbe:\n x: float\n y: float\n depth: float\n size: float\n vx: float = 0\n vy: float = 0\n age: int = 0\n heading: float | None = None\n\n\nclass MicrobialFocusEnvironment:\n score_cap = 250\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.focus = 0.5\n self.direction = 1\n self.frames = self.steps = 0\n self.next_spawn = 0.0\n self.multiplier = 1.0\n self.pressed = self.terminal = False\n self.microbes: list[Microbe] = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed:\n self.direction *= -1\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _spawn(self):\n for _ in range(8):\n depth = self.random.uniform(0.05, 0.95)\n if abs(depth - self.focus) > 0.15:\n break\n edge = self.random.integers(4)\n size = self.random.uniform(4, 8)\n along = self.random.uniform(10, 90)\n drift = self.random.uniform(-0.2, 0.2)\n speed = self.random.uniform(0.5, 1)\n outside = size - 1\n x, y, vx, vy = ((along, -outside, drift, speed),\n (100 + outside, along, -speed, drift),\n (along, 100 + outside, drift, -speed),\n (-outside, along, speed, drift))[edge]\n self.microbes.append(Microbe(x, y, depth, size, vx, vy))\n\n def _advance(self):\n if self.pressed:\n self.focus += self.direction * 0.015\n if not 0 <= self.focus <= 1:\n self.focus = min(1, max(0, self.focus))\n self.multiplier = 1\n self.multiplier *= 0.999\n if self.frames >= self.next_spawn and len(self.microbes) < 24:\n self.next_spawn = self.frames + 50 * math.sqrt(len(self.microbes) + 1)\n self._spawn()\n self.frames += 1\n reward = 0\n remaining = []\n for microbe in self.microbes:\n microbe.age += 1\n if abs(microbe.depth - self.focus) < 0.1:\n if microbe.heading is None:\n dx, dy = microbe.x - 50, microbe.y - 50\n microbe.heading = math.atan2(dy, dx) if dx or dy else self.random.uniform(0, math.tau)\n microbe.vx += math.cos(microbe.heading) * 0.02\n microbe.vy += math.sin(microbe.heading) * 0.02\n microbe.x += microbe.vx\n microbe.y += microbe.vy\n else:\n microbe.vx *= 0.99\n microbe.vy *= 0.99\n microbe.x += microbe.vx\n microbe.y += microbe.vy\n if abs(microbe.vx) < 0.01 and abs(microbe.vy) < 0.01:\n microbe.heading = None\n microbe.vx = microbe.vy = 0\n low, high = -microbe.size, 100 + microbe.size\n if low <= microbe.x <= high and low <= microbe.y <= high:\n remaining.append(microbe)\n self.terminal |= microbe.age >= 600\n else:\n reward += math.floor(self.multiplier + 0.5)\n self.multiplier += 1\n self.microbes = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for microbe in self.microbes:\n row = min(9, max(0, int(microbe.y // 10)))\n col = min(9, max(0, int(microbe.x // 10)))\n state[row, col, int(microbe.depth * 4)] = True\n state[row, col, 4] |= microbe.age >= 360\n oldest = max(self.microbes, key=lambda m: m.age, default=None)\n gauges = (self.steps, round(self.focus * 500), round(self.multiplier * 10),\n oldest.age // 2 if oldest else 0, round(oldest.depth * 500) if oldest else 0)\n for row, value in enumerate(gauges):\n for bit in range(9):\n state[row, bit, 5] = bool(min(511, value) & (1 << bit))\n state[9, :2, 5] = self.pressed, self.direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 194, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/microbial_focus.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameMicrobialFocus.c"} +{"name": "enduro", "split": "train", "game": "enduro", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Enduro as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves Activision's endurance-racing loop: build speed, coast, brake, steer\nthrough traffic, and pass a daily quota before the next sunrise. Action 5 accelerates toward five\nspeed levels, no-op or action 2 coasts at the current speed, action 4 brakes, and actions 1 and 3\nsteer left and right within a continuously curving road. A collision removes the involved traffic\ncar and drops the player's speed to one rather than ending the race.\n\nEach 350-step day moves through dawn, daylight, ice, fog, and night. Ice accepts steering only on\nalternate steps. Fog hides distant cars until they enter the lower six rows, and night exposes\nonly nearby tail-light cells rather than full car bodies. Faster player speed spawns and passes\ntraffic more rapidly, but leaves less reaction time. The first day requires 200 passes and days\ntwo through five require 300; failure at sunrise ends the race, while post-quota passes still add\nto the score.\n\nACTION MAPPING\n0: coast\n1: steer left\n2: coast\n3: steer right\n4: brake\n5: accelerate\n\nINPUT CHANNEL TABLE\n0: player car\n1: currently visible traffic danger\n2: road surface and visible traffic bodies\n3: fog/night tail-light cues\n4: previous player and traffic positions\n5: speed, day, weather, exact binary remaining quota, and collision cue\n\nSCORING, TERMINATION, AND HORIZON\nAt most one new traffic identity can spawn per environment step and each identity scores once\nwhen passed. Across five 350-step days, cumulative native reward therefore cannot exceed\n`score_cap = 1,750`, including all passes beyond the daily quota. Normalization is\n`min(max(raw_score, 0), 1_750) / 1_750`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/enduro.py`):\n```python\nimport math\n\nimport numpy as np\n\n\nclass EnduroEnvironment:\n \"\"\"Five-day endurance race with traffic quotas and changing visibility.\"\"\"\n\n score_cap = 1_750.0\n\n def __init__(self, sticky_action_prob: float = 0.1, day_length: int = 350):\n self.sticky_action_prob = sticky_action_prob\n self.day_length = day_length\n self.horizon = day_length * 5\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.player = [8, 5]\n self.previous_player = self.player.copy()\n self.speed = 0\n self.day = 1\n self.day_step = 0\n self.steps = 0\n self.passed = 0\n self.remaining_quota = 200\n self.traffic: list[dict[str, object]] = []\n self.previous_traffic: list[list[int]] = []\n self.last_action = 0\n self.terminal = False\n self.collision = False\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n self.previous_traffic = [list(car[\"position\"]) for car in self.traffic]\n self.collision = False\n self._apply_action(action)\n self._spawn_traffic()\n reward = self._move_traffic()\n self._resolve_collisions()\n self.day_step += 1\n self.steps += 1\n if self.day_step >= self.day_length:\n self._finish_day()\n return reward, self.terminal\n\n def _apply_action(self, action: int) -> None:\n if action == 5:\n self.speed = min(5, self.speed + 1)\n elif action == 4:\n self.speed = max(0, self.speed - 1)\n elif action in (1, 3):\n if self.weather == \"ice\" and self.day_step % 2:\n return\n self.player[1] += -1 if action == 1 else 1\n left, right = self.road_bounds(8)\n self.player[1] = int(np.clip(self.player[1], left, right))\n\n def _spawn_traffic(self) -> None:\n if self.speed == 0:\n return\n interval = max(1, 6 - self.speed)\n if self.day_step % interval:\n return\n left, right = self.road_bounds(0)\n occupied = {car[\"position\"][1] for car in self.traffic if car[\"position\"][0] <= 1}\n lanes = [column for column in range(left, right + 1) if column not in occupied]\n if not lanes:\n return\n self.traffic.append(\n {\n \"position\": [0, int(self.random.choice(lanes))],\n \"speed\": 1 + int(self.random.randint(2)),\n }\n )\n\n def _move_traffic(self) -> float:\n reward = 0.0\n survivors = []\n relative_speed = max(0, self.speed - 1)\n for car in self.traffic:\n movement = max(0, relative_speed - int(car[\"speed\"]) + 1)\n car[\"position\"][0] += movement\n row = min(9, car[\"position\"][0])\n left, right = self.road_bounds(row)\n car[\"position\"][1] = int(np.clip(car[\"position\"][1], left, right))\n if car[\"position\"][0] > 9:\n reward += 1.0\n self.passed += 1\n self.remaining_quota = max(0, self.remaining_quota - 1)\n else:\n survivors.append(car)\n self.traffic = survivors\n return reward\n\n def _resolve_collisions(self) -> None:\n collided = [car for car in self.traffic if car[\"position\"] == self.player]\n if not collided:\n return\n self.collision = True\n self.speed = 1\n collided_ids = {id(car) for car in collided}\n self.traffic = [car for car in self.traffic if id(car) not in collided_ids]\n\n def _finish_day(self) -> None:\n if self.remaining_quota > 0 or self.day == 5:\n self.terminal = True\n return\n self.day += 1\n self.day_step = 0\n self.remaining_quota = 300\n self.traffic = []\n\n @property\n def weather(self) -> str:\n if self.day_step < 50:\n return \"dawn\"\n if self.day_step < 150:\n return \"day\"\n if self.day_step < 220:\n return \"ice\"\n if self.day_step < 280:\n return \"fog\"\n return \"night\"\n\n def road_bounds(self, row: int) -> tuple[int, int]:\n phase = (self.day_step + (9 - row) * 4) / 24.0\n center = 5 + int(round(2 * math.sin(phase)))\n return max(0, center - 3), min(9, center + 3)\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n for row in range(10):\n left, right = self.road_bounds(row)\n state[row, left : right + 1, 2] = True\n for car in self.traffic:\n position = car[\"position\"]\n visible = self.weather not in (\"fog\", \"night\") or position[0] >= 4\n if visible:\n state[*position, 1] = True\n if self.weather not in (\"fog\", \"night\"):\n state[*position, 2] = True\n else:\n state[position[0], position[1], 3] = visible\n state[*self.previous_player, 4] = True\n for position in self.previous_traffic:\n visible = self.weather not in (\"fog\", \"night\") or position[0] >= 4\n if visible and 0 <= position[0] < 10:\n state[*position, 4] = True\n state[9, : self.speed, 5] = True\n state[8, : self.day, 5] = True\n weather_index = (\"dawn\", \"day\", \"ice\", \"fog\", \"night\").index(self.weather)\n state[7, : weather_index + 1, 5] = True\n for bit in range(9):\n if self.remaining_quota & (1 << bit):\n state[6, bit, 5] = True\n if self.collision:\n state[5, :3, 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 195, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/enduro.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "roll_hold", "split": "train", "game": "roll_hold", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Roll Hold as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to lock the turret's angle and fire automatically.\nActions 0–4 release and let it rotate again. Each new press reverses\nthe rotation direction. The turret can intercept enemies and their\nbullets for ten points each. Shots pass through targets and score\nmore when they hit enemies early. An enemy bullet hitting the base\nends the episode.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the base, turret, player shots, enemies,\nenemy bullets, and counters. The port uses fixed difficulty and\nrectangular collision bounds and omits decorative buildings. Each\naction advances up to four frames over a 400-action horizon. Clip\nthe episode score to [0, 400] and divide by 400.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/roll_hold.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import ceil, cos, hypot, pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Projectile:\n x: float\n y: float\n vx: float\n vy: float\n\n def move(self):\n self.x += self.vx\n self.y += self.vy\n\n\n@dataclass\nclass Enemy:\n x: float\n y: float\n vx: float\n score: float = 9\n fired: bool = False\n\n\nclass RollHoldEnvironment:\n score_cap = 400\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.angle = 0.0\n self.direction = 1\n self.steps = self.fire_timer = self.enemy_timer = 0\n self.held = self.terminal = False\n self.shots, self.enemies, self.bullets = [], [], []\n self._schedule_enemy()\n\n def _schedule_enemy(self):\n vx = 0.4 if self.random.random() < 0.5 else -0.4\n self.next_enemy = (-3 if vx > 0 else 103, self.random.uniform(9, 90), vx)\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n if held and not self.held:\n self.direction *= -1\n self.fire_timer = 0\n self.held = held\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n dx, dy = cos(self.angle), sin(self.angle)\n turret_x, turret_y = 50 + 12 * dx, 50 + 12 * dy\n if self.held:\n self.fire_timer -= 1\n if self.fire_timer < 0:\n self.shots.append(Projectile(turret_x, turret_y, 2 * dx, 2 * dy))\n self.fire_timer = 9\n else:\n self.angle = (self.angle + self.direction * 0.07 + pi) % (2 * pi) - pi\n for shot in self.shots:\n shot.move()\n self.shots = [shot for shot in self.shots if -9 <= shot.x <= 111 and -9 <= shot.y <= 111]\n self.enemy_timer -= 1\n if self.enemy_timer < 0:\n self.enemies.append(Enemy(*self.next_enemy))\n if self.random.random() < 0.25:\n self._schedule_enemy()\n self.enemy_timer = 120\n else:\n self.enemy_timer = 25\n reward = 0\n survivors = []\n for enemy in self.enemies:\n enemy.x += enemy.vx\n if not enemy.fired and (enemy.x > 90 if enemy.vx > 0 else enemy.x < 9):\n distance = hypot(50 - enemy.x, 50 - enemy.y)\n self.bullets.append(Projectile(enemy.x, enemy.y, 0.3 * (50 - enemy.x) / distance,\n 0.3 * (50 - enemy.y) / distance))\n enemy.fired = True\n if abs(enemy.x - turret_x) < 5 and abs(enemy.y - turret_y) < 5:\n reward += 10\n elif any(abs(enemy.x - shot.x) < 4.5 and abs(enemy.y - shot.y) < 4.5 for shot in self.shots):\n reward += max(0, ceil(enemy.score))\n elif -5 <= enemy.x <= 105:\n enemy.score -= 0.033\n survivors.append(enemy)\n self.enemies = survivors\n bullets = []\n for bullet in self.bullets:\n bullet.move()\n if abs(bullet.x - turret_x) < 4 and abs(bullet.y - turret_y) < 4:\n reward += 10\n elif abs(bullet.x - 50) < 5 and abs(bullet.y - 50) < 5:\n self.terminal = True\n else:\n bullets.append(bullet)\n self.bullets = bullets\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[5, 5, 0] = True\n x, y = 50 + 12 * cos(self.angle), 50 + 12 * sin(self.angle)\n state[int(y // 10), int(x // 10), 1] = True\n for channel, entities in ((2, self.shots), (3, self.enemies), (4, self.bullets)):\n for entity in entities:\n if 0 <= entity.x < 100 and 0 <= entity.y < 100:\n state[int(entity.y // 10), int(entity.x // 10), channel] = True\n values = (self.steps, self.held, self.direction > 0, round((self.angle + pi) * 75),\n self.fire_timer, self.enemy_timer)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 196, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/roll_hold.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameRollHold.c"} +{"name": "stompshelter", "split": "train", "game": "stompshelter", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Stompshelter as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to jump. A second tap in the air jumps again. Hold\nto slide faster along the automatic horizontal movement. Actions\n0–4 release. Climbing scores points as the screen scrolls. Stomp\nenemies from above for combo points. Platforms wear out under\nthe player and absorb falling debris. Lava, debris, and other\nenemy contact end the run.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the player, platforms, enemies, debris,\nlava, and counters. The port fixes difficulty and approximates\nsprite contacts with rectangles. Each action advances up to four\nframes over 400 actions. Clip scores to [0, 600] and divide by 600.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/stompshelter.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import floor\n\nimport numpy as np\n\n\n@dataclass\nclass Platform:\n x: float\n y: float\n width: float\n hp: int = 120\n\n\n@dataclass\nclass Enemy:\n x: float\n y: float\n direction: int\n\n\nclass StompshelterEnvironment:\n score_cap = 600\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 50., 70.\n self.vx, self.vy = 1, 0.\n self.steps = self.frame = self.jumps = self.combo = 0\n self.lava, self.distance = 102., 100.\n self.held = self.terminal = self.grounded = False\n self.platforms = [Platform(self.random.uniform(20, 60), y, self.random.uniform(25, 38))\n for y in range(15, 91, 15)]\n self.enemies, self.debris = [], []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n self.lava -= 0.025\n top = min((platform.y for platform in self.platforms), default=15)\n if top > 5:\n self.platforms.append(Platform(self.random.uniform(10, 55), top - self.random.uniform(13, 17),\n self.random.uniform(25, 38)))\n if self.distance < 0:\n candidates = [p for p in self.platforms if p.y < 20 and p.hp > 60]\n if candidates:\n platform = candidates[self.random.integers(len(candidates))]\n self.enemies.append(Enemy(platform.x + platform.width / 2, platform.y - 5,\n int(self.random.choice((-1, 1)))))\n self.distance = self.random.uniform(100, 200)\n if self.frame % 70 == 0:\n self.debris.append((self.random.uniform(8, 92), -4))\n if tap and (self.grounded or self.jumps < 2):\n self.vy = -2.6\n self.jumps += 1\n self.vy += 0.1\n self.y += self.vy\n self.x += self.vx * (1 if self.held else 0.1)\n if (self.x > 90 and self.vx > 0) or (self.x < 10 and self.vx < 0):\n self.vx *= -1\n self.grounded = False\n for p in self.platforms:\n if self.vy > 0 and p.hp > 0 and p.x - 3 < self.x < p.x + p.width + 3 and p.y - 8 < self.y < p.y + 2:\n self.y, self.vy, self.grounded = p.y - 4, 0, True\n self.jumps = self.combo = 0\n p.hp -= 1\n break\n scroll = max(0, 60 - self.y)\n self.y += scroll\n self.lava += scroll\n self.distance -= scroll\n reward = floor(scroll)\n for p in self.platforms:\n p.y += scroll\n self.platforms = [p for p in self.platforms if p.y < 110 and p.hp > 0]\n self.lava -= max(0, self.lava - 100) * 0.5\n self.terminal = self.y > self.lava - 3\n remaining = []\n for enemy in self.enemies:\n enemy.y += scroll\n if enemy.y >= 105:\n continue\n enemy.x += enemy.direction * 0.35\n for p in self.platforms:\n if abs(enemy.y + 5 - p.y) < 2:\n if enemy.x <= p.x + 2:\n enemy.direction = 1\n if enemy.x >= p.x + p.width - 2:\n enemy.direction = -1\n if abs(enemy.x - self.x) < 6.5 and abs(enemy.y - self.y) < 5:\n if self.vy > 0.5 and self.y < enemy.y - 2:\n self.vy = -2.2\n self.combo += 1\n reward += 8 + self.combo * 4\n continue\n self.terminal = True\n remaining.append(enemy)\n self.enemies = remaining\n remaining = []\n for x, y in self.debris:\n y += scroll + 0.5\n if y >= 105:\n continue\n blockers = [p for p in self.platforms if p.hp > 0 and p.x < x < p.x + p.width and p.y - 2 < y < p.y + 5]\n if blockers:\n for p in blockers:\n p.hp -= 15\n else:\n self.terminal |= abs(x - self.x) < 5 and abs(y - self.y) < 4\n remaining.append((x, y))\n self.debris = remaining\n self.frame += 1\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(np.clip(self.y // 10, 0, 9)), int(self.x // 10), 0] = True\n rows, cols = np.ogrid[:100:10, :100:10]\n for p in self.platforms:\n if p.hp > 0:\n state[:, :, 1] |= (rows < p.y + 4) & (rows + 10 > p.y) & (cols < p.x + p.width) & (cols + 10 > p.x)\n for channel, positions in ((2, [(e.x, e.y) for e in self.enemies]), (3, self.debris)):\n for x, y in positions:\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), channel] = True\n state[np.arange(10) * 10 + 10 > self.lava, :, 4] = True\n values = (self.steps, self.jumps, self.combo, self.held, self.vx > 0,\n int(np.clip(round((self.vy + 4) * 40), 0, 511)), self.grounded)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 197, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/stompshelter.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameStompshelter.c"} +{"name": "portal_j", "split": "train", "game": "portal_j", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Portal J as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to dive into a portal and emerge farther ahead. Actions\n0–4 release the button. Time jumps so the exit is above a floor.\nLong jumps score more, and collecting gold increases the score multiplier.\nFalling off the bottom or drifting off the left edge ends the episode.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the player, portal exit, floors, gold,\nthe player's cell during a jump, and gauges. The 10×10 observation\ncompresses a 200×50 playfield. The conversion fixes difficulty at one\nand uses rectangular bounds for gold pickup. Each action advances up\nto four frames, with a 400-action horizon. Normalize the accumulated\nscore by clipping it to [0, 3000] and dividing by 3000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/portal_j.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import ceil\n\nimport numpy as np\n\n\n@dataclass\nclass Floor:\n x: float\n width: float\n\n\nclass PortalJEnvironment:\n score_cap = 3000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y, self.portal = 30.0, 39.0, 36.0\n self.steps = self.phase = self.pending_score = 0\n self.fall = self.floor_distance = 0.0\n self.gold_distance = 30.0\n self.multiplier = 1\n self.floors = [Floor(0, 100), Floor(110, 80)]\n self.gold = []\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n scroll = max(0, self.x - 30) * 0.1 + 0.1\n self.floor_distance -= scroll\n if self.floor_distance < 0:\n interval = self.random.uniform(50, 99)\n fraction = self.random.uniform(0.4, 0.7)\n x = 200 + self.floor_distance + interval * self.random.uniform(0, 1 - fraction)\n self.floors.append(Floor(x, interval * fraction))\n self.floor_distance += interval\n for floor in self.floors:\n floor.x -= scroll\n self.floors = [floor for floor in self.floors if floor.x + floor.width >= 0]\n self.x -= scroll\n self.portal -= scroll\n if self.fall:\n self.fall += 0.2\n self.y = 39 + self.fall\n reward = 0\n if self.phase:\n self.phase += 1\n if self.phase < 5:\n self.y += self.phase\n else:\n distance = self.portal - self.x\n if distance > 0:\n self.pending_score = ceil(distance ** 1.5 * 0.1 * self.multiplier)\n self.x = self.portal\n self.y = 47 - self.phase\n if self.y < 39:\n self.y = 39\n self.phase = 0\n reward = self.pending_score\n self.pending_score = 0\n else:\n self.portal += 2\n if self.portal > 200:\n self.portal = self.x + 6\n if tap:\n self.phase = 1\n if self.phase == 0:\n on_floor = self.y + 2.5 > 40 and self.y - 2.5 < 48 and any(\n self.x + 2.5 > floor.x and self.x - 2.5 < floor.x + floor.width\n for floor in self.floors\n )\n self.fall = 0 if on_floor else self.fall or 1\n self.terminal = self.y > 52 or self.x < 0\n\n self.gold_distance -= scroll\n if self.gold_distance < 0:\n self.gold.append(203)\n self.gold_distance += self.random.uniform(99, 120)\n remaining = []\n for x in self.gold:\n x -= scroll\n if abs(x - self.x) < 5 and abs(self.y - 36) < 5:\n self.multiplier += 1\n elif x >= -3:\n remaining.append(x)\n self.gold = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n if 0 <= self.x < 200 and 0 <= self.y < 50:\n state[int(self.y // 5), int(self.x // 20), 0] = True\n if 0 <= self.portal < 200:\n state[8, int(self.portal // 20), 1] = True\n columns = np.arange(10) * 20\n for floor in self.floors:\n state[8:10, :, 2] |= (columns < floor.x + floor.width) & (columns + 20 > floor.x)\n for x in self.gold:\n if 0 <= x < 200:\n state[7, int(x // 20), 3] = True\n if self.phase and 0 <= self.x < 200:\n state[8, int(self.x // 20), 4] = True\n for row, value in enumerate((self.steps, self.phase, self.multiplier, self.pressed)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 198, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/portal_j.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/portalj/main.js"} +{"name": "breed_c", "split": "train", "game": "breed_c", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Breed C as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nMove the cursor with actions 1–4 (left, up, down, right). Tap action\n5 to select a cell. Action 0 waits. A selection clears its entire\northogonally connected group if it contains at least four cells of\nthe same color. It scores the group size times the multiplier and\nincreases the multiplier. A smaller group subtracts its size and\ntriggers two growth events. Selecting an empty cell also triggers\ntwo growth events.\n\nGrowth alternates between horizontal and vertical expansion and\nresets the multiplier. After a clear, blocks settle toward the\ncenter along both axes. The run ends when the board fills or after\n400 actions.\n\nINPUT CHANNEL TABLE\nThe conversion replaces pointer input with a directional cursor\nand uses a centered 9×9 board within the 10×10 observation. The six\nchannels show four colors, the cursor, and gauges. At fixed\ndifficulty, growth takes 30 actions and settling takes 15.\n\nSCORING, TERMINATION, AND HORIZON\nThe benchmark sums signed points within each episode, clips the mean\nepisode score to [0, 250], and divides by the fixed cap of 250.\nAcross 100 seeds without sticky actions, random inputs averaged\n24.30 raw points and reached 291 before clipping. Selecting the\ncenter every 45 actions averaged 50.69 and reached 197.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/breed_c.py`):\n```python\nimport numpy as np\n\n\nSIZE = 9\nCENTER = SIZE // 2\nEMPTY = -1\nHORIZON = 400\nGROWTH_INTERVAL = 30\nSETTLE_DELAY = 15\nDIRECTIONS = ((0, -1), (-1, 0), (1, 0), (0, 1))\n\n\nclass BreedCEnvironment:\n score_cap = 250\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.last_action = self.growth_count = self.settle = self.clears = 0\n self.multiplier = 1\n self.timer = GROWTH_INTERVAL\n self.terminal = False\n self.cursor = CENTER, CENTER\n self.grid = np.full((SIZE, SIZE), EMPTY, dtype=np.int8)\n self.grid[CENTER, CENTER] = self.random.integers(4)\n self._grow()\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n select = action == 5 and self.last_action != 5\n self.last_action = action\n self.steps += 1\n reward = 0\n if 1 <= action <= 4:\n dy, dx = DIRECTIONS[action - 1]\n y, x = self.cursor\n self.cursor = min(SIZE - 1, max(0, y + dy)), min(SIZE - 1, max(0, x + dx))\n if self.settle:\n self.settle -= 1\n if not self.settle:\n self._compact()\n self.clears += 1\n self.timer = GROWTH_INTERVAL\n else:\n if self.grid[CENTER, CENTER] == EMPTY:\n self.grid[CENTER, CENTER] = self.random.integers(4)\n if select:\n reward = self._erase()\n if not self.settle:\n self.timer -= 1\n if self.timer <= 0:\n self._grow()\n self.terminal = self.steps >= self.horizon or bool(np.all(self.grid != EMPTY))\n return float(reward), self.terminal\n\n def _erase(self) -> int:\n color = self.grid[self.cursor]\n group = set()\n if color != EMPTY:\n group.add(self.cursor)\n pending = [self.cursor]\n while pending:\n y, x = pending.pop()\n for dy, dx in DIRECTIONS:\n ny, nx = y + dy, x + dx\n neighbor = ny, nx\n if 0 <= ny < SIZE and 0 <= nx < SIZE and neighbor not in group and self.grid[neighbor] == color:\n group.add(neighbor)\n pending.append(neighbor)\n size = len(group)\n if size < 4:\n self._grow()\n self._grow()\n return -size\n for cell in group:\n self.grid[cell] = EMPTY\n reward = size * self.multiplier\n self.multiplier += 1\n self.settle = SETTLE_DELAY\n return reward\n\n def _grow(self) -> None:\n lines = self.grid if self.growth_count % 2 == 0 else self.grid.T\n old = lines.copy()\n lines[:, :CENTER - 1] = old[:, 1:CENTER]\n lines[:, CENTER + 2:] = old[:, CENTER + 1:-1]\n for line in lines:\n color = int(line[CENTER])\n if color != EMPTY:\n direction = int(self.random.choice((-1, 1)))\n new_color = (color + int(self.random.integers(3))) % 4\n line[CENTER - direction] = color\n line[CENTER] = line[CENTER + direction] = new_color\n self.growth_count += 1\n self.multiplier = 1\n self.timer = GROWTH_INTERVAL\n\n def _compact(self) -> None:\n axes = (self.grid, self.grid.T)\n if self.clears % 2:\n axes = axes[::-1]\n moved = True\n while moved:\n moved = False\n for lines in axes:\n for line in lines:\n for start, stop, step in ((CENTER, 0, -1), (CENTER, SIZE - 1, 1)):\n for index in range(start, stop, step):\n source = index + step\n if line[index] == EMPTY and line[source] != EMPTY:\n line[index], line[source] = line[source], EMPTY\n moved = True\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for color in range(4):\n state[:SIZE, :SIZE, color] = self.grid == color\n state[*self.cursor, 4] = True\n for row, value in enumerate((self.steps, self.timer, self.settle, self.multiplier)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.last_action == 5\n state[9, 1, 5] = self.growth_count % 2 == 1\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 199, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/breed_c.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/breedc/main.js"} +{"name": "vine_climber", "split": "train", "game": "vine_climber", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Vine Climber as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to climb the swaying vine. Release with any other\naction to slide down. Catch coins as they cross the screen.\nEach catch pays the current multiplier and increases it up to\nnine. Missing a coin resets it to one. Contact with a falling\nobstacle ends the run.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the climber, vine, obstacles, coin,\nrightward coin movement, and counters. Offscreen coins are\nprojected to the nearest edge. The port fixes difficulty and\nuses rectangular overlap to approximate sprite collisions. Each\naction advances up to four frames over 400 actions. Clip scores\nto [0, 30] and divide by 30.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/vine_climber.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, pi\n\nimport numpy as np\n\n\n@dataclass\nclass MovingObject:\n x: float\n y: float\n speed: float\n\n\nclass VineClimberEnvironment:\n score_cap = 30\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.vine_tick = 0\n self.amplitude, self.frequency, self.bend = 30., 0.03, 0.5\n self.target = (self.amplitude, self.frequency, self.bend)\n self.x, self.y = 50., 80.\n self.obstacles = []\n self.timer = 0.\n self.coin = None\n self.multiplier = 1\n self.steps = self.action = 0\n self.terminal = False\n\n def _vine_x(self, y):\n return 50 - cos((self.vine_tick + y * self.bend) * self.frequency) * self.amplitude\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n self.y = min(99, max(0, self.y + (-0.8 if self.action == 5 else 1.2)))\n self.x = self._vine_x(self.y)\n self.vine_tick += 1\n amplitude, frequency, bend = self.target\n self.amplitude += (amplitude - self.amplitude) * 0.01\n self.frequency += (frequency - self.frequency) * 0.01\n self.bend += (bend - self.bend) * 0.01\n if self.random.random() < 0.005:\n self.target = tuple(self.random.uniform((25, 0.025, 0.45), (40, 0.04, 0.6)))\n if self.vine_tick * self.frequency >= 2 * pi:\n self.vine_tick = 0\n\n for obstacle in self.obstacles:\n obstacle.speed += 0.01\n obstacle.y += obstacle.speed\n self.obstacles = [obstacle for obstacle in self.obstacles if obstacle.y <= 105]\n self.terminal = any(self._touches(obstacle) for obstacle in self.obstacles)\n self.timer -= 1\n if self.timer < 0:\n self.obstacles.append(MovingObject(self.random.uniform(10, 90), 0,\n self.random.uniform(0, 0.5)))\n self.timer = self.random.uniform(70, 90)\n\n if self.coin is None:\n speed = self.random.choice((-1, 1)) * self.random.uniform(0.18, 0.25)\n self.coin = MovingObject(-10 if speed > 0 else 110, self.random.uniform(10, 90), speed)\n self.coin.x += self.coin.speed\n if self._touches(self.coin):\n reward = self.multiplier\n self.multiplier = min(9, self.multiplier + 1)\n self.coin = None\n return reward\n if not -10 <= self.coin.x <= 110:\n self.coin = None\n self.multiplier = 1\n return 0\n\n def _touches(self, obj):\n return abs(obj.x - self.x) < 5 and abs(obj.y - self.y) < 5\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(self.y // 10), int(self.x // 10), 0] = True\n for y in range(0, 100, 2):\n state[y // 10, int(self._vine_x(y) // 10), 1] = True\n for obstacle in self.obstacles:\n if obstacle.y < 100:\n state[int(obstacle.y // 10), int(obstacle.x // 10), 2] = True\n if self.coin is not None:\n col = int(np.clip(self.coin.x // 10, 0, 9))\n state[int(self.coin.y // 10), col, 3] = True\n state[int(self.coin.y // 10), col, 4] = self.coin.speed > 0\n values = (self.steps, self.action, self.multiplier, self.vine_tick,\n round(self.amplitude * 10), round(self.frequency * 10000),\n round(self.bend * 100), round(self.timer))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 200, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/vine_climber.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameVineClimber.c"} +{"name": "cywall", "split": "train", "game": "cywall", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Cywall as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to move to the next ring center. Release with actions\n0–4 between moves. Time the move so its path clears the rotating\nwalls and other ring centers. A blocked move or drifting below\nthe screen ends the run.\n\nINPUT CHANNEL TABLE\nScore is the distance scrolled. Scrolling speeds up when the\ncurrent ring is higher on screen. The six 10×10 channels show the\ncurrent center, next center, other centers, walls, transfer path,\nand gauges. Each action advances four frames at fixed difficulty.\nThe conversion samples the transfer path against wall geometry.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 1000] and divide by the fixed cap of 1,000. Across 100 seeds\nwithout sticky actions, idle averaged 123.95 and random inputs\naveraged 82.39. A heuristic that checked the exact transfer path\naveraged 670.22 and reached 1,049.27 before clipping.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/cywall.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Ring:\n x: float\n y: float\n radius: float\n count: int\n angle: float\n spin: float\n length: float\n following: \"Ring | None\" = None\n\n def walls(self):\n for index in range(self.count):\n angle = self.angle + index * math.tau / self.count\n cos, sin = math.cos(angle), math.sin(angle)\n yield self.x + cos * self.radius, self.y + sin * self.radius, -sin, cos\n\n\nclass CywallEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = 0\n self.pressed = self.terminal = False\n self.rings: list[Ring] = []\n self.player = self._spawn()\n self.next_ring = self.random.uniform(20, 40)\n\n def _spawn(self) -> Ring:\n radius = self.random.uniform(20, 30)\n ring = Ring(self.random.uniform(20, 80), -radius, radius,\n int(self.random.integers(1, 4)), self.random.uniform(0, math.tau),\n self.random.uniform(0.02, 0.05) * self.random.choice((-1, 1)),\n self.random.uniform(10, 20))\n if self.rings:\n self.rings[-1].following = ring\n self.rings.append(ring)\n return ring\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0.0\n for frame in range(4):\n reward += self._advance_frame(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _advance_frame(self, tap: bool) -> float:\n if self.next_ring <= 0:\n self._spawn()\n self.next_ring += self.random.uniform(20, 40)\n scroll = 0.1 + max(0, 50 - self.player.y) * 0.05\n self.next_ring -= scroll\n for ring in self.rings:\n ring.y += scroll\n ring.angle = (ring.angle + ring.spin) % math.tau\n self.rings = [ring for ring in self.rings if ring.y <= 99 + ring.radius]\n if self.player.y > 99:\n self.terminal = True\n elif tap and self.player.following is not None:\n target = self.player.following\n if self._blocked(target):\n self.terminal = True\n else:\n self.player = target\n return scroll\n\n def _blocked(self, target: Ring) -> bool:\n start = self.player\n dx, dy = target.x - start.x, target.y - start.y\n samples = max(1, math.ceil(math.hypot(dx, dy)))\n for ring in self.rings:\n for x, y, wx, wy in ring.walls():\n for index in range(samples + 1):\n fraction = index / samples\n px, py = start.x + dx * fraction - x, start.y + dy * fraction - y\n if abs(px * wx + py * wy) <= ring.length / 2 + 1.5 and abs(px * wy - py * wx) <= 3:\n return True\n if ring is not start and ring is not target:\n distance_sq = dx * dx + dy * dy\n fraction = min(1, max(0, ((ring.x - start.x) * dx + (ring.y - start.y) * dy) / distance_sq)) if distance_sq else 0\n if math.hypot(start.x + dx * fraction - ring.x, start.y + dy * fraction - ring.y) < 3:\n return True\n return False\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for ring in self.rings:\n col = int(ring.x) // 10\n if 0 <= ring.y < 100:\n channel = 0 if ring is self.player else 1 if ring is self.player.following else 2\n state[int(ring.y) // 10, col, channel] = True\n for x, y, wx, wy in ring.walls():\n for offset in np.linspace(-ring.length / 2, ring.length / 2, 9):\n px, py = x + offset * wx, y + offset * wy\n if 0 <= px < 100 and 0 <= py < 100:\n state[int(py) // 10, int(px) // 10, 3] = True\n if self.player.following is not None:\n target = self.player.following\n for fraction in np.linspace(0, 1, 16):\n x = self.player.x + fraction * (target.x - self.player.x)\n y = self.player.y + fraction * (target.y - self.player.y)\n if 0 <= y < 100:\n state[int(y) // 10, int(x) // 10, 4] = True\n for row, value in enumerate((self.steps, round(self.player.y + 32))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 201, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/cywall.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/cywall/main.js"} +{"name": "twin_p", "split": "train", "game": "twin_p", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Twin P as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to stretch the rotating link. Release with any other\naction to pin the free end, swap which end rotates, and shorten the\nlink. Sweep through circles to score the current multiplier and\nincrease it. Circles that pass through the playfield uncollected\nreduce the multiplier. Crossing a hazard or moving both ends out\nof bounds ends the episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the pivot, free end, link, circles, hazards,\nand counters. Difficulty is fixed, and distance to the link\napproximates the original collision checks. Each action advances up\nto four frames over 400 actions. Clip episode scores to [0, 200]\nand divide by 200.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/twin_p.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, hypot, pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Target:\n x: float\n y: float\n vx: float\n vy: float\n hazard: bool = False\n entered: bool = False\n\n\nclass TwinPEnvironment:\n score_cap = 200\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y, self.angle = 40., 50., 0.\n self.length = self.target_length = 15.\n self.targets = []\n self.timer = 0.\n self.until_hazard = 9\n self.multiplier = 1\n self.action = self.steps = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n pin = previous == 5 and self.action != 5\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(pin and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _endpoint(self):\n return self.x + cos(self.angle) * self.length, self.y + sin(self.angle) * self.length\n\n def _advance(self, pin):\n end_x, end_y = self._endpoint()\n if not (_inside(self.x, self.y) or _inside(end_x, end_y)):\n self.terminal = True\n return 0\n\n dx, dy = end_x - self.x, end_y - self.y\n start_x, start_y = self.x, self.y\n if pin:\n self.x, self.y = end_x, end_y\n self.angle += pi\n self.target_length = 15.\n elif self.action == 5:\n self.target_length = min(99, self.target_length + 0.2)\n self.angle = (self.angle + 0.05) % (2 * pi)\n self.length += (self.target_length - self.length) * 0.2\n\n self.timer -= 1\n if self.timer < 0:\n self._spawn()\n reward = 0\n remaining = []\n for target in self.targets:\n target.x += target.vx\n target.y += target.vy\n if -5 <= target.x < 105 and -5 <= target.y < 105:\n target.entered = True\n elif target.entered:\n if not target.hazard:\n self.multiplier = max(1, self.multiplier - 1)\n continue\n rx, ry = target.x - start_x, target.y - start_y\n along = min(1, max(0, (rx * dx + ry * dy) / (dx * dx + dy * dy)))\n if hypot(rx - along * dx, ry - along * dy) <= (3.5 if target.hazard else 3):\n if target.hazard:\n self.terminal = True\n else:\n reward += self.multiplier\n self.multiplier += 1\n continue\n remaining.append(target)\n self.targets = remaining\n return reward\n\n def _spawn(self):\n angle = self.random.uniform(0, 2 * pi)\n x, y = 50 + cos(angle) * 80, 50 + sin(angle) * 80\n dx, dy = self.random.uniform(20, 80, 2) - (x, y)\n scale = 0.2 / hypot(dx, dy)\n self.targets.append(Target(x, y, dx * scale, dy * scale, self.until_hazard == 0))\n self.until_hazard -= 1\n if self.until_hazard < 0:\n self.until_hazard = int(self.random.integers(8, 12))\n self.timer = self.random.uniform(60, 90)\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n end_x, end_y = self._endpoint()\n _mark(state, self.x, self.y, 0)\n _mark(state, end_x, end_y, 1)\n for x, y in zip(np.linspace(self.x, end_x, 41), np.linspace(self.y, end_y, 41), strict=True):\n _mark(state, x, y, 2)\n for target in self.targets:\n _mark(state, target.x, target.y, 4 if target.hazard else 3)\n values = (self.steps, self.action, round(self.length * 4), round(self.target_length * 4),\n round(self.angle * 64), self.multiplier, self.until_hazard)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n\ndef _inside(x, y):\n return 0 <= x < 99 and 0 <= y < 99\n\n\ndef _mark(state, x, y, channel):\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), channel] = True\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 202, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/twin_p.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/twinp/main.js"} +{"name": "up_down_press", "split": "train", "game": "up_down_press", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Up Down Press as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 while grounded to jump. Hold it to accelerate and\nreduce gravity. Release with any other action before tapping again.\nLand on traffic to score the current multiplier and bounce. Each\nstomp doubles the multiplier up to 16. A fresh jump resets it.\nSide collisions knock the car backward. Falling behind the left\nedge ends the run.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the car, road, traffic, descending car,\nascending car, and counters. The port fixes difficulty, uses\n20×10-unit cells, and approximates sprite overlap with distance\nchecks. Each action advances up to four frames over 400 actions.\nClip episode scores to [0, 100] and divide by 100.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/up_down_press.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import atan2\n\nimport numpy as np\n\n\n@dataclass\nclass Car:\n x: float\n size: float\n target: float\n speed: float = 0.\n angle: float = 0.\n\n\nclass UpDownPressEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.road = [(0., 50.), (100., 50.)]\n self.road_distance, self.car_distance = -250., 0.\n self.cars = []\n self.x, self.y, self.speed = 20., 50., 1.\n self.vx = self.vy = self.angle = 0.\n self.airborne = self.terminal = False\n self.multiplier = 1\n self.steps = self.action = 0\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n jump = self.action == 5 and previous != 5\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(jump and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _surface(self, x):\n for (left, y), (right, end_y) in zip(self.road, self.road[1:]):\n if x < right:\n return y + (x - left) * (end_y - y) / (right - left), atan2(end_y - y, right - left)\n return self.road[-1][1], 0.\n\n def _advance(self, jump):\n scroll = 0.1 + max(0, self.x - 50) * 0.1\n ahead, _ = self._surface(self.x + 50)\n vertical = 0.1 + (ahead - min(90, max(60, ahead))) * 0.1\n self.road_distance -= scroll\n while self.road_distance < 0:\n x, y = self.road[-1]\n width = self.random.uniform(20, 60)\n rise = 0.\n if y == self.road[-2][1]:\n rise = self.random.choice((-1, 1)) * self.random.uniform(0.4, 1.1) * width\n self.road.append((x + width, y + rise))\n self.road_distance += width\n self.road = [(x - scroll, y - vertical) for x, y in self.road]\n while len(self.road) > 2 and self.road[1][0] < -50:\n self.road.pop(0)\n\n self.x += self.speed - scroll + self.vx\n self.vx *= 0.9\n if self.x < 0:\n self.terminal = True\n return 0\n height, slope = self._surface(self.x)\n if self.airborne and self.y > height:\n self.airborne = False\n if not self.airborne:\n self.y = height\n self.speed += self.angle * 0.1\n self.angle += (slope - self.angle) * 0.025\n if jump:\n self.airborne = True\n self.vy = -2\n self.multiplier = 1\n if self.airborne:\n self.y += self.vy\n self.vy += 0.05 if self.action == 5 else 0.2\n self.angle += (atan2(self.vy, self.speed) - self.angle) * 0.05\n self.speed += ((2.5 if self.action == 5 else 0.5) - self.speed) * 0.1\n return self._traffic(scroll)\n\n def _traffic(self, scroll):\n self.car_distance -= scroll\n if self.car_distance < 0:\n target = self.random.uniform(0.3, 2)\n self.cars.append(Car(205, self.random.uniform(5, 8), target))\n self.car_distance += self.random.uniform(100, 120)\n reward = 0\n remaining = []\n for car in self.cars:\n car.x += car.speed - scroll\n if not self.road[0][0] <= car.x < self.road[-1][0]:\n continue\n y, slope = self._surface(car.x)\n car.speed += car.size * car.angle * 0.02\n car.speed += (car.target - car.speed) * 0.1\n car.angle += (slope - car.angle) * 0.025\n if abs(car.x - self.x) < (car.size + 5) / 2:\n pressing = self.airborne and self.vy >= 0\n if pressing and abs((self.y - 3) - (y - car.size)) < 6:\n reward += self.multiplier\n self.multiplier = min(16, self.multiplier * 2)\n self.vy = -2\n continue\n if not pressing and abs((self.y - 5) - (y - car.size)) < 5:\n self.vx = -car.size - self.speed * 1.5\n remaining.append(car)\n self.cars = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n _mark(state, self.x, self.y, 0)\n for x in range(0, 200, 4):\n _mark(state, x, self._surface(x)[0], 1)\n for car in self.cars:\n _mark(state, car.x, self._surface(car.x)[0], 2)\n if self.airborne:\n _mark(state, self.x, self.y, 3 if self.vy >= 0 else 4)\n values = (self.steps, self.action, self.multiplier, round(self.speed * 64),\n round((self.vy + 4) * 32), round((self.vx + 16) * 16),\n round((self.angle + 2) * 64))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n\ndef _mark(state, x, y, channel):\n if 0 <= x < 200 and 0 <= y < 100:\n state[int(y // 10), int(x // 20), channel] = True\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 203, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/up_down_press.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/updownpress/main.js"} +{"name": "ice_hockey", "split": "train", "game": "ice_hockey", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Ice Hockey as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves Activision Ice Hockey's two-on-two single-period game. Each team has a\nforward and goalie, and control automatically belongs to the teammate closest to the puck. Moving\nnext to a loose puck captures it. Action 5 shoots only toward the opponent's goal when the active\nplayer has possession; the puck's three-phase movement across the stick selects an upward,\nstraight, or downward angle. Shots rebound from the top, bottom, and non-goal portions of the end\nboards, enabling bank passes and shots.\n\nWithout possession, action 5 body-checks an adjacent opponent, briefly stunning that skater and\nknocking the puck loose. The deterministic computer team uses the same possession, checking,\ngoalie, shooting, and rebound rules. Goals award one native point and reset both teams for a\nthree-step faceoff. A 360-step clock represents the original three-minute period.\n\nACTION MAPPING\n0: hold position\n1: skate left\n2: skate up\n3: skate right\n4: skate down\n5: shoot with possession or check without it\n\nINPUT CHANNEL TABLE\n0: human forward and goalie\n1: computer forward and goalie\n2: puck\n3: possession marker\n4: previous skater and puck positions\n5: exact scores, clock, active skaters, puck velocity, stick phase, possession identity, stuns, and faceoff timer\n\nSCORING, TERMINATION, AND HORIZON\nAfter every goal, three faceoff steps must elapse. Capturing the center puck requires at least one\nlive step, and a forward shot then needs at least five puck movements to travel from the capturing\nstick through the far goal line. Thus consecutive goals require at least nine clock steps. The\n360-step period permits at most `360 / 9 = 40` player goals, so `score_cap = 40`. Normalization is\n`min(max(raw_score, 0), 40) / 40`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/ice_hockey.py`):\n```python\nimport numpy as np\n\n\nclass IceHockeyEnvironment:\n \"\"\"Two-on-two timed hockey with automatic nearest-player control.\"\"\"\n\n score_cap = 40.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 360):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.player_team = [[5, 3], [5, 1]]\n self.opponent_team = [[4, 6], [4, 8]]\n self.previous_player_team = [player.copy() for player in self.player_team]\n self.previous_opponent_team = [player.copy() for player in self.opponent_team]\n self.puck = [5, 5]\n self.previous_puck = self.puck.copy()\n self.puck_velocity = [0, 0]\n self.possession: tuple[str, int] | None = None\n self.player_stun = [0, 0]\n self.opponent_stun = [0, 0]\n self.player_score = 0\n self.opponent_score = 0\n self.clock = 0\n self.faceoff_timer = 3\n self.stick_phase = -1\n self.last_action = 0\n self.terminal = False\n\n def active_player(self, team: str) -> int:\n players = self.player_team if team == \"player\" else self.opponent_team\n return min(\n range(2),\n key=lambda index: (abs(players[index][0] - self.puck[0]) + abs(players[index][1] - self.puck[1]), index),\n )\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player_team = [player.copy() for player in self.player_team]\n self.previous_opponent_team = [player.copy() for player in self.opponent_team]\n self.previous_puck = self.puck.copy()\n reward = 0.0\n if self.faceoff_timer > 0:\n self.faceoff_timer -= 1\n if self.faceoff_timer == 0:\n self._capture_loose_puck()\n else:\n self._move_player(action)\n self._move_opponent()\n self._capture_loose_puck()\n reward = self._move_puck()\n self.stick_phase = -1 if self.stick_phase == 1 else self.stick_phase + 1\n self.player_stun = [max(0, value - 1) for value in self.player_stun]\n self.opponent_stun = [max(0, value - 1) for value in self.opponent_stun]\n self.clock += 1\n if self.clock >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_player(self, action: int) -> None:\n index = self.active_player(\"player\")\n if self.player_stun[index] > 0:\n return\n if action in (1, 2, 3, 4):\n delta = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}[action]\n self._move_skater(self.player_team[index], delta)\n if self.possession == (\"player\", index):\n self.puck = self.player_team[index].copy()\n elif action == 5:\n if self.possession == (\"player\", index):\n self.possession = None\n self.puck_velocity = [self.stick_phase, 1]\n else:\n self._check(\"player\", index)\n\n def _move_opponent(self) -> None:\n index = self.active_player(\"opponent\")\n if self.opponent_stun[index] > 0:\n return\n skater = self.opponent_team[index]\n if self.possession == (\"opponent\", index) and skater[1] <= 3:\n self.possession = None\n self.puck_velocity = [self.stick_phase, -1]\n return\n target = [5, 0] if self.possession == (\"opponent\", index) else self.puck\n row_delta = int(np.sign(target[0] - skater[0]))\n column_delta = int(np.sign(target[1] - skater[1]))\n delta = (0, column_delta) if column_delta else (row_delta, 0)\n self._move_skater(skater, delta)\n if self.possession == (\"opponent\", index):\n self.puck = skater.copy()\n elif any(abs(skater[0] - player[0]) + abs(skater[1] - player[1]) <= 1 for player in self.player_team):\n self._check(\"opponent\", index)\n\n @staticmethod\n def _move_skater(skater: list[int], delta: tuple[int, int]) -> None:\n skater[0] = int(np.clip(skater[0] + delta[0], 0, 9))\n skater[1] = int(np.clip(skater[1] + delta[1], 0, 9))\n\n def _check(self, team: str, index: int) -> None:\n checker = self.player_team[index] if team == \"player\" else self.opponent_team[index]\n other_team = self.opponent_team if team == \"player\" else self.player_team\n other_stun = self.opponent_stun if team == \"player\" else self.player_stun\n for other_index, skater in enumerate(other_team):\n if abs(checker[0] - skater[0]) + abs(checker[1] - skater[1]) <= 1:\n other_stun[other_index] = 2\n if self.possession == ((\"opponent\" if team == \"player\" else \"player\"), other_index):\n self.possession = None\n self.puck = skater.copy()\n self.puck_velocity = [0, 0]\n return\n\n def _capture_loose_puck(self) -> None:\n if self.possession is not None or self.puck_velocity != [0, 0]:\n return\n candidates = []\n for team, players, stuns in (\n (\"player\", self.player_team, self.player_stun),\n (\"opponent\", self.opponent_team, self.opponent_stun),\n ):\n for index, skater in enumerate(players):\n distance = abs(skater[0] - self.puck[0]) + abs(skater[1] - self.puck[1])\n if distance <= 1 and stuns[index] == 0:\n candidates.append((distance, 0 if team == \"player\" else 1, team, index))\n if candidates:\n _, _, team, index = min(candidates)\n self.possession = (team, index)\n players = self.player_team if team == \"player\" else self.opponent_team\n self.puck = players[index].copy()\n\n def _move_puck(self) -> float:\n if self.possession is not None or self.puck_velocity == [0, 0]:\n return 0.0\n self.puck[0] += self.puck_velocity[0]\n self.puck[1] += self.puck_velocity[1]\n if self.puck[0] < 0 or self.puck[0] > 9:\n self.puck[0] = int(np.clip(self.puck[0], 0, 9))\n self.puck_velocity[0] *= -1\n if self.puck[1] >= 9:\n if self.puck[0] in (4, 5):\n self.player_score += 1\n self._faceoff()\n return 1.0\n self.puck[1] = 9\n self.puck_velocity[1] = -1\n elif self.puck[1] <= 0:\n if self.puck[0] in (4, 5):\n self.opponent_score += 1\n self._faceoff()\n return 0.0\n self.puck[1] = 0\n self.puck_velocity[1] = 1\n for team, players in ((\"player\", self.player_team), (\"opponent\", self.opponent_team)):\n for index, skater in enumerate(players):\n if skater == self.puck:\n self.possession = (team, index)\n self.puck_velocity = [0, 0]\n return 0.0\n return 0.0\n\n def _faceoff(self) -> None:\n self.player_team = [[5, 3], [5, 1]]\n self.opponent_team = [[4, 6], [4, 8]]\n self.puck = [5, 5]\n self.puck_velocity = [0, 0]\n self.possession = None\n self.faceoff_timer = 3\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for skater in self.player_team:\n state[*skater, 0] = True\n for skater in self.opponent_team:\n state[*skater, 1] = True\n state[*self.puck, 2] = True\n if self.possession is not None:\n state[*self.puck, 3] = True\n for skater in self.previous_player_team + self.previous_opponent_team:\n state[*skater, 4] = True\n state[*self.previous_puck, 4] = True\n for bit in range(6):\n state[9, bit, 5] = bool(self.player_score & (1 << bit))\n state[8, bit, 5] = bool(self.opponent_score & (1 << bit))\n for bit in range(9):\n state[7, bit, 5] = bool(self.clock & (1 << bit))\n state[6, self.active_player(\"player\"), 5] = True\n state[6, 2 + self.active_player(\"opponent\"), 5] = True\n state[6, 4 + self.puck_velocity[0], 5] = True\n state[5, 4 + self.puck_velocity[1], 5] = True\n state[5, 7 + self.stick_phase, 5] = True\n if self.possession is not None:\n state[4, 0 if self.possession[0] == \"player\" else 1, 5] = True\n state[4, 2 + self.possession[1], 5] = True\n for index, stun in enumerate(self.player_stun):\n state[3, index, 5] = stun > 0\n for index, stun in enumerate(self.opponent_stun):\n state[3, 2 + index, 5] = stun > 0\n state[3, 4 : 4 + self.faceoff_timer, 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 204, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/ice_hockey.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "tennis", "split": "train", "game": "tennis", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Tennis as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves a full-speed singles set against the computer pro, four-direction court\nmovement during rallies, lateral-only pre-serve positioning, player and computer serving, automatic\nracket swings when positioned, contact-position shot placement, sharper net angles, baseline and\nserve-and-volley strategy, alternating servers, side changes after odd games, 15–30–40 scoring,\ndeuce, advantage, six games with a two-game lead, and the cartridge's special 6–6 reset.\n\nACTION MAPPING\n0: hold position\n1: move left\n2: move toward the net\n3: move right\n4: move toward the baseline\n5: serve when the player is server\n\nINPUT CHANNEL TABLE\n0: controlled player\n1: computer pro\n2: ball\n3: net\n4: previous player, opponent, and ball positions\n5: exact point/game scores, ball velocity, server, phase, side, reset state, and clock\n\nSCORING, TERMINATION, AND HORIZON\nThe task score is bounded set progress, not a farmable count of rally points. Winning one player\ngame advances progress by one. The manual's 6–6 rule resets progress to zero; a set victory sets\nprogress to six. Action reward is the change in this potential, so games erased by the reset are\nalso removed from accumulated reward. Thus `score_cap = 6`, and normalization is\n`min(max(raw_score, 0), 6) / 6`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/tennis.py`):\n```python\nimport numpy as np\n\n\nMOVE_DELTAS = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}\n\n\nclass TennisEnvironment:\n \"\"\"One Activision-style set with automatic positional racket contact.\"\"\"\n\n score_cap = 6.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 2_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.player = [8, 5]\n self.opponent = [1, 5]\n self.previous_player = self.player.copy()\n self.previous_opponent = self.opponent.copy()\n self.ball = self.player.copy()\n self.previous_ball = self.ball.copy()\n self.ball_velocity = [0, 0]\n self.server = \"player\"\n self.phase = \"serve\"\n self.serve_delay = 2\n self.player_points = 0\n self.opponent_points = 0\n self.player_games = 0\n self.opponent_games = 0\n self.tiebreak_reset = False\n self.side_swapped = False\n self.score = 0.0\n self.steps = 0\n self.last_action = 0\n self.winner: str | None = None\n self.terminal = False\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n self.previous_opponent = self.opponent.copy()\n self.previous_ball = self.ball.copy()\n previous_progress = self._progress_score()\n self._move_player(action)\n if self.phase == \"serve\":\n self._serve(action)\n else:\n self._player_return()\n self._move_opponent()\n self._opponent_return()\n self._move_ball()\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n progress = self._progress_score()\n self.score = progress\n return progress - previous_progress, self.terminal\n\n def _move_player(self, action: int) -> None:\n if action not in MOVE_DELTAS:\n return\n row_delta, column_delta = MOVE_DELTAS[action]\n if self.phase == \"serve\":\n row_delta = 0\n self.player[0] = int(np.clip(self.player[0] + row_delta, 5, 9))\n self.player[1] = int(np.clip(self.player[1] + column_delta, 1, 8))\n if self.phase == \"serve\" and self.server == \"player\":\n self.ball = self.player.copy()\n\n def _serve(self, action: int) -> None:\n if self.server == \"player\":\n if action != 5:\n return\n lateral = int(np.sign(self.player[1] - 5))\n self.ball = self.player.copy()\n self.ball_velocity = [-1, lateral]\n self.phase = \"rally\"\n return\n self.serve_delay -= 1\n if self.serve_delay > 0:\n return\n lateral = -1 if self.player[1] >= 5 else 1\n self.ball = self.opponent.copy()\n self.ball_velocity = [1, lateral]\n self.phase = \"rally\"\n\n def _player_return(self) -> None:\n if self.ball_velocity[0] <= 0 or self.ball[0] < 6:\n return\n row_distance = abs(self.player[0] - self.ball[0])\n column_offset = self.ball[1] - self.player[1]\n if row_distance > 1 or abs(column_offset) > 1:\n return\n lateral = int(np.sign(column_offset))\n if self.player[0] <= 6 and lateral == 0:\n lateral = -1 if self.opponent[1] >= 5 else 1\n self.ball_velocity = [-1, lateral]\n\n def _move_opponent(self) -> None:\n if self.ball_velocity[0] < 0:\n target_row = int(np.clip(self.ball[0] - 2, 0, 4))\n target_column = int(np.clip(self.ball[1] + self.ball_velocity[1] * 2, 1, 8))\n else:\n target_row = 1\n target_column = 5\n if self.opponent[1] != target_column:\n self.opponent[1] += int(np.sign(target_column - self.opponent[1]))\n elif self.opponent[0] != target_row:\n self.opponent[0] += int(np.sign(target_row - self.opponent[0]))\n\n def _opponent_return(self) -> None:\n if self.ball_velocity[0] >= 0 or self.ball[0] > 3:\n return\n if abs(self.opponent[0] - self.ball[0]) > 1 or abs(self.opponent[1] - self.ball[1]) > 1:\n return\n lateral = -1 if self.player[1] >= 5 else 1\n if self.opponent[0] >= 3:\n lateral = int(np.clip(lateral * 2, -1, 1))\n self.ball_velocity = [1, lateral]\n\n def _move_ball(self) -> None:\n self.ball[0] += self.ball_velocity[0]\n self.ball[1] += self.ball_velocity[1]\n if self.ball[1] <= 0 or self.ball[1] >= 9:\n self.ball[1] = int(np.clip(self.ball[1], 0, 9))\n self.ball_velocity[1] *= -1\n if self.ball[0] < 0:\n self._award_point(\"player\")\n elif self.ball[0] > 9:\n self._award_point(\"opponent\")\n\n def _award_point(self, winner: str) -> None:\n if winner == \"player\":\n self.player_points += 1\n else:\n self.opponent_points += 1\n if max(self.player_points, self.opponent_points) >= 4 and abs(\n self.player_points - self.opponent_points\n ) >= 2:\n self._award_game(winner)\n return\n self._reset_point()\n\n def _award_game(self, winner: str) -> None:\n if winner == \"player\":\n self.player_games += 1\n else:\n self.opponent_games += 1\n self.player_points = 0\n self.opponent_points = 0\n games_played = self.player_games + self.opponent_games\n self.server = \"player\" if games_played % 2 == 0 else \"opponent\"\n self.side_swapped = games_played % 2 == 1\n if self.player_games == 6 and self.opponent_games == 6:\n self.player_games = 0\n self.opponent_games = 0\n self.tiebreak_reset = True\n lead = self.player_games - self.opponent_games\n if self.tiebreak_reset and abs(lead) >= 2:\n self.winner = \"player\" if lead > 0 else \"opponent\"\n self.terminal = True\n elif not self.tiebreak_reset and max(self.player_games, self.opponent_games) >= 6 and abs(lead) >= 2:\n self.winner = \"player\" if lead > 0 else \"opponent\"\n self.terminal = True\n if not self.terminal:\n self._reset_point()\n\n def _reset_point(self) -> None:\n self.phase = \"serve\"\n self.serve_delay = 2\n self.player = [8, 5]\n self.opponent = [1, 5]\n self.ball = (self.player if self.server == \"player\" else self.opponent).copy()\n self.ball_velocity = [0, 0]\n\n def _progress_score(self) -> float:\n if self.terminal and self.winner == \"player\":\n return self.score_cap\n return float(min(6, self.player_games))\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n state[*self.opponent, 1] = True\n state[*self.ball, 2] = True\n state[4:6, :, 3] = True\n state[*self.previous_player, 4] = True\n state[*self.previous_opponent, 4] = True\n state[*self.previous_ball, 4] = True\n values = (\n (self.player_points, 4),\n (self.opponent_points, 4),\n (self.player_games, 3),\n (self.opponent_games, 3),\n (self.ball_velocity[0] + 1, 2),\n (self.ball_velocity[1] + 1, 2),\n (self.steps, 11),\n )\n offset = 0\n for value, width in values:\n for bit in range(width):\n index = offset + bit\n state[index // 10, index % 10, 5] = bool(value & (1 << bit))\n offset += width\n state[3, 0, 5] = self.server == \"player\"\n state[3, 1, 5] = self.phase == \"rally\"\n state[3, 2, 5] = self.tiebreak_reset\n state[3, 3, 5] = self.side_swapped\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 205, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tennis.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "outpost_patrol", "split": "train", "game": "outpost_patrol", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Outpost Patrol as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to jump. Hold to extend the jump or release\nwith actions 0–4 to finish it faster. The sentry moves\naround the track automatically. Hitting a bomb during a\njump creates a shock wave that earns one point per obstacle\ndestroyed. Hitting an obstacle on the ground ends the run.\n\nINPUT CHANNEL TABLE\nSix 10×10 channels show the sentry, obstacles, bombs,\nshock waves, track, and gauges. The conversion uses angular\nwave checks and rectangular contact bounds. Each action\nadvances four frames at fixed difficulty. The 400-action\ntask clips scores to [0, 12] and divides by 12.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/outpost_patrol.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Wave:\n angle: float\n width: float = 0\n\n\ndef position(angle):\n return 50 + 40 * math.cos(angle), 50 + 40 * math.sin(angle)\n\n\ndef separation(a, b):\n return abs((a - b + math.pi) % math.tau - math.pi)\n\n\nclass OutpostPatrolEnvironment:\n score_cap = 12\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.angle = self.obstacle_timer = self.bomb_timer = 0.0\n self.jump = self.steps = 0\n self.height = 0.0\n self.obstacles = []\n self.bombs = []\n self.waves: list[Wave] = []\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n self.angle = (self.angle + 0.02) % math.tau\n if self.jump or tap:\n self.jump += 1 if self.pressed else 2\n if self.jump >= 30:\n self.jump = 0\n self.height = 10 * math.sin(self.jump * math.pi / 30)\n self.obstacle_timer -= 1\n if self.obstacle_timer < 0:\n opposite = self.angle + math.pi\n if all(separation(o, opposite) > math.pi * 0.2 for o in self.obstacles):\n self.obstacles.append(opposite)\n self.obstacle_timer += self.random.uniform(60, 150)\n self.obstacles = [o - 0.01 for o in self.obstacles]\n self.bomb_timer -= 1\n if self.bomb_timer < 0:\n self.bombs.append(self.random.uniform(0, math.tau))\n self.bomb_timer += self.random.uniform(90, 120)\n self.bombs = [b - 0.015 for b in self.bombs]\n for wave in self.waves:\n wave.width += 0.1\n survivors = [o for o in self.obstacles if all(\n separation(o, wave.angle) > wave.width / 2 + 0.09 for wave in self.waves\n )]\n reward = len(self.obstacles) - len(survivors)\n self.obstacles = survivors\n self.waves = [wave for wave in self.waves if wave.width <= 1]\n x, y = position(self.angle)\n if not self.jump:\n for obstacle in self.obstacles:\n ox, oy = position(obstacle)\n self.terminal |= abs(x - ox) < 6 and abs(y - oy) < 6\n else:\n remaining = []\n for bomb in self.bombs:\n bx, by = position(bomb)\n if abs(x - bx) < 6.5 and abs(y - self.height - by + 10) < 6.5:\n self.waves.append(Wave(bomb))\n else:\n remaining.append(bomb)\n self.bombs = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n x, y = position(self.angle)\n state[int((y - self.height) // 10), int(x // 10), 0] = True\n for channel, angles in ((1, self.obstacles), (2, self.bombs)):\n for angle in angles:\n x, y = position(angle)\n state[int((y - (10 if channel == 2 else 0)) // 10), int(x // 10), channel] = True\n for wave in self.waves:\n for angle in np.linspace(wave.angle - wave.width / 2, wave.angle + wave.width / 2, 10):\n x, y = position(angle)\n state[int(y // 10), int(x // 10), 3] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n state[:, :, 4] = abs(np.hypot(cols - 50, rows - 50) - 40) < 5\n for row, value in enumerate((self.steps, self.jump, round(self.angle * 80))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 206, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/outpost_patrol.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameOutpostPatrol.c"} +{"name": "arcfire", "split": "train", "game": "arcfire", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Arcfire as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe aim rotates continuously. Hold action 5 to sweep out a wider arc\nwith shorter reach. Release with actions 0–4 to fire and dash along the\narc's midpoint. Holding beyond half a rotation cancels the charge.\nOnly one expanding shot can be active, although another release can\nstill dash. Enemies approach the center from a seeded drifting entry\npoint. Contact with the player or the center ends the run. Each hit\npays the current combo and increments it. A new press resets the combo.\n\nINPUT CHANNEL TABLE\nChannels show player, enemies, center, expanding arc, charged arc preview,\nand gauges. The gauges encode the clock, aim, charge, start angle, combo,\nspawn index, button state, and active arc. This adaptation uses 24 angle\nsectors, a single-step dash, discrete radius growth, and tile collision.\n\nSCORING, TERMINATION, AND HORIZON\nAt most 67 enemies enter during the 400-step episode. A hit removes its\nenemy permanently. Ignoring combo resets, rewards cannot exceed the sum\nfrom 1 to 67, giving a cap of 2,278. Clip to [0, 2278] and divide by 2278.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/arcfire.py`):\n```python\nfrom math import atan2, cos, hypot, pi, sin, sqrt\n\nimport numpy as np\n\n\nHORIZON = 400\nSECTORS = 24\nMAX_CHARGE = 12\nSPAWN_INTERVAL = 6\nCENTER = (5, 5)\nMAX_ENEMIES = (HORIZON + SPAWN_INTERVAL - 1) // SPAWN_INTERVAL\n\n\nclass ArcfireEnvironment:\n score_cap = MAX_ENEMIES * (MAX_ENEMIES + 1) // 2\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.player = CENTER\n self.steps = self.last_action = self.aim = self.charge = self.arc_start = 0\n self.multiplier = 1\n self.spawn_index = int(self.random.integers(36))\n self.enemies: list[tuple[int, int]] = []\n self.shot: tuple[int, int, int, int] | None = None\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n @staticmethod\n def _range(width: int) -> int:\n return max(3, round(9 / sqrt(width)))\n\n def _in_arc(self, cell: tuple[int, int], start: int, width: int, radius: int) -> bool:\n dy, dx = cell[0] - self.player[0], cell[1] - self.player[1]\n direction = atan2(dy, dx) * SECTORS / (2 * pi)\n return (direction - start) % SECTORS <= width and abs(hypot(dx, dy) - radius) <= 0.75\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n self.steps += 1\n self.aim = (self.aim + 1) % SECTORS\n if action == 5 and self.last_action != 5:\n self.charge, self.arc_start, self.multiplier = 1, self.aim, 1\n elif action == 5 and self.charge:\n self.charge += 1\n if self.charge > MAX_CHARGE:\n self.charge = 0\n elif self.charge:\n width = self.charge\n reach = self._range(width)\n if self.shot is None:\n self.shot = (self.arc_start, width, reach, 1)\n angle = (self.arc_start + width / 2) * 2 * pi / SECTORS\n stride = reach / 2\n row, column = self.player\n self.player = (max(1, min(8, row + round(stride * sin(angle)))),\n max(1, min(8, column + round(stride * cos(angle)))))\n self.charge = 0\n self.last_action = action\n\n if self.steps % SPAWN_INTERVAL == 1:\n if self.random.random() < 0.1:\n self.spawn_index = int(self.random.integers(36))\n else:\n self.spawn_index = (self.spawn_index + int(self.random.integers(-1, 2))) % 36\n side, offset = divmod(self.spawn_index, 9)\n self.enemies.append(((0, offset), (offset, 9), (9, 9 - offset), (9 - offset, 0))[side])\n if self.steps % 3 == 0:\n self.enemies = [(row + int(np.sign(CENTER[0] - row)), column + int(np.sign(CENTER[1] - column)))\n for row, column in self.enemies]\n\n reward = 0\n if self.shot is not None:\n start, width, reach, radius = self.shot\n survivors = []\n for cell in self.enemies:\n if self._in_arc(cell, start, width, radius):\n reward += self.multiplier\n self.multiplier += 1\n else:\n survivors.append(cell)\n self.enemies = survivors\n self.shot = (start, width, reach, radius + 1) if radius < reach else None\n self.terminal = any(cell in (CENTER, self.player) for cell in self.enemies)\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n for cell in self.enemies:\n state[*cell, 1] = True\n state[*CENTER, 2] = True\n for row in range(10):\n for column in range(10):\n cell = row, column\n if self.shot is not None:\n start, width, _, radius = self.shot\n state[row, column, 3] = self._in_arc(cell, start, width, radius)\n if self.charge:\n state[row, column, 4] = self._in_arc(cell, self.arc_start, self.charge, self._range(self.charge))\n values = (self.steps, self.aim, self.charge, self.arc_start, self.multiplier,\n self.spawn_index, int(self.last_action == 5), *(self.shot or (0, 0, 0, 0)))\n offset = 0\n for value, width in zip(values, (9, 5, 4, 5, 7, 6, 1, 5, 4, 4, 4), strict=True):\n for bit in range(width):\n state[offset // 10, offset % 10, 5] = bool(value & (1 << bit))\n offset += 1\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 207, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/arcfire.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameArcfire.c"} +{"name": "krull", "split": "train", "game": "krull", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Krull as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion follows the Atari 2600 game's complete quest rather than the unrelated arcade\ngame. Colwyn first defends Lyssa at their interrupted marriage, stabbing eight advancing Slayers\nwhose values rise from 10–80 in the first quest and 20–90 in the second. Lyssa is ultimately taken,\nand the quest continues across the Iron Desert. Fire Mare travel presents three finite Glaives and\none extra life; action 5 collects an item only when it passes beneath the lead Mare.\n\nAt the Widow's web, Colwyn must jump eight sticky strands with action 5, avoid the pursuing Crystal\nSpider, and reach the cocoon before its timer expires. The cocoon reveals one of eight pathways,\nwhose correct identity changes at sunrise. Choosing incorrectly costs a life, or a Glaive when no\nextra life remains, and returns Colwyn to the web.\n\nInside the Black Fortress, action 5 throws a Glaive upward. It can be steered left or right on the\noutbound trip, removes one of six 70-point prison chunks, then rebounds straight down and must be\ncaught. Hitting the Beast or missing the catch loses that Glaive. Free Lyssa descends to grant a\nfireball, which destroys the Beast for 3,000 points. With no Glaives, Colwyn can leave through a\nlower side exit and return to the desert. Two increasingly fast complete quests form the finite\nepisode.\n\nACTION MAPPING\n0: hold position\n1: move/steer/select left\n2: move up\n3: move/steer/select right\n4: move down\n5: stab, collect, jump strand, confirm path, or throw weapon\n\nINPUT CHANNEL TABLE\n0: Colwyn\n1: Slayers, Crystal Spider, Beast, and hostile fireballs\n2: Lyssa, cocoon, and desert resources\n3: web strands, prison chunks, and player projectile\n4: previous Colwyn position\n5: current-quest reward identities, exact stage/episode timing, stage, quest, lives, Glaives, web timer, path and sunrise state, prison progress, Lyssa, and fireball state\n\nSCORING, TERMINATION, AND HORIZON\nThe first quest's Slayers total 360 and the second's total 440. Eight web strands pay 40 in the\nfirst quest and 50 in the second, totaling 720. Two first cocoon arrivals total 1,000; twelve\nprison chunks total 840; and two Beast kills total 6,000. Desert resources have no point value.\nThus `score_cap = 360 + 440 + 720 + 1,000 + 840 + 6,000 = 9,360`. Normalization is\n`min(max(raw_score, 0), 9_360) / 9_360`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/krull.py`):\n```python\nimport numpy as np\n\n\nclass KrullEnvironment:\n \"\"\"Two-quest marriage, desert, web, path, and fortress campaign.\"\"\"\n\n score_cap = 9_360.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 2_400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.quest = 0\n self.lives = 3\n self.glaives = 0\n self.score = 0.0\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self.claimed: set[tuple[int, str, int]] = set()\n self.prison_chunks: set[int] = set()\n self._start_marriage()\n\n def _base_stage(self, stage: str) -> None:\n self.stage = stage\n self.stage_steps = 0\n self.player = [8, 5]\n self.previous_player = self.player.copy()\n self.projectile: dict[str, object] | None = None\n self.enemy_projectiles: list[list[int]] = []\n\n def _start_marriage(self) -> None:\n self._base_stage(\"marriage\")\n self.lyssa = [1, 5]\n self.slayers = {\n index: [1 + index % 4, 0 if index % 2 == 0 else 9]\n for index in range(8)\n if (self.quest, \"slayer\", index) not in self.claimed\n }\n\n def _start_desert(self) -> None:\n self._base_stage(\"desert\")\n self.player = [5, 5]\n self.previous_player = self.player.copy()\n self.desert_items = [\n {\"kind\": \"glaive\", \"index\": index, \"position\": [7, 9 + index * 12]}\n for index in range(3)\n if (self.quest, \"glaive\", index) not in self.claimed\n ]\n if (self.quest, \"life\", 0) not in self.claimed:\n self.desert_items.append({\"kind\": \"life\", \"index\": 0, \"position\": [7, 27]})\n\n def _start_web(self) -> None:\n self._base_stage(\"web\")\n self.player = [9, 5]\n self.previous_player = self.player.copy()\n self.cocoon = [0, 5]\n self.spider = [0, 0]\n self.web_timer = 80 - 10 * self.quest\n self.strands = {\n index: [row, (index * 3 + self.quest) % 10]\n for index, row in enumerate((8, 7, 6, 5, 4, 3, 2, 1))\n }\n\n def _start_path(self) -> None:\n self._base_stage(\"path\")\n self.player = [5, 4]\n self.previous_player = self.player.copy()\n self.path_selection = 0\n self.sunrise = 0\n self.sun_timer = 30 - 5 * self.quest\n self.correct_path = (self.quest * 3 + self.sunrise * 5) % 8\n\n def _start_fortress(self) -> None:\n self._base_stage(\"fortress\")\n self.beast = [3, 5]\n self.lyssa = [1, 5]\n self.lyssa_free = len(self.prison_chunks) >= 6\n self.has_fireball = False\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n stage_before = self.stage\n lives_before = self.lives\n reward = {\n \"marriage\": self._act_marriage,\n \"desert\": self._act_desert,\n \"web\": self._act_web,\n \"path\": self._act_path,\n \"fortress\": self._act_fortress,\n }[self.stage](action)\n transitioned = self.stage != stage_before or self.lives != lives_before\n self.score += reward\n self.steps += 1\n if not transitioned:\n self.stage_steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_player(self, action: int) -> None:\n if action in (1, 2, 3, 4):\n delta = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}[action]\n self.player[0] = int(np.clip(self.player[0] + delta[0], 0, 9))\n self.player[1] = int(np.clip(self.player[1] + delta[1], 0, 9))\n\n def _act_marriage(self, action: int) -> float:\n self._move_player(action)\n reward = 0.0\n if action == 5:\n for index, slayer in list(self.slayers.items()):\n if abs(slayer[0] - self.player[0]) + abs(slayer[1] - self.player[1]) <= 1:\n del self.slayers[index]\n identity = (self.quest, \"slayer\", index)\n if identity not in self.claimed:\n self.claimed.add(identity)\n reward = float(10 * (index + 1 + self.quest))\n break\n interval = max(1, 3 - self.quest)\n if self.stage_steps % interval == 0:\n for slayer in self.slayers.values():\n slayer[0] += int(np.sign(self.lyssa[0] - slayer[0]))\n slayer[1] += int(np.sign(self.lyssa[1] - slayer[1]))\n if any(slayer == self.player for slayer in self.slayers.values()):\n self._lose_life()\n elif self.stage_steps >= 79 or not self.slayers:\n self._start_desert()\n return reward\n\n def _act_desert(self, action: int) -> float:\n self._move_player(action)\n for item in self.desert_items:\n item[\"position\"][1] -= 1\n if action == 5:\n for item in list(self.desert_items):\n if item[\"position\"][1] == self.player[1]:\n identity = (self.quest, str(item[\"kind\"]), int(item[\"index\"]))\n if identity not in self.claimed:\n self.claimed.add(identity)\n if item[\"kind\"] == \"glaive\":\n self.glaives = min(5, self.glaives + 1)\n else:\n self.lives = min(10, self.lives + 1)\n self.desert_items.remove(item)\n break\n self.desert_items = [item for item in self.desert_items if item[\"position\"][1] >= 0]\n if self.stage_steps >= 59:\n self._start_web()\n return 0.0\n\n def _act_web(self, action: int) -> float:\n reward = 0.0\n if action == 5:\n crossed = [index for index, strand in self.strands.items() if strand[0] == self.player[0] - 1]\n if crossed:\n index = crossed[0]\n self.player[0] = max(0, self.player[0] - 2)\n identity = (self.quest, \"strand\", index)\n if identity not in self.claimed:\n self.claimed.add(identity)\n reward += float(40 + 10 * self.quest)\n else:\n self._move_player(action)\n self.spider[0] += int(np.sign(self.player[0] - self.spider[0]))\n self.spider[1] += int(np.sign(self.player[1] - self.spider[1]))\n self.web_timer -= 1\n if self.player == self.spider or self.web_timer <= 0:\n self._lose_life()\n elif self.player == self.cocoon:\n identity = (self.quest, \"cocoon\", 0)\n if identity not in self.claimed:\n self.claimed.add(identity)\n reward += 500.0\n self._start_path()\n return reward\n\n def _act_path(self, action: int) -> float:\n if action == 1:\n self.path_selection = (self.path_selection - 1) % 8\n elif action == 3:\n self.path_selection = (self.path_selection + 1) % 8\n elif action == 5:\n if self.path_selection == self.correct_path:\n self._start_fortress()\n else:\n if self.lives > 1:\n self.lives -= 1\n elif self.glaives > 0:\n self.glaives -= 1\n else:\n self._lose_life()\n if not self.terminal:\n self._start_web()\n return 0.0\n self.sun_timer -= 1\n if self.sun_timer <= 0:\n self.sunrise += 1\n self.correct_path = (self.quest * 3 + self.sunrise * 5) % 8\n self._start_web()\n return 0.0\n\n def _act_fortress(self, action: int) -> float:\n reward = 0.0\n self._move_player(action)\n if self.projectile is None and action == 5:\n if self.has_fireball:\n self.projectile = {\"kind\": \"fireball\", \"position\": self.player.copy(), \"returning\": False}\n elif self.glaives > 0:\n self.projectile = {\"kind\": \"glaive\", \"position\": self.player.copy(), \"returning\": False}\n if self.projectile is not None:\n reward += self._move_fortress_projectile(action)\n if self.stage != \"fortress\":\n return reward\n if self.lyssa_free and not self.has_fireball and self.lyssa[0] < self.player[0]:\n self.lyssa[0] += 1\n if self.lyssa[0] == self.player[0]:\n self.has_fireball = True\n if self.stage_steps % max(4, 7 - self.quest * 2) == 0:\n self.enemy_projectiles.append(self.beast.copy())\n for fireball in list(self.enemy_projectiles):\n fireball[0] += int(np.sign(self.player[0] - fireball[0]))\n fireball[1] += int(np.sign(self.player[1] - fireball[1]))\n if fireball == self.player:\n self._lose_life()\n return reward\n if self.glaives == 0 and self.projectile is None and self.player[1] in (0, 9):\n self._start_desert()\n return reward\n\n def _move_fortress_projectile(self, action: int) -> float:\n projectile = self.projectile\n position = projectile[\"position\"]\n if projectile[\"kind\"] == \"fireball\":\n position[0] -= 1\n position[1] += int(np.sign(self.beast[1] - position[1]))\n if position == self.beast:\n self.projectile = None\n return self._destroy_beast()\n elif not projectile[\"returning\"]:\n position[0] -= 1\n if action == 1:\n position[1] = max(0, position[1] - 1)\n elif action == 3:\n position[1] = min(9, position[1] + 1)\n if position[0] <= 1 and 2 <= position[1] <= 7:\n chunk = position[1] - 2\n identity = (self.quest, \"chunk\", chunk)\n reward = 0.0\n if identity not in self.claimed:\n self.claimed.add(identity)\n self.prison_chunks.add(chunk)\n reward = 70.0\n projectile[\"returning\"] = True\n if len(self.prison_chunks) >= 6:\n self.lyssa_free = True\n return reward\n if position == self.beast:\n self.glaives -= 1\n self.projectile = None\n else:\n position[0] += 1\n if position[0] >= self.player[0]:\n if position[1] != self.player[1]:\n self.glaives -= 1\n self.projectile = None\n if self.projectile is not None and not (0 <= position[0] < 10 and 0 <= position[1] < 10):\n if projectile[\"kind\"] == \"glaive\":\n self.glaives -= 1\n self.projectile = None\n return 0.0\n\n def _destroy_beast(self) -> float:\n identity = (self.quest, \"beast\", 0)\n reward = 0.0 if identity in self.claimed else 3_000.0\n self.claimed.add(identity)\n self.quest += 1\n if self.quest >= 2:\n self.terminal = True\n else:\n self.prison_chunks = set()\n self._start_marriage()\n return reward\n\n def _lose_life(self) -> None:\n self.lives -= 1\n if self.lives <= 0:\n self.terminal = True\n elif self.stage == \"marriage\":\n self._start_marriage()\n elif self.stage in (\"web\", \"path\"):\n self._start_web()\n else:\n self._start_fortress()\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n if self.stage == \"marriage\":\n for slayer in self.slayers.values():\n state[*slayer, 1] = True\n state[*self.lyssa, 2] = True\n elif self.stage == \"desert\":\n for item in self.desert_items:\n column = int(item[\"position\"][1])\n if 0 <= column < 10:\n state[item[\"position\"][0], column, 2] = True\n elif self.stage == \"web\":\n state[*self.spider, 1] = True\n state[*self.cocoon, 2] = True\n for strand in self.strands.values():\n state[*strand, 3] = True\n elif self.stage == \"fortress\":\n state[*self.beast, 1] = True\n state[*self.lyssa, 2] = True\n for chunk in range(6):\n if chunk not in self.prison_chunks:\n state[1, chunk + 2, 3] = True\n for fireball in self.enemy_projectiles:\n state[*fireball, 1] = True\n if self.projectile is not None:\n state[*self.projectile[\"position\"], 3] = True\n state[*self.previous_player, 4] = True\n stages = (\"marriage\", \"desert\", \"web\", \"path\", \"fortress\")\n for index in range(8):\n state[0, index, 5] = (self.quest, \"strand\", index) in self.claimed\n state[0, 8, 5] = (self.quest, \"cocoon\", 0) in self.claimed\n state[0, 9, 5] = (self.quest, \"beast\", 0) in self.claimed\n for bit in range(10):\n state[1, bit, 5] = bool(self.stage_steps & (1 << bit))\n for bit in range(10):\n state[2, bit, 5] = bool(self.steps & (1 << bit))\n for bit in range(2):\n state[3, bit, 5] = bool(self.steps & (1 << (10 + bit)))\n state[3, 2 + bit, 5] = bool(self.stage_steps & (1 << (10 + bit)))\n state[9, stages.index(self.stage), 5] = True\n state[9, 5 + self.quest, 5] = True\n for bit in range(4):\n state[8, bit, 5] = bool(self.lives & (1 << bit))\n state[8, 4 + bit, 5] = bool(self.glaives & (1 << bit))\n if self.stage == \"web\":\n for bit in range(7):\n state[7, bit, 5] = bool(self.web_timer & (1 << bit))\n if self.stage == \"path\":\n state[6, self.path_selection, 5] = True\n state[5, self.correct_path, 5] = True\n for bit in range(5):\n state[4, bit, 5] = bool(self.sun_timer & (1 << bit))\n state[3, 5, 5] = self.lyssa_free if self.stage == \"fortress\" else False\n state[3, 6, 5] = self.has_fireball if self.stage == \"fortress\" else False\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 208, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/krull.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "sum_ten", "split": "train", "game": "sum_ten", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Sum Ten as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to enter the indicated cell. Actions 0–4 release.\nThe cursor alternates between left and up every 30 frames if the\nalternate cell is available. A sum divisible by ten banks\n`10 × (sum / 10)²` points and starts a new sum. Ten entries\nwithout a successful sum, an invalid move, or scrolling out of\nbounds ends the episode.\n\nINPUT CHANNEL TABLE\nFour Boolean channels encode the digits in binary, with zero\nrepresenting a blocked cell. Channel 4 marks the cursor. Channel 5\nmarks the next cell and reserves its bottom two rows for the sum,\ncount, direction timer, held button, and direction. The port fixes\ndifficulty and uses seeded NumPy board generation. Each action\nadvances up to four frames over 400 actions. Clip scores to\n[0, 1000] and divide by 1000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/sum_ten.py`):\n```python\nimport numpy as np\n\n\nclass SumTenEnvironment:\n score_cap = 1000\n directions = ((-1, 0), (0, -1))\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.grid = np.zeros((10, 10), dtype=np.uint8)\n self.grid[:, 0] = self.random.integers(1, 10, 10)\n self.grid[6, 1:7] = (6, 5, 8, 1, 7, 3)\n self.x, self.y = 7, 6\n self.scroll_x, self.scroll_y = 100., 0.\n self.direction = self.timer = self.total = self.count = self.steps = 0\n self.held = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def _next(self, direction):\n dx, dy = self.directions[direction]\n return self.x + dx, self.y + dy\n\n def _value(self, x, y):\n return int(self.grid[y, x]) if 0 <= x < 10 and 0 <= y < 10 else 0\n\n def act(self, action):\n if self.terminal:\n return 0., True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n self.timer += 1\n if self.timer == 30:\n alternate = 1 - self.direction\n if self._value(*self._next(alternate)):\n self.direction = alternate\n self.timer = 0\n if self.scroll_x - self.x * 11 < 0 or self.scroll_y + self.y * 11 + 1 > 91:\n self.terminal = True\n return 0\n reward = 0\n if tap:\n x, y = self._next(self.direction)\n value = self._value(x, y)\n if not value:\n self.terminal = True\n return 0\n self.x, self.y = x, y\n self.timer = 0\n self.total += value\n self.count += 1\n if self.total % 10 == 0:\n reward = (self.total // 10) ** 2 * 10\n self.total = self.count = 0\n elif self.count == 10:\n self.terminal = True\n if not self._value(*self._next(self.direction)):\n self.direction = 1 - self.direction\n self.scroll_x -= max(0, 7 - self.x) * 0.5 + 0.01\n self.scroll_y += max(0, 6 - self.y) * 0.5 + 0.01\n if self.scroll_x <= 90:\n self.grid[:, 1:] = self.grid[:, :-1].copy()\n self.grid[:, 0] = self.random.integers(1, 10, 10)\n gap = int(self.random.integers(1, 15))\n if gap < 10 and self.grid[gap - 1, 1]:\n self.grid[gap, 0] = 0\n self.scroll_x += 10\n self.x += 1\n if self.scroll_y >= 10:\n self.grid[1:] = self.grid[:-1].copy()\n self.grid[0] = self.random.integers(1, 10, 10)\n gap = int(self.random.integers(1, 15))\n if gap < 10 and self.grid[1, gap - 1]:\n self.grid[0, gap] = 0\n self.scroll_y -= 10\n self.y += 1\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for bit in range(4):\n state[:, :, bit] = (self.grid & (1 << bit)) != 0\n if 0 <= self.x < 10 and 0 <= self.y < 10:\n state[self.y, self.x, 4] = True\n x, y = self._next(self.direction)\n if 0 <= x < 10 and 0 <= y < 10:\n state[y, x, 5] = True\n # Reserve a column for each gauge by using the marker planes' last rows.\n packed = (self.total | (self.count << 7) | (self.timer << 11)\n | (int(self.held) << 16) | (self.direction << 17))\n for bit in range(18):\n state[8 + bit // 10, bit % 10, 5] = bool(packed & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 209, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/sum_ten.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/sumten/main.js"} +{"name": "switchboard", "split": "train", "game": "switchboard", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Switchboard as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe cursor rotates automatically. Hold action 5 to pick up a cord\nfrom the nearest active plug and slow the cursor. Release with\nactions 0–4 to connect to the nearest plug. Match the requested\npair in either order to score the rounded multiplier and raise it.\nA missed deadline or wrong connection involving a caller disables\nthat caller. Three lost contracts end the run. Connecting to a\ndisabled plug can reactivate it and recover one lost contract.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the cursor, active plugs, held cord origin,\npending call pairs, connected call pairs, and counters. The pair\nchannels use zero-based source rows and destination columns. The\nport fixes difficulty at one. Each action advances up to four frames\nover 400 actions. Clip scores to [0, 25] and divide by 25.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/switchboard.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, floor, pi, sin\n\nimport numpy as np\n\n\nSPACING = 2 * pi / 9\nPLUGS = tuple((50 + 30 * sin(i * SPACING), 50 - 30 * cos(i * SPACING)) for i in range(9))\n\n\n@dataclass\nclass Call:\n source: int\n destination: int\n remaining: int\n\n\nclass SwitchboardEnvironment:\n score_cap = 25\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.angle = 0.\n self.cursor = self.steps = self.lost = 0\n self.origin = None\n self.timer = 180\n self.multiplier = 1.\n self.active = set(range(9))\n self.requests = [Call(2, 6, 900)]\n self.connections = []\n self.held = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n press, release = held and not self.held, self.held and not held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(press and frame == 0, release and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _spawn(self):\n available = set(range(9))\n for call in (*self.requests, *self.connections):\n available.difference_update((call.source, call.destination))\n sources = available & self.active\n if sources and len(available) >= 2:\n source = int(self.random.choice(sorted(sources)))\n destination = int(self.random.choice(sorted(available - {source})))\n self.requests.append(Call(source, destination, int(self.random.integers(600, 1200))))\n\n def _lose(self, call):\n self.active.discard(call.source)\n self.lost += 1\n self.terminal |= self.lost >= 3\n\n def _advance(self, press, release):\n self.angle += 0.024 if self.held else 0.042\n if self.angle >= 2 * pi:\n self.angle = 0.\n self.cursor = floor(self.angle / SPACING + 0.5) % 9\n self.multiplier += (1 - self.multiplier) * 0.001\n self.timer -= 1\n if self.timer <= 0:\n self._spawn()\n self.timer = int(self.random.integers(100, 200))\n remaining = []\n for call in self.requests:\n call.remaining -= 1\n if call.remaining <= 0:\n self._lose(call)\n else:\n remaining.append(call)\n self.requests = remaining\n if press and self.origin is None and self.active:\n self.origin = min(sorted(self.active),\n key=lambda plug: abs((plug * SPACING - self.angle + pi) % (2 * pi) - pi))\n reward = 0\n if release and self.origin is not None:\n endpoints = {self.origin, self.cursor}\n match = next((call for call in self.requests if {call.source, call.destination} == endpoints), None)\n if match is not None:\n self.requests.remove(match)\n self.connections.append(Call(match.source, match.destination, int(self.random.integers(100, 200))))\n self.lost = max(0, self.lost - len(endpoints - self.active))\n self.active.update(endpoints)\n reward = floor(self.multiplier + 0.5)\n self.multiplier += 1\n else:\n remaining = []\n for call in self.requests:\n if call.source in endpoints:\n self._lose(call)\n else:\n remaining.append(call)\n self.requests = remaining\n self.origin = None\n for call in self.connections:\n call.remaining -= 1\n self.connections = [call for call in self.connections if call.remaining > 0]\n return reward\n\n @staticmethod\n def _mark(state, plug, channel):\n x, y = PLUGS[plug]\n state[int(y // 10), int(x // 10), channel] = True\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n self._mark(state, self.cursor, 0)\n for plug in self.active:\n self._mark(state, plug, 1)\n if self.origin is not None:\n self._mark(state, self.origin, 2)\n for call in self.requests:\n state[call.source, call.destination, 3] = True\n for call in self.connections:\n state[call.source, call.destination, 4] = True\n values = (self.steps, self.lost, self.held, round(self.multiplier * 32), round(self.angle * 100),\n min((call.remaining for call in self.requests), default=0))\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[6, 0, 5] = values[-1] >= 1024\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 210, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/switchboard.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameSwitchboard.c"} +{"name": "jump_on", "split": "train", "game": "jump_on", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Jump On as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe player walks right automatically and enters shafts on\napproach. Hold action 5 while ascending a shaft to jump onto\na floor. Actions 0–4 keep the player in the shaft. Enemies\nwalk left, leave trails of dots, and climb out near your floor.\n\nCollect dots to score the current multiplier and increase it.\nAn enemy exiting a shaft resets the multiplier. Colliding with\na walking enemy while walking, or scrolling off the left edge,\nends the run. The conversion uses proximity hitboxes.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, enemies, dots, shafts,\nfloors, and gauges. Each action advances four frames at fixed\ndifficulty. The 400-action task clips raw scores to [0, 500]\nand divides by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/jump_on.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Hole:\n x: float\n\n\n@dataclass\nclass Walker:\n x: float\n y: float\n mode: str = \"walk\"\n hole: Hole | None = None\n dot_timer: float = 0.0\n\n\nclass JumpOnEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.player = Walker(5, 87)\n self.holes = [Hole(30), Hole(60)]\n self.enemies: list[Walker] = []\n self.dots: list[tuple[float, float]] = []\n self.hole_distance = self.group_timer = self.enemy_timer = 0.0\n self.group_size = self.steps = 0\n self.multiplier = 1\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self) -> int:\n scroll = 0.03 + max(0, self.player.x - 15) * 0.1\n self.hole_distance -= scroll\n if self.hole_distance < 0:\n self.holes.append(Hole(104))\n self.hole_distance += self.random.uniform(30, 45)\n for hole in self.holes:\n hole.x -= scroll\n self.holes = [hole for hole in self.holes if hole.x >= -4]\n self.group_timer -= 1\n if self.group_timer < 0:\n self.group_size = int(self.random.integers(1, 3))\n self.group_timer = self.group_size * 8 + self.random.uniform(100, 110)\n self.enemy_timer = 0\n self.enemy_timer -= 1\n if self.group_size and self.enemy_timer < 0:\n self.enemies.append(Walker(103, 87 - 12 * self.random.integers(6),\n dot_timer=self.random.uniform(0, 6)))\n self.group_size -= 1\n self.enemy_timer = self.random.uniform(8, 10)\n walking_enemies = []\n for enemy in self.enemies:\n was_walking = enemy.mode == \"walk\"\n leave = -9 < enemy.y - 1 - self.player.y < 1\n self._move(enemy, -1, scroll, leave)\n if was_walking:\n walking_enemies.append(enemy)\n if enemy.mode == \"walk\":\n enemy.dot_timer -= 1\n if enemy.dot_timer < 0:\n self.dots.append((enemy.x, enemy.y))\n enemy.dot_timer += 6\n self.enemies = [enemy for enemy in self.enemies if enemy.x >= -3]\n was_walking = self.player.mode == \"walk\"\n self._move(self.player, 1, scroll, self.pressed)\n self.terminal = self.player.x < 0 or (was_walking and any(\n abs(enemy.x - self.player.x) < 5 and abs(enemy.y - self.player.y) < 5\n for enemy in walking_enemies\n ))\n reward = 0\n remaining = []\n for x, y in self.dots:\n x -= scroll\n if self.player.mode not in (\"up\", \"down\") and abs(x - self.player.x) < 4 and abs(y - self.player.y) < 4:\n reward += self.multiplier\n self.multiplier += 1\n elif x >= -3:\n remaining.append((x, y))\n self.dots = remaining\n return reward\n\n def _move(self, walker: Walker, direction: int, scroll: float, leave: bool) -> None:\n if walker.mode == \"walk\":\n walker.x += direction - scroll\n ahead = [hole for hole in self.holes if 0 < (hole.x - walker.x) * direction < 8]\n if ahead:\n walker.hole = min(ahead, key=lambda hole: abs(hole.x - walker.x))\n walker.mode = \"enter\"\n return\n hole = walker.hole\n assert hole is not None\n if walker.mode == \"enter\":\n walker.x += direction - scroll\n distance = (hole.x - walker.x) * direction\n walker.y += 1 if distance < 4 else -1\n if distance <= 0:\n walker.mode = \"down\"\n elif walker.mode == \"down\":\n walker.x = hole.x\n walker.y += 1\n if walker.y > 90:\n walker.mode = \"up\"\n elif walker.mode == \"up\":\n walker.x = hole.x\n walker.y -= 1\n if walker.y < 23:\n walker.mode = \"down\"\n if leave:\n walker.mode = \"exit\"\n walker.y = math.ceil((walker.y - 90) / 12) * 12 + 87\n else:\n walker.x += direction - scroll\n distance = (walker.x - hole.x) * direction\n walker.y += -1 if distance < 4 else 1\n if distance >= 8:\n walker.mode = \"walk\"\n walker.y = math.floor((walker.y - 90) / 12 + 0.5) * 12 + 87\n if direction == -1:\n self.multiplier = 1\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, max(0, int(self.player.y // 10))),\n min(9, max(0, int(self.player.x // 10))), 0] = True\n for enemy in self.enemies:\n if 0 <= enemy.x < 100 and 0 <= enemy.y < 100:\n state[int(enemy.y // 10), int(enemy.x // 10), 1] = True\n for x, y in self.dots:\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), 2] = True\n for hole in self.holes:\n if 0 <= hole.x < 100:\n state[2:10, int(hole.x // 10), 3] = True\n for y in range(90, 29, -12):\n state[y // 10, :, 4] = True\n mode = (\"walk\", \"enter\", \"down\", \"up\", \"exit\").index(self.player.mode)\n for row, value in enumerate((self.steps, min(511, self.multiplier), mode, round(self.player.y * 4))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 211, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/jump_on.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/jumpon/main.js"} +{"name": "bola_thread", "split": "train", "game": "bola_thread", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Bola Thread as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTwo balls rotate around a fixed pivot. Hold action 5 to contract\ntheir orbit. Release with actions 0–4 to expand it. Thread both\nballs through each wall gap and around any central nub. A wall\nhit ends the run. Passing a wall scores one to six points based\non the current radius and briefly freezes the action. Touching\na beacon with either ball scores eight points.\n\nINPUT CHANNEL TABLE\nThe 10×10 observation uses six channels for the pivot, balls,\nwall sections, nubs, beacons, and gauges. Each action advances\nfour simulation frames at fixed scroll and rotation speeds.\nWall collision checks use the simulated ball and wall positions.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends on collision or after 400 actions. Clip the raw\nscore to [0, 150] and divide by the fixed cap of 150.\n\nAcross 100 seeds without sticky actions, always released averaged\n2.02 raw points, always held averaged 19.03, and random inputs\naveraged 11.48. The respective maxima were 22, 66, and 63.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/bola_thread.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\nSCROLL = 0.55\nROTATION = 0.022\n\n\n@dataclass\nclass Wall:\n x: float\n gap_y: float\n height: float\n nub: bool\n passed: bool = False\n\n def blocked(self, y: float, margin: float = 0) -> bool:\n return (\n abs(y - self.gap_y) + margin > self.height / 2\n or self.nub and abs(y - 50) < 4 + margin\n )\n\n\n@dataclass\nclass Beacon:\n x: float\n y: float\n\n\nclass BolaThreadEnvironment:\n score_cap = 150\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.freeze = 0\n self.pressed = self.terminal = False\n self.angle, self.radius = 0.0, 20.0\n self.next_wall, self.next_beacon = 60.0, 100\n self.walls: list[Wall] = []\n self.beacons: list[Beacon] = []\n\n @property\n def balls(self) -> tuple[tuple[float, float], tuple[float, float]]:\n dx = math.cos(self.angle) * self.radius\n dy = math.sin(self.angle) * self.radius\n return (30 + dx, 50 + dy), (30 - dx, 50 - dy)\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(FRAMES_PER_STEP):\n reward += self._advance_frame()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self) -> int:\n if self.freeze:\n self.freeze -= 1\n return 0\n self.radius = max(6, self.radius - 0.6) if self.pressed else min(26, self.radius + 0.45)\n self.angle = (self.angle + ROTATION) % math.tau\n self.next_wall -= SCROLL\n self.next_beacon -= 1\n if self.next_wall < 0:\n arrival_angle = self.angle + ROTATION * (108 - 30) / SCROLL\n nub = self.random.random() < 0.36 and abs(math.sin(arrival_angle)) > 0.8\n gap_y = self.random.uniform(42, 58)\n height = self.random.uniform(42, 54) if nub else self.random.uniform(25, 40)\n self.walls.append(Wall(108, gap_y, height, nub))\n self.next_wall = self.random.uniform(65, 90)\n if self.next_beacon < 0:\n self.beacons.append(Beacon(108, self.random.uniform(20, 80)))\n self.next_beacon = int(self.random.integers(90, 151))\n\n reward = 0\n balls = self.balls\n for wall in self.walls:\n wall.x -= SCROLL\n if any(abs(x - wall.x) < 4 and wall.blocked(y, margin=2) for x, y in balls):\n self.terminal = True\n return reward\n if not wall.passed and wall.x < 30:\n wall.passed = True\n bonus = max(1, int((self.radius - 6) // 3))\n reward += bonus\n self.freeze = 2 + 2 * (bonus >= 3) + 2 * (bonus >= 5)\n self.walls = [wall for wall in self.walls if wall.x >= -5]\n survivors = []\n for beacon in self.beacons:\n beacon.x -= SCROLL\n if any(abs(x - beacon.x) < 4.5 and abs(y - beacon.y) < 4.5 for x, y in balls):\n reward += 8\n elif beacon.x >= -5:\n survivors.append(beacon)\n self.beacons = survivors\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[5, 3, 0] = True\n for x, y in self.balls:\n state[int(y) // 10, int(x) // 10, 1] = True\n for wall in self.walls:\n if 0 <= wall.x < 100:\n column = int(wall.x) // 10\n for row in range(10):\n state[row, column, 2] |= abs(10 * row + 5 - wall.gap_y) > wall.height / 2\n state[4:6, column, 3] |= wall.nub\n for beacon in self.beacons:\n if 0 <= beacon.x < 100:\n state[int(beacon.y) // 10, int(beacon.x) // 10, 4] = True\n for row, value in enumerate((self.steps, round(self.radius * 10), round(self.angle * 80), self.freeze)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 212, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/bola_thread.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBolaThread.c"} +{"name": "card_q", "split": "train", "game": "card_q", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Card Q as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nActions 1–5 play the exposed card in columns 1–5. Action 0 waits.\nSwitch columns directly or wait before playing the same column again.\nA card must be one rank above or below a shared pile, with Ace and\nKing adjacent. If both piles match, the last-used pile takes priority.\n\nA valid play scores the current multiplier, increases it, and moves\nthe center line upward. An invalid play or successful opponent move\nresets the multiplier and pushes the center line downward. The piles\nreshuffle when play stalls. The run ends when the center line falls\ntoo far or after 400 actions.\n\nINPUT CHANNEL TABLE\nThe 10×10 observation stores both five-by-five card queues in the\nleft five columns. Four channels encode rank in binary, least\nsignificant bit first. Rows 4 and 5 are the exposed opponent and\nplayer cards. Channel 4 marks the exposed rows and channel 5\ntelegraphs the opponent's next column. Column 5 holds the shared pile\nranks and last-used flags. Columns 6–7 encode timers and gauges.\nThe conversion replaces pointer selection with direct column actions,\nuses fixed difficulty, and advances four simulation frames per action.\n\nSCORING, TERMINATION, AND HORIZON\nClip raw scores to [0, 250] and divide by the fixed cap of 250.\nAcross 100 seeds without sticky actions, idle scored zero and random\ninputs averaged 7.15. A policy that played the first legal column\naveraged 178.14 and reached 793 before clipping.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/card_q.py`):\n```python\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\nCOLUMNS = 5\n\n\nclass CardQEnvironment:\n score_cap = 250\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.player = self.random.integers(1, 14, (5, 5))\n self.player[0] = [1, 3, 3, 11, 13]\n self.enemy = self.random.integers(1, 14, (5, 5))\n self.piles = [2, 12]\n self.steps = self.last_action = self.player_pile = self.enemy_pile = 0\n self.shuffle_timer = self.shuffle_count = 0\n self.enemy_timer = 120.0\n self.enemy_column: int | None = None\n self.center = self.target = 40.0\n self.multiplier = 1\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def _match(self, rank: int, preferred: int) -> int | None:\n for index in (preferred, 1 - preferred):\n if (rank - self.piles[index]) % 13 in (1, 12):\n return index\n return None\n\n def _place(self, cards: np.ndarray, column: int, pile: int) -> None:\n self.piles[pile] = int(cards[0, column])\n cards[:-1, column] = cards[1:, column]\n cards[-1, column] = self.random.integers(1, 14)\n self.shuffle_timer = self.shuffle_count = 0\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n column = action - 1 if 1 <= action <= COLUMNS and action != self.last_action else None\n self.last_action = action\n self.steps += 1\n reward = 0\n for frame in range(FRAMES_PER_STEP):\n reward += self._advance_frame(column if frame == 0 else None)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self, column: int | None) -> int:\n self.shuffle_timer += 1\n if self.shuffle_timer > 60:\n player_can_play = any(self._match(rank, self.player_pile) is not None for rank in self.player[0])\n enemy_can_play = any(self._match(rank, self.enemy_pile) is not None for rank in self.enemy[0])\n if not player_can_play:\n self.enemy_timer *= 0.3\n self.shuffle_count += 1\n if not (player_can_play or enemy_can_play) or self.shuffle_count > 2:\n self.piles = self.random.integers(1, 14, 2).tolist()\n self.shuffle_count = 0\n self.shuffle_timer = 0\n\n reward = 0\n if column is not None:\n pile = self._match(self.player[0, column], self.player_pile)\n if pile is None:\n self.target += 5\n self.multiplier = 1\n self.shuffle_timer = self.shuffle_count = 0\n else:\n self._place(self.player, column, pile)\n self.player_pile = pile\n self.target -= 5\n reward = self.multiplier\n self.multiplier += 1\n\n self.enemy_timer -= 1\n if self.enemy_timer < 0:\n self._enemy_turn()\n self.center += (self.target - self.center) * 0.1\n if self.target < 16:\n self.target += (16 - self.target) * 0.1\n self.terminal = self.center > 94\n return reward\n\n def _enemy_turn(self) -> None:\n self.enemy_timer = self.random.uniform(50, 70)\n if self.enemy_column is not None:\n pile = self._match(self.enemy[0, self.enemy_column], self.enemy_pile)\n if pile is None:\n self.enemy_timer *= 3\n else:\n self._place(self.enemy, self.enemy_column, pile)\n self.enemy_pile = pile\n self.target += 5\n self.multiplier = 1\n\n self.enemy_column = None\n start = int(self.random.integers(COLUMNS))\n for offset in range(COLUMNS):\n column = (start + offset) % COLUMNS\n pile = self._match(self.enemy[0, column], self.enemy_pile)\n if pile is not None:\n self.enemy_column = column\n if pile != self.enemy_pile:\n self.enemy_timer *= 1.5\n break\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n cards = np.concatenate((self.enemy[::-1], self.player))\n for bit in range(4):\n state[:, :5, bit] = (cards & (1 << bit)) != 0\n state[4:6, :5, 4] = True\n if self.enemy_column is not None:\n state[4, self.enemy_column, 5] = True\n for index, rank in enumerate(self.piles):\n for bit in range(4):\n state[4 + index, 5, bit] = bool(rank & (1 << bit))\n state[4 + index, 5, 4:6] = index == self.player_pile, index == self.enemy_pile\n for row, value in enumerate((self.steps, self.multiplier, round(self.center), round(self.target),\n round(self.enemy_timer), self.shuffle_timer, self.shuffle_count, self.last_action)):\n for bit in range(10):\n state[row, 6 + bit // 5, bit % 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 213, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/card_q.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-11-games/blob/6fea4eefe2deaa42706051d96a04ec9e36104696/docs/cardq/main.js"} +{"name": "two_lane", "split": "train", "game": "two_lane", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Two Lane as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to switch target lanes. Hold it to accelerate. Release\nwith any other action before switching again. Some stretches have\nonly one lane. Going off road resets the multiplier and slows the\ncar until it returns to pavement or stalls.\n\nCoins pay the integer part of speed squared plus one, multiplied\nby the current multiplier. Each pickup increases the multiplier\nup to 32. A missed coin lowers it when its road section wraps.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the car, road, coins, target lane, off-road\nstatus, and counters. The port fixes difficulty and approximates sprite\ncollisions with overlap checks. Each action advances up to four frames\nover 400 actions. Clip the episode score to [0, 1000] and divide by 1000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/two_lane.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import floor, sqrt\n\nimport numpy as np\n\n\n@dataclass\nclass Road:\n y: float\n lanes: tuple[int, ...] = (30, 70)\n coin: int | None = None\n\n\nclass TwoLaneEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.roads = [Road(y) for y in range(-10, 110, 10)]\n self.lanes = (30, 70)\n self.speed = 1.\n self.x = 30.\n self.target = 30\n self.multiplier = 1\n self.off_road = self.terminal = False\n self.steps = self.action = 0\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n if self.action == 5 and previous != 5:\n self.target = 100 - self.target\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n if self.off_road:\n self.speed *= 0.9\n if self.speed < 0.1:\n self.terminal = True\n return 0\n elif self.action == 5:\n self.speed = min(3, self.speed + 0.02)\n else:\n self.speed += (1 - self.speed) * 0.1\n self.x += (self.target - self.x) * 0.15 * sqrt(self.speed)\n reward = 0\n on_road = False\n for road in self.roads:\n road.y += self.speed\n if road.y >= 110:\n road.y -= 120\n self._renew(road)\n if road.coin is not None and abs(self.x - road.coin) < 5 and abs(85 - road.y) < 5:\n reward += floor(self.speed ** 2 + 1) * self.multiplier\n self.multiplier = min(32, self.multiplier + 1)\n road.coin = None\n if road.y < 93 and road.y + 10 > 87:\n on_road |= any(abs(self.x - lane) < 23 for lane in road.lanes)\n self.off_road = not on_road\n if self.off_road:\n self.multiplier = 1\n return reward\n\n def _renew(self, road):\n if self.random.random() < 0.1:\n self.lanes = ((int(self.random.choice((30, 70))),)\n if len(self.lanes) == 2 else (30, 70))\n road.lanes = self.lanes\n if road.coin is not None:\n self.multiplier = max(1, self.multiplier - 1)\n road.coin = int(self.random.choice(road.lanes)) if self.random.random() < 0.2 else None\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[9, int(self.x // 10), 0] = True\n for road in self.roads:\n for row in range(max(0, floor(road.y / 10)), min(10, floor((road.y + 9.999) / 10) + 1)):\n for lane in road.lanes:\n col = lane // 10\n state[row, col - 2:col + 2, 1] = True\n if road.coin is not None and 0 <= road.y + 5 < 100:\n state[int((road.y + 5) // 10), road.coin // 10, 2] = True\n state[9, self.target // 10, 3] = True\n state[9, int(self.x // 10), 4] = self.off_road\n values = (self.steps, self.action, round(self.speed * 100), self.multiplier,\n round(self.x * 5), len(self.lanes))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 214, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/two_lane.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/twolane/main.js"} +{"name": "scaffold", "split": "train", "game": "scaffold", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Scaffold as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to lay a scaffold segment every 16 frames. Release\nwith actions 0–4 to change the next segment's slope. Guide the\nrunner through the wall opening and toward gold. Gold scores the\ncurrent multiplier and increases it. Missed gold reduces it.\nHitting a hazard or leaving the vertical playfield ends the run.\n\nINPUT CHANNEL TABLE\nThe six channels show the runner, scaffold, next segment position,\ngold, hazards, and counters. The port fixes difficulty at one\nand models the scaffold sprites as sloped surfaces, with\nrectangular bounds for hazards and pickups. Each action advances\nup to four frames over a 400-action horizon. Clip the episode score\nto [0, 100] and divide by 100.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/scaffold.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Floor:\n x: float\n y: float\n kind: int\n\n\n@dataclass\nclass Item:\n x: float\n y: float\n vy: float\n remaining: float\n travel: float\n gold: bool\n\n\nclass ScaffoldEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 5., 50.\n self.next_x, self.next_y = 57., 52.\n self.wall_x, self.wall_y = -9., 0.\n self.kind = self.steps = self.charge = 0\n self.direction = self.multiplier = 1\n self.item_distance = 0.\n self.held = self.terminal = False\n self.floors = [Floor(i * 6 + 3, 52, 1) for i in range(9)]\n self.items = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n if self.held and not held:\n if self.kind + self.direction not in (0, 1, 2):\n self.direction *= -1\n self.kind += self.direction\n self.held = held\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n scroll = 0.05 + max(0, self.next_x - 40) * 0.1\n self.wall_x -= scroll\n if self.wall_x < -6:\n self.wall_y = 47\n for _ in range(9):\n y = 47 + 4 * self.random.integers(-9, 9)\n if abs(y - self.next_y) < 25:\n self.wall_y = y\n break\n self.wall_x = 126 - self.next_x % 6\n self.items.append(Item(self.wall_x + 4, self.wall_y + 4, 0.1, 2, 4, True))\n self.item_distance += 30\n self.charge = self.charge + 1 if self.held else 0\n if self.charge == 16:\n self.floors.append(Floor(self.next_x, self.next_y, self.kind))\n self.next_x += 6\n self.next_y += 4 * (self.kind - 1)\n self.charge = 0\n for floor in self.floors:\n floor.x -= scroll\n self.floors = [floor for floor in self.floors if floor.x >= -3]\n self.next_x -= scroll\n self.x += max(0, 20 - self.x) * 0.2 - scroll\n self.terminal = self.y < 5 or self.y > 95 or (\n abs(self.x - (self.wall_x + 4)) < 4\n and (self.y - 3 < self.wall_y - 12 or self.y + 3 > self.wall_y + 18)\n )\n foot = self.x + 4\n surface = next((self._height(floor, foot) for floor in self.floors\n if abs(foot - floor.x) <= 3), None)\n self.y += 9 if surface is None else max(-9, min(9, surface - self.y))\n self.item_distance -= scroll\n if self.item_distance < 0:\n gold = self.random.random() < 0.5\n travel = self.random.uniform(20, 60) / (4 if gold else 1.5)\n y = np.clip(self.next_y + self.random.uniform(-20, 20), 10, 90)\n self.items.append(Item(120, y, self.random.choice((-0.3, 0.3)), travel / 2, travel, gold))\n self.item_distance = self.random.uniform(15, 25)\n reward = 0\n remaining = []\n for item in self.items:\n item.x -= scroll\n item.y += item.vy\n item.remaining -= abs(item.vy)\n if item.remaining < 0:\n item.remaining = item.travel\n item.vy *= -1\n if abs(item.x - self.x) < 5 and abs(item.y - self.y) < 5:\n if item.gold:\n reward += self.multiplier\n self.multiplier += 1\n continue\n self.terminal = True\n if item.x >= -3:\n remaining.append(item)\n elif item.gold:\n self.multiplier = max(1, self.multiplier - 1)\n self.items = remaining\n return reward\n\n @staticmethod\n def _height(floor, x):\n return floor.y - 2 + (floor.kind - 1) * (x - floor.x + 3) * 2 / 3\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n entities = [(self.x, self.y, 0), (self.next_x, self.next_y, 2)]\n entities.extend((floor.x, floor.y, 1) for floor in self.floors)\n entities.extend((item.x, item.y, 3 if item.gold else 4) for item in self.items)\n for x, y, channel in entities:\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), channel] = True\n wall = self.wall_x + 4\n if 0 <= wall < 100:\n rows = np.arange(5, 100, 10)\n state[(rows < self.wall_y - 12) | (rows > self.wall_y + 18), int(wall // 10), 4] = True\n values = (self.steps, self.kind, self.direction > 0, self.charge, self.multiplier, self.held)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 215, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/scaffold.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/scaffold/main.js"} +{"name": "stage_separation", "split": "train", "game": "stage_separation", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Stage Separation as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to detach a stage when the stack is above two stages.\nActions 0–4 release. Detaching gives the rocket an upward kick and\nrestarts its burn. The stack gradually regrows. Upward velocity\nearns points and downward velocity subtracts them. Hitting debris\nor dropping below the camera ends the episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the rocket, detached stages, debris,\nexhaust, the lower boundary, and counters. The port uses fixed\ndifficulty and approximates debris contact with a ring test. Each\naction advances up to four frames over 400 actions. Clip the\naccumulated score to [0, 1500] and divide by 1500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/stage_separation.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import sqrt\n\nimport numpy as np\n\n\n@dataclass\nclass Body:\n x: float\n y: float\n vx: float\n vy: float\n size: float\n\n\nclass StageSeparationEnvironment:\n score_cap = 1500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.y, self.vy = 90., -0.5\n self.stage, self.burn = 4., 100\n self.camera, self.zoom = 0., 1.\n self.distance = 99.\n self.steps = 0\n self.held = self.terminal = False\n self.stages, self.debris = [], []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0.\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _advance(self, tap):\n reward = -self.vy * 0.1\n self.camera += max(-99, min(0, (self.y - 130 * self.zoom - self.camera) * 0.1))\n self.zoom = min(3, max(1, 1 - self.y / 9999))\n self.vy += 0.05 - self.burn / 600\n self.y += self.vy\n self.burn = max(0, self.burn - 1)\n if tap and self.stage > 2:\n self.stages.append(Body(50, self.y + 10 * (self.stage - 1),\n self.random.uniform(-0.5, 0.5), self.vy + 0.5, 10))\n self.stage -= 1\n self.vy -= 0.5\n self.burn = 60\n self.stage = min(4, self.stage + 0.02)\n self.terminal = self.y - self.camera > 150 * self.zoom\n for stage in self.stages:\n stage.vy += 0.1\n stage.x += stage.vx\n stage.y += stage.vy\n self.stages = [stage for stage in self.stages if stage.y <= self.camera + 200 * self.zoom]\n self.distance += self.vy\n if self.distance < 0:\n side = self.random.choice((-1, 1))\n self.debris.append(Body(50 + side * 70 * self.zoom,\n self.camera - self.random.uniform(0, 200) * self.zoom,\n -side * self.random.uniform(0.5, 0.8) * self.zoom / 2,\n self.random.uniform(-15, 0) * self.zoom / 2,\n self.random.uniform(5, 15)))\n self.distance = self.random.uniform(120, 160) / sqrt(self.zoom)\n for debris in self.debris:\n debris.x += debris.vx\n debris.y += debris.vy\n self.terminal |= self._hits(debris)\n self.debris = [debris for debris in self.debris if abs(debris.x - 50) <= 70 * self.zoom]\n return reward\n\n def _hits(self, debris):\n dx = abs(debris.x - 50)\n dy = max(self.y - debris.y, debris.y - (self.y + self.stage * 10), 0)\n near = sqrt(max(0, dx - 5) ** 2 + dy ** 2)\n far = sqrt((dx + 5) ** 2 + max(abs(debris.y - self.y),\n abs(debris.y - self.y - self.stage * 10)) ** 2)\n return near <= debris.size + 2 and far >= debris.size - 2\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n rows, cols = np.ogrid[7.5:150:15, 5:100:10]\n world_x = 50 + (cols - 50) * self.zoom\n world_y = self.camera + rows * self.zoom\n for x, y, height, channel in [(50, self.y, self.stage * 10, 0),\n *((s.x, s.y, s.size, 1) for s in self.stages)]:\n state[:, :, channel] |= (abs(world_x - x) < 5 + 5 * self.zoom) & (\n (world_y > y - 7.5 * self.zoom) & (world_y < y + height + 7.5 * self.zoom))\n for debris in self.debris:\n state[:, :, 2] |= abs(np.hypot(world_x - debris.x, world_y - debris.y) - debris.size) < 8 * self.zoom\n if self.burn:\n y = (self.y + 10 * self.stage - self.camera) / self.zoom\n if 0 <= y < 150:\n state[int(y // 15), 5, 3] = True\n state[9, :, 4] = True\n values = (self.steps, round(self.stage * 100), self.burn,\n min(2047, max(0, round((self.vy + 100) * 10))), self.held)\n for row, value in enumerate(values):\n for bit in range(11):\n state[row + bit // 10 * 5, bit % 10, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 216, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/stage_separation.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameStageSeparation.c"} +{"name": "g_press", "split": "train", "game": "g_press", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays G Press as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to close the moving press. Release with actions 0–4\nbefore tapping again. Each press lowers the waterline by 12 units.\nCrushed bubbles release drops that raise it again. Once the drops\nsettle, the recovered water scores points. The run ends if the\nwaterline leaves the bottom and the press and drops are idle.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the jaws, bubbles, drops, water,\nclosing area, and gauges. Each action advances four frames at\nfixed difficulty. The conversion uses rectangular jaw contact\nchecks.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action task clips raw scores to [0, 500] and divides by\n500. Across 100 seeds without sticky actions, idle scored zero\nand random inputs averaged 8.41. A policy timing the press from\nexact bubble positions averaged 287.04 and reached 460.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/g_press.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Bubble:\n x: float\n y: float\n size: float\n velocity: float\n\n\n@dataclass\nclass Drop:\n x: float\n y: float\n velocity: float = 0\n\n\nclass GPressEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.drop_timer = 0\n self.pressed = self.terminal = False\n self.y, self.direction, self.width, self.motion = 30, 1, 80.0, 0.0\n self.water = self.target = self.previous = 70.0\n self.bubble_timer = 0.0\n self.bubbles: list[Bubble] = []\n self.drops: list[Drop] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap: bool) -> int:\n if self.motion:\n self.width += 5 * self.motion\n if self.width < 0:\n self.width, self.motion = 0, 0.5\n elif self.width > 80:\n self.width, self.motion = 80, 0\n else:\n self.y += self.direction\n if (self.y < 10 and self.direction < 0) or (self.y > self.water - 10 and self.direction > 0):\n self.direction *= -1\n if tap:\n self.previous = self.target = self.water + 12\n self.motion = -1\n\n self.bubble_timer -= 1\n if self.bubble_timer < 0:\n size = self.random.uniform(5, 9)\n self.bubbles.append(Bubble(self.random.uniform(20 + size, 80 - size), self.water + size / 2,\n size, -self.random.uniform(1, 2) / size))\n self.target += size * 0.03\n self.bubble_timer += self.random.uniform(10, 50)\n self._move_bubbles()\n reward = 0\n survivors = []\n for drop in self.drops:\n drop.velocity += 0.1\n drop.y += drop.velocity\n if drop.y > self.water + 1:\n self.drop_timer = 9\n self.target -= 0.35\n else:\n survivors.append(drop)\n self.drops = survivors\n if self.drop_timer:\n self.drop_timer -= 1\n if not self.drop_timer and self.previous > self.target:\n gain = self.previous - self.target\n reward = math.ceil(gain**1.5)\n self.target += max(0, 50 - self.target) * 0.05\n self.water += (self.target - self.water) * 0.2\n self.terminal = self.motion == 0 and not self.drops and min(self.water, self.target) >= 100\n return reward\n\n def _move_bubbles(self) -> None:\n survivors = []\n left, right = 50 - self.width / 2, 50 + self.width / 2\n for bubble in self.bubbles:\n bubble.y += bubble.velocity\n radius = bubble.size / 2\n jaw = left if bubble.x < 50 else right\n if (self.motion < 0 or self.width == 0) and abs(bubble.y - self.y) < 10 + radius and abs(bubble.x - jaw) <= 5 + radius:\n if bubble.size > self.width:\n for _ in range(math.ceil(bubble.size)):\n self.drops.append(Drop(bubble.x + self.random.uniform(-radius, radius),\n bubble.y + self.random.uniform(-radius, radius)))\n continue\n bubble.x = jaw + (radius if bubble.x < 50 else -radius)\n if bubble.y >= -radius:\n survivors.append(bubble)\n self.bubbles = survivors\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n top = max(0, (self.y - 10) // 10)\n bottom = min(10, (self.y + 10) // 10 + 1)\n for x in (50 - self.width / 2, 50 + self.width / 2):\n state[top:bottom, int(x) // 10, 0] = True\n for objects, channel in ((self.bubbles, 1), (self.drops, 2)):\n for obj in objects:\n if 0 <= obj.y < 100:\n state[int(obj.y) // 10, int(obj.x) // 10, channel] = True\n state[min(10, int(self.water) // 10):, :, 3] = True\n state[top:bottom, :, 4] = self.motion < 0\n for row, value in enumerate((self.steps, round(self.width), round(self.target), self.drop_timer)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :3, 5] = self.pressed, self.direction > 0, self.motion > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 217, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/g_press.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/gpress/main.js"} +{"name": "orbit_grazer", "split": "train", "game": "orbit_grazer", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Orbit Grazer as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to reverse orbit direction. Actions 0–4 release\nthe button. Graze asteroids to score one point per nearby\nframe while vulnerable. A direct hit shrinks the orbit and\ngrants temporary protection. Touching the center ends the run.\nThe orbit slowly grows back between hits.\n\nINPUT CHANNEL TABLE\nSix 10×10 channels show the player, asteroids, projected\nasteroid positions, orbit, center, and gauges. The conversion\napproximates rotating asteroid hitboxes with rectangles and\nomits decorative trails. At fixed difficulty it advances\nfour frames per action. The 400-action task clips scores to\n[0, 250] and divides by 250.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/orbit_grazer.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Asteroid:\n x: float\n y: float\n vx: float\n vy: float\n size: float\n\n\nclass OrbitGrazerEnvironment:\n score_cap = 250\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 75.0, 50.0\n self.radius, self.angle, self.stretch = 25.0, 0.0, 1.0\n self.direction = 1\n self.steps = self.frames = self.shield = 0\n self.pressed = self.terminal = False\n self.asteroids: list[Asteroid] = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed:\n self.direction *= -1\n self.stretch = 1.6\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _spawn(self):\n angle = self.random.uniform(0, math.tau)\n x, y = 50 + 60 * math.cos(angle), 50 + 60 * math.sin(angle)\n target = self.angle + self.direction * self.random.uniform(0.2, 0.6)\n dx = 50 + self.radius * math.cos(target) - x\n dy = 50 + self.radius * math.sin(target) - y\n if math.hypot(x - self.x, y - self.y) > 50:\n length = math.hypot(dx, dy)\n self.asteroids.append(Asteroid(x, y, 0.5 * dx / length, 0.5 * dy / length,\n self.random.uniform(6, 9)))\n\n def _advance(self):\n self.stretch += (1 - self.stretch) * 0.15\n self.angle += 0.5 * self.direction / (self.radius + 0.1)\n self.x = 50 + self.radius * math.cos(self.angle)\n self.y = 50 + self.radius * math.sin(self.angle)\n if self.frames % 50 == 0:\n self._spawn()\n self.frames += 1\n self.radius = min(40, self.radius + 0.05)\n self.shield = max(-1, self.shield - 1)\n self.terminal = abs(self.x - 50) < 2 + 3 / self.stretch and abs(self.y - 50) < 2 + 3 * self.stretch\n reward = 0\n remaining = []\n shielded_at_start = self.shield > 0\n for asteroid in self.asteroids:\n asteroid.x += asteroid.vx\n asteroid.y += asteroid.vy\n dx, dy = asteroid.x - self.x, asteroid.y - self.y\n if self.shield < 0 and math.hypot(dx, dy) < asteroid.size / 2 + 15:\n reward += 1\n if abs(dx) < asteroid.size / 2 + 3 / self.stretch and abs(dy) < asteroid.size / 2 + 3 * self.stretch:\n if shielded_at_start:\n continue\n self.radius = max(0, self.radius - 20)\n self.shield = 60\n if -10 <= asteroid.x <= 110 and -10 <= asteroid.y <= 110:\n remaining.append(asteroid)\n self.asteroids = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(self.y // 10), int(self.x // 10), 0] = True\n for asteroid in self.asteroids:\n for channel, offset in ((1, 0), (2, 12)):\n x = asteroid.x + offset * asteroid.vx\n y = asteroid.y + offset * asteroid.vy\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), channel] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n state[:, :, 3] = abs(np.hypot(cols - 50, rows - 50) - self.radius) < 5\n state[4:6, 4:6, 4] = True\n for row, value in enumerate((self.steps, round(self.radius * 10), self.shield + 1,\n round(self.angle % math.tau * 80))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 218, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/orbit_grazer.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameOrbitGrazer.c"} +{"name": "m_jamming", "split": "train", "game": "m_jamming", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays M Jamming as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to expand the jamming field. Release with\nactions 0–4 to redirect nearby hostile missiles outward.\nJamming several missiles at once increases both their\nexplosive payload and the score multiplier. Redirected\nmissiles can collide with incoming missiles to start a chain\nreaction. A missile hitting the robot ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the robot, hostile missiles,\nredirected missiles, explosions, jamming field, and gauges.\nThe conversion uses geometric collision checks and four\nframes per action at fixed difficulty. The 400-action task\nclips raw scores to [0, 400] and divides by 400.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/m_jamming.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Missile:\n x: float\n y: float\n angle: float\n speed: float = 0.4\n payload: float = -1\n\n\n@dataclass\nclass Blast:\n x: float\n y: float\n target: float\n radius: float = 1\n growth: float = 0.5\n\n\nclass MJammingEnvironment:\n score_cap = 400\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x = self.y = 50.0\n self.vx = self.vy = self.radius = self.timer = 0.0\n self.steps = 0\n self.multiplier = 1\n self.pressed = self.terminal = False\n self.missiles: list[Missile] = []\n self.blasts: list[Blast] = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n release = self.pressed and not pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(release and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, release):\n sx, sy = (50 - self.x) * 0.05, (50 - self.y) * 0.05\n for blast in self.blasts:\n blast.radius += blast.growth\n if blast.radius > blast.target:\n blast.growth = -0.5\n self.blasts = [b for b in self.blasts if b.radius >= 1]\n self.vx *= 0.98\n self.vy *= 0.98\n self.x += self.vx + sx\n self.y += self.vy + sy\n if self.pressed or release:\n self.radius *= 1.01\n self.vx *= 0.9\n self.vy *= 0.9\n else:\n self.radius = min(15, self.radius + 0.5)\n reward = self._jam() if release or self.radius > 50 else 0\n self.timer -= 1\n if self.timer < 0:\n self._spawn()\n survivors = []\n for missile in self.missiles:\n if missile.payload < 0:\n target = math.atan2(self.y - missile.y, self.x - missile.x)\n delta = (target - missile.angle + math.pi) % math.tau - math.pi\n missile.angle += min(0.005, max(-0.005, delta))\n missile.x += math.cos(missile.angle) * missile.speed + sx\n missile.y += math.sin(missile.angle) * missile.speed + sy\n if any(abs(math.hypot(missile.x - b.x, missile.y - b.y) - b.radius) < 4 for b in self.blasts):\n if missile.payload > 1:\n self.blasts.append(Blast(missile.x, missile.y, missile.payload))\n reward += self.multiplier\n self.multiplier += 1\n else:\n self.terminal |= math.hypot(missile.x - self.x, missile.y - self.y) < 4\n if -100 <= missile.x < 100 and -100 <= missile.y < 100:\n survivors.append(missile)\n hostile = [m for m in survivors if m.payload < 0]\n remaining = []\n for missile in survivors:\n if missile.payload > 0 and any(math.hypot(missile.x - m.x, missile.y - m.y) < 3 for m in hostile):\n self.blasts.append(Blast(missile.x, missile.y, missile.payload))\n reward += self.multiplier\n self.multiplier += 1\n else:\n remaining.append(missile)\n self.missiles = remaining\n nearest = min(survivors, key=lambda m: math.hypot(m.x - self.x, m.y - self.y), default=None)\n if nearest is not None and math.hypot(nearest.x - self.x, nearest.y - self.y) < 50:\n angle = math.atan2(self.y - nearest.y, self.x - nearest.x) + math.pi / 3\n self.vx += math.cos(angle) * 0.01\n self.vy += math.sin(angle) * 0.01\n return reward\n\n def _jam(self):\n self.multiplier = 1\n targets = [m for m in self.missiles if m.payload < 0\n and math.hypot(m.x - self.x, m.y - self.y) < self.radius + 1]\n count = len(targets)\n for missile in targets:\n missile.angle = math.atan2(missile.y - self.y, missile.x - self.x)\n missile.payload = min(25, count ** 1.5)\n missile.speed *= 0.5\n self.radius = count\n self.multiplier += count\n return count * (count + 1) // 2\n\n def _spawn(self):\n for _ in range(int(self.random.integers(6, 9))):\n angle = self.random.uniform(0, math.tau)\n x, y = 50 + math.cos(angle) * 99, 50 + math.sin(angle) * 99\n tx, ty = self.random.uniform(40, 60, 2)\n self.missiles.append(Missile(x, y, math.atan2(ty - y, tx - x)))\n self.timer = self.random.uniform(60, 70)\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, max(0, int(self.y // 10))), min(9, max(0, int(self.x // 10))), 0] = True\n for missile in self.missiles:\n if 0 <= missile.x < 100 and 0 <= missile.y < 100:\n state[int(missile.y // 10), int(missile.x // 10), 1 + (missile.payload > 0)] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for blast in self.blasts:\n state[:, :, 3] |= abs(np.hypot(cols - blast.x, rows - blast.y) - blast.radius) < 6\n state[:, :, 4] = np.hypot(cols - self.x, rows - self.y) < self.radius + 1\n for row, value in enumerate((self.steps, min(511, self.multiplier), round(self.radius * 8))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 219, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/m_jamming.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/mjamming/main.js"} +{"name": "clean_robo", "split": "train", "game": "clean_robo", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Clean Robo as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to accelerate. Release with actions 0–4 to slow down\nand rotate the triangular cleaner. Sweep an edge over the garbage\nto score the current multiplier and add 10 to it. The multiplier\ndecays while the button is released.\n\nThe robot reverses at each wall. Cleaning moves that wall inward.\nMissing garbage moves it outward and resets speed. A wall extending\npast the room ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the robot, walls, garbage, missed\ngarbage, triangle vertices, and gauges. Each action advances four\nframes at fixed difficulty. The conversion uses geometric checks\nfor the walls and sweeps the triangle edges across horizontal\nmovement to detect pickups.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 500] and divide by the fixed cap of 500. Across 100 seeds without\nsticky actions, always released averaged 0.93, always held scored 12,\nand random inputs averaged 5.62. Repeating nine held actions and\nthree released actions averaged 131.69 and reached 707 before clipping.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/clean_robo.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\n\n\n@dataclass\nclass Wall:\n side: int\n distance: float = 50\n angle: float = 0\n\n def vertices(self) -> list[tuple[float, float]]:\n angles = [self.angle + (math.pi if self.side < 0 else 0)\n + self.side * offset * math.tau / 3 for offset in (-1, 0, 1)]\n return sorted(\n [(100 + self.side * self.distance + 17 * math.cos(angle),\n 50 + 17 * math.sin(angle)) for angle in angles],\n key=lambda point: point[1],\n )\n\n def edge_x(self, y: float) -> float:\n first, middle, last = self.vertices()\n if y <= first[1]:\n return first[0]\n if y >= last[1]:\n return last[0]\n a, b = (first, middle) if y < middle[1] else (middle, last)\n return a[0] + (b[0] - a[0]) * (y - a[1]) / (b[1] - a[1])\n\n def target(self) -> tuple[float, float]:\n angle = self.angle + (math.pi if self.side < 0 else 0)\n return (100 + self.side * (self.distance - 7) + 17 * math.cos(angle),\n 50 + 8.5 * math.sin(angle))\n\n\nclass CleanRoboEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = 0\n self.pressed = self.terminal = False\n self.x, self.angle, self.speed, self.multiplier = 90.0, 0.0, 1.0, 1.0\n self.direction = 1\n self.walls = {side: Wall(side, angle=self.random.uniform(-math.pi / 7, math.pi / 7))\n for side in (-1, 1)}\n self.garbage: tuple[float, float] | None = self.walls[1].target()\n self.missed: tuple[float, float] | None = None\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(FRAMES_PER_STEP):\n reward += self._advance_frame()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _triangle(self) -> list[tuple[float, float]]:\n return [(self.x + 10 * math.cos(self.angle + index * math.tau / 3),\n 50 + 10 * math.sin(self.angle + index * math.tau / 3)) for index in range(3)]\n\n def _advance_frame(self) -> int:\n if self.pressed:\n self.speed += 0.3\n else:\n self.angle = (self.angle + 0.05) % math.tau\n self.speed += (1 - self.speed) * 0.2\n self.multiplier = max(1, self.multiplier - 0.1)\n old_x = self.x\n self.x += self.direction * self.speed * 0.2\n triangle = self._triangle()\n wall = self.walls[self.direction]\n reward = 0\n if self.garbage is not None:\n gx, gy = self.garbage\n for a, b in zip(triangle, triangle[1:] + triangle[:1]):\n dx, dy = b[0] - a[0], b[1] - a[1]\n fraction = min(1, max(0, ((gx - a[0]) * dx + (gy - a[1]) * dy) / 300))\n edge_x = a[0] + dx * fraction\n lo, hi = sorted((edge_x, edge_x + old_x - self.x))\n distance_x = max(lo - gx, gx - hi, 0)\n if math.hypot(distance_x, gy - a[1] - dy * fraction) <= 3:\n reward = math.ceil(self.multiplier)\n self.multiplier += 10\n self.garbage = None\n break\n\n if (self.x - 100) * self.direction > 0 and any(\n (x - wall.edge_x(y)) * self.direction >= 0 for x, y in triangle\n ):\n self.direction *= -1\n self.missed = self.garbage\n if self.missed is not None:\n self.speed = 1\n wall.distance = min(100, max(30, wall.distance + (20 if self.missed is not None else -10)))\n wall.angle = self.random.uniform(-math.pi / 7, math.pi / 7)\n self.garbage = self.walls[self.direction].target()\n self.terminal = not 0 <= wall.target()[0] + wall.side * 7 <= 199\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[5, min(9, max(0, int(self.x) // 20)), 0] = True\n for wall in self.walls.values():\n for row in range(10):\n col = min(9, max(0, int(wall.edge_x(row * 10 + 5)) // 20))\n state[row, col, 1] = True\n for channel, point in ((2, self.garbage), (3, self.missed)):\n if point is not None:\n x, y = point\n state[int(y) // 10, min(9, max(0, int(x) // 20)), channel] = True\n for x, y in self._triangle():\n state[int(y) // 10, min(9, max(0, int(x) // 20)), 4] = True\n for row, value in enumerate((self.steps, math.ceil(self.multiplier), round(self.speed * 4), round(self.angle * 40))):\n for bit in range(11):\n if bit < 10:\n state[row, bit, 5] = bool(value & (1 << bit))\n else:\n state[row + 4, 0, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 220, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/clean_robo.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-11-games/blob/6fea4eefe2deaa42706051d96a04ec9e36104696/docs/cleanrobo/main.js"} +{"name": "splitzig", "split": "train", "game": "splitzig", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Splitzig as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to reverse direction. Actions 0–4 release. The player\nmoves automatically, wraps at the sides, and shoots every seven\nframes. Large and medium blocks split into two smaller blocks.\nLarge, medium, and small blocks score one, two, and three points\nrespectively. Blocks that reach the ground raise the stack, which\nslowly sinks. Contact with a block or rising above the top ends\nthe episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the player, bullets, small blocks, medium\nblocks, large blocks, and stack plus counters. The counters occupy\nthe first nine cells of the first five rows in the last channel.\nThe port uses fixed difficulty and bounding rectangles for rotated\nblocks. Each action advances up to four frames for up to 400 actions.\nClip episode scores to [0, 250] and divide by 250.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/splitzig.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\nSIZES = (5, 8, 12)\n\n\n@dataclass\nclass Block:\n x: float\n y: float\n vx: float\n vy: float\n size: int\n squash: float = 1.\n angle: float = 0.\n\n\nclass SplitzigEnvironment:\n score_cap = 250\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 50., 80.\n self.direction = 1\n self.squash = 1.\n self.tilt = self.stack = 0.\n self.frame = self.steps = self.timer = 0\n self.held = self.terminal = False\n self.blocks, self.bullets = [], []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n if held and not self.held:\n self.direction *= -1\n self.squash = 0.5\n self.held = held\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n self.squash += (1 - self.squash) * 0.15\n self.tilt += (self.direction * 0.3 - self.tilt) * 0.2\n self.x = (self.x + self.direction * 1.5) % 100\n self.stack *= 0.998\n self.y = 90 - self.stack\n self.terminal = self.y < 0\n if self.frame % 7 == 0:\n self.bullets.append((self.x, self.y - 5))\n self.bullets = [(x, y - 3) for x, y in self.bullets if y - 3 >= -5]\n self.timer += 1\n if self.timer >= self.random.uniform(88, 111):\n self.timer = 0\n self.blocks.append(Block(self.random.uniform(15, 85), -10,\n self.random.uniform(-0.3, 0.3), self.random.uniform(0.2, 0.8), 2))\n reward = 0\n spent = set()\n remaining = []\n for block in self.blocks:\n block.x += block.vx\n block.y += block.vy\n if (block.x < 5 and block.vx < 0) or (block.x > 95 and block.vx > 0):\n block.vx *= -1\n block.squash = 0.6\n block.squash += (1 - block.squash) * 0.1\n block.angle += block.vx * 0.05\n size = SIZES[block.size]\n c, s = abs(np.cos(block.angle)), abs(np.sin(block.angle))\n half_x = size * (c / block.squash + s * block.squash) / 2\n half_y = size * (s / block.squash + c * block.squash) / 2\n hits = [index for index, (x, y) in enumerate(self.bullets)\n if abs(block.x - x) < half_x + 1 and abs(block.y - y) < half_y + 2]\n if hits:\n spent.update(hits)\n reward += 3 - block.size\n if block.size:\n for direction in (-1, 1):\n remaining.append(Block(block.x + 5 * direction, block.y,\n direction * self.random.uniform(0.8, 1.1),\n block.vy * 0.8, block.size - 1, 0.6, block.angle))\n elif abs(block.x - self.x) < half_x + 3 / self.squash and abs(block.y - self.y) < half_y + 3:\n self.terminal = True\n elif block.y > 100 - self.stack - size / 2:\n self.stack += size / 2\n else:\n remaining.append(block)\n self.blocks = remaining\n self.bullets = [bullet for index, bullet in enumerate(self.bullets) if index not in spent]\n self.frame += 1\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(np.clip(self.y // 10, 0, 9)), int(self.x // 10), 0] = True\n for x, y in self.bullets:\n if 0 <= y < 100:\n state[int(y // 10), int(x // 10), 1] = True\n for block in self.blocks:\n if 0 <= block.x < 100 and 0 <= block.y < 100:\n state[int(block.y // 10), int(block.x // 10), block.size + 2] = True\n rows = np.arange(10) * 10\n state[rows + 10 > 100 - self.stack, :, 5] = True\n values = (self.steps, self.direction > 0, self.held, self.frame % 7, self.timer)\n state[:5, :9, 5] = False\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 221, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/splitzig.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameSplitzig.c"} +{"name": "pressbound", "split": "train", "game": "pressbound", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Pressbound as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to freeze the balls and charge. The walls jump inward on\nthe first press and close faster while held. Release with actions 0–4\nto score the floor of `(held frames × ball count / 10)²`, reset the\nwalls, and spawn two to four moving balls. A wall touching a frozen\nball ends the run. The run also ends if the moving arena shrinks to\n43 units of pressure.\n\nINPUT CHANNEL TABLE\nThe six channels show moving balls, frozen balls, walls, balls near\nthe walls, counters, and a warning for high pressure while released.\nThe conversion uses fixed difficulty and an axis-aligned collision\nprobe. It omits decorative bounce effects. Each action advances up to\nfour frames for up to 400 actions. Clip the episode score to\n[0, 3000] and divide by 3000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/pressbound.py`):\n```python\nimport numpy as np\n\n\nclass PressboundEnvironment:\n score_cap = 3000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.pressure = 500\n self.charge = self.steps = 0\n self.held = self.terminal = False\n self._spawn(1, 10)\n\n def _spawn(self, count, margin):\n self.balls = self.random.uniform(margin, 100 - margin, (count, 2))\n self.velocity = self.random.uniform(0.5, 1, (count, 2))\n self.velocity *= self.random.choice((-1, 1), (count, 2))\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n reward = 0\n self.steps += 1\n for _ in range(4):\n reward += self._advance(held)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, held):\n self.pressure += 20 if held else 5\n reward = 0\n if held:\n if not self.held:\n self.pressure += 200\n self.charge += 1\n margin = self.pressure / 100 + 0.5\n self.terminal = bool(np.any(self.balls < margin) or np.any(self.balls > 100 - margin))\n else:\n if self.held:\n reward = (self.charge * len(self.balls)) ** 2 // 100\n self.charge = 0\n self.pressure = 500\n self._spawn(self.random.integers(2, 5), 5)\n self.terminal = self.pressure >= 4300\n margin = self.pressure / 100 + 1\n self.balls += self.velocity\n self.velocity = np.where(self.balls < margin, abs(self.velocity), self.velocity)\n self.velocity = np.where(self.balls > 100 - margin, -abs(self.velocity), self.velocity)\n np.clip(self.balls, margin, 100 - margin, out=self.balls)\n self.held = held\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n coordinates = np.arange(5, 100, 10)\n edges = np.minimum(coordinates, 100 - coordinates)\n state[:, :, 2] = np.minimum(edges[:, None], edges) <= self.pressure / 100\n for x, y in self.balls:\n row, col = int(y // 10), int(x // 10)\n state[row, col, int(self.held)] = True\n if min(x, y, 100 - x, 100 - y) < self.pressure / 100 + 6:\n state[row, col, 3] = True\n for row, value in enumerate((self.pressure, self.charge, len(self.balls), self.steps)):\n for bit in range(13):\n state[row + bit // 10 * 4, bit % 10, 4] = bool(value & (1 << bit))\n state[:, :, 5] = not self.held and self.pressure > 3500\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 222, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pressbound.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePressbound.c"} +{"name": "roll_s", "split": "train", "game": "roll_s", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Roll S as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to stop scrolling and fire a five-shot spread. Release\nwith actions 0–4 to resume scrolling and step the aim between\nhorizontal and the two diagonal angles. Enemies cross three lanes\nand periodically stop to fire. Hits score the current multiplier,\nwhich grows with distance traveled. Enemy bullets can end the run.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the player, shots, enemies, enemies\nin their firing phase, enemy bullets, and counters. The port uses\nfixed difficulty and rectangular collision bounds. Each action\nadvances up to four frames over a 400-action horizon. Clip the\nepisode score to [0, 200] and divide by 200.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/roll_s.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import atan2, cos, floor, pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Projectile:\n x: float\n y: float\n vx: float\n vy: float\n\n def advance(self, scroll):\n self.x += self.vx - scroll\n self.y += self.vy\n return -3 <= self.x <= 103 and -3 <= self.y <= 103\n\n\n@dataclass\nclass Enemy:\n x: float\n y: int\n timer: int\n angle: float = 0.0\n\n\nclass RollSEnvironment:\n score_cap = 200\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.aim = self.fire_timer = self.spawn_timer = self.steps = 0\n self.direction = self.multiplier = 1\n self.distance = 0.0\n self.held = self.terminal = False\n self.shots, self.enemies, self.bullets = [], [], []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n released = self.held and not held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(released and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, released):\n if released:\n self.aim += self.direction\n if abs(self.aim) > 1:\n self.direction *= -1\n self.aim += self.direction * 2\n self.fire_timer = 9\n scroll = 0 if self.held else 0.5\n self.distance += scroll\n if self.distance > 100 * self.multiplier:\n self.multiplier += 1\n x, y = self._gun()\n if self.held:\n self.fire_timer -= 1\n if self.fire_timer < 0:\n for index in range(-2, 3):\n angle = self.aim * pi / 4 + index * 0.12\n self.shots.append(Projectile(x, y, 3 * cos(angle), 3 * sin(angle)))\n self.fire_timer = 9\n self.shots = [shot for shot in self.shots if shot.advance(scroll)]\n self.spawn_timer -= 1\n if self.spawn_timer < 0:\n self.enemies.append(Enemy(105, 20 + 30 * self.random.integers(3), self.random.integers(300)))\n self.spawn_timer = self.random.uniform(50, 60)\n reward = 0\n enemies = []\n for enemy in self.enemies:\n gun_x, gun_y = enemy.x, enemy.y - 9\n enemy.timer -= 1\n if enemy.timer < 0:\n if enemy.timer % 36 == 0:\n self.bullets.append(Projectile(gun_x, gun_y, cos(enemy.angle), sin(enemy.angle)))\n if enemy.timer <= -108:\n enemy.timer = 300\n else:\n enemy.angle = floor((atan2(50 - enemy.y, 20 - enemy.x) + pi / 8) / (pi / 4)) * pi / 4\n enemy.x -= 0.2\n enemy.x -= scroll\n if any(self._near(shot.x, shot.y, gun_x, gun_y)\n or self._near(shot.x, shot.y, enemy.x, enemy.y - 3) for shot in self.shots):\n reward += self.multiplier\n continue\n self.terminal |= not (self.held and self.aim == 0) and self._near(x, y, gun_x, gun_y)\n if -5 <= enemy.x <= 105:\n enemies.append(enemy)\n self.enemies = enemies\n self.bullets = [bullet for bullet in self.bullets if bullet.advance(scroll)]\n self.terminal |= any(self._near(x, y, bullet.x, bullet.y) for bullet in self.bullets)\n return reward\n\n @staticmethod\n def _near(x, y, other_x, other_y):\n return abs(x - other_x) < 4 and abs(y - other_y) < 4\n\n def _gun(self):\n return (26, 47) if self.held and self.aim == 0 else (20, 41)\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n x, y = self._gun()\n state[y // 10, x // 10, 0] = True\n for channel, entities in ((1, self.shots), (2, self.enemies), (4, self.bullets)):\n for entity in entities:\n if 0 <= entity.x < 100 and 0 <= entity.y < 100:\n row, col = int(entity.y // 10), int(entity.x // 10)\n state[row, col, channel] = True\n if channel == 2 and entity.timer < 0:\n state[row, col, 3] = True\n values = (self.steps, self.aim + 1, self.direction > 0, self.held,\n self.multiplier, self.fire_timer)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 223, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/roll_s.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/rolls/main.js"} +{"name": "name_this_game", "split": "train", "game": "name_this_game", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Name This Game as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves the fixed-screen underwater defense: the diver moves along the sea\nfloor, fires upward, shoots an increasingly deep shark, retracts four descending octopus\ntentacles, follows the boat's moving oxygen line, and protects five pieces of treasure. Running\nout of air, meeting the shark, or letting a tentacle reach the bottom costs treasure. Threat and\nair-drain speed rise across eight waves.\n\nACTION MAPPING\n0: wait\n1: move left\n2: unused\n3: move right\n4: unused\n5: fire upward\n\nINPUT CHANNEL TABLE\n0: diver\n1: shark and live tentacle segments\n2: shots and remaining treasure\n3: oxygen line\n4: previous diver, shark, and shot positions\n5: exact wave, treasure, shark identity, air, oxygen bonuses, destroyed tentacles, step timers, and directions\n\nSCORING, TERMINATION, AND HORIZON\nEach wave contains four tentacles worth 50 points (200), three sharks worth at most 100 points\n(300), and ten full-tank air units worth 10 points (100). Eight waves therefore give\n`score_cap = 8 × 600 = 4,800`. Normalization is\n`min(max(raw_score, 0), 4_800) / 4_800`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/name_this_game.py`):\n```python\nimport numpy as np\n\n\nTENTACLE_COLUMNS = (2, 4, 6, 8)\nSHARK_VALUES_BY_ROW = (0, 10, 20, 30, 40, 50, 80, 100, 100)\n\n\nclass NameThisGameEnvironment:\n \"\"\"Eight escalating treasure-defense waves under a moving oxygen line.\"\"\"\n\n score_cap = 4_800.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 3_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.wave = 0\n self.treasure = 5\n self.score = 0.0\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self._start_wave()\n\n def _start_wave(self) -> None:\n self.diver_column = 5\n self.previous_diver_column = self.diver_column\n self.air = 100\n self.air_line_column = 0\n self.air_line_direction = 1\n self.air_bonus_units = 0\n self.tentacle_lengths = [1, 1, 1, 1]\n self.tentacles_destroyed: set[int] = set()\n self.shark_index = 0\n self.shark = [1, 0]\n self.previous_shark = self.shark.copy()\n self.shark_direction = 1\n self.projectiles: list[list[int]] = []\n self.previous_projectiles: list[list[int]] = []\n self.wave_steps = 0\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_diver_column = self.diver_column\n self.previous_shark = self.shark.copy()\n self.previous_projectiles = [projectile.copy() for projectile in self.projectiles]\n if action == 1:\n self.diver_column = max(0, self.diver_column - 1)\n elif action == 3:\n self.diver_column = min(9, self.diver_column + 1)\n elif action == 5 and len(self.projectiles) < 3:\n self.projectiles.append([7, self.diver_column])\n wave_before = self.wave\n reward = self._move_projectiles()\n if self.wave == wave_before and not self.terminal:\n self._move_shark()\n self._grow_tentacles()\n reward += self._move_air_line()\n self.air -= 1 + self.wave // 3\n self._resolve_failures()\n self.score += reward\n self.steps += 1\n self.wave_steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_projectiles(self) -> float:\n reward = 0.0\n for projectile in list(self.projectiles):\n projectile[0] -= 1\n hit_tentacle = None\n for index, column in enumerate(TENTACLE_COLUMNS):\n if index in self.tentacles_destroyed:\n continue\n tip_row = self.tentacle_lengths[index]\n if projectile == [tip_row, column]:\n hit_tentacle = index\n break\n if hit_tentacle is not None:\n self.tentacles_destroyed.add(hit_tentacle)\n self.projectiles.remove(projectile)\n reward += 50.0\n continue\n if projectile == self.shark and self.shark_index < 3:\n reward += float(SHARK_VALUES_BY_ROW[self.shark[0]])\n self.shark_index += 1\n self.projectiles.remove(projectile)\n self._reset_shark()\n continue\n if projectile[0] < 0:\n self.projectiles.remove(projectile)\n if len(self.tentacles_destroyed) == 4 and self.shark_index >= 3:\n self.wave += 1\n if self.wave >= 8:\n self.terminal = True\n else:\n self._start_wave()\n return reward\n\n def _reset_shark(self) -> None:\n self.shark = [1, 0 if self.shark_direction > 0 else 9]\n self.previous_shark = self.shark.copy()\n\n def _move_shark(self) -> None:\n if self.shark_index >= 3:\n return\n interval = max(1, 3 - self.wave // 3)\n if self.wave_steps % interval:\n return\n self.shark[1] += self.shark_direction\n if self.shark[1] in (0, 9):\n self.shark_direction *= -1\n self.shark[0] = min(8, self.shark[0] + 1)\n\n def _grow_tentacles(self) -> None:\n interval = max(2, 8 - self.wave)\n if self.wave_steps % interval:\n return\n live = [index for index in range(4) if index not in self.tentacles_destroyed]\n if live:\n index = live[(self.wave_steps // interval) % len(live)]\n self.tentacle_lengths[index] = min(8, self.tentacle_lengths[index] + 1)\n\n def _move_air_line(self) -> float:\n self.air_line_column += self.air_line_direction\n if self.air_line_column in (0, 9):\n self.air_line_direction *= -1\n if self.air_line_column != self.diver_column:\n return 0.0\n if self.air < 100:\n self.air = min(100, self.air + 20)\n return 0.0\n if self.air_bonus_units < 10:\n self.air_bonus_units += 1\n return 10.0\n return 0.0\n\n def _resolve_failures(self) -> None:\n shark_hit = self.shark_index < 3 and self.shark == [8, self.diver_column]\n tentacle_hit = any(\n index not in self.tentacles_destroyed and length >= 8\n for index, length in enumerate(self.tentacle_lengths)\n )\n if self.air <= 0 or shark_hit or tentacle_hit:\n self.treasure -= 1\n if self.treasure <= 0:\n self.terminal = True\n return\n self.diver_column = 5\n self.air = 100\n self._reset_shark()\n for index in range(4):\n if index not in self.tentacles_destroyed:\n self.tentacle_lengths[index] = 1\n self.projectiles.clear()\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[8, self.diver_column, 0] = True\n state[8, self.previous_diver_column, 4] = True\n if self.shark_index < 3:\n state[*self.shark, 1] = True\n state[*self.previous_shark, 4] = True\n for index, column in enumerate(TENTACLE_COLUMNS):\n if index in self.tentacles_destroyed:\n continue\n state[0 : self.tentacle_lengths[index] + 1, column, 1] = True\n for projectile in self.projectiles:\n state[*projectile, 2] = True\n for projectile in self.previous_projectiles:\n state[*projectile, 4] = True\n state[0:8, self.air_line_column, 3] = True\n state[9, : self.treasure, 2] = True\n for bit in range(3):\n state[0, bit, 5] = bool(self.wave & (1 << bit))\n state[0, 3 + bit, 5] = bool(self.treasure & (1 << bit))\n state[0, 6 + bit, 5] = bool(self.shark_index & (1 << bit))\n for bit in range(7):\n state[1, bit, 5] = bool(max(0, self.air) & (1 << bit))\n for bit in range(4):\n state[2, bit, 5] = bool(self.air_bonus_units & (1 << bit))\n for index in range(4):\n state[2, 4 + index, 5] = index in self.tentacles_destroyed\n for bit in range(12):\n state[3 + bit // 10, bit % 10, 5] = bool(self.steps & (1 << bit))\n state[5 + bit // 10, bit % 10, 5] = bool(self.wave_steps & (1 << bit))\n state[7, 0, 5] = self.shark_direction > 0\n state[7, 1, 5] = self.air_line_direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 224, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/name_this_game.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "m_field", "split": "train", "game": "m_field", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays M Field as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to jump or double jump. Hold to accelerate\nand slow your fall. Actions 0–4 release the button. Stepping\non a mine starts its fuse and resets the multiplier.\nExplosions chain through nearby mines and defeat enemies\nfor points, doubling the multiplier up to 64.\n\nINPUT CHANNEL TABLE\nA blast hitting the player ends the run. Landing on an enemy\nbounces the player, while other enemy contact ends the run.\nSix 10×10 channels show the player, unarmed mines, armed\nmines, enemies, blasts, and gauges. The conversion uses\nrectangular contact bounds and fixed difficulty. Four frames\nadvance per action, up to 400 actions. Scores are clipped\nto [0, 200] and divided by 200.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/m_field.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Mine:\n x: float\n fuse: int = 0\n\n\n@dataclass\nclass Enemy:\n x: float\n vx: float\n\n\nclass MFieldEnvironment:\n score_cap = 200\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 80.0, 87.0\n self.vx = self.vy = self.mine_distance = self.enemy_distance = 0.0\n self.jumps = self.steps = 0\n self.multiplier = 1\n self.pressed = self.terminal = False\n self.mines = []\n self.enemies = []\n self.blasts = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _in_blast(self, x, radius):\n return any(abs(x - center) < width + radius for center, _, width in self.blasts)\n\n def _advance(self, tap):\n scroll = max(0, self.x - 99) * 0.1\n self.blasts = [(x - scroll, age + 1, max(0, math.sin((age + 1) * 0.1) * 25))\n for x, age, _ in self.blasts if age < 31]\n self.enemy_distance -= scroll\n if self.enemy_distance < 0:\n if self.random.random() < 0.7:\n self.enemies.append(Enemy(203, -0.4 * self.random.uniform(1, 2)))\n else:\n self.enemies.append(Enemy(-3, 0.4 * self.random.uniform(1.5, 2)))\n self.enemy_distance += self.random.uniform(20, 30)\n reward = 0\n surviving = []\n for enemy in self.enemies:\n enemy.x += enemy.vx - scroll\n if not self.jumps and abs(enemy.x - self.x) > 20 and (enemy.x - self.x) * enemy.vx > 0:\n enemy.vx *= -1\n if self._in_blast(enemy.x, 3):\n reward += self.multiplier\n self.multiplier = min(64, self.multiplier * 2)\n elif enemy.x >= -9:\n surviving.append(enemy)\n self.enemies = surviving\n self.vx += ((1 if self.pressed else 0.3) - self.vx) * 0.1\n if self.jumps:\n self.vy += 0.05 if self.pressed else 0.1\n if self.y > 87:\n self.y, self.vy, self.jumps = 87, 0, 0\n if tap and self.jumps < 2:\n self.jumps += 1\n self.vy = -2\n self.y -= 6\n self.x += self.vx - scroll\n self.y += self.vy\n self.terminal = abs(self.y - 86) < 7 and self._in_blast(self.x, 3)\n if abs(self.y - 87) < 6 and any(abs(self.x - enemy.x) < 5 for enemy in self.enemies):\n if self.vy > 0:\n self.y = 80\n self.vy *= -0.8\n else:\n self.terminal = True\n self._move_mines(scroll)\n return reward\n\n def _move_mines(self, scroll):\n self.mine_distance -= scroll\n if self.mine_distance < 0:\n self.mines.append(Mine(203))\n self.mine_distance = (self.random.uniform(9, 20) if self.random.random() < 0.6\n else self.random.uniform(50, 80))\n remaining = []\n chain = []\n for mine in self.mines:\n mine.x -= scroll\n if mine.fuse:\n mine.fuse += 1\n if mine.fuse > 59 or self._in_blast(mine.x, 3):\n chain.append((mine.x, 0, 0))\n elif mine.x >= -3:\n if not mine.fuse and abs(mine.x - self.x) < 6 and abs(91 - self.y) < 4.5:\n mine.fuse = 1\n self.multiplier = 1\n remaining.append(mine)\n self.mines = remaining\n self.blasts.extend(chain)\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, max(0, int(self.y // 10))), int(self.x // 20), 0] = True\n for mine in self.mines:\n if 0 <= mine.x < 200:\n state[9, int(mine.x // 20), 2 if mine.fuse else 1] = True\n for enemy in self.enemies:\n if 0 <= enemy.x < 200:\n state[8, int(enemy.x // 20), 3] = True\n for x, _, width in self.blasts:\n state[8:10, :, 4] |= abs(np.arange(10, 200, 20) - x) < width + 10\n for row, value in enumerate((self.steps, self.multiplier, self.jumps, round((self.vy + 4) * 40))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 225, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/m_field.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/mfield/main.js"} +{"name": "plasma_splitter", "split": "train", "game": "plasma_splitter", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Plasma Splitter as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to stop horizontal movement and accelerate\nthe walls. Release with actions 0–4 to leave an anchor and\nresume moving. Put both endpoints in gaps. The tether breaks\nwall segments between the endpoints and scores their width\nscaled by scroll speed. Endpoint contact ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the moving endpoint, anchor,\ntether, walls, gaps, and gauges. The conversion uses\nrectangular contact checks and four frames per action at\nfixed difficulty. The 400-action task clips raw scores to\n[0, 500] and divides by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/plasma_splitter.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Wall:\n y: float\n gaps: list[tuple[float, float]]\n\n def segments(self):\n left = 0.0\n for start, end in self.gaps:\n yield left, start\n left = end\n yield left, 100.0\n\n\nclass PlasmaSplitterEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.anchor = 50.0, 0.0\n self.direction = 1\n self.speed, self.distance = 0.2, 0.0\n self.steps = 0\n self.pressed = self.terminal = False\n self.walls: list[Wall] = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if self.pressed and not pressed:\n self.anchor = self.x\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _spawn(self):\n count = int(self.random.choice((1, 2, 2, 3, 3, 3)))\n gaps = []\n x = 0.0\n for index in range(count):\n x += self.random.uniform(10 if index else 0, 76 - x - (count - index - 1) * 34)\n gaps.append((x, x + 24))\n x += 24\n self.walls.append(Wall(-3, gaps))\n self.distance = self.random.uniform(50, 80)\n\n def _advance(self):\n if self.pressed:\n self.speed += 0.01\n else:\n self.speed += (0.2 - self.speed) * 0.1\n self.x += self.direction\n if self.x < 4 or self.x > 96:\n self.direction *= -1\n self.distance -= self.speed\n if self.distance < 0:\n self._spawn()\n reward = 0\n remaining = []\n low, high = sorted((self.x, self.anchor))\n for wall in self.walls:\n wall.y += self.speed\n destroyed = False\n for index, (left, right) in enumerate(wall.segments()):\n if right <= left:\n continue\n endpoint_hit = any(left < x + 4 and x - 4 < right for x in (self.x, self.anchor))\n if 89 < wall.y < 100 and endpoint_hit:\n self.terminal = True\n elif index < len(wall.gaps) and 91 < wall.y < 96 and low < right and left < high:\n reward += math.floor(self.speed / 0.2 * (right - left))\n destroyed = True\n if not destroyed and wall.y <= 103:\n remaining.append(wall)\n self.walls = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n a, b = int(self.x // 10), int(self.anchor // 10)\n state[9, a, 0] = True\n state[9, b, 1] = True\n state[9, min(a, b):max(a, b) + 1, 2] = True\n columns = np.arange(5, 100, 10)\n for wall in self.walls:\n if 0 <= wall.y < 100:\n row = int(wall.y // 10)\n for start, end in wall.gaps:\n state[row, :, 4] |= (columns >= start) & (columns < end)\n for start, end in wall.segments():\n state[row, :, 3] |= (columns >= start) & (columns < end)\n for row, value in enumerate((self.steps, round(self.x * 4), round(self.anchor * 4),\n min(511, round(self.speed * 30)))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 226, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/plasma_splitter.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePlasmaSplitter.c"} +{"name": "mirror_floor", "split": "train", "game": "mirror_floor", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Mirror Floor as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to jump from a platform and hold to speed up.\nActions 0–4 release. Collecting a coin flips gravity and\nmoves the player to their reflection across the platform.\nCoins raise the score multiplier, and missed coins lower it.\nFalling out of the screen in the direction of gravity ends\nthe run.\n\nINPUT CHANNEL TABLE\nSix 10×10 channels show the player, reflection, platforms,\ncoins, mirrored coins, and gauges. The conversion uses\nrectangular collision bounds and four frames per action at\nfixed difficulty. The 400-action task clips scores to\n[0, 200] and divides by 200.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/mirror_floor.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Floor:\n x: float\n y: float\n width: float\n\n\nclass MirrorFloorEnvironment:\n score_cap = 200\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.floors = [Floor(10, 50, 80)]\n self.coins = [(60, 47)]\n self.distance = 0.0\n self.y, self.mirror_y, self.vy, self.speed = 10.0, 0.0, 0.0, 1.0\n self.side = self.multiplier = 1\n self.steps = 0\n self.airborne = True\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n scroll = 0.5 * self.speed\n if tap and not self.airborne:\n self.vy = -1.5 * self.side\n self.airborne = True\n if self.airborne:\n self.vy += 0.07 * self.side\n self.y += self.vy\n self.speed += (2 - self.speed) * 0.05 if self.pressed else (1 - self.speed) * 0.2\n self.terminal = (self.y < 0 and self.side == -1) or (self.y > 99 and self.side == 1)\n if self.terminal:\n return 0\n self.distance -= scroll\n if self.distance < 0:\n floor = Floor(100, self.random.uniform(10, 90), self.random.uniform(45, 75))\n self.floors.append(floor)\n x = self.random.uniform(20, 25)\n while x < floor.width - 20:\n self.coins.append((100 + x, floor.y - 3))\n x += self.random.uniform(15, 30)\n self.distance += floor.width + self.random.uniform(10, 20)\n supported = False\n for floor in self.floors:\n floor.x -= scroll\n if floor.x - 3 < 9 < floor.x + floor.width + 3:\n supported = True\n if floor.y - 3 < self.y < floor.y + 5 and self.vy * self.side > 0:\n self.airborne = False\n self.y = floor.y + (-3 if self.side == 1 else 5)\n self.mirror_y = 2 * floor.y - self.y + 2\n self.floors = [floor for floor in self.floors if floor.x + floor.width >= 0]\n if not supported:\n self.airborne = True\n reward = 0\n remaining = []\n for x, y in self.coins:\n x -= scroll\n if abs(x - 9) < 5 and (abs(y - self.y) < 5 or (supported and abs(y - self.mirror_y) < 5)):\n reward += self.multiplier\n self.multiplier += 1\n self.side *= -1\n self.vy *= -1\n self.y = self.mirror_y\n elif x < -3:\n self.multiplier = max(1, self.multiplier - 1)\n else:\n remaining.append((x, y))\n self.coins = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for y, channel in ((self.y, 0), (self.mirror_y, 1)):\n if 0 <= y < 100:\n state[int(y // 10), 0, channel] = True\n for floor in self.floors:\n left = max(0, int(floor.x // 10))\n right = min(9, int((floor.x + floor.width) // 10))\n if left <= right:\n state[int(floor.y // 10), left:right + 1, 2] = True\n for x, y in self.coins:\n if 0 <= x < 100:\n state[int(y // 10), int(x // 10), 3] = True\n state[int((y + 8) // 10), int(x // 10), 4] = True\n values = (self.steps, min(511, self.multiplier), round(self.speed * 100),\n min(511, max(0, round((self.vy + 6) * 40))))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :3, 5] = self.pressed, self.airborne, self.side == 1\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 227, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/mirror_floor.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/mirrorfloor/main.js"} +{"name": "pulse_piper", "split": "train", "game": "pulse_piper", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Pulse Piper as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to charge and spread the two pulses apart. Actions 0–4\nrelease. The pulse moves right automatically and wraps at the edge.\nRelease as you pass a red dot to collect it for the stored charge.\nPurple obstacles destroy the pulse on contact, except on the release\nframe. Adjust the charge to fit the gap or clear a short obstacle.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the pulse, discharge, dots, short\nobstacles, tall walls, and counters. The port fixes difficulty at one\nand checks direct rectangle overlap between the pulse and obstacles.\nEach action advances up to four frames over a 400-action horizon.\nClip the episode score to [0, 1000] and divide by 1000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/pulse_piper.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Obstacle:\n x: float\n width: float\n height: float\n gap: float\n dot: bool\n\n\nclass PulsePiperEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x = 10.0\n self.charge = self.steps = self.spawn_timer = 0\n self.held = self.released = self.terminal = False\n self.obstacles = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance(held)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, held):\n self.x += 0.7\n if self.x > 100:\n self.x = 0\n self.released = self.held and not held\n discharge = self.charge if self.released else 0\n self.held = held\n self.charge = min(99, self.charge + 1) if held else 0\n offset = 2 + self.charge / 2\n reward = 0\n remaining = []\n for obstacle in self.obstacles:\n obstacle.x -= 0.5\n overlap = (\n abs(obstacle.x - self.x) < 4 + obstacle.width / 2\n and offset + 2 > obstacle.gap\n and offset - 2 < obstacle.gap + obstacle.height\n )\n if overlap and obstacle.dot and self.released:\n reward += discharge\n continue\n if overlap and not obstacle.dot and not self.released:\n self.terminal = True\n if obstacle.x + obstacle.width / 3 >= 0:\n remaining.append(obstacle)\n self.obstacles = remaining\n if self.spawn_timer == 0:\n self._spawn()\n self.spawn_timer = 60\n self.spawn_timer -= 1\n return reward\n\n def _spawn(self):\n dot = self.random.random() < 0.7\n wall = self.random.random() < 0.3\n if dot:\n self.obstacles.append(Obstacle(102, 4, 2, 0, True))\n else:\n close = not wall and self.x < 40 and self.random.random() < 0.65\n gap = 0 if close else self.random.uniform(10, 20)\n self.obstacles.append(Obstacle(104.5, 9, 50 if wall else 4, gap, False))\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n rows, cols = np.ogrid[:100:10, :100:10]\n for obstacle in self.obstacles:\n horizontal = (cols < obstacle.x + obstacle.width / 2) & (cols + 10 > obstacle.x - obstacle.width / 2)\n top = (rows < 50 - obstacle.gap) & (rows + 10 > 50 - obstacle.gap - obstacle.height)\n bottom = (rows < 50 + obstacle.gap + obstacle.height) & (rows + 10 > 50 + obstacle.gap)\n channel = 2 if obstacle.dot else 3 if obstacle.height < 50 else 4\n state[:, :, channel] |= horizontal & (top | bottom)\n offset = 2 + self.charge / 2\n for y in (50 - offset, 50 + offset):\n state[int(np.clip(y // 10, 0, 9)), min(9, int(self.x // 10)), int(self.released)] = True\n for row, value in enumerate((self.charge, self.spawn_timer, self.steps, self.held)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 228, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pulse_piper.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePulsePiper.c"} +{"name": "robot_tank", "split": "train", "game": "robot_tank", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Robot Tank as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves first-person tank maneuvering, 16-direction aiming, radar-relative\nenemy tracking, forward and reverse range control, cannon fire, interceptable enemy rockets,\nfour persistent damage systems (video, cannon, radar, and treads), changing visibility and\nweather, one active tank plus three reserves, squadron reinforcements, twelve enemies per\nsquadron, and the finite twelve-squadron mission.\n\nACTION MAPPING\n0: hold position\n1: turn left\n2: advance\n3: turn right\n4: retreat\n5: fire cannon or intercept aligned rocket\n\nINPUT CHANNEL TABLE\n0: player tank at radar center\n1: enemy radar/video returns and enemy rocket\n2: reserved for objectives\n3: cannon shot\n4: previous enemy radar return\n5: damage and exact heading, enemy pose, kills, reserves, clock, weather, and rocket range\n\nSCORING, TERMINATION, AND HORIZON\nThe manual scores one destroyed-tank marker per enemy and ends the mission after twelve\n12-tank squadrons. Therefore `score_cap = 12 × 12 = 144`. Normalization is\n`min(max(raw_score, 0), 144) / 144`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/robot_tank.py`):\n```python\nimport math\n\nimport numpy as np\n\n\nWEATHER = (\"clear\", \"fog\", \"rain\", \"snow\")\nSYSTEMS = (\"video\", \"cannon\", \"radar\", \"treads\")\n\n\nclass RobotTankEnvironment:\n \"\"\"Twelve first-person squadrons with radar, weather, and system damage.\"\"\"\n\n score_cap = 144.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 5_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.score = 0.0\n self.kills = 0\n self.reserves = 3\n self.steps = 0\n self.last_action = 0\n self.heading = 0\n self.previous_heading = 0\n self.damage: set[str] = set()\n self.rocket_distance: int | None = None\n self.shot_timer = 0\n self.terminal = False\n self._spawn_enemy()\n\n @property\n def squadron(self) -> int:\n return self.kills // 12\n\n @property\n def weather(self) -> str:\n return WEATHER[(self.squadron + self.steps // 240) % len(WEATHER)]\n\n @property\n def relative_bearing(self) -> int:\n return (self.enemy_bearing - self.heading + 8) % 16 - 8\n\n def _spawn_enemy(self) -> None:\n self.enemy_bearing = int(self.random.randint(16))\n self.previous_enemy_bearing = self.enemy_bearing\n self.enemy_distance = 5 + int(self.random.randint(4))\n self.previous_enemy_distance = self.enemy_distance\n self.rocket_distance = None\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_heading = self.heading\n self.previous_enemy_bearing = self.enemy_bearing\n self.previous_enemy_distance = self.enemy_distance\n movement_allowed = \"treads\" not in self.damage or self.steps % 3 == 0\n weather_allows_movement = self.weather != \"rain\" or self.steps % 2 == 0\n if action == 1 and movement_allowed:\n self.heading = (self.heading - 1) % 16\n elif action == 3 and movement_allowed:\n self.heading = (self.heading + 1) % 16\n elif action == 2 and movement_allowed and weather_allows_movement:\n self.enemy_distance = max(1, self.enemy_distance - 1)\n elif action == 4 and movement_allowed and weather_allows_movement:\n self.enemy_distance = min(9, self.enemy_distance + 1)\n reward = self._fire() if action == 5 else 0.0\n if reward == 0.0:\n self._enemy_turn()\n self._advance_rocket()\n self.score += reward\n self.steps += 1\n self.shot_timer = max(0, self.shot_timer - 1)\n if self.kills >= 144 or self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _fire(self) -> float:\n if \"cannon\" in self.damage and self.random.rand() < 0.5:\n return 0.0\n self.shot_timer = 2\n if self.rocket_distance is not None and abs(self.relative_bearing) <= 1:\n self.rocket_distance = None\n return 0.0\n if abs(self.relative_bearing) > 1:\n return 0.0\n self.kills += 1\n if self.kills % 12 == 0:\n self.reserves = min(12, self.reserves + 1)\n if self.kills < 144:\n self._spawn_enemy()\n return 1.0\n\n def _enemy_turn(self) -> None:\n if self.steps % max(2, 5 - self.squadron // 4) == 0:\n turn = int(np.sign((self.heading - self.enemy_bearing + 8) % 16 - 8))\n self.enemy_bearing = (self.enemy_bearing + turn) % 16\n if self.steps % 4 == 0:\n self.enemy_distance = max(1, self.enemy_distance - 1)\n if (\n self.rocket_distance is None\n and abs(self.relative_bearing) <= 1\n and self.enemy_distance <= 6\n and self.steps % max(5, 11 - self.squadron // 2) == 0\n ):\n self.rocket_distance = self.enemy_distance\n\n def _advance_rocket(self) -> None:\n if self.rocket_distance is None:\n return\n self.rocket_distance -= 1\n if self.rocket_distance > 0:\n return\n self.rocket_distance = None\n self._take_hit()\n\n def _take_hit(self) -> None:\n undamaged = [system for system in SYSTEMS if system not in self.damage]\n if undamaged:\n self.damage.add(undamaged[int(self.random.randint(len(undamaged)))])\n return\n if self.reserves == 0:\n self.terminal = True\n return\n self.reserves -= 1\n self.damage.clear()\n self.heading = 0\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[5, 5, 0] = True\n angle = self.relative_bearing * math.pi / 8\n radius = min(4, max(1, self.enemy_distance // 2))\n radar_row = int(round(5 - math.cos(angle) * radius))\n radar_column = int(round(5 + math.sin(angle) * radius))\n state[radar_row, radar_column, 1] = True\n previous_relative = (self.previous_enemy_bearing - self.previous_heading + 8) % 16 - 8\n previous_angle = previous_relative * math.pi / 8\n previous_radius = min(4, max(1, self.previous_enemy_distance // 2))\n previous_row = int(round(5 - math.cos(previous_angle) * previous_radius))\n previous_column = int(round(5 + math.sin(previous_angle) * previous_radius))\n state[previous_row, previous_column, 4] = True\n hour = (self.steps // 10) % 24\n visible = 5 <= hour < 20 and self.weather != \"fog\" and not (\n \"video\" in self.damage and self.steps % 4 < 2\n )\n if visible and abs(self.relative_bearing) <= 2:\n width = max(1, 4 - self.enemy_distance // 3)\n state[2:5, 5 - width : 6 + width, 1] = True\n if self.rocket_distance is not None:\n state[min(9, 4 + self.rocket_distance), 5, 1] = True\n if self.shot_timer > 0:\n state[4, 5, 3] = True\n for index, system in enumerate(SYSTEMS):\n state[0, index, 5] = system in self.damage\n values = (\n (self.heading, 4),\n (self.enemy_bearing, 4),\n (self.enemy_distance, 4),\n (self.kills, 8),\n (self.reserves, 4),\n (self.steps % 240, 8),\n (WEATHER.index(self.weather), 2),\n )\n offset = 4\n for value, width in values:\n for bit in range(width):\n index = offset + bit\n state[index // 10, index % 10, 5] = bool(value & (1 << bit))\n offset += width\n if self.rocket_distance is not None:\n for bit in range(4):\n index = offset + bit\n state[index // 10, index % 10, 5] = bool(self.rocket_distance & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 229, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/robot_tank.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "jujump", "split": "train", "game": "jujump", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Jujump as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to jump. Each tap alternates horizontal direction\nand uses some jump power. Holding reduces gravity. Actions 0–4\nrelease the button. Touching a platform restores full jump\npower. Falling below the screen ends the run.\n\nINPUT CHANNEL TABLE\nThe score is the accumulated scroll distance. Climbing above\nthe scroll line makes the screen move faster. The six 10×10\nchannels show the player, platforms, projected position, next\njump direction, scroll line, and gauges.\n\nSCORING, TERMINATION, AND HORIZON\nThe conversion runs at fixed difficulty for four frames per\naction, up to 400 actions. Raw scores are clipped to [0, 600]\nand divided by 600.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/jujump.py`):\n```python\nimport numpy as np\n\n\nclass JujumpEnvironment:\n score_cap = 600\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x = self.y = 50.0\n self.vx = self.vy = 0.0\n self.direction = 1\n self.power = self.spawn_distance = 1.0\n self.platforms = [(50.0, 70.0)]\n self.steps = 0\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tapped = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0.0\n for frame in range(4):\n reward += self._advance(tapped and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _advance(self, tapped: bool) -> float:\n self.x += self.vx\n self.y += self.vy\n self.vy += 0.05 if self.pressed else 0.1\n scroll = max(0, 30 - self.y) * 0.1 + 0.1\n self.spawn_distance -= scroll\n if self.spawn_distance < 0:\n self.spawn_distance = self.random.uniform(0, 99)\n self.platforms.append((self.random.uniform(0, 99), -9))\n self.y += scroll\n self.platforms = [(x, y + scroll) for x, y in self.platforms if y + scroll < 99]\n while any(abs(self.x - x) < 20 and abs(self.y - y) < 7 for x, y in self.platforms):\n self.y -= 1\n self.vx = self.vy = 0\n self.power = 1\n if tapped:\n self.direction *= -1\n self.vx = self.direction\n self.vy = -3 * self.power\n self.power *= 0.7\n self.terminal = self.y > 99\n return scroll\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for x, y, channel in ((self.x, self.y, 0), (self.x + 4 * self.vx, self.y + 4 * self.vy, 2),\n (self.x - 10 * self.direction, self.y - 10 * self.power, 3)):\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y) // 10, int(x) // 10, channel] = True\n for x, y in self.platforms:\n if 0 <= y < 100:\n left = max(0, int((x - 16.5) // 10))\n right = min(9, int((x + 16.5) // 10))\n state[int(y) // 10, left:right + 1, 1] = True\n state[3, :, 4] = True\n values = (self.steps, round(self.power * 400), min(511, max(0, round((self.vy + 3) * 40))))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 230, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/jujump.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/jujump/main.js"} +{"name": "berzerk", "split": "train", "game": "berzerk", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Berzerk as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves *Berzerk*'s fight-or-flight room loop using the manual's hard-style\nrules: armed robots, an invincible Evil Otto, electrified maze walls, and no bonus lives. Four\nrooms rotate one interior wall plan while preserving exits at the center of each boundary. The\nhumanoid may leave through any opening before clearing the room, permanently forfeiting its\nremaining targets and clear bonus.\n\nActions 1–4 move through the maze and set the laser aim direction; action 5 fires along the most\nrecent movement direction. Only one humanoid laser can be active. Robots move directly toward the\nplayer, shoot in eight directions, collide with walls and one another, and can be destroyed by\nrobot crossfire. Every robot death scores for the player regardless of cause, matching the manual.\nTouching a robot, robot fire, an electrified wall, or Evil Otto costs one of three lives. Otto\nappears after 40 room steps, ignores walls, destroys robots for player credit, and cannot be shot.\n\nACTION MAPPING\n0: wait\n1: move/aim left\n2: move/aim up\n3: move/aim right\n4: move/aim down\n5: fire in facing direction\n\nINPUT CHANNEL TABLE\n0: humanoid\n1: robots, robot lasers, and Evil Otto\n2: score-bearing robot targets\n3: humanoid laser\n4: previous humanoid and robot positions\n5: electrified walls, aim, lives, and room\n\nSCORING, TERMINATION, AND HORIZON\nEach room contains five robots worth 50 points. Clearing all five adds the manual's 10 points per\nstarting robot, or 50 more. Across four rooms, `score_cap = 4×(5×50 + 5×10) = 1,200`.\nCrossfire, wall collision, and Otto kills remove the same finite robot identities and cannot add\nextra targets. Normalization is `min(max(raw_score, 0), 1200) / 1200`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/berzerk.py`):\n```python\nimport numpy as np\n\n\nDELTAS = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}\nOPENINGS = {(0, 5), (9, 5), (5, 0), (5, 9)}\nBASE_INTERIOR = {(2, 2), (2, 3), (2, 4), (4, 7), (5, 7), (6, 7), (7, 2), (7, 3)}\nSPAWN_CANDIDATES = ((1, 1), (1, 8), (4, 4), (7, 7), (8, 1), (3, 8), (6, 2))\n\n\ndef room_walls(room: int) -> set[tuple[int, int]]:\n boundary = {\n (row, column)\n for row in range(10)\n for column in range(10)\n if row in (0, 9) or column in (0, 9)\n } - OPENINGS\n interior = BASE_INTERIOR\n for _ in range(room):\n interior = {(column, 9 - row) for row, column in interior}\n return boundary | interior\n\n\nclass BerzerkEnvironment:\n \"\"\"Four electrified mazes with robot crossfire and invincible Evil Otto pressure.\"\"\"\n\n score_cap = 1_200.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 1_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.room = 0\n self.lives = 3\n self.steps = 0\n self.last_action = 0\n self.death_this_step = False\n self.terminal = False\n self._start_room([9, 5])\n\n def _start_room(self, entry: list[int]) -> None:\n self.walls = room_walls(self.room)\n self.player = entry.copy()\n self.previous_player = self.player.copy()\n self.aim = 2\n available = [position for position in SPAWN_CANDIDATES if position not in self.walls and list(position) != self.player]\n self.robots = [list(position) for position in available[:5]]\n self.previous_robots = [robot.copy() for robot in self.robots]\n self.player_shot: list[int] | None = None\n self.robot_shots: list[list[int]] = []\n self.otto: list[int] | None = None\n self.room_steps = 0\n self.clear_bonus_awarded = False\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.death_this_step = False\n self.previous_player = self.player.copy()\n if action in DELTAS:\n self.aim = action\n if self._move_player(action):\n self.steps += 1\n return 0.0, self.terminal\n elif action == 5 and self.player_shot is None:\n row_delta, column_delta = DELTAS[self.aim]\n self.player_shot = [self.player[0], self.player[1], row_delta, column_delta, 8]\n\n self.previous_robots = [robot.copy() for robot in self.robots]\n reward = self._move_robots()\n self._move_shots()\n reward += self._resolve_player_shot()\n reward += self._resolve_robot_shots()\n self._spawn_and_move_otto()\n reward += self._resolve_otto()\n if not self.robots and not self.clear_bonus_awarded:\n reward += 50.0\n self.clear_bonus_awarded = True\n self.room_steps += 1\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_player(self, action: int) -> bool:\n row_delta, column_delta = DELTAS[action]\n target = [self.player[0] + row_delta, self.player[1] + column_delta]\n if not (0 <= target[0] < 10 and 0 <= target[1] < 10):\n if tuple(self.player) in OPENINGS:\n self.room += 1\n if self.room == 4:\n self.terminal = True\n else:\n opposite = {1: [5, 9], 2: [9, 5], 3: [5, 0], 4: [0, 5]}[action]\n self._start_room(opposite)\n return True\n return False\n if tuple(target) in self.walls:\n self._lose_life()\n elif target in self.robots or target == self.otto:\n self._lose_life()\n else:\n self.player = target\n return False\n\n def _move_robots(self) -> float:\n if self.room_steps % 2 != 0:\n return 0.0\n reward = 0.0\n for robot in self.robots.copy():\n row_delta = int(np.sign(self.player[0] - robot[0]))\n column_delta = int(np.sign(self.player[1] - robot[1]))\n target = [robot[0] + row_delta, robot[1] + column_delta]\n if tuple(target) in self.walls:\n if robot in self.robots:\n self.robots.remove(robot)\n reward += 50.0\n elif target in self.robots:\n if robot in self.robots:\n self.robots.remove(robot)\n reward += 50.0\n if target in self.robots:\n self.robots.remove(target)\n reward += 50.0\n elif target == self.player:\n self._lose_life()\n elif robot in self.robots:\n robot[:] = target\n if self.room_steps % 8 == 0:\n for robot in self.robots:\n row_delta = int(np.sign(self.player[0] - robot[0]))\n column_delta = int(np.sign(self.player[1] - robot[1]))\n self.robot_shots.append([robot[0], robot[1], row_delta, column_delta, 8])\n return reward\n\n def _move_shots(self) -> None:\n if self.player_shot is not None:\n self.player_shot[0] += self.player_shot[2]\n self.player_shot[1] += self.player_shot[3]\n self.player_shot[4] -= 1\n if (\n self.player_shot[4] <= 0\n or not (0 <= self.player_shot[0] < 10 and 0 <= self.player_shot[1] < 10)\n or tuple(self.player_shot[:2]) in self.walls\n ):\n self.player_shot = None\n remaining = []\n for shot in self.robot_shots:\n shot[0] += shot[2]\n shot[1] += shot[3]\n shot[4] -= 1\n if shot[4] > 0 and 0 <= shot[0] < 10 and 0 <= shot[1] < 10 and tuple(shot[:2]) not in self.walls:\n remaining.append(shot)\n self.robot_shots = remaining\n\n def _resolve_player_shot(self) -> float:\n if self.player_shot is None:\n return 0.0\n hit = next((robot for robot in self.robots if robot == self.player_shot[:2]), None)\n if hit is None:\n return 0.0\n self.robots.remove(hit)\n self.player_shot = None\n return 50.0\n\n def _resolve_robot_shots(self) -> float:\n reward = 0.0\n remaining = []\n for shot in self.robot_shots:\n hit = next((robot for robot in self.robots if robot == shot[:2]), None)\n if hit is not None:\n self.robots.remove(hit)\n reward += 50.0\n elif shot[:2] == self.player:\n self._lose_life()\n else:\n remaining.append(shot)\n self.robot_shots = remaining\n return reward\n\n def _spawn_and_move_otto(self) -> None:\n if self.otto is None and self.room_steps >= 40:\n self.otto = [9, 5]\n if self.otto is None or self.room_steps % 2 != 0:\n return\n self.otto[0] += int(np.sign(self.player[0] - self.otto[0]))\n self.otto[1] += int(np.sign(self.player[1] - self.otto[1]))\n\n def _resolve_otto(self) -> float:\n if self.otto is None:\n return 0.0\n reward = 0.0\n hit = next((robot for robot in self.robots if robot == self.otto), None)\n if hit is not None:\n self.robots.remove(hit)\n reward += 50.0\n if self.otto == self.player:\n self._lose_life()\n return reward\n\n def _lose_life(self) -> None:\n if self.death_this_step:\n return\n self.death_this_step = True\n self.lives -= 1\n self.player = [9, 5]\n self.previous_player = self.player.copy()\n self.player_shot = None\n self.robot_shots.clear()\n if self.lives <= 0:\n self.terminal = True\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n for robot in self.robots:\n state[*robot, 1] = True\n state[*robot, 2] = True\n for shot in self.robot_shots:\n state[shot[0], shot[1], 1] = True\n if self.otto is not None:\n state[*self.otto, 1] = True\n if self.player_shot is not None:\n state[self.player_shot[0], self.player_shot[1], 3] = True\n state[*self.previous_player, 4] = True\n for robot in self.previous_robots:\n state[*robot, 4] = True\n for wall in self.walls:\n state[*wall, 5] = True\n state[9, : self.lives, 5] = True\n state[8, : self.room + 1, 5] = True\n state[7, self.aim, 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 231, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/berzerk.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "regene", "split": "train", "game": "regene", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Regene as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nMove the eraser with actions 1 (left), 2 (up), 3 (right), and 4 (down).\nActions 0 and 5 hold position. Move over a wall tile to erase it or\nover a seed tile to release another ball. Erasing beyond nine tiles\nrestores the oldest erased tile. Moving the eraser near the right edge\nspeeds up scrolling.\n\nA ball's first bounce in a collision streak scores the current number\nof balls. Ten consecutive collision frames destroy the ball. The\nepisode ends when no balls remain.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the eraser, walls, seeds, balls, the next\ntile to regenerate when the erase buffer is full, and counters.\nThe conversion replaces pointer movement with fixed-speed directional\nactions and uses fixed difficulty. Each action advances up to four\nframes over a 400-action horizon. Clip the episode score to [0, 1000]\nand divide by 1000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/regene.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, pi, sin, sqrt\n\nimport numpy as np\n\n\n@dataclass\nclass Tile:\n x: float\n y: float\n seed: bool = False\n\n\n@dataclass\nclass Ball:\n x: float\n y: float\n vx: float\n vy: float\n hits: int = 0\n\n\nclass RegeneEnvironment:\n score_cap = 1000\n moves = ((0, 0), (-1, 0), (0, -1), (1, 0), (0, 1), (0, 0))\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x = self.y = 50\n self.steps = self.action = 0\n self.distance = 0.0\n self.terminal = False\n self.tiles = []\n self.erased = []\n self.balls = [self._ball(20, 50)]\n\n def _ball(self, x, y):\n angle = self.random.uniform(-0.1, 0.1) * pi + self.random.choice((-1, 1)) * 0.7 * pi\n return Ball(x, y, cos(angle), sin(angle))\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _spawn(self, population):\n width = self.random.integers(3, 7)\n gap = 0 if self.random.random() < 0.4 else self.random.integers(2, 6)\n top = int(gap + self.random.random() * (8 - 2 * gap))\n for col in range(width):\n for row in range(8):\n if not top <= row < top + gap:\n self.tiles.append(Tile(105 + col * 10 - self.distance, 15 + row * 10,\n self.random.random() < 0.1 / population))\n self.distance += (width + self.random.integers(3)) * 10\n\n def _advance(self):\n dx, dy = self.moves[self.action]\n self.x = min(99, max(0, self.x + 3 * dx))\n self.y = min(99, max(0, self.y + 3 * dy))\n population = sqrt(len(self.balls))\n scroll = 0.05 * (population + max(0, self.x - 90))\n self.distance -= scroll\n if self.distance < 0:\n self._spawn(population)\n for tile in self.erased:\n tile.x -= scroll\n self.erased = [tile for tile in self.erased if tile.x >= 14]\n remaining = []\n for tile in self.tiles:\n tile.x -= scroll\n reach = 5.5 if tile.seed else 6.5\n if abs(tile.x - self.x) < reach and abs(tile.y - self.y) < reach:\n if not tile.seed:\n self.erased.append(tile)\n continue\n if tile.x < 97:\n self.balls.append(self._ball(tile.x, tile.y))\n continue\n if tile.x >= (13 if tile.seed else 14):\n remaining.append(tile)\n overflow = max(0, len(self.erased) - 9)\n restored = self.erased[:overflow]\n solids = [(tile.x, tile.y) for tile in remaining if not tile.seed]\n self.tiles = remaining + restored\n self.erased = self.erased[overflow:]\n reward = 0\n survivors = []\n for ball in self.balls:\n ball.x -= scroll\n hit_x = self._blocked(ball.x + ball.vx, ball.y, solids)\n hit_y = self._blocked(ball.x, ball.y + ball.vy, solids)\n if hit_x:\n ball.vx *= -1\n ball.x += 2 * ball.vx\n if hit_y:\n ball.vy *= -1\n ball.y += 2 * ball.vy\n if ball.x < 14:\n ball.x = 14\n ball.vx = abs(ball.vx)\n if hit_x or hit_y:\n if not ball.hits:\n reward += len(self.balls)\n ball.hits += 1\n else:\n ball.hits = 0\n if ball.hits <= 9:\n ball.x += ball.vx\n ball.y += ball.vy\n survivors.append(ball)\n self.balls = survivors\n self.terminal = not survivors\n return reward\n\n @staticmethod\n def _blocked(x, y, solids):\n return x < 13 or x > 97 or y < 13 or y > 87 or any(\n abs(x - sx) < 7 and abs(y - sy) < 7 for sx, sy in solids\n )\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[self.y // 10, self.x // 10, 0] = True\n for tile in self.tiles:\n if 0 <= tile.x < 100:\n state[int(tile.y // 10), int(tile.x // 10), 1 + int(tile.seed)] = True\n for ball in self.balls:\n x = int(np.clip(ball.x // 10, 0, 9))\n y = int(np.clip(ball.y // 10, 0, 9))\n state[y, x, 3] = True\n if len(self.erased) == 9:\n oldest = self.erased[0]\n if 0 <= oldest.x < 100:\n state[int(oldest.y // 10), int(oldest.x // 10), 4] = True\n for row, value in enumerate((self.steps, len(self.erased), self.action)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 232, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/regene.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/regene/main.js"} +{"name": "quantum_leaper", "split": "train", "game": "quantum_leaper", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Quantum Leaper as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to change lanes. Actions 0–4 release. A tap moves you\none lane in the direction of the current wave displacement, wrapping\nat the ends. At each half-wave crossing, being in the gold lane scores\nthe current multiplier and increases it. Crossing elsewhere lowers it\nby one, to a minimum of one. Antiparticle contact ends the episode.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the player, antiparticles, gold lane,\ncurrent lane, next tap destination, and counters. The port fixes\ndifficulty at one and uses rectangular collision bounds. Each action\nadvances up to four frames, with a 400-action horizon. Clip episode\nscores to [0, 500] and divide by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/quantum_leaper.py`):\n```python\nfrom math import pi, sin\n\nimport numpy as np\n\n\nLANES = (20, 37.5, 55, 72.5, 90)\n\n\nclass QuantumLeaperEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.lane = self.gold = 2\n self.y = 50.0\n self.steps = self.frames = self.crossings = 0\n self.multiplier = 1\n self.gold_timer = 300\n self.held = self.terminal = False\n self.particles = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n self.frames += 1\n phase = self.frames / 10\n displacement = sin(phase) * 10\n reward = 0\n if phase >= self.crossings * pi:\n self.crossings += 1\n if self.lane == self.gold:\n reward = self.multiplier\n self.multiplier = min(99, self.multiplier + 1)\n else:\n self.multiplier = max(1, self.multiplier - 1)\n self.y = LANES[self.lane] + displacement\n if tap:\n self.lane = (self.lane + (1 if displacement > 0 else -1)) % len(LANES)\n self.gold_timer -= 1\n if self.gold_timer < 0:\n self.gold = self.random.integers(len(LANES))\n self.gold_timer += 300\n self.particles = [(x - 1, lane) for x, lane in self.particles if x >= 1]\n self.terminal = any(abs(x - 20) < 3.5 and abs(LANES[lane] - self.y) < 3.5\n for x, lane in self.particles)\n if self.random.random() < 0.02:\n self.particles.append((103, self.random.integers(len(LANES))))\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, int(self.y // 10)), 2, 0] = True\n for x, lane in self.particles:\n if x < 100:\n state[int(LANES[lane] // 10), int(x // 10), 1] = True\n state[int(LANES[self.gold] // 10), :, 2] = True\n state[int(LANES[self.lane] // 10), 2, 3] = True\n next_lane = (self.lane + (1 if sin((self.frames + 1) / 10) > 0 else -1)) % len(LANES)\n state[int(LANES[next_lane] // 10), 2, 4] = True\n for row, value in enumerate((self.steps, self.multiplier, self.gold_timer, self.held)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 233, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/quantum_leaper.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameQuantumLeaper.c"} +{"name": "ghost_hop", "split": "train", "game": "ghost_hop", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Ghost Hop as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to jump to the next of five drifting platforms.\nActions 0–4 release the button. Bullets aim at the currently\noccupied platform when they spawn and are lethal during jumps.\nLandings award the integer part of the multiplier and double\nit. The multiplier decays toward one between landings and\nis capped at 256.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, platforms, destination,\nbullets, projected bullet positions, and gauges. Each action\nadvances four frames at fixed difficulty. Bullet collisions\nuse fixed rectangular hitboxes.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action task clips raw scores to [0, 4000] and divides\nby 4000. Tapping once every four actions across 100 seeds with\nsticky actions disabled averaged 636.03 raw points and peaked\nat 4010.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/ghost_hop.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Mover:\n x: float\n y: float\n vx: float\n vy: float\n\n\nclass GhostHopEnvironment:\n score_cap = 4000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.targets = [\n Mover(20 + i % 3 * 30, 25 + i // 3 * 40, *self.random.uniform(-0.2, 0.2, 2))\n for i in range(5)\n ]\n self.index = 2\n self.x, self.y = 80, 25\n self.origin = (self.x, self.y)\n self.flight = self.steps = self.frames = 0\n self.multiplier = 1.0\n self.pressed = self.terminal = False\n self.bullets: list[Mover] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap: bool) -> int:\n current = self.targets[self.index]\n if self.frames % 50 == 0:\n offset = self.random.uniform(0, 100)\n side = self.random.integers(4)\n x, y = ((-5, offset), (105, offset), (offset, -5), (offset, 105))[side]\n angle = math.atan2(current.y - y, current.x - x)\n self.bullets.append(Mover(x, y, 0.5 * math.cos(angle), 0.5 * math.sin(angle)))\n self.frames += 1\n if tap and not self.flight:\n self.origin = (current.x, current.y)\n self.flight = 13\n for target in self.targets:\n target.x += target.vx\n target.y += target.vy\n if not 15 <= target.x <= 85:\n target.x = min(85, max(15, target.x))\n target.vx *= -1\n if not 15 <= target.y <= 85:\n target.y = min(85, max(15, target.y))\n target.vy *= -1\n reward = 0\n airborne = self.flight > 0\n if airborne:\n destination = (self.index + 1) % len(self.targets)\n target = self.targets[destination]\n self.flight -= 1\n fraction = (13 - self.flight) * 0.08\n self.x = self.origin[0] + (target.x - self.origin[0]) * fraction\n self.y = self.origin[1] + (target.y - self.origin[1]) * fraction\n if not self.flight:\n self.index = destination\n reward = int(self.multiplier)\n self.multiplier *= 2\n else:\n self.x, self.y = current.x, current.y\n for bullet in self.bullets:\n bullet.x += bullet.vx\n bullet.y += bullet.vy\n if airborne and abs(bullet.x - self.x) < 4 and abs(bullet.y - self.y) < 4:\n self.terminal = True\n self.bullets = [b for b in self.bullets if -10 <= b.x <= 110 and -10 <= b.y <= 110]\n self.multiplier = min(256, max(1, self.multiplier * 0.99))\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(self.y) // 10, int(self.x) // 10, 0] = True\n destination = (self.index + 1) % len(self.targets)\n for index, target in enumerate(self.targets):\n state[int(target.y) // 10, int(target.x) // 10, 2 if index == destination else 1] = True\n for bullet in self.bullets:\n if 0 <= bullet.x < 100 and 0 <= bullet.y < 100:\n row, col = int(bullet.y) // 10, int(bullet.x) // 10\n state[row, col, 3] = True\n state[min(9, max(0, int(bullet.y + 10 * bullet.vy) // 10)),\n min(9, max(0, int(bullet.x + 10 * bullet.vx) // 10)), 4] = True\n for row, value in enumerate((self.steps, self.flight, int(self.multiplier))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 234, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/ghost_hop.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameGhostHop.c"} +{"name": "rebirth", "split": "train", "game": "rebirth", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Rebirth as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to jump. Tap again in midair to dive. Actions 0–4\nrelease, which increases gravity during a jump. The runner drifts\noutward while on the ground. Hitting an incoming vehicle knocks\nthe runner into the opposite world and reduces the multiplier.\nCollect every diamond before it reaches the divider. Each diamond\nscores the current multiplier and increases it by one.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the runner, vehicles, diamonds,\nworld terrain, the runner's horizontal target, and counters.\nThe port uses fixed difficulty and rectangular collision bounds.\nEach action advances up to four frames over a 400-action horizon.\nClip episode scores to [0, 60] and divide by 60.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/rebirth.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Arrival:\n x: float\n world: int\n y: float = 37\n\n\nclass RebirthEnvironment:\n score_cap = 60\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y, self.offset = 110.0, 37.0, 10.0\n self.vx = self.vy = 0.0\n self.world = self.track_world = self.diamond_world = 1\n self.track_timer = self.steps = 0\n self.diamond_timer = 60\n self.diamond_count = self.multiplier = 1\n self.mode = \"run\"\n self.held = self.terminal = False\n self.tracks = []\n self.diamonds = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n self.track_timer -= 1\n if self.track_timer < 0:\n self.tracks.append(Arrival(100 + self.track_world * 103, self.track_world))\n self.track_world *= -1\n self.track_timer = self.random.uniform(50, 60)\n for track in self.tracks:\n track.x -= track.world\n self.tracks = [track for track in self.tracks if (track.x - 100) * track.world >= 3]\n\n self.x += self.vx\n self.y += self.vy\n self.vx *= 0.792\n self.vy *= 0.99\n if self.mode == \"run\":\n self.x += (100 + self.world * self.offset - self.x) * 0.05\n self.offset = min(80, self.offset + 0.3)\n if tap:\n self.mode, self.vy = \"jump\", -2\n else:\n jumping = self.mode == \"jump\"\n if jumping:\n self.vy += 0.07 if self.held else 0.14\n if self.y > 37:\n self.y, self.vy, self.mode = 37, 0, \"run\"\n if jumping and tap:\n self.mode, self.vy = \"land\", 4\n if abs(self.vx) < 2 and any(self._touches(track) for track in self.tracks):\n self.vx = -self.world * self.offset * 0.2\n self.world *= -1\n self.offset = 10\n self.multiplier = max(1, self.multiplier - 1)\n\n self.diamond_timer -= 1\n if self.diamond_timer < 0:\n self.diamond_count -= 1\n if self.diamond_count < 0:\n self.diamond_world *= -1\n self.diamond_count = int(self.random.integers(4))\n y = 37 if self.random.random() < 0.5 else self.random.uniform(20, 30)\n self.diamonds.append(Arrival(100 + self.diamond_world * 103, self.diamond_world, y))\n self.diamond_timer = self.random.uniform(120, 150)\n reward = 0\n remaining = []\n for diamond in self.diamonds:\n diamond.x -= diamond.world / 3\n if self._touches(diamond):\n reward += self.multiplier\n self.multiplier += 1\n else:\n self.terminal |= (diamond.x - 100) * diamond.world < 3\n remaining.append(diamond)\n self.diamonds = remaining\n return reward\n\n def _touches(self, arrival):\n return abs(arrival.x - self.x) < 5 and abs(arrival.y - self.y) < 5\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(np.clip(self.y // 5, 0, 9)), int(np.clip(self.x // 20, 0, 9)), 0] = True\n for channel, arrivals in ((1, self.tracks), (2, self.diamonds)):\n for arrival in arrivals:\n if 0 <= arrival.x < 200:\n state[int(arrival.y // 5), int(arrival.x // 20), channel] = True\n state[8:, 5:, 3] = True\n state[:8, :5, 3] = True\n target = 100 + self.world * self.offset\n state[7, int(target // 20), 4] = True\n gauges = (self.steps, self.multiplier, (\"run\", \"jump\", \"land\").index(self.mode),\n self.held, round((self.vy + 2) * 50))\n for row, value in enumerate(gauges):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 235, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/rebirth.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/rebirth/main.js"} +{"name": "ricochet_pins", "split": "train", "game": "ricochet_pins", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Ricochet Pins as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to shoot the nearest pin and recoil away from it.\nActions 0–4 release. Shots add heat, which increases the player's\ncollision radius. Overheating disables shots until heat drops to 30.\nContact with a pin ends the episode.\n\nEach pin scores the current multiplier. An item scores ten times\nthe multiplier and then raises it by one. Clearing a wave spawns\none more pin and scores twice the new wave size times the multiplier.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the player, stationary pins, moving\npins, the item, the shot trace, and counters. The port uses fixed\ndifficulty and preserves distance-based collisions. Each action\nadvances up to four frames over a 400-action horizon. Clip the\nepisode score to [0, 1000] and divide by 1000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/ricochet_pins.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Pin:\n position: np.ndarray\n velocity: np.ndarray\n\n\nclass RicochetPinsEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.position = np.full(2, 50.0)\n self.velocity = np.array([0.5, 0.0])\n self.steps = self.heat = self.shot_timer = 0\n self.pin_count = 5\n self.multiplier = 1\n self.held = self.overheated = self.terminal = False\n self.shot_target = None\n self._spawn_wave()\n\n def _spawn_wave(self):\n self.pins = []\n for _ in range(self.pin_count):\n for _ in range(50):\n position = self.random.uniform(15, 85, 2)\n if np.linalg.norm(position - self.position) > 30:\n break\n velocity = np.zeros(2)\n if self.random.random() < 0.4:\n velocity[self.random.integers(2)] = self.random.choice((-0.35, 0.35))\n self.pins.append(Pin(position, velocity))\n for _ in range(50):\n self.item = self.random.uniform(15, 85, 2)\n if np.linalg.norm(self.item - self.position) > 20 and all(\n np.linalg.norm(self.item - pin.position) >= 15 for pin in self.pins\n ):\n break\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n @staticmethod\n def _bounce(position, velocity, radius):\n crossed = (position < radius) | (position > 100 - radius)\n velocity[crossed] *= -1\n np.clip(position, radius, 100 - radius, out=position)\n\n def _advance(self, tap):\n self.position += self.velocity\n self.velocity *= 0.98\n self.heat = max(0, self.heat - 1)\n if self.heat <= 30:\n self.overheated = False\n radius = 3 * (1 + 0.008 * self.heat)\n self._bounce(self.position, self.velocity, radius)\n for pin in self.pins:\n pin.position += pin.velocity\n self._bounce(pin.position, pin.velocity, 3)\n distances = [np.linalg.norm(pin.position - self.position) for pin in self.pins]\n self.terminal = any(distance < radius + 3 for distance in distances)\n reward = 0\n if self.item is not None and np.linalg.norm(self.item - self.position) < 7:\n reward += 10 * self.multiplier\n self.multiplier += 1\n self.item = None\n self.shot_timer = max(0, self.shot_timer - 1)\n if tap and distances and not self.overheated and not self.terminal:\n index = int(np.argmin(distances))\n self.shot_target = self.pins.pop(index).position\n self.shot_timer = 9\n self.velocity += 2 * (self.position - self.shot_target) / distances[index]\n reward += self.multiplier\n self.heat = min(100, self.heat + 25)\n self.overheated = self.heat == 100\n if not self.pins:\n self.pin_count = min(64, self.pin_count + 1)\n self._spawn_wave()\n reward += self.pin_count * self.multiplier * 2\n return reward\n\n @staticmethod\n def _mark(state, position, channel):\n col, row = (position // 10).astype(int)\n state[row, col, channel] = True\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n self._mark(state, self.position, 0)\n for pin in self.pins:\n self._mark(state, pin.position, 1 + int(np.any(pin.velocity)))\n if self.item is not None:\n self._mark(state, self.item, 3)\n if self.shot_timer:\n for point in np.linspace(self.position, self.shot_target, 20):\n self._mark(state, point, 4)\n gauges = (self.steps, self.heat, self.overheated, self.multiplier,\n self.pin_count, self.held, round(self.velocity[0] * 20) + 256,\n round(self.velocity[1] * 20) + 256)\n for row, value in enumerate(gauges):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 236, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/ricochet_pins.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameRicochetPins.c"} +{"name": "star_eater", "split": "train", "game": "star_eater", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Star Eater as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to charge and move faster. Release with actions 0–4\nto blast once charge exceeds ten frames. Charging increases the\nplayer's collision radius. Asteroids destroyed by the same blast\nscore 1, 4, 9, and so on. Touching an asteroid ends the run.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the player, asteroids, charged body,\nactive blast, projected blast reach, and counters. The port uses\nfixed difficulty and the source's distance-based collision rules.\nEach action advances up to four frames over a 400-action horizon.\nClip scores to [0, 500] and divide by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/star_eater.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import hypot, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Asteroid:\n x: float\n y: float\n vx: float\n vy: float\n size: float\n\n\nclass StarEaterEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x = self.y = 50.\n self.charge = self.timer = self.steps = self.frame = 0\n self.blast_timer = self.destroyed = 0\n self.blast_x = self.blast_y = self.blast_radius = 0.\n self.held = self.terminal = False\n self.asteroids = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n release = self.held and not held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(release and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _spawn(self):\n edge = self.random.integers(4)\n offset = self.random.uniform(0, 100)\n drift = self.random.uniform(-0.3, 0.3)\n speed = self.random.uniform(0.5, 0.7)\n x, y, vx, vy = ((offset, 0, drift, speed), (offset, 100, drift, -speed),\n (0, offset, speed, drift), (100, offset, -speed, drift))[edge]\n if min(hypot(x - self.x, y - self.y), hypot(x - self.x + 100, y - self.y)) > 50:\n self.asteroids.append(Asteroid(x, y, vx, vy, self.random.uniform(5, 9)))\n self.timer = self.random.uniform(22, 55)\n\n def _advance(self, release):\n self.timer -= 1\n if self.timer <= 0:\n self._spawn()\n speed = 1.8 if self.held else 1\n self.x += 0.2 * speed\n if self.x > 100:\n self.x = 0.\n self.y = min(95, max(5, self.y + sin(self.frame * 0.02 * speed) * 0.1))\n if self.held:\n self.charge = min(60, self.charge + 1)\n elif release and self.charge > 10:\n self.blast_x, self.blast_y = self.x, self.y\n self.blast_radius = 15 + self.charge * 0.8\n self.blast_timer = 12\n self.charge = self.destroyed = 0\n else:\n self.charge = max(0, self.charge - 2)\n self.blast_timer = max(0, self.blast_timer - 1)\n reward = 0\n remaining = []\n for asteroid in self.asteroids:\n asteroid.x += asteroid.vx\n asteroid.y += asteroid.vy\n if not (-10 < asteroid.x < 110 and -10 < asteroid.y < 110):\n continue\n if self.blast_timer and min(\n hypot(asteroid.x - self.blast_x, asteroid.y - self.blast_y),\n hypot(asteroid.x - self.blast_x + 100, asteroid.y - self.blast_y),\n ) < self.blast_radius + asteroid.size / 2:\n self.destroyed += 1\n reward += self.destroyed ** 2\n else:\n self.terminal |= hypot(asteroid.x - self.x, asteroid.y - self.y) < (\n 5 + self.charge * 0.15 + asteroid.size / 2)\n remaining.append(asteroid)\n self.asteroids = remaining\n self.frame += 1\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(self.y // 10), min(9, int(self.x // 10)), 0] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for asteroid in self.asteroids:\n state[:, :, 1] |= np.hypot(cols - asteroid.x, rows - asteroid.y) < asteroid.size / 2 + 5\n if self.charge:\n state[:, :, 2] = np.hypot(cols - self.x, rows - self.y) < 10 + self.charge * 0.15\n if self.blast_timer:\n for x in (self.blast_x, self.blast_x - 100):\n state[:, :, 3] |= np.hypot(cols - x, rows - self.blast_y) < self.blast_radius\n if self.charge > 10:\n for x in (self.x, self.x - 100):\n state[:, :, 4] |= np.hypot(cols - x, rows - self.y) < 15 + self.charge * 0.8\n values = (self.steps, self.charge, self.held, self.blast_timer, self.destroyed)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 237, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/star_eater.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameStarEater.c"} +{"name": "rotation_rod", "split": "train", "game": "rotation_rod", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Rotation Rod as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nPress action 5 to reverse rotation and hold it to lock the rod in\nplace. Actions 0–4 release and let the rod turn. Avoid incoming\nobstacles and collect coins that follow their paths. Each coin\nscores the multiplier rounded up and adds ten to it. The multiplier\ndecays by one percent each frame.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the rod, obstacles, coins, the marked\ntip, the current entry point, and counters. The port uses fixed\ndifficulty and sampled rod collisions. Each action advances up to\nfour frames over a 400-action horizon. Clip episode scores to\n[0, 2000] and divide by 2000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/rotation_rod.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import ceil, cos, pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Mover:\n x: float\n y: float\n vx: float\n vy: float\n\n def advance(self):\n self.x += self.vx\n self.y += self.vy\n return -5 <= self.x <= 110 and -5 <= self.y <= 110\n\n\nclass RotationRodEnvironment:\n score_cap = 2000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.angle = 0.0\n self.direction = 1\n self.steps = self.obstacle_timer = self.coin_timer = 0\n self.multiplier = 1.0\n self.held = self.terminal = False\n self.obstacles, self.coins = [], []\n self.entry = None\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n if held and not self.held:\n self.direction *= -1\n self.held = held\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _rod(self):\n distance = np.arange(-24, 25)\n dx, dy = cos(self.angle), sin(self.angle)\n xs, ys = 50 + distance * dx, 50 + distance * dy\n tail = self.angle + 0.2 * self.direction\n arrow_x = np.linspace(50 + 23.04 * dx, 50 + 20.16 * cos(tail), 8)\n arrow_y = np.linspace(50 + 23.04 * dy, 50 + 20.16 * sin(tail), 8)\n return np.concatenate((xs, arrow_x)), np.concatenate((ys, arrow_y))\n\n def _advance(self):\n if not self.held:\n self.angle = (self.angle + self.direction * 0.05) % (2 * pi)\n xs, ys = self._rod()\n self.obstacle_timer -= 1\n if self.obstacle_timer < 0:\n offset = self.random.uniform(20, 40) + 40 * int(self.random.integers(2))\n entries = ((offset, -3, 0, 0.5), (103, offset, -0.5, 0),\n (offset, 103, 0, -0.5), (-3, offset, 0.5, 0))\n self.entry = entries[self.random.integers(4)]\n self.obstacles.append(Mover(*self.entry))\n self.obstacle_timer, self.coin_timer = 99, 9\n self.obstacles = [obstacle for obstacle in self.obstacles if obstacle.advance()]\n self.terminal = any(self._hit(obstacle, xs, ys, 3.5) for obstacle in self.obstacles)\n self.coin_timer -= 1\n if self.coin_timer < 0:\n self.coins.append(Mover(*self.entry))\n self.coin_timer = 9\n reward = 0\n remaining = []\n for coin in self.coins:\n if coin.advance():\n if self._hit(coin, xs, ys, 2.5):\n reward += ceil(self.multiplier)\n self.multiplier += 10\n else:\n remaining.append(coin)\n self.coins = remaining\n self.multiplier *= 0.99\n return reward\n\n @staticmethod\n def _hit(mover, xs, ys, reach):\n return bool(np.any((abs(xs - mover.x) < reach) & (abs(ys - mover.y) < reach)))\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n xs, ys = self._rod()\n state[(ys // 10).astype(int), (xs // 10).astype(int), 0] = True\n for channel, movers in ((1, self.obstacles), (2, self.coins)):\n for mover in movers:\n if 0 <= mover.x < 100 and 0 <= mover.y < 100:\n state[int(mover.y // 10), int(mover.x // 10), channel] = True\n state[int(ys[48] // 10), int(xs[48] // 10), 3] = True\n if self.entry is not None:\n x, y, _, _ = self.entry\n state[int(np.clip(y // 10, 0, 9)), int(np.clip(x // 10, 0, 9)), 4] = True\n values = (self.steps, self.held, self.direction > 0, round(self.angle * 100),\n self.obstacle_timer, self.coin_timer, round(self.multiplier))\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 238, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/rotation_rod.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameRotationRod.c"} +{"name": "make_maze", "split": "train", "game": "make_maze", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Make Maze as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nMove the cursor with actions 1–4 (left, up, right, down). Tap\naction 5 to toggle an interior wall. Enemies follow walls and\ncollect gold for the current multiplier. Each pickup increases\nit. Blocking all routes to the bottom makes an enemy dig down.\nAn enemy escaping below costs points and lowers the multiplier.\nGold scrolling off the top ends the episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show walls, gold, enemies, digging enemies,\ncursor, and counters. The port reduces the board from 16×18 to\n10×10, replaces pointer edits with cursor actions, and uses a\nfour-neighbor flood fill and wall following on the smaller board.\nDifficulty is fixed. Each action advances up to four frames over\n400 actions. Clip the episode score to [0, 100] and divide by 100.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/make_maze.py`):\n```python\nfrom collections import deque\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n_DIRECTIONS = ((0, 1), (1, 0), (0, -1), (-1, 0))\n\n\n@dataclass\nclass Enemy:\n row: int\n col: int\n turn: int\n heading: int = 1\n timer: int = 0\n angry: bool = False\n\n\nclass MakeMazeEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.walls = np.zeros((10, 10), dtype=bool)\n self.walls[:, (0, 9)] = True\n self.walls[5, (1, 8)] = True\n self.walls[6, 2:8] = True\n self.walls[7, 1:4] = self.walls[7, 6:9] = True\n self.cursor = (5, 5)\n self.enemies = []\n self.gold = set()\n self.scroll = 10.\n self.penalty = 0.\n self.timer = self.steps = self.action = 0\n self.multiplier = 1\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n if self.action in (1, 2, 3, 4):\n dr, dc = _DIRECTIONS[(self.action + 1) % 4]\n row, col = self.cursor\n self.cursor = min(9, max(0, row + dr)), min(8, max(1, col + dc))\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(frame == 0 and self.action == 5 and previous != 5)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, toggle):\n oldest = min((r for r, _ in self.gold), default=10)\n self.scroll += 0.01 + self.penalty + max(0, oldest * 10 - self.scroll - 50) * 0.02\n self.penalty *= 0.9\n if self.scroll >= 10:\n self.scroll -= 10\n self.walls[:-1] = self.walls[1:].copy()\n self.walls[-1, 1:9] = False\n self.gold = {(row - 1, col) for row, col in self.gold}\n self.gold.add((9, int(self.random.integers(1, 9))))\n for enemy in self.enemies:\n enemy.row -= 1\n if toggle and self.cursor not in self.gold:\n self.walls[self.cursor] = not self.walls[self.cursor]\n self.timer -= 1\n if self.timer < 0:\n columns = [col for col in range(1, 9) if not self.walls[0, col]]\n col = int(self.random.choice(columns or range(1, 9)))\n self.enemies.append(Enemy(0, col, int(self.random.choice((-1, 1)))))\n self.timer = 150\n\n reward = 0\n remaining = []\n for enemy in self.enemies:\n if enemy.row < 0:\n continue\n enemy.timer -= 1\n if enemy.timer < 0:\n reward += self._collect((enemy.row, enemy.col))\n reward += self._move(enemy)\n enemy.timer = 60\n if enemy.row >= 10:\n self.penalty += 1\n self.multiplier = max(1, self.multiplier - 1)\n reward -= self.multiplier\n elif enemy.row >= 0:\n remaining.append(enemy)\n self.enemies = remaining\n self.terminal = any(row < 0 for row, _ in self.gold)\n return reward\n\n def _collect(self, cell):\n if cell not in self.gold:\n return 0\n self.gold.remove(cell)\n self.multiplier += 1\n return self.multiplier - 1\n\n def _move(self, enemy):\n cell = enemy.row, enemy.col\n enemy.angry = not self._has_exit(cell)\n if enemy.angry:\n enemy.heading = 1\n enemy.row += 1\n if enemy.row < 10:\n self.walls[enemy.row, enemy.col] = False\n return self._collect((enemy.row, enemy.col))\n reward = 0\n # Follow the chosen wall, running through straight corridors in one move.\n for index in range(100):\n turns = (enemy.turn, 0, -enemy.turn, 2)\n choices = ((enemy.heading + turn) % 4 for turn in turns)\n heading = next((h for h in choices if self._open(_step(cell, h))), None)\n if heading is None or (index and heading != enemy.heading):\n break\n enemy.heading = heading\n cell = _step(cell, heading)\n enemy.row, enemy.col = cell\n reward += self._collect(cell)\n if not 0 <= enemy.row < 10:\n break\n return reward\n\n def _open(self, cell):\n row, col = cell\n return 0 < col < 9 and (not 0 <= row < 10 or not self.walls[cell])\n\n def _has_exit(self, start):\n pending = deque([start])\n seen = {start}\n while pending:\n cell = pending.popleft()\n if cell[0] == 9:\n return True\n for heading in range(4):\n other = _step(cell, heading)\n if other[0] >= 0 and other not in seen and self._open(other):\n seen.add(other)\n pending.append(other)\n return False\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[:, :, 0] = self.walls\n for row, col in self.gold:\n if row >= 0:\n state[row, col, 1] = True\n for enemy in self.enemies:\n state[enemy.row, enemy.col, 2 + enemy.angry] = True\n state[self.cursor[0], self.cursor[1], 4] = True\n for row, value in enumerate((self.steps, self.action, self.multiplier, round(self.scroll * 20), self.timer)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n\ndef _step(cell, heading):\n dr, dc = _DIRECTIONS[heading]\n return cell[0] + dr, cell[1] + dc\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 239, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/make_maze.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/makemaze/main.js"} +{"name": "beam_rider", "split": "train", "game": "beam_rider", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Beam Rider as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves *Beamrider*'s five-beam movement and weapon economy. The light ship taps\nleft or right one beam at a time. Action 5 fires a short-range laser lariat; action 2 uses one of\nthree sector torpedoes that can traverse the full matrix and destroy the first object it meets.\nEvery sector contains exactly 15 white saucers that must be destroyed. Missed saucers cycle back\nto the horizon instead of silently reducing the required count.\n\nOne yellow rejuvenator appears per sector. Catching it adds a ship, while shooting it converts it\ninto lethal red wreckage. Representative sectors 1, 2, 4, and 6 add brown debris, vulnerable\nchirpers, and green blockers according to the manual's progression. Lasers destroy saucers and\nchirpers; debris and blockers require dodging or a torpedo and give no reward. After the fifteenth\nsaucer, the Sector Sentinel crosses the horizon. Only a torpedo can destroy it for its sector and\nfleet bonus; if it escapes, play still advances. The player starts with one active ship and two\nreserves, as in the manual.\n\nACTION MAPPING\n0: wait\n1: move left\n2: fire torpedo\n3: move right\n4: wait\n5: fire laser\n\nINPUT CHANNEL TABLE\n0: light ship\n1: lethal invaders, blockers, debris, and red wreckage\n2: vulnerable invaders, safe rejuvenator, and Sentinel\n3: laser lariats and torpedoes\n4: previous object positions\n5: object/weapon identity, fleet, torpedoes, sector, and saucer count\n\nSCORING, TERMINATION, AND HORIZON\nThe finite scoring schedule increases with sector. Fifteen saucers pay `100×sector`; three\nchirpers in sectors 4 and 6 pay `200×sector`. Perfect rejuvenator collection gives fleets of\n4, 5, 6, and 7 ships at the four Sentinels, whose bonus is `500×sector + 100×fleet`.\nThus saucers contribute 19,500, chirpers 6,000, and Sentinels 8,700, for\n`score_cap = 34,200`. Normalization is `min(max(raw_score, 0), 34200) / 34200`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/beam_rider.py`):\n```python\nimport numpy as np\n\n\nBEAM_COLUMNS = (1, 3, 5, 7, 9)\nSECTORS = (1, 2, 4, 6)\n\n\nclass BeamRiderEnvironment:\n \"\"\"Five-beam sector defense with short lasers, scarce torpedoes, and rejuvenators.\"\"\"\n\n score_cap = 34_200.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 2_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.lane = 2\n self.lives = 3\n self.sector_index = 0\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self._start_sector()\n\n @property\n def sector(self) -> int:\n return SECTORS[self.sector_index]\n\n def _start_sector(self) -> None:\n self.torpedoes = 3\n self.saucers_destroyed = 0\n self.saucers_spawned = 0\n self.objects: list[dict[str, int | str | bool]] = []\n self.shots: list[dict[str, int | str]] = []\n self.previous_objects: list[list[int]] = []\n self.sector_step = 0\n self.sentinel: dict[str, int | str | bool] | None = None\n self.rejuvenator_spawned = False\n self.chirpers_spawned = 0\n self.hazard_spawned = False\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n if action == 1:\n self.lane = max(0, self.lane - 1)\n elif action == 3:\n self.lane = min(4, self.lane + 1)\n elif action == 5:\n self.shots.append({\"row\": 8, \"lane\": self.lane, \"kind\": \"laser\", \"ttl\": 4})\n elif action == 2 and self.torpedoes > 0:\n self.torpedoes -= 1\n self.shots.append({\"row\": 8, \"lane\": self.lane, \"kind\": \"torpedo\", \"ttl\": 10})\n\n self._spawn_objects()\n self.previous_objects = [[int(obj[\"row\"]), int(obj[\"lane\"])] for obj in self.objects]\n self._move_objects()\n self._move_shots()\n reward = self._resolve_shots()\n self._resolve_player_contacts()\n reward += self._move_sentinel()\n self.sector_step += 1\n self.steps += 1\n if self.saucers_destroyed == 15 and self.sentinel is None:\n self.sentinel = {\"row\": 0, \"column\": 0, \"kind\": \"sentinel\", \"active\": True}\n if self.sentinel is not None and not bool(self.sentinel[\"active\"]):\n self.sector_index += 1\n if self.sector_index == len(SECTORS):\n self.terminal = True\n else:\n self._start_sector()\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _spawn_objects(self) -> None:\n if self.saucers_spawned < 15 and self.sector_step % 5 == 0:\n self.objects.append({\"row\": 0, \"lane\": int(self.random.randint(5)), \"kind\": \"saucer\", \"red\": False})\n self.saucers_spawned += 1\n if not self.rejuvenator_spawned and self.sector_step == 20:\n self.objects.append({\"row\": 0, \"lane\": int(self.random.randint(5)), \"kind\": \"rejuvenator\", \"red\": False})\n self.rejuvenator_spawned = True\n if self.sector >= 4 and self.chirpers_spawned < 3 and self.sector_step in (12, 30, 48):\n self.objects.append({\"row\": 0, \"lane\": int(self.random.randint(5)), \"kind\": \"chirper\", \"red\": False})\n self.chirpers_spawned += 1\n if self.sector >= 2 and not self.hazard_spawned and self.sector_step == 10:\n kind = \"debris\" if self.sector < 6 else \"blocker\"\n self.objects.append({\"row\": 0, \"lane\": int(self.random.randint(5)), \"kind\": kind, \"red\": False})\n self.hazard_spawned = True\n\n def _move_objects(self) -> None:\n for obj in self.objects:\n obj[\"row\"] = int(obj[\"row\"]) + 1\n if obj[\"kind\"] == \"chirper\" and int(obj[\"row\"]) % 2 == 0:\n obj[\"lane\"] = int(np.clip(int(obj[\"lane\"]) + self.random.choice((-1, 1)), 0, 4))\n for obj in self.objects:\n if obj[\"kind\"] == \"saucer\" and int(obj[\"row\"]) > 9:\n obj[\"row\"] = 0\n obj[\"lane\"] = int(self.random.randint(5))\n self.objects = [obj for obj in self.objects if int(obj[\"row\"]) <= 9 or obj[\"kind\"] == \"saucer\"]\n\n def _move_shots(self) -> None:\n for shot in self.shots:\n shot[\"row\"] = int(shot[\"row\"]) - 1\n shot[\"ttl\"] = int(shot[\"ttl\"]) - 1\n self.shots = [shot for shot in self.shots if int(shot[\"row\"]) >= 0 and int(shot[\"ttl\"]) > 0]\n\n def _resolve_shots(self) -> float:\n reward = 0.0\n remaining = []\n for shot in self.shots:\n hit = next(\n (obj for obj in self.objects if int(obj[\"row\"]) == int(shot[\"row\"]) and int(obj[\"lane\"]) == int(shot[\"lane\"])),\n None,\n )\n if hit is None:\n remaining.append(shot)\n continue\n kind = str(hit[\"kind\"])\n torpedo = shot[\"kind\"] == \"torpedo\"\n laser_vulnerable = kind in (\"saucer\", \"chirper\")\n if kind == \"rejuvenator\" and not bool(hit[\"red\"]):\n hit[\"red\"] = True\n continue\n if torpedo or laser_vulnerable:\n self.objects.remove(hit)\n if kind == \"saucer\":\n self.saucers_destroyed += 1\n reward += 100.0 * self.sector\n elif kind == \"chirper\":\n reward += 200.0 * self.sector\n else:\n remaining.append(shot)\n self.shots = remaining\n return reward\n\n def _resolve_player_contacts(self) -> None:\n contacts = [obj for obj in self.objects if int(obj[\"row\"]) == 9 and int(obj[\"lane\"]) == self.lane]\n for obj in contacts:\n self.objects.remove(obj)\n if obj[\"kind\"] == \"rejuvenator\" and not bool(obj[\"red\"]):\n self.lives += 1\n else:\n self._lose_ship()\n\n def _move_sentinel(self) -> float:\n if self.sentinel is None or not bool(self.sentinel[\"active\"]):\n return 0.0\n self.sentinel[\"column\"] = int(self.sentinel[\"column\"]) + 1\n hit = next(\n (\n shot\n for shot in self.shots\n if shot[\"kind\"] == \"torpedo\"\n and int(shot[\"row\"]) == 0\n and BEAM_COLUMNS[int(shot[\"lane\"])] == int(self.sentinel[\"column\"])\n ),\n None,\n )\n if hit is not None:\n self.shots.remove(hit)\n self.sentinel[\"active\"] = False\n return 500.0 * self.sector + 100.0 * self.lives\n elif int(self.sentinel[\"column\"]) > 9:\n self.sentinel[\"active\"] = False\n return 0.0\n\n def _lose_ship(self) -> None:\n self.lives -= 1\n self.lane = 2\n self.shots.clear()\n if self.lives <= 0:\n self.terminal = True\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[9, BEAM_COLUMNS[self.lane], 0] = True\n for obj in self.objects:\n row, column = int(obj[\"row\"]), BEAM_COLUMNS[int(obj[\"lane\"])]\n dangerous = obj[\"kind\"] != \"rejuvenator\" or bool(obj[\"red\"])\n if dangerous:\n state[row, column, 1] = True\n if obj[\"kind\"] in (\"saucer\", \"chirper\") or (obj[\"kind\"] == \"rejuvenator\" and not bool(obj[\"red\"])):\n state[row, column, 2] = True\n marker = {\"saucer\": 0, \"chirper\": 1, \"debris\": 2, \"blocker\": 3, \"rejuvenator\": 4}[str(obj[\"kind\"])]\n state[row, marker, 5] = True\n if self.sentinel is not None and bool(self.sentinel[\"active\"]):\n state[0, min(9, int(self.sentinel[\"column\"])), 2] = True\n for shot in self.shots:\n row, column = int(shot[\"row\"]), BEAM_COLUMNS[int(shot[\"lane\"])]\n state[row, column, 3] = True\n if shot[\"kind\"] == \"torpedo\":\n state[row, column, 5] = True\n for row, lane in self.previous_objects:\n if 0 <= row < 10:\n state[row, BEAM_COLUMNS[lane], 4] = True\n state[9, : min(10, self.lives), 5] = True\n state[8, : self.torpedoes, 5] = True\n state[7, : self.sector_index + 1, 5] = True\n state[6, : min(10, (15 - self.saucers_destroyed + 1) // 2), 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 240, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/beam_rider.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "t_punch", "split": "train", "game": "t_punch", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays T Punch as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 when the arms are retracted to punch. Hold to extend and\nspin faster. Actions 0–4 release. A punch restores a missing arm if\none is available and scatters bonuses. Collect them after they mature\nto score the multiplier and raise it. A new press resets the multiplier.\nOrdinary arm contact destroys the enemy and costs the arm. Losing all\narms or taking a hit to the center ends the run.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the center and arms, punching tips, enemies,\nimmature bonuses, collectible bonuses, and counters. The port fixes\ndifficulty and approximates sprite contact with rectangles. Each action\nadvances up to four frames over 400 actions. Clip scores to [0, 1500]\nand divide by 1500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/t_punch.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, hypot, pi, sin, sqrt\n\nimport numpy as np\n\n\n@dataclass\nclass Orb:\n x: float\n y: float\n vx: float\n vy: float\n age: int = 0\n\n\nclass TPunchEnvironment:\n score_cap = 1500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.angle = self.angular_velocity = self.length = 0.\n self.arms = [True] * 6\n self.enemies, self.bonuses = [], []\n self.timer = self.steps = 0\n self.multiplier = 1\n self.attacking = self.held = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n if held and not self.held:\n self.attacking = self.length < 5\n self.multiplier = 1\n self.held = held\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _segments(self):\n size = 3 + sqrt(self.length) * 0.5\n for index, alive in enumerate(self.arms):\n if not alive:\n continue\n angle = self.angle + (index + 1) * pi / 3\n for segment in range(5):\n radius = 5 + segment * self.length / 4\n punch = segment == 4 and self.attacking\n yield index, 50 + cos(angle) * radius, 50 + sin(angle) * radius, size * (1.5 if punch else 1), punch\n\n @staticmethod\n def _contact(orb, segment):\n _, x, y, size, _ = segment\n return abs(orb.x - x) < 3 + size / 2 and abs(orb.y - y) < 3 + size / 2\n\n def _advance(self):\n if not self.held or self.length > 30:\n self.attacking = False\n self.length += ((36 if self.held else 0) - self.length) * 0.1\n self.angular_velocity += 0.001 if self.held else (0.03 - self.angular_velocity) * 0.2\n self.angle = (self.angle + self.angular_velocity) % (2 * pi)\n segments = list(self._segments())\n self.timer = self.timer - 1 if self.enemies else -1\n if self.timer < 0:\n x = self.random.uniform(0, 99)\n y = int(self.random.choice((-3, 3)))\n if self.random.random() < 0.5:\n x, y = y, x\n vx, vy = self.random.uniform(-0.3, 0.3, 2)\n self.enemies.append(Orb(x, y, vx, vy))\n self.timer = self.random.uniform(60, 99)\n reward = 0\n remaining = []\n for bonus in self.bonuses:\n distance = max(1e-9, hypot(bonus.x - 50, bonus.y - 50))\n bonus.vx = (bonus.vx + 0.002 * (bonus.x - 50) / distance) * 0.98\n bonus.vy = (bonus.vy + 0.002 * (bonus.y - 50) / distance) * 0.98\n bonus.x += bonus.vx\n bonus.y += bonus.vy\n if bonus.age > 60 and any(self._contact(bonus, segment) for segment in segments):\n reward += self.multiplier\n self.multiplier += 1\n elif -3 <= bonus.x <= 103 and -3 <= bonus.y <= 103:\n bonus.age += 1\n remaining.append(bonus)\n self.bonuses = remaining\n remaining = []\n for enemy in self.enemies:\n distance = hypot(50 - enemy.x, 50 - enemy.y)\n if distance > 30:\n enemy.vx = (enemy.vx + 0.005 * (50 - enemy.x) / distance) * 0.99\n enemy.vy = (enemy.vy + 0.005 * (50 - enemy.y) / distance) * 0.99\n enemy.x += enemy.vx\n enemy.y += enemy.vy\n hits = [segment for segment in segments if self._contact(enemy, segment)]\n if any(segment[-1] for segment in hits):\n self.bonuses.extend(Orb(enemy.x, enemy.y, i * 0.05 * cos(i), i * 0.05 * sin(i))\n for i in range(16))\n start = int(self.random.integers(6))\n for offset in range(6):\n index = (start + offset) % 6\n if not self.arms[index]:\n self.arms[index] = True\n break\n elif hits:\n for index, *_ in hits:\n self.arms[index] = False\n else:\n self.terminal |= abs(enemy.x - 49) < 6 and abs(enemy.y - 49) < 6\n remaining.append(enemy)\n self.enemies = remaining\n self.terminal |= not any(self.arms)\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[4, 4, 0] = True\n points = [(x, y, int(punch)) for _, x, y, _, punch in self._segments()]\n points.extend((enemy.x, enemy.y, 2) for enemy in self.enemies)\n points.extend((bonus.x, bonus.y, 4 if bonus.age > 60 else 3) for bonus in self.bonuses)\n for x, y, channel in points:\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), channel] = True\n values = (self.steps, self.multiplier, self.held, self.attacking,\n round(self.length * 10), round(self.angle * 70))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 242, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/t_punch.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/tpunch/main.js"} +{"name": "dark_cave", "split": "train", "game": "dark_cave", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Dark Cave as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 1 to move left or action 4 to move right. Other actions\nkeep your position. Movement tilts the light cone. Coins restore\nlight and score its current range rounded down. Spikes reduce the\nrange to one-third. The light slowly fades, and the run ends when\nits range falls below nine.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, visible coins, visible\nspikes, lit cells, unidentified glints beyond the light's range,\nand gauges. The conversion replaces pointer input with directional\nmovement, uses geometric collision checks, and shows glints without\nrevealing their type. Each action advances four frames at fixed\ndifficulty.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 2000] and divide by 2,000. Across 100 seeds without sticky\nactions, idle averaged 24.22 points and random movement averaged\n19.15. A policy with access to exact positions, including objects\noutside the cone, averaged 336.96 and reached 1,233.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/dark_cave.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nPLAYER_Y = 90\nHALF_ANGLE = math.pi / 6\n\n\n@dataclass\nclass Object:\n x: float\n y: float\n coin: bool\n\n\nclass DarkCaveEnvironment:\n score_cap = 2000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.last_action = 0\n self.x, self.angle, self.light = 50.0, 0.0, 40.0\n self.spike_distance, self.coin_distance = 0.0, 10.0\n self.terminal = False\n self.objects: list[Object] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.steps += 1\n direction = -1 if action == 1 else 1 if action == 4 else 0\n reward = 0\n for _ in range(4):\n reward += self._advance_frame(direction)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self, direction: int) -> int:\n scroll = 0.1 + self.light * 0.01\n self.spike_distance -= scroll\n self.coin_distance -= scroll\n if self.spike_distance < 0:\n self.objects.append(Object(self.random.uniform(5, 95), 0, False))\n self.spike_distance = self.random.uniform(20, 30)\n if self.coin_distance < 0:\n self.objects.append(Object(self.random.uniform(10, 90), 0, True))\n self.coin_distance = self.random.uniform(30, 40)\n next_x = min(97, max(3, self.x + 1.5 * direction))\n tilt = min(0.1, max(-0.1, next_x - self.x))\n self.angle = min(math.pi / 8, max(-math.pi / 8, self.angle + tilt))\n self.x = next_x\n self.light *= 0.999\n\n reward = 0\n survivors = []\n for obj in self.objects:\n obj.y += scroll\n if abs(obj.x - self.x) < 6 and abs(obj.y - PLAYER_Y) < 6:\n if obj.coin:\n reward += math.floor(self.light)\n self.light = min(99, self.light + 9)\n else:\n self.light /= 3\n elif obj.y <= 100:\n survivors.append(obj)\n self.objects = survivors\n self.terminal = self.light < 9\n return reward\n\n def _in_cone(self, x: float, y: float) -> bool:\n return abs(math.atan2(x - self.x, PLAYER_Y - y) - self.angle) < HALF_ANGLE\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[9, int(self.x) // 10, 0] = True\n for row in range(9):\n for column in range(10):\n x, y = 10 * column + 5, 10 * row + 5\n state[row, column, 3] = self._in_cone(x, y) and math.hypot(x - self.x, y - PLAYER_Y) < self.light\n for obj in self.objects:\n if obj.y >= 100 or not self._in_cone(obj.x, obj.y):\n continue\n row, column = int(obj.y) // 10, int(obj.x) // 10\n if math.hypot(obj.x - self.x, obj.y - PLAYER_Y) < self.light:\n state[row, column, 1 if obj.coin else 2] = True\n else:\n state[row, column, 4] = True\n for row, value in enumerate((self.steps, round(self.light * 4), round((self.angle + 0.4) * 100))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 243, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/dark_cave.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/darkcave/main.js"} +{"name": "pizza_arrow", "split": "train", "game": "pizza_arrow", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Pizza Arrow as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to pull the arrow back and slow the rotating\npizza. Release with actions 0–4 to fire. Hitting the crust\ncuts off the smaller slice and scores its angular size times\n100 and the multiplier, rounded up. Each cut raises the\nmultiplier. An arrow that reaches the exposed center ends\nthe run. Using the last arrow on a cut starts a fresh pizza\nwith one more arrow.\n\nINPUT CHANNEL TABLE\nSix 10×10 channels show crust, cut edges, center, arrow,\nflight line, and gauges. The conversion approximates sprite\ncontact by testing the arrow against the crust angle and\ncenter radius. At fixed difficulty it advances four frames\nper action. The 400-action task caps scores at 2500 and\ndivides by 2500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/pizza_arrow.py`):\n```python\nimport math\n\nimport numpy as np\n\n\nclass PizzaArrowEnvironment:\n score_cap = 2500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.angle = self.low = self.high = 0.0\n self.y = -25\n self.arrow = None\n self.velocity = self.steps = 0\n self.speed = 1.0\n self.arrows = self.capacity = self.multiplier = 1\n self.timer = 16\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n release = self.pressed and not pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(release and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, release):\n self.timer -= 1\n if self.timer == 15:\n self.angle = self.random.uniform(0, math.pi / 2)\n self.low, self.high = math.pi / 4, 7 * math.pi / 4\n self.multiplier = 1\n if self.timer >= 0:\n self.y = 50 - self.timer * 5 if self.timer <= 15 else 50 + (30 - self.timer) * 5\n cut_angle = -self.angle % math.tau\n self.angle = (self.angle + 0.2 * self.speed) % math.tau\n if self.timer < 0 and self.arrow is None and self.pressed:\n self.arrow, self.velocity = 80.0, 1\n self.arrows -= 1\n if self.arrow is None:\n return 0\n if self.pressed:\n self.speed += (0.05 - self.speed) * 0.1\n if release or self.arrow > 90:\n self.velocity = -5\n if self.velocity < 0:\n self.speed += (1 - self.speed) * 0.2\n self.arrow += self.velocity * self.speed\n radius = self.arrow - 30\n if radius <= 22 and self.low < cut_angle < self.high:\n return self._cut(cut_angle)\n if radius <= 7:\n self.terminal = True\n self.arrow = None\n return 0\n\n def _cut(self, angle):\n left, right = angle - self.low, self.high - angle\n if left < right:\n self.low = angle\n else:\n self.high = angle\n reward = math.ceil(min(left, right) * 100 * self.multiplier)\n self.multiplier += 1\n self.arrow = None\n if not self.arrows:\n self.capacity += 1\n self.arrows = self.capacity\n self.timer = 30\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for angle in np.linspace(self.low, self.high, 40):\n x, y = 30 + 20 * math.cos(angle + self.angle), self.y + 20 * math.sin(angle + self.angle)\n if 0 <= y < 100:\n state[int(y // 10), int(x // 10), 0] = True\n for angle in (self.low, self.high):\n for radius in range(5, 21, 3):\n x = 30 + radius * math.cos(angle + self.angle)\n y = self.y + radius * math.sin(angle + self.angle)\n if 0 <= y < 100:\n state[int(y // 10), int(x // 10), 1] = True\n if 0 <= self.y < 100:\n state[self.y // 10, 3, 2] = True\n if self.arrow is not None:\n state[5, int(self.arrow // 10), 3] = True\n state[5, :, 4] = True\n values = (self.steps, self.arrows, self.multiplier, round(self.angle * 80),\n round(self.low * 80), round(self.high * 80), round(self.speed * 100))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.velocity < 0 and self.arrow is not None\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 244, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pizza_arrow.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/pizzaarrow/main.js"} +{"name": "dango", "split": "train", "game": "dango", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Dango as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to stretch the stick through the swinging pieces.\nRelease with actions 0–4 before tapping again. The outward stroke\ncatches pieces, and the return stroke collects them. The collected\noperators and numbers form an expression. Multiplication takes\nprecedence over addition, and a leading multiply starts from zero.\n\nEach stroke costs one stick. Every 100 points from a stroke restores\none stick, up to nine. The run ends when the last stroke finishes\nwithout replenishing the supply, or when an uncaught piece hits the\nidle stick.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show additive, multiplicative, and caught\npieces, the stick, and metadata. The top row encodes the pieces'\nnumbers and operators in order. The conversion uses rectangular\ncollision checks and advances four frames per action at fixed\ndifficulty.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 10000] and divide by 10,000. Across 100 seeds without sticky\nactions, idle scored zero, random hold and release averaged 583.43,\nand tapping every nine actions averaged 1,143.51 and reached 7,379.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/dango.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Dango:\n x: float\n angle: float\n spin: float\n height: float\n factor: int\n multiply: bool\n caught: bool = False\n\n @property\n def y(self) -> float:\n return 50 + 30 * math.sin(self.angle)\n\n\ndef expression_score(terms: list[tuple[bool, int]]) -> int:\n total = product = 0\n for multiply, value in terms:\n if multiply:\n product *= value\n else:\n total += product\n product = value\n return total + product\n\n\nclass DangoEnvironment:\n score_cap = 10000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.stroke = 0\n self.sticks = 9\n self.offset = 0.0\n self.pressed = self.terminal = False\n self.terms: list[tuple[bool, int]] = []\n self.dangos: list[Dango] = []\n self._refill()\n\n def _refill(self) -> None:\n while len(self.dangos) < 7:\n self.dangos.append(Dango(\n -6, self.random.uniform(0, math.tau),\n self.random.uniform(0.02, 0.05) * self.random.choice((-1, 1)),\n self.random.uniform(15, 30), int(self.random.integers(2, 10)),\n self.random.random() < 0.5,\n ))\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance_frame(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _stick_x(self) -> float:\n if not self.stroke:\n return 90\n return 80 - 10 * self.stroke if self.stroke < 10 else 80 + (self.stroke - 10) * 10\n\n def _advance_frame(self, tap: bool) -> int:\n if tap and not self.stroke:\n self.stroke = 1\n self.sticks -= 1\n self.terms.clear()\n reward = 0\n if self.stroke:\n self.stroke += 1\n self.offset *= 0.1\n if self.stroke > 19:\n self.stroke = 0\n reward = expression_score(self.terms)\n self.sticks = min(9, self.sticks + reward // 100)\n elif self.sticks < 0:\n self.terminal = True\n return 0\n\n self.offset += 0.002\n survivors = []\n for dango in self.dangos:\n if dango.caught:\n if self.stroke > 10:\n dango.x += 20\n if dango.x > 99:\n self.terms.insert(0, (dango.multiply, dango.factor))\n continue\n else:\n dango.x += (80 - 12 * len(survivors) - dango.x) * 0.1\n dango.angle += dango.spin\n if abs(dango.y - 76) < dango.height / 2 + 1 and dango.x + self.offset + 6.5 > self._stick_x():\n if 0 < self.stroke < 10:\n dango.caught = True\n elif not self.stroke:\n self.terminal = True\n survivors.append(dango)\n self.dangos = survivors\n self._refill()\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for index, dango in enumerate(self.dangos):\n x = dango.x + self.offset\n if 0 <= x < 100:\n col = int(x) // 10\n low = max(0, int(dango.y - dango.height / 2) // 10)\n high = int(dango.y + dango.height / 2) // 10\n state[low:high + 1, col, 2 if dango.caught else int(dango.multiply)] = True\n for bit in range(4):\n state[0, index, bit] = bool(dango.factor & (1 << bit))\n state[0, index, 4] = dango.multiply\n if self.sticks >= 0 or self.stroke:\n state[7, max(0, int(self._stick_x()) // 10):, 3] = True\n for row, value in enumerate((self.steps, self.sticks + 1, self.stroke), 1):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 245, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/dango.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-11-games/blob/6fea4eefe2deaa42706051d96a04ec9e36104696/docs/dango/main.js"} +{"name": "rollnrope", "split": "train", "game": "rollnrope", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Rollnrope as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to run into the center. Hold it to jump from the center\nand reduce gravity in the air. Actions 0–4 release. Jump as the\nrotating rope passes the bottom. A closer jump scores more points.\nComplete the required jumps to clear the rope and retreat. Contact\nwith the rope ends the run.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the player, ground, rope, its projected\nposition, rope center, and counters. The port uses fixed difficulty\nand rectangular collision bounds. Each action advances up to four\nframes over a 400-action horizon. Clip scores to [0, 500] and divide\nby 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/rollnrope.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, floor, pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Rope:\n x: float\n angle: float\n radius: float\n size: float\n speed: float\n count: int\n\n def position(self):\n return (self.x + cos(self.angle) * self.radius,\n 91 - self.size / 2 - self.radius + sin(self.angle) * self.radius)\n\n\nclass RollnropeEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y, self.vy = 5.0, 84.0, 0.0\n self.mode = \"stop\"\n self.steps = self.frame = 0\n self.held = self.terminal = False\n self.rope = None\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n if self.rope is None:\n self.rope = Rope(150, self.random.uniform(0, 2 * pi), self.random.uniform(30, 45),\n self.random.uniform(5, 10), self.random.uniform(1, 2),\n int(self.random.integers(2, 6)) if self.frame else 2)\n if self.random.random() < 0.2:\n self.rope.speed *= -1\n rope = self.rope\n rope.x -= (rope.x - 50) * 0.1\n previous = (rope.angle + pi / 2) % (2 * pi) - pi\n rope.angle += rope.speed * 0.05\n current = (rope.angle + pi / 2) % (2 * pi) - pi\n reward = 0\n if previous * current < 0 and abs(current) < pi / 2 and self.mode == \"jump\":\n rope.count -= 1\n gap = 85 - rope.size - self.y\n reward = floor(100 / (gap if gap > 0 else 1))\n if not rope.count:\n self.rope = None\n self.mode = \"stop\"\n if self.mode == \"stop\":\n self.x += (5 - self.x) * 0.1\n if self.y == 84 and tap:\n self.mode = \"run\"\n if self.mode == \"run\":\n self.x += 2\n if self.x > 50:\n self.x, self.mode = 50, \"stand\"\n if self.mode == \"stand\" and self.held:\n self.vy, self.mode = -3, \"jump\"\n if self.mode in (\"jump\", \"stop\"):\n self.vy += 0.1 if self.held else 0.2\n self.y += self.vy\n if self.y > 84:\n self.y = 84\n if self.mode == \"jump\":\n self.mode = \"stand\"\n rx, ry = rope.position()\n self.terminal = abs(self.x - rx) < 3 + rope.size / 2 and abs(self.y - ry) < 6 + rope.size / 2\n self.frame += 1\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(self.y // 10), int(self.x // 10), 0] = True\n state[9, :, 1] = True\n count = 0\n if self.rope is not None:\n rope = self.rope\n count = rope.count\n x, y = rope.position()\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), 2] = True\n future = rope.angle + rope.speed * 0.2\n x = rope.x + cos(future) * rope.radius\n y = 91 - rope.size / 2 - rope.radius + sin(future) * rope.radius\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), 3] = True\n state[8, int(min(99, rope.x) // 10), 4] = True\n values = (self.steps, count, (\"stop\", \"run\", \"stand\", \"jump\").index(self.mode),\n self.held, min(511, round((self.vy + 4) * 16)))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 246, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/rollnrope.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/rollnrope/main.js"} +{"name": "d_pistols", "split": "train", "game": "d_pistols", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays D Pistols as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to reverse and fire left and right. Hold to slow\nmovement and periodically fire in all four directions. Release\nwith actions 0–4 to move at full speed. Enemies approach from\nthe sides and turn toward the player when they reach the center.\nContact ends the run.\n\nINPUT CHANNEL TABLE\nHits raise the multiplier and pay its new value. A tap costs\none multiplier point and crossfire costs five, with a floor\nof one on crossfire. The six 10×10 channels show the player,\napproaching enemies, center-lane enemies, shots, travel direction,\nand gauges. Each action advances four frames at fixed difficulty.\nThe conversion uses rectangular hit checks.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 500] and divide by 500. Across 100 seeds without sticky actions,\nidle scored zero, random inputs averaged 8.07, and continuous hold\naveraged 72.15. Repeating eight held actions and twelve released\nactions averaged 141.51 and reached 276.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/d_pistols.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Mover:\n x: float\n y: float\n vx: float\n vy: float\n\n def move(self) -> None:\n self.x += self.vx\n self.y += self.vy\n\n\nclass DPistolsEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.hold = self.spawn_timer = self.multiplier = 0\n self.pressed = self.terminal = False\n self.y, self.direction = 20.0, 1\n self.enemy_y, self.enemy_direction = 50.0, 1\n self.enemies: list[Mover] = []\n self.shots: list[Mover] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance_frame(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self, tap: bool) -> int:\n if tap:\n self.direction *= -1\n self.shots.extend(Mover(50, self.y + self.direction, vx, 0) for vx in (-2, 2))\n self.multiplier = max(0, self.multiplier - 1)\n self.hold = self.hold + 1 if self.pressed else 0\n if self.hold > 30:\n self.shots.extend(Mover(50, self.y, vx, vy)\n for vx, vy in ((-2, 0), (2, 0), (0, -2), (0, 2)))\n self.hold = 0\n self.multiplier = max(1, self.multiplier - 5)\n self.y += self.direction * (1 - self.hold / 30)\n if not 0 <= self.y <= 99:\n self.direction *= -1\n self.y = min(99, max(0, self.y))\n for shot in self.shots:\n shot.move()\n self.shots = [shot for shot in self.shots if -3 <= shot.x < 103 and -3 <= shot.y < 103]\n\n self.spawn_timer = self.spawn_timer - 1 if self.enemies else -1\n if self.spawn_timer < 0:\n if self.random.random() < 0.3:\n self.enemy_y = self.random.uniform(9, 90)\n self.enemy_direction *= -1\n x = -3 if self.enemy_direction > 0 else 103\n self.enemies.append(Mover(x, self.enemy_y, self.enemy_direction * 0.3, 0))\n self.spawn_timer = int(self.random.integers(20, 41))\n\n survivors = []\n reward = 0\n for enemy in self.enemies:\n enemy.move()\n if enemy.vx and (enemy.x - 50) * enemy.vx >= 0:\n enemy.x = 50\n enemy.vy = -0.3 if self.y < enemy.y else 0.3\n enemy.vx = 0\n if any(\n abs(shot.x - enemy.x) < (3 if shot.vx else 6)\n and abs(shot.y - enemy.y) < (6 if shot.vx else 3)\n for shot in self.shots\n ):\n self.multiplier = min(99, self.multiplier + 1)\n reward += self.multiplier\n else:\n self.terminal |= abs(enemy.x - 50) < 5 and abs(enemy.y - self.y) < 5\n if -4 <= enemy.y <= 104:\n survivors.append(enemy)\n self.enemies = survivors\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row = int(self.y) // 10\n state[row, 5, 0] = True\n state[row, 5, 4] = self.direction > 0\n for shot in self.shots:\n if 0 <= shot.x < 100 and 0 <= shot.y < 100:\n state[int(shot.y) // 10, int(shot.x) // 10, 3] = True\n for enemy in self.enemies:\n if 0 <= enemy.x < 100 and 0 <= enemy.y < 100:\n state[int(enemy.y) // 10, int(enemy.x) // 10, 1 if enemy.vx else 2] = True\n for row, value in enumerate((self.steps, self.hold, self.multiplier)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 247, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/d_pistols.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/dpistols/main.js"} +{"name": "from_two_sides", "split": "train", "game": "from_two_sides", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays From Two Sides as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nMove left with action 1 and right with action 4. Other actions\nhold position. Arrow volleys descend from above and rise from\nbelow. Each volley leaves openings around two wandering gap\ncenters. Touching an arrow ends the run. Each arrow launched\nadds one point.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, both arrow directions,\nthe two gap centers, and gauges. Directional controls replace\npointer input. Each action advances four frames at fixed\ndifficulty, with rectangular hit checks.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action task clips raw scores to [0, 500] and divides by\n500. Across 100 seeds without sticky actions, idle averaged\n39.81 and random movement averaged 22.77. A policy choosing\nsafe gaps from exact arrow positions averaged 295.76 and\nreached 371.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/from_two_sides.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\n\n\n@dataclass\nclass Gap:\n x: float\n velocity: float\n\n\n@dataclass\nclass Arrow:\n x: int\n y: float\n direction: int\n velocity: float = 0\n\n\nclass FromTwoSidesEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.last_action = 0\n self.x = 50\n self.terminal = False\n self.gaps = [Gap(50, -1), Gap(50, 1)]\n self.timers = [0, 60]\n self.arrows: list[Arrow] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.steps += 1\n direction = -1 if action == 1 else 1 if action == 4 else 0\n reward = 0\n for _ in range(FRAMES_PER_STEP):\n reward += self._advance(direction)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, direction: int) -> int:\n self.x = min(98, max(1, self.x + 2 * direction))\n for gap in self.gaps:\n gap.x += gap.velocity\n if (gap.x < 9 and gap.velocity < 0) or (gap.x > 90 and gap.velocity > 0):\n gap.velocity *= -1\n gap.velocity = (gap.velocity + self.random.uniform(-0.5, 0.5)) * 0.98\n\n reward = 0\n for index, heading in enumerate((1, -1)):\n self.timers[index] -= 1\n if self.timers[index] < 0:\n width = self.random.uniform(20, 50)\n for x in range(2, 99, 6):\n if all(abs(x - gap.x) >= width / 2 for gap in self.gaps):\n self.arrows.append(Arrow(x, -3 if heading > 0 else 103, heading))\n reward += 1\n self.timers[index] = int(self.random.integers(60, 91))\n\n survivors = []\n for arrow in self.arrows:\n arrow.velocity += (arrow.direction * 2 - arrow.velocity) * 0.05\n arrow.y += arrow.velocity\n self.terminal |= abs(arrow.x - self.x) < 4 and abs(arrow.y - 50) < 5\n if -3 <= arrow.y <= 103:\n survivors.append(arrow)\n self.arrows = survivors\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[5, self.x // 10, 0] = True\n for arrow in self.arrows:\n if 0 <= arrow.y < 100:\n state[int(arrow.y) // 10, arrow.x // 10, 1 if arrow.direction > 0 else 2] = True\n for index, gap in enumerate(self.gaps):\n state[0, min(9, max(0, int(gap.x) // 10)), 3 + index] = True\n for row, value in enumerate((self.steps, self.x, *self.timers)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 248, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/from_two_sides.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/fromtwosides/main.js"} +{"name": "l_rain", "split": "train", "game": "l_rain", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays L Rain as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nUse action 1 to move left and action 3 to move right.\nOther actions hold position. These controls replace\npointer movement at eight source pixels per action.\n\nLasers travel vertically before releasing waves of fragments.\nGraze a fragment with the ship's edges to score and charge\nenergy. Filling the gauge raises the multiplier and grants\ntemporary invincibility. A core hit outside that window\nends the run. Collisions use rectangular bounds.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the ship, lasers in each direction,\nfragments in each direction, and gauges. Each action advances\nfour frames at fixed difficulty. The 400-action task clips\nraw scores to [0, 3000] and divides by 3000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/l_rain.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Laser:\n x: float\n y: float\n vy: int\n width: float\n burst: int = 0\n\n\n@dataclass\nclass Fragment:\n x: float\n y: float\n vy: int\n height: float\n\n\nclass LRainEnvironment:\n score_cap = 3000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x = self.safe_x = 50.0\n self.safe_vx = self.invincible = self.timer = 0.0\n self.energy = self.steps = self.frames = self.action = 0\n self.multiplier = 1\n self.terminal = False\n self.lasers: list[Laser] = []\n self.fragments: list[Fragment] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self) -> int:\n previous = self.x\n self.x = min(99, max(0, self.x + 2 * ((self.action == 3) - (self.action == 1))))\n self.safe_x += self.safe_vx / (len(self.lasers) + 1)\n self.safe_vx += (self.safe_vx + self.random.uniform(-0.01, 0.01) + 0.1) % 0.2 - 0.1\n self.safe_vx *= 0.99\n if (self.safe_x < 9 and self.safe_vx < 0) or (self.safe_x > 90 and self.safe_vx > 0):\n self.safe_vx *= -1\n self.frames += 1\n self.timer -= 1\n if self.timer < 0:\n x, width = self.random.uniform(0, 99), self.random.uniform(3, 9)\n vy = 3 if self.random.integers(2) else -3\n if abs(x - self.safe_x) > width + 2:\n self.lasers.append(Laser(x, 0 if vy > 0 else 99, vy, width))\n cadence = abs(math.cos(self.frames * 0.001))\n self.timer = self.random.uniform(0, 30 / (5 if cadence < 0.15 else cadence))\n self._move_lasers()\n reward = 0\n hit = False\n remaining = []\n for fragment in self.fragments:\n fragment.y += fragment.vy\n if abs(fragment.y - 50) < fragment.height / 2 + 3:\n left, right = fragment.x - 1.5, fragment.x + 1.5\n if ((right > self.x + 2 and left < previous + 6)\n or (right > previous - 6 and left < self.x - 2)):\n reward += self.multiplier\n self.energy += 1\n if self.energy > 150:\n self.multiplier += 1\n self.energy = 0\n self.invincible = 30\n hit |= abs(fragment.y - 50) < fragment.height / 2 + 2 and abs(fragment.x - self.x) < 2\n if -fragment.height / 2 <= fragment.y <= 99 + fragment.height / 2:\n remaining.append(fragment)\n self.fragments = remaining\n self.terminal = hit and self.invincible < 3\n if self.invincible >= 3:\n self.invincible *= 0.98\n return reward\n\n def _move_lasers(self) -> None:\n remaining = []\n for laser in self.lasers:\n if 0 <= laser.y <= 99:\n laser.y += laser.vy\n else:\n laser.burst += 1\n width = min(math.sin(laser.burst * 0.1) * laser.width * 2, laser.width - 1)\n if width <= 0:\n continue\n height = self.random.uniform(9, 15)\n for _ in range(int(width)):\n x = laser.x + self.random.uniform(-width, width)\n offset = self.random.uniform(0, 9) + height / 2\n y = 100 - laser.y - math.copysign(offset, laser.vy)\n self.fragments.append(Fragment(x, y, laser.vy * 3, height))\n remaining.append(laser)\n self.lasers = remaining\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[5, int(self.x) // 10, 0] = True\n for laser in self.lasers:\n left = max(0, int((laser.x - laser.width) // 10))\n right = min(9, int((laser.x + laser.width) // 10))\n head = min(9, max(0, int(laser.y // 10)))\n channel = 1 if laser.vy > 0 else 2\n rows = slice(0, head + 1) if laser.vy > 0 else slice(head, 10)\n state[rows, left:right + 1, channel] = True\n for fragment in self.fragments:\n if 0 <= fragment.x < 100:\n top = max(0, int((fragment.y - fragment.height / 2) // 10))\n bottom = min(9, int((fragment.y + fragment.height / 2) // 10))\n if top <= bottom:\n state[top:bottom + 1, int(fragment.x) // 10, 3 if fragment.vy > 0 else 4] = True\n gauges = (self.steps, round(self.x * 4), self.energy, min(511, self.multiplier),\n round(self.invincible * 10))\n for row, value in enumerate(gauges):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 249, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/l_rain.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/lrain/main.js"} +{"name": "echo_bridge", "split": "train", "game": "echo_bridge", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Echo Bridge as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 when the rotating pointer lines up with an unused\nisland to build a bridge. Hold to walk along it. Release with\nactions 0–4 to pause. Tapping again can redirect you mid-crossing.\nAn unsuccessful build costs 10 material.\n\nLonger bridges cost more material. Movement pays points based\non the number of live bridges, and finishing a bridge earns\npoints and recovers some material. Drifting off the bottom\nends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, unused islands, used\nislands, bridges, the pointer, and gauges. The conversion uses\nfixed difficulty, draws islands as cells, and advances four\nframes per action.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 5000] and divide by 5,000. Across 100 seeds without sticky\nactions, idle scored zero, random inputs averaged 1,459.50 and\nreached 6,175, and an upward-alignment policy averaged 1,047.42.\nRandom inputs sometimes retained unfinished bridges, which\nincreased the movement multiplier.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/echo_bridge.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass(eq=False)\nclass Island:\n x: float\n y: float\n used: bool = False\n\n\n@dataclass(eq=False)\nclass Bridge:\n x: float\n y: float\n target: Island\n origin: Island | None\n length: float\n\n\nclass EchoBridgeEnvironment:\n score_cap = 5000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = 0\n self.pressed = self.terminal = False\n self.x, self.y, self.angle = 50.0, 0.0, 0.0\n self.material, self.spawn_y, self.last_x = 80.0, -10.0, 50.0\n self.island: Island | None = Island(50, 0)\n self.islands = [self.island]\n self.bridges: list[Bridge] = []\n self.active: Bridge | None = None\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _candidates(self):\n for island in self.islands:\n if island is self.island or island.used or not 0 <= island.y <= 100:\n continue\n dx, dy = island.x - self.x, island.y - self.y\n distance = math.hypot(dx, dy)\n if 0 < distance <= 4 * self.material:\n yield island, dx, dy, distance\n\n def _advance(self, tap: bool) -> int:\n self.angle = (self.angle + 0.05) % math.tau\n scroll = 0.15 if self.island is not None and next(self._candidates(), None) is None else 0.05\n scroll = max(scroll, 60 - self.y)\n self.y += scroll\n self.spawn_y += scroll\n for island in self.islands:\n island.y += scroll\n for bridge in self.bridges:\n bridge.y += scroll\n while self.spawn_y > -10:\n x = self.random.uniform(0, 100)\n for _ in range(9):\n if abs(x - self.last_x) >= 25:\n break\n x = self.random.uniform(0, 100)\n if abs(x - self.last_x) < 25:\n x = self.random.uniform(60, 100) if self.last_x < 50 else self.random.uniform(0, 40)\n self.islands.append(Island(x, self.spawn_y))\n self.last_x = x\n self.spawn_y -= self.random.uniform(5, 20)\n if tap:\n self._build()\n reward = self._walk() if self.pressed and self.active is not None else 0\n self.islands = [island for island in self.islands if island.y <= 120]\n self.bridges = [bridge for bridge in self.bridges if min(bridge.y, bridge.target.y) <= 120]\n if self.active not in self.bridges:\n self.active = None\n self.terminal = self.y >= 100\n return reward\n\n def _build(self) -> None:\n cos, sin = math.cos(self.angle), math.sin(self.angle)\n best = 0.3\n chosen = None\n for island, dx, dy, distance in self._candidates():\n alignment = (dx * cos + dy * sin) / distance\n if alignment > best:\n best = alignment\n chosen = Bridge(self.x, self.y, island, self.island, distance)\n if chosen is None:\n self.material = max(0, self.material - 10)\n return\n self.active = chosen\n self.bridges.append(chosen)\n chosen.target.used = True\n self.material -= chosen.length * 0.25\n\n def _walk(self) -> int:\n bridge = self.active\n dx, dy = bridge.target.x - self.x, bridge.target.y - self.y\n distance = math.hypot(dx, dy)\n if distance:\n self.x += dx / distance * 1.5\n self.y += dy / distance * 1.5\n self.island = None\n multiplier = len(self.bridges)\n reward = math.floor(1.5 * multiplier)\n if distance < 9.5:\n self.island = bridge.target\n self.x, self.y = self.island.x, self.island.y\n recovery = bridge.length * 0.2 * multiplier\n self.material = min(80, self.material + recovery)\n if bridge.origin in self.islands:\n self.islands.remove(bridge.origin)\n self.bridges.remove(bridge)\n self.active = None\n reward += math.floor(recovery)\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n\n def mark(x: float, y: float, channel: int) -> None:\n if 0 <= y < 100 and 0 <= x <= 100:\n state[int(y) // 10, min(9, int(x) // 10), channel] = True\n\n mark(self.x, self.y, 0)\n for island in self.islands:\n mark(island.x, island.y, 2 if island.used else 1)\n for bridge in self.bridges:\n for fraction in np.linspace(0, 1, 16):\n mark(bridge.x + fraction * (bridge.target.x - bridge.x),\n bridge.y + fraction * (bridge.target.y - bridge.y), 3)\n mark(self.x + 15 * math.cos(self.angle), self.y + 15 * math.sin(self.angle), 4)\n for row, value in enumerate((self.steps, round(self.material), round(self.angle * 80), len(self.bridges))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.active is not None\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 250, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/echo_bridge.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameEchoBridge.c"} +{"name": "fracave", "split": "train", "game": "fracave", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Fracave as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to accelerate. Release with actions 0–4 to slow\ndown. The player travels in its current direction and reflects\noff the scrolling cave walls. Each reflection scores one point\nand briefly prevents another reflection. Leaving the arena ends\nthe run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, walls, heading, reflection\ncooldown, arena boundary, and gauges. Each action advances four\nframes at fixed difficulty. The conversion preserves recursive\nwall generation and uses distance-to-segment collision checks.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action task clips raw scores to [0, 50] and divides by\n50. Across 100 seeds without sticky actions, idle averaged 3.02,\ncontinuous hold averaged 3.28, and random inputs averaged 3.27.\nContinuous hold and random inputs both reached 11.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/fracave.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Wall:\n x: float\n y: float\n dx: float\n dy: float\n\n def near(self, x: float, y: float) -> bool:\n dx, dy = x - self.x, y - self.y\n length = self.dx**2 + self.dy**2\n fraction = min(1, max(0, (dx * self.dx + dy * self.dy) / length)) if length else 0\n return math.hypot(dx - fraction * self.dx, dy - fraction * self.dy) < 4\n\n\nclass FracaveEnvironment:\n score_cap = 50\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.frame = 0\n self.x, self.y, self.angle, self.speed = 40.0, 75.0, 0.0, 1.0\n self.cooldown = 0.0\n self.pressed = self.terminal = False\n self.walls: list[Wall] = []\n self._generate(0)\n\n def _generate(self, y: float) -> None:\n for x in (20, 80):\n self._subdivide(x, y, x, y + 150, 3)\n\n def _subdivide(self, x1: float, y1: float, x2: float, y2: float, depth: int) -> None:\n if not depth:\n self.walls.append(Wall(x1, y1, x2 - x1, y2 - y1))\n return\n x = (x1 + x2) / 2 + self.random.uniform(-10, 10)\n y = (y1 + y2) / 2 + self.random.uniform(-5, 5)\n self._subdivide(x1, y1, x, y, depth - 1)\n self._subdivide(x, y, x2, y2, depth - 1)\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self) -> int:\n if self.frame % 150 == 0:\n self._generate(-150)\n self.frame += 1\n self.speed += ((2 if self.pressed else 0.1) - self.speed) * 0.3\n self.x += math.cos(self.angle) * self.speed\n self.y += math.sin(self.angle) * self.speed\n self.cooldown -= self.speed\n for wall in self.walls:\n wall.y += 1\n self.walls = [wall for wall in self.walls if wall.y < 170]\n reward = 0\n if self.cooldown < 0:\n for wall in self.walls:\n if wall.near(self.x, self.y):\n tangent = math.atan2(wall.dy, wall.dx)\n self.angle = (2 * tangent - self.angle) % math.tau\n self.x += math.cos(self.angle) * 7\n self.y += math.sin(self.angle) * 7\n self.speed, self.cooldown = 0.2, 9\n reward = 1\n break\n self.terminal = not (0 <= self.x <= 100 and 0 <= self.y <= 150)\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n\n def mark(x: float, y: float, channel: int) -> None:\n if 0 <= x <= 100 and 0 <= y <= 150:\n state[min(9, int(y) // 15), min(9, int(x) // 10), channel] = True\n\n mark(self.x, self.y, 0)\n mark(self.x + 9 * math.cos(self.angle), self.y + 9 * math.sin(self.angle), 2)\n if self.cooldown > 0:\n state[:, :, 3] = state[:, :, 0]\n for wall in self.walls:\n for fraction in np.linspace(0, 1, 12):\n mark(wall.x + wall.dx * fraction, wall.y + wall.dy * fraction, 1)\n state[(0, 9), :, 4] = True\n state[:, (0, 9), 4] = True\n for row, value in enumerate((self.steps, round(self.angle * 80), round(self.speed * 100))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 252, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/fracave.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameFracave.c"} +{"name": "rps", "split": "train", "game": "rps", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Rps as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to move one lane right, cycle from rock to paper to\nscissors, and return to the bottom. Actions 0–4 release. Your hand\nautomatically rises. A win removes the opposing hand and scores\nthe current multiplier, then increases it. A tie knocks the other\nhand up. A loss knocks you back, locks lane changes temporarily,\nand resets the multiplier. An opposing hand reaching the bottom\nends the episode.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the player, opposing rock, paper,\nand scissors hands, the player's collision position, and counters.\nThe port uses fixed difficulty and keeps lane-based collisions.\nEach action advances up to four frames over a 400-action horizon.\nClip episode scores to [0, 200] and divide by 200.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/rps.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Hand:\n lane: int\n kind: int\n y: float = -9\n speed: float = 0.1\n\n\nclass RpsEnvironment:\n score_cap = 200\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.lane = self.kind = self.freeze = self.steps = 0\n self.target_y = self.y = 97.0\n self.x, self.vy = 20.0, -1.0\n self.multiplier = 1\n self.held = self.terminal = False\n self.hands = []\n self.kinds = self.random.integers(3, size=4)\n self.timers = self.random.uniform(0, 99, size=4)\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n self.timers -= 1\n for lane in np.flatnonzero(self.timers < 0):\n self.hands.append(Hand(lane, self.kinds[lane]))\n self.timers[lane] = self.random.uniform(200, 300)\n if self.random.random() < 0.4:\n self.kinds[lane] = self.random.integers(3)\n for hand in self.hands:\n hand.y += hand.speed\n hand.speed += ((0.2 if hand.y > 90 else 0.1) - hand.speed) * 0.1\n for other in self.hands:\n if other is not hand and other.lane == hand.lane and abs(other.y - hand.y) < 6:\n center = (other.y + hand.y) / 2\n hand.speed, other.speed = (0.4 * other.speed - 0.2 * hand.speed,\n 0.4 * hand.speed - 0.2 * other.speed)\n offset = 3 if other.y < hand.y else -3\n hand.y, other.y = center + offset, center - offset\n self.terminal |= hand.y > 99\n self.freeze -= 1\n if self.freeze < 0 and tap:\n self.lane = (self.lane + 1) % 4\n self.kind = (self.kind + 1) % 3\n self.target_y, self.vy = 97, -1\n self.vy += ((-1 if self.freeze < 0 else 0) - self.vy) * 0.05\n self.target_y = min(97, max(10, self.target_y + self.vy))\n offset = 20 + self.lane * 20 - self.x\n self.x += offset if offset < 1 else offset * 0.5\n self.y += (self.target_y - self.y) * 0.5\n reward = 0\n remaining = []\n for hand in self.hands:\n if hand.lane == self.lane and abs(self.target_y - hand.y) < 5:\n outcome = (self.kind - hand.kind) % 3\n if outcome == 0:\n self.vy = 0\n hand.speed -= 4\n hand.y = self.target_y - 3\n elif outcome == 1:\n reward += self.multiplier\n self.multiplier += 1\n continue\n else:\n self.multiplier = 1\n self.vy = 5\n hand.speed -= 0.5\n self.target_y = hand.y + 3\n self.freeze = 60\n remaining.append(hand)\n self.hands = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, int(self.y // 10)), int(self.x // 10), 0] = True\n for hand in self.hands:\n if 0 <= hand.y < 100:\n state[int(hand.y // 10), 2 + 2 * hand.lane, 1 + hand.kind] = True\n state[min(9, int(self.target_y // 10)), 2 + 2 * self.lane, 4] = True\n values = (self.steps, self.kind, max(0, self.freeze), self.multiplier, self.held)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 253, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/rps.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/rps/main.js"} +{"name": "d_fight", "split": "train", "game": "d_fight", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays D Fight as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 1 to move left or action 4 to move right. Other actions\nstand still. The player and allied fighters automatically aim at\nenemies and fire. Moving domes block shots. Each enemy taken down by\nthe player or an ally scores one point. An enemy shot hitting the\nplayer ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, allies, enemies, friendly\nshots, enemy shots, and domes plus the step gauge. The conversion\nreplaces horizontal pointer input with directional actions and uses\ngeometric collision checks at fixed difficulty. Each action advances\nfour frames.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to [0, 25]\nand divide by 25. Across 100 seeds without sticky actions, idle\naveraged 2.23 raw points and random movement averaged 2.80. A policy\nthat closed in on the nearest enemy using exact positions averaged\n7.59 and reached 32 before clipping.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/d_fight.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass(eq=False)\nclass Agent:\n x: float\n y: float = 87\n team: int = 0\n vx: float = 0\n vy: float = 0\n spacing: float = 45\n target: \"Agent | None\" = None\n aim: float = 0\n fire: float = 0\n\n\nclass DFightEnvironment:\n score_cap = 25\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.last_action = self.enemy_timer = 0\n self.ally_timer, self.dome_timer = 9, 0.0\n self.terminal = False\n self.player = Agent(99)\n self.agents = [self.player]\n self.domes = [100.0]\n self.shots: list[tuple[float, float, int]] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.steps += 1\n direction = -1 if action == 1 else 1 if action == 4 else 0\n reward = 0\n for _ in range(4):\n reward += self._advance_frame(direction)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _spawn(self, team: int) -> None:\n left = self.random.random() < 0.3\n self.agents.append(Agent(-3 if left else 203, team=team, vx=1 if left else -1,\n spacing=self.random.uniform(30, 60)))\n\n def _advance_frame(self, direction: int) -> int:\n self.dome_timer -= 0.2\n if self.dome_timer < 0:\n self.domes.append(240)\n self.dome_timer += self.random.uniform(70, 150)\n self.domes = [x - 0.2 for x in self.domes if x > -40]\n enemy_count = sum(agent.team == 1 for agent in self.agents)\n ally_count = len(self.agents) - enemy_count - 1\n self.ally_timer -= 1\n self.enemy_timer = self.enemy_timer - 1 if enemy_count else -1\n if self.ally_timer < 0:\n self._spawn(0)\n self.ally_timer = int(self.random.integers(120, 151)) * (ally_count + 1)\n if self.enemy_timer < 0:\n self._spawn(1)\n self.enemy_timer = int(self.random.integers(60, 81)) * (enemy_count + 1)\n\n self.player.x = min(197, max(3, self.player.x + 2 * direction))\n self.shots = []\n for agent in self.agents:\n if agent is not self.player:\n self._move(agent)\n if agent.target not in self.agents:\n agent.target = min(\n (other for other in self.agents if other.team != agent.team),\n key=lambda other: math.hypot(other.x - agent.x, other.y - agent.y),\n default=None,\n )\n agent.aim = agent.fire = 0\n if agent.target is not None:\n self._aim(agent)\n\n survivors = []\n reward = 0\n for agent in self.agents:\n hit = any(team != agent.team and abs(x - agent.x) < 6 and abs(y - agent.y) < 5\n for x, y, team in self.shots)\n if hit and agent is self.player:\n self.terminal = True\n if hit and agent.team == 1:\n reward += 1\n if not hit or agent is self.player:\n survivors.append(agent)\n self.agents = survivors\n return reward\n\n def _move(self, agent: Agent) -> None:\n agent.vy += 0.05\n if (agent.x < 3 and agent.vx < 0) or (agent.x > 197 and agent.vx > 0):\n agent.x = min(197, max(3, agent.x))\n agent.vx *= -1\n if agent.y >= 87:\n agent.y = 87\n agent.vy = -self.random.uniform(3, 6) if self.random.random() < 0.01 else 0\n agent.x += agent.vx\n agent.y += agent.vy\n agent.vx *= 0.9\n agent.vy *= 0.9\n\n def _aim(self, agent: Agent) -> None:\n target = agent.target\n dx, dy = target.x - agent.x, target.y - agent.y\n distance = math.hypot(dx, dy)\n if distance > 99:\n agent.target = None\n agent.aim = agent.fire = 0\n return\n if agent is not self.player:\n agent.vx += math.copysign(0.1, dx) * (1 if distance > agent.spacing else -1)\n if agent.fire:\n agent.fire += 3\n ratio = agent.fire / max(distance, 0.01)\n x, y = agent.x + dx * ratio, agent.y + dy * ratio\n blocked = any(abs(math.hypot(x - dome, y - 90) - 40) < 4 for dome in self.domes)\n if blocked or y > 90 or agent.fire > 99:\n agent.fire = agent.aim = 0\n else:\n self.shots.append((x, y, agent.team))\n else:\n rate = 0.9 if agent is self.player else 0.4 if agent.team else 0.2\n agent.aim += rate * max(1, distance) * 0.03\n if agent.aim > distance:\n agent.fire = 5\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for agent in self.agents:\n if 0 <= agent.x < 200 and 0 <= agent.y < 100:\n state[int(agent.y) // 10, int(agent.x) // 20,\n 0 if agent is self.player else 2 if agent.team else 1] = True\n for x, y, team in self.shots:\n if 0 <= x < 200 and 0 <= y < 100:\n state[int(y) // 10, int(x) // 20, 3 + team] = True\n for dome in self.domes:\n for angle in np.linspace(math.pi, math.tau, 20):\n x, y = dome + 40 * math.cos(angle), 90 + 40 * math.sin(angle)\n if 0 <= x < 200:\n state[int(y) // 10, int(x) // 20, 5] = True\n for bit in range(9):\n state[0, bit, 5] = bool(self.steps & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 254, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/d_fight.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/dfight/main.js"} +{"name": "gloop", "split": "train", "game": "gloop", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Gloop as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nUse action 1 to move left and action 3 to move right. Other\nactions hold horizontal position. This replaces pointer sliding\nwith movement at 10 source pixels per action.\n\nThe player accelerates vertically and wraps at the top and\nbottom. Contact with an orb reverses gravity. At high speed\nthe contact also breaks the orb and clears mines within 20\nsource pixels. Clearing n mines together awards 1 + 2 + … + n\npoints. Touching an active mine ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, orbs, mines, breakable\norbs, projected vertical position, and gauges. The conversion\nuses rectangular collision checks and fixed difficulty, with\nfour frames per action. The task has a 400-action horizon. Episode scores\nare clipped to [0, 25] and divided by 25.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/gloop.py`):\n```python\nimport math\n\nimport numpy as np\n\n\nclass GloopEnvironment:\n score_cap = 25\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x = self.y = 50.0\n self.vy = 0.0\n self.gravity = -1\n self.steps = self.action = 0\n self.terminal = False\n self.orbs = [self._point() for _ in range(7)]\n self.mines: list[tuple[float, float]] = []\n\n def _point(self) -> tuple[float, float]:\n x, y = self.random.uniform(10, 90, 2)\n return x, y\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self) -> int:\n dx = {1: -2.5, 3: 2.5}.get(self.action, 0)\n self.x = min(92, max(8, self.x + dx))\n self.vy = (self.vy + 0.02 * self.gravity) * 0.99\n self.y = (self.y + self.vy) % 99\n collision_y = self.y\n while len(self.orbs) < 7:\n self.orbs.append(self._point())\n if self.random.random() < 0.02:\n x, y = self._point()\n if abs(x - self.x) + abs((y - self.y + 50) % 100 - 50) > 25:\n self.mines.append((x, y))\n surviving_orbs = []\n removed = 0\n for x, y in self.orbs:\n if abs(x - self.x) >= 5 or abs(y - collision_y) >= 4:\n surviving_orbs.append((x, y))\n continue\n if abs(self.vy) > 1:\n remaining = [mine for mine in self.mines if math.dist(mine, (x, y)) >= 20]\n removed += len(self.mines) - len(remaining)\n self.mines = remaining\n else:\n surviving_orbs.append((x, y))\n self.vy *= -0.3\n self.gravity *= -1\n self.y = y + self.gravity * 5\n self.orbs = surviving_orbs\n self.terminal = any(abs(x - self.x) < 4 and abs(y - collision_y) < 3 for x, y in self.mines)\n return removed * (removed + 1) // 2\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row, col = int(self.y) // 10, int(self.x) // 10\n state[row, col, 0] = True\n for channel, points in ((1, self.orbs), (2, self.mines)):\n for x, y in points:\n state[int(y) // 10, int(x) // 10, channel] = True\n if abs(self.vy) > 1:\n for x, y in self.orbs:\n state[int(y) // 10, int(x) // 10, 3] = True\n state[int((self.y + 10 * self.vy) % 99) // 10, col, 4] = True\n for row, value in enumerate((self.steps, round((self.vy + 2) * 100), self.action)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.gravity > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 255, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/gloop.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/gloop/main.js"} +{"name": "juggling_act", "split": "train", "game": "juggling_act", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Juggling Act as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nRelease with actions 0–4 to move automatically toward the\nnearest falling ball. Hold action 5 to catch and throw back\nballs within reach. Each catch scores the number of active\nballs. New balls arrive every 200 frames, and the run ends\nwhen none remain.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the juggler, falling balls,\nrising balls, the tracking target, catch band, and gauges.\nThe conversion runs at fixed difficulty for four frames per\naction, up to 400 actions. The normalized score clips the\nraw total to [0, 150] and divides by 150.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/juggling_act.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Ball:\n x: float\n y: float = 0.0\n vx: float = 0.0\n vy: float = 0.0\n\n\nclass JugglingActEnvironment:\n score_cap = 150\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x, self.vx = 50.0, 0.0\n self.steps = self.spawn_timer = 0\n self.pressed = self.terminal = False\n self.balls: list[Ball] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _nearest(self) -> Ball | None:\n return min((ball for ball in self.balls if ball.vy >= 0),\n key=lambda ball: abs(90 - ball.y), default=None)\n\n def _advance(self) -> int:\n if not self.pressed:\n nearest = self._nearest()\n if nearest is not None:\n self.vx += 0.36 if nearest.x > self.x else -0.36\n self.vx *= 0.85\n self.x += self.vx\n if (self.x < 5 and self.vx < 0) or (self.x > 95 and self.vx > 0):\n self.vx *= -0.5\n reward = 0\n live_count = len(self.balls)\n remaining = []\n for ball in self.balls:\n falling = ball.vy >= 0\n ball.x += ball.vx\n ball.y += ball.vy\n ball.vx *= 0.99\n ball.vy = ball.vy * 0.99 + 0.02\n if (ball.x < 0 and ball.vx < 0) or (ball.x > 100 and ball.vx > 0):\n ball.vx *= -1\n if falling and self.pressed and 82 < ball.y < 90 and abs(ball.x - self.x) < 10:\n ball.vy = -2\n ball.vx = (ball.x - self.x) / 10 + self.random.uniform(-0.1, 0.1)\n reward += live_count\n if ball.y > 100:\n live_count -= 1\n else:\n remaining.append(ball)\n self.balls = remaining\n self.spawn_timer -= 1\n if self.spawn_timer <= 0:\n self.balls.append(Ball(self.random.uniform(10, 90)))\n self.spawn_timer = 200\n self.terminal = not self.balls\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n col = min(9, max(0, int(self.x // 10)))\n state[9, col, 0] = True\n for ball in self.balls:\n if 0 <= ball.x < 100 and 0 <= ball.y < 100:\n state[int(ball.y // 10), int(ball.x // 10), 1 if ball.vy >= 0 else 2] = True\n nearest = self._nearest()\n if nearest is not None and 0 <= nearest.x < 100 and 0 <= nearest.y < 100:\n state[int(nearest.y // 10), int(nearest.x // 10), 3] = True\n state[8, max(0, col - 1):col + 2, 4] = True\n values = (self.steps, self.spawn_timer, round((self.vx + 3) * 80), round(self.x * 4))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 256, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/juggling_act.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameJugglingAct.c"} +{"name": "v_bomb", "split": "train", "game": "v_bomb", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays V Bomb as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to reverse the ship. Release with any other action\nbefore tapping again. The ship steers gradually and turns at the\nedges. Enemies drop timed bombs. Rising blasts destroy enemies\nfor points and can detonate other bombs by touching their fuses.\nEach enemy destroyed increases the multiplier until the blasts\nclear. Contact with an enemy or a blast ends the run.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the ship, enemies, bombs, blasts, ground,\nand counters. Difficulty is fixed. Rectangular overlap approximates\nsprite and fuse-text collisions. Each action advances up to four\nframes over 400 actions. Clip episode scores to [0, 100] and divide\nby 100.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/v_bomb.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Enemy:\n x: float\n y: float\n vy: float\n vx: float = 0.\n timer: float = 0.\n\n\n@dataclass\nclass Bomb:\n x: float\n y: float\n count: float\n vy: float = 0.\n\n\n@dataclass\nclass Blast:\n x: float\n y: float\n height: float = 6.\n\n\nclass VBombEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.vx, self.target = 40., 1., 1\n self.enemies, self.bombs, self.blasts = [], [], []\n self.timer = 0.\n self.multiplier = 1\n self.steps = self.action = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n turn = self.action == 5 and previous != 5\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(turn and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, turn):\n self.timer -= 1\n if self.timer < 0:\n x = -3 if self.random.random() < 0.5 else 103\n self.enemies.append(Enemy(x, self.random.uniform(70, 80), -self.random.uniform(0.01, 0.03)))\n self.timer = self.random.uniform(120, 150)\n if not self.blasts:\n self.multiplier = 1\n visible = [Blast(blast.x, blast.y, blast.height) for blast in self.blasts]\n for blast in self.blasts:\n blast.y -= 7\n blast.height += 5\n self.blasts = [blast for blast in self.blasts if blast.y + blast.height >= 0]\n reward = 0\n enemies = []\n for enemy in self.enemies:\n enemy.timer -= 1\n if enemy.timer < 0:\n if 1 < enemy.x < 99:\n self.bombs.append(Bomb(enemy.x, enemy.y, self.random.integers(3, 9) + 0.9))\n enemy.timer = self.random.uniform(200, 300)\n enemy.vx = min(0.1, max(-0.1, enemy.vx + (self.x - enemy.x) * 0.0002))\n if enemy.y < 10:\n enemy.vy = 0\n enemy.x += enemy.vx\n enemy.y += enemy.vy\n if any(_overlap(blast, enemy.x, enemy.y, 3, 3) for blast in visible):\n reward += self.multiplier\n self.multiplier += 1\n else:\n enemies.append(enemy)\n self.enemies = enemies\n\n bombs = []\n for bomb in self.bombs:\n bomb.vy += 0.1\n bomb.y = min(87, bomb.y + bomb.vy)\n fuse_y = bomb.y - (10 - bomb.count) * 2 - max(0, 1 - bomb.count) * 50\n if any(_overlap(blast, bomb.x, fuse_y, 2, 3) for blast in visible):\n bomb.count = 0\n bomb.count -= 1 / 60\n if bomb.count <= 0:\n self.blasts.append(Blast(bomb.x, bomb.y))\n else:\n bombs.append(bomb)\n self.bombs = bombs\n\n if turn or (self.x > 99 and self.target > 0) or (self.x < 1 and self.target < 0):\n self.target *= -1\n self.vx += (self.target - self.vx) * 0.1\n self.x += self.vx\n self.terminal = any(_overlap(blast, self.x, 10, 3, 3) for blast in visible) or any(\n abs(enemy.x - self.x) < 6 and abs(enemy.y - 10) < 6 for enemy in self.enemies\n )\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[1, int(np.clip(self.x // 10, 0, 9)), 0] = True\n for objects, channel in ((self.enemies, 1), (self.bombs, 2)):\n for obj in objects:\n if 0 <= obj.x < 100 and 0 <= obj.y < 100:\n state[int(obj.y // 10), int(obj.x // 10), channel] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for blast in self.blasts:\n state[:, :, 3] |= (abs(cols - blast.x) < 8) & (abs(rows - blast.y) < blast.height / 2 + 5)\n state[9, :, 4] = True\n values = (self.steps, self.action, self.target > 0, round((self.vx + 1) * 100),\n self.multiplier, round(self.timer))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n\ndef _overlap(blast, x, y, half_width, half_height):\n return abs(blast.x - x) < 3 + half_width and abs(blast.y - y) < blast.height / 2 + half_height\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 257, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/v_bomb.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/vbomb/main.js"} +{"name": "fishing_derby", "split": "train", "game": "fishing_derby", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Fishing Derby as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves Activision's one-player fishing duel against the computer. Six fish\ntravel in fixed depth rows. The first two rows are worth two pounds, the middle two four, and the\nbottom two six. Each fish remembers the side where it originated and respawns there after being\nlanded or eaten.\n\nActions 1–4 move the player's bait left, up, right, and down before a bite. When a fish is hooked,\nthe line reels upward slowly by default; action 5 reels twice as fast, action 2 adds another upward\nstep, action 4 holds depth, and horizontal actions play the fish sideways. Only one player can\nhold a hooked fish at a time. The computer targets deep fish and reels automatically.\n\nThe shark patrols unpredictably beneath the docks. Any hooked fish touching it is eaten for no\nscore and returns to its original row and side, making sideways play near the surface essential.\nThe first fisherman to land 99 pounds wins.\n\nACTION MAPPING\n0: wait or move hooked fish left\n1: move bait/fish left\n2: move bait up or reel upward\n3: move bait/fish right\n4: move bait down or hold\n5: reel hooked fish quickly\n\nINPUT CHANNEL TABLE\n0: player bait and line endpoint\n1: shark danger\n2: six fish targets\n3: computer bait and any hooked fish\n4: previous player-line and fish positions\n5: exact binary scores and hooked-fish weight\n\nSCORING, TERMINATION, AND HORIZON\nThe game ends at 99 pounds. A winning fish is clipped to the pounds remaining, so cumulative\nplayer reward cannot exceed `score_cap = 99`. Normalization is\n`min(max(raw_score, 0), 99) / 99`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/fishing_derby.py`):\n```python\nimport numpy as np\n\n\nclass FishingDerbyEnvironment:\n \"\"\"Race-to-99 fishing duel with depth values and shark interception.\"\"\"\n\n score_cap = 99.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 600):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.player_line = [2, 1]\n self.computer_line = [2, 8]\n self.previous_player_line = self.player_line.copy()\n self.previous_fish: list[list[int]] = []\n self.previous_hook_positions: dict[str, list[int]] = {}\n self.player_score = 0\n self.computer_score = 0\n self.player_hook: dict[str, object] | None = None\n self.computer_hook: dict[str, object] | None = None\n self.fish = []\n for index, row in enumerate(range(2, 8)):\n origin = \"left\" if index % 2 == 0 else \"right\"\n self.fish.append(\n {\n \"position\": [row, 0 if origin == \"left\" else 9],\n \"direction\": 1 if origin == \"left\" else -1,\n \"origin\": origin,\n \"spawn_row\": row,\n \"value\": 2 if row <= 3 else 4 if row <= 5 else 6,\n \"hooked\": None,\n }\n )\n self.shark = [1, 5]\n self.shark_direction = 1\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player_line = self.player_line.copy()\n self.previous_fish = [list(fish[\"position\"]) for fish in self.fish]\n self.previous_hook_positions = {}\n if self.player_hook is not None:\n self.previous_hook_positions[\"player\"] = list(self.player_hook[\"position\"])\n if self.computer_hook is not None:\n self.previous_hook_positions[\"computer\"] = list(self.computer_hook[\"position\"])\n self._move_player_line(action)\n self._move_computer_line()\n self._move_free_fish()\n self._move_shark()\n self._hook_fish()\n reward = self._resolve_catches()\n self.steps += 1\n if self.steps >= self.horizon or self.player_score >= 99 or self.computer_score >= 99:\n self.terminal = True\n return reward, self.terminal\n\n def _move_player_line(self, action: int) -> None:\n if self.player_hook is None:\n if action == 1:\n self.player_line[1] = max(0, self.player_line[1] - 1)\n elif action == 2:\n self.player_line[0] = max(2, self.player_line[0] - 1)\n elif action == 3:\n self.player_line[1] = min(9, self.player_line[1] + 1)\n elif action == 4:\n self.player_line[0] = min(7, self.player_line[0] + 1)\n return\n self._move_hooked_line(self.player_line, self.player_hook, action)\n\n def _move_computer_line(self) -> None:\n if self.computer_hook is not None:\n action = 5\n if self.computer_hook[\"position\"][0] <= 2 and self.computer_hook[\"position\"][1] == self.shark[1]:\n action = 1 if self.computer_line[1] > 0 else 3\n self._move_hooked_line(self.computer_line, self.computer_hook, action)\n return\n if self.player_hook is not None:\n return\n available = [fish for fish in self.fish if fish[\"hooked\"] is None]\n if not available:\n return\n target = max(available, key=lambda fish: (int(fish[\"value\"]), -abs(fish[\"position\"][1] - 8)))\n if self.computer_line[0] < target[\"position\"][0]:\n self.computer_line[0] += 1\n elif self.computer_line[0] > target[\"position\"][0]:\n self.computer_line[0] -= 1\n elif self.computer_line[1] < target[\"position\"][1]:\n self.computer_line[1] += 1\n elif self.computer_line[1] > target[\"position\"][1]:\n self.computer_line[1] -= 1\n\n @staticmethod\n def _move_hooked_line(line: list[int], fish: dict[str, object], action: int) -> None:\n line[0] -= 2 if action == 5 else 1\n if action == 1:\n line[1] = max(0, line[1] - 1)\n elif action == 2:\n line[0] -= 1\n elif action == 3:\n line[1] = min(9, line[1] + 1)\n elif action == 4:\n line[0] += 1\n fish[\"position\"] = line.copy()\n\n def _move_free_fish(self) -> None:\n for fish in self.fish:\n if fish[\"hooked\"] is not None:\n continue\n fish[\"position\"][1] += int(fish[\"direction\"])\n if fish[\"position\"][1] < 0 or fish[\"position\"][1] > 9:\n fish[\"position\"][1] %= 10\n\n def _move_shark(self) -> None:\n if self.random.rand() < 0.15:\n self.shark_direction *= -1\n self.shark[1] += self.shark_direction\n if self.shark[1] <= 0 or self.shark[1] >= 9:\n self.shark_direction *= -1\n self.shark[1] = int(np.clip(self.shark[1], 0, 9))\n\n def _hook_fish(self) -> None:\n if self.player_hook is not None or self.computer_hook is not None:\n return\n player_fish = next(\n (fish for fish in self.fish if fish[\"hooked\"] is None and fish[\"position\"] == self.player_line),\n None,\n )\n if player_fish is not None:\n player_fish[\"hooked\"] = \"player\"\n self.player_hook = player_fish\n return\n computer_fish = next(\n (fish for fish in self.fish if fish[\"hooked\"] is None and fish[\"position\"] == self.computer_line),\n None,\n )\n if computer_fish is not None:\n computer_fish[\"hooked\"] = \"computer\"\n self.computer_hook = computer_fish\n\n def _resolve_catches(self) -> float:\n reward = 0.0\n for owner in (\"player\", \"computer\"):\n fish = self.player_hook if owner == \"player\" else self.computer_hook\n if fish is None:\n continue\n previous = self.previous_hook_positions.get(owner, list(fish[\"position\"]))\n crossed_shark = (\n previous[0] >= self.shark[0] >= fish[\"position\"][0]\n and self.shark[1] in (previous[1], fish[\"position\"][1])\n )\n if fish[\"position\"] == self.shark or crossed_shark:\n self._respawn_fish(fish)\n if owner == \"player\":\n self.player_hook = None\n else:\n self.computer_hook = None\n continue\n if fish[\"position\"][0] > 0:\n continue\n value = int(fish[\"value\"])\n if owner == \"player\":\n awarded = min(value, 99 - self.player_score)\n self.player_score += awarded\n reward += float(awarded)\n self.player_hook = None\n self.player_line = [2, 1]\n else:\n self.computer_score = min(99, self.computer_score + value)\n self.computer_hook = None\n self.computer_line = [2, 8]\n self._respawn_fish(fish)\n return reward\n\n @staticmethod\n def _respawn_fish(fish: dict[str, object]) -> None:\n fish[\"position\"] = [int(fish[\"spawn_row\"]), 0 if fish[\"origin\"] == \"left\" else 9]\n fish[\"direction\"] = 1 if fish[\"origin\"] == \"left\" else -1\n fish[\"hooked\"] = None\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player_line, 0] = True\n state[*self.shark, 1] = True\n for fish in self.fish:\n state[*fish[\"position\"], 2] = True\n if fish[\"hooked\"] is not None:\n state[*fish[\"position\"], 3] = True\n state[*self.computer_line, 3] = True\n state[*self.previous_player_line, 4] = True\n for position in self.previous_fish:\n if 0 <= position[0] < 10:\n state[*position, 4] = True\n for bit in range(7):\n if self.player_score & (1 << bit):\n state[9, bit, 5] = True\n if self.computer_score & (1 << bit):\n state[8, bit, 5] = True\n if self.player_hook is not None:\n state[7, : int(self.player_hook[\"value\"]), 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 258, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/fishing_derby.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "stomping_bubbles", "split": "train", "game": "stomping_bubbles", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Stomping Bubbles as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to fall faster. Actions 0–4 release. The player moves\nsideways automatically and reverses near the edges. Contact with a\nrising bubble pops it and reverses vertical velocity. Each pop\ncreates an expanding ring that can pop nearby bubbles. Pops score\nthe current multiplier, which increases until all rings expire.\nFalling past the bottom ends the episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the player, bubbles, chain rings, heading,\nbottom boundary, and counters. The port fixes difficulty, resets\nhorizontal direction at episode start, and approximates collision\nwith geometric ring checks. Each action advances up to four frames\nover 400 actions. Clip scores to [0, 500] and divide by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/stomping_bubbles.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import hypot\n\nimport numpy as np\n\n\n@dataclass\nclass Bubble:\n x: float\n y: float\n radius: float\n speed: float\n\n\n@dataclass\nclass Chain:\n x: float\n y: float\n radius: float\n life: int = 5\n\n\nclass StompingBubblesEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 50., 0.\n self.vx, self.vy = 1.5, 0.\n self.timer = self.steps = 0\n self.multiplier = 1\n self.held = self.terminal = False\n self.bubbles, self.chains = [], []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n if self.random.random() >= self.sticky_action_prob:\n self.held = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n self.x += self.vx\n if (self.x > 95 and self.vx > 0) or (self.x < 5 and self.vx < 0):\n self.vx *= -1\n self.y += self.vy\n self.vy = (self.vy + (0.09 if self.held else 0.01)) * 0.99\n if self.y < 0 and self.vy < 0:\n self.vy *= -0.5\n self.terminal = self.y > 99\n self.timer -= 1\n if self.timer < 0:\n size = self.random.uniform(5, 9)\n self.bubbles.append(Bubble(self.random.uniform(0, 100), 102 + size,\n size, self.random.uniform(0.1, 0.3)))\n self.timer += 9\n for chain in self.chains:\n chain.radius += 1\n chain.life -= 1\n self.chains = [chain for chain in self.chains if chain.life > 0]\n active = tuple(self.chains)\n x, y = self.x, self.y\n reward = 0\n bounced = False\n remaining = []\n for bubble in self.bubbles:\n bubble.y -= bubble.speed\n dx, dy = abs(bubble.x - x), abs(bubble.y - y)\n near = hypot(max(0, dx - 2.5), max(0, dy - 2.5))\n far = hypot(dx + 2.5, dy + 2.5)\n direct = near < bubble.radius + 1 and far > bubble.radius - 1\n chained = any(self._intersects(bubble, chain) for chain in active)\n if direct or chained:\n reward += self.multiplier\n self.multiplier += 1\n self.chains.append(Chain(bubble.x, bubble.y, bubble.radius))\n if direct and not bounced:\n self.vy *= -1\n self.y += self.vy * 2\n bounced = True\n elif bubble.y >= -bubble.radius:\n remaining.append(bubble)\n self.bubbles = remaining\n if not self.chains:\n self.multiplier = 1\n return reward\n\n @staticmethod\n def _intersects(bubble, chain):\n distance = hypot(bubble.x - chain.x, bubble.y - chain.y)\n return abs(bubble.radius - chain.radius) - 2 < distance < bubble.radius + chain.radius + 2\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n row = int(np.clip(self.y // 10, 0, 9))\n state[row, int(self.x // 10), 0] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for channel, circles in ((1, self.bubbles), (2, self.chains)):\n for circle in circles:\n state[:, :, channel] |= abs(np.hypot(cols - circle.x, rows - circle.y) - circle.radius) < 7\n ahead = int(np.clip((self.x + 6 * self.vx) // 10, 0, 9))\n state[row, ahead, 3] = True\n state[9, :, 4] = True\n values = (self.steps, self.timer, self.multiplier, self.held,\n int(np.clip(round((self.vy + 15) * 16), 0, 511)))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 259, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/stomping_bubbles.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameStompingBubbles.c"} +{"name": "jet_stream", "split": "train", "game": "jet_stream", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Jet Stream as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to cycle through the upper, middle, lower,\nand middle lanes. Actions 0–4 release the button. The outer\nlanes carry you left and the middle lane carries you right.\nLeaving the screen ends the run.\n\nYour wake destroys a barrier when it hits a rotating blade.\nThis scores the current multiplier and raises it up to 16.\nA missed barrier lowers the multiplier, while hitting a\nbarrier core knocks you back. The conversion approximates\ncollisions with distances and removes barriers on contact\nwithout simulating their visual fade.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the surfer, wake, barriers by\ndirection, target lane, and gauges. Each action advances\nfour frames at fixed difficulty. The 400-action task clips\nraw scores to [0, 60] and divides by 60.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/jet_stream.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Wake:\n x: float\n y: float\n vx: float\n life: int = 24\n\n\n@dataclass\nclass Barrier:\n x: float\n lane: int\n phase: float\n rotation: float = 0\n\n @property\n def y(self) -> int:\n return 25 + 25 * self.lane\n\n\nclass JetStreamEnvironment:\n score_cap = 60\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x, self.y = 50.0, 25.0\n self.vx = self.vy = self.tap_impulse = 0.0\n self.lane_step = self.frames = self.steps = self.spawn_timer = 0\n self.spawn_interval = 120.0\n self.multiplier = 1\n self.pressed = self.terminal = False\n self.wake: list[Wake] = []\n self.barriers: list[Barrier] = []\n\n @property\n def lane(self) -> int:\n return (0, 1, 2, 1)[self.lane_step]\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed:\n self.lane_step = (self.lane_step + 1) % 4\n self.vx += self.tap_impulse\n self.vy -= 1\n self.tap_impulse += 1\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self) -> int:\n self.frames += 1\n self.tap_impulse *= 0.9\n self.y += (21 + self.lane * 25 - self.y) * 0.1 + self.vy\n drift = 1 if self.lane == 1 else -1\n self.x += self.vx + 0.5 * drift\n self.vx *= 0.9\n self.vy *= 0.9\n if self.frames % 3 == 0:\n self.wake.append(Wake(self.x - drift * 5, self.y + 4, -drift * 0.3))\n for particle in self.wake:\n particle.x += particle.vx\n particle.y -= 0.1\n particle.life -= 1\n self.wake = [p for p in self.wake if p.life and -5 <= p.x <= 105]\n self.spawn_timer += 1\n if self.spawn_timer >= self.spawn_interval + self.random.uniform(-30, 30):\n lane = int(self.random.integers(3))\n self.barriers.append(Barrier(110 if lane == 1 else -10, lane, self.random.uniform(0, math.tau)))\n self.spawn_timer = 0\n self.spawn_interval = self.random.uniform(100, 140)\n reward = 0\n remaining = []\n for barrier in self.barriers:\n direction = -1 if barrier.lane == 1 else 1\n barrier.x += direction\n barrier.rotation += 0.15 * direction\n barrier.phase += 0.2\n if self._wake_hit(barrier):\n reward += self.multiplier\n self.multiplier = min(16, self.multiplier + 1)\n elif math.hypot(self.x - barrier.x, self.y - barrier.y) < 6 + 0.9 * math.sin(barrier.phase):\n self.vx += direction * 3\n self.vy += self.random.uniform(-0.5, 0.5)\n elif not -15 <= barrier.x <= 115:\n self.multiplier = max(1, self.multiplier - 1)\n else:\n remaining.append(barrier)\n self.barriers = remaining\n self.terminal = not -3 <= self.x <= 103\n return reward\n\n def _wake_hit(self, barrier: Barrier) -> bool:\n for blade in range(4):\n angle = barrier.rotation + blade * math.pi / 2\n x = barrier.x + 6 * math.cos(angle)\n y = barrier.y + 6 * math.sin(angle)\n if any(math.hypot(p.x - x, p.y - y) < 3.5 + (24 - p.life) / 24 for p in self.wake):\n return True\n return False\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, max(0, int(self.y) // 10)), min(9, max(0, int(self.x) // 10)), 0] = True\n for particle in self.wake:\n if 0 <= particle.x < 100 and 0 <= particle.y < 100:\n state[int(particle.y) // 10, int(particle.x) // 10, 1] = True\n for barrier in self.barriers:\n if 0 <= barrier.x < 100:\n state[barrier.y // 10, int(barrier.x) // 10, 2 + (barrier.lane == 1)] = True\n state[(21 + self.lane * 25) // 10, :, 4] = True\n for row, value in enumerate((self.steps, self.multiplier, self.lane_step,\n min(511, max(0, round((self.vx + 10) * 20))))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 260, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/jet_stream.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameJetStream.c"} +{"name": "cling_hop", "split": "train", "game": "cling_hop", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Cling Hop as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to flap upward or detach from a platform. Release\nwith actions 0–4 before tapping again. Descend near a platform\nto cling to it. Clinging scores one point per frame, and switching\nplatforms pays a bonus equal to the number of live obstacles.\n\nINPUT CHANNEL TABLE\nAirborne contact pops an obstacle. Contact while clinging ends\nthe run, as does falling below the arena. The six 10×10 channels\nshow the player, platforms, obstacles, attachment, upward motion,\nand gauges. Each action advances four frames at fixed difficulty.\nThe conversion uses rectangular obstacle collisions and spawns\nobstacles just inside the arena so they enter moving inward.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 1000] and divide by the fixed cap of 1,000. Across 100 seeds\nwithout sticky actions, idle and always held scored zero. Random\ninputs averaged 1.56 raw points. A heuristic that flapped when\nfalling below height 65 while airborne averaged 123.72 and reached\n191, with height measured downward from the top.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/cling_hop.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Platform:\n x: float\n y: float\n width: float\n phase: float\n identity: int\n\n def center(self, frame: int) -> float:\n return min(98 - self.width / 2, max(self.width / 2 + 2,\n self.x + 20 * math.sin(frame * 0.05 + self.phase)))\n\n\n@dataclass\nclass Obstacle:\n x: float\n y: float\n vx: float\n vy: float\n\n def advance(self) -> None:\n self.x += self.vx\n self.y += self.vy\n if not 3 <= self.x <= 97:\n self.x = min(97, max(3, self.x))\n self.vx *= -1\n if not 3 <= self.y <= 97:\n self.y = min(97, max(3, self.y))\n self.vy *= -1\n\n\nclass ClingHopEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.frame = self.obstacle_timer = 0\n self.pressed = self.terminal = False\n self.x = self.y = 50.0\n self.vy = 0.0\n self.support: Platform | None = None\n self.last_platform = -1\n self.platforms: list[Platform] = []\n self.obstacles: list[Obstacle] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance_frame(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self, flap: bool) -> int:\n if self.frame % 90 == 0:\n self.platforms.append(Platform(self.random.uniform(20, 80), -5,\n self.random.uniform(15, 30), self.random.uniform(0, math.tau),\n self.frame))\n self.obstacle_timer -= 1\n if self.obstacle_timer < 0 or not self.obstacles:\n direction = 1 if self.x > 50 else -1\n self.obstacles.append(Obstacle(3 if direction > 0 else 97, self.random.uniform(20, 60),\n direction * self.random.uniform(0.5, 1.2), self.random.uniform(-1, 1)))\n self.obstacle_timer = 180\n\n reward = 0\n if self.support is None:\n self.vy = -2.2 if flap else self.vy + 0.12\n self.y += self.vy\n else:\n self.x = self.support.center(self.frame)\n self.y = self.support.y + 7\n self.vy = 0\n reward += 1\n if flap:\n self.support = None\n self.vy = -2.5\n self.terminal = self.y > 105\n\n for platform in self.platforms:\n platform.y += 0.3\n if (self.support is None and self.vy > 0 and -3 < self.y - platform.y < 8\n and abs(self.x - platform.center(self.frame)) < platform.width / 2 + 3):\n self.support = platform\n if platform.identity != self.last_platform:\n self.last_platform = platform.identity\n reward += len(self.obstacles)\n self.platforms = [platform for platform in self.platforms if platform.y < 110]\n if self.support is not None and self.support.y >= 110:\n self.support = None\n\n survivors = []\n for obstacle in self.obstacles:\n obstacle.advance()\n if abs(obstacle.x - self.x) < 5 and abs(obstacle.y - self.y) < 5:\n if self.support is not None:\n self.terminal = True\n survivors.append(obstacle)\n else:\n survivors.append(obstacle)\n self.obstacles = survivors\n self.frame += 1\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row, col = min(9, max(0, int(self.y) // 10)), int(self.x) // 10\n state[row, col, 0] = True\n state[row, col, 3] = self.support is not None\n state[row, col, 4] = self.vy < 0\n for platform in self.platforms:\n if 0 <= platform.y < 100:\n x = platform.center(self.frame)\n left = int(x - platform.width / 2) // 10\n right = int(x + platform.width / 2) // 10\n state[int(platform.y) // 10, left:right + 1, 1] = True\n for obstacle in self.obstacles:\n state[int(obstacle.y) // 10, int(obstacle.x) // 10, 2] = True\n for row, value in enumerate((self.steps, len(self.obstacles), self.obstacle_timer)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 261, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/cling_hop.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameClingHop.c"} +{"name": "ns_climb", "split": "train", "game": "ns_climb", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Ns Climb as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to reverse polarity. Actions 0–4 release the\nbutton. Opposite poles attract and matching poles repel.\nNeutral wall blocks exert no force. Wall contact pushes\nthe player inward. Climbing earns the scroll distance,\nand falling below the screen ends the run.\n\nINPUT CHANNEL TABLE\nSix 10×10 channels show the player, south magnets, neutral\nblocks, north magnets, projected position, and gauges. The\nconversion uses fixed difficulty and four frames per action.\nThe 400-action task clips scores to [0, 1500] and divides\nby 1500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/ns_climb.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Wall:\n x: float\n count: int\n vx: float = 0\n pole: int = 0\n previous: int = -1\n\n\n@dataclass\nclass Magnet:\n x: float\n y: float\n side: int\n pole: int\n\n\nclass NsClimbEnvironment:\n score_cap = 1500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y, self.vx, self.vy = 50.0, 90.0, 0.0, -1.0\n self.pole = 1\n self.steps = 0\n self.pressed = self.terminal = False\n self.walls = [Wall(x, int(self.random.integers(2, 4))) for x in (20, 80)]\n self.magnets = [Magnet((20, 80)[i % 2], i * 5 - 5, i % 2, -1 if i < 10 else 0)\n for i in range(22)]\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed:\n self.pole *= -1\n self.pressed = pressed\n self.steps += 1\n reward = 0.0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _advance(self):\n self.x += self.vx\n self.y += self.vy\n self.vx *= 0.98\n self.vy += 0.001\n if self.y > 99:\n self.terminal = True\n return 0.0\n scroll = max(0, 70 - self.y) * 0.1\n self.y += scroll\n for magnet in self.magnets:\n magnet.y += scroll\n dx, dy = magnet.x - self.x, magnet.y - self.y\n distance = math.hypot(dx, dy)\n if magnet.pole and distance:\n force = -magnet.pole * self.pole / distance ** 3\n self.vx += dx * force\n self.vy += dy * force\n if abs(dx) < 8 and abs(dy) < 8:\n inward = 1 if magnet.side == 0 else -1\n self.x = magnet.x + 10 * inward\n if self.vx * inward < 0:\n self.vx *= -0.7\n if magnet.y > 105:\n self._recycle(magnet)\n return scroll\n\n def _recycle(self, magnet):\n magnet.y -= 110\n wall = self.walls[magnet.side]\n wall.x += wall.vx\n magnet.x = wall.x\n wall.vx += self.random.uniform(-0.1, 0.1)\n low = 10 + magnet.side * 50\n if (wall.x < low and wall.vx < 0) or (wall.x > low + 30 and wall.vx > 0):\n wall.vx *= -0.5\n wall.count -= 1\n if wall.count < 0:\n if wall.pole:\n wall.pole = 0\n wall.count = int(self.random.integers(2, 4))\n else:\n wall.pole = wall.previous = -wall.previous\n wall.count = int(self.random.integers(3, 9))\n magnet.pole = wall.pole\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n row = min(9, max(0, int(self.y // 10)))\n col = min(9, max(0, int(self.x // 10)))\n state[row, col, 0] = True\n for magnet in self.magnets:\n if 0 <= magnet.x < 100 and 0 <= magnet.y < 100:\n state[int(magnet.y // 10), int(magnet.x // 10), 2 + magnet.pole] = True\n row = min(9, max(0, int((self.y + 4 * self.vy) // 10)))\n col = min(9, max(0, int((self.x + 4 * self.vx) // 10)))\n state[row, col, 4] = True\n for row, value in enumerate((self.steps, round((self.vy + 5) * 40), round((self.vx + 5) * 40))):\n for bit in range(9):\n state[row, bit, 5] = bool(min(511, max(0, value)) & (1 << bit))\n state[9, :2, 5] = self.pressed, self.pole == 1\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 262, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/ns_climb.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/nsclimb/main.js"} +{"name": "up_n_down", "split": "train", "game": "up_n_down", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Up N Down as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves the vertically advancing and reversing Baja Bugger, branching and\nintersecting roads, lane choices, forward-only jumps, off-road landings, enemy collisions, jumping\nonto four opponent classes, eight persistent flags per round, four prize types, five default easy\nlives, and the complete progression through increasingly difficult roads one through nine.\n\nACTION MAPPING\n0: coast\n1: take the left branch/lane\n2: accelerate forward\n3: take the right branch/lane\n4: reverse slowly\n5: jump while moving forward\n\nINPUT CHANNEL TABLE\n0: Baja Bugger\n1: opponent cars\n2: flags\n3: prizes\n4: visible road lanes and junctions\n5: exact round, course position, lane, lives, speed, jump, flags, opponents, and direction\n\nSCORING, TERMINATION, AND HORIZON\nEach round has eight 75-point flags (600), one cherry/balloon/lollypop/ice-cream prize worth\n50+65+70+75=260, and two of each 100/125/150/175-point opponent worth 1,100. The finite maximum\nis therefore `9 × (600 + 260 + 1,100) = 17,640`. Normalization is\n`min(max(raw_score, 0), 17_640) / 17_640`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/up_n_down.py`):\n```python\nimport numpy as np\n\n\nLANE_COLUMNS = (2, 5, 8)\nFLAG_SCORE = 75\nPRIZE_SCORES = (50, 65, 70, 75)\nOPPONENT_SCORES = (100, 125, 150, 175)\nCOURSE_LENGTH = 80\n\n\ndef road_lanes(position: int) -> frozenset[int]:\n segment = position % COURSE_LENGTH\n if segment < 8:\n return frozenset((1,))\n if segment < 16:\n return frozenset((0, 1))\n if segment < 24:\n return frozenset((0, 1, 2))\n if segment < 36:\n return frozenset((0, 2))\n if segment < 44:\n return frozenset((0, 1, 2))\n if segment < 56:\n return frozenset((1, 2))\n if segment < 64:\n return frozenset((0, 1, 2))\n return frozenset((1,))\n\n\nclass UpNDownEnvironment:\n \"\"\"Nine finite roads of branching, jumping Atari 2600 racing.\"\"\"\n\n score_cap = 17_640.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 4_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.round = 0\n self.lives = 5\n self.score = 0.0\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self._start_round()\n\n def _start_round(self) -> None:\n self.position = 0\n self.lane = 1\n self.direction = 1\n self.speed = 1\n self.airborne = 0\n self.flags = {\n (position, lane): identifier\n for identifier, (position, lane) in enumerate(\n ((10, 1), (18, 0), (22, 2), (30, 0), (34, 2), (48, 1), (58, 2), (70, 1))\n )\n }\n self.prizes = {\n (position, lane): identifier\n for identifier, (position, lane) in enumerate(((13, 0), (27, 2), (51, 1), (62, 0)))\n }\n opponent_positions = ((15, 0), (20, 2), (29, 0), (33, 2), (46, 1), (54, 2), (61, 0), (73, 1))\n self.opponents = [\n {\n \"id\": identifier,\n \"kind\": identifier // 2,\n \"position\": position,\n \"lane\": lane,\n \"direction\": -1 if identifier % 2 else 1,\n }\n for identifier, (position, lane) in enumerate(opponent_positions)\n ]\n self.collected_flags: set[int] = set()\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n if action == 1:\n self._change_lane(-1)\n elif action == 2:\n self.direction = 1\n self.speed = 2\n elif action == 3:\n self._change_lane(1)\n elif action == 4:\n self.direction = -1\n self.speed = 1\n elif action == 5 and self.direction > 0 and self.airborne == 0:\n self.airborne = 3\n reward = self._advance()\n self.score += reward\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _change_lane(self, delta: int) -> None:\n destination = self.lane + delta\n if 0 <= destination < 3 and destination in road_lanes(self.position):\n self.lane = destination\n\n def _advance(self) -> float:\n reward = 0.0\n previous_position = self.position\n self.position = (self.position + self.direction * self.speed) % COURSE_LENGTH\n if self.airborne > 0:\n self.airborne -= 1\n if self.lane not in road_lanes(self.position) and self.airborne == 0:\n self._lose_life()\n return reward\n flag = self.flags.pop((self.position, self.lane), None)\n if flag is not None:\n self.collected_flags.add(flag)\n reward += FLAG_SCORE\n prize = self.prizes.pop((self.position, self.lane), None)\n if prize is not None:\n reward += PRIZE_SCORES[prize]\n for opponent in self.opponents:\n opponent[\"position\"] = (opponent[\"position\"] + opponent[\"direction\"]) % COURSE_LENGTH\n collisions = [\n opponent\n for opponent in self.opponents\n if opponent[\"position\"] == self.position and opponent[\"lane\"] == self.lane\n ]\n if collisions:\n if self.airborne > 0:\n for opponent in collisions:\n reward += OPPONENT_SCORES[opponent[\"kind\"]]\n collided_ids = {opponent[\"id\"] for opponent in collisions}\n self.opponents = [opponent for opponent in self.opponents if opponent[\"id\"] not in collided_ids]\n else:\n self._lose_life()\n if len(self.collected_flags) == 8:\n self.round += 1\n if self.round == 9:\n self.terminal = True\n else:\n self._start_round()\n elif previous_position > self.position and self.direction > 0:\n self.speed = 1\n return float(reward)\n\n def _lose_life(self) -> None:\n self.lives -= 1\n self.position = 0\n self.lane = 1\n self.direction = 1\n self.speed = 1\n self.airborne = 0\n if self.lives == 0:\n self.terminal = True\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[8, LANE_COLUMNS[self.lane], 0] = True\n for row in range(10):\n world_position = (self.position + 8 - row) % COURSE_LENGTH\n for lane in road_lanes(world_position):\n state[row, LANE_COLUMNS[lane], 4] = True\n for (position, lane), _identifier in self.flags.items():\n row = 8 - ((position - self.position) % COURSE_LENGTH)\n if 0 <= row < 10:\n state[row, LANE_COLUMNS[lane], 2] = True\n for (position, lane), _identifier in self.prizes.items():\n row = 8 - ((position - self.position) % COURSE_LENGTH)\n if 0 <= row < 10:\n state[row, LANE_COLUMNS[lane], 3] = True\n for opponent in self.opponents:\n row = 8 - ((opponent[\"position\"] - self.position) % COURSE_LENGTH)\n if 0 <= row < 10:\n state[row, LANE_COLUMNS[opponent[\"lane\"]], 1] = True\n values = (\n (self.round, 4),\n (self.position, 7),\n (self.lane, 2),\n (self.lives, 3),\n (self.speed, 2),\n (self.airborne, 2),\n (len(self.collected_flags), 4),\n (len(self.opponents), 4),\n )\n offset = 0\n for value, width in values:\n for bit in range(width):\n state[offset // 10, offset % 10, 5] = bool(value & (1 << bit))\n offset += 1\n state[3, 0, 5] = self.direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 263, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/up_n_down.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "flip_o", "split": "train", "game": "flip_o", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Flip O as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to toggle the two flippers. Release with actions\n0–4 before the next tap. Flipping boosts a ball touching a\nflipper and resets that ball's combo. Fixed ramps can also\nbounce balls back into play.\n\nBreaking a block scores the ball's combo times the number of\nactive balls. Special blocks release an extra ball. The run\nends when every ball drains or a block reaches a ramp or flipper.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show balls, ordinary blocks, extra-ball\nblocks, ramps, flippers, and gauges. Each action advances four\nframes at fixed difficulty. The conversion uses geometric\ncollisions and a fixed upward flipper boost. Balls pass through\none another.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action task clips raw scores to [0, 1000] and divides by\n1,000. Across 100 seeds without sticky actions, idle and a simple\nheight-triggered tap policy scored zero. Random inputs averaged\n3.11 and reached 68.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/flip_o.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Ball:\n x: float = 80\n y: float = 10\n vx: float = 1\n vy: float = 0\n combo: int = 1\n\n\n@dataclass\nclass Block:\n x: float\n y: float\n extra_ball: bool\n\n\n@dataclass\nclass Bar:\n x: float\n y: float\n angle: float\n length: float\n\n def touches(self, x: float, y: float, radius: float) -> bool:\n cos, sin = math.cos(self.angle), math.sin(self.angle)\n dx, dy = x - self.x, y - self.y\n along = min(self.length, max(0, dx * cos + dy * sin))\n return math.hypot(dx - along * cos, dy - along * sin) < radius\n\n def bounce(self, ball: Ball, boost: bool = False) -> None:\n nx, ny = -math.sin(self.angle), math.cos(self.angle)\n if ny > 0:\n nx, ny = -nx, -ny\n inward = ball.vx * nx + ball.vy * ny\n if inward < 0:\n ball.vx -= 1.7 * inward * nx\n ball.vy -= 1.7 * inward * ny\n if boost:\n ball.vy -= 4\n ball.combo = 1\n for _ in range(8):\n if not self.touches(ball.x, ball.y, 3.5):\n break\n ball.x += nx\n ball.y += ny\n\n\nRAMPS = (Bar(7, 75, 0.5, 25), Bar(94, 75, math.pi - 0.5, 25))\n\n\nclass FlipOEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = 0\n self.pressed = self.flipped = self.terminal = False\n self.next_block = 0.0\n self.balls = [Ball()]\n self.blocks: list[Block] = []\n\n def _flippers(self) -> tuple[Bar, Bar]:\n angle = -0.5 if self.flipped else 0.5\n return Bar(33, 88, angle, 12), Bar(68, 88, math.pi + angle, 12)\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap: bool) -> int:\n deepest = max((block.y for block in self.blocks), default=0)\n scroll = (30 - deepest) * 0.1 if deepest < 29 else 0.02\n if tap:\n scroll += 0.3 * len(self.balls)\n self.flipped = not self.flipped\n flippers = self._flippers()\n bars = RAMPS + flippers\n for block in self.blocks:\n block.y += scroll\n if any(bar.touches(block.x, block.y, 6) for bar in bars):\n self.terminal = True\n\n reward = 0\n count = len(self.balls)\n spawned = []\n for ball in self.balls:\n previous_y = ball.y + scroll\n ball.vy = (ball.vy + 0.1) * 0.99\n ball.vx *= 0.99\n ball.x += ball.vx * 0.5\n ball.y = previous_y + ball.vy * 0.5\n if ball.x < 7 or ball.x > 93:\n ball.x = min(93, max(7, ball.x))\n ball.vx *= -0.7\n if ball.y < 7:\n ball.y, ball.vy = 7, abs(ball.vy) * 0.7\n survivors = []\n for block in self.blocks:\n if abs(block.x - ball.x) < 6.5 and abs(block.y - ball.y) < 4.5:\n reward += ball.combo * count\n ball.combo += 1\n if abs(previous_y - block.y) >= 4.5:\n ball.vy *= -0.7\n else:\n ball.vx *= -0.7\n if block.extra_ball:\n spawned.append(Ball(block.x, block.y))\n else:\n survivors.append(block)\n self.blocks = survivors\n for bar in RAMPS:\n if bar.touches(ball.x, ball.y, 3.5):\n bar.bounce(ball)\n for bar in flippers:\n if bar.touches(ball.x, ball.y, 3.5):\n bar.bounce(ball, boost=tap)\n self.balls = [ball for ball in self.balls if ball.y <= 101] + spawned\n self.terminal |= not self.balls\n if self.balls:\n self._spawn(scroll)\n return reward\n\n def _spawn(self, scroll: float) -> None:\n self.next_block -= scroll\n while self.next_block < 0:\n for offset in (5, 15, 25, 35):\n if self.random.random() < 0.5:\n for x in (50 - offset, 50 + offset):\n self.blocks.append(Block(x, -self.next_block, self.random.random() < 0.1 / len(self.balls)))\n self.next_block += 6\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for ball in self.balls:\n if 0 <= ball.y < 100:\n state[int(ball.y) // 10, int(ball.x) // 10, 0] = True\n for block in self.blocks:\n if 0 <= block.y < 100:\n state[int(block.y) // 10, int(block.x) // 10, 2 if block.extra_ball else 1] = True\n for index, bar in enumerate(RAMPS + self._flippers()):\n for distance in np.linspace(0, bar.length, 10):\n x, y = bar.x + distance * math.cos(bar.angle), bar.y + distance * math.sin(bar.angle)\n state[int(y) // 10, int(x) // 10, 3 + int(index >= 2)] = True\n for row, value in enumerate((self.steps, len(self.balls))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.flipped, self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 264, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/flip_o.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-11-games/blob/6fea4eefe2deaa42706051d96a04ec9e36104696/docs/flipo/main.js"} +{"name": "window_washer", "split": "train", "game": "window_washer", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Window Washer as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to raise the platform. Release with any other action\nto lower it. The platform moves sideways automatically and reverses\nat the edges. Touch dirty windows to clean them and earn the current\nmultiplier, then raise it by one. A dirty window that cycles offscreen\nlowers the multiplier. Avoid birds and stationary obstacles.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the platform, dirty windows, clean\nwindows, birds, stationary obstacles, and counters. The port fixes\ndifficulty and approximates bird sprites with rectangles. Each\naction advances up to four frames over 400 actions. Clip episode\nscores to [0, 200] and divide by 200.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/window_washer.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Window:\n x: float\n y: float\n clean: bool = False\n\n\n@dataclass\nclass Obstacle:\n x: float\n y: float\n vx: float\n\n\nclass WindowWasherEnvironment:\n score_cap = 200\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y, self.vx = 50., 10., 1\n self.windows = [Window(self.random.uniform(15, 85), 20 + i * 30) for i in range(10)]\n self.obstacles = []\n self.distance = 0.\n self.scroll = 0.5\n self.multiplier = 1\n self.steps = self.action = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n self.x += self.vx\n if self.x < 10 or self.x > 90:\n self.vx *= -1\n self.y = min(95, max(5, self.y + (-1.5 if self.action == 5 else 1)))\n reward = 0\n for window in self.windows:\n window.y -= self.scroll\n if window.y < -30:\n window.y += 330\n if not window.clean:\n self.multiplier = max(1, self.multiplier - 1)\n window.clean = False\n if not window.clean and self._overlaps(window.x, window.y, 7.5, 10):\n window.clean = True\n reward += self.multiplier\n self.multiplier += 1\n\n for obstacle in self.obstacles:\n obstacle.y -= self.scroll\n obstacle.x += obstacle.vx\n if obstacle.x < 5 or obstacle.x > 95:\n obstacle.vx *= -1\n half_width, half_height = (3, 3) if obstacle.vx else (5, 7)\n self.terminal |= self._overlaps(obstacle.x, obstacle.y, half_width, half_height)\n self.obstacles = [obstacle for obstacle in self.obstacles if obstacle.y >= -10]\n self.distance -= self.scroll\n if self.distance < 0:\n self._spawn()\n self.scroll = 0.6\n return reward\n\n def _overlaps(self, x, y, half_width, half_height):\n return abs(x - self.x) < 10 + half_width and abs(y - self.y) < 2.5 + half_height\n\n def _spawn(self):\n bird = self.random.random() < 0.5\n x = self.random.uniform(15, 85)\n bird |= any(not window.clean and abs(window.x - x) < 14.5 and abs(window.y - 110) < 19\n for window in self.windows)\n speed = self.random.choice((-0.5, 0.5)) if bird else 0.\n self.obstacles.append(Obstacle(x, 110, speed))\n self.distance += self.random.uniform(40, 50)\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n state[:, :, 0] = (abs(rows - self.y) < 7.5) & (abs(cols - self.x) < 15)\n for window in self.windows:\n state[:, :, 2 if window.clean else 1] |= (\n (abs(rows - window.y) < 15) & (abs(cols - window.x) < 12.5)\n )\n for obstacle in self.obstacles:\n half_width, half_height = (3, 3) if obstacle.vx else (5, 7)\n state[:, :, 3 if obstacle.vx else 4] |= (\n (abs(rows - obstacle.y) < half_height + 5)\n & (abs(cols - obstacle.x) < half_width + 5)\n )\n values = (self.steps, self.action, self.vx > 0, self.multiplier, round(self.distance * 4),\n round(self.x * 4), round(self.y * 4))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 265, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/window_washer.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameWindowWasher.c"} +{"name": "bottop", "split": "train", "game": "bottop", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Bottop as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to send both runners jumping toward the center.\nHolding reduces deceleration and extends the jump. Release with\nactions 0–4 to shorten it. Holding through landing starts another\njump. Either runner hitting a spike ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the top runner, bottom runner,\nspikes, rails, jump status, and episode steps. Each action\nadvances four frames at fixed scroll speed. The conversion uses\nrectangular collision checks in place of sprite collisions.\n\nSCORING, TERMINATION, AND HORIZON\nEach simulated frame scores 0.1 points, including the collision\nframe. The 400-action horizon caps the raw score at 160.\nClip to [0, 160] and divide by 160.\n\nAcross 100 seeds without sticky actions, always released averaged\n14.93 raw points, always held averaged 17.49, and random inputs\naveraged 13.93. Their respective maxima were 59.1, 42.3, and 50.5.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/bottop.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\n\n\n@dataclass\nclass Spike:\n x: float\n y: float\n\n\nclass BottopEnvironment:\n score_cap = HORIZON * FRAMES_PER_STEP / 10\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = 0\n self.spawn_distance = self.height = self.velocity = 0.0\n self.jumping = self.pressed = self.terminal = False\n self.spikes: list[Spike] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n frames = 0\n for _ in range(FRAMES_PER_STEP):\n self._advance_frame()\n frames += 1\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return frames / 10, self.terminal\n\n def _advance_frame(self) -> None:\n self.spawn_distance -= 1\n if self.spawn_distance < 0:\n if self.random.random() < 0.33:\n y = float(self.random.choice((8, 92)))\n else:\n y = self.random.uniform(8, 92)\n self.spikes.append(Spike(103, y))\n self.spawn_distance += self.random.uniform(30, 60)\n for spike in self.spikes:\n spike.x -= 1\n self.spikes = [spike for spike in self.spikes if spike.x > -3]\n\n if not self.jumping and self.pressed:\n self.jumping = True\n self.velocity = 3\n if self.jumping:\n self.velocity -= 0.1 if self.pressed else 0.3\n self.height += self.velocity\n if self.height < 0:\n self.height = self.velocity = 0\n self.jumping = False\n top, bottom = 8 + self.height, 92 - self.height\n self.terminal = any(\n abs(spike.x - 9) < 6 and min(abs(spike.y - top), abs(spike.y - bottom)) < 6\n for spike in self.spikes\n )\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(8 + self.height) // 10, 0, 0] = True\n state[int(92 - self.height) // 10, 0, 1] = True\n for spike in self.spikes:\n if 0 <= spike.x < 100:\n state[int(spike.y) // 10, int(spike.x) // 10, 2] = True\n state[(0, 9), :, 3] = True\n state[0, :3, 4] = self.pressed, self.jumping, self.velocity > 0\n for bit in range(9):\n state[9, bit, 5] = bool(self.steps & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 266, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/bottop.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/bottop/main.js"} +{"name": "b_walls", "split": "train", "game": "b_walls", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays B Walls as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to fire a single upward shot from the center. Actions\n0–4 release the button. Fire through gaps in the descending walls\nto destroy the targets behind them. One shot can destroy several\ntargets, doubling the reward for each successive hit. Walls alternate\nbetween sliding and stationary phases. That phase clock pauses while\na shot remains active. During the moving phase, a shot expires once\nit passes the lowest remaining wall. A solid wall reaching the\nplayer ends the episode.\n\nINPUT CHANNEL TABLE\nChannels show player, wall segments, targets, shot, the next shifted\nwall pattern, and gauges. The grid conversion replaces continuous\nscroll with timed one-row advances, including extra advances just\nafter firing. Each wall has a seeded repeating gap pattern.\n\nSCORING, TERMINATION, AND HORIZON\nA shot traverses at most nine scoring rows and can score once per\nstep, so a hit pays at most 256. The 400-step horizon gives a\nconservative cap of 102,400. A destroyed target and its wall are\nremoved together. Normalize by clipping to [0, 102400] and dividing\nby 102400.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/b_walls.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\nHORIZON = 400\nCOLUMN = 5\nPLAYER_ROW = 9\nPHASE_LENGTH = 6\n\n\n@dataclass\nclass Wall:\n row: int\n phase: int\n width: int\n period: int\n direction: int\n\n def blocks(self, column: int) -> bool:\n return (column - self.phase) % self.period < self.width\n\n\nclass BWallsEnvironment:\n score_cap = HORIZON * 2 ** (PLAYER_ROW - 1)\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.wall_clock = self.last_action = self.travel = 0\n self.multiplier = 1\n self.shot: int | None = None\n self.terminal = False\n self.walls: list[Wall] = []\n self._spawn(3)\n self._spawn(0)\n\n def _spawn(self, row: int) -> None:\n width = int(self.random.integers(1, 3))\n period = width + int(self.random.integers(2, 5))\n self.walls.append(Wall(row, int(self.random.integers(period)), width, period,\n int(self.random.choice((-1, 1)))))\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n @property\n def stopped(self) -> bool:\n return self.wall_clock // PHASE_LENGTH % 2 == 1\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n if action == 5 and self.last_action != 5 and self.shot is None:\n self.shot = PLAYER_ROW\n self.multiplier = 1\n self.last_action = action\n self.steps += 1\n moving = not self.stopped\n if moving:\n for wall in self.walls:\n wall.phase = (wall.phase + wall.direction) % wall.period\n\n near_launch = self.shot is not None and self.shot >= 7\n if near_launch or self.steps % (5 if self.steps < 200 else 4) == 0:\n self.travel += 1\n for wall in self.walls:\n wall.row += 1\n if self.travel % 3 == 0:\n self._spawn(0)\n\n reward = 0\n if self.shot is not None:\n self.shot -= 1\n if self.shot < 0 or any(wall.row == self.shot and wall.blocks(COLUMN) for wall in self.walls):\n self.shot = None\n else:\n for wall in self.walls:\n if wall.row - 1 == self.shot:\n reward = self.multiplier\n self.multiplier *= 2\n self.walls.remove(wall)\n break\n if moving and self.shot < max((wall.row for wall in self.walls), default=-2) + 1:\n self.shot = None\n if self.shot is None:\n self.wall_clock += 1\n self.terminal = any(wall.row == PLAYER_ROW and wall.blocks(COLUMN) for wall in self.walls)\n self.walls = [wall for wall in self.walls if wall.row <= PLAYER_ROW]\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[PLAYER_ROW, COLUMN, 0] = True\n if self.shot is not None:\n state[self.shot, COLUMN, 3] = True\n for wall in self.walls:\n for column in range(10):\n state[wall.row, column, 1] = wall.blocks(column)\n state[wall.row, column, 4] = (column - wall.phase - wall.direction) % wall.period < wall.width\n if wall.row > 0:\n state[wall.row - 1, COLUMN, 2] = True\n for row, value in enumerate((self.steps, self.wall_clock % (2 * PHASE_LENGTH),\n self.travel % 3, self.multiplier, self.last_action)):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 267, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/b_walls.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBWalls.c"} +{"name": "pulse_stream", "split": "train", "game": "pulse_stream", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Pulse Stream as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to push bubbles near a wave in the same lane. Use actions\n0–4 to release before tapping again. Each hit scores one point and\npushing a bubble off the right edge scores two more. A missed bubble\nmoves left faster. A bubble leaving on the left disables its lane,\nwhich recovers after 36 taps. Losing three lanes ends the episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show wave reach, leftward bubbles, rightward\nbubbles, disabled lanes, recovery progress, and counters. The port\nkeeps the lane physics at fixed difficulty and omits decorative wave\nmotion. Each action advances up to four frames for up to 400 actions.\nClip the episode score to [0, 100] and divide by 100.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/pulse_stream.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import hypot\n\nimport numpy as np\n\n\n@dataclass\nclass Wave:\n lane: int\n amplitude: float\n x: float = -5\n\n\n@dataclass\nclass Bubble:\n lane: int\n y: float\n vx: float = -0.2\n x: float = 98\n vy: float = 0\n\n\nclass PulseStreamEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.steps = self.frame = self.last_tap = self.auto_timer = self.spawn_lane = 0\n self.rapid_rate = 0.0\n self.held = self.terminal = False\n self.disabled = [False] * 5\n self.recovery = [0] * 5\n self.waves = []\n self.bubbles = [Bubble(2, self.random.uniform(-2, 2))]\n self.sequence = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _spawn(self):\n if self.frame % 36 == 0:\n if len(self.sequence) <= 1:\n self.sequence = self.random.permutation(np.tile(np.arange(5), 3)).tolist()\n lane = self.sequence.pop(0)\n for offset in range(5):\n lane = (lane + offset) % 5\n if not self.disabled[lane]:\n self.waves.append(Wave(lane, self.random.uniform(1, 1.7)))\n break\n if self.random.random() < 0.01:\n if self.random.random() < 0.7:\n lane = self.spawn_lane\n self.spawn_lane = (self.spawn_lane + 1) % 5\n else:\n lane = self.random.integers(5)\n while self.disabled[lane]:\n lane = (lane + 1) % 5\n self.bubbles.append(Bubble(lane, self.random.uniform(-2, 2),\n self.random.uniform(-0.3, -0.2)))\n\n def _advance(self, tap):\n self._spawn()\n if tap:\n self.last_tap = self.frame\n self.auto_timer = 0\n elif self.frame - self.last_tap >= 600:\n self.auto_timer += 1\n if self.auto_timer == 60:\n tap = True\n self.auto_timer = 0\n if tap:\n self.rapid_rate += 0.3\n for lane, disabled in enumerate(self.disabled):\n if disabled:\n self.recovery[lane] += 1\n if self.recovery[lane] == 36:\n self.disabled[lane] = False\n self.recovery[lane] = 0\n self.rapid_rate *= 0.98\n for wave in self.waves:\n wave.x += 0.8\n self.waves = [wave for wave in self.waves if wave.x <= 105]\n reward = 0\n remaining = []\n for bubble in self.bubbles:\n if self.disabled[bubble.lane]:\n continue\n bubble.x += bubble.vx\n bubble.y += bubble.vy\n if tap:\n hits = 0\n for wave in self.waves:\n if wave.lane == bubble.lane and hypot(wave.x - bubble.x, bubble.y) < wave.amplitude * 6:\n hits += 1\n bubble.vx += 0.8\n bubble.vy += self.random.uniform(-0.2, 0.2)\n reward += hits\n if not hits:\n bubble.vx -= 0.1 * (0.25 + self.rapid_rate)\n bubble.vx *= 0.993\n bubble.vy *= 0.891\n bubble.y *= 0.95\n if bubble.x < 0:\n self.disabled[bubble.lane] = True\n self.recovery[bubble.lane] = 0\n elif bubble.x > 100:\n reward += 2\n else:\n remaining.append(bubble)\n self.bubbles = [bubble for bubble in remaining if not self.disabled[bubble.lane]]\n self.waves = [wave for wave in self.waves if not self.disabled[wave.lane]]\n self.terminal = sum(self.disabled) >= 3\n self.frame += 1\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for wave in self.waves:\n columns = np.arange(5, 100, 10)\n state[2 * wave.lane, :, 0] |= abs(columns - wave.x) < wave.amplitude * 6 + 5\n for bubble in self.bubbles:\n col = min(9, int(bubble.x // 10))\n state[2 * bubble.lane, col, 1 + int(bubble.vx > 0)] = True\n for lane, disabled in enumerate(self.disabled):\n state[2 * lane, :, 3] = disabled\n for bit in range(6):\n state[2 * lane, bit, 4] = bool(self.recovery[lane] & (1 << bit))\n for row, value in enumerate((self.steps, self.frame % 36, self.held,\n min(1023, self.frame - self.last_tap), self.auto_timer,\n round(self.rapid_rate * 100))):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 268, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pulse_stream.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePulseStream.c"} +{"name": "private_eye", "split": "train", "game": "private_eye", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Private Eye as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion uses Case 5, which the manual defines as the sum of Cases 1–4. Touché drives the\njumping Model A through a mapped 32-block city, searches questionable characters, carries one\nitem at a time, verifies four evidence items, returns four stolen objects, establishes reasonable\ncause, captures Henri Le Fiend, and books him at headquarters. Secret passages, roadblocks,\npotholes, falling and street hazards, post-return dagger thugs, item swaps, and recoverable drops\nretain the original exploration and logistics loop.\n\nACTION MAPPING\n0: cruise/wait\n1: accelerate left\n2: enter alley or secret passage\n3: accelerate right\n4: unused\n5: jump or inspect a questionable character\n\nINPUT CHANNEL TABLE\n0: Touché's Model A\n1: hazards and roadblocks\n2: visible character/item\n3: item identity and secret passage\n4: previous car and hazard positions\n5: acquired/returned/empty identities, carried item, exact block/steps, direction, Le Fiend, and jump timing\n\nSCORING, TERMINATION, AND HORIZON\nThe 1,000 starting merits plus four evidence finds at 5,000, four stolen-property finds at 15,000,\nfour verifications at 10,000, four returns at 20,000, Le Fiend's 25,000 capture and 25,000 booking,\nand eight empty characters at 100 give the exact clean-case cap:\n`1,000 + 20,000 + 60,000 + 40,000 + 80,000 + 50,000 + 800 = 251,800`.\nNormalization is `min(max(raw_score, 0), 251_800) / 251_800`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/private_eye.py`):\n```python\nimport numpy as np\n\n\nITEMS = (\"gun\", \"button\", \"comb\", \"sole\", \"money\", \"vase\", \"necklace\", \"stamp\")\nITEM_BLOCKS = {item: 2 + index * 4 for index, item in enumerate(ITEMS)}\nDESTINATION_BLOCKS = {item: 3 + index * 4 for index, item in enumerate(ITEMS)}\nEMPTY_CHARACTER_BLOCKS = (1, 5, 9, 13, 17, 21, 25, 29)\nSECRET_PASSAGES = {0: 12, 7: 20, 14: 28, 21: 3, 28: 16}\nDEMERITS = {\"brick\": 100, \"flowerpot\": 200, \"rat\": 300, \"bird\": 400, \"dagger\": 1_000}\n\n\nclass PrivateEyeEnvironment:\n \"\"\"Case Five city search with one-item evidence logistics.\"\"\"\n\n score_cap = 251_800.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 800):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.block = 0\n self.car = [7, 1]\n self.previous_car = self.car.copy()\n self.facing = 1\n self.score = 1_000.0\n self.steps = 0\n self.last_action = 0\n self.jump_timer = 0\n self.terminal = False\n self.carried: str | None = None\n self.acquired: set[str] = set()\n self.returned: set[str] = set()\n self.nabbed_empty: set[int] = set()\n self.item_blocks = dict(ITEM_BLOCKS)\n self.le_fiend_nabbed = False\n self.hazard = [1, 8]\n self.previous_hazard = self.hazard.copy()\n self.hazard_kind = \"brick\"\n self.hazard_direction = -1\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_car = self.car.copy()\n self.previous_hazard = self.hazard.copy()\n block_before = self.block\n reward = self._move_car(action)\n reward += self._interact(action)\n if self.block == block_before and not self.terminal:\n self._move_hazard()\n reward += self._resolve_hazards()\n reward += self._deliver_item()\n self.score = max(0.0, self.score + reward)\n self.steps += 1\n self.jump_timer = max(0, self.jump_timer - 1)\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_car(self, action: int) -> float:\n if action == 1:\n self.car[1] -= 1\n self.facing = -1\n elif action == 3:\n self.car[1] += 1\n self.facing = 1\n elif action == 5:\n self.jump_timer = 3\n self.car[0] = 4\n elif action == 2 and self.block in SECRET_PASSAGES and self.car[1] == 5:\n self.block = SECRET_PASSAGES[self.block]\n self.car = [7, 5]\n self.previous_car = self.car.copy()\n self._reset_hazard()\n return 0.0\n if self.jump_timer == 0:\n self.car[0] = 7\n if self.car[1] < 0:\n self._change_block(-1)\n elif self.car[1] > 9:\n self._change_block(1)\n return 0.0\n\n def _change_block(self, direction: int) -> None:\n self.block = (self.block + direction) % 32\n self.car = [7, 9 if direction < 0 else 0]\n self.previous_car = self.car.copy()\n self._reset_hazard()\n\n def _reset_hazard(self) -> None:\n kinds = (\"brick\", \"flowerpot\", \"rat\", \"bird\", \"pothole\")\n if self.returned:\n kinds = (*kinds, \"dagger\")\n self.hazard_kind = kinds[self.block % len(kinds)]\n self.hazard = [1 if self.hazard_kind in (\"brick\", \"flowerpot\", \"bird\", \"dagger\") else 7, 8]\n self.previous_hazard = self.hazard.copy()\n self.hazard_direction = -1\n\n def _interact(self, action: int) -> float:\n if action != 5 or self.car[1] != 5:\n return 0.0\n for item, block in self.item_blocks.items():\n if block != self.block or item in self.returned:\n continue\n previous_item = self.carried\n self.carried = item\n self.item_blocks[item] = -1\n if previous_item in ITEMS:\n self.item_blocks[previous_item] = self.block\n if item in self.acquired:\n return 0.0\n self.acquired.add(item)\n return 5_000.0 if ITEMS.index(item) < 4 else 15_000.0\n if self.block in EMPTY_CHARACTER_BLOCKS and self.block not in self.nabbed_empty:\n self.nabbed_empty.add(self.block)\n return 100.0\n if self.block == 16 and len(self.returned) == 8 and not self.le_fiend_nabbed:\n self.le_fiend_nabbed = True\n self.carried = \"fiend\"\n return 25_000.0\n return 0.0\n\n def _deliver_item(self) -> float:\n if self.carried in ITEMS and self.block == DESTINATION_BLOCKS[self.carried] and self.car[1] == 8:\n item = self.carried\n self.returned.add(item)\n self.carried = None\n return 10_000.0 if ITEMS.index(item) < 4 else 20_000.0\n if self.carried == \"fiend\" and self.block == 0 and self.car[1] == 8:\n self.carried = None\n self.terminal = True\n return 25_000.0\n return 0.0\n\n def _move_hazard(self) -> None:\n if self.hazard_kind == \"pothole\":\n return\n if self.hazard_kind in (\"brick\", \"flowerpot\", \"bird\", \"dagger\"):\n self.hazard[0] += 1\n if self.hazard[0] > 7:\n self.hazard = [1, int(self.random.randint(1, 9))]\n else:\n self.hazard[1] += self.hazard_direction\n if self.hazard[1] in (1, 8):\n self.hazard_direction *= -1\n\n def _resolve_hazards(self) -> float:\n if self.jump_timer:\n return 0.0\n if self.block % 6 == 0 and self.car[1] == 6:\n return -1.0\n if self.block % 8 == 4 and self.car[1] == 5:\n return -100.0\n if self.hazard == self.car:\n penalty = DEMERITS.get(self.hazard_kind, 1)\n if self.hazard_kind == \"dagger\" and self.carried is not None:\n if self.carried in ITEMS:\n self.item_blocks[self.carried] = (self.block - self.facing) % 32\n self.carried = None\n return -float(penalty)\n return 0.0\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.car, 0] = True\n state[*self.previous_car, 4] = True\n state[*self.hazard, 1] = True\n state[*self.previous_hazard, 4] = True\n for item, block in self.item_blocks.items():\n if block == self.block and item not in self.returned:\n state[4, 5, 2] = True\n state[4, ITEMS.index(item), 3] = True\n if self.block in EMPTY_CHARACTER_BLOCKS and self.block not in self.nabbed_empty:\n state[4, 5, 2] = True\n if self.block == 16 and len(self.returned) == 8 and not self.le_fiend_nabbed:\n state[4, 5, 2] = True\n if self.block in SECRET_PASSAGES:\n state[7, 5, 3] = True\n if self.block % 8 == 4:\n state[7, 5, 1] = True\n for index, item in enumerate(ITEMS):\n state[index // 10, index % 10, 5] = item in self.acquired\n state[1 + index // 10, index % 10, 5] = item in self.returned\n for index, block in enumerate(EMPTY_CHARACTER_BLOCKS):\n state[2, index, 5] = block in self.nabbed_empty\n carried_codes = {None: 0, **{item: index + 1 for index, item in enumerate(ITEMS)}, \"fiend\": 9}\n code = carried_codes[self.carried]\n for bit in range(4):\n state[3, bit, 5] = bool(code & (1 << bit))\n for bit in range(5):\n state[3, 4 + bit, 5] = bool(self.block & (1 << bit))\n for bit in range(10):\n state[4, bit, 5] = bool(self.steps & (1 << bit))\n for item_index, item in enumerate(ITEMS):\n block_code = 32 if self.item_blocks[item] < 0 else self.item_blocks[item]\n for bit in range(6):\n index = 52 + item_index * 6 + bit\n state[index // 10, index % 10, 5] = bool(block_code & (1 << bit))\n facing_column = min(9, max(0, self.car[1] + self.facing))\n state[self.car[0], facing_column, 3] = True\n state[9, : self.jump_timer, 3] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 269, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/private_eye.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "slime_stretcher", "split": "train", "game": "slime_stretcher", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Slime Stretcher as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to stretch upward, narrow the slime, and slow down.\nActions 0–4 release to contract and speed up. Stretch or contract\nto get around walls and reach coins. Coins score the current\nmultiplier and increase it. Coins that scroll off the left edge\nlower it. Being pushed behind the left edge ends the run.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the slime, walls, coins, ground, stretch\nstate, and counters. The port uses fixed difficulty and rectangular\ncoin contact. Each action advances up to four frames over a\n400-action horizon. Clip episode scores to [0, 300] and divide by 300.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/slime_stretcher.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Wall:\n x: float\n y: float\n width: float\n height: float\n\n def overlaps(self, x, y, width, height):\n return (x < self.x + self.width and x + width > self.x\n and y < self.y + self.height and y + height > self.y)\n\n\nclass SlimeStretcherEnvironment:\n score_cap = 300\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 50., 90.\n self.width = self.height = 20\n self.wall_distance, self.coin_distance = 50., 30.\n self.steps = 0\n self.multiplier = 1\n self.held = self.terminal = False\n self.walls, self.coins = [], []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n if self.random.random() >= self.sticky_action_prob:\n self.held = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n if self.held:\n self.height = min(80, self.height + 2)\n self.width = max(10, self.width - 0.5)\n self.y = max(10, self.y - 2)\n speed = 0.5\n else:\n self.height = max(20, self.height - 4)\n self.width = min(20, self.width + 1)\n speed = 1.5\n self.x += speed\n if self.x < 50:\n self.x += 1\n self.terminal = self.x < -self.width\n self.wall_distance -= speed\n if self.wall_distance <= 0:\n width = self.random.uniform(20, 60)\n self.walls.append(Wall(200, self.random.uniform(0, 70), width, self.random.uniform(20, 40)))\n self.wall_distance = width + self.random.integers(35, 55)\n self.coin_distance -= speed\n if self.coin_distance <= 0:\n self.coins.append((203, self.random.uniform(20, 80)))\n self.coin_distance = self.random.integers(30, 60)\n grounded = False\n for wall in self.walls:\n if not wall.overlaps(self.x, self.y, self.width, self.height):\n continue\n if self.y + self.height < wall.y + 10:\n self.height -= 1\n self.y = wall.y - self.height\n grounded = True\n elif self.y > wall.y + wall.height - 10:\n self.y = wall.y + wall.height\n self.height -= 2\n elif self.x + self.width < wall.x + 5:\n self.x = wall.x - self.width\n self.width -= 1\n else:\n self.y = wall.y - self.height\n grounded = True\n if not grounded:\n self.y = min(90, self.y + 1)\n self.y = min(self.y, 90 - self.height)\n self.x -= speed\n for wall in self.walls:\n wall.x -= speed\n self.walls = [wall for wall in self.walls if wall.x + wall.width >= 0]\n reward = 0\n remaining = []\n for x, y in self.coins:\n if any(wall.overlaps(x - 3, y - 3, 6, 6) for wall in self.walls):\n continue\n if self.x - 3 < x < self.x + self.width + 3 and self.y - 3 < y < self.y + self.height + 3:\n reward += self.multiplier\n self.multiplier += 1\n elif x - speed < -3:\n self.multiplier = max(1, self.multiplier - 1)\n else:\n remaining.append((x - speed, y))\n self.coins = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n rows, cols = np.ogrid[:100:10, :200:20]\n state[:, :, 0] = (cols < self.x + self.width) & (cols + 20 > self.x) & (\n rows < self.y + self.height) & (rows + 10 > self.y)\n for wall in self.walls:\n state[:, :, 1] |= (cols < wall.x + wall.width) & (cols + 20 > wall.x) & (\n rows < wall.y + wall.height) & (rows + 10 > wall.y)\n for x, y in self.coins:\n if 0 <= x < 200:\n state[int(y // 10), int(x // 20), 2] = True\n state[9, :, 3] = True\n state[:, :, 4] = state[:, :, 0] & self.held\n values = (self.steps, self.multiplier, round(self.width * 10),\n round(self.height * 4), self.held)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 271, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/slime_stretcher.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameSlimeStretcher.c"} +{"name": "baroll", "split": "train", "game": "baroll", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Baroll as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe runner advances automatically. Press action 5 to jump. Holding\nslows the scroll, lowers gravity, and makes the runner bounce on\nlanding. Release with actions 0–4 to run at full speed and score.\nBarrels fall from above, then roll toward the runner. Contact ends\nthe run.\n\nINPUT CHANNEL TABLE\nThe 10×10 observation uses six channels for the runner, falling\nbarrels, rolling barrels, ground, upward motion, and input and step\ngauges. Each action advances four simulation frames. The conversion\nuses fixed difficulty and rectangular collision checks.\n\nSCORING, TERMINATION, AND HORIZON\nEach released frame scores one point. The 400-action horizon caps\nraw score at 1,600. Clip to [0, 1600] and divide by 1600.\n\nAcross 100 seeds with sticky actions disabled, always released\naveraged 135.30 raw points, always held scored zero, and random\nhold and release averaged 136.09. A heuristic using exact barrel\npositions jumped for nearby hazards and averaged 594.77, reaching\n1,540.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/baroll.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\nGROUND = 86\n\n\n@dataclass\nclass Barrel:\n x: float\n y: float = -5\n velocity: float = 0\n rolling: bool = False\n\n\nclass BarollEnvironment:\n score_cap = HORIZON * FRAMES_PER_STEP\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.spawn_timer = 0\n self.pressed = self.terminal = self.jumping = False\n self.y = float(GROUND)\n self.velocity = 0.0\n self.barrels: list[Barrel] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(FRAMES_PER_STEP):\n self._advance_frame(tap and frame == 0)\n reward += int(not pressed)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self, tap: bool) -> None:\n if self.spawn_timer == 0:\n start = 100 if self.jumping else 10\n self.barrels.append(Barrel(self.random.uniform(start, 200)))\n self.spawn_timer = int(self.random.integers(30, 90))\n self.spawn_timer -= 1\n for barrel in self.barrels:\n if barrel.rolling:\n barrel.x -= 1\n else:\n barrel.velocity = (barrel.velocity + 0.2) * 0.92\n barrel.y += barrel.velocity\n if barrel.y > 85:\n barrel.y = GROUND\n barrel.rolling = True\n barrel.x -= 1 if self.pressed else 2\n self.barrels = [barrel for barrel in self.barrels if barrel.x > -5]\n\n if self.jumping:\n self.y += self.velocity\n self.velocity += 0.1 if self.pressed else 0.2\n if self.y > 85:\n self.y = GROUND\n self.jumping = self.pressed\n self.velocity = -3 if self.pressed else 0\n elif tap:\n self.jumping = True\n self.velocity = -3.6\n self.terminal = any(\n abs(barrel.x - 9) < 5 and abs(barrel.y - self.y) < 6\n for barrel in self.barrels\n )\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row = int(self.y) // 10\n state[row, 0, 0] = True\n state[row, 0, 4] = self.jumping and self.velocity < 0\n for barrel in self.barrels:\n if barrel.x >= 0 and barrel.y >= 0:\n state[int(barrel.y) // 10, int(barrel.x) // 20, 2 if barrel.rolling else 1] = True\n state[9, :, 3] = True\n state[9, 0, 5] = self.pressed\n for bit in range(9):\n state[9, bit + 1, 5] = bool(self.steps & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 272, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/baroll.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/baroll/main.js"} +{"name": "paku_paku", "split": "train", "game": "paku_paku", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Paku Paku as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe player moves continuously around a single wrapping track. The ghost chases without\nwrapping. Each of 16 pellets pays the current multiplier. A seeded power pellet makes\nthe ghost flee unless its eyes are already returning. Capturing it pays ten times the\nmultiplier, consumes power, and raises the multiplier. Clearing the track refills it and\nraises the multiplier again. Unpowered contact ends the run.\n\nINPUT CHANNEL TABLE\nActions 1 and 3 set direction. Action 5 reverses on a fresh press. Actions 0, 2, and 4\ncoast. The track uses two rows of eight cells. Channels encode player, dangerous ghost,\nordinary pellets, power pellet and safe ghost, next player cell, and gauges respectively.\nThe gauges encode power time, wave, multiplier, step count, eyes direction, and last action.\n\nSCORING, TERMINATION, AND HORIZON\nThe adaptation replaces continuous motion with tile movement, steps up ghost speed by wave,\nand expires power at the wave boundary. Four clears or 500 steps end the default episode.\nEach wave supplies at most one capture. With zero-based wave index w, pellets pay at most\n16 × (3 + 2w) and the capture at most 10 × (2 + 2w). The sum is 584, a conservative\nstructural bound. Pellets cannot repay within a wave and captures consume the power window.\nThe normalized score is the raw score clipped to [0, cap] and divided by the cap.\n\nOver 100 seeds starting at 1729 with sticky actions disabled, fixed coast averaged\n120.74 points, random averaged 30.63, and a local ghost-avoidance heuristic averaged\n28.68. Coast is a strong baseline in this discretization. Multi-seed MLP learnability\nand comparison with the native game remain open.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/paku_paku.py`):\n```python\nimport numpy as np\n\n\nTRACK_LENGTH = 16\nWAVES = 4\n\n\nclass PakuPakuEnvironment:\n # Each wave can raise the multiplier once through a ghost capture.\n score_cap = float(sum(16 * (3 + 2 * wave) + 10 * (2 + 2 * wave) for wave in range(WAVES)))\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 500):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.default_rng(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.player = 6\n self.ghost = 15\n self.direction = 1\n self.eyes = 0\n self.power = 0\n self.steps = 0\n self.wave = 0\n self.multiplier = 1\n self.last_action = 0\n self.terminal = False\n self._refill()\n\n def _refill(self) -> None:\n self.pellets = set(range(TRACK_LENGTH))\n self.power_cell = int(self.random.integers(1, 6) if self.player >= 8 else self.random.integers(10, 15))\n self.multiplier += 1\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n if action == 5 and self.last_action != 5:\n self.direction *= -1\n elif action in (1, 3):\n self.direction = -1 if action == 1 else 1\n self.last_action = action\n self.steps += 1\n previous_player = self.player\n previous_ghost = self.ghost\n self.player = (self.player + self.direction) % TRACK_LENGTH\n reward = 0\n if self.player in self.pellets:\n self.pellets.remove(self.player)\n reward += self.multiplier\n if self.player == self.power_cell and not self.eyes:\n self.power = 16\n returning = bool(self.eyes)\n if returning:\n self.ghost += self.eyes\n if self.ghost in (0, TRACK_LENGTH - 1):\n self.eyes = 0\n else:\n interval = 3 if self.power else max(1, 3 - self.wave)\n if self.steps % interval == 0:\n direction = 1 if self.player > self.ghost else -1\n if self.power:\n direction *= -1\n self.ghost = max(0, min(TRACK_LENGTH - 1, self.ghost + direction))\n crossed = self.player == previous_ghost and self.ghost == previous_player\n if not returning and (self.player == self.ghost or crossed):\n if self.power:\n reward += 10 * self.multiplier\n self.multiplier += 1\n self.power = 0\n self.eyes = -1 if self.ghost >= 8 else 1\n else:\n self.terminal = True\n self.power = max(0, self.power - 1)\n if not self.terminal and not self.pellets:\n self.wave += 1\n if self.wave == WAVES:\n self.terminal = True\n else:\n self.power = 0\n self._refill()\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def state(self) -> np.ndarray:\n observation = np.zeros((10, 10, 6), dtype=bool)\n observation[self.player // 8, self.player % 8, 0] = True\n ghost_channel = 3 if self.eyes or self.power else 1\n observation[self.ghost // 8, self.ghost % 8, ghost_channel] = True\n for pellet in self.pellets:\n observation[pellet // 8, pellet % 8, 3 if pellet == self.power_cell else 2] = True\n next_cell = (self.player + self.direction) % TRACK_LENGTH\n observation[next_cell // 8, next_cell % 8, 4] = True\n for row, value in enumerate((self.power, self.wave, self.multiplier, self.steps, self.eyes + 1, self.last_action), start=2):\n for bit in range(10):\n observation[row, bit, 5] = bool(value & (1 << bit))\n return observation\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 273, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/paku_paku.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gamePakuPaku.c"} +{"name": "r_wheel", "split": "train", "game": "r_wheel", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays R Wheel as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to jump, including in midair. Hold it to fall more\nslowly. Actions 0–4 release. At the top of a jump, a purple bar\nfalls and grows the wheel spikes it hits. Catch a rotating bonus\nto send a yellow bar down. Each spike that bar clears adds its\nheight to the multiplier, then scores the new multiplier. Jumping\nfrom the ground resets the multiplier. Touching a spike ends the run.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the player, spikes, bonuses, purple\nbars, yellow bars, and counters. The port uses fixed difficulty and\nsamples spike edges against rectangular bounds. Each action advances\nup to four frames over a 400-action horizon. Clip the episode score\nto [0, 1000] and divide by 1000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/r_wheel.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import ceil, cos, floor, pi, sin\n\nimport numpy as np\n\n\nSECTOR = 2 * pi / 32\n\n\n@dataclass\nclass Bar:\n y: float\n grows_spikes: bool\n width: float = 0\n\n\nclass RWheelEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.y = self.vy = self.angle = 0.0\n self.steps = 0\n self.multiplier = 1\n self.held = self.terminal = False\n self.spikes = [0] * 32\n self.hit = [False] * 32\n self.bars = []\n self.bonuses = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _add_bonus(self):\n for _ in range(ceil(sum(height > 0 for height in self.spikes) / 9)):\n angle = -2 * pi / 3 + self.random.uniform(-3 * pi / 4, 3 * pi / 4)\n self.bonuses.append((angle, self.random.uniform(10, 30)))\n\n def _advance(self, tap):\n if tap:\n self.vy = -2\n self.hit = [False] * 32\n if self.y == 0:\n self.y = self.vy\n self.multiplier = 0\n self._add_bonus()\n if self.y < 0:\n previous = self.vy\n self.vy = (self.vy + (0.03 if self.held else 0.09)) * 0.98\n if self.y < -74 and self.vy < 0:\n self.vy *= -0.5\n if previous * self.vy <= 0:\n self.bars.append(Bar(90 + self.y, True))\n self.y += self.vy\n if self.y > 0:\n self.y = self.vy = 0\n bonuses = []\n for angle, radius in self.bonuses:\n if abs(radius * cos(angle)) < 5 and abs(50 + radius * sin(angle) - (87 + self.y)) < 6:\n self.bars.append(Bar(90 + self.y, False))\n else:\n bonuses.append((angle + 0.03, radius))\n self.bonuses = bonuses\n for bar in self.bars:\n bar.width += 1 if bar.grows_spikes else 2\n bar.y += 3 if bar.grows_spikes else 2\n self.bars = [bar for bar in self.bars if bar.y <= 103]\n self.angle = (self.angle + 0.03) % (2 * pi)\n reward = 0\n for index, height in enumerate(self.spikes):\n xs, ys = self._spike_points(index, height)\n if not self.hit[index] and any(\n bar.grows_spikes and self._overlap(xs, ys, bar.y, bar.width / 2, 1.5)\n for bar in self.bars\n ):\n height += 1\n self.hit[index] = True\n if height:\n if any(not bar.grows_spikes and self._overlap(xs, ys, bar.y, bar.width / 2, 1.5)\n for bar in self.bars):\n self.multiplier += height\n reward += self.multiplier\n height = 0\n elif self._overlap(xs, ys, 87 + self.y, 3, 3):\n self.terminal = True\n self.spikes[index] = height\n if not any(self.spikes):\n for angle in (-pi / 4, -3 * pi / 4):\n self.spikes[floor((angle - self.angle) / SECTOR) % 32] = 1\n self._add_bonus()\n return reward\n\n def _spike_points(self, index, height):\n angle = self.angle + index * SECTOR\n dx, dy = cos(angle), sin(angle)\n radius = 40 - 4 * height\n fractions = np.linspace(0, 1, 2 + 4 * height)\n lengths = radius + (40 - radius) * fractions\n side = fractions * (50 / 32)\n return (\n np.concatenate((50 + dx * lengths - dy * side, 50 + dx * lengths + dy * side)),\n np.concatenate((50 + dy * lengths + dx * side, 50 + dy * lengths - dx * side)),\n )\n\n @staticmethod\n def _overlap(xs, ys, y, half_width, half_height):\n return bool(np.any((abs(xs - 50) <= half_width) & (abs(ys - y) <= half_height)))\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int((87 + self.y) // 10), 5, 0] = True\n for index, height in enumerate(self.spikes):\n if height:\n x, y = self._spike_points(index, height)\n visible = (x >= 0) & (x < 100) & (y >= 0) & (y < 100)\n state[(y[visible] // 10).astype(int), (x[visible] // 10).astype(int), 1] = True\n for angle, radius in self.bonuses:\n state[int((50 + radius * sin(angle)) // 10),\n int((50 + radius * cos(angle)) // 10), 2] = True\n columns = np.arange(5, 100, 10)\n for bar in self.bars:\n if 0 <= bar.y < 100:\n state[int(bar.y // 10), :, 3 if bar.grows_spikes else 4] |= abs(columns - 50) < bar.width / 2 + 5\n for row, value in enumerate((self.steps, self.multiplier, int(self.held), round((self.vy + 2) * 100))):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 274, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/r_wheel.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/rwheel/main.js"} +{"name": "alien", "split": "train", "game": "alien", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Alien as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves the Atari 2600 game's maze chase: a human traverses ship corridors to\nsmash a finite field of Alien eggs while three adult Aliens pursue. Three Pulsars temporarily make\nthe Aliens vulnerable, contact with an unpowered Alien ends the expedition, and clearing every egg\ncompletes the task.\n\nACTION MAPPING\n0: wait\n1: move left\n2: move up\n3: move right\n4: move down\n5: unused fire action\n\nINPUT CHANNEL TABLE\n0: human\n1: adult Aliens\n2: eggs\n3: Pulsars\n4: previous Alien positions, exposing motion\n5: Pulsar power timer\n\nSCORING, TERMINATION, AND HORIZON\nThe one-maze task has 20 one-point eggs and three unique five-point Aliens, so its structural\nmaximum is `score_cap = 20 + 3×5 = 35`. Normalization is\n`min(max(raw_score, 0), 35) / 35`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/alien.py`):\n```python\nimport numpy as np\n\n\nMAZE = np.array([\n [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],\n [1, 0, 0, 0, 1, 0, 0, 0, 0, 1],\n [1, 0, 1, 0, 1, 0, 1, 1, 0, 1],\n [1, 0, 1, 0, 0, 0, 0, 1, 0, 1],\n [1, 0, 1, 1, 1, 1, 0, 1, 0, 1],\n [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],\n [1, 1, 0, 1, 1, 0, 1, 1, 0, 1],\n [1, 0, 0, 0, 1, 0, 0, 0, 0, 1],\n [1, 0, 1, 0, 0, 0, 1, 0, 0, 1],\n [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],\n], dtype=bool)\n\n\nclass AlienEnvironment:\n \"\"\"Maze pursuit with eggs, pulsars, and three vulnerable Alien enemies.\"\"\"\n\n score_cap = 35.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 500):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.player = [8, 5]\n self.previous_player = self.player.copy()\n self.aliens = [[1, 1], [1, 8], [7, 1]]\n self.previous_aliens = [position.copy() for position in self.aliens]\n passages = [tuple(position) for position in np.argwhere(~MAZE)]\n reserved = {tuple(self.player), *(tuple(position) for position in self.aliens)}\n self.pulsars = {(3, 3), (5, 8), (8, 1)}\n self.eggs = {position for position in passages if position not in reserved | self.pulsars}\n self.eggs = set(sorted(self.eggs)[:20])\n self.power_timer = 0\n self.last_action = 0\n self.steps = 0\n self.terminal = False\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n delta = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}.get(action, (0, 0))\n target = [self.player[0] + delta[0], self.player[1] + delta[1]]\n if not MAZE[*target]:\n self.player = target\n\n reward = 0.0\n position = tuple(self.player)\n if position in self.eggs:\n self.eggs.remove(position)\n reward += 1.0\n if position in self.pulsars:\n self.pulsars.remove(position)\n self.power_timer = 30\n\n self.previous_aliens = [alien.copy() for alien in self.aliens]\n for alien in self.aliens:\n self._move_alien(alien)\n defeated = []\n for alien in self.aliens:\n if alien == self.player:\n if self.power_timer > 0:\n reward += 5.0\n defeated.append(alien)\n else:\n self.terminal = True\n for alien in defeated:\n self.aliens.remove(alien)\n self.power_timer = max(0, self.power_timer - 1)\n self.steps += 1\n if not self.eggs:\n self.terminal = True\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_alien(self, alien: list[int]) -> None:\n candidates = []\n for row_delta, column_delta in ((0, -1), (-1, 0), (0, 1), (1, 0)):\n candidate = [alien[0] + row_delta, alien[1] + column_delta]\n if not MAZE[*candidate]:\n distance = abs(candidate[0] - self.player[0]) + abs(candidate[1] - self.player[1])\n candidates.append((distance, self.random.rand(), candidate))\n if candidates:\n alien[:] = min(candidates)[2]\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n for alien in self.aliens:\n state[*alien, 1] = True\n for egg in self.eggs:\n state[*egg, 2] = True\n for pulsar in self.pulsars:\n state[*pulsar, 3] = True\n for previous in self.previous_aliens:\n state[*previous, 4] = True\n state[9, : min(10, (self.power_timer + 2) // 3), 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 275, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/alien.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "flipbomb", "split": "train", "game": "flipbomb", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Flipbomb as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to flip incoming balls once they pass x=70. Release\nwith actions 0–4 before tapping again. Later flips send balls at\na different angle. Launched balls detonate bombs, and explosions\ncan set off nearby bombs. Bomb kills increase the multiplier.\nEvery tap resets it.\n\nINPUT CHANNEL TABLE\nA bomb touching a ramp or an unlaunched ball, or reaching the\nbottom, ends the run. The six 10×10 channels show incoming balls,\nlaunched balls, bombs, explosions, ramps, and gauges. Each action\nadvances four frames at fixed difficulty. The conversion uses\ngeometric checks for ramp and explosion contact.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action task clips raw scores to [0, 250] and divides by\n250. Across 100 seeds without sticky actions, idle scored zero\nand random inputs averaged 40.83. A policy that flipped at a\nspecific ball position averaged 74.04 and reached 238.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/flipbomb.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Body:\n x: float\n y: float\n vx: float\n vy: float\n launched: bool = False\n\n def move(self) -> None:\n self.x += self.vx\n self.y += self.vy\n\n\n@dataclass\nclass Explosion:\n x: float\n y: float\n angle: float\n age: int = 0\n\n def lobes(self):\n radius = self.age * 0.5 if self.age < 20 else 30 - self.age\n half_width = 5 if not self.age else (radius + 3) / 2\n for index in range(5):\n angle = self.angle + index * math.tau / 5\n yield self.x + radius * math.cos(angle), self.y + radius * math.sin(angle), half_width\n\n\nclass FlipbombEnvironment:\n score_cap = 250\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.ball_timer = 0\n self.bomb_timer = 0.0\n self.multiplier = 1\n self.pressed = self.terminal = False\n self.balls: list[Body] = []\n self.bombs: list[Body] = []\n self.explosions: list[Explosion] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap: bool) -> int:\n if tap:\n self.multiplier = 1\n lobes = [lobe for explosion in self.explosions for lobe in explosion.lobes()]\n for explosion in self.explosions:\n explosion.age += 1\n explosion.angle += 0.2\n self.explosions = [explosion for explosion in self.explosions if explosion.age < 30]\n self.ball_timer -= 1\n if self.ball_timer < 0:\n self.balls.append(Body(99, 70, -1, 0.5))\n self.ball_timer = 60\n balls = []\n for ball in self.balls:\n ball.move()\n if tap and not ball.launched and ball.x < 70:\n angle = (ball.x - 70) * 0.06\n ball.vx = 2 * math.cos(angle) + 4 * math.sin(angle)\n ball.vy = 2 * math.sin(angle) - 4 * math.cos(angle)\n ball.launched = True\n if 0 <= ball.x < 99 and 0 <= ball.y < 99 and not self._blast_hit(ball, lobes, 1.5):\n balls.append(ball)\n self.balls = balls\n\n self.bomb_timer -= 1\n if self.bomb_timer < 0:\n x = self.random.uniform(0, 80)\n self.bombs.append(Body(x, 0, (self.random.uniform(20, 70) - x) / 500, 0.14))\n self.bomb_timer += self.random.uniform(30, 50)\n\n reward = 0\n bombs = []\n for bomb in self.bombs:\n bomb.move()\n if self._blast_hit(bomb, lobes, 2.5) or any(\n ball.launched and abs(ball.x - bomb.x) < 4 and abs(ball.y - bomb.y) < 4\n for ball in self.balls\n ):\n self.explosions.append(Explosion(bomb.x, bomb.y, self.random.uniform(-math.pi, math.pi)))\n reward += self.multiplier\n self.multiplier += 1\n elif bomb.y > 99 or any(\n not ball.launched and abs(ball.x - bomb.x) < 4 and abs(ball.y - bomb.y) < 4\n for ball in self.balls\n ) or self._hits_ramp(bomb, tap):\n self.terminal = True\n else:\n bombs.append(bomb)\n self.bombs = bombs\n return reward\n\n @staticmethod\n def _blast_hit(body: Body, lobes: list[tuple[float, float, float]], margin: float) -> bool:\n return any(abs(body.x - x) < radius + margin and abs(body.y - y) < radius + margin\n for x, y, radius in lobes)\n\n @staticmethod\n def _hits_ramp(bomb: Body, tap: bool) -> bool:\n return (\n 72 <= bomb.x <= 102 and abs(bomb.y - (75 + (99 - bomb.x) * 11 / 24)) < 3\n or 47 <= bomb.x <= 73 and abs(bomb.y - (89 + (70 - bomb.x) * (-0.45 if tap else 0.45))) < 3\n )\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for ball in self.balls:\n state[int(ball.y) // 10, int(ball.x) // 10, int(ball.launched)] = True\n for bomb in self.bombs:\n if 0 <= bomb.x < 100 and 0 <= bomb.y < 100:\n state[int(bomb.y) // 10, int(bomb.x) // 10, 2] = True\n for explosion in self.explosions:\n for x, y, _ in explosion.lobes():\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y) // 10, int(x) // 10, 3] = True\n state[8, 5:8, 4] = True\n state[7:9, 8:10, 4] = True\n for row, value in enumerate((self.steps, self.multiplier, self.ball_timer)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 276, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/flipbomb.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/flipbomb/main.js"} +{"name": "totoge", "split": "train", "game": "totoge", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Totoge as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe bird drifts sideways and reverses at the walls. Tap action 5\nwhile descending to jump, and release it with any other action.\nA jump late in a fall can score the squared fall speed. Descending\nalso scores one point per new wall segment. Contact with a spike\nstrip ends the episode.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the bird, visible spikes, incoming\nspikes projected onto the bottom row, wall segments, the falling\nbird, and counters. Counters encode elapsed actions, the effective\naction, heading, vertical velocity, scroll speed, and wall phase.\nThe port uses fixed difficulty and geometric spike collision checks.\nEach action advances up to four frames over 400 actions. Clip the\nepisode score to [0, 1000] and divide by 1000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/totoge.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import ceil\n\nimport numpy as np\n\n\n@dataclass\nclass SpikeStrip:\n x: float\n y: float\n count: int\n\n\nclass TotogeEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y, self.vx, self.vy = 50., 9., 0.33, 0.\n self.scroll, self.next_wall = 0., 105.\n self.spikes = []\n self.spike_distance, self.next_spike_x, self.spike_direction = 0., 10., 1\n self.action = self.steps = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n jump = self.action == 5 and previous != 5\n self.steps += 1\n reward = 0.\n for frame in range(4):\n reward += self._advance(jump and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _advance(self, jump):\n reward = 0.\n while self.next_wall < 105:\n self.next_wall += 10\n reward += 1\n self.next_wall -= self.scroll\n\n self.spike_distance -= self.scroll\n if self.spike_distance < 0:\n count = int(self.random.integers(2, 5))\n x = float(np.clip(self.next_spike_x, 12, 93 - count * 6))\n self.spikes.append(SpikeStrip(x, 199, count))\n self.spike_distance = self.random.uniform(99, 199)\n self.next_spike_x += self.spike_direction * count * 6\n if self.next_spike_x < 9 or self.next_spike_x > 90:\n self.spike_direction *= -1\n for strip in self.spikes:\n strip.y -= self.scroll\n self.spikes = [strip for strip in self.spikes if strip.y > -99]\n samples = ceil(min(99, max(1, self.vy / 6)))\n if any(self._hits(strip, self.y - 6 * offset)\n for strip in self.spikes for offset in range(samples)):\n self.terminal = True\n return reward\n\n self.x += self.vx\n self.y += self.vy - self.scroll\n if self.y < 10:\n self.scroll = (self.y - 10) / 2\n elif self.y > 30:\n self.scroll = (self.y - 30) / 2\n self.vy += 0.05\n if (self.x < 9 and self.vx < 0) or (self.x > 90 and self.vx > 0):\n self.vx *= -1\n if jump and self.vy > 0 and self.next_wall < 150:\n bonus = self.vy ** 2\n if bonus > 10:\n reward += bonus\n self.vy = -1\n return reward\n\n def _hits(self, strip, y):\n draw_y = min(99, max(-99, strip.y))\n for index in range(strip.count):\n dx = abs(self.x - strip.x - index * 6)\n dy = y - draw_y\n if dx < 6 and -5 < dy < 5 and dx < 4.5 + dy * 0.3:\n return True\n return False\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n col = int(np.clip(self.x // 10, 0, 9))\n row = int(np.clip(self.y // 10, 0, 9))\n state[row, col, 0] = True\n for strip in self.spikes:\n if 0 <= strip.y < 100:\n for index in range(strip.count):\n state[int(strip.y // 10), int((strip.x + index * 6) // 10), 1] = True\n elif strip.y >= 100:\n for index in range(strip.count):\n state[9, int((strip.x + index * 6) // 10), 2] = True\n for y in np.arange(self.next_wall - 10, -5, -10):\n if 0 <= y < 100:\n state[int(y // 10), (0, 9), 3] = True\n state[row, col, 4] = self.vy > 0\n values = (self.steps, self.action, self.vx > 0, round((self.vy + 1) * 16),\n round((self.scroll + 4) * 16), round(self.next_wall * 2))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 277, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/totoge.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/totoge/main.js"} +{"name": "slashes", "split": "train", "game": "slashes", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Slashes as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to reverse horizontal travel. Actions 0–4 release.\nGlide through the wide purple bands to build speed and bank points\nwhen you leave. Touching the narrow dark core ends the run.\n\nINPUT CHANNEL TABLE\nSix channels show the player, cores, scoring bands, heading,\npending-score marker, and counters. The port fixes difficulty and\napproximates bar collisions with rotated rectangles. Each action\nadvances up to four frames over 400 actions. Clip the episode score\nto [0, 400] and divide by 400.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/slashes.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import sqrt\n\nimport numpy as np\n\n\n@dataclass\nclass Slash:\n x: float\n y: float\n slope: int\n width: float\n\n def overlaps(self, x, y, width, thickness, margin=0):\n dx, dy = x - self.x, y - self.y\n return ((abs(dx + self.slope * dy) < (width / 2 + margin) * sqrt(2))\n & (abs(dy - self.slope * dx) < (thickness / 2 + margin) * sqrt(2)))\n\n\nclass SlashesEnvironment:\n score_cap = 400\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.slashes = [Slash(22, 50, 1, 30)]\n self.direction = 1\n self.speed = 1.\n self.pending = self.timer = 0.\n self.steps = 0\n self.held = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n if held and not self.held:\n self.direction *= -1\n self.held = held\n self.steps += 1\n reward = 0.\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _advance(self):\n self.speed += (1 - self.speed) * 0.03\n self.timer -= 1\n if self.timer < 0:\n width = self.random.integers(40, 70)\n candidate = Slash(self.random.integers(-99, 199), -width,\n self.random.choice((-1, 1)), width)\n points = np.linspace(-width / 2, width / 2, width) / sqrt(2)\n if not any(np.any(slash.overlaps(candidate.x + points,\n candidate.y + candidate.slope * points,\n slash.width, 4, 10)) for slash in self.slashes):\n candidate.width -= 20\n self.slashes.append(candidate)\n self.timer += self.random.uniform(10, 15)\n self.terminal = any(slash.overlaps(50, 90, slash.width, 4, 2) for slash in self.slashes)\n reward = 0.\n if not self.terminal:\n if any(slash.overlaps(50, 90, slash.width, 22, 2) for slash in self.slashes):\n self.speed += 0.03\n self.pending += self.speed\n else:\n reward, self.pending = self.pending, 0.\n for slash in self.slashes:\n slash.x += self.direction * self.speed\n slash.y += self.speed\n self.slashes = [slash for slash in self.slashes if slash.y < 99 + slash.width]\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[9, 5, 0] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for slash in self.slashes:\n state[:, :, 1] |= slash.overlaps(cols, rows, slash.width, 4, 5)\n state[:, :, 2] |= slash.overlaps(cols, rows, slash.width, 22, 5)\n state[8, 4 if self.direction > 0 else 6, 3] = True\n state[9, 5, 4] = self.pending > 0\n for row, value in enumerate((self.steps, self.held, round(self.speed * 100),\n min(1023, round(self.pending * 4)))):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 279, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/slashes.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/slashes/main.js"} +{"name": "geyser_hop", "split": "train", "game": "geyser_hop", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Geyser Hop as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to rise and use actions 0–4 to fall. Land on the\ntop of a geyser while descending to bounce, shrink the geyser,\nand score the current combo. Consecutive stomps raise the combo\nup to 16. A missed geyser lowers it. Hitting the floor, ceiling,\nor a geyser from below ends the run. The ceiling descends after\na long stretch without a stomp and recedes after each stomp.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, geyser tops, geyser bodies,\nspent geysers, ceiling, and gauges. Each action advances four\nframes at fixed difficulty. Collisions use rectangular hitboxes.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action task clips raw scores to [0, 150] and divides by\n150. The cap is a normalization parameter.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/geyser_hop.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Geyser:\n x: float\n height: int\n stomped: bool = False\n\n\nclass GeyserHopEnvironment:\n score_cap = 150\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x = self.y = 40.0\n self.vy = 0.0\n self.ceiling = 3.0\n self.steps = self.frames = self.since_stomp = 0\n self.combo = 1\n self.pressed = self.terminal = False\n self.geysers = [Geyser(95, 40)]\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self) -> int:\n self.frames += 1\n self.since_stomp += 1\n if self.since_stomp > 200:\n self.ceiling += 0.1\n if self.frames % 91 == 61:\n self.geysers.append(Geyser(110, int(self.random.integers(40, 60))))\n self.x += (45 - self.x) * 0.01\n self.vy = min(3, max(-2.2, self.vy + (-0.16 if self.pressed else 0.13)))\n self.y += self.vy\n if self.y < self.ceiling or self.y > 92:\n self.terminal = True\n return 0\n reward = 0\n for geyser in self.geysers:\n geyser.x -= 1\n if geyser.x < -15 and not geyser.stomped:\n self.combo = max(1, self.combo - 1)\n if geyser.stomped:\n continue\n top = 92 - geyser.height\n dx = abs(self.x - geyser.x)\n if dx < 8 and self.y + 2 > top and self.y - 2 < top + 6:\n if self.vy <= 0:\n self.terminal = True\n break\n reward += self.combo\n self.combo = min(16, self.combo + 1)\n self.vy = -2.8\n self.y = top - 2\n geyser.height = 8\n geyser.stomped = True\n self.ceiling = max(3, self.ceiling - 8)\n self.since_stomp = 0\n elif dx < 7 and self.y + 2 > top + 4:\n self.terminal = True\n break\n self.geysers = [geyser for geyser in self.geysers if geyser.x >= -15]\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, max(0, int(self.y) // 10)), int(self.x) // 10, 0] = True\n for geyser in self.geysers:\n top = (92 - geyser.height) // 10\n for col in range(max(0, int(geyser.x - 5) // 10), min(10, int(geyser.x + 5) // 10 + 1)):\n if not geyser.stomped:\n state[top, col, 1] = True\n state[top + int(not geyser.stomped):10, col, 3 if geyser.stomped else 2] = True\n state[:min(10, int(self.ceiling) // 10 + 1), :, 4] = True\n for row, value in enumerate((self.steps, self.combo, round((self.vy + 3) * 50), min(511, self.since_stomp))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 280, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/geyser_hop.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameGeyserHop.c"} +{"name": "clock_turret", "split": "train", "game": "clock_turret", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Clock Turret as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to stop the rotating hand and fire from both ends.\nRelease with actions 0–4 to rotate again. Each new press reverses\nthe next rotation direction. Enemy kills pay the current\nmultiplier and release a coin. Catching a coin with the hand raises\nthe multiplier. An enemy shot touching the hand ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the hand, friendly shots, enemies,\nenemy shots and warning rays, coins, and gauges. Each action\nadvances four frames at fixed difficulty. The conversion uses\ndistance-based collisions and samples fast enemy shots along their\npath.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 250] and divide by 250. Across 100 seeds without sticky actions,\nidle scored zero, holding averaged 5.58, and random inputs averaged\n6.60. Repeating five held actions and four released actions averaged\n10.96 and reached 71.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/clock_turret.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Moving:\n x: float\n y: float\n angle: float\n\n def move(self, distance: float) -> None:\n self.x += math.cos(self.angle) * distance\n self.y += math.sin(self.angle) * distance\n\n def visible(self, margin: float = 0) -> bool:\n return -margin <= self.x < 100 + margin and -margin <= self.y < 100 + margin\n\n\n@dataclass\nclass Enemy(Moving):\n aim: float\n windup: int = 0\n\n\nclass ClockTurretEnvironment:\n score_cap = 250\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.fire_timer = self.enemy_timer = self.bullet_timer = 0\n self.angle = -math.pi / 2\n self.direction = self.multiplier = 1\n self.pressed = self.terminal = False\n self.enemies: list[Enemy] = []\n self.shots: list[Moving] = []\n self.bullets: list[Moving] = []\n self.coins: list[Moving] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed:\n self.direction *= -1\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance_frame()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _near_hand(self, x: float, y: float, radius: float) -> bool:\n dx, dy = x - 50, y - 50\n cos, sin = math.cos(self.angle), math.sin(self.angle)\n along = min(14, max(-6, dx * cos + dy * sin))\n return math.hypot(dx - along * cos, dy - along * sin) < radius\n\n def _advance_frame(self) -> int:\n for shot in self.shots:\n shot.move(3)\n self.shots = [shot for shot in self.shots if shot.visible(5)]\n if self.pressed:\n self.fire_timer += 1\n if self.fire_timer > 7:\n self.fire_timer -= 7\n for angle, distance in ((self.angle, 12), (self.angle + math.pi, 5)):\n shot = Moving(50, 50, angle)\n shot.move(distance)\n self.shots.append(shot)\n else:\n self.angle = (self.angle + self.direction * 0.1) % math.tau\n\n coins = []\n for coin in self.coins:\n coin.move(1)\n if self._near_hand(coin.x, coin.y, 5):\n self.multiplier += 1\n elif coin.visible(5):\n coins.append(coin)\n self.coins = coins\n self._spawn()\n\n reward = 0\n enemies = []\n for enemy in self.enemies:\n enemy.move(0.5)\n if enemy.windup:\n enemy.windup -= 1\n if not enemy.windup:\n self.bullets.append(Moving(enemy.x, enemy.y, enemy.aim))\n if any(math.hypot(enemy.x - shot.x, enemy.y - shot.y) < 5 for shot in self.shots):\n reward += self.multiplier\n self.coins.append(Moving(enemy.x, enemy.y, enemy.aim))\n elif (enemy.x - 50) * math.cos(enemy.angle) + (enemy.y - 50) * math.sin(enemy.angle) < 75:\n enemies.append(enemy)\n self.enemies = enemies\n\n for bullet in self.bullets:\n for _ in range(3):\n bullet.move(3)\n self.terminal |= self._near_hand(bullet.x, bullet.y, 3.5)\n self.bullets = [bullet for bullet in self.bullets if bullet.visible(5)]\n return reward\n\n def _spawn(self) -> None:\n self.bullet_timer -= 1\n if self.bullet_timer < 0 and self.enemies:\n enemy = self.enemies[int(self.random.integers(len(self.enemies)))]\n predicted = Moving(enemy.x, enemy.y, enemy.angle)\n predicted.move(22.5)\n angle = math.atan2(50 - predicted.y, 50 - predicted.x)\n offset = (angle - enemy.aim + math.pi) % math.tau - math.pi\n if not enemy.windup and predicted.visible(-5) and abs(offset) > math.pi * 0.07:\n enemy.windup = 45\n self.bullet_timer = int(self.random.integers(45, 61))\n self.enemy_timer -= 1\n if self.enemy_timer < 0:\n angle = self.random.uniform(0, math.tau)\n aim = angle + self.random.choice((-1, 1)) * math.pi / 2\n enemy = Enemy(50, 50, angle, aim)\n enemy.move(-60)\n distance = self.random.uniform(30, 40)\n enemy.x -= distance * math.cos(aim)\n enemy.y -= distance * math.sin(aim)\n self.enemies.append(enemy)\n self.enemy_timer = int(self.random.integers(50, 91))\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for distance in range(-6, 15, 2):\n point = Moving(50, 50, self.angle)\n point.move(distance)\n state[int(point.y) // 10, int(point.x) // 10, 0] = True\n for channel, objects in enumerate((self.shots, self.enemies, self.bullets, self.coins), 1):\n for obj in objects:\n if obj.visible():\n state[int(obj.y) // 10, int(obj.x) // 10, channel] = True\n for enemy in self.enemies:\n if enemy.windup:\n warning = Moving(enemy.x, enemy.y, enemy.aim)\n for _ in range(20):\n if warning.visible():\n state[int(warning.y) // 10, int(warning.x) // 10, 3] = True\n warning.move(5)\n for row, value in enumerate((self.steps, self.multiplier, round(self.angle % math.tau * 80), self.fire_timer)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 281, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/clock_turret.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-11-games/blob/6fea4eefe2deaa42706051d96a04ec9e36104696/docs/clockturret/main.js"} +{"name": "ring_blast", "split": "train", "game": "ring_blast", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Ring Blast as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nActions 1 and 3 aim left and right. Actions 2 and 4 increase and\ndecrease launch speed. Actions 0 and 5 hold the setting. Both sides\nlaunch automatically every 100 frames. A player stone hitting an\nenemy stone starts a 60-frame fuse, which produces an expanding arc.\nAn arc hit scores the current multiplier, then raises it. Hits on\nyour own stones also refund ammunition. The multiplier resets when\nall rings expire. The episode ends when ammunition runs out and\nno fuse or ring remains.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show player stones, enemy stones, armed\nstones, blast arcs, the aiming marker, and counters. This port uses\nthe native D-pad mapping, fixed difficulty, and geometric arc\ncollisions. Stone contacts are resolved once per pair per frame.\nEach action advances up to four frames for up to 400 actions. Clip\nthe episode score to [0, 300] and divide by 300.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/ring_blast.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import atan2, cos, pi, sin\n\nimport numpy as np\n\n\nCENTER = np.array([50, 60])\n\n\n@dataclass\nclass Stone:\n position: np.ndarray\n velocity: np.ndarray\n side: int\n fuse: int = 60\n\n\n@dataclass\nclass Ring:\n radius: float\n angle: float\n spread: float\n growth: float\n\n\nclass RingBlastEnvironment:\n score_cap = 300\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.stones = []\n self.rings = []\n self.angle, self.enemy_angle = -pi / 2, pi / 2\n self.speed = self.enemy_speed = 1.0\n self.angle_direction = self.speed_direction = 1\n self.ammo, self.timer = 10, 100\n self.multiplier = 1\n self.action = self.steps = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _aim(self):\n self.angle += 0.03 * ((self.action == 3) - (self.action == 1))\n self.angle = min(-pi / 6, max(-5 * pi / 6, self.angle))\n self.speed = min(4, max(1, self.speed + 0.05 * ((self.action == 2) - (self.action == 4))))\n self.enemy_angle += self.angle_direction * self.random.uniform(0.02, 0.03)\n if abs(self.enemy_angle - pi / 2) > pi / 3 and (self.enemy_angle - pi / 2) * self.angle_direction > 0:\n self.angle_direction *= -1\n self.enemy_speed += self.speed_direction * self.random.uniform(0.03, 0.04)\n if (self.enemy_speed > 4 and self.speed_direction > 0) or (self.enemy_speed < 1 and self.speed_direction < 0):\n self.speed_direction *= -1\n\n def _advance(self):\n self._aim()\n self.timer = max(0, self.timer - 1)\n if self.timer == 0:\n if self.ammo:\n self.ammo -= 1\n self.timer = 100\n launches = ((120, self.angle, self.speed), (0, self.enemy_angle, self.enemy_speed))\n for side, (y, angle, speed) in enumerate(launches):\n self.stones.append(Stone(np.array([50., float(y)]),\n speed * np.array([cos(angle), sin(angle)]), side))\n elif not self.rings and not any(stone.side == 2 for stone in self.stones):\n self.terminal = True\n return 0\n for ring in self.rings:\n ring.spread += ring.growth\n active_rings = tuple(self.rings)\n reward = 0\n survivors = []\n for stone in self.stones:\n stone.position += stone.velocity\n stone.velocity *= 0.98\n lower, upper = np.array([13, 3]), np.array([87, 117])\n bounce = ((stone.position < lower) & (stone.velocity < 0)) | (\n (stone.position > upper) & (stone.velocity > 0)\n )\n stone.velocity[bounce] *= -1\n delta = stone.position - CENTER\n radius = np.linalg.norm(delta)\n angle = atan2(delta[1], delta[0])\n if stone.side == 2:\n stone.fuse -= 1\n if stone.fuse == 0:\n self.rings.append(Ring(radius, angle, 0, 1 / (radius + 1)))\n continue\n elif any(self._ring_hit(ring, radius, angle) for ring in active_rings):\n self.ammo += int(stone.side == 0)\n reward += self.multiplier\n self.multiplier += 1\n continue\n survivors.append(stone)\n for index, stone in enumerate(survivors):\n for other in survivors[index + 1:]:\n delta = other.position - stone.position\n distance = np.linalg.norm(delta)\n if distance >= 6:\n continue\n axis = delta / distance if distance else np.array([1., 0.])\n impulse = 0.7 * (abs(other.velocity @ axis) - abs(stone.velocity @ axis))\n stone.velocity -= impulse * axis\n other.velocity += impulse * axis\n stone.position += 2 * stone.velocity\n other.position += 2 * other.velocity\n if {stone.side, other.side} == {0, 1}:\n (stone if stone.side == 1 else other).side = 2\n self.stones = survivors\n for ring in active_rings:\n ring.radius += 2\n self.rings = [ring for ring in self.rings if ring.radius <= 99]\n if not self.rings:\n self.multiplier = 1\n return reward\n\n @staticmethod\n def _ring_hit(ring, radius, angle):\n difference = abs((angle - ring.angle + pi) % (2 * pi) - pi)\n tolerance = 4.5 / max(1, ring.radius)\n return abs(radius - ring.radius) < 4.5 and difference <= ring.spread + tolerance\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for stone in self.stones:\n x, y = stone.position\n if 0 <= x < 100 and 0 <= y < 150:\n state[int(y // 15), int(x // 10), stone.side] = True\n rows, cols = np.ogrid[7.5:150:15, 5:100:10]\n radius = np.hypot(cols - 50, rows - 60)\n angle = np.arctan2(rows - 60, cols - 50)\n for ring in self.rings:\n difference = abs((angle - ring.angle + pi) % (2 * pi) - pi)\n state[:, :, 3] |= (abs(radius - ring.radius) < 9) & (\n difference <= ring.spread + 9 / max(1, ring.radius)\n )\n x = 50 + self.speed * 5 * cos(self.angle)\n y = 120 + self.speed * 5 * sin(self.angle)\n state[int(y // 15), int(x // 10), 4] = True\n values = (self.steps, self.ammo, self.timer, self.multiplier,\n round((self.angle + pi) * 100), round(self.speed * 100),\n round(self.enemy_angle * 100), round(self.enemy_speed * 100))\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 282, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/ring_blast.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameRingBlast.c"} +{"name": "hit_blow_up", "split": "train", "game": "hit_blow_up", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Hit Blow Up as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nMove the cursor with actions 1 and 3, then tap action 5 to\nselect a color. Actions 0, 2, and 4 release without moving.\nFill every slot to submit a guess. A hit is a correct color\nin the right position. A blow is a correct color in the\nwrong position. Solving a stage scores more when you use\nfewer guesses and finish faster.\n\nINPUT CHANNEL TABLE\nThe six boolean channels represent the six colors. Rows 0–6\nstore up to 14 guesses across two five-column blocks. The\nfifth cell of each block holds hit and blow counts as two\nthree-bit fields. The bottom three rows hold the palette,\npartial guess, slot count, cursor, timer, and stage. During\nthe transition the bottom row reveals the answer. This\nlayout preserves guess history despite discretizing the\noriginal pointer selection.\n\nSCORING, TERMINATION, AND HORIZON\nThe task lasts up to 400 actions and normalizes raw scores\nby clipping to [0, 1000] and dividing by 1000.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/hit_blow_up.py`):\n```python\nimport numpy as np\n\n\nclass HitBlowUpEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.stage = self.action = 0\n self.terminal = False\n self._new_stage()\n\n def _new_stage(self) -> None:\n stage = self.stage % 6\n if stage == 0:\n self.palette = self.random.permutation(6).tolist()\n self.selector = self.palette[:3 + (stage + 1) // 2]\n self.target = self.random.permutation(self.selector)[:2 + stage // 2].tolist()\n self.cursor = self.cooldown = 0\n self.selector_y = 90.0\n self.guess: list[int] = []\n self.history: list[tuple[list[int], int, int]] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0.0\n if self.cooldown:\n self.cooldown -= 4\n if not self.cooldown:\n self.stage += 1\n self._new_stage()\n else:\n self.selector_y -= 0.2 * 2 ** (self.stage // 6) / (len(self.target) ** 2 + len(self.selector))\n if self.action == 1:\n self.cursor = (self.cursor - 1) % len(self.selector)\n elif self.action == 3:\n self.cursor = (self.cursor + 1) % len(self.selector)\n elif self.action == 5 and previous != 5:\n reward = self._select()\n self.terminal = not self.cooldown and self.selector_y - 3 - 6 * len(self.history) < 3\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _select(self) -> float:\n self.guess.append(self.selector[self.cursor])\n if len(self.guess) < len(self.target):\n return 0.0\n hit = sum(a == b for a, b in zip(self.target, self.guess, strict=True))\n blow = len(set(self.target).intersection(self.guess)) - hit\n self.history.append((self.guess, hit, blow))\n self.guess = []\n if hit == len(self.target):\n self.cooldown = 60\n return (self.selector_y - 6 * len(self.history)) * (self.stage // 6 + 1)\n return 0.0\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for index, (guess, hit, blow) in enumerate(self.history):\n row, start = (index, 0) if index < 7 else (index - 7, 5)\n for column, color in enumerate(guess, start):\n state[row, column, color] = True\n for bit in range(3):\n state[row, start + 4, bit] = bool(hit & (1 << bit))\n state[row, start + 4, bit + 3] = bool(blow & (1 << bit))\n for column, color in enumerate(self.selector):\n state[7, column, color] = True\n if not self.cooldown:\n state[9, self.cursor, 4] = True\n for column in range(len(self.target)):\n if column < len(self.guess):\n state[8, column, self.guess[column]] = True\n for row, value in ((8, round(self.selector_y)), (9, self.stage)):\n for bit in range(6):\n state[row, 9, bit] = bool(value & (1 << bit))\n state[row, 8, 5] = bool(value & 64)\n state[9, 8, 0] = self.cooldown > 0\n state[9, 8, 1] = self.action == 5\n state[8, 5:5 + len(self.target), 0] = True\n if self.cooldown:\n for column, color in enumerate(self.target):\n state[9, column, color] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 283, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/hit_blow_up.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/hitblowup/main.js"} +{"name": "parking", "split": "train", "game": "parking", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Parking as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to turn the moving cars right. Actions 0–4\nstraighten them. Park cars in the right-hand strip for\nten times the current multiplier. Collect gold to raise\nthe multiplier. Parking increases how many cars may be on\nthe road. A collision or a car leaving the bottom ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show moving cars, parked cars, gold,\nthe parking strip, road edges, and gauges. The conversion\napproximates oriented sprite collisions with rectangular\nbounds. It uses four frames per action at fixed difficulty.\nThe 400-action task clips scores to [0, 500] and divides by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/parking.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Car:\n x: float\n y: float\n\n\nclass ParkingEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.cars: list[Car] = []\n self.parked: list[Car] = []\n self.angle = -math.pi / 2\n self.car_timer = self.parked_distance = self.road = 0.0\n self.capacity = 1.0\n self.gold: Car | None = None\n self.multiplier = 1\n self.steps = 0\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n scroll = 1.05\n if self.cars:\n scroll += max(0, 50 - self.cars[0].y) * 0.1\n else:\n self.car_timer -= 1\n self.road += scroll\n if self.gold is None:\n self.gold = Car(self.random.uniform(40, 70), self.random.uniform(-50, -20))\n self.gold.y += scroll\n if self.gold.y > 103:\n self.gold = None\n self.multiplier = max(1, self.multiplier - 1)\n self.parked_distance -= scroll\n if self.parked_distance < 0:\n self.parked.append(Car(self.random.uniform(80, 84), -5))\n self.parked_distance = (self.random.uniform(8, 12) if self.random.random() < 0.7\n else self.random.uniform(100, 200))\n for car in self.parked:\n car.y += scroll\n self.parked = [car for car in self.parked if car.y <= 105]\n self.car_timer -= scroll - 1\n if len(self.cars) < self.capacity and self.car_timer < 0:\n self.cars.append(Car(self.random.uniform(20, 60), -5))\n self.car_timer = 15\n self.angle = min(0, max(-math.pi / 2, self.angle + (0.1 if self.pressed else -0.1)))\n reward = 0\n remaining = []\n for car in self.cars:\n heading = -math.pi / 2 if car.y < 3 else self.angle\n car.x += math.cos(heading)\n car.y += scroll + math.sin(heading)\n occupied = (*self.parked, *remaining)\n if any(abs(car.x - other.x) < 4 and abs(car.y - other.y) < 4 for other in occupied):\n self.terminal = True\n break\n if car.x + 2 > 82 and self._parking_strip(car.y):\n reward += self.multiplier * 10\n self.parked.append(car)\n self.capacity += 1 / self.capacity\n continue\n if self.gold is not None and abs(car.x - self.gold.x) < 6 and abs(car.y - self.gold.y) < 6:\n if self.gold.y > -3:\n reward += self.multiplier\n self.multiplier += 1\n self.gold = None\n if car.y > 103:\n self.terminal = True\n break\n remaining.append(car)\n self.cars = remaining\n return reward\n\n def _parking_strip(self, y):\n return any(start - 2 < y < start + 92 for start in (self.road % 93 + 6, self.road % 93 - 88))\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for channel, cars in ((0, self.cars), (1, self.parked), (2, [self.gold] if self.gold else [])):\n for car in cars:\n if 0 <= car.x < 100 and 0 <= car.y < 100:\n state[int(car.y // 10), int(car.x // 10), channel] = True\n for row in range(10):\n state[row, 8, 3] = self._parking_strip(10 * row + 5)\n state[:, (0, 9), 4] = True\n values = (self.steps, self.multiplier, round(-self.angle * 100), round(self.capacity * 20))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(min(511, value) & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 284, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/parking.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/parking/main.js"} +{"name": "blade_dancer", "split": "train", "game": "blade_dancer", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Blade Dancer as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to jump and swing the sword. Hold to stay airborne\nlonger. Release with actions 0–4 before tapping again. The sword\nrotates and extends during the jump. Sword hits score a rising\ncombo that resets on takeoff. Body contact with an enemy or\nstanding over a gap ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the runner, sword, enemies, platform\nsupport, airborne status, and gauges for input, jump time, combo,\nand episode step. Each action advances four frames. This conversion\nuses fixed scroll speed and tests sword hits by distance to the blade\nsegment.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends on death or after 400 actions. The normalization cap\nis a fixed 100 raw points. Clip to [0, 100] and divide by 100.\n\nAcross 100 seeds without sticky actions, idle and always held each\naveraged 0.23 raw points. Random hold and release averaged 16.99 and\nreached 97. A timing heuristic using exact enemy and platform\npositions averaged 44.23 and reached 187.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/blade_dancer.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\nPLAYER_X = 35\nGROUND = 80\nJUMP_DURATION = 30\n\n\n@dataclass\nclass Enemy:\n x: float\n y: float\n size: float\n\n\nclass BladeDancerEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = 0\n self.pressed = self.terminal = False\n self.jump_ticks = 0.0\n self.y = float(GROUND)\n self.angle = math.pi / 2\n self.length = 10.0\n self.multiplier = 1\n self.enemies: list[Enemy] = []\n self.platforms = [(0.0, 200.0)]\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed and not self.jump_ticks:\n self.jump_ticks = JUMP_DURATION\n self.multiplier = 1\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for _ in range(FRAMES_PER_STEP):\n reward += self._advance_frame()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _sword_vector(self) -> tuple[float, float]:\n return self.length * math.cos(self.angle), self.length * math.sin(self.angle)\n\n def _advance_frame(self) -> int:\n if self.jump_ticks:\n self.jump_ticks = max(0, self.jump_ticks - (0.5 if self.pressed else 1))\n progress = self.jump_ticks / JUMP_DURATION\n self.y = GROUND - math.sin(progress * math.pi) * 30\n self.angle = self.angle - 0.3 if self.jump_ticks else math.pi / 2\n self.length = 8 + (1 - progress) * 22 if self.jump_ticks else 10\n\n if not self.enemies or self.random.random() < 0.04:\n if len(self.enemies) == 32:\n self.enemies.pop(0)\n self.enemies.append(Enemy(205, self.random.uniform(30, 75), self.random.uniform(3, 6)))\n reward = 0\n survivors = []\n sword_x, sword_y = self._sword_vector()\n sword_radius = 2.5 if self.jump_ticks else 1\n for enemy in self.enemies:\n enemy.x -= 1\n dx, dy = enemy.x - PLAYER_X, enemy.y - (self.y - 4)\n fraction = min(1, max(0, (dx * sword_x + dy * sword_y) / self.length**2))\n distance = math.hypot(dx - fraction * sword_x, dy - fraction * sword_y)\n radius = enemy.size / 2\n if distance <= radius + sword_radius:\n reward += self.multiplier\n self.multiplier += 1\n continue\n if abs(dx) < 2 + radius and abs(enemy.y - self.y) < 4 + radius:\n self.terminal = True\n if enemy.x >= -10:\n survivors.append(enemy)\n self.enemies = survivors\n\n self.platforms = [(left - 1, right - 1) for left, right in self.platforms if right >= 1]\n end = self.platforms[-1][1]\n if end < 200:\n gap = self.random.uniform(15, 30) if self.random.random() < 0.32 else 0\n length = self.random.uniform(30, 100) if gap else self.random.uniform(50, 150)\n self.platforms.append((end + gap, end + gap + length))\n if not self.jump_ticks and not any(left <= PLAYER_X <= right for left, right in self.platforms):\n self.terminal = True\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row, column = int(self.y) // 10, PLAYER_X // 20\n state[row, column, 0] = True\n state[row, column, 4] = self.jump_ticks > 0\n sword_x, sword_y = self._sword_vector()\n for fraction in np.linspace(0, 1, 12):\n y = int(self.y - 4 + fraction * sword_y) // 10\n x = int(PLAYER_X + fraction * sword_x) // 20\n state[y, x, 1] = True\n for enemy in self.enemies:\n if 0 <= enemy.x < 200:\n state[int(enemy.y) // 10, int(enemy.x) // 20, 2] = True\n for column in range(10):\n x = 20 * column + PLAYER_X % 20\n state[8, column, 3] = any(left <= x <= right for left, right in self.platforms)\n state[9, 0, 5] = self.pressed\n for row, value in enumerate((int(self.jump_ticks * 2), self.multiplier, self.steps)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 285, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/blade_dancer.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBladeDancer.c"} +{"name": "interspace", "split": "train", "game": "interspace", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Interspace as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nUse action 1 to move left and action 3 to move right.\nOther actions hold position. Directional movement replaces\npointer sliding and moves five source pixels per action.\n\nAlign with the moving wall's gap. The player stretches\nwhen clear of the wall, which increases scrolling speed\nand score. Wall contact ends the run. After a wall passes,\nthe next gap shifts horizontally.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, wall, gap,\nplayer column, gap column, and gauges. The gauges preserve\nsubcell alignment. Each action advances four frames at fixed\ndifficulty. The 400-action task divides the clipped score\nby 11,840, the bound from 1,600 frames at 7.4 points per frame.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/interspace.py`):\n```python\nimport numpy as np\n\n\nclass InterspaceEnvironment:\n score_cap = 11840\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x, self.y = 50.0, 10.0\n self.height = 7.0\n self.gap_x, self.wall_y = 50.0, 99.0\n self.steps = self.action = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0.0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return reward, self.terminal\n\n def _advance(self) -> float:\n scroll = 0.5 + (self.height - 7) * 0.3\n self.wall_y -= scroll\n if self.wall_y < 0:\n self.gap_x = (self.gap_x + self.random.uniform(-9, 9) - 9) % 81 + 9\n self.wall_y = 99\n self.x = min(99, max(0, self.x + 1.25 * ((self.action == 3) - (self.action == 1))))\n outside_gap = abs(self.x - self.gap_x) > 3.5\n wall_in_probe = self.wall_y < self.y + 49.5 and self.wall_y + 9 > self.y - 49.5\n if outside_gap and wall_in_probe:\n self.y += (10 - self.y) * 0.1\n self.height += (7 - self.height) * 0.4\n else:\n self.y += (30 - self.y) * 0.1\n self.height += (30 - self.height) * 0.1\n self.terminal = (outside_gap and self.y + self.height / 2 > self.wall_y\n and self.y - self.height / 2 < self.wall_y + 9)\n return scroll\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n col = int(self.x // 10)\n top = max(0, int((self.y - self.height / 2) // 10))\n bottom = min(9, int((self.y + self.height / 2) // 10))\n state[top:bottom + 1, col, 0] = True\n wall_top = int(self.wall_y // 10)\n wall_bottom = min(9, int((self.wall_y + 9) // 10))\n for column in range(10):\n cell_x = column * 10 + 5\n state[wall_top:wall_bottom + 1, column, 1] = abs(cell_x - self.gap_x) >= 7\n state[wall_top:wall_bottom + 1, int(self.gap_x // 10), 2] = True\n state[:, col, 3] = True\n state[:, int(self.gap_x // 10), 4] = True\n gauges = (self.steps, round(self.x * 4), round(self.gap_x * 4),\n round(self.wall_y * 4), round(self.height * 10), round(self.y * 10), self.action)\n for row, value in enumerate(gauges):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 286, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/interspace.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/interspace/main.js"} +{"name": "ms_pac_man", "split": "train", "game": "ms_pac_man", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Ms Pac Man as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves four changing mazes, dot clearing, four corner energizers, four ghosts\nwith distinct targeting behavior, tunnel wrapping, frightened-ghost chains, timed fruit, three\nstarting lives, the first-10,000-point bonus life, and increasing difficulty. Clearing every dot\nand energizer advances the maze. Ghosts accelerate after the first maze and frightened time falls.\n\nACTION MAPPING\n0: wait\n1: move left\n2: move up\n3: move right\n4: move down\n5: unused\n\nINPUT CHANNEL TABLE\n0: Ms. Pac-Man\n1: four ghosts\n2: dots, energizers, and active fruit\n3: walls, energizer distinction, and fruit distinction\n4: previous player and ghost positions\n5: maze, lives, ghost chain, exact frightened/fruit timers, ghost directions, exact steps, and one-time reward flags\n\nSCORING, TERMINATION, AND HORIZON\nEach maze has 47 dots (470), four energizers (200), and at most four complete ghost chains\n(`4 × 3,000 = 12,000`). The four fruit are worth 100, 200, 500, and 700. Therefore the finite\ncampaign cap is `4 × (470 + 200 + 12,000) + 1,500 = 52,180`. Normalization is\n`min(max(raw_score, 0), 52_180) / 52_180`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/ms_pac_man.py`):\n```python\nimport numpy as np\n\n\nFRUIT_VALUES = (100, 200, 500, 700)\nGHOST_VALUES = (200, 400, 800, 1_600)\nENERGIZERS = ((1, 1), (1, 8), (8, 1), (8, 8))\nPLAYER_START = (7, 5)\nGHOST_STARTS = ((4, 4), (4, 5), (5, 4), (5, 5))\nINTERNAL_WALLS = (\n frozenset({(2, 2), (2, 3), (2, 6), (2, 7), (7, 2), (7, 3), (7, 6), (7, 7)}),\n frozenset({(2, 4), (2, 5), (4, 2), (5, 2), (4, 7), (5, 7), (7, 4), (7, 5)}),\n frozenset({(2, 2), (2, 7), (3, 4), (3, 5), (6, 4), (6, 5), (7, 2), (7, 7)}),\n frozenset({(2, 3), (2, 6), (4, 2), (4, 7), (5, 2), (5, 7), (7, 3), (7, 6)}),\n)\nDIRECTIONS = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}\n\n\nclass MsPacManEnvironment:\n \"\"\"Four-maze dot clearing with fruit, energizers, and four ghosts.\"\"\"\n\n score_cap = 52_180.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 4_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.maze = 0\n self.lives = 3\n self.score = 0.0\n self.bonus_life_awarded = False\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self._start_maze()\n\n def _walls(self) -> set[tuple[int, int]]:\n walls = {(0, column) for column in range(10)} | {(9, column) for column in range(10)}\n walls |= {(row, 0) for row in range(10) if row != 5}\n walls |= {(row, 9) for row in range(10) if row != 5}\n walls |= set(INTERNAL_WALLS[self.maze])\n return walls\n\n def _start_maze(self) -> None:\n walls = self._walls()\n excluded = {PLAYER_START, *GHOST_STARTS, *ENERGIZERS, (5, 5)}\n self.dots = {\n (row, column)\n for row in range(1, 9)\n for column in range(1, 9)\n if (row, column) not in walls and (row, column) not in excluded\n }\n self.initial_dot_count = len(self.dots)\n self.energizers = set(ENERGIZERS)\n self.fruit_collected = False\n self.fruit_active = False\n self.fruit_timer = 0\n self.frightened_timer = 0\n self.ghost_chain = 0\n self.frightened_eaten: set[int] = set()\n self._reset_actors()\n\n def _reset_actors(self) -> None:\n self.player = list(PLAYER_START)\n self.previous_player = self.player.copy()\n self.ghosts = [list(position) for position in GHOST_STARTS]\n self.previous_ghosts = [ghost.copy() for ghost in self.ghosts]\n self.ghost_directions = [1, 3, 1, 3]\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n self.previous_ghosts = [ghost.copy() for ghost in self.ghosts]\n maze_before = self.maze\n self._move_player(action)\n reward = self._eat_at_player()\n if self.maze == maze_before and not self.terminal:\n self._move_ghosts()\n reward += self._resolve_collisions()\n self.score += reward\n if self.score >= 10_000 and not self.bonus_life_awarded:\n self.lives += 1\n self.bonus_life_awarded = True\n self.steps += 1\n self.frightened_timer = max(0, self.frightened_timer - 1)\n self.fruit_timer = max(0, self.fruit_timer - 1)\n if self.fruit_timer == 0:\n self.fruit_active = False\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_player(self, action: int) -> None:\n if action not in DIRECTIONS:\n return\n row_delta, column_delta = DIRECTIONS[action]\n target = [self.player[0] + row_delta, self.player[1] + column_delta]\n if self.player[0] == 5 and target[1] < 0:\n target[1] = 9\n elif self.player[0] == 5 and target[1] > 9:\n target[1] = 0\n if tuple(target) not in self._walls():\n self.player = target\n\n def _eat_at_player(self) -> float:\n position = tuple(self.player)\n reward = 0.0\n if position in self.dots:\n self.dots.remove(position)\n reward += 10.0\n if position in self.energizers:\n self.energizers.remove(position)\n self.frightened_timer = max(8, 20 - self.maze * 4)\n self.ghost_chain = 0\n self.frightened_eaten.clear()\n reward += 50.0\n if not self.fruit_collected and not self.fruit_active and len(self.dots) <= self.initial_dot_count // 2:\n self.fruit_active = True\n self.fruit_timer = 80\n if self.fruit_active and position == (5, 5):\n self.fruit_active = False\n self.fruit_collected = True\n reward += float(FRUIT_VALUES[self.maze])\n if not self.dots and not self.energizers:\n self.maze += 1\n if self.maze >= 4:\n self.terminal = True\n else:\n self._start_maze()\n return reward\n\n def _move_ghosts(self) -> None:\n if self.maze == 0 and self.steps % 2:\n return\n walls = self._walls()\n for index, ghost in enumerate(self.ghosts):\n options = []\n reverse = {1: 3, 2: 4, 3: 1, 4: 2}[self.ghost_directions[index]]\n for action, (row_delta, column_delta) in DIRECTIONS.items():\n target = [ghost[0] + row_delta, ghost[1] + column_delta]\n if ghost[0] == 5 and target[1] < 0:\n target[1] = 9\n elif ghost[0] == 5 and target[1] > 9:\n target[1] = 0\n if tuple(target) not in walls and action != reverse:\n options.append((action, target))\n if not options:\n row_delta, column_delta = DIRECTIONS[reverse]\n options = [(reverse, [ghost[0] + row_delta, ghost[1] + column_delta])]\n target_player = self._ghost_target(index)\n scored = []\n for option in options:\n distance = abs(option[1][0] - target_player[0]) + abs(option[1][1] - target_player[1])\n scored.append((distance, option))\n best_value = max(value for value, _ in scored) if self.frightened_timer else min(value for value, _ in scored)\n best = [option for value, option in scored if value == best_value]\n action, target = best[int(self.random.randint(len(best)))]\n self.ghost_directions[index] = action\n self.ghosts[index] = target\n\n def _ghost_target(self, index: int) -> tuple[int, int]:\n if index == 0:\n return tuple(self.player)\n if index == 1:\n delta = DIRECTIONS.get(self.last_action, (0, 0))\n return self.player[0] + delta[0] * 2, self.player[1] + delta[1] * 2\n if index == 2:\n return (1, 1) if (self.steps // 8) % 2 else tuple(self.player)\n return (8, 8) if self.player[0] < 5 else (1, 8)\n\n def _resolve_collisions(self) -> float:\n reward = 0.0\n for index, ghost in enumerate(self.ghosts):\n crossed = ghost == self.previous_player and self.player == self.previous_ghosts[index]\n if ghost != self.player and not crossed:\n continue\n if self.frightened_timer and index not in self.frightened_eaten:\n reward += float(GHOST_VALUES[min(3, self.ghost_chain)])\n self.ghost_chain += 1\n self.frightened_eaten.add(index)\n self.ghosts[index] = list(GHOST_STARTS[index])\n self.previous_ghosts[index] = self.ghosts[index].copy()\n else:\n self.lives -= 1\n if self.lives <= 0:\n self.terminal = True\n else:\n self.frightened_timer = 0\n self.ghost_chain = 0\n self.frightened_eaten.clear()\n self._reset_actors()\n break\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n state[*self.previous_player, 4] = True\n for index, ghost in enumerate(self.ghosts):\n state[*ghost, 1] = True\n state[*self.previous_ghosts[index], 4] = True\n for dot in self.dots:\n state[*dot, 2] = True\n for energizer in self.energizers:\n state[*energizer, 2] = True\n state[*energizer, 3] = True\n if self.fruit_active:\n state[5, 5, 2] = True\n state[5, 5, 3] = True\n for wall in self._walls():\n state[*wall, 3] = True\n for bit in range(2):\n state[0, bit, 5] = bool(self.maze & (1 << bit))\n for bit in range(3):\n state[0, 2 + bit, 5] = bool(self.lives & (1 << bit))\n state[0, 5 + bit, 5] = bool(self.ghost_chain & (1 << bit))\n for bit in range(5):\n index = 8 + bit\n state[index // 10, index % 10, 5] = bool(self.frightened_timer & (1 << bit))\n for bit in range(7):\n index = 13 + bit\n state[index // 10, index % 10, 5] = bool(self.fruit_timer & (1 << bit))\n for index, direction in enumerate(self.ghost_directions):\n for bit in range(3):\n gauge_index = 20 + index * 3 + bit\n state[gauge_index // 10, gauge_index % 10, 5] = bool(direction & (1 << bit))\n for bit in range(12):\n gauge_index = 32 + bit\n state[gauge_index // 10, gauge_index % 10, 5] = bool(self.steps & (1 << bit))\n state[4, 4, 5] = self.fruit_collected\n state[4, 5, 5] = self.bonus_life_awarded\n for index in range(4):\n state[4, 6 + index, 5] = index in self.frightened_eaten\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 287, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/ms_pac_man.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "growth", "split": "train", "game": "growth", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Growth as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to grow and release with actions 0–4 to shrink.\nSmall sizes build speed. Larger sizes let the player absorb\nlarger enemies but slow the player down. Hitting an enemy\nlarger than the player or falling off the left edge ends\nthe run. Absorbing an enemy scores its size times current\nspeed, with speed floored at one and points rounded up.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, edible enemies,\ndangerous enemies, floor, nearest enemy, and gauges.\nThe conversion runs at fixed difficulty for four frames\nper action. The task lasts up to 400 actions and clips\nraw scores to [0, 3500] before dividing by 3500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/growth.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Enemy:\n x: float\n size: float\n\n @property\n def screen_x(self) -> float:\n return self.x / (1 + max(0, self.x - 100) / 300)\n\n\nclass GrowthEnvironment:\n score_cap = 3500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x, self.speed, self.size = 9.0, 1.0, 5.0\n self.spawn_distance = 0.0\n self.steps = 0\n self.pressed = self.terminal = False\n self.enemies: list[Enemy] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self) -> int:\n scroll = max(0, (self.x - 9) * 0.5)\n target = 50 if self.pressed else 5\n self.size += (target - self.size) * min(999, max(1, self.speed)) * 0.01\n self.speed += (15 / self.size - 1) * 0.02\n self.x += self.speed - scroll\n front = self.x + self.size / 2\n if front < 1:\n self.terminal = True\n return 0\n self.spawn_distance -= scroll\n if self.spawn_distance < 0:\n size = 3.0\n if self.random.random() >= 0.8:\n width, height = self.random.uniform(0, 5, 2)\n size = width * height + 3\n self.enemies.append(Enemy(400, size if size >= 7 else 3))\n self.spawn_distance += self.random.uniform(30, 50)\n reward = 0\n remaining = []\n for enemy in self.enemies:\n enemy.x -= scroll\n if enemy.screen_x >= front:\n remaining.append(enemy)\n elif enemy.size > self.size:\n self.terminal = True\n break\n else:\n reward += math.ceil(min(999, max(1, self.speed)) * enemy.size)\n if not self.terminal:\n self.enemies = remaining\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n top = max(0, int((60 - self.size) // 7))\n front = min(9, max(0, int((self.x + self.size / 2) // 20)))\n state[top:9, :front + 1, 0] = True\n for enemy in self.enemies:\n if 0 <= enemy.screen_x <= 200:\n col = min(9, int(enemy.screen_x // 20))\n state[int((60 - enemy.size) // 7):9, col, 1 if enemy.size <= self.size else 2] = True\n state[9, :, 3] = True\n if self.enemies:\n nearest = self.enemies[0]\n state[8, min(9, max(0, int(nearest.screen_x // 20))), 4] = True\n speed = min(511, max(0, round((self.speed + 5) * 8)))\n for row, value in enumerate((self.steps, round(self.size * 10), speed)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 288, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/growth.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameGrowth.c"} +{"name": "number_line", "split": "train", "game": "number_line", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Number Line as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to sum the digits currently inside the play\narea on each line. Actions 0–4 release the button. After\na 61-frame delay, the upper sum minus the lower sum is\nadded to the score. A positive difference pushes the lines\napart. A negative difference pulls them closer. The run ends\nwhen the lines meet.\n\nINPUT CHANNEL TABLE\nThe 10×10×6 observation encodes each line's digits in spawn\norder and stores each digit's travel position in binary.\nThe bottom two rows carry line heights, pending sums, and\ninput and timing gauges. The conversion resolves the sum\ndirectly and retains the original delay in place of the\nmerge animation. At fixed difficulty the task advances four\nframes per action, up to 400 actions. It clips the score to\n[0, 100] and divides by 100.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/number_line.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Number:\n value: int\n x: float = -3\n\n\nclass NumberLineEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.lines = [12.0, 94.0]\n self.targets = self.lines.copy()\n self.numbers: list[list[Number]] = [[], []]\n self.timers = [0.0, 0.0]\n self.sums = [0, 0]\n self.countdown = self.steps = 0\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n self.targets[0] += 0.01\n self.targets[1] -= 0.01\n for index in range(2):\n self.lines[index] += (self.targets[index] - self.lines[index]) * 0.2\n reward = 0\n if self.lines[0] < 12:\n self.targets[0] += 1\n reward += 1\n if self.lines[1] > 94:\n self.targets[1] -= 1\n self.terminal = self.lines[0] >= self.lines[1]\n if self.countdown:\n self.countdown -= 1\n if not self.countdown:\n difference = self.sums[0] - self.sums[1]\n reward += difference\n self.targets[0] -= difference\n self.targets[1] += difference\n self.sums = [0, 0]\n elif tap:\n for index, numbers in enumerate(self.numbers):\n self.sums[index] = sum(n.value for n in numbers if 3 < n.x < 97)\n self.numbers[index] = [n for n in numbers if not 3 < n.x < 97]\n self.countdown = 61\n for index in range(2):\n self.timers[index] -= 1\n if self.timers[index] < 0:\n self.numbers[index].append(Number(int(self.random.integers(1, 10))))\n self.timers[index] = self.random.uniform(10, 30)\n for number in self.numbers[index]:\n number.x += 0.7\n self.numbers[index] = [n for n in self.numbers[index] if n.x <= 103]\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for side, numbers in enumerate(self.numbers):\n for index, number in enumerate(numbers):\n row, col = 4 * side + index // 10 * 2, index % 10\n for bit in range(4):\n state[row, col, bit] = bool(number.value & (1 << bit))\n position = round(number.x + 3)\n for bit in range(7):\n state[row + (bit >= 2), col, bit + 4 if bit < 2 else bit - 2] = bool(position & (1 << bit))\n values = (self.steps, self.countdown, self.sums[0], self.sums[1],\n round(self.lines[0]) + 128, round(self.lines[1]) + 128)\n for channel, value in enumerate(values):\n for bit in range(9):\n state[8, bit, channel] = bool(value & (1 << bit))\n state[9, 0, 0] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 289, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/number_line.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/numberline/main.js"} +{"name": "sight_on", "split": "train", "game": "sight_on", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Sight On as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to detonate at the automatic sight. Actions 0–4\nrelease. Enemies chase moving targets while the sight tracks the\nlowest enemy. Each kill raises the multiplier. Firing resets it\nand pushes the targets downward according to the accumulated fire\npenalty. An enemy reaching the bottom zone ends the run.\n\nINPUT CHANNEL TABLE\nSix channels show the sight, enemies, targets, explosions, the\ndanger zone, and counters. The port fixes difficulty and uses\nrectangular collision bounds. Each action advances up to four\nframes over 400 actions. Clip scores to [0, 150] and divide by 150.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/sight_on.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos\n\nimport numpy as np\n\n\n@dataclass\nclass Motion:\n pos: np.ndarray\n vel: np.ndarray\n\n\n@dataclass\nclass Enemy:\n motion: Motion\n sink: np.ndarray\n target: Motion\n\n\nclass SightOnEnvironment:\n score_cap = 150\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.sight = Motion(np.full(2, 50.), np.zeros(2))\n self.enemies, self.targets, self.blasts = [], [], []\n self.steps = self.count = self.wave_timer = self.enemy_timer = 0\n self.multiplier = 1\n self.penalty = 0.\n self.held = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _wave(self):\n target = Motion(np.array([self.random.uniform(20, 80), 0.]),\n np.array([self.random.uniform(-0.1, 0.1), 0.1]))\n self.targets.append(target)\n self.template = Enemy(\n Motion(np.array([self.random.uniform(10, 90), -5.]),\n self.random.uniform(1, 2, 2) * self.random.choice((-1, 1), 2)),\n self.random.uniform(0.02, 0.07, 2), target,\n )\n self.count = self.random.integers(2, 5)\n self.interval = self.random.uniform(3, 9)\n self.enemy_timer = 0\n self.wave_timer = self.random.uniform(120, 150)\n\n def _advance(self, tap):\n self.wave_timer -= 1\n if self.wave_timer < 0:\n self._wave()\n for target in self.targets:\n target.pos += target.vel\n target.pos[0] %= 99\n self.targets = [target for target in self.targets if target.pos[1] <= 150]\n template = self.template\n template.motion.pos += template.target.vel\n self.enemy_timer -= 1\n if self.count and self.enemy_timer < 0:\n self.enemies.append(Enemy(Motion(template.motion.pos.copy(), template.motion.vel.copy()),\n template.sink, template.target))\n self.count -= 1\n self.enemy_timer = self.interval\n if not self.enemies and not self.count:\n self.wave_timer = 0\n reward = 0\n remaining = []\n for enemy in self.enemies:\n motion = enemy.motion\n delta = enemy.target.pos - motion.pos\n delta[0] = (delta[0] + 50) % 100 - 50\n motion.vel = (motion.vel + delta * enemy.sink) * 0.997\n motion.pos += motion.vel * 0.2\n motion.pos[0] %= 99\n if any(np.all(abs(motion.pos - center) < 3 + 7.5 * cos(age * 0.05))\n for center, age in self.blasts):\n reward += self.multiplier\n self.multiplier += 1\n else:\n self.terminal |= bool(motion.pos[1] > 90)\n remaining.append(enemy)\n self.enemies = remaining\n self.blasts = [(center, age + 1) for center, age in self.blasts if age < 31]\n leader = max(self.enemies, key=lambda enemy: enemy.motion.pos[1], default=None)\n target = leader.motion.pos if leader is not None and leader.motion.pos[1] > 0 else np.full(2, 50.)\n delta = target - self.sight.pos\n delta[0] = (delta[0] + 50) % 100 - 50\n self.sight.vel = (self.sight.vel + delta * 0.01) * 0.97\n self.sight.pos += self.sight.vel * 0.2\n self.sight.pos[0] %= 99\n if tap:\n self.multiplier = 1\n self.blasts.append((self.sight.pos.copy(), 0))\n for target in self.targets:\n target.pos[1] += self.penalty\n self.penalty += 1\n self.sight.vel *= 0.1\n self.penalty *= 0.99\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n positions = [(self.sight.pos, 0)]\n positions.extend((enemy.motion.pos, 1) for enemy in self.enemies)\n positions.extend((target.pos, 2) for target in self.targets)\n for (x, y), channel in positions:\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), channel] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for (x, y), age in self.blasts:\n reach = 7.5 * cos(age * 0.05) + 5\n state[:, :, 3] |= (abs(cols - x) < reach) & (abs(rows - y) < reach)\n state[9, :, 4] = True\n for row, value in enumerate((self.steps, self.multiplier, self.held, round(self.penalty * 10))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 290, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/sight_on.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/sighton/main.js"} +{"name": "pairs_drop", "split": "train", "game": "pairs_drop", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Pairs Drop as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nMove the cursor with actions 1–4 (left, up, right, down).\nTap action 5 to reveal a card. Action 0 holds position.\nThese discrete controls replace pointer selection.\n\nMatching ranks drop both cards and everything below them\nin their columns. Falling cards score when they leave the\nscreen. A card that reaches the bottom without falling\nends the run. A mismatched pair stays revealed briefly.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels encode revealed ranks in four bits,\nplus card presence and falling status. Columns 7–8 carry\ncursor and timing information. Hidden ranks stay hidden.\nThe conversion uses fixed difficulty and four frames per\naction. The 400-action task clips scores to [0, 200] and\ndivides by 200.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/pairs_drop.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Card:\n column: int\n y: float\n rank: int\n opened: bool = False\n velocity: float = 0\n\n\nclass PairsDropEnvironment:\n score_cap = 200\n moves = ((0, 0), (-1, 0), (0, -1), (1, 0), (0, 1), (0, 0))\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.cards: list[Card] = []\n self.opened: list[Card] = []\n self.column, self.row = 3, 4\n self.scroll = 0.0\n self.next_y, self.next_column = -6.0, 0\n self.timer = self.steps = self.action = 0\n self.multiplier = 1\n self.terminal = False\n self._deal()\n\n def _deal(self):\n for rank in self.random.permutation(np.tile(np.arange(1, 14), 2)):\n self.cards.append(Card(self.next_column, self.next_y, int(rank)))\n self.next_column = (self.next_column + 1) % 7\n if not self.next_column:\n self.next_y -= 12\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n dx, dy = self.moves[self.action]\n self.column = min(6, max(0, self.column + dx))\n self.row = min(9, max(0, self.row + dy))\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(frame == 0 and self.action == 5 and previous != 5)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _open(self):\n for card in self.cards:\n if (card.column == self.column and 0 <= card.y < 100\n and int(card.y // 10) == self.row and not card.opened and not card.velocity):\n if self.timer:\n self._close()\n card.opened = True\n self.opened.append(card)\n if len(self.opened) == 2:\n first, second = self.opened\n self.timer = 60\n if first.rank == second.rank:\n for other in self.cards:\n if any(other.column == match.column and other.y >= match.y for match in self.opened):\n other.velocity = 1\n self.opened = []\n self.multiplier = 1\n return True\n return False\n\n def _close(self):\n for card in self.opened:\n card.opened = False\n self.opened.clear()\n self.timer = 0\n\n def _advance(self, tap):\n if self.timer:\n self.timer -= 1\n if not self.timer:\n self._close()\n opened = tap and self._open()\n reward = 0\n remaining = []\n min_y, max_y = 99, 0\n for card in self.cards:\n card.y += self.scroll + card.velocity\n if card.velocity:\n card.velocity += 0.1\n min_y, max_y = min(min_y, card.y), max(max_y, card.y)\n if not card.velocity and card.y > 95:\n self.terminal = True\n if card.y > 99:\n reward += self.multiplier\n self.multiplier += 1\n else:\n remaining.append(card)\n self.cards = remaining\n self.next_y += self.scroll\n self.scroll += (0.0015 - self.scroll) * 0.2 + 0.15 * opened\n self.scroll += max(0, 50 - max_y) * 0.01\n if min_y > -6:\n self._deal()\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for card in self.cards:\n if 0 <= card.y < 100:\n row, col = int(card.y // 10), card.column\n state[row, col, 4] = True\n state[row, col, 5] |= card.velocity > 0\n if card.opened:\n for bit in range(4):\n state[row, col, bit] |= bool(card.rank & (1 << bit))\n state[self.row, 7, 0] = True\n state[self.column, 7, 1] = True\n values = (self.steps, self.timer, min(511, self.multiplier), self.action)\n for channel, value in enumerate(values):\n for bit in range(9):\n state[bit, 8, channel] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 291, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pairs_drop.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/pairsdrop/main.js"} +{"name": "chopper_command", "split": "train", "game": "chopper_command", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Chopper Command as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves Activision's convoy-defense loop over the full long-range scanner.\nThe player helicopter moves vertically and horizontally through a ten-column wraparound combat\nzone, turns when moving left or right, and fires horizontally in its facing direction. Twelve\nfriendly trucks circulate below while 12 hostile aircraft cross each wave. Enemy helicopters\naward 100 points and jets award 200.\n\nEnemy aircraft launch missiles that descend and split into two diagonal warheads. The missiles\ncannot be shot; the player must evade them while preventing them from reaching the convoy.\nAircraft can also collide with the player. Clearing a wave awards `remaining trucks × wave × 100`.\nAll ten waves increase enemy movement and fire pressure. The player begins with three helicopters\nand gains one per 10,000 points up to six.\n\nACTION MAPPING\n0: wait\n1: move left\n2: move up\n3: move right\n4: move down\n5: fire\n\nINPUT CHANNEL TABLE\n0: player helicopter\n1: hostile aircraft and unshootable split missiles\n2: shootable aircraft and convoy trucks\n3: player laser shots\n4: previous player and threat positions\n5: jet identity, truck count, reserves, and wave gauge\n\nSCORING, TERMINATION, AND HORIZON\nThe structural maximum is `score_cap = 90,000`. Across ten waves there are 120 hostile aircraft;\ntreating every identity as the highest-value 200-point jet bounds aircraft reward at 24,000.\nSaving all 12 trucks through every wave gives\n`12 × 100 × (1 + 2 + ... + 10) = 66,000`. Extra helicopters do not award points. Therefore the\ntotal cannot exceed 90,000, and normalization is\n`min(max(raw_score, 0), 90_000) / 90_000`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/chopper_command.py`):\n```python\nimport numpy as np\n\n\nclass ChopperCommandEnvironment:\n \"\"\"Ten-wave convoy-defense shooter over a wraparound scanner world.\"\"\"\n\n score_cap = 90_000.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 4_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.player = [4, 1]\n self.previous_player = self.player.copy()\n self.facing = 1\n self.shots: list[dict[str, object]] = []\n self.missiles: list[dict[str, object]] = []\n self.trucks = [[8, column % 10] for column in range(12)]\n self.lives = 3\n self.score = 0.0\n self.next_life_score = 10_000.0\n self.wave = 1\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self.previous_threats: list[list[int]] = []\n self._start_wave()\n\n def _start_wave(self) -> None:\n self.enemies = [\n {\n \"position\": [1 + index % 4, (index * 3 + self.wave) % 10],\n \"kind\": \"jet\" if index % 2 else \"helicopter\",\n }\n for index in range(12)\n ]\n self.wave_steps = 0\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n self.previous_threats = self._threat_positions()\n self._apply_action(action)\n self._move_world()\n reward = self._resolve_shots()\n reward += self._resolve_missiles_and_contacts()\n self.score += reward\n if not self.enemies:\n reward += len(self.trucks) * self.wave * 100.0\n self.score += len(self.trucks) * self.wave * 100.0\n self.wave += 1\n if self.wave > 10:\n self.terminal = True\n else:\n self._start_wave()\n while self.score >= self.next_life_score and self.lives < 6:\n self.lives += 1\n self.next_life_score += 10_000.0\n self.wave_steps += 1\n self.steps += 1\n if self.steps >= self.horizon or not self.trucks:\n self.terminal = True\n return reward, self.terminal\n\n def _apply_action(self, action: int) -> None:\n if action == 1:\n self.player[1] = (self.player[1] - 1) % 10\n self.facing = -1\n elif action == 2:\n self.player[0] = max(0, self.player[0] - 1)\n elif action == 3:\n self.player[1] = (self.player[1] + 1) % 10\n self.facing = 1\n elif action == 4:\n self.player[0] = min(6, self.player[0] + 1)\n elif action == 5 and len(self.shots) < 3:\n self.shots.append({\"position\": self.player.copy(), \"direction\": self.facing})\n\n def _move_world(self) -> None:\n for shot in self.shots:\n shot[\"position\"][1] = (shot[\"position\"][1] + int(shot[\"direction\"])) % 10\n shot[\"distance\"] = int(shot.get(\"distance\", 0)) + 1\n self.shots = [shot for shot in self.shots if int(shot[\"distance\"]) < 10]\n move_interval = max(1, 5 - (self.wave - 1) // 2)\n if self.wave_steps % move_interval == 0:\n for enemy in self.enemies:\n enemy[\"position\"][1] = (enemy[\"position\"][1] - 1) % 10\n fire_probability = min(0.45, 0.04 + 0.025 * self.wave)\n for enemy in self.enemies:\n if self.random.rand() < fire_probability / max(1, len(self.enemies)):\n self.missiles.append({\"position\": list(enemy[\"position\"]), \"split\": False, \"direction\": 0})\n new_missiles = []\n for missile in self.missiles:\n missile[\"position\"][0] += 1\n missile[\"position\"][1] = (missile[\"position\"][1] + int(missile[\"direction\"])) % 10\n if missile[\"position\"][0] == 4 and not bool(missile[\"split\"]):\n for direction in (-1, 1):\n new_missiles.append({\"position\": list(missile[\"position\"]), \"split\": True, \"direction\": direction})\n elif missile[\"position\"][0] <= 8:\n new_missiles.append(missile)\n self.missiles = new_missiles\n if self.wave_steps % 2 == 0:\n for truck in self.trucks:\n truck[1] = (truck[1] - 1) % 10\n\n def _resolve_shots(self) -> float:\n reward = 0.0\n remaining_shots = []\n hit_enemy_ids: set[int] = set()\n for shot in self.shots:\n hit = next(\n (\n enemy\n for enemy in self.enemies\n if id(enemy) not in hit_enemy_ids and enemy[\"position\"] == shot[\"position\"]\n ),\n None,\n )\n if hit is None:\n remaining_shots.append(shot)\n continue\n hit_enemy_ids.add(id(hit))\n reward += 200.0 if hit[\"kind\"] == \"jet\" else 100.0\n self.shots = remaining_shots\n self.enemies = [enemy for enemy in self.enemies if id(enemy) not in hit_enemy_ids]\n return reward\n\n def _resolve_missiles_and_contacts(self) -> float:\n hit_truck_ids: set[int] = set()\n remaining_missiles = []\n player_hit = any(enemy[\"position\"] == self.player for enemy in self.enemies)\n for missile in self.missiles:\n if missile[\"position\"] == self.player:\n player_hit = True\n continue\n truck = next(\n (\n truck\n for truck in self.trucks\n if id(truck) not in hit_truck_ids and truck == missile[\"position\"]\n ),\n None,\n )\n if truck is not None:\n hit_truck_ids.add(id(truck))\n else:\n remaining_missiles.append(missile)\n self.trucks = [truck for truck in self.trucks if id(truck) not in hit_truck_ids]\n self.missiles = remaining_missiles\n if player_hit:\n self.lives -= 1\n self.player = [4, 1]\n self.previous_player = self.player.copy()\n self.shots = []\n self.missiles = []\n if self.lives <= 0:\n self.terminal = True\n return 0.0\n\n def _threat_positions(self) -> list[list[int]]:\n positions = [list(enemy[\"position\"]) for enemy in self.enemies]\n positions.extend(list(missile[\"position\"]) for missile in self.missiles)\n return positions\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n for enemy in self.enemies:\n position = enemy[\"position\"]\n state[*position, 1] = True\n state[*position, 2] = True\n if enemy[\"kind\"] == \"jet\":\n state[position[0], position[1], 5] = True\n for missile in self.missiles:\n state[*missile[\"position\"], 1] = True\n for shot in self.shots:\n state[*shot[\"position\"], 3] = True\n state[*self.previous_player, 4] = True\n for position in self.previous_threats:\n state[*position, 4] = True\n for truck in self.trucks:\n state[*truck, 2] = True\n state[9, : min(10, len(self.trucks)), 5] = True\n state[8, : self.lives, 5] = True\n state[7, : self.wave, 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 292, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/chopper_command.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "snake1", "split": "train", "game": "snake1", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Snake1 as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to queue a turn for the next move. Actions 0–4 release.\nThe snake moves automatically and each dollar scores one point,\nadds a body segment on the next move, and reverses the direction\nof future turns. Hitting the border or the body ends the run.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the head, body, dollars, walls, possible turn\ndestination, and counters. The port projects the original cell grid\nonto 10×10 and uses cell occupancy for collisions. The counters\ninclude the exact head coordinates. Difficulty is fixed. Each action\nadvances up to four frames over 400 actions. Clip scores to [0, 20]\nand divide by 20.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/snake1.py`):\n```python\nfrom collections import deque\n\nimport numpy as np\n\n\nclass Snake1Environment:\n score_cap = 20\n directions = ((1, 0), (0, 1), (-1, 0), (0, -1))\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.head = (8, 8)\n self.direction = self.timer = self.steps = 0\n self.rotation = 1\n self.queued = self.grow = self.held = self.terminal = False\n self.body = deque((x, 8) for x in range(4, 8))\n self.dollars = [(12, 8)]\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n self.queued |= held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for _ in range(4):\n self.timer -= 1\n if self.timer < 0:\n self.timer = 20\n reward += self._move()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _move(self):\n if not self.grow:\n self.body.popleft()\n self.grow = False\n self.body.append(self.head)\n if self.queued:\n self.direction = (self.direction + self.rotation) % 4\n self.queued = False\n dx, dy = self.directions[self.direction]\n self.head = self.head[0] + dx, self.head[1] + dy\n x, y = self.head\n self.terminal = self.head in self.body or not (1 <= x <= 14 and 2 <= y <= 14)\n if self.head not in self.dollars:\n return 0\n self.dollars = [dollar for dollar in self.dollars if dollar != self.head]\n self.grow = True\n self.rotation *= -1\n for _ in range(2):\n for _ in range(99):\n position = tuple(self.random.integers((2, 3), (14, 14)))\n if position != self.head and position not in self.body:\n self.dollars.append(position)\n break\n return 1\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n\n def mark(x, y, channel):\n state[min(9, max(0, (y - 1) * 10 // 15)), min(9, max(0, x * 10 // 16)), channel] = True\n\n mark(*self.head, 0)\n for point in self.body:\n mark(*point, 1)\n for point in self.dollars:\n mark(*point, 2)\n state[[0, 9], :, 3] = True\n state[:, [0, 9], 3] = True\n dx, dy = self.directions[(self.direction + self.rotation) % 4]\n mark(self.head[0] + dx, self.head[1] + dy, 4)\n values = (self.steps, self.direction, self.rotation > 0, self.timer,\n self.queued, self.grow, self.held, *self.head)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 293, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/snake1.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/snake1/main.js"} +{"name": "hopping_p", "split": "train", "game": "hopping_p", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Hopping P as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to reverse direction. Actions 0–4 release the\nbutton. The player hops automatically and turns at the edges.\nEnemy contact ends the run unless the player is powered up.\n\nCollecting a P pickup reverses the other hoppers and temporarily\ndoubles the player's movement updates. Defeating enemies while\npowered awards 1, 2, 4, and so on up to 64 points per enemy.\nThe multiplier resets when power expires.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, enemies moving in each\ndirection, pickups, ground, and gauges. The conversion uses\nrectangular hitboxes and fixed difficulty. Each action advances\nfour frames. The 400-action task clips raw scores to [0, 1000]\nand divides by 1000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/hopping_p.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nPATTERNS = ((1, 1, 0.65), (1, 0.8, 2), (1.6, 0.6, 2), (1, 2, 1.8))\n\n\n@dataclass\nclass Hopper:\n x: float\n y: float\n direction: int\n hop_x: float\n hop_y: float\n gravity: float\n vx: float = 0\n vy: float = 0\n rest: int = 0\n power: bool = False\n\n def turn(self) -> None:\n self.direction *= -1\n self.vx *= -1\n\n def advance(self, fast: bool = False) -> float:\n if self.rest:\n self.rest -= 1\n if self.rest:\n return self.y - 10 * abs(self.rest - 5) / 5\n self.vx = self.hop_x * self.direction\n self.vy = self.hop_y\n for _ in range(2 if fast else 1):\n self.x += self.vx\n self.y += self.vy\n self.vy += self.gravity\n if self.y > 90:\n self.y = 90\n self.rest = 9\n if (self.x < 0 and self.direction < 0) or (self.x > 199 and self.direction > 0):\n self.turn()\n return self.y - 10\n\n\nclass HoppingPEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.player = Hopper(99, 60, 1, 0.5, -1.2, 0.02, vx=0.5)\n self.player_y = 50.0\n self.hoppers: list[Hopper] = []\n self.enemy_timer, self.pickup_timer = 0.0, 200.0\n self.power_ticks = self.steps = 0\n self.multiplier = 1\n self.first_pickup = True\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _spawn(self, power: bool, weak: bool = False) -> None:\n direction = 1 if self.random.random() < 0.5 else -1\n pattern = (0.88, 1.25, 1.25) if power and self.first_pickup else PATTERNS[self.random.integers(4)]\n sx, sy, sg = pattern\n scale = 0.8 if power else 1\n self.hoppers.append(Hopper(-5 if direction == 1 else 205, 89, direction,\n 0.5 * sx * scale * (0.5 if weak else 1),\n -1.2 * sy * scale, 0.02 * sg * scale, power=power))\n\n def _advance(self, tap: bool) -> int:\n weak = self.power_ticks > 60\n self.enemy_timer -= 3 if weak else 1\n if self.enemy_timer < 0:\n self._spawn(False, weak)\n self.enemy_timer = self.random.uniform(100, 150) * math.sqrt(1 + len(self.hoppers))\n self.pickup_timer -= 1\n if self.pickup_timer < 0:\n self._spawn(True)\n self.first_pickup = False\n self.pickup_timer = self.random.uniform(700, 999)\n self.power_ticks = max(0, self.power_ticks - 1)\n if not self.power_ticks:\n self.multiplier = 1\n if tap:\n self.player.turn()\n self.player_y = self.player.advance(self.power_ticks > 0) - (2 if self.power_ticks else 0)\n reward = 0\n remaining = []\n for hopper in self.hoppers:\n y = hopper.advance() - (2 if hopper.power else 0)\n extent = 3 * (1 + bool(self.power_ticks) + hopper.power)\n if abs(self.player.x - hopper.x) >= extent or abs(self.player_y - y) >= extent:\n remaining.append(hopper)\n elif hopper.power:\n self.power_ticks = int(300 * (1 + len(self.hoppers)) ** 0.25)\n for other in self.hoppers:\n other.turn()\n elif self.power_ticks:\n reward += self.multiplier\n self.multiplier = min(64, self.multiplier * 2)\n else:\n self.terminal = True\n remaining.append(hopper)\n self.hoppers = remaining\n if not self.hoppers:\n self.enemy_timer = 0\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, max(0, int(self.player_y) // 10)), min(9, max(0, int(self.player.x) // 20)), 0] = True\n for hopper in self.hoppers:\n if 0 <= hopper.x < 200:\n height = hopper.y - (10 * abs(hopper.rest - 5) / 5 if hopper.rest else 10)\n row, col = min(9, max(0, int(height) // 10)), int(hopper.x) // 20\n state[row, col, 3 if hopper.power else 1 + (hopper.direction < 0)] = True\n state[9, :, 4] = True\n values = (self.steps, min(511, self.power_ticks), self.multiplier, self.player.rest)\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.player.direction > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 294, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/hopping_p.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/hoppingp/main.js"} +{"name": "g_tail", "split": "train", "game": "g_tail", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays G Tail as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nMove left with action 1 and right with action 4. Other actions\nhold position. Meteors home toward the ship and leave gold in\ntheir wakes. Collect every piece of gold in a wake to destroy\nthe meteor, earn a bonus, and raise the multiplier. A meteor\nhit knocks the ship downward. The ship slowly recovers altitude,\nbut falling below the screen ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the ship, meteor heads, gold, trail\nhistory, offscreen meteor cues, and gauges. The conversion\nreplaces pointer movement with directional actions and uses\nrectangular collision checks. Each action advances four frames.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action task clips raw scores to [0, 250] and divides by\n250. Across 100 seeds without sticky actions, idle averaged\n1.27 and random inputs averaged 14.71. A policy using exact gold\npositions averaged 57.62 and reached 302 before clipping.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/g_tail.py`):\n```python\nfrom collections import deque\nfrom dataclasses import dataclass, field\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Meteor:\n x: float\n y: float\n vx: float\n vy: float = 0\n gold: list[int] = field(default_factory=list)\n history: deque = field(default_factory=lambda: deque(maxlen=200))\n\n\nclass GTailEnvironment:\n score_cap = 250\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.last_action = 0\n self.x, self.y = 50, 50.0\n self.spawn_timer = 0.0\n self.multiplier = 1\n self.terminal = False\n self.meteors: list[Meteor] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.steps += 1\n direction = -1 if action == 1 else 1 if action == 4 else 0\n reward = 0\n for _ in range(4):\n reward += self._advance(direction)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, direction: int) -> int:\n self.x = min(99, max(0, self.x + direction * 2))\n self.y += (50 - self.y) * 0.001\n self.spawn_timer -= 1\n if self.spawn_timer < 0:\n self.meteors.append(Meteor(self.random.uniform(10, 90), -5, self.random.uniform(-0.5, 0.5),\n gold=list(range(10, 10 + 5 * int(self.random.integers(3, 8)), 5))))\n self.spawn_timer = self.random.uniform(99, 120) * math.sqrt(len(self.meteors))\n reward = 0\n survivors = []\n for meteor in self.meteors:\n meteor.vx = min(2, max(-2, meteor.vx + (self.x - meteor.x) / 999))\n meteor.vy = min(2, max(-2, meteor.vy + (self.y - meteor.y) / 999))\n meteor.x += meteor.vx\n meteor.y += meteor.vy\n meteor.history.appendleft((meteor.x, meteor.y))\n remaining = []\n for age in meteor.gold:\n if age < len(meteor.history) and self._touches(*meteor.history[age], radius=5):\n reward += self.multiplier\n else:\n remaining.append(age)\n meteor.gold = remaining\n if not meteor.gold:\n reward += self.multiplier\n self.multiplier += 1\n elif self._touches(meteor.x, meteor.y, radius=5.5):\n self.y += 10\n elif -100 <= meteor.x < 200 and -100 <= meteor.y < 200:\n survivors.append(meteor)\n self.meteors = survivors\n self.terminal = self.y > 99\n return reward\n\n def _touches(self, x: float, y: float, radius: float) -> bool:\n return abs(self.x - x) < radius and abs(self.y - y) < radius\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, int(self.y) // 10), self.x // 10, 0] = True\n for meteor in self.meteors:\n if 0 <= meteor.x < 100 and 0 <= meteor.y < 100:\n state[int(meteor.y) // 10, int(meteor.x) // 10, 1] = True\n else:\n row = min(9, max(0, int(meteor.y) // 10))\n col = min(9, max(0, int(meteor.x) // 10))\n state[row, col, 4] = True\n for index, (x, y) in enumerate(meteor.history):\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y) // 10, int(x) // 10, 2 if index in meteor.gold else 3] = True\n for row, value in enumerate((self.steps, self.multiplier, round(self.spawn_timer), self.x)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 295, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/g_tail.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/gtail/main.js"} +{"name": "adventure", "split": "train", "game": "adventure", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Adventure as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThe conversion preserves *Adventure*'s object-and-room planning loop: explore six connected rooms,\ncarry one object at a time, match colored keys to castles, use the sword against three dragons,\nuse the magnet to pull distant objects, place or carry the bridge across a barrier, cope with the\nobject-stealing bat, recover the chalice, and return it through the opened gold castle.\n\nThe six rooms form a compact two-column by three-row world. Crossing a screen edge changes rooms.\nDragons pursue the player in their current room; contact is fatal unless the sword is carried.\nThe bat can visit every room and can relocate the carried object. Action 5 drops the carried item.\n\nACTION MAPPING\n0: wait\n1: move left\n2: move up\n3: move right\n4: move down\n5: drop held item\n\nINPUT CHANNEL TABLE\n0: player\n1: dragons, bat, castle gates, and the room-3 barrier\n2: chalice objective\n3: keys and usable objects\n4: previous dragon and bat positions\n5: room, held-object identity, key colors, and opened castles\n\nSCORING, TERMINATION, AND HORIZON\nThe chalice can be returned once and ends the episode, so `score_cap = 1`. Normalization is\n`min(max(raw_score, 0), 1)`. The 1,000-step horizon bounds unsuccessful episodes.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/adventure.py`):\n```python\nimport numpy as np\n\n\nclass AdventureEnvironment:\n \"\"\"Compact Adventure: rooms, keys, carried objects, dragon, bat, and chalice return.\"\"\"\n\n score_cap = 1.0\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 1_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.room = 0\n self.player = [8, 5]\n self.held = None\n self.items = {\n \"gold_key\": [0, 5, 7], \"black_key\": [2, 7, 7], \"white_key\": [4, 2, 2],\n \"sword\": [1, 7, 2], \"chalice\": [5, 2, 7], \"bridge\": [3, 6, 2],\n \"magnet\": [5, 7, 2],\n }\n self.dragons = [[2, 5, 5], [3, 3, 7], [5, 6, 6]]\n self.previous_dragons = [dragon.copy() for dragon in self.dragons]\n self.bat = [1, 2, 8]\n self.previous_bat = self.bat.copy()\n self.castles = {\n 0: {\"key\": \"gold_key\", \"open\": False},\n 2: {\"key\": \"black_key\", \"open\": False},\n 4: {\"key\": \"white_key\", \"open\": False},\n }\n self.dragon_alive = [True, True, True]\n self.last_action = 0\n self.steps = 0\n self.terminal = False\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n dropped = False\n if action in (1, 2, 3, 4):\n dy, dx = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}[action]\n target = [min(9, max(0, self.player[0] + dy)), min(9, max(0, self.player[1] + dx))]\n if self._can_move(target):\n self.player = target\n self._change_room()\n elif action == 5 and self.held is not None:\n self.items[self.held] = [self.room, *self.player]\n self.held = None\n dropped = True\n\n if not dropped:\n self._collect_item()\n self._use_magnet()\n self.previous_dragons = [dragon.copy() for dragon in self.dragons]\n self.previous_bat = self.bat.copy()\n self._move_dragons()\n self._move_bat()\n castle = self.castles.get(self.room)\n if castle and self.player[0] <= 1 and self.held == castle[\"key\"]:\n castle[\"open\"] = True\n if self.room == 0 and self.player[0] <= 1 and self.held == \"chalice\" and self.castles[0][\"open\"]:\n self.terminal = True\n return 1.0, True\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return 0.0, self.terminal\n\n def _can_move(self, target: list[int]) -> bool:\n if self.room != 3 or {self.player[0], target[0]} != {4, 5}:\n return True\n bridge = self.items.get(\"bridge\")\n bridge_column = bridge[2] if bridge is not None and bridge[0] == 3 else None\n return self.held == \"bridge\" or bridge_column == target[1]\n\n def _change_room(self) -> None:\n if self.player[1] == 0 and self.room % 2 == 1:\n self.room -= 1\n self.player[1] = 9\n elif self.player[1] == 9 and self.room % 2 == 0:\n self.room += 1\n self.player[1] = 0\n elif self.player[0] == 0 and self.room >= 2:\n self.room -= 2\n self.player[0] = 9\n elif self.player[0] == 9 and self.room < 4:\n self.room += 2\n self.player[0] = 0\n\n def _collect_item(self) -> None:\n for name, location in list(self.items.items()):\n if location == [self.room, *self.player] and self.held is None:\n self.held = name\n del self.items[name]\n castle = self.castles.get(self.room)\n if castle and self.held == castle[\"key\"] and self.player[0] <= 1:\n castle[\"open\"] = True\n\n def _move_dragons(self) -> None:\n for index, dragon in enumerate(self.dragons):\n if not self.dragon_alive[index] or dragon[0] != self.room:\n continue\n _, row, column = dragon\n row += int(np.sign(self.player[0] - row))\n column += int(np.sign(self.player[1] - column))\n dragon[1:] = [row, column]\n if [row, column] == self.player:\n if self.held == \"sword\":\n self.dragon_alive[index] = False\n else:\n self.terminal = True\n\n def _use_magnet(self) -> None:\n if self.held != \"magnet\":\n return\n candidates = [(name, location) for name, location in self.items.items() if location[0] == self.room]\n if not candidates:\n return\n _, location = min(candidates, key=lambda item: abs(item[1][1] - self.player[0]) + abs(item[1][2] - self.player[1]))\n location[1] += int(np.sign(self.player[0] - location[1]))\n location[2] += int(np.sign(self.player[1] - location[2]))\n\n def _move_bat(self) -> None:\n if self.random.rand() >= 0.15:\n return\n self.bat[0] = int(self.random.randint(6))\n self.bat[1] = int(self.random.randint(10))\n self.bat[2] = int(self.random.randint(10))\n if self.bat == [self.room, *self.player] and self.held is not None:\n name = self.held\n self.held = None\n self.items[name] = self.bat.copy()\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[*self.player, 0] = True\n for name, (room, row, column) in self.items.items():\n if room == self.room:\n if name == \"chalice\":\n state[row, column, 2] = True\n else:\n state[row, column, 3] = True\n marker = {\n \"gold_key\": 0,\n \"black_key\": 1,\n \"white_key\": 2,\n \"sword\": 3,\n \"bridge\": 4,\n \"magnet\": 5,\n }[name]\n state[row, marker, 5] = True\n for alive, dragon in zip(self.dragon_alive, self.dragons, strict=True):\n if alive and dragon[0] == self.room:\n state[dragon[1], dragon[2], 1] = True\n for previous, alive in zip(self.previous_dragons, self.dragon_alive, strict=True):\n if alive and previous[0] == self.room:\n state[previous[1], previous[2], 4] = True\n if self.bat[0] == self.room:\n state[self.bat[1], self.bat[2], 1] = True\n if self.previous_bat[0] == self.room:\n state[self.previous_bat[1], self.previous_bat[2], 4] = True\n if self.room == 3:\n state[4, :, 1] = True\n bridge = self.items.get(\"bridge\")\n if self.held == \"bridge\":\n state[4, self.player[1], 1] = False\n elif bridge is not None and bridge[0] == 3:\n state[4, bridge[2], 1] = False\n if self.room in self.castles:\n state[0, 4:7, 1] = not self.castles[self.room][\"open\"]\n if self.held is not None:\n held_marker = {\n \"gold_key\": 0,\n \"black_key\": 1,\n \"white_key\": 2,\n \"sword\": 3,\n \"chalice\": 4,\n \"bridge\": 5,\n \"magnet\": 6,\n }[self.held]\n state[8, held_marker, 5] = True\n state[9, self.room, 5] = True\n for castle_room, castle in self.castles.items():\n if castle[\"open\"]:\n state[7, castle_room, 5] = True\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 296, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/adventure.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "cast_n", "split": "train", "game": "cast_n", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Cast N as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to charge the cast, release with any other action to cast, then tap\n5 again to reel in. Holding at full power auto-casts. Fish touching the line\nduring retrieval are carried home and scored once. Blue fish pay the current\ncatch index and lower the water. Red fish cost one point, raise the water, and\nadvance the catch index. Rising water ends the run when it floods the angler,\nwith the flood check deferred during retrieval.\n\nINPUT CHANNEL TABLE\nChannels 0 through 5 show the lure, red fish, blue fish, line, water surface,\nand gauges. Gauges encode control mode, charge, water, clock, catch count and\norder, and previous button state. The 10×10 version uses three cast ranges,\na falling lure with a straight line, and seeded three-fish schools moving left.\nIt omits continuous line tension, terrain rebounds, and individual fish jitter.\nRed schools are periodic and start deeper.\n\nSCORING, TERMINATION, AND HORIZON\nAt most 120 fish can spawn over 320 steps. Even if every fish were blue and the\ncatch index never reset, the score could not exceed 7,260. Each landed fish is\nremoved, and the catch index resets with every cast. The normalized score is the\nraw sum clipped to [0, 7260] and divided by 7260.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/cast_n.py`):\n```python\nimport numpy as np\n\n\nHORIZON = 320\nSCHOOL_INTERVAL = 8\nMAX_FISH = (HORIZON // SCHOOL_INTERVAL) * 3\nANCHOR = (3, 0)\n\n\nclass CastNEnvironment:\n score_cap = MAX_FISH * (MAX_FISH + 1) // 2\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.mode = 0\n self.power = 0\n self.water = 50\n self.steps = 0\n self.last_action = 0\n self.lure = ANCHOR\n self.fish: set[tuple[int, int, bool]] = set()\n self.caught: list[bool] = []\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def _line(self) -> set[tuple[int, int]]:\n row, column = self.lure\n if column == 0:\n return {ANCHOR}\n return {(round(ANCHOR[0] + (row - ANCHOR[0]) * x / column), x)\n for x in range(column + 1)}\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() < self.sticky_action_prob:\n action = self.last_action\n pressed = action == 5 and self.last_action != 5\n self.last_action = action\n self.steps += 1\n if self.mode == 0 and pressed:\n self.mode, self.power = 1, 1\n elif self.mode == 1:\n if action == 5 and self.power < 3:\n self.power += 1\n else:\n self.lure = (2, self.power * 3)\n self.mode = 2\n elif self.mode == 2 and pressed:\n self.mode = 3\n if self.mode == 2:\n row, column = self.lure\n self.lure = (min(9, row + 1), column)\n\n if self.steps % 2 == 0:\n surface = min(8, self.water // 10 + 1)\n self.fish = {(max(surface, row), column - 1, red)\n for row, column, red in self.fish if column > 0}\n if self.steps % SCHOOL_INTERVAL == 0:\n red = self.steps % (SCHOOL_INTERVAL * 4) == 0\n depth = min(7, self.water // 10 + 1 + int(red))\n row = int(self.random.integers(depth, 8))\n self.fish.update((row + offset, 9, red) for offset in range(3))\n\n reward = 0\n if self.mode == 3:\n line = self._line()\n hooked = {fish for fish in self.fish if fish[:2] in line}\n self.fish.difference_update(hooked)\n self.caught.extend(red for _, _, red in sorted(hooked))\n row, column = self.lure\n if column <= 1:\n for index, red in enumerate(self.caught, 1):\n reward += -1 if red else index\n self.water = max(0, min(50, self.water + (-5 if red else 1)))\n self.caught.clear()\n self.lure, self.mode = ANCHOR, 0\n else:\n self.lure = (row + int(np.sign(ANCHOR[0] - row)), column - 1)\n if self.steps % 2 == 0:\n self.water = max(0, self.water - 1)\n self.terminal = self.steps >= self.horizon or (self.mode != 3 and self.water < 26)\n return float(reward), self.terminal\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[self.lure[0], self.lure[1], 0] = True\n for row, column, red in self.fish:\n state[row, column, 1 if red else 2] = True\n for row, column in self._line():\n state[row, column, 3] = True\n state[self.water // 10, :, 4] = True\n values = (self.mode, self.power, self.water, self.steps,\n len(self.caught), int(self.last_action == 5))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n for index, red in enumerate(self.caught):\n state[6 + index // 10, index % 10, 5] = red\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 297, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/cast_n.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameCastN.c"} +{"name": "number_ball", "split": "train", "game": "number_ball", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Number Ball as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to raise the shot angle. Release with actions\n0–4 to fire. Match a ball's number to the floor segment it\nsettles on to remove that segment and score. Matches double\nthe multiplier up to 16. Firing halves it and briefly speeds\nup the scroll. The run ends when the leading floor retreats\npast the launch area.\n\nINPUT CHANNEL TABLE\nAt fixed difficulty the numbered balls and floors use values\n1 and 2. The six 10×10 channels show balls by value, two\nfloor-value masks, the ready ball, and gauges. An unnumbered\nfloor appears in both floor masks. Each action advances four\nframes. The 400-action task clips scores to [0, 150] and\ndivides by 150.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/number_ball.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Floor:\n x: float\n width: float\n value: int = 0\n\n\n@dataclass\nclass Ball:\n value: int\n x: float = 10\n y: float = 47\n vx: float = 0\n vy: float = 0\n mode: str = \"ready\"\n\n\nclass NumberBallEnvironment:\n score_cap = 150\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.floors = [Floor(0, 200)]\n self.balls: list[Ball] = []\n self.frames = self.steps = 0\n self.boost = self.launch_penalty = 0.0\n self.angle = -0.1\n self.multiplier = 1\n self.add_ball = True\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n release = self.pressed and not pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(release and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, release):\n lead = self.floors[0]\n scroll = 0.04 + self.boost + max(0, lead.x + lead.width - 100) * 0.1\n self.boost *= 0.9\n self.launch_penalty = min(9, max(0, self.launch_penalty - 0.01))\n reward = self._move_floors(scroll)\n if self.terminal:\n return reward\n if self.frames > 30 and self.add_ball:\n values = {floor.value for floor in self.floors}\n for _ in range(9):\n value = int(self.random.integers(1, 3))\n if value in values:\n break\n self.balls.append(Ball(value))\n self.add_ball = False\n self.angle = -0.1\n remaining = []\n for ball in self.balls:\n self._move_ball(ball, release, scroll)\n if -20 <= ball.x <= 220 and -50 <= ball.y <= 63:\n remaining.append(ball)\n elif ball.mode == \"flying\":\n self.add_ball = True\n self.balls = remaining\n self.frames += 1\n return reward\n\n def _move_floors(self, scroll):\n reward = 0\n right = 0\n remaining = []\n for index, floor in enumerate(self.floors):\n floor.x -= scroll\n right = floor.x + floor.width\n if floor.value and any(ball.mode == \"floor\" and ball.value == floor.value\n and floor.x - 3 < ball.x < right + 3 for ball in self.balls):\n reward += floor.value * self.multiplier\n self.multiplier = min(16, self.multiplier * 2)\n continue\n if index + 1 < len(self.floors):\n gap = self.floors[index + 1].x - right\n floor.x += gap * 0.1 if gap > -2 else gap\n remaining.append(floor)\n self.floors = remaining\n self.terminal = not remaining or remaining[0].x + remaining[0].width < 30\n if right < 200:\n self.floors.append(Floor(200, self.random.uniform(20, 50), int(self.random.integers(1, 3))))\n return reward\n\n def _move_ball(self, ball, release, scroll):\n if ball.mode == \"ready\":\n self.angle -= 0.01 * self.pressed\n if release or self.angle < -math.pi * 0.47:\n self.multiplier = max(1, self.multiplier // 2)\n self.boost = self.launch_penalty\n self.launch_penalty += 1\n ball.vx, ball.vy = 5 * math.cos(self.angle), 5 * math.sin(self.angle)\n ball.mode = \"flying\"\n elif ball.mode == \"flying\":\n ball.vx *= 0.99\n ball.vy = (ball.vy + 0.1) * 0.99\n ball.x += ball.vx\n ball.y += ball.vy\n if ball.y > 47:\n ball.y = 47\n ball.vx *= 0.5\n ball.vy *= -0.5\n if abs(ball.vy) < 0.5:\n ball.mode = \"floor\"\n self.add_ball = True\n elif ball.mode == \"floor\":\n ball.vx *= 0.9\n ball.x += ball.vx\n ball.vy = 0\n if ball.x < 30:\n ball.mode = \"falling\"\n else:\n ball.vy += 0.1\n ball.y += ball.vy\n if ball.mode in (\"flying\", \"floor\"):\n ball.x -= scroll\n for other in self.balls:\n dx, dy = ball.x - other.x, ball.y - other.y\n distance = math.hypot(dx, dy)\n if other is not ball and distance < 6:\n angle = math.atan2(dy, dx)\n ux, uy = math.cos(angle), math.sin(angle)\n push = math.hypot(other.vx, other.vy) * 0.7\n ball.vx += ux * push\n ball.vy += uy * push\n push = math.hypot(ball.vx, ball.vy) * 0.7\n other.vx -= ux * push\n other.vy -= uy * push\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for ball in self.balls:\n if 0 <= ball.x < 200 and 0 <= ball.y < 60:\n row, col = int(ball.y // 6), int(ball.x // 20)\n state[row, col, ball.value - 1] = True\n state[row, col, 4] |= ball.mode == \"ready\"\n for floor in self.floors:\n left, right = max(0, int(floor.x // 20)), min(9, int((floor.x + floor.width) // 20))\n if left <= right:\n state[9, left:right + 1, 2:4] |= [floor.value != 2, floor.value != 1]\n for row, value in enumerate((self.steps, self.multiplier, round(-self.angle * 100),\n round(self.boost * 40))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 298, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/number_ball.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/numberball/main.js"} +{"name": "blast_buoy", "split": "train", "game": "blast_buoy", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Blast Buoy as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to sink. Release with actions 0–4 to float. Ram a\nsubmarine to detonate it and clear nearby submarines and bullets.\nA blast scores five points plus eight per additional submarine,\nmultiplied by the current combo. Blasts briefly freeze play, knock\nthe buoy away, and grant temporary protection. An unshielded\nbullet hit ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the buoy, rightward submarines, leftward\nsubmarines, bullets, shield status, and gauges. Each action advances\nfour frames at fixed difficulty. The conversion uses continuous\nprotection throughout the shield timer in place of the source's\nflicker-based collision windows.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends on death or at 400 actions. Clip the raw score to\n[0, 500] and divide by the fixed cap of 500.\n\nAcross 100 seeds without sticky actions, always released averaged\n4.69 raw points and always held averaged 6.04. Random inputs averaged\n38.09 and reached 175. A heuristic that tracked exact submarine\npositions averaged 42.96 and reached 239.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/blast_buoy.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\nHORIZON = 400\nFRAMES_PER_STEP = 4\nBLAST_RADIUS = 25\n\n\n@dataclass\nclass Submarine:\n x: float\n y: float\n vx: float\n fire_timer: int\n\n\n@dataclass\nclass Bullet:\n x: float\n y: float\n vx: float\n\n\nclass BlastBuoyEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.spawn_timer = self.combo_timer = self.shield = self.freeze = 0\n self.combo = 1\n self.pressed = self.terminal = False\n self.x, self.y = 30.0, 40.0\n self.vx = self.vy = 0.0\n self.submarines: list[Submarine] = []\n self.bullets: list[Bullet] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(FRAMES_PER_STEP):\n reward += self._advance_frame()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self) -> int:\n if self.freeze:\n self.freeze -= 1\n return 0\n self.vy = min(1.1, max(-1.1, self.vy + (0.06 if self.pressed else -0.05)))\n self.vx *= 0.95\n self.x = min(95, max(5, self.x + self.vx))\n self.y = min(87, max(13, self.y + self.vy))\n if self.y in (13, 87):\n self.vy = 0\n\n self.shield = max(0, self.shield - 1)\n if self.combo_timer:\n self.combo_timer -= 1\n else:\n self.combo = 1\n\n if not self.spawn_timer:\n direction = int(self.random.choice((-1, 1)))\n self.submarines.append(Submarine(\n -8 if direction > 0 else 108,\n self.random.uniform(13, 87),\n direction * self.random.uniform(0.2, 0.45),\n int(self.random.integers(60, 121)),\n ))\n self.spawn_timer = int(self.random.integers(50, 91))\n self.spawn_timer -= 1\n\n contact = None\n for sub in self.submarines:\n sub.x += sub.vx\n sub.fire_timer -= 1\n if sub.fire_timer < 0 and 0 < sub.x < 100 and abs(sub.y - self.y) < 10:\n if math.hypot(sub.x - self.x, sub.y - self.y) > 36:\n direction = 1 if self.x > sub.x else -1\n self.bullets.append(Bullet(sub.x + direction * 6, sub.y, direction * 0.95))\n sub.fire_timer = int(self.random.integers(90, 151))\n if contact is None and not self.shield and abs(sub.x - self.x) < 7.5 and abs(sub.y - self.y) < 5:\n contact = sub\n\n self.submarines = [sub for sub in self.submarines if -12 <= sub.x <= 112]\n reward = self._blast(contact) if contact is not None else 0\n\n survivors = []\n for bullet in self.bullets:\n bullet.x += bullet.vx\n if abs(bullet.x - self.x) < 5.5 and abs(bullet.y - self.y) < 4:\n self.terminal |= not self.shield\n elif -5 <= bullet.x <= 105:\n survivors.append(bullet)\n self.bullets = survivors\n return reward\n\n def _blast(self, center: Submarine) -> int:\n self.submarines.remove(center)\n remaining = [\n sub for sub in self.submarines\n if math.hypot(sub.x - center.x, sub.y - center.y) >= BLAST_RADIUS\n ]\n extras = len(self.submarines) - len(remaining)\n self.submarines = remaining\n self.bullets = [\n bullet for bullet in self.bullets\n if math.hypot(bullet.x - center.x, bullet.y - center.y) >= BLAST_RADIUS\n ]\n reward = (5 + 8 * extras) * self.combo\n self.combo += 1\n self.combo_timer = 120\n angle = math.atan2(self.y - center.y, self.x - center.x)\n self.vx, self.vy = 2.2 * math.cos(angle), 2.2 * math.sin(angle)\n self.shield = 40\n self.freeze = min(8, 3 + extras)\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row, column = int(self.y) // 10, int(self.x) // 10\n state[row, column, 0] = True\n state[row, column, 4] = self.shield > 0\n for sub in self.submarines:\n if 0 <= sub.x < 100:\n state[int(sub.y) // 10, int(sub.x) // 10, 1 if sub.vx > 0 else 2] = True\n for bullet in self.bullets:\n if 0 <= bullet.x < 100:\n state[int(bullet.y) // 10, int(bullet.x) // 10, 3] = True\n for row, value in enumerate((self.steps, self.combo, self.combo_timer, self.shield, self.freeze)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.vy > 0\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 299, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/blast_buoy.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBlastBuoy.c"} +{"name": "thrust_lr", "split": "train", "game": "thrust_lr", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Thrust Lr as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nUse action 1 to thrust left and action 3 to thrust right. Other\nactions coast. Exhaust pushes diamonds in the opposite direction\nwhen they overlap the ship's altitude. Push diamonds off either side\nto score their size rounded down. Touching a diamond outline ends\nthe episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the ship, small diamonds, large diamonds,\ndiamonds at thrust height, exhaust direction, and counters. The\nport replaces pointer thrust with fixed-strength directional actions,\nfixes difficulty, and samples the ship against diamond outlines.\nIt floors thrust clearance at half a unit to keep near-contact\nforces finite. Each action advances up to four frames over 400\nactions. Clip scores to [0, 500] and divide by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/thrust_lr.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import floor\n\nimport numpy as np\n\n\n@dataclass\nclass Diamond:\n x: float\n y: float\n size: float\n vx: float = 0.\n\n\nclass ThrustLrEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.vx, self.distance = 50., 0., 0.\n self.action = self.steps = 0\n self.terminal = False\n self.diamonds = []\n for y in (60, 40, 20):\n self._spawn(y)\n\n def _spawn(self, y=0):\n small = self.random.random() < 0.3\n size = self.random.uniform(7, 12) if small else self.random.uniform(20, 30)\n x = self.random.uniform(10, 90) if small else (\n 50 + self.random.choice((-1, 1)) * self.random.uniform(40, 60)\n )\n self.diamonds.append(Diamond(x, y - size, size))\n return size\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n thrust = 50 * ((self.action == 3) - (self.action == 1))\n self.distance -= 0.2\n if self.distance < 0:\n size = self._spawn()\n self.distance = 10 + (size - 10) * self.random.random()\n reward = 0\n remaining = []\n for diamond in self.diamonds:\n diamond.y += 0.2\n dy = abs(diamond.y - 85)\n if dy < diamond.size:\n dx = diamond.x - self.x\n if dx * thrust < 0:\n clearance = abs(dx) - (diamond.size - dy)\n diamond.vx -= thrust * 0.2 / (max(0.5, clearance) * diamond.size)\n diamond.vx *= 0.98\n diamond.x += diamond.vx\n if diamond.x < -diamond.size or diamond.x > 99 + diamond.size:\n reward += floor(diamond.size)\n elif diamond.y - 2 * diamond.size <= 99:\n remaining.append(diamond)\n self.diamonds = remaining\n self.vx += thrust * 0.001\n self.x = min(96, max(4, self.x + self.vx))\n if (self.x < 5 and self.vx < 0) or (self.x > 95 and self.vx > 0):\n self.vx *= -0.7\n self.vx *= 0.95\n self.terminal = any(\n abs(abs(self.x + side * (1 + t) - diamond.x) + abs(83 + 4 * t - diamond.y)\n - diamond.size) < 2.5\n for diamond in self.diamonds for side in (-1, 1) for t in (0, 0.5, 1)\n )\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[8, int(self.x // 10), 0] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for diamond in self.diamonds:\n mask = abs(abs(cols - diamond.x) + abs(rows - diamond.y) - diamond.size) < 10\n state[:, :, 1 if diamond.size < 15 else 2] |= mask\n if abs(diamond.y - 85) < diamond.size:\n state[:, :, 3] |= mask\n if self.action in (1, 3):\n offset = 10 if self.action == 1 else -10\n state[8, int(np.clip((self.x + offset) // 10, 0, 9)), 4] = True\n values = (self.steps, self.action, round((self.vx + 2) * 100), round(self.distance * 10))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 300, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/thrust_lr.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/thrustlr/main.js"} +{"name": "lie_down", "split": "train", "game": "lie_down", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Lie Down as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to duck under rocks and brace against holes.\nActions 0–4 let the player stand and accelerate. Contact\nwith a rising enemy scores the current multiplier and raises\nit. Ducking lowers the multiplier by one on each new press.\n\nAn active rock can hit a standing player. A deep hole\ncan cause a fatal fall if the player crosses it upright.\nThe conversion uses proximity hitboxes and fixed difficulty.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, holes, enemies, rocks,\nground, and gauges. Each action advances four frames for\nup to 400 actions. Raw scores are clipped to [0, 200] and\ndivided by 200.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/lie_down.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Emitter:\n x: float\n speed: float\n height: float = 0\n\n\n@dataclass\nclass Rock:\n x: float\n target_speed: float\n speed: float = 0\n\n\nclass LieDownEnvironment:\n score_cap = 200\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x, self.speed = 20.0, 0.0\n self.fall = self.steps = self.hole_timer = 0\n self.enemy_timer = 60\n self.multiplier = 1\n self.pressed = self.terminal = False\n self.holes: list[Emitter] = []\n self.enemies: list[Emitter] = []\n self.rocks: list[Rock] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed and not self.fall:\n self.multiplier = max(1, self.multiplier - 1)\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self) -> int:\n scroll = 0 if self.fall else 0.1 + max(0, self.x - 30) * 0.1\n self.enemy_timer -= 1\n if self.enemy_timer < 0:\n speed = 0.1 + self.random.uniform(0, 2) * self.random.uniform(0, 2) * 0.1\n self.enemies.append(Emitter(self.random.uniform(100, 250), speed))\n self.enemy_timer = 50\n for rock in self.rocks:\n rock.x -= scroll + rock.speed\n rock.speed += (rock.target_speed - rock.speed) * 0.1\n self.rocks = [rock for rock in self.rocks if -3 <= rock.x <= 203]\n self.hole_timer -= 1\n if self.hole_timer < 0:\n self.holes.append(Emitter(self.random.uniform(0, 300), self.random.uniform(0.1, 0.2)))\n self.hole_timer = 100\n for hole in self.holes:\n hole.x -= scroll\n hole.height += hole.speed\n if hole.height > 11 and hole.speed > 0:\n hole.speed *= -1\n self.holes = [hole for hole in self.holes if hole.height >= 0]\n if self.fall:\n self.fall += 1\n self.terminal = self.fall > 8\n else:\n self.speed = (self.speed + (0 if self.pressed else 0.02)) * 0.99\n self.x += self.speed - scroll\n self.terminal = self.x < 0 or (not self.pressed and any(\n abs(rock.x - self.x) < 4 and rock.speed > rock.target_speed * 0.5 for rock in self.rocks\n ))\n if any(hole.height > 9 and abs(hole.x + 4.5 - self.x) < 2 for hole in self.holes):\n self.speed = 0\n if self.pressed:\n self.x -= 5\n else:\n self.fall = 1\n reward = 0\n remaining = []\n for enemy in self.enemies:\n enemy.x -= scroll\n enemy.height += math.sqrt(enemy.speed * 10) / 10 if enemy.speed > 0 else enemy.speed\n if enemy.height > 15 and enemy.speed > 0:\n self.rocks.append(Rock(enemy.x, enemy.speed * 3))\n enemy.speed *= -1\n y = 37 + (10 - min(10, max(0, enemy.height))) ** 2 / 10\n player_y = 37 + self.fall if self.fall else (39 if self.pressed else 37)\n if abs(enemy.x - self.x) < 5 and abs(y - player_y) < (4 if self.pressed else 6):\n reward += self.multiplier\n self.multiplier += 1\n elif enemy.height >= 0:\n remaining.append(enemy)\n self.enemies = remaining\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, (37 + self.fall + 2 * self.pressed) // 5),\n min(9, max(0, int(self.x // 20))), 0] = True\n for channel, objects in ((1, self.holes), (2, self.enemies), (3, self.rocks)):\n for obj in objects:\n if 0 <= obj.x < 200:\n state[(8, 7, 6)[channel - 1], int(obj.x // 20), channel] = True\n state[8:, :, 4] = True\n for row, value in enumerate((self.steps, self.multiplier, self.fall, round(self.speed * 100))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 301, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/lie_down.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/liedown/main.js"} +{"name": "s_shake", "split": "train", "game": "s_shake", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays S Shake as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to shake the rolling terrain. Actions 0–4 release.\nThe shake amplifies the hills and launches enemies where the ground\nrises beneath them. Enemies thrown off the top score the current\nmultiplier and raise it by one. Each shake resets the multiplier.\nAn enemy reaching the left edge ends the episode.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show terrain, grounded enemies, rising\nenemies, falling enemies, the left boundary, and counters. The\nport uses fixed difficulty and approximates terrain contact by\ninterpolating its height at each enemy's center. Each action\nadvances up to four frames over a 400-action horizon. Clip the\nepisode score to [0, 100] and divide by 100.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/s_shake.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Ground:\n x: float\n angle: float\n height: float = 9\n\n\n@dataclass\nclass Enemy:\n x: float = 203\n y: float = 50\n vy: float = 0\n grounded: bool = True\n\n\nclass SShakeEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.ground = [Ground(i * 10, (i + 1) * pi / 5) for i in range(22)]\n self.terrain_x = np.arange(22) * 10\n self.terrain_y = np.full(22, 99.0)\n self.ratio = 1.0\n self.steps = self.timer = 0\n self.multiplier = 1\n self.held = self.terminal = False\n self.enemies = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n if tap:\n self.ratio = 3\n self.multiplier = 1\n self.ratio += (1 - self.ratio) * 0.05\n for index, ground in enumerate(self.ground):\n ground.x += 0.3\n if ground.x > 210:\n ground.x -= 220\n neighbor = self.ground[(index + 1) % 22]\n ground.angle = neighbor.angle - pi / 5 * self.random.uniform(0.5, 1.5)\n ground.height = 0.95 * (neighbor.height + self.random.uniform(-1, 1)) + 0.45\n ordered = sorted(self.ground, key=lambda ground: ground.x)\n self.terrain_x = np.array([ground.x for ground in ordered])\n heights = np.array([sin(ground.angle) * ground.height for ground in ordered])\n self.terrain_y = 99 + (heights - max(0, heights.max())) * self.ratio\n self.timer -= 1\n if self.timer < 0:\n self.enemies.append(Enemy())\n self.timer = self.random.uniform(0, 120)\n reward = 0\n remaining = []\n for enemy in self.enemies:\n enemy.x -= 0.3\n enemy.y += enemy.vy\n surface = float(np.interp(enemy.x, self.terrain_x, self.terrain_y))\n if enemy.grounded:\n if tap and enemy.y > surface - 2.5:\n launch = max(1, int(enemy.y - surface + 2.5))\n enemy.vy = -0.3 * launch\n enemy.grounded = False\n enemy.y = surface - 3.5\n else:\n enemy.vy += 0.03\n if abs(enemy.y - surface) <= 3.5 or (enemy.vy > 0 and surface < enemy.y <= surface + 30):\n enemy.y, enemy.vy, enemy.grounded = surface - 3.5, 0, True\n if enemy.y < -3:\n reward += self.multiplier\n self.multiplier += 1\n else:\n self.terminal |= enemy.x < 3\n if enemy.y <= 103:\n remaining.append(enemy)\n self.enemies = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n columns = np.arange(10)\n surfaces = np.interp(columns * 20 + 10, self.terrain_x, self.terrain_y)\n state[(surfaces // 10).astype(int), columns, 0] = True\n for enemy in self.enemies:\n if 0 <= enemy.x < 200 and 0 <= enemy.y < 100:\n row, col = int(enemy.y // 10), int(enemy.x // 20)\n channel = 1 if enemy.grounded else 2 if enemy.vy < 0 else 3\n state[row, col, channel] = True\n state[:, 0, 4] = True\n for row, value in enumerate((self.steps, self.multiplier, self.held, round(self.ratio * 100))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 302, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/s_shake.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/sshake/main.js"} +{"name": "stormveil", "split": "train", "game": "stormveil", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Stormveil as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to cycle through the three lanes. Actions 0–4 release.\nObstacles and coins fall in different lanes. Coins score the current\nmultiplier and increase it up to 16. Missing a coin resets it to one.\nHitting an obstacle ends the episode.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the player, obstacles, coins, lane\nguides, selected lane, and counters. The port uses fixed difficulty\nand bounding rectangles for the moving sprites. Each action advances\nup to four frames over 400 actions. Clip scores to [0, 500] and\ndivide by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/stormveil.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import cos, pi, sin\n\nimport numpy as np\n\n\nLANES = (25, 50, 75)\n\n\n@dataclass\nclass Falling:\n lane: int\n y: float = -5\n phase: float = 0\n\n\nclass StormveilEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x = 50.\n self.lane = 1\n self.squash = 1.\n self.steps = self.frame = self.timer = 0\n self.multiplier = 1\n self.held = self.terminal = False\n self.obstacles, self.coins = [], []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n if held and not self.held:\n self.lane = (self.lane + 1) % 3\n self.squash = 0.6\n self.held = held\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n vx = (LANES[self.lane] - self.x) * 0.5\n self.x += vx\n self.squash += (1 - self.squash) * 0.15\n breathe = 1 + sin(self.frame * 0.1) * 0.05\n tilt = vx * 0.08\n width, height = 3 * self.squash * breathe, 3 * (2 - self.squash) * breathe\n half_x = abs(cos(tilt)) * height + abs(sin(tilt)) * width\n half_y = abs(sin(tilt)) * height + abs(cos(tilt)) * width\n self.timer -= 1\n if self.timer < 0:\n blocked = int(self.random.integers(3))\n self.obstacles.append(Falling(blocked, phase=self.random.uniform(0, 2 * pi)))\n coin_lane = int(self.random.choice([lane for lane in range(3) if lane != blocked]))\n self.coins.append(Falling(coin_lane))\n self.timer += 40\n for obstacle in self.obstacles:\n obstacle.y += 1.5\n obstacle.phase += 0.2\n pulse = 1 + sin(obstacle.phase) * 0.15\n self.terminal |= self._touches(obstacle, half_x + 3 * pulse, half_y + 3 * (2 - pulse))\n self.obstacles = [obstacle for obstacle in self.obstacles if obstacle.y <= 105]\n reward = 0\n remaining = []\n for coin in self.coins:\n coin.y += 1.5\n coin.phase += 0.12\n if self._touches(coin, half_x + 1 + 2 * abs(cos(coin.phase)), half_y + 3):\n reward += self.multiplier\n self.multiplier = min(16, self.multiplier + 1)\n elif coin.y > 105:\n self.multiplier = 1\n else:\n remaining.append(coin)\n self.coins = remaining\n self.frame += 1\n return reward\n\n def _touches(self, item, half_x, half_y):\n return abs(LANES[item.lane] - self.x) < half_x and abs(item.y - 85) < half_y\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[8, int(self.x // 10), 0] = True\n for channel, items in ((1, self.obstacles), (2, self.coins)):\n for item in items:\n if 0 <= item.y < 100:\n state[int(item.y // 10), LANES[item.lane] // 10, channel] = True\n state[:, [x // 10 for x in LANES], 3] = True\n state[8, LANES[self.lane] // 10, 4] = True\n values = (self.steps, self.multiplier, self.held, self.timer, round(self.squash * 100))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 303, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/stormveil.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameStormveil.c"} +{"name": "lift_up", "split": "train", "game": "lift_up", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Lift Up as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to speed up the scrolling tunnel and reduce\nhorizontal drift. Actions 0–4 release. Arrows reverse your\nhorizontal direction. Bonuses score the current multiplier,\nraise it, and pull the player down away from the top edge.\nMissed bonuses lower the multiplier. Hitting the tunnel walls\nor reaching the top ends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, walls, arrows, bonuses,\nmovement direction, and gauges. The conversion approximates\nsprite collisions with rectangular bounds and uses fixed\ndifficulty. Each action advances four frames. The 400-action\ntask clips raw scores to [0, 150] and divides by 150.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/lift_up.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Wall:\n x: float\n y: float\n width: float\n\n\n@dataclass\nclass Item:\n x: float\n y: float\n bonus: bool\n\n\nclass LiftUpEnvironment:\n score_cap = 150\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.walls = [Wall(50, i * 6 - 3, 60) for i in range(19)]\n self.top_wall = self.walls[0]\n self.wall_vx = self.wall_vw = 0.0\n self.x, self.y, self.target_y = 40.0, 90.0, 90.0\n self.direction = self.item_side = self.multiplier = 1\n self.ratio = self.item_distance = self.bonus_x = 0.0\n self.bonus_count = self.steps = 0\n self.items: list[Item] = []\n self.pressed = self.terminal = False\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.random() >= self.sticky_action_prob:\n self.pressed = action == 5\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self) -> int:\n self.ratio += (self.pressed - self.ratio) * 0.1\n scroll = (1 + self.ratio * 3) * 0.2\n for index, wall in enumerate(self.walls):\n wall.y += scroll\n if wall.y > 110:\n self._recycle_wall(index, wall)\n self.item_distance -= scroll\n if self.item_distance < 0:\n self._spawn_item()\n self.x += self.direction * 0.05 * (4 - self.ratio * 3)\n self.target_y -= 0.04\n self.y += (self.target_y - self.y) * 0.2\n self.terminal = self.y < 0 or self._hits_wall(self.x, self.y)\n reward = 0\n remaining = []\n for item in self.items:\n item.y += scroll\n if self._hits_wall(item.x, item.y):\n item.x += -1 if item.x > self.top_wall.x else 1\n if abs(item.x - self.x) < 5 and abs(item.y - self.y) < 5:\n if item.bonus:\n reward += self.multiplier\n self.multiplier = min(99, self.multiplier + 1)\n self.target_y += (99 - self.target_y) * 0.1\n else:\n self.direction *= -1\n elif item.y <= 103:\n remaining.append(item)\n elif item.bonus:\n self.multiplier = max(1, self.multiplier - 1)\n self.items = remaining\n return reward\n\n def _hits_wall(self, x: float, y: float) -> bool:\n return any(abs(y - wall.y) < 5 and abs(x - wall.x) + 3 > wall.width / 2\n for wall in self.walls)\n\n def _recycle_wall(self, index: int, wall: Wall) -> None:\n previous = self.walls[index - 1]\n wall.y -= 114\n wall.x, wall.width = previous.x + self.wall_vx, previous.width + self.wall_vw\n self.top_wall = wall\n self.wall_vx = min(5, max(-5, self.wall_vx + self.random.uniform(-1, 1))) * 0.95\n self.wall_vw = min(3, max(-3, self.wall_vw + self.random.uniform(-1, 1))) * 0.95\n if ((wall.x + wall.width / 2 > 95 and self.wall_vx > 0)\n or (wall.x - wall.width / 2 < 5 and self.wall_vx < 0)):\n self.wall_vx *= -0.5\n if (wall.width > 80 and self.wall_vw > 0) or (wall.width < 40 and self.wall_vw < 0):\n self.wall_vw *= -0.5\n\n def _spawn_item(self) -> None:\n wall = self.top_wall\n if self.bonus_count > 0:\n self.items.append(Item(self.bonus_x, -3, True))\n self.item_distance = 6\n elif self.bonus_count < 0 and self.random.random() < 0.5:\n self.bonus_count = int(self.random.integers(2, 6))\n self.bonus_x = wall.x + self.random.uniform(-0.25, 0.25) * wall.width\n self.item_distance = 0\n else:\n x = wall.x + self.random.uniform(0.1, 0.4) * self.item_side * wall.width\n self.items.append(Item(x, -3, False))\n if self.random.random() < 0.8:\n self.item_side *= -1\n self.item_distance = self.random.uniform(10, 20)\n self.bonus_count -= 1\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row, col = min(9, max(0, int(self.y // 10))), min(9, max(0, int(self.x // 10)))\n state[row, col, 0] = True\n for wall in self.walls:\n if 0 <= wall.y < 100:\n state[int(wall.y // 10), :, 1] |= abs(np.arange(5, 100, 10) - wall.x) > wall.width / 2\n for item in self.items:\n if 0 <= item.x < 100 and 0 <= item.y < 100:\n state[int(item.y // 10), int(item.x // 10), 2 + item.bonus] = True\n state[row, min(9, max(0, col + self.direction)), 4] = True\n for row, value in enumerate((self.steps, self.multiplier, round(self.ratio * 100))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 304, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/lift_up.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/liftup/main.js"} +{"name": "tongue_hunter", "split": "train", "game": "tongue_hunter", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Tongue Hunter as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to aim and extend the frog's tongue toward the prey\nnearest its tip. Other actions retract it. A catch pays the rounded-up\ntongue length times the current combo, then increases the combo by one.\nRetracting to five units or less resets the combo. A falling hazard\nends the episode if it touches the extended tongue.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the frog, tongue, tip, prey, hazards,\nand counters. Counters encode elapsed actions, effective action,\ncombo, tongue length, and tongue angle. The port fixes difficulty and\napproximates sprite collisions with box and segment checks. Each action\nadvances up to four frames over 400 actions. Clip the episode score to\n[0, 1000] and divide by 1000.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/tongue_hunter.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import atan2, ceil, cos, pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Prey:\n x: float\n y: float\n vx: float\n\n\n@dataclass\nclass Hazard:\n x: float\n y: float = -5.\n\n\nclass TongueHunterEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.prey, self.hazards = [], []\n self.length, self.angle = 0., -pi / 2\n self.tip = (50., 90.)\n self.combo = 1\n self.steps = self.frames = self.action = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n if self.frames % 60 == 0:\n left = self.random.random() < 0.5\n speed = self.random.uniform(0.3, 0.6)\n self.prey.append(Prey(-5 if left else 105, self.random.uniform(20, 60),\n speed if left else -speed))\n if self.frames % 90 == 0:\n self.hazards.append(Hazard(self.random.uniform(10, 90)))\n\n dx, dy = cos(self.angle) * self.length, sin(self.angle) * self.length\n tip_x, tip_y = self.tip = (50 + dx, 90 + dy)\n if self.action == 5 and self.prey:\n target = min(self.prey, key=lambda p: (p.x - tip_x) ** 2 + (p.y - tip_y) ** 2)\n angle = atan2(target.y - 90, target.x - 50)\n delta = angle - self.angle\n if abs(delta) < 0.1:\n self.angle = angle\n self.length += 8\n else:\n self.angle += 0.1 if delta > 0 else -0.1\n self.length = min(80, max(0, self.length - 5))\n\n for prey in self.prey:\n prey.x += prey.vx * 1.05\n self.prey = [p for p in self.prey if -10 < p.x < 110]\n for hazard in self.hazards:\n hazard.y += 0.5\n self.hazards = [h for h in self.hazards if h.y < 110]\n\n reward = 0\n if self.length <= 5:\n self.combo = 1\n else:\n radius = 2.5 + 3 * (1 + sin(self.frames * 0.3) * 0.2)\n if any(abs(p.x - tip_x) <= radius and abs(p.y - tip_y) <= radius for p in self.prey):\n target = min(self.prey, key=lambda p: (p.x - tip_x) ** 2 + (p.y - tip_y) ** 2)\n self.prey.remove(target)\n reward = ceil(self.length) * self.combo\n self.combo += 1\n self.terminal = any(self._touches_tongue(h, dx, dy) for h in self.hazards)\n self.frames += 1\n return reward\n\n def _touches_tongue(self, hazard, dx, dy):\n radius = 1 + 4 * (1 + sin(self.frames * 0.15 + hazard.x) * 0.1)\n near, far = 0., 1.\n for offset, movement in ((hazard.x - 50, dx), (hazard.y - 90, dy)):\n if abs(movement) < 1e-9:\n if abs(offset) > radius:\n return False\n else:\n edges = sorted(((offset - radius) / movement, (offset + radius) / movement))\n near, far = max(near, edges[0]), min(far, edges[1])\n return near <= far\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[9, 5, 0] = True\n if self.length > 5:\n tip_x, tip_y = self.tip\n for x, y in zip(np.linspace(50, tip_x, 33), np.linspace(90, tip_y, 33), strict=True):\n self._mark(state, x, y, 1)\n self._mark(state, tip_x, tip_y, 2)\n for prey in self.prey:\n self._mark(state, prey.x, prey.y, 3)\n for hazard in self.hazards:\n self._mark(state, hazard.x, hazard.y, 4)\n values = (self.steps, self.action, self.combo, round(self.length * 4),\n round((self.angle + pi) * 128))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n @staticmethod\n def _mark(state, x, y, channel):\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), channel] = True\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 305, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tongue_hunter.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameTongueHunter.c"} +{"name": "forfour", "split": "train", "game": "forfour", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Forfour as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to rotate the board clockwise. Release with actions\n0–4 between taps. Incoming pieces attach to the first occupied\ncell in their path. Wild pieces copy the color they hit or take\na random color when they hit the core.\n\nGroups of four or more orthogonally connected pieces of the same\ncolor clear. Pieces disconnected from the core also clear. The\npayout is the square of the total removed minus three, with the\nsubtraction applied before squaring. A piece that cannot attach\nwithin the board ends the run.\n\nINPUT CHANNEL TABLE\nThe conversion uses a 9×9 board within the six-channel 10×10\nobservation. Five channels show the core and four colors. The\nsixth shows the incoming lane and gauges. The incoming piece\nmoves in discrete cells after a fixed delay.\n\nSCORING, TERMINATION, AND HORIZON\nThe 400-action task clips raw scores to [0, 500] and divides by\n500. Across 100 seeds without sticky actions, idle averaged 3.66\nand reached 49. Random inputs averaged 2.24 and reached 36.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/forfour.py`):\n```python\nimport math\n\nimport numpy as np\n\n\nSIZE = 9\nCENTER = SIZE // 2\nCORE = (CENTER, CENTER)\nDIRECTIONS = ((0, 1), (1, 0), (0, -1), (-1, 0))\n\n\nclass ForfourEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = 0\n self.pressed = self.terminal = False\n self.board = np.full((SIZE, SIZE), -1, dtype=np.int8)\n self.board[CORE] = 0\n self.board[CENTER, CENTER + 1:CENTER + 4] = self.random.integers(1, 5, size=3)\n self._spawn()\n\n def _spawn(self) -> None:\n extent = int(np.max(np.abs(np.argwhere(self.board >= 0) - CENTER))) + 1\n self.color = int(self.random.integers(1, 5))\n if self.random.random() < math.sqrt(extent) * 0.1:\n self.color = 0\n extent = math.ceil(extent * 0.7)\n lane = int(self.random.integers(CENTER - extent + 1, CENTER + extent))\n self.direction = int(self.random.integers(4))\n self.row, self.column = ((lane, -1), (-1, lane), (lane, SIZE), (SIZE, lane))[self.direction]\n self.timer = 60\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance()\n if tap and frame == 0 and not self.terminal:\n self.board = np.rot90(self.board, -1).copy()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self) -> int:\n self.timer -= 1\n if self.timer > 0:\n return 0\n self.timer = 6\n dy, dx = DIRECTIONS[self.direction]\n next_cell = self.row + dy, self.column + dx\n if not self._inside(*next_cell):\n self._spawn()\n return 0\n hit = int(self.board[next_cell])\n if hit < 0:\n self.row, self.column = next_cell\n return 0\n if not self._inside(self.row, self.column):\n self.terminal = True\n return 0\n color = self.color or hit or int(self.random.integers(1, 5))\n cell = self.row, self.column\n self.board[cell] = color\n group = self._connected(cell, color)\n reward = 0\n if len(group) >= 4:\n for removed in group:\n self.board[removed] = -1\n attached = self._connected(CORE)\n count = len(group)\n for row, column in np.argwhere(self.board > 0):\n if (row, column) not in attached:\n self.board[row, column] = -1\n count += 1\n reward = (count - 3)**2\n self._spawn()\n return reward\n\n @staticmethod\n def _inside(row: int, column: int) -> bool:\n return 0 <= row < SIZE and 0 <= column < SIZE\n\n def _connected(self, start: tuple[int, int], color: int | None = None) -> set[tuple[int, int]]:\n reached = {start}\n pending = [start]\n while pending:\n row, column = pending.pop()\n for dy, dx in DIRECTIONS:\n cell = row + dy, column + dx\n if self._inside(*cell) and cell not in reached:\n value = self.board[cell]\n if (value >= 0 if color is None else value == color):\n reached.add(cell)\n pending.append(cell)\n return reached\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n for color in range(5):\n state[:SIZE, :SIZE, color] = self.board == color\n if self.direction % 2 == 0:\n state[self.row, :SIZE, 5] = True\n else:\n state[:SIZE, self.column, 5] = True\n row, column = min(8, max(0, self.row)), min(8, max(0, self.column))\n state[row, column, self.color] = True\n state[9, self.color, 5] = True\n state[9, 5 + self.direction, 5] = True\n state[9, 9, 5] = self.pressed\n for bit in range(6):\n state[bit, 9, 5] = bool(self.timer & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 306, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/forfour.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/forfour/main.js"} +{"name": "sky_raftsman", "split": "train", "game": "sky_raftsman", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Sky Raftsman as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to jump in the direction the current raft is pointing.\nHold it to reduce gravity in flight. Actions 0–4 release. Land on a\nrotating raft to jump again. The raft you leave recoils in the\nopposite direction. Each time a raft accumulates more than 20 units\nof downward travel, it scores five times its downward speed,\nrounded down. Falling below the screen ends the episode.\n\nINPUT CHANNEL TABLE\nThe six Boolean channels show the player, rafts, the occupied\nraft, off-screen raft markers, the direction of motion or launch,\nand counters. The port uses fixed difficulty and approximates\nlanding with a radial contact test. Each action advances up to\nfour frames over a 400-action horizon. Clip episode scores to\n[0, 150] and divide by 150.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/sky_raftsman.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import atan2, cos, floor, hypot, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Log:\n x: float\n y: float\n size: float\n spin: float\n angle: float = 0\n vx: float = 0\n vy: float = 0\n distance: float = 0\n\n\nclass SkyRaftsmanEnvironment:\n score_cap = 150\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x = self.y = self.vx = self.vy = self.distance = 0.\n self.steps = 0\n self.jumping = self.held = self.terminal = False\n self.current = Log(50, 75, 20, -0.05)\n self.logs = [self.current, *(self._log(75 + i * 30) for i in range(1, 5))]\n\n def _log(self, y):\n return Log(self.random.uniform(10, 90), y, self.random.uniform(15, 25),\n self.random.uniform(0.04, 0.08) * self.random.choice((-1, 1)))\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n scroll = -0.05 + 0.1 * max(0, 20 - self.y) - 0.2 * max(0, self.y - 50)\n log = self.current\n if tap and not self.jumping:\n self.jumping = True\n self.vx, self.vy = 2 * cos(log.angle), 2 * sin(log.angle)\n self.x += 2 * self.vx\n self.y += 2 * self.vy\n log.vx, log.vy = -self.vx, -self.vy\n if self.jumping:\n self.x += self.vx\n self.y += self.vy + scroll\n self.vx *= 0.99\n self.vy = self.vy * 0.99 + (0.05 if self.held else 0.1)\n else:\n self.x = log.x + log.size / 2 * cos(log.angle)\n self.y = log.y + log.size / 2 * sin(log.angle)\n if (self.x < 3 and self.vx < 0) or (self.x > 97 and self.vx > 0):\n self.vx *= -1\n self.terminal = self.y > 100\n reward = 0\n for log in self.logs:\n log.x += log.vx\n log.y += log.vy + scroll\n log.distance += log.vy\n if log.distance > 20:\n log.distance -= 20\n reward += max(0, floor(log.vy * 5))\n log.vx *= 0.99\n log.vy *= 0.99\n if (log.x < log.size / 2 and log.vx < 0) or (log.x > 100 - log.size / 2 and log.vx > 0):\n log.vx *= -1\n log.angle += log.spin\n self.logs = [log for log in self.logs if log.y >= -99 or log is self.current]\n self.distance += scroll\n if self.distance < 0 and not self.jumping:\n self.logs.append(self._log(125))\n self.distance = 100\n if self.jumping:\n for log in self.logs:\n if log.y <= 100 + log.size / 2 and abs(\n hypot(self.x - log.x, self.y - log.y) - log.size / 2\n ) < 5:\n self.jumping = False\n self.current = log\n log.angle = atan2(self.y - log.y, self.x - log.x)\n break\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n row, col = np.clip(np.array([self.y, self.x]) // 10, 0, 9).astype(int)\n state[row, col, 0] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for log in self.logs:\n if log.y > 100 + log.size / 2:\n state[9, :, 3] |= abs(cols[0] - log.x) < log.size / 2 + 5\n else:\n channel = 2 if log is self.current and not self.jumping else 1\n state[:, :, channel] |= abs(np.hypot(cols - log.x, rows - log.y) - log.size / 2) < 6\n dx, dy = (self.vx, self.vy) if self.jumping else (cos(self.current.angle), sin(self.current.angle))\n row, col = np.clip(np.array([self.y + 10 * dy, self.x + 10 * dx]) // 10, 0, 9).astype(int)\n state[row, col, 4] = True\n values = (self.steps, self.held, self.jumping,\n round((self.vx + 10) * 20), round((self.vy + 10) * 20))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 307, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/sky_raftsman.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameSkyRaftsman.c"} +{"name": "river_raid", "split": "train", "game": "river_raid", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays River Raid as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves the vertically scrolling River of No Return, changing banks and narrow\nchannels, throttle, constant-rate fuel drain, slower refueling, steerable missiles, tankers,\nhelicopters, fuel depots, jets, bridge-delimited sections, bridge checkpoints, collisions, four\navailable jets (one active and three reserve), and 10,000-point reinforcements. Fuel depots become\nscarcer in practical time because later sections narrow and traffic moves faster.\n\nACTION MAPPING\n0: cruise\n1: bank left and steer missiles left\n2: accelerate\n3: bank right and steer missiles right\n4: slow down\n5: fire missile\n\nINPUT CHANNEL TABLE\n0: assault jet\n1: typed enemies and bridge\n2: object-type bit, fuel depots, and missiles\n3: object-type bit and river banks\n4: previous jet, object, and missile positions\n5: current-section reward identities, exact section/lives/fuel/speed/progress/steps, and reinforcement state\n\nSCORING, TERMINATION, AND HORIZON\nOne section contains a 30-point tanker, 60-point helicopter, 80-point fuel depot, 100-point jet,\nand 500-point bridge, totaling 770. Across sixteen finite sections,\n`score_cap = 16 × 770 = 12,320`. Normalization is\n`min(max(raw_score, 0), 12_320) / 12_320`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/river_raid.py`):\n```python\nimport numpy as np\n\n\nOBJECT_VALUES = {\"tanker\": 30, \"helicopter\": 60, \"fuel\": 80, \"jet\": 100, \"bridge\": 500}\nSPAWN_OFFSETS = {\"tanker\": 4, \"helicopter\": 9, \"fuel\": 15, \"jet\": 21, \"bridge\": 29}\n\n\nclass RiverRaidEnvironment:\n \"\"\"Sixteen bridge sections with fuel, throttle, traffic, and checkpoints.\"\"\"\n\n score_cap = 12_320.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 3_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.section = 0\n self.section_progress = 0\n self.player_column = 5\n self.previous_player_column = 5\n self.speed = 1\n self.fuel = 100\n self.lives = 4\n self.score = 0.0\n self.next_reinforcement = 10_000\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self.claimed: set[tuple[int, str]] = set()\n self.missiles: list[list[int]] = []\n self.previous_missiles: list[list[int]] = []\n self._load_section()\n\n def _load_section(self) -> None:\n self.objects = []\n for kind, offset in SPAWN_OFFSETS.items():\n if (self.section, kind) in self.claimed:\n continue\n column = 2 + (self.section * 3 + len(kind)) % 6\n self.objects.append({\"kind\": kind, \"offset\": offset, \"column\": column, \"direction\": 1 if offset % 2 else -1})\n self.previous_objects = {str(item[\"kind\"]): self._object_position(item) for item in self.objects}\n\n def _object_position(self, item: dict[str, object]) -> list[int]:\n return [8 - (int(item[\"offset\"]) - self.section_progress), int(item[\"column\"])]\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player_column = self.player_column\n self.previous_missiles = [missile.copy() for missile in self.missiles]\n self.previous_objects = {str(item[\"kind\"]): self._object_position(item) for item in self.objects}\n if action == 0:\n self.speed = 1\n elif action == 1:\n self.player_column = max(0, self.player_column - 1)\n for missile in self.missiles:\n missile[1] = max(0, missile[1] - 1)\n elif action == 3:\n self.player_column = min(9, self.player_column + 1)\n for missile in self.missiles:\n missile[1] = min(9, missile[1] + 1)\n elif action == 2:\n self.speed = 2\n elif action == 4:\n self.speed = 0\n elif action == 5 and len(self.missiles) < 3:\n self.missiles.append([8, self.player_column])\n section_before = self.section\n reward = self._move_missiles()\n if self.section == section_before and not self.terminal:\n self._move_objects()\n self._refuel()\n self.section_progress += self.speed\n self.fuel -= 1\n self._resolve_collisions()\n self.score += reward\n while self.score >= self.next_reinforcement:\n self.lives = min(10, self.lives + 1)\n self.next_reinforcement += 10_000\n self.steps += 1\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_missiles(self) -> float:\n reward = 0.0\n for missile in list(self.missiles):\n missile[0] -= 1\n hit = None\n for item in self.objects:\n if missile == self._object_position(item):\n hit = item\n break\n if hit is not None:\n kind = str(hit[\"kind\"])\n self.claimed.add((self.section, kind))\n self.objects.remove(hit)\n self.missiles.remove(missile)\n reward += float(OBJECT_VALUES[kind])\n if kind == \"bridge\":\n self.section += 1\n if self.section >= 16:\n self.terminal = True\n else:\n self.section_progress = 0\n self.missiles.clear()\n self._load_section()\n break\n elif missile[0] < 0:\n self.missiles.remove(missile)\n return reward\n\n def _move_objects(self) -> None:\n for item in self.objects:\n if item[\"kind\"] not in (\"helicopter\", \"jet\"):\n continue\n interval = max(1, 4 - self.section // 5)\n if self.steps % interval:\n continue\n item[\"column\"] = int(item[\"column\"]) + int(item[\"direction\"])\n if item[\"column\"] in (1, 8):\n item[\"direction\"] = -int(item[\"direction\"])\n\n def _refuel(self) -> None:\n for item in self.objects:\n if item[\"kind\"] == \"fuel\" and self._object_position(item) == [8, self.player_column]:\n self.fuel = min(100, self.fuel + (8 if self.speed == 0 else 4))\n\n def _river_bounds(self, progress: int) -> tuple[int, int]:\n center = 5 + ((progress // 7 + self.section) % 3 - 1)\n half_width = max(2, 4 - self.section // 6)\n return max(0, center - half_width), min(9, center + half_width)\n\n def _resolve_collisions(self) -> None:\n left, right = self._river_bounds(self.section_progress)\n object_hit = any(self._object_position(item) == [8, self.player_column] for item in self.objects)\n if self.player_column <= left or self.player_column >= right or object_hit or self.fuel <= 0:\n self._lose_jet()\n\n def _lose_jet(self) -> None:\n self.lives -= 1\n if self.lives <= 0:\n self.terminal = True\n return\n self.section_progress = 0\n self.player_column = 5\n self.previous_player_column = 5\n self.speed = 1\n self.fuel = 100\n self.missiles.clear()\n self._load_section()\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[8, self.player_column, 0] = True\n state[8, self.previous_player_column, 4] = True\n for row in range(9):\n left, right = self._river_bounds(self.section_progress + 8 - row)\n state[row, : left + 1, 3] = True\n state[row, right:, 3] = True\n kind_codes = {\"tanker\": 0, \"helicopter\": 1, \"fuel\": 2, \"jet\": 3}\n for item in self.objects:\n row, column = self._object_position(item)\n if 0 <= row < 9:\n if item[\"kind\"] == \"bridge\":\n left, right = self._river_bounds(self.section_progress + 8 - row)\n state[row, left + 1 : right, 1] = True\n else:\n code = kind_codes[str(item[\"kind\"])]\n state[row, column, 1] = True\n state[row, column, 2] = bool(code & 1)\n state[row, column, 3] = bool(code & 2)\n previous = self.previous_objects.get(str(item[\"kind\"]))\n if previous is not None and 0 <= previous[0] < 9:\n state[*previous, 4] = True\n for missile in self.missiles:\n state[*missile, 2] = True\n for missile in self.previous_missiles:\n state[*missile, 4] = True\n for kind_index, kind in enumerate(OBJECT_VALUES):\n state[0, kind_index, 5] = (self.section, kind) in self.claimed\n for bit in range(4):\n state[0, 5 + bit, 5] = bool(self.section & (1 << bit))\n state[1, bit, 5] = bool(self.lives & (1 << bit))\n for bit in range(7):\n index = 14 + bit\n state[index // 10, index % 10, 5] = bool(max(0, self.fuel) & (1 << bit))\n state[2, 1, 5] = bool(self.speed & 1)\n state[2, 2, 5] = bool(self.speed & 2)\n state[2, 3, 5] = self.score >= 10_000\n for bit in range(5):\n state[2, 4 + bit, 5] = bool(self.section_progress & (1 << bit))\n for bit in range(12):\n index = 30 + bit\n state[index // 10, index % 10, 5] = bool(self.steps & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 308, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/river_raid.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "t_laser", "split": "train", "game": "t_laser", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays T Laser as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nMove the sight with actions 1–4 (left, up, right, down). Actions\n0 and 5 hold position. Sweep the sight over enemies to lock on.\nThe laser launches automatically and chases targets in lock order.\nEach hit scores the current multiplier and raises it. A new laser\nresets the multiplier. An unlocked enemy crossing the far edge\nends the episode.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the sight, unlocked enemies, locked\nenemies, laser trail, downward-moving enemies, and counters.\nThe port replaces pointer input with directional motion, fixes\ndifficulty, and uses the unjittered laser trail for contact. Each\naction advances up to four frames over 400 actions. Clip scores\nto [0, 500] and divide by 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/t_laser.py`):\n```python\nfrom collections import deque\nfrom dataclasses import dataclass\nfrom math import sqrt\n\nimport numpy as np\n\n\n@dataclass\nclass Enemy:\n x: float\n y: float\n z: float\n vy: float\n lock: int = -1\n\n\nclass TLaserEnvironment:\n score_cap = 500\n moves = ((0, 0), (-1, 0), (0, -1), (1, 0), (0, 1), (0, 0))\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(400, horizon)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x = self.y = 50\n self.action = self.steps = self.timer = self.lock_index = 0\n self.multiplier = 1\n self.terminal = False\n self.enemies = []\n self.laser = None\n self.history = deque(maxlen=19)\n self.velocity = np.zeros(2)\n self.depth = 1.\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n dx, dy = self.moves[self.action]\n self.x = min(99, max(0, self.x + dx * 3))\n self.y = min(99, max(0, self.y + dy * 3))\n target = min((enemy for enemy in self.enemies if enemy.lock >= 0),\n key=lambda enemy: enemy.lock, default=None)\n if target is not None and self.laser is None:\n self.laser = np.array([50., 99.])\n self.velocity[:] = 0, -1\n self.depth = 1.\n self.multiplier = 1\n self.history.clear()\n self.history.append(self.laser.copy())\n if self.laser is not None:\n change = 0.\n if target is not None:\n self.velocity = (self.velocity + 0.5 * (np.array([target.x, target.y]) - self.laser)) * 0.5\n change = (target.z - self.depth) * 0.1\n self.depth += change\n else:\n speed = np.linalg.norm(self.velocity)\n if speed:\n self.velocity *= 5 / speed\n self.laser += self.velocity / (self.depth * (1 + 9 * abs(change)))\n self.history.append(self.laser.copy())\n margin = 99 / self.depth\n if np.any((self.laser < -margin) | (self.laser > 100 + margin)):\n self.laser = None\n self.history.clear()\n self.multiplier = 1\n self.timer -= 1\n if self.timer < 0:\n depth = self.random.uniform(0.5, 3)\n vy = self.random.choice((-1, 1)) * self.random.uniform(0.2, 0.3) / sqrt(depth)\n x, y = self.random.uniform(10, 90), -5 if vy > 0 else 105\n self.enemies.extend(Enemy(x, y - vy * i * 30, depth, vy)\n for i in range(self.random.integers(3, 6)))\n self.timer += self.random.uniform(60, 99)\n reward = 0\n survivors = []\n for enemy in self.enemies:\n enemy.y += enemy.vy\n half = 3 / sqrt(enemy.z)\n if enemy is target and self._laser_hit(enemy, half):\n reward += self.multiplier\n self.multiplier += 1\n continue\n if enemy.lock < 0 and abs(enemy.x - self.x) < half + 3 and abs(enemy.y - self.y) < half + 3:\n enemy.lock = self.lock_index\n self.lock_index += 1\n if enemy.lock < 0 and (enemy.y < 0 if enemy.vy < 0 else enemy.y > 99):\n self.terminal = True\n survivors.append(enemy)\n self.enemies = survivors\n return reward\n\n def _laser_hit(self, enemy, half):\n if len(self.history) < 2:\n return False\n path = np.asarray(self.history)\n starts, vectors = path[:-1], np.diff(path, axis=0)\n delta = np.array([enemy.x, enemy.y]) - starts\n length_sq = np.sum(vectors * vectors, axis=1)\n ratio = np.sum(delta * vectors, axis=1) / np.maximum(length_sq, 1e-9)\n nearest = delta - vectors * np.clip(ratio, 0, 1)[:, None]\n return bool(np.any(np.linalg.norm(nearest, axis=1) < half + 1.5 / self.depth))\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[self.y // 10, self.x // 10, 0] = True\n for enemy in self.enemies:\n if 0 <= enemy.y < 100:\n col, row = int(enemy.x // 10), int(enemy.y // 10)\n state[row, col, 1 if enemy.lock < 0 else 2] = True\n state[row, col, 4] |= enemy.vy > 0\n for start, end in zip(self.history, list(self.history)[1:]):\n points = np.linspace(start, end, 20)\n points = points[np.all((points >= 0) & (points < 100), axis=1)]\n cols, rows = (points // 10).astype(int).T\n state[rows, cols, 3] = True\n for row, value in enumerate((self.steps, self.multiplier, self.action,\n max(0, round(self.timer)), round(self.depth * 100))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 309, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/t_laser.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/tlaser/main.js"} +{"name": "cue_crumb", "split": "train", "game": "cue_crumb", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Cue Crumb as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nYour heading rotates automatically. Tap action 5 to thrust along\nit. Release with actions 0–4 before tapping again. Strike a large\nrock at speed to split it and score one point. Fast hot fragments\ncan split other rocks for points equal to their chain depth.\nTouching a fast hot fragment ends the run. Cooled crumbs score\nthree points when collected.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, cold rocks, hot fragments,\ncooled crumbs, the heading marker, and gauges. Each action advances\nfour frames at fixed difficulty. The conversion uses distance\nchecks and starts new rocks on the bounce boundary.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 100] and divide by 100. Across 100 seeds without sticky actions,\nidle scored zero, continuous hold averaged 0.88, and random\nhold and release averaged 6.18 raw points.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/cue_crumb.py`):\n```python\nfrom dataclasses import dataclass\nfrom itertools import combinations\nimport math\n\nimport numpy as np\n\n\n@dataclass(eq=False)\nclass Body:\n x: float\n y: float\n vx: float = 0\n vy: float = 0\n\n @property\n def speed(self) -> float:\n return math.hypot(self.vx, self.vy)\n\n def move(self, friction: float, margin: float) -> None:\n self.vx *= friction\n self.vy *= friction\n self.x += self.vx\n self.y += self.vy\n if not margin <= self.x <= 100 - margin:\n self.vx *= -1\n self.x = min(100 - margin, max(margin, self.x))\n if not margin <= self.y <= 100 - margin:\n self.vy *= -1\n self.y = min(100 - margin, max(margin, self.y))\n\n\n@dataclass(eq=False)\nclass Rock(Body):\n size: float = 9\n hot: int = 0\n depth: int = 0\n\n\nclass CueCrumbEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.freeze = 0\n self.spawn_timer = 300\n self.pressed = self.terminal = False\n self.player = Body(50, 50)\n self.angle = self.random.uniform(0, math.tau)\n self.rocks: list[Rock] = []\n for _ in range(4):\n x, y = self.random.uniform(12, 88, 2)\n if math.hypot(x - 50, y - 50) < 20:\n x = 12 + (x - 12 + 35) % 76\n self.rocks.append(Rock(x, y))\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance_frame(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self, tap: bool) -> int:\n if not self.freeze:\n self.angle = (self.angle + 0.058) % math.tau\n if tap:\n self.player.vx += 1.7 * math.cos(self.angle)\n self.player.vy += 1.7 * math.sin(self.angle)\n if self.freeze:\n self.freeze -= 1\n return 0\n\n self.player.move(0.965, 5)\n self._spawn()\n reward = self._collide_rocks()\n for rock in self.rocks[:]:\n rock.hot = max(0, rock.hot - 1)\n rock.move(0.985, 4)\n dx, dy = rock.x - self.player.x, rock.y - self.player.y\n if math.hypot(dx, dy) >= rock.size / 2 + 3:\n continue\n angle = math.atan2(dy, dx)\n speed = self.player.speed\n if rock.size <= 4.5 and not rock.hot:\n self.rocks.remove(rock)\n reward += 3\n elif rock.hot and rock.speed > 0.4:\n self.terminal = True\n break\n elif speed > 0.9 and rock.size > 4.5:\n self._split(rock, angle, 1.2 + speed * 0.4, 1)\n self.player.vx *= 0.3\n self.player.vy *= 0.3\n self.freeze = max(self.freeze, 2 + 2 * (speed > 1.4) + 2 * (speed > 2.2))\n reward += 1\n else:\n rock.vx += math.cos(angle) * 0.5\n rock.vy += math.sin(angle) * 0.5\n return reward\n\n def _spawn(self) -> None:\n self.spawn_timer -= 1\n if self.spawn_timer >= 0 or sum(rock.size > 4.5 for rock in self.rocks) >= 10:\n return\n side = int(self.random.integers(4))\n offset = self.random.uniform(4, 96)\n x, y = ((offset, 4), (96, offset), (offset, 96), (4, offset))[side]\n self.rocks.append(Rock(x, y, *self.random.uniform(-0.2, 0.2, 2)))\n self.spawn_timer = int(self.random.integers(200, 321))\n\n def _collide_rocks(self) -> int:\n queued: dict[Rock, tuple[float, int]] = {}\n large_count = sum(rock.size > 4.5 for rock in self.rocks)\n for first, second in combinations(self.rocks, 2):\n dx, dy = second.x - first.x, second.y - first.y\n distance = math.hypot(dx, dy)\n if not 0.01 < distance < (first.size + second.size) / 2:\n continue\n source, target = (first, second) if first.hot and first.speed > 0.7 else (second, first)\n if source.hot and source.speed > 0.7 and target.size > 4.5 and target not in queued and large_count < 10:\n queued[target] = source.speed, max(1, source.depth) + 1\n else:\n vx, vy = dx * 0.3 / distance, dy * 0.3 / distance\n first.vx -= vx\n first.vy -= vy\n second.vx += vx\n second.vy += vy\n for target, (speed, depth) in queued.items():\n self._split(target, self.random.uniform(0, math.tau), 1.3, depth)\n self.freeze = max(self.freeze, 2 + (speed > 1.0) + (speed > 1.6))\n return sum(depth for _, depth in queued.values())\n\n def _split(self, rock: Rock, angle: float, speed: float, depth: int) -> None:\n self.rocks.remove(rock)\n for offset in (-0.6, 0.6):\n dx, dy = math.cos(angle + offset), math.sin(angle + offset)\n self.rocks.append(Rock(rock.x + 4 * dx, rock.y + 4 * dy,\n speed * dx, speed * dy, rock.size * 0.62, 55, depth))\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n player = self.player\n state[int(player.y) // 10, int(player.x) // 10, 0] = True\n x = player.x + 8 * math.cos(self.angle)\n y = player.y + 8 * math.sin(self.angle)\n state[min(9, max(0, int(y) // 10)), min(9, max(0, int(x) // 10)), 4] = True\n for rock in self.rocks:\n channel = 2 if rock.hot else 3 if rock.size <= 4.5 else 1\n state[min(9, int(rock.y) // 10), min(9, int(rock.x) // 10), channel] = True\n values = (self.steps, round(self.angle * 80), self.freeze,\n round((player.vx + 16) * 8), round((player.vy + 16) * 8))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 310, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/cue_crumb.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameCueCrumb.c"} +{"name": "marble_bounce", "split": "train", "game": "marble_bounce", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Marble Bounce as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to kick the marble upward. Actions 0–4 release\nthe button. Regular pins bounce the marble and score the\ncurrent multiplier. Hitting the target scores 100 times the\nmultiplier and promotes another pin. Clearing every pin\nstarts a new wave and raises the multiplier. A target that\nsurvives longer than 900 frames ends the run.\n\nINPUT CHANNEL TABLE\nSix 10×10 channels show the marble, regular pins, target,\nground, target warning, and gauges. The conversion uses\ncircular collision bounds at fixed difficulty, with four\nframes per action. The 400-action task clips scores to\n[0, 1500] and divides by 1500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/marble_bounce.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Pin:\n x: float\n y: float\n size: float\n last_hit: int = 0\n\n\nclass MarbleBounceEnvironment:\n score_cap = 1500\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 50.0, 80.0\n self.vx = self.vy = 0.0\n self.steps = self.frames = self.timer = self.target_since = 0\n self.interval = 360\n self.multiplier = 1\n self.pressed = self.terminal = False\n self.pins: list[Pin] = []\n self._wave(2)\n\n def _wave(self, size):\n for _ in range(8):\n pin = self._sample_pin(50, size)\n if pin is None:\n pin = Pin(self.random.uniform(10, 90), self.random.uniform(20, 80), size)\n self.pins.append(pin)\n self.target = self.pins[0]\n\n def _sample_pin(self, attempts, size):\n for _ in range(attempts):\n x, y = self.random.uniform(10, 90), self.random.uniform(20, 80)\n if math.hypot(x - self.x, y - self.y) >= 15 and all(\n math.hypot(x - pin.x, y - pin.y) >= 15 for pin in self.pins):\n return Pin(x, y, size)\n return None\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n tap = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _distance(self, pin):\n return math.hypot(self.x - pin.x, self.y - pin.y)\n\n def _advance(self, tap):\n self.vy += 0.15\n if tap:\n self.vy = min(5, max(-5, self.vy - 3))\n self.timer += 1\n if self.timer >= self.interval:\n self.timer = 0\n pin = self._sample_pin(20, 0)\n if pin is not None:\n self.pins.append(pin)\n self.interval = max(90, self.interval - 30)\n self.x += self.vx\n self.y += self.vy\n if self.y >= 89.5:\n self.y = 89.5\n self.vy *= -0.7\n if abs(self.vx) < 0.5:\n self.vx += self.random.uniform(1, 2) * self.random.choice((-1, 1))\n if self.frames - self.target_since > 900:\n self.terminal = True\n return 0\n for pin in self.pins:\n pin.size = min(2, pin.size + 0.1)\n reward = self._hit_pins()\n if not 5 <= self.x <= 95:\n self.vx = abs(self.vx) if self.x < 5 else -abs(self.vx)\n self.x = min(95, max(5, self.x))\n if self.y < 5:\n self.y = 5\n self.vy = abs(self.vy)\n self.frames += 1\n return reward\n\n def _hit_pins(self):\n reward = 0\n regular = min((pin for pin in self.pins if pin is not self.target),\n key=self._distance, default=None)\n if regular is not None and self._distance(regular) < 3 + regular.size:\n angle = math.atan2(self.y - regular.y, self.x - regular.x)\n separation = 3 + regular.size\n self.x = regular.x + math.cos(angle) * separation\n self.y = regular.y + math.sin(angle) * separation\n if self.frames - regular.last_hit > 9:\n reward += self.multiplier\n regular.last_hit = self.frames\n self.vx = self.random.uniform(1, 2) * self.random.choice((-1, 1))\n self.vy = -abs(self.vy) * 0.8\n if self._distance(self.target) < 3 + self.target.size:\n angle = math.atan2(self.y - self.target.y, self.x - self.target.x)\n self.x += 2 * math.cos(angle)\n self.y += 2 * math.sin(angle)\n self.vx = self.random.uniform(2, 3) * self.random.choice((-1, 1))\n self.vy = -abs(self.vy) * 0.9\n reward += 100 * self.multiplier\n self.pins = [pin for pin in self.pins if pin is not self.target]\n if self.pins:\n self.target = self.pins[self.random.integers(len(self.pins))]\n else:\n self.multiplier += 1\n self._wave(0)\n self.interval, self.timer, self.target_since = 360, 0, self.frames\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[min(9, max(0, int(self.y // 10))), min(9, max(0, int(self.x // 10))), 0] = True\n for pin in self.pins:\n state[int(pin.y // 10), int(pin.x // 10), 2 if pin is self.target else 1] = True\n state[9, :, 3] = True\n if self.frames - self.target_since > 600:\n state[int(self.target.y // 10), int(self.target.x // 10), 4] = True\n gauges = (self.steps, (self.frames - self.target_since) // 2, self.multiplier,\n round((self.vx + 8) * 20), round((self.vy + 8) * 20))\n for row, value in enumerate(gauges):\n for bit in range(9):\n state[row, bit, 5] = bool(min(511, max(0, value)) & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 311, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/marble_bounce.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameMarbleBounce.c"} +{"name": "sky_golf", "split": "train", "game": "sky_golf", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Sky Golf as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nPress action 5 to lock the sweeping aim and charge the shot. Release\nwith actions 0–4 to shoot. A full charge fires automatically. Sand\nweakens the next shot. Water and falling off a platform return the\nball to its previous lie. A gentle landing on the flag clears the hole.\n\nINPUT CHANNEL TABLE\nThe task starts on the three-hole Easy course, grants five shots\nper hole, and awards one point per completed hole. NumPy generates\nthe layouts from the Easy seed values. The port uses rectangular\ncontact bounds and advances directly to the next hole. The six\nchannels show the ball, solid terrain and trees, sand, water, flags,\nand counters. Each action advances up to four frames for up to 400\nactions. Clip the episode score to [0, 3] and divide by 3.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/sky_golf.py`):\n```python\nfrom math import cos, hypot, pi, sin\n\nimport numpy as np\n\n\nFAIRWAY, SAND, WATER, TREE, FLAG = range(5)\n\n\nclass SkyGolfEnvironment:\n score_cap = 3\n hole_seeds = (71, 45, 9)\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.hole = self.ammo = self.steps = 0\n self.held = self.terminal = False\n self._start_hole()\n\n def _start_hole(self):\n course = np.random.default_rng(self.hole_seeds[self.hole])\n self.tiles = []\n\n def platform(x, y, count, tee=False, flag=False):\n kinds = np.full(count, FAIRWAY)\n heights = np.zeros(count)\n for kind, probability in ((TREE, 1), (FAIRWAY, 0.7), (SAND, 0.8), (WATER, 0.5)):\n if course.random() < probability:\n width = int(course.integers(3, count // 2))\n start = int(course.integers(0, count - width))\n kinds[start:start + width] = kind\n if kind == TREE:\n heights[start:start + width] = course.integers(10, 20) + course.integers(-5, 6, width)\n if tee:\n kinds[:5] = FAIRWAY\n if flag:\n width = int(course.integers(3, 6))\n start = count - width - int(course.integers(3))\n kinds[start:start + width] = FAIRWAY\n kinds[start + width // 2] = FLAG\n self.tiles.extend((x + i * 6, y, kind, heights[i]) for i, kind in enumerate(kinds))\n\n width, y = 25, 90\n count = course.integers(1, 3)\n if course.random() < 0.5:\n width = course.integers(12, 20)\n if course.random() < 0.5:\n y = course.integers(30, 70)\n platform(0, y, width, tee=True)\n for index in range(count):\n width = course.integers(9, 20)\n platform(course.integers(150 - 6 * width), course.integers(30, 70),\n width, flag=index == count - 1)\n self.x, self.y = 5., y - 7.\n self.vx = self.vy = self.angle = 0.\n self.direction = -1\n self.base = 1.\n self.previous = self.x, self.y, self.base\n self.power = 0.1\n self.mode = \"aim\"\n self.ammo += 5\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap, release = held and not self.held, self.held and not held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0, release and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _surface(self, x, y):\n for left, bottom, kind, height in self.tiles:\n if left - 2 < x < left + 8 and bottom - 7 < y < bottom + 2:\n return kind\n if kind == TREE and left - 1 < x < left + 7 and bottom - 7 - height < y < bottom - 5:\n return FAIRWAY\n return None\n\n def _advance(self, tap, release):\n if self.mode == \"aim\":\n self.angle += self.direction * 0.05\n if not -pi <= self.angle <= 0:\n self.direction *= -1\n self.angle += self.direction * 0.1\n if tap:\n self.mode = \"power\"\n elif self.mode == \"power\":\n self.power += 0.2\n if self.power > 9 or release:\n speed = self.power * 0.5 * self.base\n self.vx, self.vy = speed * cos(self.angle), speed * sin(self.angle)\n self.mode = \"flight\"\n self.ammo -= 1\n else:\n return self._fly()\n return 0\n\n def _fly(self):\n if self._surface(self.x + self.vx, self.y) is not None or not 2 <= self.x + self.vx <= 148:\n self.vx *= -0.8\n self.vy *= 0.8\n surface = self._surface(self.x, self.y + self.vy)\n if surface is not None:\n factor = {SAND: 0.5, WATER: 0.4}.get(surface, 0.8) if self.vy > 0 else 0.8\n self.vy *= -factor\n self.vx *= factor\n if self.vy < 0 and hypot(self.vx, self.vy) < 0.5:\n if surface == FLAG:\n self.hole += 1\n self.terminal = self.hole == len(self.hole_seeds)\n if not self.terminal:\n self._start_hole()\n return 1\n if surface == WATER:\n self.x, self.y, self.base = self.previous\n else:\n self.base = 0.5 if surface == SAND else 1\n self.previous = self.x, self.y, self.base\n self._rest()\n return 0\n self.x += self.vx\n self.y += self.vy\n self.vx *= 0.98\n self.vy = self.vy * 0.98 + 0.1\n if self.y > 110:\n self.x, self.y, self.base = self.previous\n self._rest()\n return 0\n\n def _rest(self):\n self.mode = \"aim\"\n self.power = 0.1\n self.terminal = self.ammo <= 0\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[int(np.clip(self.y // 10, 0, 9)), int(np.clip(self.x // 15, 0, 9)), 0] = True\n for x, y, kind, height in self.tiles:\n col = int(x // 15)\n channel = 2 if kind == SAND else 3 if kind == WATER else 4 if kind == FLAG else 1\n state[int((y - 3) // 10), col, channel] = True\n if kind == TREE:\n state[int((y - 5 - height) // 10):int((y - 5) // 10) + 1, col, 1] = True\n gauges = (self.steps, self.hole, self.ammo, round(self.power * 50),\n round(-self.angle * 100), self.direction > 0, self.held,\n (\"aim\", \"power\", \"flight\").index(self.mode), self.base < 1)\n for row, value in enumerate(gauges):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 312, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/sky_golf.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameSkyGolf.c"} +{"name": "elastic_hero", "split": "train", "game": "elastic_hero", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Elastic Hero as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nHold action 5 to stretch and rotate your aim. Release with actions\n0–4 to launch in the chosen direction. Bounce off walls and\nplatforms. Rising water slows you down, and it ends the run when\nit reaches the top.\n\nINPUT CHANNEL TABLE\nCrossing the top scores the current water depth rounded down,\nlowers the water relative to the new screen, and generates new\nplatforms. The six 10×10 channels show the hero, platforms, water,\naim, walls, and gauges. Each action advances four frames at fixed\ndifficulty. The conversion checks platform bounces by crossing\ntheir top or bottom surfaces.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 5000] and divide by 5,000. Across 100 seeds without sticky\nactions, idle scored zero and random inputs averaged 33.47.\nA policy that released fully charged upward launches averaged\n492.01 and reached 1,691.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/elastic_hero.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Platform:\n x: float\n y: float\n width: float\n\n\nclass ElasticHeroEnvironment:\n score_cap = 5000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.stretch = 0\n self.pressed = self.terminal = False\n self.x, self.y, self.vx, self.vy = 50.0, 130.0, 0.0, -1.0\n self.angle, self.water = 0.0, 150.0\n self._generate_platforms()\n\n def _generate_platforms(self) -> None:\n self.platforms = []\n for y in range(110, 20, -20):\n width = self.random.uniform(20, 30)\n self.platforms.append(Platform(self.random.uniform(width / 2, 100 - width / 2), y, width))\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n released = self.pressed and not pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(released and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, released: bool) -> int:\n old_y = self.y\n self.x += self.vx\n self.y += self.vy\n drag = 0.99 if self.y < self.water else 0.9\n self.vx *= drag\n self.vy = (self.vy + 0.1) * drag\n if self.pressed:\n self.stretch = min(20, self.stretch + 1)\n self.angle = (self.angle + 0.1) % math.tau\n elif released:\n self.vx = math.cos(self.angle) * self.stretch * 0.5\n self.vy = math.sin(self.angle) * self.stretch * 0.5\n self.stretch = 0\n\n if (self.x < 3 and self.vx < 0) or (self.x > 97 and self.vx > 0):\n self.vx *= -0.8\n reward = 0\n if self.y < 3:\n self.y += 150\n reward = math.floor(self.water)\n self.water += 150\n self._generate_platforms()\n old_y = self.y\n if self.y > 147 and self.vy > 0:\n self.vy *= -0.8\n self.water -= 0.1 + max(0, self.water - 140) * 0.05\n for platform in self.platforms:\n if abs(self.x - platform.x) > platform.width / 2 + 5:\n continue\n top, bottom = platform.y - 6.5, platform.y + 6.5\n if self.vy > 0 and old_y <= top <= self.y:\n self.y, self.vy = top, self.vy * -0.8\n elif self.vy < 0 and self.y <= bottom <= old_y:\n self.y, self.vy = bottom, self.vy * -0.8\n self.terminal = self.water < 0\n return reward\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n\n def mark(x: float, y: float, channel: int) -> None:\n state[min(9, max(0, int(y) // 15)), min(9, max(0, int(x) // 10)), channel] = True\n\n mark(self.x, self.y, 0)\n for platform in self.platforms:\n for x in np.linspace(platform.x - platform.width / 2, platform.x + platform.width / 2, 9):\n mark(x, platform.y, 1)\n for row in range(10):\n state[row, :, 2] = row * 15 + 7.5 >= self.water\n for radius in (self.stretch / 2, self.stretch):\n mark(self.x + radius * math.cos(self.angle), self.y + radius * math.sin(self.angle), 3)\n state[:, (0, 9), 4] = True\n state[9, :, 4] = True\n for row, value in enumerate((self.steps, self.stretch, round(self.angle * 80),\n round(self.water), round(self.vx * 10) + 256, round(self.vy * 10) + 256)):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 313, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/elastic_hero.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameElasticHero.c"} +{"name": "tarutobi", "split": "train", "game": "tarutobi", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Tarutobi as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nAction 1 moves the steering cursor left, and action 3 moves it right.\nOther actions keep the cursor still. The runner accelerates toward\nthe cursor, with weaker steering in the air. Grounded contact with\na barrel launches a jump. Barrels are dangerous while airborne.\nEach barrel that passes behind the runner scores the current\nmultiplier and increases it. Running on the ground resets it.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show the runner, safe barrels, dangerous\nbarrels, ground, steering cursor, and counters. The port replaces\npointer input with a directional cursor, fixes difficulty, and\napproximates sprite collisions with rectangles. Each action advances\nup to four frames over 400 actions. Clip scores to [0, 100] and\ndivide by 100.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/tarutobi.py`):\n```python\nfrom dataclasses import dataclass\n\nimport numpy as np\n\n\n@dataclass\nclass Barrel:\n x: float\n speed: float\n scored: bool = False\n\n\nclass TarutobiEnvironment:\n score_cap = 100\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x = self.y = self.cursor = 30.\n self.vx = self.vy = 0.\n self.multiplier = 1\n self.steps = self.action = 0\n self.airborne = True\n self.terminal = False\n self.barrels = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self):\n self.cursor = min(120, max(0, self.cursor + 3 * ((self.action == 3) - (self.action == 1))))\n if self.random.random() < 0.01:\n self.barrels.append(Barrel(123, self.random.uniform(0.4, 0.8)))\n reward = 0\n dangerous = self.airborne\n for barrel in self.barrels:\n barrel.x -= barrel.speed\n if not barrel.scored and barrel.x < self.x:\n reward += self.multiplier\n self.multiplier += 1\n barrel.scored = True\n self.barrels = [barrel for barrel in self.barrels if barrel.x > 0]\n if self.airborne:\n self.vy += 0.1\n if self.y > 47:\n self.airborne = False\n self.y, self.vy = 47, 0.\n else:\n self.vx *= 0.95\n self.vy *= 0.95\n self.multiplier = 1\n if not 0 <= self.x <= 120:\n self.x = min(120, max(0, self.x))\n self.vx = 0.\n offset = min(7, max(-7, self.cursor - self.x))\n self.vx += offset * (0.004 if self.airborne else 0.01)\n self.x += self.vx\n self.y += self.vy\n if any(abs(barrel.x - self.x) < 5.5 for barrel in self.barrels) and abs(47 - self.y) < 5.5:\n if dangerous:\n self.terminal = True\n else:\n self.airborne = True\n self.y, self.vy = 42, -1.2 - abs(self.vx)\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n row = int(np.clip(self.y // 6, 0, 9))\n col = int(np.clip(self.x // 12, 0, 9))\n state[row, col, 0] = True\n for barrel in self.barrels:\n if 0 <= barrel.x < 120:\n state[7, int(barrel.x // 12), 2 if self.airborne else 1] = True\n state[8:, :, 3] = True\n state[9, min(9, int(self.cursor // 12)), 4] = True\n values = (self.steps, self.airborne, self.multiplier, self.action,\n round((self.vx + 4) * 50), round((self.vy + 4) * 50))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(int(np.clip(value, 0, 511)) & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 314, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/tarutobi.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/tarutobi/main.js"} +{"name": "qbert", "split": "train", "game": "qbert", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Qbert as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES\nThis conversion preserves the 28-cube pyramid, four diagonal hop directions, two flying discs,\nfive levels with four rounds each, all five manual color-transition rules, four starting Q*berts,\nscheduled bonus lives, red and purple balls, Coily's pursuit, Sam's color reversion, the green\nball's freeze, falling deaths, and disc-based Coily luring. Creature speed increases by level.\n\nACTION MAPPING\n0: wait\n1: hop up-left\n2: hop up-right\n3: hop down-right\n4: hop down-left\n5: unused\n\nINPUT CHANNEL TABLE\n0: Q*bert\n1: balls, Sam, green ball, and Coily\n2: first/intermediate cube color bit\n3: second/destination color bit and discs\n4: previous Q*bert and creature positions\n5: rewarded cubes, exact level/round/lives/steps/freeze, caught identities, discs, and typed creature positions\n\nSCORING, TERMINATION, AND HORIZON\nEach round has 28 first-time destination changes worth 25 (700), Sam worth 300, a green ball worth\n100, Coily worth 500, and the 3,100 completion bonus: 4,700. Across the finite 20-round campaign,\n`score_cap = 20 × 4,700 = 94,000`. Normalization is\n`min(max(raw_score, 0), 94_000) / 94_000`.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/qbert.py`):\n```python\nimport numpy as np\n\n\nCUBES = tuple((row, column) for row in range(7) for column in range(row + 1))\nDIRECTIONS = {1: (-1, -1), 2: (-1, 0), 3: (1, 1), 4: (1, 0)}\n\n\nclass QbertEnvironment:\n \"\"\"Twenty-round color pyramid campaign with balls, Sam, Coily, and discs.\"\"\"\n\n score_cap = 94_000.0\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 5_000):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = horizon\n self.random = np.random.RandomState()\n self.seed(0)\n self.reset()\n\n @classmethod\n def normalize_score(cls, raw_score: float) -> float:\n return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap\n\n def seed(self, seed: int) -> None:\n self.random.seed(seed)\n\n def reset(self) -> None:\n self.level = 0\n self.round = 0\n self.lives = 4\n self.score = 0.0\n self.steps = 0\n self.last_action = 0\n self.terminal = False\n self.bonus_rounds: set[int] = set()\n self._start_round()\n\n def _start_round(self) -> None:\n self.player = [0, 0]\n self.previous_player = self.player.copy()\n self.colors = {cube: 0 for cube in CUBES}\n self.rewarded_cubes: set[tuple[int, int]] = set()\n self.discs = {\"left\", \"right\"}\n self.enemies = {\n \"red\": [0, 0],\n \"purple\": [0, 0],\n \"sam\": [0, 0],\n \"green\": [0, 0],\n }\n self.previous_enemies = {kind: position.copy() for kind, position in self.enemies.items()}\n self.caught_rewards: set[str] = set()\n self.freeze_timer = 0\n self.round_steps = 0\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n if self.random.rand() < self.sticky_action_prob:\n action = self.last_action\n self.last_action = action\n self.previous_player = self.player.copy()\n self.previous_enemies = {kind: position.copy() for kind, position in self.enemies.items()}\n campaign_round_before = self.level * 4 + self.round\n reward = self._move_player(action)\n if self.level * 4 + self.round == campaign_round_before and not self.terminal:\n if self.freeze_timer == 0:\n self._move_enemies()\n reward += self._resolve_collisions()\n self.score += reward\n self.steps += 1\n self.round_steps += 1\n self.freeze_timer = max(0, self.freeze_timer - 1)\n if self.steps >= self.horizon:\n self.terminal = True\n return reward, self.terminal\n\n def _move_player(self, action: int) -> float:\n if action not in DIRECTIONS:\n return 0.0\n row_delta, column_delta = DIRECTIONS[action]\n target = [self.player[0] + row_delta, self.player[1] + column_delta]\n if tuple(target) not in CUBES:\n disc = None\n if self.player == [3, 0] and action == 1:\n disc = \"left\"\n elif self.player == [3, 3] and action == 2:\n disc = \"right\"\n if disc in self.discs:\n self.discs.remove(disc)\n self.player = [0, 0]\n if \"coily\" in self.enemies:\n del self.enemies[\"coily\"]\n if \"coily\" not in self.caught_rewards:\n self.caught_rewards.add(\"coily\")\n return 500.0\n return 0.0\n self._lose_life(fell=True)\n return 0.0\n self.player = target\n reward = self._change_cube(tuple(target))\n if self._round_complete():\n reward += 3_100.0\n self._advance_round()\n return reward\n\n def _change_cube(self, cube: tuple[int, int]) -> float:\n color = self.colors[cube]\n if self.level == 0:\n color = 1\n elif self.level == 1:\n color = min(2, color + 1)\n elif self.level == 2:\n color = 0 if color == 1 else 1\n elif self.level == 3:\n color = 1 if color == 2 else color + 1\n else:\n color = (color + 1) % 3\n self.colors[cube] = color\n if color == self._destination_color() and cube not in self.rewarded_cubes:\n self.rewarded_cubes.add(cube)\n return 25.0\n return 0.0\n\n def _destination_color(self) -> int:\n return 1 if self.level in (0, 2) else 2\n\n def _round_complete(self) -> bool:\n destination = self._destination_color()\n return all(color == destination for color in self.colors.values())\n\n def _move_enemies(self) -> None:\n interval = max(1, 4 - self.level // 2)\n if self.round_steps % interval:\n return\n for kind in list(self.enemies):\n position = self.enemies[kind]\n if kind == \"coily\":\n self.enemies[kind] = self._chase_step(position)\n continue\n if position[0] >= 6:\n if kind == \"purple\":\n del self.enemies[kind]\n self.enemies[\"coily\"] = [6, position[1]]\n else:\n del self.enemies[kind]\n continue\n choose_right = (self.round_steps + len(kind) + self.round) % 2\n position[0] += 1\n position[1] += choose_right\n if kind == \"sam\":\n self.colors[tuple(position)] = self._reverted_color(self.colors[tuple(position)])\n\n def _chase_step(self, position: list[int]) -> list[int]:\n candidates = []\n for row_delta, column_delta in DIRECTIONS.values():\n target = (position[0] + row_delta, position[1] + column_delta)\n if target in CUBES:\n distance = abs(target[0] - self.player[0]) + abs(target[1] - self.player[1])\n candidates.append((distance, target))\n return list(min(candidates)[1]) if candidates else position\n\n def _reverted_color(self, color: int) -> int:\n return max(0, color - 1)\n\n def _resolve_collisions(self) -> float:\n reward = 0.0\n for kind in list(self.enemies):\n if self.enemies[kind] != self.player:\n continue\n if kind == \"sam\":\n if kind not in self.caught_rewards:\n reward += 300.0\n self.caught_rewards.add(kind)\n del self.enemies[kind]\n elif kind == \"green\":\n if kind not in self.caught_rewards:\n reward += 100.0\n self.caught_rewards.add(kind)\n self.freeze_timer = 4\n del self.enemies[kind]\n else:\n self._lose_life(fell=False)\n break\n return reward\n\n def _lose_life(self, fell: bool) -> None:\n self.lives -= 1\n if self.lives <= 0:\n self.terminal = True\n return\n if fell:\n self.player = [0, 0]\n\n def _advance_round(self) -> None:\n completed = self.level * 4 + self.round + 1\n if completed == 5 or (completed > 5 and (completed - 5) % 4 == 0):\n self.lives += 1\n self.bonus_rounds.add(completed)\n self.round += 1\n if self.round >= 4:\n self.round = 0\n self.level += 1\n if self.level >= 5:\n self.terminal = True\n else:\n self._start_round()\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n state[self.player[0] + 1, self.player[1] + 1, 0] = True\n state[self.previous_player[0] + 1, self.previous_player[1] + 1, 4] = True\n for kind, position in self.enemies.items():\n state[position[0] + 1, position[1] + 1, 1] = True\n if kind in self.previous_enemies:\n previous = self.previous_enemies[kind]\n state[previous[0] + 1, previous[1] + 1, 4] = True\n for cube, color in self.colors.items():\n row, column = cube\n state[row + 1, column + 1, 2] = color >= 1\n state[row + 1, column + 1, 3] = color >= 2\n for cube in self.rewarded_cubes:\n row, column = cube\n state[row + 1, column + 1, 5] = True\n state[4, 0, 3] = \"left\" in self.discs\n state[4, 5, 3] = \"right\" in self.discs\n cube_gauge_cells = {(row + 1, column + 1) for row, column in CUBES}\n free_cells = [(row, column) for row in range(10) for column in range(10) if (row, column) not in cube_gauge_cells]\n gauge_bits = []\n for bit in range(3):\n gauge_bits.append(bool(self.level & (1 << bit)))\n for bit in range(2):\n gauge_bits.append(bool(self.round & (1 << bit)))\n for bit in range(4):\n gauge_bits.append(bool(self.lives & (1 << bit)))\n for bit in range(13):\n gauge_bits.append(bool(self.steps & (1 << bit)))\n for bit in range(3):\n gauge_bits.append(bool(self.freeze_timer & (1 << bit)))\n gauge_bits.extend(kind in self.caught_rewards for kind in (\"sam\", \"green\", \"coily\"))\n gauge_bits.extend((\"left\" in self.discs, \"right\" in self.discs))\n for kind in (\"red\", \"purple\", \"sam\", \"green\", \"coily\"):\n position = self.enemies.get(kind)\n code = 31 if position is None else position[0] * 7 + position[1]\n for bit in range(5):\n gauge_bits.append(bool(code & (1 << bit)))\n for cell, value in zip(free_cells, gauge_bits):\n state[*cell, 5] = value\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 315, "family": "atari_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/qbert.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": null} +{"name": "wiper", "split": "train", "game": "wiper", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Wiper as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nThe blade sweeps automatically. Tap action 5 to jump to the\npreviewed angle and reverse the sweep. Release with any other\naction before tapping again. Nearby raindrops can merge into\nfaster, heavier drops. Clearing a drop scores its size minus one.\nA drop reaching the bottom ends the run.\n\nINPUT CHANNEL TABLE\nSix Boolean channels show small drops, merged drops, the blade,\nits destination on a tap, low drops, and counters. The port fixes\ndifficulty and uses distance to the blade segment to approximate\ncollisions. Each action advances up to four frames over 400 actions.\nClip episode scores to [0, 150] and divide by 150.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/wiper.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import ceil, cos, hypot, pi, sin, sqrt\n\nimport numpy as np\n\n\n_LEFT, _RIGHT = -4 * pi / 5, -pi / 5\n\n\n@dataclass\nclass Drop:\n x: float\n y: float\n size: int = 2\n\n\nclass WiperEnvironment:\n score_cap = 150\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.angle, self.direction = _LEFT, 1\n self.drops = []\n self.timer = self.action = self.steps = 0\n self.terminal = False\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n swing = self.action == 5 and previous != 5\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(swing and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _target(self):\n if self.angle > -pi / 3:\n return _LEFT\n if self.angle < -2 * pi / 3:\n return _RIGHT\n return _RIGHT if self.direction > 0 else _LEFT\n\n def _advance(self, swing):\n self.angle += self.direction * 0.05\n if (self.angle > _RIGHT and self.direction > 0) or (self.angle < _LEFT and self.direction < 0):\n self.direction *= -1\n if swing:\n self.angle = self._target()\n self.direction *= -1\n self.timer -= 1\n if self.timer < 0:\n self.drops.append(Drop(self.random.uniform(10, 90), self.random.uniform(0, 20)))\n self.timer = 10\n\n dx, dy = cos(self.angle), sin(self.angle)\n reward = 0\n live = dict(enumerate(self.drops))\n for index, drop in enumerate(self.drops):\n if index not in live:\n continue\n before = _blade_distance(drop, dx, dy)\n absorbed = False\n for other in live.values():\n if other.y < drop.y and hypot(drop.x - other.x, drop.y - other.y) < 2 * sqrt(drop.size + other.size):\n other.size += drop.size\n other.x = (other.x + drop.x) / 2\n absorbed = True\n if absorbed:\n del live[index]\n continue\n drop.y += sqrt(drop.size - 1.9) * 0.3\n if before <= 3 + sqrt(drop.size) or _blade_distance(drop, dx, dy) <= 3 + sqrt(drop.size) / 2:\n reward += ceil(drop.size - 1)\n del live[index]\n elif drop.y > 99:\n self.terminal = True\n self.drops = list(live.values())\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for drop in self.drops:\n col = int(drop.x // 10)\n row = min(9, int(drop.y // 10))\n state[row, col, 0 if drop.size == 2 else 1] = True\n if drop.y >= 85:\n state[row, col, 4] = True\n for channel, angle in ((2, self.angle), (3, self._target())):\n for radius in range(25, 62):\n x, y = 50 + radius * cos(angle), 110 + radius * sin(angle)\n if 0 <= x < 100 and 0 <= y < 100:\n state[int(y // 10), int(x // 10), channel] = True\n values = (self.steps, self.action, self.direction > 0, self.timer, round((self.angle + pi) * 128))\n for row, value in enumerate(values):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n\ndef _blade_distance(drop, dx, dy):\n x, y = drop.x - 50, drop.y - 110\n along = min(61.2, max(25.2, x * dx + y * dy))\n return hypot(x - along * dx, y - along * dy)\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 316, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/wiper.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/wiper/main.js"} +{"name": "pump_press", "split": "train", "game": "pump_press", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Pump Press as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to fire. Holding it accelerates the ship. Actions 0–4\nrelease. Shots temporarily inflate enemies and destroy them after\nenough hits. An uninflated enemy touching the ship ends the episode.\n\nShoot a rocket to send it left. It picks up enemies it passes and\nscores `n × (n + 1) / 2` when it reaches the left edge with `n` enemies.\n\nINPUT CHANNEL TABLE\nSix channels show the ship, shot, rocket, uninflated enemies, inflated\nenemies, and counters. The rocket has a second marker while launched.\nAttached enemies appear one row above free enemies. The port uses fixed\ndifficulty and horizontal bounds for sprite collisions. Each action\nadvances up to four frames, with a 400-action horizon. Normalize the\nepisode score by clipping to [0, 200] and dividing by 200.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/pump_press.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import ceil\n\nimport numpy as np\n\n\n@dataclass\nclass Enemy:\n x: float = 205\n size: float = 0\n attachment: float | None = None\n\n\nclass PumpPressEnvironment:\n score_cap = 200\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.ship = 100.0\n self.speed = 1.0\n self.shot = self.rocket = None\n self.shot_range = self.steps = 0\n self.held = self.launched = self.terminal = False\n self.enemy_distance, self.rocket_distance = 0.0, 30.0\n self.enemies = []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0.0, True\n held = self.held if self.random.random() < self.sticky_action_prob else action == 5\n tap = held and not self.held\n self.held = held\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n self.ship += self.speed\n self.speed += ((1 if self.held else 0.5) - self.speed) * 0.1\n scroll = 0.1 + max(0, self.ship - 100) * 0.1\n self.ship -= scroll\n if self.shot is None and tap:\n self.shot = self.ship + 6\n self.shot_range = 60\n shot = self.shot\n if shot is not None:\n shot += 3 - scroll\n self.shot_range -= 3\n self.shot = shot if self.shot_range >= 0 else None\n self.enemy_distance -= scroll\n if self.enemy_distance < 0:\n self.enemies.append(Enemy())\n self.enemy_distance = self.random.uniform(33, 43)\n reward = 0\n if self.rocket is None:\n self.rocket_distance -= scroll\n if self.rocket_distance < 0:\n self.rocket = 205\n self.launched = False\n self.rocket_distance = 100\n else:\n self.rocket -= scroll + int(self.launched)\n if not self.launched and shot is not None and abs(self.rocket - shot) < 5.5:\n self.launched = True\n self.shot = None\n if self.rocket < 5:\n count = sum(enemy.attachment is not None for enemy in self.enemies)\n reward = count * (count + 1) // 2\n self.rocket = None\n self.launched = False\n remaining = []\n for enemy in self.enemies:\n if enemy.attachment is not None:\n if self.rocket is not None:\n enemy.x = self.rocket + enemy.attachment\n remaining.append(enemy)\n continue\n if enemy.size > 0:\n enemy.size = max(0, enemy.size - 0.02)\n else:\n enemy.x += 0.5 if enemy.x < self.ship else -0.5\n enemy.x -= scroll\n radius = ceil(enemy.size) * 2 + 2\n if shot is not None and abs(enemy.x - shot) < radius + 3:\n self.shot = None\n enemy.size = ceil(enemy.size) + 1\n if enemy.size > 3:\n continue\n if self.launched and abs(enemy.x - self.rocket) < radius + 2.5:\n enemy.attachment = self.random.uniform(-6, -2)\n if enemy.size == 0 and abs(enemy.x - self.ship) < radius + 3:\n self.terminal = True\n if enemy.x >= -5:\n remaining.append(enemy)\n self.enemies = remaining\n return reward\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n for x, row, channel in ((self.ship, 5, 0), (self.shot, 5, 1),\n (self.rocket, 5, 2), (self.rocket if self.launched else None, 4, 2)):\n if x is not None and 0 <= x < 200:\n state[row, int(x // 20), channel] = True\n for enemy in self.enemies:\n if 0 <= enemy.x < 200:\n row = 4 if enemy.attachment is not None else 5\n state[row, int(enemy.x // 20), 3 + int(enemy.size > 0)] = True\n for row, value in enumerate((self.steps, round(self.speed * 100),\n max(0, self.shot_range), self.held)):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 317, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/pump_press.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/pumppress/main.js"} +{"name": "barge_hop", "split": "train", "game": "barge_hop", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Barge Hop as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nPress action 5 from a dock or barge to jump right. Hold it to reduce\ngravity and travel farther. Release with actions 0–4 before pressing\nagain. Land on a barge to score one point and ride it. Falling in the\nwater returns the runner to the left dock while the clock keeps\nrunning. Reaching the far dock awards up to 120 points based on time\nleft and starts a harder round with up to 500 time units restored.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the runner, docks, water, barges, grounded\nstatus, and barge direction plus timer and held-input gauges. Each\naction advances four simulation frames. The conversion starts barges\nin three jittered positions and uses downward crossings of platform\ntops for landings in place of the source's projected collision box.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends at timeout or 400 actions. The normalization cap is a\nfixed 1,000 raw points. Clip to [0, 1000] and divide by 1000.\n\nAcross 100 seeded episodes without sticky actions, idle scored zero.\nRandom hold and release averaged 233.57, reached 545, and crossed the\nriver at least once in 94 episodes. Jumping as soon as grounded and\nholding throughout each jump averaged 398.37 and reached 643.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/barge_hop.py`):\n```python\nfrom dataclasses import dataclass\nfrom itertools import combinations\nimport math\n\nimport numpy as np\n\n\nHORIZON = 400\nTIME_LIMIT = 1000\nFRAMES_PER_STEP = 4\n\n\n@dataclass\nclass Barge:\n x: float\n width: float\n velocity: float\n phase: float\n frequency: float\n amplitude: float\n top: float = 65\n\n\nclass BargeHopEnvironment:\n score_cap = 1000\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, HORIZON)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = self.frame = self.level = 0\n self.pressed = self.terminal = False\n self.remaining = float(TIME_LIMIT)\n self._setup_round()\n\n def _setup_round(self) -> None:\n speed = 0.175 * (1 + math.sqrt(self.level * 0.3))\n self.barges = [\n Barge(\n center + self.random.uniform(-4, 4),\n float(self.random.integers(20, 29)),\n float(self.random.choice((-1, 1))) * speed * self.random.uniform(0.9, 1.5),\n self.random.uniform(0, math.tau),\n self.random.uniform(0.02, 0.05),\n self.random.uniform(1, 2),\n )\n for center in (32, 75, 118)\n ]\n self._return_to_dock()\n\n def _return_to_dock(self) -> None:\n self.x, self.feet = 8.0, 63.0\n self.vx = self.vy = 0.0\n self.grounded = True\n self.support: Barge | None = None\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n jump = pressed and not self.pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for frame in range(FRAMES_PER_STEP):\n reward += self._advance_frame(jump and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _move_barges(self) -> None:\n for barge in self.barges:\n barge.x += barge.velocity\n barge.top = 65 - barge.amplitude * (\n 1 - math.sin(self.frame * barge.frequency + barge.phase)\n )\n low, high = 15 + barge.width / 2, 135 - barge.width / 2\n if barge.x <= low:\n barge.x, barge.velocity = low, abs(barge.velocity)\n elif barge.x >= high:\n barge.x, barge.velocity = high, -abs(barge.velocity)\n for first, second in combinations(self.barges, 2):\n gap = (first.width + second.width) / 2 - (second.x - first.x)\n if gap <= 0:\n continue\n first.x -= gap / 2\n second.x += gap / 2\n if first.velocity > 0:\n first.velocity *= -1\n if second.velocity < 0:\n second.velocity *= -1\n\n def _advance_frame(self, jump: bool) -> int:\n difficulty = 1 + self.level / 5\n self.frame += 1\n self.remaining -= math.sqrt(difficulty)\n if self.remaining <= 0:\n self.terminal = True\n return 0\n old_support_x = self.support.x if self.support is not None else 0\n self._move_barges()\n if self.grounded:\n if self.support is not None:\n self.x += self.support.x - old_support_x\n self.feet = self.support.top\n if not jump:\n return 0\n self.grounded = False\n self.support = None\n self.vx = 0.7 * math.sqrt(difficulty)\n self.vy = -2.1 * math.sqrt(difficulty)\n previous_feet = self.feet\n self.vy += 0.15 * (0.5 if self.pressed else 1.5) * difficulty\n self.x += self.vx\n self.feet += self.vy\n if self.vy < 0:\n return 0\n if self.x >= 133 and previous_feet <= 63 <= self.feet:\n reward = int(120 * self.remaining / TIME_LIMIT)\n self.level += 1\n self.remaining = min(TIME_LIMIT, self.remaining + TIME_LIMIT / 2)\n self._setup_round()\n return reward\n for barge in self.barges:\n if abs(self.x - barge.x) <= barge.width / 2 + 3 and previous_feet <= barge.top <= self.feet:\n self.support = barge\n self.grounded = True\n self.feet = barge.top\n self.vx = self.vy = 0\n return 1\n if self.feet >= 71:\n self._return_to_dock()\n return 0\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n column = min(9, int(self.x / 15))\n row = int((self.feet - 4) / 10)\n state[row, column, 0] = True\n state[row, column, 4] = self.grounded\n state[6, (0, 9), 1] = True\n state[7:9, :, 2] = True\n for barge in self.barges:\n left = max(0, int((barge.x - barge.width / 2) / 15))\n right = min(9, int((barge.x + barge.width / 2) / 15))\n state[int(barge.top / 10), left:right + 1, 3] = True\n state[int(barge.top / 10), left:right + 1, 5] |= barge.velocity < 0\n state[9, :math.ceil(max(0, self.remaining) / 100), 5] = True\n state[8, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 318, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/barge_hop.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/src/games/gameBargeHop.c"} +{"name": "i_slash", "split": "train", "game": "i_slash", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays I Slash as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nPress and release action 5 once to arm the slash. Then hold\naction 5 to slash and repeat. Actions 0–4 release the button.\nThe first slash travels twice the distance to the nearest\nenemy. Continuing to hold repeats that distance.\n\nCrossing one enemy scores the current multiplier and raises\nit by one. Crossing a second enemy on the same slash causes\nknockback and lowers the multiplier. An enemy reaching you\nwhile waiting also knocks you back. Moving off the left edge\nends the run.\n\nINPUT CHANNEL TABLE\nThe six 10×10 channels show the player, enemies, slash,\nknockback, floor, and gauges. The conversion uses fixed\ndifficulty and four frames per action. At most 400 actions\nare allowed. Raw scores are clipped to [0, 500] and divided\nby 500.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/i_slash.py`):\n```python\nimport numpy as np\n\n\nclass ISlashEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.x, self.knockback, self.slash_distance, self.hit_x = 10.0, 0.0, 0.0, 0.0\n self.spawn_distance = 0.0\n self.steps = self.slash_timer = 0\n self.multiplier = 1\n self.ready = self.pressed = self.terminal = False\n self.enemies: list[float] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n self.ready |= self.pressed and not pressed\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self) -> int:\n scroll = (self.x - 30) * 0.05\n self.spawn_distance -= scroll + (self.slash_timer == 0)\n if not self.enemies or self.spawn_distance <= 0:\n spacing = self.random.uniform(15, 30)\n count = self.random.integers(3, 10)\n self.enemies.extend(203 + i * spacing for i in range(count))\n self.spawn_distance = spacing * count + self.random.uniform(0, 30)\n self.x -= scroll + self.knockback\n if self.x < 0:\n self.terminal = True\n return 0\n self.knockback *= 0.9\n if self.knockback > 1:\n self.hit_x -= scroll\n slashing = self.ready and self.pressed\n reward = 0\n if slashing and self.knockback < 1 and not self.slash_timer:\n self.slash_distance = (self.enemies[0] - self.x) * 2\n reward += self._slash()\n if not self.slash_timer:\n if self.enemies and self.enemies[0] < self.x:\n self._hit(0)\n else:\n self.slash_timer -= 1\n if not self.slash_timer and slashing and self.enemies:\n reward += self._slash()\n drift = scroll + (self.slash_timer == 0)\n self.enemies = [x - drift for x in self.enemies]\n return reward\n\n def _slash(self) -> int:\n self.x += self.slash_distance\n crossed = self.enemies[0] < self.x\n overshot = len(self.enemies) > 1 and self.enemies[1] < self.x\n if overshot:\n self._hit(1)\n else:\n self.slash_timer = 10 if crossed else 0\n if crossed:\n self.enemies.pop(0)\n if not overshot:\n reward = self.multiplier\n self.multiplier += 1\n return reward\n return 0\n\n def _hit(self, index: int) -> None:\n self.hit_x = self.enemies[index]\n self.knockback = (self.x - self.hit_x + 9) * 0.25\n self.x = self.hit_x - 6\n self.slash_timer = 0\n self.multiplier = max(1, self.multiplier - 1)\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n col = min(9, max(0, int(self.x // 20)))\n state[7, col, 0] = True\n for x in self.enemies:\n if 0 <= x < 200:\n state[7, int(x // 20), 1] = True\n if self.slash_timer:\n left = max(0, min(9, int((self.x - self.slash_distance) // 20)))\n state[7, min(left, col):max(left, col) + 1, 2] = True\n if self.knockback > 1:\n hit = min(9, max(0, int(self.hit_x // 20)))\n state[7, min(hit, col):max(hit, col) + 1, 3] = True\n state[8:, :, 4] = True\n for row, value in enumerate((self.steps, self.multiplier, self.slash_timer,\n min(511, round(self.knockback * 10)))):\n for bit in range(9):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, :2, 5] = self.pressed, self.ready\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 319, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/i_slash.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/islash/main.js"} +{"name": "smoke_g", "split": "train", "game": "smoke_g", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays Smoke G as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nMove the grenade cursor with actions 1–4 (left, up, right, down).\nTap action 5 to throw, then release with another action. Grenades\ncreate expanding smoke rings that interrupt line of sight. The\ndefender automatically aims at visible enemies. Each enemy hit\nscores one point. Enemy fire or an enemy reaching the bottom ends\nthe episode.\n\nINPUT CHANNEL TABLE\nThe six channels show the defender, cursor, enemies, smoke, grenades,\nand counters. The port replaces pointer movement with directional\nactions, fixes difficulty, and approximates firing and visibility\nwith geometric tests. Each action advances up to four frames over a\n400-action horizon. Clip scores to [0, 20] and divide by 20.\n\nSCORING, TERMINATION, AND HORIZON\nUse the environment's exact score_cap, normalize_score, terminal conditions, and horizon from the source below.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/smoke_g.py`):\n```python\nfrom dataclasses import dataclass\nfrom math import atan2, cos, hypot, pi, sin\n\nimport numpy as np\n\n\n@dataclass\nclass Grenade:\n x: float\n y: float\n tx: float\n ty: float\n age: int = 0\n\n\n@dataclass\nclass Smoke:\n x: float\n y: float\n radius: float = 0\n growing: bool = True\n\n\n@dataclass\nclass Enemy:\n x: float\n y: float\n angle: float\n\n\nclass SmokeGEnvironment:\n score_cap = 20\n moves = ((0, 0), (-1, 0), (0, -1), (1, 0), (0, 1), (0, 0))\n\n def __init__(self, sticky_action_prob=0.1, horizon=400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed):\n self.random = np.random.default_rng(seed)\n\n def reset(self):\n self.x, self.y = 50, 45\n self.angle = -pi / 2\n self.steps = self.action = self.side_count = 0\n self.side = 1\n self.distance = 0.\n self.terminal = False\n self.grenades, self.smoke, self.enemies = [], [], []\n\n @classmethod\n def normalize_score(cls, score):\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action):\n if self.terminal:\n return 0., True\n previous = self.action\n if self.random.random() >= self.sticky_action_prob:\n self.action = action\n tap = self.action == 5 and previous != 5\n self.steps += 1\n reward = 0\n for frame in range(4):\n reward += self._advance(tap and frame == 0)\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance(self, tap):\n dx, dy = self.moves[self.action]\n self.x = min(99, max(0, self.x + 3 * dx))\n self.y = min(99, max(0, self.y + 3 * dy))\n if tap and len(self.smoke) < 9:\n self.grenades.append(Grenade(50, 90, self.x, self.y))\n for grenade in self.grenades:\n grenade.age += 1\n grenade.x += (grenade.tx - grenade.x) * 0.1\n grenade.y += (grenade.ty - grenade.y) * 0.1 + cos(grenade.age * pi * 4 / 30) + 0.1\n if grenade.age > 30:\n self.smoke.append(Smoke(grenade.tx, grenade.ty))\n self.grenades = [grenade for grenade in self.grenades if grenade.age <= 30]\n for smoke in self.smoke:\n smoke.y += 0.1\n if smoke.growing:\n smoke.radius += (10 - smoke.radius) * 0.2\n if smoke.radius > 9:\n smoke.radius, smoke.growing = 10, False\n else:\n smoke.radius *= 0.995\n self.smoke = [smoke for smoke in self.smoke if smoke.growing or smoke.radius >= 2]\n if not self.enemies:\n self.distance = 0\n self.distance -= 0.1\n if self.distance < 0:\n self.side_count -= 1\n if self.side_count < 0:\n self.side *= -1\n self.side_count = self.random.uniform(1, 5)\n self.distance += 7\n x = 50 + self.random.uniform(0, 40) * self.side\n self.enemies.append(Enemy(x, -3, atan2(-93, x - 50) + self.random.uniform(-0.2, 0.2)))\n self.distance += self.random.uniform(5, 9)\n visible = [enemy for enemy in self.enemies\n if hypot(enemy.x - 50, enemy.y - 90) < 99 and not self._blocked(enemy)]\n if visible:\n target = min(visible, key=lambda enemy: hypot(enemy.x - 50, enemy.y - 90))\n self.angle = self._turn(self.angle, atan2(target.y - 90, target.x - 50), 0.012)\n reward = 0\n remaining = []\n for enemy in self.enemies:\n enemy.y += 0.1\n if not self._blocked(enemy):\n enemy.angle = self._turn(enemy.angle, atan2(90 - enemy.y, 50 - enemy.x), 0.008)\n self.terminal |= self._ray_hit(enemy.x, enemy.y, enemy.angle, 50, 90, 50)\n if self._ray_hit(50, 90, self.angle, enemy.x, enemy.y, 55):\n reward += 1\n else:\n self.terminal |= enemy.y > 99\n remaining.append(enemy)\n self.enemies = remaining\n return reward\n\n def _blocked(self, enemy):\n dx, dy = enemy.x - 50, enemy.y - 90\n length = dx * dx + dy * dy\n for smoke in self.smoke:\n t = min(1, max(0, ((smoke.x - 50) * dx + (smoke.y - 90) * dy) / max(length, 1e-9)))\n nearest = hypot(smoke.x - 50 - t * dx, smoke.y - 90 - t * dy)\n farthest = max(hypot(smoke.x - 50, smoke.y - 90), hypot(smoke.x - enemy.x, smoke.y - enemy.y))\n if nearest <= smoke.radius + 1 and farthest >= smoke.radius - 1:\n return True\n return False\n\n @staticmethod\n def _turn(angle, target, speed):\n difference = (target - angle + pi) % (2 * pi) - pi\n return angle + min(speed, max(-speed, difference))\n\n @staticmethod\n def _ray_hit(x, y, angle, tx, ty, reach):\n dx, dy = tx - x, ty - y\n along = dx * cos(angle) + dy * sin(angle)\n across = dy * cos(angle) - dx * sin(angle)\n return -4 < along < reach + 4 and abs(across) < 4\n\n def state(self):\n state = np.zeros((10, 10, 6), dtype=bool)\n state[9, 5, 0] = True\n state[self.y // 10, self.x // 10, 1] = True\n for enemy in self.enemies:\n if 0 <= enemy.y < 100:\n state[int(enemy.y // 10), int(enemy.x // 10), 2] = True\n rows, cols = np.ogrid[5:100:10, 5:100:10]\n for smoke in self.smoke:\n state[:, :, 3] |= abs(np.hypot(cols - smoke.x, rows - smoke.y) - smoke.radius) < 6\n for grenade in self.grenades:\n if 0 <= grenade.y < 100:\n state[int(grenade.y // 10), int(grenade.x // 10), 4] = True\n values = (self.steps, self.action, round((self.angle % (2 * pi)) * 100))\n for row, value in enumerate(values):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 320, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/smoke_g.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/smokeg/main.js"} +{"name": "d_laser", "split": "train", "game": "d_laser", "source": "synth", "prompt": "Write from scratch the weights of a policy network that plays D Laser as well as possible.\n\nThere is no training, data, loss, gradients, fine-tuning, code execution, calculator, or environment feedback. This is one response. Briefly describe the strategy and hidden units, then provide the weights in the final `edits` code block.\n\nGAME RULES AND ACTION MAPPING\nTap action 5 to reverse direction and hold it to stop. Release with\nactions 0–4 to climb. Lasers fire downward in ten lanes. Settled\nshields stop the laser in their lane. A hit knocks you down and\nresets the laser cycle. Falling off the bottom ends the run.\n\nINPUT CHANNEL TABLE\nCompleting a laser cycle without a hit scores the distance climbed\nduring that cycle raised to the power 1.5, multiplied by 0.1 and\nrounded up. The six 10×10 channels show the runner, settled shields,\nmoving shields, lasers, heading, and gauges. Each action advances\nfour frames at fixed difficulty. The conversion uses lane and\nrectangle checks for laser collisions.\n\nSCORING, TERMINATION, AND HORIZON\nThe task ends after at most 400 actions. Clip raw scores to\n[0, 500] and divide by 500. Across 100 seeds without sticky actions,\nidle averaged 13.74 points, continuous hold scored zero, and random\ninputs averaged 11.75. A policy that stopped under a settled shield\nas a laser charged averaged 325.52 and reached 839 before clipping.\n\nActions are sampled from softmax logits and have sticky-action probability 0.1.\n\nExact minAtar-synth source (`minatar_synth/games/d_laser.py`):\n```python\nfrom dataclasses import dataclass\nimport math\n\nimport numpy as np\n\n\n@dataclass\nclass Shield:\n x: float\n y: float\n target: float\n\n\n@dataclass\nclass Laser:\n bottom: float = 20\n blocked: bool = False\n\n\nclass DLaserEnvironment:\n score_cap = 500\n\n def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400):\n self.sticky_action_prob = sticky_action_prob\n self.horizon = min(horizon, 400)\n self.seed(0)\n self.reset()\n\n def seed(self, seed: int) -> None:\n self.random = np.random.default_rng(seed)\n\n def reset(self) -> None:\n self.steps = 0\n self.pressed = self.terminal = False\n self.x, self.y, self.direction = 50.0, 90.0, 1\n self.camera = 80.0\n self.distance = self.charge = self.charge_speed = self.acceleration = 0.0\n self.shield_distance = 0.0\n self.shields: list[Shield] = []\n self.lasers: list[Laser] = []\n\n @classmethod\n def normalize_score(cls, score: float) -> float:\n return min(max(score, 0), cls.score_cap) / cls.score_cap\n\n def act(self, action: int) -> tuple[float, bool]:\n if self.terminal:\n return 0.0, True\n pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5\n if pressed and not self.pressed:\n self.direction *= -1\n self.pressed = pressed\n self.steps += 1\n reward = 0\n for _ in range(4):\n reward += self._advance_frame()\n if self.terminal:\n break\n self.terminal |= self.steps >= self.horizon\n return float(reward), self.terminal\n\n def _advance_frame(self) -> int:\n scroll = 0.05 + max(0, self.camera - self.y) * 0.1\n self.camera += (80 - self.camera) * 0.001\n self.shield_distance -= scroll\n if self.shield_distance < 0:\n target = 5 + 10 * int(self.random.integers(10))\n self.shields.append(Shield(0 if target < 50 else 99, 15, target))\n self.shield_distance += self.random.uniform(9, 36)\n for shield in self.shields:\n shield.y += scroll\n delta = shield.target - shield.x\n shield.x = shield.target if abs(delta) < 1 else shield.x + delta * 0.2\n self.shields = [shield for shield in self.shields if shield.y <= 99]\n\n reward = 0\n if self.charge > 10:\n self.charge += 9\n if not self.lasers:\n self.lasers = [Laser() for _ in range(10)]\n if self.charge > 199:\n reward = math.ceil(self.distance**1.5 * 0.1)\n self._reset_lasers()\n else:\n self.acceleration += self.random.uniform(-0.0001, 0.0001)\n self.charge_speed += self.acceleration\n if self.charge_speed < 0 and self.acceleration < 0 or self.charge_speed > 0.2 and self.acceleration > 0:\n self.acceleration *= -1\n self.charge_speed *= self.random.uniform(0.2, 1.5)\n self.charge += self.charge_speed\n\n for column, laser in enumerate(self.lasers):\n if laser.blocked:\n laser.bottom += scroll\n else:\n laser.bottom += 9\n stops = [shield.y - 2 for shield in self.shields if shield.x == 5 + 10 * column\n and 10 <= shield.y - 2 <= laser.bottom]\n if stops:\n laser.bottom = min(stops)\n laser.blocked = True\n\n self.y += scroll\n if not self.pressed:\n self.x += self.direction\n if not 0 <= self.x <= 99:\n self.x = min(99, max(0, self.x))\n self.direction *= -1\n self.y -= 0.5\n self.distance += 0.5\n if self.lasers and any(\n 10 * column - 2 <= self.x <= 10 * column + 12 and 8 <= self.y <= laser.bottom + 2\n for column, laser in enumerate(self.lasers)\n ):\n self.camera += 7\n self.y += 7\n self._reset_lasers()\n self.terminal = self.y > 99\n return reward\n\n def _reset_lasers(self) -> None:\n self.lasers.clear()\n self.distance = self.charge = 0.0\n self.charge_speed *= self.random.random()\n self.acceleration *= self.random.random()\n\n def state(self) -> np.ndarray:\n state = np.zeros((10, 10, 6), dtype=bool)\n row, col = min(9, max(0, int(self.y) // 10)), int(self.x) // 10\n state[row, col, 0] = True\n state[row, col, 4] = self.direction > 0\n for shield in self.shields:\n state[int(shield.y) // 10, int(shield.x) // 10, 1 if shield.x == shield.target else 2] = True\n for col, laser in enumerate(self.lasers):\n state[1:min(10, int(laser.bottom) // 10 + 1), col, 3] = True\n for row, value in enumerate((self.steps, round(max(0, self.charge)), round(self.distance))):\n for bit in range(10):\n state[row, bit, 5] = bool(value & (1 << bit))\n state[9, 0, 5] = self.pressed\n return state\n\n```\n\nInput: a row-major 10x10x6 binary grid. Index `(row * 10 + column) * 6 + channel`. Channels: listed explicitly in the task-specific input channel table above.\n\nNetwork: `h1=tanh(x@W1+b1)`, `h2=tanh(h1@W2+b2)`, `logits=h2@W3+b3`. Shapes are W1 600x32, b1 32, W2 32x32, b2 32, W3 32x6, b3 6. All 20,486 values start at zero.\n\nThe hidden evaluator runs 1,000 fixed-seed episodes, stopping each after 10,000 steps. It divides mean game score by the game's fixed cap and clips the result to [0, 1].\n\nThe final fenced block must start with `edits`. It may contain numeric assignments to indexed entries or slices of W1, b1, W2, b2, W3, and b3. Half-open Python slices and numeric lists are supported, as are `*=`, `+=`, and `-=`. Values must be finite and have absolute value at most 1e6. Example:\n```edits\nW1[12, 0] = 2.5\nb1[0:4] = -1\nW2[0:2, 0:3] = [[1, -1, 0.5], [0, 2, 0]]\nW3[:, 2] *= 2\n```\n", "system_prompt": "You directly program neural-network weights. Follow the task constraints exactly.", "episodes": 1000, "task_id": 321, "family": "crisp_synthetic", "upstream_source_url": "https://github.com/Trajectorylabs/minatar-synth/blob/4038830175c4201ca10e004ed4441985f2acddf2/minatar_synth/games/d_laser.py", "upstream_revision": "4038830175c4201ca10e004ed4441985f2acddf2", "native_source_url": "https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/docs/dlaser/main.js"} diff --git a/runtime/LICENSE-Crisp b/runtime/LICENSE-Crisp new file mode 100644 index 0000000000000000000000000000000000000000..1841958f12370dd699a7551d2ae73ce9cf487412 --- /dev/null +++ b/runtime/LICENSE-Crisp @@ -0,0 +1,54 @@ +Crisp source notices +=================== + +The following 2021 MIT notice is reproduced verbatim from: +https://github.com/abagames/crisp-game-lib-games/blob/cfb39d2f988feb5918eb83697145b5a35adabf58/LICENSE.txt + +MIT License + +Copyright (c) 2021 ABA Games + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +The following 2022 MIT notice is reproduced verbatim. Both pinned sources +below carry this same notice: +https://github.com/abagames/crisp-game-lib-11-games/blob/6fea4eefe2deaa42706051d96a04ec9e36104696/LICENSE.txt +https://github.com/joyrider3774/crisp-game-lib-portable-sdl/blob/04bc2c4cfc2853628eda25a46190bb7ac6fe216a/LICENSE.txt + +MIT License + +Copyright (c) 2022 ABA Games + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/runtime/LICENSE-MinAtar b/runtime/LICENSE-MinAtar new file mode 100644 index 0000000000000000000000000000000000000000..94a9ed024d3859793618152ea559a168bbcbb5e2 --- /dev/null +++ b/runtime/LICENSE-MinAtar @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/runtime/NOTICE.txt b/runtime/NOTICE.txt new file mode 100644 index 0000000000000000000000000000000000000000..865779c85eb8b859265761a77458812d0a38d824 --- /dev/null +++ b/runtime/NOTICE.txt @@ -0,0 +1,28 @@ +WeightProgramBench source notices + +The 317 synthetic game implementations come from Trajectory Labs, Jerry Chan, +and contributors to https://github.com/Trajectorylabs/minatar-synth at commit +4038830175c4201ca10e004ed4441985f2acddf2. That pinned repository does not declare a +license for the converted implementations; this notice grants none. + +266 games adapt designs and source credited to ABA Games, with portable SDL/C +versions credited to Joyrider3774 and contributors. The original collections +are https://github.com/abagames/crisp-game-lib-games, +https://github.com/abagames/crisp-game-lib-11-games, and +https://github.com/joyrider3774/crisp-game-lib-portable-sdl. Their applicable MIT +copyright and permission notices are preserved in LICENSE-Crisp. + +The five original MinAtar games use MinAtar 1.0.15, by Kenny Young and Tian Tian: +https://github.com/kenjyoung/MinAtar. GPL-3.0 MinAtar source is embedded in the +original-game prompts as well as installed as a dependency. LICENSE-MinAtar +contains the full GPL text. This material is not relicensed by the cookbook. + +The weight-space programming experiment is credited to Rikiya Takehi, +Jayden Teoh, Alex Zhang, and Omar Khattab: +https://rikiyat.github.io/blog/weight-space-programming/ +Experiment prompt/log materials are attributed under CC BY 4.0: +https://creativecommons.org/licenses/by/4.0/ +The expanded corpus and subsequent model training are separate adaptations. + +The example's THIRD_PARTY_NOTICES.md and TASK_ORIGINS.json provide the complete +source mapping, pinned revisions, and prompt and implementation digests. diff --git a/runtime/minatar_synth/games/accel_b.py b/runtime/minatar_synth/games/accel_b.py new file mode 100644 index 0000000000000000000000000000000000000000..ad24cc0843d747084c9aeb598e9d72c45aeb1020 --- /dev/null +++ b/runtime/minatar_synth/games/accel_b.py @@ -0,0 +1,133 @@ +from dataclasses import dataclass + +import numpy as np + + +HORIZON = 400 +MIN_SPAWN_STEPS = 4 +MAX_MULTIPLIER = 64 +PLAYER_ROW = 4 + + +@dataclass +class Target: + row: int + column: int + fire_in: int = 0 + + +@dataclass +class HomingShot: + row: int + column: int + target: Target + age: int = 0 + + +class AccelBEnvironment: + score_cap = (HORIZON // MIN_SPAWN_STEPS) * 2 * MAX_MULTIPLIER + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.last_action = self.throttle = 0 + self.spawn_in = MIN_SPAWN_STEPS + self.multiplier = 1 + self.enemies: list[Target] = [] + self.hostile: list[Target] = [] + self.shots: list[HomingShot] = [] + self.blasts: list[tuple[int, int, int]] = [] + self.terminal = False + + @property + def column(self) -> int: + return 1 + self.throttle // 2 + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + self.steps += 1 + pressed = action == 5 and self.last_action != 5 + self.last_action = action + self.throttle = min(6, self.throttle + 1) if action == 5 else max(0, self.throttle - 1) + if pressed and not (self.shots or self.blasts): + self.multiplier = 1 + self.shots = [HomingShot(PLAYER_ROW, self.column, target) + for target in (*self.enemies, *self.hostile)] + self._advance_targets() + self._advance_salvo() + reward = 0 + for targets in (self.enemies, self.hostile): + remaining = [] + for target in targets: + if any(abs(target.row - row) <= 1 and abs(target.column - column) <= 1 + for row, column, _ in self.blasts): + reward += self.multiplier + self.multiplier = min(MAX_MULTIPLIER, 2 * self.multiplier) + elif target.column >= 0: + remaining.append(target) + targets[:] = remaining + self.terminal = any((missile.row, missile.column) == (PLAYER_ROW, self.column) + for missile in self.hostile) or self.steps >= self.horizon + self.spawn_in -= 1 + if self.spawn_in == 0 and not self.terminal: + self.enemies.append(Target(int(self.random.choice((1, 2, 3, 5, 6, 7, 8))), 9, 3)) + self.spawn_in = max(MIN_SPAWN_STEPS, 10 - self.throttle) + return float(reward), self.terminal + + def _advance_targets(self) -> None: + for enemy in self.enemies: + if self.throttle >= 3 or self.steps % 3 == 0: + enemy.column -= 1 + enemy.fire_in -= 1 + if enemy.fire_in == 0 and enemy.column >= 0: + self.hostile.append(Target(enemy.row, enemy.column)) + for missile in self.hostile: + missile.column -= 1 + if self.steps % 2 == 0: + missile.row += int(np.sign(PLAYER_ROW - missile.row)) + + def _advance_salvo(self) -> None: + self.blasts = [(row, column, timer - 1) + for row, column, timer in self.blasts if timer > 1] + remaining = [] + for shot in self.shots: + shot.age += 1 + shot.column += 1 if shot.age == 1 else int(np.sign(shot.target.column - shot.column)) + if shot.age > 1: + shot.row += int(np.sign(shot.target.row - shot.row)) + distance = max(abs(shot.row - shot.target.row), abs(shot.column - shot.target.column)) + if distance <= 1 or shot.age >= 12: + self.blasts.append((shot.row, max(0, min(9, shot.column)), 3)) + else: + remaining.append(shot) + self.shots = remaining + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[PLAYER_ROW, self.column, 0] = True + for channel, targets in ((1, self.hostile), (2, self.enemies), (3, self.shots)): + for target in targets: + if 0 <= target.column < 10: + state[target.row, target.column, channel] = True + for row, column, _ in self.blasts: + state[max(0, row - 1):row + 2, max(0, column - 1):column + 2, 4] = True + values = (self.steps, self.throttle, self.spawn_in, self.multiplier, + int(self.last_action == 5), int(not (self.shots or self.blasts))) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/adventure.py b/runtime/minatar_synth/games/adventure.py new file mode 100644 index 0000000000000000000000000000000000000000..c7d193d6c6badb797fe84eb5feff62347ef95d5d --- /dev/null +++ b/runtime/minatar_synth/games/adventure.py @@ -0,0 +1,199 @@ +import numpy as np + + +class AdventureEnvironment: + """Compact Adventure: rooms, keys, carried objects, dragon, bat, and chalice return.""" + + score_cap = 1.0 + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 1_000): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.room = 0 + self.player = [8, 5] + self.held = None + self.items = { + "gold_key": [0, 5, 7], "black_key": [2, 7, 7], "white_key": [4, 2, 2], + "sword": [1, 7, 2], "chalice": [5, 2, 7], "bridge": [3, 6, 2], + "magnet": [5, 7, 2], + } + self.dragons = [[2, 5, 5], [3, 3, 7], [5, 6, 6]] + self.previous_dragons = [dragon.copy() for dragon in self.dragons] + self.bat = [1, 2, 8] + self.previous_bat = self.bat.copy() + self.castles = { + 0: {"key": "gold_key", "open": False}, + 2: {"key": "black_key", "open": False}, + 4: {"key": "white_key", "open": False}, + } + self.dragon_alive = [True, True, True] + self.last_action = 0 + self.steps = 0 + self.terminal = False + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + dropped = False + if action in (1, 2, 3, 4): + dy, dx = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}[action] + target = [min(9, max(0, self.player[0] + dy)), min(9, max(0, self.player[1] + dx))] + if self._can_move(target): + self.player = target + self._change_room() + elif action == 5 and self.held is not None: + self.items[self.held] = [self.room, *self.player] + self.held = None + dropped = True + + if not dropped: + self._collect_item() + self._use_magnet() + self.previous_dragons = [dragon.copy() for dragon in self.dragons] + self.previous_bat = self.bat.copy() + self._move_dragons() + self._move_bat() + castle = self.castles.get(self.room) + if castle and self.player[0] <= 1 and self.held == castle["key"]: + castle["open"] = True + if self.room == 0 and self.player[0] <= 1 and self.held == "chalice" and self.castles[0]["open"]: + self.terminal = True + return 1.0, True + self.steps += 1 + if self.steps >= self.horizon: + self.terminal = True + return 0.0, self.terminal + + def _can_move(self, target: list[int]) -> bool: + if self.room != 3 or {self.player[0], target[0]} != {4, 5}: + return True + bridge = self.items.get("bridge") + bridge_column = bridge[2] if bridge is not None and bridge[0] == 3 else None + return self.held == "bridge" or bridge_column == target[1] + + def _change_room(self) -> None: + if self.player[1] == 0 and self.room % 2 == 1: + self.room -= 1 + self.player[1] = 9 + elif self.player[1] == 9 and self.room % 2 == 0: + self.room += 1 + self.player[1] = 0 + elif self.player[0] == 0 and self.room >= 2: + self.room -= 2 + self.player[0] = 9 + elif self.player[0] == 9 and self.room < 4: + self.room += 2 + self.player[0] = 0 + + def _collect_item(self) -> None: + for name, location in list(self.items.items()): + if location == [self.room, *self.player] and self.held is None: + self.held = name + del self.items[name] + castle = self.castles.get(self.room) + if castle and self.held == castle["key"] and self.player[0] <= 1: + castle["open"] = True + + def _move_dragons(self) -> None: + for index, dragon in enumerate(self.dragons): + if not self.dragon_alive[index] or dragon[0] != self.room: + continue + _, row, column = dragon + row += int(np.sign(self.player[0] - row)) + column += int(np.sign(self.player[1] - column)) + dragon[1:] = [row, column] + if [row, column] == self.player: + if self.held == "sword": + self.dragon_alive[index] = False + else: + self.terminal = True + + def _use_magnet(self) -> None: + if self.held != "magnet": + return + candidates = [(name, location) for name, location in self.items.items() if location[0] == self.room] + if not candidates: + return + _, location = min(candidates, key=lambda item: abs(item[1][1] - self.player[0]) + abs(item[1][2] - self.player[1])) + location[1] += int(np.sign(self.player[0] - location[1])) + location[2] += int(np.sign(self.player[1] - location[2])) + + def _move_bat(self) -> None: + if self.random.rand() >= 0.15: + return + self.bat[0] = int(self.random.randint(6)) + self.bat[1] = int(self.random.randint(10)) + self.bat[2] = int(self.random.randint(10)) + if self.bat == [self.room, *self.player] and self.held is not None: + name = self.held + self.held = None + self.items[name] = self.bat.copy() + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + for name, (room, row, column) in self.items.items(): + if room == self.room: + if name == "chalice": + state[row, column, 2] = True + else: + state[row, column, 3] = True + marker = { + "gold_key": 0, + "black_key": 1, + "white_key": 2, + "sword": 3, + "bridge": 4, + "magnet": 5, + }[name] + state[row, marker, 5] = True + for alive, dragon in zip(self.dragon_alive, self.dragons, strict=True): + if alive and dragon[0] == self.room: + state[dragon[1], dragon[2], 1] = True + for previous, alive in zip(self.previous_dragons, self.dragon_alive, strict=True): + if alive and previous[0] == self.room: + state[previous[1], previous[2], 4] = True + if self.bat[0] == self.room: + state[self.bat[1], self.bat[2], 1] = True + if self.previous_bat[0] == self.room: + state[self.previous_bat[1], self.previous_bat[2], 4] = True + if self.room == 3: + state[4, :, 1] = True + bridge = self.items.get("bridge") + if self.held == "bridge": + state[4, self.player[1], 1] = False + elif bridge is not None and bridge[0] == 3: + state[4, bridge[2], 1] = False + if self.room in self.castles: + state[0, 4:7, 1] = not self.castles[self.room]["open"] + if self.held is not None: + held_marker = { + "gold_key": 0, + "black_key": 1, + "white_key": 2, + "sword": 3, + "chalice": 4, + "bridge": 5, + "magnet": 6, + }[self.held] + state[8, held_marker, 5] = True + state[9, self.room, 5] = True + for castle_room, castle in self.castles.items(): + if castle["open"]: + state[7, castle_room, 5] = True + return state diff --git a/runtime/minatar_synth/games/aerial_bar.py b/runtime/minatar_synth/games/aerial_bar.py new file mode 100644 index 0000000000000000000000000000000000000000..412f58e48cc9ea84dd0db3a34073b349e74e7fca --- /dev/null +++ b/runtime/minatar_synth/games/aerial_bar.py @@ -0,0 +1,129 @@ +from dataclasses import dataclass +from math import cos, pi, sin + +import numpy as np + + +HORIZON = 400 +UNIT = 8 +WATER = 72 +PERIOD = 32 + + +@dataclass +class Bar: + anchor: int + length: int + phase: int + used: bool = False + + def tip(self, ceiling: int) -> tuple[int, int]: + angle = 0.85 * sin(self.phase * 2 * pi / PERIOD) + return self.anchor + round(self.length * sin(angle)), ceiling + round(self.length * cos(angle)) + + +class AerialBarEnvironment: + score_cap = HORIZON + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.last_action = self.flight = 0 + self.ceiling = 8 + self.attached: Bar | None = Bar(32, 38, 0, True) + self.bars = [self.attached, Bar(66, int(self.random.integers(25, 34)), 0)] + self.x, self.y = self.attached.tip(self.ceiling) + self.vx = self.vy = 0 + self.bounced = False + self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + pressed = action == 5 and self.last_action != 5 + self.last_action = action + self.steps += 1 + scroll = int(self.steps % 8 == 0) + max(0, (self.x - 40) // 8) + self.x -= scroll + for bar in self.bars: + bar.anchor -= scroll + bar.phase = (bar.phase + 1) % PERIOD + if self.bars[-1].anchor < 55: + self.bars.append(Bar(self.bars[-1].anchor + int(self.random.integers(26, 42)), + int(self.random.integers(18, 39)), int(self.random.integers(PERIOD)))) + + reward = 0 + if self.attached is not None: + bar = self.attached + self.x, self.y = bar.tip(self.ceiling) + if pressed: + future = Bar(bar.anchor, bar.length, (bar.phase + 1) % PERIOD) + next_x, next_y = future.tip(self.ceiling) + self.vx, self.vy = next_x - self.x, next_y - self.y - 1 + self.attached = None + self.flight = 0 + self.bounced = False + else: + self.flight += 1 + self.x += self.vx + self.y += self.vy + if action != 5 or self.steps % 5 == 0: + self.vy += 1 + if action != 5 and self.steps % 4 == 0: + self.vx -= int(np.sign(self.vx)) + if self.y >= WATER: + self.y = WATER - 1 + self.vy = -max(1, self.vy * 3 // 2) + self.ceiling += 8 + self.bounced = True + for bar in self.bars: + bar.used = False + if self.y <= self.ceiling: + self.y = self.ceiling + self.vy = max(0, -self.vy // 2) + for bar in self.bars: + x, y = bar.tip(self.ceiling) + if not bar.used and abs(self.x - x) <= 5 and abs(self.y - y) <= 5: + self.attached = bar + bar.used = True + reward = 0 if self.bounced else self.flight + self.ceiling = max(8, self.ceiling - 4) + self.x, self.y = bar.tip(self.ceiling) + break + self.bars = [bar for bar in self.bars if bar.anchor >= -24 or bar is self.attached] + self.terminal = ( + (self.attached.anchor < 0 if self.attached is not None else self.x < 0) + or any(bar.tip(self.ceiling)[1] >= WATER for bar in self.bars) + or self.steps >= self.horizon + ) + return float(reward), self.terminal + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, self.y // UNIT), max(0, min(9, self.x // UNIT)), 0] = True + state[WATER // UNIT:, :, 1] = True + for bar in self.bars: + x, y = bar.tip(self.ceiling) + if 0 <= x < 80 and 0 <= y < 80: + state[y // UNIT, x // UNIT, 3 if bar.used else 2] = True + state[:min(10, self.ceiling // UNIT), :, 4] = True + values = (self.steps, self.flight, self.ceiling, self.x + 32, self.y, + self.vx + 16, self.vy + 64, int(self.attached is not None), + int(self.bounced), int(self.last_action == 5)) + for row, value in enumerate(values): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/alien.py b/runtime/minatar_synth/games/alien.py new file mode 100644 index 0000000000000000000000000000000000000000..2fc1172db43c39e55d67e8f854749d47b3e55500 --- /dev/null +++ b/runtime/minatar_synth/games/alien.py @@ -0,0 +1,116 @@ +import numpy as np + + +MAZE = np.array([ + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [1, 0, 0, 0, 1, 0, 0, 0, 0, 1], + [1, 0, 1, 0, 1, 0, 1, 1, 0, 1], + [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], + [1, 0, 1, 1, 1, 1, 0, 1, 0, 1], + [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], + [1, 1, 0, 1, 1, 0, 1, 1, 0, 1], + [1, 0, 0, 0, 1, 0, 0, 0, 0, 1], + [1, 0, 1, 0, 0, 0, 1, 0, 0, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +], dtype=bool) + + +class AlienEnvironment: + """Maze pursuit with eggs, pulsars, and three vulnerable Alien enemies.""" + + score_cap = 35.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 500): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.player = [8, 5] + self.previous_player = self.player.copy() + self.aliens = [[1, 1], [1, 8], [7, 1]] + self.previous_aliens = [position.copy() for position in self.aliens] + passages = [tuple(position) for position in np.argwhere(~MAZE)] + reserved = {tuple(self.player), *(tuple(position) for position in self.aliens)} + self.pulsars = {(3, 3), (5, 8), (8, 1)} + self.eggs = {position for position in passages if position not in reserved | self.pulsars} + self.eggs = set(sorted(self.eggs)[:20]) + self.power_timer = 0 + self.last_action = 0 + self.steps = 0 + self.terminal = False + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + delta = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}.get(action, (0, 0)) + target = [self.player[0] + delta[0], self.player[1] + delta[1]] + if not MAZE[*target]: + self.player = target + + reward = 0.0 + position = tuple(self.player) + if position in self.eggs: + self.eggs.remove(position) + reward += 1.0 + if position in self.pulsars: + self.pulsars.remove(position) + self.power_timer = 30 + + self.previous_aliens = [alien.copy() for alien in self.aliens] + for alien in self.aliens: + self._move_alien(alien) + defeated = [] + for alien in self.aliens: + if alien == self.player: + if self.power_timer > 0: + reward += 5.0 + defeated.append(alien) + else: + self.terminal = True + for alien in defeated: + self.aliens.remove(alien) + self.power_timer = max(0, self.power_timer - 1) + self.steps += 1 + if not self.eggs: + self.terminal = True + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _move_alien(self, alien: list[int]) -> None: + candidates = [] + for row_delta, column_delta in ((0, -1), (-1, 0), (0, 1), (1, 0)): + candidate = [alien[0] + row_delta, alien[1] + column_delta] + if not MAZE[*candidate]: + distance = abs(candidate[0] - self.player[0]) + abs(candidate[1] - self.player[1]) + candidates.append((distance, self.random.rand(), candidate)) + if candidates: + alien[:] = min(candidates)[2] + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + for alien in self.aliens: + state[*alien, 1] = True + for egg in self.eggs: + state[*egg, 2] = True + for pulsar in self.pulsars: + state[*pulsar, 3] = True + for previous in self.previous_aliens: + state[*previous, 4] = True + state[9, : min(10, (self.power_timer + 2) // 3), 5] = True + return state diff --git a/runtime/minatar_synth/games/amidar.py b/runtime/minatar_synth/games/amidar.py new file mode 100644 index 0000000000000000000000000000000000000000..8544c33ef4b221bad3d7621722b589129b38cadd --- /dev/null +++ b/runtime/minatar_synth/games/amidar.py @@ -0,0 +1,133 @@ +import numpy as np + + +ACTIONS = { + 1: (0, -1), + 2: (-1, 0), + 3: (0, 1), + 4: (1, 0), +} + + +class AmidarEnvironment: + """Trace a rectilinear maze while avoiding deterministic patrol enemies.""" + + score_cap = 9.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 600): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.player = [9, 0] + self.previous_player = self.player.copy() + self.enemies = [[0, 0], [0, 9], [9, 9]] + self.previous_enemies = [position.copy() for position in self.enemies] + self.enemy_directions = [4, 1, 2] + self.painted_edges: set[tuple[tuple[int, int], tuple[int, int]]] = set() + self.completed_boxes: set[tuple[int, int]] = set() + self.shadow_timer = 0 + self.shadow_uses = 3 + self.last_action = 0 + self.steps = 0 + self.terminal = False + + @staticmethod + def _on_path(position: list[int] | tuple[int, int]) -> bool: + row, column = position + return 0 <= row < 10 and 0 <= column < 10 and (row % 3 == 0 or column % 3 == 0) + + @staticmethod + def _edge(first: list[int], second: list[int]) -> tuple[tuple[int, int], tuple[int, int]]: + return tuple(sorted((tuple(first), tuple(second)))) + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + if action == 5 and self.shadow_uses > 0 and self.shadow_timer == 0: + self.shadow_uses -= 1 + self.shadow_timer = 12 + elif action in ACTIONS: + row_delta, column_delta = ACTIONS[action] + target = [self.player[0] + row_delta, self.player[1] + column_delta] + if self._on_path(target): + self.player = target + if self.player != self.previous_player: + self.painted_edges.add(self._edge(self.previous_player, self.player)) + + reward = self._complete_boxes() + self.previous_enemies = [position.copy() for position in self.enemies] + if self.shadow_timer == 0: + for index in range(len(self.enemies)): + self._move_enemy(index) + if self.shadow_timer == 0 and any(enemy == self.player for enemy in self.enemies): + self.terminal = True + self.shadow_timer = max(0, self.shadow_timer - 1) + self.steps += 1 + if len(self.completed_boxes) == 9 or self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _move_enemy(self, index: int) -> None: + direction = self.enemy_directions[index] + preferences = (direction, {1: 2, 2: 3, 3: 4, 4: 1}[direction], {1: 4, 2: 1, 3: 2, 4: 3}[direction]) + for candidate_direction in preferences: + row_delta, column_delta = ACTIONS[candidate_direction] + target = [self.enemies[index][0] + row_delta, self.enemies[index][1] + column_delta] + if self._on_path(target): + self.enemies[index] = target + self.enemy_directions[index] = candidate_direction + return + + def _complete_boxes(self) -> float: + reward = 0.0 + for box_row in range(3): + for box_column in range(3): + box = (box_row, box_column) + if box in self.completed_boxes: + continue + top = box_row * 3 + left = box_column * 3 + required = set() + for offset in range(3): + required.add(self._edge([top, left + offset], [top, left + offset + 1])) + required.add(self._edge([top + 3, left + offset], [top + 3, left + offset + 1])) + required.add(self._edge([top + offset, left], [top + offset + 1, left])) + required.add(self._edge([top + offset, left + 3], [top + offset + 1, left + 3])) + if required <= self.painted_edges: + self.completed_boxes.add(box) + reward += 1.0 + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + for enemy in self.enemies: + channel = 3 if self.shadow_timer > 0 else 1 + state[*enemy, channel] = True + for box_row in range(3): + for box_column in range(3): + center = (min(9, box_row * 3 + 1), min(9, box_column * 3 + 1)) + if (box_row, box_column) not in self.completed_boxes: + state[*center, 2] = True + for first, second in self.painted_edges: + state[*first, 4] = True + state[*second, 4] = True + state[9, : self.shadow_uses, 5] = True + if self.shadow_timer > 0: + state[8, : min(10, self.shadow_timer), 5] = True + return state diff --git a/runtime/minatar_synth/games/ant_lion.py b/runtime/minatar_synth/games/ant_lion.py new file mode 100644 index 0000000000000000000000000000000000000000..994294691dc002e31cd7b47c5a01d6085a3b7d0e --- /dev/null +++ b/runtime/minatar_synth/games/ant_lion.py @@ -0,0 +1,118 @@ +from dataclasses import dataclass +from math import cos, pi, sin + +import numpy as np + + +HORIZON = 400 +ANGLES = 32 + + +@dataclass +class EscapeBar: + angle: int + inner: int + outer: int + speed: int = 2 + + +class AntLionEnvironment: + score_cap = HORIZON * (HORIZON + 1) + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.angle, self.radius = 8, 32 + self.steps = self.last_action = self.velocity = self.multiplier = 0 + self.spawn_in = 1 + self.bars: list[EscapeBar] = [] + self.attached: EscapeBar | None = None + self.offset = 0 + self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.steps += 1 + if self.attached is None: + self.velocity = max(-2, min(2, self.velocity + (1 if action == 5 else -1))) + self.angle = (self.angle + self.velocity) % ANGLES + self.radius -= 2 if self.radius > 40 else 1 + if self.radius <= 3: + self.terminal = True + return 0.0, True + self.spawn_in -= 1 + if not self.spawn_in: + self.bars.append(EscapeBar(int(self.random.integers(ANGLES)), 42, + 42 + int(self.random.integers(8, 17)))) + self.spawn_in = max(8, int(self.random.integers(14, 20)) - self.steps // 80) + remaining = [] + for bar in self.bars: + if self.steps % 4 == 0: + bar.angle = (bar.angle - 1) % ANGLES + movement = bar.speed + int(bar.inner > 40) + bar.inner = max(0, bar.inner - movement) + bar.outer -= movement + if bar.outer >= 0: + remaining.append(bar) + else: + self.multiplier = max(1, self.multiplier - 1) if self.multiplier else 0 + if self.attached is bar: + self.attached = None + self.bars = remaining + if self.attached is not None: + bar = self.attached + self.offset += 3 + if self.steps % 5 == 0: + bar.speed = min(3, bar.speed + 1) + self.angle, self.radius = bar.angle, bar.inner + self.offset + if self.radius > bar.outer + 3: + self.attached = None + reward = 0 + if self.attached is None and self.radius > 3: + for bar in self.bars: + separation = (self.angle - bar.angle) % ANGLES + if min(separation, ANGLES - separation) <= 1 and bar.inner <= self.radius <= bar.outer: + self.attached = bar + self.offset = self.radius - bar.inner + self.multiplier += 2 + reward = self.multiplier + break + self.terminal = self.radius <= 3 or self.steps >= self.horizon + return float(reward), self.terminal + + @staticmethod + def _cell(angle: int, radius: int) -> tuple[int, int]: + radians = angle * 2 * pi / ANGLES + return round(4.5 + sin(radians) * radius / 9), round(4.5 + cos(radians) * radius / 9) + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row, column = self._cell(self.angle, self.radius) + state[max(0, min(9, row)), max(0, min(9, column)), 0] = True + state[4:6, 4:6, 1] = True + for bar in self.bars: + for radius in range(bar.inner, bar.outer + 1): + row, column = self._cell(bar.angle, radius) + if 0 <= row < 10 and 0 <= column < 10: + state[row, column, 3 if bar is self.attached else 2] = True + values = (self.angle, self.radius, self.velocity + 2, self.offset, + self.multiplier, self.steps, self.spawn_in, self.last_action) + for row, value in enumerate(values): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/arcfire.py b/runtime/minatar_synth/games/arcfire.py new file mode 100644 index 0000000000000000000000000000000000000000..41e32f83e14bfa943ac8dd8d379930612a0eb8e0 --- /dev/null +++ b/runtime/minatar_synth/games/arcfire.py @@ -0,0 +1,122 @@ +from math import atan2, cos, hypot, pi, sin, sqrt + +import numpy as np + + +HORIZON = 400 +SECTORS = 24 +MAX_CHARGE = 12 +SPAWN_INTERVAL = 6 +CENTER = (5, 5) +MAX_ENEMIES = (HORIZON + SPAWN_INTERVAL - 1) // SPAWN_INTERVAL + + +class ArcfireEnvironment: + score_cap = MAX_ENEMIES * (MAX_ENEMIES + 1) // 2 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.player = CENTER + self.steps = self.last_action = self.aim = self.charge = self.arc_start = 0 + self.multiplier = 1 + self.spawn_index = int(self.random.integers(36)) + self.enemies: list[tuple[int, int]] = [] + self.shot: tuple[int, int, int, int] | None = None + self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + @staticmethod + def _range(width: int) -> int: + return max(3, round(9 / sqrt(width))) + + def _in_arc(self, cell: tuple[int, int], start: int, width: int, radius: int) -> bool: + dy, dx = cell[0] - self.player[0], cell[1] - self.player[1] + direction = atan2(dy, dx) * SECTORS / (2 * pi) + return (direction - start) % SECTORS <= width and abs(hypot(dx, dy) - radius) <= 0.75 + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + self.steps += 1 + self.aim = (self.aim + 1) % SECTORS + if action == 5 and self.last_action != 5: + self.charge, self.arc_start, self.multiplier = 1, self.aim, 1 + elif action == 5 and self.charge: + self.charge += 1 + if self.charge > MAX_CHARGE: + self.charge = 0 + elif self.charge: + width = self.charge + reach = self._range(width) + if self.shot is None: + self.shot = (self.arc_start, width, reach, 1) + angle = (self.arc_start + width / 2) * 2 * pi / SECTORS + stride = reach / 2 + row, column = self.player + self.player = (max(1, min(8, row + round(stride * sin(angle)))), + max(1, min(8, column + round(stride * cos(angle))))) + self.charge = 0 + self.last_action = action + + if self.steps % SPAWN_INTERVAL == 1: + if self.random.random() < 0.1: + self.spawn_index = int(self.random.integers(36)) + else: + self.spawn_index = (self.spawn_index + int(self.random.integers(-1, 2))) % 36 + side, offset = divmod(self.spawn_index, 9) + self.enemies.append(((0, offset), (offset, 9), (9, 9 - offset), (9 - offset, 0))[side]) + if self.steps % 3 == 0: + self.enemies = [(row + int(np.sign(CENTER[0] - row)), column + int(np.sign(CENTER[1] - column))) + for row, column in self.enemies] + + reward = 0 + if self.shot is not None: + start, width, reach, radius = self.shot + survivors = [] + for cell in self.enemies: + if self._in_arc(cell, start, width, radius): + reward += self.multiplier + self.multiplier += 1 + else: + survivors.append(cell) + self.enemies = survivors + self.shot = (start, width, reach, radius + 1) if radius < reach else None + self.terminal = any(cell in (CENTER, self.player) for cell in self.enemies) + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + for cell in self.enemies: + state[*cell, 1] = True + state[*CENTER, 2] = True + for row in range(10): + for column in range(10): + cell = row, column + if self.shot is not None: + start, width, _, radius = self.shot + state[row, column, 3] = self._in_arc(cell, start, width, radius) + if self.charge: + state[row, column, 4] = self._in_arc(cell, self.arc_start, self.charge, self._range(self.charge)) + values = (self.steps, self.aim, self.charge, self.arc_start, self.multiplier, + self.spawn_index, int(self.last_action == 5), *(self.shot or (0, 0, 0, 0))) + offset = 0 + for value, width in zip(values, (9, 5, 4, 5, 7, 6, 1, 5, 4, 4, 4), strict=True): + for bit in range(width): + state[offset // 10, offset % 10, 5] = bool(value & (1 << bit)) + offset += 1 + return state diff --git a/runtime/minatar_synth/games/assault.py b/runtime/minatar_synth/games/assault.py new file mode 100644 index 0000000000000000000000000000000000000000..951c12666063e2ca6e44b13cf1cdb09fbb4bf9b7 --- /dev/null +++ b/runtime/minatar_synth/games/assault.py @@ -0,0 +1,190 @@ +import numpy as np + + +class AssaultEnvironment: + """Fixed-cannon wave defense with vertical/lateral fire and weapon heat.""" + + score_cap = 75.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 1_500): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.player_column = 5 + self.facing = 1 + self.mothership_column = 0 + self.mothership_direction = 1 + self.aliens: list[dict[str, int | bool]] = [] + self.friendly_shots: list[list[int]] = [] + self.hostile_shots: list[list[int]] = [] + self.fireballs: list[list[int]] = [] + self.previous_aliens: list[list[int]] = [] + self.previous_hostiles: list[list[int]] = [] + self.wave = 0 + self.spawned = 0 + self.lives = 3 + self.heat = 0 + self.steps = 0 + self.last_action = 0 + self.terminal = False + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + fired = False + if action == 1: + self.player_column = max(0, self.player_column - 1) + self.facing = -1 + elif action == 3: + self.player_column = min(9, self.player_column + 1) + self.facing = 1 + elif action == 2 and self.heat < 9: + self.friendly_shots.append([8, self.player_column, -1, 0]) + fired = True + elif action == 5 and self.heat < 9: + self.friendly_shots.append([9, self.player_column, 0, self.facing]) + fired = True + self.heat = min(10, self.heat + 2) if fired else max(0, self.heat - 1) + if self.heat >= 10: + self._lose_life() + + self._move_mothership() + self._spawn_alien() + self.previous_aliens = [[int(alien["row"]), int(alien["column"])] for alien in self.aliens] + self.previous_hostiles = [shot[:2] for shot in self.hostile_shots + self.fireballs] + self._move_aliens() + self._move_projectiles() + reward = self._resolve_friendly_hits() + self._resolve_hostile_hits() + self._launch_hostile_weapon() + self.steps += 1 + if self.spawned == 10 and not self.aliens: + self.wave += 1 + if self.wave == 5: + self.terminal = True + else: + self.spawned = 0 + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _move_mothership(self) -> None: + self.mothership_column += self.mothership_direction + if self.mothership_column in (0, 9): + self.mothership_direction *= -1 + + def _spawn_alien(self) -> None: + if self.spawned >= 10 or self.steps % 4 != 0: + return + self.aliens.append({ + "row": 1, + "column": self.mothership_column, + "direction": self.mothership_direction, + "split": self.spawned % 2 == 1, + }) + self.spawned += 1 + + def _move_aliens(self) -> None: + for alien in self.aliens: + direction = int(alien["direction"]) + column = int(alien["column"]) + direction + if column < 0 or column > 9: + direction *= -1 + column = min(9, max(0, column)) + alien["column"] = column + alien["direction"] = direction + if self.wave % 3 == 1 and self.steps % 3 == 0: + alien["row"] = min(7, int(alien["row"]) + 1) + elif self.wave % 3 == 2 and self.random.rand() < 0.2: + alien["row"] = int(self.random.randint(1, 7)) + alien["column"] = int(self.random.randint(10)) + + def _move_projectiles(self) -> None: + for shot in self.friendly_shots: + shot[0] += shot[2] + shot[1] += shot[3] + self.friendly_shots = [shot for shot in self.friendly_shots if 0 <= shot[0] < 10 and 0 <= shot[1] < 10] + for shot in self.hostile_shots: + shot[0] += 1 + reached_base = [shot for shot in self.hostile_shots if shot[0] >= 9] + self.hostile_shots = [shot for shot in self.hostile_shots if shot[0] < 9] + for shot in reached_base: + direction = int(np.sign(self.player_column - shot[1])) or 1 + self.fireballs.append([9, shot[1], 0, direction]) + for fireball in self.fireballs: + fireball[1] += fireball[3] + self.fireballs = [shot for shot in self.fireballs if 0 <= shot[1] < 10] + + def _resolve_friendly_hits(self) -> float: + reward = 0.0 + remaining_shots = [] + for shot in self.friendly_shots: + hit_fireball = next((fireball for fireball in self.fireballs if fireball[:2] == shot[:2]), None) + if hit_fireball is not None: + self.fireballs.remove(hit_fireball) + continue + hit = next((alien for alien in self.aliens if [alien["row"], alien["column"]] == shot[:2]), None) + if hit is None: + remaining_shots.append(shot) + continue + self.aliens.remove(hit) + if bool(hit["split"]): + column = int(hit["column"]) + row = int(hit["row"]) + for direction in (-1, 1): + self.aliens.append({"row": row, "column": column, "direction": direction, "split": False}) + else: + reward += 1.0 + self.friendly_shots = remaining_shots + return reward + + def _resolve_hostile_hits(self) -> None: + if any(shot[:2] == [9, self.player_column] for shot in self.fireballs): + self.fireballs = [shot for shot in self.fireballs if shot[:2] != [9, self.player_column]] + self._lose_life() + + def _launch_hostile_weapon(self) -> None: + if self.steps % 12 != 0 or not self.aliens: + return + lowest = max(self.aliens, key=lambda alien: int(alien["row"])) + self.hostile_shots.append([int(lowest["row"]) + 1, int(lowest["column"])]) + + def _lose_life(self) -> None: + self.lives -= 1 + self.heat = 0 + self.friendly_shots.clear() + self.hostile_shots.clear() + self.fireballs.clear() + if self.lives <= 0: + self.terminal = True + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[9, self.player_column, 0] = True + state[0, self.mothership_column, 1] = True + for shot in self.hostile_shots + self.fireballs: + state[shot[0], shot[1], 1] = True + for alien in self.aliens: + state[int(alien["row"]), int(alien["column"]), 2] = True + for shot in self.friendly_shots: + state[shot[0], shot[1], 3] = True + for row, column in self.previous_aliens + self.previous_hostiles: + state[row, column, 4] = True + state[9, : self.heat, 5] = True + state[8, : self.lives, 5] = True + state[7, : self.wave + 1, 5] = True + return state diff --git a/runtime/minatar_synth/games/asteroids.py b/runtime/minatar_synth/games/asteroids.py new file mode 100644 index 0000000000000000000000000000000000000000..387d2a9679782a3ca663ff5bf16fa5b429a1bc9a --- /dev/null +++ b/runtime/minatar_synth/games/asteroids.py @@ -0,0 +1,167 @@ +import numpy as np + + +DIRECTIONS = ( + (-1, 0), + (-1, 1), + (0, 1), + (1, 1), + (1, 0), + (1, -1), + (0, -1), + (-1, -1), +) +POINTS = {3: 20.0, 2: 50.0, 1: 100.0} + + +class AsteroidsEnvironment: + """Momentum, wraparound, fragmentation, and risky hyperspace on a torus.""" + + score_cap = 6_240.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 1_500): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.ship = [5, 5] + self.previous_ship = self.ship.copy() + self.velocity = [0, 0] + self.direction = 0 + self.shots: list[list[int]] = [] + self.wave = 0 + self.lives = 4 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self._start_wave() + + def _start_wave(self) -> None: + starts = ((0, 0, 1, 1), (0, 9, 1, -1), (9, 0, -1, 1), (9, 9, -1, -1)) + self.asteroids = [ + {"row": row, "column": column, "dr": dr, "dc": dc, "size": 3} + for row, column, dr, dc in starts + ] + self.previous_asteroids = [[int(asteroid["row"]), int(asteroid["column"])] for asteroid in self.asteroids] + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_ship = self.ship.copy() + if action == 1: + self.direction = (self.direction - 1) % 8 + elif action == 3: + self.direction = (self.direction + 1) % 8 + elif action == 2: + thrust = DIRECTIONS[self.direction] + self.velocity[0] = int(np.clip(self.velocity[0] + thrust[0], -1, 1)) + self.velocity[1] = int(np.clip(self.velocity[1] + thrust[1], -1, 1)) + elif action == 4: + self.ship = [int(self.random.randint(10)), int(self.random.randint(10))] + self.velocity = [0, 0] + elif action == 5: + dr, dc = DIRECTIONS[self.direction] + self.shots.append([self.ship[0], self.ship[1], dr, dc, 12]) + + if action != 4: + self.ship[0] = (self.ship[0] + self.velocity[0]) % 10 + self.ship[1] = (self.ship[1] + self.velocity[1]) % 10 + self.previous_asteroids = [[int(asteroid["row"]), int(asteroid["column"])] for asteroid in self.asteroids] + self._move_asteroids() + self._move_shots() + reward = self._resolve_shots() + if any([asteroid["row"], asteroid["column"]] == self.ship for asteroid in self.asteroids): + self._lose_ship() + self.steps += 1 + if not self.asteroids: + self.wave += 1 + if self.wave == 3: + self.terminal = True + else: + self._start_wave() + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _move_asteroids(self) -> None: + for asteroid in self.asteroids: + asteroid["row"] = (int(asteroid["row"]) + int(asteroid["dr"])) % 10 + asteroid["column"] = (int(asteroid["column"]) + int(asteroid["dc"])) % 10 + + def _move_shots(self) -> None: + for shot in self.shots: + shot[0] = (shot[0] + shot[2]) % 10 + shot[1] = (shot[1] + shot[3]) % 10 + shot[4] -= 1 + self.shots = [shot for shot in self.shots if shot[4] > 0] + + def _resolve_shots(self) -> float: + reward = 0.0 + remaining_shots = [] + for shot in self.shots: + hit = next( + (asteroid for asteroid in self.asteroids if [asteroid["row"], asteroid["column"]] == shot[:2]), + None, + ) + if hit is None: + remaining_shots.append(shot) + continue + self.asteroids.remove(hit) + size = int(hit["size"]) + reward += POINTS[size] + if size > 1: + for turn in (-1, 1): + direction = DIRECTIONS.index((int(hit["dr"]), int(hit["dc"]))) + dr, dc = DIRECTIONS[(direction + turn) % 8] + self.asteroids.append({ + "row": int(hit["row"]), + "column": int(hit["column"]), + "dr": dr, + "dc": dc, + "size": size - 1, + }) + self.shots = remaining_shots + return reward + + def _lose_ship(self) -> None: + self.lives -= 1 + self.ship = [5, 5] + self.previous_ship = self.ship.copy() + self.velocity = [0, 0] + self.shots.clear() + if self.lives <= 0: + self.terminal = True + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.ship, 0] = True + for asteroid in self.asteroids: + row, column = int(asteroid["row"]), int(asteroid["column"]) + state[row, column, 1] = True + state[row, column, 2] = True + size = int(asteroid["size"]) + state[row, (column + size - 1) % 10, 5] = True + for shot in self.shots: + state[shot[0], shot[1], 3] = True + for row, column in self.previous_asteroids: + state[row, column, 4] = True + state[*self.previous_ship, 4] = True + state[9, : self.lives, 5] = True + state[8, : self.wave + 1, 5] = True + velocity_marker = (self.velocity[0] + 1) * 3 + self.velocity[1] + 1 + state[7, velocity_marker, 5] = True + state[6, self.direction, 5] = True + return state diff --git a/runtime/minatar_synth/games/atlantis.py b/runtime/minatar_synth/games/atlantis.py new file mode 100644 index 0000000000000000000000000000000000000000..942d7df73efa11f136d9e5c729006163ea913878 --- /dev/null +++ b/runtime/minatar_synth/games/atlantis.py @@ -0,0 +1,158 @@ +import numpy as np + + +class AtlantisEnvironment: + """Three fixed defense posts protect seven installations from descending formations.""" + + score_cap = 35_500.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 1_500): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.installations = [True] * 7 + self.shots: list[list[int | str]] = [] + self.wave = 0 + self.wave_step = 0 + self.steps = 0 + self.total_score = 0.0 + self.restorations_used = 0 + self.last_action = 0 + self.terminal = False + self.escaped = False + self._start_wave() + + def _start_wave(self) -> None: + self.enemies = [ + {"row": index // 5, "column": (index * 2) % 10, "direction": 1, "bandit": index == 8} + for index in range(9) + ] + self.previous_enemies = [[int(enemy["row"]), int(enemy["column"])] for enemy in self.enemies] + self.wave_step = 0 + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + if action == 1: + self.shots.append([8, 1, -1, 1, "sentry"]) + elif action == 3: + self.shots.append([8, 8, -1, -1, "sentry"]) + elif action == 5 and self.installations[0]: + self.shots.append([8, 5, -1, 0, "command"]) + + self.previous_enemies = [[int(enemy["row"]), int(enemy["column"])] for enemy in self.enemies] + self._move_enemies() + self._move_shots() + reward = self._resolve_hits() + self._resolve_deathrays() + self.wave_step += 1 + self.steps += 1 + if not any(self.installations): + self.escaped = True + self.terminal = True + elif not self.enemies: + bonus = 500.0 * sum(self.installations) + reward += bonus + self.total_score += bonus + self._restore_installations() + self.wave += 1 + if self.wave == 5: + self.terminal = True + else: + self._start_wave() + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _move_enemies(self) -> None: + if self.wave_step % max(1, 4 - min(self.wave, 2)) != 0: + return + for enemy in self.enemies: + column = int(enemy["column"]) + int(enemy["direction"]) + if column < 0 or column > 9: + enemy["direction"] = -int(enemy["direction"]) + enemy["row"] = int(enemy["row"]) + 1 + column = min(9, max(0, column)) + enemy["column"] = column + + def _move_shots(self) -> None: + for shot in self.shots: + shot[0] = int(shot[0]) + int(shot[2]) + shot[1] = int(shot[1]) + int(shot[3]) + self.shots = [shot for shot in self.shots if 0 <= int(shot[0]) < 10 and 0 <= int(shot[1]) < 10] + + def _resolve_hits(self) -> float: + reward = 0.0 + remaining_shots = [] + for shot in self.shots: + hit = next( + (enemy for enemy in self.enemies if [enemy["row"], enemy["column"]] == shot[:2]), + None, + ) + if hit is None: + remaining_shots.append(shot) + continue + sentry = shot[4] == "sentry" + if bool(hit["bandit"]): + reward += 2_000.0 if sentry else 1_000.0 + self.enemies.clear() + remaining_shots = [] + break + reward += 200.0 if sentry else 100.0 + self.enemies.remove(hit) + self.shots = remaining_shots + self.total_score += reward + return reward + + def _resolve_deathrays(self) -> None: + attackers = [enemy for enemy in self.enemies if int(enemy["row"]) >= 8] + for enemy in attackers: + live = [index for index, intact in enumerate(self.installations) if intact] + if live: + target = 0 if self.installations[0] else live[int(self.random.randint(len(live)))] + self.installations[target] = False + self.enemies.remove(enemy) + + def _restore_installations(self) -> None: + available = int(self.total_score // 10_000) - self.restorations_used + while available > 0 and not all(self.installations): + target = next(index for index, intact in enumerate(self.installations) if not intact) + self.installations[target] = True + self.restorations_used += 1 + available -= 1 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[9, 0, 0] = True + state[9, 9, 0] = True + if self.installations[0]: + state[9, 5, 0] = True + for enemy in self.enemies: + row, column = int(enemy["row"]), int(enemy["column"]) + state[row, column, 1] = True + state[row, column, 2] = True + if bool(enemy["bandit"]): + state[row, column, 5] = True + for shot in self.shots: + state[int(shot[0]), int(shot[1]), 3] = True + for row, column in self.previous_enemies: + if 0 <= row < 10 and 0 <= column < 10: + state[row, column, 4] = True + for index, intact in enumerate(self.installations): + state[9, index + 1, 5] = intact + state[8, : self.wave + 1, 5] = True + return state diff --git a/runtime/minatar_synth/games/attack_chain.py b/runtime/minatar_synth/games/attack_chain.py new file mode 100644 index 0000000000000000000000000000000000000000..ec31bf423345810e3cb24d6c089720ee79654ece --- /dev/null +++ b/runtime/minatar_synth/games/attack_chain.py @@ -0,0 +1,118 @@ +from math import sqrt + +import numpy as np + + +HORIZON = 400 +CARDS = 6 +CHAINS_PER_DEAL = 7 +RED, GREEN, BLUE = range(3) +PRESSURE_LIMIT = 300 + + +class AttackChainEnvironment: + # One chain per two steps at most, and no card reaches 200 damage. + score_cap = (HORIZON // 2) * (99 + 250) * (1 + HORIZON // 2) + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.pressure = self.total = self.turn = self.chains = 0 + self.cooldown = self.pending = 0 + self.last_type = -1 + self.last_action = 0 + self.multiplier = 1 + self.terminal = False + self._deal() + + def _deal(self) -> None: + green_left = 2 + self.types = [] + for _ in range(CARDS): + if green_left and self.random.random() < 0.2: + self.types.append(GREEN) + green_left -= 1 + else: + self.types.append(int(self.random.choice((RED, BLUE)))) + scale = 4 + sqrt(min(20, self.multiplier)) + self.values = [int(value * scale) for value in self.random.integers(3, 7, size=CARDS)] + self.available = [True] * CARDS + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.steps += 1 + self.pressure += 1 + reward = 0 + if self.cooldown: + self.cooldown = 0 + self.total += self.pending + self.pending = 0 + if self.total >= 100 or not any(self.available): + reward = self._settle() + elif self.pressure >= PRESSURE_LIMIT: + self.terminal = True + elif self.available[action]: + self.pressure += 4 + self.available[action] = False + value, color = self.values[action], self.types[action] + if color == RED and self.turn == 0: + value = value * 5 // 4 + elif color == GREEN: + value = min(value, 99 - self.total) + self.pending = value + self.cooldown = 1 + self.last_type = color + self.turn += 1 + self.values[action] = self.values[action] * 11 // 10 + 10 + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _settle(self) -> int: + reward = self.total * self.multiplier + excess = max(0, self.total - 115) + self.pressure = max(0, self.pressure - int(excess * sqrt(excess / self.multiplier))) + returns = sum(self.total >= threshold for threshold in (100, 150, 200)) + unavailable = [index for index, ready in enumerate(self.available) if not ready] + if returns and unavailable and self.last_type == BLUE: + best = max(unavailable, key=self.values.__getitem__) + self.available[best] = True + unavailable.remove(best) + returns -= 1 + for index in self.random.permutation(unavailable)[:returns]: + self.available[index] = True + self.chains += 1 + if not any(self.available) or self.chains == CHAINS_PER_DEAL: + self.chains = 0 + self.multiplier += 1 + self._deal() + self.total = self.turn = 0 + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for index, (color, value, ready) in enumerate(zip(self.types, self.values, self.available, strict=True)): + state[9, index, color] = True + state[9, index, 3] = ready + for bit in range(8): + state[bit, index, 4] = bool(value & (1 << bit)) + values = (self.pressure, self.total, self.turn, self.chains, self.multiplier, + self.pending, self.cooldown, self.last_type + 1, self.steps, self.last_action) + for row, value in enumerate(values): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/b_blast.py b/runtime/minatar_synth/games/b_blast.py new file mode 100644 index 0000000000000000000000000000000000000000..fb307bb74ea172ba4466330730351010685d86e8 --- /dev/null +++ b/runtime/minatar_synth/games/b_blast.py @@ -0,0 +1,121 @@ +from dataclasses import dataclass + +import numpy as np + + +HORIZON = 300 +RED_INTERVAL = 12 +ORDINARY_INTERVAL = 4 +MAX_RED = (HORIZON + RED_INTERVAL - 1) // RED_INTERVAL +MAX_BALLS = HORIZON // ORDINARY_INTERVAL + 10 * MAX_RED +MOVES = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)} + + +@dataclass +class Ball: + row: int + column: int + red: bool = False + + +class BBlastEnvironment: + score_cap = MAX_BALLS * (MAX_BALLS + 1) // 2 + 10 * MAX_RED + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.cursor = (5, 5) + self.center = self.cursor + self.steps = self.last_action = self.charge = self.cooldown = 0 + self.balls: list[Ball] = [] + self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + self.steps += 1 + self.cooldown = max(0, self.cooldown - 1) + reward = 0 + if action == 5: + if not self.charge: + self.center = self.cursor + self.charge = 1 + elif not self.cooldown or self.steps % 3 == 0: + self.charge = min(12, self.charge + 1) + else: + if self.charge: + reward += self._blast() + if action in MOVES: + dr, dc = MOVES[action] + row, column = self.cursor + self.cursor = max(0, min(9, row + dr)), max(0, min(9, column + dc)) + self.last_action = action + if self.steps % RED_INTERVAL == 1: + self.balls.append(Ball(1, int(self.random.integers(2, 8)), True)) + if self.steps % ORDINARY_INTERVAL == 0: + self.balls.append(Ball(int(self.random.integers(2, 8)), int(self.random.integers(1, 9)))) + if self.steps % 2 == 0: + reward += self._settle() + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _blast(self) -> int: + row, column = self.center + hit = [ball for ball in self.balls + if (ball.row - row) ** 2 + (ball.column - column) ** 2 <= (self.charge / 2 + 0.5) ** 2] + removed = {id(ball) for ball in hit} + self.balls = [ball for ball in self.balls if id(ball) not in removed] + for ball in hit: + if ball.red: + self.balls.extend(Ball(max(0, min(9, ball.row + dr)), max(0, min(9, ball.column + dc))) + for dr in (-1, 0, 1) for dc in (-1, 0, 1)) + self.charge = 0 + self.cooldown = 6 + return len(hit) * (len(hit) + 1) // 2 + + def _settle(self) -> int: + reward = 0 + occupied: set[tuple[int, int]] = set() + for ball in sorted(self.balls, key=lambda item: -item.row): + options = [(ball.row + 1, ball.column), (ball.row, ball.column), + (ball.row, ball.column - 1), (ball.row, ball.column + 1), + (ball.row - 1, ball.column)] + for row, column in options: + if 0 <= row < 10 and 0 <= column < 10 and (row, column) not in occupied: + ball.row, ball.column = row, column + occupied.add((row, column)) + break + if ball.red and ball.row == 9: + reward += 10 + ball.red = False + if ball.row == 0: + self.terminal = True + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.cursor, 0] = True + for ball in self.balls: + state[ball.row, ball.column, 1 if ball.red else 2] = True + if self.charge: + state[*self.center, 3] = True + rows, columns = np.ogrid[:10, :10] + state[:, :, 4] = ((rows - self.center[0]) ** 2 + (columns - self.center[1]) ** 2 + <= (self.charge / 2 + 0.5) ** 2) + for row, value in enumerate((self.steps, self.charge, self.cooldown, self.last_action)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/b_cannon.py b/runtime/minatar_synth/games/b_cannon.py new file mode 100644 index 0000000000000000000000000000000000000000..df281230589a7f7bdc24f9c32dda2fe641d110a9 --- /dev/null +++ b/runtime/minatar_synth/games/b_cannon.py @@ -0,0 +1,159 @@ +from dataclasses import dataclass + +import numpy as np + + +HORIZON = 400 +WAVE_DELAY = 8 +MAX_WAVE = 4 +PERIMETER = ( + tuple((9, x) for x in range(10)) + + tuple((y, 9) for y in range(8, -1, -1)) + + tuple((0, x) for x in range(8, -1, -1)) + + tuple((y, 0) for y in range(1, 9)) +) + + +@dataclass +class Ball: + row: int + column: int + dy: int + dx: int + size: int = 3 + immunity: int = 0 + + +class BCannonEnvironment: + score_cap = HORIZON // WAVE_DELAY * MAX_WAVE * 8 * 99 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.last_action = self.held = self.wave_size = self.ball_index = 0 + self.perimeter_index, self.direction = 5, 1 + self.wave_max, self.ball_period, self.wave_wait = 2, 3, WAVE_DELAY + self.balls: list[Ball] = [] + self.rope: list[tuple[int, int]] = [] + self.rope_length = 0 + self.terminal = False + + @property + def player(self) -> tuple[int, int]: + return PERIMETER[self.perimeter_index] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def _aim(self) -> tuple[int, int] | None: + if not self.balls: + return None + row, column = self.player + ball = min(self.balls, key=lambda item: (item.row - row) ** 2 + (item.column - column) ** 2) + return max(1, min(8, ball.row + ball.dy)), max(1, min(8, ball.column + ball.dx)) + + def _fire(self, target: tuple[int, int]) -> None: + row, column = self.player + dy, dx = target[0] - row, target[1] - column + scale = max(abs(dy), abs(dx)) + self.rope = [] + for distance in range(1, 11): + cell = row + round(dy * distance / scale), column + round(dx * distance / scale) + if not all(0 < coordinate < 9 for coordinate in cell): + break + self.rope.append(cell) + self.rope_length = 1 + + def _spawn_wave(self) -> None: + self.wave_size += 1 + if self.wave_size > self.wave_max: + self.wave_size = 1 + self.wave_max = min(MAX_WAVE, self.wave_max + 1) + self.ball_period = max(1, self.ball_period - 1) + start = int(self.random.integers(1, 3)) + self.balls = [Ball(3, start + 2 * index, 1, 0) for index in range(self.wave_size)] + self.ball_index = (self.ball_index + self.wave_size) % 100 + self.wave_wait = WAVE_DELAY + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + if action == 5 and self.last_action != 5: + self.direction *= -1 + self.last_action = action + self.steps += 1 + if action == 5: + if self.balls: + self.held += 1 + target = self._aim() + if self.held == 3 and target is not None: + self._fire(target) + else: + self.held = 0 + self.perimeter_index = (self.perimeter_index + self.direction) % len(PERIMETER) + reward = self._advance_balls() + if self.rope: + self.rope_length += 1 + if self.rope_length > len(self.rope) + 1: + self.rope.clear() + self.rope_length = 0 + if not self.balls: + self.wave_wait -= 1 + if self.wave_wait == 0: + self._spawn_wave() + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_balls(self) -> int: + reward = 0 + remaining = [] + rope = set(self.rope[:self.rope_length]) + for ball in self.balls: + if self.steps % self.ball_period == 0: + if not 0 <= ball.row + ball.dy < 10: + ball.dy *= -1 + if not 0 <= ball.column + ball.dx < 10: + ball.dx *= -1 + ball.row += ball.dy + ball.column += ball.dx + ball.immunity = max(0, ball.immunity - 1) + cell = ball.row, ball.column + if cell in rope and not ball.immunity: + if ball.size == 0: + reward += self.ball_index + else: + remaining.extend(Ball(*cell, -ball.dy or 1, dx, ball.size - 1, 3) for dx in (-1, 1)) + self.ball_index = (self.ball_index + 2) % 100 + else: + self.terminal |= cell == self.player + remaining.append(ball) + self.balls = remaining + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + for ball in self.balls: + state[ball.row, ball.column, 1] = True + state[ball.row, ball.column, 2] |= ball.immunity > 0 + for cell in self.rope[:self.rope_length]: + state[*cell, 3] = True + target = self._aim() + if target is not None: + state[*target, 4] = True + values = (self.steps, self.held, self.wave_size, self.wave_max, self.wave_wait, + self.ball_period, self.ball_index, int(self.direction > 0), int(self.last_action == 5)) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/b_math.py b/runtime/minatar_synth/games/b_math.py new file mode 100644 index 0000000000000000000000000000000000000000..6a774abe4549812391bdb63cb3d54636492453da --- /dev/null +++ b/runtime/minatar_synth/games/b_math.py @@ -0,0 +1,98 @@ +import numpy as np + + +HORIZON = 400 +FULL_TIME = 60 +FEEDBACK_STEPS = 3 +MAX_ANSWERS = (HORIZON + FEEDBACK_STEPS) // (FEEDBACK_STEPS + 1) + + +class BMathEnvironment: + score_cap = 57 * MAX_ANSWERS * (MAX_ANSWERS + 1) // 2 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.questions = self.feedback = self.last_action = 0 + self.time = FULL_TIME + self.multiplier = 1 + self.correct = False + self.selected = 0 + self.terminal = False + self._question() + + def _question(self) -> None: + self.operation = int(self.random.integers(min(4, 1 + self.questions // 5))) + if self.operation < 2: + total = int(self.random.integers(10, 100)) + part = int(self.random.integers(1, total)) + self.left, self.right, self.answer = ( + (part, total - part, total) if self.operation == 0 else (total, part, total - part) + ) + else: + factor = int(self.random.integers(2, 10)) + quotient = int(self.random.integers(2, 99 // factor + 1)) + product = factor * quotient + self.left, self.right, self.answer = ( + (quotient, factor, product) if self.operation == 2 else (product, factor, quotient) + ) + distractors = [value for value in range(max(1, self.answer - 7), min(99, self.answer + 7) + 1) + if value != self.answer] + choices = self.random.choice(distractors, size=4, replace=False) + self.options = self.random.permutation([self.answer, *choices]).tolist() + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.steps += 1 + reward = 0 + if self.feedback: + self.feedback -= 1 + if not self.feedback: + self._question() + elif 1 <= action <= 5: + reward = (57 * self.time * self.multiplier + FULL_TIME - 1) // FULL_TIME + self.correct = self.options[action - 1] == self.answer + self.selected = action + if self.correct: + self.time += 30 + if self.time >= FULL_TIME: + self.multiplier += 1 + else: + self.time -= 15 + self.multiplier = max(1, self.multiplier - 1) + self.time = min(FULL_TIME, self.time) + self.feedback = FEEDBACK_STEPS + self.questions += 1 + self.time = max(0, self.time - 1) + self.terminal = self.time == 0 or self.steps >= self.horizon + return float(reward), self.terminal + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[self.operation, 0, 0] = True + for row, value in enumerate((self.left, self.right, *self.options)): + for bit in range(8): + state[row, bit, 1] = bool(value & (1 << bit)) + if self.feedback: + state[0, self.selected, 2] = True + state[int(self.correct), 0, 3] = True + for row, value in enumerate((self.time, self.multiplier, self.questions, + self.feedback, self.steps, self.last_action)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/b_walls.py b/runtime/minatar_synth/games/b_walls.py new file mode 100644 index 0000000000000000000000000000000000000000..8e8a7a39b4b363c2038dfcbad919b4c74c97b09b --- /dev/null +++ b/runtime/minatar_synth/games/b_walls.py @@ -0,0 +1,118 @@ +from dataclasses import dataclass + +import numpy as np + + +HORIZON = 400 +COLUMN = 5 +PLAYER_ROW = 9 +PHASE_LENGTH = 6 + + +@dataclass +class Wall: + row: int + phase: int + width: int + period: int + direction: int + + def blocks(self, column: int) -> bool: + return (column - self.phase) % self.period < self.width + + +class BWallsEnvironment: + score_cap = HORIZON * 2 ** (PLAYER_ROW - 1) + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.wall_clock = self.last_action = self.travel = 0 + self.multiplier = 1 + self.shot: int | None = None + self.terminal = False + self.walls: list[Wall] = [] + self._spawn(3) + self._spawn(0) + + def _spawn(self, row: int) -> None: + width = int(self.random.integers(1, 3)) + period = width + int(self.random.integers(2, 5)) + self.walls.append(Wall(row, int(self.random.integers(period)), width, period, + int(self.random.choice((-1, 1))))) + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + @property + def stopped(self) -> bool: + return self.wall_clock // PHASE_LENGTH % 2 == 1 + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + if action == 5 and self.last_action != 5 and self.shot is None: + self.shot = PLAYER_ROW + self.multiplier = 1 + self.last_action = action + self.steps += 1 + moving = not self.stopped + if moving: + for wall in self.walls: + wall.phase = (wall.phase + wall.direction) % wall.period + + near_launch = self.shot is not None and self.shot >= 7 + if near_launch or self.steps % (5 if self.steps < 200 else 4) == 0: + self.travel += 1 + for wall in self.walls: + wall.row += 1 + if self.travel % 3 == 0: + self._spawn(0) + + reward = 0 + if self.shot is not None: + self.shot -= 1 + if self.shot < 0 or any(wall.row == self.shot and wall.blocks(COLUMN) for wall in self.walls): + self.shot = None + else: + for wall in self.walls: + if wall.row - 1 == self.shot: + reward = self.multiplier + self.multiplier *= 2 + self.walls.remove(wall) + break + if moving and self.shot < max((wall.row for wall in self.walls), default=-2) + 1: + self.shot = None + if self.shot is None: + self.wall_clock += 1 + self.terminal = any(wall.row == PLAYER_ROW and wall.blocks(COLUMN) for wall in self.walls) + self.walls = [wall for wall in self.walls if wall.row <= PLAYER_ROW] + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[PLAYER_ROW, COLUMN, 0] = True + if self.shot is not None: + state[self.shot, COLUMN, 3] = True + for wall in self.walls: + for column in range(10): + state[wall.row, column, 1] = wall.blocks(column) + state[wall.row, column, 4] = (column - wall.phase - wall.direction) % wall.period < wall.width + if wall.row > 0: + state[wall.row - 1, COLUMN, 2] = True + for row, value in enumerate((self.steps, self.wall_clock % (2 * PHASE_LENGTH), + self.travel % 3, self.multiplier, self.last_action)): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/balance.py b/runtime/minatar_synth/games/balance.py new file mode 100644 index 0000000000000000000000000000000000000000..de8522f77cb253dbcee480f22a56817c4a4bbaf6 --- /dev/null +++ b/runtime/minatar_synth/games/balance.py @@ -0,0 +1,111 @@ +from math import ceil, cos, sin + +import numpy as np + + +HORIZON = 400 +SPAWN_INTERVAL = 6 +FLOOR = 9 +MIN_LENGTH = 20 +MAX_LENGTH = 64 + + +class BalanceEnvironment: + score_cap = ((HORIZON + SPAWN_INTERVAL - 1) // SPAWN_INTERVAL) * 3 * MAX_LENGTH + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.last_action = 0 + self.base = self.cursor = 4.5 + self.velocity = self.angle = self.angular_velocity = self.wind = 0.0 + self.length = MIN_LENGTH + self.coin_column = float(self.random.choice((2, 7))) + self.coins: list[tuple[float, float, float]] = [] + self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + @property + def tip(self) -> tuple[float, float]: + return FLOOR - cos(self.angle) * self.length / 8, self.base + sin(self.angle) * self.length / 8 + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.steps += 1 + self.cursor = max(0.0, min(9.0, self.cursor + (1 if action == 3 else -1 if action == 1 else 0))) + self.wind = 0.94 * (self.wind + float(self.random.uniform(-0.025, 0.025))) + self.velocity = 0.90 * (self.velocity + 0.08 * (self.cursor - self.base) - self.wind) + self.base += self.velocity + self.angular_velocity = 0.88 * (self.angular_velocity - 0.16 * self.velocity + + self.angle * self.length / 800) + self.angle += self.angular_velocity + row, column = self.tip + shift = (4.5 - column) * 0.18 + self.base += shift + self.cursor = max(0.0, min(9.0, self.cursor + shift)) + if row >= FLOOR - 0.25: + self.length /= 2 + self.angular_velocity *= -0.5 + if self.length < MIN_LENGTH: + self.terminal = True + return 0.0, True + self.angle /= 2 + if self.steps % SPAWN_INTERVAL == 1: + self.coins.append((0.0, self.coin_column, float(self.random.uniform(-0.15, 0.15)))) + self.coin_column = (self.coin_column + shift + float(self.random.uniform(-0.6, 0.6))) % 10 + + row, column = self.tip + reward = 0 + remaining = [] + for y, x, drift in self.coins: + y += 0.5 + drift = 0.96 * (drift + self.wind / 2) + x += drift + shift + tip_hit = abs(y - row) <= 0.45 and abs(x - column) <= 0.55 + fraction = (FLOOR - y) / max(0.01, FLOOR - row) + shaft_x = self.base + (column - self.base) * fraction + if tip_hit or (0 <= fraction <= 1 and abs(x - shaft_x) <= 0.45): + for _ in range(3 if tip_hit else 1): + reward += ceil(self.length) + self.length = min(MAX_LENGTH, self.length + 1) + elif y < FLOOR: + remaining.append((y, x, drift)) + self.coins = remaining + self.terminal = self.steps >= self.horizon + return float(reward), self.terminal + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row, column = self.tip + state[min(9, max(0, round(row))), min(9, max(0, round(column))), 0] = True + state[FLOOR, :, 1] = True + for y, x, _ in self.coins: + if 0 <= round(x) < 10: + state[round(y), round(x), 2] = True + for fraction in np.linspace(0, 1, 16): + x = round(self.base + fraction * (column - self.base)) + y = round(FLOOR + fraction * (row - FLOOR)) + if 0 <= x < 10 and 0 <= y < 10: + state[y, x, 3] = True + state[FLOOR, round(self.cursor), 4] = True + values = (self.steps, round(self.length * 4), round(self.angle * 64) + 256, + round(self.angular_velocity * 128) + 256, round(self.velocity * 32) + 256, + round(self.wind * 512) + 256, self.last_action) + for row, value in enumerate(values): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/ball_tour.py b/runtime/minatar_synth/games/ball_tour.py new file mode 100644 index 0000000000000000000000000000000000000000..f520e028534d5def1096b54ce9f751fb8f29ab93 --- /dev/null +++ b/runtime/minatar_synth/games/ball_tour.py @@ -0,0 +1,108 @@ +import numpy as np + + +ORBIT = (5, 6, 7, 8, 8, 8, 7, 6, 5, 4, 3, 2, 2, 2, 3, 4) +HORIZON = 500 + + +class BallTourEnvironment: + # A ball is spawned no more often than every three columns of travel. + score_cap = 999 * ((HORIZON + 2) // 3) + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.distance = self.scroll_fraction = self.last_action = 0 + self.next_spike = 1 + self.next_ball = 2 + self.multiplier = 100 + self.spikes: list[tuple[int, int, int]] = [] + self.balls: list[tuple[int, int]] = [] + self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + @property + def row(self) -> int: + return ORBIT[self.steps % len(ORBIT)] + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.steps += 1 + self.scroll_fraction += 10 if action == 5 else 1 + advance, self.scroll_fraction = divmod(self.scroll_fraction, 10) + self.distance += advance + moved_spikes = [] + for row, column, velocity in self.spikes: + column += advance + if column > 9: + continue + if velocity and self.steps % 4 == 0: + if not 1 <= row + velocity <= 8: + velocity = -velocity + row += velocity + moved_spikes.append((row, column, velocity)) + self.spikes = moved_spikes + if self.distance == self.next_spike: + row = int(self.random.integers(1, 9)) + velocity = int(self.random.choice((-1, 1))) if self.random.random() < 0.2 else 0 + self.spikes.append((row, 0, velocity)) + self.next_spike += int(self.random.integers(1, 6)) + self.terminal = any(column == 9 and row == self.row - 1 for row, column, _ in self.spikes) + if self.terminal: + return 0.0, True + reward = 0 + remaining = [] + for row, column in self.balls: + column += advance + if column == 9 and row in (self.row - 1, self.row): + reward += self.multiplier // 100 + self.multiplier = min(99_900, self.multiplier + 1_000) + elif column <= 9: + remaining.append((row, column)) + self.balls = remaining + if self.distance == self.next_ball: + row = int(self.random.integers(2, 8)) + if any(spike_row == row and column == 0 for spike_row, column, _ in self.spikes): + self.next_ball += 1 + else: + self.balls.append((row, 0)) + self.next_ball += int(self.random.integers(3, 8)) + self.multiplier = max(100, self.multiplier - 2) + self.terminal = self.steps >= self.horizon + return float(reward), self.terminal + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[self.row, 9, 0] = True + state[self.row - 1, 9, 3] = True + state[ORBIT[(self.steps + 1) % len(ORBIT)], 9, 4] = True + for row, column in self.balls: + state[row, column, 2] = True + for row, column, velocity in self.spikes: + state[row, column, 1] = True + state[row, column, 4] = velocity == 1 + state[row, column, 5] = velocity == -1 + gauges = ((self.steps, 9), (self.scroll_fraction, 4), (self.multiplier, 17), + (self.next_spike - self.distance, 3), (self.next_ball - self.distance, 3), + (int(self.last_action == 5), 1)) + offset = 0 + for value, width in gauges: + for bit in range(width): + index = offset + bit + state[index // 9, index % 9, 3] = bool(value & (1 << bit)) + offset += width + return state diff --git a/runtime/minatar_synth/games/balloon.py b/runtime/minatar_synth/games/balloon.py new file mode 100644 index 0000000000000000000000000000000000000000..63d4dd18feef370dd42894bf99d5f491e8aff393 --- /dev/null +++ b/runtime/minatar_synth/games/balloon.py @@ -0,0 +1,124 @@ +from dataclasses import dataclass +from math import hypot + +import numpy as np + + +HORIZON = 400 +BONUS_INTERVAL = 8 +BALLOON_INTERVAL = 28 +MAX_BONUSES = (HORIZON + BONUS_INTERVAL - 1) // BONUS_INTERVAL +MOVES = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)} + + +@dataclass +class Balloon: + row: float + column: float + drift: float + rise: float = -0.24 + radius: float = 1.8 + + +@dataclass +class Bonus: + row: float + column: float + balloon: Balloon | None = None + + +class BalloonEnvironment: + score_cap = MAX_BONUSES * (MAX_BONUSES + 1) // 2 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.last_action = 0 + self.cursor = (5, 5) + self.wind = (0.0, 0.0) + self.balloons: list[Balloon] = [] + self.bonuses: list[Bonus] = [] + self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.steps += 1 + row, column = self.cursor + dr, dc = MOVES.get(action, (0, 0)) + self.cursor = max(0, min(9, row + dr)), max(0, min(9, column + dc)) + self.wind = (0.5 * self.wind[0] + 0.25 * (self.cursor[0] - row), + 0.5 * self.wind[1] + 0.25 * (self.cursor[1] - column)) + if self.steps % BALLOON_INTERVAL == 1: + self.balloons.append(Balloon(9.5, float(self.random.uniform(2, 7)), + float(self.random.uniform(-0.12, 0.12)))) + if self.steps % BONUS_INTERVAL == 1: + self.bonuses.append(Bonus(0.0, float(self.random.uniform(1, 8)))) + for balloon in self.balloons: + if hypot(balloon.row - self.cursor[0], balloon.column - self.cursor[1]) < balloon.radius: + balloon.rise += self.wind[0] + balloon.drift += self.wind[1] + balloon.row += balloon.rise + balloon.column += balloon.drift + if not balloon.radius <= balloon.column <= 9 - balloon.radius: + balloon.column = max(balloon.radius, min(9 - balloon.radius, balloon.column)) + balloon.drift *= -0.7 + if balloon.row > 10 - balloon.radius and balloon.rise > 0: + balloon.rise *= -0.7 + balloon.drift *= 0.9 + balloon.rise += 0.15 * (-0.24 - balloon.rise) + balloon.radius -= 0.015 * hypot(balloon.drift, balloon.rise) + self.balloons = [balloon for balloon in self.balloons + if balloon.row >= balloon.radius and balloon.radius >= 0.8] + alive = {id(balloon) for balloon in self.balloons} + collected = 0 + remaining = [] + for bonus in self.bonuses: + if bonus.balloon is None: + bonus.row += 0.22 + for balloon in self.balloons: + if hypot(balloon.row - bonus.row, balloon.column - bonus.column) < 1.3 * balloon.radius: + bonus.balloon = balloon + break + if bonus.balloon is None and bonus.row >= 10: + self.terminal = True + if bonus.balloon is not None: + if id(bonus.balloon) not in alive: + collected += 1 + continue + bonus.row, bonus.column = bonus.balloon.row, bonus.balloon.column + remaining.append(bonus) + self.bonuses = remaining + self.terminal |= self.steps >= self.horizon + return float(collected * (collected + 1) // 2), self.terminal + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.cursor, 0] = True + rows, columns = np.ogrid[:10, :10] + for balloon in self.balloons: + state[:, :, 1] |= (rows - balloon.row) ** 2 + (columns - balloon.column) ** 2 <= balloon.radius ** 2 + state[max(0, min(9, round(balloon.row + balloon.rise))), + max(0, min(9, round(balloon.column + balloon.drift))), 4] = True + for bonus in self.bonuses: + state[max(0, min(9, round(bonus.row))), round(bonus.column), 3 if bonus.balloon else 2] = True + values = (self.steps, round(self.wind[0] * 64) + 32, + round(self.wind[1] * 64) + 32, self.last_action) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/balls_bombs.py b/runtime/minatar_synth/games/balls_bombs.py new file mode 100644 index 0000000000000000000000000000000000000000..2e10a23399e786dd9362b3a94c8326e2a14cc620 --- /dev/null +++ b/runtime/minatar_synth/games/balls_bombs.py @@ -0,0 +1,129 @@ +from dataclasses import dataclass + +import numpy as np + + +HORIZON = 400 +GROUND = 32 +UNIT = 4 +SPAWN_INTERVAL = 5 +MAX_BALLS = (HORIZON + SPAWN_INTERVAL - 1) // SPAWN_INTERVAL + + +@dataclass +class Ball: + x: int + y: int + vx: int + vy: int = 0 + + +class BallsBombsEnvironment: + score_cap = MAX_BALLS * (MAX_BALLS + 1) // 2 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.last_action = self.scroll = 0 + self.player = 2 + self.next_bomb = 6 + self.bomb: int | None = None + self.armed = False + self.blast: tuple[int, int] | None = None + self.multiplier = 1 + self.balls: list[Ball] = [] + self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.steps += 1 + if action == 5: + self.player += 1 + self.scroll = max(0, self.player - 4) + if not self.armed and self.bomb is None and self.player >= self.next_bomb: + self.bomb = self.scroll + 9 + if self.bomb == self.player: + self.armed = True + self.bomb = None + self.next_bomb = self.player + int(self.random.integers(9, 13)) + if self.blast is not None: + center, radius = self.blast + self.blast = (center, radius + 1) if radius < 6 else None + if self.blast is None: + self.multiplier = 1 + if self.steps % SPAWN_INTERVAL == 1: + from_left = self.random.random() < 0.1 + self.balls.append(Ball(self.scroll + (0 if from_left else 9), + int(self.random.integers(5, 17)), 1 if from_left else -1)) + reward = 0 + survivors = [] + for ball in self.balls: + ball.vy += 1 + ball.y += ball.vy + if ball.y >= GROUND: + ball.y = GROUND + ball.vy = -ball.vy + if self.steps % 2 == 0: + ball.x += ball.vx + if ball.x <= self.scroll and ball.vx < 0: + ball.vx = 2 + elif ball.x >= self.scroll + 9 and ball.vx > 0: + ball.vx = -1 + if self._in_blast(ball.y // UNIT, ball.x): + reward += self.multiplier + self.multiplier += 1 + elif ball.x == self.player and ball.y // UNIT == GROUND // UNIT: + if self.armed: + self.armed = False + self.blast = self.player, 1 + else: + self.terminal = True + elif ball.x >= self.scroll - 2: + survivors.append(ball) + self.balls = survivors + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _in_blast(self, row: int, x: int) -> bool: + if self.blast is None: + return False + center, radius = self.blast + distance_squared = (x - center) ** 2 + (GROUND // UNIT - row) ** 2 + return (radius - 0.75) ** 2 <= distance_squared <= (radius + 0.75) ** 2 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[GROUND // UNIT, self.player - self.scroll, 0] = True + for ball in self.balls: + column = ball.x - self.scroll + if 0 <= column < 10: + row = max(0, ball.y // UNIT) + state[row, column, 1] = True + state[row, column, 4] |= ball.vy < 0 + if self.bomb is not None and 0 <= self.bomb - self.scroll < 10: + state[GROUND // UNIT, self.bomb - self.scroll, 2] = True + if self.blast is not None: + for row in range(9): + for column in range(10): + state[row, column, 3] = self._in_blast(row, column + self.scroll) + values = (self.steps, self.multiplier, int(self.armed), self.player, + self.next_bomb, self.last_action, 0 if self.blast is None else self.blast[1]) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/bamboo.py b/runtime/minatar_synth/games/bamboo.py new file mode 100644 index 0000000000000000000000000000000000000000..73bb1bb98250679453bf74af5c7b7be7e7a0f6cb --- /dev/null +++ b/runtime/minatar_synth/games/bamboo.py @@ -0,0 +1,108 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 +MIN_SPAWN_INTERVAL = 70 +MAX_HARVEST = 100 +TRACK_WIDTH = 200 + + +@dataclass +class Stalk: + x: int + height: float = 0 + speed: float = 1 + + +class BambooEnvironment: + score_cap = math.ceil(HORIZON * FRAMES_PER_STEP / MIN_SPAWN_INTERVAL) * MAX_HARVEST + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.spawn_timer = 0 + self.pressed = self.terminal = False + self.x = 190.0 + self.direction = 1 + self.boost = 0.0 + self.stalks: list[Stalk] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed: + self.direction *= -1 + self.pressed = pressed + self.steps += 1 + reward = 0 + for _ in range(FRAMES_PER_STEP): + reward += self._advance_frame() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self) -> int: + self.x = (self.x + self.direction * (1 + self.boost)) % TRACK_WIDTH + self.boost *= 0.9 + if self.spawn_timer == 0: + self.stalks.append(Stalk(int(self.random.integers(5, 195)))) + self.spawn_timer = int(self.random.integers(MIN_SPAWN_INTERVAL, 101)) + self.spawn_timer -= 1 + + reward = 0 + survivors = [] + for stalk in self.stalks: + stalk.height += 0.14 * stalk.speed + distance = abs(self.x - stalk.x) + if not self.pressed and min(distance, TRACK_WIDTH - distance) <= 6: + if 5 <= stalk.height <= 25: + grade = math.ceil((stalk.height - 5) / 3) + reward += MAX_HARVEST if grade == 7 else grade**2 + continue + if stalk.height > 25: + stalk.height *= 0.7 + stalk.speed *= 0.6 + self.direction *= -1 + self.boost = min(5, self.boost + 1) + if stalk.height <= 25: + continue + if stalk.height > 50: + stalk.speed *= 0.997 + if stalk.height >= 89: + self.terminal = True + survivors.append(stalk) + self.stalks = survivors + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + column = int(self.x) // 20 + state[8, column, 0] = True + state[8, column, 1] = self.direction < 0 + for stalk in self.stalks: + column = stalk.x // 20 + height = max(1, math.ceil(stalk.height / 10)) + state[9 - height:9, column, 2] = True + state[9 - height, column, 3] |= 5 <= stalk.height <= 25 + state[9 - height, column, 4] |= 23 < stalk.height <= 25 + state[9, 0, 5] = self.pressed + for bit in range(9): + state[9, bit + 1, 5] = bool(self.steps & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/bank_heist.py b/runtime/minatar_synth/games/bank_heist.py new file mode 100644 index 0000000000000000000000000000000000000000..199995f046427f8e17ed633385a616de88bc905d --- /dev/null +++ b/runtime/minatar_synth/games/bank_heist.py @@ -0,0 +1,197 @@ +import numpy as np + + +ROADS = np.array([ + [1, 1, 1, 0, 0, 0, 1, 1, 1, 1], + [1, 0, 1, 1, 1, 1, 1, 0, 1, 0], + [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], + [1, 1, 1, 0, 1, 1, 1, 1, 1, 1], + [0, 0, 1, 0, 0, 0, 1, 0, 1, 0], + [1, 1, 1, 1, 1, 0, 1, 0, 1, 0], + [1, 0, 0, 0, 1, 0, 1, 1, 1, 0], + [1, 1, 1, 1, 1, 1, 1, 0, 1, 1], + [1, 0, 1, 0, 0, 0, 1, 0, 1, 0], + [1, 1, 1, 1, 1, 1, 1, 0, 1, 0], +], dtype=bool) +BANK_LOCATIONS = ((1, 2), (1, 6), (3, 4), (3, 8), (5, 2), (5, 6), (7, 4), (7, 8), (9, 2)) +TOWN_BONUSES = (93.0, 186.0, 279.0, 372.0) +DELTAS = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)} + + +class BankHeistEnvironment: + """Four-town robbery route with fuel, pursuing cops, and tailpipe dynamite.""" + + score_cap = 4_530.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 1_500): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.town = 0 + self.cars = 5 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self._start_town(full_fuel=True) + + def _start_town(self, full_fuel: bool) -> None: + previous_fuel = getattr(self, "fuel", 100) + self.fuel = 100 if full_fuel else max(previous_fuel, 50) + self.player = [9, 0] + self.previous_player = self.player.copy() + self.direction = 3 + self.cops: list[dict[str, object]] = [] + self.previous_cops: list[list[int]] = [] + self.dynamite: list[dict[str, int]] = [] + self.robbed = 0 + self.spawned_banks = 3 + self.banks = set(BANK_LOCATIONS[:3]) + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + if action in DELTAS: + self.direction = action + self._move_player(action) + elif action == 5 and self.fuel > 5: + row_delta, column_delta = DELTAS[self.direction] + self.dynamite.append({ + "row": (self.player[0] - row_delta) % 10, + "column": (self.player[1] - column_delta) % 10, + "timer": 2, + }) + self.fuel -= 5 + + reward = self._rob_bank() + self.previous_cops = [list(cop["position"]) for cop in self.cops] + self._move_cops() + reward += self._detonate_dynamite() + if any(list(cop["position"]) == self.player for cop in self.cops): + self._lose_car() + self.fuel -= 1 + if self.fuel <= 0: + self._lose_car() + if self.player == [0, 9]: + reward += self._leave_town() + self.steps += 1 + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _move_player(self, action: int) -> None: + row_delta, column_delta = DELTAS[action] + target = [self.player[0] + row_delta, self.player[1] + column_delta] + if self.player[0] in (3, 7) and target[1] < 0: + target[1] = 9 + elif self.player[0] in (3, 7) and target[1] > 9: + target[1] = 0 + if 0 <= target[0] < 10 and 0 <= target[1] < 10 and ROADS[*target]: + self.player = target + + def _rob_bank(self) -> float: + position = tuple(self.player) + if position not in self.banks: + return 0.0 + self.banks.remove(position) + self.robbed += 1 + if len(self.cops) < 3: + self.cops.append({"position": [*position], "previous": [*position]}) + return float(self.robbed * 10) + + def _move_cops(self) -> None: + for cop in self.cops: + position = list(cop["position"]) + previous = list(cop["previous"]) + candidates = [] + for action in DELTAS: + row_delta, column_delta = DELTAS[action] + target = [position[0] + row_delta, position[1] + column_delta] + if position[0] in (3, 7) and target[1] < 0: + target[1] = 9 + elif position[0] in (3, 7) and target[1] > 9: + target[1] = 0 + if 0 <= target[0] < 10 and 0 <= target[1] < 10 and ROADS[*target] and target != previous: + distance = abs(target[0] - self.player[0]) + abs(target[1] - self.player[1]) + candidates.append((distance, action, target)) + if candidates: + cop["previous"] = position + cop["position"] = min(candidates)[2] + + def _detonate_dynamite(self) -> float: + reward = 0.0 + remaining = [] + for stick in self.dynamite: + stick["timer"] -= 1 + if stick["timer"] > 0: + remaining.append(stick) + continue + blast = [stick["row"], stick["column"]] + if blast == self.player: + self._lose_car() + pursuit_count = len(self.cops) + value = {1: 10.0, 2: 30.0, 3: 50.0}.get(pursuit_count, 0.0) + destroyed = [cop for cop in self.cops if list(cop["position"]) == blast] + for cop in destroyed: + self.cops.remove(cop) + reward += value + if self.spawned_banks < 9: + self.banks.add(BANK_LOCATIONS[self.spawned_banks]) + self.spawned_banks += 1 + self.dynamite = remaining + return reward + + def _lose_car(self) -> None: + self.cars -= 1 + self.player = [9, 0] + self.previous_player = self.player.copy() + self.fuel = 100 + self.cops.clear() + self.dynamite.clear() + if self.cars <= 0: + self.terminal = True + + def _leave_town(self) -> float: + reward = TOWN_BONUSES[self.town] if self.robbed >= 9 else 0.0 + full_fuel = self.robbed >= 9 + if full_fuel: + self.cars += 1 + self.town += 1 + if self.town == 4: + self.terminal = True + else: + self._start_town(full_fuel=full_fuel) + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + for cop in self.cops: + state[*list(cop["position"]), 1] = True + for bank in self.banks: + state[*bank, 2] = True + state[0, 9, 2] = True + for stick in self.dynamite: + state[stick["row"], stick["column"], 3] = True + state[*self.previous_player, 4] = True + for position in self.previous_cops: + state[*position, 4] = True + state[9, : min(10, (self.fuel + 9) // 10), 5] = True + state[8, : min(10, self.cars), 5] = True + state[7, : self.town + 1, 5] = True + state[6, : min(9, self.robbed), 5] = True + return state diff --git a/runtime/minatar_synth/games/barge_hop.py b/runtime/minatar_synth/games/barge_hop.py new file mode 100644 index 0000000000000000000000000000000000000000..1d3753146ecdf70898f6043ccf58752250f8c185 --- /dev/null +++ b/runtime/minatar_synth/games/barge_hop.py @@ -0,0 +1,161 @@ +from dataclasses import dataclass +from itertools import combinations +import math + +import numpy as np + + +HORIZON = 400 +TIME_LIMIT = 1000 +FRAMES_PER_STEP = 4 + + +@dataclass +class Barge: + x: float + width: float + velocity: float + phase: float + frequency: float + amplitude: float + top: float = 65 + + +class BargeHopEnvironment: + score_cap = 1000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.frame = self.level = 0 + self.pressed = self.terminal = False + self.remaining = float(TIME_LIMIT) + self._setup_round() + + def _setup_round(self) -> None: + speed = 0.175 * (1 + math.sqrt(self.level * 0.3)) + self.barges = [ + Barge( + center + self.random.uniform(-4, 4), + float(self.random.integers(20, 29)), + float(self.random.choice((-1, 1))) * speed * self.random.uniform(0.9, 1.5), + self.random.uniform(0, math.tau), + self.random.uniform(0.02, 0.05), + self.random.uniform(1, 2), + ) + for center in (32, 75, 118) + ] + self._return_to_dock() + + def _return_to_dock(self) -> None: + self.x, self.feet = 8.0, 63.0 + self.vx = self.vy = 0.0 + self.grounded = True + self.support: Barge | None = None + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + jump = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(FRAMES_PER_STEP): + reward += self._advance_frame(jump and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _move_barges(self) -> None: + for barge in self.barges: + barge.x += barge.velocity + barge.top = 65 - barge.amplitude * ( + 1 - math.sin(self.frame * barge.frequency + barge.phase) + ) + low, high = 15 + barge.width / 2, 135 - barge.width / 2 + if barge.x <= low: + barge.x, barge.velocity = low, abs(barge.velocity) + elif barge.x >= high: + barge.x, barge.velocity = high, -abs(barge.velocity) + for first, second in combinations(self.barges, 2): + gap = (first.width + second.width) / 2 - (second.x - first.x) + if gap <= 0: + continue + first.x -= gap / 2 + second.x += gap / 2 + if first.velocity > 0: + first.velocity *= -1 + if second.velocity < 0: + second.velocity *= -1 + + def _advance_frame(self, jump: bool) -> int: + difficulty = 1 + self.level / 5 + self.frame += 1 + self.remaining -= math.sqrt(difficulty) + if self.remaining <= 0: + self.terminal = True + return 0 + old_support_x = self.support.x if self.support is not None else 0 + self._move_barges() + if self.grounded: + if self.support is not None: + self.x += self.support.x - old_support_x + self.feet = self.support.top + if not jump: + return 0 + self.grounded = False + self.support = None + self.vx = 0.7 * math.sqrt(difficulty) + self.vy = -2.1 * math.sqrt(difficulty) + previous_feet = self.feet + self.vy += 0.15 * (0.5 if self.pressed else 1.5) * difficulty + self.x += self.vx + self.feet += self.vy + if self.vy < 0: + return 0 + if self.x >= 133 and previous_feet <= 63 <= self.feet: + reward = int(120 * self.remaining / TIME_LIMIT) + self.level += 1 + self.remaining = min(TIME_LIMIT, self.remaining + TIME_LIMIT / 2) + self._setup_round() + return reward + for barge in self.barges: + if abs(self.x - barge.x) <= barge.width / 2 + 3 and previous_feet <= barge.top <= self.feet: + self.support = barge + self.grounded = True + self.feet = barge.top + self.vx = self.vy = 0 + return 1 + if self.feet >= 71: + self._return_to_dock() + return 0 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + column = min(9, int(self.x / 15)) + row = int((self.feet - 4) / 10) + state[row, column, 0] = True + state[row, column, 4] = self.grounded + state[6, (0, 9), 1] = True + state[7:9, :, 2] = True + for barge in self.barges: + left = max(0, int((barge.x - barge.width / 2) / 15)) + right = min(9, int((barge.x + barge.width / 2) / 15)) + state[int(barge.top / 10), left:right + 1, 3] = True + state[int(barge.top / 10), left:right + 1, 5] |= barge.velocity < 0 + state[9, :math.ceil(max(0, self.remaining) / 100), 5] = True + state[8, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/baroll.py b/runtime/minatar_synth/games/baroll.py new file mode 100644 index 0000000000000000000000000000000000000000..4f820a8bbed51d907a61b274ef3f52c2a43acad0 --- /dev/null +++ b/runtime/minatar_synth/games/baroll.py @@ -0,0 +1,103 @@ +from dataclasses import dataclass + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 +GROUND = 86 + + +@dataclass +class Barrel: + x: float + y: float = -5 + velocity: float = 0 + rolling: bool = False + + +class BarollEnvironment: + score_cap = HORIZON * FRAMES_PER_STEP + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.spawn_timer = 0 + self.pressed = self.terminal = self.jumping = False + self.y = float(GROUND) + self.velocity = 0.0 + self.barrels: list[Barrel] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(FRAMES_PER_STEP): + self._advance_frame(tap and frame == 0) + reward += int(not pressed) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self, tap: bool) -> None: + if self.spawn_timer == 0: + start = 100 if self.jumping else 10 + self.barrels.append(Barrel(self.random.uniform(start, 200))) + self.spawn_timer = int(self.random.integers(30, 90)) + self.spawn_timer -= 1 + for barrel in self.barrels: + if barrel.rolling: + barrel.x -= 1 + else: + barrel.velocity = (barrel.velocity + 0.2) * 0.92 + barrel.y += barrel.velocity + if barrel.y > 85: + barrel.y = GROUND + barrel.rolling = True + barrel.x -= 1 if self.pressed else 2 + self.barrels = [barrel for barrel in self.barrels if barrel.x > -5] + + if self.jumping: + self.y += self.velocity + self.velocity += 0.1 if self.pressed else 0.2 + if self.y > 85: + self.y = GROUND + self.jumping = self.pressed + self.velocity = -3 if self.pressed else 0 + elif tap: + self.jumping = True + self.velocity = -3.6 + self.terminal = any( + abs(barrel.x - 9) < 5 and abs(barrel.y - self.y) < 6 + for barrel in self.barrels + ) + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row = int(self.y) // 10 + state[row, 0, 0] = True + state[row, 0, 4] = self.jumping and self.velocity < 0 + for barrel in self.barrels: + if barrel.x >= 0 and barrel.y >= 0: + state[int(barrel.y) // 10, int(barrel.x) // 20, 2 if barrel.rolling else 1] = True + state[9, :, 3] = True + state[9, 0, 5] = self.pressed + for bit in range(9): + state[9, bit + 1, 5] = bool(self.steps & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/baserunner_dash.py b/runtime/minatar_synth/games/baserunner_dash.py new file mode 100644 index 0000000000000000000000000000000000000000..da50b627d22c7b1a7aa752680588646109f46194 --- /dev/null +++ b/runtime/minatar_synth/games/baserunner_dash.py @@ -0,0 +1,113 @@ +import math + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 8 +BASES = ((50, 90), (90, 50), (50, 10), (10, 50)) +LEG_LENGTH = math.dist(BASES[0], BASES[1]) +RUNNER_SPEED = 0.6 +BALL_SPEED = 0.3 + + +class BaserunnerDashEnvironment: + score_cap = HORIZON * FRAMES_PER_STEP // math.ceil(LEG_LENGTH / RUNNER_SPEED) + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = 0 + self.pressed = self.terminal = False + self.runner_base = 1 + self.progress = 0.0 + self.ball = BASES[0] + self.ball_base = 0 + self.ball_target = 2 + self.thrown = True + + @property + def runner_target(self) -> int: + return (self.runner_base + 1) % len(BASES) + + @property + def runner_position(self) -> tuple[float, float]: + x, y = BASES[self.runner_base] + target_x, target_y = BASES[self.runner_target] + fraction = self.progress / LEG_LENGTH + return x + (target_x - x) * fraction, y + (target_y - y) * fraction + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(FRAMES_PER_STEP): + reward += self._advance_runner() + self._advance_ball() + runner_x, runner_y = self.runner_position + ball_x, ball_y = self.ball + if self.progress > 0 and not self.thrown and abs(runner_x - ball_x) < 6 and abs(runner_y - ball_y) < 6: + self.terminal = True + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_runner(self) -> int: + if not self.pressed: + self.progress = max(0, self.progress - RUNNER_SPEED) + return 0 + self.progress += RUNNER_SPEED + if self.progress < LEG_LENGTH: + return 0 + self.runner_base = self.runner_target + self.progress = 0.0 + return 1 + + def _advance_ball(self) -> None: + x, y = self.ball + target = BASES[self.ball_target] + dx, dy = target[0] - x, target[1] - y + distance = math.hypot(dx, dy) + speed = BALL_SPEED * (3 if self.thrown else 1) + if distance <= speed: + self.ball = target + self.ball_base = self.ball_target + self.thrown = False + self.ball_target = self.runner_target if self.ball_base == self.runner_base else self.runner_base + return + self.ball = x + dx * speed / distance, y + dy * speed / distance + if not self.thrown and self.random.random() < 0.05: + self.thrown = True + if self.ball_base not in (self.runner_base, self.runner_target): + self.ball_target = self.runner_target + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for x, y in BASES: + state[y // 10, x // 10, 0] = True + runner_x, runner_y = self.runner_position + state[int(runner_y) // 10, int(runner_x) // 10, 1] = True + ball_x, ball_y = self.ball + state[int(ball_y) // 10, int(ball_x) // 10, 2 if self.thrown else 3] = True + target_x, target_y = BASES[self.ball_target] + state[target_y // 10, target_x // 10, 4] = True + for index, channel in ((self.runner_base, 4), (self.runner_target, 5)): + state[0, index, channel] = True + for bit in range(9): + state[9, bit, 5] = bool(self.steps & (1 << bit)) + state[9, 9, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/battle_zone.py b/runtime/minatar_synth/games/battle_zone.py new file mode 100644 index 0000000000000000000000000000000000000000..7874bd2c3a5f9d41093a632ceb1d5d8ddfb8a285 --- /dev/null +++ b/runtime/minatar_synth/games/battle_zone.py @@ -0,0 +1,223 @@ +import numpy as np + + +DIRECTIONS = ( + (-1, 0), + (-1, 1), + (0, 1), + (1, 1), + (1, 0), + (1, -1), + (0, -1), + (-1, -1), +) +POINTS = {"tank": 1_000.0, "fighter": 2_000.0, "supertank": 3_000.0, "saucer": 5_000.0} +WAVES = ( + ("tank", "tank", "tank", "fighter", "saucer"), + ("tank", "tank", "fighter", "fighter", "saucer"), + ("tank", "tank", "fighter", "supertank", "saucer"), + ("tank", "fighter", "fighter", "supertank", "saucer"), + ("tank", "fighter", "supertank", "supertank", "saucer"), +) +OBSTACLES = {(2, 2), (2, 7), (5, 1), (5, 8), (7, 3), (7, 6)} +SPAWNS = ((0, 1), (0, 5), (0, 9), (4, 0), (4, 9)) + + +class BattleZoneEnvironment: + """Radar combat with oriented movement, cover, shell dodging, and four target classes.""" + + score_cap = 60_000.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 1_500): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.player = [9, 5] + self.previous_player = self.player.copy() + self.direction = 0 + self.lives = 5 + self.wave = 0 + self.steps = 0 + self.total_score = 0.0 + self.bonus_awarded = False + self.player_shell: list[int] | None = None + self.enemy_shells: list[list[int]] = [] + self.last_action = 0 + self.terminal = False + self._start_wave() + + def _start_wave(self) -> None: + self.enemies = [ + {"kind": kind, "position": [*SPAWNS[index]], "previous": [*SPAWNS[index]]} + for index, kind in enumerate(WAVES[self.wave]) + ] + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + if action == 1: + self.direction = (self.direction - 1) % 8 + elif action == 3: + self.direction = (self.direction + 1) % 8 + elif action in (2, 4): + multiplier = 1 if action == 2 else -1 + row_delta, column_delta = DIRECTIONS[self.direction] + target = [self.player[0] + multiplier * row_delta, self.player[1] + multiplier * column_delta] + if self._open(target): + self.player = target + elif action == 5 and self.player_shell is None: + row_delta, column_delta = DIRECTIONS[self.direction] + self.player_shell = [self.player[0], self.player[1], row_delta, column_delta, 9] + + self._move_enemies() + self._move_shells() + reward = self._resolve_player_shell() + self._resolve_enemy_shells() + self._enemy_fire() + self.steps += 1 + if self.total_score >= 50_000 and not self.bonus_awarded: + self.lives += 1 + self.bonus_awarded = True + if not self.enemies: + self.wave += 1 + if self.wave == len(WAVES): + self.terminal = True + else: + self._start_wave() + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + @staticmethod + def _open(position: list[int]) -> bool: + return 0 <= position[0] < 10 and 0 <= position[1] < 10 and tuple(position) not in OBSTACLES + + def _move_enemies(self) -> None: + for enemy in self.enemies: + enemy["previous"] = list(enemy["position"]) + kind = str(enemy["kind"]) + if kind == "saucer": + enemy["position"][1] = (enemy["position"][1] + 1) % 10 + continue + interval = {"tank": 3, "fighter": 2, "supertank": 1}[kind] + if self.steps % interval != 0: + continue + position = list(enemy["position"]) + row_delta = int(np.sign(self.player[0] - position[0])) + column_delta = int(np.sign(self.player[1] - position[1])) + if kind == "fighter" and self.steps % 4 < 2: + column_delta = -column_delta or 1 + candidates = ([position[0] + row_delta, position[1] + column_delta], [position[0] + row_delta, position[1]]) + for target in candidates: + if self._open(target) and target != self.player: + enemy["position"] = target + break + + def _move_shells(self) -> None: + if self.player_shell is not None: + self.player_shell[0] += self.player_shell[2] + self.player_shell[1] += self.player_shell[3] + self.player_shell[4] -= 1 + if not self._open(self.player_shell[:2]) or self.player_shell[4] <= 0: + self.player_shell = None + remaining = [] + for shell in self.enemy_shells: + shell[0] += shell[2] + shell[1] += shell[3] + shell[4] -= 1 + if self._open(shell[:2]) and shell[4] > 0: + remaining.append(shell) + self.enemy_shells = remaining + + def _resolve_player_shell(self) -> float: + if self.player_shell is None: + return 0.0 + hit = next((enemy for enemy in self.enemies if enemy["position"] == self.player_shell[:2]), None) + if hit is None: + return 0.0 + self.enemies.remove(hit) + self.player_shell = None + reward = POINTS[str(hit["kind"])] + self.total_score += reward + return reward + + def _resolve_enemy_shells(self) -> None: + remaining = [] + for shell in self.enemy_shells: + friendly_hit = next((enemy for enemy in self.enemies if enemy["position"] == shell[:2]), None) + if friendly_hit is not None: + self.enemies.remove(friendly_hit) + elif shell[:2] == self.player: + self._lose_tank() + else: + remaining.append(shell) + self.enemy_shells = remaining + + def _enemy_fire(self) -> None: + for enemy in self.enemies: + kind = str(enemy["kind"]) + if kind == "saucer": + continue + interval = {"tank": 12, "fighter": 9, "supertank": 7}[kind] + if self.steps % interval != 0: + continue + position = list(enemy["position"]) + row_delta = int(np.sign(self.player[0] - position[0])) + column_delta = int(np.sign(self.player[1] - position[1])) + self.enemy_shells.append([position[0], position[1], row_delta, column_delta, 10]) + + def _lose_tank(self) -> None: + self.lives -= 1 + self.player = [9, 5] + self.previous_player = self.player.copy() + self.direction = 0 + self.player_shell = None + self.enemy_shells.clear() + if self.lives <= 0: + self.terminal = True + + def _in_view(self, position: list[int]) -> bool: + row_delta = int(np.sign(position[0] - self.player[0])) + column_delta = int(np.sign(position[1] - self.player[1])) + if (row_delta, column_delta) == (0, 0): + return True + target_direction = DIRECTIONS.index((row_delta, column_delta)) + return min((target_direction - self.direction) % 8, (self.direction - target_direction) % 8) <= 1 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + for enemy in self.enemies: + position = list(enemy["position"]) + state[*position, 1] = True + if self._in_view(position): + state[*position, 2] = True + type_marker = {"tank": 0, "fighter": 1, "supertank": 2, "saucer": 3}[str(enemy["kind"])] + state[position[0], type_marker, 5] = True + state[*list(enemy["previous"]), 4] = True + for shell in self.enemy_shells: + state[shell[0], shell[1], 1] = True + if self.player_shell is not None: + state[self.player_shell[0], self.player_shell[1], 3] = True + state[*self.previous_player, 4] = True + for obstacle in OBSTACLES: + state[*obstacle, 5] = True + state[9, : min(10, self.lives), 5] = True + state[8, : self.wave + 1, 5] = True + state[7, self.direction, 5] = True + return state diff --git a/runtime/minatar_synth/games/beam_rider.py b/runtime/minatar_synth/games/beam_rider.py new file mode 100644 index 0000000000000000000000000000000000000000..b5444ca96df0b42455e4c2dd6a23b1e79a9a47eb --- /dev/null +++ b/runtime/minatar_synth/games/beam_rider.py @@ -0,0 +1,215 @@ +import numpy as np + + +BEAM_COLUMNS = (1, 3, 5, 7, 9) +SECTORS = (1, 2, 4, 6) + + +class BeamRiderEnvironment: + """Five-beam sector defense with short lasers, scarce torpedoes, and rejuvenators.""" + + score_cap = 34_200.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 2_000): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.lane = 2 + self.lives = 3 + self.sector_index = 0 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self._start_sector() + + @property + def sector(self) -> int: + return SECTORS[self.sector_index] + + def _start_sector(self) -> None: + self.torpedoes = 3 + self.saucers_destroyed = 0 + self.saucers_spawned = 0 + self.objects: list[dict[str, int | str | bool]] = [] + self.shots: list[dict[str, int | str]] = [] + self.previous_objects: list[list[int]] = [] + self.sector_step = 0 + self.sentinel: dict[str, int | str | bool] | None = None + self.rejuvenator_spawned = False + self.chirpers_spawned = 0 + self.hazard_spawned = False + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + if action == 1: + self.lane = max(0, self.lane - 1) + elif action == 3: + self.lane = min(4, self.lane + 1) + elif action == 5: + self.shots.append({"row": 8, "lane": self.lane, "kind": "laser", "ttl": 4}) + elif action == 2 and self.torpedoes > 0: + self.torpedoes -= 1 + self.shots.append({"row": 8, "lane": self.lane, "kind": "torpedo", "ttl": 10}) + + self._spawn_objects() + self.previous_objects = [[int(obj["row"]), int(obj["lane"])] for obj in self.objects] + self._move_objects() + self._move_shots() + reward = self._resolve_shots() + self._resolve_player_contacts() + reward += self._move_sentinel() + self.sector_step += 1 + self.steps += 1 + if self.saucers_destroyed == 15 and self.sentinel is None: + self.sentinel = {"row": 0, "column": 0, "kind": "sentinel", "active": True} + if self.sentinel is not None and not bool(self.sentinel["active"]): + self.sector_index += 1 + if self.sector_index == len(SECTORS): + self.terminal = True + else: + self._start_sector() + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _spawn_objects(self) -> None: + if self.saucers_spawned < 15 and self.sector_step % 5 == 0: + self.objects.append({"row": 0, "lane": int(self.random.randint(5)), "kind": "saucer", "red": False}) + self.saucers_spawned += 1 + if not self.rejuvenator_spawned and self.sector_step == 20: + self.objects.append({"row": 0, "lane": int(self.random.randint(5)), "kind": "rejuvenator", "red": False}) + self.rejuvenator_spawned = True + if self.sector >= 4 and self.chirpers_spawned < 3 and self.sector_step in (12, 30, 48): + self.objects.append({"row": 0, "lane": int(self.random.randint(5)), "kind": "chirper", "red": False}) + self.chirpers_spawned += 1 + if self.sector >= 2 and not self.hazard_spawned and self.sector_step == 10: + kind = "debris" if self.sector < 6 else "blocker" + self.objects.append({"row": 0, "lane": int(self.random.randint(5)), "kind": kind, "red": False}) + self.hazard_spawned = True + + def _move_objects(self) -> None: + for obj in self.objects: + obj["row"] = int(obj["row"]) + 1 + if obj["kind"] == "chirper" and int(obj["row"]) % 2 == 0: + obj["lane"] = int(np.clip(int(obj["lane"]) + self.random.choice((-1, 1)), 0, 4)) + for obj in self.objects: + if obj["kind"] == "saucer" and int(obj["row"]) > 9: + obj["row"] = 0 + obj["lane"] = int(self.random.randint(5)) + self.objects = [obj for obj in self.objects if int(obj["row"]) <= 9 or obj["kind"] == "saucer"] + + def _move_shots(self) -> None: + for shot in self.shots: + shot["row"] = int(shot["row"]) - 1 + shot["ttl"] = int(shot["ttl"]) - 1 + self.shots = [shot for shot in self.shots if int(shot["row"]) >= 0 and int(shot["ttl"]) > 0] + + def _resolve_shots(self) -> float: + reward = 0.0 + remaining = [] + for shot in self.shots: + hit = next( + (obj for obj in self.objects if int(obj["row"]) == int(shot["row"]) and int(obj["lane"]) == int(shot["lane"])), + None, + ) + if hit is None: + remaining.append(shot) + continue + kind = str(hit["kind"]) + torpedo = shot["kind"] == "torpedo" + laser_vulnerable = kind in ("saucer", "chirper") + if kind == "rejuvenator" and not bool(hit["red"]): + hit["red"] = True + continue + if torpedo or laser_vulnerable: + self.objects.remove(hit) + if kind == "saucer": + self.saucers_destroyed += 1 + reward += 100.0 * self.sector + elif kind == "chirper": + reward += 200.0 * self.sector + else: + remaining.append(shot) + self.shots = remaining + return reward + + def _resolve_player_contacts(self) -> None: + contacts = [obj for obj in self.objects if int(obj["row"]) == 9 and int(obj["lane"]) == self.lane] + for obj in contacts: + self.objects.remove(obj) + if obj["kind"] == "rejuvenator" and not bool(obj["red"]): + self.lives += 1 + else: + self._lose_ship() + + def _move_sentinel(self) -> float: + if self.sentinel is None or not bool(self.sentinel["active"]): + return 0.0 + self.sentinel["column"] = int(self.sentinel["column"]) + 1 + hit = next( + ( + shot + for shot in self.shots + if shot["kind"] == "torpedo" + and int(shot["row"]) == 0 + and BEAM_COLUMNS[int(shot["lane"])] == int(self.sentinel["column"]) + ), + None, + ) + if hit is not None: + self.shots.remove(hit) + self.sentinel["active"] = False + return 500.0 * self.sector + 100.0 * self.lives + elif int(self.sentinel["column"]) > 9: + self.sentinel["active"] = False + return 0.0 + + def _lose_ship(self) -> None: + self.lives -= 1 + self.lane = 2 + self.shots.clear() + if self.lives <= 0: + self.terminal = True + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[9, BEAM_COLUMNS[self.lane], 0] = True + for obj in self.objects: + row, column = int(obj["row"]), BEAM_COLUMNS[int(obj["lane"])] + dangerous = obj["kind"] != "rejuvenator" or bool(obj["red"]) + if dangerous: + state[row, column, 1] = True + if obj["kind"] in ("saucer", "chirper") or (obj["kind"] == "rejuvenator" and not bool(obj["red"])): + state[row, column, 2] = True + marker = {"saucer": 0, "chirper": 1, "debris": 2, "blocker": 3, "rejuvenator": 4}[str(obj["kind"])] + state[row, marker, 5] = True + if self.sentinel is not None and bool(self.sentinel["active"]): + state[0, min(9, int(self.sentinel["column"])), 2] = True + for shot in self.shots: + row, column = int(shot["row"]), BEAM_COLUMNS[int(shot["lane"])] + state[row, column, 3] = True + if shot["kind"] == "torpedo": + state[row, column, 5] = True + for row, lane in self.previous_objects: + if 0 <= row < 10: + state[row, BEAM_COLUMNS[lane], 4] = True + state[9, : min(10, self.lives), 5] = True + state[8, : self.torpedoes, 5] = True + state[7, : self.sector_index + 1, 5] = True + state[6, : min(10, (15 - self.saucers_destroyed + 1) // 2), 5] = True + return state diff --git a/runtime/minatar_synth/games/berzerk.py b/runtime/minatar_synth/games/berzerk.py new file mode 100644 index 0000000000000000000000000000000000000000..ae9f584d1a2dfb377271f8a816d446050848b7cd --- /dev/null +++ b/runtime/minatar_synth/games/berzerk.py @@ -0,0 +1,246 @@ +import numpy as np + + +DELTAS = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)} +OPENINGS = {(0, 5), (9, 5), (5, 0), (5, 9)} +BASE_INTERIOR = {(2, 2), (2, 3), (2, 4), (4, 7), (5, 7), (6, 7), (7, 2), (7, 3)} +SPAWN_CANDIDATES = ((1, 1), (1, 8), (4, 4), (7, 7), (8, 1), (3, 8), (6, 2)) + + +def room_walls(room: int) -> set[tuple[int, int]]: + boundary = { + (row, column) + for row in range(10) + for column in range(10) + if row in (0, 9) or column in (0, 9) + } - OPENINGS + interior = BASE_INTERIOR + for _ in range(room): + interior = {(column, 9 - row) for row, column in interior} + return boundary | interior + + +class BerzerkEnvironment: + """Four electrified mazes with robot crossfire and invincible Evil Otto pressure.""" + + score_cap = 1_200.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 1_000): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.room = 0 + self.lives = 3 + self.steps = 0 + self.last_action = 0 + self.death_this_step = False + self.terminal = False + self._start_room([9, 5]) + + def _start_room(self, entry: list[int]) -> None: + self.walls = room_walls(self.room) + self.player = entry.copy() + self.previous_player = self.player.copy() + self.aim = 2 + available = [position for position in SPAWN_CANDIDATES if position not in self.walls and list(position) != self.player] + self.robots = [list(position) for position in available[:5]] + self.previous_robots = [robot.copy() for robot in self.robots] + self.player_shot: list[int] | None = None + self.robot_shots: list[list[int]] = [] + self.otto: list[int] | None = None + self.room_steps = 0 + self.clear_bonus_awarded = False + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.death_this_step = False + self.previous_player = self.player.copy() + if action in DELTAS: + self.aim = action + if self._move_player(action): + self.steps += 1 + return 0.0, self.terminal + elif action == 5 and self.player_shot is None: + row_delta, column_delta = DELTAS[self.aim] + self.player_shot = [self.player[0], self.player[1], row_delta, column_delta, 8] + + self.previous_robots = [robot.copy() for robot in self.robots] + reward = self._move_robots() + self._move_shots() + reward += self._resolve_player_shot() + reward += self._resolve_robot_shots() + self._spawn_and_move_otto() + reward += self._resolve_otto() + if not self.robots and not self.clear_bonus_awarded: + reward += 50.0 + self.clear_bonus_awarded = True + self.room_steps += 1 + self.steps += 1 + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _move_player(self, action: int) -> bool: + row_delta, column_delta = DELTAS[action] + target = [self.player[0] + row_delta, self.player[1] + column_delta] + if not (0 <= target[0] < 10 and 0 <= target[1] < 10): + if tuple(self.player) in OPENINGS: + self.room += 1 + if self.room == 4: + self.terminal = True + else: + opposite = {1: [5, 9], 2: [9, 5], 3: [5, 0], 4: [0, 5]}[action] + self._start_room(opposite) + return True + return False + if tuple(target) in self.walls: + self._lose_life() + elif target in self.robots or target == self.otto: + self._lose_life() + else: + self.player = target + return False + + def _move_robots(self) -> float: + if self.room_steps % 2 != 0: + return 0.0 + reward = 0.0 + for robot in self.robots.copy(): + row_delta = int(np.sign(self.player[0] - robot[0])) + column_delta = int(np.sign(self.player[1] - robot[1])) + target = [robot[0] + row_delta, robot[1] + column_delta] + if tuple(target) in self.walls: + if robot in self.robots: + self.robots.remove(robot) + reward += 50.0 + elif target in self.robots: + if robot in self.robots: + self.robots.remove(robot) + reward += 50.0 + if target in self.robots: + self.robots.remove(target) + reward += 50.0 + elif target == self.player: + self._lose_life() + elif robot in self.robots: + robot[:] = target + if self.room_steps % 8 == 0: + for robot in self.robots: + row_delta = int(np.sign(self.player[0] - robot[0])) + column_delta = int(np.sign(self.player[1] - robot[1])) + self.robot_shots.append([robot[0], robot[1], row_delta, column_delta, 8]) + return reward + + def _move_shots(self) -> None: + if self.player_shot is not None: + self.player_shot[0] += self.player_shot[2] + self.player_shot[1] += self.player_shot[3] + self.player_shot[4] -= 1 + if ( + self.player_shot[4] <= 0 + or not (0 <= self.player_shot[0] < 10 and 0 <= self.player_shot[1] < 10) + or tuple(self.player_shot[:2]) in self.walls + ): + self.player_shot = None + remaining = [] + for shot in self.robot_shots: + shot[0] += shot[2] + shot[1] += shot[3] + shot[4] -= 1 + if shot[4] > 0 and 0 <= shot[0] < 10 and 0 <= shot[1] < 10 and tuple(shot[:2]) not in self.walls: + remaining.append(shot) + self.robot_shots = remaining + + def _resolve_player_shot(self) -> float: + if self.player_shot is None: + return 0.0 + hit = next((robot for robot in self.robots if robot == self.player_shot[:2]), None) + if hit is None: + return 0.0 + self.robots.remove(hit) + self.player_shot = None + return 50.0 + + def _resolve_robot_shots(self) -> float: + reward = 0.0 + remaining = [] + for shot in self.robot_shots: + hit = next((robot for robot in self.robots if robot == shot[:2]), None) + if hit is not None: + self.robots.remove(hit) + reward += 50.0 + elif shot[:2] == self.player: + self._lose_life() + else: + remaining.append(shot) + self.robot_shots = remaining + return reward + + def _spawn_and_move_otto(self) -> None: + if self.otto is None and self.room_steps >= 40: + self.otto = [9, 5] + if self.otto is None or self.room_steps % 2 != 0: + return + self.otto[0] += int(np.sign(self.player[0] - self.otto[0])) + self.otto[1] += int(np.sign(self.player[1] - self.otto[1])) + + def _resolve_otto(self) -> float: + if self.otto is None: + return 0.0 + reward = 0.0 + hit = next((robot for robot in self.robots if robot == self.otto), None) + if hit is not None: + self.robots.remove(hit) + reward += 50.0 + if self.otto == self.player: + self._lose_life() + return reward + + def _lose_life(self) -> None: + if self.death_this_step: + return + self.death_this_step = True + self.lives -= 1 + self.player = [9, 5] + self.previous_player = self.player.copy() + self.player_shot = None + self.robot_shots.clear() + if self.lives <= 0: + self.terminal = True + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + for robot in self.robots: + state[*robot, 1] = True + state[*robot, 2] = True + for shot in self.robot_shots: + state[shot[0], shot[1], 1] = True + if self.otto is not None: + state[*self.otto, 1] = True + if self.player_shot is not None: + state[self.player_shot[0], self.player_shot[1], 3] = True + state[*self.previous_player, 4] = True + for robot in self.previous_robots: + state[*robot, 4] = True + for wall in self.walls: + state[*wall, 5] = True + state[9, : self.lives, 5] = True + state[8, : self.room + 1, 5] = True + state[7, self.aim, 5] = True + return state diff --git a/runtime/minatar_synth/games/blade_dancer.py b/runtime/minatar_synth/games/blade_dancer.py new file mode 100644 index 0000000000000000000000000000000000000000..eb140a5da5ad4a073785c3afa7c1b4d028548512 --- /dev/null +++ b/runtime/minatar_synth/games/blade_dancer.py @@ -0,0 +1,130 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 +PLAYER_X = 35 +GROUND = 80 +JUMP_DURATION = 30 + + +@dataclass +class Enemy: + x: float + y: float + size: float + + +class BladeDancerEnvironment: + score_cap = 100 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = 0 + self.pressed = self.terminal = False + self.jump_ticks = 0.0 + self.y = float(GROUND) + self.angle = math.pi / 2 + self.length = 10.0 + self.multiplier = 1 + self.enemies: list[Enemy] = [] + self.platforms = [(0.0, 200.0)] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed and not self.jump_ticks: + self.jump_ticks = JUMP_DURATION + self.multiplier = 1 + self.pressed = pressed + self.steps += 1 + reward = 0 + for _ in range(FRAMES_PER_STEP): + reward += self._advance_frame() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _sword_vector(self) -> tuple[float, float]: + return self.length * math.cos(self.angle), self.length * math.sin(self.angle) + + def _advance_frame(self) -> int: + if self.jump_ticks: + self.jump_ticks = max(0, self.jump_ticks - (0.5 if self.pressed else 1)) + progress = self.jump_ticks / JUMP_DURATION + self.y = GROUND - math.sin(progress * math.pi) * 30 + self.angle = self.angle - 0.3 if self.jump_ticks else math.pi / 2 + self.length = 8 + (1 - progress) * 22 if self.jump_ticks else 10 + + if not self.enemies or self.random.random() < 0.04: + if len(self.enemies) == 32: + self.enemies.pop(0) + self.enemies.append(Enemy(205, self.random.uniform(30, 75), self.random.uniform(3, 6))) + reward = 0 + survivors = [] + sword_x, sword_y = self._sword_vector() + sword_radius = 2.5 if self.jump_ticks else 1 + for enemy in self.enemies: + enemy.x -= 1 + dx, dy = enemy.x - PLAYER_X, enemy.y - (self.y - 4) + fraction = min(1, max(0, (dx * sword_x + dy * sword_y) / self.length**2)) + distance = math.hypot(dx - fraction * sword_x, dy - fraction * sword_y) + radius = enemy.size / 2 + if distance <= radius + sword_radius: + reward += self.multiplier + self.multiplier += 1 + continue + if abs(dx) < 2 + radius and abs(enemy.y - self.y) < 4 + radius: + self.terminal = True + if enemy.x >= -10: + survivors.append(enemy) + self.enemies = survivors + + self.platforms = [(left - 1, right - 1) for left, right in self.platforms if right >= 1] + end = self.platforms[-1][1] + if end < 200: + gap = self.random.uniform(15, 30) if self.random.random() < 0.32 else 0 + length = self.random.uniform(30, 100) if gap else self.random.uniform(50, 150) + self.platforms.append((end + gap, end + gap + length)) + if not self.jump_ticks and not any(left <= PLAYER_X <= right for left, right in self.platforms): + self.terminal = True + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row, column = int(self.y) // 10, PLAYER_X // 20 + state[row, column, 0] = True + state[row, column, 4] = self.jump_ticks > 0 + sword_x, sword_y = self._sword_vector() + for fraction in np.linspace(0, 1, 12): + y = int(self.y - 4 + fraction * sword_y) // 10 + x = int(PLAYER_X + fraction * sword_x) // 20 + state[y, x, 1] = True + for enemy in self.enemies: + if 0 <= enemy.x < 200: + state[int(enemy.y) // 10, int(enemy.x) // 20, 2] = True + for column in range(10): + x = 20 * column + PLAYER_X % 20 + state[8, column, 3] = any(left <= x <= right for left, right in self.platforms) + state[9, 0, 5] = self.pressed + for row, value in enumerate((int(self.jump_ticks * 2), self.multiplier, self.steps)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/blast_buoy.py b/runtime/minatar_synth/games/blast_buoy.py new file mode 100644 index 0000000000000000000000000000000000000000..77b8b129d34559ca71e17e4bda541838128ccd4a --- /dev/null +++ b/runtime/minatar_synth/games/blast_buoy.py @@ -0,0 +1,155 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 +BLAST_RADIUS = 25 + + +@dataclass +class Submarine: + x: float + y: float + vx: float + fire_timer: int + + +@dataclass +class Bullet: + x: float + y: float + vx: float + + +class BlastBuoyEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.spawn_timer = self.combo_timer = self.shield = self.freeze = 0 + self.combo = 1 + self.pressed = self.terminal = False + self.x, self.y = 30.0, 40.0 + self.vx = self.vy = 0.0 + self.submarines: list[Submarine] = [] + self.bullets: list[Bullet] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(FRAMES_PER_STEP): + reward += self._advance_frame() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self) -> int: + if self.freeze: + self.freeze -= 1 + return 0 + self.vy = min(1.1, max(-1.1, self.vy + (0.06 if self.pressed else -0.05))) + self.vx *= 0.95 + self.x = min(95, max(5, self.x + self.vx)) + self.y = min(87, max(13, self.y + self.vy)) + if self.y in (13, 87): + self.vy = 0 + + self.shield = max(0, self.shield - 1) + if self.combo_timer: + self.combo_timer -= 1 + else: + self.combo = 1 + + if not self.spawn_timer: + direction = int(self.random.choice((-1, 1))) + self.submarines.append(Submarine( + -8 if direction > 0 else 108, + self.random.uniform(13, 87), + direction * self.random.uniform(0.2, 0.45), + int(self.random.integers(60, 121)), + )) + self.spawn_timer = int(self.random.integers(50, 91)) + self.spawn_timer -= 1 + + contact = None + for sub in self.submarines: + sub.x += sub.vx + sub.fire_timer -= 1 + if sub.fire_timer < 0 and 0 < sub.x < 100 and abs(sub.y - self.y) < 10: + if math.hypot(sub.x - self.x, sub.y - self.y) > 36: + direction = 1 if self.x > sub.x else -1 + self.bullets.append(Bullet(sub.x + direction * 6, sub.y, direction * 0.95)) + sub.fire_timer = int(self.random.integers(90, 151)) + if contact is None and not self.shield and abs(sub.x - self.x) < 7.5 and abs(sub.y - self.y) < 5: + contact = sub + + self.submarines = [sub for sub in self.submarines if -12 <= sub.x <= 112] + reward = self._blast(contact) if contact is not None else 0 + + survivors = [] + for bullet in self.bullets: + bullet.x += bullet.vx + if abs(bullet.x - self.x) < 5.5 and abs(bullet.y - self.y) < 4: + self.terminal |= not self.shield + elif -5 <= bullet.x <= 105: + survivors.append(bullet) + self.bullets = survivors + return reward + + def _blast(self, center: Submarine) -> int: + self.submarines.remove(center) + remaining = [ + sub for sub in self.submarines + if math.hypot(sub.x - center.x, sub.y - center.y) >= BLAST_RADIUS + ] + extras = len(self.submarines) - len(remaining) + self.submarines = remaining + self.bullets = [ + bullet for bullet in self.bullets + if math.hypot(bullet.x - center.x, bullet.y - center.y) >= BLAST_RADIUS + ] + reward = (5 + 8 * extras) * self.combo + self.combo += 1 + self.combo_timer = 120 + angle = math.atan2(self.y - center.y, self.x - center.x) + self.vx, self.vy = 2.2 * math.cos(angle), 2.2 * math.sin(angle) + self.shield = 40 + self.freeze = min(8, 3 + extras) + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row, column = int(self.y) // 10, int(self.x) // 10 + state[row, column, 0] = True + state[row, column, 4] = self.shield > 0 + for sub in self.submarines: + if 0 <= sub.x < 100: + state[int(sub.y) // 10, int(sub.x) // 10, 1 if sub.vx > 0 else 2] = True + for bullet in self.bullets: + if 0 <= bullet.x < 100: + state[int(bullet.y) // 10, int(bullet.x) // 10, 3] = True + for row, value in enumerate((self.steps, self.combo, self.combo_timer, self.shield, self.freeze)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.vy > 0 + return state diff --git a/runtime/minatar_synth/games/blaze_thrust.py b/runtime/minatar_synth/games/blaze_thrust.py new file mode 100644 index 0000000000000000000000000000000000000000..418a1b007cded5b4e261c39f9bf565f48dece1a9 --- /dev/null +++ b/runtime/minatar_synth/games/blaze_thrust.py @@ -0,0 +1,131 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 + + +@dataclass +class Bubble: + x: float + y: float + size: float + + +class BlazeThrustEnvironment: + score_cap = 250 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.hold_time = 0 + self.pressed = self.terminal = False + self.x, self.y = 50.0, 90.0 + self.vx = self.vy = 0.0 + self.size = 9.0 + self.multiplier = 1 + self.next_bubble = self.random.uniform(10, 40) + self.winds = [(0.0, self.random.uniform(20, 40))] + self.bubbles: list[Bubble] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(FRAMES_PER_STEP): + reward += self._advance_frame() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _wind_left(self, y: float) -> bool: + return any(top <= y <= bottom for top, bottom in self.winds) + + def _advance_frame(self) -> int: + self.vy += -0.1 if self.pressed else 0.1 + self.hold_time = self.hold_time + 1 if self.pressed else max(0, self.hold_time - 3) + scroll = max(0, (60 - self.y) * 0.1) + self.x += self.vx + self.y += self.vy + scroll + self.vx *= 0.95 + self.vy *= 0.95 + if self.x < 5: + self.x, self.vx = 10, abs(self.vx) * 0.5 + elif self.x > 95: + self.x, self.vx = 90, -abs(self.vx) * 0.5 + if self.y > 95: + self.y, self.vy = 90, -abs(self.vy) * 0.3 + + if scroll: + self.winds = [(top + scroll, bottom + scroll) for top, bottom in self.winds if top + scroll < 120] + top = self.winds[0][0] + if top >= 0: + bottom = top - self.random.uniform(20, 40) + self.winds.insert(0, (bottom - self.random.uniform(20, 40), bottom)) + self.vx += self.size * (-0.02 if self._wind_left(self.y) else 0.02) + self.size *= 1 - 0.0016 * (1 + self.hold_time * 0.01) + if self.size <= 2: + self.terminal = True + return 0 + + reward = self._advance_bubbles(scroll) + if scroll and len(self.bubbles) < 15: + self.next_bubble -= scroll + if self.next_bubble <= 0: + size = self.random.uniform(3, 9) + self.bubbles.append(Bubble(self.random.uniform(10, 90), -size, size)) + self.next_bubble = self.random.uniform(5, 55) + return reward + + def _advance_bubbles(self, scroll: float) -> int: + reward = 0 + remaining = [] + for bubble in self.bubbles: + bubble.y += scroll + 0.3 - (bubble.size - 3) * 0.015 + bubble.x += bubble.size * (-0.02 if self._wind_left(bubble.y) else 0.02) + bubble.x = min(95, max(5, bubble.x)) + if math.hypot(bubble.x - self.x, bubble.y - self.y) <= bubble.size + self.size: + reward += self.multiplier + self.multiplier = min(16, self.multiplier + 1) + self.size = min(25, self.size + bubble.size * 0.2) + elif bubble.y > 120: + self.multiplier = 1 + else: + remaining.append(bubble) + self.bubbles = remaining + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row, column = int(self.y) // 10, int(self.x) // 10 + state[row, column, 0] = True + state[row, column, 4] = self.vy < 0 + for row in range(10): + state[row, :, 1 if self._wind_left(10 * row + 5) else 2] = True + for bubble in self.bubbles: + if 0 <= bubble.y < 100: + state[int(bubble.y) // 10, int(bubble.x) // 10, 3] = True + for row, value in enumerate((round(self.size * 10), self.multiplier, self.hold_time, self.steps)): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + state[row + 4, 0, 5] = bool(value & 1024) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/block_stacker.py b/runtime/minatar_synth/games/block_stacker.py new file mode 100644 index 0000000000000000000000000000000000000000..cc872a430361d727381d49bd38ca16ea96ee7e7d --- /dev/null +++ b/runtime/minatar_synth/games/block_stacker.py @@ -0,0 +1,123 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 + + +@dataclass +class Block: + x: float + y: float + width: float + + +class BlockStackerEnvironment: + score_cap = 50 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.stacked = 0 + self.pressed = self.falling = self.terminal = False + self.angle = self.vx = self.vy = self.drift = 0.0 + self.current = Block(50, 25, self.random.uniform(10, 30)) + self.tower = [Block(50, 99, 99)] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(FRAMES_PER_STEP): + reward += self._advance_frame(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self, tap: bool) -> int: + difficulty = 1 + self.stacked / 50 + self.angle += 0.05 * difficulty + previous_y = self.current.y + if self.falling: + self.current.x += self.vx * difficulty + self.current.y += self.vy * difficulty + self.vy += 0.1 + else: + swing = math.sin(self.angle) + self.current.x = 50 - 20 * math.sin(swing) + self.current.y = 5 + 20 * math.cos(swing) + if tap: + self.falling = True + self.vx, self.vy = -math.cos(self.angle), 0.0 + + for block in self.tower: + block.x = (block.x + self.drift) % 100 + top = min(block.y for block in self.tower) + reward = 0 + if self.falling: + for block in sorted(self.tower, key=lambda block: block.y): + distance = abs((self.current.x - block.x + 50) % 100 - 50) + if previous_y <= block.y - 10 <= self.current.y and distance < (self.current.width + block.width) / 2: + self.current.y = block.y - 10 + self.tower.append(self.current) + self.current = Block(50, 25, self.random.uniform(10, 30)) + self.falling = False + self.stacked += 1 + self.drift = self.random.uniform(-1, 1) * self.stacked / 50 + reward = 1 + break + else: + self.terminal = self.current.y > 105 + scroll = difficulty * 0.01 + max(0, 70 - top) * 0.1 + for block in self.tower: + block.y += scroll + self.tower = [block for block in self.tower if block.y <= 106] + self.terminal |= not self.tower + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for block in self.tower: + self._draw_block(state, block, 0, wraps=True) + self._draw_block(state, self.current, 2 if self.falling else 1, wraps=False) + if not self.falling: + for fraction in np.linspace(0, 1, 8): + x = 50 + (self.current.x - 50) * fraction + y = (self.current.y - 5) * fraction + state[int(y) // 10, int(x) // 10, 3] = True + if self.drift < 0: + state[:, :, 4] = state[:, :, 0] + state[9, 0, 5] = self.pressed + for row, value in enumerate((self.steps, self.stacked)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 1, 5] = (self.vx < 0 if self.falling else math.cos(self.angle) > 0) + return state + + @staticmethod + def _draw_block(state: np.ndarray, block: Block, channel: int, wraps: bool) -> None: + for row in range(10): + if row * 10 < block.y + 5 and (row + 1) * 10 > block.y - 5: + for column in range(10): + dx = column * 10 + 5 - block.x + distance = abs((dx + 50) % 100 - 50) if wraps else abs(dx) + state[row, column, channel] |= distance < block.width / 2 + 5 diff --git a/runtime/minatar_synth/games/boarding.py b/runtime/minatar_synth/games/boarding.py new file mode 100644 index 0000000000000000000000000000000000000000..42f6ff8606a237e10699e7880d3628f71a21e8ed --- /dev/null +++ b/runtime/minatar_synth/games/boarding.py @@ -0,0 +1,150 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 + + +@dataclass +class Board: + x: float + y: float + slope: int + + +@dataclass +class Passenger: + x: float + y: float + kind: int + vx: float = 0 + vy: float = 0 + bounces: int = 0 + + +class BoardingEnvironment: + score_cap = 250 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.cooldown = 0 + self.pressed = self.ready = self.terminal = False + self.x, self.direction, self.kind = 50.0, -1, -1 + self.gate = self.gate_target = 91.0 + self.board_credit = 0 + self.boards: list[Board] = [] + self.passengers: list[Passenger] = [] + for y in range(47, 88, 2): + self._add_board(y) + + def _add_board(self, y: float) -> None: + x = self.random.uniform(9, 90) + if all(math.hypot(board.x - x, board.y - y) >= 16 for board in self.boards): + self.boards.append(Board(x, y, int(self.random.choice((-1, 1))))) + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + released = self.pressed and not pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(FRAMES_PER_STEP): + reward += self._advance_frame(released and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self, released: bool) -> int: + for board in self.boards: + board.y -= 0.1 + self.boards = [board for board in self.boards if 15 < board.y < self.gate] + self.gate_target = max(11, self.gate_target - 0.1) + self.gate += (self.gate_target - self.gate) * 0.1 + if self.gate <= 12: + self.terminal = True + return 0 + if self.board_credit >= 2: + self._add_board(self.gate - 3) + self.board_credit -= 2 + + self.cooldown = max(0, self.cooldown - 1) + boarding = self.pressed and self.ready + if boarding and not self.cooldown: + self.passengers.append(Passenger(self.x, 9, self.kind)) + self.cooldown = 10 + self.x += self.direction * (0.1 if boarding else 1) + if self.x < 10 or self.x > 90: + self.direction = 1 if self.x < 10 else -1 + if released: + if self.ready: + self.kind *= -1 + self.ready = True + + reward = 0 + survivors = [] + for passenger in self.passengers: + self._move_passenger(passenger) + if passenger.y <= self.gate: + survivors.append(passenger) + elif (passenger.x - 50) * passenger.kind > 0: + reward += passenger.bounces + self.gate_target = min(91, self.gate_target + 2 * passenger.bounces) + self.board_credit += passenger.bounces + else: + reward -= 1 + passenger.bounces + self.gate_target -= min(20, math.sqrt(1 + passenger.bounces)) + self.passengers = survivors + return reward + + def _move_passenger(self, passenger: Passenger) -> None: + old_x, old_y = passenger.x, passenger.y + passenger.vx *= 0.9 + passenger.vy = (passenger.vy + 0.2) * 0.9 + passenger.x += passenger.vx + passenger.y += passenger.vy + for board in self.boards: + previous = old_y - board.y - board.slope * (old_x - board.x) + current = passenger.y - board.y - board.slope * (passenger.x - board.x) + if previous > 0 or current < 0 or current == previous: + continue + crossing_x = old_x + (passenger.x - old_x) * (-previous / (current - previous)) + if abs(crossing_x - board.x) <= 4: + impulse = math.hypot(passenger.vx, passenger.vy) * math.sqrt(2) + passenger.vx += board.slope * impulse + passenger.vy += impulse + passenger.x += 2 * passenger.vx + passenger.y += 2 * passenger.vy + passenger.bounces += 1 + break + if passenger.x < 0 or passenger.x > 99: + passenger.x = min(99, max(0, passenger.x)) + passenger.vx *= -1 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[0, int(self.x) // 10, 0] = True + state[int(self.gate) // 10, :, 1] = True + for board in self.boards: + state[int(board.y) // 10, int(board.x) // 10, 2 if board.slope < 0 else 3] = True + for passenger in self.passengers: + state[int(passenger.y) // 10, int(passenger.x) // 10, 4 if passenger.kind < 0 else 5] = True + state[0, :4, 1] = self.kind > 0, self.direction > 0, self.ready, self.pressed + return state diff --git a/runtime/minatar_synth/games/bola_thread.py b/runtime/minatar_synth/games/bola_thread.py new file mode 100644 index 0000000000000000000000000000000000000000..140e7aa30134e9356e3a76a2078e6f77bf91b575 --- /dev/null +++ b/runtime/minatar_synth/games/bola_thread.py @@ -0,0 +1,138 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 +SCROLL = 0.55 +ROTATION = 0.022 + + +@dataclass +class Wall: + x: float + gap_y: float + height: float + nub: bool + passed: bool = False + + def blocked(self, y: float, margin: float = 0) -> bool: + return ( + abs(y - self.gap_y) + margin > self.height / 2 + or self.nub and abs(y - 50) < 4 + margin + ) + + +@dataclass +class Beacon: + x: float + y: float + + +class BolaThreadEnvironment: + score_cap = 150 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.freeze = 0 + self.pressed = self.terminal = False + self.angle, self.radius = 0.0, 20.0 + self.next_wall, self.next_beacon = 60.0, 100 + self.walls: list[Wall] = [] + self.beacons: list[Beacon] = [] + + @property + def balls(self) -> tuple[tuple[float, float], tuple[float, float]]: + dx = math.cos(self.angle) * self.radius + dy = math.sin(self.angle) * self.radius + return (30 + dx, 50 + dy), (30 - dx, 50 - dy) + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(FRAMES_PER_STEP): + reward += self._advance_frame() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self) -> int: + if self.freeze: + self.freeze -= 1 + return 0 + self.radius = max(6, self.radius - 0.6) if self.pressed else min(26, self.radius + 0.45) + self.angle = (self.angle + ROTATION) % math.tau + self.next_wall -= SCROLL + self.next_beacon -= 1 + if self.next_wall < 0: + arrival_angle = self.angle + ROTATION * (108 - 30) / SCROLL + nub = self.random.random() < 0.36 and abs(math.sin(arrival_angle)) > 0.8 + gap_y = self.random.uniform(42, 58) + height = self.random.uniform(42, 54) if nub else self.random.uniform(25, 40) + self.walls.append(Wall(108, gap_y, height, nub)) + self.next_wall = self.random.uniform(65, 90) + if self.next_beacon < 0: + self.beacons.append(Beacon(108, self.random.uniform(20, 80))) + self.next_beacon = int(self.random.integers(90, 151)) + + reward = 0 + balls = self.balls + for wall in self.walls: + wall.x -= SCROLL + if any(abs(x - wall.x) < 4 and wall.blocked(y, margin=2) for x, y in balls): + self.terminal = True + return reward + if not wall.passed and wall.x < 30: + wall.passed = True + bonus = max(1, int((self.radius - 6) // 3)) + reward += bonus + self.freeze = 2 + 2 * (bonus >= 3) + 2 * (bonus >= 5) + self.walls = [wall for wall in self.walls if wall.x >= -5] + survivors = [] + for beacon in self.beacons: + beacon.x -= SCROLL + if any(abs(x - beacon.x) < 4.5 and abs(y - beacon.y) < 4.5 for x, y in balls): + reward += 8 + elif beacon.x >= -5: + survivors.append(beacon) + self.beacons = survivors + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[5, 3, 0] = True + for x, y in self.balls: + state[int(y) // 10, int(x) // 10, 1] = True + for wall in self.walls: + if 0 <= wall.x < 100: + column = int(wall.x) // 10 + for row in range(10): + state[row, column, 2] |= abs(10 * row + 5 - wall.gap_y) > wall.height / 2 + state[4:6, column, 3] |= wall.nub + for beacon in self.beacons: + if 0 <= beacon.x < 100: + state[int(beacon.y) // 10, int(beacon.x) // 10, 4] = True + for row, value in enumerate((self.steps, round(self.radius * 10), round(self.angle * 80), self.freeze)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/bomb_up.py b/runtime/minatar_synth/games/bomb_up.py new file mode 100644 index 0000000000000000000000000000000000000000..eb00a38085cb7ec909fa9f0d6015ff21685f5f4e --- /dev/null +++ b/runtime/minatar_synth/games/bomb_up.py @@ -0,0 +1,165 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 + + +@dataclass +class Body: + x: float + y: float + vx: float = 0 + vy: float = 0 + + +@dataclass +class Blast: + x: float + y: float + age: int = 0 + + @property + def radius(self) -> float: + return 25 * math.sin(self.age * 0.15) + + def hits(self, x: float, y: float, tolerance: float) -> bool: + return abs(math.hypot(x - self.x, y - self.y) - self.radius) <= tolerance + + +class BombUpEnvironment: + score_cap = 250 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.spawn_timer = 0 + self.multiplier = 1 + self.pressed = self.terminal = False + self.player = Body(50, 50) + self.spawner = Body(80, 0) + self.bomb: Body | None = None + self.blast: Blast | None = None + self.rocks: list[Body] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(FRAMES_PER_STEP): + reward += self._advance_frame(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + @staticmethod + def _bounce(body: Body) -> None: + if (body.x < 7 and body.vx < 0) or (body.x > 93 and body.vx > 0): + body.x = min(93, max(7, body.x)) + body.vx *= -0.7 + + def _tap(self) -> None: + player = self.player + if self.bomb is None: + direction = -1 if player.vx < 0 else 1 + self.bomb = Body(player.x + 2 * direction, player.y, player.vx + 0.5 * direction, player.vy) + self.multiplier = 1 + return + self.blast = Blast(self.bomb.x, self.bomb.y) + dx, dy = player.x - self.bomb.x, player.y - self.bomb.y + distance_squared = max(1, dx * dx + dy * dy) + player.vx += 20 * dx / distance_squared + player.vy += 20 * dy / distance_squared + self.bomb = None + + def _advance_frame(self, tap: bool) -> int: + player = self.player + scroll = (40 - player.y) * 0.3 if player.y < 40 else min(0, (60 - player.y) * 0.2) + self._bounce(player) + player.vx *= 0.99 + player.vy = (player.vy + 0.02) * 0.99 + player.x += player.vx + player.y += player.vy + scroll + if tap: + self._tap() + if self.bomb is not None: + bomb = self.bomb + self._bounce(bomb) + bomb.vx *= 0.98 + bomb.vy = (bomb.vy + 0.15) * 0.98 + bomb.x += bomb.vx + bomb.y += bomb.vy + scroll + if bomb.y > 103: + self.bomb = None + if self.blast is not None: + self.blast.age += 1 + if self.blast.radius < 0: + self.blast = None + + self.spawner.vx = (self.spawner.vx + self.random.uniform(-0.1, 0.1)) * 0.99 + self.spawner.x += self.spawner.vx + self._bounce(self.spawner) + if self.spawn_timer == 0: + bottom = self.random.random() > (0.05 if player.y > 30 else 0.9) + y = 103 if bottom else -3 + vy = -self.random.uniform(0.5, 1) if bottom else player.vy / 2 + self.rocks.append(Body(self.spawner.x, y, vy=vy)) + self.spawn_timer = int(self.random.integers(8, 11)) + self.spawn_timer -= 1 + + reward = 0 + remaining = [] + for rock in self.rocks: + rock.y += rock.vy + rock.vy = (rock.vy + 0.01) * 0.99 + rock.y += rock.vy + scroll + if self.blast is not None and self.blast.hits(rock.x, rock.y, 3.5): + reward += self.multiplier + self.multiplier += 1 + continue + if abs(rock.x - player.x) < 5.5 and abs(rock.y - player.y) < 5.5: + self.terminal = True + if -50 <= rock.y <= 150: + remaining.append(rock) + self.rocks = remaining + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row = min(9, max(0, int(self.player.y) // 10)) + column = min(9, max(0, int(self.player.x) // 10)) + state[row, column, 0] = True + state[row, column, 4] = self.player.vy < 0 + if self.bomb is not None and 0 <= self.bomb.x < 100 and 0 <= self.bomb.y < 100: + state[int(self.bomb.y) // 10, int(self.bomb.x) // 10, 1] = True + for rock in self.rocks: + if 0 <= rock.y < 100: + state[int(rock.y) // 10, int(rock.x) // 10, 2] = True + if self.blast is not None: + for y in range(10): + for x in range(10): + state[y, x, 3] = self.blast.hits(x * 10 + 5, y * 10 + 5, 7) + for row, value in enumerate((self.steps, self.multiplier)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :3, 5] = self.pressed, self.bomb is not None, self.player.vx < 0 + return state diff --git a/runtime/minatar_synth/games/bore_comet.py b/runtime/minatar_synth/games/bore_comet.py new file mode 100644 index 0000000000000000000000000000000000000000..aefa14d939c65e6e4330c63f8d7bb0155af2dd02 --- /dev/null +++ b/runtime/minatar_synth/games/bore_comet.py @@ -0,0 +1,150 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 +PLAYER_X = 35 +SCROLL = 0.6 + + +@dataclass +class Rock: + x: float + y: float + width: float + height: float + bore: int = 0 + + @property + def threshold(self) -> int: + return round(math.sqrt(self.width * self.height) / (SCROLL / 0.5)) + + def contains(self, y: float) -> bool: + return abs(self.x - PLAYER_X) < self.width / 2 + 2 and abs(self.y - y) < self.height / 2 + 2 + + +@dataclass +class Enemy: + x: float + y: float + vx: float + + +class BoreCometEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.freeze = 0 + self.pressed = self.terminal = self.was_in_rock = False + self.y, self.vy = 30.0, 0.0 + self.next_rock, self.next_enemy = 20.0, 60 + self.rocks: list[Rock] = [] + self.enemies: list[Enemy] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(FRAMES_PER_STEP): + reward += self._advance_frame() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self) -> int: + if self.freeze: + self.freeze -= 1 + return 0 + rock = next((rock for rock in reversed(self.rocks) if rock.contains(self.y)), None) + if rock is not None and not self.pressed: + self.terminal = True + return 0 + + reward = 0 + if self.pressed: + self.vy -= 0.06 if rock is not None else 0.11 + if rock is not None: + rock.bore += 1 + reward += 1 + if rock.bore >= rock.threshold: + reward += rock.threshold + self._blast(15 + (rock.width + rock.height) / 4, 3) + self.rocks.remove(rock) + rock = None + self.vy = min(1.8, max(-1.5, self.vy + 0.05)) + self.y += self.vy * (0.45 if rock is not None else 1) + if self.y < 10: + self.y, self.vy = 10, 0 + if self.was_in_rock and rock is None and self.pressed: + reward += self._blast(22, 2) + self.was_in_rock = rock is not None + + self._spawn() + for obstacle in self.rocks: + obstacle.x -= SCROLL + self.rocks = [obstacle for obstacle in self.rocks if obstacle.x >= -20] + for enemy in self.enemies: + enemy.x += enemy.vx + if rock is None and math.hypot(enemy.x - PLAYER_X, enemy.y - self.y) < 5: + self.terminal = True + self.enemies = [enemy for enemy in self.enemies if enemy.x >= -8] + self.terminal |= self.y > 91 + return reward + + def _blast(self, radius: float, freeze: int) -> int: + survivors = [enemy for enemy in self.enemies if math.hypot(enemy.x - PLAYER_X, enemy.y - self.y) >= radius] + kills = len(self.enemies) - len(survivors) + self.enemies = survivors + if kills or freeze == 3: + self.freeze = max(self.freeze, min(8, freeze + kills)) + return 3 * kills**2 + + def _spawn(self) -> None: + self.next_rock -= SCROLL + if self.next_rock < 0: + self.rocks.append(Rock(112, self.random.uniform(25, 75), self.random.uniform(14, 30), self.random.uniform(10, 22))) + self.next_rock = self.random.uniform(30, 55) + self.next_enemy -= 1 + if self.next_enemy < 0: + self.enemies.append(Enemy(105, self.random.uniform(8, 84), -SCROLL - self.random.uniform(0.2, 0.5))) + self.next_enemy = int(self.random.integers(50, 91)) + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row = int(self.y) // 10 + state[row, 3, 0] = True + state[row, 3, 4] = self.pressed + state[9, :, 3] = True + for rock in self.rocks: + for row in range(10): + if abs(row * 10 + 5 - rock.y) < rock.height / 2 + 5: + for column in range(10): + state[row, column, 1] |= abs(column * 10 + 5 - rock.x) < rock.width / 2 + 5 + for enemy in self.enemies: + if 0 <= enemy.x < 100: + state[int(enemy.y) // 10, int(enemy.x) // 10, 2] = True + active_rock = next((rock for rock in reversed(self.rocks) if rock.contains(self.y)), None) + for row, value in enumerate((self.steps, self.freeze, active_rock.bore if active_rock else 0)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.vy < 0, self.was_in_rock + return state diff --git a/runtime/minatar_synth/games/bottop.py b/runtime/minatar_synth/games/bottop.py new file mode 100644 index 0000000000000000000000000000000000000000..2274935394b534ec04301a15a257344ed95d129e --- /dev/null +++ b/runtime/minatar_synth/games/bottop.py @@ -0,0 +1,92 @@ +from dataclasses import dataclass + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 + + +@dataclass +class Spike: + x: float + y: float + + +class BottopEnvironment: + score_cap = HORIZON * FRAMES_PER_STEP / 10 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = 0 + self.spawn_distance = self.height = self.velocity = 0.0 + self.jumping = self.pressed = self.terminal = False + self.spikes: list[Spike] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + frames = 0 + for _ in range(FRAMES_PER_STEP): + self._advance_frame() + frames += 1 + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return frames / 10, self.terminal + + def _advance_frame(self) -> None: + self.spawn_distance -= 1 + if self.spawn_distance < 0: + if self.random.random() < 0.33: + y = float(self.random.choice((8, 92))) + else: + y = self.random.uniform(8, 92) + self.spikes.append(Spike(103, y)) + self.spawn_distance += self.random.uniform(30, 60) + for spike in self.spikes: + spike.x -= 1 + self.spikes = [spike for spike in self.spikes if spike.x > -3] + + if not self.jumping and self.pressed: + self.jumping = True + self.velocity = 3 + if self.jumping: + self.velocity -= 0.1 if self.pressed else 0.3 + self.height += self.velocity + if self.height < 0: + self.height = self.velocity = 0 + self.jumping = False + top, bottom = 8 + self.height, 92 - self.height + self.terminal = any( + abs(spike.x - 9) < 6 and min(abs(spike.y - top), abs(spike.y - bottom)) < 6 + for spike in self.spikes + ) + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[int(8 + self.height) // 10, 0, 0] = True + state[int(92 - self.height) // 10, 0, 1] = True + for spike in self.spikes: + if 0 <= spike.x < 100: + state[int(spike.y) // 10, int(spike.x) // 10, 2] = True + state[(0, 9), :, 3] = True + state[0, :3, 4] = self.pressed, self.jumping, self.velocity > 0 + for bit in range(9): + state[9, bit, 5] = bool(self.steps & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/bowling.py b/runtime/minatar_synth/games/bowling.py new file mode 100644 index 0000000000000000000000000000000000000000..e767477ca7b86c239a39a9380f91be765a6d61e7 --- /dev/null +++ b/runtime/minatar_synth/games/bowling.py @@ -0,0 +1,164 @@ +import numpy as np + + +PIN_POSITIONS = ((4, 6), (3, 7), (5, 7), (2, 8), (4, 8), (6, 8), (1, 9), (3, 9), (5, 9), (7, 9)) + + +class BowlingEnvironment: + """Ten-frame steerable bowling with standard strike, spare, and tenth-frame scoring.""" + + score_cap = 300.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 500): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.bowler_row = 4 + self.ball: list[int] | None = None + self.previous_ball: list[int] | None = None + self.hook = 0 + self.standing = set(range(10)) + self.frames: list[list[int]] = [[] for _ in range(10)] + self.frame = 0 + self.confirmed_score = 0 + self.steps = 0 + self.last_action = 0 + self.terminal = False + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + if self.ball is None: + if action == 2: + self.bowler_row = max(1, self.bowler_row - 1) + elif action == 4: + self.bowler_row = min(7, self.bowler_row + 1) + elif action == 5: + self.ball = [self.bowler_row, 0] + self.previous_ball = self.ball.copy() + self.hook = 0 + else: + self.previous_ball = self.ball.copy() + if action == 2: + self.ball[0] = max(1, self.ball[0] - 1) + self.hook = max(-1, self.hook - 1) + elif action == 4: + self.ball[0] = min(7, self.ball[0] + 1) + self.hook = min(1, self.hook + 1) + self.ball[1] += 1 + if self.ball[1] >= 9: + previous_score = self.confirmed_score + self._finish_roll() + self.confirmed_score = self._score_available() + reward = float(self.confirmed_score - previous_score) + self.steps += 1 + return reward, self.terminal + self.steps += 1 + if self.steps >= self.horizon: + self.terminal = True + return 0.0, self.terminal + + def _finish_roll(self) -> None: + knocked = self._knocked_pins() + self.standing -= knocked + pinfall = len(knocked) + frame_rolls = self.frames[self.frame] + frame_rolls.append(pinfall) + self.ball = None + self.previous_ball = None + self.hook = 0 + if self.frame < 9: + if pinfall == 10 or len(frame_rolls) == 2: + self.frame += 1 + self.standing = set(range(10)) + return + if len(frame_rolls) == 1: + if pinfall == 10: + self.standing = set(range(10)) + elif len(frame_rolls) == 2: + if frame_rolls[0] == 10: + if pinfall == 10: + self.standing = set(range(10)) + elif sum(frame_rolls) == 10: + self.standing = set(range(10)) + else: + self.terminal = True + else: + self.terminal = True + + def _knocked_pins(self) -> set[int]: + if not self.standing or self.ball is None: + return set() + entry_row = self.ball[0] + if self.standing == set(range(10)) and entry_row == 4 and self.hook != 0: + return self.standing.copy() + knocked = { + index + for index in self.standing + if abs(PIN_POSITIONS[index][0] - entry_row) <= 1 + } + if self.hook < 0: + knocked |= {index for index in self.standing if PIN_POSITIONS[index][0] < entry_row and abs(PIN_POSITIONS[index][0] - entry_row) <= 2} + elif self.hook > 0: + knocked |= {index for index in self.standing if PIN_POSITIONS[index][0] > entry_row and abs(PIN_POSITIONS[index][0] - entry_row) <= 2} + return knocked + + def _score_available(self) -> int: + flattened = [roll for frame in self.frames for roll in frame] + score = 0 + cursor = 0 + for frame_index in range(9): + frame = self.frames[frame_index] + if not frame: + break + if frame[0] == 10: + if cursor + 2 >= len(flattened): + break + score += 10 + flattened[cursor + 1] + flattened[cursor + 2] + cursor += 1 + elif len(frame) == 2 and sum(frame) == 10: + if cursor + 2 >= len(flattened): + break + score += 10 + flattened[cursor + 2] + cursor += 2 + elif len(frame) == 2: + score += sum(frame) + cursor += 2 + else: + break + tenth = self.frames[9] + if self.frame == 9 or self.terminal: + score += sum(tenth) + return score + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[self.bowler_row, 0, 0] = True + state[0, :, 1] = True + state[9, :, 1] = True + for index in self.standing: + state[*PIN_POSITIONS[index], 2] = True + if self.ball is not None: + state[*self.ball, 3] = True + if self.previous_ball is not None: + state[*self.previous_ball, 4] = True + state[9, : self.frame + 1, 5] = True + state[8, : min(10, len(self.frames[self.frame]) + 1), 5] = True + score_bucket = min(9, self.confirmed_score // 30) + state[7, : score_bucket + 1, 5] = True + state[6, self.hook + 1, 5] = True + return state diff --git a/runtime/minatar_synth/games/boxing.py b/runtime/minatar_synth/games/boxing.py new file mode 100644 index 0000000000000000000000000000000000000000..0b0d41745d29da814f9c9d0a8314bfff393e1496 --- /dev/null +++ b/runtime/minatar_synth/games/boxing.py @@ -0,0 +1,147 @@ +import numpy as np + + +DELTAS = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)} + + +class BoxingEnvironment: + """Two-minute top-down bout with guarded jabs, power punches, and counter windows.""" + + score_cap = 100.0 + + def __init__(self, sticky_action_prob: float = 0.1, round_steps: int = 120): + self.sticky_action_prob = sticky_action_prob + self.round_steps = round_steps + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.player = [5, 2] + self.opponent = [5, 7] + self.previous_player = self.player.copy() + self.previous_opponent = self.opponent.copy() + self.player_score = 0 + self.opponent_score = 0 + self.player_recovery = 0 + self.opponent_recovery = 0 + self.player_punch: list[int] | None = None + self.opponent_punch: list[int] | None = None + self.steps = 0 + self.last_action = 0 + self.terminal = False + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + self.previous_opponent = self.opponent.copy() + self.player_punch = None + self.opponent_punch = None + reward = 0.0 + if action in DELTAS: + self._move(self.player, self.opponent, action) + elif action == 5 and self.player_recovery == 0: + scored = self._punch(self.player, self.opponent, defender_is_player=False) + reward = float(min(scored, 100 - self.player_score)) + self.player_score += int(reward) + self.player_recovery = 2 + if self.player_score >= 100: + self.player_score = 100 + self.terminal = True + return reward, True + + if self.steps < 60 or self.steps % 2 == 0: + self._opponent_action() + self.player_recovery = max(0, self.player_recovery - 1) + self.opponent_recovery = max(0, self.opponent_recovery - 1) + self.steps += 1 + if self.opponent_score >= 100 or self.steps >= self.round_steps: + self.opponent_score = min(100, self.opponent_score) + self.terminal = True + return reward, self.terminal + + @staticmethod + def _move(boxer: list[int], other: list[int], action: int) -> None: + row_delta, column_delta = DELTAS[action] + target = [boxer[0] + row_delta, boxer[1] + column_delta] + if 1 <= target[0] <= 8 and 1 <= target[1] <= 8 and target != other: + boxer[:] = target + + def _punch(self, attacker: list[int], defender: list[int], defender_is_player: bool) -> int: + row_distance = abs(attacker[0] - defender[0]) + column_distance = abs(attacker[1] - defender[1]) + distance = max(row_distance, column_distance) + if distance > 2: + return 0 + recovery = self.player_recovery if defender_is_player else self.opponent_recovery + angled = row_distance > 0 and column_distance > 0 + if not angled and recovery == 0: + return 0 + points = 2 if distance == 1 else 1 + punch_cell = [ + attacker[0] + int(np.sign(defender[0] - attacker[0])), + attacker[1] + int(np.sign(defender[1] - attacker[1])), + ] + if defender_is_player: + self.opponent_punch = punch_cell + else: + self.player_punch = punch_cell + self._push(attacker, defender) + return points + + @staticmethod + def _push(attacker: list[int], defender: list[int]) -> None: + row_delta = int(np.sign(defender[0] - attacker[0])) + column_delta = int(np.sign(defender[1] - attacker[1])) + target = [ + int(np.clip(defender[0] + row_delta, 1, 8)), + int(np.clip(defender[1] + column_delta, 1, 8)), + ] + if target != attacker: + defender[:] = target + + def _opponent_action(self) -> None: + row_distance = abs(self.opponent[0] - self.player[0]) + column_distance = abs(self.opponent[1] - self.player[1]) + if max(row_distance, column_distance) <= 2 and self.opponent_recovery == 0: + self.opponent_score += self._punch(self.opponent, self.player, defender_is_player=True) + self.opponent_recovery = 2 + return + candidates = [] + for action in DELTAS: + row_delta, column_delta = DELTAS[action] + target = [self.opponent[0] + row_delta, self.opponent[1] + column_delta] + if not (1 <= target[0] <= 8 and 1 <= target[1] <= 8) or target == self.player: + continue + distance = max(abs(target[0] - self.player[0]), abs(target[1] - self.player[1])) + angled_bonus = -1 if target[0] != self.player[0] and target[1] != self.player[1] else 0 + candidates.append((distance + angled_bonus, self.random.rand(), action)) + if candidates: + self._move(self.opponent, self.player, min(candidates)[2]) + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + state[*self.opponent, 1] = True + state[*self.opponent, 2] = True + if self.player_punch is not None: + state[*self.player_punch, 3] = True + state[*self.previous_player, 4] = True + state[*self.previous_opponent, 4] = True + state[9, : min(10, (self.player_score + 9) // 10), 5] = True + state[8, : min(10, (self.opponent_score + 9) // 10), 5] = True + remaining = max(0, self.round_steps - self.steps) + state[7, : min(10, (remaining + 11) // 12), 5] = True + state[6, : self.player_recovery, 5] = True + return state diff --git a/runtime/minatar_synth/games/breed_c.py b/runtime/minatar_synth/games/breed_c.py new file mode 100644 index 0000000000000000000000000000000000000000..8db75abc5801cea99f99cfdff60488a113cca8ce --- /dev/null +++ b/runtime/minatar_synth/games/breed_c.py @@ -0,0 +1,138 @@ +import numpy as np + + +SIZE = 9 +CENTER = SIZE // 2 +EMPTY = -1 +HORIZON = 400 +GROWTH_INTERVAL = 30 +SETTLE_DELAY = 15 +DIRECTIONS = ((0, -1), (-1, 0), (1, 0), (0, 1)) + + +class BreedCEnvironment: + score_cap = 250 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.last_action = self.growth_count = self.settle = self.clears = 0 + self.multiplier = 1 + self.timer = GROWTH_INTERVAL + self.terminal = False + self.cursor = CENTER, CENTER + self.grid = np.full((SIZE, SIZE), EMPTY, dtype=np.int8) + self.grid[CENTER, CENTER] = self.random.integers(4) + self._grow() + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + select = action == 5 and self.last_action != 5 + self.last_action = action + self.steps += 1 + reward = 0 + if 1 <= action <= 4: + dy, dx = DIRECTIONS[action - 1] + y, x = self.cursor + self.cursor = min(SIZE - 1, max(0, y + dy)), min(SIZE - 1, max(0, x + dx)) + if self.settle: + self.settle -= 1 + if not self.settle: + self._compact() + self.clears += 1 + self.timer = GROWTH_INTERVAL + else: + if self.grid[CENTER, CENTER] == EMPTY: + self.grid[CENTER, CENTER] = self.random.integers(4) + if select: + reward = self._erase() + if not self.settle: + self.timer -= 1 + if self.timer <= 0: + self._grow() + self.terminal = self.steps >= self.horizon or bool(np.all(self.grid != EMPTY)) + return float(reward), self.terminal + + def _erase(self) -> int: + color = self.grid[self.cursor] + group = set() + if color != EMPTY: + group.add(self.cursor) + pending = [self.cursor] + while pending: + y, x = pending.pop() + for dy, dx in DIRECTIONS: + ny, nx = y + dy, x + dx + neighbor = ny, nx + if 0 <= ny < SIZE and 0 <= nx < SIZE and neighbor not in group and self.grid[neighbor] == color: + group.add(neighbor) + pending.append(neighbor) + size = len(group) + if size < 4: + self._grow() + self._grow() + return -size + for cell in group: + self.grid[cell] = EMPTY + reward = size * self.multiplier + self.multiplier += 1 + self.settle = SETTLE_DELAY + return reward + + def _grow(self) -> None: + lines = self.grid if self.growth_count % 2 == 0 else self.grid.T + old = lines.copy() + lines[:, :CENTER - 1] = old[:, 1:CENTER] + lines[:, CENTER + 2:] = old[:, CENTER + 1:-1] + for line in lines: + color = int(line[CENTER]) + if color != EMPTY: + direction = int(self.random.choice((-1, 1))) + new_color = (color + int(self.random.integers(3))) % 4 + line[CENTER - direction] = color + line[CENTER] = line[CENTER + direction] = new_color + self.growth_count += 1 + self.multiplier = 1 + self.timer = GROWTH_INTERVAL + + def _compact(self) -> None: + axes = (self.grid, self.grid.T) + if self.clears % 2: + axes = axes[::-1] + moved = True + while moved: + moved = False + for lines in axes: + for line in lines: + for start, stop, step in ((CENTER, 0, -1), (CENTER, SIZE - 1, 1)): + for index in range(start, stop, step): + source = index + step + if line[index] == EMPTY and line[source] != EMPTY: + line[index], line[source] = line[source], EMPTY + moved = True + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for color in range(4): + state[:SIZE, :SIZE, color] = self.grid == color + state[*self.cursor, 4] = True + for row, value in enumerate((self.steps, self.timer, self.settle, self.multiplier)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.last_action == 5 + state[9, 1, 5] = self.growth_count % 2 == 1 + return state diff --git a/runtime/minatar_synth/games/bridge_cross.py b/runtime/minatar_synth/games/bridge_cross.py new file mode 100644 index 0000000000000000000000000000000000000000..a4f12afbcf789738444e17f736f678e91d5331c9 --- /dev/null +++ b/runtime/minatar_synth/games/bridge_cross.py @@ -0,0 +1,113 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 +BRIGADE_LEFT = 10 +BRIGADE_RIGHT = 40 +BRIDGE_TOP = 32 +GROUND = 37 + + +@dataclass +class Bridge: + x: float + length: float + + def overlaps_brigade(self) -> bool: + return self.x <= BRIGADE_RIGHT and self.x + self.length >= BRIGADE_LEFT + + +class BridgeCrossEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.score_timer = 0 + self.spawn_timer = 0.0 + self.multiplier = 1 + self.y, self.vy = float(GROUND), 0.0 + self.pressed = self.jumping = self.falling = self.on_bridge = self.terminal = False + self.bridges: list[Bridge] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(FRAMES_PER_STEP): + reward += self._advance_frame(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self, tap: bool) -> int: + if self.spawn_timer <= 0: + self.bridges.append(Bridge(153, self.random.uniform(20, 40))) + self.spawn_timer = self.random.uniform(50, 100) + self.spawn_timer -= 1 + for bridge in self.bridges: + bridge.x -= 1 + self.bridges = [bridge for bridge in self.bridges if bridge.x + bridge.length > 0] + above_bridge = any(bridge.overlaps_brigade() for bridge in self.bridges) + + if self.y < 35 and not above_bridge: + self.falling, self.on_bridge = True, False + if self.jumping or self.falling: + self.y += self.vy + self.vy += 0.1 if self.pressed else 0.2 + surface = BRIDGE_TOP if above_bridge else GROUND + if self.y > surface and self.vy > 0: + self.y, self.vy = float(surface), 0.0 + self.jumping = self.falling = False + self.on_bridge = above_bridge + + if tap and not self.jumping: + self.jumping, self.on_bridge = True, False + self.vy = -2 + self.multiplier = math.ceil(self.multiplier / 2) + if not self.jumping and self.y > BRIDGE_TOP and above_bridge: + self.terminal = True + + if self.on_bridge: + self.score_timer -= 1 + if self.score_timer < 0: + reward = self.multiplier + self.multiplier += 1 + self.score_timer = 10 + return reward + return 0 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row = int(self.y) // 5 + state[row, :3, 0] = True + state[row, :3, 3] = self.on_bridge + state[8:, :, 2] = True + for bridge in self.bridges: + for column in range(10): + state[7, column, 1] |= column * 15 < bridge.x + bridge.length and (column + 1) * 15 > bridge.x + state[0, :3, 4] = self.pressed, self.jumping, self.vy < 0 + for row, value in enumerate((self.steps, self.multiplier, self.score_timer)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/bs_fish.py b/runtime/minatar_synth/games/bs_fish.py new file mode 100644 index 0000000000000000000000000000000000000000..911007ef6ccdb4c858e5e1e64f9f4c40af96e39a --- /dev/null +++ b/runtime/minatar_synth/games/bs_fish.py @@ -0,0 +1,111 @@ +from dataclasses import dataclass + +import numpy as np + + +HORIZON = 400 +SPAWN_INTERVAL = 8 +MAX_FISH = (HORIZON // SPAWN_INTERVAL) * 13 +BIRD_ROW = 2 +NORMAL, BIG, FAKE, EYE = range(4) +FLIGHT = (8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9) +FRAGMENTS = ((0, 2), (0, 3), (0, 4), (1, 0), (1, 1), (1, 2), (1, 3), + (1, 4), (1, 5), (2, 1), (2, 2), (2, 3), (2, 5)) + + +@dataclass +class Fish: + column: int + kind: int = NORMAL + age: int = 0 + row_offset: int = 0 + + @property + def row(self) -> int: + return max(0, min(9, FLIGHT[self.age] + self.row_offset)) + + +class BSFishEnvironment: + score_cap = MAX_FISH * (1 + 5 * (MAX_FISH - 1)) + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.last_action = self.speed = 0 + self.multiplier = 1 + self.special_in = 3 + self.fish: list[Fish] = [] + self.terminal = False + + @property + def bird_column(self) -> int: + return 1 + self.speed // 2 + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.steps += 1 + self.speed = min(6, self.speed + 1) if action == 5 else max(0, self.speed - 1) + if self.steps % SPAWN_INTERVAL == 1: + if self.special_in == 0: + kind = int(self.random.choice((BIG, FAKE))) + self.special_in = int(self.random.integers(3, 9)) + else: + kind = NORMAL + self.special_in -= 1 + self.fish.append(Fish(int(self.random.integers(7, 10)), kind)) + reward = 0 + remaining = [] + for fish in self.fish: + fish.age += 1 + if self.speed >= 4 or self.steps % 3 == 0: + fish.column -= 1 + if fish.age == len(FLIGHT) or fish.column < -1: + if fish.kind != BIG: + self.multiplier = max(1, self.multiplier - 1) + continue + if fish.kind == FAKE and fish.row <= 5: + remaining.extend(Fish(fish.column + column - 2, EYE if (row, column) == (1, 2) else NORMAL, + fish.age, row - 1) for row, column in FRAGMENTS) + elif fish.kind == BIG: + if abs(fish.row - BIRD_ROW) <= 1 and abs(fish.column - self.bird_column) <= 1: + self.terminal = True + remaining.append(fish) + elif fish.row == BIRD_ROW and fish.column == self.bird_column: + reward += self.multiplier + self.multiplier += 10 if fish.kind == EYE else 1 + else: + remaining.append(fish) + self.fish = remaining + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[BIRD_ROW, self.bird_column, 0] = True + for fish in self.fish: + if 0 <= fish.column < 10: + channel = (2, 1, 1, 3)[fish.kind] + state[fish.row, fish.column, channel] = True + next_row = FLIGHT[min(fish.age + 1, len(FLIGHT) - 1)] + fish.row_offset + if 0 <= next_row < 10: + state[next_row, fish.column, 4] = True + for row, value in enumerate((self.steps, self.speed, self.multiplier, self.special_in, self.last_action)): + for bit in range(13): + index = row * 13 + bit + state[index // 10, index % 10, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/c_nodes.py b/runtime/minatar_synth/games/c_nodes.py new file mode 100644 index 0000000000000000000000000000000000000000..e1d91e269a2c5a0403f0af5297bf41953c56e3d4 --- /dev/null +++ b/runtime/minatar_synth/games/c_nodes.py @@ -0,0 +1,165 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 +DIRECTIONS = ((0, -1), (-1, 0), (1, 0), (0, 1)) + + +@dataclass(eq=False) +class Node: + x: float + y: float + vx: float = 0 + vy: float = 0 + anchored: bool = True + tethered: bool = False + + +@dataclass +class Link: + a: Node + b: Node + length: float + + def near(self, x: float, y: float) -> bool: + dx, dy = self.b.x - self.a.x, self.b.y - self.a.y + px, py = x - self.a.x, y - self.a.y + squared = dx * dx + dy * dy + fraction = min(1, max(0, (px * dx + py * dy) / squared)) if squared else 0 + return math.hypot(px - fraction * dx, py - fraction * dy) <= 5 + + +class CNodesEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.last_action = 0 + self.multiplier = 1 + self.next_node = self.boost = 0.0 + self.cursor = (3, 5) + self.terminal = False + self.nodes: list[Node] = [] + self.links: list[Link] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + if 1 <= action <= 4: + dy, dx = DIRECTIONS[action - 1] + row, col = self.cursor + self.cursor = min(9, max(2, row + dy)), min(9, max(0, col + dx)) + if action == 5 and self.last_action != 5: + row, col = self.cursor + self.links = [link for link in self.links if not link.near(col * 10 + 5, row * 10 + 5)] + self.multiplier = 1 + self.boost = 1 + self.last_action = action + self.steps += 1 + reward = 0 + for _ in range(FRAMES_PER_STEP): + reward += self._advance_frame() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self) -> int: + lowest = max((node.y for node in self.nodes), default=0) + scroll = 0.03 + self.boost + max(0, 29 - lowest) * 0.1 + self.boost *= 0.7 + self.next_node -= scroll + if self.next_node < 0: + new = Node(self.random.uniform(10, 90), 0) + for node in self.nodes: + if node.anchored and abs(new.x - node.x) / 2 + abs(node.y) < 30 and self.random.random() < 0.7: + self.links.append(Link(new, node, math.hypot(new.x - node.x, node.y))) + self.nodes.append(new) + self.next_node = 4 + for link in self.links: + dx, dy = link.b.x - link.a.x, link.b.y - link.a.y + distance = math.hypot(dx, dy) + if distance: + force = (distance - link.length) * 0.02 / distance + link.a.vx += force * dx + link.a.vy += force * dy + link.b.vx -= force * dx + link.b.vy -= force * dy + for node in self.nodes: + node.y += scroll + node.anchored &= node.y <= 20 + if node.anchored: + node.vx = node.vy = 0 + else: + node.x += node.vx + node.y += node.vy + node.vx *= 0.95 + node.vy = (node.vy + 0.03) * 0.95 + self.links = [link for link in self.links if min(link.a.y, link.b.y) <= 100] + self._update_tethers() + reward = 0 + survivors = [] + for node in self.nodes: + if node.tethered and node.y > 100: + self.terminal = True + if node.y > 140: + reward += self.multiplier + self.multiplier = min(64, self.multiplier * 2) + else: + survivors.append(node) + self.nodes = survivors + alive = set(survivors) + self.links = [link for link in self.links if link.a in alive and link.b in alive] + return reward + + def _update_tethers(self) -> None: + connected = {node: [] for node in self.nodes} + for link in self.links: + connected[link.a].append(link.b) + connected[link.b].append(link.a) + pending = [node for node in self.nodes if node.anchored] + reached = set(pending) + while pending: + for neighbor in connected[pending.pop()]: + if neighbor not in reached: + reached.add(neighbor) + pending.append(neighbor) + for node in self.nodes: + node.tethered = node in reached and not node.anchored + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for node in self.nodes: + if 0 <= node.x < 100 and 0 <= node.y < 100: + channel = 0 if node.anchored else 1 if node.tethered else 2 + state[int(node.y) // 10, int(node.x) // 10, channel] = True + for link in self.links: + for fraction in np.linspace(0, 1, 12): + x = link.a.x + (link.b.x - link.a.x) * fraction + y = link.a.y + (link.b.y - link.a.y) * fraction + if 0 <= x < 100 and 0 <= y < 100: + state[int(y) // 10, int(x) // 10, 3] = True + row, col = self.cursor + state[row, col, 4] = True + for row, value in enumerate((self.steps, self.multiplier, self.last_action)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/c_tower.py b/runtime/minatar_synth/games/c_tower.py new file mode 100644 index 0000000000000000000000000000000000000000..5befba8e092385a0c4bb835c9b7140ccd84bd8e4 --- /dev/null +++ b/runtime/minatar_synth/games/c_tower.py @@ -0,0 +1,124 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 +HALF_PI = math.pi / 2 + + +def wrap(angle: float) -> float: + return (angle + math.pi) % math.tau - math.pi + + +@dataclass +class Wall: + angle: float + width: float + y: float + floating: bool + bonus: bool + + def projection(self, player_angle: float, rear: bool = False) -> tuple[float, float]: + relative = player_angle - self.angle + (math.pi if rear else 0) + start = max(-HALF_PI, min(HALF_PI, wrap(relative - self.width / 2))) + end = max(-HALF_PI, min(HALF_PI, wrap(relative + self.width / 2))) + radius = 48 if self.floating else 44 + return 50 + math.sin(start) * radius, 50 + math.sin(end) * radius + + +class CTowerEnvironment: + score_cap = 5000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = 0 + self.pressed = self.terminal = False + self.angle, self.y, self.speed = 0.0, 80.0, 3.0 + self.angular_velocity = -1.0 + self.direction = -1 + self.next_wall = 0.0 + self.next_bonus = self.multiplier = 1 + self.walls: list[Wall] = [] + + @property + def player_x(self) -> float: + return 50 + 30 * self.angular_velocity + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0.0 + for _ in range(FRAMES_PER_STEP): + reward += self._advance_frame() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return reward, self.terminal + + def _advance_frame(self) -> float: + self.speed += ((9 if self.pressed else 1) - self.speed) * 0.2 + self.angular_velocity += (self.direction - self.angular_velocity) * 0.2 + self.y = max(80, self.y - 0.01) + self.angle = wrap(self.angle + self.angular_velocity * 0.05) + scroll = self.speed * 0.3 + self.next_wall -= scroll + if self.next_wall < 0: + self.next_bonus -= 1 + bonus = self.next_bonus < 0 + if bonus: + self.next_bonus = int(self.random.integers(9, 13)) + self.walls.append(Wall(self.random.uniform(0, math.tau), + self.random.uniform(math.pi / 4, HALF_PI), + -5, bonus or self.random.random() < 0.3, bonus)) + self.next_wall += self.random.uniform(30, 40) + + for wall in self.walls: + wall.y += scroll + left, right = wall.projection(self.angle) + if left >= right or not (left - 3 < self.player_x < right + 3 and self.y - 3 < wall.y < self.y + 8): + continue + if wall.bonus: + self.multiplier += 1 + wall.bonus = False + elif not wall.floating: + self.angle = wrap(wall.angle - self.direction * (wall.width / 2 + 0.7)) + self.direction *= -1 + self.y = min(99, wall.y + 6) + self.walls = [wall for wall in self.walls if wall.y <= 105] + self.terminal = self.y > 97 + return scroll * self.multiplier + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[int(self.y) // 10, int(self.player_x) // 10, 0] = True + for wall in self.walls: + if 0 <= wall.y < 100: + row = int(wall.y) // 10 + for rear in (False, True): + left, right = wall.projection(self.angle, rear) + if left < right: + channel = 4 if rear else 3 if wall.bonus else 2 if wall.floating else 1 + state[row, int(left) // 10:int(right) // 10 + 1, channel] = True + for row, value in enumerate((self.steps, self.multiplier, round(self.speed * 10))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.direction > 0 + return state diff --git a/runtime/minatar_synth/games/card_q.py b/runtime/minatar_synth/games/card_q.py new file mode 100644 index 0000000000000000000000000000000000000000..4f8bc03c5171140f8c32b1e3272267a4d3fb882d --- /dev/null +++ b/runtime/minatar_synth/games/card_q.py @@ -0,0 +1,141 @@ +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 +COLUMNS = 5 + + +class CardQEnvironment: + score_cap = 250 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.player = self.random.integers(1, 14, (5, 5)) + self.player[0] = [1, 3, 3, 11, 13] + self.enemy = self.random.integers(1, 14, (5, 5)) + self.piles = [2, 12] + self.steps = self.last_action = self.player_pile = self.enemy_pile = 0 + self.shuffle_timer = self.shuffle_count = 0 + self.enemy_timer = 120.0 + self.enemy_column: int | None = None + self.center = self.target = 40.0 + self.multiplier = 1 + self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def _match(self, rank: int, preferred: int) -> int | None: + for index in (preferred, 1 - preferred): + if (rank - self.piles[index]) % 13 in (1, 12): + return index + return None + + def _place(self, cards: np.ndarray, column: int, pile: int) -> None: + self.piles[pile] = int(cards[0, column]) + cards[:-1, column] = cards[1:, column] + cards[-1, column] = self.random.integers(1, 14) + self.shuffle_timer = self.shuffle_count = 0 + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + column = action - 1 if 1 <= action <= COLUMNS and action != self.last_action else None + self.last_action = action + self.steps += 1 + reward = 0 + for frame in range(FRAMES_PER_STEP): + reward += self._advance_frame(column if frame == 0 else None) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self, column: int | None) -> int: + self.shuffle_timer += 1 + if self.shuffle_timer > 60: + player_can_play = any(self._match(rank, self.player_pile) is not None for rank in self.player[0]) + enemy_can_play = any(self._match(rank, self.enemy_pile) is not None for rank in self.enemy[0]) + if not player_can_play: + self.enemy_timer *= 0.3 + self.shuffle_count += 1 + if not (player_can_play or enemy_can_play) or self.shuffle_count > 2: + self.piles = self.random.integers(1, 14, 2).tolist() + self.shuffle_count = 0 + self.shuffle_timer = 0 + + reward = 0 + if column is not None: + pile = self._match(self.player[0, column], self.player_pile) + if pile is None: + self.target += 5 + self.multiplier = 1 + self.shuffle_timer = self.shuffle_count = 0 + else: + self._place(self.player, column, pile) + self.player_pile = pile + self.target -= 5 + reward = self.multiplier + self.multiplier += 1 + + self.enemy_timer -= 1 + if self.enemy_timer < 0: + self._enemy_turn() + self.center += (self.target - self.center) * 0.1 + if self.target < 16: + self.target += (16 - self.target) * 0.1 + self.terminal = self.center > 94 + return reward + + def _enemy_turn(self) -> None: + self.enemy_timer = self.random.uniform(50, 70) + if self.enemy_column is not None: + pile = self._match(self.enemy[0, self.enemy_column], self.enemy_pile) + if pile is None: + self.enemy_timer *= 3 + else: + self._place(self.enemy, self.enemy_column, pile) + self.enemy_pile = pile + self.target += 5 + self.multiplier = 1 + + self.enemy_column = None + start = int(self.random.integers(COLUMNS)) + for offset in range(COLUMNS): + column = (start + offset) % COLUMNS + pile = self._match(self.enemy[0, column], self.enemy_pile) + if pile is not None: + self.enemy_column = column + if pile != self.enemy_pile: + self.enemy_timer *= 1.5 + break + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + cards = np.concatenate((self.enemy[::-1], self.player)) + for bit in range(4): + state[:, :5, bit] = (cards & (1 << bit)) != 0 + state[4:6, :5, 4] = True + if self.enemy_column is not None: + state[4, self.enemy_column, 5] = True + for index, rank in enumerate(self.piles): + for bit in range(4): + state[4 + index, 5, bit] = bool(rank & (1 << bit)) + state[4 + index, 5, 4:6] = index == self.player_pile, index == self.enemy_pile + for row, value in enumerate((self.steps, self.multiplier, round(self.center), round(self.target), + round(self.enemy_timer), self.shuffle_timer, self.shuffle_count, self.last_action)): + for bit in range(10): + state[row, 6 + bit // 5, bit % 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/cast_n.py b/runtime/minatar_synth/games/cast_n.py new file mode 100644 index 0000000000000000000000000000000000000000..826a7e5bc41b33025711011e036f4393265b83f3 --- /dev/null +++ b/runtime/minatar_synth/games/cast_n.py @@ -0,0 +1,111 @@ +import numpy as np + + +HORIZON = 320 +SCHOOL_INTERVAL = 8 +MAX_FISH = (HORIZON // SCHOOL_INTERVAL) * 3 +ANCHOR = (3, 0) + + +class CastNEnvironment: + score_cap = MAX_FISH * (MAX_FISH + 1) // 2 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.mode = 0 + self.power = 0 + self.water = 50 + self.steps = 0 + self.last_action = 0 + self.lure = ANCHOR + self.fish: set[tuple[int, int, bool]] = set() + self.caught: list[bool] = [] + self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def _line(self) -> set[tuple[int, int]]: + row, column = self.lure + if column == 0: + return {ANCHOR} + return {(round(ANCHOR[0] + (row - ANCHOR[0]) * x / column), x) + for x in range(column + 1)} + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + pressed = action == 5 and self.last_action != 5 + self.last_action = action + self.steps += 1 + if self.mode == 0 and pressed: + self.mode, self.power = 1, 1 + elif self.mode == 1: + if action == 5 and self.power < 3: + self.power += 1 + else: + self.lure = (2, self.power * 3) + self.mode = 2 + elif self.mode == 2 and pressed: + self.mode = 3 + if self.mode == 2: + row, column = self.lure + self.lure = (min(9, row + 1), column) + + if self.steps % 2 == 0: + surface = min(8, self.water // 10 + 1) + self.fish = {(max(surface, row), column - 1, red) + for row, column, red in self.fish if column > 0} + if self.steps % SCHOOL_INTERVAL == 0: + red = self.steps % (SCHOOL_INTERVAL * 4) == 0 + depth = min(7, self.water // 10 + 1 + int(red)) + row = int(self.random.integers(depth, 8)) + self.fish.update((row + offset, 9, red) for offset in range(3)) + + reward = 0 + if self.mode == 3: + line = self._line() + hooked = {fish for fish in self.fish if fish[:2] in line} + self.fish.difference_update(hooked) + self.caught.extend(red for _, _, red in sorted(hooked)) + row, column = self.lure + if column <= 1: + for index, red in enumerate(self.caught, 1): + reward += -1 if red else index + self.water = max(0, min(50, self.water + (-5 if red else 1))) + self.caught.clear() + self.lure, self.mode = ANCHOR, 0 + else: + self.lure = (row + int(np.sign(ANCHOR[0] - row)), column - 1) + if self.steps % 2 == 0: + self.water = max(0, self.water - 1) + self.terminal = self.steps >= self.horizon or (self.mode != 3 and self.water < 26) + return float(reward), self.terminal + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[self.lure[0], self.lure[1], 0] = True + for row, column, red in self.fish: + state[row, column, 1 if red else 2] = True + for row, column in self._line(): + state[row, column, 3] = True + state[self.water // 10, :, 4] = True + values = (self.mode, self.power, self.water, self.steps, + len(self.caught), int(self.last_action == 5)) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + for index, red in enumerate(self.caught): + state[6 + index // 10, index % 10, 5] = red + return state diff --git a/runtime/minatar_synth/games/catapult.py b/runtime/minatar_synth/games/catapult.py new file mode 100644 index 0000000000000000000000000000000000000000..afd537456d8dd351e3f12d1be9ec73ff73ce9098 --- /dev/null +++ b/runtime/minatar_synth/games/catapult.py @@ -0,0 +1,130 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 +DIAGONAL = math.sqrt(0.5) + + +@dataclass +class Bar: + x: float + y: float + width: float + passed: bool = False + + +class CatapultEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.passed_count = 0 + self.pressed = self.terminal = False + self.x, self.y, self.vx, self.vy = 200.0, 60.0, 0.0, 0.0 + self.bar_position, self.base_score, self.next_bar = -10.0, 1.0, 50.0 + self.support: Bar | None = Bar(200, 60, 20, passed=True) + self.bars = [self.support] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(FRAMES_PER_STEP): + reward += self._advance_frame(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self, tap: bool) -> int: + scroll = 0.05 + max(0, self.x - 30) * 0.1 + slope = 1 if self.pressed else -1 + self.x -= scroll + if self.support is not None: + self.bar_position -= slope * 0.2 + self.base_score = max(1, self.base_score - 0.5) + self.x = self.support.x + slope * (4 - self.bar_position) * DIAGONAL + self.y = self.support.y - (4 + self.bar_position) * DIAGONAL + if abs(self.bar_position) > self.support.width * 0.65: + self.support = None + self.vx = self.vy = 0.0 + elif tap and self.bar_position > 0: + self.vx = math.sqrt(self.bar_position) * DIAGONAL + self.vy = -self.vx + self.x += self.vx + self.y += self.vy + self.support = None + self.passed_count = 0 + else: + self.x += self.vx + self.y += self.vy + self.vy += 0.1 + self.base_score += self.vx * 0.1 + + if self.y > 99 or self.x < 0: + self.terminal = True + return 0 + + reward = 0 + for bar in self.bars: + bar.x -= scroll + dx, dy = self.x - bar.x, self.y - bar.y + if self.support is None and abs(dy - slope * dx) * DIAGONAL < 4 and abs(dx + slope * dy) * DIAGONAL < bar.width / 2 + 2: + self.support = bar + offset = math.hypot(dx - slope * 4 * DIAGONAL, dy + 4 * DIAGONAL) + self.bar_position = max(-bar.width * 0.4, min(bar.width * 0.4, offset if dx <= slope * 4 * DIAGONAL else -offset)) + reward += math.ceil(self.base_score) + bar.passed = True + if not bar.passed and bar.x + bar.width / 2 < self.x: + bar.passed = True + self.passed_count += 1 + bonus = 10 * self.passed_count + reward += bonus + self.base_score += bonus + self.bars = [bar for bar in self.bars if bar.x >= -bar.width / 2] + + self.next_bar -= scroll + if self.next_bar < 0: + width = self.random.uniform(20, 30) + self.bars.append(Bar(200 + width / 2, self.random.uniform(50, 90), width)) + self.next_bar += width / 2 + self.random.uniform(30, 50) + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row = min(9, max(0, int(self.y) // 10)) + column = min(9, max(0, int(self.x) // 20)) + state[row, column, 0] = True + state[row, column, 3] = self.support is not None + slope = 1 if self.pressed else -1 + for bar in self.bars: + for distance in np.linspace(-bar.width / 2, bar.width / 2, 9): + x = bar.x + distance * DIAGONAL + y = bar.y + slope * distance * DIAGONAL + if 0 <= x < 200 and 0 <= y < 100: + state[int(y) // 10, int(x) // 20, 1 if bar.passed else 2] = True + for row, value in enumerate((self.steps, round((self.bar_position + 32) * 4), math.ceil(self.base_score), self.passed_count)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :3, 4] = self.pressed, self.vy < 0, self.bar_position > 0 + return state diff --git a/runtime/minatar_synth/games/catching_wheel.py b/runtime/minatar_synth/games/catching_wheel.py new file mode 100644 index 0000000000000000000000000000000000000000..85dec47245a9ca7dfc52130a7c560978fd60d1d3 --- /dev/null +++ b/runtime/minatar_synth/games/catching_wheel.py @@ -0,0 +1,135 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 +SPOKES = 6 + + +@dataclass +class Falling: + x: float + y: float = 0 + vy: float = 0 + + def advance(self) -> None: + self.vy += 0.02 + self.y += self.vy + + def near(self, x: float, y: float, radius: float) -> bool: + return math.hypot(self.x - x, self.y - y) < radius + + +class CatchingWheelEnvironment: + score_cap = 150 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = 0 + self.angle = 0.0 + self.human_timer, self.obstacle_timer = 40.0, 99.0 + self.multiplier = 1 + self.pressed = self.terminal = False + self.baskets = [True] * SPOKES + self.humans: list[Falling] = [] + self.obstacles: list[Falling] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(FRAMES_PER_STEP): + reward += self._advance_frame() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _positions(self) -> list[tuple[float, float]]: + angles = (self.angle + index * math.tau / SPOKES for index in range(SPOKES)) + return [(50 + 40 * math.cos(angle), 90 + 40 * math.sin(angle)) for angle in angles] + + def _change_basket(self, restore: bool) -> None: + start = int(self.random.integers(SPOKES)) + for offset in range(SPOKES): + index = (start + offset) % SPOKES + if self.baskets[index] != restore: + self.baskets[index] = restore + if not restore: + self.multiplier = 1 + break + + def _advance_frame(self) -> int: + self.obstacle_timer -= 1 + if self.obstacle_timer <= 0: + self.obstacles.append(Falling(self.random.uniform(20, 80))) + self.obstacle_timer = self.random.uniform(79.2, 118.8) + for obstacle in self.obstacles: + obstacle.advance() + self.obstacles = [obstacle for obstacle in self.obstacles if obstacle.y <= 95] + + if self.pressed: + self.angle = (self.angle + 0.05) % math.tau + positions = self._positions() + for index, (x, y) in enumerate(positions): + if self.baskets[index] and any(obstacle.near(x, y, 9) for obstacle in self.obstacles): + self.baskets[index] = False + self.multiplier = 1 + catchable = [point for point, live in zip(positions, self.baskets) if live] + + self.human_timer -= 1 + if self.human_timer <= 0: + self.humans.append(Falling(self.random.uniform(10, 90))) + self.human_timer = self.random.uniform(28, 40) + reward = 0 + remaining = [] + for human in self.humans: + human.advance() + if any(obstacle.near(human.x, human.y, 5) for obstacle in self.obstacles): + continue + if any(human.near(x, y, 6) for x, y in catchable): + reward += self.multiplier + self.multiplier += 1 + self._change_basket(restore=True) + elif human.y > 100: + self._change_basket(restore=False) + else: + remaining.append(human) + self.humans = remaining + self.terminal = not any(self.baskets) + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[9, 5, 0] = True + for live, (x, y) in zip(self.baskets, self._positions()): + if 0 <= y < 100: + state[int(y) // 10, int(x) // 10, 1 if live else 2] = True + for channel, objects in ((3, self.humans), (4, self.obstacles)): + for obj in objects: + if obj.y < 100: + state[int(obj.y) // 10, int(obj.x) // 10, channel] = True + for row, value in enumerate((self.steps, self.multiplier, round(self.angle * 80))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :SPOKES, 5] = self.baskets + state[9, SPOKES, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/cate_p.py b/runtime/minatar_synth/games/cate_p.py new file mode 100644 index 0000000000000000000000000000000000000000..1805428dc380fd6265fe6562620297a1d7535e9b --- /dev/null +++ b/runtime/minatar_synth/games/cate_p.py @@ -0,0 +1,150 @@ +from dataclasses import dataclass + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 +DIRECTIONS = ((1, 0), (0.7, 0.7), (0, 1), (-0.7, 0.7), + (-1, 0), (-0.7, -0.7), (0, -1), (0.7, -0.7)) + + +@dataclass +class Mover: + x: float + y: float + direction: int + + def move(self, speed: float) -> None: + dx, dy = DIRECTIONS[self.direction] + self.x += speed * dx + self.y += speed * dy + + def inside(self, low: float, high: float) -> bool: + return low <= self.x <= high and low <= self.y <= high + + def clamp(self) -> None: + self.x = min(90, max(9, self.x)) + self.y = min(90, max(9, self.y)) + + def touches(self, other: "Mover") -> bool: + return abs(self.x - other.x) < 5 and abs(self.y - other.y) < 5 + + +@dataclass +class Cate(Mover): + entering: bool = True + + +class CatePEnvironment: + score_cap = 100 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.wave_count = self.wave_timer = 0 + self.multiplier = 1 + self.pressed = self.terminal = False + self.player = Mover(50, 50, 0) + self.shot: Mover | None = None + self.entrance: Mover | None = None + self.newest: Cate | None = None + self.cates: list[Cate] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(FRAMES_PER_STEP): + reward += self._advance_frame(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self, tap: bool) -> int: + player = self.player + if tap or not player.inside(9, 90): + if tap and self.shot is None: + self.shot = Mover(player.x, player.y, player.direction) + self.multiplier = 1 + player.clamp() + player.direction = (player.direction + 2) % 8 + player.move(0.2) + if self.shot is not None: + if self.shot.inside(9, 91): + self.shot.move(1.5) + else: + self.shot = None + + self._spawn() + survivors = [] + reward = 0 + for cate in self.cates: + cate.move(0.2) + if cate.entering: + cate.entering = not cate.inside(9, 90) + elif not cate.inside(9, 90): + corner = not 9 <= cate.x <= 90 and not 9 <= cate.y <= 90 + cate.direction = (cate.direction + (4 if corner else 3)) % 8 + cate.clamp() + if self.shot is not None and cate.touches(self.shot): + reward += self.multiplier + self.multiplier += 1 + if self.newest is cate: + self.newest = None + else: + self.terminal |= cate.touches(player) + survivors.append(cate) + self.cates = survivors + return reward + + def _spawn(self) -> None: + if self.wave_timer <= 0: + direction = int(self.random.integers(4)) * 2 + offset = self.random.uniform(9, 90) + x, y = ((-3, offset), (offset, -3), (103, offset), (offset, 103))[direction // 2] + self.entrance = Mover(x, y, direction) + self.wave_count = int(self.random.integers(5, 9)) + self.wave_timer = int(self.random.integers(60, 91)) + if self.wave_count == 0: + self.wave_timer -= 1 + if self.newest is not None and self.newest.inside(3, 97): + self.newest = None + if self.wave_count and self.newest is None and self.entrance is not None: + self.newest = Cate(self.entrance.x, self.entrance.y, self.entrance.direction) + self.cates.append(self.newest) + self.wave_count -= 1 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for channel, movers in ((0, [self.player]), (1, self.cates), (2, [self.shot])): + for mover in movers: + if mover is not None and mover.inside(0, 99.999): + row, col = int(mover.y) // 10, int(mover.x) // 10 + state[row, col, channel] = True + if isinstance(mover, Cate): + state[row, col, 3] |= mover.entering + state[(0, 9), :, 4] = True + state[:, (0, 9), 4] = True + for row, value in enumerate((self.steps, self.player.direction, self.multiplier, + self.shot.direction if self.shot is not None else 0)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/centipede.py b/runtime/minatar_synth/games/centipede.py new file mode 100644 index 0000000000000000000000000000000000000000..6f008e15c0bf96a8145867c479541e01aeeae8dd --- /dev/null +++ b/runtime/minatar_synth/games/centipede.py @@ -0,0 +1,241 @@ +import numpy as np + + +INITIAL_MUSHROOMS = ( + (1, 1), (1, 5), (1, 8), (2, 3), (2, 7), + (3, 1), (3, 5), (3, 9), (4, 2), (4, 6), + (5, 0), (5, 4), (5, 8), (6, 2), (6, 7), +) + + +class CentipedeEnvironment: + """Four-wave mushroom-field shooter with splitting chains and specialist insects.""" + + score_cap = 9_528.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 2_000): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.player = [9, 5] + self.previous_player = self.player.copy() + self.shot: list[int] | None = None + self.mushrooms = {position: {"health": 3, "poisoned": False} for position in INITIAL_MUSHROOMS} + self.lives = 3 + self.wave = 0 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self._start_wave() + + def _start_wave(self) -> None: + head_count = self.wave + 1 + main_length = 10 - head_count + self.chains = [self._make_chain(main_length, 0, 1)] + for index in range(head_count - 1): + self.chains.append(self._make_chain(1, index + 1, -1 if index % 2 else 1)) + self.spider: list[int] | None = [8, 9] + self.flea: dict[str, object] | None = {"position": [0, int(self.random.randint(10))], "health": 2} + self.scorpion: list[int] | None = [3, 0] if self.wave >= 3 else None + self.previous_insects: list[list[int]] = [] + self.wave_steps = 0 + + @staticmethod + def _make_chain(length: int, row: int, direction: int) -> dict[str, object]: + start = 0 if direction > 0 else 9 + segments = [[row, (start - direction * index) % 10] for index in range(length)] + return {"segments": segments, "direction": direction, "diving": False} + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + if action in (1, 2, 3, 4): + row_delta, column_delta = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}[action] + target = [self.player[0] + row_delta, self.player[1] + column_delta] + if 7 <= target[0] <= 9 and 0 <= target[1] < 10: + self.player = target + elif action == 5 and self.shot is None: + self.shot = [self.player[0] - 1, self.player[1]] + + self.previous_insects = self._insect_positions() + self._move_centipedes() + self._move_specials() + if self.shot is not None: + self.shot[0] -= 1 + if self.shot[0] < 0: + self.shot = None + reward = self._resolve_shot() + reward += self._resolve_contacts() + self.wave_steps += 1 + self.steps += 1 + if not self.chains: + self.wave += 1 + if self.wave == 4: + self.terminal = True + else: + self._start_wave() + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _move_centipedes(self) -> None: + for chain in self.chains: + segments = chain["segments"] + previous = [segment.copy() for segment in segments] + head = segments[0] + if bool(chain["diving"]): + head[0] = min(9, head[0] + 1) + if head[0] >= 8: + chain["diving"] = False + chain["direction"] = -int(chain["direction"]) + else: + target_column = head[1] + int(chain["direction"]) + target = (head[0], target_column) + if target_column < 0 or target_column > 9 or target in self.mushrooms: + mushroom = self.mushrooms.get(target) + if mushroom is not None and bool(mushroom["poisoned"]): + chain["diving"] = True + head[0] = min(9, head[0] + 1) + chain["direction"] = -int(chain["direction"]) + else: + head[1] = target_column + for index in range(1, len(segments)): + segments[index][:] = previous[index - 1] + + def _move_specials(self) -> None: + if self.spider is not None: + self.spider[1] += -1 if self.wave_steps % 4 < 2 else 1 + self.spider[0] = int(np.clip(self.spider[0] + (-1 if self.wave_steps % 3 == 0 else 1), 7, 9)) + if self.spider[1] < 0 or self.spider[1] > 9: + self.spider[1] %= 10 + if self.flea is not None: + position = self.flea["position"] + position[0] += 2 if int(self.flea["health"]) == 1 else 1 + if position[0] in (2, 4, 6) and tuple(position) not in self.mushrooms: + self.mushrooms[tuple(position)] = {"health": 3, "poisoned": False} + if position[0] > 9: + self.flea = None + if self.scorpion is not None: + self.scorpion[1] += 1 + position = tuple(self.scorpion) + if position in self.mushrooms: + self.mushrooms[position]["poisoned"] = True + if self.scorpion[1] > 9: + self.scorpion = None + + def _resolve_shot(self) -> float: + if self.shot is None: + return 0.0 + for chain in self.chains.copy(): + segments = chain["segments"] + hit_index = next((index for index, segment in enumerate(segments) if segment == self.shot), None) + if hit_index is None: + continue + position = tuple(segments[hit_index]) + reward = 100.0 if hit_index == 0 else 10.0 + before = segments[:hit_index] + after = segments[hit_index + 1:] + self.chains.remove(chain) + if before: + self.chains.append({"segments": before, "direction": chain["direction"], "diving": chain["diving"]}) + if after: + self.chains.append({"segments": after, "direction": -int(chain["direction"]), "diving": False}) + self.mushrooms.setdefault(position, {"health": 3, "poisoned": False}) + self.shot = None + return reward + if self.spider == self.shot: + distance = abs(self.spider[0] - self.player[0]) + abs(self.spider[1] - self.player[1]) + self.spider = None + self.shot = None + return 900.0 if distance <= 2 else 600.0 if distance <= 4 else 300.0 + if self.flea is not None and self.flea["position"] == self.shot: + self.flea["health"] = int(self.flea["health"]) - 1 + self.shot = None + if int(self.flea["health"]) == 0: + self.flea = None + return 200.0 + return 0.0 + if self.scorpion == self.shot: + self.scorpion = None + self.shot = None + for mushroom in self.mushrooms.values(): + mushroom["poisoned"] = False + return 1_000.0 + shot_position = tuple(self.shot) + mushroom = self.mushrooms.get(shot_position) + if mushroom is not None: + mushroom["health"] = int(mushroom["health"]) - 1 + self.shot = None + if int(mushroom["health"]) == 0: + del self.mushrooms[shot_position] + return 1.0 + return 0.0 + + def _resolve_contacts(self) -> float: + hazards = self._insect_positions() + if self.player not in hazards: + return 0.0 + bonus = float((len(self.mushrooms) // 2) * 5) + self.lives -= 1 + self.player = [9, 5] + self.previous_player = self.player.copy() + self.shot = None + for mushroom in self.mushrooms.values(): + mushroom["poisoned"] = False + mushroom["health"] = 3 + if self.lives <= 0: + self.terminal = True + return bonus + + def _insect_positions(self) -> list[list[int]]: + positions = [segment.copy() for chain in self.chains for segment in chain["segments"]] + if self.spider is not None: + positions.append(self.spider.copy()) + if self.flea is not None: + positions.append(list(self.flea["position"])) + if self.scorpion is not None: + positions.append(self.scorpion.copy()) + return positions + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + for chain in self.chains: + for index, segment in enumerate(chain["segments"]): + state[*segment, 1] = True + state[*segment, 2] = True + if index == 0: + state[segment[0], segment[1], 5] = True + for position in (self.spider, None if self.flea is None else self.flea["position"], self.scorpion): + if position is not None: + state[*position, 1] = True + state[*position, 2] = True + for position, mushroom in self.mushrooms.items(): + state[*position, 2] = True + state[*position, 5] = True + if bool(mushroom["poisoned"]): + state[*position, 1] = True + if self.shot is not None: + state[*self.shot, 3] = True + state[*self.previous_player, 4] = True + for position in self.previous_insects: + if 0 <= position[0] < 10 and 0 <= position[1] < 10: + state[*position, 4] = True + state[9, : self.lives, 5] = True + state[8, : self.wave + 1, 5] = True + return state diff --git a/runtime/minatar_synth/games/chalkboard.py b/runtime/minatar_synth/games/chalkboard.py new file mode 100644 index 0000000000000000000000000000000000000000..1272662753ab47f61cec49a56a34f02f259ec51e --- /dev/null +++ b/runtime/minatar_synth/games/chalkboard.py @@ -0,0 +1,128 @@ +from collections import deque +from dataclasses import dataclass +import math + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 +HEADINGS = ((1, 0), (0, 1), (-1, 0), (0, -1)) + + +@dataclass +class Segment: + x: float + y: float + dx: float + dy: float + born: int + + def overlaps(self, x: float, y: float) -> bool: + if abs(x - self.x) > abs(self.dx) + 3 or abs(y - self.y) > abs(self.dy) + 3: + return False + length_squared = self.dx**2 + self.dy**2 + fraction = ((x - self.x) * self.dx + (y - self.y) * self.dy) / length_squared + fraction = min(1, max(0, fraction)) + return math.hypot(x - self.x - fraction * self.dx, y - self.y - fraction * self.dy) < 3 + + +class ChalkboardEnvironment: + score_cap = HORIZON * FRAMES_PER_STEP * 3 // 10 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.frame = self.heading = self.streak = 0 + self.turn_timer = 120 + self.pressed = self.terminal = False + self.x = self.y = self.score_carry = 0.0 + self.write_x = self.write_y = 0.0 + self.energy = 60.0 + self.segments = deque( + (Segment(70, y, 0, 10, -4) for y in range(-40, 40, 10)), + maxlen=1000, + ) + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + changed = pressed != self.pressed + self.pressed = pressed + if changed: + self.streak = 0 + self.steps += 1 + reward = 0 + for frame in range(FRAMES_PER_STEP): + reward += self._advance_frame(changed and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self, changed: bool) -> int: + self.frame += 1 + self.turn_timer -= 1 + if not self.turn_timer: + self.heading = (self.heading + 1) % 4 + self.turn_timer = int(self.random.integers(30, 150)) + dx, dy = HEADINGS[self.heading] + self.x += 0.9 * dx + self.y += 0.9 * dy + self.streak = min(120, self.streak + 1) + amount = 0.3 * (self.streak / 120)**1.5 + reward = 0 + if self.pressed: + if changed: + self.write_x, self.write_y = self.x, self.y + if any(self.frame - line.born >= 4 and line.overlaps(self.x, self.y) for line in self.segments): + self.energy -= 10 + else: + self.energy += amount + self.score_carry += amount + reward = int(self.score_carry) + self.score_carry -= reward + dx, dy = self.x - self.write_x, self.y - self.write_y + if dx * dx + dy * dy >= 4: + self.segments.append(Segment(self.write_x, self.write_y, dx, dy, self.frame)) + self.write_x, self.write_y = self.x, self.y + else: + self.energy -= amount + self.energy = min(100, max(0, self.energy)) + self.terminal = self.energy <= 0 + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[5, 5, 0] = True + for line in self.segments: + x, y = line.x - self.x + 50, line.y - self.y + 50 + if not (-12 <= x < 112 and -12 <= y < 112): + continue + channel = 2 if self.frame - line.born < 4 else 1 + for fraction in (0, 0.5, 1): + px, py = x + line.dx * fraction, y + line.dy * fraction + if 0 <= px < 100 and 0 <= py < 100: + state[int(py) // 10, int(px) // 10, channel] = True + dx, dy = HEADINGS[self.heading] + state[5 + dy, 5 + dx, 3] = True + if self.turn_timer <= 30: + dx, dy = HEADINGS[(self.heading + 1) % 4] + state[5 + dy, 5 + dx, 4] = True + for row, value in enumerate((self.steps, round(self.energy), self.turn_timer, self.streak)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/charge_beam.py b/runtime/minatar_synth/games/charge_beam.py new file mode 100644 index 0000000000000000000000000000000000000000..27dba4591603380429d52ec6f367089b129d132c --- /dev/null +++ b/runtime/minatar_synth/games/charge_beam.py @@ -0,0 +1,152 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Target: + x: float + size: int = 1 + coin: bool = False + suction: float = 0 + + +class ChargeBeamEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.power = 0 + self.pressed = self.terminal = self.last_coin = False + self.charge = self.penalty = 0.0 + self.spawn_distance = 30.0 + self.shot: float | None = None + self.coin_combo = self.enemy_combo = self.penalty_combo = 1 + self.targets = [Target(150)] + [Target(x, coin=True) for x in (160, 170, 180)] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance_frame() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self) -> int: + if self.shot is None: + if self.pressed and self.charge < 99: + self.charge += 1.5 + elif self.charge: + self.power = 1 + math.ceil(max(0, self.charge - 25) / 9) + self.shot, self.charge = 10.0, 0.0 + self.coin_combo = self.enemy_combo = self.penalty_combo = 1 + if self.shot is not None: + self.shot += 2.5 + if self.shot > 203: + self.shot = None + + self.penalty = max(0, self.penalty - 0.02) + speed = (1 + self.penalty) * 0.5 + self.spawn_distance -= speed + if self.spawn_distance < 0: + self._spawn_wave() + + for target in self.targets: + target.x -= target.suction or speed + if target.suction: + target.suction += 0.1 + first_enemy = min((target.x for target in self.targets if not target.coin), default=math.inf) + + reward = 0 + survivors = [] + for target in self.targets: + if self._shot_hits(target): + spent = self.power == 1 + if target.coin: + reward -= self.penalty_combo + self.penalty_combo = min(64, self.penalty_combo * 2) + self.penalty += 0.5 + if spent: + self.shot = None + continue + if target.size <= self.power: + reward += target.size * self.enemy_combo + self.enemy_combo += 1 + if target.size > 1: + self.power -= target.size + if spent or not self.power: + self.shot = None + continue + target.size -= self.power + self.shot = None + if target.coin: + if target.suction and target.x < 10: + reward += self.coin_combo + self.coin_combo = min(64, self.coin_combo * 2) + continue + if not target.suction and target.x < first_enemy: + target.suction = 1 + elif target.x < 15: + self.terminal = True + survivors.append(target) + self.targets = survivors + if not any(target.x <= 200 and not target.suction for target in self.targets): + self.spawn_distance = 0 + return reward + + def _shot_hits(self, target: Target) -> bool: + return self.shot is not None and ( + self.shot - 5 <= target.x + 3 * (target.size - 1) + and target.x - 5 <= self.shot + 3 * (self.power - 1) + ) + + def _spawn_wave(self) -> None: + self.last_coin = not self.last_coin and self.random.random() < 0.5 + x = 200 + for _ in range(int(self.random.integers(3, 9))): + size = 1 + if not self.last_coin and self.random.random() < 0.3: + size = int(self.random.integers(2, 6)) + self.targets.append(Target(x, size, self.last_coin)) + x += 10 + math.ceil((size - 1) / 2) * 6 + self.spawn_distance = x - 190 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[5, 0, 0] = True + for target in self.targets: + if 0 <= target.x < 200: + col = int(target.x) // 20 + if target.coin: + state[5, col, 3 if target.suction else 2] = True + else: + state[6 - target.size:6, col, 1] = True + if self.shot is not None and self.shot < 200: + start = int(self.shot) // 20 + end = int(self.shot + 3 * (self.power - 1)) // 20 + state[5, start:end + 1, 4] = True + for row, value in enumerate((self.steps, round(self.charge), self.power, round(self.penalty * 10), + self.coin_combo, self.enemy_combo, self.penalty_combo)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/chopper_command.py b/runtime/minatar_synth/games/chopper_command.py new file mode 100644 index 0000000000000000000000000000000000000000..a94ad541b1c3750ad016806875b4ae473fa56d08 --- /dev/null +++ b/runtime/minatar_synth/games/chopper_command.py @@ -0,0 +1,201 @@ +import numpy as np + + +class ChopperCommandEnvironment: + """Ten-wave convoy-defense shooter over a wraparound scanner world.""" + + score_cap = 90_000.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 4_000): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.player = [4, 1] + self.previous_player = self.player.copy() + self.facing = 1 + self.shots: list[dict[str, object]] = [] + self.missiles: list[dict[str, object]] = [] + self.trucks = [[8, column % 10] for column in range(12)] + self.lives = 3 + self.score = 0.0 + self.next_life_score = 10_000.0 + self.wave = 1 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self.previous_threats: list[list[int]] = [] + self._start_wave() + + def _start_wave(self) -> None: + self.enemies = [ + { + "position": [1 + index % 4, (index * 3 + self.wave) % 10], + "kind": "jet" if index % 2 else "helicopter", + } + for index in range(12) + ] + self.wave_steps = 0 + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + self.previous_threats = self._threat_positions() + self._apply_action(action) + self._move_world() + reward = self._resolve_shots() + reward += self._resolve_missiles_and_contacts() + self.score += reward + if not self.enemies: + reward += len(self.trucks) * self.wave * 100.0 + self.score += len(self.trucks) * self.wave * 100.0 + self.wave += 1 + if self.wave > 10: + self.terminal = True + else: + self._start_wave() + while self.score >= self.next_life_score and self.lives < 6: + self.lives += 1 + self.next_life_score += 10_000.0 + self.wave_steps += 1 + self.steps += 1 + if self.steps >= self.horizon or not self.trucks: + self.terminal = True + return reward, self.terminal + + def _apply_action(self, action: int) -> None: + if action == 1: + self.player[1] = (self.player[1] - 1) % 10 + self.facing = -1 + elif action == 2: + self.player[0] = max(0, self.player[0] - 1) + elif action == 3: + self.player[1] = (self.player[1] + 1) % 10 + self.facing = 1 + elif action == 4: + self.player[0] = min(6, self.player[0] + 1) + elif action == 5 and len(self.shots) < 3: + self.shots.append({"position": self.player.copy(), "direction": self.facing}) + + def _move_world(self) -> None: + for shot in self.shots: + shot["position"][1] = (shot["position"][1] + int(shot["direction"])) % 10 + shot["distance"] = int(shot.get("distance", 0)) + 1 + self.shots = [shot for shot in self.shots if int(shot["distance"]) < 10] + move_interval = max(1, 5 - (self.wave - 1) // 2) + if self.wave_steps % move_interval == 0: + for enemy in self.enemies: + enemy["position"][1] = (enemy["position"][1] - 1) % 10 + fire_probability = min(0.45, 0.04 + 0.025 * self.wave) + for enemy in self.enemies: + if self.random.rand() < fire_probability / max(1, len(self.enemies)): + self.missiles.append({"position": list(enemy["position"]), "split": False, "direction": 0}) + new_missiles = [] + for missile in self.missiles: + missile["position"][0] += 1 + missile["position"][1] = (missile["position"][1] + int(missile["direction"])) % 10 + if missile["position"][0] == 4 and not bool(missile["split"]): + for direction in (-1, 1): + new_missiles.append({"position": list(missile["position"]), "split": True, "direction": direction}) + elif missile["position"][0] <= 8: + new_missiles.append(missile) + self.missiles = new_missiles + if self.wave_steps % 2 == 0: + for truck in self.trucks: + truck[1] = (truck[1] - 1) % 10 + + def _resolve_shots(self) -> float: + reward = 0.0 + remaining_shots = [] + hit_enemy_ids: set[int] = set() + for shot in self.shots: + hit = next( + ( + enemy + for enemy in self.enemies + if id(enemy) not in hit_enemy_ids and enemy["position"] == shot["position"] + ), + None, + ) + if hit is None: + remaining_shots.append(shot) + continue + hit_enemy_ids.add(id(hit)) + reward += 200.0 if hit["kind"] == "jet" else 100.0 + self.shots = remaining_shots + self.enemies = [enemy for enemy in self.enemies if id(enemy) not in hit_enemy_ids] + return reward + + def _resolve_missiles_and_contacts(self) -> float: + hit_truck_ids: set[int] = set() + remaining_missiles = [] + player_hit = any(enemy["position"] == self.player for enemy in self.enemies) + for missile in self.missiles: + if missile["position"] == self.player: + player_hit = True + continue + truck = next( + ( + truck + for truck in self.trucks + if id(truck) not in hit_truck_ids and truck == missile["position"] + ), + None, + ) + if truck is not None: + hit_truck_ids.add(id(truck)) + else: + remaining_missiles.append(missile) + self.trucks = [truck for truck in self.trucks if id(truck) not in hit_truck_ids] + self.missiles = remaining_missiles + if player_hit: + self.lives -= 1 + self.player = [4, 1] + self.previous_player = self.player.copy() + self.shots = [] + self.missiles = [] + if self.lives <= 0: + self.terminal = True + return 0.0 + + def _threat_positions(self) -> list[list[int]]: + positions = [list(enemy["position"]) for enemy in self.enemies] + positions.extend(list(missile["position"]) for missile in self.missiles) + return positions + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + for enemy in self.enemies: + position = enemy["position"] + state[*position, 1] = True + state[*position, 2] = True + if enemy["kind"] == "jet": + state[position[0], position[1], 5] = True + for missile in self.missiles: + state[*missile["position"], 1] = True + for shot in self.shots: + state[*shot["position"], 3] = True + state[*self.previous_player, 4] = True + for position in self.previous_threats: + state[*position, 4] = True + for truck in self.trucks: + state[*truck, 2] = True + state[9, : min(10, len(self.trucks)), 5] = True + state[8, : self.lives, 5] = True + state[7, : self.wave, 5] = True + return state diff --git a/runtime/minatar_synth/games/circle_w.py b/runtime/minatar_synth/games/circle_w.py new file mode 100644 index 0000000000000000000000000000000000000000..b10e16148ecc3044c43e18e5664c76a5338983fe --- /dev/null +++ b/runtime/minatar_synth/games/circle_w.py @@ -0,0 +1,124 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Ring: + x: float + y: float + radius: float + danger: bool = False + + +class CircleWEnvironment: + score_cap = 25000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = 0 + self.pressed = self.terminal = False + self.player = Ring(200, 50, 1) + self.scroll_x = self.scroll_y = self.next_ring = 0.0 + self.danger_count = 30 + self.multiplier = 1 + self.rings: list[Ring] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance_frame() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + @staticmethod + def _touches(first: Ring, second: Ring) -> bool: + distance = math.hypot(first.x - second.x, first.y - second.y) + return abs(first.radius - second.radius) - 2 <= distance <= first.radius + second.radius + 2 + + def _advance_frame(self) -> int: + player = self.player + if player.radius < 9: + self.multiplier = max(1, self.multiplier - 1) + player.radius = max(1, player.radius + (0.5 if self.pressed else -0.5)) + for ring in [player, *self.rings]: + ring.x += self.scroll_x + ring.y = (ring.y + self.scroll_y + 15) % 130 - 15 + player.x = max(20, player.x) + self.rings = [ring for ring in self.rings if ring.x >= -ring.radius] + destination = None + for ring in self.rings: + if self._touches(player, ring): + if ring.danger: + self.terminal = True + return 0 + if destination is None: + destination = ring + reward = 0 + if destination is not None: + self.multiplier += math.ceil(player.radius) + reward = self.multiplier + self.player = destination + self.rings.remove(destination) + + self.next_ring += self.scroll_x + if self.next_ring < 0: + self._spawn() + self.scroll_x = -1 - max(0, player.x - 20) * 0.1 + self.scroll_y = (50 - player.y) * 0.1 + return reward + + def _spawn(self) -> None: + danger = self.danger_count == 0 + for _ in range(9): + radius = self.random.uniform(8, 15) + x, y = 200 + radius, int(self.random.integers(99)) + half_width = radius * (4 if danger else 2.5) + if any(abs(x - ring.x) < half_width + ring.radius and abs(y - ring.y) < radius * 1.25 + ring.radius + for ring in self.rings): + continue + self.rings.append(Ring(x, y, radius, danger)) + self.danger_count = int(self.random.integers(24, 30)) if danger else self.danger_count - 1 + self.next_ring = 5 + break + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for ring, channel in [(self.player, 0), *((ring, 2 if ring.danger else 1) for ring in self.rings)]: + for row in range(10): + for col in range(10): + distance = math.hypot(col * 20 + 10 - ring.x, row * 10 + 5 - ring.y) + state[row, col, channel] |= abs(distance - ring.radius) <= 9 + row = min(9, max(0, int(self.player.y) // 10)) + col = min(9, int(self.player.x) // 20) + state[row, col, 3] = True + for ring in self.rings: + if 0 <= ring.x < 200 and 0 <= ring.y < 100: + state[int(ring.y) // 10, int(ring.x) // 20, 4] = True + for row, value in enumerate((self.steps, round(self.player.radius * 2), self.multiplier, self.danger_count)): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + for bit in range(6): + state[4, bit, 5] = bool(self.multiplier & (1 << (bit + 10))) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/clean_robo.py b/runtime/minatar_synth/games/clean_robo.py new file mode 100644 index 0000000000000000000000000000000000000000..1d23784f6aa586c867e1a4eae58c1f46dc53b9f1 --- /dev/null +++ b/runtime/minatar_synth/games/clean_robo.py @@ -0,0 +1,144 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 + + +@dataclass +class Wall: + side: int + distance: float = 50 + angle: float = 0 + + def vertices(self) -> list[tuple[float, float]]: + angles = [self.angle + (math.pi if self.side < 0 else 0) + + self.side * offset * math.tau / 3 for offset in (-1, 0, 1)] + return sorted( + [(100 + self.side * self.distance + 17 * math.cos(angle), + 50 + 17 * math.sin(angle)) for angle in angles], + key=lambda point: point[1], + ) + + def edge_x(self, y: float) -> float: + first, middle, last = self.vertices() + if y <= first[1]: + return first[0] + if y >= last[1]: + return last[0] + a, b = (first, middle) if y < middle[1] else (middle, last) + return a[0] + (b[0] - a[0]) * (y - a[1]) / (b[1] - a[1]) + + def target(self) -> tuple[float, float]: + angle = self.angle + (math.pi if self.side < 0 else 0) + return (100 + self.side * (self.distance - 7) + 17 * math.cos(angle), + 50 + 8.5 * math.sin(angle)) + + +class CleanRoboEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = 0 + self.pressed = self.terminal = False + self.x, self.angle, self.speed, self.multiplier = 90.0, 0.0, 1.0, 1.0 + self.direction = 1 + self.walls = {side: Wall(side, angle=self.random.uniform(-math.pi / 7, math.pi / 7)) + for side in (-1, 1)} + self.garbage: tuple[float, float] | None = self.walls[1].target() + self.missed: tuple[float, float] | None = None + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(FRAMES_PER_STEP): + reward += self._advance_frame() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _triangle(self) -> list[tuple[float, float]]: + return [(self.x + 10 * math.cos(self.angle + index * math.tau / 3), + 50 + 10 * math.sin(self.angle + index * math.tau / 3)) for index in range(3)] + + def _advance_frame(self) -> int: + if self.pressed: + self.speed += 0.3 + else: + self.angle = (self.angle + 0.05) % math.tau + self.speed += (1 - self.speed) * 0.2 + self.multiplier = max(1, self.multiplier - 0.1) + old_x = self.x + self.x += self.direction * self.speed * 0.2 + triangle = self._triangle() + wall = self.walls[self.direction] + reward = 0 + if self.garbage is not None: + gx, gy = self.garbage + for a, b in zip(triangle, triangle[1:] + triangle[:1]): + dx, dy = b[0] - a[0], b[1] - a[1] + fraction = min(1, max(0, ((gx - a[0]) * dx + (gy - a[1]) * dy) / 300)) + edge_x = a[0] + dx * fraction + lo, hi = sorted((edge_x, edge_x + old_x - self.x)) + distance_x = max(lo - gx, gx - hi, 0) + if math.hypot(distance_x, gy - a[1] - dy * fraction) <= 3: + reward = math.ceil(self.multiplier) + self.multiplier += 10 + self.garbage = None + break + + if (self.x - 100) * self.direction > 0 and any( + (x - wall.edge_x(y)) * self.direction >= 0 for x, y in triangle + ): + self.direction *= -1 + self.missed = self.garbage + if self.missed is not None: + self.speed = 1 + wall.distance = min(100, max(30, wall.distance + (20 if self.missed is not None else -10))) + wall.angle = self.random.uniform(-math.pi / 7, math.pi / 7) + self.garbage = self.walls[self.direction].target() + self.terminal = not 0 <= wall.target()[0] + wall.side * 7 <= 199 + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[5, min(9, max(0, int(self.x) // 20)), 0] = True + for wall in self.walls.values(): + for row in range(10): + col = min(9, max(0, int(wall.edge_x(row * 10 + 5)) // 20)) + state[row, col, 1] = True + for channel, point in ((2, self.garbage), (3, self.missed)): + if point is not None: + x, y = point + state[int(y) // 10, min(9, max(0, int(x) // 20)), channel] = True + for x, y in self._triangle(): + state[int(y) // 10, min(9, max(0, int(x) // 20)), 4] = True + for row, value in enumerate((self.steps, math.ceil(self.multiplier), round(self.speed * 4), round(self.angle * 40))): + for bit in range(11): + if bit < 10: + state[row, bit, 5] = bool(value & (1 << bit)) + else: + state[row + 4, 0, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.direction > 0 + return state diff --git a/runtime/minatar_synth/games/cleaner.py b/runtime/minatar_synth/games/cleaner.py new file mode 100644 index 0000000000000000000000000000000000000000..a0cefd554c2f942dde0e9fb2fb2e236bfc055a66 --- /dev/null +++ b/runtime/minatar_synth/games/cleaner.py @@ -0,0 +1,125 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 + + +@dataclass +class Particle: + x: float + y: float + radius: float + + +class CleanerEnvironment: + score_cap = 1000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.frame = 0 + self.pressed = self.terminal = False + self.x = self.head_x = 50.0 + self.head_y = 130.0 + self.length = 0.0 + self.dust_timer, self.hole_timer = 0, 99 + self.multiplier = 1 + self.dust: list[Particle] = [] + self.holes: list[Particle] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed: + self.multiplier = 1 + self.pressed = pressed + self.steps += 1 + reward = 0 + for _ in range(FRAMES_PER_STEP): + reward += self._advance_frame() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self) -> int: + angle = math.sin(self.frame * 0.1) + self.frame += 1 + self.head_x = self.x + math.sin(angle) * self.length + self.head_y = 130 - math.cos(angle) * self.length + if self.pressed: + self.length += (150 - self.length) * 0.005 + else: + self.x = min(100, max(0, self.x + (self.head_x - self.x) * 0.005 * self.length)) + self.length *= 0.9 + + self.dust_timer -= 1 + if self.dust_timer < 0: + self.dust.append(Particle(self.random.uniform(10, 90), -20, self.random.uniform(1.5, 4.5))) + self.dust_timer = int(self.random.integers(10, 21)) + reward = 0 + remaining = [] + for dust in self.dust: + dust.y += 1 + if self._sweeps(dust): + reward += self.multiplier + self.multiplier += 1 + elif dust.y <= 170: + remaining.append(dust) + self.dust = remaining + + self.hole_timer -= 1 + if self.hole_timer < 0: + self.holes.append(Particle(self.random.uniform(0, 100), -20, self.random.uniform(5, 12))) + self.hole_timer = int(self.random.integers(99, 121)) + for hole in self.holes: + hole.y += 1 + if abs(math.hypot(hole.x - self.x, hole.y - 139) - hole.radius) <= 7: + self.terminal = True + self.holes = [hole for hole in self.holes if hole.y <= 170] + return reward + + def _sweeps(self, dust: Particle) -> bool: + if abs(dust.x - self.head_x) < 7.5 + dust.radius and abs(dust.y - self.head_y) < 5 + dust.radius: + return True + dx, dy = self.head_x - self.x, self.head_y - 130 + px, py = dust.x - self.x, dust.y - 130 + squared = dx * dx + dy * dy + fraction = min(1, max(0, (px * dx + py * dy) / squared)) if squared else 0 + return math.hypot(px - fraction * dx, py - fraction * dy) < 3.5 + dust.radius + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[9, min(9, int(self.x) // 10), 0] = True + for fraction in np.linspace(0, 1, 12): + x = self.x + (self.head_x - self.x) * fraction + y = 130 + (self.head_y - 130) * fraction + if 0 <= x <= 100 and 0 <= y < 150: + state[int(y) // 15, min(9, int(x) // 10), 1] = True + if 0 <= self.head_x <= 100 and 0 <= self.head_y < 150: + state[int(self.head_y) // 15, min(9, int(self.head_x) // 10), 4] = True + for channel, particles in ((2, self.dust), (3, self.holes)): + for particle in particles: + if 0 <= particle.y < 150: + state[int(particle.y) // 15, int(particle.x) // 10, channel] = True + for row, value in enumerate((self.steps, round(self.length), self.multiplier, self.frame % 63)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/cling_hop.py b/runtime/minatar_synth/games/cling_hop.py new file mode 100644 index 0000000000000000000000000000000000000000..5ddb237a0834c8a4221e37b40631c8b9e7ad6a69 --- /dev/null +++ b/runtime/minatar_synth/games/cling_hop.py @@ -0,0 +1,148 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Platform: + x: float + y: float + width: float + phase: float + identity: int + + def center(self, frame: int) -> float: + return min(98 - self.width / 2, max(self.width / 2 + 2, + self.x + 20 * math.sin(frame * 0.05 + self.phase))) + + +@dataclass +class Obstacle: + x: float + y: float + vx: float + vy: float + + def advance(self) -> None: + self.x += self.vx + self.y += self.vy + if not 3 <= self.x <= 97: + self.x = min(97, max(3, self.x)) + self.vx *= -1 + if not 3 <= self.y <= 97: + self.y = min(97, max(3, self.y)) + self.vy *= -1 + + +class ClingHopEnvironment: + score_cap = 1000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.frame = self.obstacle_timer = 0 + self.pressed = self.terminal = False + self.x = self.y = 50.0 + self.vy = 0.0 + self.support: Platform | None = None + self.last_platform = -1 + self.platforms: list[Platform] = [] + self.obstacles: list[Obstacle] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance_frame(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self, flap: bool) -> int: + if self.frame % 90 == 0: + self.platforms.append(Platform(self.random.uniform(20, 80), -5, + self.random.uniform(15, 30), self.random.uniform(0, math.tau), + self.frame)) + self.obstacle_timer -= 1 + if self.obstacle_timer < 0 or not self.obstacles: + direction = 1 if self.x > 50 else -1 + self.obstacles.append(Obstacle(3 if direction > 0 else 97, self.random.uniform(20, 60), + direction * self.random.uniform(0.5, 1.2), self.random.uniform(-1, 1))) + self.obstacle_timer = 180 + + reward = 0 + if self.support is None: + self.vy = -2.2 if flap else self.vy + 0.12 + self.y += self.vy + else: + self.x = self.support.center(self.frame) + self.y = self.support.y + 7 + self.vy = 0 + reward += 1 + if flap: + self.support = None + self.vy = -2.5 + self.terminal = self.y > 105 + + for platform in self.platforms: + platform.y += 0.3 + if (self.support is None and self.vy > 0 and -3 < self.y - platform.y < 8 + and abs(self.x - platform.center(self.frame)) < platform.width / 2 + 3): + self.support = platform + if platform.identity != self.last_platform: + self.last_platform = platform.identity + reward += len(self.obstacles) + self.platforms = [platform for platform in self.platforms if platform.y < 110] + if self.support is not None and self.support.y >= 110: + self.support = None + + survivors = [] + for obstacle in self.obstacles: + obstacle.advance() + if abs(obstacle.x - self.x) < 5 and abs(obstacle.y - self.y) < 5: + if self.support is not None: + self.terminal = True + survivors.append(obstacle) + else: + survivors.append(obstacle) + self.obstacles = survivors + self.frame += 1 + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row, col = min(9, max(0, int(self.y) // 10)), int(self.x) // 10 + state[row, col, 0] = True + state[row, col, 3] = self.support is not None + state[row, col, 4] = self.vy < 0 + for platform in self.platforms: + if 0 <= platform.y < 100: + x = platform.center(self.frame) + left = int(x - platform.width / 2) // 10 + right = int(x + platform.width / 2) // 10 + state[int(platform.y) // 10, left:right + 1, 1] = True + for obstacle in self.obstacles: + state[int(obstacle.y) // 10, int(obstacle.x) // 10, 2] = True + for row, value in enumerate((self.steps, len(self.obstacles), self.obstacle_timer)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/clock_turret.py b/runtime/minatar_synth/games/clock_turret.py new file mode 100644 index 0000000000000000000000000000000000000000..089afd5ba9181b542924da4a72ab76c8e9a8cb04 --- /dev/null +++ b/runtime/minatar_synth/games/clock_turret.py @@ -0,0 +1,166 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Moving: + x: float + y: float + angle: float + + def move(self, distance: float) -> None: + self.x += math.cos(self.angle) * distance + self.y += math.sin(self.angle) * distance + + def visible(self, margin: float = 0) -> bool: + return -margin <= self.x < 100 + margin and -margin <= self.y < 100 + margin + + +@dataclass +class Enemy(Moving): + aim: float + windup: int = 0 + + +class ClockTurretEnvironment: + score_cap = 250 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.fire_timer = self.enemy_timer = self.bullet_timer = 0 + self.angle = -math.pi / 2 + self.direction = self.multiplier = 1 + self.pressed = self.terminal = False + self.enemies: list[Enemy] = [] + self.shots: list[Moving] = [] + self.bullets: list[Moving] = [] + self.coins: list[Moving] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed: + self.direction *= -1 + self.pressed = pressed + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance_frame() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _near_hand(self, x: float, y: float, radius: float) -> bool: + dx, dy = x - 50, y - 50 + cos, sin = math.cos(self.angle), math.sin(self.angle) + along = min(14, max(-6, dx * cos + dy * sin)) + return math.hypot(dx - along * cos, dy - along * sin) < radius + + def _advance_frame(self) -> int: + for shot in self.shots: + shot.move(3) + self.shots = [shot for shot in self.shots if shot.visible(5)] + if self.pressed: + self.fire_timer += 1 + if self.fire_timer > 7: + self.fire_timer -= 7 + for angle, distance in ((self.angle, 12), (self.angle + math.pi, 5)): + shot = Moving(50, 50, angle) + shot.move(distance) + self.shots.append(shot) + else: + self.angle = (self.angle + self.direction * 0.1) % math.tau + + coins = [] + for coin in self.coins: + coin.move(1) + if self._near_hand(coin.x, coin.y, 5): + self.multiplier += 1 + elif coin.visible(5): + coins.append(coin) + self.coins = coins + self._spawn() + + reward = 0 + enemies = [] + for enemy in self.enemies: + enemy.move(0.5) + if enemy.windup: + enemy.windup -= 1 + if not enemy.windup: + self.bullets.append(Moving(enemy.x, enemy.y, enemy.aim)) + if any(math.hypot(enemy.x - shot.x, enemy.y - shot.y) < 5 for shot in self.shots): + reward += self.multiplier + self.coins.append(Moving(enemy.x, enemy.y, enemy.aim)) + elif (enemy.x - 50) * math.cos(enemy.angle) + (enemy.y - 50) * math.sin(enemy.angle) < 75: + enemies.append(enemy) + self.enemies = enemies + + for bullet in self.bullets: + for _ in range(3): + bullet.move(3) + self.terminal |= self._near_hand(bullet.x, bullet.y, 3.5) + self.bullets = [bullet for bullet in self.bullets if bullet.visible(5)] + return reward + + def _spawn(self) -> None: + self.bullet_timer -= 1 + if self.bullet_timer < 0 and self.enemies: + enemy = self.enemies[int(self.random.integers(len(self.enemies)))] + predicted = Moving(enemy.x, enemy.y, enemy.angle) + predicted.move(22.5) + angle = math.atan2(50 - predicted.y, 50 - predicted.x) + offset = (angle - enemy.aim + math.pi) % math.tau - math.pi + if not enemy.windup and predicted.visible(-5) and abs(offset) > math.pi * 0.07: + enemy.windup = 45 + self.bullet_timer = int(self.random.integers(45, 61)) + self.enemy_timer -= 1 + if self.enemy_timer < 0: + angle = self.random.uniform(0, math.tau) + aim = angle + self.random.choice((-1, 1)) * math.pi / 2 + enemy = Enemy(50, 50, angle, aim) + enemy.move(-60) + distance = self.random.uniform(30, 40) + enemy.x -= distance * math.cos(aim) + enemy.y -= distance * math.sin(aim) + self.enemies.append(enemy) + self.enemy_timer = int(self.random.integers(50, 91)) + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for distance in range(-6, 15, 2): + point = Moving(50, 50, self.angle) + point.move(distance) + state[int(point.y) // 10, int(point.x) // 10, 0] = True + for channel, objects in enumerate((self.shots, self.enemies, self.bullets, self.coins), 1): + for obj in objects: + if obj.visible(): + state[int(obj.y) // 10, int(obj.x) // 10, channel] = True + for enemy in self.enemies: + if enemy.windup: + warning = Moving(enemy.x, enemy.y, enemy.aim) + for _ in range(20): + if warning.visible(): + state[int(warning.y) // 10, int(warning.x) // 10, 3] = True + warning.move(5) + for row, value in enumerate((self.steps, self.multiplier, round(self.angle % math.tau * 80), self.fire_timer)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.direction > 0 + return state diff --git a/runtime/minatar_synth/games/color_roll.py b/runtime/minatar_synth/games/color_roll.py new file mode 100644 index 0000000000000000000000000000000000000000..e9308cad2d0de04a4bcebb09a905c35cfce396a1 --- /dev/null +++ b/runtime/minatar_synth/games/color_roll.py @@ -0,0 +1,113 @@ +import numpy as np + + +HORIZON = 400 +CENTER = 5 +WIDTH = 10 + + +class ColorRollEnvironment: + score_cap = HORIZON * 2 ** 18 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = 0 + self.last_action = 0 + self.pressure = 0 + self.penalty = 1 + self.base = 0 + self.target_count = 2 + self.chain = 0 + self.shot_color: int | None = None + self.shot_delay = 0 + self.terminal = False + self.lanes: list[tuple[np.ndarray, int]] = [] + self.previous_palette: list[int] = [] + self._refill() + + def _refill(self) -> None: + while len(self.lanes) < self.target_count: + palette = self.previous_palette.copy() + if not palette: + palette.append(int(self.random.integers(4))) + if len(palette) == 1 or (len(palette) < 4 and self.random.random() < 0.5): + palette.append(int(self.random.integers(4))) + else: + palette.pop(int(self.random.integers(len(palette)))) + self.previous_palette = palette + colors = np.resize(np.repeat(palette, (WIDTH + len(palette) - 1) // len(palette)), WIDTH) + colors = np.roll(colors, int(self.random.integers(WIDTH))) + self.lanes.append((colors, int(self.random.choice((-1, 1))))) + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + pressed = action == 5 and self.last_action != 5 + self.last_action = action + self.steps += 1 + self.pressure += 1 + self.lanes = [(np.roll(colors, velocity), velocity) for colors, velocity in self.lanes] + reward = 0 + if self.shot_delay: + self.shot_delay -= 1 + if self.shot_delay == 0: + reward = self._contact() + elif pressed: + self.shot_color = None + self.chain = 0 + self.shot_delay = 2 + self.pressure += 4 * self.penalty + if not self.shot_delay: + self.terminal = self.pressure + 4 * len(self.lanes) >= 48 + if not self.terminal: + self._refill() + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _contact(self) -> int: + color = int(self.lanes[0][0][CENTER]) + if self.shot_color is not None and color != self.shot_color: + self.penalty = max(1, min(4, self.penalty * (3 // (2 ** self.chain)))) + self.shot_color = None + return 0 + self.shot_color = color + self.lanes.pop(0) + self.pressure = max(0, self.pressure - 2 ** self.chain) + reward = 2 ** (self.base + self.chain) + self.chain += 1 + if self.lanes: + self.shot_delay = 1 + else: + self.shot_color = None + self.target_count += 1 + if self.target_count > min(10, 5 + self.base): + self.base = min(9, self.base + 1) + self.target_count = 2 + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for row, (colors, velocity) in enumerate(reversed(self.lanes), 10 - len(self.lanes)): + state[row, np.arange(WIDTH), colors] = True + state[row, 0, 4] = velocity == 1 + values = (self.pressure, self.penalty, self.base, self.target_count, + self.chain, self.shot_delay, 0 if self.shot_color is None else self.shot_color + 1, + int(self.last_action == 5), self.steps) + for row, value in enumerate(values): + for bit in range(WIDTH): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/count.py b/runtime/minatar_synth/games/count.py new file mode 100644 index 0000000000000000000000000000000000000000..6b792b90c354bf5e2f2e14b32b33eed73b82e3f9 --- /dev/null +++ b/runtime/minatar_synth/games/count.py @@ -0,0 +1,89 @@ +import math + +import numpy as np + + +class CountEnvironment: + score_cap = 9 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = 0 + self.turn = 1 + self.pressed = self.terminal = False + self._new_round() + + def _new_round(self) -> None: + self.count, self.timer, self.feedback = 0, 80, 0 + self.correct = False + chance = 0.5 + (math.sqrt(self.turn) * 0.2 - 0.5) % 0.5 + vary_shape, vary_color = self.random.random(2) < chance + if not (vary_shape or vary_color): + vary_shape = bool(self.random.integers(2)) + vary_color = not vary_shape + self.by_shape = bool(vary_shape and (not vary_color or self.random.integers(2))) + size = min(70, 3 + int(math.sqrt(self.turn)) + int(self.random.integers(self.turn))) + shapes = self.random.integers(3, size=size) if vary_shape else [int(self.random.integers(3))] * size + colors = self.random.integers(3, size=size) if vary_color else [int(self.random.integers(3))] * size + self.objects = [(int(cell), int(shape), int(color)) for cell, shape, color in + zip(self.random.choice(70, size, replace=False), shapes, colors)] + _, shape, color = self.objects[int(self.random.integers(size))] + self.target = shape if self.by_shape else color + self.target_count = sum(self._matches(shape, color) for _, shape, color in self.objects) + + def _matches(self, shape: int, color: int) -> bool: + return (shape if self.by_shape else color) == self.target + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + if self.feedback: + self.feedback -= 4 + if not self.feedback: + if self.correct: + self.turn += 1 + self._new_round() + else: + self.terminal = True + elif tap or self.count > self.target_count: + self.correct = self.count == self.target_count + self.feedback = 92 + reward = int(self.correct) + else: + self.timer -= 4 + if self.timer <= 0: + self.count += 1 + self.timer = 60 + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for cell, shape, color in self.objects: + if not self.feedback or self._matches(shape, color): + row, col = divmod(cell, 10) + state[row + 3, col, color] = True + state[row + 3, col, 3:5] = bool(shape & 1), bool(shape & 2) + state[0, self.target, 5] = True + state[0, 3:7, 5] = self.by_shape, bool(self.feedback), self.correct, self.pressed + for row, value in enumerate((self.count, self.timer, self.feedback, self.turn, self.steps), 1): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/counter_b.py b/runtime/minatar_synth/games/counter_b.py new file mode 100644 index 0000000000000000000000000000000000000000..338138258b8323adfa8fd0467dd9f82d3d91c106 --- /dev/null +++ b/runtime/minatar_synth/games/counter_b.py @@ -0,0 +1,183 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +Y = 60 + + +@dataclass(eq=False) +class Enemy: + x: float + y: float + angle: float + speed: float + beam: float = 0 + + def tip(self) -> tuple[float, float]: + return self.x + math.cos(self.angle) * self.beam, self.y + math.sin(self.angle) * self.beam + + +@dataclass +class Counter: + x: float + radius: float + enemy: Enemy | None + + +class CounterBEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.shield = 0 + self.spawn_timer = 9 + self.multiplier = 1 + self.x, self.base_x = 20.0, 30.0 + self.speed = self.beam = 0.0 + self.pressed = self.terminal = False + self.counter: Counter | None = None + self.enemies = [Enemy(205, Y, math.pi, 0.5)] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance_frame() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self) -> int: + scroll = (self.x - self.base_x) * 0.1 + self.base_x += (30 - self.base_x) * 0.001 + self.speed += ((0.2 if self.pressed else 2) - self.speed) * 0.2 + self.x += self.speed - scroll + if self.counter is None: + self.beam = min(300, self.beam + 4) if self.pressed else 0 + else: + self.counter.x -= scroll + self.beam = max(0, self.counter.x - self.x) + if not self.beam and self.counter.enemy is not None: + self.counter.enemy.beam = -9999 + self.counter.enemy = None + growth = 1 if self.pressed and self.counter.enemy is not None else -2 + self.counter.radius = min(30, self.counter.radius + growth) + if self.counter.radius < 1: + if self.counter.enemy is not None: + self.counter.enemy.beam = -9999 + self.counter = None + + self.spawn_timer -= 1 + if self.spawn_timer < 0: + self._spawn() + reward = 0 + incoming = False + survivors = [] + for enemy in self.enemies: + enemy.x += math.cos(enemy.angle) * enemy.speed - scroll + enemy.y += math.sin(enemy.angle) * enemy.speed + if self.counter is not None and self.counter.enemy is enemy: + enemy.beam = math.hypot(enemy.x - self.counter.x, enemy.y - Y) + enemy.speed *= 0.8 + else: + enemy.beam += 0.8 + if enemy.beam > 0: + tx, ty = enemy.tip() + if self.counter is None and self.beam and abs(tx - self.x - self.beam) < 5 and abs(ty - Y) < 5: + self.counter = Counter(self.x + self.beam, 1, enemy) + self.multiplier = 1 + if (self.counter is None or self.counter.enemy is not enemy) and ( + ty > 90 or tx < -99 or self._counter_hits(tx, ty) + ): + enemy.beam = -9999 + if self._counter_hits(enemy.x, enemy.y): + reward += self.multiplier + self.multiplier = min(64, self.multiplier * 2) + if self.counter is not None and self.counter.enemy is enemy: + self.counter.enemy = None + elif self.beam and self.x <= enemy.x <= self.x + self.beam and abs(enemy.y - Y) < 3: + if self.counter is not None and self.counter.enemy is enemy: + self.counter.enemy = None + elif enemy.x >= -5: + incoming |= self._beam_hits_player(enemy) + if enemy.beam < -999: + enemy.speed += (1 - enemy.speed) * 0.1 + enemy.angle += (math.pi - enemy.angle) * 0.05 + survivors.append(enemy) + self.enemies = survivors + self.shield = max(0, self.shield - 1) + if incoming and not self.shield and ( + self.counter is None or abs(self.x - self.counter.x) >= self.counter.radius + 9 + ): + self.x -= 10 + self.base_x -= 10 + self.shield = 60 + self.terminal = self.x < 0 + return reward + + def _counter_hits(self, x: float, y: float) -> bool: + return self.counter is not None and abs( + math.hypot(x - self.counter.x, y - Y) - self.counter.radius + ) < 4 + + def _beam_hits_player(self, enemy: Enemy) -> bool: + if enemy.beam <= 0: + return False + dx, dy = self.x - enemy.x, Y - enemy.y + cos, sin = math.cos(enemy.angle), math.sin(enemy.angle) + distance = min(enemy.beam, max(0, dx * cos + dy * sin)) + return math.hypot(dx - distance * cos, dy - distance * sin) < 3 + + def _spawn(self) -> None: + if self.random.random() < 0.6: + x, y = self.random.uniform(150, 300), -5 + else: + x, y = 205, self.random.uniform(0, 85) + target = self.x + 9 if self.random.random() < 0.05 else x - self.random.uniform(30, 150) + self.enemies.append(Enemy(x, y, math.atan2(Y - y, target - x) % math.tau, + 1, -self.random.uniform(0, 20))) + self.spawn_timer = int(self.random.integers(30, 41)) + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + column = min(9, max(0, int(self.x) // 20)) + state[6, column, 0] = True + if self.beam: + state[6, column:min(10, int(self.x + self.beam) // 20 + 1), 1] = True + for enemy in self.enemies: + if 0 <= enemy.x < 200 and 0 <= enemy.y < 100: + state[int(enemy.y) // 10, int(enemy.x) // 20, 2] = True + if enemy.beam > 0: + tx, ty = enemy.tip() + for fraction in np.linspace(0, 1, 16): + x = enemy.x + (tx - enemy.x) * fraction + y = enemy.y + (ty - enemy.y) * fraction + if 0 <= x < 200 and 0 <= y < 100: + state[int(y) // 10, int(x) // 20, 3] = True + for row in range(10): + for column in range(10): + state[row, column, 4] = self._counter_hits(column * 20 + 10, row * 10 + 5) + for row, value in enumerate((self.steps, self.multiplier, round(self.beam), self.shield)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/crazy_climber.py b/runtime/minatar_synth/games/crazy_climber.py new file mode 100644 index 0000000000000000000000000000000000000000..758f24e129e6ba02121d6cea7dd094910b503b34 --- /dev/null +++ b/runtime/minatar_synth/games/crazy_climber.py @@ -0,0 +1,200 @@ +import numpy as np + + +class CrazyClimberEnvironment: + """Four-building two-phase climbing task with windows and falling hazards.""" + + score_cap = 1_008_000.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 2_000): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.building = 1 + self.lives = 5 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self.previous_player = [8, 4] + self._start_building() + + def _start_building(self) -> None: + self.player = [8, 4] + self.previous_player = self.player.copy() + self.reaching = False + self.at_roof = False + self.pickup_steps = 30 + self.helicopter_column = 0 + self.bonus = self.building * 100_000.0 + self.building_steps = 0 + self.electric_shocks = 0 + self.hazards: list[dict[str, object]] = [] + self.previous_hazards: list[list[int]] = [] + self._update_windows() + + def _update_windows(self) -> None: + period = max(4, 9 - self.building) + closed_span = 1 + self.building // 3 + self.windows = np.ones((8, 10), dtype=bool) + for row in range(8): + for column in range(10): + phase = (self.building_steps + row * 3 + column * 5) % period + self.windows[row, column] = phase >= closed_span + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + self.previous_hazards = [list(hazard["position"]) for hazard in self.hazards] + building_before_action = self.building + reward = 0.0 + if self.at_roof: + reward += self._act_on_roof(action) + else: + reward += self._act_on_wall(action) + if self.building != building_before_action or self.terminal: + self.steps += 1 + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + self._move_hazards() + self._update_windows() + if not self.at_roof: + self._resolve_window_grip(action) + self._resolve_hazard_contact() + self._resolve_electric_sign() + self.building_steps += 1 + self.steps += 1 + if self.building_steps % 10 == 0: + self.bonus = max(0.0, self.bonus - 100.0) + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _act_on_wall(self, action: int) -> float: + if action in (1, 3) and not self.reaching: + delta = -1 if action == 1 else 1 + self.player[1] = int(np.clip(self.player[1] + delta, 0, 8)) + elif action == 2: + if self.reaching: + self.player[0] -= 1 + self.reaching = False + if self.player[0] == 0: + self.at_roof = True + self.pickup_steps = 30 + return self.building * 100.0 + self.reaching = True + elif action == 4: + self.reaching = False + return 0.0 + + def _act_on_roof(self, action: int) -> float: + if action == 1: + self.player[1] = max(0, self.player[1] - 1) + elif action == 3: + self.player[1] = min(9, self.player[1] + 1) + self.helicopter_column = (self.helicopter_column + 1) % 10 + self.pickup_steps -= 1 + if self.pickup_steps <= 0: + self.bonus = 0.0 + if action != 5 or abs(self.player[1] - self.helicopter_column) > 1: + return 0.0 + reward = self.bonus + self.building += 1 + if self.building > 4: + self.terminal = True + else: + self._start_building() + return reward + + def _move_hazards(self) -> None: + spawn_period = max(5, 13 - 2 * self.building) + if self.building_steps % spawn_period == 0: + kinds = ["doctor", "egg"] + if self.building >= 2: + kinds.append("girder") + kind = kinds[int(self.random.randint(len(kinds)))] + self.hazards.append( + {"position": [0, int(self.random.randint(10))], "kind": kind} + ) + for hazard in self.hazards: + hazard["position"][0] += 1 + self.hazards = [hazard for hazard in self.hazards if hazard["position"][0] <= 8] + + def _hand_positions(self) -> tuple[tuple[int, int], tuple[int, int]]: + row = max(0, self.player[0] - 1) if self.reaching else min(7, self.player[0]) + return (row, self.player[1]), (row, self.player[1] + 1) + + def _resolve_window_grip(self, action: int) -> None: + hands = self._hand_positions() + closed = sum(not self.windows[position] for position in hands) + if closed == 2 or (closed == 1 and action in (1, 2, 3, 4)): + self._fall() + + def _resolve_hazard_contact(self) -> None: + contacts = [hazard for hazard in self.hazards if hazard["position"] == self.player] + for hazard in contacts: + self.bonus = max(0.0, self.bonus - 100.0) + if self.reaching or hazard["kind"] == "girder": + self._fall() + break + self.hazards = [hazard for hazard in self.hazards if hazard not in contacts] + + def _resolve_electric_sign(self) -> None: + if self.building < 3 or self.player[0] != 3 or self.player[1] not in (7, 8): + return + self.electric_shocks += 1 + self.bonus = max(0.0, self.bonus - 100.0) + if self.electric_shocks >= 11: + self._fall() + + def _fall(self) -> None: + self.lives -= 1 + self.reaching = False + self.hazards = [] + self.electric_shocks = 0 + if self.lives <= 0: + self.terminal = True + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + for row in range(8): + for column in range(10): + if not self.windows[row, column]: + state[row, column, 1] = True + else: + state[row, column, 2] = True + for hazard in self.hazards: + state[*hazard["position"], 1] = True + if hazard["kind"] == "girder": + state[*hazard["position"], 5] = True + if self.at_roof: + state[0, self.helicopter_column, 2] = True + state[0, self.helicopter_column, 3] = True + state[*self.previous_player, 4] = True + for position in self.previous_hazards: + state[*position, 4] = True + if self.building >= 3: + state[3, 7:9, 1] = True + state[3, 7:9, 3] = True + state[9, : self.lives, 5] = True + state[8, : self.building, 5] = True + if self.reaching: + state[7, :2, 5] = True + state[6, : min(10, self.electric_shocks), 5] = True + return state diff --git a/runtime/minatar_synth/games/cross_line.py b/runtime/minatar_synth/games/cross_line.py new file mode 100644 index 0000000000000000000000000000000000000000..99885a1d2eff8e24bbfd86b1b1773e070dc3c1da --- /dev/null +++ b/runtime/minatar_synth/games/cross_line.py @@ -0,0 +1,140 @@ +from dataclasses import dataclass + +import numpy as np + + +DIRECTIONS = ((0, -1), (-1, 0), (1, 0), (0, 1)) +HORIZON = 400 + + +@dataclass(eq=False) +class Point: + x: float + y: float + direction: int + + def cell(self) -> tuple[int, int]: + return int(self.y // 10), int(self.x // 10) + + +@dataclass +class Line: + start: Point + end: Point + age: int = 0 + + def crosses(self, other: "Line") -> bool: + def side(a: Point, b: Point, p: Point) -> float: + return (b.x - a.x) * (p.y - a.y) - (b.y - a.y) * (p.x - a.x) + + return ( + side(self.start, self.end, other.start) * side(self.start, self.end, other.end) < 0 + and side(other.start, other.end, self.start) * side(other.start, other.end, self.end) < 0 + ) + + +class CrossLineEnvironment: + score_cap = 100 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.last_action = self.spawn_count = 0 + self.next_point = 0.0 + self.terminal = False + self.cursor = (5, 5) + self.selected = Point(70, 1, 1) + self.points = [self.selected] + self.lines = [Line(Point(30, 99, -1), self.selected)] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + if 1 <= action <= 4: + dy, dx = DIRECTIONS[action - 1] + row, col = self.cursor + self.cursor = min(9, max(0, row + dy)), min(9, max(0, col + dx)) + connect = action == 5 and self.last_action != 5 + self.last_action = action + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance_frame(connect and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self, connect: bool) -> int: + depth = max((point.y if point.direction > 0 else 100 - point.y for point in self.points), default=0) + scroll = 0.03 + max(0, 40 - depth) * 0.1 + self.next_point -= scroll + while self.next_point < 0: + direction = -1 if self.spawn_count % 2 == 0 else 1 + pair = self.spawn_count // 2 % 7 + lo, hi = {3: (10, 30), 6: (70, 90)}.get(pair, (10, 90)) + y = -19 - self.next_point if direction > 0 else 119 + self.next_point + self.points.append(Point(self.random.uniform(lo, hi), y, direction)) + self.next_point += 4 + self.spawn_count += 1 + + endpoints = {point for line in self.lines for point in (line.start, line.end)} + for point in endpoints.union(self.points): + point.y += scroll * point.direction + reward = self._connect() if connect else 0 + self.terminal = any( + not 0 <= point.y <= 99 + for line in self.lines for point in (line.start, line.end) + ) + return reward + + def _connect(self) -> int: + candidate = next((point for point in self.points + if point is not self.selected and point.cell() == self.cursor), None) + if candidate is None: + return 0 + new_line = Line(self.selected, candidate) + self.points.remove(self.selected) + self.selected = candidate + reward, multiplier = 0, 1 + survivors = [] + for line in self.lines: + line.age += 1 + if line.age >= 2 and line.crosses(new_line): + reward += multiplier + multiplier *= 2 + else: + survivors.append(line) + self.lines = [*survivors, new_line] + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for point in self.points: + row, col = point.cell() + if 0 <= row < 10 and 0 <= col < 10: + channel = 2 if point is self.selected else int(point.direction < 0) + state[row, col, channel] = True + for line in self.lines: + for fraction in np.linspace(0, 1, 20): + row = int((line.start.y + (line.end.y - line.start.y) * fraction) // 10) + col = int((line.start.x + (line.end.x - line.start.x) * fraction) // 10) + if 0 <= row < 10 and 0 <= col < 10: + state[row, col, 3] = True + state[row, col, 4] |= line.age >= 1 + row, col = self.cursor + state[row, col, 5] = True + return state diff --git a/runtime/minatar_synth/games/cue_crumb.py b/runtime/minatar_synth/games/cue_crumb.py new file mode 100644 index 0000000000000000000000000000000000000000..6af92e48c34aeed74298669f1a9eb9dcc1610532 --- /dev/null +++ b/runtime/minatar_synth/games/cue_crumb.py @@ -0,0 +1,176 @@ +from dataclasses import dataclass +from itertools import combinations +import math + +import numpy as np + + +@dataclass(eq=False) +class Body: + x: float + y: float + vx: float = 0 + vy: float = 0 + + @property + def speed(self) -> float: + return math.hypot(self.vx, self.vy) + + def move(self, friction: float, margin: float) -> None: + self.vx *= friction + self.vy *= friction + self.x += self.vx + self.y += self.vy + if not margin <= self.x <= 100 - margin: + self.vx *= -1 + self.x = min(100 - margin, max(margin, self.x)) + if not margin <= self.y <= 100 - margin: + self.vy *= -1 + self.y = min(100 - margin, max(margin, self.y)) + + +@dataclass(eq=False) +class Rock(Body): + size: float = 9 + hot: int = 0 + depth: int = 0 + + +class CueCrumbEnvironment: + score_cap = 100 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.freeze = 0 + self.spawn_timer = 300 + self.pressed = self.terminal = False + self.player = Body(50, 50) + self.angle = self.random.uniform(0, math.tau) + self.rocks: list[Rock] = [] + for _ in range(4): + x, y = self.random.uniform(12, 88, 2) + if math.hypot(x - 50, y - 50) < 20: + x = 12 + (x - 12 + 35) % 76 + self.rocks.append(Rock(x, y)) + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance_frame(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self, tap: bool) -> int: + if not self.freeze: + self.angle = (self.angle + 0.058) % math.tau + if tap: + self.player.vx += 1.7 * math.cos(self.angle) + self.player.vy += 1.7 * math.sin(self.angle) + if self.freeze: + self.freeze -= 1 + return 0 + + self.player.move(0.965, 5) + self._spawn() + reward = self._collide_rocks() + for rock in self.rocks[:]: + rock.hot = max(0, rock.hot - 1) + rock.move(0.985, 4) + dx, dy = rock.x - self.player.x, rock.y - self.player.y + if math.hypot(dx, dy) >= rock.size / 2 + 3: + continue + angle = math.atan2(dy, dx) + speed = self.player.speed + if rock.size <= 4.5 and not rock.hot: + self.rocks.remove(rock) + reward += 3 + elif rock.hot and rock.speed > 0.4: + self.terminal = True + break + elif speed > 0.9 and rock.size > 4.5: + self._split(rock, angle, 1.2 + speed * 0.4, 1) + self.player.vx *= 0.3 + self.player.vy *= 0.3 + self.freeze = max(self.freeze, 2 + 2 * (speed > 1.4) + 2 * (speed > 2.2)) + reward += 1 + else: + rock.vx += math.cos(angle) * 0.5 + rock.vy += math.sin(angle) * 0.5 + return reward + + def _spawn(self) -> None: + self.spawn_timer -= 1 + if self.spawn_timer >= 0 or sum(rock.size > 4.5 for rock in self.rocks) >= 10: + return + side = int(self.random.integers(4)) + offset = self.random.uniform(4, 96) + x, y = ((offset, 4), (96, offset), (offset, 96), (4, offset))[side] + self.rocks.append(Rock(x, y, *self.random.uniform(-0.2, 0.2, 2))) + self.spawn_timer = int(self.random.integers(200, 321)) + + def _collide_rocks(self) -> int: + queued: dict[Rock, tuple[float, int]] = {} + large_count = sum(rock.size > 4.5 for rock in self.rocks) + for first, second in combinations(self.rocks, 2): + dx, dy = second.x - first.x, second.y - first.y + distance = math.hypot(dx, dy) + if not 0.01 < distance < (first.size + second.size) / 2: + continue + source, target = (first, second) if first.hot and first.speed > 0.7 else (second, first) + if source.hot and source.speed > 0.7 and target.size > 4.5 and target not in queued and large_count < 10: + queued[target] = source.speed, max(1, source.depth) + 1 + else: + vx, vy = dx * 0.3 / distance, dy * 0.3 / distance + first.vx -= vx + first.vy -= vy + second.vx += vx + second.vy += vy + for target, (speed, depth) in queued.items(): + self._split(target, self.random.uniform(0, math.tau), 1.3, depth) + self.freeze = max(self.freeze, 2 + (speed > 1.0) + (speed > 1.6)) + return sum(depth for _, depth in queued.values()) + + def _split(self, rock: Rock, angle: float, speed: float, depth: int) -> None: + self.rocks.remove(rock) + for offset in (-0.6, 0.6): + dx, dy = math.cos(angle + offset), math.sin(angle + offset) + self.rocks.append(Rock(rock.x + 4 * dx, rock.y + 4 * dy, + speed * dx, speed * dy, rock.size * 0.62, 55, depth)) + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + player = self.player + state[int(player.y) // 10, int(player.x) // 10, 0] = True + x = player.x + 8 * math.cos(self.angle) + y = player.y + 8 * math.sin(self.angle) + state[min(9, max(0, int(y) // 10)), min(9, max(0, int(x) // 10)), 4] = True + for rock in self.rocks: + channel = 2 if rock.hot else 3 if rock.size <= 4.5 else 1 + state[min(9, int(rock.y) // 10), min(9, int(rock.x) // 10), channel] = True + values = (self.steps, round(self.angle * 80), self.freeze, + round((player.vx + 16) * 8), round((player.vy + 16) * 8)) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/cywall.py b/runtime/minatar_synth/games/cywall.py new file mode 100644 index 0000000000000000000000000000000000000000..009bd1a333190f285d61807528dbd8df1c4ba031 --- /dev/null +++ b/runtime/minatar_synth/games/cywall.py @@ -0,0 +1,135 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Ring: + x: float + y: float + radius: float + count: int + angle: float + spin: float + length: float + following: "Ring | None" = None + + def walls(self): + for index in range(self.count): + angle = self.angle + index * math.tau / self.count + cos, sin = math.cos(angle), math.sin(angle) + yield self.x + cos * self.radius, self.y + sin * self.radius, -sin, cos + + +class CywallEnvironment: + score_cap = 1000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = 0 + self.pressed = self.terminal = False + self.rings: list[Ring] = [] + self.player = self._spawn() + self.next_ring = self.random.uniform(20, 40) + + def _spawn(self) -> Ring: + radius = self.random.uniform(20, 30) + ring = Ring(self.random.uniform(20, 80), -radius, radius, + int(self.random.integers(1, 4)), self.random.uniform(0, math.tau), + self.random.uniform(0.02, 0.05) * self.random.choice((-1, 1)), + self.random.uniform(10, 20)) + if self.rings: + self.rings[-1].following = ring + self.rings.append(ring) + return ring + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0.0 + for frame in range(4): + reward += self._advance_frame(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return reward, self.terminal + + def _advance_frame(self, tap: bool) -> float: + if self.next_ring <= 0: + self._spawn() + self.next_ring += self.random.uniform(20, 40) + scroll = 0.1 + max(0, 50 - self.player.y) * 0.05 + self.next_ring -= scroll + for ring in self.rings: + ring.y += scroll + ring.angle = (ring.angle + ring.spin) % math.tau + self.rings = [ring for ring in self.rings if ring.y <= 99 + ring.radius] + if self.player.y > 99: + self.terminal = True + elif tap and self.player.following is not None: + target = self.player.following + if self._blocked(target): + self.terminal = True + else: + self.player = target + return scroll + + def _blocked(self, target: Ring) -> bool: + start = self.player + dx, dy = target.x - start.x, target.y - start.y + samples = max(1, math.ceil(math.hypot(dx, dy))) + for ring in self.rings: + for x, y, wx, wy in ring.walls(): + for index in range(samples + 1): + fraction = index / samples + px, py = start.x + dx * fraction - x, start.y + dy * fraction - y + if abs(px * wx + py * wy) <= ring.length / 2 + 1.5 and abs(px * wy - py * wx) <= 3: + return True + if ring is not start and ring is not target: + distance_sq = dx * dx + dy * dy + fraction = min(1, max(0, ((ring.x - start.x) * dx + (ring.y - start.y) * dy) / distance_sq)) if distance_sq else 0 + if math.hypot(start.x + dx * fraction - ring.x, start.y + dy * fraction - ring.y) < 3: + return True + return False + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for ring in self.rings: + col = int(ring.x) // 10 + if 0 <= ring.y < 100: + channel = 0 if ring is self.player else 1 if ring is self.player.following else 2 + state[int(ring.y) // 10, col, channel] = True + for x, y, wx, wy in ring.walls(): + for offset in np.linspace(-ring.length / 2, ring.length / 2, 9): + px, py = x + offset * wx, y + offset * wy + if 0 <= px < 100 and 0 <= py < 100: + state[int(py) // 10, int(px) // 10, 3] = True + if self.player.following is not None: + target = self.player.following + for fraction in np.linspace(0, 1, 16): + x = self.player.x + fraction * (target.x - self.player.x) + y = self.player.y + fraction * (target.y - self.player.y) + if 0 <= y < 100: + state[int(y) // 10, int(x) // 10, 4] = True + for row, value in enumerate((self.steps, round(self.player.y + 32))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/d_fight.py b/runtime/minatar_synth/games/d_fight.py new file mode 100644 index 0000000000000000000000000000000000000000..46965d4c173f14f7fb67c937b803a5a237e4cbab --- /dev/null +++ b/runtime/minatar_synth/games/d_fight.py @@ -0,0 +1,166 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass(eq=False) +class Agent: + x: float + y: float = 87 + team: int = 0 + vx: float = 0 + vy: float = 0 + spacing: float = 45 + target: "Agent | None" = None + aim: float = 0 + fire: float = 0 + + +class DFightEnvironment: + score_cap = 25 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.last_action = self.enemy_timer = 0 + self.ally_timer, self.dome_timer = 9, 0.0 + self.terminal = False + self.player = Agent(99) + self.agents = [self.player] + self.domes = [100.0] + self.shots: list[tuple[float, float, int]] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.steps += 1 + direction = -1 if action == 1 else 1 if action == 4 else 0 + reward = 0 + for _ in range(4): + reward += self._advance_frame(direction) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _spawn(self, team: int) -> None: + left = self.random.random() < 0.3 + self.agents.append(Agent(-3 if left else 203, team=team, vx=1 if left else -1, + spacing=self.random.uniform(30, 60))) + + def _advance_frame(self, direction: int) -> int: + self.dome_timer -= 0.2 + if self.dome_timer < 0: + self.domes.append(240) + self.dome_timer += self.random.uniform(70, 150) + self.domes = [x - 0.2 for x in self.domes if x > -40] + enemy_count = sum(agent.team == 1 for agent in self.agents) + ally_count = len(self.agents) - enemy_count - 1 + self.ally_timer -= 1 + self.enemy_timer = self.enemy_timer - 1 if enemy_count else -1 + if self.ally_timer < 0: + self._spawn(0) + self.ally_timer = int(self.random.integers(120, 151)) * (ally_count + 1) + if self.enemy_timer < 0: + self._spawn(1) + self.enemy_timer = int(self.random.integers(60, 81)) * (enemy_count + 1) + + self.player.x = min(197, max(3, self.player.x + 2 * direction)) + self.shots = [] + for agent in self.agents: + if agent is not self.player: + self._move(agent) + if agent.target not in self.agents: + agent.target = min( + (other for other in self.agents if other.team != agent.team), + key=lambda other: math.hypot(other.x - agent.x, other.y - agent.y), + default=None, + ) + agent.aim = agent.fire = 0 + if agent.target is not None: + self._aim(agent) + + survivors = [] + reward = 0 + for agent in self.agents: + hit = any(team != agent.team and abs(x - agent.x) < 6 and abs(y - agent.y) < 5 + for x, y, team in self.shots) + if hit and agent is self.player: + self.terminal = True + if hit and agent.team == 1: + reward += 1 + if not hit or agent is self.player: + survivors.append(agent) + self.agents = survivors + return reward + + def _move(self, agent: Agent) -> None: + agent.vy += 0.05 + if (agent.x < 3 and agent.vx < 0) or (agent.x > 197 and agent.vx > 0): + agent.x = min(197, max(3, agent.x)) + agent.vx *= -1 + if agent.y >= 87: + agent.y = 87 + agent.vy = -self.random.uniform(3, 6) if self.random.random() < 0.01 else 0 + agent.x += agent.vx + agent.y += agent.vy + agent.vx *= 0.9 + agent.vy *= 0.9 + + def _aim(self, agent: Agent) -> None: + target = agent.target + dx, dy = target.x - agent.x, target.y - agent.y + distance = math.hypot(dx, dy) + if distance > 99: + agent.target = None + agent.aim = agent.fire = 0 + return + if agent is not self.player: + agent.vx += math.copysign(0.1, dx) * (1 if distance > agent.spacing else -1) + if agent.fire: + agent.fire += 3 + ratio = agent.fire / max(distance, 0.01) + x, y = agent.x + dx * ratio, agent.y + dy * ratio + blocked = any(abs(math.hypot(x - dome, y - 90) - 40) < 4 for dome in self.domes) + if blocked or y > 90 or agent.fire > 99: + agent.fire = agent.aim = 0 + else: + self.shots.append((x, y, agent.team)) + else: + rate = 0.9 if agent is self.player else 0.4 if agent.team else 0.2 + agent.aim += rate * max(1, distance) * 0.03 + if agent.aim > distance: + agent.fire = 5 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for agent in self.agents: + if 0 <= agent.x < 200 and 0 <= agent.y < 100: + state[int(agent.y) // 10, int(agent.x) // 20, + 0 if agent is self.player else 2 if agent.team else 1] = True + for x, y, team in self.shots: + if 0 <= x < 200 and 0 <= y < 100: + state[int(y) // 10, int(x) // 20, 3 + team] = True + for dome in self.domes: + for angle in np.linspace(math.pi, math.tau, 20): + x, y = dome + 40 * math.cos(angle), 90 + 40 * math.sin(angle) + if 0 <= x < 200: + state[int(y) // 10, int(x) // 20, 5] = True + for bit in range(9): + state[0, bit, 5] = bool(self.steps & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/d_laser.py b/runtime/minatar_synth/games/d_laser.py new file mode 100644 index 0000000000000000000000000000000000000000..5ac809c12eacbe53e026f0cb33af714aff8ce415 --- /dev/null +++ b/runtime/minatar_synth/games/d_laser.py @@ -0,0 +1,140 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Shield: + x: float + y: float + target: float + + +@dataclass +class Laser: + bottom: float = 20 + blocked: bool = False + + +class DLaserEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = 0 + self.pressed = self.terminal = False + self.x, self.y, self.direction = 50.0, 90.0, 1 + self.camera = 80.0 + self.distance = self.charge = self.charge_speed = self.acceleration = 0.0 + self.shield_distance = 0.0 + self.shields: list[Shield] = [] + self.lasers: list[Laser] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed: + self.direction *= -1 + self.pressed = pressed + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance_frame() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self) -> int: + scroll = 0.05 + max(0, self.camera - self.y) * 0.1 + self.camera += (80 - self.camera) * 0.001 + self.shield_distance -= scroll + if self.shield_distance < 0: + target = 5 + 10 * int(self.random.integers(10)) + self.shields.append(Shield(0 if target < 50 else 99, 15, target)) + self.shield_distance += self.random.uniform(9, 36) + for shield in self.shields: + shield.y += scroll + delta = shield.target - shield.x + shield.x = shield.target if abs(delta) < 1 else shield.x + delta * 0.2 + self.shields = [shield for shield in self.shields if shield.y <= 99] + + reward = 0 + if self.charge > 10: + self.charge += 9 + if not self.lasers: + self.lasers = [Laser() for _ in range(10)] + if self.charge > 199: + reward = math.ceil(self.distance**1.5 * 0.1) + self._reset_lasers() + else: + self.acceleration += self.random.uniform(-0.0001, 0.0001) + self.charge_speed += self.acceleration + if self.charge_speed < 0 and self.acceleration < 0 or self.charge_speed > 0.2 and self.acceleration > 0: + self.acceleration *= -1 + self.charge_speed *= self.random.uniform(0.2, 1.5) + self.charge += self.charge_speed + + for column, laser in enumerate(self.lasers): + if laser.blocked: + laser.bottom += scroll + else: + laser.bottom += 9 + stops = [shield.y - 2 for shield in self.shields if shield.x == 5 + 10 * column + and 10 <= shield.y - 2 <= laser.bottom] + if stops: + laser.bottom = min(stops) + laser.blocked = True + + self.y += scroll + if not self.pressed: + self.x += self.direction + if not 0 <= self.x <= 99: + self.x = min(99, max(0, self.x)) + self.direction *= -1 + self.y -= 0.5 + self.distance += 0.5 + if self.lasers and any( + 10 * column - 2 <= self.x <= 10 * column + 12 and 8 <= self.y <= laser.bottom + 2 + for column, laser in enumerate(self.lasers) + ): + self.camera += 7 + self.y += 7 + self._reset_lasers() + self.terminal = self.y > 99 + return reward + + def _reset_lasers(self) -> None: + self.lasers.clear() + self.distance = self.charge = 0.0 + self.charge_speed *= self.random.random() + self.acceleration *= self.random.random() + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row, col = min(9, max(0, int(self.y) // 10)), int(self.x) // 10 + state[row, col, 0] = True + state[row, col, 4] = self.direction > 0 + for shield in self.shields: + state[int(shield.y) // 10, int(shield.x) // 10, 1 if shield.x == shield.target else 2] = True + for col, laser in enumerate(self.lasers): + state[1:min(10, int(laser.bottom) // 10 + 1), col, 3] = True + for row, value in enumerate((self.steps, round(max(0, self.charge)), round(self.distance))): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/d_missile.py b/runtime/minatar_synth/games/d_missile.py new file mode 100644 index 0000000000000000000000000000000000000000..a55ceb4d16315f7bfcc3a3efc921a12fc24a2977 --- /dev/null +++ b/runtime/minatar_synth/games/d_missile.py @@ -0,0 +1,132 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +LAUNCH_ANGLE = -8 * math.pi / 9 + + +@dataclass +class Missile: + x: float = 60 + y: float = 90 + angle: float = LAUNCH_ANGLE + speed: float = 0.5 + + +@dataclass +class Enemy: + x: float + y: float + vx: float + vy: float + timer: int + + +class DMissileEnvironment: + score_cap = 100 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.tap_timer = self.spawn_timer = 0 + self.pressed = self.terminal = False + self.multiplier = 1.0 + self.missiles: list[Missile] = [] + self.enemies: list[Enemy] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed: + count = len(self.missiles) + self.tap_timer = 99 if count == 0 else 9 if count < 3 else 0 + released = self.pressed and not pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance_frame(released and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _enemy(self, x: float, y: float, timer: int) -> Enemy: + angle = math.atan2(90 - y, self.random.uniform(10, 90) - x) + return Enemy(x, y, math.cos(angle) * 0.1, math.sin(angle) * 0.1, timer) + + def _advance_frame(self, released: bool) -> int: + self.tap_timer = max(0, self.tap_timer - 1) + if released and self.tap_timer: + self.missiles.append(Missile()) + self.multiplier = max(1, self.multiplier * 0.9) + for missile in self.missiles: + missile.x += math.cos(missile.angle) * missile.speed + missile.y += math.sin(missile.angle) * missile.speed + missile.speed *= 1.002 + if self.pressed: + missile.angle = (missile.angle + missile.speed * (0.1 if missile.speed < 3 else 0.01)) % math.tau + self.missiles = [missile for missile in self.missiles + if -3 <= missile.x < 103 and -3 <= missile.y < 90] + self.spawn_timer = self.spawn_timer - 1 if self.enemies else -1 + if self.spawn_timer < 0: + count = int(self.random.integers(3, 6)) + for _ in range(count): + self.enemies.append(self._enemy(self.random.uniform(10, 90), -self.random.uniform(5, 25), + int(self.random.integers(300, 401)))) + self.spawn_timer = 150 * count + + reward = 0 + survivors = [] + for enemy in self.enemies: + enemy.x += enemy.vx + enemy.y += enemy.vy + enemy.timer -= 1 + if enemy.timer == 0: + for _ in range(int(self.random.integers(2, 5))): + survivors.append(self._enemy(enemy.x, enemy.y, 999)) + elif any(abs(missile.x - enemy.x) < 3.5 and abs(missile.y - enemy.y) < 3.5 + for missile in self.missiles): + reward += math.floor(self.multiplier) + self.multiplier += 1 / len(self.missiles) + else: + survivors.append(enemy) + self.terminal |= enemy.y > 90 + self.enemies = survivors + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[9, :, 4] = True + state[9, 6, 0] = len(self.missiles) < 3 + for missile in self.missiles: + if 0 <= missile.x < 100 and 0 <= missile.y < 100: + state[int(missile.y) // 10, int(missile.x) // 10, 0] = True + x = missile.x + 8 * math.cos(missile.angle) + y = missile.y + 8 * math.sin(missile.angle) + if 0 <= x < 100 and 0 <= y < 100: + state[int(y) // 10, int(x) // 10, 1] = True + for enemy in self.enemies: + if 0 <= enemy.x < 100 and 0 <= enemy.y < 100: + row, col = int(enemy.y) // 10, int(enemy.x) // 10 + state[row, col, 2] = True + state[row, col, 3] |= enemy.timer <= 40 + for row, value in enumerate((self.steps, round(self.multiplier * 8), self.tap_timer, len(self.missiles))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/d_pistols.py b/runtime/minatar_synth/games/d_pistols.py new file mode 100644 index 0000000000000000000000000000000000000000..67ca8cb44b48e1914a9e62f2d10dc2a94df7bf57 --- /dev/null +++ b/runtime/minatar_synth/games/d_pistols.py @@ -0,0 +1,122 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Mover: + x: float + y: float + vx: float + vy: float + + def move(self) -> None: + self.x += self.vx + self.y += self.vy + + +class DPistolsEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.hold = self.spawn_timer = self.multiplier = 0 + self.pressed = self.terminal = False + self.y, self.direction = 20.0, 1 + self.enemy_y, self.enemy_direction = 50.0, 1 + self.enemies: list[Mover] = [] + self.shots: list[Mover] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance_frame(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self, tap: bool) -> int: + if tap: + self.direction *= -1 + self.shots.extend(Mover(50, self.y + self.direction, vx, 0) for vx in (-2, 2)) + self.multiplier = max(0, self.multiplier - 1) + self.hold = self.hold + 1 if self.pressed else 0 + if self.hold > 30: + self.shots.extend(Mover(50, self.y, vx, vy) + for vx, vy in ((-2, 0), (2, 0), (0, -2), (0, 2))) + self.hold = 0 + self.multiplier = max(1, self.multiplier - 5) + self.y += self.direction * (1 - self.hold / 30) + if not 0 <= self.y <= 99: + self.direction *= -1 + self.y = min(99, max(0, self.y)) + for shot in self.shots: + shot.move() + self.shots = [shot for shot in self.shots if -3 <= shot.x < 103 and -3 <= shot.y < 103] + + self.spawn_timer = self.spawn_timer - 1 if self.enemies else -1 + if self.spawn_timer < 0: + if self.random.random() < 0.3: + self.enemy_y = self.random.uniform(9, 90) + self.enemy_direction *= -1 + x = -3 if self.enemy_direction > 0 else 103 + self.enemies.append(Mover(x, self.enemy_y, self.enemy_direction * 0.3, 0)) + self.spawn_timer = int(self.random.integers(20, 41)) + + survivors = [] + reward = 0 + for enemy in self.enemies: + enemy.move() + if enemy.vx and (enemy.x - 50) * enemy.vx >= 0: + enemy.x = 50 + enemy.vy = -0.3 if self.y < enemy.y else 0.3 + enemy.vx = 0 + if any( + abs(shot.x - enemy.x) < (3 if shot.vx else 6) + and abs(shot.y - enemy.y) < (6 if shot.vx else 3) + for shot in self.shots + ): + self.multiplier = min(99, self.multiplier + 1) + reward += self.multiplier + else: + self.terminal |= abs(enemy.x - 50) < 5 and abs(enemy.y - self.y) < 5 + if -4 <= enemy.y <= 104: + survivors.append(enemy) + self.enemies = survivors + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row = int(self.y) // 10 + state[row, 5, 0] = True + state[row, 5, 4] = self.direction > 0 + for shot in self.shots: + if 0 <= shot.x < 100 and 0 <= shot.y < 100: + state[int(shot.y) // 10, int(shot.x) // 10, 3] = True + for enemy in self.enemies: + if 0 <= enemy.x < 100 and 0 <= enemy.y < 100: + state[int(enemy.y) // 10, int(enemy.x) // 10, 1 if enemy.vx else 2] = True + for row, value in enumerate((self.steps, self.hold, self.multiplier)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/dango.py b/runtime/minatar_synth/games/dango.py new file mode 100644 index 0000000000000000000000000000000000000000..7248a5d02bde05c3cdcc1d220bbafb21f6bfb4bf --- /dev/null +++ b/runtime/minatar_synth/games/dango.py @@ -0,0 +1,144 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Dango: + x: float + angle: float + spin: float + height: float + factor: int + multiply: bool + caught: bool = False + + @property + def y(self) -> float: + return 50 + 30 * math.sin(self.angle) + + +def expression_score(terms: list[tuple[bool, int]]) -> int: + total = product = 0 + for multiply, value in terms: + if multiply: + product *= value + else: + total += product + product = value + return total + product + + +class DangoEnvironment: + score_cap = 10000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.stroke = 0 + self.sticks = 9 + self.offset = 0.0 + self.pressed = self.terminal = False + self.terms: list[tuple[bool, int]] = [] + self.dangos: list[Dango] = [] + self._refill() + + def _refill(self) -> None: + while len(self.dangos) < 7: + self.dangos.append(Dango( + -6, self.random.uniform(0, math.tau), + self.random.uniform(0.02, 0.05) * self.random.choice((-1, 1)), + self.random.uniform(15, 30), int(self.random.integers(2, 10)), + self.random.random() < 0.5, + )) + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance_frame(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _stick_x(self) -> float: + if not self.stroke: + return 90 + return 80 - 10 * self.stroke if self.stroke < 10 else 80 + (self.stroke - 10) * 10 + + def _advance_frame(self, tap: bool) -> int: + if tap and not self.stroke: + self.stroke = 1 + self.sticks -= 1 + self.terms.clear() + reward = 0 + if self.stroke: + self.stroke += 1 + self.offset *= 0.1 + if self.stroke > 19: + self.stroke = 0 + reward = expression_score(self.terms) + self.sticks = min(9, self.sticks + reward // 100) + elif self.sticks < 0: + self.terminal = True + return 0 + + self.offset += 0.002 + survivors = [] + for dango in self.dangos: + if dango.caught: + if self.stroke > 10: + dango.x += 20 + if dango.x > 99: + self.terms.insert(0, (dango.multiply, dango.factor)) + continue + else: + dango.x += (80 - 12 * len(survivors) - dango.x) * 0.1 + dango.angle += dango.spin + if abs(dango.y - 76) < dango.height / 2 + 1 and dango.x + self.offset + 6.5 > self._stick_x(): + if 0 < self.stroke < 10: + dango.caught = True + elif not self.stroke: + self.terminal = True + survivors.append(dango) + self.dangos = survivors + self._refill() + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for index, dango in enumerate(self.dangos): + x = dango.x + self.offset + if 0 <= x < 100: + col = int(x) // 10 + low = max(0, int(dango.y - dango.height / 2) // 10) + high = int(dango.y + dango.height / 2) // 10 + state[low:high + 1, col, 2 if dango.caught else int(dango.multiply)] = True + for bit in range(4): + state[0, index, bit] = bool(dango.factor & (1 << bit)) + state[0, index, 4] = dango.multiply + if self.sticks >= 0 or self.stroke: + state[7, max(0, int(self._stick_x()) // 10):, 3] = True + for row, value in enumerate((self.steps, self.sticks + 1, self.stroke), 1): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/dark_cave.py b/runtime/minatar_synth/games/dark_cave.py new file mode 100644 index 0000000000000000000000000000000000000000..226f99432f291ee7cdfd42a7c96e82d9fb573edc --- /dev/null +++ b/runtime/minatar_synth/games/dark_cave.py @@ -0,0 +1,110 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +PLAYER_Y = 90 +HALF_ANGLE = math.pi / 6 + + +@dataclass +class Object: + x: float + y: float + coin: bool + + +class DarkCaveEnvironment: + score_cap = 2000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.last_action = 0 + self.x, self.angle, self.light = 50.0, 0.0, 40.0 + self.spike_distance, self.coin_distance = 0.0, 10.0 + self.terminal = False + self.objects: list[Object] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.steps += 1 + direction = -1 if action == 1 else 1 if action == 4 else 0 + reward = 0 + for _ in range(4): + reward += self._advance_frame(direction) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self, direction: int) -> int: + scroll = 0.1 + self.light * 0.01 + self.spike_distance -= scroll + self.coin_distance -= scroll + if self.spike_distance < 0: + self.objects.append(Object(self.random.uniform(5, 95), 0, False)) + self.spike_distance = self.random.uniform(20, 30) + if self.coin_distance < 0: + self.objects.append(Object(self.random.uniform(10, 90), 0, True)) + self.coin_distance = self.random.uniform(30, 40) + next_x = min(97, max(3, self.x + 1.5 * direction)) + tilt = min(0.1, max(-0.1, next_x - self.x)) + self.angle = min(math.pi / 8, max(-math.pi / 8, self.angle + tilt)) + self.x = next_x + self.light *= 0.999 + + reward = 0 + survivors = [] + for obj in self.objects: + obj.y += scroll + if abs(obj.x - self.x) < 6 and abs(obj.y - PLAYER_Y) < 6: + if obj.coin: + reward += math.floor(self.light) + self.light = min(99, self.light + 9) + else: + self.light /= 3 + elif obj.y <= 100: + survivors.append(obj) + self.objects = survivors + self.terminal = self.light < 9 + return reward + + def _in_cone(self, x: float, y: float) -> bool: + return abs(math.atan2(x - self.x, PLAYER_Y - y) - self.angle) < HALF_ANGLE + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[9, int(self.x) // 10, 0] = True + for row in range(9): + for column in range(10): + x, y = 10 * column + 5, 10 * row + 5 + state[row, column, 3] = self._in_cone(x, y) and math.hypot(x - self.x, y - PLAYER_Y) < self.light + for obj in self.objects: + if obj.y >= 100 or not self._in_cone(obj.x, obj.y): + continue + row, column = int(obj.y) // 10, int(obj.x) // 10 + if math.hypot(obj.x - self.x, obj.y - PLAYER_Y) < self.light: + state[row, column, 1 if obj.coin else 2] = True + else: + state[row, column, 4] = True + for row, value in enumerate((self.steps, round(self.light * 4), round((self.angle + 0.4) * 100))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/dark_sort.py b/runtime/minatar_synth/games/dark_sort.py new file mode 100644 index 0000000000000000000000000000000000000000..e08493b5cc35252567654e009167b55154c20f95 --- /dev/null +++ b/runtime/minatar_synth/games/dark_sort.py @@ -0,0 +1,91 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Orb: + x: float + y: float + light: bool + + +class DarkSortEnvironment: + score_cap = 100 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.combo = self.spawn_timer = 0 + self.x, self.direction = 50, 1 + self.light = self.terminal = False + self.orbs: list[Orb] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.light = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance_frame() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self) -> int: + self.spawn_timer -= 1 + if self.spawn_timer <= 0: + self.orbs.append(Orb(self.random.uniform(12, 88), -5, self.random.random() < 0.5)) + self.spawn_timer = 29 + self.x += self.direction + if self.x > 90 or self.x < 10: + self.direction *= -1 + + reward = 0 + survivors = [] + for orb in self.orbs: + orb.y += 0.8 + if 90 <= orb.y <= 95 and abs(orb.x - self.x) < 14: + if orb.light == self.light: + self.combo += 1 + reward += self.combo + continue + self.terminal = True + if orb.y > 100: + self.combo = 0 + else: + survivors.append(orb) + self.orbs = survivors + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + gate = slice(max(0, (self.x - 12) // 10), min(10, (self.x + 12) // 10 + 1)) + state[9, gate, 0] = True + state[9, gate, 1] = self.light + for row in range(10): + for col in range(10): + state[row, col, 4] = math.hypot(10 * col + 5 - self.x, 10 * row + 5 - 67) < 55 + for orb in self.orbs: + if 0 <= orb.y < 100 and math.hypot(orb.x - self.x, orb.y - 67) < 55: + state[int(orb.y) // 10, int(orb.x) // 10, 2 if orb.light else 3] = True + for row, value in enumerate((self.steps, self.combo, self.x, self.spawn_timer)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.direction > 0 + return state diff --git a/runtime/minatar_synth/games/defender.py b/runtime/minatar_synth/games/defender.py new file mode 100644 index 0000000000000000000000000000000000000000..8db163f4534f90028705722367a6484ea573436a --- /dev/null +++ b/runtime/minatar_synth/games/defender.py @@ -0,0 +1,317 @@ +import numpy as np + + +ALIEN_VALUES = { + "pod": 1_000.0, + "swarmer": 500.0, + "bomber": 250.0, + "baiter": 200.0, + "lander": 150.0, + "mutant": 150.0, +} + + +class DefenderEnvironment: + """Five-wave scanner shooter centered on humanoid abduction and rescue.""" + + score_cap = 48_500.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 4_000): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.player = [4, 1] + self.previous_player = self.player.copy() + self.facing = 1 + self.lives = 3 + self.smart_bombs = 3 + self.score = 0.0 + self.next_bonus_score = 10_000.0 + self.wave = 1 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self.shots: list[dict[str, object]] = [] + self.hostile_shots: list[list[int]] = [] + self.humanoids = [ + {"position": [8, column], "state": "ground"} for column in (0, 2, 4, 6, 8) + ] + self.carried_humanoid: dict[str, object] | None = None + self.previous_threats: list[list[int]] = [] + self._start_wave() + + def _start_wave(self) -> None: + kinds = ["lander"] * 5 + ["bomber", "baiter", "pod"] + self.enemies = [ + {"kind": kind, "position": [1 + index % 5, (index * 3 + self.wave) % 10]} + for index, kind in enumerate(kinds) + ] + self.hostile_shots = [] + self.wave_steps = 0 + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + self.previous_threats = self._threat_positions() + reward = self._apply_action(action) + self._move_world() + reward += self._resolve_player_shots() + reward += self._resolve_humanoids() + reward += self._resolve_player_contact() + self.score += reward + if not self.enemies: + reward += self._complete_wave() + while self.score >= self.next_bonus_score: + self.lives += 1 + self.smart_bombs += 1 + self.next_bonus_score += 10_000.0 + self.wave_steps += 1 + self.steps += 1 + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _apply_action(self, action: int) -> float: + if action == 1: + self.player[1] = (self.player[1] - 1) % 10 + self.facing = -1 + elif action == 2: + self.player[0] = max(0, self.player[0] - 1) + elif action == 3: + self.player[1] = (self.player[1] + 1) % 10 + self.facing = 1 + elif action == 4: + self.player[0] = min(8, self.player[0] + 1) + elif action == 5: + if self.player[0] == 0: + self.player = [int(self.random.randint(1, 8)), int(self.random.randint(10))] + elif self.player[0] == 8 and self.smart_bombs > 0: + self.smart_bombs -= 1 + reward = sum(ALIEN_VALUES[str(enemy["kind"])] for enemy in self.enemies) + destroyed_ids = {id(enemy) for enemy in self.enemies} + for humanoid in self.humanoids: + if humanoid["state"] == "abducted" and id(humanoid.get("lander")) in destroyed_ids: + humanoid["state"] = "falling" + humanoid.pop("lander", None) + self.enemies = [] + return reward + elif len(self.shots) < 3: + self.shots.append({"position": self.player.copy(), "direction": self.facing}) + return 0.0 + + def _move_world(self) -> None: + for shot in self.shots: + shot["position"][1] = (shot["position"][1] + int(shot["direction"])) % 10 + shot["distance"] = int(shot.get("distance", 0)) + 1 + self.shots = [shot for shot in self.shots if int(shot["distance"]) < 10] + for enemy in self.enemies: + kind = str(enemy["kind"]) + position = enemy["position"] + if kind == "lander": + self._move_lander(enemy) + elif kind in ("baiter", "mutant", "swarmer"): + position[0] += int(np.sign(self.player[0] - position[0])) + position[1] = (position[1] + int(np.sign(self.player[1] - position[1]))) % 10 + else: + position[1] = (position[1] - 1) % 10 + if self.random.rand() < min(0.2, 0.015 * self.wave): + self.hostile_shots.append(list(position)) + for hostile_shot in self.hostile_shots: + hostile_shot[0] += int(np.sign(self.player[0] - hostile_shot[0])) + hostile_shot[1] = (hostile_shot[1] + int(np.sign(self.player[1] - hostile_shot[1]))) % 10 + self.hostile_shots = [shot for shot in self.hostile_shots if 0 <= shot[0] < 9] + for humanoid in self.humanoids: + if humanoid["state"] == "falling": + humanoid["position"][0] += 1 + + def _move_lander(self, lander: dict[str, object]) -> None: + carried = next( + ( + humanoid + for humanoid in self.humanoids + if humanoid["state"] == "abducted" and humanoid.get("lander") is lander + ), + None, + ) + position = lander["position"] + if carried is not None: + position[0] -= 1 + carried["position"] = [position[0] + 1, position[1]] + if position[0] <= 0: + carried["state"] = "lost" + lander["kind"] = "mutant" + lander["position"] = [1, position[1]] + return + if self.carried_humanoid is not None or any( + humanoid["state"] == "abducted" for humanoid in self.humanoids + ): + position[1] = (position[1] - 1) % 10 + return + ground = [humanoid for humanoid in self.humanoids if humanoid["state"] == "ground"] + if not ground: + position[1] = (position[1] - 1) % 10 + return + target = min(ground, key=lambda humanoid: abs(humanoid["position"][1] - position[1])) + if position[1] != target["position"][1]: + position[1] = (position[1] + int(np.sign(target["position"][1] - position[1]))) % 10 + elif position[0] < 7: + position[0] += 1 + else: + target["state"] = "abducted" + target["lander"] = lander + + def _resolve_player_shots(self) -> float: + reward = 0.0 + remaining_shots = [] + destroyed_ids: set[int] = set() + spawned: list[dict[str, object]] = [] + for shot in self.shots: + enemy = next( + ( + candidate + for candidate in self.enemies + if id(candidate) not in destroyed_ids and candidate["position"] == shot["position"] + ), + None, + ) + if enemy is None: + remaining_shots.append(shot) + continue + destroyed_ids.add(id(enemy)) + reward += ALIEN_VALUES[str(enemy["kind"])] + if enemy["kind"] == "pod": + for offset in (-1, 0, 1, 2): + spawned.append( + {"kind": "swarmer", "position": [enemy["position"][0], (enemy["position"][1] + offset) % 10]} + ) + for humanoid in self.humanoids: + if humanoid["state"] == "abducted" and humanoid.get("lander") is enemy: + humanoid["state"] = "falling" + humanoid.pop("lander", None) + self.shots = remaining_shots + self.enemies = [enemy for enemy in self.enemies if id(enemy) not in destroyed_ids] + spawned + return reward + + def _resolve_humanoids(self) -> float: + reward = 0.0 + if self.carried_humanoid is None: + caught = next( + ( + humanoid + for humanoid in self.humanoids + if humanoid["state"] == "falling" and humanoid["position"] == self.player + ), + None, + ) + if caught is not None: + caught["state"] = "carried" + self.carried_humanoid = caught + if self.carried_humanoid is not None: + self.carried_humanoid["position"] = self.player.copy() + if self.player[0] == 8: + self.carried_humanoid["state"] = "ground" + self.carried_humanoid["position"] = [8, self.player[1]] + self.carried_humanoid = None + reward += 1_000.0 + for humanoid in self.humanoids: + if humanoid["state"] != "falling" or humanoid["position"][0] < 8: + continue + if humanoid["position"][0] == 8: + humanoid["state"] = "ground" + reward += 250.0 + else: + humanoid["state"] = "lost" + return reward + + def _resolve_player_contact(self) -> float: + collided_enemy = next( + (enemy for enemy in self.enemies if enemy["position"] == self.player), + None, + ) + if collided_enemy is None and self.player not in self.hostile_shots: + return 0.0 + reward = 0.0 + if collided_enemy is not None: + reward = ALIEN_VALUES[str(collided_enemy["kind"])] + self.enemies = [enemy for enemy in self.enemies if enemy is not collided_enemy] + for humanoid in self.humanoids: + if humanoid["state"] == "abducted" and humanoid.get("lander") is collided_enemy: + humanoid["state"] = "falling" + humanoid.pop("lander", None) + self.lives -= 1 + self.player = [4, 1] + self.previous_player = self.player.copy() + self.shots = [] + self.hostile_shots = [] + if self.carried_humanoid is not None: + self.carried_humanoid["state"] = "ground" + self.carried_humanoid["position"] = [8, self.player[1]] + self.carried_humanoid = None + if self.lives <= 0: + self.terminal = True + return reward + + def _complete_wave(self) -> float: + survivors = sum(humanoid["state"] in ("ground", "carried") for humanoid in self.humanoids) + reward = survivors * 100.0 + if self.carried_humanoid is not None: + self.carried_humanoid["state"] = "ground" + self.carried_humanoid["position"] = [8, self.player[1]] + self.carried_humanoid = None + self.score += reward + self.wave += 1 + if self.wave > 5: + self.terminal = True + else: + if self.wave == 5 and survivors == 0: + self.humanoids = [ + {"position": [8, column], "state": "ground"} for column in (0, 2, 4, 6, 8) + ] + self._start_wave() + return reward + + def _threat_positions(self) -> list[list[int]]: + return [list(enemy["position"]) for enemy in self.enemies] + [ + shot.copy() for shot in self.hostile_shots + ] + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + for enemy in self.enemies: + position = enemy["position"] + state[*position, 1] = True + state[*position, 2] = True + if enemy["kind"] in ("lander", "mutant", "pod"): + state[*position, 5] = True + for hostile_shot in self.hostile_shots: + state[*hostile_shot, 1] = True + for shot in self.shots: + state[*shot["position"], 3] = True + for humanoid in self.humanoids: + if humanoid["state"] != "lost": + state[*humanoid["position"], 2] = True + if humanoid["state"] != "ground": + state[*humanoid["position"], 3] = True + state[*self.previous_player, 4] = True + for position in self.previous_threats: + state[*position, 4] = True + state[9, : min(10, self.lives), 5] = True + state[8, : min(10, self.smart_bombs), 5] = True + state[7, : self.wave, 5] = True + return state diff --git a/runtime/minatar_synth/games/demon_attack.py b/runtime/minatar_synth/games/demon_attack.py new file mode 100644 index 0000000000000000000000000000000000000000..8195d644758dc2a14ad751decaa75e0e96d2169e --- /dev/null +++ b/runtime/minatar_synth/games/demon_attack.py @@ -0,0 +1,182 @@ +import numpy as np + + +PRIMARY_VALUES = (10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35) +SPLIT_VALUES = (0, 0, 0, 0, 40, 40, 50, 50, 60, 60, 70, 70) +DIVING_VALUES = (0, 0, 0, 0, 80, 80, 100, 100, 120, 120, 140, 140) + + +class DemonAttackEnvironment: + """Twelve-wave fixed shooter with splitting and diving demon states.""" + + score_cap = 12_180.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 4_000): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.player = [9, 4] + self.previous_player = self.player.copy() + self.bunkers = 3 + self.wave = 1 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self.player_shots: list[list[int]] = [] + self.enemy_shots: list[list[int]] = [] + self.previous_enemies: list[list[int]] = [] + self._start_wave() + + def _start_wave(self) -> None: + self.enemies = [ + { + "position": [1 + index % 3, 1 + (index * 2) % 9], + "state": "primary", + "direction": 1 if index % 2 == 0 else -1, + "age": 0, + "shooter": True, + } + for index in range(6) + ] + self.wave_steps = 0 + self.wave_hit = False + self.enemy_shots = [] + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + self.previous_enemies = [list(enemy["position"]) for enemy in self.enemies] + if action == 1: + self.player[1] = max(0, self.player[1] - 1) + elif action == 3: + self.player[1] = min(9, self.player[1] + 1) + elif action == 5 and len(self.player_shots) < 3: + self.player_shots.append([8, self.player[1]]) + self._move_world() + reward = self._resolve_player_shots() + self._resolve_player_hits() + if not self.enemies: + if not self.wave_hit: + self.bunkers = min(6, self.bunkers + 1) + self.wave += 1 + if self.wave > 12: + self.terminal = True + else: + self._start_wave() + self.wave_steps += 1 + self.steps += 1 + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _move_world(self) -> None: + for shot in self.player_shots: + shot[0] -= 1 + self.player_shots = [shot for shot in self.player_shots if shot[0] >= 0] + for enemy in self.enemies: + position = enemy["position"] + enemy["age"] = int(enemy["age"]) + 1 + if enemy["state"] == "diving": + position[0] += 1 + position[1] += int(np.sign(self.player[1] - position[1])) + if position[0] > 9: + position[0] = 1 + else: + position[1] += int(enemy["direction"]) + if position[1] <= 0 or position[1] >= 9: + enemy["direction"] = -int(enemy["direction"]) + position[1] = int(np.clip(position[1], 0, 9)) + if enemy["state"] == "split" and int(enemy["age"]) >= 8: + enemy["state"] = "diving" + if bool(enemy["shooter"]) and self.random.rand() < min(0.25, 0.015 + self.wave * 0.008): + self.enemy_shots.append([position[0] + 1, position[1]]) + for shot in self.enemy_shots: + shot[0] += 1 + self.enemy_shots = [shot for shot in self.enemy_shots if shot[0] <= 9] + + def _resolve_player_shots(self) -> float: + reward = 0.0 + surviving_shots = [] + destroyed_ids: set[int] = set() + spawned: list[dict[str, object]] = [] + for shot in self.player_shots: + enemy = next( + ( + candidate + for candidate in self.enemies + if id(candidate) not in destroyed_ids and candidate["position"] == shot + ), + None, + ) + if enemy is None: + surviving_shots.append(shot) + continue + destroyed_ids.add(id(enemy)) + state = str(enemy["state"]) + if state == "primary": + reward += PRIMARY_VALUES[self.wave - 1] + if self.wave >= 5: + for direction in (-1, 1): + spawned.append( + { + "position": list(enemy["position"]), + "state": "split", + "direction": direction, + "age": 0, + "shooter": direction == 1, + } + ) + elif state == "split": + reward += SPLIT_VALUES[self.wave - 1] + else: + reward += DIVING_VALUES[self.wave - 1] + self.player_shots = surviving_shots + self.enemies = [enemy for enemy in self.enemies if id(enemy) not in destroyed_ids] + spawned + return reward + + def _resolve_player_hits(self) -> None: + enemy_contact = any(enemy["position"] == self.player for enemy in self.enemies) + shot_contact = self.player in self.enemy_shots + if not enemy_contact and not shot_contact: + return + self.wave_hit = True + self.enemy_shots = [shot for shot in self.enemy_shots if shot != self.player] + if self.bunkers > 0: + self.bunkers -= 1 + else: + self.terminal = True + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + for enemy in self.enemies: + position = enemy["position"] + state[*position, 1] = True + state[*position, 2] = True + if enemy["state"] != "primary": + state[*position, 5] = True + for shot in self.enemy_shots: + state[*shot, 1] = True + for shot in self.player_shots: + state[*shot, 3] = True + state[*self.previous_player, 4] = True + for position in self.previous_enemies: + state[*position, 4] = True + state[9, : self.bunkers, 5] = True + state[8, : min(10, self.wave), 5] = True + return state diff --git a/runtime/minatar_synth/games/descents.py b/runtime/minatar_synth/games/descents.py new file mode 100644 index 0000000000000000000000000000000000000000..acd05168d737976e08019ef5a4b7df3eb4c0faec --- /dev/null +++ b/runtime/minatar_synth/games/descents.py @@ -0,0 +1,100 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +SHIP_X = 9 + + +@dataclass +class Deck: + x: float + y: float + width: float + + +class DescentsEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = 0 + self.pressed = self.terminal = False + self.y, self.vy = 9.0, 0.0 + self.up, self.down, self.next_up, self.next_down = -2, 2, -3, 3 + self.decks = [Deck(30, 50, 40), Deck(50, 75, 35), Deck(70, 99, 30)] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance_frame() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self) -> int: + self.vy += (self.up if self.pressed else self.down) * 0.005 + self.y += self.vy + scroll = (min(19, max(9, self.y)) - self.y) * 0.2 + self.y += scroll + for deck in self.decks: + deck.x -= 0.2 + deck.y += scroll + first = self.decks[0] + edge = first.x + first.width + if self.y < 0 or edge < SHIP_X - 3: + self.terminal = True + return 0 + if first.x - 3 <= SHIP_X <= edge + 3 and abs(first.y - self.y) <= 2: + if self.vy > 1: + self.terminal = True + return 0 + self.decks.pop(0) + last = self.decks[-1] + self.decks.append(Deck(last.x + last.width * 0.7 + self.random.uniform(0, 30), + last.y + self.random.uniform(20, 40), self.random.uniform(25, 50))) + self.up, self.down = self.next_up, self.next_down + self.next_up = math.floor(-4 + self.random.uniform(-3, 3)) + self.next_down = math.floor(4 + self.random.uniform(-2, 2)) + self.vy = 0 + return max(0, math.floor(edge - SHIP_X + 1)) + if self.y >= first.y + 1: + self.terminal = True + return 0 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, max(0, int(self.y) // 10)), 0, 0] = True + for index, deck in enumerate(self.decks): + if 0 <= deck.y < 100: + row = int(deck.y) // 10 + for col in range(10): + state[row, col, 1 if index == 0 else 2] |= col * 10 < deck.x + deck.width and (col + 1) * 10 > deck.x + first = self.decks[0] + if 0 <= first.y + 3 < 100: + state[int(first.y + 3) // 10, :min(10, max(0, int((first.x + first.width) / 10) + 1)), 3] = True + state[0, :3, 4] = self.pressed, self.vy > 0.6, self.vy > 1 + for row, value in enumerate((self.steps, round(self.vy * 20) + 256, -self.up, + self.down, -self.next_up, self.next_down)): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/divarr.py b/runtime/minatar_synth/games/divarr.py new file mode 100644 index 0000000000000000000000000000000000000000..0a9c4d6c88ff4824681b120830e8b19e03c0cf0e --- /dev/null +++ b/runtime/minatar_synth/games/divarr.py @@ -0,0 +1,141 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +DIRECTIONS = ((1, 0), (0, 1), (-1, 0), (0, -1)) + + +@dataclass +class Shot: + x: float = 50 + y: float = 85 + heading: int = 3 + overlap: int = 0 + + +@dataclass +class Falling: + x: float + y: float + vx: float + vy: float + human: bool + + +class DivarrEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.spawn_timer = 0 + self.until_human = 3 + self.first_human = True + self.pressed = self.terminal = False + self.shots: list[Shot] = [] + self.falling: list[Falling] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed: + self._fire_or_split() + self.pressed = pressed + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance_frame() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _fire_or_split(self) -> None: + if not self.shots: + self.shots = [Shot()] + return + offsets = (-1, 1) if len(self.shots) < 16 else (1,) + self.shots = [Shot(shot.x, shot.y, (shot.heading + offset) % 4) + for shot in self.shots for offset in offsets] + + def _advance_frame(self) -> int: + visible = [] + for shot in self.shots: + dx, dy = DIRECTIONS[shot.heading] + shot.x += dx + shot.y += dy + if -2 <= shot.x < 102 and -2 <= shot.y < 88: + touches = any(abs(other.x - shot.x) < 3 and abs(other.y - shot.y) < 3 for other in visible) + shot.overlap = shot.overlap + 1 if touches else 0 + if shot.overlap <= 8: + visible.append(shot) + self.shots = visible + + self.spawn_timer -= 1 + if self.spawn_timer < 0: + self._spawn() + reward = 0 + remaining = [] + for obj in self.falling: + obj.x += obj.vx + obj.y += obj.vy + hittable = not obj.human or obj.y >= 20 + if hittable and any(abs(obj.x - shot.x) < 4 and abs(obj.y - shot.y) < 4 for shot in self.shots): + if obj.human: + self.terminal = True + else: + reward += len(self.shots) + elif obj.y > 88: + if obj.human: + reward += 100 + else: + self.terminal = True + else: + remaining.append(obj) + self.falling = remaining + return reward + + def _spawn(self) -> None: + self.until_human -= 1 + human = self.until_human < 0 + x = self.random.uniform(9, 90) + if human: + if self.first_human: + x = 25 + self.first_human = False + self.until_human = int(self.random.integers(3, 15)) + dx = min(90, max(9, x + self.random.uniform(-10, 10))) - x + speed = self.random.uniform(0.1, 0.2) * (1.6 if human else 1) + distance = math.hypot(dx, 93) + self.falling.append(Falling(x, -3, dx * speed / distance, 93 * speed / distance, human)) + self.spawn_timer = int(self.random.integers(60, 81)) + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[8, 5, 0] = True + state[9, :, 4] = True + for shot in self.shots: + if 0 <= shot.x < 100 and 0 <= shot.y < 100: + state[int(shot.y) // 10, int(shot.x) // 10, 1] = True + for obj in self.falling: + if 0 <= obj.y < 100: + state[int(obj.y) // 10, int(obj.x) // 10, 3 if obj.human else 2] = True + for row, value in enumerate((self.steps, len(self.shots), self.spawn_timer, self.until_human + 1)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/doshin.py b/runtime/minatar_synth/games/doshin.py new file mode 100644 index 0000000000000000000000000000000000000000..c562c38825e465636e7f0da6c51ff950f84c345d --- /dev/null +++ b/runtime/minatar_synth/games/doshin.py @@ -0,0 +1,117 @@ +from dataclasses import dataclass + +import numpy as np + + +CENTERS = (25, 75, 125, 175) + + +@dataclass +class Walker: + x: float + speed: float + friendly: bool + y: float = 87 + vy: float = 0 + struck: bool = False + + +class DoshinEnvironment: + score_cap = 200 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.last_action = self.until_friend = 0 + self.terminal = False + self.cooldowns = [0] * len(CENTERS) + self.walkers: list[Walker] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + press = action - 1 if 1 <= action <= 4 and action != self.last_action else None + self.last_action = action + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance_frame(press if frame == 0 else None) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance_frame(self, press: int | None) -> int: + if self.random.random() < 0.03: + self.until_friend -= 1 + friendly = self.until_friend < 0 + if friendly: + speed = 0.6 + 0.2 * int(self.random.integers(2)) + self.until_friend = int(self.random.integers(10, 20)) + else: + speed = 0.1 + 0.2 * int(self.random.integers(4)) + self.walkers.append(Walker(0, speed, friendly)) + active = press is not None and self.cooldowns[press] == 0 + self.cooldowns = [max(0, timer - 1) for timer in self.cooldowns] + if active: + self.cooldowns[press] = 60 + + survivors = [] + reward, combo = 0, 1 + for walker in self.walkers: + walker.x += walker.speed + walker.y += walker.vy + if walker.struck: + walker.vy += 0.1 + if walker.y > 99: + if walker.friendly: + self.terminal = True + else: + reward += combo + combo += 1 + continue + else: + if active and abs(walker.x - CENTERS[press]) < 18: + walker.struck = True + walker.vy = -1 + if walker.x > 199: + if walker.friendly: + reward += 10 + else: + self.terminal = True + continue + survivors.append(walker) + self.walkers = survivors + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for index, (center, timer) in enumerate(zip(CENTERS, self.cooldowns)): + column = center // 20 + row = min(9, (30 + timer) // 10) + state[:row, column, 0] = True + state[0, column, 1] = timer == 0 + for bit in range(6): + state[index, bit, 5] = bool(timer & (1 << bit)) + for walker in self.walkers: + if 0 <= walker.x < 200 and 0 <= walker.y < 100: + row, col = int(walker.y) // 10, int(walker.x) // 20 + state[row, col, 2 if walker.friendly else 3] = True + state[row, col, 4] |= walker.struck + for bit in range(9): + state[8, bit, 5] = bool(self.steps & (1 << bit)) + state[9, self.last_action, 5] = True + return state diff --git a/runtime/minatar_synth/games/double_dunk.py b/runtime/minatar_synth/games/double_dunk.py new file mode 100644 index 0000000000000000000000000000000000000000..04c15272a6c13fe79f1fdaf22f2a06ade34c6068 --- /dev/null +++ b/runtime/minatar_synth/games/double_dunk.py @@ -0,0 +1,264 @@ +import numpy as np + + +BASKET = [1, 5] +MOVE_DELTAS = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)} + + +class DoubleDunkEnvironment: + """First-to-24 two-on-two half-court basketball game.""" + + score_cap = 24.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 300): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.player_team = [[7, 3], [4, 5]] + self.opponent_team = [[7, 7], [3, 5]] + self.previous_positions = [position.copy() for position in self.player_team + self.opponent_team] + self.possession = "player" + self.ball_handler = 0 + self.player_score = 0 + self.opponent_score = 0 + self.phase = "live" + self.jump_age = 0 + self.pass_used = False + self.shot_clock = 10 + self.lane_steps = 0 + self.cleared = True + self.block_attempt = False + self.steps = 0 + self.last_action = 0 + self.last_ball_position: list[int] | None = None + self.terminal = False + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_positions = [position.copy() for position in self.player_team + self.opponent_team] + self.last_ball_position = self._ball_position().copy() + reward = 0.0 + if self.possession == "player": + reward += self._player_offense(action) + self._computer_defense() + else: + self._player_defense(action) + self._computer_offense() + if self.phase == "jumping": + self.jump_age += 1 + self._update_violations() + self.steps += 1 + if self.steps >= self.horizon or self.player_score >= 24 or self.opponent_score >= 24: + self.terminal = True + return reward, self.terminal + + def _player_offense(self, action: int) -> float: + handler = self.player_team[self.ball_handler] + if self.phase == "jumping": + if action == 5: + return self._resolve_shot("player") + return 0.0 + if action in MOVE_DELTAS: + self._move(handler, action) + if not self.cleared and self._outside_arc(handler): + self.cleared = True + elif action == 5: + if not self.pass_used and self._distance(handler, BASKET) > 1: + self.ball_handler = 1 - self.ball_handler + self.pass_used = True + else: + self.phase = "jumping" + self.jump_age = 0 + return 0.0 + + def _player_defense(self, action: int) -> None: + defender = self.player_team[self.ball_handler] + if action in MOVE_DELTAS: + self._move(defender, action) + elif action == 5: + if self.phase == "jumping": + self.block_attempt = True + else: + self._attempt_steal() + + def _computer_defense(self) -> None: + handler = self.player_team[self.ball_handler] + defender = self.opponent_team[self.ball_handler] + if self.phase == "jumping": + return + self._step_toward(defender, handler) + + def _computer_offense(self) -> None: + handler = self.opponent_team[self.ball_handler] + defender = self.player_team[self.ball_handler] + if self.phase == "jumping": + if self.jump_age >= 1: + self._resolve_shot("opponent") + return + if not self.cleared: + target = [7, 2 if handler[1] < 5 else 8] + self._step_toward(handler, target) + if self._outside_arc(handler): + self.cleared = True + return + distance = self._distance(handler, BASKET) + if distance <= 2 or self.shot_clock <= 3: + self.phase = "jumping" + self.jump_age = 0 + else: + self._step_toward(handler, BASKET) + if self.phase == "live" and self._distance(handler, defender) == 0: + handler[1] = int(np.clip(handler[1] + (1 if handler[1] <= 5 else -1), 0, 9)) + + def _resolve_shot(self, team: str) -> float: + offense = self.player_team if team == "player" else self.opponent_team + defense = self.opponent_team if team == "player" else self.player_team + handler = offense[self.ball_handler] + defender = defense[self.ball_handler] + distance = self._distance(handler, BASKET) + if not self.cleared: + self._change_possession() + return 0.0 + points = 3 if self._outside_arc(handler) else 2 + dunk = distance <= 1 + skill = 0.82 if (self.ball_handler == 1 and distance <= 3) else 0.72 if ( + self.ball_handler == 0 and self._outside_arc(handler) + ) else 0.58 + if dunk: + skill = 0.96 + if self.jump_age > 2: + skill -= 0.35 + guard_distance = self._distance(handler, defender) + if guard_distance <= 1: + skill -= 0.25 + if self.block_attempt and guard_distance <= 2: + skill -= 0.4 + made = self.random.rand() < max(0.05, skill) + self.phase = "live" + self.jump_age = 0 + self.block_attempt = False + if made: + reward = 0.0 + if team == "player": + awarded = min(points, 24 - self.player_score) + self.player_score += awarded + reward = float(awarded) + else: + self.opponent_score = min(24, self.opponent_score + points) + self._change_possession() + return reward + self._resolve_rebound(team) + return 0.0 + + def _resolve_rebound(self, shooting_team: str) -> None: + player_inside_distance = self._distance(self.player_team[1], BASKET) + opponent_inside_distance = self._distance(self.opponent_team[1], BASKET) + player_weight = 0.65 if player_inside_distance <= opponent_inside_distance else 0.35 + player_rebound = self.random.rand() < player_weight + rebound_team = "player" if player_rebound else "opponent" + self.possession = rebound_team + self.ball_handler = 1 + self.phase = "live" + self.pass_used = True + self.shot_clock = 10 + self.lane_steps = 0 + self.cleared = rebound_team == shooting_team + + def _attempt_steal(self) -> None: + ball_carrier = self.opponent_team[self.ball_handler] + defender = self.player_team[self.ball_handler] + distance = self._distance(ball_carrier, defender) + if distance <= 1: + chance = 0.6 if self.ball_handler == 0 else 0.35 + if self.random.rand() < chance: + self._change_possession("player") + return + if distance > 1 and self.random.rand() < 0.25: + self._free_throw("opponent") + + def _free_throw(self, team: str) -> None: + made = self.random.rand() < 0.7 + if made and team == "player": + self.player_score = min(24, self.player_score + 1) + elif made: + self.opponent_score = min(24, self.opponent_score + 1) + self._change_possession("player" if team == "opponent" else "opponent") + + def _update_violations(self) -> None: + if self.phase != "live": + return + self.shot_clock -= 1 + handler = self._ball_position() + in_lane = handler[0] <= 4 and 4 <= handler[1] <= 6 + self.lane_steps = self.lane_steps + 1 if in_lane else 0 + if self.shot_clock <= 0 or self.lane_steps > 3: + self._change_possession() + + def _change_possession(self, possession: str | None = None) -> None: + self.possession = possession or ("opponent" if self.possession == "player" else "player") + self.ball_handler = 0 + self.phase = "live" + self.jump_age = 0 + self.pass_used = False + self.shot_clock = 10 + self.lane_steps = 0 + self.cleared = True + self.block_attempt = False + + def _ball_position(self) -> list[int]: + team = self.player_team if self.possession == "player" else self.opponent_team + return team[self.ball_handler] + + @staticmethod + def _move(position: list[int], action: int) -> None: + row_delta, column_delta = MOVE_DELTAS[action] + position[0] = int(np.clip(position[0] + row_delta, 1, 9)) + position[1] = int(np.clip(position[1] + column_delta, 0, 9)) + + def _step_toward(self, position: list[int], target: list[int]) -> None: + if position[0] != target[0]: + position[0] += int(np.sign(target[0] - position[0])) + elif position[1] != target[1]: + position[1] += int(np.sign(target[1] - position[1])) + + @staticmethod + def _distance(first: list[int], second: list[int]) -> int: + return abs(first[0] - second[0]) + abs(first[1] - second[1]) + + def _outside_arc(self, position: list[int]) -> bool: + return self._distance(position, BASKET) >= 6 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for position in self.player_team: + state[*position, 0] = True + for position in self.opponent_team: + state[*position, 1] = True + state[*BASKET, 2] = True + state[*self._ball_position(), 3] = True + for position in self.previous_positions: + state[*position, 4] = True + state[9 - self.player_score // 10, self.player_score % 10, 5] = True + state[6 - self.opponent_score // 10, self.opponent_score % 10, 5] = True + state[3, : self.shot_clock, 5] = True + state[2, : self.lane_steps, 5] = True + if self.phase == "jumping": + state[1, : min(10, self.jump_age + 1), 5] = True + if not self.cleared: + state[0, :3, 5] = True + return state diff --git a/runtime/minatar_synth/games/earock.py b/runtime/minatar_synth/games/earock.py new file mode 100644 index 0000000000000000000000000000000000000000..8777b33c6940d118533fed7e50a811517df8fa16 --- /dev/null +++ b/runtime/minatar_synth/games/earock.py @@ -0,0 +1,151 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Body: + x: float + y: float + vx: float = 0 + vy: float = 0 + + def accelerate(self, angle: float, amount: float) -> None: + self.vx += math.cos(angle) * amount + self.vy += math.sin(angle) * amount + + def move(self, scale: float = 1) -> None: + self.x += self.vx * scale + self.y += self.vy * scale + + def drag(self, scale: float) -> None: + self.vx *= scale + self.vy *= scale + + def toward_earth(self) -> float: + return math.atan2(50 - self.y, 50 - self.x) + + +def wrap_angle(angle: float) -> float: + return (angle + math.pi) % math.tau - math.pi + + +class EarockEnvironment: + score_cap = 15 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.spawn_timer = 0 + self.combo = 1 + self.pressed = self.terminal = False + self.angle = 0.0 + self.ship = Body(50, 20, 0.1) + self.stars: list[Body] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + changed = pressed != self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance_frame(changed and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _turn(self, speed: float) -> None: + offset = wrap_angle(self.ship.toward_earth() - self.angle) + self.angle = wrap_angle(self.angle + min(speed, max(-speed, offset))) + + def _reflect(self, normal: float) -> None: + offset = wrap_angle(self.angle + math.pi - normal) + if abs(offset) < math.pi / 2: + self.angle = wrap_angle(self.angle + math.pi - 2 * offset) + speed = math.hypot(self.ship.vx, self.ship.vy) / 2 + self.ship.vx = self.ship.vy = 0 + self.ship.accelerate(self.angle, speed) + self.combo = 1 + + def _advance_frame(self, changed: bool) -> int: + ship = self.ship + if self.pressed: + if changed: + ship.drag(0.5) + ship.accelerate(self.angle, 0.1) + ship.accelerate(self.angle, 0.01) + else: + self._turn(0.01) + if changed: + self._turn(0.2) + ship.drag(0.98) + ship.move() + if ship.x < 0 or ship.x > 99: + self._reflect(0 if ship.x < 0 else math.pi) + if ship.y < 0 or ship.y > 99: + self._reflect(math.pi / 2 if ship.y < 0 else -math.pi / 2) + if math.hypot(ship.x - 50, ship.y - 50) < 16.5: + self._reflect(ship.toward_earth() + math.pi) + + self.spawn_timer = self.spawn_timer - 1 if self.stars else -1 + if self.spawn_timer < 0: + angle = self.random.uniform(0, math.tau) + star = Body(50 + 70 * math.cos(angle), 50 + 70 * math.sin(angle)) + star.accelerate(angle + math.pi + self.random.uniform(-1, 1), 0.1) + self.stars.append(star) + self.spawn_timer = 300 + + reward = 0 + remaining = [] + for star in self.stars: + star.move() + star.drag(0.99) + star.accelerate(star.toward_earth(), 0.0002) + if math.hypot(star.x - ship.x, star.y - ship.y) < 5: + reward += self.combo + self.combo += 1 + continue + if not (-3 <= star.x < 100 and -3 <= star.y < 100): + star.move(9) + if -50 <= star.x < 100 and -50 <= star.y < 100: + self.terminal |= math.hypot(star.x - 50, star.y - 50) < 15 + remaining.append(star) + self.stars = remaining + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + ship = self.ship + points = ((ship.x, ship.y, 0), + (ship.x + 8 * math.cos(self.angle), ship.y + 8 * math.sin(self.angle), 1)) + for x, y, channel in points: + state[min(9, max(0, int(y) // 10)), min(9, max(0, int(x) // 10)), channel] = True + for row in range(10): + for col in range(10): + state[row, col, 2] = math.hypot(col * 10 + 5 - 50, row * 10 + 5 - 50) < 16.5 + for star in self.stars: + if 0 <= star.x < 100 and 0 <= star.y < 100: + state[int(star.y) // 10, int(star.x) // 10, 3] = True + else: + state[min(9, max(0, int(star.y) // 10)), min(9, max(0, int(star.x) // 10)), 4] = True + for row, value in enumerate((self.steps, self.combo, round((self.angle + math.pi) * 80))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/echo_bridge.py b/runtime/minatar_synth/games/echo_bridge.py new file mode 100644 index 0000000000000000000000000000000000000000..19a64366b7a245f6edac962a8780f02cc6744ed2 --- /dev/null +++ b/runtime/minatar_synth/games/echo_bridge.py @@ -0,0 +1,162 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass(eq=False) +class Island: + x: float + y: float + used: bool = False + + +@dataclass(eq=False) +class Bridge: + x: float + y: float + target: Island + origin: Island | None + length: float + + +class EchoBridgeEnvironment: + score_cap = 5000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = 0 + self.pressed = self.terminal = False + self.x, self.y, self.angle = 50.0, 0.0, 0.0 + self.material, self.spawn_y, self.last_x = 80.0, -10.0, 50.0 + self.island: Island | None = Island(50, 0) + self.islands = [self.island] + self.bridges: list[Bridge] = [] + self.active: Bridge | None = None + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _candidates(self): + for island in self.islands: + if island is self.island or island.used or not 0 <= island.y <= 100: + continue + dx, dy = island.x - self.x, island.y - self.y + distance = math.hypot(dx, dy) + if 0 < distance <= 4 * self.material: + yield island, dx, dy, distance + + def _advance(self, tap: bool) -> int: + self.angle = (self.angle + 0.05) % math.tau + scroll = 0.15 if self.island is not None and next(self._candidates(), None) is None else 0.05 + scroll = max(scroll, 60 - self.y) + self.y += scroll + self.spawn_y += scroll + for island in self.islands: + island.y += scroll + for bridge in self.bridges: + bridge.y += scroll + while self.spawn_y > -10: + x = self.random.uniform(0, 100) + for _ in range(9): + if abs(x - self.last_x) >= 25: + break + x = self.random.uniform(0, 100) + if abs(x - self.last_x) < 25: + x = self.random.uniform(60, 100) if self.last_x < 50 else self.random.uniform(0, 40) + self.islands.append(Island(x, self.spawn_y)) + self.last_x = x + self.spawn_y -= self.random.uniform(5, 20) + if tap: + self._build() + reward = self._walk() if self.pressed and self.active is not None else 0 + self.islands = [island for island in self.islands if island.y <= 120] + self.bridges = [bridge for bridge in self.bridges if min(bridge.y, bridge.target.y) <= 120] + if self.active not in self.bridges: + self.active = None + self.terminal = self.y >= 100 + return reward + + def _build(self) -> None: + cos, sin = math.cos(self.angle), math.sin(self.angle) + best = 0.3 + chosen = None + for island, dx, dy, distance in self._candidates(): + alignment = (dx * cos + dy * sin) / distance + if alignment > best: + best = alignment + chosen = Bridge(self.x, self.y, island, self.island, distance) + if chosen is None: + self.material = max(0, self.material - 10) + return + self.active = chosen + self.bridges.append(chosen) + chosen.target.used = True + self.material -= chosen.length * 0.25 + + def _walk(self) -> int: + bridge = self.active + dx, dy = bridge.target.x - self.x, bridge.target.y - self.y + distance = math.hypot(dx, dy) + if distance: + self.x += dx / distance * 1.5 + self.y += dy / distance * 1.5 + self.island = None + multiplier = len(self.bridges) + reward = math.floor(1.5 * multiplier) + if distance < 9.5: + self.island = bridge.target + self.x, self.y = self.island.x, self.island.y + recovery = bridge.length * 0.2 * multiplier + self.material = min(80, self.material + recovery) + if bridge.origin in self.islands: + self.islands.remove(bridge.origin) + self.bridges.remove(bridge) + self.active = None + reward += math.floor(recovery) + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + + def mark(x: float, y: float, channel: int) -> None: + if 0 <= y < 100 and 0 <= x <= 100: + state[int(y) // 10, min(9, int(x) // 10), channel] = True + + mark(self.x, self.y, 0) + for island in self.islands: + mark(island.x, island.y, 2 if island.used else 1) + for bridge in self.bridges: + for fraction in np.linspace(0, 1, 16): + mark(bridge.x + fraction * (bridge.target.x - bridge.x), + bridge.y + fraction * (bridge.target.y - bridge.y), 3) + mark(self.x + 15 * math.cos(self.angle), self.y + 15 * math.sin(self.angle), 4) + for row, value in enumerate((self.steps, round(self.material), round(self.angle * 80), len(self.bridges))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.active is not None + return state diff --git a/runtime/minatar_synth/games/elastic_hero.py b/runtime/minatar_synth/games/elastic_hero.py new file mode 100644 index 0000000000000000000000000000000000000000..9a63b78489d7535de27dbf8fd79743f04dbbe241 --- /dev/null +++ b/runtime/minatar_synth/games/elastic_hero.py @@ -0,0 +1,117 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Platform: + x: float + y: float + width: float + + +class ElasticHeroEnvironment: + score_cap = 5000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.stretch = 0 + self.pressed = self.terminal = False + self.x, self.y, self.vx, self.vy = 50.0, 130.0, 0.0, -1.0 + self.angle, self.water = 0.0, 150.0 + self._generate_platforms() + + def _generate_platforms(self) -> None: + self.platforms = [] + for y in range(110, 20, -20): + width = self.random.uniform(20, 30) + self.platforms.append(Platform(self.random.uniform(width / 2, 100 - width / 2), y, width)) + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + released = self.pressed and not pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(released and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, released: bool) -> int: + old_y = self.y + self.x += self.vx + self.y += self.vy + drag = 0.99 if self.y < self.water else 0.9 + self.vx *= drag + self.vy = (self.vy + 0.1) * drag + if self.pressed: + self.stretch = min(20, self.stretch + 1) + self.angle = (self.angle + 0.1) % math.tau + elif released: + self.vx = math.cos(self.angle) * self.stretch * 0.5 + self.vy = math.sin(self.angle) * self.stretch * 0.5 + self.stretch = 0 + + if (self.x < 3 and self.vx < 0) or (self.x > 97 and self.vx > 0): + self.vx *= -0.8 + reward = 0 + if self.y < 3: + self.y += 150 + reward = math.floor(self.water) + self.water += 150 + self._generate_platforms() + old_y = self.y + if self.y > 147 and self.vy > 0: + self.vy *= -0.8 + self.water -= 0.1 + max(0, self.water - 140) * 0.05 + for platform in self.platforms: + if abs(self.x - platform.x) > platform.width / 2 + 5: + continue + top, bottom = platform.y - 6.5, platform.y + 6.5 + if self.vy > 0 and old_y <= top <= self.y: + self.y, self.vy = top, self.vy * -0.8 + elif self.vy < 0 and self.y <= bottom <= old_y: + self.y, self.vy = bottom, self.vy * -0.8 + self.terminal = self.water < 0 + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + + def mark(x: float, y: float, channel: int) -> None: + state[min(9, max(0, int(y) // 15)), min(9, max(0, int(x) // 10)), channel] = True + + mark(self.x, self.y, 0) + for platform in self.platforms: + for x in np.linspace(platform.x - platform.width / 2, platform.x + platform.width / 2, 9): + mark(x, platform.y, 1) + for row in range(10): + state[row, :, 2] = row * 15 + 7.5 >= self.water + for radius in (self.stretch / 2, self.stretch): + mark(self.x + radius * math.cos(self.angle), self.y + radius * math.sin(self.angle), 3) + state[:, (0, 9), 4] = True + state[9, :, 4] = True + for row, value in enumerate((self.steps, self.stretch, round(self.angle * 80), + round(self.water), round(self.vx * 10) + 256, round(self.vy * 10) + 256)): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/embattled.py b/runtime/minatar_synth/games/embattled.py new file mode 100644 index 0000000000000000000000000000000000000000..6b8bd81cc1cd6941751f6f6af0e13461b8b5cdad --- /dev/null +++ b/runtime/minatar_synth/games/embattled.py @@ -0,0 +1,162 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Tank: + x: float + y: float + side: int + heading: float + turret: float + timer: float + interval: float + + +@dataclass +class Bullet: + x: float + y: float + angle: float + side: int + + +def turn(angle: float, target: float, rate: float) -> float: + offset = (target - angle + math.pi) % math.tau - math.pi + return angle + min(rate, max(-rate, offset)) + + +class EmbattledEnvironment: + score_cap = 250 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.frame = self.held = self.side = self.side_count = 0 + self.pressed = self.terminal = False + self.y, self.direction, self.multiplier = 30.0, 1, 1 + self.spawn_timer = 0.0 + self.tanks: list[Tank] = [] + self.bullets: list[Bullet] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap: bool) -> int: + if tap or self.y < 3 and self.direction < 0 or self.y > 97 and self.direction > 0: + self.direction *= -1 + self.held = self.held + 1 if self.pressed else 0 + if not self.pressed: + self.y += self.direction * 0.5 + shield = self.held > 10 + pace = 2 if shield else 1 + live_bullets = [] + for bullet in self.bullets: + bullet.x += math.cos(bullet.angle) * 0.5 * pace + bullet.y += math.sin(bullet.angle) * 0.5 * pace + dx, dy = abs(bullet.x - 50), abs(bullet.y - self.y) + if shield and dx < 8 and dy < 9: + continue + self.terminal |= dx < 4 and dy < 4 + if -5 <= bullet.x <= 105 and -5 <= bullet.y <= 105: + live_bullets.append(bullet) + self.bullets = live_bullets + + self.spawn_timer = self.spawn_timer - pace if self.tanks else -1 + if self.spawn_timer < 0: + self._spawn() + for tank in self.tanks: + self._move_tank(tank, shield, pace) + + reward = 0 + survivors = [] + for tank in self.tanks: + hit = next((bullet for bullet in self.bullets if bullet.side != tank.side + and math.hypot(bullet.x - tank.x, bullet.y - tank.y) < 4), None) + if hit is not None: + self.bullets.remove(hit) + reward += self.multiplier + self.multiplier += 1 + else: + self.terminal |= abs(tank.x - 50) < 4 and abs(tank.y - self.y) < 4 + if -5 <= tank.x <= 105 and -5 <= tank.y <= 105: + survivors.append(tank) + self.tanks = survivors + if self.frame % 60 == 0: + self.multiplier = max(1, self.multiplier - 1) + self.frame += 1 + return reward + + def _spawn(self) -> None: + side = self.side + self.side_count -= 1 + if self.side_count <= 0: + self.side = 1 - self.side + self.side_count = int(self.random.integers(1, 4)) + x, y = (-5 if side == 0 else 105), self.random.uniform(0, 99) + angle = math.atan2(self.y - y, 50 - x) + interval = self.random.uniform(300, 400) + self.tanks.append(Tank(x, y, side, angle, angle, self.random.uniform(0, interval), interval)) + self.spawn_timer = self.random.uniform(60, 80) + + def _move_tank(self, tank: Tank, shield: bool, pace: int) -> None: + target = (50, self.y) if shield else None + distance = math.hypot(50 - tank.x, self.y - tank.y) if shield else 99 + for other in self.tanks: + if tank.side != other.side: + candidate = math.hypot(other.x - tank.x, other.y - tank.y) + if candidate < distance: + target, distance = (other.x, other.y), candidate + if target is not None: + angle = math.atan2(target[1] - tank.y, target[0] - tank.x) + tank.heading = turn(tank.heading, angle, 0.02) + tank.turret = turn(tank.turret, angle, 0.03 * pace) + tank.x += math.cos(tank.heading) * 0.02 * pace + tank.y += math.sin(tank.heading) * 0.02 * pace + tank.timer -= pace + if tank.timer < 0: + self.bullets.append(Bullet(tank.x, tank.y, tank.turret, tank.side)) + tank.timer = tank.interval + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row = int(self.y) // 10 + state[row, 5, 0] = True + if self.held > 10: + state[max(0, row - 1):row + 2, 4:6, 1] = True + for tank in self.tanks: + if 0 <= tank.x < 100 and 0 <= tank.y < 100: + state[int(tank.y) // 10, int(tank.x) // 10, 2 + tank.side] = True + for bullet in self.bullets: + if 0 <= bullet.x < 100 and 0 <= bullet.y < 100: + state[int(bullet.y) // 10, int(bullet.x) // 10, 4] = True + for row, value in enumerate((self.steps, self.multiplier, min(self.held, 11))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.direction > 0 + return state diff --git a/runtime/minatar_synth/games/enduro.py b/runtime/minatar_synth/games/enduro.py new file mode 100644 index 0000000000000000000000000000000000000000..aa049dfcda5e93ddfb46e01b1d0cc720df074084 --- /dev/null +++ b/runtime/minatar_synth/games/enduro.py @@ -0,0 +1,173 @@ +import math + +import numpy as np + + +class EnduroEnvironment: + """Five-day endurance race with traffic quotas and changing visibility.""" + + score_cap = 1_750.0 + + def __init__(self, sticky_action_prob: float = 0.1, day_length: int = 350): + self.sticky_action_prob = sticky_action_prob + self.day_length = day_length + self.horizon = day_length * 5 + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.player = [8, 5] + self.previous_player = self.player.copy() + self.speed = 0 + self.day = 1 + self.day_step = 0 + self.steps = 0 + self.passed = 0 + self.remaining_quota = 200 + self.traffic: list[dict[str, object]] = [] + self.previous_traffic: list[list[int]] = [] + self.last_action = 0 + self.terminal = False + self.collision = False + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + self.previous_traffic = [list(car["position"]) for car in self.traffic] + self.collision = False + self._apply_action(action) + self._spawn_traffic() + reward = self._move_traffic() + self._resolve_collisions() + self.day_step += 1 + self.steps += 1 + if self.day_step >= self.day_length: + self._finish_day() + return reward, self.terminal + + def _apply_action(self, action: int) -> None: + if action == 5: + self.speed = min(5, self.speed + 1) + elif action == 4: + self.speed = max(0, self.speed - 1) + elif action in (1, 3): + if self.weather == "ice" and self.day_step % 2: + return + self.player[1] += -1 if action == 1 else 1 + left, right = self.road_bounds(8) + self.player[1] = int(np.clip(self.player[1], left, right)) + + def _spawn_traffic(self) -> None: + if self.speed == 0: + return + interval = max(1, 6 - self.speed) + if self.day_step % interval: + return + left, right = self.road_bounds(0) + occupied = {car["position"][1] for car in self.traffic if car["position"][0] <= 1} + lanes = [column for column in range(left, right + 1) if column not in occupied] + if not lanes: + return + self.traffic.append( + { + "position": [0, int(self.random.choice(lanes))], + "speed": 1 + int(self.random.randint(2)), + } + ) + + def _move_traffic(self) -> float: + reward = 0.0 + survivors = [] + relative_speed = max(0, self.speed - 1) + for car in self.traffic: + movement = max(0, relative_speed - int(car["speed"]) + 1) + car["position"][0] += movement + row = min(9, car["position"][0]) + left, right = self.road_bounds(row) + car["position"][1] = int(np.clip(car["position"][1], left, right)) + if car["position"][0] > 9: + reward += 1.0 + self.passed += 1 + self.remaining_quota = max(0, self.remaining_quota - 1) + else: + survivors.append(car) + self.traffic = survivors + return reward + + def _resolve_collisions(self) -> None: + collided = [car for car in self.traffic if car["position"] == self.player] + if not collided: + return + self.collision = True + self.speed = 1 + collided_ids = {id(car) for car in collided} + self.traffic = [car for car in self.traffic if id(car) not in collided_ids] + + def _finish_day(self) -> None: + if self.remaining_quota > 0 or self.day == 5: + self.terminal = True + return + self.day += 1 + self.day_step = 0 + self.remaining_quota = 300 + self.traffic = [] + + @property + def weather(self) -> str: + if self.day_step < 50: + return "dawn" + if self.day_step < 150: + return "day" + if self.day_step < 220: + return "ice" + if self.day_step < 280: + return "fog" + return "night" + + def road_bounds(self, row: int) -> tuple[int, int]: + phase = (self.day_step + (9 - row) * 4) / 24.0 + center = 5 + int(round(2 * math.sin(phase))) + return max(0, center - 3), min(9, center + 3) + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + for row in range(10): + left, right = self.road_bounds(row) + state[row, left : right + 1, 2] = True + for car in self.traffic: + position = car["position"] + visible = self.weather not in ("fog", "night") or position[0] >= 4 + if visible: + state[*position, 1] = True + if self.weather not in ("fog", "night"): + state[*position, 2] = True + else: + state[position[0], position[1], 3] = visible + state[*self.previous_player, 4] = True + for position in self.previous_traffic: + visible = self.weather not in ("fog", "night") or position[0] >= 4 + if visible and 0 <= position[0] < 10: + state[*position, 4] = True + state[9, : self.speed, 5] = True + state[8, : self.day, 5] = True + weather_index = ("dawn", "day", "ice", "fog", "night").index(self.weather) + state[7, : weather_index + 1, 5] = True + for bit in range(9): + if self.remaining_quota & (1 << bit): + state[6, bit, 5] = True + if self.collision: + state[5, :3, 5] = True + return state diff --git a/runtime/minatar_synth/games/fall_bounce.py b/runtime/minatar_synth/games/fall_bounce.py new file mode 100644 index 0000000000000000000000000000000000000000..18a22b9a6c7e6d6af01f03ce378c1e5582fe10b9 --- /dev/null +++ b/runtime/minatar_synth/games/fall_bounce.py @@ -0,0 +1,99 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 + + +@dataclass +class Platform: + x: float + y: float + width: float + + +class FallBounceEnvironment: + score_cap = 1000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.spawn_timer = 0 + self.pressed = self.bouncing = self.terminal = False + self.x, self.y = 50.0, 10.0 + self.platforms: list[Platform] = [] + self._spawn_pair() + + def _spawn_pair(self) -> None: + for _ in range(2): + self.platforms.append(Platform(self.random.uniform(0, 85), -5, self.random.uniform(15, 35))) + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0.0 + for _ in range(FRAMES_PER_STEP): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return reward, self.terminal + + def _advance(self) -> float: + if self.bouncing: + self.y += (10 - self.y) * 0.2 + self.bouncing = abs(10 - self.y) >= 1 + else: + self.y += 1.5 if self.pressed else 0.25 + self.x = (self.x + 1) % 100 + if self.y > 103: + self.terminal = True + return 0.0 + + self.spawn_timer -= 1 + if self.spawn_timer < 0: + self._spawn_pair() + self.spawn_timer = math.ceil(self.random.uniform(40, 60)) + reward = 0.0 + for platform in self.platforms: + platform.y += 1 + if (self.pressed and not self.bouncing and abs(platform.y - self.y) < 4 + and abs(platform.x - self.x) < platform.width / 2 + 5): + self.bouncing = True + reward = self.y - 10 + self.platforms = [platform for platform in self.platforms if platform.y < 103] + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row, col = min(9, int(self.y) // 10), int(self.x) // 10 + state[row, col, 0] = True + state[row, col, 2] = self.bouncing + state[row, col, 3] = self.pressed + for platform in self.platforms: + if 0 <= platform.y < 100: + left = max(0, math.floor((platform.x - platform.width / 2) / 10)) + right = min(10, math.ceil((platform.x + platform.width / 2) / 10)) + state[int(platform.y) // 10, left:right, 1] = True + state[9, :, 4] = True + for row, value in enumerate((self.steps, self.spawn_timer, round(self.y * 4))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/feeding_frenzy.py b/runtime/minatar_synth/games/feeding_frenzy.py new file mode 100644 index 0000000000000000000000000000000000000000..bed68430abaa34be75a159ff24e09413f2861203 --- /dev/null +++ b/runtime/minatar_synth/games/feeding_frenzy.py @@ -0,0 +1,122 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +RADIUS = 45 +HORIZON = 400 + + +@dataclass +class Fish: + x: float + y: float + angle: float + speed: float + + +class FeedingFrenzyEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = 0 + self.spawn_timer = 0.0 + self.multiplier = 1 + self.x, self.y, self.angle = 95.0, 50.0, 0.0 + self.pressed = self.darting = self.terminal = False + self.fish: list[Fish] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap: bool) -> int: + if self.darting: + if self.pressed: + self.angle = (self.angle - 0.1) % math.tau + self.x += 3.9 * math.cos(self.angle) + self.y += 3.9 * math.sin(self.angle) + distance = math.hypot(self.x - 50, self.y - 50) + if distance > RADIUS: + self.darting = False + self.x = 50 + (self.x - 50) * RADIUS / distance + self.y = 50 + (self.y - 50) * RADIUS / distance + else: + radial = math.atan2(self.y - 50, self.x - 50) - 0.7 / RADIUS + self.x = 50 + RADIUS * math.cos(radial) + self.y = 50 + RADIUS * math.sin(radial) + self.angle = (radial - math.pi / 2) % math.tau + if tap: + self.darting = True + self.angle = (self.angle - 0.5) % math.tau + self.multiplier = 1 + + self.spawn_timer -= 1 + if self.spawn_timer < 0: + angle = self.random.uniform(0, math.tau) + radius = self.random.uniform(0, 36) + self.fish.append(Fish(50 + radius * math.cos(angle), 50 + radius * math.sin(angle), + angle + math.pi + self.random.uniform(-1, 1), + self.random.uniform(0.03, 0.05))) + self.spawn_timer = 10 * math.sqrt(len(self.fish)) + reward = 0 + remaining = [] + for fish in self.fish: + speed = fish.speed * (2.5 if self.darting else 1) + if math.hypot(fish.x - 50, fish.y - 50) > RADIUS * 1.1: + speed *= 4 + fish.x += speed * math.cos(fish.angle) + fish.y += speed * math.sin(fish.angle) + if math.hypot(fish.x - self.x, fish.y - self.y) < 6: + reward += self.multiplier + self.multiplier += 1 + elif 0 <= fish.x < 100 and 0 <= fish.y < 100: + remaining.append(fish) + else: + self.terminal = True + self.fish = remaining + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row, col = int(self.y) // 10, int(self.x) // 10 + state[row, col, 0] = True + state[row, col, 4] = self.darting + for fish in self.fish: + state[int(fish.y) // 10, int(fish.x) // 10, 1] = True + for row in range(10): + for col in range(10): + state[row, col, 2] = abs(math.hypot(10 * col - 45, 10 * row - 45) - RADIUS) < 6 + x = min(99, max(0, self.x + 8 * math.cos(self.angle))) + y = min(99, max(0, self.y + 8 * math.sin(self.angle))) + state[int(y) // 10, int(x) // 10, 3] = True + for row, value in enumerate((self.steps, self.multiplier, round(self.angle * 80))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/find_a_star.py b/runtime/minatar_synth/games/find_a_star.py new file mode 100644 index 0000000000000000000000000000000000000000..cbb32f1d92cda93ccae186f260ca96e5ae8a44a4 --- /dev/null +++ b/runtime/minatar_synth/games/find_a_star.py @@ -0,0 +1,125 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class BoxLine: + y: float + secret: int + low: int = 0 + high: int = 15 + + +@dataclass +class Star: + y: float + column: int + score: int + timer: int = 32 + velocity: float = 1 + + +class FindAStarEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.last_action = 0 + self.cursor = 7 + self.scroll_boost = self.spawn_distance = 0.0 + self.terminal = False + self.lines: list[BoxLine] = [] + self.stars: list[Star] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + tap = action == 5 and self.last_action != 5 + self.last_action = action + self.steps += 1 + if action in (1, 4): + self.cursor = min(15, max(0, self.cursor + (-1 if action == 1 else 1))) + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap: bool) -> int: + if tap: + self.scroll_boost += 2 + scroll = 0.06 + self.scroll_boost + self.scroll_boost *= 0.07 + self.spawn_distance -= scroll + if self.spawn_distance < 0: + self.lines.append(BoxLine(-3, int(self.random.integers(16)))) + self.spawn_distance += 10 + + remaining = [] + combo = 1 + for index, line in enumerate(self.lines, 1): + if line.y < 9: + line.y += (9 - line.y) * 0.2 + elif tap: + if self.cursor == line.secret: + self.stars.append(Star(line.y, self.cursor, index**2 * combo)) + combo += 1 + continue + if self.cursor < line.secret: + line.low = max(line.low, self.cursor + 1) + else: + line.high = min(line.high, self.cursor - 1) + line.y += scroll + self.terminal |= line.y > 97 + remaining.append(line) + self.lines = remaining + if not self.lines: + self.spawn_distance = 0 + + reward = 0 + active = [] + for star in self.stars: + star.y += star.velocity + star.velocity *= 0.9 + star.timer -= 1 + if star.timer: + active.append(star) + else: + reward += star.score + self.stars = active + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for line in self.lines: + if 0 <= line.y < 100: + row = int(line.y) // 10 + for column in range(16): + half, slot = divmod(column, 8) + state[row, slot, 2 * half + int(not line.low <= column <= line.high)] = True + for star in self.stars: + if 0 <= star.y < 100: + state[int(star.y) // 10, star.column // 2, 4] = True + half, slot = divmod(self.cursor, 8) + state[half, slot, 5] = True + for bit in range(9): + state[9, bit, 5] = bool(self.steps & (1 << bit)) + state[8, 9, 5] = self.last_action == 5 + return state diff --git a/runtime/minatar_synth/games/fish_grill.py b/runtime/minatar_synth/games/fish_grill.py new file mode 100644 index 0000000000000000000000000000000000000000..9b196b82c441bf93e2246725f96333c25e52c24b --- /dev/null +++ b/runtime/minatar_synth/games/fish_grill.py @@ -0,0 +1,109 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +EMBER_X = 20 + + +@dataclass +class Fish: + x: float + y: float + width: float + burned: bool = False + + +@dataclass +class Updraft: + y: float + timer: int = 10 + + +class FishGrillEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = 0 + self.pressed = self.terminal = False + self.y, self.velocity = 50.0, 0.0 + self.energy = self.base_energy = 100.0 + self.fish = [Fish(100, 50, 15)] + self.updrafts: list[Updraft] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self) -> int: + self.velocity += 0.1 + self.y += self.velocity + self.base_energy += 0.1 + self.energy += (self.base_energy - self.energy) * 0.01 + radius = 1 + self.energy / 50 + if self.pressed: + self.velocity = -1 + self.updrafts.append(Updraft(self.y + radius)) + for updraft in self.updrafts: + updraft.timer -= 1 + self.updrafts = [updraft for updraft in self.updrafts if updraft.timer > 0] + + reward = 0 + for fish in self.fish: + fish.x -= 1 + horizontal_gap = abs(fish.x - EMBER_X) - fish.width / 2 + if horizontal_gap <= 3 and any(abs(fish.y - updraft.y - 2.5) <= 6 for updraft in self.updrafts): + self.energy += 5 + reward += math.floor(self.energy / (100 if fish.burned else 10)) + fish.burned = True + distance = math.hypot(max(0, horizontal_gap), max(0, abs(fish.y - self.y) - 3)) + self.terminal |= distance <= radius + 1.5 + self.fish = [fish for fish in self.fish if fish.x + fish.width >= 0] + if self.fish[-1].x < 100: + self.fish.append(Fish(self.fish[-1].x + self.random.uniform(50, 80), + self.random.uniform(10, 90), self.random.uniform(10, 20))) + self.terminal |= not -radius <= self.y <= 100 + radius + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row = min(9, max(0, int(self.y) // 10)) + state[row, 2, 0] = True + state[row, 2, 4] = self.velocity < 0 + for fish in self.fish: + left = max(0, math.floor((fish.x - fish.width / 2) / 10)) + right = min(10, math.ceil((fish.x + fish.width / 2) / 10)) + if left < right: + state[int(fish.y) // 10, left:right, 2 if fish.burned else 1] = True + for updraft in self.updrafts: + if 0 <= updraft.y < 100: + state[int(updraft.y) // 10, 2, 3] = True + for row, value in enumerate((self.steps, round(self.energy), round(self.velocity * 10) + 128)): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/fishing_derby.py b/runtime/minatar_synth/games/fishing_derby.py new file mode 100644 index 0000000000000000000000000000000000000000..1a23ab5939c633ec63015a13cc3d7f83cd7f2370 --- /dev/null +++ b/runtime/minatar_synth/games/fishing_derby.py @@ -0,0 +1,219 @@ +import numpy as np + + +class FishingDerbyEnvironment: + """Race-to-99 fishing duel with depth values and shark interception.""" + + score_cap = 99.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 600): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.player_line = [2, 1] + self.computer_line = [2, 8] + self.previous_player_line = self.player_line.copy() + self.previous_fish: list[list[int]] = [] + self.previous_hook_positions: dict[str, list[int]] = {} + self.player_score = 0 + self.computer_score = 0 + self.player_hook: dict[str, object] | None = None + self.computer_hook: dict[str, object] | None = None + self.fish = [] + for index, row in enumerate(range(2, 8)): + origin = "left" if index % 2 == 0 else "right" + self.fish.append( + { + "position": [row, 0 if origin == "left" else 9], + "direction": 1 if origin == "left" else -1, + "origin": origin, + "spawn_row": row, + "value": 2 if row <= 3 else 4 if row <= 5 else 6, + "hooked": None, + } + ) + self.shark = [1, 5] + self.shark_direction = 1 + self.steps = 0 + self.last_action = 0 + self.terminal = False + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player_line = self.player_line.copy() + self.previous_fish = [list(fish["position"]) for fish in self.fish] + self.previous_hook_positions = {} + if self.player_hook is not None: + self.previous_hook_positions["player"] = list(self.player_hook["position"]) + if self.computer_hook is not None: + self.previous_hook_positions["computer"] = list(self.computer_hook["position"]) + self._move_player_line(action) + self._move_computer_line() + self._move_free_fish() + self._move_shark() + self._hook_fish() + reward = self._resolve_catches() + self.steps += 1 + if self.steps >= self.horizon or self.player_score >= 99 or self.computer_score >= 99: + self.terminal = True + return reward, self.terminal + + def _move_player_line(self, action: int) -> None: + if self.player_hook is None: + if action == 1: + self.player_line[1] = max(0, self.player_line[1] - 1) + elif action == 2: + self.player_line[0] = max(2, self.player_line[0] - 1) + elif action == 3: + self.player_line[1] = min(9, self.player_line[1] + 1) + elif action == 4: + self.player_line[0] = min(7, self.player_line[0] + 1) + return + self._move_hooked_line(self.player_line, self.player_hook, action) + + def _move_computer_line(self) -> None: + if self.computer_hook is not None: + action = 5 + if self.computer_hook["position"][0] <= 2 and self.computer_hook["position"][1] == self.shark[1]: + action = 1 if self.computer_line[1] > 0 else 3 + self._move_hooked_line(self.computer_line, self.computer_hook, action) + return + if self.player_hook is not None: + return + available = [fish for fish in self.fish if fish["hooked"] is None] + if not available: + return + target = max(available, key=lambda fish: (int(fish["value"]), -abs(fish["position"][1] - 8))) + if self.computer_line[0] < target["position"][0]: + self.computer_line[0] += 1 + elif self.computer_line[0] > target["position"][0]: + self.computer_line[0] -= 1 + elif self.computer_line[1] < target["position"][1]: + self.computer_line[1] += 1 + elif self.computer_line[1] > target["position"][1]: + self.computer_line[1] -= 1 + + @staticmethod + def _move_hooked_line(line: list[int], fish: dict[str, object], action: int) -> None: + line[0] -= 2 if action == 5 else 1 + if action == 1: + line[1] = max(0, line[1] - 1) + elif action == 2: + line[0] -= 1 + elif action == 3: + line[1] = min(9, line[1] + 1) + elif action == 4: + line[0] += 1 + fish["position"] = line.copy() + + def _move_free_fish(self) -> None: + for fish in self.fish: + if fish["hooked"] is not None: + continue + fish["position"][1] += int(fish["direction"]) + if fish["position"][1] < 0 or fish["position"][1] > 9: + fish["position"][1] %= 10 + + def _move_shark(self) -> None: + if self.random.rand() < 0.15: + self.shark_direction *= -1 + self.shark[1] += self.shark_direction + if self.shark[1] <= 0 or self.shark[1] >= 9: + self.shark_direction *= -1 + self.shark[1] = int(np.clip(self.shark[1], 0, 9)) + + def _hook_fish(self) -> None: + if self.player_hook is not None or self.computer_hook is not None: + return + player_fish = next( + (fish for fish in self.fish if fish["hooked"] is None and fish["position"] == self.player_line), + None, + ) + if player_fish is not None: + player_fish["hooked"] = "player" + self.player_hook = player_fish + return + computer_fish = next( + (fish for fish in self.fish if fish["hooked"] is None and fish["position"] == self.computer_line), + None, + ) + if computer_fish is not None: + computer_fish["hooked"] = "computer" + self.computer_hook = computer_fish + + def _resolve_catches(self) -> float: + reward = 0.0 + for owner in ("player", "computer"): + fish = self.player_hook if owner == "player" else self.computer_hook + if fish is None: + continue + previous = self.previous_hook_positions.get(owner, list(fish["position"])) + crossed_shark = ( + previous[0] >= self.shark[0] >= fish["position"][0] + and self.shark[1] in (previous[1], fish["position"][1]) + ) + if fish["position"] == self.shark or crossed_shark: + self._respawn_fish(fish) + if owner == "player": + self.player_hook = None + else: + self.computer_hook = None + continue + if fish["position"][0] > 0: + continue + value = int(fish["value"]) + if owner == "player": + awarded = min(value, 99 - self.player_score) + self.player_score += awarded + reward += float(awarded) + self.player_hook = None + self.player_line = [2, 1] + else: + self.computer_score = min(99, self.computer_score + value) + self.computer_hook = None + self.computer_line = [2, 8] + self._respawn_fish(fish) + return reward + + @staticmethod + def _respawn_fish(fish: dict[str, object]) -> None: + fish["position"] = [int(fish["spawn_row"]), 0 if fish["origin"] == "left" else 9] + fish["direction"] = 1 if fish["origin"] == "left" else -1 + fish["hooked"] = None + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player_line, 0] = True + state[*self.shark, 1] = True + for fish in self.fish: + state[*fish["position"], 2] = True + if fish["hooked"] is not None: + state[*fish["position"], 3] = True + state[*self.computer_line, 3] = True + state[*self.previous_player_line, 4] = True + for position in self.previous_fish: + if 0 <= position[0] < 10: + state[*position, 4] = True + for bit in range(7): + if self.player_score & (1 << bit): + state[9, bit, 5] = True + if self.computer_score & (1 << bit): + state[8, bit, 5] = True + if self.player_hook is not None: + state[7, : int(self.player_hook["value"]), 5] = True + return state diff --git a/runtime/minatar_synth/games/flip_o.py b/runtime/minatar_synth/games/flip_o.py new file mode 100644 index 0000000000000000000000000000000000000000..d4f59341a1ddea3b43cdf859066e1e78cca53668 --- /dev/null +++ b/runtime/minatar_synth/games/flip_o.py @@ -0,0 +1,177 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Ball: + x: float = 80 + y: float = 10 + vx: float = 1 + vy: float = 0 + combo: int = 1 + + +@dataclass +class Block: + x: float + y: float + extra_ball: bool + + +@dataclass +class Bar: + x: float + y: float + angle: float + length: float + + def touches(self, x: float, y: float, radius: float) -> bool: + cos, sin = math.cos(self.angle), math.sin(self.angle) + dx, dy = x - self.x, y - self.y + along = min(self.length, max(0, dx * cos + dy * sin)) + return math.hypot(dx - along * cos, dy - along * sin) < radius + + def bounce(self, ball: Ball, boost: bool = False) -> None: + nx, ny = -math.sin(self.angle), math.cos(self.angle) + if ny > 0: + nx, ny = -nx, -ny + inward = ball.vx * nx + ball.vy * ny + if inward < 0: + ball.vx -= 1.7 * inward * nx + ball.vy -= 1.7 * inward * ny + if boost: + ball.vy -= 4 + ball.combo = 1 + for _ in range(8): + if not self.touches(ball.x, ball.y, 3.5): + break + ball.x += nx + ball.y += ny + + +RAMPS = (Bar(7, 75, 0.5, 25), Bar(94, 75, math.pi - 0.5, 25)) + + +class FlipOEnvironment: + score_cap = 1000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = 0 + self.pressed = self.flipped = self.terminal = False + self.next_block = 0.0 + self.balls = [Ball()] + self.blocks: list[Block] = [] + + def _flippers(self) -> tuple[Bar, Bar]: + angle = -0.5 if self.flipped else 0.5 + return Bar(33, 88, angle, 12), Bar(68, 88, math.pi + angle, 12) + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap: bool) -> int: + deepest = max((block.y for block in self.blocks), default=0) + scroll = (30 - deepest) * 0.1 if deepest < 29 else 0.02 + if tap: + scroll += 0.3 * len(self.balls) + self.flipped = not self.flipped + flippers = self._flippers() + bars = RAMPS + flippers + for block in self.blocks: + block.y += scroll + if any(bar.touches(block.x, block.y, 6) for bar in bars): + self.terminal = True + + reward = 0 + count = len(self.balls) + spawned = [] + for ball in self.balls: + previous_y = ball.y + scroll + ball.vy = (ball.vy + 0.1) * 0.99 + ball.vx *= 0.99 + ball.x += ball.vx * 0.5 + ball.y = previous_y + ball.vy * 0.5 + if ball.x < 7 or ball.x > 93: + ball.x = min(93, max(7, ball.x)) + ball.vx *= -0.7 + if ball.y < 7: + ball.y, ball.vy = 7, abs(ball.vy) * 0.7 + survivors = [] + for block in self.blocks: + if abs(block.x - ball.x) < 6.5 and abs(block.y - ball.y) < 4.5: + reward += ball.combo * count + ball.combo += 1 + if abs(previous_y - block.y) >= 4.5: + ball.vy *= -0.7 + else: + ball.vx *= -0.7 + if block.extra_ball: + spawned.append(Ball(block.x, block.y)) + else: + survivors.append(block) + self.blocks = survivors + for bar in RAMPS: + if bar.touches(ball.x, ball.y, 3.5): + bar.bounce(ball) + for bar in flippers: + if bar.touches(ball.x, ball.y, 3.5): + bar.bounce(ball, boost=tap) + self.balls = [ball for ball in self.balls if ball.y <= 101] + spawned + self.terminal |= not self.balls + if self.balls: + self._spawn(scroll) + return reward + + def _spawn(self, scroll: float) -> None: + self.next_block -= scroll + while self.next_block < 0: + for offset in (5, 15, 25, 35): + if self.random.random() < 0.5: + for x in (50 - offset, 50 + offset): + self.blocks.append(Block(x, -self.next_block, self.random.random() < 0.1 / len(self.balls))) + self.next_block += 6 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for ball in self.balls: + if 0 <= ball.y < 100: + state[int(ball.y) // 10, int(ball.x) // 10, 0] = True + for block in self.blocks: + if 0 <= block.y < 100: + state[int(block.y) // 10, int(block.x) // 10, 2 if block.extra_ball else 1] = True + for index, bar in enumerate(RAMPS + self._flippers()): + for distance in np.linspace(0, bar.length, 10): + x, y = bar.x + distance * math.cos(bar.angle), bar.y + distance * math.sin(bar.angle) + state[int(y) // 10, int(x) // 10, 3 + int(index >= 2)] = True + for row, value in enumerate((self.steps, len(self.balls))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.flipped, self.pressed + return state diff --git a/runtime/minatar_synth/games/flipbomb.py b/runtime/minatar_synth/games/flipbomb.py new file mode 100644 index 0000000000000000000000000000000000000000..ce778100dc96e91a6a92338b8d2ecf521c4bd8c2 --- /dev/null +++ b/runtime/minatar_synth/games/flipbomb.py @@ -0,0 +1,155 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Body: + x: float + y: float + vx: float + vy: float + launched: bool = False + + def move(self) -> None: + self.x += self.vx + self.y += self.vy + + +@dataclass +class Explosion: + x: float + y: float + angle: float + age: int = 0 + + def lobes(self): + radius = self.age * 0.5 if self.age < 20 else 30 - self.age + half_width = 5 if not self.age else (radius + 3) / 2 + for index in range(5): + angle = self.angle + index * math.tau / 5 + yield self.x + radius * math.cos(angle), self.y + radius * math.sin(angle), half_width + + +class FlipbombEnvironment: + score_cap = 250 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.ball_timer = 0 + self.bomb_timer = 0.0 + self.multiplier = 1 + self.pressed = self.terminal = False + self.balls: list[Body] = [] + self.bombs: list[Body] = [] + self.explosions: list[Explosion] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap: bool) -> int: + if tap: + self.multiplier = 1 + lobes = [lobe for explosion in self.explosions for lobe in explosion.lobes()] + for explosion in self.explosions: + explosion.age += 1 + explosion.angle += 0.2 + self.explosions = [explosion for explosion in self.explosions if explosion.age < 30] + self.ball_timer -= 1 + if self.ball_timer < 0: + self.balls.append(Body(99, 70, -1, 0.5)) + self.ball_timer = 60 + balls = [] + for ball in self.balls: + ball.move() + if tap and not ball.launched and ball.x < 70: + angle = (ball.x - 70) * 0.06 + ball.vx = 2 * math.cos(angle) + 4 * math.sin(angle) + ball.vy = 2 * math.sin(angle) - 4 * math.cos(angle) + ball.launched = True + if 0 <= ball.x < 99 and 0 <= ball.y < 99 and not self._blast_hit(ball, lobes, 1.5): + balls.append(ball) + self.balls = balls + + self.bomb_timer -= 1 + if self.bomb_timer < 0: + x = self.random.uniform(0, 80) + self.bombs.append(Body(x, 0, (self.random.uniform(20, 70) - x) / 500, 0.14)) + self.bomb_timer += self.random.uniform(30, 50) + + reward = 0 + bombs = [] + for bomb in self.bombs: + bomb.move() + if self._blast_hit(bomb, lobes, 2.5) or any( + ball.launched and abs(ball.x - bomb.x) < 4 and abs(ball.y - bomb.y) < 4 + for ball in self.balls + ): + self.explosions.append(Explosion(bomb.x, bomb.y, self.random.uniform(-math.pi, math.pi))) + reward += self.multiplier + self.multiplier += 1 + elif bomb.y > 99 or any( + not ball.launched and abs(ball.x - bomb.x) < 4 and abs(ball.y - bomb.y) < 4 + for ball in self.balls + ) or self._hits_ramp(bomb, tap): + self.terminal = True + else: + bombs.append(bomb) + self.bombs = bombs + return reward + + @staticmethod + def _blast_hit(body: Body, lobes: list[tuple[float, float, float]], margin: float) -> bool: + return any(abs(body.x - x) < radius + margin and abs(body.y - y) < radius + margin + for x, y, radius in lobes) + + @staticmethod + def _hits_ramp(bomb: Body, tap: bool) -> bool: + return ( + 72 <= bomb.x <= 102 and abs(bomb.y - (75 + (99 - bomb.x) * 11 / 24)) < 3 + or 47 <= bomb.x <= 73 and abs(bomb.y - (89 + (70 - bomb.x) * (-0.45 if tap else 0.45))) < 3 + ) + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for ball in self.balls: + state[int(ball.y) // 10, int(ball.x) // 10, int(ball.launched)] = True + for bomb in self.bombs: + if 0 <= bomb.x < 100 and 0 <= bomb.y < 100: + state[int(bomb.y) // 10, int(bomb.x) // 10, 2] = True + for explosion in self.explosions: + for x, y, _ in explosion.lobes(): + if 0 <= x < 100 and 0 <= y < 100: + state[int(y) // 10, int(x) // 10, 3] = True + state[8, 5:8, 4] = True + state[7:9, 8:10, 4] = True + for row, value in enumerate((self.steps, self.multiplier, self.ball_timer)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/floater.py b/runtime/minatar_synth/games/floater.py new file mode 100644 index 0000000000000000000000000000000000000000..26f06be3f999b9bacaeb54659494151a02802723 --- /dev/null +++ b/runtime/minatar_synth/games/floater.py @@ -0,0 +1,117 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Platform: + x: float + center: float + angle: float + radius: float + speed: float + used: bool = False + + @property + def y(self) -> float: + return self.center + math.sin(self.angle) * self.radius + + +class FloaterEnvironment: + score_cap = 1000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = 0 + self.x, self.y, self.vx, self.vy = 105.0, 10.0, 0.0, 0.0 + self.pressed = self.terminal = False + self.next_platform = 0.0 + self.center = 50.0 + self.support: Platform | None = None + self.platforms: list[Platform] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0.0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return reward, self.terminal + + def _advance(self, tap: bool) -> float: + if self.next_platform <= 0: + radius = self.random.uniform(10, 20) + low, high = 30 + radius, 80 - radius + if self.center < low: + self.center = 2 * low - self.center + elif self.center > high: + self.center = 2 * high - self.center + self.platforms.append(Platform(105, self.center, self.random.uniform(0, math.tau), + radius, self.random.uniform(0.05, 0.1))) + self.center += self.random.uniform(-20, 20) + self.next_platform += self.random.uniform(20, 40) + + scroll = 0.1 + max(0, self.x - 30) * 0.05 + self.next_platform -= scroll + for platform in self.platforms: + platform.x -= scroll + platform.angle = (platform.angle + platform.speed) % math.tau + self.platforms = [platform for platform in self.platforms if platform.x >= -10] + self.x -= scroll + if self.support is not None: + self.y = self.support.y - 6 + if tap: + self.vx = 1 + self.vy = math.cos(self.support.angle) * self.support.speed * 20 - 1 + self.support.used = True + self.support = None + else: + self.vy += 0.05 if self.pressed else 0.2 + self.x += self.vx + self.y += self.vy + if self.y < 8 and self.vy < 0: + self.vy *= -0.25 + for platform in self.platforms: + if not platform.used and abs(platform.x - self.x) < 11 and abs(platform.y - self.y) < 6: + self.support = platform + break + self.terminal = self.y > 99 or self.x < 0 + return scroll + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row = min(9, max(0, int(self.y) // 10)) + col = min(9, max(0, int(self.x) // 10)) + state[row, col, 0] = True + state[row, col, 3] = self.support is not None + state[row, col, 4] = self.vy < 0 + for platform in self.platforms: + if 0 <= platform.y < 100: + left = max(0, math.floor((platform.x - 7.5) / 10)) + right = min(10, math.ceil((platform.x + 7.5) / 10)) + state[int(platform.y) // 10, left:right, 2 if platform.used else 1] = True + for row, value in enumerate((self.steps, round(self.vy * 16) + 128)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/floors5.py b/runtime/minatar_synth/games/floors5.py new file mode 100644 index 0000000000000000000000000000000000000000..b2d4f1327b5cc4c5f1a8ecde86ad786596d9dfc4 --- /dev/null +++ b/runtime/minatar_synth/games/floors5.py @@ -0,0 +1,135 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +CAR_X = 10 + + +@dataclass(eq=False) +class Floor: + x: float + y: float + width: float + color: int + paint_from: float = 0 + paint_to: float = 0 + + +class Floors5Environment: + score_cap = 1000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.jumps = self.grace = 0 + self.pressed = self.terminal = False + self.y, self.vy, self.speed = 10.0, 0.0, 1.0 + self.support: Floor | None = None + self.visited: set[int] = set() + self.multiplier = 1 + self.floors = [Floor(x, y, width, color) for color, (x, y, width) in enumerate( + ((25, 30, 10), (52, 50, 35), (105, 70, 30), (160, 60, 30), (220, 40, 50)) + )] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap: bool) -> int: + for floor in self.floors: + if floor.x + floor.width < 0: + floor.x, floor.y = self.random.uniform(200, 250), self.random.uniform(30, 90) + floor.width = self.random.uniform(20, 60) + floor.paint_from = floor.paint_to = 0 + floor.x -= self.speed + self.speed += 0.02 + self.grace = max(0, self.grace - 1) + reward = 0 + if self.support is not None: + floor = self.support + floor.paint_to = min(floor.width, max(0, CAR_X + 5 - floor.x)) + if tap or floor.x + floor.width < CAR_X - 3: + width = floor.paint_to - floor.paint_from + reward = min(999, max(0, math.floor(width) * self.multiplier)) + if width >= floor.width: + reward *= 3 + floor.x = -999 + self.support = None + self.speed = 1 + if tap: + self.vy = -2 + self.jumps += 1 + else: + self.jumps = 0 + self.grace = 9 + else: + old_y = self.y + self.vy += 0.03 if self.pressed else 0.18 + self.y += self.vy + for floor in self.floors: + if not floor.x - 3 <= CAR_X <= floor.x + floor.width + 3: + continue + if self.vy >= 0 and old_y <= floor.y - 3 <= self.y: + self.y, self.vy, self.speed = floor.y - 3, 0, 1 + self.support = floor + floor.paint_from = max(0, CAR_X - 5 - floor.x) + floor.paint_to = min(floor.width, max(0, CAR_X + 5 - floor.x)) + self.jumps = 0 + self.visited.add(floor.color) + if len(self.visited) == 5: + self.multiplier += 1 + self.visited.clear() + break + if self.vy < 0 and self.y <= floor.y + 9 <= old_y: + self.y = floor.y + 9 + self.vy *= -0.7 + break + if tap and self.support is None and (self.grace or self.jumps < 2): + self.vy, self.speed = -2, 1 + self.jumps += 1 + self.terminal = self.y > 99 + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, max(0, int(self.y) // 10)), 0, 0] = True + for floor in self.floors: + row = int(floor.y) // 10 + for col in range(10): + if col * 20 < floor.x + floor.width and (col + 1) * 20 > floor.x: + for bit in range(3): + state[row, col, bit + 1] |= bool((floor.color + 1) & (1 << bit)) + state[row, col, 4] |= floor.paint_to > floor.paint_from and ( + col * 20 < floor.x + floor.paint_to and (col + 1) * 20 > floor.x + floor.paint_from + ) + for row, value in enumerate((self.steps, self.multiplier, self.jumps, self.grace, + round(self.vy * 16) + 128)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[8, :5, 5] = [color in self.visited for color in range(5)] + state[9, :2, 5] = self.pressed, self.support is not None + return state diff --git a/runtime/minatar_synth/games/foot_laser.py b/runtime/minatar_synth/games/foot_laser.py new file mode 100644 index 0000000000000000000000000000000000000000..36d696d085862616a76394ea60d29f272eaf001b --- /dev/null +++ b/runtime/minatar_synth/games/foot_laser.py @@ -0,0 +1,123 @@ +from dataclasses import dataclass + +import numpy as np + + +GROUND = 90 +PLAYER_X = 20 + + +@dataclass +class Enemy: + x: float + y: float + vx: float + flying: bool = False + + +class FootLaserEnvironment: + score_cap = 250 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.enemy_timer = 0 + self.wall_timer = self.random.uniform(300, 400) + self.flying_timer = self.random.uniform(200, 300) + self.y, self.vy = 50.0, 0.0 + self.jumps, self.multiplier = 9, 1 + self.pressed = self.grounded = self.terminal = False + self.enemies: list[Enemy] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap: bool) -> int: + if not self.grounded: + self.vy += 0.1 if self.pressed else 0.3 + self.y += self.vy + if self.y > GROUND: + self.y, self.vy = GROUND, 0 + self.grounded = True + self.jumps, self.multiplier = 0, 1 + if tap: + if self.jumps < 2: + self.vy, self.grounded = -3, False + elif self.jumps == 2: + self.vy += 9 + self.jumps = min(9, self.jumps + 1) + + self._spawn() + reward = 0 + survivors = [] + for enemy in self.enemies: + enemy.x += enemy.vx + distance = abs(enemy.x - PLAYER_X) + if not self.grounded and distance < 4 and enemy.y > self.y + 2: + reward += self.multiplier + self.multiplier += 1 + else: + self.terminal |= distance < 5 and abs(enemy.y - self.y) < 5 + if enemy.x >= -6: + survivors.append(enemy) + self.enemies = survivors + return reward + + def _spawn(self) -> None: + self.enemy_timer -= 1 + self.wall_timer -= 1 + self.flying_timer -= 1 + if self.enemy_timer < 0: + self.enemies.append(Enemy(200, GROUND, -self.random.uniform(1, 2))) + self.enemy_timer = self.random.uniform(30, 60) + if self.wall_timer < 0: + vx = -self.random.uniform(1, 2) + for index in range(int(self.random.integers(3, 6))): + self.enemies.append(Enemy(200, GROUND - 6 * index, vx)) + self.wall_timer = self.random.uniform(100, 600) + self.enemy_timer += 9 + if self.flying_timer < 0: + vx, y = -self.random.uniform(1, 2), self.random.uniform(50, 80) + for index in range(int(self.random.integers(1, 5))): + self.enemies.append(Enemy(206 + 7 * index, y, vx, flying=True)) + self.flying_timer = self.random.uniform(100, 400) + self.enemy_timer += 9 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row = max(0, int(self.y) // 10) + state[row, 1, 0] = True + if not self.grounded: + state[row:, 1, 3] = True + state[9, :, 4] = True + for enemy in self.enemies: + if 0 <= enemy.x < 200: + state[int(enemy.y) // 10, int(enemy.x) // 20, 2 if enemy.flying else 1] = True + for row, value in enumerate((self.steps, self.jumps, self.multiplier, round(self.vy * 10) + 128)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.grounded + return state diff --git a/runtime/minatar_synth/games/forfour.py b/runtime/minatar_synth/games/forfour.py new file mode 100644 index 0000000000000000000000000000000000000000..86be6cef13caaaae909cc08797f557100263c932 --- /dev/null +++ b/runtime/minatar_synth/games/forfour.py @@ -0,0 +1,132 @@ +import math + +import numpy as np + + +SIZE = 9 +CENTER = SIZE // 2 +CORE = (CENTER, CENTER) +DIRECTIONS = ((0, 1), (1, 0), (0, -1), (-1, 0)) + + +class ForfourEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = 0 + self.pressed = self.terminal = False + self.board = np.full((SIZE, SIZE), -1, dtype=np.int8) + self.board[CORE] = 0 + self.board[CENTER, CENTER + 1:CENTER + 4] = self.random.integers(1, 5, size=3) + self._spawn() + + def _spawn(self) -> None: + extent = int(np.max(np.abs(np.argwhere(self.board >= 0) - CENTER))) + 1 + self.color = int(self.random.integers(1, 5)) + if self.random.random() < math.sqrt(extent) * 0.1: + self.color = 0 + extent = math.ceil(extent * 0.7) + lane = int(self.random.integers(CENTER - extent + 1, CENTER + extent)) + self.direction = int(self.random.integers(4)) + self.row, self.column = ((lane, -1), (-1, lane), (lane, SIZE), (SIZE, lane))[self.direction] + self.timer = 60 + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance() + if tap and frame == 0 and not self.terminal: + self.board = np.rot90(self.board, -1).copy() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self) -> int: + self.timer -= 1 + if self.timer > 0: + return 0 + self.timer = 6 + dy, dx = DIRECTIONS[self.direction] + next_cell = self.row + dy, self.column + dx + if not self._inside(*next_cell): + self._spawn() + return 0 + hit = int(self.board[next_cell]) + if hit < 0: + self.row, self.column = next_cell + return 0 + if not self._inside(self.row, self.column): + self.terminal = True + return 0 + color = self.color or hit or int(self.random.integers(1, 5)) + cell = self.row, self.column + self.board[cell] = color + group = self._connected(cell, color) + reward = 0 + if len(group) >= 4: + for removed in group: + self.board[removed] = -1 + attached = self._connected(CORE) + count = len(group) + for row, column in np.argwhere(self.board > 0): + if (row, column) not in attached: + self.board[row, column] = -1 + count += 1 + reward = (count - 3)**2 + self._spawn() + return reward + + @staticmethod + def _inside(row: int, column: int) -> bool: + return 0 <= row < SIZE and 0 <= column < SIZE + + def _connected(self, start: tuple[int, int], color: int | None = None) -> set[tuple[int, int]]: + reached = {start} + pending = [start] + while pending: + row, column = pending.pop() + for dy, dx in DIRECTIONS: + cell = row + dy, column + dx + if self._inside(*cell) and cell not in reached: + value = self.board[cell] + if (value >= 0 if color is None else value == color): + reached.add(cell) + pending.append(cell) + return reached + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for color in range(5): + state[:SIZE, :SIZE, color] = self.board == color + if self.direction % 2 == 0: + state[self.row, :SIZE, 5] = True + else: + state[:SIZE, self.column, 5] = True + row, column = min(8, max(0, self.row)), min(8, max(0, self.column)) + state[row, column, self.color] = True + state[9, self.color, 5] = True + state[9, 5 + self.direction, 5] = True + state[9, 9, 5] = self.pressed + for bit in range(6): + state[bit, 9, 5] = bool(self.timer & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/fracave.py b/runtime/minatar_synth/games/fracave.py new file mode 100644 index 0000000000000000000000000000000000000000..fe70a49040155d46bfb15301568764e1d82ace1d --- /dev/null +++ b/runtime/minatar_synth/games/fracave.py @@ -0,0 +1,117 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Wall: + x: float + y: float + dx: float + dy: float + + def near(self, x: float, y: float) -> bool: + dx, dy = x - self.x, y - self.y + length = self.dx**2 + self.dy**2 + fraction = min(1, max(0, (dx * self.dx + dy * self.dy) / length)) if length else 0 + return math.hypot(dx - fraction * self.dx, dy - fraction * self.dy) < 4 + + +class FracaveEnvironment: + score_cap = 50 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.frame = 0 + self.x, self.y, self.angle, self.speed = 40.0, 75.0, 0.0, 1.0 + self.cooldown = 0.0 + self.pressed = self.terminal = False + self.walls: list[Wall] = [] + self._generate(0) + + def _generate(self, y: float) -> None: + for x in (20, 80): + self._subdivide(x, y, x, y + 150, 3) + + def _subdivide(self, x1: float, y1: float, x2: float, y2: float, depth: int) -> None: + if not depth: + self.walls.append(Wall(x1, y1, x2 - x1, y2 - y1)) + return + x = (x1 + x2) / 2 + self.random.uniform(-10, 10) + y = (y1 + y2) / 2 + self.random.uniform(-5, 5) + self._subdivide(x1, y1, x, y, depth - 1) + self._subdivide(x, y, x2, y2, depth - 1) + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self) -> int: + if self.frame % 150 == 0: + self._generate(-150) + self.frame += 1 + self.speed += ((2 if self.pressed else 0.1) - self.speed) * 0.3 + self.x += math.cos(self.angle) * self.speed + self.y += math.sin(self.angle) * self.speed + self.cooldown -= self.speed + for wall in self.walls: + wall.y += 1 + self.walls = [wall for wall in self.walls if wall.y < 170] + reward = 0 + if self.cooldown < 0: + for wall in self.walls: + if wall.near(self.x, self.y): + tangent = math.atan2(wall.dy, wall.dx) + self.angle = (2 * tangent - self.angle) % math.tau + self.x += math.cos(self.angle) * 7 + self.y += math.sin(self.angle) * 7 + self.speed, self.cooldown = 0.2, 9 + reward = 1 + break + self.terminal = not (0 <= self.x <= 100 and 0 <= self.y <= 150) + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + + def mark(x: float, y: float, channel: int) -> None: + if 0 <= x <= 100 and 0 <= y <= 150: + state[min(9, int(y) // 15), min(9, int(x) // 10), channel] = True + + mark(self.x, self.y, 0) + mark(self.x + 9 * math.cos(self.angle), self.y + 9 * math.sin(self.angle), 2) + if self.cooldown > 0: + state[:, :, 3] = state[:, :, 0] + for wall in self.walls: + for fraction in np.linspace(0, 1, 12): + mark(wall.x + wall.dx * fraction, wall.y + wall.dy * fraction, 1) + state[(0, 9), :, 4] = True + state[:, (0, 9), 4] = True + for row, value in enumerate((self.steps, round(self.angle * 80), round(self.speed * 100))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/from_two_sides.py b/runtime/minatar_synth/games/from_two_sides.py new file mode 100644 index 0000000000000000000000000000000000000000..a090474805f7d936de241ffeb2fcaec8c278d1ac --- /dev/null +++ b/runtime/minatar_synth/games/from_two_sides.py @@ -0,0 +1,104 @@ +from dataclasses import dataclass + +import numpy as np + + +HORIZON = 400 +FRAMES_PER_STEP = 4 + + +@dataclass +class Gap: + x: float + velocity: float + + +@dataclass +class Arrow: + x: int + y: float + direction: int + velocity: float = 0 + + +class FromTwoSidesEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.last_action = 0 + self.x = 50 + self.terminal = False + self.gaps = [Gap(50, -1), Gap(50, 1)] + self.timers = [0, 60] + self.arrows: list[Arrow] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.steps += 1 + direction = -1 if action == 1 else 1 if action == 4 else 0 + reward = 0 + for _ in range(FRAMES_PER_STEP): + reward += self._advance(direction) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, direction: int) -> int: + self.x = min(98, max(1, self.x + 2 * direction)) + for gap in self.gaps: + gap.x += gap.velocity + if (gap.x < 9 and gap.velocity < 0) or (gap.x > 90 and gap.velocity > 0): + gap.velocity *= -1 + gap.velocity = (gap.velocity + self.random.uniform(-0.5, 0.5)) * 0.98 + + reward = 0 + for index, heading in enumerate((1, -1)): + self.timers[index] -= 1 + if self.timers[index] < 0: + width = self.random.uniform(20, 50) + for x in range(2, 99, 6): + if all(abs(x - gap.x) >= width / 2 for gap in self.gaps): + self.arrows.append(Arrow(x, -3 if heading > 0 else 103, heading)) + reward += 1 + self.timers[index] = int(self.random.integers(60, 91)) + + survivors = [] + for arrow in self.arrows: + arrow.velocity += (arrow.direction * 2 - arrow.velocity) * 0.05 + arrow.y += arrow.velocity + self.terminal |= abs(arrow.x - self.x) < 4 and abs(arrow.y - 50) < 5 + if -3 <= arrow.y <= 103: + survivors.append(arrow) + self.arrows = survivors + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[5, self.x // 10, 0] = True + for arrow in self.arrows: + if 0 <= arrow.y < 100: + state[int(arrow.y) // 10, arrow.x // 10, 1 if arrow.direction > 0 else 2] = True + for index, gap in enumerate(self.gaps): + state[0, min(9, max(0, int(gap.x) // 10)), 3 + index] = True + for row, value in enumerate((self.steps, self.x, *self.timers)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/froooog.py b/runtime/minatar_synth/games/froooog.py new file mode 100644 index 0000000000000000000000000000000000000000..3db735227b9e4d9139f4617b0551c93baa1ef62d --- /dev/null +++ b/runtime/minatar_synth/games/froooog.py @@ -0,0 +1,110 @@ +from dataclasses import dataclass + +import numpy as np + + +HORIZON = 400 +MAX_JUMP = 8 +CENTER = 5 + + +@dataclass(frozen=True) +class Lane: + direction: int + period: int + phase: int + width: int + + def traffic(self, tick: int) -> np.ndarray: + if self.direction == 0: + return np.zeros(10, dtype=bool) + return (np.arange(10) - self.phase - self.direction * tick) % self.period < self.width + + +class FroooogEnvironment: + score_cap = HORIZON * MAX_JUMP + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.position = self.bottom = self.charge = self.last_action = 0 + self.destination: int | None = None + self.launch_position = 0 + self.terminal = False + self.lanes = [Lane(0, 1, 0, 0) for _ in range(3)] + self.next_safe = int(self.random.integers(9, 16)) + self._extend() + + def _extend(self) -> None: + while len(self.lanes) < self.bottom + 10: + if len(self.lanes) == self.next_safe: + self.lanes.append(Lane(0, 1, 0, 0)) + self.next_safe += int(self.random.integers(9, 16)) + else: + period = int(self.random.integers(5, 11)) + self.lanes.append(Lane(int(self.random.choice((-1, 1))), period, + int(self.random.integers(period)), int(self.random.integers(1, 3)))) + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.steps += 1 + reward = 0 + if self.destination is None: + if self.lanes[self.position].traffic(self.steps)[CENTER]: + self.terminal = True + return 0.0, True + if action == 5: + self.charge += 1 + if self.charge and (action != 5 or self.charge == MAX_JUMP): + self.launch_position = self.position + self.destination = self.position + min(self.charge, self.bottom + 9 - self.position) + self.charge = 0 + if self.destination is not None: + self.position = min(self.position + 2, self.destination) + if self.position == self.destination: + landing = self.lanes[self.position] + self.terminal = bool(landing.traffic(self.steps)[CENTER]) + if not self.terminal and landing.direction and self.lanes[self.launch_position].direction: + reward = (self.position - self.launch_position) ** 2 + self.destination = None + self.bottom = max(self.bottom, self.position - 1) + if self.steps % 8 == 0: + self.bottom += 1 + self._extend() + self.terminal |= self.position < self.bottom or self.steps >= self.horizon + return float(reward), self.terminal + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + if self.position >= self.bottom: + state[9 - (self.position - self.bottom), CENTER, 0] = True + for row, lane in enumerate(reversed(self.lanes[self.bottom:self.bottom + 10])): + state[row, :, 1] = lane.traffic(self.steps) + state[row, :, 2] = lane.direction == 0 + state[row, :, 4] = lane.traffic(self.steps + 1) + if self.destination is not None and self.destination >= self.bottom: + state[9 - (self.destination - self.bottom), CENTER, 3] = True + elif self.charge: + preview = min(9, self.position - self.bottom + self.charge) + state[9 - preview, CENTER, 3] = True + values = (self.steps, self.charge, int(self.destination is not None), + self.position - self.launch_position if self.destination is not None else 0) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/frostbite.py b/runtime/minatar_synth/games/frostbite.py new file mode 100644 index 0000000000000000000000000000000000000000..65f756d1b803096c0814726e6e103945bcb8f919 --- /dev/null +++ b/runtime/minatar_synth/games/frostbite.py @@ -0,0 +1,218 @@ +import numpy as np + + +ICE_ROWS = (3, 4, 5, 6) + + +class FrostbiteEnvironment: + """Nine-level ice-floe construction game with temperature pressure.""" + + score_cap = 41_850.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 2_025): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.player = [7, 5] + self.previous_player = self.player.copy() + self.level = 1 + self.lives = 4 + self.score = 0.0 + self.next_life_score = 5_000.0 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self.life_lost_this_step = False + self._start_level() + + def _start_level(self) -> None: + self.player = [7, 5] + self.previous_player = self.player.copy() + self.life_lost_this_step = False + self.floes = {row: {(row + offset * 3) % 10 for offset in range(4)} for row in ICE_ROWS} + self.floe_directions = {row: 1 if row % 2 else -1 for row in ICE_ROWS} + self.white_rows = set(ICE_ROWS) + self.igloo_blocks = 0 + self.scored_blocks = 0 + self.temperature = 45 + self.level_steps = 0 + self.fish_remaining = 4 + self.fish: list[dict[str, object]] = [] + self.hazards = [ + { + "position": [row, (row * 2 + self.level) % 10], + "direction": -self.floe_directions[row], + "kind": ("clam", "crab", "goose")[(row - 3) % 3], + } + for row in ICE_ROWS + ] + self.bear = [2, 9] if self.level >= 4 else None + self.previous_objects: list[list[int]] = [] + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + self.previous_objects = [list(hazard["position"]) for hazard in self.hazards] + self.previous_objects.extend(list(fish["position"]) for fish in self.fish) + level_before_action = self.level + reward = self._apply_action(action) + if self.level != level_before_action or self.terminal: + self.score += reward + self.steps += 1 + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + self._move_world() + reward += self._resolve_landing() + reward += self._resolve_fish() + self._resolve_hazards() + self.level_steps += 1 + self.steps += 1 + if self.level_steps % 5 == 0 and not self.life_lost_this_step: + self.temperature -= 1 + if self.temperature <= 0: + self._lose_life() + self.score += reward + while self.score >= self.next_life_score and self.lives < 10: + self.lives += 1 + self.next_life_score += 5_000.0 + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _apply_action(self, action: int) -> float: + if action == 5: + for row in ICE_ROWS: + self.floe_directions[row] *= -1 + if self.igloo_blocks < 16 and self.igloo_blocks > 0: + self.igloo_blocks -= 1 + return 0.0 + if action in (1, 2, 3, 4): + row_delta, column_delta = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}[action] + target = [self.player[0] + row_delta, self.player[1] + column_delta] + if 1 <= target[0] <= 7 and 0 <= target[1] < 10: + self.player = target + if self.igloo_blocks >= 16 and self.player == [1, 9]: + return self._enter_igloo() + return 0.0 + + def _move_world(self) -> None: + standing_row = self.previous_player[0] + carried = standing_row in ICE_ROWS and self.previous_player[1] in self.floes[standing_row] + for row in ICE_ROWS: + direction = self.floe_directions[row] + self.floes[row] = {(column + direction) % 10 for column in self.floes[row]} + if carried and self.player == self.previous_player: + self.player[1] = (self.player[1] + self.floe_directions[standing_row]) % 10 + for hazard in self.hazards: + hazard["position"][1] = (hazard["position"][1] + int(hazard["direction"])) % 10 + for fish in self.fish: + fish["position"][1] = (fish["position"][1] + int(fish["direction"])) % 10 + if self.fish_remaining > 0 and self.level_steps % 12 == 0: + row = ICE_ROWS[self.fish_remaining % 4] + self.fish.append( + {"position": [row, int(self.random.randint(10))], "direction": self.floe_directions[row]} + ) + self.fish_remaining -= 1 + if self.bear is not None: + self.bear[1] += int(np.sign(self.player[1] - self.bear[1])) + + def _resolve_landing(self) -> float: + row, column = self.player + if row in ICE_ROWS and column not in self.floes[row]: + self._lose_life() + return 0.0 + if row not in self.white_rows or row not in ICE_ROWS: + return 0.0 + self.white_rows.remove(row) + self.igloo_blocks += 1 + reward = 0.0 + if self.scored_blocks < 16: + self.scored_blocks += 1 + reward = float(min(self.level, 9) * 10) + if not self.white_rows and self.igloo_blocks < 16: + self.white_rows = set(ICE_ROWS) + return reward + + def _resolve_fish(self) -> float: + caught = [fish for fish in self.fish if fish["position"] == self.player] + if not caught: + return 0.0 + caught_ids = {id(fish) for fish in caught} + self.fish = [fish for fish in self.fish if id(fish) not in caught_ids] + return 200.0 * len(caught) + + def _resolve_hazards(self) -> None: + if self.life_lost_this_step: + return + if any(hazard["position"] == self.player for hazard in self.hazards): + self._lose_life() + return + if self.bear is not None and self.bear == self.player: + self._lose_life() + + def _lose_life(self) -> None: + if self.life_lost_this_step: + return + self.life_lost_this_step = True + self.lives -= 1 + self.player = [7, 5] + self.previous_player = self.player.copy() + self.temperature = 45 + if self.lives <= 0: + self.terminal = True + + def _enter_igloo(self) -> float: + level_value = min(self.level, 9) + reward = float(160 * level_value + 10 * self.temperature * level_value) + self.level += 1 + if self.level > 9: + self.terminal = True + else: + self._start_level() + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + for row in ICE_ROWS: + for column in self.floes[row]: + state[row, column, 2] = True + if row in self.white_rows: + state[row, column, 3] = True + for hazard in self.hazards: + state[*hazard["position"], 1] = True + if self.bear is not None: + state[*self.bear, 1] = True + for fish in self.fish: + state[*fish["position"], 2] = True + if self.igloo_blocks >= 16: + state[1, 9, 2] = True + state[1, 9, 3] = True + state[*self.previous_player, 4] = True + for position in self.previous_objects: + state[*position, 4] = True + state[9, : self.lives, 5] = True + for bit in range(5): + if self.igloo_blocks & (1 << bit): + state[8, bit, 5] = True + state[7, : self.level, 5] = True + for bit in range(6): + if self.temperature & (1 << bit): + state[2, bit, 5] = True + return state diff --git a/runtime/minatar_synth/games/future_wake.py b/runtime/minatar_synth/games/future_wake.py new file mode 100644 index 0000000000000000000000000000000000000000..5743e1e2623db92edab143599d7da6621f54b6ee --- /dev/null +++ b/runtime/minatar_synth/games/future_wake.py @@ -0,0 +1,103 @@ +import math + +import numpy as np + + +class FutureWakeEnvironment: + score_cap = 2500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.last_action = 0 + self.paddle = self.x = self.y = 50.0 + self.vx = self.vy = math.sqrt(0.5) + self.speed = self.multiplier = 1.0 + self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def _position(self, distance: float) -> tuple[float, float, float]: + offset = (self.x + self.vx * distance - 8.5) % 166 + if offset <= 83: + x, vx = 8.5 + offset, self.vx + else: + x, vx = 174.5 - offset, -self.vx + return x, self.y + self.vy * distance, vx + + def _impact(self) -> tuple[float, float, float]: + edge = 91 if self.vy > 0 else 9 + distance = max(0, (edge - self.y) / self.vy) + x, _, vx = self._position(distance) + return distance, x, vx + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.steps += 1 + direction = -1 if action == 1 else 1 if action == 4 else 0 + reward = 0 + for _ in range(4): + self.paddle = min(83, max(17, self.paddle + direction * 2)) + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self) -> int: + distance, impact_x, impact_vx = self._impact() + offset = (impact_x - self.paddle) / 10 + ready = abs(offset) <= 1.15 + reward = 0 + if ready and self.speed >= distance: + self.x = impact_x + self.y = 91 if self.vy > 0 else 9 + if abs(offset) < 0.6: + self.vx, self.vy = impact_vx, -self.vy + else: + angle = math.pi / 4 + 1 - offset if offset > 0 else 3 * math.pi / 4 - 1 - offset + self.vx, self.vy = math.cos(angle), math.copysign(math.sin(angle), -self.vy) + reward = math.floor(self.multiplier) + self.multiplier += 10 + if self.multiplier > 100: + self.vx += self.random.uniform(-1, 1) / 3 + length = math.hypot(self.vx, self.vy) + self.vx /= length + self.vy /= length + else: + self.x, self.y, self.vx = self._position(self.speed) + self.speed = self.speed + 1 if ready else 1 + self.multiplier = min(100.99, max(1, self.multiplier * 0.99)) + self.terminal = not 0 <= self.y <= 99 + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + if 0 <= self.y < 100: + state[int(self.y) // 10, int(self.x) // 10, 0] = True + left, right = int(self.paddle - 10) // 10, int(self.paddle + 10) // 10 + state[(0, 9), left:right + 1, 1] = True + distance, impact_x, _ = self._impact() + for offset in np.linspace(0, distance, 20): + x, y, _ = self._position(offset) + if 0 <= y < 100: + state[int(y) // 10, int(x) // 10, 2] = True + state[9 if self.vy > 0 else 0, int(impact_x) // 10, 3] = True + state[:, (0, 9), 4] = True + for row, value in enumerate((self.steps, round(self.speed), math.floor(self.multiplier))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/g_press.py b/runtime/minatar_synth/games/g_press.py new file mode 100644 index 0000000000000000000000000000000000000000..5a079c73bd24648a6342818aac78c90f7ad6cd09 --- /dev/null +++ b/runtime/minatar_synth/games/g_press.py @@ -0,0 +1,140 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Bubble: + x: float + y: float + size: float + velocity: float + + +@dataclass +class Drop: + x: float + y: float + velocity: float = 0 + + +class GPressEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.drop_timer = 0 + self.pressed = self.terminal = False + self.y, self.direction, self.width, self.motion = 30, 1, 80.0, 0.0 + self.water = self.target = self.previous = 70.0 + self.bubble_timer = 0.0 + self.bubbles: list[Bubble] = [] + self.drops: list[Drop] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap: bool) -> int: + if self.motion: + self.width += 5 * self.motion + if self.width < 0: + self.width, self.motion = 0, 0.5 + elif self.width > 80: + self.width, self.motion = 80, 0 + else: + self.y += self.direction + if (self.y < 10 and self.direction < 0) or (self.y > self.water - 10 and self.direction > 0): + self.direction *= -1 + if tap: + self.previous = self.target = self.water + 12 + self.motion = -1 + + self.bubble_timer -= 1 + if self.bubble_timer < 0: + size = self.random.uniform(5, 9) + self.bubbles.append(Bubble(self.random.uniform(20 + size, 80 - size), self.water + size / 2, + size, -self.random.uniform(1, 2) / size)) + self.target += size * 0.03 + self.bubble_timer += self.random.uniform(10, 50) + self._move_bubbles() + reward = 0 + survivors = [] + for drop in self.drops: + drop.velocity += 0.1 + drop.y += drop.velocity + if drop.y > self.water + 1: + self.drop_timer = 9 + self.target -= 0.35 + else: + survivors.append(drop) + self.drops = survivors + if self.drop_timer: + self.drop_timer -= 1 + if not self.drop_timer and self.previous > self.target: + gain = self.previous - self.target + reward = math.ceil(gain**1.5) + self.target += max(0, 50 - self.target) * 0.05 + self.water += (self.target - self.water) * 0.2 + self.terminal = self.motion == 0 and not self.drops and min(self.water, self.target) >= 100 + return reward + + def _move_bubbles(self) -> None: + survivors = [] + left, right = 50 - self.width / 2, 50 + self.width / 2 + for bubble in self.bubbles: + bubble.y += bubble.velocity + radius = bubble.size / 2 + jaw = left if bubble.x < 50 else right + if (self.motion < 0 or self.width == 0) and abs(bubble.y - self.y) < 10 + radius and abs(bubble.x - jaw) <= 5 + radius: + if bubble.size > self.width: + for _ in range(math.ceil(bubble.size)): + self.drops.append(Drop(bubble.x + self.random.uniform(-radius, radius), + bubble.y + self.random.uniform(-radius, radius))) + continue + bubble.x = jaw + (radius if bubble.x < 50 else -radius) + if bubble.y >= -radius: + survivors.append(bubble) + self.bubbles = survivors + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + top = max(0, (self.y - 10) // 10) + bottom = min(10, (self.y + 10) // 10 + 1) + for x in (50 - self.width / 2, 50 + self.width / 2): + state[top:bottom, int(x) // 10, 0] = True + for objects, channel in ((self.bubbles, 1), (self.drops, 2)): + for obj in objects: + if 0 <= obj.y < 100: + state[int(obj.y) // 10, int(obj.x) // 10, channel] = True + state[min(10, int(self.water) // 10):, :, 3] = True + state[top:bottom, :, 4] = self.motion < 0 + for row, value in enumerate((self.steps, round(self.width), round(self.target), self.drop_timer)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :3, 5] = self.pressed, self.direction > 0, self.motion > 0 + return state diff --git a/runtime/minatar_synth/games/g_tail.py b/runtime/minatar_synth/games/g_tail.py new file mode 100644 index 0000000000000000000000000000000000000000..b914648be9931086b26c8e82f57e2cb40b755ad0 --- /dev/null +++ b/runtime/minatar_synth/games/g_tail.py @@ -0,0 +1,111 @@ +from collections import deque +from dataclasses import dataclass, field +import math + +import numpy as np + + +@dataclass +class Meteor: + x: float + y: float + vx: float + vy: float = 0 + gold: list[int] = field(default_factory=list) + history: deque = field(default_factory=lambda: deque(maxlen=200)) + + +class GTailEnvironment: + score_cap = 250 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.last_action = 0 + self.x, self.y = 50, 50.0 + self.spawn_timer = 0.0 + self.multiplier = 1 + self.terminal = False + self.meteors: list[Meteor] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.steps += 1 + direction = -1 if action == 1 else 1 if action == 4 else 0 + reward = 0 + for _ in range(4): + reward += self._advance(direction) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, direction: int) -> int: + self.x = min(99, max(0, self.x + direction * 2)) + self.y += (50 - self.y) * 0.001 + self.spawn_timer -= 1 + if self.spawn_timer < 0: + self.meteors.append(Meteor(self.random.uniform(10, 90), -5, self.random.uniform(-0.5, 0.5), + gold=list(range(10, 10 + 5 * int(self.random.integers(3, 8)), 5)))) + self.spawn_timer = self.random.uniform(99, 120) * math.sqrt(len(self.meteors)) + reward = 0 + survivors = [] + for meteor in self.meteors: + meteor.vx = min(2, max(-2, meteor.vx + (self.x - meteor.x) / 999)) + meteor.vy = min(2, max(-2, meteor.vy + (self.y - meteor.y) / 999)) + meteor.x += meteor.vx + meteor.y += meteor.vy + meteor.history.appendleft((meteor.x, meteor.y)) + remaining = [] + for age in meteor.gold: + if age < len(meteor.history) and self._touches(*meteor.history[age], radius=5): + reward += self.multiplier + else: + remaining.append(age) + meteor.gold = remaining + if not meteor.gold: + reward += self.multiplier + self.multiplier += 1 + elif self._touches(meteor.x, meteor.y, radius=5.5): + self.y += 10 + elif -100 <= meteor.x < 200 and -100 <= meteor.y < 200: + survivors.append(meteor) + self.meteors = survivors + self.terminal = self.y > 99 + return reward + + def _touches(self, x: float, y: float, radius: float) -> bool: + return abs(self.x - x) < radius and abs(self.y - y) < radius + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, int(self.y) // 10), self.x // 10, 0] = True + for meteor in self.meteors: + if 0 <= meteor.x < 100 and 0 <= meteor.y < 100: + state[int(meteor.y) // 10, int(meteor.x) // 10, 1] = True + else: + row = min(9, max(0, int(meteor.y) // 10)) + col = min(9, max(0, int(meteor.x) // 10)) + state[row, col, 4] = True + for index, (x, y) in enumerate(meteor.history): + if 0 <= x < 100 and 0 <= y < 100: + state[int(y) // 10, int(x) // 10, 2 if index in meteor.gold else 3] = True + for row, value in enumerate((self.steps, self.multiplier, round(self.spawn_timer), self.x)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/geocent.py b/runtime/minatar_synth/games/geocent.py new file mode 100644 index 0000000000000000000000000000000000000000..021f70d0b01488146fbb75629b6dccbe3e878f30 --- /dev/null +++ b/runtime/minatar_synth/games/geocent.py @@ -0,0 +1,112 @@ +from collections import deque +import math + +import numpy as np + + +EARTH = 3 + + +class GeocentEnvironment: + score_cap = 100 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = 0 + self.pressed = self.terminal = False + self.phases = self.random.uniform(0, math.tau, 9) + self.planets = np.zeros((9, 2)) + self.crates: list[int] = [] + self.history: deque[tuple[float, float]] = deque() + self.turn = 0.0 + self._launch() + self._locate_planets() + + def _launch(self) -> None: + self.angle = (self.random.integers(4) + self.random.uniform(0.3, 0.7)) * math.pi / 2 + self.distance = abs(math.sin(2 * self.angle)) * 25 + 36 + self.speed = 0.0 + self.crates = list(range(9, 9 * (len(self.crates) + 1) + 1, 9)) + self.history = deque(maxlen=max(self.crates) + 1) + + def _locate_planets(self) -> None: + radii = np.arange(9) * 4 + self.planets[:, 0] = radii * np.cos(self.phases) + self.planets[:, 1] = radii * np.sin(self.phases) + self.planets += 50 - self.planets[EARTH].copy() + + @property + def position(self) -> tuple[float, float]: + return 50 + self.distance * math.cos(self.angle), 50 + self.distance * math.sin(self.angle) + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _hazard(self, x: float, y: float, margin: float) -> bool: + return any(math.hypot(px - x, py - y) < margin + (3 if index == 0 else 1) + for index, (px, py) in enumerate(self.planets) if index != EARTH) + + def _advance(self, tap: bool) -> int: + self.phases += 0.03 * 0.7 ** np.arange(1, 10) + self._locate_planets() + if tap: + self.speed += 1 + self.speed += ((0.5 if self.pressed else 0.1) - self.speed) * 0.5 + self.distance -= self.speed + self.turn += ((0.03 if self.pressed else -0.003) - self.turn) * 0.05 + self.angle = (self.angle + self.turn) % math.tau + x, y = self.position + self.history.appendleft((x, y)) + self.crates = [age for age in self.crates + if not self._hazard(*(self.history[age] if age < len(self.history) else (x, y)), 1)] + if self.distance < 3.5: + reward = len(self.crates) + self._launch() + return reward + self.terminal = self._hazard(x, y, 1.5) + return 0 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + + def mark(x: float, y: float, channel: int) -> None: + if 0 <= x < 100 and 0 <= y < 100: + state[int(y) // 10, int(x) // 10, channel] = True + + for index, (x, y) in enumerate(self.planets): + mark(x, y, 2 if index == EARTH else 1) + x, y = self.position + mark(min(99, max(0, x)), min(99, max(0, y)), 0) + for age in self.crates: + mark(*(self.history[age] if age < len(self.history) else (x, y)), 3) + mark(50 + (self.distance - 8) * math.cos(self.angle), + 50 + (self.distance - 8) * math.sin(self.angle), 4) + for row, value in enumerate((self.steps, len(self.crates), round(self.distance * 4), round(self.angle * 80))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/geoerase.py b/runtime/minatar_synth/games/geoerase.py new file mode 100644 index 0000000000000000000000000000000000000000..7a2d64cf6b77462eeeea349b9cc89193e5ea7713 --- /dev/null +++ b/runtime/minatar_synth/games/geoerase.py @@ -0,0 +1,103 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Enemy: + x: float + y: float + vx: float + vy: float + square: bool + marked: bool = False + + +class GeoeraseEnvironment: + score_cap = 100 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.spawn_timer = 0 + self.angle = 0.0 + self.combo = 1 + self.pressed = self.terminal = False + self.enemies: list[Enemy] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + release = self.pressed and not pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(release and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, release: bool) -> int: + self.spawn_timer -= 1 + if self.spawn_timer <= 0: + self._spawn() + self.spawn_timer = 60 + self.angle = (self.angle + (0.04 if self.pressed else 0.08)) % math.tau + reward = 0 + if release: + marked = [enemy for enemy in self.enemies if enemy.marked] + reward = self.combo * sum(2 if enemy.square else 1 for enemy in marked) + self.combo = min(16, self.combo + len(marked) - 1) if len(marked) > 1 else max(1, self.combo - 1) + self.enemies = [enemy for enemy in self.enemies if not enemy.marked] + for enemy in self.enemies: + if self.pressed: + dx, dy = enemy.x - 50, enemy.y - 50 + difference = (math.atan2(dy, dx) - self.angle + math.pi) % math.tau - math.pi + enemy.marked |= 3 < math.hypot(dx, dy) < 60 and abs(difference) < 0.2 + enemy.x += enemy.vx + enemy.y += enemy.vy + self.terminal |= abs(enemy.x - 50) < 5.5 and abs(enemy.y - 50) < 5.5 + return reward + + def _spawn(self) -> None: + offset = self.random.uniform(0, 100) + side = int(self.random.integers(4)) + x, y = ((offset, -5), (offset, 105), (-5, offset), (105, offset))[side] + square = self.random.random() < 0.3 + speed = 0.4 if square else 0.25 + angle = math.atan2(50 - y, 50 - x) + self.enemies.append(Enemy(x, y, speed * math.cos(angle), speed * math.sin(angle), square)) + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[5, 5, 0] = True + for enemy in self.enemies: + if 0 <= enemy.x < 100 and 0 <= enemy.y < 100: + row, col = int(enemy.y) // 10, int(enemy.x) // 10 + state[row, col, 2 if enemy.square else 1] = True + state[row, col, 3] |= enemy.marked + for distance in range(0, 61, 4): + x = 50 + math.cos(self.angle) * distance + y = 50 + math.sin(self.angle) * distance + if 0 <= x < 100 and 0 <= y < 100: + state[int(y) // 10, int(x) // 10, 4] = True + for row, value in enumerate((self.steps, self.combo, round(self.angle * 80))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/geyser_hop.py b/runtime/minatar_synth/games/geyser_hop.py new file mode 100644 index 0000000000000000000000000000000000000000..8c6424500b7c87fcefb45d86052675b35f285beb --- /dev/null +++ b/runtime/minatar_synth/games/geyser_hop.py @@ -0,0 +1,106 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Geyser: + x: float + height: int + stomped: bool = False + + +class GeyserHopEnvironment: + score_cap = 150 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x = self.y = 40.0 + self.vy = 0.0 + self.ceiling = 3.0 + self.steps = self.frames = self.since_stomp = 0 + self.combo = 1 + self.pressed = self.terminal = False + self.geysers = [Geyser(95, 40)] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self) -> int: + self.frames += 1 + self.since_stomp += 1 + if self.since_stomp > 200: + self.ceiling += 0.1 + if self.frames % 91 == 61: + self.geysers.append(Geyser(110, int(self.random.integers(40, 60)))) + self.x += (45 - self.x) * 0.01 + self.vy = min(3, max(-2.2, self.vy + (-0.16 if self.pressed else 0.13))) + self.y += self.vy + if self.y < self.ceiling or self.y > 92: + self.terminal = True + return 0 + reward = 0 + for geyser in self.geysers: + geyser.x -= 1 + if geyser.x < -15 and not geyser.stomped: + self.combo = max(1, self.combo - 1) + if geyser.stomped: + continue + top = 92 - geyser.height + dx = abs(self.x - geyser.x) + if dx < 8 and self.y + 2 > top and self.y - 2 < top + 6: + if self.vy <= 0: + self.terminal = True + break + reward += self.combo + self.combo = min(16, self.combo + 1) + self.vy = -2.8 + self.y = top - 2 + geyser.height = 8 + geyser.stomped = True + self.ceiling = max(3, self.ceiling - 8) + self.since_stomp = 0 + elif dx < 7 and self.y + 2 > top + 4: + self.terminal = True + break + self.geysers = [geyser for geyser in self.geysers if geyser.x >= -15] + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, max(0, int(self.y) // 10)), int(self.x) // 10, 0] = True + for geyser in self.geysers: + top = (92 - geyser.height) // 10 + for col in range(max(0, int(geyser.x - 5) // 10), min(10, int(geyser.x + 5) // 10 + 1)): + if not geyser.stomped: + state[top, col, 1] = True + state[top + int(not geyser.stomped):10, col, 3 if geyser.stomped else 2] = True + state[:min(10, int(self.ceiling) // 10 + 1), :, 4] = True + for row, value in enumerate((self.steps, self.combo, round((self.vy + 3) * 50), min(511, self.since_stomp))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/ghost_hop.py b/runtime/minatar_synth/games/ghost_hop.py new file mode 100644 index 0000000000000000000000000000000000000000..111338c9a6a62541fe5fd3c8faf365375f1221c9 --- /dev/null +++ b/runtime/minatar_synth/games/ghost_hop.py @@ -0,0 +1,120 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Mover: + x: float + y: float + vx: float + vy: float + + +class GhostHopEnvironment: + score_cap = 4000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.targets = [ + Mover(20 + i % 3 * 30, 25 + i // 3 * 40, *self.random.uniform(-0.2, 0.2, 2)) + for i in range(5) + ] + self.index = 2 + self.x, self.y = 80, 25 + self.origin = (self.x, self.y) + self.flight = self.steps = self.frames = 0 + self.multiplier = 1.0 + self.pressed = self.terminal = False + self.bullets: list[Mover] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap: bool) -> int: + current = self.targets[self.index] + if self.frames % 50 == 0: + offset = self.random.uniform(0, 100) + side = self.random.integers(4) + x, y = ((-5, offset), (105, offset), (offset, -5), (offset, 105))[side] + angle = math.atan2(current.y - y, current.x - x) + self.bullets.append(Mover(x, y, 0.5 * math.cos(angle), 0.5 * math.sin(angle))) + self.frames += 1 + if tap and not self.flight: + self.origin = (current.x, current.y) + self.flight = 13 + for target in self.targets: + target.x += target.vx + target.y += target.vy + if not 15 <= target.x <= 85: + target.x = min(85, max(15, target.x)) + target.vx *= -1 + if not 15 <= target.y <= 85: + target.y = min(85, max(15, target.y)) + target.vy *= -1 + reward = 0 + airborne = self.flight > 0 + if airborne: + destination = (self.index + 1) % len(self.targets) + target = self.targets[destination] + self.flight -= 1 + fraction = (13 - self.flight) * 0.08 + self.x = self.origin[0] + (target.x - self.origin[0]) * fraction + self.y = self.origin[1] + (target.y - self.origin[1]) * fraction + if not self.flight: + self.index = destination + reward = int(self.multiplier) + self.multiplier *= 2 + else: + self.x, self.y = current.x, current.y + for bullet in self.bullets: + bullet.x += bullet.vx + bullet.y += bullet.vy + if airborne and abs(bullet.x - self.x) < 4 and abs(bullet.y - self.y) < 4: + self.terminal = True + self.bullets = [b for b in self.bullets if -10 <= b.x <= 110 and -10 <= b.y <= 110] + self.multiplier = min(256, max(1, self.multiplier * 0.99)) + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[int(self.y) // 10, int(self.x) // 10, 0] = True + destination = (self.index + 1) % len(self.targets) + for index, target in enumerate(self.targets): + state[int(target.y) // 10, int(target.x) // 10, 2 if index == destination else 1] = True + for bullet in self.bullets: + if 0 <= bullet.x < 100 and 0 <= bullet.y < 100: + row, col = int(bullet.y) // 10, int(bullet.x) // 10 + state[row, col, 3] = True + state[min(9, max(0, int(bullet.y + 10 * bullet.vy) // 10)), + min(9, max(0, int(bullet.x + 10 * bullet.vx) // 10)), 4] = True + for row, value in enumerate((self.steps, self.flight, int(self.multiplier))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/gloop.py b/runtime/minatar_synth/games/gloop.py new file mode 100644 index 0000000000000000000000000000000000000000..ea225c0ef5118b7d31e2e4c8bc08f1f3a6c0ce8a --- /dev/null +++ b/runtime/minatar_synth/games/gloop.py @@ -0,0 +1,95 @@ +import math + +import numpy as np + + +class GloopEnvironment: + score_cap = 25 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x = self.y = 50.0 + self.vy = 0.0 + self.gravity = -1 + self.steps = self.action = 0 + self.terminal = False + self.orbs = [self._point() for _ in range(7)] + self.mines: list[tuple[float, float]] = [] + + def _point(self) -> tuple[float, float]: + x, y = self.random.uniform(10, 90, 2) + return x, y + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.action = action + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self) -> int: + dx = {1: -2.5, 3: 2.5}.get(self.action, 0) + self.x = min(92, max(8, self.x + dx)) + self.vy = (self.vy + 0.02 * self.gravity) * 0.99 + self.y = (self.y + self.vy) % 99 + collision_y = self.y + while len(self.orbs) < 7: + self.orbs.append(self._point()) + if self.random.random() < 0.02: + x, y = self._point() + if abs(x - self.x) + abs((y - self.y + 50) % 100 - 50) > 25: + self.mines.append((x, y)) + surviving_orbs = [] + removed = 0 + for x, y in self.orbs: + if abs(x - self.x) >= 5 or abs(y - collision_y) >= 4: + surviving_orbs.append((x, y)) + continue + if abs(self.vy) > 1: + remaining = [mine for mine in self.mines if math.dist(mine, (x, y)) >= 20] + removed += len(self.mines) - len(remaining) + self.mines = remaining + else: + surviving_orbs.append((x, y)) + self.vy *= -0.3 + self.gravity *= -1 + self.y = y + self.gravity * 5 + self.orbs = surviving_orbs + self.terminal = any(abs(x - self.x) < 4 and abs(y - collision_y) < 3 for x, y in self.mines) + return removed * (removed + 1) // 2 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row, col = int(self.y) // 10, int(self.x) // 10 + state[row, col, 0] = True + for channel, points in ((1, self.orbs), (2, self.mines)): + for x, y in points: + state[int(y) // 10, int(x) // 10, channel] = True + if abs(self.vy) > 1: + for x, y in self.orbs: + state[int(y) // 10, int(x) // 10, 3] = True + state[int((self.y + 10 * self.vy) % 99) // 10, col, 4] = True + for row, value in enumerate((self.steps, round((self.vy + 2) * 100), self.action)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.gravity > 0 + return state diff --git a/runtime/minatar_synth/games/golfme.py b/runtime/minatar_synth/games/golfme.py new file mode 100644 index 0000000000000000000000000000000000000000..5796be2dd8a20290da843288fa0057d5e231bd4f --- /dev/null +++ b/runtime/minatar_synth/games/golfme.py @@ -0,0 +1,99 @@ +import math + +import numpy as np + + +class GolfmeEnvironment: + score_cap = 2400 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x, self.y = 50.0, 85.0 + self.vx = self.vy = self.angle = 0.0 + self.platform_end = self.gap = 0.0 + self.steps = 0 + self.pressed = self.airborne = self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + released = self.pressed and not pressed + self.pressed = pressed + self.steps += 1 + reward = 0.0 + for frame in range(4): + reward += self._advance(released and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return reward, self.terminal + + def _advance(self, released: bool) -> float: + next_start = self.platform_end + self.gap + if next_start < 0: + self.platform_end = 200 + self.gap = self.random.uniform(50, 150) + next_start = self.platform_end + self.gap + if self.x < 0 or self.y > 99: + self.terminal = True + return 0.0 + if self.airborne: + self.x += self.vx + self.y += self.vy + self.vy += 0.1 + on_platform = self.x - 4.5 < self.platform_end or self.x + 4.5 > next_start + if self.vy > 0 and 85.5 < self.y < 103.5 and on_platform: + self.airborne = False + self.angle = 0 + self.y = 85 + else: + if self.pressed: + self.angle -= 0.05 + if released: + self.airborne = True + self.vx = 4 * math.cos(self.angle) + self.vy = 4 * math.sin(self.angle) + scroll = 1 + min(99, max(0, self.x - 50)) * 0.1 + self.x -= scroll + self.platform_end -= scroll + return scroll + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row = min(9, max(0, int(self.y) // 10)) + col = min(9, max(0, int(self.x) // 20)) + state[row, col, 0] = True + next_start = self.platform_end + self.gap + for column in range(10): + left, right = 20 * column, 20 * (column + 1) + state[9, column, 1] = left < self.platform_end or right > next_start + state[9, column, 2] = left < next_start and right > self.platform_end + if not self.airborne: + for distance in range(5, 25, 5): + x = self.x + distance * math.cos(self.angle) + y = self.y + distance * math.sin(self.angle) + if 0 <= x < 200 and 0 <= y < 100: + state[int(y) // 10, int(x) // 20, 3] = True + else: + x = self.x + 4 * self.vx + y = self.y + 4 * self.vy + if 0 <= x < 200 and 0 <= y < 100: + state[int(y) // 10, int(x) // 20, 4] = True + for row, value in enumerate((self.steps, round((-self.angle % math.tau) * 70))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.airborne + return state diff --git a/runtime/minatar_synth/games/gopher.py b/runtime/minatar_synth/games/gopher.py new file mode 100644 index 0000000000000000000000000000000000000000..8af128ee392794536622ef62afc48b68c9767bc0 --- /dev/null +++ b/runtime/minatar_synth/games/gopher.py @@ -0,0 +1,158 @@ +import numpy as np + + +CARROT_COLUMNS = (3, 5, 7) + + +class GopherEnvironment: + """Twelve-raid carrot defense with tunnel repair and seed recovery.""" + + score_cap = 4_560.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 1_200): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.farmer = [2, 5] + self.previous_farmer = self.farmer.copy() + self.carrots = set(CARROT_COLUMNS) + self.carrying_seed = False + self.seed_position: list[int] | None = None + self.duck: list[int] | None = None + self.raid = 0 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self.previous_gopher: list[int] | None = None + self._start_raid() + + def _start_raid(self) -> None: + if self.raid >= 12 or not self.carrots: + self.terminal = True + return + target_column = sorted(self.carrots)[self.raid % len(self.carrots)] + start_column = 0 if self.raid % 2 == 0 else 9 + step = 1 if target_column > start_column else -1 + horizontal = [[8, column] for column in range(start_column, target_column + step, step)] + vertical = [[row, target_column] for row in range(7, 1, -1)] + self.gopher_path = horizontal + vertical + self.gopher_index = 0 + self.gopher = self.gopher_path[0].copy() + self.tunnels: set[tuple[int, int]] = {tuple(self.gopher)} + self.scored_sections: set[tuple[int, int]] = set() + self.raid_steps = 0 + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_farmer = self.farmer.copy() + self.previous_gopher = self.gopher.copy() + raid_before_action = self.raid + reward = self._apply_action(action) + if self.raid == raid_before_action and not self.terminal: + self._move_gopher() + self._move_duck_and_seed() + self._resolve_seed_catch() + self.raid_steps += 1 + self.steps += 1 + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _apply_action(self, action: int) -> float: + if action == 1: + self.farmer[1] = max(0, self.farmer[1] - 1) + elif action == 3: + self.farmer[1] = min(9, self.farmer[1] + 1) + elif action == 5: + if self.carrying_seed and self.farmer[1] in CARROT_COLUMNS and self.farmer[1] not in self.carrots: + self.carrots.add(self.farmer[1]) + self.carrying_seed = False + return 0.0 + if self.gopher[0] == 2 and self.gopher[1] == self.farmer[1]: + self.raid += 1 + self._start_raid() + return 100.0 + column_sections = [section for section in self.tunnels if section[1] == self.farmer[1]] + if column_sections: + section = min(column_sections) + self.tunnels.remove(section) + self.gopher_index = max(0, self.gopher_index - 1) + self.gopher = self.gopher_path[self.gopher_index].copy() + if section not in self.scored_sections: + self.scored_sections.add(section) + return 20.0 + return 0.0 + + def _move_gopher(self) -> None: + interval = max(1, 5 - self.raid // 3) + if self.raid_steps % interval: + return + if self.gopher_index < len(self.gopher_path) - 1: + self.gopher_index += 1 + self.gopher = self.gopher_path[self.gopher_index].copy() + self.tunnels.add(tuple(self.gopher)) + return + target_column = self.gopher[1] + self.carrots.discard(target_column) + self.raid += 1 + self._start_raid() + + def _move_duck_and_seed(self) -> None: + missing = [column for column in CARROT_COLUMNS if column not in self.carrots] + if missing and self.duck is None and self.seed_position is None and not self.carrying_seed: + if self.steps % 24 == 0: + self.duck = [0, 0] + if self.duck is not None: + self.duck[1] += 1 + if self.duck[1] == 5 and self.seed_position is None: + self.seed_position = [0, 5] + if self.duck[1] > 9: + self.duck = None + if self.seed_position is not None: + self.seed_position[0] += 1 + if self.seed_position[0] > 2: + self.seed_position = None + + def _resolve_seed_catch(self) -> None: + if self.seed_position == self.farmer: + self.seed_position = None + self.carrying_seed = True + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.farmer, 0] = True + state[*self.gopher, 1] = True + for column in self.carrots: + state[1, column, 2] = True + if self.seed_position is not None: + state[*self.seed_position, 2] = True + if self.duck is not None: + state[*self.duck, 2] = True + for section in self.tunnels: + state[*section, 3] = True + state[*self.previous_farmer, 4] = True + if self.previous_gopher is not None: + state[*self.previous_gopher, 4] = True + state[9, : len(self.carrots), 5] = True + for bit in range(4): + state[8, bit, 5] = bool(self.raid & (1 << bit)) + for bit in range(4): + state[7, bit, 5] = bool(len(self.tunnels) & (1 << bit)) + if self.carrying_seed: + state[6, :3, 5] = True + return state diff --git a/runtime/minatar_synth/games/grappling_h.py b/runtime/minatar_synth/games/grappling_h.py new file mode 100644 index 0000000000000000000000000000000000000000..267997637ff4f7019c3333a68c97dc08d231009f --- /dev/null +++ b/runtime/minatar_synth/games/grappling_h.py @@ -0,0 +1,112 @@ +import numpy as np + + +HORIZON = 500 +UNIT = 8 +ANCHOR_SPACING = 16 +BOTTOM = 80 +REACH = 16 + + +class GrapplingHEnvironment: + # At most four scroll units per step, plus one rounding point per catch. + score_cap = HORIZON + HORIZON * 4 // UNIT + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x, self.y = 24, 16 + self.vx = self.vy = 0 + self.steps = self.scroll = self.since_release = self.last_action = 0 + self.anchors = [(40, 0), (48, 8)] + self.attached: tuple[int, int] | None = self.anchors[0] + self.rearmed = False + self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def _nearby(self) -> tuple[int, int] | None: + candidates = [(dx * dx + dy * dy, anchor) + for anchor in self.anchors + for dx, dy in [(anchor[0] - self.x, anchor[1] + self.scroll - self.y)]] + distance, anchor = min(candidates, default=(REACH ** 2, None)) + return anchor if distance < REACH ** 2 else None + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + pressed = action == 5 and self.last_action != 5 + self.last_action = action + self.steps += 1 + reward = 0 + if self.attached is None and action == 5 and self.rearmed: + self.attached = self._nearby() + if self.attached is not None: + reward = (self.since_release + UNIT - 1) // UNIT + pressed = False + + advance = max(1, min(4, (40 - self.y) // 8)) + previous_scroll = self.scroll + self.scroll += advance + self.since_release += advance + self.y += advance + if self.scroll // ANCHOR_SPACING > previous_scroll // ANCHOR_SPACING: + self.anchors.append((UNIT * int(self.random.integers(1, 9)), + -(self.scroll // ANCHOR_SPACING) * ANCHOR_SPACING)) + + self.vy += 1 + if self.attached is not None: + dx = self.attached[0] - self.x + dy = self.attached[1] + self.scroll - self.y + divisor = 4 if pressed else 12 + self.vx += round(dx / divisor) + self.vy += round(dy / divisor) + if pressed: + self.anchors.remove(self.attached) + self.attached = None + self.since_release = 0 + self.rearmed = False + self.vx = max(-12, min(12, self.vx)) + self.vy = max(-12, min(12, self.vy)) + self.x += self.vx + self.y = max(0, self.y + self.vy) + if not 0 <= self.x < BOTTOM: + self.x = max(0, min(BOTTOM - 1, self.x)) + self.vx = -round(self.vx * 0.8) + expired = self.attached is not None and self.attached[1] + self.scroll >= BOTTOM + self.anchors = [anchor for anchor in self.anchors if anchor[1] + self.scroll < BOTTOM] + if action != 5: + self.rearmed = True + self.terminal = expired or self.y >= BOTTOM or self.steps >= self.horizon + return float(reward), self.terminal + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, self.y // UNIT), self.x // UNIT, 0] = True + nearby = self._nearby() if self.attached is None else None + for anchor in self.anchors: + x, y = anchor + row, column = (y + self.scroll) // UNIT, x // UNIT + state[row, column, 2] = True + if anchor == self.attached: + state[row, column, 3] = True + if anchor == nearby: + state[row, column, 4] = True + values = (self.x, self.y, self.vx + 12, self.vy + 12, self.scroll % ANCHOR_SPACING, + self.since_release, self.steps, int(self.rearmed), int(self.last_action == 5)) + for row, value in enumerate(values): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = bool(self.since_release & 1024) + return state diff --git a/runtime/minatar_synth/games/graveler.py b/runtime/minatar_synth/games/graveler.py new file mode 100644 index 0000000000000000000000000000000000000000..8428cb324664104dc13b87dce30060bcd41c11f5 --- /dev/null +++ b/runtime/minatar_synth/games/graveler.py @@ -0,0 +1,137 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Item: + x: float + y: float + spike: bool = False + + +class GravelerEnvironment: + score_cap = 300 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.walls = [(50.0, 60.0)] * 11 + self.center, self.width = 50.0, 60.0 + self.center_speed = self.width_speed = 0.0 + self.offset = 0.0 + self.y, self.vy = 65.0, 0.0 + self.items = [Item(15 + i * 7, 65) for i in range(5)] + self.object_distance = 10.0 + self.coins_left, self.coin_y = 0, 65.0 + self.steps, self.multiplier = 0, 1 + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self) -> int: + center, width = self.walls[1] + force = -0.015 if self.y < center else 0.015 + self.vy += force * (-1.5 if self.pressed else 1) + self.y += self.vy + self.vy *= 0.99 + self.terminal = abs(self.y - center) + 2 >= width / 2 + reward = 0 + remaining = [] + for item in self.items: + if abs(item.x - 10) < 5 and abs(item.y - self.y) < 4: + if item.spike: + self.terminal = True + else: + reward += self.multiplier + self.multiplier += 1 + continue + if not item.spike and 0 <= item.x < 100: + wall = int((item.x + self.offset) // 10) + item_center, item_width = self.walls[wall] + if abs(item.y - item_center) + 2 >= item_width / 2: + self.coin_y += 10 if self.coin_y < 50 else -10 + continue + item.x -= 0.5 + if item.x >= -3: + remaining.append(item) + elif not item.spike: + self.multiplier = max(1, self.multiplier - 1) + self.items = remaining + self.offset += 0.5 + if self.offset >= 10: + self.offset -= 10 + self._append_wall() + self.object_distance -= 0.5 + if self.object_distance < 0: + self._spawn_item() + return reward + + def _append_wall(self) -> None: + self.center_speed += self.random.uniform(-0.2, 0.2) + self.width_speed += self.random.uniform(-0.2, 0.2) + self.center += self.center_speed + self.width += self.width_speed + if self.center - self.width / 2 < 20 and self.center_speed < 0: + self.center_speed += 1 + if self.center + self.width / 2 > 80 and self.center_speed > 0: + self.center_speed -= 1 + if self.width < 32 and self.width_speed < 0: + self.width_speed += 1 + if self.width > 60 and self.width_speed > 0: + self.width_speed -= 1 + self.walls.pop(0) + self.walls.append((self.center, self.width)) + + def _spawn_item(self) -> None: + if self.coins_left: + self.items.append(Item(103, self.coin_y)) + self.coins_left -= 1 + self.object_distance = 7 if self.coins_left else self.random.uniform(40, 60) + else: + self.items.append(Item(103, self.center + self.random.uniform(-10, 10), spike=True)) + self.coins_left = int(self.random.integers(3, 7)) + self.object_distance = self.random.uniform(40, 60) + side = self.random.choice((-1, 1)) + self.coin_y = self.center + side * self.width * self.random.uniform(0.2, 0.36) + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, max(0, int(self.y) // 10)), 1, 0] = True + for col in range(10): + center, width = self.walls[int((col * 10 + 5 + self.offset) // 10)] + for row in range(10): + state[row, col, 1] = abs(row * 10 + 5 - center) >= width / 2 + state[min(9, max(0, int(center) // 10)), col, 4] = True + for item in self.items: + if 0 <= item.x < 100 and 0 <= item.y < 100: + state[int(item.y) // 10, int(item.x) // 10, 3 if item.spike else 2] = True + velocity = min(511, max(0, round((self.vy + 2) * 100))) + for row, value in enumerate((self.steps, self.multiplier, velocity)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/gravitar.py b/runtime/minatar_synth/games/gravitar.py new file mode 100644 index 0000000000000000000000000000000000000000..866853a386d843baeb4aef09b49cda97b02e914a --- /dev/null +++ b/runtime/minatar_synth/games/gravitar.py @@ -0,0 +1,317 @@ +import numpy as np + + +HEADINGS = ((-1, 0), (0, 1), (1, 0), (0, -1)) +PLANET_LAYOUTS = ( + (7, 7, 6, 6, 7, 8, 8, 7, 7, 6), + (8, 7, 7, 6, 5, 5, 6, 7, 8, 8), + (6, 6, 7, 8, 8, 7, 6, 5, 5, 6), +) + + +class GravitarEnvironment: + """Finite twelve-system gravity, fuel, bunker, and reactor campaign.""" + + score_cap = 147_000.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 10_800): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.mode = "map" + self.system = 0 + self.completed_planets: set[int] = set() + self.selected_destination = 0 + self.lives = 6 + self.fuel = 10_000 + self.score = 0.0 + self.next_bonus_score = 10_000.0 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self.player = [5, 5] + self.previous_player = self.player.copy() + self.heading = 0 + self.velocity = [0, 0] + self.projectile: list[int] | None = None + self.projectile_heading = 0 + self.shield_active = False + self.enemy_projectiles: list[list[int]] = [] + self.bunkers: set[tuple[int, int]] = set() + self.fuel_depots: set[tuple[int, int]] = set() + self.terrain = PLANET_LAYOUTS[0] + self.mission_steps = 0 + self.reactor_activated = False + self.reactor_countdown = 0 + self.destroyed_bunkers: set[tuple[int, int, int, int]] = set() + self.collected_depots: set[tuple[int, int, int, int]] = set() + + @property + def reverse_gravity(self) -> bool: + return (self.system // 3) % 2 == 1 + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + reward = self._act_map(action) if self.mode == "map" else self._act_flight(action) + self.score += reward + while self.score >= self.next_bonus_score: + self.lives = min(30, self.lives + 1) + self.next_bonus_score += 10_000.0 + self.steps += 1 + if self.steps >= self.horizon or self.fuel <= 0 or self.lives <= 0: + self.terminal = True + return reward, self.terminal + + def _act_map(self, action: int) -> float: + if action == 1: + self.selected_destination = (self.selected_destination - 1) % 4 + elif action == 3: + self.selected_destination = (self.selected_destination + 1) % 4 + elif action in (2, 4, 5): + if self.selected_destination == 3: + self._enter_reactor() + elif self.selected_destination not in self.completed_planets: + self._enter_planet(self.selected_destination) + return 0.0 + + def _enter_planet(self, planet: int) -> None: + self.mode = "planet" + self.terrain = PLANET_LAYOUTS[planet] + bunker_columns = ((1, 5, 8), (0, 4, 9), (2, 6, 8))[planet] + bunkers = {(self.terrain[column] - 1, column) for column in bunker_columns} + self.bunkers = { + bunker for bunker in bunkers if (self.system, planet, *bunker) not in self.destroyed_bunkers + } + depot_columns = ((3, 7), (2, 7), (1, 6))[planet] + depots = {(self.terrain[column] - 1, column) for column in depot_columns} + self.fuel_depots = { + depot for depot in depots if (self.system, planet, *depot) not in self.collected_depots + } + self._reset_ship() + + def _enter_reactor(self) -> None: + self.mode = "reactor" + self.terrain = (9, 8, 7, 6, 5, 5, 6, 7, 8, 9) + bunkers = {(6, 2), (6, 7)} + self.bunkers = { + bunker for bunker in bunkers if (self.system, 3, *bunker) not in self.destroyed_bunkers + } + self.fuel_depots = set() + self.reactor_activated = False + self.reactor_countdown = max(20, 60 - 3 * self.system) + self._reset_ship() + + def _reset_ship(self) -> None: + self.player = [1, 5] + self.previous_player = self.player.copy() + self.heading = 2 + self.velocity = [0, 0] + self.projectile = None + self.shield_active = False + self.enemy_projectiles = [] + self.mission_steps = 0 + + def _act_flight(self, action: int) -> float: + self.previous_player = self.player.copy() + self.shield_active = False + if action == 1: + self.heading = (self.heading - 1) % 4 + elif action == 3: + self.heading = (self.heading + 1) % 4 + elif action == 2: + self._thrust() + elif action == 4: + self.shield_active = self.fuel >= 10 + self._tractor() + elif action == 5 and self.projectile is None: + self.projectile = self.player.copy() + self.projectile_heading = self.heading + reward = self._move_projectiles() + if self.mode == "map": + return reward + if self.mode == "reactor" and self.reactor_activated and self.player[0] == 0: + return reward + self._advance_system() + self._apply_gravity_and_move() + if self.mode == "map": + return reward + reward += self._move_enemy_projectiles() + if self.mode == "map": + return reward + self._fire_bunkers() + self.mission_steps += 1 + if self.mode == "reactor" and self.reactor_activated: + self.reactor_countdown -= 1 + if self.reactor_countdown <= 0: + self._lose_ship() + return reward + + def _thrust(self) -> None: + if self.fuel < 25: + return + direction = HEADINGS[self.heading] + self.velocity[0] = int(np.clip(self.velocity[0] + direction[0], -2, 2)) + self.velocity[1] = int(np.clip(self.velocity[1] + direction[1], -2, 2)) + self.fuel -= 25 + + def _tractor(self) -> None: + if self.fuel < 10: + return + self.fuel -= 10 + nearby = [depot for depot in self.fuel_depots if abs(depot[0] - self.player[0]) + abs(depot[1] - self.player[1]) <= 2] + if nearby: + depot = min(nearby) + self.fuel_depots.remove(depot) + self.collected_depots.add((self.system, self.selected_destination, *depot)) + self.fuel = min(20_000, self.fuel + 5_000) + + def _move_projectiles(self) -> float: + if self.projectile is None: + return 0.0 + direction = HEADINGS[self.projectile_heading] + self.projectile[0] += direction[0] + self.projectile[1] += direction[1] + position = tuple(self.projectile) + if position in self.bunkers: + self.bunkers.remove(position) + destination = self.selected_destination if self.mode == "planet" else 3 + self.destroyed_bunkers.add((self.system, destination, *position)) + self.projectile = None + reward = 250.0 + if self.mode == "planet" and not self.bunkers: + reward += self._complete_planet() + return reward + if self.mode == "reactor" and position == (4, 5): + self.reactor_activated = True + self.projectile = None + return 0.0 + if not (0 <= position[0] < 10 and 0 <= position[1] < 10): + self.projectile = None + elif position[0] >= self.terrain[position[1]]: + self.projectile = None + return 0.0 + + def _apply_gravity_and_move(self) -> None: + gravity = -1 if self.reverse_gravity else 1 + if self.mission_steps % 2 == 0: + self.velocity[0] = int(np.clip(self.velocity[0] + gravity, -2, 2)) + self.player[0] += int(np.sign(self.velocity[0])) + self.player[1] += int(np.sign(self.velocity[1])) + if self.player[0] < 0: + if self.mode == "planet": + self.player[0] = 0 + self.velocity[0] = 0 + else: + self.player[0] = 0 + return + if self.player[1] < 0 or self.player[1] > 9 or self.player[0] > 9: + self._lose_ship() + return + if self.player[0] >= self.terrain[self.player[1]]: + self._lose_ship() + + def _move_enemy_projectiles(self) -> float: + moved = [] + for projectile in self.enemy_projectiles: + projectile[0] += int(np.sign(self.player[0] - projectile[0])) + projectile[1] += int(np.sign(self.player[1] - projectile[1])) + if projectile == self.player: + if self.shield_active: + continue + self._lose_ship() + return 0.0 + if 0 <= projectile[0] < 10 and 0 <= projectile[1] < 10: + moved.append(projectile) + self.enemy_projectiles = moved + return 0.0 + + def _fire_bunkers(self) -> None: + if self.mission_steps % 12 or not self.bunkers: + return + bunker = min(self.bunkers, key=lambda item: abs(item[1] - self.player[1])) + self.enemy_projectiles.append(list(bunker)) + + def _complete_planet(self) -> float: + planet = self.selected_destination + self.completed_planets.add(planet) + bonus = float(max(0, 2_000 - 10 * self.mission_steps)) + self.mode = "map" + self.player = [5, 5] + if len(self.completed_planets) == 3: + bonus += self._advance_system() + return bonus + + def _advance_system(self) -> float: + self.system += 1 + self.completed_planets = set() + self.mode = "map" + self.player = [5, 5] + self.selected_destination = 0 + self.fuel = min(20_000, self.fuel + 7_000) + self.lives = min(30, self.lives + 2) + if self.system >= 12: + self.terminal = True + return 4_000.0 + + def _lose_ship(self) -> None: + self.lives -= 1 + self.mode = "map" + self.player = [5, 5] + self.velocity = [0, 0] + self.projectile = None + self.enemy_projectiles = [] + if self.lives <= 0: + self.terminal = True + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + for bunker in self.bunkers: + state[*bunker, 1] = True + for projectile in self.enemy_projectiles: + state[*projectile, 1] = True + for depot in self.fuel_depots: + state[*depot, 2] = True + if self.mode == "reactor" and not self.reactor_activated: + state[4, 5, 2] = True + if self.projectile is not None: + state[*self.projectile, 3] = True + if self.shield_active: + state[*self.player, 3] = True + state[*self.previous_player, 4] = True + if self.mode != "map": + for column, floor in enumerate(self.terrain): + state[floor:, column, 4] = True + for bit in range(4): + state[9, bit, 5] = bool(self.system & (1 << bit)) + for bit in range(5): + state[8, bit, 5] = bool(self.lives & (1 << bit)) + fuel_bucket = min(31, self.fuel // 625) + for bit in range(5): + state[7, bit, 5] = bool(fuel_bucket & (1 << bit)) + state[6, self.heading, 5] = True + state[5, self.selected_destination, 5] = True + for planet in self.completed_planets: + state[4, planet, 5] = True + state[3, self.velocity[0] + 2, 5] = True + state[2, self.velocity[1] + 2, 5] = True + state[1, 0, 5] = self.mode == "map" + state[1, 1, 5] = self.mode == "planet" + state[1, 2, 5] = self.mode == "reactor" + state[1, 3, 5] = self.reverse_gravity + state[1, 4, 5] = self.reactor_activated + return state diff --git a/runtime/minatar_synth/games/gravity_bubble.py b/runtime/minatar_synth/games/gravity_bubble.py new file mode 100644 index 0000000000000000000000000000000000000000..14453a33dbf7e88fa7ec08df05df3b84762a150e --- /dev/null +++ b/runtime/minatar_synth/games/gravity_bubble.py @@ -0,0 +1,179 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Body: + x: float + y: float + vx: float + vy: float + size: float + + def move(self) -> None: + self.x += self.vx + self.y += self.vy + if self.x > 95 or self.x < 5: + self.vx *= -1 + + +@dataclass +class Bubble: + x: float + y: float + size: float + life: int = 180 + + +@dataclass +class Wall: + x: float + y: float + width: float + + def bounce(self, body: Body, damping: float) -> None: + clearance = (body.size + 4) / 2 + if abs(body.x - self.x) < (self.width + body.size) / 2 and abs(body.y - self.y) < clearance: + body.vy *= -damping + body.y = self.y + (clearance + 1) * (-1 if body.y < self.y else 1) + + +class GravityBubbleEnvironment: + score_cap = 2000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.player = Body(50, 50, 1, 0, 6) + self.height = 0.0 + self.steps = self.frames = self.best_height = self.hold = 0 + self.next_wall = 150.0 + self.next_enemy = 60.0 + self.pressed = self.terminal = False + self.preview = Bubble(50, 50, 8) + self.bubbles: list[Bubble] = [] + self.enemies: list[Body] = [] + self.walls: list[Wall] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + released = self.pressed and not pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(released and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, released: bool) -> int: + player = self.player + player.vy = (player.vy + 0.025) * 0.995 + player.move() + scroll = max(0, (60 - player.y) * 0.5) + player.y += scroll + self.height += scroll + for objects in (self.bubbles, self.enemies, self.walls): + for obj in objects: + obj.y += scroll + if self.pressed: + self.hold += 1 + x = player.x + vx = player.vx + for _ in range(self.hold): + x += vx + if x > 95 or x < 5: + vx *= -1 + self.preview = Bubble(x, player.y + player.vy * self.hold, 8 + min(25, self.hold * 0.2)) + else: + if released: + self.bubbles.append(self.preview) + self.hold = 0 + altitude = self.height + max(0, 100 - player.y) + self._spawn(altitude) + self.frames += 1 + for bubble in self.bubbles: + bubble.life -= 1 + radius = bubble.size * min(1, bubble.life / 150) + if math.hypot(player.x - bubble.x, player.y - bubble.y) < radius + 9: + player.vy -= 0.05 + reward = max(0, int(altitude) - self.best_height) + self.best_height = max(self.best_height, int(altitude)) + surviving = [] + for enemy in self.enemies: + inside = False + for bubble in self.bubbles: + radius = bubble.size * min(1, bubble.life / 150) + inside = math.hypot(enemy.x - bubble.x, enemy.y - bubble.y) < radius + enemy.size / 2 + if inside: + enemy.vy -= 0.08 + if not inside: + enemy.vy += 0.02 + enemy.move() + for wall in self.walls: + wall.bounce(enemy, 0.6) + if math.hypot(player.x - enemy.x, player.y - enemy.y) < (6 + enemy.size) / 2 + 2: + player.vy += enemy.vy * 1.5 + reward += 100 + elif enemy.y <= 110: + surviving.append(enemy) + self.enemies = surviving + self.bubbles = [bubble for bubble in self.bubbles if bubble.life] + for wall in self.walls: + wall.bounce(player, 0.8) + self.walls = [wall for wall in self.walls if wall.y <= 110] + self.terminal = player.y > 105 + return reward + + def _spawn(self, altitude: float) -> None: + level = int(altitude // 100) + 1 + if self.frames >= self.next_enemy: + speed = self.random.uniform(0.2, 0.25 + math.sqrt(level) * 0.08) + self.enemies.append(Body(self.random.uniform(15, 85), -5, self.random.uniform(-0.6, 0.6), + speed, 7 + min(3, level // 2))) + interval = max(45, 120 - level * 10) + self.next_enemy = self.frames + interval * self.random.uniform(0.7, 1.3) + if level > 2 and altitude >= self.next_wall: + width = self.random.uniform(25, 50) + self.walls.append(Wall(self.random.uniform(width / 2, 100 - width / 2), -5, width)) + self.next_wall = altitude + self.random.uniform(70, 150) + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + player = self.player + state[min(9, max(0, int(player.y) // 10)), int(player.x) // 10, 0] = True + for enemy in self.enemies: + if 0 <= enemy.y < 100: + state[int(enemy.y) // 10, int(enemy.x) // 10, 1] = True + for wall in self.walls: + if 0 <= wall.y < 100: + state[int(wall.y) // 10, int(wall.x - wall.width / 2) // 10: + int(wall.x + wall.width / 2) // 10 + 1, 2] = True + for channel, bubbles in ((3, self.bubbles), (4, [self.preview] if self.pressed else [])): + for bubble in bubbles: + radius = bubble.size * min(1, bubble.life / 150) + rows, cols = np.ogrid[5:100:10, 5:100:10] + state[:, :, channel] |= (cols - bubble.x) ** 2 + (rows - bubble.y) ** 2 < radius ** 2 + velocity = min(511, max(0, round((player.vy + 5) * 50))) + for row, value in enumerate((self.steps, min(511, self.hold), velocity)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, player.vx > 0 + return state diff --git a/runtime/minatar_synth/games/gravity_drift.py b/runtime/minatar_synth/games/gravity_drift.py new file mode 100644 index 0000000000000000000000000000000000000000..a00f4b5769d237268b494ef5bb0f57080232034e --- /dev/null +++ b/runtime/minatar_synth/games/gravity_drift.py @@ -0,0 +1,98 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Object: + x: float + y: float + size: float + + +class GravityDriftEnvironment: + score_cap = 4000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x, self.y, self.vy = 20.0, 50.0, 0.0 + self.steps = self.frames = 0 + self.multiplier = 1 + self.reversed = self.pressed = self.terminal = False + self.stars: list[Object] = [] + self.asteroids: list[Object] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self) -> int: + self.x += ((80 if self.reversed else 20) - self.x) * 0.05 + self.vy = (self.vy + 0.12 - 0.25 * self.pressed) * 0.95 + self.y += self.vy + if not 0 <= self.y <= 100: + self.terminal = True + return 0 + spawn_x = -5 if self.reversed else 105 + if self.frames % 25 == 0: + target = min(100, max(0, self.y + self.random.uniform(-9, 9))) + self.asteroids.append(Object(spawn_x, target, self.random.uniform(5, 10))) + if self.frames % 120 == 0: + self.stars.append(Object(spawn_x, self.random.uniform(20, 80), 4)) + self.frames += 1 + remaining = [] + for star in self.stars: + star.x += 0.5 if self.reversed else -0.5 + if self._hits_player(star): + self.reversed = not self.reversed + self.multiplier += 1 + elif -10 < star.x < 110: + remaining.append(star) + self.stars = remaining + for asteroid in self.asteroids: + asteroid.x += 1 if self.reversed else -1 + if self._hits_player(asteroid): + self.terminal = True + self.asteroids = [asteroid for asteroid in self.asteroids if -10 < asteroid.x < 110] + return 0 if self.terminal else self.multiplier + + def _hits_player(self, obj: Object) -> bool: + extent = obj.size / 2 + 2.5 + return abs(obj.x - self.x) < extent and abs(obj.y - self.y) < extent + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, max(0, int(self.y) // 10)), int(self.x) // 10, 0] = True + for channel, objects in ((1, self.asteroids), (2, self.stars)): + for obj in objects: + if 0 <= obj.x < 100: + state[min(9, int(obj.y) // 10), int(obj.x) // 10, channel] = True + state[:, 8 if self.reversed else 2, 3] = True + state[min(9, max(0, int(self.y + 4 * self.vy) // 10)), int(self.x) // 10, 4] = True + for row, value in enumerate((self.steps, self.multiplier, round((self.vy + 3) * 80))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.reversed + return state diff --git a/runtime/minatar_synth/games/gravity_well.py b/runtime/minatar_synth/games/gravity_well.py new file mode 100644 index 0000000000000000000000000000000000000000..62e35f4b2e095ae93398e4a438026b4369606fc1 --- /dev/null +++ b/runtime/minatar_synth/games/gravity_well.py @@ -0,0 +1,125 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class BlackHole: + x: float + y: float + radius: float + + +class GravityWellEnvironment: + score_cap = 243 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x = self.y = 50.0 + self.vx = self.vy = 0.0 + self.radius = 9.0 + self.spawn_distance = 0.0 + self.steps = self.frames = 0 + self.pressed = self.terminal = False + self.holes: list[BlackHole] = [] + self.pulses: list[int] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tapped = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tapped and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap: bool) -> int: + reward = int(self.radius) if self.frames % 60 == 0 else 0 + self.frames += 1 + for hole in self.holes: + hole.x -= 0.5 + self.holes = [hole for hole in self.holes if hole.x >= -10] + self.spawn_distance -= 0.5 + if self.spawn_distance < 0: + radius = self.random.uniform(5, 9) + self.holes.append(BlackHole(100 + radius, self.random.uniform(10, 90), radius)) + self.spawn_distance += self.random.uniform(30, 40) + self.x += self.vx + self.y += self.vy + self.vx = (self.vx + self._edge_force(self.x, 110)) * 0.99 + self.vy = (self.vy + self._edge_force(self.y, 105)) * 0.99 + for hole in self.holes: + dx, dy = hole.x - self.x, hole.y - self.y + distance_squared = dx * dx + dy * dy + if distance_squared > 0: + self.vx += 0.1 * dx / distance_squared + self.vy += 0.1 * dy / distance_squared + if tap and self.radius > 2: + self.radius -= 1 + self.pulses.append(0) + for radius in self.pulses: + for hole in self.holes: + dx, dy = hole.x - self.x, hole.y - self.y + distance = math.hypot(dx, dy) + if 0 < distance < radius + 1 + hole.radius: + force = 0.5 / distance ** 1.5 + self.vx -= dx * force + self.vy -= dy * force + hole.x += dx * force + hole.y += dy * force + self.pulses = [radius + 1 for radius in self.pulses if radius < 20] + if any(math.hypot(h.x - self.x, h.y - self.y) < self.radius + h.radius for h in self.holes): + self.radius -= 0.2 + else: + self.radius = min(9, self.radius + 0.05) + self.terminal = self.radius < 1 + if (self.x < 0 and self.vx < 0) or (self.x > 100 and self.vx > 0): + self.vx *= -1 + if (self.y < 0 and self.vy < 0) or (self.y > 100 and self.vy > 0): + self.vy *= -1 + return reward + + @staticmethod + def _edge_force(position: float, far_edge: int) -> float: + return 1 / max(1, position + 10) ** 2 - 1 / max(1, far_edge - position) ** 2 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row = min(9, max(0, int(self.y) // 10)) + col = min(9, max(0, int(self.x) // 10)) + state[row, col, 0] = True + rows, cols = np.ogrid[5:100:10, 5:100:10] + for hole in self.holes: + state[:, :, 1] |= (cols - hole.x) ** 2 + (rows - hole.y) ** 2 < hole.radius ** 2 + if 0 <= hole.x < 100 and 0 <= hole.y < 100: + state[int(hole.y) // 10, int(hole.x) // 10, 2] = True + distance = np.hypot(cols - self.x, rows - self.y) + for radius in self.pulses: + state[:, :, 3] |= abs(distance - radius) < 5 + future_row = min(9, max(0, int(self.y + 4 * self.vy) // 10)) + future_col = min(9, max(0, int(self.x + 4 * self.vx) // 10)) + state[future_row, future_col, 4] = True + for gauge_row, value in enumerate((self.steps, round(self.radius * 50))): + for bit in range(9): + state[gauge_row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/grenadier.py b/runtime/minatar_synth/games/grenadier.py new file mode 100644 index 0000000000000000000000000000000000000000..b7af7ac70c485b7a6588af218a29d07407a725ce --- /dev/null +++ b/runtime/minatar_synth/games/grenadier.py @@ -0,0 +1,148 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Tank: + x: float + timer: float + interval: float + + +@dataclass +class Grenade: + x: float + y: float + vx: float + vy: float + + +class GrenadierEnvironment: + score_cap = 2000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x = 10.0 + self.mode = "cover" + self.angle = 0.0 + self.speed = 1.0 + self.spawn_timer = 0.0 + self.steps = 0 + self.pressed = self.terminal = False + self.holes = [10.0] + self.tanks: list[Tank] = [] + self.bullets: list[float] = [] + self.grenades: list[Grenade] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap, release = pressed and not self.pressed, self.pressed and not pressed + self.pressed = pressed + self.steps += 1 + reward = 0.0 + for frame in range(4): + reward += self._advance(tap and frame == 0, release and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return reward, self.terminal + + def _advance(self, tap: bool, release: bool) -> float: + scroll = (self.x - 10) * 0.05 + self.spawn_timer -= 1 + if self.spawn_timer < 0: + interval = 300 / (1 + self.random.random()) + self.tanks.append(Tank(203, self.random.uniform(0, interval), interval)) + self.spawn_timer = 200 / (1 + self.random.random()) + for tank in self.tanks: + tank.x -= 0.08 * self.speed + scroll + self.holes = [x - scroll for x in self.holes if x - scroll > -4] + reward = 0.0 + airborne = [] + for grenade in self.grenades: + grenade.x += grenade.vx + grenade.y += grenade.vy + grenade.vy += 0.1 + hit = next((tank for tank in self.tanks + if abs(tank.x - grenade.x) < 4 and abs(67 - grenade.y) < 4), None) + if hit is not None: + reward += max(0, hit.x) + self.tanks.remove(hit) + elif grenade.y > 68: + self.holes.append(grenade.x) + else: + airborne.append(grenade) + self.grenades = airborne + self.tanks = [tank for tank in self.tanks if tank.x > -4] + if not self.tanks: + self.spawn_timer *= 0.7 + for tank in self.tanks: + tank.timer -= 1 + if tank.x > 150 and self.mode != "cover" and tank.timer < 0: + self.bullets.append(tank.x - 5) + tank.timer = tank.interval + self.bullets = [x - 0.4 * self.speed - scroll for x in self.bullets + if x - 0.4 * self.speed - scroll > -4] + self.holes = [x for x in self.holes if all(abs(tank.x - x) >= 6 for tank in self.tanks)] + self.x -= scroll + if self.mode == "cover": + self.speed += 0.05 + if tap: + self.mode = "run" + self.x += 6 + else: + self.terminal = any(abs(tank.x - self.x) < 5 for tank in self.tanks) + if any(abs(x - self.x - 5) < 6 for x in self.holes): + self.x += 1 + else: + self.speed += (1 - self.speed) * 0.1 + if self.mode == "run": + self.x += 0.8 + if any(abs(x - self.x) < 5 for x in self.holes): + self.mode = "cover" + elif tap: + self.mode = "aim" + self.angle = 0.0 + elif release or self.angle < -1: + speed = 4 - self.angle * 0.5 + self.grenades.append(Grenade(self.x, 67, speed * math.cos(self.angle), + speed * math.sin(self.angle))) + self.mode = "run" + else: + self.angle -= 0.02 + self.terminal = any(abs(tank.x - self.x) < 5 for tank in self.tanks) or any( + abs(x - self.x) < 4 for x in self.bullets + ) + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[9 if self.mode == "cover" else 8, int(self.x) // 20, 0] = True + for channel, positions in ((1, self.holes), (2, [tank.x for tank in self.tanks]), (3, self.bullets)): + for x in positions: + if 0 <= x < 200: + state[8, int(x) // 20, channel] = True + for grenade in self.grenades: + if 0 <= grenade.x < 200 and 0 <= grenade.y < 80: + state[int(grenade.y) // 8, int(grenade.x) // 20, 4] = True + for row, value in enumerate((self.steps, round(-100 * self.angle))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :3, 5] = self.pressed, self.mode == "cover", self.mode == "aim" + return state diff --git a/runtime/minatar_synth/games/growth.py b/runtime/minatar_synth/games/growth.py new file mode 100644 index 0000000000000000000000000000000000000000..a01af069ab0d4a9125f7ba163341c63f98da075a --- /dev/null +++ b/runtime/minatar_synth/games/growth.py @@ -0,0 +1,105 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Enemy: + x: float + size: float + + @property + def screen_x(self) -> float: + return self.x / (1 + max(0, self.x - 100) / 300) + + +class GrowthEnvironment: + score_cap = 3500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x, self.speed, self.size = 9.0, 1.0, 5.0 + self.spawn_distance = 0.0 + self.steps = 0 + self.pressed = self.terminal = False + self.enemies: list[Enemy] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self) -> int: + scroll = max(0, (self.x - 9) * 0.5) + target = 50 if self.pressed else 5 + self.size += (target - self.size) * min(999, max(1, self.speed)) * 0.01 + self.speed += (15 / self.size - 1) * 0.02 + self.x += self.speed - scroll + front = self.x + self.size / 2 + if front < 1: + self.terminal = True + return 0 + self.spawn_distance -= scroll + if self.spawn_distance < 0: + size = 3.0 + if self.random.random() >= 0.8: + width, height = self.random.uniform(0, 5, 2) + size = width * height + 3 + self.enemies.append(Enemy(400, size if size >= 7 else 3)) + self.spawn_distance += self.random.uniform(30, 50) + reward = 0 + remaining = [] + for enemy in self.enemies: + enemy.x -= scroll + if enemy.screen_x >= front: + remaining.append(enemy) + elif enemy.size > self.size: + self.terminal = True + break + else: + reward += math.ceil(min(999, max(1, self.speed)) * enemy.size) + if not self.terminal: + self.enemies = remaining + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + top = max(0, int((60 - self.size) // 7)) + front = min(9, max(0, int((self.x + self.size / 2) // 20))) + state[top:9, :front + 1, 0] = True + for enemy in self.enemies: + if 0 <= enemy.screen_x <= 200: + col = min(9, int(enemy.screen_x // 20)) + state[int((60 - enemy.size) // 7):9, col, 1 if enemy.size <= self.size else 2] = True + state[9, :, 3] = True + if self.enemies: + nearest = self.enemies[0] + state[8, min(9, max(0, int(nearest.screen_x // 20))), 4] = True + speed = min(511, max(0, round((self.speed + 5) * 8))) + for row, value in enumerate((self.steps, round(self.size * 10), speed)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/hero.py b/runtime/minatar_synth/games/hero.py new file mode 100644 index 0000000000000000000000000000000000000000..4e5549db6054c17479436018cecfef6d78357ac5 --- /dev/null +++ b/runtime/minatar_synth/games/hero.py @@ -0,0 +1,257 @@ +import numpy as np + + +class HeroEnvironment: + """Twenty-level prop-pack mine rescue with finite reward identities.""" + + score_cap = 79_700.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 6_000): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.level = 1 + self.lives = 4 + self.score = 0.0 + self.next_bonus_life = 20_000.0 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self.claimed_enemies: set[tuple[int, int]] = set() + self.claimed_walls: set[tuple[int, int]] = set() + self._start_level() + + def _start_level(self) -> None: + self.player = [0, 1] + self.previous_player = self.player.copy() + self.facing = 1 + self.power = max(140, 300 - 5 * (self.level - 1)) + self.dynamite = 6 + self.laser: list[int] | None = None + self.laser_direction = 1 + self.bomb: dict[str, object] | None = None + wall_columns = (3, 6) + wall_rows = (3 + self.level % 2, 6 - self.level % 2) + self.walls = { + (row, column): 3 + for row, column in zip(wall_rows, wall_columns, strict=True) + if (self.level, row * 10 + column) not in self.claimed_walls + } + enemy_positions = ((2, 7), (5, 2), (7, 7)) + self.enemies = { + index: [row, (column + self.level) % 9] + for index, (row, column) in enumerate(enemy_positions) + if (self.level, index) not in self.claimed_enemies + } + self.enemy_directions = {index: 1 if (index + self.level) % 2 else -1 for index in self.enemies} + self.miner = [8, 8] + self.lava_columns = set(range(2, 8)) if self.level >= 5 else set() + self.raft = [8, 2 + self.level % 6] + self.raft_direction = 1 + self.lantern = [1, 8] + self.lantern_lit = True + self.level_steps = 0 + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + level_before = self.level + lives_before = self.lives + reward = self._apply_action(action) + reward += self._move_laser() + reward += self._tick_bomb() + if self.level != level_before or self.lives != lives_before: + return self._finish_step(reward, consume_power=False) + if self.terminal: + return self._finish_step(reward) + self._apply_gravity(action) + if self.terminal: + return self._finish_step(reward) + self._move_enemies() + self._move_raft() + self._resolve_contacts() + if not self.terminal and self.player == self.miner: + reward += self._rescue_miner() + transitioned = self.level != level_before or self.lives != lives_before + return self._finish_step(reward, consume_power=not transitioned) + + def _finish_step(self, reward: float, consume_power: bool = True) -> tuple[float, bool]: + self.score += reward + while self.score >= self.next_bonus_life: + self.lives = min(20, self.lives + 1) + self.next_bonus_life += 20_000.0 + if consume_power: + self.power -= 1 + self.level_steps += 1 + self.steps += 1 + if self.power <= 0 and not self.terminal: + self._lose_life() + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _apply_action(self, action: int) -> float: + if action == 1: + self.player[1] = max(0, self.player[1] - 1) + self.facing = -1 + elif action == 2: + self.player[0] = max(0, self.player[0] - 1) + elif action == 3: + self.player[1] = min(9, self.player[1] + 1) + self.facing = 1 + elif action == 4 and self.dynamite > 0 and self.bomb is None: + self.dynamite -= 1 + self.bomb = {"position": self.player.copy(), "fuse": 3} + elif action == 5 and self.laser is None: + self.laser = self.player.copy() + self.laser_direction = self.facing + return 0.0 + + def _move_laser(self) -> float: + if self.laser is None: + return 0.0 + self.laser[1] += self.laser_direction + position = tuple(self.laser) + for index, enemy in list(self.enemies.items()): + if enemy == self.laser: + del self.enemies[index] + self.claimed_enemies.add((self.level, index)) + self.laser = None + return 50.0 + if position in self.walls: + self.walls[position] -= 1 + if self.walls[position] <= 0: + del self.walls[position] + self.claimed_walls.add((self.level, position[0] * 10 + position[1])) + self.laser = None + elif self.laser == self.lantern: + self.lantern_lit = False + self.laser = None + elif not 0 <= self.laser[1] < 10: + self.laser = None + return 0.0 + + def _tick_bomb(self) -> float: + if self.bomb is None: + return 0.0 + self.bomb["fuse"] = int(self.bomb["fuse"]) - 1 + if self.bomb["fuse"]: + return 0.0 + bomb_position = list(self.bomb["position"]) + self.bomb = None + reward = 0.0 + for position in list(self.walls): + if abs(position[0] - bomb_position[0]) + abs(position[1] - bomb_position[1]) <= 2: + del self.walls[position] + identity = (self.level, position[0] * 10 + position[1]) + if identity not in self.claimed_walls: + self.claimed_walls.add(identity) + reward += 75.0 + for index, enemy in list(self.enemies.items()): + if abs(enemy[0] - bomb_position[0]) + abs(enemy[1] - bomb_position[1]) <= 2: + del self.enemies[index] + identity = (self.level, index) + if identity not in self.claimed_enemies: + self.claimed_enemies.add(identity) + reward += 50.0 + if abs(self.player[0] - bomb_position[0]) + abs(self.player[1] - bomb_position[1]) <= 1: + self._lose_life() + return reward + + def _apply_gravity(self, action: int) -> None: + if action != 2: + target = [min(8, self.player[0] + 1), self.player[1]] + if tuple(target) not in self.walls: + self.player = target + if tuple(self.player) in self.walls: + self.player = self.previous_player.copy() + + def _move_enemies(self) -> None: + if self.level_steps % 2: + return + for index, enemy in self.enemies.items(): + next_column = enemy[1] + self.enemy_directions[index] + if next_column < 0 or next_column > 9 or (enemy[0], next_column) in self.walls: + self.enemy_directions[index] *= -1 + else: + enemy[1] = next_column + + def _move_raft(self) -> None: + if not self.lava_columns: + return + carried = self.player == self.raft + self.raft[1] += self.raft_direction + if self.raft[1] <= min(self.lava_columns) or self.raft[1] >= max(self.lava_columns): + self.raft_direction *= -1 + if carried: + self.player = self.raft.copy() + + def _resolve_contacts(self) -> None: + if any(enemy == self.player for enemy in self.enemies.values()): + self._lose_life() + return + if self.player[0] == 8 and self.player[1] in self.lava_columns and self.player != self.raft: + self._lose_life() + + def _rescue_miner(self) -> float: + reward = 1_000.0 + 50.0 * self.dynamite + float(self.power * self.level) + self.level += 1 + if self.level > 20: + self.terminal = True + else: + self._start_level() + return reward + + def _lose_life(self) -> None: + self.lives -= 1 + if self.lives <= 0: + self.terminal = True + else: + self._start_level() + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + for enemy in self.enemies.values(): + state[*enemy, 1] = True + for column in self.lava_columns: + state[8, column, 1] = True + state[*self.miner, 2] = True + state[*self.raft, 2] = True + if self.lantern_lit: + state[*self.lantern, 2] = True + for wall in self.walls: + state[*wall, 3] = True + if self.laser is not None: + state[*self.laser, 3] = True + if self.bomb is not None: + state[*self.bomb["position"], 3] = True + state[*self.previous_player, 4] = True + for bit in range(5): + state[9, bit, 5] = bool(self.level & (1 << bit)) + for bit in range(3): + state[7, bit, 5] = bool(self.dynamite & (1 << bit)) + for bit in range(9): + state[6, bit, 5] = bool(self.power & (1 << bit)) + for bit in range(5): + state[5, bit, 5] = bool(self.lives & (1 << bit)) + state[4, 0, 5] = self.facing > 0 + state[4, 1, 5] = self.lantern_lit + if self.bomb is not None: + state[4, 2 + int(self.bomb["fuse"]), 5] = True + return state diff --git a/runtime/minatar_synth/games/hexmin.py b/runtime/minatar_synth/games/hexmin.py new file mode 100644 index 0000000000000000000000000000000000000000..1bac870d54279bed11350086c4b32fb2079aaed3 --- /dev/null +++ b/runtime/minatar_synth/games/hexmin.py @@ -0,0 +1,100 @@ +import numpy as np + + +HORIZON = 300 +MIN_PULSE_INTERVAL = 2 +MAX_SPAWNS = (HORIZON + MIN_PULSE_INTERVAL - 1) // MIN_PULSE_INTERVAL +RAYS = ( + ((4, 6), (4, 7), (4, 8), (4, 9)), + ((6, 5), (7, 6), (8, 7), (9, 8)), + ((6, 3), (7, 2), (8, 1), (9, 0)), + ((4, 3), (4, 2), (4, 1), (4, 0)), + ((3, 3), (2, 2), (1, 1), (0, 0)), + ((3, 5), (2, 6), (1, 7), (0, 8)), +) + + +class HexminEnvironment: + score_cap = MAX_SPAWNS * (1 + 3 * (MAX_SPAWNS - 1)) + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.lanes = [0] * len(RAYS) + self.orientation = self.steps = self.last_action = self.repeat = self.spawn_wait = 0 + self.pulse = 1 + self.multiplier = 1 + self.terminal = False + + @property + def gates(self) -> tuple[int, int]: + return self.orientation, (self.orientation + 2) % len(RAYS) + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + self.steps += 1 + self.repeat = max(0, self.repeat - 1) + if action in (1, 3, 5) and (action != self.last_action or self.repeat == 0): + self.orientation = (self.orientation + (-1 if action == 1 else 1)) % len(RAYS) + self.multiplier = max(1, (9 * self.multiplier + 9) // 10 - 1) + self.repeat = 2 + self.last_action = action + + self.pulse -= 1 + if self.pulse == 0: + self.lanes = [age + 1 if age else 0 for age in self.lanes] + if max(self.lanes) > 4: + self.terminal = True + return 0.0, True + if self.spawn_wait == 0: + start = int(self.random.integers(len(RAYS))) + for offset in range(len(RAYS)): + lane = (start + offset) % len(RAYS) + if self.lanes[lane] == 0: + self.lanes[lane] = 1 + break + self.spawn_wait = int(self.random.integers(max(1, 4 - self.steps // 100))) + else: + self.spawn_wait -= 1 + self.pulse = max(MIN_PULSE_INTERVAL, 4 - self.steps // 100) + + reward = 0 + for lane in range(len(RAYS)): + if self.lanes[lane] == 4 and lane in self.gates: + reward += self.multiplier + self.multiplier += 6 + self.lanes[lane] = 0 + self.terminal = self.steps >= self.horizon + return float(reward), self.terminal + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[4, 4, 0] = True + for lane, cells in enumerate(RAYS): + row, column = cells[0] + state[row, column, 3] = lane in self.gates + for row, column in cells[4 - min(self.lanes[lane], 4):]: + state[row, column, 1] = True + if self.lanes[lane] >= 4: + row, column = cells[0] + state[row, column, 2] = True + gauges = (self.orientation, self.steps, self.pulse, self.spawn_wait, + self.repeat, self.multiplier, self.last_action) + for row, value in enumerate(gauges): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/hit_blow_up.py b/runtime/minatar_synth/games/hit_blow_up.py new file mode 100644 index 0000000000000000000000000000000000000000..3b19e9616f374c0dc6c7300864b75439098cc064 --- /dev/null +++ b/runtime/minatar_synth/games/hit_blow_up.py @@ -0,0 +1,100 @@ +import numpy as np + + +class HitBlowUpEnvironment: + score_cap = 1000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.stage = self.action = 0 + self.terminal = False + self._new_stage() + + def _new_stage(self) -> None: + stage = self.stage % 6 + if stage == 0: + self.palette = self.random.permutation(6).tolist() + self.selector = self.palette[:3 + (stage + 1) // 2] + self.target = self.random.permutation(self.selector)[:2 + stage // 2].tolist() + self.cursor = self.cooldown = 0 + self.selector_y = 90.0 + self.guess: list[int] = [] + self.history: list[tuple[list[int], int, int]] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + previous = self.action + if self.random.random() >= self.sticky_action_prob: + self.action = action + self.steps += 1 + reward = 0.0 + if self.cooldown: + self.cooldown -= 4 + if not self.cooldown: + self.stage += 1 + self._new_stage() + else: + self.selector_y -= 0.2 * 2 ** (self.stage // 6) / (len(self.target) ** 2 + len(self.selector)) + if self.action == 1: + self.cursor = (self.cursor - 1) % len(self.selector) + elif self.action == 3: + self.cursor = (self.cursor + 1) % len(self.selector) + elif self.action == 5 and previous != 5: + reward = self._select() + self.terminal = not self.cooldown and self.selector_y - 3 - 6 * len(self.history) < 3 + self.terminal |= self.steps >= self.horizon + return reward, self.terminal + + def _select(self) -> float: + self.guess.append(self.selector[self.cursor]) + if len(self.guess) < len(self.target): + return 0.0 + hit = sum(a == b for a, b in zip(self.target, self.guess, strict=True)) + blow = len(set(self.target).intersection(self.guess)) - hit + self.history.append((self.guess, hit, blow)) + self.guess = [] + if hit == len(self.target): + self.cooldown = 60 + return (self.selector_y - 6 * len(self.history)) * (self.stage // 6 + 1) + return 0.0 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for index, (guess, hit, blow) in enumerate(self.history): + row, start = (index, 0) if index < 7 else (index - 7, 5) + for column, color in enumerate(guess, start): + state[row, column, color] = True + for bit in range(3): + state[row, start + 4, bit] = bool(hit & (1 << bit)) + state[row, start + 4, bit + 3] = bool(blow & (1 << bit)) + for column, color in enumerate(self.selector): + state[7, column, color] = True + if not self.cooldown: + state[9, self.cursor, 4] = True + for column in range(len(self.target)): + if column < len(self.guess): + state[8, column, self.guess[column]] = True + for row, value in ((8, round(self.selector_y)), (9, self.stage)): + for bit in range(6): + state[row, 9, bit] = bool(value & (1 << bit)) + state[row, 8, 5] = bool(value & 64) + state[9, 8, 0] = self.cooldown > 0 + state[9, 8, 1] = self.action == 5 + state[8, 5:5 + len(self.target), 0] = True + if self.cooldown: + for column, color in enumerate(self.target): + state[9, column, color] = True + return state diff --git a/runtime/minatar_synth/games/hoard_spout.py b/runtime/minatar_synth/games/hoard_spout.py new file mode 100644 index 0000000000000000000000000000000000000000..fb0700c155973e5e10939753d1623d68b18d5bea --- /dev/null +++ b/runtime/minatar_synth/games/hoard_spout.py @@ -0,0 +1,125 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Spark: + x: float + y: float + vx: float + vy: float + blue: bool + size: float = 1.0 + + +class HoardSpoutEnvironment: + score_cap = 150 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x = self.y = 50.0 + self.angle = self.random.uniform(0, math.tau) + self.speed, self.size = 1.0, 3.0 + self.spawn_timer = 0.0 + self.steps = 0 + self.blue = self.pressed = self.terminal = False + self.sparks: list[Spark] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + released = self.pressed and not pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(released and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, released: bool) -> int: + self.x += math.cos(self.angle) * self.speed + self.y += math.sin(self.angle) * self.speed + if released: + self.blue = not self.blue + if self.pressed: + if self.speed < 2: + self.speed += 0.01 + self.angle += 0.01 + else: + self.speed += (1 - self.speed) * 0.1 + self.spawn_timer -= 1.1 if self.pressed else 0.1 + if self.spawn_timer < 0: + angle = self.angle + math.pi + self.random.uniform(-0.2, 0.2) + self.sparks.append(Spark(self.x, self.y, math.cos(angle), math.sin(angle), not self.blue)) + self.spawn_timer = 9 + if not 0 <= self.x <= 100: + self.x = min(100, max(0, self.x)) + self.angle = math.pi - self.angle + if not 0 <= self.y <= 100: + self.y = min(100, max(0, self.y)) + self.angle = -self.angle + self.size = min(9, self.size - 0.002) + if self.size < 1: + self.terminal = True + return 0 + reward = 0 + remaining = [] + for spark in self.sparks: + spark.x += spark.vx + spark.y += spark.vy + spark.size += 0.2 if spark.size < 5 else 0.01 + if spark.size > 9: + continue + if spark.size >= 5 and self._hits_player(spark): + if spark.blue == self.blue: + reward += math.floor(self.size) + self.size += 0.2 + else: + self.size -= 0.4 + continue + if not 0 <= spark.x <= 100: + spark.x = min(100, max(0, spark.x)) + spark.vx *= -1 + if not 0 <= spark.y <= 100: + spark.y = min(100, max(0, spark.y)) + spark.vy *= -1 + remaining.append(spark) + self.sparks = remaining + return reward + + def _hits_player(self, spark: Spark) -> bool: + dx, dy = spark.x - self.x, spark.y - self.y + cosine, sine = math.cos(self.angle), math.sin(self.angle) + return (abs(dx * cosine + dy * sine) < (self.size + 3 + spark.size) / 2 + and abs(-dx * sine + dy * cosine) < (self.size + spark.size) / 2) + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, int(self.y) // 10), min(9, int(self.x) // 10), 0] = True + for spark in self.sparks: + channel = 1 + 2 * spark.blue + (spark.size >= 5) + state[min(9, int(spark.y) // 10), min(9, int(spark.x) // 10), channel] = True + for row, value in enumerate((self.steps, round(self.size * 50), + round((self.angle % math.tau) * 80), round(self.speed * 100))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.blue + return state diff --git a/runtime/minatar_synth/games/holes.py b/runtime/minatar_synth/games/holes.py new file mode 100644 index 0000000000000000000000000000000000000000..dd2d54f3f12a0ad694d67827cfe6cbe43857e83b --- /dev/null +++ b/runtime/minatar_synth/games/holes.py @@ -0,0 +1,162 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +SLOPE = math.tan(0.2) + + +@dataclass +class Ball: + x: float + y: float + vx: float = 0.0 + vy: float = 0.0 + + def reflect(self, nx: float, ny: float) -> None: + approach = min(0, self.vx * nx + self.vy * ny) + self.vx -= 1.7 * approach * nx + self.vy -= 1.7 * approach * ny + + +@dataclass +class Ramp: + x: float + y: float + direction: int + length: float + gate: int = -1 + + def height_at(self, distance: float) -> float: + return self.y + distance * SLOPE + + +class HolesEnvironment: + score_cap = 2000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.balls = [Ball(10, 0)] + self.ramps: list[Ramp] = [] + self.gate = self.next_gate = self.steps = 0 + self.scroll, self.scroll_line = 0.0, 60.0 + self.pressed = self.terminal = False + self._place_coin(20, 1) + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed: + self.gate ^= 1 + self.scroll_line -= 9 + self.pressed = pressed + self.steps += 1 + reward = 0.0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return reward, self.terminal + + def _place_coin(self, y: float, direction: int) -> None: + self.coin_x = 10 if direction == 1 else 89 + self.coin_y = y + self.coin_ramp = Ramp(7 if direction == 1 else 93, y + 9, direction, 9) + self.ramps.append(self.coin_ramp) + + def _extend(self) -> None: + ramp = self.coin_ramp + self.ramps.remove(ramp) + holes = [] + for x in self.random.uniform(15, 64.5, 5): + if all(abs(x - other) >= 21 for other in holes): + holes.append(x) + start = 0.0 + for x in sorted(holes): + edge = x - 6 + self._segment(ramp, start, edge - start - 5) + self._segment(ramp, edge, 7, self.next_gate) + if self.random.random() < 0.7: + self.next_gate ^= 1 + start = x + 6 + self._segment(ramp, start, 80 - start - 5) + self._place_coin(ramp.y + 80 * math.sin(0.2) + 9, -ramp.direction) + + def _segment(self, ramp: Ramp, start: float, length: float, gate: int = -1) -> None: + self.ramps.append(Ramp(ramp.x + start * ramp.direction, ramp.height_at(start), + ramp.direction, length, gate)) + + def _advance(self) -> float: + reward = self.scroll * len(self.balls) + self.coin_y -= self.scroll + for ramp in self.ramps: + ramp.y -= self.scroll + if ramp.y < 9: + ramp.y -= 1 + self.ramps = [ramp for ramp in self.ramps if ramp is self.coin_ramp or ramp.height_at(ramp.length) >= 0] + deepest = 0.0 + for ball in tuple(self.balls): + ball.vy = (ball.vy + 0.2) * 0.98 + ball.vx *= 0.98 + ball.x += ball.vx * 0.5 + ball.y += ball.vy * 0.5 - self.scroll + if ball.y < self.scroll_line + 20: + deepest = max(deepest, ball.y) + if math.hypot(ball.x - self.coin_x, ball.y - self.coin_y) < 5: + reward += 10 * len(self.balls) + if len(self.balls) < 9: + self.balls.append(Ball(self.random.uniform(30, 70), 0, vy=1)) + self._extend() + if ball.x < 6 or ball.x > 94: + ball.reflect(1 if ball.x < 6 else -1, 0) + ball.x = min(94, max(6, ball.x)) + for ramp in self.ramps: + distance = (ball.x - ramp.x) * ramp.direction + height = ramp.height_at(distance) + if ramp.gate in (-1, self.gate) and -1 < distance < ramp.length + 1 and abs(ball.y - height) < 3: + ball.reflect(math.sin(0.2) * ramp.direction, -math.cos(0.2)) + ball.y = height - 3 + self.balls = [ball for ball in self.balls if -1 <= ball.y <= 100] + for ball in self.balls: + for other in self.balls: + dx, dy = ball.x - other.x, ball.y - other.y + distance = math.hypot(dx, dy) + if 0 < distance <= 2: + ball.reflect(dx / distance, dy / distance) + self.scroll = max(0, deepest - self.scroll_line) * 0.1 + self.scroll_line += (60 - self.scroll_line) * 0.01 + self.terminal = not self.balls + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for ball in self.balls: + state[min(9, max(0, int(ball.y) // 10)), int(ball.x) // 10, 0] = True + for ramp in self.ramps: + channel = 1 if ramp.gate < 0 else 2 + ramp.gate + for distance in range(0, math.ceil(ramp.length) + 1, 2): + x, y = ramp.x + distance * ramp.direction, ramp.height_at(distance) + if 0 <= x < 100 and 0 <= y < 100: + state[int(y) // 10, int(x) // 10, channel] = True + if 0 <= self.coin_y < 100: + state[int(self.coin_y) // 10, self.coin_x // 10, 4] = True + for row, value in enumerate((self.steps, len(self.balls), round(self.scroll_line) + 256)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, bool(self.gate) + return state diff --git a/runtime/minatar_synth/games/hoppin_hazards.py b/runtime/minatar_synth/games/hoppin_hazards.py new file mode 100644 index 0000000000000000000000000000000000000000..3e4c293d393f9cdd12ced0daeaff7227901c9494 --- /dev/null +++ b/runtime/minatar_synth/games/hoppin_hazards.py @@ -0,0 +1,90 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Hazard: + x: float + y: float + direction: int + snake: bool + + +class HoppinHazardsEnvironment: + score_cap = 318.1 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.y, self.size = 90, 10 + self.spawn_timer = 0.0 + self.steps = 0 + self.pressed = self.terminal = False + self.hazards: list[Hazard] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + cents = 0 + for _ in range(4): + cents += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return cents / 100, self.terminal + + def _advance(self) -> int: + rise = 1 if self.pressed else -2 + self.y = min(90, max(10, self.y - rise)) + self.size = min(30, max(10, self.size + rise)) + self.spawn_timer -= 1 + if self.spawn_timer < 0: + direction = 1 if self.random.integers(2) == 0 else -1 + snake = bool(self.random.integers(2)) + self.hazards.append(Hazard(-10 if direction == 1 else 110, + self.random.uniform(10, 90), direction, snake)) + self.spawn_timer = self.random.uniform(45, 120) + half_size = self.size / 2 + for hazard in self.hazards: + hazard.x += hazard.direction + if hazard.snake: + # Use the bounding box of the leading semicircle. + center = hazard.x + 2.5 * hazard.direction + hit = abs(center - 50) < half_size + 4 and abs(hazard.y - self.y) < half_size + 6.5 + else: + hit = abs(hazard.x - 50) < half_size + 5 and abs(hazard.y - self.y) < half_size + 1.5 + self.terminal |= hit + self.hazards = [hazard for hazard in self.hazards if -10 <= hazard.x <= 110] + return self.size - 10 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + top = max(0, int((self.y - self.size / 2) // 10)) + bottom = min(9, int((self.y + self.size / 2) // 10)) + left = int((50 - self.size / 2) // 10) + right = int((50 + self.size / 2) // 10) + state[top:bottom + 1, left:right + 1, 0] = True + for hazard in self.hazards: + if 0 <= hazard.x < 100: + row, col = int(hazard.y // 10), int(hazard.x // 10) + state[row, col, 1 + 2 * hazard.snake + (hazard.direction < 0)] = True + for row, value in enumerate((self.steps, self.y, self.size)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/hopping_p.py b/runtime/minatar_synth/games/hopping_p.py new file mode 100644 index 0000000000000000000000000000000000000000..ad60ba2327a86b3a28a37efad1fae219b1bc45c2 --- /dev/null +++ b/runtime/minatar_synth/games/hopping_p.py @@ -0,0 +1,149 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +PATTERNS = ((1, 1, 0.65), (1, 0.8, 2), (1.6, 0.6, 2), (1, 2, 1.8)) + + +@dataclass +class Hopper: + x: float + y: float + direction: int + hop_x: float + hop_y: float + gravity: float + vx: float = 0 + vy: float = 0 + rest: int = 0 + power: bool = False + + def turn(self) -> None: + self.direction *= -1 + self.vx *= -1 + + def advance(self, fast: bool = False) -> float: + if self.rest: + self.rest -= 1 + if self.rest: + return self.y - 10 * abs(self.rest - 5) / 5 + self.vx = self.hop_x * self.direction + self.vy = self.hop_y + for _ in range(2 if fast else 1): + self.x += self.vx + self.y += self.vy + self.vy += self.gravity + if self.y > 90: + self.y = 90 + self.rest = 9 + if (self.x < 0 and self.direction < 0) or (self.x > 199 and self.direction > 0): + self.turn() + return self.y - 10 + + +class HoppingPEnvironment: + score_cap = 1000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.player = Hopper(99, 60, 1, 0.5, -1.2, 0.02, vx=0.5) + self.player_y = 50.0 + self.hoppers: list[Hopper] = [] + self.enemy_timer, self.pickup_timer = 0.0, 200.0 + self.power_ticks = self.steps = 0 + self.multiplier = 1 + self.first_pickup = True + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _spawn(self, power: bool, weak: bool = False) -> None: + direction = 1 if self.random.random() < 0.5 else -1 + pattern = (0.88, 1.25, 1.25) if power and self.first_pickup else PATTERNS[self.random.integers(4)] + sx, sy, sg = pattern + scale = 0.8 if power else 1 + self.hoppers.append(Hopper(-5 if direction == 1 else 205, 89, direction, + 0.5 * sx * scale * (0.5 if weak else 1), + -1.2 * sy * scale, 0.02 * sg * scale, power=power)) + + def _advance(self, tap: bool) -> int: + weak = self.power_ticks > 60 + self.enemy_timer -= 3 if weak else 1 + if self.enemy_timer < 0: + self._spawn(False, weak) + self.enemy_timer = self.random.uniform(100, 150) * math.sqrt(1 + len(self.hoppers)) + self.pickup_timer -= 1 + if self.pickup_timer < 0: + self._spawn(True) + self.first_pickup = False + self.pickup_timer = self.random.uniform(700, 999) + self.power_ticks = max(0, self.power_ticks - 1) + if not self.power_ticks: + self.multiplier = 1 + if tap: + self.player.turn() + self.player_y = self.player.advance(self.power_ticks > 0) - (2 if self.power_ticks else 0) + reward = 0 + remaining = [] + for hopper in self.hoppers: + y = hopper.advance() - (2 if hopper.power else 0) + extent = 3 * (1 + bool(self.power_ticks) + hopper.power) + if abs(self.player.x - hopper.x) >= extent or abs(self.player_y - y) >= extent: + remaining.append(hopper) + elif hopper.power: + self.power_ticks = int(300 * (1 + len(self.hoppers)) ** 0.25) + for other in self.hoppers: + other.turn() + elif self.power_ticks: + reward += self.multiplier + self.multiplier = min(64, self.multiplier * 2) + else: + self.terminal = True + remaining.append(hopper) + self.hoppers = remaining + if not self.hoppers: + self.enemy_timer = 0 + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, max(0, int(self.player_y) // 10)), min(9, max(0, int(self.player.x) // 20)), 0] = True + for hopper in self.hoppers: + if 0 <= hopper.x < 200: + height = hopper.y - (10 * abs(hopper.rest - 5) / 5 if hopper.rest else 10) + row, col = min(9, max(0, int(height) // 10)), int(hopper.x) // 20 + state[row, col, 3 if hopper.power else 1 + (hopper.direction < 0)] = True + state[9, :, 4] = True + values = (self.steps, min(511, self.power_ticks), self.multiplier, self.player.rest) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.player.direction > 0 + return state diff --git a/runtime/minatar_synth/games/hyper_laser.py b/runtime/minatar_synth/games/hyper_laser.py new file mode 100644 index 0000000000000000000000000000000000000000..804ea5b0b3b50985a917a85efe670714f09e9ac1 --- /dev/null +++ b/runtime/minatar_synth/games/hyper_laser.py @@ -0,0 +1,210 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Projectile: + x: float + y: float + vx: float + vy: float + age: int = 0 + + +@dataclass +class Enemy: + x: float + y: float + interval: float + charge: float + burst_size: int + heading: float = math.pi / 2 + target: float = math.pi / 2 + turret: float = math.pi / 2 + turn_timer: float = 0 + burst_timer: int = 0 + remaining: int = 0 + + @property + def shielded(self) -> bool: + return self.charge > 0 and self.y < 70 + + +class HyperLaserEnvironment: + score_cap = 150 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x, self.y = 50.0, 95.0 + self.aim = self.steps = self.action = self.laser_timer = 0 + self.block_timer = self.enemy_timer = 0.0 + self.multiplier = 1 + self.terminal = False + self.blocks: list[tuple[float, float]] = [] + self.enemies: list[Enemy] = [] + self.lasers: list[Projectile] = [] + self.shots: list[Projectile] = [] + + @property + def angle(self) -> float: + return -math.pi / 2 + self.aim * math.pi / 12 + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.action = action + self.steps += 1 + self.aim = min(5, max(-5, self.aim + (self.action == 4) - (self.action == 2))) + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _blocked(self, x: float, y: float) -> bool: + return any(abs(x - bx) < 4 and abs(y - by) < 4 for bx, by in self.blocks) + + def _advance(self) -> int: + shielded = self.action != 5 + if shielded: + self.x = min(93, max(7, self.x + 0.3 * ((self.action == 3) - (self.action == 1)))) + else: + self.laser_timer -= 1 + if self.laser_timer < 0: + self.lasers.append(Projectile(self.x, self.y, 3 * math.cos(self.angle), 3 * math.sin(self.angle))) + self.laser_timer = 9 + self.block_timer -= 0.1 + if self.block_timer < 0: + x = self.random.uniform(8, 92) + if not self._blocked(x, -9): + self.blocks.append((x, -9)) + self.block_timer = self.random.uniform(0, 16) + self.blocks = [(x, y + 0.1) for x, y in self.blocks + if y < 103 and (abs(x - self.x) >= 5 or abs(y - self.y) >= 5)] + self._move_lasers() + if not self.enemies: + self.block_timer = 0 + self.enemy_timer -= 1 + if self.enemy_timer < 0: + interval = self.random.uniform(60, 120) + self.enemies.append(Enemy(self.random.uniform(10, 90), -9, interval, + self.random.uniform(0, interval), int(self.random.integers(3, 9)))) + self.enemy_timer = self.random.uniform(150, 200) + reward = self._move_enemies() + remaining = [] + for shot in self.shots: + shot.x += shot.vx + shot.y += shot.vy + 0.1 + if abs(shot.x - self.x) < (6 if shielded else 4) and abs(shot.y - self.y) < (6 if shielded else 4): + if shielded: + reward += self.multiplier + self.multiplier += 1 + else: + self.terminal = True + elif 5 <= shot.x <= 95 and -9 <= shot.y <= 100 and not self._blocked(shot.x, shot.y): + remaining.append(shot) + self.shots = remaining + return reward + + def _move_lasers(self) -> None: + surviving = [] + for laser in self.lasers: + laser.y += 0.1 + x, y = laser.x + laser.vx, laser.y + laser.vy + hit_x = not 5 <= x <= 95 or self._blocked(x, laser.y) + hit_y = self._blocked(laser.x, y) + corner = not (hit_x or hit_y) and self._blocked(x, y) + if hit_x or corner: + laser.vx *= -1 + if hit_y or corner: + laser.vy *= -1 + laser.x += laser.vx + laser.y += laser.vy + laser.age += 1 + if -5 <= laser.y <= 105 and laser.age <= 120 and not self._blocked(laser.x, laser.y): + surviving.append(laser) + self.lasers = surviving + + def _move_enemies(self) -> int: + reward = 0 + remaining = [] + for enemy in self.enemies: + enemy.y += 0.1 + delta = (enemy.target - enemy.heading + math.pi) % math.tau - math.pi + if abs(delta) >= 0.1: + enemy.heading += delta * 0.1 + else: + enemy.heading = enemy.target + x = enemy.x + 0.1 * math.cos(enemy.heading) + y = enemy.y + 0.1 * math.sin(enemy.heading) + enemy.turn_timer -= 1 + if enemy.turn_timer < 0 or not 9 <= x <= 90 or self._blocked(x, y): + enemy.target += math.pi / 2 * self.random.choice((-1, 1)) + enemy.turn_timer = self.random.uniform(200, 300) + else: + enemy.x, enemy.y = x, y + enemy.charge -= 1 + shielded = enemy.shielded + if shielded: + angle = math.atan2(self.y - enemy.y, self.x - enemy.x) + enemy.turret = round(angle / (math.pi / 4)) * math.pi / 4 + if enemy.charge < 0: + if not enemy.remaining: + enemy.remaining = enemy.burst_size + enemy.burst_timer = 0 + enemy.burst_timer -= 1 + if enemy.burst_timer < 0: + self.shots.append(Projectile(enemy.x, enemy.y, 2 * math.cos(enemy.turret), + 2 * math.sin(enemy.turret))) + enemy.remaining -= 1 + enemy.burst_timer = 20 + if not enemy.remaining: + enemy.charge = enemy.interval + hit = [laser for laser in self.lasers if abs(laser.x - enemy.x) < 5 and abs(laser.y - enemy.y) < 5] + if hit: + self.lasers = [laser for laser in self.lasers if laser not in hit] + if hit and not shielded: + reward += self.multiplier * 10 + else: + self.terminal |= enemy.y > 99 + remaining.append(enemy) + self.enemies = remaining + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[9, int(self.x) // 10, 0] = True + for x, y in self.blocks: + if 0 <= y < 100: + state[int(y) // 10, int(x) // 10, 1] = True + for enemy in self.enemies: + if 0 <= enemy.y < 100: + row, col = int(enemy.y) // 10, int(enemy.x) // 10 + state[row, col, 2] = True + state[row, col, 3] |= enemy.shielded + for channel, projectiles in ((4, self.shots), (5, self.lasers)): + for p in projectiles: + if 0 <= p.x < 100 and 0 <= p.y < 100: + state[int(p.y) // 10, int(p.x) // 10, channel] = True + for row, value in enumerate((self.aim + 5, min(self.multiplier, 31))): + for bit in range(5): + state[bit, 0 if row == 0 else 9, 0] = bool(value & (1 << bit)) + state[5, 9, 0] = self.action != 5 + return state diff --git a/runtime/minatar_synth/games/i_slash.py b/runtime/minatar_synth/games/i_slash.py new file mode 100644 index 0000000000000000000000000000000000000000..f4657ea533549e14b91d02de65c34ca5f865cbac --- /dev/null +++ b/runtime/minatar_synth/games/i_slash.py @@ -0,0 +1,116 @@ +import numpy as np + + +class ISlashEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x, self.knockback, self.slash_distance, self.hit_x = 10.0, 0.0, 0.0, 0.0 + self.spawn_distance = 0.0 + self.steps = self.slash_timer = 0 + self.multiplier = 1 + self.ready = self.pressed = self.terminal = False + self.enemies: list[float] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + self.ready |= self.pressed and not pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self) -> int: + scroll = (self.x - 30) * 0.05 + self.spawn_distance -= scroll + (self.slash_timer == 0) + if not self.enemies or self.spawn_distance <= 0: + spacing = self.random.uniform(15, 30) + count = self.random.integers(3, 10) + self.enemies.extend(203 + i * spacing for i in range(count)) + self.spawn_distance = spacing * count + self.random.uniform(0, 30) + self.x -= scroll + self.knockback + if self.x < 0: + self.terminal = True + return 0 + self.knockback *= 0.9 + if self.knockback > 1: + self.hit_x -= scroll + slashing = self.ready and self.pressed + reward = 0 + if slashing and self.knockback < 1 and not self.slash_timer: + self.slash_distance = (self.enemies[0] - self.x) * 2 + reward += self._slash() + if not self.slash_timer: + if self.enemies and self.enemies[0] < self.x: + self._hit(0) + else: + self.slash_timer -= 1 + if not self.slash_timer and slashing and self.enemies: + reward += self._slash() + drift = scroll + (self.slash_timer == 0) + self.enemies = [x - drift for x in self.enemies] + return reward + + def _slash(self) -> int: + self.x += self.slash_distance + crossed = self.enemies[0] < self.x + overshot = len(self.enemies) > 1 and self.enemies[1] < self.x + if overshot: + self._hit(1) + else: + self.slash_timer = 10 if crossed else 0 + if crossed: + self.enemies.pop(0) + if not overshot: + reward = self.multiplier + self.multiplier += 1 + return reward + return 0 + + def _hit(self, index: int) -> None: + self.hit_x = self.enemies[index] + self.knockback = (self.x - self.hit_x + 9) * 0.25 + self.x = self.hit_x - 6 + self.slash_timer = 0 + self.multiplier = max(1, self.multiplier - 1) + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + col = min(9, max(0, int(self.x // 20))) + state[7, col, 0] = True + for x in self.enemies: + if 0 <= x < 200: + state[7, int(x // 20), 1] = True + if self.slash_timer: + left = max(0, min(9, int((self.x - self.slash_distance) // 20))) + state[7, min(left, col):max(left, col) + 1, 2] = True + if self.knockback > 1: + hit = min(9, max(0, int(self.hit_x // 20))) + state[7, min(hit, col):max(hit, col) + 1, 3] = True + state[8:, :, 4] = True + for row, value in enumerate((self.steps, self.multiplier, self.slash_timer, + min(511, round(self.knockback * 10)))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.ready + return state diff --git a/runtime/minatar_synth/games/ice_hockey.py b/runtime/minatar_synth/games/ice_hockey.py new file mode 100644 index 0000000000000000000000000000000000000000..96528910823ce9dbb59611595bcc6b1dbf7291c6 --- /dev/null +++ b/runtime/minatar_synth/games/ice_hockey.py @@ -0,0 +1,215 @@ +import numpy as np + + +class IceHockeyEnvironment: + """Two-on-two timed hockey with automatic nearest-player control.""" + + score_cap = 40.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 360): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.player_team = [[5, 3], [5, 1]] + self.opponent_team = [[4, 6], [4, 8]] + self.previous_player_team = [player.copy() for player in self.player_team] + self.previous_opponent_team = [player.copy() for player in self.opponent_team] + self.puck = [5, 5] + self.previous_puck = self.puck.copy() + self.puck_velocity = [0, 0] + self.possession: tuple[str, int] | None = None + self.player_stun = [0, 0] + self.opponent_stun = [0, 0] + self.player_score = 0 + self.opponent_score = 0 + self.clock = 0 + self.faceoff_timer = 3 + self.stick_phase = -1 + self.last_action = 0 + self.terminal = False + + def active_player(self, team: str) -> int: + players = self.player_team if team == "player" else self.opponent_team + return min( + range(2), + key=lambda index: (abs(players[index][0] - self.puck[0]) + abs(players[index][1] - self.puck[1]), index), + ) + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player_team = [player.copy() for player in self.player_team] + self.previous_opponent_team = [player.copy() for player in self.opponent_team] + self.previous_puck = self.puck.copy() + reward = 0.0 + if self.faceoff_timer > 0: + self.faceoff_timer -= 1 + if self.faceoff_timer == 0: + self._capture_loose_puck() + else: + self._move_player(action) + self._move_opponent() + self._capture_loose_puck() + reward = self._move_puck() + self.stick_phase = -1 if self.stick_phase == 1 else self.stick_phase + 1 + self.player_stun = [max(0, value - 1) for value in self.player_stun] + self.opponent_stun = [max(0, value - 1) for value in self.opponent_stun] + self.clock += 1 + if self.clock >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _move_player(self, action: int) -> None: + index = self.active_player("player") + if self.player_stun[index] > 0: + return + if action in (1, 2, 3, 4): + delta = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}[action] + self._move_skater(self.player_team[index], delta) + if self.possession == ("player", index): + self.puck = self.player_team[index].copy() + elif action == 5: + if self.possession == ("player", index): + self.possession = None + self.puck_velocity = [self.stick_phase, 1] + else: + self._check("player", index) + + def _move_opponent(self) -> None: + index = self.active_player("opponent") + if self.opponent_stun[index] > 0: + return + skater = self.opponent_team[index] + if self.possession == ("opponent", index) and skater[1] <= 3: + self.possession = None + self.puck_velocity = [self.stick_phase, -1] + return + target = [5, 0] if self.possession == ("opponent", index) else self.puck + row_delta = int(np.sign(target[0] - skater[0])) + column_delta = int(np.sign(target[1] - skater[1])) + delta = (0, column_delta) if column_delta else (row_delta, 0) + self._move_skater(skater, delta) + if self.possession == ("opponent", index): + self.puck = skater.copy() + elif any(abs(skater[0] - player[0]) + abs(skater[1] - player[1]) <= 1 for player in self.player_team): + self._check("opponent", index) + + @staticmethod + def _move_skater(skater: list[int], delta: tuple[int, int]) -> None: + skater[0] = int(np.clip(skater[0] + delta[0], 0, 9)) + skater[1] = int(np.clip(skater[1] + delta[1], 0, 9)) + + def _check(self, team: str, index: int) -> None: + checker = self.player_team[index] if team == "player" else self.opponent_team[index] + other_team = self.opponent_team if team == "player" else self.player_team + other_stun = self.opponent_stun if team == "player" else self.player_stun + for other_index, skater in enumerate(other_team): + if abs(checker[0] - skater[0]) + abs(checker[1] - skater[1]) <= 1: + other_stun[other_index] = 2 + if self.possession == (("opponent" if team == "player" else "player"), other_index): + self.possession = None + self.puck = skater.copy() + self.puck_velocity = [0, 0] + return + + def _capture_loose_puck(self) -> None: + if self.possession is not None or self.puck_velocity != [0, 0]: + return + candidates = [] + for team, players, stuns in ( + ("player", self.player_team, self.player_stun), + ("opponent", self.opponent_team, self.opponent_stun), + ): + for index, skater in enumerate(players): + distance = abs(skater[0] - self.puck[0]) + abs(skater[1] - self.puck[1]) + if distance <= 1 and stuns[index] == 0: + candidates.append((distance, 0 if team == "player" else 1, team, index)) + if candidates: + _, _, team, index = min(candidates) + self.possession = (team, index) + players = self.player_team if team == "player" else self.opponent_team + self.puck = players[index].copy() + + def _move_puck(self) -> float: + if self.possession is not None or self.puck_velocity == [0, 0]: + return 0.0 + self.puck[0] += self.puck_velocity[0] + self.puck[1] += self.puck_velocity[1] + if self.puck[0] < 0 or self.puck[0] > 9: + self.puck[0] = int(np.clip(self.puck[0], 0, 9)) + self.puck_velocity[0] *= -1 + if self.puck[1] >= 9: + if self.puck[0] in (4, 5): + self.player_score += 1 + self._faceoff() + return 1.0 + self.puck[1] = 9 + self.puck_velocity[1] = -1 + elif self.puck[1] <= 0: + if self.puck[0] in (4, 5): + self.opponent_score += 1 + self._faceoff() + return 0.0 + self.puck[1] = 0 + self.puck_velocity[1] = 1 + for team, players in (("player", self.player_team), ("opponent", self.opponent_team)): + for index, skater in enumerate(players): + if skater == self.puck: + self.possession = (team, index) + self.puck_velocity = [0, 0] + return 0.0 + return 0.0 + + def _faceoff(self) -> None: + self.player_team = [[5, 3], [5, 1]] + self.opponent_team = [[4, 6], [4, 8]] + self.puck = [5, 5] + self.puck_velocity = [0, 0] + self.possession = None + self.faceoff_timer = 3 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for skater in self.player_team: + state[*skater, 0] = True + for skater in self.opponent_team: + state[*skater, 1] = True + state[*self.puck, 2] = True + if self.possession is not None: + state[*self.puck, 3] = True + for skater in self.previous_player_team + self.previous_opponent_team: + state[*skater, 4] = True + state[*self.previous_puck, 4] = True + for bit in range(6): + state[9, bit, 5] = bool(self.player_score & (1 << bit)) + state[8, bit, 5] = bool(self.opponent_score & (1 << bit)) + for bit in range(9): + state[7, bit, 5] = bool(self.clock & (1 << bit)) + state[6, self.active_player("player"), 5] = True + state[6, 2 + self.active_player("opponent"), 5] = True + state[6, 4 + self.puck_velocity[0], 5] = True + state[5, 4 + self.puck_velocity[1], 5] = True + state[5, 7 + self.stick_phase, 5] = True + if self.possession is not None: + state[4, 0 if self.possession[0] == "player" else 1, 5] = True + state[4, 2 + self.possession[1], 5] = True + for index, stun in enumerate(self.player_stun): + state[3, index, 5] = stun > 0 + for index, stun in enumerate(self.opponent_stun): + state[3, 2 + index, 5] = stun > 0 + state[3, 4 : 4 + self.faceoff_timer, 5] = True + return state diff --git a/runtime/minatar_synth/games/in_tow.py b/runtime/minatar_synth/games/in_tow.py new file mode 100644 index 0000000000000000000000000000000000000000..fd3bb4366ff04015483f207553b0d4860efa1fad --- /dev/null +++ b/runtime/minatar_synth/games/in_tow.py @@ -0,0 +1,129 @@ +import numpy as np + + +HORIZON = 400 +UNIT = 4 +BIRD_COLUMN = 4 +MAX_CHICKS = BIRD_COLUMN +MIN_PLATFORM_SPACING = 4 + + +class InTowEnvironment: + score_cap = MAX_CHICKS * (2 + HORIZON // MIN_PLATFORM_SPACING) + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.y = 3 * UNIT + self.velocity = 0 + self.steps = self.distance = self.last_action = self.chicks = 0 + self.grounded = False + self.terminal = False + self.platforms = [(7, 1, 7), (5, 8, 11)] + self.pickups = {(4, 9)} + self.bullets: set[tuple[int, int]] = set() + self.history = [self.y] * MAX_CHICKS + self.next_platform = 4 + self.next_bullet = 12 + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def _scroll(self) -> None: + self.distance += 1 + self.platforms = [(row, left - 1, right - 1) + for row, left, right in self.platforms if right > 0] + self.pickups = {(row, column - 1) for row, column in self.pickups if column > 0} + if self.distance == self.next_platform: + row = int(self.random.integers(3, 9)) + width = int(self.random.integers(3, 5)) + self.platforms.append((row, 9, 8 + width)) + self.pickups.add((row - 1, 9 + width // 2)) + self.next_platform += width + int(self.random.integers(1, 4)) + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + pressed = action == 5 and self.last_action != 5 + self.last_action = action + self.steps += 1 + self.history = [self.y, *self.history[:-1]] + if self.steps % 2 == 0 or self.steps >= 200: + self._scroll() + if self.grounded: + self.grounded = any(left <= BIRD_COLUMN <= right and (row - 1) * UNIT == self.y + for row, left, right in self.platforms) + if pressed and (self.grounded or self.chicks): + if not self.grounded: + self.chicks -= 1 + self.grounded = False + self.velocity = -5 + previous_y = self.y + if not self.grounded: + gravity = int(action != 5 or self.steps % 2 == 0) + self.velocity = min(7, self.velocity + gravity) + self.y = max(0, self.y + self.velocity) + if self.velocity > 0: + landings = [(row - 1) * UNIT for row, left, right in self.platforms + if left <= BIRD_COLUMN <= right and previous_y <= (row - 1) * UNIT <= self.y] + if landings: + self.y = min(landings) + self.velocity = 0 + self.grounded = True + self.bullets = {(row, column - 1) for row, column in self.bullets if column > 0} + if self.steps == self.next_bullet: + self.bullets.add((int(self.random.integers(1, 9)), 9)) + self.next_bullet += int(self.random.integers(6, 11)) + reward = 0 + for row, column in sorted(self.pickups): + if column == BIRD_COLUMN and min(previous_y, self.y) // UNIT <= row <= max(previous_y, self.y) // UNIT: + self.pickups.remove((row, column)) + self.chicks = min(MAX_CHICKS, self.chicks + 1) + reward += self.chicks + head = (self.y // UNIT, BIRD_COLUMN) + if head in self.bullets: + self.bullets.remove(head) + if self.chicks: + self.chicks = 0 + self.grounded = False + self.velocity = 7 + else: + self.terminal = True + for index in range(self.chicks): + tail = (self.history[index] // UNIT, BIRD_COLUMN - index - 1) + if tail in self.bullets: + self.chicks = index + break + self.terminal |= self.y >= 10 * UNIT or self.steps >= self.horizon + return float(reward), self.terminal + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, self.y // UNIT), BIRD_COLUMN, 0] = True + for row, column in self.bullets: + state[row, column, 1] = True + for row, column in self.pickups: + if column < 10: + state[row, column, 2] = True + for row, left, right in self.platforms: + state[row, max(0, left): min(10, right + 1)] = True + for index in range(self.chicks): + state[self.history[index] // UNIT, BIRD_COLUMN - index - 1, 4] = True + values = (self.y, self.velocity + 5, self.steps, self.chicks, int(self.grounded), + int(self.last_action == 5), self.next_platform - self.distance, + self.next_bullet - self.steps, *self.history) + for index, value in enumerate(values): + for bit in range(7 if index != 2 else 9): + offset = index * 7 + bit + (2 if index > 2 else 0) + state[offset // 10, offset % 10, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/inf_range.py b/runtime/minatar_synth/games/inf_range.py new file mode 100644 index 0000000000000000000000000000000000000000..2cd685d01db9ae94815bc42198e0332a44de99fc --- /dev/null +++ b/runtime/minatar_synth/games/inf_range.py @@ -0,0 +1,131 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Arrow: + x: float + y: float + angle: float + + +class InfRangeEnvironment: + score_cap = 200 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x, self.y = 50.0, 80.0 + self.angle = self.tap_angle = -math.pi / 2 + self.scroll_x = self.scroll_y = 0.0 + self.steps = self.frames = 0 + self.tap_frame = -99 + self.spawn_timer = 200.0 + self.multiplier = 10.9 + self.pressed = self.terminal = False + self.arrows: list[Arrow] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap, release = pressed and not self.pressed, self.pressed and not pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0, release and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap: bool, release: bool) -> int: + self.x += math.cos(self.angle) + self.y += math.sin(self.angle) + if not 40 <= self.x <= 60: + self.scroll_x = (min(60, max(40, self.x)) - self.x) * 0.2 + if not 40 <= self.y <= 60: + self.scroll_y = (min(60, max(40, self.y)) - self.y) * 0.2 + self.x += self.scroll_x + self.y += self.scroll_y + drawn_angle = self.angle + if tap: + self.tap_angle, self.tap_frame = self.angle, self.frames + if self.pressed: + self.angle += 0.02 + if release and self.frames - self.tap_frame < 9: + self.angle = self.tap_angle + math.pi / 2 + self.frames += 1 + reward = 0 + remaining = [] + for arrow in self.arrows: + arrow.x = (arrow.x + math.cos(arrow.angle) * 0.5 + self.scroll_x + 3) % 106 - 3 + arrow.y = (arrow.y + math.sin(arrow.angle) * 0.5 + self.scroll_y + 3) % 106 - 3 + dx, dy = arrow.x - self.x, arrow.y - self.y + arrow_tip = (dx + 4 * math.cos(arrow.angle), dy + 4 * math.sin(arrow.angle)) + player_tip = (4 * math.cos(drawn_angle), 4 * math.sin(drawn_angle)) + body_hit = math.hypot(dx, dy) < 3 or math.dist((dx, dy), player_tip) < 3 + tip_hit = math.hypot(*arrow_tip) < 3 + if body_hit or tip_hit: + facing = abs((self.angle - arrow.angle) % math.tau - math.pi) < 0.7 + if facing: + arrow.angle += math.pi + arrow.x += math.cos(arrow.angle) + arrow.y += math.sin(arrow.angle) + self.angle += math.pi + elif body_hit: + reward += int(self.multiplier) + self.multiplier += 10 + continue + else: + self.terminal = True + remaining.append(arrow) + self.arrows = remaining + self.spawn_timer = self.spawn_timer - 1 if remaining else -1 + if self.spawn_timer < 0: + self._spawn() + self.multiplier = max(10.9, self.multiplier - 0.02) + return reward + + def _spawn(self) -> None: + for _ in range(9): + x, y = self.random.uniform(10, 90, 2) + dx, dy = (self.x - x + 50) % 100 - 50, (self.y - y + 50) % 100 - 50 + if abs(dx) + abs(dy) > 36: + self.arrows.append(Arrow(x, y, self.random.uniform(0, math.tau))) + self.spawn_timer = self.random.uniform(150, 250) + break + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for x, y, channel in ((self.x, self.y, 0), + (self.x + 8 * math.cos(self.angle), self.y + 8 * math.sin(self.angle), 1)): + if 0 <= x < 100 and 0 <= y < 100: + state[int(y) // 10, int(x) // 10, channel] = True + for arrow in self.arrows: + for x, y, channel in ((arrow.x, arrow.y, 2), + (arrow.x + 4 * math.cos(arrow.angle), arrow.y + 4 * math.sin(arrow.angle), 3), + (arrow.x + 10 * math.cos(arrow.angle), arrow.y + 10 * math.sin(arrow.angle), 4)): + if 0 <= x < 100 and 0 <= y < 100: + state[int(y) // 10, int(x) // 10, channel] = True + values = (self.steps, min(511, int(self.multiplier)), round(self.angle % math.tau * 80), + min(9, self.frames - self.tap_frame)) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/inkinh.py b/runtime/minatar_synth/games/inkinh.py new file mode 100644 index 0000000000000000000000000000000000000000..81ff44a26b48d50cc444da826c87597343036e2a --- /dev/null +++ b/runtime/minatar_synth/games/inkinh.py @@ -0,0 +1,134 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Orb: + x: float + y: float + life: int = 300 + phase: float = 0.0 + + +@dataclass +class Obstacle: + x: float + y: float + vx: float + + +class InkinhEnvironment: + score_cap = 150 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x, self.y = 50.0, 80.0 + self.vx = self.vy = 0.0 + self.angle = -math.pi / 2 + self.stretch = 1.0 + self.combo = self.combo_timer = self.steps = self.frames = 0 + self.pressed = self.terminal = False + self.orbs: list[Orb] = [] + self.obstacles: list[Obstacle] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self) -> int: + self.combo_timer = max(0, self.combo_timer - 1) + if not self.combo_timer: + self.combo = 0 + if self.frames % 72 == 0: + self.obstacles.append(Obstacle(self.random.uniform(10, 90), -8, self.random.uniform(-0.2, 0.2))) + if self.frames % 30 == 0 and len(self.orbs) < 8: + for _ in range(9): + x, y = self.random.uniform(15, 85), self.random.uniform(20, 90) + if math.hypot(x - self.x, y - self.y) > 20: + break + self.orbs.append(Orb(x, y, phase=self.random.uniform(0, math.tau))) + self.frames += 1 + self.angle += 0.02 if self.pressed else 0.05 + if self.pressed: + self.vx += 0.15 * math.cos(self.angle) + self.vy += 0.15 * math.sin(self.angle) + for orb in self.orbs: + dx, dy = self.x - orb.x, self.y - orb.y + distance = math.hypot(dx, dy) + if 0 < distance < 30: + orb.x += 0.6 * dx / distance + orb.y += 0.6 * dy / distance + self.vx *= 0.96 + self.vy *= 0.96 + self.x = min(95, max(5, self.x + self.vx)) + self.y = min(95, max(5, self.y + self.vy)) + self.stretch += (1 + math.hypot(self.vx, self.vy) * 0.3 - self.stretch) * 0.2 + reward = 0 + remaining = [] + for orb in self.orbs: + orb.life -= 1 + orb.phase += 0.1 + size = (4 + 2 * min(1, orb.life / 60)) * (1 + 0.15 * math.sin(orb.phase)) + if self._hits(orb.x, orb.y, size): + self.combo += 1 + self.combo_timer = 60 + reward += self.combo + elif orb.life: + remaining.append(orb) + self.orbs = remaining + for obstacle in self.obstacles: + obstacle.x += obstacle.vx + obstacle.y += 0.5 + self.terminal |= self._hits(obstacle.x, obstacle.y, 7) + self.obstacles = [obstacle for obstacle in self.obstacles if obstacle.y < 110] + return reward + + def _hits(self, x: float, y: float, size: float) -> bool: + return (abs(self.x - x) < size / 2 + 3 / self.stretch + and abs(self.y - y) < size / 2 + 3 * self.stretch) + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[int(self.y) // 10, int(self.x) // 10, 0] = True + for orb in self.orbs: + state[int(orb.y) // 10, int(orb.x) // 10, 1] = True + for obstacle in self.obstacles: + if 0 <= obstacle.x < 100 and 0 <= obstacle.y < 100: + state[int(obstacle.y) // 10, int(obstacle.x) // 10, 2] = True + x, y = self.x + 10 * math.cos(self.angle), self.y + 10 * math.sin(self.angle) + if 0 <= x < 100 and 0 <= y < 100: + state[int(y) // 10, int(x) // 10, 3] = True + if self.pressed: + rows, cols = np.ogrid[5:100:10, 5:100:10] + state[:, :, 4] = (cols - self.x) ** 2 + (rows - self.y) ** 2 < 30 ** 2 + gauges = (self.steps, self.combo, self.combo_timer, round(self.angle % math.tau * 80), + round((self.vx + 4) * 60), round((self.vy + 4) * 60)) + for row, value in enumerate(gauges): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/interspace.py b/runtime/minatar_synth/games/interspace.py new file mode 100644 index 0000000000000000000000000000000000000000..c01169aba572245022f0898513597a3a07fd1ad7 --- /dev/null +++ b/runtime/minatar_synth/games/interspace.py @@ -0,0 +1,79 @@ +import numpy as np + + +class InterspaceEnvironment: + score_cap = 11840 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x, self.y = 50.0, 10.0 + self.height = 7.0 + self.gap_x, self.wall_y = 50.0, 99.0 + self.steps = self.action = 0 + self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.action = action + self.steps += 1 + reward = 0.0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return reward, self.terminal + + def _advance(self) -> float: + scroll = 0.5 + (self.height - 7) * 0.3 + self.wall_y -= scroll + if self.wall_y < 0: + self.gap_x = (self.gap_x + self.random.uniform(-9, 9) - 9) % 81 + 9 + self.wall_y = 99 + self.x = min(99, max(0, self.x + 1.25 * ((self.action == 3) - (self.action == 1)))) + outside_gap = abs(self.x - self.gap_x) > 3.5 + wall_in_probe = self.wall_y < self.y + 49.5 and self.wall_y + 9 > self.y - 49.5 + if outside_gap and wall_in_probe: + self.y += (10 - self.y) * 0.1 + self.height += (7 - self.height) * 0.4 + else: + self.y += (30 - self.y) * 0.1 + self.height += (30 - self.height) * 0.1 + self.terminal = (outside_gap and self.y + self.height / 2 > self.wall_y + and self.y - self.height / 2 < self.wall_y + 9) + return scroll + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + col = int(self.x // 10) + top = max(0, int((self.y - self.height / 2) // 10)) + bottom = min(9, int((self.y + self.height / 2) // 10)) + state[top:bottom + 1, col, 0] = True + wall_top = int(self.wall_y // 10) + wall_bottom = min(9, int((self.wall_y + 9) // 10)) + for column in range(10): + cell_x = column * 10 + 5 + state[wall_top:wall_bottom + 1, column, 1] = abs(cell_x - self.gap_x) >= 7 + state[wall_top:wall_bottom + 1, int(self.gap_x // 10), 2] = True + state[:, col, 3] = True + state[:, int(self.gap_x // 10), 4] = True + gauges = (self.steps, round(self.x * 4), round(self.gap_x * 4), + round(self.wall_y * 4), round(self.height * 10), round(self.y * 10), self.action) + for row, value in enumerate(gauges): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/invincible_man.py b/runtime/minatar_synth/games/invincible_man.py new file mode 100644 index 0000000000000000000000000000000000000000..164b0df7ab48d9c42f08cca4b52c2f25dedf172d --- /dev/null +++ b/runtime/minatar_synth/games/invincible_man.py @@ -0,0 +1,172 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Actor: + x: float + y: float + vx: float = 0.0 + vy: float = 0.0 + target_x: float = 50.0 + target_y: float = 50.0 + + def distance(self, other: "Actor") -> float: + return math.hypot(self.x - other.x, self.y - other.y) + + def steer(self, angle: float, force: float, damping: float) -> None: + self.vx = (self.vx + math.cos(angle) * force) * damping + self.vy = (self.vy + math.sin(angle) * force) * damping + self.x += self.vx + self.y += self.vy + + +@dataclass +class Explosion: + x: float + y: float + radius: float = 1.0 + growing: bool = True + + def hits(self, actor: Actor) -> bool: + return abs(math.hypot(self.x - actor.x, self.y - actor.y) - self.radius) < 4 + + +class InvincibleManEnvironment: + score_cap = 300 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.player = Actor(50, 40) + self.direction = -1 + self.humans = [self._human(*self.random.uniform(40, 60, 2)) for _ in range(10)] + self.enemies: list[Actor] = [] + self.explosions: list[Explosion] = [] + self.human_timer = self.enemy_timer = 0.0 + self.steps = 0 + self.multiplier = 1 + self.pressed = self.terminal = False + + def _human(self, x: float, y: float) -> Actor: + tx, ty = self.random.uniform(40, 60, 2) + return Actor(x, y, target_x=tx, target_y=ty) + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed: + self.direction *= -1 + self.pressed = pressed + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self) -> int: + player = self.player + toward = math.atan2(50 - player.y, 50 - player.x) + angle, speed = (toward, -1) if self.pressed else (toward + math.pi / 2 * self.direction, 0.7) + player.x += math.cos(angle) * speed + player.y += math.sin(angle) * speed + pull = (math.hypot(player.x - 50, player.y - 50) + 9) * 0.005 + player.x = min(100, max(0, player.x + math.cos(toward) * pull)) + player.y = min(100, max(0, player.y + math.sin(toward) * pull)) + for blast in self.explosions: + blast.radius += 0.6 if blast.growing else -0.6 + if blast.radius > 12: + blast.growing = False + self.explosions = [blast for blast in self.explosions if blast.radius >= 1] + self.human_timer -= 1 + if self.human_timer < 0: + if len(self.humans) < 9: + count = len(self.humans) + 1 + self.humans.append(self._human((50 + sum(h.x for h in self.humans)) / count, + (50 + sum(h.y for h in self.humans)) / count)) + self.human_timer = 600 + self._move_humans() + self.enemy_timer -= 1 + if self.enemy_timer < 0: + angle = self.random.uniform(0, math.tau) + x, y = 50 + 80 * math.cos(angle), 50 + 80 * math.sin(angle) + count = int(self.random.integers(3, 9)) + for _ in range(count): + dx, dy = self.random.uniform(-9, 9, 2) + vx, vy = self.random.uniform(-1, 1, 2) + self.enemies.append(Actor(x + dx, y + dy, vx, vy)) + self.enemies = self.enemies[-64:] + self.enemy_timer = self.random.uniform(70, 99) * math.sqrt(count) + reward = self._move_enemies() + if not self.explosions: + self.multiplier = 1 + self.terminal = not self.humans + return reward + + def _move_humans(self) -> None: + alive = [] + for human in self.humans: + enemy = min(self.enemies, key=human.distance, default=None) + if enemy is not None and human.distance(enemy) < 25: + angle = math.atan2(human.y - enemy.y, human.x - enemy.x) + else: + if math.hypot(human.x - human.target_x, human.y - human.target_y) < 1: + human.target_x, human.target_y = self.random.uniform(40, 60, 2) + angle = math.atan2(human.target_y - human.y, human.target_x - human.x) + human.steer(angle, 0.01, 0.9) + human.x = min(90, max(10, human.x)) + human.y = min(90, max(10, human.y)) + if not any(blast.hits(human) for blast in self.explosions): + alive.append(human) + self.humans = alive + + def _move_enemies(self) -> int: + reward = 0 + alive = [] + for enemy in self.enemies: + human = min(self.humans, key=enemy.distance, default=None) + if human is not None: + enemy.steer(math.atan2(human.y - enemy.y, human.x - enemy.x), 0.005, 0.95) + if (enemy.distance(self.player) < 5 or any(enemy.distance(h) < 5 for h in self.humans) + or any(blast.hits(enemy) for blast in self.explosions)): + self.explosions.append(Explosion(enemy.x, enemy.y)) + self.explosions = self.explosions[-16:] + reward += self.multiplier + self.multiplier += 1 + else: + alive.append(enemy) + self.enemies = alive + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for channel, actors in ((0, [self.player]), (1, self.humans), (2, self.enemies)): + for actor in actors: + if 0 <= actor.x <= 100 and 0 <= actor.y <= 100: + state[min(9, int(actor.y) // 10), min(9, int(actor.x) // 10), channel] = True + rows, cols = np.ogrid[5:100:10, 5:100:10] + for blast in self.explosions: + distance = np.hypot(cols - blast.x, rows - blast.y) + state[:, :, 3 if blast.growing else 4] |= abs(distance - blast.radius) < 6 + for row, value in enumerate((self.steps, len(self.humans), min(511, self.multiplier))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.direction > 0 + return state diff --git a/runtime/minatar_synth/games/james_bond.py b/runtime/minatar_synth/games/james_bond.py new file mode 100644 index 0000000000000000000000000000000000000000..3ce04c8eb25c53011eb714330fc668ed5e98fc03 --- /dev/null +++ b/runtime/minatar_synth/games/james_bond.py @@ -0,0 +1,279 @@ +import numpy as np + + +MISSION_NAMES = ("diamonds", "moonraker", "spy") + + +class JamesBondEnvironment: + """Three-mission multipurpose-craft campaign with alternating weapons.""" + + score_cap = 20_500.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 1_800): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.mission = 0 + self.lives = 6 + self.score = 0.0 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self.destroyed: set[tuple[int, str, int]] = set() + self._start_mission() + + def _start_mission(self) -> None: + self.player = [5, 1] + self.previous_player = self.player.copy() + self.entities: list[dict[str, object]] = [] + self.projectiles: list[dict[str, object]] = [] + self.mission_steps = 0 + self.next_weapon = "shot" + self.light_timer = 0 + self.rig: list[int] | None = None + self.lab: list[int] | None = None + self.capsule: list[int] | None = None + self.capsule_timer = 0 + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + mission_before = self.mission + lives_before = self.lives + self._move_player(action) + if action == 5: + self._fire_weapon() + self._spawn_entities() + reward = self._move_projectiles() + if self.terminal or self.mission >= 3: + return self._finish_step(reward) + self._move_entities() + self._resolve_player_contacts() + if self.terminal or self.lives != lives_before: + return self._finish_step(reward, advance_mission=False) + reward += self._resolve_objectives() + return self._finish_step(reward, advance_mission=self.mission == mission_before) + + def _finish_step(self, reward: float, advance_mission: bool = True) -> tuple[float, bool]: + self.score += reward + self.steps += 1 + if self.mission < 3 and advance_mission: + self.mission_steps += 1 + self.light_timer = max(0, self.light_timer - 1) + if self.capsule is not None: + self.capsule_timer -= 1 + if self.capsule_timer <= 0: + self.capsule = None + self.lab = None + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _move_player(self, action: int) -> None: + if action == 1: + self.player[1] = max(0, self.player[1] - 1) + elif action == 2: + self.player[0] = max(0, self.player[0] - 1) + elif action == 3: + self.player[1] = min(9, self.player[1] + 1) + elif action == 4: + self.player[0] = min(9, self.player[0] + 1) + elif self.player[0] < 5: + self.player[0] += 1 + elif self.player[0] > 5: + self.player[0] -= 1 + + def _fire_weapon(self) -> None: + if len(self.projectiles) >= 2: + return + if self.next_weapon == "shot": + self.projectiles.append({"position": self.player.copy(), "direction": [-1, 1], "kind": "shot"}) + self.next_weapon = "bomb" + else: + self.projectiles.append({"position": self.player.copy(), "direction": [1, 1], "kind": "bomb"}) + self.next_weapon = "shot" + + def _mission_schedule(self) -> list[tuple[int, str, int, int, int]]: + if self.mission == 0: + return [ + (5, "diamond", 1, 50, 4), + (18, "frogman", 7, 200, 4), + (32, "diamond", 1, 50, 4), + (46, "frogman", 7, 200, 4), + ] + if self.mission == 1: + return [ + (5, "satellite", 1, 500, 3), + (15, "shuttle", 8, 200, 4), + (28, "submarine", 7, 200, 3), + (40, "torpedo", 6, 100, 3), + ] + return [ + (8, "rocket", 8, 100, 4), + (24, "submarine", 7, 200, 3), + (38, "torpedo", 6, 100, 3), + ] + + def _spawn_entities(self) -> None: + cycle_step = self.mission_steps % 60 + cycle = self.mission_steps // 60 + for spawn_step, kind, row, value, count in self._mission_schedule(): + index = cycle % count + identity = (self.mission, kind, index) + present = any(entity["identity"] == identity for entity in self.entities) + if cycle_step == spawn_step and identity not in self.destroyed and not present: + self.entities.append( + { + "identity": identity, + "kind": kind, + "position": [row, 9], + "value": value, + "age": 0, + } + ) + if self.mission == 0 and self.mission_steps >= 120 and self.rig is None: + self.rig = [3, 8] + if self.mission == 2 and self.mission_steps >= 120 and self.lab is None and self.capsule is None: + self.lab = [8, 8] + + def _move_projectiles(self) -> float: + reward = 0.0 + remaining = [] + for projectile in self.projectiles: + position = projectile["position"] + direction = projectile["direction"] + position[0] += direction[0] + position[1] += direction[1] + hit = False + for entity in list(self.entities): + if entity["position"] == position: + self.entities.remove(entity) + identity = entity["identity"] + if identity not in self.destroyed: + self.destroyed.add(identity) + reward += float(entity["value"]) + if entity["kind"] == "diamond": + self.light_timer = 30 + hit = True + break + if self.lab == position and projectile["kind"] == "bomb": + self.lab = None + self.capsule = [6, 8] + self.capsule_timer = 8 + hit = True + elif self.capsule == position and projectile["kind"] == "bomb": + self.capsule[0] = min(8, self.capsule[0] + 1) + self.capsule_timer = 8 + hit = True + if not hit and 0 <= position[0] < 10 and 0 <= position[1] < 10: + remaining.append(projectile) + self.projectiles = remaining + return reward + + def _move_entities(self) -> None: + for entity in list(self.entities): + entity["age"] = int(entity["age"]) + 1 + position = entity["position"] + position[1] -= 1 + if entity["kind"] in ("shuttle", "rocket") and position[0] <= 1: + entity["kind"] = "poison" if entity["kind"] == "shuttle" else "fire_bomb" + entity["value"] = 100 + position[0] = 1 + elif entity["kind"] in ("shuttle", "rocket"): + position[0] -= 1 + elif entity["kind"] in ("poison", "fire_bomb"): + position[0] += 1 + if position[1] < 0 or position[0] > 9: + self.entities.remove(entity) + + def _resolve_player_contacts(self) -> None: + if any(entity["position"] == self.player for entity in self.entities): + self._lose_life() + + def _resolve_objectives(self) -> float: + if self.mission == 0 and self.rig is not None and self.player == self.rig and self.light_timer > 0: + return self._complete_mission() + satellites = sum(1 for mission, kind, _ in self.destroyed if mission == 1 and kind == "satellite") + if self.mission == 1 and satellites >= 3: + return self._complete_mission() + if self.mission == 2 and self.capsule is not None and self.player == self.capsule: + return self._complete_mission() + return 0.0 + + def _complete_mission(self) -> float: + self.mission += 1 + if self.mission >= 3: + self.terminal = True + else: + self._start_mission() + return 5_000.0 + + def _lose_life(self) -> None: + self.lives -= 1 + if self.lives <= 0: + self.terminal = True + else: + self._start_mission() + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + for entity in self.entities: + channel = 2 if entity["kind"] in ("poison", "fire_bomb") else 1 + state[*entity["position"], channel] = True + if self.rig is not None and self.light_timer > 0: + state[*self.rig, 2] = True + if self.lab is not None: + state[*self.lab, 2] = True + if self.capsule is not None: + state[*self.capsule, 2] = True + for projectile in self.projectiles: + state[*projectile["position"], 3] = True + state[*self.previous_player, 4] = True + reward_identities = [] + for mission in range(3): + old_mission = self.mission + self.mission = mission + for _, kind, _, _, count in self._mission_schedule(): + reward_identities.extend((mission, kind, index) for index in range(count)) + self.mission = old_mission + for index, identity in enumerate(reward_identities): + state[index // 10, index % 10, 5] = identity in self.destroyed + for bit in range(2): + state[4, 4 + bit, 5] = bool(self.mission & (1 << bit)) + state[4, 6, 5] = self.next_weapon == "shot" + state[4, 7, 5] = self.next_weapon == "bomb" + for bit in range(3): + state[5, bit, 5] = bool(self.lives & (1 << bit)) + for bit in range(4): + state[5, 3 + bit, 5] = bool(self.capsule_timer & (1 << bit)) + for bit in range(5): + state[6, bit, 5] = bool(self.light_timer & (1 << bit)) + cycle_step = self.mission_steps % 60 + cycle = (self.mission_steps // 60) % 12 + for bit in range(6): + state[7, bit, 5] = bool(cycle_step & (1 << bit)) + state[7, 6, 5] = self.mission_steps >= 120 + for bit in range(4): + state[9, 3 + bit, 5] = bool(cycle & (1 << bit)) + for bit in range(10): + state[8, bit, 5] = bool(self.steps & (1 << bit)) + state[9, 9, 5] = bool(self.steps & (1 << 10)) + for index, name in enumerate(MISSION_NAMES): + state[4, index, 5] = self.mission < 3 and MISSION_NAMES[self.mission] == name + return state diff --git a/runtime/minatar_synth/games/jet_stream.py b/runtime/minatar_synth/games/jet_stream.py new file mode 100644 index 0000000000000000000000000000000000000000..ab2ad46ba13ef4b8f66a8b6d68374e080f17fdc4 --- /dev/null +++ b/runtime/minatar_synth/games/jet_stream.py @@ -0,0 +1,142 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Wake: + x: float + y: float + vx: float + life: int = 24 + + +@dataclass +class Barrier: + x: float + lane: int + phase: float + rotation: float = 0 + + @property + def y(self) -> int: + return 25 + 25 * self.lane + + +class JetStreamEnvironment: + score_cap = 60 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x, self.y = 50.0, 25.0 + self.vx = self.vy = self.tap_impulse = 0.0 + self.lane_step = self.frames = self.steps = self.spawn_timer = 0 + self.spawn_interval = 120.0 + self.multiplier = 1 + self.pressed = self.terminal = False + self.wake: list[Wake] = [] + self.barriers: list[Barrier] = [] + + @property + def lane(self) -> int: + return (0, 1, 2, 1)[self.lane_step] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed: + self.lane_step = (self.lane_step + 1) % 4 + self.vx += self.tap_impulse + self.vy -= 1 + self.tap_impulse += 1 + self.pressed = pressed + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self) -> int: + self.frames += 1 + self.tap_impulse *= 0.9 + self.y += (21 + self.lane * 25 - self.y) * 0.1 + self.vy + drift = 1 if self.lane == 1 else -1 + self.x += self.vx + 0.5 * drift + self.vx *= 0.9 + self.vy *= 0.9 + if self.frames % 3 == 0: + self.wake.append(Wake(self.x - drift * 5, self.y + 4, -drift * 0.3)) + for particle in self.wake: + particle.x += particle.vx + particle.y -= 0.1 + particle.life -= 1 + self.wake = [p for p in self.wake if p.life and -5 <= p.x <= 105] + self.spawn_timer += 1 + if self.spawn_timer >= self.spawn_interval + self.random.uniform(-30, 30): + lane = int(self.random.integers(3)) + self.barriers.append(Barrier(110 if lane == 1 else -10, lane, self.random.uniform(0, math.tau))) + self.spawn_timer = 0 + self.spawn_interval = self.random.uniform(100, 140) + reward = 0 + remaining = [] + for barrier in self.barriers: + direction = -1 if barrier.lane == 1 else 1 + barrier.x += direction + barrier.rotation += 0.15 * direction + barrier.phase += 0.2 + if self._wake_hit(barrier): + reward += self.multiplier + self.multiplier = min(16, self.multiplier + 1) + elif math.hypot(self.x - barrier.x, self.y - barrier.y) < 6 + 0.9 * math.sin(barrier.phase): + self.vx += direction * 3 + self.vy += self.random.uniform(-0.5, 0.5) + elif not -15 <= barrier.x <= 115: + self.multiplier = max(1, self.multiplier - 1) + else: + remaining.append(barrier) + self.barriers = remaining + self.terminal = not -3 <= self.x <= 103 + return reward + + def _wake_hit(self, barrier: Barrier) -> bool: + for blade in range(4): + angle = barrier.rotation + blade * math.pi / 2 + x = barrier.x + 6 * math.cos(angle) + y = barrier.y + 6 * math.sin(angle) + if any(math.hypot(p.x - x, p.y - y) < 3.5 + (24 - p.life) / 24 for p in self.wake): + return True + return False + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, max(0, int(self.y) // 10)), min(9, max(0, int(self.x) // 10)), 0] = True + for particle in self.wake: + if 0 <= particle.x < 100 and 0 <= particle.y < 100: + state[int(particle.y) // 10, int(particle.x) // 10, 1] = True + for barrier in self.barriers: + if 0 <= barrier.x < 100: + state[barrier.y // 10, int(barrier.x) // 10, 2 + (barrier.lane == 1)] = True + state[(21 + self.lane * 25) // 10, :, 4] = True + for row, value in enumerate((self.steps, self.multiplier, self.lane_step, + min(511, max(0, round((self.vx + 10) * 20))))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/jpaddle.py b/runtime/minatar_synth/games/jpaddle.py new file mode 100644 index 0000000000000000000000000000000000000000..1ef400575f7adbe246d93e350d0b13f72f9be50d --- /dev/null +++ b/runtime/minatar_synth/games/jpaddle.py @@ -0,0 +1,103 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Ball: + x: float + y: float + vx: float + vy: float + + +class JpaddleEnvironment: + score_cap = 600 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x, self.y = 50.0, 90.0 + self.jumps = self.steps = self.frames = 0 + self.direction = -1 + self.pressed = self.terminal = False + self.balls: list[Ball] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0.0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return reward, self.terminal + + def _advance(self, tap: bool) -> float: + if tap and self.jumps < 99: + self.jumps += 1 + self.y -= 12 // self.jumps + self.direction *= -1 + else: + self.y += 0.1 + if self.pressed and self.jumps: + self.x += 0.5 * self.direction + self.x = min(97, max(3, self.x)) + self.y = min(110, max(30, self.y)) + reward = 0.0 + remaining = [] + for ball in self.balls: + ball.x += ball.vx + ball.y += ball.vy + if ball.x < 0 or ball.x > 97: + ball.vx *= -1 + if ball.vy > 0 and abs(ball.x - self.x) < 7.5 and abs(ball.y - self.y) < 6.5: + ball.y = self.y - 3 + ball.vy *= -1 + reward += 99 - ball.y + self.jumps = max(0, self.jumps - 9) + if ball.y <= 100: + remaining.append(ball) + self.balls = remaining + if self.frames % 60 == 0: + x = self.random.uniform(10, 90) + vx = self.random.uniform(-1, 1) + length = math.hypot(vx, 1) + self.balls.append(Ball(x, 0, vx / length, 1 / length)) + self.frames += 1 + self.terminal = self.y > 99 + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row, col = min(9, int(self.y // 10)), int(self.x // 10) + state[row, col, 0] = True + for ball in self.balls: + if 0 <= ball.y < 100 and 0 <= ball.x < 100: + state[int(ball.y // 10), int(ball.x // 10), 1 if ball.vy > 0 else 2] = True + x, y = ball.x + 8 * ball.vx, ball.y + 8 * ball.vy + if 0 <= x < 100 and 0 <= y < 100: + state[int(y // 10), int(x // 10), 3] = True + state[9, :, 4] = True + for row, value in enumerate((self.steps, self.jumps, round(self.x * 4), round(self.y * 4))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.direction > 0 + return state diff --git a/runtime/minatar_synth/games/juggling_act.py b/runtime/minatar_synth/games/juggling_act.py new file mode 100644 index 0000000000000000000000000000000000000000..fa8238b3772cc4e9346162cd0c2bd9b3badb178b --- /dev/null +++ b/runtime/minatar_synth/games/juggling_act.py @@ -0,0 +1,106 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Ball: + x: float + y: float = 0.0 + vx: float = 0.0 + vy: float = 0.0 + + +class JugglingActEnvironment: + score_cap = 150 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x, self.vx = 50.0, 0.0 + self.steps = self.spawn_timer = 0 + self.pressed = self.terminal = False + self.balls: list[Ball] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _nearest(self) -> Ball | None: + return min((ball for ball in self.balls if ball.vy >= 0), + key=lambda ball: abs(90 - ball.y), default=None) + + def _advance(self) -> int: + if not self.pressed: + nearest = self._nearest() + if nearest is not None: + self.vx += 0.36 if nearest.x > self.x else -0.36 + self.vx *= 0.85 + self.x += self.vx + if (self.x < 5 and self.vx < 0) or (self.x > 95 and self.vx > 0): + self.vx *= -0.5 + reward = 0 + live_count = len(self.balls) + remaining = [] + for ball in self.balls: + falling = ball.vy >= 0 + ball.x += ball.vx + ball.y += ball.vy + ball.vx *= 0.99 + ball.vy = ball.vy * 0.99 + 0.02 + if (ball.x < 0 and ball.vx < 0) or (ball.x > 100 and ball.vx > 0): + ball.vx *= -1 + if falling and self.pressed and 82 < ball.y < 90 and abs(ball.x - self.x) < 10: + ball.vy = -2 + ball.vx = (ball.x - self.x) / 10 + self.random.uniform(-0.1, 0.1) + reward += live_count + if ball.y > 100: + live_count -= 1 + else: + remaining.append(ball) + self.balls = remaining + self.spawn_timer -= 1 + if self.spawn_timer <= 0: + self.balls.append(Ball(self.random.uniform(10, 90))) + self.spawn_timer = 200 + self.terminal = not self.balls + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + col = min(9, max(0, int(self.x // 10))) + state[9, col, 0] = True + for ball in self.balls: + if 0 <= ball.x < 100 and 0 <= ball.y < 100: + state[int(ball.y // 10), int(ball.x // 10), 1 if ball.vy >= 0 else 2] = True + nearest = self._nearest() + if nearest is not None and 0 <= nearest.x < 100 and 0 <= nearest.y < 100: + state[int(nearest.y // 10), int(nearest.x // 10), 3] = True + state[8, max(0, col - 1):col + 2, 4] = True + values = (self.steps, self.spawn_timer, round((self.vx + 3) * 80), round(self.x * 4)) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/jujump.py b/runtime/minatar_synth/games/jujump.py new file mode 100644 index 0000000000000000000000000000000000000000..d7ce1dafb72837d381f5e364bb6eef5b1c3c72a3 --- /dev/null +++ b/runtime/minatar_synth/games/jujump.py @@ -0,0 +1,84 @@ +import numpy as np + + +class JujumpEnvironment: + score_cap = 600 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x = self.y = 50.0 + self.vx = self.vy = 0.0 + self.direction = 1 + self.power = self.spawn_distance = 1.0 + self.platforms = [(50.0, 70.0)] + self.steps = 0 + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tapped = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0.0 + for frame in range(4): + reward += self._advance(tapped and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return reward, self.terminal + + def _advance(self, tapped: bool) -> float: + self.x += self.vx + self.y += self.vy + self.vy += 0.05 if self.pressed else 0.1 + scroll = max(0, 30 - self.y) * 0.1 + 0.1 + self.spawn_distance -= scroll + if self.spawn_distance < 0: + self.spawn_distance = self.random.uniform(0, 99) + self.platforms.append((self.random.uniform(0, 99), -9)) + self.y += scroll + self.platforms = [(x, y + scroll) for x, y in self.platforms if y + scroll < 99] + while any(abs(self.x - x) < 20 and abs(self.y - y) < 7 for x, y in self.platforms): + self.y -= 1 + self.vx = self.vy = 0 + self.power = 1 + if tapped: + self.direction *= -1 + self.vx = self.direction + self.vy = -3 * self.power + self.power *= 0.7 + self.terminal = self.y > 99 + return scroll + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for x, y, channel in ((self.x, self.y, 0), (self.x + 4 * self.vx, self.y + 4 * self.vy, 2), + (self.x - 10 * self.direction, self.y - 10 * self.power, 3)): + if 0 <= x < 100 and 0 <= y < 100: + state[int(y) // 10, int(x) // 10, channel] = True + for x, y in self.platforms: + if 0 <= y < 100: + left = max(0, int((x - 16.5) // 10)) + right = min(9, int((x + 16.5) // 10)) + state[int(y) // 10, left:right + 1, 1] = True + state[3, :, 4] = True + values = (self.steps, round(self.power * 400), min(511, max(0, round((self.vy + 3) * 40)))) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.direction > 0 + return state diff --git a/runtime/minatar_synth/games/jump_on.py b/runtime/minatar_synth/games/jump_on.py new file mode 100644 index 0000000000000000000000000000000000000000..90fc8c14e87a89644b3af8456767f2f285459705 --- /dev/null +++ b/runtime/minatar_synth/games/jump_on.py @@ -0,0 +1,171 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Hole: + x: float + + +@dataclass +class Walker: + x: float + y: float + mode: str = "walk" + hole: Hole | None = None + dot_timer: float = 0.0 + + +class JumpOnEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.player = Walker(5, 87) + self.holes = [Hole(30), Hole(60)] + self.enemies: list[Walker] = [] + self.dots: list[tuple[float, float]] = [] + self.hole_distance = self.group_timer = self.enemy_timer = 0.0 + self.group_size = self.steps = 0 + self.multiplier = 1 + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self) -> int: + scroll = 0.03 + max(0, self.player.x - 15) * 0.1 + self.hole_distance -= scroll + if self.hole_distance < 0: + self.holes.append(Hole(104)) + self.hole_distance += self.random.uniform(30, 45) + for hole in self.holes: + hole.x -= scroll + self.holes = [hole for hole in self.holes if hole.x >= -4] + self.group_timer -= 1 + if self.group_timer < 0: + self.group_size = int(self.random.integers(1, 3)) + self.group_timer = self.group_size * 8 + self.random.uniform(100, 110) + self.enemy_timer = 0 + self.enemy_timer -= 1 + if self.group_size and self.enemy_timer < 0: + self.enemies.append(Walker(103, 87 - 12 * self.random.integers(6), + dot_timer=self.random.uniform(0, 6))) + self.group_size -= 1 + self.enemy_timer = self.random.uniform(8, 10) + walking_enemies = [] + for enemy in self.enemies: + was_walking = enemy.mode == "walk" + leave = -9 < enemy.y - 1 - self.player.y < 1 + self._move(enemy, -1, scroll, leave) + if was_walking: + walking_enemies.append(enemy) + if enemy.mode == "walk": + enemy.dot_timer -= 1 + if enemy.dot_timer < 0: + self.dots.append((enemy.x, enemy.y)) + enemy.dot_timer += 6 + self.enemies = [enemy for enemy in self.enemies if enemy.x >= -3] + was_walking = self.player.mode == "walk" + self._move(self.player, 1, scroll, self.pressed) + self.terminal = self.player.x < 0 or (was_walking and any( + abs(enemy.x - self.player.x) < 5 and abs(enemy.y - self.player.y) < 5 + for enemy in walking_enemies + )) + reward = 0 + remaining = [] + for x, y in self.dots: + x -= scroll + if self.player.mode not in ("up", "down") and abs(x - self.player.x) < 4 and abs(y - self.player.y) < 4: + reward += self.multiplier + self.multiplier += 1 + elif x >= -3: + remaining.append((x, y)) + self.dots = remaining + return reward + + def _move(self, walker: Walker, direction: int, scroll: float, leave: bool) -> None: + if walker.mode == "walk": + walker.x += direction - scroll + ahead = [hole for hole in self.holes if 0 < (hole.x - walker.x) * direction < 8] + if ahead: + walker.hole = min(ahead, key=lambda hole: abs(hole.x - walker.x)) + walker.mode = "enter" + return + hole = walker.hole + assert hole is not None + if walker.mode == "enter": + walker.x += direction - scroll + distance = (hole.x - walker.x) * direction + walker.y += 1 if distance < 4 else -1 + if distance <= 0: + walker.mode = "down" + elif walker.mode == "down": + walker.x = hole.x + walker.y += 1 + if walker.y > 90: + walker.mode = "up" + elif walker.mode == "up": + walker.x = hole.x + walker.y -= 1 + if walker.y < 23: + walker.mode = "down" + if leave: + walker.mode = "exit" + walker.y = math.ceil((walker.y - 90) / 12) * 12 + 87 + else: + walker.x += direction - scroll + distance = (walker.x - hole.x) * direction + walker.y += -1 if distance < 4 else 1 + if distance >= 8: + walker.mode = "walk" + walker.y = math.floor((walker.y - 90) / 12 + 0.5) * 12 + 87 + if direction == -1: + self.multiplier = 1 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, max(0, int(self.player.y // 10))), + min(9, max(0, int(self.player.x // 10))), 0] = True + for enemy in self.enemies: + if 0 <= enemy.x < 100 and 0 <= enemy.y < 100: + state[int(enemy.y // 10), int(enemy.x // 10), 1] = True + for x, y in self.dots: + if 0 <= x < 100 and 0 <= y < 100: + state[int(y // 10), int(x // 10), 2] = True + for hole in self.holes: + if 0 <= hole.x < 100: + state[2:10, int(hole.x // 10), 3] = True + for y in range(90, 29, -12): + state[y // 10, :, 4] = True + mode = ("walk", "enter", "down", "up", "exit").index(self.player.mode) + for row, value in enumerate((self.steps, min(511, self.multiplier), mode, round(self.player.y * 4))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/kangaroo.py b/runtime/minatar_synth/games/kangaroo.py new file mode 100644 index 0000000000000000000000000000000000000000..8d271e6d7445e44811f0a62eb59b75c760a998e1 --- /dev/null +++ b/runtime/minatar_synth/games/kangaroo.py @@ -0,0 +1,308 @@ +import numpy as np + + +FRUIT_VALUES = (100, 200, 400, 800) +FRUIT_POSITIONS = ((7, 2), (4, 5), (1, 7)) + + +class KangarooEnvironment: + """Three-screen rescue cycle with ladders, leaps, bells, and boxing.""" + + score_cap = 74_700.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 1_800): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.round = 0 + self.screen = 0 + self.lives = 3 + self.score = 0.0 + self.next_bonus_life = 20_000.0 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self.claimed_monkeys: set[tuple[int, int, int]] = set() + self.claimed_apples: set[tuple[int, int, int]] = set() + self.claimed_fruit: set[tuple[int, int, int, int]] = set() + self._start_screen() + + def _start_screen(self) -> None: + self.player = [8, 0] + self.previous_player = self.player.copy() + self.baby = [1, 9] + self.ladders = ({2, 6, 8}, {1, 5, 8}, {3, 6, 9})[self.screen] + self.gaps = set() + if self.screen == 1: + self.gaps = {(8, 3), (8, 4), (5, 6), (5, 7)} + elif self.screen == 2: + self.gaps = {(8, 4), (5, 2), (5, 3)} + monkey_positions = ((8, 8), (5, 3), (2, 8), (5, 8)) + self.monkeys = { + index: list(position) + for index, position in enumerate(monkey_positions) + if (self.round, self.screen, index) not in self.claimed_monkeys + } + self.monkey_directions = {index: -1 for index in self.monkeys} + self.apples: list[dict[str, object]] = [] + self.spawned_apples: set[int] = set() + self.fruit_tiers = {index: 0 for index in range(3)} + self.available_fruit = { + index for index in range(3) if (self.round, self.screen, 0, index) not in self.claimed_fruit + } + self.collected_for_bell: set[int] = set() + self.bell_rings = 0 + self.bell = [1, 5] + self.timer = 2_000 + self.screen_steps = 0 + self.jump_timer = 0 + self.ducking = False + self.previous_apples: list[list[int]] = [] + + @property + def fruit_tier(self) -> int: + return max(self.fruit_tiers.values()) + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + lives_before = self.lives + screen_before = (self.round, self.screen) + self.ducking = action == 4 + self._move_player(action) + if self.lives != lives_before or self.terminal: + return self._finish_step(0.0, consume_timer=False) + reward = self._collect_fruit_and_ring_bell() + if action == 5: + reward += self._punch() + self._spawn_apples() + self._move_monkeys() + self._move_apples() + self._resolve_contacts(action) + if self.lives != lives_before or self.terminal: + return self._finish_step(reward, consume_timer=False) + if self.player == self.baby: + reward += self._rescue_baby() + transitioned = (self.round, self.screen) != screen_before + return self._finish_step(reward, consume_timer=not transitioned) + + def _finish_step(self, reward: float, consume_timer: bool = True) -> tuple[float, bool]: + self.score += reward + while self.score >= self.next_bonus_life: + self.lives = min(20, self.lives + 1) + self.next_bonus_life += 20_000.0 + if consume_timer: + self.timer -= 20 + self.screen_steps += 1 + self.jump_timer = max(0, self.jump_timer - 1) + if self.timer <= 0: + self._lose_life() + self.steps += 1 + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _move_player(self, action: int) -> None: + if action in (1, 3): + delta = -1 if action == 1 else 1 + distance = 2 if self.jump_timer > 0 else 1 + target_column = int(np.clip(self.player[1] + delta * distance, 0, 9)) + crossed = range(min(self.player[1], target_column), max(self.player[1], target_column) + 1) + if self.player[0] in (5, 8) and any((self.player[0], column) in self.gaps for column in crossed): + if self.jump_timer == 0: + self._lose_life() + return + self.player[1] = target_column + elif action == 2: + if self.player[1] in self.ladders and self.player[0] > 1: + self.player[0] -= 1 + else: + self.jump_timer = 2 + self.player[0] = max(0, self.player[0] - 1) + elif action == 4 and self.player[1] in self.ladders and self.player[0] < 8: + self.player[0] += 1 + elif self.jump_timer == 0 and self.player[0] not in (1, 2, 5, 8): + self.player[0] = min(8, self.player[0] + 1) + + def _collect_fruit_and_ring_bell(self) -> float: + reward = 0.0 + for index in list(self.available_fruit): + if self.player == list(FRUIT_POSITIONS[index]): + tier = self.fruit_tiers[index] + identity = (self.round, self.screen, tier, index) + self.available_fruit.remove(index) + self.collected_for_bell.add(index) + if identity not in self.claimed_fruit: + self.claimed_fruit.add(identity) + reward += float(FRUIT_VALUES[tier]) + if self.player == self.bell and self.collected_for_bell and self.bell_rings < 3: + self.bell_rings += 1 + for index in self.collected_for_bell: + self.fruit_tiers[index] = min(3, self.fruit_tiers[index] + 1) + identity = (self.round, self.screen, self.fruit_tiers[index], index) + if identity not in self.claimed_fruit: + self.available_fruit.add(index) + self.collected_for_bell = set() + return reward + + def _punch(self) -> float: + reward = 0.0 + for index, monkey in list(self.monkeys.items()): + if abs(monkey[0] - self.player[0]) + abs(monkey[1] - self.player[1]) <= 1: + del self.monkeys[index] + identity = (self.round, self.screen, index) + if identity not in self.claimed_monkeys: + self.claimed_monkeys.add(identity) + reward += 200.0 + return reward + for apple in list(self.apples): + position = apple["position"] + if abs(position[0] - self.player[0]) + abs(position[1] - self.player[1]) <= 1: + self.apples.remove(apple) + identity = (self.round, self.screen, int(apple["identity"])) + if identity not in self.claimed_apples: + self.claimed_apples.add(identity) + reward += 200.0 if apple["kind"] == "falling" else 100.0 + return reward + return reward + + def _spawn_apples(self) -> None: + interval = max(5, 10 - self.round) + if self.screen_steps % interval or len(self.spawned_apples) >= 8 or not self.monkeys: + return + identity = len(self.spawned_apples) + self.spawned_apples.add(identity) + monkey = self.monkeys[min(self.monkeys)] + kinds = ("low", "high", "middle", "falling") + kind = kinds[(identity + self.round) % len(kinds)] + position = [max(0, monkey[0] - 2), monkey[1]] if kind == "falling" else monkey.copy() + self.apples.append( + { + "identity": identity, + "kind": kind, + "position": position, + "direction": int(np.sign(self.player[1] - monkey[1])) or -1, + } + ) + + def _move_monkeys(self) -> None: + if self.screen_steps % max(2, 4 - self.round // 2): + return + for index, monkey in self.monkeys.items(): + direction = int(np.sign(self.player[1] - monkey[1])) + monkey[1] = int(np.clip(monkey[1] + direction, 0, 9)) + self.monkey_directions[index] = direction + + def _move_apples(self) -> None: + self.previous_apples = [list(apple["position"]) for apple in self.apples] + for apple in list(self.apples): + if apple["kind"] == "falling": + apple["position"][0] += 1 + else: + apple["position"][1] += int(apple["direction"]) + position = apple["position"] + if not (0 <= position[0] < 10 and 0 <= position[1] < 10): + self.apples.remove(apple) + + def _resolve_contacts(self, action: int) -> None: + if any(monkey == self.player for monkey in self.monkeys.values()): + self._lose_life() + return + for apple in self.apples: + if apple["position"] != self.player: + continue + avoided = (apple["kind"] == "low" and action == 2) or (apple["kind"] == "high" and self.ducking) + if not avoided: + self._lose_life() + return + + def _rescue_baby(self) -> float: + reward = float(self.timer) + self.screen += 1 + if self.screen >= 3: + self.screen = 0 + self.round += 1 + if self.round >= 3: + self.terminal = True + else: + self._start_screen() + return reward + + def _lose_life(self) -> None: + self.lives -= 1 + if self.lives <= 0: + self.terminal = True + else: + self._start_screen() + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + for monkey in self.monkeys.values(): + state[*monkey, 1] = True + state[*monkey, 3] = True + for apple in self.apples: + state[*apple["position"], 1] = True + if apple["kind"] in ("high", "middle"): + state[*apple["position"], 2] = True + if apple["kind"] == "middle": + state[*apple["position"], 3] = True + if apple["kind"] == "falling": + state[*apple["position"], 4] = True + state[*self.baby, 2] = True + for index in self.available_fruit: + state[*FRUIT_POSITIONS[index], 2] = True + state[*self.bell, 2] = True + for row in (2, 5, 8): + for column in range(10): + if (row, column) not in self.gaps: + state[row, column, 3] = True + for column in self.ladders: + state[1:9, column, 3] = True + state[*self.previous_player, 4] = True + for apple in self.previous_apples: + state[*apple, 4] = True + current_claims = [] + current_claims.extend( + (self.round, self.screen, index) in self.claimed_monkeys for index in range(4) + ) + current_claims.extend( + (self.round, self.screen, index) in self.claimed_apples for index in range(8) + ) + current_claims.extend( + (self.round, self.screen, tier, index) in self.claimed_fruit + for tier in range(4) + for index in range(3) + ) + for index, claimed in enumerate(current_claims): + state[index // 10, index % 10, 5] = claimed + for index in self.spawned_apples: + state[3, index, 5] = True + for index, tier in self.fruit_tiers.items(): + state[4, index * 2, 5] = bool(tier & 1) + state[4, index * 2 + 1, 5] = bool(tier & 2) + state[9, self.round, 5] = True + state[9, 3 + self.screen, 5] = True + for bit in range(5): + state[8, bit, 5] = bool(self.lives & (1 << bit)) + for bit in range(7): + state[7, bit, 5] = bool((self.timer // 20) & (1 << bit)) + state[6, 4 + self.bell_rings, 5] = True + state[5, : self.jump_timer, 5] = True + state[5, 2, 5] = self.ducking + return state diff --git a/runtime/minatar_synth/games/kelp_climber.py b/runtime/minatar_synth/games/kelp_climber.py new file mode 100644 index 0000000000000000000000000000000000000000..cf8e55c0a4b4d502414c0e05b993d708125a9c02 --- /dev/null +++ b/runtime/minatar_synth/games/kelp_climber.py @@ -0,0 +1,115 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Kelp: + x: float + y: float + + +@dataclass +class Obstacle: + x: float + y: float + width: float + height: float + + +class KelpClimberEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x = 50.0 + self.kelp = [Kelp(25, 40), Kelp(50, 50), Kelp(75, 45)] + self.grabbed = self.kelp[1] + self.obstacles: list[Obstacle] = [] + self.kelp_distance = self.obstacle_distance = 0.0 + self.steps = 0 + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _nearest(self) -> Kelp | None: + return min((strand for strand in self.kelp if strand is not self.grabbed and strand.y > 40), + key=lambda strand: abs(strand.x - self.x), default=None) + + def _advance(self, tap: bool) -> int: + reward = 0 + if tap: + target = self._nearest() + if target is not None: + reward = math.ceil(abs(target.x - self.x)) + self.grabbed.y = 199 + self.grabbed = target + self.x = target.x + for strand in self.kelp: + strand.y += 0.5 + self.kelp = [strand for strand in self.kelp if strand.y <= 150] + self.kelp_distance -= 0.5 + if self.kelp_distance < 0: + self.kelp.append(Kelp(self.random.uniform(10, 90), -50)) + self.kelp_distance += self.random.uniform(30, 50) + for obstacle in self.obstacles: + obstacle.y += 0.5 + self.obstacles = [obstacle for obstacle in self.obstacles if obstacle.y <= 110] + self.obstacle_distance -= 0.5 + if self.obstacle_distance < 0: + x = self.random.uniform(10, 90) + width, height = self.random.uniform(5, 15, 2) + self.obstacles.append(Obstacle(x, -10, width, height)) + self.obstacle_distance += self.random.uniform(40, 50) + self.terminal = any(abs(o.x - self.x) < (o.width + 5) / 2 + and abs(o.y - 90) < (o.height + 5) / 2 for o in self.obstacles) + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[9, int(self.x) // 10, 0] = True + for strand in self.kelp: + top = max(0, int((strand.y - 50) // 10)) + bottom = min(9, int((strand.y + 50) // 10)) + state[top:bottom + 1, int(strand.x) // 10, 1 + (strand.y > 40 and strand is not self.grabbed)] = True + for o in self.obstacles: + top = max(0, int((o.y - o.height / 2) // 10)) + bottom = min(9, int((o.y + o.height / 2) // 10)) + left = max(0, int((o.x - o.width / 2) // 10)) + right = min(9, int((o.x + o.width / 2) // 10)) + if top <= bottom: + state[top:bottom + 1, left:right + 1, 3] = True + target = self._nearest() + if target is not None: + state[9, int(target.x) // 10, 4] = True + for row, value in enumerate((self.steps, round(self.x * 4))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/kite.py b/runtime/minatar_synth/games/kite.py new file mode 100644 index 0000000000000000000000000000000000000000..9fef4bfbfef2c6f8aac9f3f0ebfe884ddf0a892e --- /dev/null +++ b/runtime/minatar_synth/games/kite.py @@ -0,0 +1,181 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Body: + x: float + y: float + vx: float = 0 + vy: float = 0 + + def move(self, scroll: float = 0) -> None: + self.x += self.vx - scroll + self.y += self.vy + + +@dataclass +class Spike: + x: float + base: float + height: float + + def hits(self, body: Body) -> bool: + depth = (body.y - self.base) * (1 if self.height > 0 else -1) + height = abs(self.height) + width = 5 * (1 - max(0, depth - 3) / height) + return -3 < depth < height + 3 and abs(body.x - self.x) < width + 3 + + +class KiteEnvironment: + score_cap = 3000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.kite, self.player = Body(40, 50), Body(20, 87) + self.winds: list[Body] = [] + self.coins: list[Body] = [] + self.spikes: list[Spike] = [] + self.spike_angles = [(0.0, 0.0), (math.pi / 2, math.pi)] + self.spike_distance = self.coin_distance = self.wind_timer = 0.0 + self.steps = 0 + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self) -> int: + kite, player = self.kite, self.player + scroll = max(0, kite.x - 60) * 0.1 + reward = self._move_spikes(scroll) + kite.vx = (kite.vx + 0.2 * self.pressed) * 0.95 + kite.vy = (kite.vy + 0.01 - 0.2 * self.pressed) * 0.95 + kite.move(scroll) + if not 0 <= kite.y <= 87: + kite.y = min(87, max(0, kite.y)) + kite.vy = 0 + direction = 1 if kite.y < 50 else -1 + bumps = 0 + while bumps < 9 and any(spike.hits(kite) for spike in self.spikes): + kite.y += 3 * direction + bumps += 1 + if bumps: + kite.vy = math.sqrt(bumps) * direction * 2 + player.move(scroll) + if player.y < 87: + player.vy += math.sqrt(99 - player.y) * 0.01 + player.vx *= 0.95 + else: + player.y, player.vy = 87, 0 + player.vx *= 0.9 + if any(spike.hits(player) for spike in self.spikes): + self.terminal = True + return reward + dx, dy = kite.x - player.x, kite.y - player.y + distance = math.hypot(dx, dy) + if distance > 50: + pull = (distance - 50) / distance + player.vx += dx * pull * 0.05 + player.vy += dy * pull * 0.05 + kite.vx -= dx * pull * 0.01 + kite.vy -= dy * pull * 0.01 + kite.x -= dx * pull + kite.y -= dy * pull + self.wind_timer -= 3 if self.pressed else 1 + if self.wind_timer < 0: + speed = self.random.uniform(1, 2) * (2 if self.pressed else 1) + self.winds.append(Body(-3, self.random.uniform(0, 87), vx=speed)) + self.wind_timer += 30 + surviving = [] + for wind in self.winds: + wind.move() + if abs(wind.x - kite.x) < 6 and abs(wind.y - kite.y) < 6: + kite.vx += wind.vx + elif wind.x <= 203: + surviving.append(wind) + self.winds = surviving + return reward + self._move_coins(scroll) + + def _move_spikes(self, scroll: float) -> int: + self.spike_distance -= scroll + spawn = self.spike_distance < 0 + if spawn: + self.spike_distance += 10 + for index, (a, b) in enumerate(self.spike_angles): + height = math.sin(a) * 9 + math.sin(b) * 20 - 10 + self.spike_angles[index] = (a + self.random.uniform(0, 0.2), b + self.random.uniform(0, 0.4)) + if height > 0: + self.spikes.append(Spike(205, 90 if index else 0, -height if index else height)) + for spike in self.spikes: + spike.x -= scroll + self.spikes = [spike for spike in self.spikes if spike.x >= -5] + return int(spawn) + + def _move_coins(self, scroll: float) -> int: + self.coin_distance -= scroll + if self.coin_distance < 0: + self.coins.append(Body(203, self.random.uniform(30, 80), vx=-0.5)) + self.coin_distance += self.random.uniform(199, 299) + player = self.player + reward = 0 + remaining = [] + for coin in self.coins: + coin.move(scroll) + if any(spike.hits(coin) for spike in self.spikes): + continue + dx, dy = player.x - coin.x, player.y - coin.y + distance = math.hypot(dx, dy) + if abs(dx) < 6 and abs(dy) < 6: + reward += min(99, max(1, math.ceil(player.vx * 5))) * 50 + continue + if any(abs(w.x - coin.x) < 6 and abs(w.y - coin.y) < 6 for w in self.winds): + coin.x += 1 + if 0 < distance < 24: + coin.vx = (coin.vx + dx / distance) * 0.9 + coin.vy = (coin.vy + dy / distance) * 0.9 + if -3 <= coin.x <= 207 and -3 <= coin.y <= 90: + remaining.append(coin) + self.coins = remaining + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for channel, objects in enumerate(([self.player], [self.kite], self.winds, self.coins)): + for body in objects: + if 0 <= body.x < 200 and 0 <= body.y < 100: + state[int(body.y // 10), int(body.x // 20), channel] = True + for spike in self.spikes: + if 0 <= spike.x < 200: + start, end = sorted((spike.base, spike.base + spike.height)) + state[int(start // 10):int(end // 10) + 1, int(spike.x // 20), 4] = True + for row, value in enumerate((self.steps, round((self.kite.vy + 10) * 20), + round((self.kite.vx + 5) * 20))): + for bit in range(9): + state[row, bit, 5] = bool(min(511, max(0, value)) & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/kite_master.py b/runtime/minatar_synth/games/kite_master.py new file mode 100644 index 0000000000000000000000000000000000000000..caf799118c2cd7390676413d3e1f05e58640944c --- /dev/null +++ b/runtime/minatar_synth/games/kite_master.py @@ -0,0 +1,117 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Cloud: + x: float + y: float + vx: float + + +class KiteMasterEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x, self.y = 35.0, 70.0 + self.vx = self.vy = 0.0 + self.line_length = 20.0 + self.wind = 1.0 + self.steps = self.frames = 0 + self.pressed = self.terminal = False + self.cloud: Cloud | None = None + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0.0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return reward, self.terminal + + def _advance(self) -> float: + self.wind = 1 + 0.5 * math.sin(self.frames * 0.01) + self.frames += 1 + dx, dy = self.x - 20, self.y - 87 + distance = math.hypot(dx, dy) + if self.pressed: + self.line_length = max(5, self.line_length - 0.2) + if distance > self.line_length: + self.line_length = min(120, self.line_length + self.wind * 0.1) + tension = max(0, distance - self.line_length) * 0.1 + radial_force = (self.wind * 0.81 - tension) / distance if distance else 0 + fx = dx * radial_force + self.wind * 0.19 + fy = dy * radial_force + 0.3 - self.pressed + self.vx = (self.vx + fx * 0.02) * 0.98 + self.vy = (self.vy + fy * 0.02) * 0.98 + self.x = min(95, max(5, self.x + self.vx)) + self.y = min(95, max(5, self.y + self.vy)) + if self.cloud is None: + self.cloud = Cloud(self.random.uniform(25, 75), -5, self.random.uniform(-0.1, 0.1)) + cloud = self.cloud + cloud.x += cloud.vx + cloud.y += 0.15 + if (cloud.x <= 20 and cloud.vx < 0) or (cloud.x >= 80 and cloud.vx > 0): + cloud.vx *= -1 + if cloud.y > 90: + self.terminal = True + return 0.0 + reward = 0.0 + if self._collects(cloud): + reward = 100 - cloud.y + self.cloud = None + self.terminal = self.y > 85 + return reward + + def _collects(self, cloud: Cloud) -> bool: + angle = math.atan2(self.y - 87, self.x - 20) + self.wind * 0.3 + math.pi / 2 + cosine, sine = math.cos(angle), math.sin(angle) + for offset in (-3, 3): + cx = cloud.x + offset + dx, dy = cx - self.x, cloud.y - self.y + along = min(6, max(-6, dx * cosine + dy * sine)) + if math.hypot(dx - along * cosine, dy - along * sine) < 6: + return True + if abs(cx - 20) < 7 and abs(cloud.y - 87) < 7: + return True + return False + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[8, 2, 0] = True + state[int(self.y) // 10, int(self.x) // 10, 1] = True + if self.cloud is not None and 0 <= self.cloud.y < 100: + state[int(self.cloud.y) // 10, int(self.cloud.x) // 10, 2] = True + for fraction in np.linspace(0, 1, 12): + x = 20 + fraction * (self.x - 20) + y = 87 + fraction * (self.y - 87) + state[int(y) // 10, int(x) // 10, 3] = True + state[9, :, 4] = True + values = (self.steps, round(self.line_length * 4), round(self.wind * 100), + round((self.vx + 3) * 80), round((self.vy + 3) * 80)) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(min(511, max(0, value)) & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/knight_vs_pawns.py b/runtime/minatar_synth/games/knight_vs_pawns.py new file mode 100644 index 0000000000000000000000000000000000000000..42198c4cd96d071a3e870c195fe657d18542010e --- /dev/null +++ b/runtime/minatar_synth/games/knight_vs_pawns.py @@ -0,0 +1,86 @@ +import numpy as np + + +MOVES = ((1, -2), (2, -1), (2, 1), (1, 2), (-1, 2), (-2, 1), (-2, -1), (-1, -2)) + + +class KnightVsPawnsEnvironment: + score_cap = 1200 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.knight = (3, 7) + self.ghost = (5, 6) + self.move_index = self.steps = self.frames = 0 + self.pressed = self.terminal = False + self.pawns: list[tuple[int, int]] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap: bool) -> int: + if self.frames % 30 == 0: + self._cycle_ghost() + reward = 0 + if tap: + self.knight = self.ghost + self._cycle_ghost() + reward = 8 - self.knight[1] + if self.frames % 60 == 0: + self.pawns = [(x, y + 1) for x, y in self.pawns if y < 7] + if self.frames % 120 == 0: + self.pawns.append((int(self.random.integers(8)), 0)) + self.frames += 1 + self.terminal = self.knight in self.pawns + return reward + + def _cycle_ghost(self) -> None: + x, y = self.knight + for _ in MOVES: + dx, dy = MOVES[self.move_index] + self.move_index = (self.move_index + 1) % len(MOVES) + if 0 <= x + dx < 8 and 0 <= y + dy < 8: + self.ghost = (x + dx, y + dy) + return + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + x, y = self.knight + state[y + 1, x + 1, 0] = True + x, y = self.ghost + state[y + 1, x + 1, 1] = True + for x, y in self.pawns: + state[y + 1, x + 1, 2] = True + if y < 7: + state[y + 2, x + 1, 3] = True + state[1:9, 1:9, 4] = True + values = (self.steps, self.frames % 120, self.move_index) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/krull.py b/runtime/minatar_synth/games/krull.py new file mode 100644 index 0000000000000000000000000000000000000000..480f9ecf8f9229d029881ed89566e8da53ce4649 --- /dev/null +++ b/runtime/minatar_synth/games/krull.py @@ -0,0 +1,366 @@ +import numpy as np + + +class KrullEnvironment: + """Two-quest marriage, desert, web, path, and fortress campaign.""" + + score_cap = 9_360.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 2_400): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.quest = 0 + self.lives = 3 + self.glaives = 0 + self.score = 0.0 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self.claimed: set[tuple[int, str, int]] = set() + self.prison_chunks: set[int] = set() + self._start_marriage() + + def _base_stage(self, stage: str) -> None: + self.stage = stage + self.stage_steps = 0 + self.player = [8, 5] + self.previous_player = self.player.copy() + self.projectile: dict[str, object] | None = None + self.enemy_projectiles: list[list[int]] = [] + + def _start_marriage(self) -> None: + self._base_stage("marriage") + self.lyssa = [1, 5] + self.slayers = { + index: [1 + index % 4, 0 if index % 2 == 0 else 9] + for index in range(8) + if (self.quest, "slayer", index) not in self.claimed + } + + def _start_desert(self) -> None: + self._base_stage("desert") + self.player = [5, 5] + self.previous_player = self.player.copy() + self.desert_items = [ + {"kind": "glaive", "index": index, "position": [7, 9 + index * 12]} + for index in range(3) + if (self.quest, "glaive", index) not in self.claimed + ] + if (self.quest, "life", 0) not in self.claimed: + self.desert_items.append({"kind": "life", "index": 0, "position": [7, 27]}) + + def _start_web(self) -> None: + self._base_stage("web") + self.player = [9, 5] + self.previous_player = self.player.copy() + self.cocoon = [0, 5] + self.spider = [0, 0] + self.web_timer = 80 - 10 * self.quest + self.strands = { + index: [row, (index * 3 + self.quest) % 10] + for index, row in enumerate((8, 7, 6, 5, 4, 3, 2, 1)) + } + + def _start_path(self) -> None: + self._base_stage("path") + self.player = [5, 4] + self.previous_player = self.player.copy() + self.path_selection = 0 + self.sunrise = 0 + self.sun_timer = 30 - 5 * self.quest + self.correct_path = (self.quest * 3 + self.sunrise * 5) % 8 + + def _start_fortress(self) -> None: + self._base_stage("fortress") + self.beast = [3, 5] + self.lyssa = [1, 5] + self.lyssa_free = len(self.prison_chunks) >= 6 + self.has_fireball = False + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + stage_before = self.stage + lives_before = self.lives + reward = { + "marriage": self._act_marriage, + "desert": self._act_desert, + "web": self._act_web, + "path": self._act_path, + "fortress": self._act_fortress, + }[self.stage](action) + transitioned = self.stage != stage_before or self.lives != lives_before + self.score += reward + self.steps += 1 + if not transitioned: + self.stage_steps += 1 + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _move_player(self, action: int) -> None: + if action in (1, 2, 3, 4): + delta = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)}[action] + self.player[0] = int(np.clip(self.player[0] + delta[0], 0, 9)) + self.player[1] = int(np.clip(self.player[1] + delta[1], 0, 9)) + + def _act_marriage(self, action: int) -> float: + self._move_player(action) + reward = 0.0 + if action == 5: + for index, slayer in list(self.slayers.items()): + if abs(slayer[0] - self.player[0]) + abs(slayer[1] - self.player[1]) <= 1: + del self.slayers[index] + identity = (self.quest, "slayer", index) + if identity not in self.claimed: + self.claimed.add(identity) + reward = float(10 * (index + 1 + self.quest)) + break + interval = max(1, 3 - self.quest) + if self.stage_steps % interval == 0: + for slayer in self.slayers.values(): + slayer[0] += int(np.sign(self.lyssa[0] - slayer[0])) + slayer[1] += int(np.sign(self.lyssa[1] - slayer[1])) + if any(slayer == self.player for slayer in self.slayers.values()): + self._lose_life() + elif self.stage_steps >= 79 or not self.slayers: + self._start_desert() + return reward + + def _act_desert(self, action: int) -> float: + self._move_player(action) + for item in self.desert_items: + item["position"][1] -= 1 + if action == 5: + for item in list(self.desert_items): + if item["position"][1] == self.player[1]: + identity = (self.quest, str(item["kind"]), int(item["index"])) + if identity not in self.claimed: + self.claimed.add(identity) + if item["kind"] == "glaive": + self.glaives = min(5, self.glaives + 1) + else: + self.lives = min(10, self.lives + 1) + self.desert_items.remove(item) + break + self.desert_items = [item for item in self.desert_items if item["position"][1] >= 0] + if self.stage_steps >= 59: + self._start_web() + return 0.0 + + def _act_web(self, action: int) -> float: + reward = 0.0 + if action == 5: + crossed = [index for index, strand in self.strands.items() if strand[0] == self.player[0] - 1] + if crossed: + index = crossed[0] + self.player[0] = max(0, self.player[0] - 2) + identity = (self.quest, "strand", index) + if identity not in self.claimed: + self.claimed.add(identity) + reward += float(40 + 10 * self.quest) + else: + self._move_player(action) + self.spider[0] += int(np.sign(self.player[0] - self.spider[0])) + self.spider[1] += int(np.sign(self.player[1] - self.spider[1])) + self.web_timer -= 1 + if self.player == self.spider or self.web_timer <= 0: + self._lose_life() + elif self.player == self.cocoon: + identity = (self.quest, "cocoon", 0) + if identity not in self.claimed: + self.claimed.add(identity) + reward += 500.0 + self._start_path() + return reward + + def _act_path(self, action: int) -> float: + if action == 1: + self.path_selection = (self.path_selection - 1) % 8 + elif action == 3: + self.path_selection = (self.path_selection + 1) % 8 + elif action == 5: + if self.path_selection == self.correct_path: + self._start_fortress() + else: + if self.lives > 1: + self.lives -= 1 + elif self.glaives > 0: + self.glaives -= 1 + else: + self._lose_life() + if not self.terminal: + self._start_web() + return 0.0 + self.sun_timer -= 1 + if self.sun_timer <= 0: + self.sunrise += 1 + self.correct_path = (self.quest * 3 + self.sunrise * 5) % 8 + self._start_web() + return 0.0 + + def _act_fortress(self, action: int) -> float: + reward = 0.0 + self._move_player(action) + if self.projectile is None and action == 5: + if self.has_fireball: + self.projectile = {"kind": "fireball", "position": self.player.copy(), "returning": False} + elif self.glaives > 0: + self.projectile = {"kind": "glaive", "position": self.player.copy(), "returning": False} + if self.projectile is not None: + reward += self._move_fortress_projectile(action) + if self.stage != "fortress": + return reward + if self.lyssa_free and not self.has_fireball and self.lyssa[0] < self.player[0]: + self.lyssa[0] += 1 + if self.lyssa[0] == self.player[0]: + self.has_fireball = True + if self.stage_steps % max(4, 7 - self.quest * 2) == 0: + self.enemy_projectiles.append(self.beast.copy()) + for fireball in list(self.enemy_projectiles): + fireball[0] += int(np.sign(self.player[0] - fireball[0])) + fireball[1] += int(np.sign(self.player[1] - fireball[1])) + if fireball == self.player: + self._lose_life() + return reward + if self.glaives == 0 and self.projectile is None and self.player[1] in (0, 9): + self._start_desert() + return reward + + def _move_fortress_projectile(self, action: int) -> float: + projectile = self.projectile + position = projectile["position"] + if projectile["kind"] == "fireball": + position[0] -= 1 + position[1] += int(np.sign(self.beast[1] - position[1])) + if position == self.beast: + self.projectile = None + return self._destroy_beast() + elif not projectile["returning"]: + position[0] -= 1 + if action == 1: + position[1] = max(0, position[1] - 1) + elif action == 3: + position[1] = min(9, position[1] + 1) + if position[0] <= 1 and 2 <= position[1] <= 7: + chunk = position[1] - 2 + identity = (self.quest, "chunk", chunk) + reward = 0.0 + if identity not in self.claimed: + self.claimed.add(identity) + self.prison_chunks.add(chunk) + reward = 70.0 + projectile["returning"] = True + if len(self.prison_chunks) >= 6: + self.lyssa_free = True + return reward + if position == self.beast: + self.glaives -= 1 + self.projectile = None + else: + position[0] += 1 + if position[0] >= self.player[0]: + if position[1] != self.player[1]: + self.glaives -= 1 + self.projectile = None + if self.projectile is not None and not (0 <= position[0] < 10 and 0 <= position[1] < 10): + if projectile["kind"] == "glaive": + self.glaives -= 1 + self.projectile = None + return 0.0 + + def _destroy_beast(self) -> float: + identity = (self.quest, "beast", 0) + reward = 0.0 if identity in self.claimed else 3_000.0 + self.claimed.add(identity) + self.quest += 1 + if self.quest >= 2: + self.terminal = True + else: + self.prison_chunks = set() + self._start_marriage() + return reward + + def _lose_life(self) -> None: + self.lives -= 1 + if self.lives <= 0: + self.terminal = True + elif self.stage == "marriage": + self._start_marriage() + elif self.stage in ("web", "path"): + self._start_web() + else: + self._start_fortress() + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + if self.stage == "marriage": + for slayer in self.slayers.values(): + state[*slayer, 1] = True + state[*self.lyssa, 2] = True + elif self.stage == "desert": + for item in self.desert_items: + column = int(item["position"][1]) + if 0 <= column < 10: + state[item["position"][0], column, 2] = True + elif self.stage == "web": + state[*self.spider, 1] = True + state[*self.cocoon, 2] = True + for strand in self.strands.values(): + state[*strand, 3] = True + elif self.stage == "fortress": + state[*self.beast, 1] = True + state[*self.lyssa, 2] = True + for chunk in range(6): + if chunk not in self.prison_chunks: + state[1, chunk + 2, 3] = True + for fireball in self.enemy_projectiles: + state[*fireball, 1] = True + if self.projectile is not None: + state[*self.projectile["position"], 3] = True + state[*self.previous_player, 4] = True + stages = ("marriage", "desert", "web", "path", "fortress") + for index in range(8): + state[0, index, 5] = (self.quest, "strand", index) in self.claimed + state[0, 8, 5] = (self.quest, "cocoon", 0) in self.claimed + state[0, 9, 5] = (self.quest, "beast", 0) in self.claimed + for bit in range(10): + state[1, bit, 5] = bool(self.stage_steps & (1 << bit)) + for bit in range(10): + state[2, bit, 5] = bool(self.steps & (1 << bit)) + for bit in range(2): + state[3, bit, 5] = bool(self.steps & (1 << (10 + bit))) + state[3, 2 + bit, 5] = bool(self.stage_steps & (1 << (10 + bit))) + state[9, stages.index(self.stage), 5] = True + state[9, 5 + self.quest, 5] = True + for bit in range(4): + state[8, bit, 5] = bool(self.lives & (1 << bit)) + state[8, 4 + bit, 5] = bool(self.glaives & (1 << bit)) + if self.stage == "web": + for bit in range(7): + state[7, bit, 5] = bool(self.web_timer & (1 << bit)) + if self.stage == "path": + state[6, self.path_selection, 5] = True + state[5, self.correct_path, 5] = True + for bit in range(5): + state[4, bit, 5] = bool(self.sun_timer & (1 << bit)) + state[3, 5, 5] = self.lyssa_free if self.stage == "fortress" else False + state[3, 6, 5] = self.has_fireball if self.stage == "fortress" else False + return state diff --git a/runtime/minatar_synth/games/kung_fu_master.py b/runtime/minatar_synth/games/kung_fu_master.py new file mode 100644 index 0000000000000000000000000000000000000000..9e36db1985d5bf1d9bf0e27e9509bd79f5894c49 --- /dev/null +++ b/runtime/minatar_synth/games/kung_fu_master.py @@ -0,0 +1,335 @@ +import numpy as np + + +BOSS_NAMES = ("fist_fighter", "boomerang_thrower", "giant_kicker", "lightning_magician", "gang_master") +BOSS_VALUES = (2_000, 3_000, 3_000, 5_000, 10_000) +REGULAR_ROSTERS = ( + ("henchman",) * 4 + ("knife_thrower",) * 2, + ("henchman",) * 3 + ("midget",) * 3 + ("knife_thrower",), + ("dragon_ball",) * 3 + ("snake",) * 2 + ("moth",) * 2, + ("moth",) * 3 + ("knife_thrower",) * 2 + ("henchman",) * 2, + ("henchman",) * 4 + ("knife_thrower",) * 2 + ("midget",) * 2, +) +ENEMY_VALUES = { + "henchman": (100, 100), + "knife_thrower": (500, 800), + "midget": (200, 300), + "dragon_ball": (2_000, 2_000), + "moth": (500, 600), + "snake": (0, 0), +} +ENEMY_HEALTH = {"henchman": 1, "knife_thrower": 2, "midget": 1, "dragon_ball": 1, "moth": 1, "snake": 99} + + +class KungFuMasterEnvironment: + """Two five-floor temple climbs with stance-sensitive combat.""" + + score_cap = 120_800.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 4_000): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.climb = 0 + self.floor = 0 + self.lives = 3 + self.score = 0.0 + self.bonus_life_awarded = False + self.steps = 0 + self.last_action = 0 + self.terminal = False + self.claimed: set[tuple[int, int, int]] = set() + self._start_floor() + + def _start_floor(self) -> None: + self.player = [5, 5] + self.previous_player = self.player.copy() + self.facing = 1 + self.energy = 10 + self.timer = 300 + self.jump_timer = 0 + self.squat_timer = 0 + self.grabbed_by: int | None = None + self.last_escape_direction = 0 + self.enemies: dict[int, dict[str, object]] = {} + for index, kind in enumerate(REGULAR_ROSTERS[self.floor]): + if (self.climb, self.floor, index) not in self.claimed: + side = 9 if index % 2 == 0 else 0 + row = 4 if kind == "moth" else 5 + self.enemies[index] = { + "kind": kind, + "position": [row, side], + "health": ENEMY_HEALTH[kind], + "cooldown": index % 4, + "direction": -1 if side == 9 else 1, + } + self.knives: list[dict[str, object]] = [] + self.previous_knives: list[list[int]] = [] + self.boss: dict[str, object] | None = None + self.boss_projectiles: list[list[int]] = [] + self.floor_steps = 0 + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + floor_before = (self.climb, self.floor) + lives_before = self.lives + self._apply_stance_and_movement(action) + reward = self._attack() if action == 5 else 0.0 + self._move_regular_enemies() + self._move_knives() + self._move_boss() + self._resolve_damage() + if self.lives != lives_before or self.terminal: + return self._finish_step(reward, consume_timer=False) + if not self.enemies and self.boss is None: + self._spawn_boss() + transitioned = (self.climb, self.floor) != floor_before + return self._finish_step(reward, consume_timer=not transitioned) + + def _finish_step(self, reward: float, consume_timer: bool = True) -> tuple[float, bool]: + self.score += reward + if self.score >= 75_000 and not self.bonus_life_awarded: + self.lives = min(9, self.lives + 1) + self.bonus_life_awarded = True + if consume_timer: + self.timer -= 1 + self.floor_steps += 1 + self.jump_timer = max(0, self.jump_timer - 1) + self.squat_timer = max(0, self.squat_timer - 1) + if self.timer <= 0: + self._lose_life() + self.steps += 1 + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _apply_stance_and_movement(self, action: int) -> None: + if self.grabbed_by is not None: + direction = -1 if action == 1 else 1 if action == 3 else 0 + if direction and direction != self.last_escape_direction: + self.last_escape_direction = direction + enemy = self.enemies.get(self.grabbed_by) + if enemy is not None: + enemy["health"] = int(enemy["health"]) - 1 + if enemy["health"] <= -2: + self.grabbed_by = None + return + if action == 1: + self.player[1] = max(0, self.player[1] - 1) + self.facing = -1 + elif action == 3: + self.player[1] = min(9, self.player[1] + 1) + self.facing = 1 + elif action == 2: + self.jump_timer = 2 + self.player[0] = 3 + elif action == 4: + self.squat_timer = 2 + self.player[0] = 6 + elif self.jump_timer == 0 and self.squat_timer == 0: + self.player[0] = 5 + + def _attack(self) -> float: + if self.jump_timer > 0: + return 0.0 + low = self.squat_timer > 0 + candidates = [] + for index, enemy in self.enemies.items(): + position = enemy["position"] + distance = abs(position[1] - self.player[1]) + correct_side = int(np.sign(position[1] - self.player[1])) == self.facing + height_ok = low if enemy["kind"] == "midget" else not low + if correct_side and distance <= 2 and height_ok: + candidates.append((distance, index, enemy)) + if candidates: + distance, index, enemy = min(candidates) + if enemy["kind"] == "snake": + return 0.0 + enemy["health"] = int(enemy["health"]) - 1 + if enemy["health"] <= 0: + del self.enemies[index] + self.claimed.add((self.climb, self.floor, index)) + kick_value, punch_value = ENEMY_VALUES[str(enemy["kind"])] + return float(kick_value if distance == 2 else punch_value) + return 0.0 + if self.boss is not None: + distance = abs(self.boss["position"][1] - self.player[1]) + correct_side = int(np.sign(self.boss["position"][1] - self.player[1])) == self.facing + if correct_side and distance <= 2: + self.boss["health"] = int(self.boss["health"]) - 1 + if self.boss["health"] <= 0: + return self._complete_floor() + return 0.0 + + def _move_regular_enemies(self) -> None: + interval = max(1, 3 - self.climb) + for index, enemy in list(self.enemies.items()): + kind = str(enemy["kind"]) + position = enemy["position"] + if kind == "snake": + position[1] += int(enemy["direction"]) + if not 0 <= position[1] < 10: + del self.enemies[index] + continue + enemy["cooldown"] = int(enemy["cooldown"]) - 1 + if kind == "knife_thrower" and enemy["cooldown"] <= 0: + height = "high" if (index + self.floor_steps) % 2 else "low" + self.knives.append( + {"position": position.copy(), "direction": int(np.sign(self.player[1] - position[1])) or -1, "height": height} + ) + enemy["cooldown"] = max(3, 7 - self.climb) + if self.floor_steps % interval: + continue + if kind == "moth": + position[0] = 4 if position[0] == 5 else 5 + position[1] += int(np.sign(self.player[1] - position[1])) + if kind == "snake" and position[1] == self.player[1]: + direction = -1 if position[1] > 0 else 1 + position[1] += direction + + def _move_knives(self) -> None: + self.previous_knives = [list(knife["position"]) for knife in self.knives] + for knife in list(self.knives): + knife["position"][1] += int(knife["direction"]) + if not 0 <= knife["position"][1] < 10: + self.knives.remove(knife) + + def _spawn_boss(self) -> None: + self.boss = { + "kind": BOSS_NAMES[self.floor], + "position": [5, 8], + "health": 4 + self.floor + self.climb, + "cooldown": 3, + } + + def _move_boss(self) -> None: + if self.boss is None: + return + self.boss["cooldown"] = int(self.boss["cooldown"]) - 1 + if self.boss["cooldown"] <= 0: + self.boss_projectiles.append(self.boss["position"].copy()) + self.boss["cooldown"] = max(2, 6 - self.floor // 2 - self.climb) + if self.floor_steps % 2 == 0: + self.boss["position"][1] += int(np.sign(self.player[1] - self.boss["position"][1])) + for projectile in list(self.boss_projectiles): + projectile[1] += int(np.sign(self.player[1] - projectile[1])) + if not 0 <= projectile[1] < 10: + self.boss_projectiles.remove(projectile) + + def _resolve_damage(self) -> None: + for index, enemy in self.enemies.items(): + if enemy["position"] != self.player: + continue + if enemy["kind"] == "henchman" and self.grabbed_by is None: + self.grabbed_by = index + self.energy -= 1 + break + for knife in list(self.knives): + if knife["position"][1] != self.player[1]: + continue + avoided = (knife["height"] == "low" and self.jump_timer > 0) or ( + knife["height"] == "high" and self.squat_timer > 0 + ) + if not avoided: + self.energy -= 2 + self.knives.remove(knife) + if self.boss is not None and self.boss["position"] == self.player: + self.energy -= 3 + for projectile in list(self.boss_projectiles): + if projectile[1] == self.player[1]: + self.energy -= 2 + self.boss_projectiles.remove(projectile) + if self.grabbed_by is not None: + self.energy -= 1 + if self.energy <= 0: + self._lose_life() + + def _complete_floor(self) -> float: + reward = float(BOSS_VALUES[self.floor] + self.timer * 10 + self.energy * 100) + self.floor += 1 + if self.floor >= 5: + self.floor = 0 + self.climb += 1 + if self.climb >= 2: + self.terminal = True + else: + self._start_floor() + return reward + + def _lose_life(self) -> None: + self.lives -= 1 + if self.lives <= 0: + self.terminal = True + else: + self._start_floor() + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + for enemy in self.enemies.values(): + state[*enemy["position"], 1] = True + kind = str(enemy["kind"]) + if kind in ("knife_thrower", "dragon_ball"): + state[*enemy["position"], 2] = True + if kind in ("midget", "dragon_ball"): + state[*enemy["position"], 3] = True + if kind in ("moth", "snake"): + state[*enemy["position"], 4] = True + if self.boss is not None: + state[*self.boss["position"], 1] = True + for knife in self.knives: + state[*knife["position"], 2 if knife["height"] == "high" else 1] = True + for projectile in self.boss_projectiles: + state[*projectile, 1] = True + state[*self.previous_player, 4] = True + for knife in self.previous_knives: + state[*knife, 4] = True + for index in range(len(REGULAR_ROSTERS[self.floor])): + state[index // 10, index % 10, 5] = (self.climb, self.floor, index) in self.claimed + state[2, self.floor, 5] = True + state[2, 5 + self.climb, 5] = True + for bit in range(4): + state[3, bit, 5] = bool(self.lives & (1 << bit)) + state[3, 4 + bit, 5] = bool(self.energy & (1 << bit)) + for bit in range(9): + state[4, bit, 5] = bool(self.timer & (1 << bit)) + for bit in range(12): + state[5 + bit // 10, bit % 10, 5] = bool(self.steps & (1 << bit)) + state[7, 0, 5] = self.facing > 0 + state[7, 1 : 1 + self.jump_timer, 5] = True + state[7, 3 : 3 + self.squat_timer, 5] = True + state[7, 5, 5] = self.grabbed_by is not None + if self.grabbed_by is not None: + for bit in range(4): + state[7, 6 + bit, 5] = bool(self.grabbed_by & (1 << bit)) + if self.boss is not None: + for bit in range(4): + state[8, bit, 5] = bool(int(self.boss["health"]) & (1 << bit)) + for bit in range(3): + state[8, 4 + bit, 5] = bool(int(self.boss["cooldown"]) & (1 << bit)) + state[8, 7, 5] = self.bonus_life_awarded + knife_throwers = [enemy for enemy in self.enemies.values() if enemy["kind"] == "knife_thrower"] + for index, enemy in enumerate(knife_throwers[:2]): + for bit in range(3): + state[1, index * 3 + bit, 5] = bool(int(enemy["cooldown"]) & (1 << bit)) + for bit in range(10): + state[9, bit, 5] = bool(self.floor_steps & (1 << bit)) + for bit in range(2): + state[8, 8 + bit, 5] = bool(self.floor_steps & (1 << (10 + bit))) + return state diff --git a/runtime/minatar_synth/games/l_rain.py b/runtime/minatar_synth/games/l_rain.py new file mode 100644 index 0000000000000000000000000000000000000000..06acdb5109b2c2b5b0073241646fc9814eb002ae --- /dev/null +++ b/runtime/minatar_synth/games/l_rain.py @@ -0,0 +1,145 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Laser: + x: float + y: float + vy: int + width: float + burst: int = 0 + + +@dataclass +class Fragment: + x: float + y: float + vy: int + height: float + + +class LRainEnvironment: + score_cap = 3000 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x = self.safe_x = 50.0 + self.safe_vx = self.invincible = self.timer = 0.0 + self.energy = self.steps = self.frames = self.action = 0 + self.multiplier = 1 + self.terminal = False + self.lasers: list[Laser] = [] + self.fragments: list[Fragment] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.action = action + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self) -> int: + previous = self.x + self.x = min(99, max(0, self.x + 2 * ((self.action == 3) - (self.action == 1)))) + self.safe_x += self.safe_vx / (len(self.lasers) + 1) + self.safe_vx += (self.safe_vx + self.random.uniform(-0.01, 0.01) + 0.1) % 0.2 - 0.1 + self.safe_vx *= 0.99 + if (self.safe_x < 9 and self.safe_vx < 0) or (self.safe_x > 90 and self.safe_vx > 0): + self.safe_vx *= -1 + self.frames += 1 + self.timer -= 1 + if self.timer < 0: + x, width = self.random.uniform(0, 99), self.random.uniform(3, 9) + vy = 3 if self.random.integers(2) else -3 + if abs(x - self.safe_x) > width + 2: + self.lasers.append(Laser(x, 0 if vy > 0 else 99, vy, width)) + cadence = abs(math.cos(self.frames * 0.001)) + self.timer = self.random.uniform(0, 30 / (5 if cadence < 0.15 else cadence)) + self._move_lasers() + reward = 0 + hit = False + remaining = [] + for fragment in self.fragments: + fragment.y += fragment.vy + if abs(fragment.y - 50) < fragment.height / 2 + 3: + left, right = fragment.x - 1.5, fragment.x + 1.5 + if ((right > self.x + 2 and left < previous + 6) + or (right > previous - 6 and left < self.x - 2)): + reward += self.multiplier + self.energy += 1 + if self.energy > 150: + self.multiplier += 1 + self.energy = 0 + self.invincible = 30 + hit |= abs(fragment.y - 50) < fragment.height / 2 + 2 and abs(fragment.x - self.x) < 2 + if -fragment.height / 2 <= fragment.y <= 99 + fragment.height / 2: + remaining.append(fragment) + self.fragments = remaining + self.terminal = hit and self.invincible < 3 + if self.invincible >= 3: + self.invincible *= 0.98 + return reward + + def _move_lasers(self) -> None: + remaining = [] + for laser in self.lasers: + if 0 <= laser.y <= 99: + laser.y += laser.vy + else: + laser.burst += 1 + width = min(math.sin(laser.burst * 0.1) * laser.width * 2, laser.width - 1) + if width <= 0: + continue + height = self.random.uniform(9, 15) + for _ in range(int(width)): + x = laser.x + self.random.uniform(-width, width) + offset = self.random.uniform(0, 9) + height / 2 + y = 100 - laser.y - math.copysign(offset, laser.vy) + self.fragments.append(Fragment(x, y, laser.vy * 3, height)) + remaining.append(laser) + self.lasers = remaining + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[5, int(self.x) // 10, 0] = True + for laser in self.lasers: + left = max(0, int((laser.x - laser.width) // 10)) + right = min(9, int((laser.x + laser.width) // 10)) + head = min(9, max(0, int(laser.y // 10))) + channel = 1 if laser.vy > 0 else 2 + rows = slice(0, head + 1) if laser.vy > 0 else slice(head, 10) + state[rows, left:right + 1, channel] = True + for fragment in self.fragments: + if 0 <= fragment.x < 100: + top = max(0, int((fragment.y - fragment.height / 2) // 10)) + bottom = min(9, int((fragment.y + fragment.height / 2) // 10)) + if top <= bottom: + state[top:bottom + 1, int(fragment.x) // 10, 3 if fragment.vy > 0 else 4] = True + gauges = (self.steps, round(self.x * 4), self.energy, min(511, self.multiplier), + round(self.invincible * 10)) + for row, value in enumerate(gauges): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/ladder_drop.py b/runtime/minatar_synth/games/ladder_drop.py new file mode 100644 index 0000000000000000000000000000000000000000..c31876e41c44b4454da5ef3e17c53dceba841651 --- /dev/null +++ b/runtime/minatar_synth/games/ladder_drop.py @@ -0,0 +1,151 @@ +from dataclasses import dataclass + +import numpy as np + + +HORIZON = 400 +WIDTH = 10 +MAX_PANEL_WIDTH = 6 +MAX_COINS = (HORIZON // 4) * MAX_PANEL_WIDTH + + +@dataclass +class Panel: + row: int + left: int + width: int + ladder: int + depth: int + has_coins: bool = False + + def floor(self) -> set[tuple[int, int]]: + return {(self.row, column) for column in range(self.left, self.left + self.width)} + + def rungs(self) -> set[tuple[int, int]]: + return {(row, self.left + self.ladder) for row in range(self.row, self.row + self.depth)} + + +class LadderDropEnvironment: + score_cap = MAX_COINS * (MAX_COINS + 1) // 2 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.last_action = self.panel_count = 0 + self.row, self.column = 8, 1 + self.direction = self.panel_direction = self.multiplier = 1 + self.climbing = self.falling = self.terminal = False + self.panels = [Panel(9, 0, WIDTH, 0, 0)] + self.coins: set[tuple[int, int]] = set() + self._new_panel(5) + + def _new_panel(self, left: int) -> None: + self.panel_count += 1 + width = int(self.random.integers(4, MAX_PANEL_WIDTH + 1)) + self.panel = Panel(0, min(left, WIDTH - width), width, + int(self.random.integers(width)), int(self.random.integers(3, 6)), + self.panel_count % 4 == 0) + self.falling = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def _settled_cells(self) -> tuple[set[tuple[int, int]], set[tuple[int, int]]]: + floors: set[tuple[int, int]] = set() + ladders: set[tuple[int, int]] = set() + for panel in self.panels: + floors.update(panel.floor()) + ladders.update(panel.rungs()) + return floors, ladders + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + pressed = action == 5 and self.last_action != 5 + self.last_action = action + self.steps += 1 + if self.steps % 16 == 0 or (self.steps % 4 == 0 and min(p.row for p in self.panels) < 3): + self.row += 1 + for panel in self.panels: + panel.row += 1 + self.panels = [panel for panel in self.panels if panel.row < 10] + self.multiplier = max(1, self.multiplier - sum(row == 9 for row, _ in self.coins)) + self.coins = {(row + 1, column) for row, column in self.coins if row < 9} + + floors, ladders = self._settled_cells() + if not self.falling: + left = self.panel.left + self.panel_direction + if not 0 <= left <= WIDTH - self.panel.width: + self.panel_direction *= -1 + else: + self.panel.left = left + self.falling = pressed + if self.falling: + self.panel.row += 1 + if (self.row, self.column) in self.panel.floor() - self.panel.rungs(): + self.terminal = True + return 0.0, True + if (self.panel.floor() | self.panel.rungs()) & (floors | ladders): + self.panel.row -= 1 + self.panels.append(self.panel) + if self.panel.has_coins: + self.coins.update((self.panel.row - 1, column) + for column in range(self.panel.left, self.panel.left + self.panel.width) + if self.panel.row > 0) + self._new_panel(self.panel.left) + floors, ladders = self._settled_cells() + elif self.panel.row >= 10: + self._new_panel(self.panel.left) + + self._move_player(floors, ladders) + reward = 0 + cell = self.row, self.column + if cell in self.coins: + self.coins.remove(cell) + reward = self.multiplier + self.multiplier += 1 + self.terminal = self.row >= 10 or self.steps >= self.horizon or not self.panels + return float(reward), self.terminal + + def _move_player(self, floors: set, ladders: set) -> None: + if (self.row, self.column) in ladders: + self.row -= 1 + self.climbing = True + return + if (self.row + 1, self.column) not in floors: + self.row += 1 + self.climbing = False + return + destination = self.column + self.direction + if not 0 <= destination < WIDTH or (self.row, destination) in floors - ladders: + self.direction *= -1 + else: + self.column = destination + self.climbing = False + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, max(0, self.row)), self.column, 0] = True + floors, ladders = self._settled_cells() + for channel, cells in enumerate((floors, ladders, self.coins, + self.panel.floor() | self.panel.rungs()), start=1): + for row, column in cells: + if 0 <= row < 10: + state[row, column, channel] = True + gauges = (self.steps, self.multiplier, self.panel_count % 4, self.panel.ladder, + int(self.falling), int(self.direction > 0), int(self.panel_direction > 0), + int(self.last_action == 5), self.row + 1) + for row, value in enumerate(gauges): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/laser_fortress.py b/runtime/minatar_synth/games/laser_fortress.py new file mode 100644 index 0000000000000000000000000000000000000000..798a2fb243915c33b20c46d788300583d9230c8a --- /dev/null +++ b/runtime/minatar_synth/games/laser_fortress.py @@ -0,0 +1,120 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Unit: + x: float + speed: int + ally: bool + + +class LaserFortressEnvironment: + score_cap = 400 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.units: list[Unit] = [] + self.timer = 0.0 + self.group_remaining = 6 + self.fast_index = -1 + self.ally_group = False + self.sight = 40.0 + self.beam = 0.0 + self.multiplier = 1 + self.steps = 0 + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed: + self.beam = self.sight + self.multiplier = 1 + self.pressed = pressed + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self) -> int: + beam_x = self.beam + if self.pressed: + self.beam += 2 + self.timer -= 1 + if self.timer < 0: + self._spawn() + reward = 0 + nearest = 200.0 + remaining = [] + for unit in self.units: + unit.x -= unit.speed + if not unit.ally: + nearest = min(nearest, unit.x) + if self.pressed and abs(beam_x - unit.x) < 5: + if unit.ally: + self.terminal = True + else: + reward += self.multiplier + self.multiplier += 1 + elif unit.x < 0: + self.terminal |= not unit.ally + else: + remaining.append(unit) + self.units = remaining + if nearest < 200: + self.sight += (nearest - 8 - self.sight) * 0.3 + return reward + + def _spawn(self) -> None: + speed = 2 if self.group_remaining - 1 == self.fast_index else 1 + self.units.append(Unit(163, speed, self.ally_group)) + self.group_remaining -= 1 + if self.group_remaining: + self.timer = self.random.uniform(5, 8) + else: + self.group_remaining = 10 - math.floor(math.sqrt(self.random.uniform(0, 50))) + self.timer = self.random.uniform(20, 30) + self.ally_group = not self.ally_group and self.random.random() < 0.3 + self.fast_index = -1 if self.random.random() < 0.5 else int(self.random.integers(2)) + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[1:5, 0, 0] = True + for unit in self.units: + if 0 <= unit.x < 160: + state[7, int(unit.x) // 16, 2 if unit.ally else 1] = True + if 0 <= self.sight < 160: + state[7, int(self.sight) // 16, 3] = True + if self.pressed: + for fraction in np.linspace(0, 1, 20): + x = 20 + (self.beam - 2 - 20) * fraction + y = 8 + 42 * fraction + if 0 <= x < 160: + state[int(y) // 6, int(x) // 16, 4] = True + values = (self.steps, min(511, self.multiplier), min(511, max(0, round(self.sight * 3))), + min(511, max(0, round(self.beam * 3)))) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/levitation.py b/runtime/minatar_synth/games/levitation.py new file mode 100644 index 0000000000000000000000000000000000000000..823e41f934773988cf6f39497110229298113ed2 --- /dev/null +++ b/runtime/minatar_synth/games/levitation.py @@ -0,0 +1,98 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Platform: + x: float + y: float + width: float + + +class LevitationEnvironment: + score_cap = 100 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x = self.y = 40.0 + self.vy = self.spawn_distance = 0.0 + self.platforms = [Platform(0, 60, 99)] + self.steps = 0 + self.multiplier = 1 + self.rolling = self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed: + self.rolling = not self.rolling + self.multiplier = 1 + self.pressed = pressed + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self) -> int: + self.x += 0.2 if self.rolling else -0.4 + self.vy = (self.vy + 0.2) * 0.99 if self.rolling else 0 + self.y += self.vy + if self.y < 0 and self.vy < 0: + self.y = 0 + self.vy *= -0.3 + self.spawn_distance -= 0.5 + if self.spawn_distance < 0: + width = self.random.uniform(30, 50) + self.platforms.append(Platform(100, self.random.uniform(30, 90), width)) + self.spawn_distance = width + self.random.uniform(0, 9) + self.terminal = self.y > 100 or not -3 <= self.x <= 103 + if self.terminal: + return 0 + reward = 0 + for platform in self.platforms: + if (self.rolling and self.vy >= 0 and platform.x - 3 < self.x < platform.x + platform.width + 3 + and platform.y - 3 < self.y < platform.y + 8): + reward += self.multiplier + self.multiplier += 1 + self.y = platform.y - 3 + self.vy *= -1.5 + platform.x -= 0.5 + self.platforms = [p for p in self.platforms if p.x + p.width >= 0] + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + col = min(9, max(0, int(self.x // 10))) + row = min(9, max(0, int(self.y // 10))) + state[row, col, int(self.rolling)] = True + for platform in self.platforms: + left = max(0, int(platform.x // 10)) + right = min(9, int((platform.x + platform.width) // 10)) + state[int(platform.y // 10), left:right + 1, 2] = True + future_row = min(9, max(0, int((self.y + 4 * self.vy) // 10))) + state[future_row, col, 3] = True + state[:, (0, 9), 4] = True + gauges = (self.steps, min(511, self.multiplier), min(511, max(0, round((self.vy + 25) * 10)))) + for row, value in enumerate(gauges): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/lie_down.py b/runtime/minatar_synth/games/lie_down.py new file mode 100644 index 0000000000000000000000000000000000000000..09134ac7f49a2f9008741775d6ac34802d926d86 --- /dev/null +++ b/runtime/minatar_synth/games/lie_down.py @@ -0,0 +1,130 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Emitter: + x: float + speed: float + height: float = 0 + + +@dataclass +class Rock: + x: float + target_speed: float + speed: float = 0 + + +class LieDownEnvironment: + score_cap = 200 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.x, self.speed = 20.0, 0.0 + self.fall = self.steps = self.hole_timer = 0 + self.enemy_timer = 60 + self.multiplier = 1 + self.pressed = self.terminal = False + self.holes: list[Emitter] = [] + self.enemies: list[Emitter] = [] + self.rocks: list[Rock] = [] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed and not self.fall: + self.multiplier = max(1, self.multiplier - 1) + self.pressed = pressed + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self) -> int: + scroll = 0 if self.fall else 0.1 + max(0, self.x - 30) * 0.1 + self.enemy_timer -= 1 + if self.enemy_timer < 0: + speed = 0.1 + self.random.uniform(0, 2) * self.random.uniform(0, 2) * 0.1 + self.enemies.append(Emitter(self.random.uniform(100, 250), speed)) + self.enemy_timer = 50 + for rock in self.rocks: + rock.x -= scroll + rock.speed + rock.speed += (rock.target_speed - rock.speed) * 0.1 + self.rocks = [rock for rock in self.rocks if -3 <= rock.x <= 203] + self.hole_timer -= 1 + if self.hole_timer < 0: + self.holes.append(Emitter(self.random.uniform(0, 300), self.random.uniform(0.1, 0.2))) + self.hole_timer = 100 + for hole in self.holes: + hole.x -= scroll + hole.height += hole.speed + if hole.height > 11 and hole.speed > 0: + hole.speed *= -1 + self.holes = [hole for hole in self.holes if hole.height >= 0] + if self.fall: + self.fall += 1 + self.terminal = self.fall > 8 + else: + self.speed = (self.speed + (0 if self.pressed else 0.02)) * 0.99 + self.x += self.speed - scroll + self.terminal = self.x < 0 or (not self.pressed and any( + abs(rock.x - self.x) < 4 and rock.speed > rock.target_speed * 0.5 for rock in self.rocks + )) + if any(hole.height > 9 and abs(hole.x + 4.5 - self.x) < 2 for hole in self.holes): + self.speed = 0 + if self.pressed: + self.x -= 5 + else: + self.fall = 1 + reward = 0 + remaining = [] + for enemy in self.enemies: + enemy.x -= scroll + enemy.height += math.sqrt(enemy.speed * 10) / 10 if enemy.speed > 0 else enemy.speed + if enemy.height > 15 and enemy.speed > 0: + self.rocks.append(Rock(enemy.x, enemy.speed * 3)) + enemy.speed *= -1 + y = 37 + (10 - min(10, max(0, enemy.height))) ** 2 / 10 + player_y = 37 + self.fall if self.fall else (39 if self.pressed else 37) + if abs(enemy.x - self.x) < 5 and abs(y - player_y) < (4 if self.pressed else 6): + reward += self.multiplier + self.multiplier += 1 + elif enemy.height >= 0: + remaining.append(enemy) + self.enemies = remaining + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, (37 + self.fall + 2 * self.pressed) // 5), + min(9, max(0, int(self.x // 20))), 0] = True + for channel, objects in ((1, self.holes), (2, self.enemies), (3, self.rocks)): + for obj in objects: + if 0 <= obj.x < 200: + state[(8, 7, 6)[channel - 1], int(obj.x // 20), channel] = True + state[8:, :, 4] = True + for row, value in enumerate((self.steps, self.multiplier, self.fall, round(self.speed * 100))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/lift_up.py b/runtime/minatar_synth/games/lift_up.py new file mode 100644 index 0000000000000000000000000000000000000000..52a64949c3009e1cf2340b5fff4bbfb51d9045d8 --- /dev/null +++ b/runtime/minatar_synth/games/lift_up.py @@ -0,0 +1,144 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Wall: + x: float + y: float + width: float + + +@dataclass +class Item: + x: float + y: float + bonus: bool + + +class LiftUpEnvironment: + score_cap = 150 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.walls = [Wall(50, i * 6 - 3, 60) for i in range(19)] + self.top_wall = self.walls[0] + self.wall_vx = self.wall_vw = 0.0 + self.x, self.y, self.target_y = 40.0, 90.0, 90.0 + self.direction = self.item_side = self.multiplier = 1 + self.ratio = self.item_distance = self.bonus_x = 0.0 + self.bonus_count = self.steps = 0 + self.items: list[Item] = [] + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self) -> int: + self.ratio += (self.pressed - self.ratio) * 0.1 + scroll = (1 + self.ratio * 3) * 0.2 + for index, wall in enumerate(self.walls): + wall.y += scroll + if wall.y > 110: + self._recycle_wall(index, wall) + self.item_distance -= scroll + if self.item_distance < 0: + self._spawn_item() + self.x += self.direction * 0.05 * (4 - self.ratio * 3) + self.target_y -= 0.04 + self.y += (self.target_y - self.y) * 0.2 + self.terminal = self.y < 0 or self._hits_wall(self.x, self.y) + reward = 0 + remaining = [] + for item in self.items: + item.y += scroll + if self._hits_wall(item.x, item.y): + item.x += -1 if item.x > self.top_wall.x else 1 + if abs(item.x - self.x) < 5 and abs(item.y - self.y) < 5: + if item.bonus: + reward += self.multiplier + self.multiplier = min(99, self.multiplier + 1) + self.target_y += (99 - self.target_y) * 0.1 + else: + self.direction *= -1 + elif item.y <= 103: + remaining.append(item) + elif item.bonus: + self.multiplier = max(1, self.multiplier - 1) + self.items = remaining + return reward + + def _hits_wall(self, x: float, y: float) -> bool: + return any(abs(y - wall.y) < 5 and abs(x - wall.x) + 3 > wall.width / 2 + for wall in self.walls) + + def _recycle_wall(self, index: int, wall: Wall) -> None: + previous = self.walls[index - 1] + wall.y -= 114 + wall.x, wall.width = previous.x + self.wall_vx, previous.width + self.wall_vw + self.top_wall = wall + self.wall_vx = min(5, max(-5, self.wall_vx + self.random.uniform(-1, 1))) * 0.95 + self.wall_vw = min(3, max(-3, self.wall_vw + self.random.uniform(-1, 1))) * 0.95 + if ((wall.x + wall.width / 2 > 95 and self.wall_vx > 0) + or (wall.x - wall.width / 2 < 5 and self.wall_vx < 0)): + self.wall_vx *= -0.5 + if (wall.width > 80 and self.wall_vw > 0) or (wall.width < 40 and self.wall_vw < 0): + self.wall_vw *= -0.5 + + def _spawn_item(self) -> None: + wall = self.top_wall + if self.bonus_count > 0: + self.items.append(Item(self.bonus_x, -3, True)) + self.item_distance = 6 + elif self.bonus_count < 0 and self.random.random() < 0.5: + self.bonus_count = int(self.random.integers(2, 6)) + self.bonus_x = wall.x + self.random.uniform(-0.25, 0.25) * wall.width + self.item_distance = 0 + else: + x = wall.x + self.random.uniform(0.1, 0.4) * self.item_side * wall.width + self.items.append(Item(x, -3, False)) + if self.random.random() < 0.8: + self.item_side *= -1 + self.item_distance = self.random.uniform(10, 20) + self.bonus_count -= 1 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + row, col = min(9, max(0, int(self.y // 10))), min(9, max(0, int(self.x // 10))) + state[row, col, 0] = True + for wall in self.walls: + if 0 <= wall.y < 100: + state[int(wall.y // 10), :, 1] |= abs(np.arange(5, 100, 10) - wall.x) > wall.width / 2 + for item in self.items: + if 0 <= item.x < 100 and 0 <= item.y < 100: + state[int(item.y // 10), int(item.x // 10), 2 + item.bonus] = True + state[row, min(9, max(0, col + self.direction)), 4] = True + for row, value in enumerate((self.steps, self.multiplier, round(self.ratio * 100))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/light_dark.py b/runtime/minatar_synth/games/light_dark.py new file mode 100644 index 0000000000000000000000000000000000000000..91c21e4741fa81820523daa19d89fd30b266a16a --- /dev/null +++ b/runtime/minatar_synth/games/light_dark.py @@ -0,0 +1,108 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Item: + x: float + dark: bool + spike: bool = False + + +class LightDarkEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.height = self.velocity = 0.0 + self.dark = self.airborne = self.pressed = self.terminal = False + self.steps = 0 + self.multiplier = 1 + self.items = [Item(25 + i * 9 if i < 5 else 99 + i * 9, i >= 5) for i in range(10)] + self.distances = [200.0, 300.0] + self.next_spike = [False, True] + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tapped = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tapped and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tapped: bool) -> int: + if tapped: + self.dark = not self.dark + if self.airborne: + self.velocity -= 0.1 if self.pressed else 0.5 + self.height += self.velocity + if self.height < 0: + self.height = 0 + self.airborne = False + elif tapped: + self.velocity, self.height = 3, 7 + self.airborne = True + reward = 0 + remaining = [] + for item in self.items: + extent = 6 if item.spike else 5 + if item.dark == self.dark and abs(item.x - 9) < extent and abs(self.height - 1) < extent: + if item.spike: + self.terminal = True + break + reward += self.multiplier + self.multiplier += 1 + continue + item.x -= 2 + if item.x >= -3: + remaining.append(item) + elif not item.spike: + self.multiplier = max(1, self.multiplier - 1) + self.items = remaining + for side in range(2): + self.distances[side] -= 2 + if self.distances[side] < 0: + spike = self.next_spike[side] + spacing = 6 if spike else 9 + count = int(self.random.integers(5, 15) if spike else self.random.integers(4, 8)) + self.items.extend(Item(200 + i * spacing, bool(side), spike) for i in range(count)) + self.distances[side] = count * spacing + self.random.uniform(40, 120) + self.next_spike[side] = not spike + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + y = 53 + self.height if self.dark else 47 - self.height + state[min(9, max(0, int(y // 10))), 0, 0] = True + for item in self.items: + if 0 <= item.x < 200: + state[5 if item.dark else 4, int(item.x // 20), 1 + item.spike] = True + state[5:, :, 3] = True + state[5 if self.dark else 4, :, 4] = True + values = (self.steps, min(511, self.multiplier), round(self.height * 8), + min(511, max(0, round((self.velocity + 8) * 30)))) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.airborne + return state diff --git a/runtime/minatar_synth/games/line_b.py b/runtime/minatar_synth/games/line_b.py new file mode 100644 index 0000000000000000000000000000000000000000..5965f71a52eafa12db4fec3f55648fefdb099214 --- /dev/null +++ b/runtime/minatar_synth/games/line_b.py @@ -0,0 +1,101 @@ +import math + +import numpy as np + + +class LineBEnvironment: + score_cap = 350 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + angles = self.random.uniform(-math.pi / 3, math.pi / 3, 2) + np.array([0, math.pi]) + self.points = np.full((2, 2), 50.0) + self.velocity = np.column_stack((np.cos(angles), np.sin(angles))) + self.gold = None + self.radius = 1.0 + self.steps = 0 + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tapped = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tapped and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _distance(self, point: np.ndarray) -> float: + start, end = self.points + segment = end - start + length_squared = float(segment @ segment) + fraction = float((point - start) @ segment) / length_squared if length_squared else 0 + return float(np.linalg.norm(point - (start + min(1, max(0, fraction)) * segment))) + + def _advance(self, tapped: bool) -> int: + if self.gold is None: + for _ in range(99): + self.gold = self.random.uniform(20, 80, 2) + if self._distance(self.gold) > 22: + break + self.radius = 1 + ring = self.radius + hits_wall = ring + 1.5 >= min(*self.gold - 3, *(97 - self.gold)) + self.radius += 0.05 + if tapped: + for index, delta in enumerate(self.points.mean(axis=0) - self.points): + angle = math.atan2(delta[1], delta[0]) + self.velocity[index] += (9 * math.cos(angle), 9 * math.sin(angle)) + self.points += self.velocity + for point, velocity in zip(self.points, self.velocity, strict=True): + for axis, low in enumerate((4, 5)): + if (point[axis] < low and velocity[axis] < 0) or (point[axis] > 96 and velocity[axis] > 0): + velocity[axis] *= -1 + other = 1 - axis + jitter = self.random.uniform(0.1, 0.2) * self.random.choice((-1, 1)) + velocity[other] += jitter / (abs(velocity[other]) + 1) + if np.linalg.norm(velocity) > 1: + velocity *= 0.9 + velocity *= 0.999 + farthest = max(np.linalg.norm(point - self.gold) for point in self.points) + if self._distance(self.gold) <= ring + 2 and farthest >= ring - 2: + self.gold = None + return math.ceil(self.radius ** 1.5) + self.terminal = hits_wall + return 0 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + for channel, (x, y) in enumerate(self.points): + state[min(9, max(0, int(y // 10))), min(9, max(0, int(x // 10))), channel] = True + for x, y in np.linspace(*self.points, 30): + if 0 <= x < 100 and 0 <= y < 100: + state[int(y // 10), int(x // 10), 2] = True + if self.gold is not None: + x, y = self.gold + state[int(y // 10), int(x // 10), 3] = True + rows, cols = np.ogrid[5:100:10, 5:100:10] + state[:, :, 4] = abs(np.hypot(cols - x, rows - y) - self.radius) < 6 + for row, value in enumerate((self.steps, round(self.radius * 10))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/lland.py b/runtime/minatar_synth/games/lland.py new file mode 100644 index 0000000000000000000000000000000000000000..d2069538f443e19ac25c39817acb73f9a219d8a1 --- /dev/null +++ b/runtime/minatar_synth/games/lland.py @@ -0,0 +1,100 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Terrain: + y: float + pad: bool = False + + +class LlandEnvironment: + score_cap = 10 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.terrain = [Terrain(49, True) if i == 4 else Terrain(90 - i) for i in range(9)] + self.y, self.velocity = 30.0, 0.0 + self.offset = self.distance = self.index = self.steps = 0 + self.pad_countdown = 7 + self.landed = self.unlocked = self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _positions(self): + for i, tile in enumerate(self.terrain): + yield (i * 13 + self.offset) % 117 - 13, tile + + def _advance(self, tap: bool) -> int: + if self.landed and not tap: + return 0 + self.landed = False + positions = list(self._positions()) + contacts = [tile for x, tile in positions if x < 28 and x + 13 > 22 and self.y + 3 > tile.y] + missed_pad = any(tile.pad and x <= 0 < x + 13 for x, tile in positions) + self.offset -= 1 + self.distance -= 1 + if self.distance < 0: + pad = self.pad_countdown == 0 + low, high = (40, 70) if pad else (70 if self.pad_countdown > 7 or self.pad_countdown == 1 else 40, 90) + self.terrain[self.index] = Terrain(self.random.uniform(low, high), pad) + self.index = (self.index + 1) % 9 + self.distance += 13 + self.pad_countdown = 9 if pad else self.pad_countdown - 1 + if self.unlocked: + self.velocity -= 0.4 * tap + 0.2 * self.pressed + self.velocity = (self.velocity + 0.1) * 0.99 + if self.y < 0 and self.velocity < 0: + self.velocity *= -1 + self.y += self.velocity + self.terminal = missed_pad or any(not tile.pad for tile in contacts) + for tile in contacts: + if tile.pad: + self.y, self.velocity = tile.y - 3, 0 + self.landed = self.unlocked = True + for terrain in self.terrain: + terrain.pad = False + return 1 + return 0 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, max(0, int(self.y // 10))), 2, 0] = True + for x, tile in self._positions(): + left, right = max(0, int(x // 10)), min(9, int((x + 13) // 10)) + state[int(tile.y // 10):, left:right + 1, 2 if tile.pad else 1] = True + future = min(9, max(0, int((self.y + 4 * self.velocity) // 10))) + state[future, 2, 3] = True + state[:, 2, 4] = True + values = (self.steps, round((self.velocity + 12) * 16), round(self.y * 4)) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(min(511, max(0, value)) & (1 << bit)) + state[9, :3, 5] = self.pressed, self.landed, self.unlocked + return state diff --git a/runtime/minatar_synth/games/m_field.py b/runtime/minatar_synth/games/m_field.py new file mode 100644 index 0000000000000000000000000000000000000000..f4cb23568658d446887ff6f7b951bc07d09c91df --- /dev/null +++ b/runtime/minatar_synth/games/m_field.py @@ -0,0 +1,144 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Mine: + x: float + fuse: int = 0 + + +@dataclass +class Enemy: + x: float + vx: float + + +class MFieldEnvironment: + score_cap = 200 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.y = 80.0, 87.0 + self.vx = self.vy = self.mine_distance = self.enemy_distance = 0.0 + self.jumps = self.steps = 0 + self.multiplier = 1 + self.pressed = self.terminal = False + self.mines = [] + self.enemies = [] + self.blasts = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _in_blast(self, x, radius): + return any(abs(x - center) < width + radius for center, _, width in self.blasts) + + def _advance(self, tap): + scroll = max(0, self.x - 99) * 0.1 + self.blasts = [(x - scroll, age + 1, max(0, math.sin((age + 1) * 0.1) * 25)) + for x, age, _ in self.blasts if age < 31] + self.enemy_distance -= scroll + if self.enemy_distance < 0: + if self.random.random() < 0.7: + self.enemies.append(Enemy(203, -0.4 * self.random.uniform(1, 2))) + else: + self.enemies.append(Enemy(-3, 0.4 * self.random.uniform(1.5, 2))) + self.enemy_distance += self.random.uniform(20, 30) + reward = 0 + surviving = [] + for enemy in self.enemies: + enemy.x += enemy.vx - scroll + if not self.jumps and abs(enemy.x - self.x) > 20 and (enemy.x - self.x) * enemy.vx > 0: + enemy.vx *= -1 + if self._in_blast(enemy.x, 3): + reward += self.multiplier + self.multiplier = min(64, self.multiplier * 2) + elif enemy.x >= -9: + surviving.append(enemy) + self.enemies = surviving + self.vx += ((1 if self.pressed else 0.3) - self.vx) * 0.1 + if self.jumps: + self.vy += 0.05 if self.pressed else 0.1 + if self.y > 87: + self.y, self.vy, self.jumps = 87, 0, 0 + if tap and self.jumps < 2: + self.jumps += 1 + self.vy = -2 + self.y -= 6 + self.x += self.vx - scroll + self.y += self.vy + self.terminal = abs(self.y - 86) < 7 and self._in_blast(self.x, 3) + if abs(self.y - 87) < 6 and any(abs(self.x - enemy.x) < 5 for enemy in self.enemies): + if self.vy > 0: + self.y = 80 + self.vy *= -0.8 + else: + self.terminal = True + self._move_mines(scroll) + return reward + + def _move_mines(self, scroll): + self.mine_distance -= scroll + if self.mine_distance < 0: + self.mines.append(Mine(203)) + self.mine_distance = (self.random.uniform(9, 20) if self.random.random() < 0.6 + else self.random.uniform(50, 80)) + remaining = [] + chain = [] + for mine in self.mines: + mine.x -= scroll + if mine.fuse: + mine.fuse += 1 + if mine.fuse > 59 or self._in_blast(mine.x, 3): + chain.append((mine.x, 0, 0)) + elif mine.x >= -3: + if not mine.fuse and abs(mine.x - self.x) < 6 and abs(91 - self.y) < 4.5: + mine.fuse = 1 + self.multiplier = 1 + remaining.append(mine) + self.mines = remaining + self.blasts.extend(chain) + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, max(0, int(self.y // 10))), int(self.x // 20), 0] = True + for mine in self.mines: + if 0 <= mine.x < 200: + state[9, int(mine.x // 20), 2 if mine.fuse else 1] = True + for enemy in self.enemies: + if 0 <= enemy.x < 200: + state[8, int(enemy.x // 20), 3] = True + for x, _, width in self.blasts: + state[8:10, :, 4] |= abs(np.arange(10, 200, 20) - x) < width + 10 + for row, value in enumerate((self.steps, self.multiplier, self.jumps, round((self.vy + 4) * 40))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/m_jamming.py b/runtime/minatar_synth/games/m_jamming.py new file mode 100644 index 0000000000000000000000000000000000000000..10749b3afbfab6fe85143e011fee2b8d87eab88c --- /dev/null +++ b/runtime/minatar_synth/games/m_jamming.py @@ -0,0 +1,155 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Missile: + x: float + y: float + angle: float + speed: float = 0.4 + payload: float = -1 + + +@dataclass +class Blast: + x: float + y: float + target: float + radius: float = 1 + growth: float = 0.5 + + +class MJammingEnvironment: + score_cap = 400 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x = self.y = 50.0 + self.vx = self.vy = self.radius = self.timer = 0.0 + self.steps = 0 + self.multiplier = 1 + self.pressed = self.terminal = False + self.missiles: list[Missile] = [] + self.blasts: list[Blast] = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + release = self.pressed and not pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(release and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, release): + sx, sy = (50 - self.x) * 0.05, (50 - self.y) * 0.05 + for blast in self.blasts: + blast.radius += blast.growth + if blast.radius > blast.target: + blast.growth = -0.5 + self.blasts = [b for b in self.blasts if b.radius >= 1] + self.vx *= 0.98 + self.vy *= 0.98 + self.x += self.vx + sx + self.y += self.vy + sy + if self.pressed or release: + self.radius *= 1.01 + self.vx *= 0.9 + self.vy *= 0.9 + else: + self.radius = min(15, self.radius + 0.5) + reward = self._jam() if release or self.radius > 50 else 0 + self.timer -= 1 + if self.timer < 0: + self._spawn() + survivors = [] + for missile in self.missiles: + if missile.payload < 0: + target = math.atan2(self.y - missile.y, self.x - missile.x) + delta = (target - missile.angle + math.pi) % math.tau - math.pi + missile.angle += min(0.005, max(-0.005, delta)) + missile.x += math.cos(missile.angle) * missile.speed + sx + missile.y += math.sin(missile.angle) * missile.speed + sy + if any(abs(math.hypot(missile.x - b.x, missile.y - b.y) - b.radius) < 4 for b in self.blasts): + if missile.payload > 1: + self.blasts.append(Blast(missile.x, missile.y, missile.payload)) + reward += self.multiplier + self.multiplier += 1 + else: + self.terminal |= math.hypot(missile.x - self.x, missile.y - self.y) < 4 + if -100 <= missile.x < 100 and -100 <= missile.y < 100: + survivors.append(missile) + hostile = [m for m in survivors if m.payload < 0] + remaining = [] + for missile in survivors: + if missile.payload > 0 and any(math.hypot(missile.x - m.x, missile.y - m.y) < 3 for m in hostile): + self.blasts.append(Blast(missile.x, missile.y, missile.payload)) + reward += self.multiplier + self.multiplier += 1 + else: + remaining.append(missile) + self.missiles = remaining + nearest = min(survivors, key=lambda m: math.hypot(m.x - self.x, m.y - self.y), default=None) + if nearest is not None and math.hypot(nearest.x - self.x, nearest.y - self.y) < 50: + angle = math.atan2(self.y - nearest.y, self.x - nearest.x) + math.pi / 3 + self.vx += math.cos(angle) * 0.01 + self.vy += math.sin(angle) * 0.01 + return reward + + def _jam(self): + self.multiplier = 1 + targets = [m for m in self.missiles if m.payload < 0 + and math.hypot(m.x - self.x, m.y - self.y) < self.radius + 1] + count = len(targets) + for missile in targets: + missile.angle = math.atan2(missile.y - self.y, missile.x - self.x) + missile.payload = min(25, count ** 1.5) + missile.speed *= 0.5 + self.radius = count + self.multiplier += count + return count * (count + 1) // 2 + + def _spawn(self): + for _ in range(int(self.random.integers(6, 9))): + angle = self.random.uniform(0, math.tau) + x, y = 50 + math.cos(angle) * 99, 50 + math.sin(angle) * 99 + tx, ty = self.random.uniform(40, 60, 2) + self.missiles.append(Missile(x, y, math.atan2(ty - y, tx - x))) + self.timer = self.random.uniform(60, 70) + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, max(0, int(self.y // 10))), min(9, max(0, int(self.x // 10))), 0] = True + for missile in self.missiles: + if 0 <= missile.x < 100 and 0 <= missile.y < 100: + state[int(missile.y // 10), int(missile.x // 10), 1 + (missile.payload > 0)] = True + rows, cols = np.ogrid[5:100:10, 5:100:10] + for blast in self.blasts: + state[:, :, 3] |= abs(np.hypot(cols - blast.x, rows - blast.y) - blast.radius) < 6 + state[:, :, 4] = np.hypot(cols - self.x, rows - self.y) < self.radius + 1 + for row, value in enumerate((self.steps, min(511, self.multiplier), round(self.radius * 8))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/m_rider.py b/runtime/minatar_synth/games/m_rider.py new file mode 100644 index 0000000000000000000000000000000000000000..cab14c050f27299d095a1413c51331573227cddc --- /dev/null +++ b/runtime/minatar_synth/games/m_rider.py @@ -0,0 +1,148 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Body: + x: float + y: float + vx: float = 0 + vy: float = 0 + + def move(self, scroll=0): + self.x += self.vx - scroll + self.y += self.vy + + +@dataclass +class Plane(Body): + fuse: float = 0 + base_fuse: float = 0 + + +class MRiderEnvironment: + score_cap = 150 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.rider = Body(30, 46) + self.mount = Body(30, 50, 1) + self.missiles = [self.mount] + self.planes: list[Plane] = [] + self.missile_timer, self.plane_timer = 9, 0 + self.steps = 0 + self.multiplier = 1 + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self): + rider, mount = self.rider, self.mount + if mount is None: + rider.vx = (rider.vx + (0.04 if self.pressed else -0.02)) * 0.99 + rider.vy = (rider.vy + (0.01 if self.pressed else 0.05)) * 0.99 + rider.move() + else: + mount.vy = (mount.vy + (-0.05 if self.pressed else 0.05)) * 0.99 + mount.vx += (1 - mount.vx) * 0.1 + rider.x, rider.y = mount.x, mount.y - 4 + rider.vx, rider.vy = mount.vx, mount.vy + scroll = max(0, rider.x - 50) * 0.1 + rider.x -= scroll + if rider.y > 99 or (mount is not None and rider.y < -1): + self.terminal = True + return 0 + self._move_missiles(scroll) + return self._move_planes(scroll) + + def _move_missiles(self, scroll): + self.missile_timer -= 1 + if self.missile_timer < 0: + y = self.random.uniform(40, 70) + angle = math.atan2(y - self.random.uniform(50, 60), 210) + speed = self.random.uniform(0.4, 0.5) + self.missiles.append(Body(210, y, speed * math.cos(angle), speed * math.sin(angle))) + self.missile_timer = self.random.uniform(60, 300) + airborne = self.mount is None + for missile in self.missiles: + missile.move(scroll) + if airborne and abs(missile.x - self.rider.x) < 12 and abs(missile.y - self.rider.y) < 5: + self.multiplier = (self.multiplier + 1) // 2 + self.mount = missile + self.missiles = [m for m in self.missiles if -9 <= m.x < 221 and -3 <= m.y < 113] + + def _move_planes(self, scroll): + self.plane_timer -= 1 + if self.plane_timer < 0: + y = self.random.uniform(30, 90) + angle = math.atan2(y - self.random.uniform(40, 90), 203) + speed = self.random.uniform(0.05, 0.3) + self.planes.append(Plane(203, y, speed * math.cos(angle), speed * math.sin(angle))) + self.plane_timer = self.random.uniform(20, 24) + reward = 0 + remaining = [] + for plane in self.planes: + plane.move(scroll) + if plane.fuse > 0: + plane.fuse -= 1 + if plane.fuse <= 0: + reward += self.multiplier + self.multiplier += 1 + delay = plane.base_fuse * 0.9 + if delay > 2: + for other in self.planes: + if other is not plane and math.hypot(other.x - plane.x, other.y - plane.y) < 36: + other.fuse = other.base_fuse = delay + continue + if self.mount is not None and abs(self.mount.x - plane.x) < 12 and abs(self.mount.y - plane.y) < 5: + self.rider.vy = -2 + self.mount.x = -99 + self.mount = None + plane.fuse = plane.base_fuse = 9 + if -3 <= plane.x < 203 and -3 <= plane.y < 103: + remaining.append(plane) + self.planes = remaining + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + rider = self.rider + state[min(9, max(0, int(rider.y // 10))), min(9, max(0, int(rider.x // 20))), 0] = True + for missile in self.missiles: + if 0 <= missile.x < 200 and 0 <= missile.y < 100: + state[int(missile.y // 10), int(missile.x // 20), 2 if missile is self.mount else 1] = True + for plane in self.planes: + if 0 <= plane.x < 200 and 0 <= plane.y < 100: + state[int(plane.y // 10), int(plane.x // 20), 4 if plane.fuse else 3] = True + for row, value in enumerate((self.steps, self.multiplier, round((rider.vy + 6) * 35), + round((rider.vx + 4) * 50))): + for bit in range(9): + state[row, bit, 5] = bool(min(511, max(0, value)) & (1 << bit)) + state[9, :2, 5] = self.pressed, self.mount is not None + return state diff --git a/runtime/minatar_synth/games/magnetic_pendulum.py b/runtime/minatar_synth/games/magnetic_pendulum.py new file mode 100644 index 0000000000000000000000000000000000000000..d5c481d85f6e92b50a08d8dcf7d44d569d36d973 --- /dev/null +++ b/runtime/minatar_synth/games/magnetic_pendulum.py @@ -0,0 +1,110 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Magnet: + x: float + y: float = 0 + + +class MagneticPendulumEnvironment: + score_cap = 162 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.y = 50.0, 71.0 + self.length, self.angle, self.angular_velocity = 66.0, 0.0, 0.024 + self.floor = self.target_floor = 100.0 + self.spawn_timer = 70 + self.steps = 0 + self.multiplier = 1 + self.pressed = self.terminal = False + self.magnets: list[Magnet] = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self): + self.target_floor = min(100, self.target_floor + 0.01) + self.floor += (self.target_floor - self.floor) * 0.5 + self.length = min(66, max(10, self.length + (-1 if self.pressed else 1))) + self.spawn_timer -= 1 + if self.spawn_timer == 0: + self.magnets.append(Magnet(self.random.uniform(15, 85))) + self.spawn_timer = 70 + sine, cosine = math.sin(self.angle), math.cos(self.angle) + tangent = 0.0 + for magnet in self.magnets: + dx, dy = magnet.x - self.x, magnet.y - self.y + distance = math.hypot(dx, dy) + if 0 < distance < 30: + tangent += 0.15 * (1 - distance / 30) * (dx * cosine - dy * sine) / distance + self.angular_velocity = (self.angular_velocity + (tangent - 0.13 * sine) / self.length) * 0.99 + self.angle += self.angular_velocity + self.x = 50 + math.sin(self.angle) * self.length + self.y = 5 + math.cos(self.angle) * self.length + self.terminal = self.y + 3 > self.floor + if self.terminal: + return 0 + reward = 0 + remaining = [] + for magnet in self.magnets: + magnet.y += 0.45 + if abs(magnet.x - self.x) < 6 and abs(magnet.y - self.y) < 6: + reward += self.multiplier + self.multiplier = min(9, self.multiplier + 1) + self.target_floor = min(100, self.target_floor + 2) + elif magnet.y + 4 > self.floor: + self.target_floor = max(0, self.target_floor - 10) + self.multiplier = 1 + else: + remaining.append(magnet) + self.magnets = remaining + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + for fraction in np.linspace(0, 1, 16): + x = 50 + fraction * (self.x - 50) + y = 5 + fraction * (self.y - 5) + if 0 <= x < 100 and 0 <= y < 100: + state[int(y // 10), int(x // 10), 1] = True + state[min(9, max(0, int(self.y // 10))), min(9, max(0, int(self.x // 10))), 0] = True + for magnet in self.magnets: + row, col = int(magnet.y // 10), int(magnet.x // 10) + state[row, col, 2] = True + state[row, col, 3] |= math.hypot(magnet.x - self.x, magnet.y - self.y) < 30 + state[math.floor(self.floor / 10):, :, 4] = True + values = (self.steps, int(self.length), self.multiplier, round(self.floor * 4), + round((self.angular_velocity + 0.25) * 1000)) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(min(511, max(0, value)) & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/make_maze.py b/runtime/minatar_synth/games/make_maze.py new file mode 100644 index 0000000000000000000000000000000000000000..01cdf764bce7e73a37907b5245ac58a468f25907 --- /dev/null +++ b/runtime/minatar_synth/games/make_maze.py @@ -0,0 +1,178 @@ +from collections import deque +from dataclasses import dataclass + +import numpy as np + + +_DIRECTIONS = ((0, 1), (1, 0), (0, -1), (-1, 0)) + + +@dataclass +class Enemy: + row: int + col: int + turn: int + heading: int = 1 + timer: int = 0 + angry: bool = False + + +class MakeMazeEnvironment: + score_cap = 100 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.walls = np.zeros((10, 10), dtype=bool) + self.walls[:, (0, 9)] = True + self.walls[5, (1, 8)] = True + self.walls[6, 2:8] = True + self.walls[7, 1:4] = self.walls[7, 6:9] = True + self.cursor = (5, 5) + self.enemies = [] + self.gold = set() + self.scroll = 10. + self.penalty = 0. + self.timer = self.steps = self.action = 0 + self.multiplier = 1 + self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0., True + previous = self.action + if self.random.random() >= self.sticky_action_prob: + self.action = action + if self.action in (1, 2, 3, 4): + dr, dc = _DIRECTIONS[(self.action + 1) % 4] + row, col = self.cursor + self.cursor = min(9, max(0, row + dr)), min(8, max(1, col + dc)) + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(frame == 0 and self.action == 5 and previous != 5) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, toggle): + oldest = min((r for r, _ in self.gold), default=10) + self.scroll += 0.01 + self.penalty + max(0, oldest * 10 - self.scroll - 50) * 0.02 + self.penalty *= 0.9 + if self.scroll >= 10: + self.scroll -= 10 + self.walls[:-1] = self.walls[1:].copy() + self.walls[-1, 1:9] = False + self.gold = {(row - 1, col) for row, col in self.gold} + self.gold.add((9, int(self.random.integers(1, 9)))) + for enemy in self.enemies: + enemy.row -= 1 + if toggle and self.cursor not in self.gold: + self.walls[self.cursor] = not self.walls[self.cursor] + self.timer -= 1 + if self.timer < 0: + columns = [col for col in range(1, 9) if not self.walls[0, col]] + col = int(self.random.choice(columns or range(1, 9))) + self.enemies.append(Enemy(0, col, int(self.random.choice((-1, 1))))) + self.timer = 150 + + reward = 0 + remaining = [] + for enemy in self.enemies: + if enemy.row < 0: + continue + enemy.timer -= 1 + if enemy.timer < 0: + reward += self._collect((enemy.row, enemy.col)) + reward += self._move(enemy) + enemy.timer = 60 + if enemy.row >= 10: + self.penalty += 1 + self.multiplier = max(1, self.multiplier - 1) + reward -= self.multiplier + elif enemy.row >= 0: + remaining.append(enemy) + self.enemies = remaining + self.terminal = any(row < 0 for row, _ in self.gold) + return reward + + def _collect(self, cell): + if cell not in self.gold: + return 0 + self.gold.remove(cell) + self.multiplier += 1 + return self.multiplier - 1 + + def _move(self, enemy): + cell = enemy.row, enemy.col + enemy.angry = not self._has_exit(cell) + if enemy.angry: + enemy.heading = 1 + enemy.row += 1 + if enemy.row < 10: + self.walls[enemy.row, enemy.col] = False + return self._collect((enemy.row, enemy.col)) + reward = 0 + # Follow the chosen wall, running through straight corridors in one move. + for index in range(100): + turns = (enemy.turn, 0, -enemy.turn, 2) + choices = ((enemy.heading + turn) % 4 for turn in turns) + heading = next((h for h in choices if self._open(_step(cell, h))), None) + if heading is None or (index and heading != enemy.heading): + break + enemy.heading = heading + cell = _step(cell, heading) + enemy.row, enemy.col = cell + reward += self._collect(cell) + if not 0 <= enemy.row < 10: + break + return reward + + def _open(self, cell): + row, col = cell + return 0 < col < 9 and (not 0 <= row < 10 or not self.walls[cell]) + + def _has_exit(self, start): + pending = deque([start]) + seen = {start} + while pending: + cell = pending.popleft() + if cell[0] == 9: + return True + for heading in range(4): + other = _step(cell, heading) + if other[0] >= 0 and other not in seen and self._open(other): + seen.add(other) + pending.append(other) + return False + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[:, :, 0] = self.walls + for row, col in self.gold: + if row >= 0: + state[row, col, 1] = True + for enemy in self.enemies: + state[enemy.row, enemy.col, 2 + enemy.angry] = True + state[self.cursor[0], self.cursor[1], 4] = True + for row, value in enumerate((self.steps, self.action, self.multiplier, round(self.scroll * 20), self.timer)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state + + +def _step(cell, heading): + dr, dc = _DIRECTIONS[heading] + return cell[0] + dr, cell[1] + dc diff --git a/runtime/minatar_synth/games/marble_bounce.py b/runtime/minatar_synth/games/marble_bounce.py new file mode 100644 index 0000000000000000000000000000000000000000..2cd55686a1ed2687f9f10dc07d74d2f18000bf89 --- /dev/null +++ b/runtime/minatar_synth/games/marble_bounce.py @@ -0,0 +1,152 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Pin: + x: float + y: float + size: float + last_hit: int = 0 + + +class MarbleBounceEnvironment: + score_cap = 1500 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.y = 50.0, 80.0 + self.vx = self.vy = 0.0 + self.steps = self.frames = self.timer = self.target_since = 0 + self.interval = 360 + self.multiplier = 1 + self.pressed = self.terminal = False + self.pins: list[Pin] = [] + self._wave(2) + + def _wave(self, size): + for _ in range(8): + pin = self._sample_pin(50, size) + if pin is None: + pin = Pin(self.random.uniform(10, 90), self.random.uniform(20, 80), size) + self.pins.append(pin) + self.target = self.pins[0] + + def _sample_pin(self, attempts, size): + for _ in range(attempts): + x, y = self.random.uniform(10, 90), self.random.uniform(20, 80) + if math.hypot(x - self.x, y - self.y) >= 15 and all( + math.hypot(x - pin.x, y - pin.y) >= 15 for pin in self.pins): + return Pin(x, y, size) + return None + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _distance(self, pin): + return math.hypot(self.x - pin.x, self.y - pin.y) + + def _advance(self, tap): + self.vy += 0.15 + if tap: + self.vy = min(5, max(-5, self.vy - 3)) + self.timer += 1 + if self.timer >= self.interval: + self.timer = 0 + pin = self._sample_pin(20, 0) + if pin is not None: + self.pins.append(pin) + self.interval = max(90, self.interval - 30) + self.x += self.vx + self.y += self.vy + if self.y >= 89.5: + self.y = 89.5 + self.vy *= -0.7 + if abs(self.vx) < 0.5: + self.vx += self.random.uniform(1, 2) * self.random.choice((-1, 1)) + if self.frames - self.target_since > 900: + self.terminal = True + return 0 + for pin in self.pins: + pin.size = min(2, pin.size + 0.1) + reward = self._hit_pins() + if not 5 <= self.x <= 95: + self.vx = abs(self.vx) if self.x < 5 else -abs(self.vx) + self.x = min(95, max(5, self.x)) + if self.y < 5: + self.y = 5 + self.vy = abs(self.vy) + self.frames += 1 + return reward + + def _hit_pins(self): + reward = 0 + regular = min((pin for pin in self.pins if pin is not self.target), + key=self._distance, default=None) + if regular is not None and self._distance(regular) < 3 + regular.size: + angle = math.atan2(self.y - regular.y, self.x - regular.x) + separation = 3 + regular.size + self.x = regular.x + math.cos(angle) * separation + self.y = regular.y + math.sin(angle) * separation + if self.frames - regular.last_hit > 9: + reward += self.multiplier + regular.last_hit = self.frames + self.vx = self.random.uniform(1, 2) * self.random.choice((-1, 1)) + self.vy = -abs(self.vy) * 0.8 + if self._distance(self.target) < 3 + self.target.size: + angle = math.atan2(self.y - self.target.y, self.x - self.target.x) + self.x += 2 * math.cos(angle) + self.y += 2 * math.sin(angle) + self.vx = self.random.uniform(2, 3) * self.random.choice((-1, 1)) + self.vy = -abs(self.vy) * 0.9 + reward += 100 * self.multiplier + self.pins = [pin for pin in self.pins if pin is not self.target] + if self.pins: + self.target = self.pins[self.random.integers(len(self.pins))] + else: + self.multiplier += 1 + self._wave(0) + self.interval, self.timer, self.target_since = 360, 0, self.frames + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, max(0, int(self.y // 10))), min(9, max(0, int(self.x // 10))), 0] = True + for pin in self.pins: + state[int(pin.y // 10), int(pin.x // 10), 2 if pin is self.target else 1] = True + state[9, :, 3] = True + if self.frames - self.target_since > 600: + state[int(self.target.y // 10), int(self.target.x // 10), 4] = True + gauges = (self.steps, (self.frames - self.target_since) // 2, self.multiplier, + round((self.vx + 8) * 20), round((self.vy + 8) * 20)) + for row, value in enumerate(gauges): + for bit in range(9): + state[row, bit, 5] = bool(min(511, max(0, value)) & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/marusansi.py b/runtime/minatar_synth/games/marusansi.py new file mode 100644 index 0000000000000000000000000000000000000000..b1dc31e68a00675adae0c414898ec021ddb71719 --- /dev/null +++ b/runtime/minatar_synth/games/marusansi.py @@ -0,0 +1,139 @@ +import numpy as np + + +class MarusansiEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.grid = np.zeros((12, 6), dtype=np.int8) + self.blocks = (1, 2) + self.cursor = self.steps = self.action = self.timer = self.delay = 0 + self.multiplier = 1 + self.terminal = False + self.marked = np.zeros_like(self.grid, dtype=bool) + self.pending = None + self._next_row() + + def _next_row(self): + self.next_row = [] + for col in range(6): + colors = [c for c in (1, 2, 3) + if not (self.grid[0, col] == self.grid[1, col] == c) + and self.next_row[-2:] != [c, c]] + self.next_row.append(int(self.random.choice(colors))) + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + previous = self.action + if self.random.random() >= self.sticky_action_prob: + self.action = action + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(self.action if frame == 0 and self.action != previous else 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, command): + if self.delay: + self.delay -= 1 + if self.delay: + return 0 + if self.pending is not None: + changed = self.pending > 0 + self.grid[changed] = self.pending[changed] + self.marked |= changed + self.pending = None + reward = self._match() if self.multiplier < 32 else 0 + if not self.delay: + self.grid[self.marked] = 0 + self.delay = 5 + return reward + for col in range(6): + values = self.grid[:, col] + remaining = values[values != 0] + values[:] = 0 + values[:len(remaining)] = remaining + self.marked[:] = False + self.timer = 0 + reward = self._match() + self._next_row() + return reward + heights = np.count_nonzero(self.grid, axis=0) + if np.all(heights >= 11): + self.terminal = True + return 0 + self.timer += 1 + if self.timer > 400 or command == 4: + self.grid[1:] = self.grid[:-1].copy() + self.grid[0] = self.next_row + self._next_row() + self.timer = 0 + elif command in (1, 3): + self.cursor = (self.cursor + (1 if command == 3 else -1)) % 6 + elif command == 2: + self.blocks = self.blocks[::-1] + elif command == 5 and heights[self.cursor] < 11: + height = heights[self.cursor] + self.grid[height:height + 2, self.cursor] = self.blocks[::-1] + pair = tuple(int(c) for c in self.random.integers(1, 4, 2)) + self.blocks = ((pair[0] % 3 + 1, pair[1]) if pair == self.blocks else pair) + self.multiplier = 1 + return self._match() + return 0 + + def _match(self): + changes = np.zeros_like(self.grid) + count = 0 + for board, output in ((self.grid.T, changes.T), (self.grid, changes)): + for line, dest in zip(board, output, strict=True): + start = 0 + while start < len(line): + end = start + 1 + while end < len(line) and line[end] == line[start]: + end += 1 + color = int(line[start]) + if color and end - start >= 3: + others = [c for c in (1, 2, 3) if c != color] + others.sort(key=lambda c: (c - color) % 3) + for index in range(start, end): + dest[index] = others[(index - start) % 2] + count += end - start + start = end + if not count: + return 0 + self.pending = changes + self.delay = 50 + reward = count * self.multiplier + self.multiplier += 1 + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + for row, col in np.argwhere(self.grid > 0): + state[row % 8, col, 3 * (row // 8) + self.grid[row, col] - 1] = True + for col, color in enumerate(self.next_row): + state[8, col, color - 1] = True + for col, color in enumerate(self.blocks): + state[9, col, color - 1] = True + state[9, self.cursor, 3] = True + for col, value in enumerate((self.timer, self.delay, self.multiplier, self.action), 6): + for bit in range(9): + state[bit, col, 0] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/meteo_planet.py b/runtime/minatar_synth/games/meteo_planet.py new file mode 100644 index 0000000000000000000000000000000000000000..9feab769260447e5441a91b21199b11c42d24d7c --- /dev/null +++ b/runtime/minatar_synth/games/meteo_planet.py @@ -0,0 +1,98 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Falling: + distance: float + lane: int + value: int = 0 + + +class MeteoPlanetEnvironment: + score_cap = 350 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.fallings = [Falling(53, int(self.random.integers(4)))] + self.next_lane = int(self.random.integers(1, 4)) + self.angle = self.timer = 0.0 + self.target_lane = self.steps = 0 + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed: + self.target_lane += 1 + self.pressed = pressed + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _position(self, falling): + angle = falling.lane * math.pi / 2 - self.angle + return 50 + math.cos(angle) * falling.distance, 50 + math.sin(angle) * falling.distance + + def _advance(self): + self.angle = min(self.target_lane * math.pi / 2, self.angle + 0.3) + self.timer -= 1 + if self.timer < 0: + count = int(self.random.integers(6)) + for index in range(-count, count + 1): + value = count - abs(index) + 1 if index else 0 + self.fallings.append(Falling(100 + 6 * index, self.next_lane, value)) + self.next_lane = (self.next_lane + int(self.random.integers(1, 4))) % 4 + self.timer = self.random.uniform(30, 50) + reward = 0 + remaining = [] + for falling in self.fallings: + falling.distance -= 0.5 + x, y = self._position(falling) + extent = 3 + (falling.value / 2 if falling.value else 3) + if abs(x - 50) < extent and abs(y - 42) < extent: + if falling.value: + reward += falling.value + continue + self.terminal = True + if falling.distance >= 5: + remaining.append(falling) + self.fallings = remaining + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[4, 5, 0] = True + state[5, 5, 1] = True + for falling in self.fallings: + x, y = self._position(falling) + if 0 <= x < 100 and 0 <= y < 100: + state[int(y // 10), int(x // 10), 2 if not falling.value else 3] = True + if falling.distance < 25 and not falling.value and 0 <= x < 100 and 0 <= y < 100: + state[int(y // 10), int(x // 10), 4] = True + gauges = (self.steps, self.target_lane % 4, round(self.angle % math.tau * 80)) + for row, value in enumerate(gauges): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/microbial_focus.py b/runtime/minatar_synth/games/microbial_focus.py new file mode 100644 index 0000000000000000000000000000000000000000..5336b61261033b19e3c8f5bcae25230f55d17567 --- /dev/null +++ b/runtime/minatar_synth/games/microbial_focus.py @@ -0,0 +1,132 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Microbe: + x: float + y: float + depth: float + size: float + vx: float = 0 + vy: float = 0 + age: int = 0 + heading: float | None = None + + +class MicrobialFocusEnvironment: + score_cap = 250 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.focus = 0.5 + self.direction = 1 + self.frames = self.steps = 0 + self.next_spawn = 0.0 + self.multiplier = 1.0 + self.pressed = self.terminal = False + self.microbes: list[Microbe] = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed: + self.direction *= -1 + self.pressed = pressed + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _spawn(self): + for _ in range(8): + depth = self.random.uniform(0.05, 0.95) + if abs(depth - self.focus) > 0.15: + break + edge = self.random.integers(4) + size = self.random.uniform(4, 8) + along = self.random.uniform(10, 90) + drift = self.random.uniform(-0.2, 0.2) + speed = self.random.uniform(0.5, 1) + outside = size - 1 + x, y, vx, vy = ((along, -outside, drift, speed), + (100 + outside, along, -speed, drift), + (along, 100 + outside, drift, -speed), + (-outside, along, speed, drift))[edge] + self.microbes.append(Microbe(x, y, depth, size, vx, vy)) + + def _advance(self): + if self.pressed: + self.focus += self.direction * 0.015 + if not 0 <= self.focus <= 1: + self.focus = min(1, max(0, self.focus)) + self.multiplier = 1 + self.multiplier *= 0.999 + if self.frames >= self.next_spawn and len(self.microbes) < 24: + self.next_spawn = self.frames + 50 * math.sqrt(len(self.microbes) + 1) + self._spawn() + self.frames += 1 + reward = 0 + remaining = [] + for microbe in self.microbes: + microbe.age += 1 + if abs(microbe.depth - self.focus) < 0.1: + if microbe.heading is None: + dx, dy = microbe.x - 50, microbe.y - 50 + microbe.heading = math.atan2(dy, dx) if dx or dy else self.random.uniform(0, math.tau) + microbe.vx += math.cos(microbe.heading) * 0.02 + microbe.vy += math.sin(microbe.heading) * 0.02 + microbe.x += microbe.vx + microbe.y += microbe.vy + else: + microbe.vx *= 0.99 + microbe.vy *= 0.99 + microbe.x += microbe.vx + microbe.y += microbe.vy + if abs(microbe.vx) < 0.01 and abs(microbe.vy) < 0.01: + microbe.heading = None + microbe.vx = microbe.vy = 0 + low, high = -microbe.size, 100 + microbe.size + if low <= microbe.x <= high and low <= microbe.y <= high: + remaining.append(microbe) + self.terminal |= microbe.age >= 600 + else: + reward += math.floor(self.multiplier + 0.5) + self.multiplier += 1 + self.microbes = remaining + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + for microbe in self.microbes: + row = min(9, max(0, int(microbe.y // 10))) + col = min(9, max(0, int(microbe.x // 10))) + state[row, col, int(microbe.depth * 4)] = True + state[row, col, 4] |= microbe.age >= 360 + oldest = max(self.microbes, key=lambda m: m.age, default=None) + gauges = (self.steps, round(self.focus * 500), round(self.multiplier * 10), + oldest.age // 2 if oldest else 0, round(oldest.depth * 500) if oldest else 0) + for row, value in enumerate(gauges): + for bit in range(9): + state[row, bit, 5] = bool(min(511, value) & (1 << bit)) + state[9, :2, 5] = self.pressed, self.direction > 0 + return state diff --git a/runtime/minatar_synth/games/mirror_floor.py b/runtime/minatar_synth/games/mirror_floor.py new file mode 100644 index 0000000000000000000000000000000000000000..7e1e3a38af1125abb6587ad37d03f159f8dcedc7 --- /dev/null +++ b/runtime/minatar_synth/games/mirror_floor.py @@ -0,0 +1,124 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Floor: + x: float + y: float + width: float + + +class MirrorFloorEnvironment: + score_cap = 200 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.floors = [Floor(10, 50, 80)] + self.coins = [(60, 47)] + self.distance = 0.0 + self.y, self.mirror_y, self.vy, self.speed = 10.0, 0.0, 0.0, 1.0 + self.side = self.multiplier = 1 + self.steps = 0 + self.airborne = True + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap): + scroll = 0.5 * self.speed + if tap and not self.airborne: + self.vy = -1.5 * self.side + self.airborne = True + if self.airborne: + self.vy += 0.07 * self.side + self.y += self.vy + self.speed += (2 - self.speed) * 0.05 if self.pressed else (1 - self.speed) * 0.2 + self.terminal = (self.y < 0 and self.side == -1) or (self.y > 99 and self.side == 1) + if self.terminal: + return 0 + self.distance -= scroll + if self.distance < 0: + floor = Floor(100, self.random.uniform(10, 90), self.random.uniform(45, 75)) + self.floors.append(floor) + x = self.random.uniform(20, 25) + while x < floor.width - 20: + self.coins.append((100 + x, floor.y - 3)) + x += self.random.uniform(15, 30) + self.distance += floor.width + self.random.uniform(10, 20) + supported = False + for floor in self.floors: + floor.x -= scroll + if floor.x - 3 < 9 < floor.x + floor.width + 3: + supported = True + if floor.y - 3 < self.y < floor.y + 5 and self.vy * self.side > 0: + self.airborne = False + self.y = floor.y + (-3 if self.side == 1 else 5) + self.mirror_y = 2 * floor.y - self.y + 2 + self.floors = [floor for floor in self.floors if floor.x + floor.width >= 0] + if not supported: + self.airborne = True + reward = 0 + remaining = [] + for x, y in self.coins: + x -= scroll + if abs(x - 9) < 5 and (abs(y - self.y) < 5 or (supported and abs(y - self.mirror_y) < 5)): + reward += self.multiplier + self.multiplier += 1 + self.side *= -1 + self.vy *= -1 + self.y = self.mirror_y + elif x < -3: + self.multiplier = max(1, self.multiplier - 1) + else: + remaining.append((x, y)) + self.coins = remaining + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + for y, channel in ((self.y, 0), (self.mirror_y, 1)): + if 0 <= y < 100: + state[int(y // 10), 0, channel] = True + for floor in self.floors: + left = max(0, int(floor.x // 10)) + right = min(9, int((floor.x + floor.width) // 10)) + if left <= right: + state[int(floor.y // 10), left:right + 1, 2] = True + for x, y in self.coins: + if 0 <= x < 100: + state[int(y // 10), int(x // 10), 3] = True + state[int((y + 8) // 10), int(x // 10), 4] = True + values = (self.steps, min(511, self.multiplier), round(self.speed * 100), + min(511, max(0, round((self.vy + 6) * 40)))) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :3, 5] = self.pressed, self.airborne, self.side == 1 + return state diff --git a/runtime/minatar_synth/games/missile_guide.py b/runtime/minatar_synth/games/missile_guide.py new file mode 100644 index 0000000000000000000000000000000000000000..073daf755b40e3885b8149e06998523cc99c3682 --- /dev/null +++ b/runtime/minatar_synth/games/missile_guide.py @@ -0,0 +1,126 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Outpost: + x: float + y: float = -5 + phase: float = 0 + + +@dataclass +class Wall: + x: float + y: float = -10 + + +class MissileGuideEnvironment: + score_cap = 120 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.y = 50.0, 65.0 + self.last_x = 50.0 + self.fuel = 1000 + self.frames = self.steps = self.combo = 0 + self.timer = 30 + self.frozen = self.terminal = False + self.outposts: list[Outpost] = [] + self.walls: list[Wall] = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.frozen = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _target(self): + return min((o for o in self.outposts if -60 < o.y - self.y < 40), + key=lambda o: abs(o.y - self.y), default=None) + + def _advance(self): + self.fuel = self.fuel - 4 if self.frozen else min(1000, self.fuel + 1) + if self.fuel <= 0: + self.terminal = True + return 0 + self.timer -= 1 + if not self.timer: + x = min(88, max(12, self.last_x + self.random.uniform(-40, 40))) + if self.random.random() < 0.8: + self.outposts.append(Outpost(x, phase=self.random.uniform(0, math.tau))) + self.last_x = x + if self.frames > 60 and self.random.random() < 0.6: + self.walls.append(Wall(min(80, max(20, x + self.random.uniform(-20, 20))))) + self.timer = 50 + self.frames += 1 + if not self.frozen: + target = self._target() + if target is not None: + self.x += min(0.8, max(-0.8, (target.x - self.x) * 0.03)) + self.y += min(0.8, max(-0.8, (target.y - self.y) * 0.01)) + self.x = min(94, max(6, self.x)) + self.y = min(90, max(60, self.y)) + reward = 0 + remaining = [] + for outpost in self.outposts: + outpost.y += 0.6 + outpost.phase += 0.15 + radius = 3 * (1 + math.sin(outpost.phase) * 0.15) + if not self.frozen and abs(outpost.x - self.x) < radius + 2 and abs(outpost.y - self.y) < radius + 3.5: + self.combo += 1 + reward += 1 + self.combo // 3 + self.fuel = min(1000, self.fuel + 120) + elif outpost.y > 105: + self.combo = 0 + else: + remaining.append(outpost) + self.outposts = remaining + for wall in self.walls: + wall.y += 0.6 + if not self.frozen and abs(wall.y - self.y) < 6 and abs(wall.x - self.x) > 13: + self.terminal = True + self.walls = [wall for wall in self.walls if wall.y <= 105] + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, int(self.y // 10)), int(self.x // 10), 0] = True + for outpost in self.outposts: + if 0 <= outpost.y < 100: + state[int(outpost.y // 10), int(outpost.x // 10), 1] = True + for wall in self.walls: + if 0 <= wall.y < 100: + row = int(wall.y // 10) + state[row, :, 2] |= abs(np.arange(5, 100, 10) - wall.x) >= 15 + state[row, int(wall.x // 10), 3] = True + target = self._target() + if target is not None and 0 <= target.y < 100: + state[int(target.y // 10), int(target.x // 10), 4] = True + for row, value in enumerate((self.steps, self.fuel // 2, self.combo, round(self.x * 4))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.frozen + return state diff --git a/runtime/minatar_synth/games/mole_n.py b/runtime/minatar_synth/games/mole_n.py new file mode 100644 index 0000000000000000000000000000000000000000..9f5bcc1f16f9f6846275d4f8b37e1c84358e100a --- /dev/null +++ b/runtime/minatar_synth/games/mole_n.py @@ -0,0 +1,153 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Mole: + x: int + y: int + value: int + timer: int = 0 + award: int = 0 + + +class MoleNEnvironment: + score_cap = 40 + moves = ((0, 0), (-1, 0), (0, -1), (1, 0), (0, 1), (0, 0)) + mole_moves = ((1, 0), (0, 1), (-1, 0), (0, -1)) + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.numbers = self.random.integers(0, 10, (9, 9)) + self.x, self.y = 4, 4 + self.target = 1 + self.scroll = self.penalty = self.spawn_distance = 0.0 + self.target_count = self.move_timer = self.steps = self.action = 0 + self.moles: list[Mole] = [] + self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + previous = self.action + if self.random.random() >= self.sticky_action_prob: + self.action = action + dx, dy = self.moves[self.action] + self.x = min(8, max(0, self.x + dx)) + self.y = min(8, max(0, self.y + dy)) + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(frame == 0 and self.action == 5 and previous != 5) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _random_number(self): + return int(self.random.uniform(1, 2.5)) + + def _whack(self): + for mole in self.moles: + if not mole.timer and (mole.x, mole.y) == (self.x, self.y): + if mole.value == self.target: + self.target = self._random_number() + for other in self.moles: + other.timer, other.award = 60, other.value + else: + mole.timer, mole.award = 60, -mole.value + self.penalty += 1 + break + self.penalty += 1 + + def _advance(self, whack): + scroll = 0.02 + self.penalty + self.penalty *= 0.9 + self.scroll += scroll + if self.scroll > 0: + self.numbers[1:] = self.numbers[:-1].copy() + self.numbers[0] = self.random.integers(0, 10, 9) + for mole in self.moles: + mole.y += 1 + self.scroll -= 11 + if whack: + self._whack() + self.spawn_distance = self.spawn_distance - scroll if self.moles else -scroll + if self.spawn_distance < 0: + occupied = {m.x for m in self.moles if m.y == 0} + for _ in range(9): + x = int(self.random.integers(9)) + if x not in occupied: + self.target_count -= 1 + value = self._random_number() + if self.target_count <= 0: + value = self.target + self.target_count = int(self.random.integers(4, 7)) + self.moles.append(Mole(x, 0, value)) + break + self.spawn_distance += self.random.uniform(9, 12) + self.move_timer -= 1 + if self.move_timer < 0: + self._move_moles() + self.move_timer += 99 + remaining = [] + reward = 0 + for mole in self.moles: + if mole.timer: + mole.timer -= 1 + if not mole.timer: + reward += mole.award + continue + elif mole.y >= 8: + mole.timer = 60 + self.terminal |= mole.value == self.target + remaining.append(mole) + self.moles = remaining + return reward + + def _move_moles(self): + occupied = {(m.x, m.y) for m in self.moles} + for mole in self.moles: + if mole.timer: + continue + start = int(self.random.integers(4)) + for offset in range(4): + dx, dy = self.mole_moves[(start + offset) % 4] + x, y = mole.x + dx, mole.y + dy + if 0 <= x < 9 and 0 < y < 9 and (x, y) not in occupied: + occupied.remove((mole.x, mole.y)) + occupied.add((x, y)) + mole.x, mole.y = x, y + break + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + visible = self.numbers.copy() + for mole in self.moles: + if mole.y < 9: + if mole.timer: + visible[mole.y, mole.x] = mole.value + state[mole.y, mole.x, 4] = True + else: + visible[mole.y, mole.x] = (visible[mole.y, mole.x] + mole.value) % 10 + for bit in range(4): + state[:9, :9, bit] = (visible & (1 << bit)) != 0 + state[self.y, self.x, 5] = True + for col, value in enumerate((self.target, round(-self.scroll * 4), self.move_timer, self.action)): + for bit in range(6): + state[bit, 9, col] = bool(value & (1 << bit)) + state[9, col, 0] = bool(value & 64) + return state diff --git a/runtime/minatar_synth/games/monjum.py b/runtime/minatar_synth/games/monjum.py new file mode 100644 index 0000000000000000000000000000000000000000..07c8ad3bcd91d2d0657e63d052d827399d182164 --- /dev/null +++ b/runtime/minatar_synth/games/monjum.py @@ -0,0 +1,138 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Monster: + x: float = 99 + y: float = 87 + vy: float = 0 + jumping: bool = False + + +class MonjumEnvironment: + score_cap = 200 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.y = 50.0, 87.0 + self.vx = self.vy = 0.0 + self.floor_timer = self.monster_timer = self.coin_timer = 0.0 + self.floors = [(0.0, 99.0)] + self.monsters: list[Monster] = [] + self.coins: list[float] = [] + self.steps = self.frames = self.items = 0 + self.pressed = self.jumping = self.falling = self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + release = self.pressed and not pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(release and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _ground(self, x): + return any(start - 3 < x < start + width + 3 for start, width in self.floors) + + def _advance(self, release): + self.floor_timer -= 0.5 + if self.floor_timer < 0: + width = int(self.random.integers(50, 90)) + self.floors.append((110, width)) + self.floor_timer += 10 + width + self.floors = [(x - 0.5, w) for x, w in self.floors if x - 0.5 + w > 0] + self.monster_timer -= 1 + if self.monster_timer < 0: + self.monsters.append(Monster()) + self.monster_timer += self.random.uniform(200, 300) + for monster in self.monsters: + monster.x -= 0.75 + monster.y += monster.vy + if monster.jumping: + monster.vy += 0.09 + if monster.y > 87: + monster.y, monster.vy, monster.jumping = 87, 0, False + elif not self._ground(monster.x - 4): + monster.jumping, monster.vy = True, -1.4 + if abs(monster.x - self.x) < 5: + self.terminal |= abs(monster.y - self.y) < 5 + self.items |= 2 if abs(monster.y - self.y) < 27 else 0 + self.monsters = [monster for monster in self.monsters if monster.x > -3] + self.coin_timer -= 1 + if self.coin_timer < 0: + self.coins.append(99) + self.coin_timer += self.random.uniform(50, 100) + remaining = [] + for x in self.coins: + x -= 1 + if abs(x - self.x) < 5 and abs(self.y - 60) < 5: + self.items |= 4 + elif x > -3: + remaining.append(x) + self.coins = remaining + gap = not self._ground(self.x) + if gap: + self.items |= 1 + reward = 0 + if self.falling: + self.vy += 0.14 + self.terminal |= self.y > 99 + elif self.jumping: + self.vy += 0.12 + if self.y > 87: + self.y, self.vy = 87, 0 + if gap: + self.falling = True + else: + self.jumping = False + reward = (0, 1, 5, 20)[self.items.bit_count()] + else: + self.falling = gap + self.vx = -0.5 if self.pressed else 0 + if not self.pressed: + self.x += (50 - self.x) * 0.02 + if release and self.frames > 5: + self.vy, self.jumping, self.items = -2.5, True, 0 + self.x = min(50, max(0, self.x + self.vx)) + self.y += self.vy + self.frames += 1 + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, int(self.y // 10)), int(self.x // 10), 0] = True + for x, width in self.floors: + state[9, max(0, int(x // 10)):min(9, int((x + width) // 10)) + 1, 1] = True + for monster in self.monsters: + if 0 <= monster.x < 100: + state[int(monster.y // 10), int(monster.x // 10), 2] = True + for x in self.coins: + if 0 <= x < 100: + state[6, int(x // 10), 3] = True + state[min(9, max(0, int((self.y + 4 * self.vy) // 10))), int(self.x // 10), 4] = True + for row, value in enumerate((self.steps, self.items, round((self.vy + 3) * 60))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :3, 5] = self.pressed, self.jumping, self.falling + return state diff --git a/runtime/minatar_synth/games/monkey_t.py b/runtime/minatar_synth/games/monkey_t.py new file mode 100644 index 0000000000000000000000000000000000000000..972d80ce6071288a94fcb72e550f4c75e538a4c7 --- /dev/null +++ b/runtime/minatar_synth/games/monkey_t.py @@ -0,0 +1,115 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Hazard: + x: float + y: float + speed: float + + +class MonkeyTEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.y, self.vx, self.vy = 50.0, 90.0, 0.3, 0.0 + self.count = self.compression = self.power = self.steps = 0 + self.multiplier = 1 + self.pressed = self.terminal = False + self._spawn_coins() + self.hazards = [Hazard(self.random.uniform(10, 90), self.random.uniform(10, 70), + 0.5 + i * 0.1) for i in range(3)] + + def _spawn_coins(self): + self.coins = [(self.random.uniform(30, 70), self.random.uniform(20, 70)) for _ in range(5)] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed: + self.power = self.compression = 0 + elif self.pressed and not pressed: + self.power = self.compression + self.compression = self.count = 0 + self.pressed = pressed + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + @property + def trampoline_y(self): + return 90 + (self.compression + self.power) * 0.25 + + def _advance(self): + if self.pressed: + self.compression = min(30, self.compression + 1) + self.vy += 0.1 + self.x += self.vx + self.y += self.vy + if (self.x < 25 and self.vx < 0) or (self.x > 75 and self.vx > 0): + self.vx *= -1 + if self.vy > 0 and abs(self.y - self.trampoline_y) < 4: + self.y = self.trampoline_y - 5 + self.vy = -self.vy * 0.2 - self.power * 0.13 + if self.power > 1: + self.power = 0 + if self.y > 99: + self.y = 80 + remaining = [] + reward = 0 + for x, y in self.coins: + if abs(x - self.x) < 5 and abs(y - self.y) < 5: + self.multiplier += self.count + self.count += 1 + reward += self.multiplier + else: + remaining.append((x, y)) + self.coins = remaining + if not self.coins: + self._spawn_coins() + for hazard in self.hazards: + inward = (hazard.x < 10 and hazard.speed > 0) or (hazard.x > 90 and hazard.speed < 0) + hazard.x += hazard.speed * (0.5 if inward else 1) + if (hazard.x < -10 and hazard.speed < 0) or (hazard.x > 110 and hazard.speed > 0): + hazard.y = self.random.uniform(10, 70) + hazard.speed *= -1 + self.terminal |= abs(hazard.x - self.x) < 5 and abs(hazard.y - self.y) < 5 + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, max(0, int(self.y // 10))), int(self.x // 10), 0] = True + for x, y in self.coins: + state[int(y // 10), int(x // 10), 1] = True + for hazard in self.hazards: + if 0 <= hazard.x < 100: + state[int(hazard.y // 10), int(hazard.x // 10), 2 + (hazard.speed < 0)] = True + state[int(self.trampoline_y // 10), 2:8, 4] = True + values = (self.steps, self.compression, self.power, self.count, self.multiplier, + round((self.vy + 10) * 20)) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(min(511, max(0, value)) & (1 << bit)) + state[9, :2, 5] = self.pressed, self.vx > 0 + return state diff --git a/runtime/minatar_synth/games/montezumas_revenge.py b/runtime/minatar_synth/games/montezumas_revenge.py new file mode 100644 index 0000000000000000000000000000000000000000..953ad94c2a6322609853e1baeed590da62ed8846 --- /dev/null +++ b/runtime/minatar_synth/games/montezumas_revenge.py @@ -0,0 +1,306 @@ +import numpy as np + + +ITEM_VALUES = {"key": 100, "sword": 100, "amulet": 200, "jewel": 1_000, "torch": 3_000} +ITEM_LAYOUT = { + 0: (("key", 2), ("sword", 7)), + 1: (("jewel", 4),), + 2: (("amulet", 7), ("sword", 2)), + 3: (("key", 2), ("jewel", 7)), + 4: (("torch", 4), ("sword", 8)), + 5: (("key", 7),), + 6: (("sword", 2),), +} +DOORS = frozenset({(0, 1), (3, 4), (7, 8)}) +ROOM_NEIGHBORS = { + 0: {3: 1, 4: 3}, + 1: {1: 0, 3: 2, 4: 4}, + 2: {1: 1, 4: 5}, + 3: {2: 0, 3: 4, 4: 6}, + 4: {2: 1, 1: 3, 3: 5, 4: 7}, + 5: {2: 2, 1: 4, 4: 8}, + 6: {2: 3, 3: 7}, + 7: {2: 4, 1: 6, 3: 8}, + 8: {2: 5, 1: 7}, +} + + +class MontezumasRevengeEnvironment: + """Three compact fortress levels with inventory-gated exploration.""" + + score_cap = 50_400.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 3_000): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.level = 0 + self.lives = 5 + self.score = 0.0 + self.next_bonus_life = 10_000 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self.claimed: set[tuple[int, str, int, int]] = set() + self.open_doors: set[tuple[int, int, int]] = set() + self.defeated: set[tuple[int, str, int]] = set() + self.inventory: list[str] = [] + self._start_level() + + def _start_level(self) -> None: + self.room = 0 + self.player = [8, 1] + self.previous_player = self.player.copy() + self.jump_timer = 0 + self.amulet_timer = 0 + self.facing = 1 + self.room_steps = 0 + self.skull_column = 8 + self.skull_direction = -1 + self.spider_column = 1 + self.spider_direction = 1 + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + level_before = self.level + room_before = self.room + self.transition_reward = 0.0 + self._move_player(action) + reward = self.transition_reward + self._collect_item() + if action == 5: + reward += self._use_sword() + if self.level == level_before and self.room == room_before: + self._move_creatures() + self._resolve_hazards() + self.score += reward + while self.score >= self.next_bonus_life: + self.lives = min(6, self.lives + 1) + self.next_bonus_life += 10_000 + self.steps += 1 + self.room_steps += 1 + self.jump_timer = max(0, self.jump_timer - 1) + self.amulet_timer = max(0, self.amulet_timer - 1) + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _move_player(self, action: int) -> None: + if action == 1: + self.player[1] -= 1 + self.facing = -1 + elif action == 3: + self.player[1] += 1 + self.facing = 1 + elif action == 2: + if self.player[1] == 5 and 2 in ROOM_NEIGHBORS[self.room]: + self._change_room(2) + return + self.jump_timer = 3 + self.player[0] = 6 + elif action == 4 and self.player[1] == 5 and 4 in ROOM_NEIGHBORS[self.room]: + self._change_room(4) + return + if self.jump_timer == 0: + self.player[0] = 8 + if self.player[1] < 0: + self._change_room(1) + elif self.player[1] > 9: + self._change_room(3) + + def _change_room(self, direction: int) -> None: + destination = ROOM_NEIGHBORS[self.room].get(direction) + if destination is None: + self.player[1] = min(9, max(0, self.player[1])) + return + edge = tuple(sorted((self.room, destination))) + door = (self.level, *edge) + if edge in DOORS and door not in self.open_doors: + if "key" not in self.inventory: + self.player[1] = min(9, max(0, self.player[1])) + return + self.inventory.remove("key") + self.open_doors.add(door) + self.transition_reward += 300.0 + self.room = destination + if direction == 1: + self.player = [8, 9] + elif direction == 3: + self.player = [8, 0] + else: + self.player = [8, 5] + self.previous_player = self.player.copy() + self.room_steps = 0 + self.skull_column = 8 + self.skull_direction = -1 + self.spider_column = 1 + self.spider_direction = 1 + if self.room == 8 and (self.level, 7, 8) in self.open_doors: + self.level += 1 + if self.level >= 3: + self.terminal = True + else: + self.inventory.clear() + self._start_level() + + def _collect_item(self) -> float: + for index, (kind, column) in enumerate(ITEM_LAYOUT.get(self.room, ())): + identity = (self.level, kind, self.room, index) + if identity in self.claimed or self.player != [8, column]: + continue + if kind != "jewel" and len(self.inventory) >= 4: + return 0.0 + self.claimed.add(identity) + if kind != "jewel": + self.inventory.append(kind) + if kind == "amulet": + self.amulet_timer = 20 + return float(ITEM_VALUES[kind]) + return 0.0 + + def _use_sword(self) -> float: + if "sword" not in self.inventory: + return 0.0 + target = self.player[1] + self.facing + if self.room in (2, 6): + identity = (self.level, "skull", self.room) + if identity not in self.defeated and self.skull_column == target: + self.defeated.add(identity) + self.inventory.remove("sword") + return 2_000.0 + if self.room in (5, 7): + identity = (self.level, "spider", self.room) + if identity not in self.defeated and self.spider_column == target: + self.defeated.add(identity) + self.inventory.remove("sword") + return 3_000.0 + return 0.0 + + def _move_creatures(self) -> None: + speed = max(1, 3 - self.level) + if self.room_steps % speed: + return + if self.room in (2, 6) and (self.level, "skull", self.room) not in self.defeated: + self.skull_column += self.skull_direction + if self.skull_column in (1, 8): + self.skull_direction *= -1 + if self.room in (5, 7) and (self.level, "spider", self.room) not in self.defeated: + self.spider_column += self.spider_direction + if self.spider_column in (1, 8): + self.spider_direction *= -1 + + def _resolve_hazards(self) -> None: + if self.amulet_timer > 0: + return + creature_hit = ( + self.room in (2, 6) + and (self.level, "skull", self.room) not in self.defeated + and self.skull_column == self.player[1] + ) or ( + self.room in (5, 7) + and (self.level, "spider", self.room) not in self.defeated + and self.spider_column == self.player[1] + ) + fire_hit = self.room in (3, 6) and self.player[1] in (3, 7) and self.jump_timer == 0 + laser_hit = self.room == 4 and self.player[1] == 6 and self.room_steps % 6 < 3 + dark_fall = self.room >= 6 and "torch" not in self.inventory and self.player[1] in (4, 8) + if creature_hit or fire_hit or laser_hit or dark_fall: + self._lose_life() + + def _lose_life(self) -> None: + self.lives -= 1 + if self.lives <= 0: + self.terminal = True + return + room = self.room + self.player = [8, 1] + self.previous_player = self.player.copy() + self.jump_timer = 0 + self.amulet_timer = 0 + self.room_steps = 0 + self.skull_column = 8 + self.skull_direction = -1 + self.spider_column = 1 + self.spider_direction = 1 + self.room = room + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + state[*self.previous_player, 4] = True + for _kind, column in ITEM_LAYOUT.get(self.room, ()): + index = list(ITEM_LAYOUT[self.room]).index((_kind, column)) + if (self.level, _kind, self.room, index) not in self.claimed: + state[8, column, 2] = True + if self.room in (2, 6) and (self.level, "skull", self.room) not in self.defeated: + state[8, self.skull_column, 1] = True + if self.room in (5, 7) and (self.level, "spider", self.room) not in self.defeated: + state[8, self.spider_column, 1] = True + state[8, :, 3] = True + if self.room in (3, 6): + state[8, (3, 7), 3] = False + state[:, 5, 3] = True + item_identities = [] + for level in range(3): + for room, items in ITEM_LAYOUT.items(): + for index, (kind, _column) in enumerate(items): + item_identities.append((level, kind, room, index)) + for index, identity in enumerate(item_identities): + state[index // 10, index % 10, 5] = identity in self.claimed + door_edges = sorted(DOORS) + for level in range(3): + for edge_index, edge in enumerate(door_edges): + index = 33 + level * 3 + edge_index + state[index // 10, index % 10, 5] = (level, *edge) in self.open_doors + creature_identities = [] + for level in range(3): + for kind, room in (("skull", 2), ("skull", 6), ("spider", 5), ("spider", 7)): + creature_identities.append((level, kind, room)) + for offset, identity in enumerate(creature_identities): + index = 42 + offset + state[index // 10, index % 10, 5] = identity in self.defeated + inventory_codes = {"key": 1, "sword": 2, "amulet": 3, "torch": 4} + for slot, kind in enumerate(self.inventory): + code = inventory_codes[kind] + for bit in range(3): + index = 54 + slot * 3 + bit + state[index // 10, index % 10, 5] = bool(code & (1 << bit)) + for bit in range(2): + index = 66 + bit + state[index // 10, index % 10, 5] = bool(self.level & (1 << bit)) + for bit in range(4): + index = 68 + bit + state[index // 10, index % 10, 5] = bool(self.room & (1 << bit)) + for bit in range(3): + index = 72 + bit + state[index // 10, index % 10, 5] = bool(self.lives & (1 << bit)) + for bit in range(12): + index = 75 + bit + state[index // 10, index % 10, 5] = bool(self.steps & (1 << bit)) + for bit in range(2): + index = 87 + bit + state[index // 10, index % 10, 5] = bool(self.jump_timer & (1 << bit)) + for bit in range(5): + index = 89 + bit + state[index // 10, index % 10, 5] = bool(self.amulet_timer & (1 << bit)) + state[9, 4, 5] = self.facing > 0 + state[9, 5, 5] = self.room >= 6 and "torch" not in self.inventory + for bit in range(3): + state[9, 6 + bit, 5] = bool((self.room_steps % 6) & (1 << bit)) + state[9, 9, 5] = self.skull_direction > 0 if self.room in (2, 6) else self.spider_direction > 0 + return state diff --git a/runtime/minatar_synth/games/mortar.py b/runtime/minatar_synth/games/mortar.py new file mode 100644 index 0000000000000000000000000000000000000000..73a9203fc464b347e8eeec2d325251bff7e85f59 --- /dev/null +++ b/runtime/minatar_synth/games/mortar.py @@ -0,0 +1,165 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Enemy: + x: float + y: float + speed: float + + +@dataclass +class Shot: + x: float + y: float + width: float + + +@dataclass +class Blast: + x: float + y: float + target_radius: float + radius: float = 0 + + +class MortarEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.enemies = [Enemy(self.random.uniform(49, 60), self.random.uniform(-149, -140), 0.1) + for _ in range(5)] + self.x, self.direction = 30.0, 1 + self.sight = self.shot = self.blast = None + self.offset = self.timer = self.max_enemy_y = 0.0 + self.sight_speed = 3 + self.multiplier = 1 + self.steps = self.breach = 0 + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap, release = pressed and not self.pressed, self.pressed and not pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0, release and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap, release): + if self.blast is not None: + self.blast.radius += (self.blast.target_radius - self.blast.radius) * 0.1 + if self.blast.target_radius - self.blast.radius < 1: + self.blast = None + elif self.sight is not None: + self.sight -= 2 * self.sight_speed + if self.sight < 0: + self.offset += (90 - self.sight - self.offset) * 0.05 * self.sight_speed + if release or self.sight < -200: + if self.sight >= 0: + if self.shot is None: + self.shot = Shot(self.x, 95, math.ceil((91 - self.sight) * 0.2)) + else: + self.blast = Blast(self.x, self.sight, 2 + min(30, -self.sight * 0.3)) + self.sight = None + self.sight_speed = max(1, self.sight_speed - 1) + else: + self.offset *= 0.8 + self.x += self.direction + if (self.x < 3 and self.direction < 0) or (self.x > 96 and self.direction > 0): + self.direction *= -1 + if tap: + self.sight = 90 + self.multiplier = 1 + if self.shot is not None: + self.shot.y -= 3 + if self.shot.y < -3: + self.shot = None + if self.breach: + self.offset *= 0.5 + if self.breach > 9: + self.terminal = True + return 0 + self.timer = self.timer - 1 if self.enemies else -1 + if self.timer < 0: + speed = self.random.uniform(0.5, 2) * 0.1 + center = self.random.uniform(20, 80) + for _ in range(int(self.random.integers(5, 9))): + x, y = self.random.uniform(-9, 9, 2) + self.enemies.append(Enemy(center + x, -280 + y, speed * self.random.uniform(0.9, 1.1))) + self.timer = 99 * math.sqrt(len(self.enemies)) + return self._move_enemies() + + def _move_enemies(self): + reward = 0 + remaining = [] + rate = math.sqrt(120 - self.max_enemy_y) / 4 + if self.sight is not None: + rate *= 0.3 + top_progress = -200 + for enemy in self.enemies: + if enemy.y > 99: + self.breach += 1 + else: + shot = self.shot + blast = self.blast + hit = shot is not None and abs(shot.x - enemy.x) < shot.width / 2 + 3 and abs(shot.y - enemy.y) < 6 + if blast is not None: + distance = math.hypot(blast.x - enemy.x, blast.y - enemy.y) + hit |= abs(distance - blast.radius) < 5.5 + if hit: + reward += self.multiplier + self.multiplier += 1 + continue + enemy.y += enemy.speed * rate + top_progress = max(top_progress, enemy.y) + remaining.append(enemy) + self.enemies = remaining + self.max_enemy_y = top_progress + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + points = [(self.x, 95, 0)] + if self.sight is not None: + points.append((self.x, self.sight, 2)) + if self.shot is not None: + points.append((self.shot.x, self.shot.y, 3)) + points.extend((e.x, e.y, 1) for e in self.enemies) + for x, y, channel in points: + y += self.offset + if 0 <= y < 100: + state[int(y // 10), int(x // 10), channel] = True + if self.blast is not None: + rows, cols = np.ogrid[5:100:10, 5:100:10] + state[:, :, 4] = abs(np.hypot(cols - self.blast.x, + rows - self.blast.y - self.offset) - self.blast.radius) < 6 + values = (self.steps, min(511, self.multiplier), self.sight_speed, round(self.offset), + round(200 + self.sight) if self.sight is not None else 0) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(max(0, value) & (1 << bit)) + state[9, :2, 5] = self.pressed, self.direction > 0 + return state diff --git a/runtime/minatar_synth/games/ms_pac_man.py b/runtime/minatar_synth/games/ms_pac_man.py new file mode 100644 index 0000000000000000000000000000000000000000..d93bcbc0257511f1354bf1a9a1cd82aeaf45f205 --- /dev/null +++ b/runtime/minatar_synth/games/ms_pac_man.py @@ -0,0 +1,248 @@ +import numpy as np + + +FRUIT_VALUES = (100, 200, 500, 700) +GHOST_VALUES = (200, 400, 800, 1_600) +ENERGIZERS = ((1, 1), (1, 8), (8, 1), (8, 8)) +PLAYER_START = (7, 5) +GHOST_STARTS = ((4, 4), (4, 5), (5, 4), (5, 5)) +INTERNAL_WALLS = ( + frozenset({(2, 2), (2, 3), (2, 6), (2, 7), (7, 2), (7, 3), (7, 6), (7, 7)}), + frozenset({(2, 4), (2, 5), (4, 2), (5, 2), (4, 7), (5, 7), (7, 4), (7, 5)}), + frozenset({(2, 2), (2, 7), (3, 4), (3, 5), (6, 4), (6, 5), (7, 2), (7, 7)}), + frozenset({(2, 3), (2, 6), (4, 2), (4, 7), (5, 2), (5, 7), (7, 3), (7, 6)}), +) +DIRECTIONS = {1: (0, -1), 2: (-1, 0), 3: (0, 1), 4: (1, 0)} + + +class MsPacManEnvironment: + """Four-maze dot clearing with fruit, energizers, and four ghosts.""" + + score_cap = 52_180.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 4_000): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.maze = 0 + self.lives = 3 + self.score = 0.0 + self.bonus_life_awarded = False + self.steps = 0 + self.last_action = 0 + self.terminal = False + self._start_maze() + + def _walls(self) -> set[tuple[int, int]]: + walls = {(0, column) for column in range(10)} | {(9, column) for column in range(10)} + walls |= {(row, 0) for row in range(10) if row != 5} + walls |= {(row, 9) for row in range(10) if row != 5} + walls |= set(INTERNAL_WALLS[self.maze]) + return walls + + def _start_maze(self) -> None: + walls = self._walls() + excluded = {PLAYER_START, *GHOST_STARTS, *ENERGIZERS, (5, 5)} + self.dots = { + (row, column) + for row in range(1, 9) + for column in range(1, 9) + if (row, column) not in walls and (row, column) not in excluded + } + self.initial_dot_count = len(self.dots) + self.energizers = set(ENERGIZERS) + self.fruit_collected = False + self.fruit_active = False + self.fruit_timer = 0 + self.frightened_timer = 0 + self.ghost_chain = 0 + self.frightened_eaten: set[int] = set() + self._reset_actors() + + def _reset_actors(self) -> None: + self.player = list(PLAYER_START) + self.previous_player = self.player.copy() + self.ghosts = [list(position) for position in GHOST_STARTS] + self.previous_ghosts = [ghost.copy() for ghost in self.ghosts] + self.ghost_directions = [1, 3, 1, 3] + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + self.previous_ghosts = [ghost.copy() for ghost in self.ghosts] + maze_before = self.maze + self._move_player(action) + reward = self._eat_at_player() + if self.maze == maze_before and not self.terminal: + self._move_ghosts() + reward += self._resolve_collisions() + self.score += reward + if self.score >= 10_000 and not self.bonus_life_awarded: + self.lives += 1 + self.bonus_life_awarded = True + self.steps += 1 + self.frightened_timer = max(0, self.frightened_timer - 1) + self.fruit_timer = max(0, self.fruit_timer - 1) + if self.fruit_timer == 0: + self.fruit_active = False + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _move_player(self, action: int) -> None: + if action not in DIRECTIONS: + return + row_delta, column_delta = DIRECTIONS[action] + target = [self.player[0] + row_delta, self.player[1] + column_delta] + if self.player[0] == 5 and target[1] < 0: + target[1] = 9 + elif self.player[0] == 5 and target[1] > 9: + target[1] = 0 + if tuple(target) not in self._walls(): + self.player = target + + def _eat_at_player(self) -> float: + position = tuple(self.player) + reward = 0.0 + if position in self.dots: + self.dots.remove(position) + reward += 10.0 + if position in self.energizers: + self.energizers.remove(position) + self.frightened_timer = max(8, 20 - self.maze * 4) + self.ghost_chain = 0 + self.frightened_eaten.clear() + reward += 50.0 + if not self.fruit_collected and not self.fruit_active and len(self.dots) <= self.initial_dot_count // 2: + self.fruit_active = True + self.fruit_timer = 80 + if self.fruit_active and position == (5, 5): + self.fruit_active = False + self.fruit_collected = True + reward += float(FRUIT_VALUES[self.maze]) + if not self.dots and not self.energizers: + self.maze += 1 + if self.maze >= 4: + self.terminal = True + else: + self._start_maze() + return reward + + def _move_ghosts(self) -> None: + if self.maze == 0 and self.steps % 2: + return + walls = self._walls() + for index, ghost in enumerate(self.ghosts): + options = [] + reverse = {1: 3, 2: 4, 3: 1, 4: 2}[self.ghost_directions[index]] + for action, (row_delta, column_delta) in DIRECTIONS.items(): + target = [ghost[0] + row_delta, ghost[1] + column_delta] + if ghost[0] == 5 and target[1] < 0: + target[1] = 9 + elif ghost[0] == 5 and target[1] > 9: + target[1] = 0 + if tuple(target) not in walls and action != reverse: + options.append((action, target)) + if not options: + row_delta, column_delta = DIRECTIONS[reverse] + options = [(reverse, [ghost[0] + row_delta, ghost[1] + column_delta])] + target_player = self._ghost_target(index) + scored = [] + for option in options: + distance = abs(option[1][0] - target_player[0]) + abs(option[1][1] - target_player[1]) + scored.append((distance, option)) + best_value = max(value for value, _ in scored) if self.frightened_timer else min(value for value, _ in scored) + best = [option for value, option in scored if value == best_value] + action, target = best[int(self.random.randint(len(best)))] + self.ghost_directions[index] = action + self.ghosts[index] = target + + def _ghost_target(self, index: int) -> tuple[int, int]: + if index == 0: + return tuple(self.player) + if index == 1: + delta = DIRECTIONS.get(self.last_action, (0, 0)) + return self.player[0] + delta[0] * 2, self.player[1] + delta[1] * 2 + if index == 2: + return (1, 1) if (self.steps // 8) % 2 else tuple(self.player) + return (8, 8) if self.player[0] < 5 else (1, 8) + + def _resolve_collisions(self) -> float: + reward = 0.0 + for index, ghost in enumerate(self.ghosts): + crossed = ghost == self.previous_player and self.player == self.previous_ghosts[index] + if ghost != self.player and not crossed: + continue + if self.frightened_timer and index not in self.frightened_eaten: + reward += float(GHOST_VALUES[min(3, self.ghost_chain)]) + self.ghost_chain += 1 + self.frightened_eaten.add(index) + self.ghosts[index] = list(GHOST_STARTS[index]) + self.previous_ghosts[index] = self.ghosts[index].copy() + else: + self.lives -= 1 + if self.lives <= 0: + self.terminal = True + else: + self.frightened_timer = 0 + self.ghost_chain = 0 + self.frightened_eaten.clear() + self._reset_actors() + break + return reward + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + state[*self.previous_player, 4] = True + for index, ghost in enumerate(self.ghosts): + state[*ghost, 1] = True + state[*self.previous_ghosts[index], 4] = True + for dot in self.dots: + state[*dot, 2] = True + for energizer in self.energizers: + state[*energizer, 2] = True + state[*energizer, 3] = True + if self.fruit_active: + state[5, 5, 2] = True + state[5, 5, 3] = True + for wall in self._walls(): + state[*wall, 3] = True + for bit in range(2): + state[0, bit, 5] = bool(self.maze & (1 << bit)) + for bit in range(3): + state[0, 2 + bit, 5] = bool(self.lives & (1 << bit)) + state[0, 5 + bit, 5] = bool(self.ghost_chain & (1 << bit)) + for bit in range(5): + index = 8 + bit + state[index // 10, index % 10, 5] = bool(self.frightened_timer & (1 << bit)) + for bit in range(7): + index = 13 + bit + state[index // 10, index % 10, 5] = bool(self.fruit_timer & (1 << bit)) + for index, direction in enumerate(self.ghost_directions): + for bit in range(3): + gauge_index = 20 + index * 3 + bit + state[gauge_index // 10, gauge_index % 10, 5] = bool(direction & (1 << bit)) + for bit in range(12): + gauge_index = 32 + bit + state[gauge_index // 10, gauge_index % 10, 5] = bool(self.steps & (1 << bit)) + state[4, 4, 5] = self.fruit_collected + state[4, 5, 5] = self.bonus_life_awarded + for index in range(4): + state[4, 6 + index, 5] = index in self.frightened_eaten + return state diff --git a/runtime/minatar_synth/games/name_this_game.py b/runtime/minatar_synth/games/name_this_game.py new file mode 100644 index 0000000000000000000000000000000000000000..0556d24e2b4de8928ecfd777c65e802a50f48c66 --- /dev/null +++ b/runtime/minatar_synth/games/name_this_game.py @@ -0,0 +1,205 @@ +import numpy as np + + +TENTACLE_COLUMNS = (2, 4, 6, 8) +SHARK_VALUES_BY_ROW = (0, 10, 20, 30, 40, 50, 80, 100, 100) + + +class NameThisGameEnvironment: + """Eight escalating treasure-defense waves under a moving oxygen line.""" + + score_cap = 4_800.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 3_000): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.wave = 0 + self.treasure = 5 + self.score = 0.0 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self._start_wave() + + def _start_wave(self) -> None: + self.diver_column = 5 + self.previous_diver_column = self.diver_column + self.air = 100 + self.air_line_column = 0 + self.air_line_direction = 1 + self.air_bonus_units = 0 + self.tentacle_lengths = [1, 1, 1, 1] + self.tentacles_destroyed: set[int] = set() + self.shark_index = 0 + self.shark = [1, 0] + self.previous_shark = self.shark.copy() + self.shark_direction = 1 + self.projectiles: list[list[int]] = [] + self.previous_projectiles: list[list[int]] = [] + self.wave_steps = 0 + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_diver_column = self.diver_column + self.previous_shark = self.shark.copy() + self.previous_projectiles = [projectile.copy() for projectile in self.projectiles] + if action == 1: + self.diver_column = max(0, self.diver_column - 1) + elif action == 3: + self.diver_column = min(9, self.diver_column + 1) + elif action == 5 and len(self.projectiles) < 3: + self.projectiles.append([7, self.diver_column]) + wave_before = self.wave + reward = self._move_projectiles() + if self.wave == wave_before and not self.terminal: + self._move_shark() + self._grow_tentacles() + reward += self._move_air_line() + self.air -= 1 + self.wave // 3 + self._resolve_failures() + self.score += reward + self.steps += 1 + self.wave_steps += 1 + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _move_projectiles(self) -> float: + reward = 0.0 + for projectile in list(self.projectiles): + projectile[0] -= 1 + hit_tentacle = None + for index, column in enumerate(TENTACLE_COLUMNS): + if index in self.tentacles_destroyed: + continue + tip_row = self.tentacle_lengths[index] + if projectile == [tip_row, column]: + hit_tentacle = index + break + if hit_tentacle is not None: + self.tentacles_destroyed.add(hit_tentacle) + self.projectiles.remove(projectile) + reward += 50.0 + continue + if projectile == self.shark and self.shark_index < 3: + reward += float(SHARK_VALUES_BY_ROW[self.shark[0]]) + self.shark_index += 1 + self.projectiles.remove(projectile) + self._reset_shark() + continue + if projectile[0] < 0: + self.projectiles.remove(projectile) + if len(self.tentacles_destroyed) == 4 and self.shark_index >= 3: + self.wave += 1 + if self.wave >= 8: + self.terminal = True + else: + self._start_wave() + return reward + + def _reset_shark(self) -> None: + self.shark = [1, 0 if self.shark_direction > 0 else 9] + self.previous_shark = self.shark.copy() + + def _move_shark(self) -> None: + if self.shark_index >= 3: + return + interval = max(1, 3 - self.wave // 3) + if self.wave_steps % interval: + return + self.shark[1] += self.shark_direction + if self.shark[1] in (0, 9): + self.shark_direction *= -1 + self.shark[0] = min(8, self.shark[0] + 1) + + def _grow_tentacles(self) -> None: + interval = max(2, 8 - self.wave) + if self.wave_steps % interval: + return + live = [index for index in range(4) if index not in self.tentacles_destroyed] + if live: + index = live[(self.wave_steps // interval) % len(live)] + self.tentacle_lengths[index] = min(8, self.tentacle_lengths[index] + 1) + + def _move_air_line(self) -> float: + self.air_line_column += self.air_line_direction + if self.air_line_column in (0, 9): + self.air_line_direction *= -1 + if self.air_line_column != self.diver_column: + return 0.0 + if self.air < 100: + self.air = min(100, self.air + 20) + return 0.0 + if self.air_bonus_units < 10: + self.air_bonus_units += 1 + return 10.0 + return 0.0 + + def _resolve_failures(self) -> None: + shark_hit = self.shark_index < 3 and self.shark == [8, self.diver_column] + tentacle_hit = any( + index not in self.tentacles_destroyed and length >= 8 + for index, length in enumerate(self.tentacle_lengths) + ) + if self.air <= 0 or shark_hit or tentacle_hit: + self.treasure -= 1 + if self.treasure <= 0: + self.terminal = True + return + self.diver_column = 5 + self.air = 100 + self._reset_shark() + for index in range(4): + if index not in self.tentacles_destroyed: + self.tentacle_lengths[index] = 1 + self.projectiles.clear() + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[8, self.diver_column, 0] = True + state[8, self.previous_diver_column, 4] = True + if self.shark_index < 3: + state[*self.shark, 1] = True + state[*self.previous_shark, 4] = True + for index, column in enumerate(TENTACLE_COLUMNS): + if index in self.tentacles_destroyed: + continue + state[0 : self.tentacle_lengths[index] + 1, column, 1] = True + for projectile in self.projectiles: + state[*projectile, 2] = True + for projectile in self.previous_projectiles: + state[*projectile, 4] = True + state[0:8, self.air_line_column, 3] = True + state[9, : self.treasure, 2] = True + for bit in range(3): + state[0, bit, 5] = bool(self.wave & (1 << bit)) + state[0, 3 + bit, 5] = bool(self.treasure & (1 << bit)) + state[0, 6 + bit, 5] = bool(self.shark_index & (1 << bit)) + for bit in range(7): + state[1, bit, 5] = bool(max(0, self.air) & (1 << bit)) + for bit in range(4): + state[2, bit, 5] = bool(self.air_bonus_units & (1 << bit)) + for index in range(4): + state[2, 4 + index, 5] = index in self.tentacles_destroyed + for bit in range(12): + state[3 + bit // 10, bit % 10, 5] = bool(self.steps & (1 << bit)) + state[5 + bit // 10, bit % 10, 5] = bool(self.wave_steps & (1 << bit)) + state[7, 0, 5] = self.shark_direction > 0 + state[7, 1, 5] = self.air_line_direction > 0 + return state diff --git a/runtime/minatar_synth/games/neon_pollinator.py b/runtime/minatar_synth/games/neon_pollinator.py new file mode 100644 index 0000000000000000000000000000000000000000..819551b45b79078b2a7f5e702b10675828631405 --- /dev/null +++ b/runtime/minatar_synth/games/neon_pollinator.py @@ -0,0 +1,124 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Flower: + x: float + y: float + size: float + pollinated: bool = False + glow: float = 0 + + +class NeonPollinatorEnvironment: + score_cap = 100 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.y, self.energy, self.glow = 50.0, 100.0, 5.0 + self.flower_distance = self.orb_distance = 0.0 + self.steps = 0 + self.multiplier = 1 + self.pressed = self.terminal = False + self.flowers: list[Flower] = [] + self.orbs: list[tuple[float, float]] = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed: + self.multiplier = 1 + self.pressed = pressed + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self): + if self.pressed and self.energy > 0: + self.y -= 1 + self.glow = min(25, self.glow + 0.25) + self.energy -= 0.5 + else: + self.y += 0.7 + self.glow = max(3, self.glow - 0.5) + self.energy -= 0.1 + self.energy = max(0, self.energy) + if not 0 <= self.y <= 100: + self.terminal = True + return 0 + self.flower_distance -= 0.5 + if self.flower_distance < 0: + self.flowers.append(Flower(115, self.random.uniform(10, 90), self.random.uniform(5, 15))) + self.flower_distance += 20 + for flower in self.flowers: + flower.x -= 0.5 + self.flowers = [flower for flower in self.flowers if flower.x >= -10] + lights = [(f.x, f.y, f.glow) for f in self.flowers if f.glow > 0] + if self.glow > 3: + lights.append((20, self.y, self.glow)) + reward = 0 + for flower in self.flowers: + if not flower.pollinated and any( + abs(radius - flower.size) - 2 < math.hypot(x - flower.x, y - flower.y) + < radius + flower.size + 2 for x, y, radius in lights): + flower.pollinated = True + flower.glow = flower.size * 3 + reward += self.multiplier + self.multiplier += 1 + flower.glow = max(0, flower.glow - 0.2) + self.orb_distance -= 0.5 + if self.orb_distance < 0: + self.orbs.append((100, self.random.uniform(10, 90))) + self.orb_distance += self.random.uniform(16, 20) + remaining = [] + for x, y in self.orbs: + if abs(x - 20) < 7 and abs(y - self.y) < 7: + self.energy = min(100, self.energy + 20) + elif x >= -9.5: + remaining.append((x - 0.5, y)) + self.orbs = remaining + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, max(0, int(self.y // 10))), 2, 0] = True + rows, cols = np.ogrid[5:100:10, 5:100:10] + if self.glow > 3: + state[:, :, 3] = abs(np.hypot(cols - 20, rows - self.y) - self.glow) < 6 + for flower in self.flowers: + distance = np.hypot(cols - flower.x, rows - flower.y) + state[:, :, 2 if flower.pollinated else 1] |= abs(distance - flower.size) < 6 + if flower.glow: + state[:, :, 3] |= abs(distance - flower.glow) < 6 + for x, y in self.orbs: + visible = math.hypot(x - 20, y - self.y) < self.glow or any( + math.hypot(x - f.x, y - f.y) < f.glow for f in self.flowers + ) + if visible and 0 <= x < 100: + state[int(y // 10), int(x // 10), 4] = True + for row, value in enumerate((self.steps, round(self.energy * 4), round(self.glow * 10), self.multiplier)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/not_turn.py b/runtime/minatar_synth/games/not_turn.py new file mode 100644 index 0000000000000000000000000000000000000000..52ba3dd437619f5fb6a12a2cb8309d653661f215 --- /dev/null +++ b/runtime/minatar_synth/games/not_turn.py @@ -0,0 +1,134 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Walker: + x: float + y: float + lane: int + dx: int = 0 + cooldown: float = 0 + dot_distance: float = 0 + + +class NotTurnEnvironment: + score_cap = 200 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.player = Walker(50, 99, 2, cooldown=5) + self.speed = 1.0 + self.enemy_timer = 20.0 + self.bar_distance = 0.0 + self.steps = 0 + self.multiplier = 1 + self.pressed = self.terminal = False + self.bars = [] + self.enemies = [] + self.dots = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _move(self, walker, speed, vertical, turn): + if walker.dx: + walker.x += walker.dx * speed + target = 10 + walker.lane * 20 + if (walker.x - target) * walker.dx >= 0: + walker.x, walker.dx = target, 0 + return + walker.y += vertical * speed + walker.cooldown -= speed + if turn and walker.cooldown < 0: + for direction in (1, -1): + lane = walker.lane + direction + if 0 <= lane < 5 and any( + abs(x - walker.x - 6 * direction) < 9 and abs(y - walker.y - 3) < 2 + for x, y in self.bars): + walker.dx, walker.lane, walker.cooldown = direction, lane, 5 + break + + def _advance(self): + player = self.player + scroll = max(0, player.y - 20) * 0.1 + self.bar_distance -= scroll + if self.bar_distance < 0: + a, b = self.random.integers(4, size=2) + self.bars.append((20 + a * 20, 102)) + if abs(a - b) > 1: + self.bars.append((20 + b * 20, 102)) + self.bar_distance += self.random.uniform(9, 12) + self.bars = [(x, y - scroll) for x, y in self.bars if y - scroll >= -1] + self._move(player, self.speed * 0.2, 1, self.pressed) + self.speed += ((4 if self.pressed else 1) - self.speed) * 0.2 + self.enemy_timer -= 1 + if self.enemy_timer < 0: + lane = int(self.random.integers(5)) + self.enemies.append(Walker(10 + lane * 20, 103, lane)) + self.enemy_timer = self.random.uniform(100, 150) + remaining = [] + for enemy in self.enemies: + self._move(enemy, 0.3, -1, True) + self.terminal |= abs(enemy.x - player.x) < 5 and abs(enemy.y - player.y) < 5 + enemy.y -= scroll + enemy.dot_distance -= 0.3 + if enemy.dot_distance < 0: + enemy.dot_distance += 6 + self.dots.append((enemy.x, enemy.y)) + if enemy.y >= -3: + remaining.append(enemy) + else: + self.multiplier = max(1, self.multiplier - 1) + self.enemies = remaining + reward = 0 + remaining = [] + for x, y in self.dots: + if abs(x - player.x) < 4 and abs(y - player.y) < 4: + reward += self.multiplier + self.multiplier += 1 + elif y - scroll >= -3: + remaining.append((x, y - scroll)) + self.dots = remaining + player.y -= scroll + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, max(0, int(self.player.y // 10))), int(self.player.x // 10), 0] = True + state[:, 1::2, 1] = True + for channel, points in ((2, self.bars), (3, [(e.x, e.y) for e in self.enemies]), (4, self.dots)): + for x, y in points: + if 0 <= y < 100: + state[int(y // 10), int(x // 10), channel] = True + values = (self.steps, min(511, self.multiplier), round(self.speed * 100), + self.player.lane, self.player.dx + 1) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/ns_climb.py b/runtime/minatar_synth/games/ns_climb.py new file mode 100644 index 0000000000000000000000000000000000000000..a7a8dc9bdc1ebfdbb3ec0faeac653afefd090304 --- /dev/null +++ b/runtime/minatar_synth/games/ns_climb.py @@ -0,0 +1,126 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Wall: + x: float + count: int + vx: float = 0 + pole: int = 0 + previous: int = -1 + + +@dataclass +class Magnet: + x: float + y: float + side: int + pole: int + + +class NsClimbEnvironment: + score_cap = 1500 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.y, self.vx, self.vy = 50.0, 90.0, 0.0, -1.0 + self.pole = 1 + self.steps = 0 + self.pressed = self.terminal = False + self.walls = [Wall(x, int(self.random.integers(2, 4))) for x in (20, 80)] + self.magnets = [Magnet((20, 80)[i % 2], i * 5 - 5, i % 2, -1 if i < 10 else 0) + for i in range(22)] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed: + self.pole *= -1 + self.pressed = pressed + self.steps += 1 + reward = 0.0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return reward, self.terminal + + def _advance(self): + self.x += self.vx + self.y += self.vy + self.vx *= 0.98 + self.vy += 0.001 + if self.y > 99: + self.terminal = True + return 0.0 + scroll = max(0, 70 - self.y) * 0.1 + self.y += scroll + for magnet in self.magnets: + magnet.y += scroll + dx, dy = magnet.x - self.x, magnet.y - self.y + distance = math.hypot(dx, dy) + if magnet.pole and distance: + force = -magnet.pole * self.pole / distance ** 3 + self.vx += dx * force + self.vy += dy * force + if abs(dx) < 8 and abs(dy) < 8: + inward = 1 if magnet.side == 0 else -1 + self.x = magnet.x + 10 * inward + if self.vx * inward < 0: + self.vx *= -0.7 + if magnet.y > 105: + self._recycle(magnet) + return scroll + + def _recycle(self, magnet): + magnet.y -= 110 + wall = self.walls[magnet.side] + wall.x += wall.vx + magnet.x = wall.x + wall.vx += self.random.uniform(-0.1, 0.1) + low = 10 + magnet.side * 50 + if (wall.x < low and wall.vx < 0) or (wall.x > low + 30 and wall.vx > 0): + wall.vx *= -0.5 + wall.count -= 1 + if wall.count < 0: + if wall.pole: + wall.pole = 0 + wall.count = int(self.random.integers(2, 4)) + else: + wall.pole = wall.previous = -wall.previous + wall.count = int(self.random.integers(3, 9)) + magnet.pole = wall.pole + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + row = min(9, max(0, int(self.y // 10))) + col = min(9, max(0, int(self.x // 10))) + state[row, col, 0] = True + for magnet in self.magnets: + if 0 <= magnet.x < 100 and 0 <= magnet.y < 100: + state[int(magnet.y // 10), int(magnet.x // 10), 2 + magnet.pole] = True + row = min(9, max(0, int((self.y + 4 * self.vy) // 10))) + col = min(9, max(0, int((self.x + 4 * self.vx) // 10))) + state[row, col, 4] = True + for row, value in enumerate((self.steps, round((self.vy + 5) * 40), round((self.vx + 5) * 40))): + for bit in range(9): + state[row, bit, 5] = bool(min(511, max(0, value)) & (1 << bit)) + state[9, :2, 5] = self.pressed, self.pole == 1 + return state diff --git a/runtime/minatar_synth/games/number_ball.py b/runtime/minatar_synth/games/number_ball.py new file mode 100644 index 0000000000000000000000000000000000000000..a05c049882bff51400043c75a7e47b9d001694e4 --- /dev/null +++ b/runtime/minatar_synth/games/number_ball.py @@ -0,0 +1,176 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Floor: + x: float + width: float + value: int = 0 + + +@dataclass +class Ball: + value: int + x: float = 10 + y: float = 47 + vx: float = 0 + vy: float = 0 + mode: str = "ready" + + +class NumberBallEnvironment: + score_cap = 150 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.floors = [Floor(0, 200)] + self.balls: list[Ball] = [] + self.frames = self.steps = 0 + self.boost = self.launch_penalty = 0.0 + self.angle = -0.1 + self.multiplier = 1 + self.add_ball = True + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + release = self.pressed and not pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(release and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, release): + lead = self.floors[0] + scroll = 0.04 + self.boost + max(0, lead.x + lead.width - 100) * 0.1 + self.boost *= 0.9 + self.launch_penalty = min(9, max(0, self.launch_penalty - 0.01)) + reward = self._move_floors(scroll) + if self.terminal: + return reward + if self.frames > 30 and self.add_ball: + values = {floor.value for floor in self.floors} + for _ in range(9): + value = int(self.random.integers(1, 3)) + if value in values: + break + self.balls.append(Ball(value)) + self.add_ball = False + self.angle = -0.1 + remaining = [] + for ball in self.balls: + self._move_ball(ball, release, scroll) + if -20 <= ball.x <= 220 and -50 <= ball.y <= 63: + remaining.append(ball) + elif ball.mode == "flying": + self.add_ball = True + self.balls = remaining + self.frames += 1 + return reward + + def _move_floors(self, scroll): + reward = 0 + right = 0 + remaining = [] + for index, floor in enumerate(self.floors): + floor.x -= scroll + right = floor.x + floor.width + if floor.value and any(ball.mode == "floor" and ball.value == floor.value + and floor.x - 3 < ball.x < right + 3 for ball in self.balls): + reward += floor.value * self.multiplier + self.multiplier = min(16, self.multiplier * 2) + continue + if index + 1 < len(self.floors): + gap = self.floors[index + 1].x - right + floor.x += gap * 0.1 if gap > -2 else gap + remaining.append(floor) + self.floors = remaining + self.terminal = not remaining or remaining[0].x + remaining[0].width < 30 + if right < 200: + self.floors.append(Floor(200, self.random.uniform(20, 50), int(self.random.integers(1, 3)))) + return reward + + def _move_ball(self, ball, release, scroll): + if ball.mode == "ready": + self.angle -= 0.01 * self.pressed + if release or self.angle < -math.pi * 0.47: + self.multiplier = max(1, self.multiplier // 2) + self.boost = self.launch_penalty + self.launch_penalty += 1 + ball.vx, ball.vy = 5 * math.cos(self.angle), 5 * math.sin(self.angle) + ball.mode = "flying" + elif ball.mode == "flying": + ball.vx *= 0.99 + ball.vy = (ball.vy + 0.1) * 0.99 + ball.x += ball.vx + ball.y += ball.vy + if ball.y > 47: + ball.y = 47 + ball.vx *= 0.5 + ball.vy *= -0.5 + if abs(ball.vy) < 0.5: + ball.mode = "floor" + self.add_ball = True + elif ball.mode == "floor": + ball.vx *= 0.9 + ball.x += ball.vx + ball.vy = 0 + if ball.x < 30: + ball.mode = "falling" + else: + ball.vy += 0.1 + ball.y += ball.vy + if ball.mode in ("flying", "floor"): + ball.x -= scroll + for other in self.balls: + dx, dy = ball.x - other.x, ball.y - other.y + distance = math.hypot(dx, dy) + if other is not ball and distance < 6: + angle = math.atan2(dy, dx) + ux, uy = math.cos(angle), math.sin(angle) + push = math.hypot(other.vx, other.vy) * 0.7 + ball.vx += ux * push + ball.vy += uy * push + push = math.hypot(ball.vx, ball.vy) * 0.7 + other.vx -= ux * push + other.vy -= uy * push + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + for ball in self.balls: + if 0 <= ball.x < 200 and 0 <= ball.y < 60: + row, col = int(ball.y // 6), int(ball.x // 20) + state[row, col, ball.value - 1] = True + state[row, col, 4] |= ball.mode == "ready" + for floor in self.floors: + left, right = max(0, int(floor.x // 20)), min(9, int((floor.x + floor.width) // 20)) + if left <= right: + state[9, left:right + 1, 2:4] |= [floor.value != 2, floor.value != 1] + for row, value in enumerate((self.steps, self.multiplier, round(-self.angle * 100), + round(self.boost * 40))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/number_line.py b/runtime/minatar_synth/games/number_line.py new file mode 100644 index 0000000000000000000000000000000000000000..8a6475cbb8ffa7668d0c9d5ce00baee6a8399861 --- /dev/null +++ b/runtime/minatar_synth/games/number_line.py @@ -0,0 +1,103 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Number: + value: int + x: float = -3 + + +class NumberLineEnvironment: + score_cap = 100 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.lines = [12.0, 94.0] + self.targets = self.lines.copy() + self.numbers: list[list[Number]] = [[], []] + self.timers = [0.0, 0.0] + self.sums = [0, 0] + self.countdown = self.steps = 0 + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap): + self.targets[0] += 0.01 + self.targets[1] -= 0.01 + for index in range(2): + self.lines[index] += (self.targets[index] - self.lines[index]) * 0.2 + reward = 0 + if self.lines[0] < 12: + self.targets[0] += 1 + reward += 1 + if self.lines[1] > 94: + self.targets[1] -= 1 + self.terminal = self.lines[0] >= self.lines[1] + if self.countdown: + self.countdown -= 1 + if not self.countdown: + difference = self.sums[0] - self.sums[1] + reward += difference + self.targets[0] -= difference + self.targets[1] += difference + self.sums = [0, 0] + elif tap: + for index, numbers in enumerate(self.numbers): + self.sums[index] = sum(n.value for n in numbers if 3 < n.x < 97) + self.numbers[index] = [n for n in numbers if not 3 < n.x < 97] + self.countdown = 61 + for index in range(2): + self.timers[index] -= 1 + if self.timers[index] < 0: + self.numbers[index].append(Number(int(self.random.integers(1, 10)))) + self.timers[index] = self.random.uniform(10, 30) + for number in self.numbers[index]: + number.x += 0.7 + self.numbers[index] = [n for n in self.numbers[index] if n.x <= 103] + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + for side, numbers in enumerate(self.numbers): + for index, number in enumerate(numbers): + row, col = 4 * side + index // 10 * 2, index % 10 + for bit in range(4): + state[row, col, bit] = bool(number.value & (1 << bit)) + position = round(number.x + 3) + for bit in range(7): + state[row + (bit >= 2), col, bit + 4 if bit < 2 else bit - 2] = bool(position & (1 << bit)) + values = (self.steps, self.countdown, self.sums[0], self.sums[1], + round(self.lines[0]) + 128, round(self.lines[1]) + 128) + for channel, value in enumerate(values): + for bit in range(9): + state[8, bit, channel] = bool(value & (1 << bit)) + state[9, 0, 0] = self.pressed + return state diff --git a/runtime/minatar_synth/games/orbit_grazer.py b/runtime/minatar_synth/games/orbit_grazer.py new file mode 100644 index 0000000000000000000000000000000000000000..eba1207787f311604bf9d542d8f0afa75f75cf97 --- /dev/null +++ b/runtime/minatar_synth/games/orbit_grazer.py @@ -0,0 +1,115 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Asteroid: + x: float + y: float + vx: float + vy: float + size: float + + +class OrbitGrazerEnvironment: + score_cap = 250 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.y = 75.0, 50.0 + self.radius, self.angle, self.stretch = 25.0, 0.0, 1.0 + self.direction = 1 + self.steps = self.frames = self.shield = 0 + self.pressed = self.terminal = False + self.asteroids: list[Asteroid] = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed: + self.direction *= -1 + self.stretch = 1.6 + self.pressed = pressed + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _spawn(self): + angle = self.random.uniform(0, math.tau) + x, y = 50 + 60 * math.cos(angle), 50 + 60 * math.sin(angle) + target = self.angle + self.direction * self.random.uniform(0.2, 0.6) + dx = 50 + self.radius * math.cos(target) - x + dy = 50 + self.radius * math.sin(target) - y + if math.hypot(x - self.x, y - self.y) > 50: + length = math.hypot(dx, dy) + self.asteroids.append(Asteroid(x, y, 0.5 * dx / length, 0.5 * dy / length, + self.random.uniform(6, 9))) + + def _advance(self): + self.stretch += (1 - self.stretch) * 0.15 + self.angle += 0.5 * self.direction / (self.radius + 0.1) + self.x = 50 + self.radius * math.cos(self.angle) + self.y = 50 + self.radius * math.sin(self.angle) + if self.frames % 50 == 0: + self._spawn() + self.frames += 1 + self.radius = min(40, self.radius + 0.05) + self.shield = max(-1, self.shield - 1) + self.terminal = abs(self.x - 50) < 2 + 3 / self.stretch and abs(self.y - 50) < 2 + 3 * self.stretch + reward = 0 + remaining = [] + shielded_at_start = self.shield > 0 + for asteroid in self.asteroids: + asteroid.x += asteroid.vx + asteroid.y += asteroid.vy + dx, dy = asteroid.x - self.x, asteroid.y - self.y + if self.shield < 0 and math.hypot(dx, dy) < asteroid.size / 2 + 15: + reward += 1 + if abs(dx) < asteroid.size / 2 + 3 / self.stretch and abs(dy) < asteroid.size / 2 + 3 * self.stretch: + if shielded_at_start: + continue + self.radius = max(0, self.radius - 20) + self.shield = 60 + if -10 <= asteroid.x <= 110 and -10 <= asteroid.y <= 110: + remaining.append(asteroid) + self.asteroids = remaining + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[int(self.y // 10), int(self.x // 10), 0] = True + for asteroid in self.asteroids: + for channel, offset in ((1, 0), (2, 12)): + x = asteroid.x + offset * asteroid.vx + y = asteroid.y + offset * asteroid.vy + if 0 <= x < 100 and 0 <= y < 100: + state[int(y // 10), int(x // 10), channel] = True + rows, cols = np.ogrid[5:100:10, 5:100:10] + state[:, :, 3] = abs(np.hypot(cols - 50, rows - 50) - self.radius) < 5 + state[4:6, 4:6, 4] = True + for row, value in enumerate((self.steps, round(self.radius * 10), self.shield + 1, + round(self.angle % math.tau * 80))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.direction > 0 + return state diff --git a/runtime/minatar_synth/games/orbit_man.py b/runtime/minatar_synth/games/orbit_man.py new file mode 100644 index 0000000000000000000000000000000000000000..9055d981122948ecd8c0e335ec897b34c1c4b9dd --- /dev/null +++ b/runtime/minatar_synth/games/orbit_man.py @@ -0,0 +1,122 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Planet: + x: float + y: float + radius: float + + +class OrbitManEnvironment: + score_cap = 120 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.home = Planet(50, 0, 5) + self.planets = [self.home] + self.x, self.y = 50.0, 0.0 + self.angle = math.pi / 2 + self.distance = 20.0 + self.direction = self.multiplier = 1 + self.flight = self.steps = 0 + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _aligned(self): + cosine, sine = math.cos(self.angle), math.sin(self.angle) + aligned = [] + for planet in self.planets: + if planet is self.home or planet.y <= -planet.radius - 4: + continue + dx, dy = planet.x - self.home.x, planet.y - self.home.y + along = dx * cosine + dy * sine + across = -dx * sine + dy * cosine + end = min(99 + self.home.radius * 1.485, max(self.home.radius * 1.485, along)) + if math.hypot(along - end, across) < planet.radius + 2: + aligned.append(planet) + return aligned + + def _advance(self, tap): + self.flight = max(1, self.flight - 1) + scroll = 0.05 + max(0, 80 - self.home.y) * 0.1 / self.flight + self.distance -= scroll + while self.distance < 0: + radius = self.random.uniform(4, 9) + self.planets.append(Planet(self.random.uniform(10 + radius, 90 - radius), self.distance - 30, radius)) + self.distance += radius * self.random.uniform(1, 2) + self.angle += 0.03 * self.direction + for planet in self.planets: + planet.y += scroll + self.planets = [p for p in self.planets if p is self.home or p.y <= 100 + p.radius * 2] + reward = 0 + if tap: + aligned = self._aligned() + if not aligned: + self.terminal = True + return 0 + target = max(aligned, key=lambda p: math.hypot(p.x - self.home.x, p.y - self.home.y)) + destroyed = [self.home, *(p for p in aligned if p is not target)] + self.multiplier = max(1, self.multiplier - 1) + reward = len(destroyed) * (2 * self.multiplier + len(destroyed) - 1) // 2 + self.multiplier += len(destroyed) + self.planets = [p for p in self.planets if all(p is not old for old in destroyed)] + self.home = target + self.angle += math.pi + self.direction *= -1 + self.flight = 20 + self.x += (self.home.x + self.home.radius * math.cos(self.angle) - self.x) * 0.1 + self.y += (self.home.y + self.home.radius * math.sin(self.angle) - self.y) * 0.1 + self.terminal = self.home.y - self.home.radius > 99 + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + if 0 <= self.y < 100: + state[int(self.y // 10), int(self.x // 10), 0] = True + aligned = self._aligned() + for planet in self.planets: + if 0 <= planet.y < 100: + row, col = int(planet.y // 10), int(planet.x // 10) + state[row, col, 1 if planet is self.home else 2] = True + state[row, col, 3] |= planet in aligned + for distance in range(0, 100, 4): + x = self.home.x + distance * math.cos(self.angle) + y = self.home.y + distance * math.sin(self.angle) + if 0 <= x < 100 and 0 <= y < 100: + state[int(y // 10), int(x // 10), 4] = True + values = (self.steps, min(511, self.multiplier), self.flight, round(self.angle % math.tau * 80)) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.direction > 0 + return state diff --git a/runtime/minatar_synth/games/outpost_patrol.py b/runtime/minatar_synth/games/outpost_patrol.py new file mode 100644 index 0000000000000000000000000000000000000000..85ebcb22fd24fd6e332e7e1922df7bbc53900f4d --- /dev/null +++ b/runtime/minatar_synth/games/outpost_patrol.py @@ -0,0 +1,122 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Wave: + angle: float + width: float = 0 + + +def position(angle): + return 50 + 40 * math.cos(angle), 50 + 40 * math.sin(angle) + + +def separation(a, b): + return abs((a - b + math.pi) % math.tau - math.pi) + + +class OutpostPatrolEnvironment: + score_cap = 12 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.angle = self.obstacle_timer = self.bomb_timer = 0.0 + self.jump = self.steps = 0 + self.height = 0.0 + self.obstacles = [] + self.bombs = [] + self.waves: list[Wave] = [] + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap): + self.angle = (self.angle + 0.02) % math.tau + if self.jump or tap: + self.jump += 1 if self.pressed else 2 + if self.jump >= 30: + self.jump = 0 + self.height = 10 * math.sin(self.jump * math.pi / 30) + self.obstacle_timer -= 1 + if self.obstacle_timer < 0: + opposite = self.angle + math.pi + if all(separation(o, opposite) > math.pi * 0.2 for o in self.obstacles): + self.obstacles.append(opposite) + self.obstacle_timer += self.random.uniform(60, 150) + self.obstacles = [o - 0.01 for o in self.obstacles] + self.bomb_timer -= 1 + if self.bomb_timer < 0: + self.bombs.append(self.random.uniform(0, math.tau)) + self.bomb_timer += self.random.uniform(90, 120) + self.bombs = [b - 0.015 for b in self.bombs] + for wave in self.waves: + wave.width += 0.1 + survivors = [o for o in self.obstacles if all( + separation(o, wave.angle) > wave.width / 2 + 0.09 for wave in self.waves + )] + reward = len(self.obstacles) - len(survivors) + self.obstacles = survivors + self.waves = [wave for wave in self.waves if wave.width <= 1] + x, y = position(self.angle) + if not self.jump: + for obstacle in self.obstacles: + ox, oy = position(obstacle) + self.terminal |= abs(x - ox) < 6 and abs(y - oy) < 6 + else: + remaining = [] + for bomb in self.bombs: + bx, by = position(bomb) + if abs(x - bx) < 6.5 and abs(y - self.height - by + 10) < 6.5: + self.waves.append(Wave(bomb)) + else: + remaining.append(bomb) + self.bombs = remaining + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + x, y = position(self.angle) + state[int((y - self.height) // 10), int(x // 10), 0] = True + for channel, angles in ((1, self.obstacles), (2, self.bombs)): + for angle in angles: + x, y = position(angle) + state[int((y - (10 if channel == 2 else 0)) // 10), int(x // 10), channel] = True + for wave in self.waves: + for angle in np.linspace(wave.angle - wave.width / 2, wave.angle + wave.width / 2, 10): + x, y = position(angle) + state[int(y // 10), int(x // 10), 3] = True + rows, cols = np.ogrid[5:100:10, 5:100:10] + state[:, :, 4] = abs(np.hypot(cols - 50, rows - 50) - 40) < 5 + for row, value in enumerate((self.steps, self.jump, round(self.angle * 80))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/p_fit.py b/runtime/minatar_synth/games/p_fit.py new file mode 100644 index 0000000000000000000000000000000000000000..ea5307f230b08b54b62aedfabad0f87c4c742ecb --- /dev/null +++ b/runtime/minatar_synth/games/p_fit.py @@ -0,0 +1,103 @@ +import numpy as np + + +class PFitEnvironment: + score_cap = 2400 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.cursor = 50 + self.steps = self.action = 0 + self.terminal = False + self._new_pair() + + def _new_pair(self): + start = self.random.uniform(22, 32) + heights = start + np.cumsum(self.random.uniform(10, 50, 6) / 6) + self.heights = self.random.permutation(heights) + for _ in range(9): + self.target = self.random.uniform(10, 90) + if abs(self.offset) > 20: + break + self.fixed_y, self.moving_y = 75.0, 225.0 + self.fixed_target, self.moving_target = -25.0, 125.0 + self.match_ticks = 0 + self.points = 300 + + @property + def offset(self): + return (self.cursor - self.target + 60) % 120 - 60 + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.action = action + if self.match_ticks <= 30: + self.cursor = min(99, max(0, self.cursor + 4 * ((self.action == 3) - (self.action == 1)))) + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self): + self.fixed_y += (self.fixed_target - self.fixed_y) * 0.1 + self.moving_y += (self.moving_target - self.moving_y) * 0.1 + if self.match_ticks > 30: + self.match_ticks += 1 + if self.match_ticks == 60: + self._new_pair() + return 0 + self.fixed_target += 0.02 + self.moving_target -= 0.02 + if self.match_ticks < 30 and self._collision(): + self.terminal = True + return 0 + self.match_ticks = self.match_ticks + 1 if abs(self.offset) < 3 else 0 + if self.match_ticks > 30: + self.fixed_target, self.moving_target = 1, 99 + return self.points + self.points = max(0, self.points - 1) + return 0 + + def _collision(self): + for i, height in enumerate(self.heights): + left = 20 * i - 10 + fixed_bottom = self.fixed_y + height + for j, moving_height in enumerate(self.heights): + moving_left = (20 * j - 10 + self.offset + 20) % 120 - 20 + if abs(left - moving_left) < 20 and self.moving_y + moving_height - 99 < fixed_bottom: + return True + return False + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + rows, cols = np.ogrid[5:100:10, 5:100:10] + fixed = self.heights[((cols + 10) // 20) % 6] + moving = self.heights[(((cols - self.offset + 10) % 120) // 20).astype(int)] + state[:, :, 0] = (rows >= self.fixed_y) & (rows < self.fixed_y + fixed) + state[:, :, 1] = (rows <= self.moving_y) & (rows > self.moving_y + moving - 99) + state[:, :, 2] = (rows <= self.moving_y) & (rows > self.moving_y + fixed - 99) + state[9, self.cursor // 10, 3] = True + state[9, int(self.target // 10), 4] = True + values = (self.steps, self.points, self.match_ticks, round((self.offset + 60) * 4)) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/paint_ball.py b/runtime/minatar_synth/games/paint_ball.py new file mode 100644 index 0000000000000000000000000000000000000000..85dfde7b8e9673e3e9710b3269c8a4efaff93c49 --- /dev/null +++ b/runtime/minatar_synth/games/paint_ball.py @@ -0,0 +1,140 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Ball: + x: float + y: float + vx: float + vy: float + color: int + paint: int = 0 + + +class PaintBallEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.grid = np.zeros((15, 12), dtype=np.uint8) + self.offset = 0.0 + self.x, self.y, self.angle = 9.0, 70.0, 0.0 + self.direction = -1 + self.timer = self.steps = 0 + self.multiplier = 1 + self.ready = True + self.pressed = self.terminal = False + self.balls: list[Ball] = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap): + self.offset += 0.03 + if self.offset > 4: + self.offset -= 7 + self.grid[1:] = self.grid[:-1].copy() + self.grid[0] = 0 + if self.ready: + self.y = min(95, self.y + 0.03) + self.angle += self.direction * 0.02 + if self.angle * self.direction > math.pi / 4: + self.direction *= -1 + if tap: + angle = self.angle if self.x < 50 else math.pi - self.angle + self.balls.append(Ball(self.x, self.y, 2 * math.cos(angle), 2 * math.sin(angle), 1)) + self.ready = False + self.multiplier = 1 + self.timer -= 1 + if self.timer < 0: + angle = self.random.uniform(math.pi / 8, math.pi * 7 / 8) + self.balls.append(Ball(self.random.uniform(20, 80), -3, + 0.1 * math.cos(angle), 0.1 * math.sin(angle), 2)) + self.timer = 150 + reward = 0 + remaining = [] + for ball in self.balls: + col = math.floor((ball.x - 8.5) / 7) + row = math.floor((ball.y + 2 - self.offset) / 7) + inside = 0 <= row < 15 and 0 <= col < 12 + tile = self.grid[row, col] if inside else 0 + slow = ball.color == 2 and tile == 1 + ball.paint = ball.paint + 1 if slow else 999 + speed = 0.1 if slow else 1 + ball.x += ball.vx * speed + ball.y += ball.vy * speed + 0.03 + if (ball.x <= 9 and ball.vx < 0) or (ball.x >= 90 and ball.vx > 0): + if ball.color == 1: + self.x, self.y, self.angle = ball.x, ball.y, 0 + self.direction, self.multiplier, self.ready = -1, 1, True + continue + ball.vx *= -1 + self.terminal |= ball.color == 2 and ball.y > 99 + if (ball.y < 3 and ball.vy < 0) or (ball.y > 99 and ball.vy > 0): + ball.vy *= -1 + if inside and (ball.color == 1 or ball.paint > 99): + if ball.color == 1 and tile != 1: + self.multiplier += tile == 2 + reward += self.multiplier + self.grid[row, col] = ball.color + ball.paint = 0 + remaining.append(ball) + player = [b for b in remaining if b.color == 1] + targets = [(b.x, b.y) for b in player] + if self.ready: + targets.append((self.x, self.y)) + self.balls = [] + for ball in remaining: + if ball.color == 2 and any(abs(ball.x - x) < 5 and abs(ball.y - y) < 5 for x, y in targets): + self.multiplier += 1 + reward += self.multiplier + else: + self.balls.append(ball) + if not self.balls: + self.timer = 0 + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + pairs = self.grid.reshape(9, 10, 2) + packed = pairs[:, :, 0] + 3 * pairs[:, :, 1] + for bit in range(4): + state[:9, :, bit] = (packed & (1 << bit)) != 0 + for ball in self.balls: + if 0 <= ball.y < 100 and 0 <= ball.x < 100: + state[int(ball.y // 10), int(ball.x // 10), 3 + ball.color] = True + if self.ready: + state[min(9, max(0, int(self.y // 10))), int(self.x // 10), 4] = True + values = (self.steps, min(511, self.multiplier), round((self.angle + 1) * 100), round((self.offset + 3) * 30)) + for channel, value in enumerate(values): + for bit in range(9): + state[9, bit, channel] = bool(value & (1 << bit)) + state[9, 9, :3] = self.pressed, self.ready, self.direction > 0 + return state diff --git a/runtime/minatar_synth/games/pairs_drop.py b/runtime/minatar_synth/games/pairs_drop.py new file mode 100644 index 0000000000000000000000000000000000000000..1dea8216bb41fde69e3b24af16e790286b83a575 --- /dev/null +++ b/runtime/minatar_synth/games/pairs_drop.py @@ -0,0 +1,139 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Card: + column: int + y: float + rank: int + opened: bool = False + velocity: float = 0 + + +class PairsDropEnvironment: + score_cap = 200 + moves = ((0, 0), (-1, 0), (0, -1), (1, 0), (0, 1), (0, 0)) + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.cards: list[Card] = [] + self.opened: list[Card] = [] + self.column, self.row = 3, 4 + self.scroll = 0.0 + self.next_y, self.next_column = -6.0, 0 + self.timer = self.steps = self.action = 0 + self.multiplier = 1 + self.terminal = False + self._deal() + + def _deal(self): + for rank in self.random.permutation(np.tile(np.arange(1, 14), 2)): + self.cards.append(Card(self.next_column, self.next_y, int(rank))) + self.next_column = (self.next_column + 1) % 7 + if not self.next_column: + self.next_y -= 12 + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + previous = self.action + if self.random.random() >= self.sticky_action_prob: + self.action = action + dx, dy = self.moves[self.action] + self.column = min(6, max(0, self.column + dx)) + self.row = min(9, max(0, self.row + dy)) + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(frame == 0 and self.action == 5 and previous != 5) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _open(self): + for card in self.cards: + if (card.column == self.column and 0 <= card.y < 100 + and int(card.y // 10) == self.row and not card.opened and not card.velocity): + if self.timer: + self._close() + card.opened = True + self.opened.append(card) + if len(self.opened) == 2: + first, second = self.opened + self.timer = 60 + if first.rank == second.rank: + for other in self.cards: + if any(other.column == match.column and other.y >= match.y for match in self.opened): + other.velocity = 1 + self.opened = [] + self.multiplier = 1 + return True + return False + + def _close(self): + for card in self.opened: + card.opened = False + self.opened.clear() + self.timer = 0 + + def _advance(self, tap): + if self.timer: + self.timer -= 1 + if not self.timer: + self._close() + opened = tap and self._open() + reward = 0 + remaining = [] + min_y, max_y = 99, 0 + for card in self.cards: + card.y += self.scroll + card.velocity + if card.velocity: + card.velocity += 0.1 + min_y, max_y = min(min_y, card.y), max(max_y, card.y) + if not card.velocity and card.y > 95: + self.terminal = True + if card.y > 99: + reward += self.multiplier + self.multiplier += 1 + else: + remaining.append(card) + self.cards = remaining + self.next_y += self.scroll + self.scroll += (0.0015 - self.scroll) * 0.2 + 0.15 * opened + self.scroll += max(0, 50 - max_y) * 0.01 + if min_y > -6: + self._deal() + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + for card in self.cards: + if 0 <= card.y < 100: + row, col = int(card.y // 10), card.column + state[row, col, 4] = True + state[row, col, 5] |= card.velocity > 0 + if card.opened: + for bit in range(4): + state[row, col, bit] |= bool(card.rank & (1 << bit)) + state[self.row, 7, 0] = True + state[self.column, 7, 1] = True + values = (self.steps, self.timer, min(511, self.multiplier), self.action) + for channel, value in enumerate(values): + for bit in range(9): + state[bit, 8, channel] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/paku_paku.py b/runtime/minatar_synth/games/paku_paku.py new file mode 100644 index 0000000000000000000000000000000000000000..8cc60369da60f22aaf47653ba6a98fe204c65a0f --- /dev/null +++ b/runtime/minatar_synth/games/paku_paku.py @@ -0,0 +1,107 @@ +import numpy as np + + +TRACK_LENGTH = 16 +WAVES = 4 + + +class PakuPakuEnvironment: + # Each wave can raise the multiplier once through a ghost capture. + score_cap = float(sum(16 * (3 + 2 * wave) + 10 * (2 + 2 * wave) for wave in range(WAVES))) + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 500): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.default_rng(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.player = 6 + self.ghost = 15 + self.direction = 1 + self.eyes = 0 + self.power = 0 + self.steps = 0 + self.wave = 0 + self.multiplier = 1 + self.last_action = 0 + self.terminal = False + self._refill() + + def _refill(self) -> None: + self.pellets = set(range(TRACK_LENGTH)) + self.power_cell = int(self.random.integers(1, 6) if self.player >= 8 else self.random.integers(10, 15)) + self.multiplier += 1 + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + if action == 5 and self.last_action != 5: + self.direction *= -1 + elif action in (1, 3): + self.direction = -1 if action == 1 else 1 + self.last_action = action + self.steps += 1 + previous_player = self.player + previous_ghost = self.ghost + self.player = (self.player + self.direction) % TRACK_LENGTH + reward = 0 + if self.player in self.pellets: + self.pellets.remove(self.player) + reward += self.multiplier + if self.player == self.power_cell and not self.eyes: + self.power = 16 + returning = bool(self.eyes) + if returning: + self.ghost += self.eyes + if self.ghost in (0, TRACK_LENGTH - 1): + self.eyes = 0 + else: + interval = 3 if self.power else max(1, 3 - self.wave) + if self.steps % interval == 0: + direction = 1 if self.player > self.ghost else -1 + if self.power: + direction *= -1 + self.ghost = max(0, min(TRACK_LENGTH - 1, self.ghost + direction)) + crossed = self.player == previous_ghost and self.ghost == previous_player + if not returning and (self.player == self.ghost or crossed): + if self.power: + reward += 10 * self.multiplier + self.multiplier += 1 + self.power = 0 + self.eyes = -1 if self.ghost >= 8 else 1 + else: + self.terminal = True + self.power = max(0, self.power - 1) + if not self.terminal and not self.pellets: + self.wave += 1 + if self.wave == WAVES: + self.terminal = True + else: + self.power = 0 + self._refill() + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def state(self) -> np.ndarray: + observation = np.zeros((10, 10, 6), dtype=bool) + observation[self.player // 8, self.player % 8, 0] = True + ghost_channel = 3 if self.eyes or self.power else 1 + observation[self.ghost // 8, self.ghost % 8, ghost_channel] = True + for pellet in self.pellets: + observation[pellet // 8, pellet % 8, 3 if pellet == self.power_cell else 2] = True + next_cell = (self.player + self.direction) % TRACK_LENGTH + observation[next_cell // 8, next_cell % 8, 4] = True + for row, value in enumerate((self.power, self.wave, self.multiplier, self.steps, self.eyes + 1, self.last_action), start=2): + for bit in range(10): + observation[row, bit, 5] = bool(value & (1 << bit)) + return observation diff --git a/runtime/minatar_synth/games/parking.py b/runtime/minatar_synth/games/parking.py new file mode 100644 index 0000000000000000000000000000000000000000..c50ebf0ec80e095a4f65353187ed1440d4c0584c --- /dev/null +++ b/runtime/minatar_synth/games/parking.py @@ -0,0 +1,124 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Car: + x: float + y: float + + +class ParkingEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.cars: list[Car] = [] + self.parked: list[Car] = [] + self.angle = -math.pi / 2 + self.car_timer = self.parked_distance = self.road = 0.0 + self.capacity = 1.0 + self.gold: Car | None = None + self.multiplier = 1 + self.steps = 0 + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.pressed = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self): + scroll = 1.05 + if self.cars: + scroll += max(0, 50 - self.cars[0].y) * 0.1 + else: + self.car_timer -= 1 + self.road += scroll + if self.gold is None: + self.gold = Car(self.random.uniform(40, 70), self.random.uniform(-50, -20)) + self.gold.y += scroll + if self.gold.y > 103: + self.gold = None + self.multiplier = max(1, self.multiplier - 1) + self.parked_distance -= scroll + if self.parked_distance < 0: + self.parked.append(Car(self.random.uniform(80, 84), -5)) + self.parked_distance = (self.random.uniform(8, 12) if self.random.random() < 0.7 + else self.random.uniform(100, 200)) + for car in self.parked: + car.y += scroll + self.parked = [car for car in self.parked if car.y <= 105] + self.car_timer -= scroll - 1 + if len(self.cars) < self.capacity and self.car_timer < 0: + self.cars.append(Car(self.random.uniform(20, 60), -5)) + self.car_timer = 15 + self.angle = min(0, max(-math.pi / 2, self.angle + (0.1 if self.pressed else -0.1))) + reward = 0 + remaining = [] + for car in self.cars: + heading = -math.pi / 2 if car.y < 3 else self.angle + car.x += math.cos(heading) + car.y += scroll + math.sin(heading) + occupied = (*self.parked, *remaining) + if any(abs(car.x - other.x) < 4 and abs(car.y - other.y) < 4 for other in occupied): + self.terminal = True + break + if car.x + 2 > 82 and self._parking_strip(car.y): + reward += self.multiplier * 10 + self.parked.append(car) + self.capacity += 1 / self.capacity + continue + if self.gold is not None and abs(car.x - self.gold.x) < 6 and abs(car.y - self.gold.y) < 6: + if self.gold.y > -3: + reward += self.multiplier + self.multiplier += 1 + self.gold = None + if car.y > 103: + self.terminal = True + break + remaining.append(car) + self.cars = remaining + return reward + + def _parking_strip(self, y): + return any(start - 2 < y < start + 92 for start in (self.road % 93 + 6, self.road % 93 - 88)) + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + for channel, cars in ((0, self.cars), (1, self.parked), (2, [self.gold] if self.gold else [])): + for car in cars: + if 0 <= car.x < 100 and 0 <= car.y < 100: + state[int(car.y // 10), int(car.x // 10), channel] = True + for row in range(10): + state[row, 8, 3] = self._parking_strip(10 * row + 5) + state[:, (0, 9), 4] = True + values = (self.steps, self.multiplier, round(-self.angle * 100), round(self.capacity * 20)) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(min(511, value) & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/periscope_ping.py b/runtime/minatar_synth/games/periscope_ping.py new file mode 100644 index 0000000000000000000000000000000000000000..53c84a7c27a5176d2f783b0543fed677339f3a29 --- /dev/null +++ b/runtime/minatar_synth/games/periscope_ping.py @@ -0,0 +1,120 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Contact: + x: float + y: float + heading: float + triangle: bool = False + visible: bool = False + + def move(self, speed: float) -> None: + self.x += math.cos(self.heading) * speed + self.y += math.sin(self.heading) * speed + + +class PeriscopePingEnvironment: + score_cap = 350 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.angle = self.radius = 0.0 + self.direction = 1 + self.steps = self.timer = 0 + self.pressed = self.terminal = False + self.targets: list[Contact] = [] + self.shots: list[Contact] = [] + + @property + def scope(self): + return 50 + 10 * math.cos(self.angle), 50 + 10 * math.sin(self.angle) + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap): + self.angle = (self.angle + 0.04 * self.direction) % math.tau + sx, sy = self.scope + if tap: + self.radius = 0 + self.direction *= -1 + self.shots.append(Contact(sx, sy, self.angle)) + if self.pressed: + self.radius += 1 + for shot in self.shots: + shot.move(1) + self.shots = [shot for shot in self.shots if math.hypot(shot.x - 50, shot.y - 50) <= 50] + reward = 0 + remaining = [] + for target in self.targets: + target.move(0.1) + distance = math.hypot(target.x - 50, target.y - 50) + if distance < 5: + continue + extent = 2.5 if target.triangle else 3 + if any(abs(shot.x - target.x) < extent + 1.5 and abs(shot.y - target.y) < extent + 1.5 + for shot in self.shots): + reward += int(distance) + continue + scope_hit = abs(target.x - sx) < extent + 1.5 and abs(target.y - sy) < extent + 1.5 + tower_hit = abs(target.x - 50) < extent + 5 and abs(target.y - 50) < extent + 5 + sonar_hit = self.pressed and abs(math.hypot(target.x - sx, target.y - sy) - self.radius) < extent + 2.5 + target.visible = scope_hit or tower_hit or sonar_hit + self.terminal |= scope_hit or tower_hit + remaining.append(target) + self.targets = remaining + self.timer += 1 + if not self.targets or self.timer >= 200: + self.timer = 0 + angle = self.random.uniform(0, math.tau) + triangle = bool(self.random.integers(2)) + heading = angle + math.pi + self.random.uniform(-0.5, 0.5) + self.targets.append(Contact(50 + 50 * math.cos(angle), 50 + 50 * math.sin(angle), heading, triangle)) + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + sx, sy = self.scope + state[int(sy // 10), int(sx // 10), 0] = True + for target in self.targets: + if target.visible and 0 <= target.x < 100 and 0 <= target.y < 100: + state[int(target.y // 10), int(target.x // 10), 1 + target.triangle] = True + for shot in self.shots: + if 0 <= shot.x < 100 and 0 <= shot.y < 100: + state[int(shot.y // 10), int(shot.x // 10), 3] = True + if self.pressed: + rows, cols = np.ogrid[5:100:10, 5:100:10] + state[:, :, 4] = abs(np.hypot(cols - sx, rows - sy) - self.radius) < 5 + for row, value in enumerate((self.steps, round(self.angle * 80), min(511, int(self.radius)))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.direction > 0 + return state diff --git a/runtime/minatar_synth/games/phaserun.py b/runtime/minatar_synth/games/phaserun.py new file mode 100644 index 0000000000000000000000000000000000000000..dd28b4d20a228f2a3f147aac1233b472e2deadd9 --- /dev/null +++ b/runtime/minatar_synth/games/phaserun.py @@ -0,0 +1,113 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Coin: + x: float + phase: float = 0 + + @property + def y(self): + return 50 + 3 * math.sin(self.phase) + + +class PhaserunEnvironment: + score_cap = 5000 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.size = self.target_size = 8.0 + self.scale_x = 1.0 + self.animation = self.steps = self.frames = 0 + self.obstacle_timer, self.coin_timer = 60, 0 + self.solid = True + self.pressed = self.terminal = False + self.obstacles: list[float] = [] + self.coins: list[Coin] = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed: + self.solid = not self.solid + self.scale_x = 1.3 + self.animation = 10 + self.pressed = pressed + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self): + self.frames += 1 + if self.animation: + self.animation -= 1 + self.scale_x += (1 - self.scale_x) * 0.3 + else: + self.scale_x = 1 + math.sin(self.frames * 0.08) * 0.03 + self.obstacle_timer -= 1 + if self.obstacle_timer <= 0: + self.obstacles.append(105) + self.obstacle_timer = int(self.random.integers(88, 111)) + self.coin_timer -= 1 + if self.coin_timer <= 0: + self.coins.append(Coin(105, self.random.uniform(0, math.tau))) + self.coin_timer = int(self.random.integers(11, 77)) + self.target_size += 3 if self.pressed else (8 - self.target_size) * 0.5 + self.size += (self.target_size - self.size) * 0.3 + half_width = self.size * self.scale_x / 2 + half_height = self.size * (2 - self.scale_x) / 2 + reward = 0 + remaining = [] + for coin in self.coins: + coin.x -= 1 + coin.phase += 0.15 + if self.solid and abs(coin.x - 20) < half_width + 3 and abs(coin.y - 50) < half_height + 3: + reward += math.ceil(self.size) + elif coin.x >= -10: + remaining.append(coin) + self.coins = remaining + self.obstacles = [x - 1 for x in self.obstacles if x - 1 >= -10] + self.terminal = self.solid and any(abs(x - 20) < half_width + 5 for x in self.obstacles) + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + rows, cols = np.ogrid[5:100:10, 5:100:10] + state[:, :, 0 if self.solid else 1] = ( + (abs(cols - 20) <= max(5, self.size * self.scale_x / 2)) + & (abs(rows - 50) <= max(5, self.size * (2 - self.scale_x) / 2)) + ) + for x in self.obstacles: + if 0 <= x < 100: + state[5, int(x // 10), 2] = True + for coin in self.coins: + if 0 <= coin.x < 100: + state[int(coin.y // 10), int(coin.x // 10), 3] = True + state[5, :, 4] = True + for row, value in enumerate((self.steps, round(self.size), round(self.target_size), self.animation)): + for bit in range(13): + gauge_row, col = 2 * row + bit // 10, bit % 10 + state[gauge_row, col, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/phoenix.py b/runtime/minatar_synth/games/phoenix.py new file mode 100644 index 0000000000000000000000000000000000000000..183f2c2f738b8e0a329d5211b024c09727b24909 --- /dev/null +++ b/runtime/minatar_synth/games/phoenix.py @@ -0,0 +1,275 @@ +import numpy as np + + +class PhoenixEnvironment: + """Three five-stage Phoenix cycles with shield and layered mothership.""" + + score_cap = 30_720.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 4_000): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.cycle = 0 + self.stage = 0 + self.lives = 5 + self.score = 0.0 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self._start_stage() + + def _start_stage(self) -> None: + self.player_column = 5 + self.previous_player_column = 5 + self.shield_timer = 0 + self.shield_cooldown = 0 + self.shot: list[int] | None = None + self.previous_shot: list[int] | None = None + self.bombs: list[list[int]] = [] + self.previous_bombs: list[list[int]] = [] + self.stage_steps = 0 + if self.stage < 2: + self.enemies = [ + {"id": index, "position": [1 + index // 4, 1 + (index % 4) * 2], "direction": 1 if index % 2 == 0 else -1} + for index in range(8) + ] + self.wing_rewarded: set[int] = set() + elif self.stage < 4: + self.enemies = [ + {"id": index, "position": [1 + index // 2, 2 + (index % 2) * 5], "direction": 1 if index % 2 == 0 else -1} + for index in range(4) + ] + self.wing_rewarded = set() + else: + self.enemies = [] + self.hull_health = [0, 0, 2, 2, 2, 2, 2, 2, 0, 0] + self.rotating_hole = 2 + self.rotating_direction = 1 + self.mothership_shots = 0 + self.previous_enemies = {int(enemy["id"]): list(enemy["position"]) for enemy in self.enemies} + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player_column = self.player_column + self.previous_shot = None if self.shot is None else self.shot.copy() + self.previous_bombs = [bomb.copy() for bomb in self.bombs] + self.previous_enemies = {int(enemy["id"]): list(enemy["position"]) for enemy in self.enemies} + if self.shield_timer == 0: + if action == 1: + self.player_column = max(0, self.player_column - 1) + elif action == 3: + self.player_column = min(9, self.player_column + 1) + elif action == 4 and self.shield_cooldown == 0: + self.shield_timer = 3 + self.shield_cooldown = 10 + if action == 5 and self.shot is None: + self.shot = [7, self.player_column] + stage_before = (self.cycle, self.stage) + reward = self._move_shot() + if (self.cycle, self.stage) == stage_before and not self.terminal: + if self.stage < 4: + self._move_birds() + else: + self._move_mothership() + self._move_bombs() + reward += self._resolve_collisions() + self.score += reward + self.steps += 1 + self.stage_steps += 1 + self.shield_timer = max(0, self.shield_timer - 1) + self.shield_cooldown = max(0, self.shield_cooldown - 1) + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _move_shot(self) -> float: + if self.shot is None: + return 0.0 + self.shot[0] -= 1 + if self.stage < 2: + for enemy in list(self.enemies): + if self.shot == enemy["position"]: + reward = 80.0 if enemy["position"][0] >= 5 else 20.0 + self.enemies.remove(enemy) + self.shot = None + self._advance_if_clear() + return reward + elif self.stage < 4: + for enemy in list(self.enemies): + row, column = enemy["position"] + if self.shot[0] != row: + continue + if self.shot[1] == column: + reward = float(100 + min(4, row - 1) * 100) + self.enemies.remove(enemy) + self.shot = None + self._advance_if_clear() + return reward + if abs(self.shot[1] - column) == 1: + reward = 0.0 + if enemy["id"] not in self.wing_rewarded: + self.wing_rewarded.add(enemy["id"]) + reward = 20.0 + self.shot = None + return reward + else: + self.mothership_shots += 1 + row, column = self.shot + if row == 2 and self.hull_health[column] > 0: + self.hull_health[column] -= 1 + self.shot = None + return 0.0 + if row == 1 and column == 5 and self.hull_health[5] == 0 and self.rotating_hole == 5: + maximum = 4_000 + self.cycle * 1_000 + reward = float(max(1_000, maximum - max(0, self.mothership_shots - 1) * 100)) + self.shot = None + self._advance_stage() + return reward + if self.shot is not None and self.shot[0] < 0: + self.shot = None + return 0.0 + + def _move_birds(self) -> None: + for enemy in self.enemies: + row, column = enemy["position"] + if self.stage_steps % max(1, 3 - self.cycle) == 0: + column += enemy["direction"] + if column <= 0 or column >= 9: + enemy["direction"] *= -1 + column = min(9, max(0, column)) + row = min(7, row + 1) + enemy["position"] = [row, column] + if (self.stage_steps + enemy["id"]) % max(5, 12 - self.cycle * 2) == 0: + self.bombs.append([row + 1, column]) + + def _move_mothership(self) -> None: + if self.stage_steps % 2 == 0: + self.rotating_hole += self.rotating_direction + if self.rotating_hole in (2, 7): + self.rotating_direction *= -1 + interval = max(3, 8 - self.cycle * 2) + if self.stage_steps % interval == 0: + self.bombs.append([2, int(self.random.randint(2, 8))]) + + def _move_bombs(self) -> None: + for bomb in list(self.bombs): + bomb[0] += 1 + if bomb[0] > 8: + self.bombs.remove(bomb) + + def _resolve_collisions(self) -> float: + reward = 0.0 + for enemy in list(self.enemies): + if enemy["position"] != [8, self.player_column]: + continue + if self.shield_timer: + reward += self._shield_bird_value(enemy) + self.enemies.remove(enemy) + self._advance_if_clear() + else: + self._lose_life() + break + for bomb in list(self.bombs): + if bomb != [8, self.player_column]: + continue + self.bombs.remove(bomb) + if not self.shield_timer: + self._lose_life() + break + return reward + + def _shield_bird_value(self, enemy: dict[str, object]) -> float: + if self.stage < 2: + return 80.0 + return 500.0 + + def _advance_if_clear(self) -> None: + if not self.enemies: + self._advance_stage() + + def _advance_stage(self) -> None: + self.stage += 1 + if self.stage >= 5: + self.stage = 0 + self.cycle += 1 + if self.cycle >= 3: + self.terminal = True + else: + self._start_stage() + + def _lose_life(self) -> None: + self.lives -= 1 + if self.lives <= 0: + self.terminal = True + else: + self.player_column = 5 + self.shield_timer = 0 + self.shield_cooldown = 0 + self.shot = None + self.bombs.clear() + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[8, self.player_column, 0] = True + state[8, self.previous_player_column, 4] = True + for enemy in self.enemies: + row, column = enemy["position"] + state[row, column, 1] = True + state[*self.previous_enemies[int(enemy["id"])], 4] = True + if self.stage >= 2: + state[row, max(0, column - 1) : min(10, column + 2), 1] = True + if enemy["id"] in self.wing_rewarded: + state[row, column, 3] = True + for bomb in self.bombs: + state[*bomb, 1] = True + for bomb in self.previous_bombs: + state[*bomb, 4] = True + if self.shot is not None: + state[*self.shot, 2] = True + if self.previous_shot is not None: + state[*self.previous_shot, 4] = True + if self.stage == 4: + for column in range(2, 8): + if self.hull_health[column]: + state[2, column, 3] = True + state[1, 5, 1] = True + state[3, self.rotating_hole, 3] = True + if self.shield_timer: + state[7:10, max(0, self.player_column - 1) : min(10, self.player_column + 2), 3] = True + state[9, : self.lives, 2] = True + for bit in range(2): + state[0, bit, 5] = bool(self.cycle & (1 << bit)) + for bit in range(3): + state[0, 2 + bit, 5] = bool(self.stage & (1 << bit)) + state[0, 5 + bit, 5] = bool(self.lives & (1 << bit)) + for bit in range(4): + state[1, bit, 5] = bool(self.shield_cooldown & (1 << bit)) + state[1, 4 + bit, 5] = bool(self.shield_timer & (1 << bit)) + for index in self.wing_rewarded: + state[2, index, 5] = True + for bit in range(12): + state[3 + bit // 10, bit % 10, 5] = bool(self.steps & (1 << bit)) + state[5 + bit // 10, bit % 10, 5] = bool(self.stage_steps & (1 << bit)) + if self.stage == 4: + for column in range(2, 8): + for bit in range(2): + state[7 + bit, column, 5] = bool(self.hull_health[column] & (1 << bit)) + state[9, self.rotating_hole, 5] = True + state[9, 8, 5] = self.rotating_direction > 0 + return state diff --git a/runtime/minatar_synth/games/photon_line.py b/runtime/minatar_synth/games/photon_line.py new file mode 100644 index 0000000000000000000000000000000000000000..62c410cafb7a48b1829caa863604143b1a4da1fc --- /dev/null +++ b/runtime/minatar_synth/games/photon_line.py @@ -0,0 +1,176 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Photon: + x: float + direction: int + color: int + reflected: bool = False + + +class PhotonLineEnvironment: + score_cap = 200 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.angle = self.turn_target = 0.0 + self.rotating = self.pressed = self.terminal = False + self.hands = [[0], [1]] + self.target = [[0], [1]] + self.photons: list[Photon] = [] + self.world, self.stage, self.colors = 1, 0, 2 + self.steps = self.transition = 0 + self._next_stage() + + def _next_stage(self): + if self.stage >= min(5, self.world + 1): + self.world += 1 + self.stage = 0 + self.colors = min(4, int(self.random.integers(2, self.world + 2))) + self.target = [[int(self.random.integers(self.colors))] for _ in range(2)] + self.hands = [hand.copy() for hand in self.target] + previous = [hand.copy() for hand in self.target] + self.target = [hand[:4] for hand in self.target] + ratio = 3 / self.colors + additions = round(self.random.uniform(1, self.world) * ratio) + removals = round(min(2, max(0, self.random.uniform(0, self.world) - 1)) * ratio) + if additions == removals: + removals -= 1 + for _ in range(removals): + hand = self.target[self.random.integers(2)] + if hand: + hand.pop() + for _ in range(additions + removals): + self.target[self.random.integers(2)].append(int(self.random.integers(self.colors))) + self.target = [hand[:5] for hand in self.target] + if self.target == previous: + hand = next((h for h in self.target if h), self.target[0]) + if hand: + hand[-1] = (hand[-1] + 1) % self.colors + else: + hand.append(0) + self.stage += 1 + self.timer, self.width = 60.0, 30.0 + self.bag = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap): + reward = 0 + if self.transition: + self.transition -= 1 + if self.width > -3: + reward = self.world + self.width -= 1 + if not self.transition: + self._next_stage() + else: + self.timer -= 1 + if self.timer < 0: + if not self.bag: + self.bag = self.random.permutation(list(range(self.colors)) * 2 + + [4] * math.ceil(self.colors * 0.4)).tolist() + direction = 1 if self.random.random() < 0.5 else -1 + self.photons.append(Photon(self.width if direction == 1 else 200 - self.width, + direction, self.bag.pop())) + self.timer = self.random.uniform(60, 90) + self._move_photons() + if tap and not self.rotating and not self.transition: + self.rotating = True + self.turn_target += math.pi + if self.rotating: + self.angle += 0.2 + if self.angle >= self.turn_target: + if self.pressed: + self.turn_target += math.pi + else: + self.angle = self.turn_target + self.rotating = False + if self.angle >= math.tau: + self.angle -= math.tau + self.turn_target -= math.tau + self.width -= 0.02 + self.terminal = not self.transition and self.width < -3 + return reward + + def _move_photons(self): + remaining = [] + swapped = math.pi / 2 <= self.angle <= 3 * math.pi / 2 + for photon in self.photons: + direction = photon.direction + photon.x += direction * (-2 if photon.reflected else 0.4) + if photon.reflected: + if self.width <= photon.x <= 200 - self.width: + remaining.append(photon) + continue + hand = self.hands[(direction < 0) ^ swapped] + edge = 100 - (7 * len(hand) + 6) * direction + if (photon.x - edge) * direction <= 0: + remaining.append(photon) + elif self.rotating: + photon.reflected = True + remaining.append(photon) + else: + if photon.color == 4: + if hand: + hand.pop() + else: + hand.append(photon.color) + if len(hand) > 9: + self.width /= 2 + direct = self.hands == self.target + reverse = self.hands[::-1] == self.target + if direct or reverse: + if (direct and swapped) or (not direct and reverse and not swapped): + self.rotating = True + self.turn_target += math.pi + self.transition = 60 + self.photons = [] + return + self.photons = remaining + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + for row, hand in enumerate((*self.target, *self.hands)): + for col, color in enumerate(hand[:10]): + state[row, col, color] = True + for photon in self.photons: + col = min(9, max(0, int(photon.x // 20))) + row = 4 + 2 * (photon.direction < 0) + photon.reflected + state[row, col, photon.color] = True + values = (self.steps, round(self.angle * 80), self.world, self.stage, + self.transition, round((self.width + 4) * 10)) + for channel, value in enumerate(values): + for bit in range(9): + state[8, bit, channel] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.rotating + return state diff --git a/runtime/minatar_synth/games/pileup.py b/runtime/minatar_synth/games/pileup.py new file mode 100644 index 0000000000000000000000000000000000000000..28426bc0587aa5b8a80d00f33b552150ad611c93 --- /dev/null +++ b/runtime/minatar_synth/games/pileup.py @@ -0,0 +1,103 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Block: + x: float + y: float + fixed: bool = False + + +class PileupEnvironment: + score_cap = 2500 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.y = 50.0, 80.0 + self.board: Block | None = None + self.board_speed = 0.0 + self.blocks: list[Block] = [] + self.timer = self.steps = self.action = 0 + self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.action = action + self.steps += 1 + reward = 0.0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return reward, self.terminal + + def _board_hits(self, x, y): + return self.board is not None and abs(self.board.x - x) < 13.5 and abs(self.board.y - y) < 6 + + def _advance(self): + reward = 0.0 + if self.board is None: + self.board = Block(self.random.uniform(0, 99), 0) + self.board_speed = 0.0 + else: + self.board_speed += 0.1 + self.board.y += self.board_speed + if self.board.y > 99: + self.board = None + reward = 99 - self.y + y = 80 + remaining = [] + for block in self.blocks: + if block.fixed: + y = min(y, block.y - 9) + else: + block.y += 1 + block.fixed = block.y + 3.5 > 95 or any( + other.fixed and abs(block.x - other.x) < 7 and abs(block.y - other.y) < 7 + for other in remaining + ) + if not self._board_hits(block.x, block.y): + remaining.append(block) + self.blocks = remaining + movement = (self.action == 3) - (self.action == 1) + self.x = min(99, max(0, self.x + 2 * movement)) + self.y = y + self.terminal = y < 0 or self._board_hits(self.x, y) + self.timer -= 1 + if self.timer < 0: + self.blocks.append(Block(self.x, y)) + self.timer += 10 + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, max(0, int(self.y // 10))), int(self.x // 10), 0] = True + for block in self.blocks: + if 0 <= block.y < 100: + state[int(block.y // 10), int(block.x // 10), 1 if block.fixed else 2] = True + if self.board is not None: + left = max(0, int((self.board.x - 10) // 10)) + right = min(9, int((self.board.x + 10) // 10)) + state[int(self.board.y // 10), left:right + 1, 3] = True + state[9, :, 4] = True + for row, value in enumerate((self.steps, self.timer, round(self.board_speed * 100), round(self.x * 4))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/pillars_3d.py b/runtime/minatar_synth/games/pillars_3d.py new file mode 100644 index 0000000000000000000000000000000000000000..df072effc1516b173b662192d9f9215af51e1c68 --- /dev/null +++ b/runtime/minatar_synth/games/pillars_3d.py @@ -0,0 +1,110 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Pillar: + x: float + depth: float + width: float + height: float + bonus: bool = False + + def bounds(self): + x = 50 + self.x / self.depth + half_width = self.width / (2 * self.depth) + return (x - half_width, x + half_width, + 60 - self.height / (6 * self.depth), 60 + 5 * self.height / (6 * self.depth)) + + +class Pillars3dEnvironment: + score_cap = 250 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.y, self.vy = 50.0, 10.0, 0.0 + self.pillars = [Pillar(0, 20, 100, 100, True)] + self.timer = self.bonus_timer = 9 + self.steps = self.action = 0 + self.multiplier = 1 + self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.action = action + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self): + self.timer -= 1 + if self.timer < 0: + self.bonus_timer -= 1 + bonus = self.bonus_timer < 0 + x = self.random.uniform(60, 160) * self.random.choice((-1, 1)) + self.pillars.append(Pillar(x, 20, self.random.uniform(50, 100), + self.random.uniform(70, 180), bonus)) + self.timer = 20 + if bonus: + self.bonus_timer = 9 + self.x = min(93, max(6, self.x + 1.5 * ((self.action == 3) - (self.action == 1)))) + self.y += self.vy + self.vy += 0.1 + if self.y > 95: + self.terminal = True + return 0 + reward = 0 + remaining = [] + collision_y = self.y + for pillar in self.pillars: + left, right, top, bottom = pillar.bounds() + if left < self.x + 3 and right > self.x - 5 and top < collision_y + 3 and bottom > collision_y - 3: + if self.vy > 0: + self.vy = -2.5 + self.y = min(self.y, top) + reward += self.multiplier + self.multiplier += int(pillar.bonus) + else: + pillar.depth -= 0.2 + if pillar.depth > 1: + remaining.append(pillar) + self.pillars = remaining + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + col = int(self.x // 10) + state[min(9, max(0, int(self.y // 10))), col, 0] = True + rows, cols = np.ogrid[5:100:10, 5:100:10] + for pillar in self.pillars: + left, right, top, bottom = pillar.bounds() + visible = ((cols + 5 > left) & (cols - 5 < right) & + (rows + 5 > top) & (rows - 5 < bottom)) + state[:, :, 2 if pillar.bonus else 1] |= visible + state[:, :, 3] |= visible & (pillar.depth < 6) + state[min(9, max(0, int((self.y + 4 * self.vy) // 10))), col, 4] = True + values = (self.steps, self.multiplier, round(self.x * 4), round((self.vy + 4) * 40), self.action) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(min(511, max(0, value)) & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/pin_climb.py b/runtime/minatar_synth/games/pin_climb.py new file mode 100644 index 0000000000000000000000000000000000000000..4c998947906c7f5dc95bc827e0f8138cd6d7ec97 --- /dev/null +++ b/runtime/minatar_synth/games/pin_climb.py @@ -0,0 +1,102 @@ +from math import ceil, cos, hypot, pi, sin + +import numpy as np + + +HORIZON = 400 +UNIT = 8 +EDGE = 10 * UNIT +REST_LENGTH = 6 +ANGLE_COUNT = 32 +PIN_RADIUS = 2 + + +class PinClimbEnvironment: + score_cap = HORIZON * ceil(hypot(EDGE - 1, EDGE - 1)) + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = HORIZON): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, HORIZON) + self.seed(0) + self.reset() + + def seed(self, seed: int) -> None: + self.random = np.random.default_rng(seed) + + def reset(self) -> None: + self.steps = self.angle = self.last_action = self.scroll = 0 + self.length = REST_LENGTH + self.anchor = (40, 4) + self.pins = [self.anchor] + self.next_pin = 4 + self.terminal = False + + @classmethod + def normalize_score(cls, score: float) -> float: + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def _catch(self) -> float: + angle = self.angle * 2 * pi / ANGLE_COUNT + horizontal, vertical = cos(angle), sin(angle) + x, y = self.anchor + target = None + for pin in self.pins: + if pin == self.anchor: + continue + dx, dy = pin[0] - x, pin[1] - y + along = dx * horizontal + dy * vertical + across = dx * vertical - dy * horizontal + if 0 < along <= self.length and abs(across) <= PIN_RADIUS: + target = pin + if target is None: + return 0.0 + self.anchor = target + self.length = REST_LENGTH + return float(ceil(hypot(target[0] - x, target[1] - y))) + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.random() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.steps += 1 + self.angle = (self.angle + (2 if self.steps >= 200 else 1)) % ANGLE_COUNT + if action == 5: + self.length = min(EDGE * 2, self.length + 2) + else: + self.length -= (self.length - REST_LENGTH + 3) // 4 + advance = max(1, (64 - self.anchor[1]) // 8) + self.scroll += advance + x, y = self.anchor + self.anchor = x, y + advance + self.pins = [(x, y + advance) for x, y in self.pins if y + advance < EDGE] + while self.next_pin <= self.scroll: + pin = int(self.random.integers(UNIT, EDGE - UNIT)), self.scroll - self.next_pin + self.pins.append(pin) + self.next_pin += int(self.random.integers(4, 13)) + if self.anchor[1] >= EDGE: + self.terminal = True + return 0.0, True + reward = self._catch() + self.terminal = self.steps >= self.horizon + return reward, self.terminal + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + x, y = self.anchor + state[min(9, y // UNIT), x // UNIT, 0] = True + for px, py in self.pins: + state[py // UNIT, px // UNIT, 2] = True + angle = self.angle * 2 * pi / ANGLE_COUNT + for distance in range(self.length + 1): + px = round(x + cos(angle) * distance) + py = round(y + sin(angle) * distance) + if 0 <= px < EDGE and 0 <= py < EDGE: + state[py // UNIT, px // UNIT, 3] = True + values = (self.steps, self.angle, self.length, self.next_pin - self.scroll, + int(self.last_action == 5), x, y) + for row, value in enumerate(values): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/pitfall.py b/runtime/minatar_synth/games/pitfall.py new file mode 100644 index 0000000000000000000000000000000000000000..e3358d056634ea310e226da3eb26cb258eef69d6 --- /dev/null +++ b/runtime/minatar_synth/games/pitfall.py @@ -0,0 +1,224 @@ +import numpy as np + + +TREASURE_VALUES = (2_000, 3_000, 4_000, 5_000) +TREASURE_SCENES = tuple(range(16)) + tuple(range(32, 48)) + + +class PitfallEnvironment: + """Mapped surface-and-tunnel treasure hunt across a 64-scene ring.""" + + score_cap = 114_000.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 500): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.scene = 0 + self.player = [4, 1] + self.previous_player = self.player.copy() + self.level = 0 + self.lives = 3 + self.score = 2_000.0 + self.steps = 0 + self.last_action = 0 + self.jump_timer = 0 + self.swing_timer = 0 + self.terminal = False + self.claimed: set[int] = set() + self.log_column = 8 + self.scorpion_column = 8 + self.scorpion_direction = -1 + self.vine_column = 4 + self.vine_direction = 1 + self.previous_log_column = self.log_column + self.previous_scorpion_column = self.scorpion_column + self.previous_vine_column = self.vine_column + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + self.previous_log_column = self.log_column + self.previous_scorpion_column = self.scorpion_column + self.previous_vine_column = self.vine_column + scene_before = self.scene + self._move_player(action) + reward = self._collect_treasure() + if self.scene == scene_before and not self.terminal: + self._move_hazards() + reward += self._resolve_hazards() + self.score = max(0.0, self.score + reward) + self.steps += 1 + self.jump_timer = max(0, self.jump_timer - 1) + self.swing_timer = max(0, self.swing_timer - 1) + if self.steps >= self.horizon or len(self.claimed) == 32: + self.terminal = True + return reward, self.terminal + + def _move_player(self, action: int) -> None: + if self.swing_timer: + self.player[1] = self.vine_column + if action == 4: + self.swing_timer = 0 + self.jump_timer = 2 + return + if action == 5: + if self.level == 0 and abs(self.player[1] - self.vine_column) <= 1 and self._hazard_kind() == "pit": + self.swing_timer = 4 + self.player[1] = self.vine_column + else: + self.jump_timer = 3 + self.player[0] = 2 if self.level == 0 else 6 + return + if action == 1: + self.player[1] -= 1 + elif action == 3: + self.player[1] += 1 + elif action == 4 and self.level == 0 and self._has_ladder() and self.player[1] == 5: + self.level = 1 + self.player = [8, 5] + elif action == 2 and self.level == 1 and self._has_ladder() and self.player[1] == 5: + self.level = 0 + self.player = [4, 5] + if self.jump_timer == 0: + self.player[0] = 4 if self.level == 0 else 8 + if self.player[1] < 0: + self._change_scene(-1) + elif self.player[1] > 9: + self._change_scene(1) + + def _change_scene(self, direction: int) -> None: + distance = 1 if self.level == 0 else 3 + self.scene = (self.scene + direction * distance) % 64 + self.player = [4 if self.level == 0 else 8, 9 if direction < 0 else 0] + self.previous_player = self.player.copy() + self.log_column = 8 + self.scorpion_column = 8 + self.scorpion_direction = -1 + self.vine_column = 4 + self.vine_direction = 1 + self.previous_log_column = self.log_column + self.previous_scorpion_column = self.scorpion_column + self.previous_vine_column = self.vine_column + + def _has_ladder(self) -> bool: + return self.scene % 4 == 0 + + def _hazard_kind(self) -> str: + kinds = ("logs", "pit", "crocodiles", "snake", "fire", "hole", "clear") + return kinds[self.scene % len(kinds)] + + def _collect_treasure(self) -> float: + if self.level or self.scene not in TREASURE_SCENES or self.scene in self.claimed: + return 0.0 + if self.player != [4, 8]: + return 0.0 + self.claimed.add(self.scene) + treasure_index = TREASURE_SCENES.index(self.scene) + return float(TREASURE_VALUES[treasure_index % 4]) + + def _move_hazards(self) -> None: + if self.level == 0: + if self._hazard_kind() == "logs": + self.log_column -= 1 + if self.log_column < 0: + self.log_column = 9 + if self._hazard_kind() == "pit": + self.vine_column += self.vine_direction + if self.vine_column in (3, 7): + self.vine_direction *= -1 + else: + self.scorpion_column += self.scorpion_direction + if self.scorpion_column in (1, 8): + self.scorpion_direction *= -1 + + def _resolve_hazards(self) -> float: + if self.level == 1: + if self.player == [8, self.scorpion_column] and self.jump_timer == 0: + self._lose_life() + return 0.0 + kind = self._hazard_kind() + if kind == "logs" and self.player[1] == self.log_column and self.jump_timer == 0: + return -10.0 + if kind == "hole" and self.player[1] in (4, 5) and self.jump_timer == 0: + self.level = 1 + self.player = [8, 5] + return -100.0 + dangerous = ( + kind == "pit" and self.player[1] in (4, 5, 6) and self.jump_timer == 0 and self.swing_timer == 0 + ) or (kind == "crocodiles" and self.player[1] in (4, 5, 6) and self.jump_timer == 0) or ( + kind in ("snake", "fire") and self.player[1] == 6 and self.jump_timer == 0 + ) + if dangerous: + self._lose_life() + return 0.0 + + def _lose_life(self) -> None: + self.lives -= 1 + if self.lives <= 0: + self.terminal = True + return + self.player = [4 if self.level == 0 else 8, 1] + self.previous_player = self.player.copy() + self.jump_timer = 0 + self.swing_timer = 0 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.player, 0] = True + state[*self.previous_player, 4] = True + if self.scene in TREASURE_SCENES and self.scene not in self.claimed: + state[4, 8, 2] = True + state[4, :, 3] = True + state[8, :, 3] = True + if self._has_ladder(): + state[4:9, 5, 3] = True + kind = self._hazard_kind() + if self.level == 0: + if kind == "logs": + state[4, self.log_column, 1] = True + state[4, self.previous_log_column, 4] = True + elif kind in ("pit", "crocodiles", "hole"): + state[4, 4:7, 3] = False + state[5, 4:7, 1] = True + elif kind in ("snake", "fire"): + state[4, 6, 1] = True + if kind == "pit": + state[1:5, self.vine_column, 3] = True + state[1:5, self.previous_vine_column, 4] = True + else: + state[8, self.scorpion_column, 1] = True + state[8, self.previous_scorpion_column, 4] = True + for index, scene in enumerate(TREASURE_SCENES): + state[index // 10, index % 10, 5] = scene in self.claimed + for bit in range(6): + index = 32 + bit + state[index // 10, index % 10, 5] = bool(self.scene & (1 << bit)) + state[3, 8, 5] = bool(self.level) + for bit in range(2): + index = 39 + bit + state[index // 10, index % 10, 5] = bool(self.lives & (1 << bit)) + for bit in range(9): + index = 41 + bit + state[index // 10, index % 10, 5] = bool(self.steps & (1 << bit)) + for bit in range(2): + state[5, bit, 5] = bool(self.jump_timer & (1 << bit)) + state[5, 2 + bit, 5] = bool(self.swing_timer & (1 << bit)) + state[5, 4, 5] = self.scorpion_direction > 0 + state[5, 5, 5] = self.vine_direction > 0 + return state diff --git a/runtime/minatar_synth/games/pizza_arrow.py b/runtime/minatar_synth/games/pizza_arrow.py new file mode 100644 index 0000000000000000000000000000000000000000..af0e24889581f977cf6d2bdee5267a0115320253 --- /dev/null +++ b/runtime/minatar_synth/games/pizza_arrow.py @@ -0,0 +1,115 @@ +import math + +import numpy as np + + +class PizzaArrowEnvironment: + score_cap = 2500 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.angle = self.low = self.high = 0.0 + self.y = -25 + self.arrow = None + self.velocity = self.steps = 0 + self.speed = 1.0 + self.arrows = self.capacity = self.multiplier = 1 + self.timer = 16 + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + release = self.pressed and not pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(release and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, release): + self.timer -= 1 + if self.timer == 15: + self.angle = self.random.uniform(0, math.pi / 2) + self.low, self.high = math.pi / 4, 7 * math.pi / 4 + self.multiplier = 1 + if self.timer >= 0: + self.y = 50 - self.timer * 5 if self.timer <= 15 else 50 + (30 - self.timer) * 5 + cut_angle = -self.angle % math.tau + self.angle = (self.angle + 0.2 * self.speed) % math.tau + if self.timer < 0 and self.arrow is None and self.pressed: + self.arrow, self.velocity = 80.0, 1 + self.arrows -= 1 + if self.arrow is None: + return 0 + if self.pressed: + self.speed += (0.05 - self.speed) * 0.1 + if release or self.arrow > 90: + self.velocity = -5 + if self.velocity < 0: + self.speed += (1 - self.speed) * 0.2 + self.arrow += self.velocity * self.speed + radius = self.arrow - 30 + if radius <= 22 and self.low < cut_angle < self.high: + return self._cut(cut_angle) + if radius <= 7: + self.terminal = True + self.arrow = None + return 0 + + def _cut(self, angle): + left, right = angle - self.low, self.high - angle + if left < right: + self.low = angle + else: + self.high = angle + reward = math.ceil(min(left, right) * 100 * self.multiplier) + self.multiplier += 1 + self.arrow = None + if not self.arrows: + self.capacity += 1 + self.arrows = self.capacity + self.timer = 30 + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + for angle in np.linspace(self.low, self.high, 40): + x, y = 30 + 20 * math.cos(angle + self.angle), self.y + 20 * math.sin(angle + self.angle) + if 0 <= y < 100: + state[int(y // 10), int(x // 10), 0] = True + for angle in (self.low, self.high): + for radius in range(5, 21, 3): + x = 30 + radius * math.cos(angle + self.angle) + y = self.y + radius * math.sin(angle + self.angle) + if 0 <= y < 100: + state[int(y // 10), int(x // 10), 1] = True + if 0 <= self.y < 100: + state[self.y // 10, 3, 2] = True + if self.arrow is not None: + state[5, int(self.arrow // 10), 3] = True + state[5, :, 4] = True + values = (self.steps, self.arrows, self.multiplier, round(self.angle * 80), + round(self.low * 80), round(self.high * 80), round(self.speed * 100)) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.velocity < 0 and self.arrow is not None + return state diff --git a/runtime/minatar_synth/games/plasma_splitter.py b/runtime/minatar_synth/games/plasma_splitter.py new file mode 100644 index 0000000000000000000000000000000000000000..4ec74ab866bb943b2504bda808254fba8ee45d6e --- /dev/null +++ b/runtime/minatar_synth/games/plasma_splitter.py @@ -0,0 +1,121 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Wall: + y: float + gaps: list[tuple[float, float]] + + def segments(self): + left = 0.0 + for start, end in self.gaps: + yield left, start + left = end + yield left, 100.0 + + +class PlasmaSplitterEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.anchor = 50.0, 0.0 + self.direction = 1 + self.speed, self.distance = 0.2, 0.0 + self.steps = 0 + self.pressed = self.terminal = False + self.walls: list[Wall] = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if self.pressed and not pressed: + self.anchor = self.x + self.pressed = pressed + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _spawn(self): + count = int(self.random.choice((1, 2, 2, 3, 3, 3))) + gaps = [] + x = 0.0 + for index in range(count): + x += self.random.uniform(10 if index else 0, 76 - x - (count - index - 1) * 34) + gaps.append((x, x + 24)) + x += 24 + self.walls.append(Wall(-3, gaps)) + self.distance = self.random.uniform(50, 80) + + def _advance(self): + if self.pressed: + self.speed += 0.01 + else: + self.speed += (0.2 - self.speed) * 0.1 + self.x += self.direction + if self.x < 4 or self.x > 96: + self.direction *= -1 + self.distance -= self.speed + if self.distance < 0: + self._spawn() + reward = 0 + remaining = [] + low, high = sorted((self.x, self.anchor)) + for wall in self.walls: + wall.y += self.speed + destroyed = False + for index, (left, right) in enumerate(wall.segments()): + if right <= left: + continue + endpoint_hit = any(left < x + 4 and x - 4 < right for x in (self.x, self.anchor)) + if 89 < wall.y < 100 and endpoint_hit: + self.terminal = True + elif index < len(wall.gaps) and 91 < wall.y < 96 and low < right and left < high: + reward += math.floor(self.speed / 0.2 * (right - left)) + destroyed = True + if not destroyed and wall.y <= 103: + remaining.append(wall) + self.walls = remaining + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + a, b = int(self.x // 10), int(self.anchor // 10) + state[9, a, 0] = True + state[9, b, 1] = True + state[9, min(a, b):max(a, b) + 1, 2] = True + columns = np.arange(5, 100, 10) + for wall in self.walls: + if 0 <= wall.y < 100: + row = int(wall.y // 10) + for start, end in wall.gaps: + state[row, :, 4] |= (columns >= start) & (columns < end) + for start, end in wall.segments(): + state[row, :, 3] |= (columns >= start) & (columns < end) + for row, value in enumerate((self.steps, round(self.x * 4), round(self.anchor * 4), + min(511, round(self.speed * 30)))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, :2, 5] = self.pressed, self.direction > 0 + return state diff --git a/runtime/minatar_synth/games/pod_migration.py b/runtime/minatar_synth/games/pod_migration.py new file mode 100644 index 0000000000000000000000000000000000000000..537ff4af663f8baa27d046f1b7716a08ffbc3f02 --- /dev/null +++ b/runtime/minatar_synth/games/pod_migration.py @@ -0,0 +1,147 @@ +from dataclasses import dataclass +import math + +import numpy as np + + +@dataclass +class Whale: + x: float + y: float + lost: bool = False + + +@dataclass +class Ice: + x: float + y: float + width: float + height: float + life: float + age: int = 0 + + def geometry(self): + scale = 1 - (1 - min(1, self.age / 150)) ** 3 + if self.age > self.life - 120: + scale *= max(0, 1 - ((self.age - self.life + 120) / 120) ** 2) + height = self.height * scale + return self.y + self.height - height, height + + +class PodMigrationEnvironment: + score_cap = 200 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.lead = Whale(20, 50) + self.pod = [Whale(10, 45), Whale(10, 55), Whale(5, 50)] + self.ice: list[Ice] = [] + self.direction = self.steps = self.respawn = self.knockback = 0 + self.kx = self.ky = 0.0 + self.multiplier = 1.0 + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + if pressed and not self.pressed: + self.direction = (self.direction + 1) % 4 + self.pressed = pressed + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self): + self.multiplier = max(1, self.multiplier * 0.998) + self.respawn += 1 + if self.respawn >= 300: + whale = next((w for w in self.pod if w.lost), None) + if whale is not None: + whale.lost = False + self.respawn = 0 + previous = self.lead + for whale in self.pod: + whale.x += (previous.x - whale.x) * 0.05 + whale.y += (previous.y - whale.y) * 0.05 + previous = whale + if not whale.lost and abs(whale.x - self.lead.x) < 5 and abs(whale.y - self.lead.y) < 3: + whale.lost = True + self.respawn = 0 + chance = 0.03 if len(self.ice) < 3 else 0.02 if len(self.ice) < 5 else 0.01 + if self.random.random() < chance: + x, y = self.random.uniform(10, 90, 2) + if all(math.hypot(w.x - x, w.y - y) >= 20 for w in self.pod): + self.ice.append(Ice(x, y, self.random.uniform(9, 16), + self.random.uniform(6, 10), self.random.uniform(500, 600))) + blocked = False + reward = 0 + remaining = [] + for ice in self.ice: + if ice.age < ice.life: + y, height = ice.geometry() + if height and any(not w.lost and self._hits(w, ice, y, height) for w in self.pod): + reward += math.floor(self.multiplier + 0.5) + self.multiplier += 1 + continue + if 150 <= ice.age < ice.life - 120: + blocked |= self._hits(self.lead, ice, y, height) + ice.age += 1 + remaining.append(ice) + self.ice = remaining + dx, dy = ((1, 0), (0, 1), (-1, 0), (0, -1))[self.direction] + if self.knockback: + self.lead.x += self.kx + self.lead.y += self.ky + self.kx *= 0.88 + self.ky *= 0.88 + self.knockback -= 1 + if blocked: + self.kx, self.ky, self.knockback = -1.8 * dx, -1.8 * dy, 25 + else: + self.lead.x += dx + self.lead.y += dy + self.lead.x = min(97, max(3, self.lead.x)) + self.lead.y = min(97, max(3, self.lead.y)) + self.terminal = all(whale.lost for whale in self.pod) + return reward + + @staticmethod + def _hits(whale, ice, y, height): + return abs(whale.x - ice.x) < ice.width / 2 + 3 and abs(whale.y - y) < height / 2 + 2 + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[int(self.lead.y // 10), int(self.lead.x // 10), 0] = True + for whale in self.pod: + state[int(whale.y // 10), int(whale.x // 10), 2 if whale.lost else 1] = True + rows, cols = np.ogrid[5:100:10, 5:100:10] + for ice in self.ice: + y, height = ice.geometry() + if height: + channel = 3 if 150 <= ice.age < ice.life - 120 else 4 + state[:, :, channel] |= (abs(cols - ice.x) < ice.width / 2 + 5) & (abs(rows - y) < height / 2 + 5) + gauges = (self.steps, self.direction, min(511, self.respawn), self.knockback, + min(511, round(self.multiplier * 10))) + for row, value in enumerate(gauges): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + state[9, 0, 5] = self.pressed + return state diff --git a/runtime/minatar_synth/games/portal_j.py b/runtime/minatar_synth/games/portal_j.py new file mode 100644 index 0000000000000000000000000000000000000000..8d3dcbc42c096fb4473aa46ce449f76c599a83d9 --- /dev/null +++ b/runtime/minatar_synth/games/portal_j.py @@ -0,0 +1,132 @@ +from dataclasses import dataclass +from math import ceil + +import numpy as np + + +@dataclass +class Floor: + x: float + width: float + + +class PortalJEnvironment: + score_cap = 3000 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.y, self.portal = 30.0, 39.0, 36.0 + self.steps = self.phase = self.pending_score = 0 + self.fall = self.floor_distance = 0.0 + self.gold_distance = 30.0 + self.multiplier = 1 + self.floors = [Floor(0, 100), Floor(110, 80)] + self.gold = [] + self.pressed = self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + pressed = self.pressed if self.random.random() < self.sticky_action_prob else action == 5 + tap = pressed and not self.pressed + self.pressed = pressed + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap): + scroll = max(0, self.x - 30) * 0.1 + 0.1 + self.floor_distance -= scroll + if self.floor_distance < 0: + interval = self.random.uniform(50, 99) + fraction = self.random.uniform(0.4, 0.7) + x = 200 + self.floor_distance + interval * self.random.uniform(0, 1 - fraction) + self.floors.append(Floor(x, interval * fraction)) + self.floor_distance += interval + for floor in self.floors: + floor.x -= scroll + self.floors = [floor for floor in self.floors if floor.x + floor.width >= 0] + self.x -= scroll + self.portal -= scroll + if self.fall: + self.fall += 0.2 + self.y = 39 + self.fall + reward = 0 + if self.phase: + self.phase += 1 + if self.phase < 5: + self.y += self.phase + else: + distance = self.portal - self.x + if distance > 0: + self.pending_score = ceil(distance ** 1.5 * 0.1 * self.multiplier) + self.x = self.portal + self.y = 47 - self.phase + if self.y < 39: + self.y = 39 + self.phase = 0 + reward = self.pending_score + self.pending_score = 0 + else: + self.portal += 2 + if self.portal > 200: + self.portal = self.x + 6 + if tap: + self.phase = 1 + if self.phase == 0: + on_floor = self.y + 2.5 > 40 and self.y - 2.5 < 48 and any( + self.x + 2.5 > floor.x and self.x - 2.5 < floor.x + floor.width + for floor in self.floors + ) + self.fall = 0 if on_floor else self.fall or 1 + self.terminal = self.y > 52 or self.x < 0 + + self.gold_distance -= scroll + if self.gold_distance < 0: + self.gold.append(203) + self.gold_distance += self.random.uniform(99, 120) + remaining = [] + for x in self.gold: + x -= scroll + if abs(x - self.x) < 5 and abs(self.y - 36) < 5: + self.multiplier += 1 + elif x >= -3: + remaining.append(x) + self.gold = remaining + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + if 0 <= self.x < 200 and 0 <= self.y < 50: + state[int(self.y // 5), int(self.x // 20), 0] = True + if 0 <= self.portal < 200: + state[8, int(self.portal // 20), 1] = True + columns = np.arange(10) * 20 + for floor in self.floors: + state[8:10, :, 2] |= (columns < floor.x + floor.width) & (columns + 20 > floor.x) + for x in self.gold: + if 0 <= x < 200: + state[7, int(x // 20), 3] = True + if self.phase and 0 <= self.x < 200: + state[8, int(self.x // 20), 4] = True + for row, value in enumerate((self.steps, self.phase, self.multiplier, self.pressed)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/press_m.py b/runtime/minatar_synth/games/press_m.py new file mode 100644 index 0000000000000000000000000000000000000000..a207ebddd0e4767d0dc80ba5a5c46531ca7ef102 --- /dev/null +++ b/runtime/minatar_synth/games/press_m.py @@ -0,0 +1,127 @@ +from math import hypot, pi, sin + +import numpy as np + + +class PressMEnvironment: + score_cap = 1000 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(400, horizon) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x = 50 + self.steps = self.action = self.frame = 0 + self.multiplier = 1 + self.terminal = False + self.ends = np.repeat([[40.0], [60.0]], 10, axis=1) + self.walls = self.ends.copy() + self.flying = [] + self._new_cycle() + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def _new_cycle(self): + self.multiplier = max(1, self.multiplier - 1) + self.starts = np.empty((2, 10)) + for side, center in enumerate((20, 80)): + angle = self.random.uniform(0, 2 * pi) + velocity = self.random.uniform(0.4, 1) * self.random.choice((-1, 1)) + radius = self.random.uniform(10, 20) + y = center + self.random.uniform(-5, 5) + for col in range(10): + self.starts[side, col] = np.clip(y + sin(angle) * radius, 2, 97) + velocity += self.random.uniform(-0.1, 0.1) + radius += self.random.uniform(-1, 1) + angle += velocity + y += self.random.uniform(-1, 1) + gaps = self.starts[1] - self.starts[0] + narrowest = np.argmin(gaps) + self.targets = self.starts + np.array([[1], [-1]]) * gaps[narrowest] / 2 + if not np.any((self.targets[0] < 40) & (self.targets[1] > 60)): + for col in range(10): + if col != narrowest: + adjustment = np.array([min(0, 40 - self.targets[0, col]), + max(0, 60 - self.targets[1, col])]) + self.starts[:, col] += adjustment + self.targets[:, col] += adjustment + self.attached = list(zip(*np.where(self.random.random((2, 10)) < 0.2))) + + def act(self, action): + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.action = action + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self): + self.x = min(96, max(3, self.x + 3 * ((self.action == 3) - (self.action == 1)))) + if self.frame < 60: + self.walls = self.ends + (self.starts - self.ends) * (self.frame / 60) + else: + remaining = 79 - self.frame + amount = 1 - remaining / 5 if remaining < 5 else (1 - remaining / 20) * 0.2 + self.walls = self.starts + (self.targets - self.starts) * amount + if remaining < 5: + self.terminal = any( + col * 10 + 9 > self.x - 3 and col * 10 < self.x + 3 + and (self.walls[0, col] > 47.5 or self.walls[1, col] < 52.5) + for col in range(10) + ) + attached = [] + for side, col in self.attached: + x = col * 10 + 5 + y = self.walls[side, col] + (4 if side == 0 else -4) + if self.frame >= 60 and hypot(self.x - x, 50 - y) < 30: + self.flying.append((x, y, self.random.uniform(0.1, 0.3))) + else: + attached.append((side, col)) + self.attached = attached + reward = 0 + flying = [] + for x, y, speed in self.flying: + x += (self.x - x) * speed + y += (50 - y) * speed + if abs(x - self.x) < 5 and abs(y - 50) < 5: + reward += self.multiplier + self.multiplier += 1 + else: + flying.append((x, y, speed)) + self.flying = flying + self.frame += 1 + if self.frame == 80: + self.frame = 0 + self.ends = self.targets + self._new_cycle() + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[5, int(self.x // 10), 0] = True + rows = np.arange(10)[:, None] * 10 + state[:, :, 1] = rows < self.walls[0] + state[:, :, 2] = rows + 10 > self.walls[1] + for side, col in self.attached: + y = self.walls[side, col] + (4 if side == 0 else -4) + state[int(np.clip(y // 10, 0, 9)), col, 3] = True + for x, y, _ in self.flying: + state[int(np.clip(y // 10, 0, 9)), int(x // 10), 4] = True + for row, value in enumerate((self.frame, self.multiplier, self.steps, self.action)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/pressbound.py b/runtime/minatar_synth/games/pressbound.py new file mode 100644 index 0000000000000000000000000000000000000000..1c1b5655542f9d770209966e9994e9a102e5b1ad --- /dev/null +++ b/runtime/minatar_synth/games/pressbound.py @@ -0,0 +1,82 @@ +import numpy as np + + +class PressboundEnvironment: + score_cap = 3000 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.pressure = 500 + self.charge = self.steps = 0 + self.held = self.terminal = False + self._spawn(1, 10) + + def _spawn(self, count, margin): + self.balls = self.random.uniform(margin, 100 - margin, (count, 2)) + self.velocity = self.random.uniform(0.5, 1, (count, 2)) + self.velocity *= self.random.choice((-1, 1), (count, 2)) + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + reward = 0 + self.steps += 1 + for _ in range(4): + reward += self._advance(held) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, held): + self.pressure += 20 if held else 5 + reward = 0 + if held: + if not self.held: + self.pressure += 200 + self.charge += 1 + margin = self.pressure / 100 + 0.5 + self.terminal = bool(np.any(self.balls < margin) or np.any(self.balls > 100 - margin)) + else: + if self.held: + reward = (self.charge * len(self.balls)) ** 2 // 100 + self.charge = 0 + self.pressure = 500 + self._spawn(self.random.integers(2, 5), 5) + self.terminal = self.pressure >= 4300 + margin = self.pressure / 100 + 1 + self.balls += self.velocity + self.velocity = np.where(self.balls < margin, abs(self.velocity), self.velocity) + self.velocity = np.where(self.balls > 100 - margin, -abs(self.velocity), self.velocity) + np.clip(self.balls, margin, 100 - margin, out=self.balls) + self.held = held + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + coordinates = np.arange(5, 100, 10) + edges = np.minimum(coordinates, 100 - coordinates) + state[:, :, 2] = np.minimum(edges[:, None], edges) <= self.pressure / 100 + for x, y in self.balls: + row, col = int(y // 10), int(x // 10) + state[row, col, int(self.held)] = True + if min(x, y, 100 - x, 100 - y) < self.pressure / 100 + 6: + state[row, col, 3] = True + for row, value in enumerate((self.pressure, self.charge, len(self.balls), self.steps)): + for bit in range(13): + state[row + bit // 10 * 4, bit % 10, 4] = bool(value & (1 << bit)) + state[:, :, 5] = not self.held and self.pressure > 3500 + return state diff --git a/runtime/minatar_synth/games/private_eye.py b/runtime/minatar_synth/games/private_eye.py new file mode 100644 index 0000000000000000000000000000000000000000..9b9a37a93ec1869f2b2e42489eac521f6c547d27 --- /dev/null +++ b/runtime/minatar_synth/games/private_eye.py @@ -0,0 +1,216 @@ +import numpy as np + + +ITEMS = ("gun", "button", "comb", "sole", "money", "vase", "necklace", "stamp") +ITEM_BLOCKS = {item: 2 + index * 4 for index, item in enumerate(ITEMS)} +DESTINATION_BLOCKS = {item: 3 + index * 4 for index, item in enumerate(ITEMS)} +EMPTY_CHARACTER_BLOCKS = (1, 5, 9, 13, 17, 21, 25, 29) +SECRET_PASSAGES = {0: 12, 7: 20, 14: 28, 21: 3, 28: 16} +DEMERITS = {"brick": 100, "flowerpot": 200, "rat": 300, "bird": 400, "dagger": 1_000} + + +class PrivateEyeEnvironment: + """Case Five city search with one-item evidence logistics.""" + + score_cap = 251_800.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 800): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.block = 0 + self.car = [7, 1] + self.previous_car = self.car.copy() + self.facing = 1 + self.score = 1_000.0 + self.steps = 0 + self.last_action = 0 + self.jump_timer = 0 + self.terminal = False + self.carried: str | None = None + self.acquired: set[str] = set() + self.returned: set[str] = set() + self.nabbed_empty: set[int] = set() + self.item_blocks = dict(ITEM_BLOCKS) + self.le_fiend_nabbed = False + self.hazard = [1, 8] + self.previous_hazard = self.hazard.copy() + self.hazard_kind = "brick" + self.hazard_direction = -1 + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_car = self.car.copy() + self.previous_hazard = self.hazard.copy() + block_before = self.block + reward = self._move_car(action) + reward += self._interact(action) + if self.block == block_before and not self.terminal: + self._move_hazard() + reward += self._resolve_hazards() + reward += self._deliver_item() + self.score = max(0.0, self.score + reward) + self.steps += 1 + self.jump_timer = max(0, self.jump_timer - 1) + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _move_car(self, action: int) -> float: + if action == 1: + self.car[1] -= 1 + self.facing = -1 + elif action == 3: + self.car[1] += 1 + self.facing = 1 + elif action == 5: + self.jump_timer = 3 + self.car[0] = 4 + elif action == 2 and self.block in SECRET_PASSAGES and self.car[1] == 5: + self.block = SECRET_PASSAGES[self.block] + self.car = [7, 5] + self.previous_car = self.car.copy() + self._reset_hazard() + return 0.0 + if self.jump_timer == 0: + self.car[0] = 7 + if self.car[1] < 0: + self._change_block(-1) + elif self.car[1] > 9: + self._change_block(1) + return 0.0 + + def _change_block(self, direction: int) -> None: + self.block = (self.block + direction) % 32 + self.car = [7, 9 if direction < 0 else 0] + self.previous_car = self.car.copy() + self._reset_hazard() + + def _reset_hazard(self) -> None: + kinds = ("brick", "flowerpot", "rat", "bird", "pothole") + if self.returned: + kinds = (*kinds, "dagger") + self.hazard_kind = kinds[self.block % len(kinds)] + self.hazard = [1 if self.hazard_kind in ("brick", "flowerpot", "bird", "dagger") else 7, 8] + self.previous_hazard = self.hazard.copy() + self.hazard_direction = -1 + + def _interact(self, action: int) -> float: + if action != 5 or self.car[1] != 5: + return 0.0 + for item, block in self.item_blocks.items(): + if block != self.block or item in self.returned: + continue + previous_item = self.carried + self.carried = item + self.item_blocks[item] = -1 + if previous_item in ITEMS: + self.item_blocks[previous_item] = self.block + if item in self.acquired: + return 0.0 + self.acquired.add(item) + return 5_000.0 if ITEMS.index(item) < 4 else 15_000.0 + if self.block in EMPTY_CHARACTER_BLOCKS and self.block not in self.nabbed_empty: + self.nabbed_empty.add(self.block) + return 100.0 + if self.block == 16 and len(self.returned) == 8 and not self.le_fiend_nabbed: + self.le_fiend_nabbed = True + self.carried = "fiend" + return 25_000.0 + return 0.0 + + def _deliver_item(self) -> float: + if self.carried in ITEMS and self.block == DESTINATION_BLOCKS[self.carried] and self.car[1] == 8: + item = self.carried + self.returned.add(item) + self.carried = None + return 10_000.0 if ITEMS.index(item) < 4 else 20_000.0 + if self.carried == "fiend" and self.block == 0 and self.car[1] == 8: + self.carried = None + self.terminal = True + return 25_000.0 + return 0.0 + + def _move_hazard(self) -> None: + if self.hazard_kind == "pothole": + return + if self.hazard_kind in ("brick", "flowerpot", "bird", "dagger"): + self.hazard[0] += 1 + if self.hazard[0] > 7: + self.hazard = [1, int(self.random.randint(1, 9))] + else: + self.hazard[1] += self.hazard_direction + if self.hazard[1] in (1, 8): + self.hazard_direction *= -1 + + def _resolve_hazards(self) -> float: + if self.jump_timer: + return 0.0 + if self.block % 6 == 0 and self.car[1] == 6: + return -1.0 + if self.block % 8 == 4 and self.car[1] == 5: + return -100.0 + if self.hazard == self.car: + penalty = DEMERITS.get(self.hazard_kind, 1) + if self.hazard_kind == "dagger" and self.carried is not None: + if self.carried in ITEMS: + self.item_blocks[self.carried] = (self.block - self.facing) % 32 + self.carried = None + return -float(penalty) + return 0.0 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[*self.car, 0] = True + state[*self.previous_car, 4] = True + state[*self.hazard, 1] = True + state[*self.previous_hazard, 4] = True + for item, block in self.item_blocks.items(): + if block == self.block and item not in self.returned: + state[4, 5, 2] = True + state[4, ITEMS.index(item), 3] = True + if self.block in EMPTY_CHARACTER_BLOCKS and self.block not in self.nabbed_empty: + state[4, 5, 2] = True + if self.block == 16 and len(self.returned) == 8 and not self.le_fiend_nabbed: + state[4, 5, 2] = True + if self.block in SECRET_PASSAGES: + state[7, 5, 3] = True + if self.block % 8 == 4: + state[7, 5, 1] = True + for index, item in enumerate(ITEMS): + state[index // 10, index % 10, 5] = item in self.acquired + state[1 + index // 10, index % 10, 5] = item in self.returned + for index, block in enumerate(EMPTY_CHARACTER_BLOCKS): + state[2, index, 5] = block in self.nabbed_empty + carried_codes = {None: 0, **{item: index + 1 for index, item in enumerate(ITEMS)}, "fiend": 9} + code = carried_codes[self.carried] + for bit in range(4): + state[3, bit, 5] = bool(code & (1 << bit)) + for bit in range(5): + state[3, 4 + bit, 5] = bool(self.block & (1 << bit)) + for bit in range(10): + state[4, bit, 5] = bool(self.steps & (1 << bit)) + for item_index, item in enumerate(ITEMS): + block_code = 32 if self.item_blocks[item] < 0 else self.item_blocks[item] + for bit in range(6): + index = 52 + item_index * 6 + bit + state[index // 10, index % 10, 5] = bool(block_code & (1 << bit)) + facing_column = min(9, max(0, self.car[1] + self.facing)) + state[self.car[0], facing_column, 3] = True + state[9, : self.jump_timer, 3] = True + return state diff --git a/runtime/minatar_synth/games/pulse_piper.py b/runtime/minatar_synth/games/pulse_piper.py new file mode 100644 index 0000000000000000000000000000000000000000..bae8c75a4ba7e3146107568312e210575b4efb4b --- /dev/null +++ b/runtime/minatar_synth/games/pulse_piper.py @@ -0,0 +1,107 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Obstacle: + x: float + width: float + height: float + gap: float + dot: bool + + +class PulsePiperEnvironment: + score_cap = 1000 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x = 10.0 + self.charge = self.steps = self.spawn_timer = 0 + self.held = self.released = self.terminal = False + self.obstacles = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance(held) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, held): + self.x += 0.7 + if self.x > 100: + self.x = 0 + self.released = self.held and not held + discharge = self.charge if self.released else 0 + self.held = held + self.charge = min(99, self.charge + 1) if held else 0 + offset = 2 + self.charge / 2 + reward = 0 + remaining = [] + for obstacle in self.obstacles: + obstacle.x -= 0.5 + overlap = ( + abs(obstacle.x - self.x) < 4 + obstacle.width / 2 + and offset + 2 > obstacle.gap + and offset - 2 < obstacle.gap + obstacle.height + ) + if overlap and obstacle.dot and self.released: + reward += discharge + continue + if overlap and not obstacle.dot and not self.released: + self.terminal = True + if obstacle.x + obstacle.width / 3 >= 0: + remaining.append(obstacle) + self.obstacles = remaining + if self.spawn_timer == 0: + self._spawn() + self.spawn_timer = 60 + self.spawn_timer -= 1 + return reward + + def _spawn(self): + dot = self.random.random() < 0.7 + wall = self.random.random() < 0.3 + if dot: + self.obstacles.append(Obstacle(102, 4, 2, 0, True)) + else: + close = not wall and self.x < 40 and self.random.random() < 0.65 + gap = 0 if close else self.random.uniform(10, 20) + self.obstacles.append(Obstacle(104.5, 9, 50 if wall else 4, gap, False)) + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + rows, cols = np.ogrid[:100:10, :100:10] + for obstacle in self.obstacles: + horizontal = (cols < obstacle.x + obstacle.width / 2) & (cols + 10 > obstacle.x - obstacle.width / 2) + top = (rows < 50 - obstacle.gap) & (rows + 10 > 50 - obstacle.gap - obstacle.height) + bottom = (rows < 50 + obstacle.gap + obstacle.height) & (rows + 10 > 50 + obstacle.gap) + channel = 2 if obstacle.dot else 3 if obstacle.height < 50 else 4 + state[:, :, channel] |= horizontal & (top | bottom) + offset = 2 + self.charge / 2 + for y in (50 - offset, 50 + offset): + state[int(np.clip(y // 10, 0, 9)), min(9, int(self.x // 10)), int(self.released)] = True + for row, value in enumerate((self.charge, self.spawn_timer, self.steps, self.held)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/pulse_stream.py b/runtime/minatar_synth/games/pulse_stream.py new file mode 100644 index 0000000000000000000000000000000000000000..ab92c0876744aa86e9a328407bcbc8b0d14ad313 --- /dev/null +++ b/runtime/minatar_synth/games/pulse_stream.py @@ -0,0 +1,157 @@ +from dataclasses import dataclass +from math import hypot + +import numpy as np + + +@dataclass +class Wave: + lane: int + amplitude: float + x: float = -5 + + +@dataclass +class Bubble: + lane: int + y: float + vx: float = -0.2 + x: float = 98 + vy: float = 0 + + +class PulseStreamEnvironment: + score_cap = 100 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.steps = self.frame = self.last_tap = self.auto_timer = self.spawn_lane = 0 + self.rapid_rate = 0.0 + self.held = self.terminal = False + self.disabled = [False] * 5 + self.recovery = [0] * 5 + self.waves = [] + self.bubbles = [Bubble(2, self.random.uniform(-2, 2))] + self.sequence = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap = held and not self.held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _spawn(self): + if self.frame % 36 == 0: + if len(self.sequence) <= 1: + self.sequence = self.random.permutation(np.tile(np.arange(5), 3)).tolist() + lane = self.sequence.pop(0) + for offset in range(5): + lane = (lane + offset) % 5 + if not self.disabled[lane]: + self.waves.append(Wave(lane, self.random.uniform(1, 1.7))) + break + if self.random.random() < 0.01: + if self.random.random() < 0.7: + lane = self.spawn_lane + self.spawn_lane = (self.spawn_lane + 1) % 5 + else: + lane = self.random.integers(5) + while self.disabled[lane]: + lane = (lane + 1) % 5 + self.bubbles.append(Bubble(lane, self.random.uniform(-2, 2), + self.random.uniform(-0.3, -0.2))) + + def _advance(self, tap): + self._spawn() + if tap: + self.last_tap = self.frame + self.auto_timer = 0 + elif self.frame - self.last_tap >= 600: + self.auto_timer += 1 + if self.auto_timer == 60: + tap = True + self.auto_timer = 0 + if tap: + self.rapid_rate += 0.3 + for lane, disabled in enumerate(self.disabled): + if disabled: + self.recovery[lane] += 1 + if self.recovery[lane] == 36: + self.disabled[lane] = False + self.recovery[lane] = 0 + self.rapid_rate *= 0.98 + for wave in self.waves: + wave.x += 0.8 + self.waves = [wave for wave in self.waves if wave.x <= 105] + reward = 0 + remaining = [] + for bubble in self.bubbles: + if self.disabled[bubble.lane]: + continue + bubble.x += bubble.vx + bubble.y += bubble.vy + if tap: + hits = 0 + for wave in self.waves: + if wave.lane == bubble.lane and hypot(wave.x - bubble.x, bubble.y) < wave.amplitude * 6: + hits += 1 + bubble.vx += 0.8 + bubble.vy += self.random.uniform(-0.2, 0.2) + reward += hits + if not hits: + bubble.vx -= 0.1 * (0.25 + self.rapid_rate) + bubble.vx *= 0.993 + bubble.vy *= 0.891 + bubble.y *= 0.95 + if bubble.x < 0: + self.disabled[bubble.lane] = True + self.recovery[bubble.lane] = 0 + elif bubble.x > 100: + reward += 2 + else: + remaining.append(bubble) + self.bubbles = [bubble for bubble in remaining if not self.disabled[bubble.lane]] + self.waves = [wave for wave in self.waves if not self.disabled[wave.lane]] + self.terminal = sum(self.disabled) >= 3 + self.frame += 1 + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + for wave in self.waves: + columns = np.arange(5, 100, 10) + state[2 * wave.lane, :, 0] |= abs(columns - wave.x) < wave.amplitude * 6 + 5 + for bubble in self.bubbles: + col = min(9, int(bubble.x // 10)) + state[2 * bubble.lane, col, 1 + int(bubble.vx > 0)] = True + for lane, disabled in enumerate(self.disabled): + state[2 * lane, :, 3] = disabled + for bit in range(6): + state[2 * lane, bit, 4] = bool(self.recovery[lane] & (1 << bit)) + for row, value in enumerate((self.steps, self.frame % 36, self.held, + min(1023, self.frame - self.last_tap), self.auto_timer, + round(self.rapid_rate * 100))): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/pump_press.py b/runtime/minatar_synth/games/pump_press.py new file mode 100644 index 0000000000000000000000000000000000000000..2d23bbc11435e8026d26b2bb6c75570d4a6938a0 --- /dev/null +++ b/runtime/minatar_synth/games/pump_press.py @@ -0,0 +1,129 @@ +from dataclasses import dataclass +from math import ceil + +import numpy as np + + +@dataclass +class Enemy: + x: float = 205 + size: float = 0 + attachment: float | None = None + + +class PumpPressEnvironment: + score_cap = 200 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.ship = 100.0 + self.speed = 1.0 + self.shot = self.rocket = None + self.shot_range = self.steps = 0 + self.held = self.launched = self.terminal = False + self.enemy_distance, self.rocket_distance = 0.0, 30.0 + self.enemies = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap = held and not self.held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap): + self.ship += self.speed + self.speed += ((1 if self.held else 0.5) - self.speed) * 0.1 + scroll = 0.1 + max(0, self.ship - 100) * 0.1 + self.ship -= scroll + if self.shot is None and tap: + self.shot = self.ship + 6 + self.shot_range = 60 + shot = self.shot + if shot is not None: + shot += 3 - scroll + self.shot_range -= 3 + self.shot = shot if self.shot_range >= 0 else None + self.enemy_distance -= scroll + if self.enemy_distance < 0: + self.enemies.append(Enemy()) + self.enemy_distance = self.random.uniform(33, 43) + reward = 0 + if self.rocket is None: + self.rocket_distance -= scroll + if self.rocket_distance < 0: + self.rocket = 205 + self.launched = False + self.rocket_distance = 100 + else: + self.rocket -= scroll + int(self.launched) + if not self.launched and shot is not None and abs(self.rocket - shot) < 5.5: + self.launched = True + self.shot = None + if self.rocket < 5: + count = sum(enemy.attachment is not None for enemy in self.enemies) + reward = count * (count + 1) // 2 + self.rocket = None + self.launched = False + remaining = [] + for enemy in self.enemies: + if enemy.attachment is not None: + if self.rocket is not None: + enemy.x = self.rocket + enemy.attachment + remaining.append(enemy) + continue + if enemy.size > 0: + enemy.size = max(0, enemy.size - 0.02) + else: + enemy.x += 0.5 if enemy.x < self.ship else -0.5 + enemy.x -= scroll + radius = ceil(enemy.size) * 2 + 2 + if shot is not None and abs(enemy.x - shot) < radius + 3: + self.shot = None + enemy.size = ceil(enemy.size) + 1 + if enemy.size > 3: + continue + if self.launched and abs(enemy.x - self.rocket) < radius + 2.5: + enemy.attachment = self.random.uniform(-6, -2) + if enemy.size == 0 and abs(enemy.x - self.ship) < radius + 3: + self.terminal = True + if enemy.x >= -5: + remaining.append(enemy) + self.enemies = remaining + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + for x, row, channel in ((self.ship, 5, 0), (self.shot, 5, 1), + (self.rocket, 5, 2), (self.rocket if self.launched else None, 4, 2)): + if x is not None and 0 <= x < 200: + state[row, int(x // 20), channel] = True + for enemy in self.enemies: + if 0 <= enemy.x < 200: + row = 4 if enemy.attachment is not None else 5 + state[row, int(enemy.x // 20), 3 + int(enemy.size > 0)] = True + for row, value in enumerate((self.steps, round(self.speed * 100), + max(0, self.shot_range), self.held)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/qbert.py b/runtime/minatar_synth/games/qbert.py new file mode 100644 index 0000000000000000000000000000000000000000..a3faf9a34c90afcd5dbeadefb87195b3c5db27c1 --- /dev/null +++ b/runtime/minatar_synth/games/qbert.py @@ -0,0 +1,248 @@ +import numpy as np + + +CUBES = tuple((row, column) for row in range(7) for column in range(row + 1)) +DIRECTIONS = {1: (-1, -1), 2: (-1, 0), 3: (1, 1), 4: (1, 0)} + + +class QbertEnvironment: + """Twenty-round color pyramid campaign with balls, Sam, Coily, and discs.""" + + score_cap = 94_000.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 5_000): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.level = 0 + self.round = 0 + self.lives = 4 + self.score = 0.0 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self.bonus_rounds: set[int] = set() + self._start_round() + + def _start_round(self) -> None: + self.player = [0, 0] + self.previous_player = self.player.copy() + self.colors = {cube: 0 for cube in CUBES} + self.rewarded_cubes: set[tuple[int, int]] = set() + self.discs = {"left", "right"} + self.enemies = { + "red": [0, 0], + "purple": [0, 0], + "sam": [0, 0], + "green": [0, 0], + } + self.previous_enemies = {kind: position.copy() for kind, position in self.enemies.items()} + self.caught_rewards: set[str] = set() + self.freeze_timer = 0 + self.round_steps = 0 + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player = self.player.copy() + self.previous_enemies = {kind: position.copy() for kind, position in self.enemies.items()} + campaign_round_before = self.level * 4 + self.round + reward = self._move_player(action) + if self.level * 4 + self.round == campaign_round_before and not self.terminal: + if self.freeze_timer == 0: + self._move_enemies() + reward += self._resolve_collisions() + self.score += reward + self.steps += 1 + self.round_steps += 1 + self.freeze_timer = max(0, self.freeze_timer - 1) + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _move_player(self, action: int) -> float: + if action not in DIRECTIONS: + return 0.0 + row_delta, column_delta = DIRECTIONS[action] + target = [self.player[0] + row_delta, self.player[1] + column_delta] + if tuple(target) not in CUBES: + disc = None + if self.player == [3, 0] and action == 1: + disc = "left" + elif self.player == [3, 3] and action == 2: + disc = "right" + if disc in self.discs: + self.discs.remove(disc) + self.player = [0, 0] + if "coily" in self.enemies: + del self.enemies["coily"] + if "coily" not in self.caught_rewards: + self.caught_rewards.add("coily") + return 500.0 + return 0.0 + self._lose_life(fell=True) + return 0.0 + self.player = target + reward = self._change_cube(tuple(target)) + if self._round_complete(): + reward += 3_100.0 + self._advance_round() + return reward + + def _change_cube(self, cube: tuple[int, int]) -> float: + color = self.colors[cube] + if self.level == 0: + color = 1 + elif self.level == 1: + color = min(2, color + 1) + elif self.level == 2: + color = 0 if color == 1 else 1 + elif self.level == 3: + color = 1 if color == 2 else color + 1 + else: + color = (color + 1) % 3 + self.colors[cube] = color + if color == self._destination_color() and cube not in self.rewarded_cubes: + self.rewarded_cubes.add(cube) + return 25.0 + return 0.0 + + def _destination_color(self) -> int: + return 1 if self.level in (0, 2) else 2 + + def _round_complete(self) -> bool: + destination = self._destination_color() + return all(color == destination for color in self.colors.values()) + + def _move_enemies(self) -> None: + interval = max(1, 4 - self.level // 2) + if self.round_steps % interval: + return + for kind in list(self.enemies): + position = self.enemies[kind] + if kind == "coily": + self.enemies[kind] = self._chase_step(position) + continue + if position[0] >= 6: + if kind == "purple": + del self.enemies[kind] + self.enemies["coily"] = [6, position[1]] + else: + del self.enemies[kind] + continue + choose_right = (self.round_steps + len(kind) + self.round) % 2 + position[0] += 1 + position[1] += choose_right + if kind == "sam": + self.colors[tuple(position)] = self._reverted_color(self.colors[tuple(position)]) + + def _chase_step(self, position: list[int]) -> list[int]: + candidates = [] + for row_delta, column_delta in DIRECTIONS.values(): + target = (position[0] + row_delta, position[1] + column_delta) + if target in CUBES: + distance = abs(target[0] - self.player[0]) + abs(target[1] - self.player[1]) + candidates.append((distance, target)) + return list(min(candidates)[1]) if candidates else position + + def _reverted_color(self, color: int) -> int: + return max(0, color - 1) + + def _resolve_collisions(self) -> float: + reward = 0.0 + for kind in list(self.enemies): + if self.enemies[kind] != self.player: + continue + if kind == "sam": + if kind not in self.caught_rewards: + reward += 300.0 + self.caught_rewards.add(kind) + del self.enemies[kind] + elif kind == "green": + if kind not in self.caught_rewards: + reward += 100.0 + self.caught_rewards.add(kind) + self.freeze_timer = 4 + del self.enemies[kind] + else: + self._lose_life(fell=False) + break + return reward + + def _lose_life(self, fell: bool) -> None: + self.lives -= 1 + if self.lives <= 0: + self.terminal = True + return + if fell: + self.player = [0, 0] + + def _advance_round(self) -> None: + completed = self.level * 4 + self.round + 1 + if completed == 5 or (completed > 5 and (completed - 5) % 4 == 0): + self.lives += 1 + self.bonus_rounds.add(completed) + self.round += 1 + if self.round >= 4: + self.round = 0 + self.level += 1 + if self.level >= 5: + self.terminal = True + else: + self._start_round() + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[self.player[0] + 1, self.player[1] + 1, 0] = True + state[self.previous_player[0] + 1, self.previous_player[1] + 1, 4] = True + for kind, position in self.enemies.items(): + state[position[0] + 1, position[1] + 1, 1] = True + if kind in self.previous_enemies: + previous = self.previous_enemies[kind] + state[previous[0] + 1, previous[1] + 1, 4] = True + for cube, color in self.colors.items(): + row, column = cube + state[row + 1, column + 1, 2] = color >= 1 + state[row + 1, column + 1, 3] = color >= 2 + for cube in self.rewarded_cubes: + row, column = cube + state[row + 1, column + 1, 5] = True + state[4, 0, 3] = "left" in self.discs + state[4, 5, 3] = "right" in self.discs + cube_gauge_cells = {(row + 1, column + 1) for row, column in CUBES} + free_cells = [(row, column) for row in range(10) for column in range(10) if (row, column) not in cube_gauge_cells] + gauge_bits = [] + for bit in range(3): + gauge_bits.append(bool(self.level & (1 << bit))) + for bit in range(2): + gauge_bits.append(bool(self.round & (1 << bit))) + for bit in range(4): + gauge_bits.append(bool(self.lives & (1 << bit))) + for bit in range(13): + gauge_bits.append(bool(self.steps & (1 << bit))) + for bit in range(3): + gauge_bits.append(bool(self.freeze_timer & (1 << bit))) + gauge_bits.extend(kind in self.caught_rewards for kind in ("sam", "green", "coily")) + gauge_bits.extend(("left" in self.discs, "right" in self.discs)) + for kind in ("red", "purple", "sam", "green", "coily"): + position = self.enemies.get(kind) + code = 31 if position is None else position[0] * 7 + position[1] + for bit in range(5): + gauge_bits.append(bool(code & (1 << bit))) + for cell, value in zip(free_cells, gauge_bits): + state[*cell, 5] = value + return state diff --git a/runtime/minatar_synth/games/quantum_leaper.py b/runtime/minatar_synth/games/quantum_leaper.py new file mode 100644 index 0000000000000000000000000000000000000000..281bae1ba6b54681c82fa79308b0139885a9cf34 --- /dev/null +++ b/runtime/minatar_synth/games/quantum_leaper.py @@ -0,0 +1,88 @@ +from math import pi, sin + +import numpy as np + + +LANES = (20, 37.5, 55, 72.5, 90) + + +class QuantumLeaperEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.lane = self.gold = 2 + self.y = 50.0 + self.steps = self.frames = self.crossings = 0 + self.multiplier = 1 + self.gold_timer = 300 + self.held = self.terminal = False + self.particles = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap = held and not self.held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap): + self.frames += 1 + phase = self.frames / 10 + displacement = sin(phase) * 10 + reward = 0 + if phase >= self.crossings * pi: + self.crossings += 1 + if self.lane == self.gold: + reward = self.multiplier + self.multiplier = min(99, self.multiplier + 1) + else: + self.multiplier = max(1, self.multiplier - 1) + self.y = LANES[self.lane] + displacement + if tap: + self.lane = (self.lane + (1 if displacement > 0 else -1)) % len(LANES) + self.gold_timer -= 1 + if self.gold_timer < 0: + self.gold = self.random.integers(len(LANES)) + self.gold_timer += 300 + self.particles = [(x - 1, lane) for x, lane in self.particles if x >= 1] + self.terminal = any(abs(x - 20) < 3.5 and abs(LANES[lane] - self.y) < 3.5 + for x, lane in self.particles) + if self.random.random() < 0.02: + self.particles.append((103, self.random.integers(len(LANES)))) + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, int(self.y // 10)), 2, 0] = True + for x, lane in self.particles: + if x < 100: + state[int(LANES[lane] // 10), int(x // 10), 1] = True + state[int(LANES[self.gold] // 10), :, 2] = True + state[int(LANES[self.lane] // 10), 2, 3] = True + next_lane = (self.lane + (1 if sin((self.frames + 1) / 10) > 0 else -1)) % len(LANES) + state[int(LANES[next_lane] // 10), 2, 4] = True + for row, value in enumerate((self.steps, self.multiplier, self.gold_timer, self.held)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/r_ring.py b/runtime/minatar_synth/games/r_ring.py new file mode 100644 index 0000000000000000000000000000000000000000..bc30d709e84447dbebeaf28ce5cb6d7efed7be19 --- /dev/null +++ b/runtime/minatar_synth/games/r_ring.py @@ -0,0 +1,138 @@ +from collections import deque +from dataclasses import dataclass +from math import atan2, cos, hypot, pi, sin + +import numpy as np + + +@dataclass +class Ring: + x: float + y: float + radius: float = 1 + hit: bool = False + + def arcs(self): + r = self.radius + return ( + self._arc(self.x - r * 0.32, self.y, r * 0.2, 5 * pi / 6, 7 * pi / 6), + self._arc(self.x + r * 0.32, self.y, r * 0.2, -pi / 6, pi / 6), + self._arc(self.x, self.y + r * 0.3, r * 0.6, -3 * pi / 4, -pi / 4), + ) + + @staticmethod + def _arc(x, y, radius, start, end): + angles = np.linspace(start, end, max(2, int(radius * (end - start)) + 2)) + return x + radius * np.cos(angles), y + radius * np.sin(angles) + + +class RRingEnvironment: + score_cap = 200 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x = 50.0 + self.ship_x = self.ship_y = 20.0 + self.target_x = self.target_y = 20.0 + self.angle = 0.0 + self.move_ticks = self.stop_ticks = self.fire_ticks = 0 + self.power_ticks = 60 + self.options = self.action = self.steps = 0 + self.max_options = self.multiplier = 1 + self.history = deque(maxlen=99) + self.followers = [] + self.rings = [] + self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.action = action + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self): + self.x = min(99, max(0, self.x + 3 * ((self.action == 3) - (self.action == 1)))) + self.stop_ticks -= 1 + if self.stop_ticks < 0: + self.move_ticks = self.random.uniform(120, 180) + self.stop_ticks = self.move_ticks + self.random.uniform(40, 60) + self.move_ticks -= 1 + if self.move_ticks > 0: + if hypot(self.target_x - self.ship_x, self.target_y - self.ship_y) < 5: + self.target_x = self.random.uniform(10, 90) + self.target_y = self.random.uniform(3, 30) + target = atan2(self.target_y - self.ship_y, self.target_x - self.ship_x) + turn = (target - self.angle + pi) % (2 * pi) - pi + self.angle += min(0.1, max(-0.1, turn)) + self.ship_x = min(99, max(0, self.ship_x + 0.5 * cos(self.angle))) + self.ship_y = min(50, max(0, self.ship_y + 0.5 * sin(self.angle))) + self.history.appendleft((self.ship_x, self.ship_y)) + self.power_ticks -= 1 + if self.power_ticks < 0: + self.options += 1 + if self.options > self.max_options: + self.options = 0 + self.max_options = min(4, self.max_options + 1) + self.power_ticks = 300 / self.options if self.options else 60 + self.followers = [self.history[i * 24] for i in range(1, self.options + 1) + if i * 24 < len(self.history)] + self.fire_ticks -= 1 + if self.fire_ticks < 0: + self.rings.append(Ring(self.ship_x, self.ship_y)) + self.rings.extend(Ring(x, y) for x, y in self.followers) + self.fire_ticks = 60 + reward = 0 + remaining = [] + for ring in self.rings: + ring.y += 1 + ring.radius += 0.5 + left, right, center = ring.arcs() + self.terminal |= self._touches(left) or self._touches(right) + if not ring.hit and self._touches(center): + reward += self.multiplier + self.multiplier += 1 + ring.hit = True + if ring.y <= 110: + remaining.append(ring) + elif not ring.hit: + self.multiplier = max(1, self.multiplier - 1) + self.rings = remaining + return reward + + def _touches(self, arc): + x, y = arc + return bool(np.any((abs(x - self.x) < 4) & (abs(y - 95) < 4))) + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[9, int(self.x // 10), 0] = True + for x, y in [(self.ship_x, self.ship_y), *self.followers]: + state[int(y // 10), int(x // 10), 1] = True + for ring in self.rings: + for channel, (xs, ys) in zip((2, 2, 4 if ring.hit else 3), ring.arcs()): + visible = (0 <= xs) & (xs < 100) & (0 <= ys) & (ys < 100) + state[(ys[visible] // 10).astype(int), (xs[visible] // 10).astype(int), channel] = True + for row, value in enumerate((self.steps, self.multiplier, self.fire_ticks, self.options)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/r_wheel.py b/runtime/minatar_synth/games/r_wheel.py new file mode 100644 index 0000000000000000000000000000000000000000..8964cc211f6b5efa33bffd63f6b4673df6c67568 --- /dev/null +++ b/runtime/minatar_synth/games/r_wheel.py @@ -0,0 +1,151 @@ +from dataclasses import dataclass +from math import ceil, cos, floor, pi, sin + +import numpy as np + + +SECTOR = 2 * pi / 32 + + +@dataclass +class Bar: + y: float + grows_spikes: bool + width: float = 0 + + +class RWheelEnvironment: + score_cap = 1000 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.y = self.vy = self.angle = 0.0 + self.steps = 0 + self.multiplier = 1 + self.held = self.terminal = False + self.spikes = [0] * 32 + self.hit = [False] * 32 + self.bars = [] + self.bonuses = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap = held and not self.held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _add_bonus(self): + for _ in range(ceil(sum(height > 0 for height in self.spikes) / 9)): + angle = -2 * pi / 3 + self.random.uniform(-3 * pi / 4, 3 * pi / 4) + self.bonuses.append((angle, self.random.uniform(10, 30))) + + def _advance(self, tap): + if tap: + self.vy = -2 + self.hit = [False] * 32 + if self.y == 0: + self.y = self.vy + self.multiplier = 0 + self._add_bonus() + if self.y < 0: + previous = self.vy + self.vy = (self.vy + (0.03 if self.held else 0.09)) * 0.98 + if self.y < -74 and self.vy < 0: + self.vy *= -0.5 + if previous * self.vy <= 0: + self.bars.append(Bar(90 + self.y, True)) + self.y += self.vy + if self.y > 0: + self.y = self.vy = 0 + bonuses = [] + for angle, radius in self.bonuses: + if abs(radius * cos(angle)) < 5 and abs(50 + radius * sin(angle) - (87 + self.y)) < 6: + self.bars.append(Bar(90 + self.y, False)) + else: + bonuses.append((angle + 0.03, radius)) + self.bonuses = bonuses + for bar in self.bars: + bar.width += 1 if bar.grows_spikes else 2 + bar.y += 3 if bar.grows_spikes else 2 + self.bars = [bar for bar in self.bars if bar.y <= 103] + self.angle = (self.angle + 0.03) % (2 * pi) + reward = 0 + for index, height in enumerate(self.spikes): + xs, ys = self._spike_points(index, height) + if not self.hit[index] and any( + bar.grows_spikes and self._overlap(xs, ys, bar.y, bar.width / 2, 1.5) + for bar in self.bars + ): + height += 1 + self.hit[index] = True + if height: + if any(not bar.grows_spikes and self._overlap(xs, ys, bar.y, bar.width / 2, 1.5) + for bar in self.bars): + self.multiplier += height + reward += self.multiplier + height = 0 + elif self._overlap(xs, ys, 87 + self.y, 3, 3): + self.terminal = True + self.spikes[index] = height + if not any(self.spikes): + for angle in (-pi / 4, -3 * pi / 4): + self.spikes[floor((angle - self.angle) / SECTOR) % 32] = 1 + self._add_bonus() + return reward + + def _spike_points(self, index, height): + angle = self.angle + index * SECTOR + dx, dy = cos(angle), sin(angle) + radius = 40 - 4 * height + fractions = np.linspace(0, 1, 2 + 4 * height) + lengths = radius + (40 - radius) * fractions + side = fractions * (50 / 32) + return ( + np.concatenate((50 + dx * lengths - dy * side, 50 + dx * lengths + dy * side)), + np.concatenate((50 + dy * lengths + dx * side, 50 + dy * lengths - dx * side)), + ) + + @staticmethod + def _overlap(xs, ys, y, half_width, half_height): + return bool(np.any((abs(xs - 50) <= half_width) & (abs(ys - y) <= half_height))) + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[int((87 + self.y) // 10), 5, 0] = True + for index, height in enumerate(self.spikes): + if height: + x, y = self._spike_points(index, height) + visible = (x >= 0) & (x < 100) & (y >= 0) & (y < 100) + state[(y[visible] // 10).astype(int), (x[visible] // 10).astype(int), 1] = True + for angle, radius in self.bonuses: + state[int((50 + radius * sin(angle)) // 10), + int((50 + radius * cos(angle)) // 10), 2] = True + columns = np.arange(5, 100, 10) + for bar in self.bars: + if 0 <= bar.y < 100: + state[int(bar.y // 10), :, 3 if bar.grows_spikes else 4] |= abs(columns - 50) < bar.width / 2 + 5 + for row, value in enumerate((self.steps, self.multiplier, int(self.held), round((self.vy + 2) * 100))): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/raid.py b/runtime/minatar_synth/games/raid.py new file mode 100644 index 0000000000000000000000000000000000000000..5293f0a529850a0d796bf17978cfe2fc198d786d --- /dev/null +++ b/runtime/minatar_synth/games/raid.py @@ -0,0 +1,144 @@ +from dataclasses import dataclass +from math import ceil + +import numpy as np + + +@dataclass +class Bomb: + x: float + y: float + vx: float + vy: float + + +@dataclass +class Debris: + x: float + y: float + vy: float + + +class RaidEnvironment: + score_cap = 300 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.y = 50.0, 15.0 + self.vx, self.vy, self.speed = 1.0, 0.0, 1.0 + self.down_distance = self.recoil = 0.0 + self.steps = self.frame = 0 + self.held = self.terminal = False + self.bomb = None + self.heights = self.random.uniform(10, 60, 8) + self.debris = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + released = self.held and not held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(released and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, released): + scroll = max(0, self.y - 15) * 0.05 + if self.held: + self.speed += 0.01 + else: + self.speed += (1 - self.speed) * 0.2 + if released and self.bomb is None and self.frame > 30: + self.bomb = Bomb(self.x, self.y, self.vx * self.speed, self.vy * self.speed) + self.recoil = 0.33 + self.x += self.vx * self.speed + self.y += self.vy * self.speed + self.recoil - scroll + self.recoil *= 0.8 + if self.vy == 0: + if (self.x < 10 and self.vx < 0) or (self.x > 90 and self.vx > 0): + self.vy = 0.1 + self.down_distance = 1 + else: + direction = 1 if self.x < 50 else -1 + self.vx += (direction - self.vx) * 0.05 + self.down_distance -= self.vy * self.speed + if self.down_distance < 0: + self.vx, self.vy = direction, 0 + bomb = self.bomb + if bomb is not None: + bomb.vy = (bomb.vy + 0.1) * 0.99 + bomb.vx *= 0.99 + bomb.x += bomb.vx + bomb.y += bomb.vy - scroll + if (bomb.x < 0 and bomb.vx < 0) or (bomb.x > 99 and bomb.vx > 0): + bomb.vx *= -1 + if bomb.y > 99: + self.bomb = bomb = None + for fragment in self.debris: + fragment.vy += 0.1 + fragment.y += fragment.vy - scroll + self.debris = [fragment for fragment in self.debris if fragment.y <= 110] + old_debris = tuple(self.debris) + self.heights += scroll + reward = 0 + for index, height in enumerate(self.heights): + x = 10 + index * 10 + blocks = ceil(height / 10) + base = 100 - height + blocks * 10 + for block in range(blocks): + y = base - block * 10 + if bomb is not None and self._touches(x, y, bomb.x, bomb.y, 1.5, 1.5): + removed = blocks - block + reward += removed * (removed + 1) // 2 + self.heights[index] = max(0, 100 - y) + self.bomb = bomb = None + for offset in range(1, removed): + self.debris.append(Debris(x, y - 10 * offset, -(offset + 1) * 0.5)) + break + if any(abs(fragment.x - x) < 9 and abs(fragment.y - y) < 10 for fragment in old_debris): + self.heights[index] = max(0, 100 - y) + if self._touches(x, y, self.x, self.y, 3, 2.5): + self.terminal = True + self.frame += 1 + return reward + + @staticmethod + def _touches(x, y, px, py, half_width, half_height): + return x - half_width < px < x + 9 + half_width and y - half_height < py < y + 10 + half_height + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[int(np.clip(self.y // 10, 0, 9)), int(np.clip(self.x // 10, 0, 9)), 0] = True + if self.bomb is not None and 0 <= self.bomb.x < 100 and 0 <= self.bomb.y < 100: + state[int(self.bomb.y // 10), int(self.bomb.x // 10), 1] = True + rows = np.arange(10) * 10 + for index, height in enumerate(self.heights): + if height > 0: + state[rows + 10 > 110 - height, index + 1, 2] = True + for fragment in self.debris: + state[(rows < fragment.y + 10) & (rows + 10 > fragment.y), int(fragment.x // 10), 3] = True + ahead = self.x + self.vx * 10 + state[int(np.clip((self.y + self.vy * 10) // 10, 0, 9)), + int(np.clip(ahead // 10, 0, 9)), 4] = True + for row, value in enumerate((self.steps, round(self.speed * 100), self.held, self.vy > 0)): + for bit in range(11): + state[row + bit // 10 * 4, bit % 10, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/rb_drive.py b/runtime/minatar_synth/games/rb_drive.py new file mode 100644 index 0000000000000000000000000000000000000000..a2bc3c8fb9b7afa7ca3de1837bc5037412354c40 --- /dev/null +++ b/runtime/minatar_synth/games/rb_drive.py @@ -0,0 +1,115 @@ +from dataclasses import dataclass + +import numpy as np + + +DIRECTIONS = np.array(((1, 0), (0, 1), (-1, 0), (0, -1))) + + +@dataclass +class Car: + lane: int + color: int + phase: float = 0 + entry: int = 0 + + def position(self): + direction = DIRECTIONS[self.lane] + shoulder = DIRECTIONS[(self.lane + 1) % 4] * 5 + if self.phase < 1: + offset = direction * (50 - 40 * self.phase) + shoulder + elif self.phase < 2: + start = DIRECTIONS[self.entry] * 10 + DIRECTIONS[(self.entry + 1) % 4] * 5 + end = direction * 10 - shoulder + offset = start + (end - start) * (self.phase - 1) + else: + offset = direction * (10 + 40 * (self.phase - 2)) - shoulder + return 50 + offset + + +class RBDriveEnvironment: + score_cap = 16 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.lane = 3 + self.health = np.full(4, 0.7) + self.cars = [] + self.spawn_timer = self.color_count = self.steps = 0 + self.color = int(self.random.integers(2)) + self.held = self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + if held and not self.held: + self.lane = (self.lane + 1) % 4 + self.held = held + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self): + self.spawn_timer -= 1 + if self.spawn_timer < 0: + self.color_count -= 1 + if self.color_count < 0: + self.color = 1 - self.color + self.color_count = int(self.random.integers(1, 4)) + self.cars.append(Car(int(self.random.integers(4)), self.color)) + self.spawn_timer += self.random.uniform(80, 99) + reward = 0 + remaining = [] + for car in self.cars: + previous = car.phase + car.phase += 0.05 if 1 < previous < 2 else 0.01 + if previous < 1 <= car.phase: + car.entry = car.lane + car.lane = self.lane if self.lane != car.entry else (car.entry + 2) % 4 + if car.phase <= 3: + remaining.append(car) + elif car.lane % 2 == car.color: + self.health[car.lane] *= 0.66 + else: + self.health[car.lane] = min(1, self.health[car.lane] + 0.3) + reward += 1 + self.cars = remaining + self.health -= 0.0006 + self.terminal = bool(np.any(self.health < 0.01)) + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + for car in self.cars: + x, y = np.clip(car.position() // 10, 0, 9).astype(int) + state[y, x, car.color] = True + if car.phase >= 1: + state[y, x, 4] = True + for lane, (dx, dy) in enumerate(DIRECTIONS): + for distance in range(1, 5): + row, col = 5 + dy * distance, 5 + dx * distance + state[row, col, 2] = lane == self.lane + state[row, col, 3] = self.health[lane] > (distance - 1) / 4 + gauges = (self.steps, self.held, *(round(value * 100) for value in self.health)) + for row, value in enumerate(gauges): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/rebirth.py b/runtime/minatar_synth/games/rebirth.py new file mode 100644 index 0000000000000000000000000000000000000000..b98ca00aafca0ec2f8f62b07f7a6527abe453a55 --- /dev/null +++ b/runtime/minatar_synth/games/rebirth.py @@ -0,0 +1,130 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Arrival: + x: float + world: int + y: float = 37 + + +class RebirthEnvironment: + score_cap = 60 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.y, self.offset = 110.0, 37.0, 10.0 + self.vx = self.vy = 0.0 + self.world = self.track_world = self.diamond_world = 1 + self.track_timer = self.steps = 0 + self.diamond_timer = 60 + self.diamond_count = self.multiplier = 1 + self.mode = "run" + self.held = self.terminal = False + self.tracks = [] + self.diamonds = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap = held and not self.held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap): + self.track_timer -= 1 + if self.track_timer < 0: + self.tracks.append(Arrival(100 + self.track_world * 103, self.track_world)) + self.track_world *= -1 + self.track_timer = self.random.uniform(50, 60) + for track in self.tracks: + track.x -= track.world + self.tracks = [track for track in self.tracks if (track.x - 100) * track.world >= 3] + + self.x += self.vx + self.y += self.vy + self.vx *= 0.792 + self.vy *= 0.99 + if self.mode == "run": + self.x += (100 + self.world * self.offset - self.x) * 0.05 + self.offset = min(80, self.offset + 0.3) + if tap: + self.mode, self.vy = "jump", -2 + else: + jumping = self.mode == "jump" + if jumping: + self.vy += 0.07 if self.held else 0.14 + if self.y > 37: + self.y, self.vy, self.mode = 37, 0, "run" + if jumping and tap: + self.mode, self.vy = "land", 4 + if abs(self.vx) < 2 and any(self._touches(track) for track in self.tracks): + self.vx = -self.world * self.offset * 0.2 + self.world *= -1 + self.offset = 10 + self.multiplier = max(1, self.multiplier - 1) + + self.diamond_timer -= 1 + if self.diamond_timer < 0: + self.diamond_count -= 1 + if self.diamond_count < 0: + self.diamond_world *= -1 + self.diamond_count = int(self.random.integers(4)) + y = 37 if self.random.random() < 0.5 else self.random.uniform(20, 30) + self.diamonds.append(Arrival(100 + self.diamond_world * 103, self.diamond_world, y)) + self.diamond_timer = self.random.uniform(120, 150) + reward = 0 + remaining = [] + for diamond in self.diamonds: + diamond.x -= diamond.world / 3 + if self._touches(diamond): + reward += self.multiplier + self.multiplier += 1 + else: + self.terminal |= (diamond.x - 100) * diamond.world < 3 + remaining.append(diamond) + self.diamonds = remaining + return reward + + def _touches(self, arrival): + return abs(arrival.x - self.x) < 5 and abs(arrival.y - self.y) < 5 + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[int(np.clip(self.y // 5, 0, 9)), int(np.clip(self.x // 20, 0, 9)), 0] = True + for channel, arrivals in ((1, self.tracks), (2, self.diamonds)): + for arrival in arrivals: + if 0 <= arrival.x < 200: + state[int(arrival.y // 5), int(arrival.x // 20), channel] = True + state[8:, 5:, 3] = True + state[:8, :5, 3] = True + target = 100 + self.world * self.offset + state[7, int(target // 20), 4] = True + gauges = (self.steps, self.multiplier, ("run", "jump", "land").index(self.mode), + self.held, round((self.vy + 2) * 50)) + for row, value in enumerate(gauges): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/recoil_radar.py b/runtime/minatar_synth/games/recoil_radar.py new file mode 100644 index 0000000000000000000000000000000000000000..03fc4e6e31d7c29ffcb58f3c5f74fdbaf1ee4373 --- /dev/null +++ b/runtime/minatar_synth/games/recoil_radar.py @@ -0,0 +1,131 @@ +from dataclasses import dataclass +from math import atan2, cos, floor, sin + +import numpy as np + + +@dataclass +class Hazard: + position: np.ndarray + velocity: np.ndarray + size: float + + +class RecoilRadarEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.position = np.array([50.0, 50.0]) + self.velocity = np.zeros(2) + self.charge = self.steps = self.shot_ticks = 0 + self.radius = 8.0 + self.timer = 45 + self.held = self.terminal = False + self.hazards = [] + self.shot = None + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance(held) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, held): + reward = 0 + if held: + self.charge += 1 + self.radius = min(46, 8 + self.charge * 0.55) + elif self.held: + target_index = None + distance = self.radius + if self.charge >= 10: + for index, hazard in enumerate(self.hazards): + candidate = np.linalg.norm(self.position - hazard.position) + if candidate <= distance: + target_index, distance = index, candidate + if target_index is not None: + target = self.hazards.pop(target_index) + delta = self.position - target.position + angle = atan2(delta[1], delta[0]) + self.velocity += (1.2 + (46 - distance) * 0.025) * np.array([cos(angle), sin(angle)]) + self.shot = (self.position.copy(), target.position.copy()) + self.shot_ticks = 5 + reward = floor(55 - distance + 0.5) + self.charge, self.radius = 0, 8.0 + self.held = held + self.position += self.velocity + self.velocity *= 0.985 + lower = np.array([8, 9]) + self.velocity = np.where(self.position < lower, abs(self.velocity) * 0.8, self.velocity) + self.velocity = np.where(self.position > 92, -abs(self.velocity) * 0.8, self.velocity) + np.clip(self.position, lower, 92, out=self.position) + self.timer -= 1 + if self.timer < 0: + self._spawn() + self.timer += 72 + angle = atan2(self.velocity[1], self.velocity[0]) + direction = np.array([cos(angle), sin(angle)]) + bar = self.position + np.linspace(-4.5, 4.5, 10)[:, None] * direction + remaining = [] + for hazard in self.hazards: + hazard.position += hazard.velocity * 0.63 + half = hazard.size / 2 + body_hit = np.all(abs(self.position - hazard.position) < half + 3) + bar_hit = np.any(np.all(abs(bar - hazard.position) < half + 1, axis=1)) + self.terminal |= bool(body_hit or bar_hit) + if np.all((-12 <= hazard.position) & (hazard.position <= 112)): + remaining.append(hazard) + self.hazards = remaining + self.shot_ticks = max(0, self.shot_ticks - 1) + return reward + + def _spawn(self): + offset = self.random.uniform(10, 90) + edge = self.random.integers(4) + position = np.array(((offset, -5), (105, offset), (offset, 105), (-5, offset))[edge]) + delta = self.position - position + angle = atan2(delta[1], delta[0]) + self.random.uniform(-0.45, 0.45) + self.hazards.append(Hazard(position, np.array([cos(angle), sin(angle)]), self.random.uniform(5, 8))) + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + x, y = (self.position // 10).astype(int) + state[y, x, 0] = True + for hazard in self.hazards: + hx, hy = (hazard.position // 10).astype(int) + if 0 <= hx < 10 and 0 <= hy < 10: + revealed = self.charge >= 10 and np.linalg.norm(hazard.position - self.position) <= self.radius + state[hy, hx, 1 + int(revealed)] = True + if self.held: + rows, cols = np.ogrid[5:100:10, 5:100:10] + state[:, :, 3] = np.hypot(cols - self.position[0], rows - self.position[1]) <= self.radius + if self.shot_ticks: + points = np.linspace(*self.shot, 50) + xs, ys = np.clip(points // 10, 0, 9).astype(int).T + state[ys, xs, 4] = True + gauges = (self.steps, min(511, self.charge), self.timer, self.held, + int(round(self.velocity[0] * 16)) + 256, int(round(self.velocity[1] * 16)) + 256) + for row, value in enumerate(gauges): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/refbals.py b/runtime/minatar_synth/games/refbals.py new file mode 100644 index 0000000000000000000000000000000000000000..43bb225510f9f81dc89afe4b128b5379b1232c31 --- /dev/null +++ b/runtime/minatar_synth/games/refbals.py @@ -0,0 +1,85 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Ball: + x: float + y: float = 0 + velocity: float = 0 + + +class RefbalsEnvironment: + score_cap = 100 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.steps = self.frame = 0 + self.held = self.terminal = False + self.balls = [] + self.walls = [(-29 * i, -9) for i in range(5)] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.held = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self): + if self.frame % 99 == 0: + self.balls.append(Ball(self.random.uniform(0, 50))) + moving_walls = [(x - (2 if self.held else 1), y) for x, y in self.walls] + self.walls = [ + (x + self.random.uniform(130, 150), self.random.uniform(50, 90)) + if x < -19 else (x, y) + for x, y in moving_walls + ] + reward = 0 + for ball in self.balls: + ball.velocity += 0.03 + ball.y += ball.velocity + self.terminal |= ball.y > 99 + if any(abs(ball.x - x) < 20.5 and abs(ball.y - y) < 4 for x, y in moving_walls): + reward += 1 + ball.velocity *= -1 + ball.y += ball.velocity * 2 + self.frame += 1 + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + rows, cols = np.ogrid[:100:10, :100:10] + for x, y in self.walls: + state[:, :, 2] |= (cols < x + 18) & (cols + 10 > x - 18) & (rows < y + 1.5) & (rows + 10 > y - 1.5) + for ball in self.balls: + row, col = int(np.clip(ball.y // 10, 0, 9)), int(ball.x // 10) + state[row, col, int(ball.velocity < 0)] = True + if ball.y < 0: + state[0, col, 3] = True + if ball.y >= 80 and ball.velocity > 0: + state[row, col, 4] = True + for row, value in enumerate((self.steps, self.frame % 99, self.held)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/reflector.py b/runtime/minatar_synth/games/reflector.py new file mode 100644 index 0000000000000000000000000000000000000000..e987ddae94298391da55dda3dd53d9fc6ddb4258 --- /dev/null +++ b/runtime/minatar_synth/games/reflector.py @@ -0,0 +1,168 @@ +from dataclasses import dataclass +from math import atan2, cos, hypot, pi, sin + +import numpy as np + + +@dataclass +class Tank: + x: float + speed: float + turn: float + interval: float + timer: float + shot_speed: float + angle: float = -pi / 2 + + +@dataclass +class Bullet: + x: float + y: float + vx: float + vy: float + + +@dataclass +class Blast: + x: float + y: float + radius: float + duration: float + age: int = 0 + + def reach(self): + return self.radius * sin(pi * self.age / self.duration) + + +class ReflectorEnvironment: + score_cap = 100 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.direction = 40.0, 1 + self.angle = self.power = 0.0 + self.timer = self.steps = 0 + self.multiplier = 1 + self.held = self.terminal = False + self.tanks = [] + self.bullets = [] + self.blasts = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap = held and not self.held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap): + if tap or (self.x < 3 and self.direction < 0) or (self.x > 97 and self.direction > 0): + self.direction *= -1 + if self.held: + self.power += (1 - self.power) * 0.05 + else: + self.power *= 0.9 + self.angle = min(pi / 4, max(-pi / 4, self.angle - self.direction * 0.07)) + self.x += self.direction * (0.25 if self.held else 0.5) + if not self.tanks: + self.timer = 0 + self.timer -= 1 + if self.timer < 0: + direction = self.random.choice((-1, 1)) + interval = self.random.uniform(200, 300) + agility = self.random.uniform(1, 5) + self.tanks.append(Tank(-3 if direction > 0 else 103, direction * 0.1 / agility ** 0.5, + agility * 0.002, interval, interval, self.random.uniform(1, 1.5))) + self.timer = self.random.uniform(60, 80) + if not self.blasts: + self.multiplier = 1 + for blast in self.blasts: + blast.age += 1 + self.blasts = [blast for blast in self.blasts if blast.age <= blast.duration] + reward = 0 + tanks = [] + for tank in self.tanks: + tank.x += tank.speed + aim = atan2(-78, self.x - tank.x) + tank.angle += min(tank.turn, max(-tank.turn, aim - tank.angle)) + if any(hypot(tank.x - blast.x, 87 - blast.y) <= blast.reach() + 3 for blast in self.blasts): + reward += self.multiplier + self.multiplier += 1 + continue + tank.timer -= 1 + if tank.timer < 0: + self.bullets.append(Bullet(tank.x, 87, cos(tank.angle) * tank.shot_speed, + sin(tank.angle) * tank.shot_speed)) + tank.timer = tank.interval + if -3 <= tank.x <= 103: + tanks.append(tank) + self.tanks = tanks + bullets = [] + for bullet in self.bullets: + bullet.x += bullet.vx + bullet.y += bullet.vy + if bullet.vy < 0: + if self._shield_hit(bullet): + angle = 2 * self.angle - atan2(bullet.vy, bullet.vx) + speed = hypot(bullet.vx, bullet.vy) * (1 + 4 * self.power) + bullet.vx, bullet.vy = speed * cos(angle), speed * sin(angle) + bullet.x += bullet.vx * 2 + bullet.y = max(20, bullet.y + bullet.vy * 2) + elif abs(bullet.x - self.x) < 5 and abs(bullet.y - 9) < 5: + self.terminal = True + if bullet.vy > 0 and (bullet.y >= 88 or any( + abs(bullet.x - tank.x) < 5 and abs(bullet.y - 87) < 5 for tank in self.tanks + )): + speed = hypot(bullet.vx, bullet.vy) + self.blasts.append(Blast(bullet.x, bullet.y, speed ** 2, speed * 9)) + elif -3 <= bullet.x <= 103 and -3 <= bullet.y <= 103: + bullets.append(bullet) + self.bullets = bullets + return reward + + def _shield_hit(self, bullet): + dx = bullet.x - (self.x - 6 * sin(self.angle)) + dy = bullet.y - (9 + 6 * cos(self.angle)) + parallel = dx * cos(self.angle) + dy * sin(self.angle) + normal = -dx * sin(self.angle) + dy * cos(self.angle) + return abs(parallel) < (9 - self.power * 9) / 2 + 2 and abs(normal) < (3 + self.power * 3) / 2 + 2 + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[0, int(self.x // 10), 0] = True + for tank in self.tanks: + if 0 <= tank.x < 100: + state[8, int(tank.x // 10), 1] = True + for bullet in self.bullets: + if 0 <= bullet.x < 100 and 0 <= bullet.y < 100: + state[int(bullet.y // 10), int(bullet.x // 10), 2 + int(bullet.vy >= 0)] = True + rows, cols = np.ogrid[5:100:10, 5:100:10] + for blast in self.blasts: + state[:, :, 4] |= np.hypot(cols - blast.x, rows - blast.y) <= blast.reach() + 5 + gauges = (self.steps, self.multiplier, round(self.power * 100), + round((self.angle + pi / 4) * 100), self.direction > 0, self.held) + for row, value in enumerate(gauges): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/regene.py b/runtime/minatar_synth/games/regene.py new file mode 100644 index 0000000000000000000000000000000000000000..c45537777ed7046a76edada21db699d0b279d478 --- /dev/null +++ b/runtime/minatar_synth/games/regene.py @@ -0,0 +1,160 @@ +from dataclasses import dataclass +from math import cos, pi, sin, sqrt + +import numpy as np + + +@dataclass +class Tile: + x: float + y: float + seed: bool = False + + +@dataclass +class Ball: + x: float + y: float + vx: float + vy: float + hits: int = 0 + + +class RegeneEnvironment: + score_cap = 1000 + moves = ((0, 0), (-1, 0), (0, -1), (1, 0), (0, 1), (0, 0)) + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x = self.y = 50 + self.steps = self.action = 0 + self.distance = 0.0 + self.terminal = False + self.tiles = [] + self.erased = [] + self.balls = [self._ball(20, 50)] + + def _ball(self, x, y): + angle = self.random.uniform(-0.1, 0.1) * pi + self.random.choice((-1, 1)) * 0.7 * pi + return Ball(x, y, cos(angle), sin(angle)) + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.action = action + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _spawn(self, population): + width = self.random.integers(3, 7) + gap = 0 if self.random.random() < 0.4 else self.random.integers(2, 6) + top = int(gap + self.random.random() * (8 - 2 * gap)) + for col in range(width): + for row in range(8): + if not top <= row < top + gap: + self.tiles.append(Tile(105 + col * 10 - self.distance, 15 + row * 10, + self.random.random() < 0.1 / population)) + self.distance += (width + self.random.integers(3)) * 10 + + def _advance(self): + dx, dy = self.moves[self.action] + self.x = min(99, max(0, self.x + 3 * dx)) + self.y = min(99, max(0, self.y + 3 * dy)) + population = sqrt(len(self.balls)) + scroll = 0.05 * (population + max(0, self.x - 90)) + self.distance -= scroll + if self.distance < 0: + self._spawn(population) + for tile in self.erased: + tile.x -= scroll + self.erased = [tile for tile in self.erased if tile.x >= 14] + remaining = [] + for tile in self.tiles: + tile.x -= scroll + reach = 5.5 if tile.seed else 6.5 + if abs(tile.x - self.x) < reach and abs(tile.y - self.y) < reach: + if not tile.seed: + self.erased.append(tile) + continue + if tile.x < 97: + self.balls.append(self._ball(tile.x, tile.y)) + continue + if tile.x >= (13 if tile.seed else 14): + remaining.append(tile) + overflow = max(0, len(self.erased) - 9) + restored = self.erased[:overflow] + solids = [(tile.x, tile.y) for tile in remaining if not tile.seed] + self.tiles = remaining + restored + self.erased = self.erased[overflow:] + reward = 0 + survivors = [] + for ball in self.balls: + ball.x -= scroll + hit_x = self._blocked(ball.x + ball.vx, ball.y, solids) + hit_y = self._blocked(ball.x, ball.y + ball.vy, solids) + if hit_x: + ball.vx *= -1 + ball.x += 2 * ball.vx + if hit_y: + ball.vy *= -1 + ball.y += 2 * ball.vy + if ball.x < 14: + ball.x = 14 + ball.vx = abs(ball.vx) + if hit_x or hit_y: + if not ball.hits: + reward += len(self.balls) + ball.hits += 1 + else: + ball.hits = 0 + if ball.hits <= 9: + ball.x += ball.vx + ball.y += ball.vy + survivors.append(ball) + self.balls = survivors + self.terminal = not survivors + return reward + + @staticmethod + def _blocked(x, y, solids): + return x < 13 or x > 97 or y < 13 or y > 87 or any( + abs(x - sx) < 7 and abs(y - sy) < 7 for sx, sy in solids + ) + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[self.y // 10, self.x // 10, 0] = True + for tile in self.tiles: + if 0 <= tile.x < 100: + state[int(tile.y // 10), int(tile.x // 10), 1 + int(tile.seed)] = True + for ball in self.balls: + x = int(np.clip(ball.x // 10, 0, 9)) + y = int(np.clip(ball.y // 10, 0, 9)) + state[y, x, 3] = True + if len(self.erased) == 9: + oldest = self.erased[0] + if 0 <= oldest.x < 100: + state[int(oldest.y // 10), int(oldest.x // 10), 4] = True + for row, value in enumerate((self.steps, len(self.erased), self.action)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/revolve_a.py b/runtime/minatar_synth/games/revolve_a.py new file mode 100644 index 0000000000000000000000000000000000000000..c813ee37a183348936229be6df2de5937f26dd00 --- /dev/null +++ b/runtime/minatar_synth/games/revolve_a.py @@ -0,0 +1,120 @@ +from math import cos, pi, sin + +import numpy as np + + +class RevolveAEnvironment: + score_cap = 200 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.position = np.array([50.0, 50.0]) + self.velocity = np.full(2, 2 ** -0.5) + self.angle = -pi / 2 + self.steps = self.timer = 0 + self.held = self.terminal = False + self.enemies = np.empty((0, 2)) + self.velocities = np.empty((0, 2)) + self.removed = np.empty(0, dtype=bool) + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap = held and not self.held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _spawn(self): + position = np.array([self.random.uniform(0, 99), self.random.choice((-3, 103))]) + if self.random.random() < 0.5: + position = position[::-1] + delta = self.random.uniform(10, 90, 2) - position + self.enemies = np.vstack((self.enemies, position)) + self.velocities = np.vstack((self.velocities, 0.3 * delta / np.linalg.norm(delta))) + self.removed = np.append(self.removed, False) + + def _advance(self, tap): + self.timer -= 1 + if self.timer < 0: + self._spawn() + self.timer = self.random.uniform(30, 40) + count = int(self.removed.sum()) + self.enemies[~self.removed] += self.velocities[~self.removed] + keep = ~self.removed & np.all((self.enemies >= -5) & (self.enemies <= 105), axis=1) + self.enemies = self.enemies[keep] + self.velocities = self.velocities[keep] + self.removed = np.zeros(len(self.enemies), dtype=bool) + if tap: + self.velocity[:] = cos(self.angle), sin(self.angle) + bounce = ((self.position < 3) & (self.velocity < 0)) | ((self.position > 97) & (self.velocity > 0)) + self.velocity[bounce] *= -1 + self.position += self.velocity * 0.4 + self.angle = (self.angle + 0.08) % (2 * pi) + delta = self.enemies - self.position + self.terminal = bool(np.any(np.all(abs(delta) < 4.5, axis=1))) + if not self.terminal: + links = self._links() + if len(links): + starts, ends = self.enemies[links[:, 0]], self.enemies[links[:, 1]] + vectors = ends - starts + lengths = np.sum(vectors ** 2, axis=1) + projected = np.divide(np.sum((self.position - starts) * vectors, axis=1), + lengths, out=np.zeros_like(lengths), where=lengths > 0) + closest = starts + np.clip(projected, 0, 1)[:, None] * vectors + if np.any(np.linalg.norm(closest - self.position, axis=1) < 3): + self.removed = np.linalg.norm(delta, axis=1) < 30 + while True: + touching = self.removed[links].any(axis=1) + linked = links[touching].ravel() + if self.removed[linked].all(): + break + self.removed[linked] = True + return count * (count + 1) // 2 + + def _links(self): + left, right = np.triu_indices(len(self.enemies), 1) + near = np.linalg.norm(self.enemies[left] - self.enemies[right], axis=1) < 30 + return np.column_stack((left[near], right[near])) + + @staticmethod + def _mark(state, points, channel): + visible = np.all((points >= 0) & (points < 100), axis=1) + cols, rows = (points[visible] // 10).astype(int).T + state[rows, cols, channel] = True + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + self._mark(state, self.position[None], 0) + self._mark(state, self.enemies[~self.removed], 1) + for left, right in self._links(): + if not (self.removed[left] or self.removed[right]): + self._mark(state, np.linspace(self.enemies[left], self.enemies[right], 31), 2) + aim = self.position + 10 * np.array([cos(self.angle), sin(self.angle)]) + self._mark(state, np.clip(aim, 0, 99)[None], 3) + self._mark(state, self.enemies[self.removed], 4) + for row, value in enumerate((self.steps, self.held, round(self.angle * 50), + round((self.velocity[0] + 1) * 100), + round((self.velocity[1] + 1) * 100))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/ricochet_pins.py b/runtime/minatar_synth/games/ricochet_pins.py new file mode 100644 index 0000000000000000000000000000000000000000..da25852b14fe28ac9a4de010d06bafa11facc06e --- /dev/null +++ b/runtime/minatar_synth/games/ricochet_pins.py @@ -0,0 +1,131 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Pin: + position: np.ndarray + velocity: np.ndarray + + +class RicochetPinsEnvironment: + score_cap = 1000 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.position = np.full(2, 50.0) + self.velocity = np.array([0.5, 0.0]) + self.steps = self.heat = self.shot_timer = 0 + self.pin_count = 5 + self.multiplier = 1 + self.held = self.overheated = self.terminal = False + self.shot_target = None + self._spawn_wave() + + def _spawn_wave(self): + self.pins = [] + for _ in range(self.pin_count): + for _ in range(50): + position = self.random.uniform(15, 85, 2) + if np.linalg.norm(position - self.position) > 30: + break + velocity = np.zeros(2) + if self.random.random() < 0.4: + velocity[self.random.integers(2)] = self.random.choice((-0.35, 0.35)) + self.pins.append(Pin(position, velocity)) + for _ in range(50): + self.item = self.random.uniform(15, 85, 2) + if np.linalg.norm(self.item - self.position) > 20 and all( + np.linalg.norm(self.item - pin.position) >= 15 for pin in self.pins + ): + break + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap = held and not self.held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + @staticmethod + def _bounce(position, velocity, radius): + crossed = (position < radius) | (position > 100 - radius) + velocity[crossed] *= -1 + np.clip(position, radius, 100 - radius, out=position) + + def _advance(self, tap): + self.position += self.velocity + self.velocity *= 0.98 + self.heat = max(0, self.heat - 1) + if self.heat <= 30: + self.overheated = False + radius = 3 * (1 + 0.008 * self.heat) + self._bounce(self.position, self.velocity, radius) + for pin in self.pins: + pin.position += pin.velocity + self._bounce(pin.position, pin.velocity, 3) + distances = [np.linalg.norm(pin.position - self.position) for pin in self.pins] + self.terminal = any(distance < radius + 3 for distance in distances) + reward = 0 + if self.item is not None and np.linalg.norm(self.item - self.position) < 7: + reward += 10 * self.multiplier + self.multiplier += 1 + self.item = None + self.shot_timer = max(0, self.shot_timer - 1) + if tap and distances and not self.overheated and not self.terminal: + index = int(np.argmin(distances)) + self.shot_target = self.pins.pop(index).position + self.shot_timer = 9 + self.velocity += 2 * (self.position - self.shot_target) / distances[index] + reward += self.multiplier + self.heat = min(100, self.heat + 25) + self.overheated = self.heat == 100 + if not self.pins: + self.pin_count = min(64, self.pin_count + 1) + self._spawn_wave() + reward += self.pin_count * self.multiplier * 2 + return reward + + @staticmethod + def _mark(state, position, channel): + col, row = (position // 10).astype(int) + state[row, col, channel] = True + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + self._mark(state, self.position, 0) + for pin in self.pins: + self._mark(state, pin.position, 1 + int(np.any(pin.velocity))) + if self.item is not None: + self._mark(state, self.item, 3) + if self.shot_timer: + for point in np.linspace(self.position, self.shot_target, 20): + self._mark(state, point, 4) + gauges = (self.steps, self.heat, self.overheated, self.multiplier, + self.pin_count, self.held, round(self.velocity[0] * 20) + 256, + round(self.velocity[1] * 20) + 256) + for row, value in enumerate(gauges): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/ring_blast.py b/runtime/minatar_synth/games/ring_blast.py new file mode 100644 index 0000000000000000000000000000000000000000..87d2aba0207ad507e9fec7e98b699615f2a8b39f --- /dev/null +++ b/runtime/minatar_synth/games/ring_blast.py @@ -0,0 +1,170 @@ +from dataclasses import dataclass +from math import atan2, cos, pi, sin + +import numpy as np + + +CENTER = np.array([50, 60]) + + +@dataclass +class Stone: + position: np.ndarray + velocity: np.ndarray + side: int + fuse: int = 60 + + +@dataclass +class Ring: + radius: float + angle: float + spread: float + growth: float + + +class RingBlastEnvironment: + score_cap = 300 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.stones = [] + self.rings = [] + self.angle, self.enemy_angle = -pi / 2, pi / 2 + self.speed = self.enemy_speed = 1.0 + self.angle_direction = self.speed_direction = 1 + self.ammo, self.timer = 10, 100 + self.multiplier = 1 + self.action = self.steps = 0 + self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.action = action + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _aim(self): + self.angle += 0.03 * ((self.action == 3) - (self.action == 1)) + self.angle = min(-pi / 6, max(-5 * pi / 6, self.angle)) + self.speed = min(4, max(1, self.speed + 0.05 * ((self.action == 2) - (self.action == 4)))) + self.enemy_angle += self.angle_direction * self.random.uniform(0.02, 0.03) + if abs(self.enemy_angle - pi / 2) > pi / 3 and (self.enemy_angle - pi / 2) * self.angle_direction > 0: + self.angle_direction *= -1 + self.enemy_speed += self.speed_direction * self.random.uniform(0.03, 0.04) + if (self.enemy_speed > 4 and self.speed_direction > 0) or (self.enemy_speed < 1 and self.speed_direction < 0): + self.speed_direction *= -1 + + def _advance(self): + self._aim() + self.timer = max(0, self.timer - 1) + if self.timer == 0: + if self.ammo: + self.ammo -= 1 + self.timer = 100 + launches = ((120, self.angle, self.speed), (0, self.enemy_angle, self.enemy_speed)) + for side, (y, angle, speed) in enumerate(launches): + self.stones.append(Stone(np.array([50., float(y)]), + speed * np.array([cos(angle), sin(angle)]), side)) + elif not self.rings and not any(stone.side == 2 for stone in self.stones): + self.terminal = True + return 0 + for ring in self.rings: + ring.spread += ring.growth + active_rings = tuple(self.rings) + reward = 0 + survivors = [] + for stone in self.stones: + stone.position += stone.velocity + stone.velocity *= 0.98 + lower, upper = np.array([13, 3]), np.array([87, 117]) + bounce = ((stone.position < lower) & (stone.velocity < 0)) | ( + (stone.position > upper) & (stone.velocity > 0) + ) + stone.velocity[bounce] *= -1 + delta = stone.position - CENTER + radius = np.linalg.norm(delta) + angle = atan2(delta[1], delta[0]) + if stone.side == 2: + stone.fuse -= 1 + if stone.fuse == 0: + self.rings.append(Ring(radius, angle, 0, 1 / (radius + 1))) + continue + elif any(self._ring_hit(ring, radius, angle) for ring in active_rings): + self.ammo += int(stone.side == 0) + reward += self.multiplier + self.multiplier += 1 + continue + survivors.append(stone) + for index, stone in enumerate(survivors): + for other in survivors[index + 1:]: + delta = other.position - stone.position + distance = np.linalg.norm(delta) + if distance >= 6: + continue + axis = delta / distance if distance else np.array([1., 0.]) + impulse = 0.7 * (abs(other.velocity @ axis) - abs(stone.velocity @ axis)) + stone.velocity -= impulse * axis + other.velocity += impulse * axis + stone.position += 2 * stone.velocity + other.position += 2 * other.velocity + if {stone.side, other.side} == {0, 1}: + (stone if stone.side == 1 else other).side = 2 + self.stones = survivors + for ring in active_rings: + ring.radius += 2 + self.rings = [ring for ring in self.rings if ring.radius <= 99] + if not self.rings: + self.multiplier = 1 + return reward + + @staticmethod + def _ring_hit(ring, radius, angle): + difference = abs((angle - ring.angle + pi) % (2 * pi) - pi) + tolerance = 4.5 / max(1, ring.radius) + return abs(radius - ring.radius) < 4.5 and difference <= ring.spread + tolerance + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + for stone in self.stones: + x, y = stone.position + if 0 <= x < 100 and 0 <= y < 150: + state[int(y // 15), int(x // 10), stone.side] = True + rows, cols = np.ogrid[7.5:150:15, 5:100:10] + radius = np.hypot(cols - 50, rows - 60) + angle = np.arctan2(rows - 60, cols - 50) + for ring in self.rings: + difference = abs((angle - ring.angle + pi) % (2 * pi) - pi) + state[:, :, 3] |= (abs(radius - ring.radius) < 9) & ( + difference <= ring.spread + 9 / max(1, ring.radius) + ) + x = 50 + self.speed * 5 * cos(self.angle) + y = 120 + self.speed * 5 * sin(self.angle) + state[int(y // 15), int(x // 10), 4] = True + values = (self.steps, self.ammo, self.timer, self.multiplier, + round((self.angle + pi) * 100), round(self.speed * 100), + round(self.enemy_angle * 100), round(self.enemy_speed * 100)) + for row, value in enumerate(values): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/river_raid.py b/runtime/minatar_synth/games/river_raid.py new file mode 100644 index 0000000000000000000000000000000000000000..218bbcac5a0fcee42fdb0a7cfa9553259892158b --- /dev/null +++ b/runtime/minatar_synth/games/river_raid.py @@ -0,0 +1,210 @@ +import numpy as np + + +OBJECT_VALUES = {"tanker": 30, "helicopter": 60, "fuel": 80, "jet": 100, "bridge": 500} +SPAWN_OFFSETS = {"tanker": 4, "helicopter": 9, "fuel": 15, "jet": 21, "bridge": 29} + + +class RiverRaidEnvironment: + """Sixteen bridge sections with fuel, throttle, traffic, and checkpoints.""" + + score_cap = 12_320.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 3_000): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.section = 0 + self.section_progress = 0 + self.player_column = 5 + self.previous_player_column = 5 + self.speed = 1 + self.fuel = 100 + self.lives = 4 + self.score = 0.0 + self.next_reinforcement = 10_000 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self.claimed: set[tuple[int, str]] = set() + self.missiles: list[list[int]] = [] + self.previous_missiles: list[list[int]] = [] + self._load_section() + + def _load_section(self) -> None: + self.objects = [] + for kind, offset in SPAWN_OFFSETS.items(): + if (self.section, kind) in self.claimed: + continue + column = 2 + (self.section * 3 + len(kind)) % 6 + self.objects.append({"kind": kind, "offset": offset, "column": column, "direction": 1 if offset % 2 else -1}) + self.previous_objects = {str(item["kind"]): self._object_position(item) for item in self.objects} + + def _object_position(self, item: dict[str, object]) -> list[int]: + return [8 - (int(item["offset"]) - self.section_progress), int(item["column"])] + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_player_column = self.player_column + self.previous_missiles = [missile.copy() for missile in self.missiles] + self.previous_objects = {str(item["kind"]): self._object_position(item) for item in self.objects} + if action == 0: + self.speed = 1 + elif action == 1: + self.player_column = max(0, self.player_column - 1) + for missile in self.missiles: + missile[1] = max(0, missile[1] - 1) + elif action == 3: + self.player_column = min(9, self.player_column + 1) + for missile in self.missiles: + missile[1] = min(9, missile[1] + 1) + elif action == 2: + self.speed = 2 + elif action == 4: + self.speed = 0 + elif action == 5 and len(self.missiles) < 3: + self.missiles.append([8, self.player_column]) + section_before = self.section + reward = self._move_missiles() + if self.section == section_before and not self.terminal: + self._move_objects() + self._refuel() + self.section_progress += self.speed + self.fuel -= 1 + self._resolve_collisions() + self.score += reward + while self.score >= self.next_reinforcement: + self.lives = min(10, self.lives + 1) + self.next_reinforcement += 10_000 + self.steps += 1 + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _move_missiles(self) -> float: + reward = 0.0 + for missile in list(self.missiles): + missile[0] -= 1 + hit = None + for item in self.objects: + if missile == self._object_position(item): + hit = item + break + if hit is not None: + kind = str(hit["kind"]) + self.claimed.add((self.section, kind)) + self.objects.remove(hit) + self.missiles.remove(missile) + reward += float(OBJECT_VALUES[kind]) + if kind == "bridge": + self.section += 1 + if self.section >= 16: + self.terminal = True + else: + self.section_progress = 0 + self.missiles.clear() + self._load_section() + break + elif missile[0] < 0: + self.missiles.remove(missile) + return reward + + def _move_objects(self) -> None: + for item in self.objects: + if item["kind"] not in ("helicopter", "jet"): + continue + interval = max(1, 4 - self.section // 5) + if self.steps % interval: + continue + item["column"] = int(item["column"]) + int(item["direction"]) + if item["column"] in (1, 8): + item["direction"] = -int(item["direction"]) + + def _refuel(self) -> None: + for item in self.objects: + if item["kind"] == "fuel" and self._object_position(item) == [8, self.player_column]: + self.fuel = min(100, self.fuel + (8 if self.speed == 0 else 4)) + + def _river_bounds(self, progress: int) -> tuple[int, int]: + center = 5 + ((progress // 7 + self.section) % 3 - 1) + half_width = max(2, 4 - self.section // 6) + return max(0, center - half_width), min(9, center + half_width) + + def _resolve_collisions(self) -> None: + left, right = self._river_bounds(self.section_progress) + object_hit = any(self._object_position(item) == [8, self.player_column] for item in self.objects) + if self.player_column <= left or self.player_column >= right or object_hit or self.fuel <= 0: + self._lose_jet() + + def _lose_jet(self) -> None: + self.lives -= 1 + if self.lives <= 0: + self.terminal = True + return + self.section_progress = 0 + self.player_column = 5 + self.previous_player_column = 5 + self.speed = 1 + self.fuel = 100 + self.missiles.clear() + self._load_section() + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[8, self.player_column, 0] = True + state[8, self.previous_player_column, 4] = True + for row in range(9): + left, right = self._river_bounds(self.section_progress + 8 - row) + state[row, : left + 1, 3] = True + state[row, right:, 3] = True + kind_codes = {"tanker": 0, "helicopter": 1, "fuel": 2, "jet": 3} + for item in self.objects: + row, column = self._object_position(item) + if 0 <= row < 9: + if item["kind"] == "bridge": + left, right = self._river_bounds(self.section_progress + 8 - row) + state[row, left + 1 : right, 1] = True + else: + code = kind_codes[str(item["kind"])] + state[row, column, 1] = True + state[row, column, 2] = bool(code & 1) + state[row, column, 3] = bool(code & 2) + previous = self.previous_objects.get(str(item["kind"])) + if previous is not None and 0 <= previous[0] < 9: + state[*previous, 4] = True + for missile in self.missiles: + state[*missile, 2] = True + for missile in self.previous_missiles: + state[*missile, 4] = True + for kind_index, kind in enumerate(OBJECT_VALUES): + state[0, kind_index, 5] = (self.section, kind) in self.claimed + for bit in range(4): + state[0, 5 + bit, 5] = bool(self.section & (1 << bit)) + state[1, bit, 5] = bool(self.lives & (1 << bit)) + for bit in range(7): + index = 14 + bit + state[index // 10, index % 10, 5] = bool(max(0, self.fuel) & (1 << bit)) + state[2, 1, 5] = bool(self.speed & 1) + state[2, 2, 5] = bool(self.speed & 2) + state[2, 3, 5] = self.score >= 10_000 + for bit in range(5): + state[2, 4 + bit, 5] = bool(self.section_progress & (1 << bit)) + for bit in range(12): + index = 30 + bit + state[index // 10, index % 10, 5] = bool(self.steps & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/road_runner.py b/runtime/minatar_synth/games/road_runner.py new file mode 100644 index 0000000000000000000000000000000000000000..fd330b30d419d8400bb6db7849a6efb3fb6049d4 --- /dev/null +++ b/runtime/minatar_synth/games/road_runner.py @@ -0,0 +1,212 @@ +import numpy as np + + +SEED_OFFSETS = tuple(3 + index * 3 for index in range(10)) +HAZARDS = {8: "mine", 16: "truck", 24: "cannon", 34: "rock", 38: "cliff"} + + +class RoadRunnerEnvironment: + """Eight desert chases with seed streaks and Coyote hazard baiting.""" + + score_cap = 57_600.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 2_000): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.level = 0 + self.lives = 3 + self.score = 0.0 + self.steps = 0 + self.last_action = 0 + self.terminal = False + self.claimed: set[tuple[int, str, int]] = set() + self._start_level() + + def _start_level(self) -> None: + self.progress = 0 + self.lane = 5 + self.previous_lane = self.lane + self.jump_timer = 0 + self.magnet_timer = 0 + self.seed_streak = 0 + self.coyote_distance = 8 + self.previous_coyote_distance = self.coyote_distance + self.projectile: list[int] | None = None + self.previous_projectile: list[int] | None = None + self.level_steps = 0 + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_lane = self.lane + self.previous_coyote_distance = self.coyote_distance + self.previous_projectile = None if self.projectile is None else self.projectile.copy() + progress_before = self.progress + if action == 1: + self.progress += 1 + self.coyote_distance = min(9, self.coyote_distance + 2) + elif action == 3: + self.progress = max(0, self.progress - 1) + self.coyote_distance -= 1 + elif action == 2: + self.lane = max(3, self.lane - 1) + elif action == 4: + self.lane = min(7, self.lane + 1) + elif action == 5: + self.jump_timer = 3 + reward = self._resolve_course(progress_before) + self._move_projectile() + self.coyote_distance -= 1 + int(self.magnet_timer > 0) + reward += self._resolve_coyote_hazard() + self._resolve_player_hazards() + self.score += reward + self.steps += 1 + self.level_steps += 1 + self.jump_timer = max(0, self.jump_timer - 1) + self.magnet_timer = max(0, self.magnet_timer - 1) + if self.progress >= 40 and not self.terminal: + self.level += 1 + if self.level >= 8: + self.terminal = True + else: + self._start_level() + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _resolve_course(self, previous_progress: int) -> float: + reward = 0.0 + for index, offset in enumerate(SEED_OFFSETS): + identity = (self.level, "seed", index) + if identity in self.claimed or not previous_progress < offset <= self.progress: + continue + self.claimed.add(identity) + seed_lane = 4 + (index + self.level) % 4 + if self.lane == seed_lane: + self.seed_streak = min(10, self.seed_streak + 1) + reward += float(self.seed_streak * 100) + else: + self.seed_streak = 0 + steel_identity = (self.level, "steel", 0) + if steel_identity not in self.claimed and previous_progress < 32 <= self.progress: + self.claimed.add(steel_identity) + if self.lane == 5: + self.magnet_timer = 20 + reward += 100.0 + return reward + + def _move_projectile(self) -> None: + if self.progress >= 23 and self.progress <= 28 and self.projectile is None: + self.projectile = [self.lane, 9] + if self.projectile is not None: + self.projectile[1] -= 1 + self.level // 3 + if self.projectile[1] < 0: + self.projectile = None + + def _resolve_coyote_hazard(self) -> float: + if self.coyote_distance > 2: + return 0.0 + for offset, kind in HAZARDS.items(): + if kind == "cliff" or abs(self.progress - offset) > 1: + continue + identity = (self.level, "coyote", offset) + if identity in self.claimed: + continue + hazard_lane = 4 + (offset // 8 + self.level) % 4 + if self.lane == hazard_lane and self.jump_timer == 0: + continue + self.claimed.add(identity) + self.coyote_distance = 8 + return 1_000.0 if kind == "truck" else 200.0 + return 0.0 + + def _resolve_player_hazards(self) -> None: + if self.coyote_distance <= 0: + self._lose_life() + return + for offset, kind in HAZARDS.items(): + if abs(self.progress - offset) > 0: + continue + hazard_lane = 4 + (offset // 8 + self.level) % 4 + if self.lane != hazard_lane or self.jump_timer > 0: + continue + self._lose_life() + return + if self.projectile is not None and self.projectile == [self.lane, 5] and self.jump_timer == 0: + self._lose_life() + + def _lose_life(self) -> None: + self.lives -= 1 + if self.lives <= 0: + self.terminal = True + return + self.lane = 5 + self.jump_timer = 0 + self.magnet_timer = 0 + self.coyote_distance = 8 + self.projectile = None + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[self.lane, 5, 0] = True + state[self.previous_lane, 5, 4] = True + coyote_column = max(0, 5 - self.coyote_distance) + previous_coyote_column = max(0, 5 - self.previous_coyote_distance) + state[self.lane, coyote_column, 1] = True + state[self.previous_lane, previous_coyote_column, 4] = True + for index, offset in enumerate(SEED_OFFSETS): + screen_column = 5 + offset - self.progress + if 0 <= screen_column < 10 and (self.level, "seed", index) not in self.claimed: + lane = 4 + (index + self.level) % 4 + state[lane, screen_column, 2] = True + steel_column = 5 + 32 - self.progress + if 0 <= steel_column < 10 and (self.level, "steel", 0) not in self.claimed: + state[5, steel_column, 2] = True + state[5, steel_column, 3] = True + for offset, kind in HAZARDS.items(): + screen_column = 5 + offset - self.progress + if 0 <= screen_column < 10: + lane = 4 + (offset // 8 + self.level) % 4 + state[lane, screen_column, 1] = True + if kind == "cliff": + state[3:8, screen_column, 3] = True + if self.projectile is not None: + state[*self.projectile, 1] = True + if self.previous_projectile is not None: + state[*self.previous_projectile, 4] = True + for index in range(10): + state[0, index, 5] = (self.level, "seed", index) in self.claimed + state[1, 0, 5] = (self.level, "steel", 0) in self.claimed + for index, offset in enumerate(HAZARDS): + if HAZARDS[offset] != "cliff": + state[1, 1 + index, 5] = (self.level, "coyote", offset) in self.claimed + for bit in range(3): + state[2, bit, 5] = bool(self.level & (1 << bit)) + state[2, 3 + bit, 5] = bool(self.lives & (1 << bit)) + for bit in range(6): + state[3, bit, 5] = bool(self.progress & (1 << bit)) + for bit in range(4): + state[3, 6 + bit, 5] = bool(self.seed_streak & (1 << bit)) + for bit in range(5): + state[4, bit, 5] = bool(self.magnet_timer & (1 << bit)) + for bit in range(2): + state[4, 5 + bit, 5] = bool(self.jump_timer & (1 << bit)) + for bit in range(4): + index = 47 + bit + state[index // 10, index % 10, 5] = bool(self.coyote_distance & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/robot_tank.py b/runtime/minatar_synth/games/robot_tank.py new file mode 100644 index 0000000000000000000000000000000000000000..2ccfc3c1a8d0b942bd8eabf699b6f9b005ac6e86 --- /dev/null +++ b/runtime/minatar_synth/games/robot_tank.py @@ -0,0 +1,189 @@ +import math + +import numpy as np + + +WEATHER = ("clear", "fog", "rain", "snow") +SYSTEMS = ("video", "cannon", "radar", "treads") + + +class RobotTankEnvironment: + """Twelve first-person squadrons with radar, weather, and system damage.""" + + score_cap = 144.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 5_000): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.score = 0.0 + self.kills = 0 + self.reserves = 3 + self.steps = 0 + self.last_action = 0 + self.heading = 0 + self.previous_heading = 0 + self.damage: set[str] = set() + self.rocket_distance: int | None = None + self.shot_timer = 0 + self.terminal = False + self._spawn_enemy() + + @property + def squadron(self) -> int: + return self.kills // 12 + + @property + def weather(self) -> str: + return WEATHER[(self.squadron + self.steps // 240) % len(WEATHER)] + + @property + def relative_bearing(self) -> int: + return (self.enemy_bearing - self.heading + 8) % 16 - 8 + + def _spawn_enemy(self) -> None: + self.enemy_bearing = int(self.random.randint(16)) + self.previous_enemy_bearing = self.enemy_bearing + self.enemy_distance = 5 + int(self.random.randint(4)) + self.previous_enemy_distance = self.enemy_distance + self.rocket_distance = None + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_heading = self.heading + self.previous_enemy_bearing = self.enemy_bearing + self.previous_enemy_distance = self.enemy_distance + movement_allowed = "treads" not in self.damage or self.steps % 3 == 0 + weather_allows_movement = self.weather != "rain" or self.steps % 2 == 0 + if action == 1 and movement_allowed: + self.heading = (self.heading - 1) % 16 + elif action == 3 and movement_allowed: + self.heading = (self.heading + 1) % 16 + elif action == 2 and movement_allowed and weather_allows_movement: + self.enemy_distance = max(1, self.enemy_distance - 1) + elif action == 4 and movement_allowed and weather_allows_movement: + self.enemy_distance = min(9, self.enemy_distance + 1) + reward = self._fire() if action == 5 else 0.0 + if reward == 0.0: + self._enemy_turn() + self._advance_rocket() + self.score += reward + self.steps += 1 + self.shot_timer = max(0, self.shot_timer - 1) + if self.kills >= 144 or self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _fire(self) -> float: + if "cannon" in self.damage and self.random.rand() < 0.5: + return 0.0 + self.shot_timer = 2 + if self.rocket_distance is not None and abs(self.relative_bearing) <= 1: + self.rocket_distance = None + return 0.0 + if abs(self.relative_bearing) > 1: + return 0.0 + self.kills += 1 + if self.kills % 12 == 0: + self.reserves = min(12, self.reserves + 1) + if self.kills < 144: + self._spawn_enemy() + return 1.0 + + def _enemy_turn(self) -> None: + if self.steps % max(2, 5 - self.squadron // 4) == 0: + turn = int(np.sign((self.heading - self.enemy_bearing + 8) % 16 - 8)) + self.enemy_bearing = (self.enemy_bearing + turn) % 16 + if self.steps % 4 == 0: + self.enemy_distance = max(1, self.enemy_distance - 1) + if ( + self.rocket_distance is None + and abs(self.relative_bearing) <= 1 + and self.enemy_distance <= 6 + and self.steps % max(5, 11 - self.squadron // 2) == 0 + ): + self.rocket_distance = self.enemy_distance + + def _advance_rocket(self) -> None: + if self.rocket_distance is None: + return + self.rocket_distance -= 1 + if self.rocket_distance > 0: + return + self.rocket_distance = None + self._take_hit() + + def _take_hit(self) -> None: + undamaged = [system for system in SYSTEMS if system not in self.damage] + if undamaged: + self.damage.add(undamaged[int(self.random.randint(len(undamaged)))]) + return + if self.reserves == 0: + self.terminal = True + return + self.reserves -= 1 + self.damage.clear() + self.heading = 0 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[5, 5, 0] = True + angle = self.relative_bearing * math.pi / 8 + radius = min(4, max(1, self.enemy_distance // 2)) + radar_row = int(round(5 - math.cos(angle) * radius)) + radar_column = int(round(5 + math.sin(angle) * radius)) + state[radar_row, radar_column, 1] = True + previous_relative = (self.previous_enemy_bearing - self.previous_heading + 8) % 16 - 8 + previous_angle = previous_relative * math.pi / 8 + previous_radius = min(4, max(1, self.previous_enemy_distance // 2)) + previous_row = int(round(5 - math.cos(previous_angle) * previous_radius)) + previous_column = int(round(5 + math.sin(previous_angle) * previous_radius)) + state[previous_row, previous_column, 4] = True + hour = (self.steps // 10) % 24 + visible = 5 <= hour < 20 and self.weather != "fog" and not ( + "video" in self.damage and self.steps % 4 < 2 + ) + if visible and abs(self.relative_bearing) <= 2: + width = max(1, 4 - self.enemy_distance // 3) + state[2:5, 5 - width : 6 + width, 1] = True + if self.rocket_distance is not None: + state[min(9, 4 + self.rocket_distance), 5, 1] = True + if self.shot_timer > 0: + state[4, 5, 3] = True + for index, system in enumerate(SYSTEMS): + state[0, index, 5] = system in self.damage + values = ( + (self.heading, 4), + (self.enemy_bearing, 4), + (self.enemy_distance, 4), + (self.kills, 8), + (self.reserves, 4), + (self.steps % 240, 8), + (WEATHER.index(self.weather), 2), + ) + offset = 4 + for value, width in values: + for bit in range(width): + index = offset + bit + state[index // 10, index % 10, 5] = bool(value & (1 << bit)) + offset += width + if self.rocket_distance is not None: + for bit in range(4): + index = offset + bit + state[index // 10, index % 10, 5] = bool(self.rocket_distance & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/rocket_trail.py b/runtime/minatar_synth/games/rocket_trail.py new file mode 100644 index 0000000000000000000000000000000000000000..364cfb4d5881f568618fd9f5663279ce1a2f8fa0 --- /dev/null +++ b/runtime/minatar_synth/games/rocket_trail.py @@ -0,0 +1,134 @@ +from dataclasses import dataclass +from math import atan2, cos, pi, sin + +import numpy as np + + +@dataclass +class Particle: + x: float + y: float + vx: float + vy: float + life: int = 0 + + def move(self): + self.x += self.vx + self.y += self.vy + self.life -= 1 + + +class RocketTrailEnvironment: + score_cap = 200 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.y = 50., 65. + self.vx = self.vy = 0. + self.angle = pi / 2 + self.direction = self.multiplier = 1 + self.steps = self.timer = 0 + self.interval = 60 + self.held = self.terminal = False + self.flames = [] + self.fuel = [] + self.asteroids = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.held = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self): + self.vx *= 0.95 + self.vy = (self.vy + 0.1) * 0.98 + if self.x <= 45: + self.direction = 1 + elif self.x >= 55: + self.direction = -1 + self.angle += (pi / 2 + self.direction - self.angle) * 0.05 + dx, dy = cos(self.angle), sin(self.angle) + if self.held: + self.vx -= 0.3 * dx + self.vy -= 0.3 * dy + if self.random.random() < 0.3: + angle = self.angle + self.random.uniform(-0.5, 0.5) + self.fuel.append(Particle(self.x, self.y, 1.8 * cos(angle), 1.8 * sin(angle), 20)) + self.x += self.vx + self.y += self.vy + self.flames.append(Particle(self.x, self.y, 2.1 * dx, 2.1 * dy, 25)) + self.x = min(99, max(1, self.x)) + self.terminal = self.y < 0 or self.y > 105 + for particle in (*self.flames, *self.fuel): + particle.move() + self.flames = [particle for particle in self.flames if particle.life > 0] + self.fuel = [particle for particle in self.fuel if particle.life > 0] + self.timer += 1 + if not self.asteroids or self.timer >= self.interval: + x = self.random.uniform(5, 95) + angle = atan2(104, self.random.uniform(20, 80) - x) + speed = self.random.uniform(0.3, 0.5) + self.asteroids.append(Particle(x, -5, speed * cos(angle), speed * sin(angle))) + self.timer = 0 + self.interval = 80 - self.random.uniform(-30, 30) + reward = 0 + remaining = [] + for asteroid in self.asteroids: + asteroid.move() + if any(self._overlap(asteroid, flame, 3.5 - (25 - flame.life) / 40) + for flame in self.flames) or any( + self._overlap(asteroid, fuel, 2.5) for fuel in self.fuel + ): + reward += self.multiplier + self.multiplier = min(16, self.multiplier + 1) + elif any(abs(asteroid.x - (self.x - offset * dx)) < 3 + and abs(asteroid.y - (self.y - offset * dy)) < 3 for offset in range(6)): + self.vy += 2 + self.multiplier = 1 + elif asteroid.y > 105: + self.multiplier = max(1, self.multiplier - 1) + else: + remaining.append(asteroid) + self.asteroids = remaining + return reward + + @staticmethod + def _overlap(asteroid, particle, reach): + return abs(asteroid.x - particle.x) < reach and abs(asteroid.y - particle.y) < reach + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[int(np.clip(self.y // 10, 0, 9)), int(self.x // 10), 0] = True + for channel, particles in ((1, self.flames), (2, self.fuel), (3, self.asteroids)): + for particle in particles: + if 0 <= particle.x < 100 and 0 <= particle.y < 100: + state[int(particle.y // 10), int(particle.x // 10), channel] = True + x = self.x - 12 * cos(self.angle) + y = self.y - 12 * sin(self.angle) + state[int(np.clip(y // 10, 0, 9)), int(np.clip(x // 10, 0, 9)), 4] = True + for row, value in enumerate((self.steps, self.multiplier, self.held, + round(self.angle * 100), round((self.vy + 16) * 16))): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/rolfrg.py b/runtime/minatar_synth/games/rolfrg.py new file mode 100644 index 0000000000000000000000000000000000000000..9978dac6114d6cc318132531bc8d4eb45dcbf4a9 --- /dev/null +++ b/runtime/minatar_synth/games/rolfrg.py @@ -0,0 +1,95 @@ +from dataclasses import dataclass +from math import cos, sin + +import numpy as np + + +@dataclass +class Frog: + x: float + y: float + angle: float + + +class RolfrgEnvironment: + score_cap = 1600 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.direction = 50, 1 + self.frame = self.steps = 0 + self.held = self.terminal = False + self.frogs = [Frog(0, -index * 9, self.random.uniform(0, 9)) for index in range(5)] + self.bars = [] + self.long_bar = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap = held and not self.held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + self._advance(tap and frame == 0) + reward += 1 + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap): + self.long_bar = self.frame % 30 == 0 + length = 30 if self.long_bar else 4 + self.bars = [] + for frog in self.frogs: + if frog.y < 0: + frog.x = self.random.uniform(0, 99) + frog.y += self.random.uniform(99, 120) + points = np.arange(length + 1) + xs = frog.x + points * cos(frog.angle) + ys = frog.y + points * sin(frog.angle) + self.bars.append((xs, ys)) + frog.angle += 1 / 9 + frog.y -= 0.5 + if self.long_bar: + frog.x += 30 * cos(frog.angle) + frog.y += 30 * sin(frog.angle) + self.x += self.direction + if tap or self.x < 0 or self.x > 99: + self.direction *= -1 + self.terminal = any(np.any((abs(xs - self.x) < 3) & (abs(ys - 36) < 3)) + for xs, ys in self.bars) + self.frame += 1 + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[3, min(9, max(0, self.x // 10)), 0] = True + for xs, ys in self.bars: + visible = (xs >= 0) & (xs < 100) & (ys >= 0) & (ys < 100) + state[(ys[visible] // 10).astype(int), (xs[visible] // 10).astype(int), + 2 if self.long_bar else 1] = True + for frog in self.frogs: + if 0 <= frog.x < 100 and 0 <= frog.y < 100: + state[int(frog.y // 10), int(frog.x // 10), 3] = True + x = frog.x + 12 * cos(frog.angle) + y = frog.y + 12 * sin(frog.angle) + if 0 <= x < 100 and 0 <= y < 100: + state[int(y // 10), int(x // 10), 4] = True + for row, value in enumerate((self.steps, self.frame % 30, self.direction > 0, self.held)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/roll_hold.py b/runtime/minatar_synth/games/roll_hold.py new file mode 100644 index 0000000000000000000000000000000000000000..b1839d2c1827b82581ecdb6fe89602ab7fd4b537 --- /dev/null +++ b/runtime/minatar_synth/games/roll_hold.py @@ -0,0 +1,137 @@ +from dataclasses import dataclass +from math import ceil, cos, hypot, pi, sin + +import numpy as np + + +@dataclass +class Projectile: + x: float + y: float + vx: float + vy: float + + def move(self): + self.x += self.vx + self.y += self.vy + + +@dataclass +class Enemy: + x: float + y: float + vx: float + score: float = 9 + fired: bool = False + + +class RollHoldEnvironment: + score_cap = 400 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.angle = 0.0 + self.direction = 1 + self.steps = self.fire_timer = self.enemy_timer = 0 + self.held = self.terminal = False + self.shots, self.enemies, self.bullets = [], [], [] + self._schedule_enemy() + + def _schedule_enemy(self): + vx = 0.4 if self.random.random() < 0.5 else -0.4 + self.next_enemy = (-3 if vx > 0 else 103, self.random.uniform(9, 90), vx) + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + if held and not self.held: + self.direction *= -1 + self.fire_timer = 0 + self.held = held + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self): + dx, dy = cos(self.angle), sin(self.angle) + turret_x, turret_y = 50 + 12 * dx, 50 + 12 * dy + if self.held: + self.fire_timer -= 1 + if self.fire_timer < 0: + self.shots.append(Projectile(turret_x, turret_y, 2 * dx, 2 * dy)) + self.fire_timer = 9 + else: + self.angle = (self.angle + self.direction * 0.07 + pi) % (2 * pi) - pi + for shot in self.shots: + shot.move() + self.shots = [shot for shot in self.shots if -9 <= shot.x <= 111 and -9 <= shot.y <= 111] + self.enemy_timer -= 1 + if self.enemy_timer < 0: + self.enemies.append(Enemy(*self.next_enemy)) + if self.random.random() < 0.25: + self._schedule_enemy() + self.enemy_timer = 120 + else: + self.enemy_timer = 25 + reward = 0 + survivors = [] + for enemy in self.enemies: + enemy.x += enemy.vx + if not enemy.fired and (enemy.x > 90 if enemy.vx > 0 else enemy.x < 9): + distance = hypot(50 - enemy.x, 50 - enemy.y) + self.bullets.append(Projectile(enemy.x, enemy.y, 0.3 * (50 - enemy.x) / distance, + 0.3 * (50 - enemy.y) / distance)) + enemy.fired = True + if abs(enemy.x - turret_x) < 5 and abs(enemy.y - turret_y) < 5: + reward += 10 + elif any(abs(enemy.x - shot.x) < 4.5 and abs(enemy.y - shot.y) < 4.5 for shot in self.shots): + reward += max(0, ceil(enemy.score)) + elif -5 <= enemy.x <= 105: + enemy.score -= 0.033 + survivors.append(enemy) + self.enemies = survivors + bullets = [] + for bullet in self.bullets: + bullet.move() + if abs(bullet.x - turret_x) < 4 and abs(bullet.y - turret_y) < 4: + reward += 10 + elif abs(bullet.x - 50) < 5 and abs(bullet.y - 50) < 5: + self.terminal = True + else: + bullets.append(bullet) + self.bullets = bullets + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[5, 5, 0] = True + x, y = 50 + 12 * cos(self.angle), 50 + 12 * sin(self.angle) + state[int(y // 10), int(x // 10), 1] = True + for channel, entities in ((2, self.shots), (3, self.enemies), (4, self.bullets)): + for entity in entities: + if 0 <= entity.x < 100 and 0 <= entity.y < 100: + state[int(entity.y // 10), int(entity.x // 10), channel] = True + values = (self.steps, self.held, self.direction > 0, round((self.angle + pi) * 75), + self.fire_timer, self.enemy_timer) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/roll_s.py b/runtime/minatar_synth/games/roll_s.py new file mode 100644 index 0000000000000000000000000000000000000000..29ae3cc34967053e3ce9b4e90785323e5833294d --- /dev/null +++ b/runtime/minatar_synth/games/roll_s.py @@ -0,0 +1,139 @@ +from dataclasses import dataclass +from math import atan2, cos, floor, pi, sin + +import numpy as np + + +@dataclass +class Projectile: + x: float + y: float + vx: float + vy: float + + def advance(self, scroll): + self.x += self.vx - scroll + self.y += self.vy + return -3 <= self.x <= 103 and -3 <= self.y <= 103 + + +@dataclass +class Enemy: + x: float + y: int + timer: int + angle: float = 0.0 + + +class RollSEnvironment: + score_cap = 200 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.aim = self.fire_timer = self.spawn_timer = self.steps = 0 + self.direction = self.multiplier = 1 + self.distance = 0.0 + self.held = self.terminal = False + self.shots, self.enemies, self.bullets = [], [], [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + released = self.held and not held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(released and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, released): + if released: + self.aim += self.direction + if abs(self.aim) > 1: + self.direction *= -1 + self.aim += self.direction * 2 + self.fire_timer = 9 + scroll = 0 if self.held else 0.5 + self.distance += scroll + if self.distance > 100 * self.multiplier: + self.multiplier += 1 + x, y = self._gun() + if self.held: + self.fire_timer -= 1 + if self.fire_timer < 0: + for index in range(-2, 3): + angle = self.aim * pi / 4 + index * 0.12 + self.shots.append(Projectile(x, y, 3 * cos(angle), 3 * sin(angle))) + self.fire_timer = 9 + self.shots = [shot for shot in self.shots if shot.advance(scroll)] + self.spawn_timer -= 1 + if self.spawn_timer < 0: + self.enemies.append(Enemy(105, 20 + 30 * self.random.integers(3), self.random.integers(300))) + self.spawn_timer = self.random.uniform(50, 60) + reward = 0 + enemies = [] + for enemy in self.enemies: + gun_x, gun_y = enemy.x, enemy.y - 9 + enemy.timer -= 1 + if enemy.timer < 0: + if enemy.timer % 36 == 0: + self.bullets.append(Projectile(gun_x, gun_y, cos(enemy.angle), sin(enemy.angle))) + if enemy.timer <= -108: + enemy.timer = 300 + else: + enemy.angle = floor((atan2(50 - enemy.y, 20 - enemy.x) + pi / 8) / (pi / 4)) * pi / 4 + enemy.x -= 0.2 + enemy.x -= scroll + if any(self._near(shot.x, shot.y, gun_x, gun_y) + or self._near(shot.x, shot.y, enemy.x, enemy.y - 3) for shot in self.shots): + reward += self.multiplier + continue + self.terminal |= not (self.held and self.aim == 0) and self._near(x, y, gun_x, gun_y) + if -5 <= enemy.x <= 105: + enemies.append(enemy) + self.enemies = enemies + self.bullets = [bullet for bullet in self.bullets if bullet.advance(scroll)] + self.terminal |= any(self._near(x, y, bullet.x, bullet.y) for bullet in self.bullets) + return reward + + @staticmethod + def _near(x, y, other_x, other_y): + return abs(x - other_x) < 4 and abs(y - other_y) < 4 + + def _gun(self): + return (26, 47) if self.held and self.aim == 0 else (20, 41) + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + x, y = self._gun() + state[y // 10, x // 10, 0] = True + for channel, entities in ((1, self.shots), (2, self.enemies), (4, self.bullets)): + for entity in entities: + if 0 <= entity.x < 100 and 0 <= entity.y < 100: + row, col = int(entity.y // 10), int(entity.x // 10) + state[row, col, channel] = True + if channel == 2 and entity.timer < 0: + state[row, col, 3] = True + values = (self.steps, self.aim + 1, self.direction > 0, self.held, + self.multiplier, self.fire_timer) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/rollnrope.py b/runtime/minatar_synth/games/rollnrope.py new file mode 100644 index 0000000000000000000000000000000000000000..052c792b55aca62d4fd1af587c5ebfaa04e765fd --- /dev/null +++ b/runtime/minatar_synth/games/rollnrope.py @@ -0,0 +1,123 @@ +from dataclasses import dataclass +from math import cos, floor, pi, sin + +import numpy as np + + +@dataclass +class Rope: + x: float + angle: float + radius: float + size: float + speed: float + count: int + + def position(self): + return (self.x + cos(self.angle) * self.radius, + 91 - self.size / 2 - self.radius + sin(self.angle) * self.radius) + + +class RollnropeEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.y, self.vy = 5.0, 84.0, 0.0 + self.mode = "stop" + self.steps = self.frame = 0 + self.held = self.terminal = False + self.rope = None + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap = held and not self.held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap): + if self.rope is None: + self.rope = Rope(150, self.random.uniform(0, 2 * pi), self.random.uniform(30, 45), + self.random.uniform(5, 10), self.random.uniform(1, 2), + int(self.random.integers(2, 6)) if self.frame else 2) + if self.random.random() < 0.2: + self.rope.speed *= -1 + rope = self.rope + rope.x -= (rope.x - 50) * 0.1 + previous = (rope.angle + pi / 2) % (2 * pi) - pi + rope.angle += rope.speed * 0.05 + current = (rope.angle + pi / 2) % (2 * pi) - pi + reward = 0 + if previous * current < 0 and abs(current) < pi / 2 and self.mode == "jump": + rope.count -= 1 + gap = 85 - rope.size - self.y + reward = floor(100 / (gap if gap > 0 else 1)) + if not rope.count: + self.rope = None + self.mode = "stop" + if self.mode == "stop": + self.x += (5 - self.x) * 0.1 + if self.y == 84 and tap: + self.mode = "run" + if self.mode == "run": + self.x += 2 + if self.x > 50: + self.x, self.mode = 50, "stand" + if self.mode == "stand" and self.held: + self.vy, self.mode = -3, "jump" + if self.mode in ("jump", "stop"): + self.vy += 0.1 if self.held else 0.2 + self.y += self.vy + if self.y > 84: + self.y = 84 + if self.mode == "jump": + self.mode = "stand" + rx, ry = rope.position() + self.terminal = abs(self.x - rx) < 3 + rope.size / 2 and abs(self.y - ry) < 6 + rope.size / 2 + self.frame += 1 + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[int(self.y // 10), int(self.x // 10), 0] = True + state[9, :, 1] = True + count = 0 + if self.rope is not None: + rope = self.rope + count = rope.count + x, y = rope.position() + if 0 <= x < 100 and 0 <= y < 100: + state[int(y // 10), int(x // 10), 2] = True + future = rope.angle + rope.speed * 0.2 + x = rope.x + cos(future) * rope.radius + y = 91 - rope.size / 2 - rope.radius + sin(future) * rope.radius + if 0 <= x < 100 and 0 <= y < 100: + state[int(y // 10), int(x // 10), 3] = True + state[8, int(min(99, rope.x) // 10), 4] = True + values = (self.steps, count, ("stop", "run", "stand", "jump").index(self.mode), + self.held, min(511, round((self.vy + 4) * 16))) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/rope_corral.py b/runtime/minatar_synth/games/rope_corral.py new file mode 100644 index 0000000000000000000000000000000000000000..644ff35a5e745072ca97239bfd9e596d156e5de6 --- /dev/null +++ b/runtime/minatar_synth/games/rope_corral.py @@ -0,0 +1,158 @@ +from dataclasses import dataclass +from math import atan2, cos, hypot, pi, sin + +import numpy as np + + +@dataclass +class Critter: + x: float + y: float + angle: float + + +@dataclass +class Spike: + x: float + y: float + warm: int + + +class RopeCorralEnvironment: + score_cap = 500 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.y = 30., 50. + self.bx, self.by = 20., 50. + self.vx, self.vy = 0.75, 0.32 + self.angle = self.swept = 0. + self.steps = self.frame = self.hitstop = 0 + self.timer = 200 + self.held = self.terminal = False + self.critters = [self._critter() for _ in range(5)] + for critter in self.critters: + if hypot(critter.x - self.x, critter.y - self.y) < 18: + critter.x = 15 + (critter.x + 25) % 70 + self.spikes = [] + for _ in range(3): + self._spawn_spike(0) + + def _critter(self): + x, y = self.random.uniform(15, 85, 2) + return Critter(x, y, self.random.uniform(0, 2 * pi)) + + def _spawn_spike(self, warm): + for _ in range(8): + x, y = self.random.uniform(10, 90, 2) + if hypot(x - self.x, y - self.y) >= 20 and all( + hypot(x - spike.x, y - spike.y) >= 24 for spike in self.spikes + ): + break + self.spikes.append(Spike(x, y, warm)) + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap = held and not self.held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap): + frozen = self.hitstop > 0 + self.hitstop = max(0, self.hitstop - 1) + reward = 0 + if self.held: + if tap: + self.angle = atan2(self.y - self.by, self.x - self.bx) + self.swept = 0 + if not frozen: + self.angle += 0.075 + self.swept += 0.075 + dx, dy = cos(self.angle), sin(self.angle) + self.x, self.y = self.bx + 22 * dx, self.by + 22 * dy + self.vx, self.vy = -1.32 * dy, 1.32 * dx + if self.swept >= 2 * pi: + self.swept = 0 + count = len(self.critters) + len(self.spikes) + self.critters = [c for c in self.critters if hypot(c.x - self.bx, c.y - self.by) >= 20] + self.spikes = [s for s in self.spikes if hypot(s.x - self.bx, s.y - self.by) >= 20] + caught = count - len(self.critters) - len(self.spikes) + if caught: + reward += 4 * caught ** 2 + self.hitstop = min(8, 2 + caught) + self.critters.extend(self._critter() for _ in range(caught)) + elif not frozen: + self.x += self.vx + self.y += self.vy + if not 6 <= self.x <= 94: + self.vx *= -1 + self.x = min(94, max(6, self.x)) + if not 6 <= self.y <= 94: + self.vy *= -1 + self.y = min(94, max(6, self.y)) + dx, dy = self.x - self.bx, self.y - self.by + distance = hypot(dx, dy) + if distance > 22: + self.bx, self.by = self.x - 22 * dx / distance, self.y - 22 * dy / distance + if not frozen: + self.timer -= 1 + if self.timer < 0 and len(self.critters) < 8: + self.critters.append(self._critter()) + self.timer = self.random.uniform(140, 220) + if self.frame % 700 == 699 and len(self.spikes) < 6: + self._spawn_spike(60) + remaining = [] + for critter in self.critters: + critter.angle += self.random.uniform(-0.2, 0.2) + critter.x = min(92, max(8, critter.x + 0.28 * cos(critter.angle))) + critter.y = min(92, max(8, critter.y + 0.28 * sin(critter.angle))) + if critter.x in (8, 92): + critter.angle = pi - critter.angle + if critter.y in (8, 92): + critter.angle *= -1 + if hypot(critter.x - self.x, critter.y - self.y) >= 4.5: + remaining.append(critter) + collected = len(self.critters) - len(remaining) + self.critters = remaining + [self._critter() for _ in range(collected)] + for spike in self.spikes: + if spike.warm: + spike.warm -= 1 + elif hypot(spike.x - self.x, spike.y - self.y) < 4: + self.terminal = True + self.frame += 1 + return reward + collected + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + positions = [(self.x, self.y, 0), (self.bx, self.by, 1)] + positions.extend((c.x, c.y, 2) for c in self.critters) + positions.extend((s.x, s.y, 4 if s.warm else 3) for s in self.spikes) + for x, y, channel in positions: + state[int(np.clip(y // 10, 0, 9)), int(np.clip(x // 10, 0, 9)), channel] = True + values = (self.steps, self.held, round(self.swept * 50), self.hitstop, + round((self.vx + 2) * 50), round((self.vy + 2) * 50)) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/rotating_tunnel.py b/runtime/minatar_synth/games/rotating_tunnel.py new file mode 100644 index 0000000000000000000000000000000000000000..1dfcf3d4d131560cb2f2f18b99d4c1ca0b4c6b9c --- /dev/null +++ b/runtime/minatar_synth/games/rotating_tunnel.py @@ -0,0 +1,108 @@ +from dataclasses import dataclass +from math import ceil, cos, pi, sin + +import numpy as np + + +@dataclass +class Arc: + radius: float + start: float + width: float + gold: bool + + +class RotatingTunnelEnvironment: + score_cap = 300 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.angle = 0. + self.radius = 20. + self.multiplier = 0. + self.steps = self.spawn_timer = self.score_timer = 0 + self.held = self.terminal = False + self.arcs = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.held = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self): + self.angle = (self.angle + 0.025) % (2 * pi) + self.radius = min(50, max(10, self.radius + (0.65 if self.held else -0.65))) + self.spawn_timer -= 1 + if self.spawn_timer < 0: + gold = self.random.random() < 0.3 + self.arcs.append(Arc(50, self.random.uniform(0, 2 * pi), + self.random.uniform(pi / 4, pi / 3), gold)) + self.spawn_timer += 80 + reward = 0 + for arc in self.arcs: + arc.radius -= 0.25 + if arc.radius <= 10 or abs(self.radius - arc.radius) > 2.5: + continue + angle = (self.angle - arc.start) % (2 * pi) + margin = 2.5 / arc.radius + if angle > arc.width + margin and angle < 2 * pi - margin: + continue + if arc.gold: + self.score_timer -= 1 + if self.score_timer < 0: + self.multiplier += 1 + reward += ceil(self.multiplier) + self.score_timer += 5 + else: + self.terminal = True + self.arcs = [arc for arc in self.arcs if arc.radius > 10] + self.multiplier *= 0.99 + return reward + + @staticmethod + def _mark(state, x, y, channel): + cols = np.clip(np.asarray(x) // 10, 0, 9).astype(int) + rows = np.clip(np.asarray(y) // 10, 0, 9).astype(int) + state[rows, cols, channel] = True + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + dx, dy = cos(self.angle), sin(self.angle) + self._mark(state, 50 + self.radius * dx, 50 + self.radius * dy, 0) + for arc in self.arcs: + angles = np.linspace(arc.start, arc.start + arc.width, 40) + self._mark(state, 50 + arc.radius * np.cos(angles), 50 + arc.radius * np.sin(angles), + 2 if arc.gold else 1) + angles = np.linspace(0, 2 * pi, 96) + for radius in (10, 50): + self._mark(state, 50 + radius * np.cos(angles), 50 + radius * np.sin(angles), 3) + future = self.angle + 0.1 + self._mark(state, 50 + self.radius * cos(future), 50 + self.radius * sin(future), 4) + values = (self.steps, self.held, self.spawn_timer, self.score_timer, + round(self.radius * 10), round(self.angle * 100), + min(1023, round(self.multiplier * 100))) + for row, value in enumerate(values): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/rotation_rod.py b/runtime/minatar_synth/games/rotation_rod.py new file mode 100644 index 0000000000000000000000000000000000000000..4d9058a20e06c01278d9cc15ab0246a18dde6df4 --- /dev/null +++ b/runtime/minatar_synth/games/rotation_rod.py @@ -0,0 +1,122 @@ +from dataclasses import dataclass +from math import ceil, cos, pi, sin + +import numpy as np + + +@dataclass +class Mover: + x: float + y: float + vx: float + vy: float + + def advance(self): + self.x += self.vx + self.y += self.vy + return -5 <= self.x <= 110 and -5 <= self.y <= 110 + + +class RotationRodEnvironment: + score_cap = 2000 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.angle = 0.0 + self.direction = 1 + self.steps = self.obstacle_timer = self.coin_timer = 0 + self.multiplier = 1.0 + self.held = self.terminal = False + self.obstacles, self.coins = [], [] + self.entry = None + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + if held and not self.held: + self.direction *= -1 + self.held = held + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _rod(self): + distance = np.arange(-24, 25) + dx, dy = cos(self.angle), sin(self.angle) + xs, ys = 50 + distance * dx, 50 + distance * dy + tail = self.angle + 0.2 * self.direction + arrow_x = np.linspace(50 + 23.04 * dx, 50 + 20.16 * cos(tail), 8) + arrow_y = np.linspace(50 + 23.04 * dy, 50 + 20.16 * sin(tail), 8) + return np.concatenate((xs, arrow_x)), np.concatenate((ys, arrow_y)) + + def _advance(self): + if not self.held: + self.angle = (self.angle + self.direction * 0.05) % (2 * pi) + xs, ys = self._rod() + self.obstacle_timer -= 1 + if self.obstacle_timer < 0: + offset = self.random.uniform(20, 40) + 40 * int(self.random.integers(2)) + entries = ((offset, -3, 0, 0.5), (103, offset, -0.5, 0), + (offset, 103, 0, -0.5), (-3, offset, 0.5, 0)) + self.entry = entries[self.random.integers(4)] + self.obstacles.append(Mover(*self.entry)) + self.obstacle_timer, self.coin_timer = 99, 9 + self.obstacles = [obstacle for obstacle in self.obstacles if obstacle.advance()] + self.terminal = any(self._hit(obstacle, xs, ys, 3.5) for obstacle in self.obstacles) + self.coin_timer -= 1 + if self.coin_timer < 0: + self.coins.append(Mover(*self.entry)) + self.coin_timer = 9 + reward = 0 + remaining = [] + for coin in self.coins: + if coin.advance(): + if self._hit(coin, xs, ys, 2.5): + reward += ceil(self.multiplier) + self.multiplier += 10 + else: + remaining.append(coin) + self.coins = remaining + self.multiplier *= 0.99 + return reward + + @staticmethod + def _hit(mover, xs, ys, reach): + return bool(np.any((abs(xs - mover.x) < reach) & (abs(ys - mover.y) < reach))) + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + xs, ys = self._rod() + state[(ys // 10).astype(int), (xs // 10).astype(int), 0] = True + for channel, movers in ((1, self.obstacles), (2, self.coins)): + for mover in movers: + if 0 <= mover.x < 100 and 0 <= mover.y < 100: + state[int(mover.y // 10), int(mover.x // 10), channel] = True + state[int(ys[48] // 10), int(xs[48] // 10), 3] = True + if self.entry is not None: + x, y, _, _ = self.entry + state[int(np.clip(y // 10, 0, 9)), int(np.clip(x // 10, 0, 9)), 4] = True + values = (self.steps, self.held, self.direction > 0, round(self.angle * 100), + self.obstacle_timer, self.coin_timer, round(self.multiplier)) + for row, value in enumerate(values): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/rps.py b/runtime/minatar_synth/games/rps.py new file mode 100644 index 0000000000000000000000000000000000000000..dfb1fff04b69a7c5f91dcfd1aee18eb8774a1b14 --- /dev/null +++ b/runtime/minatar_synth/games/rps.py @@ -0,0 +1,117 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Hand: + lane: int + kind: int + y: float = -9 + speed: float = 0.1 + + +class RpsEnvironment: + score_cap = 200 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.lane = self.kind = self.freeze = self.steps = 0 + self.target_y = self.y = 97.0 + self.x, self.vy = 20.0, -1.0 + self.multiplier = 1 + self.held = self.terminal = False + self.hands = [] + self.kinds = self.random.integers(3, size=4) + self.timers = self.random.uniform(0, 99, size=4) + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap = held and not self.held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap): + self.timers -= 1 + for lane in np.flatnonzero(self.timers < 0): + self.hands.append(Hand(lane, self.kinds[lane])) + self.timers[lane] = self.random.uniform(200, 300) + if self.random.random() < 0.4: + self.kinds[lane] = self.random.integers(3) + for hand in self.hands: + hand.y += hand.speed + hand.speed += ((0.2 if hand.y > 90 else 0.1) - hand.speed) * 0.1 + for other in self.hands: + if other is not hand and other.lane == hand.lane and abs(other.y - hand.y) < 6: + center = (other.y + hand.y) / 2 + hand.speed, other.speed = (0.4 * other.speed - 0.2 * hand.speed, + 0.4 * hand.speed - 0.2 * other.speed) + offset = 3 if other.y < hand.y else -3 + hand.y, other.y = center + offset, center - offset + self.terminal |= hand.y > 99 + self.freeze -= 1 + if self.freeze < 0 and tap: + self.lane = (self.lane + 1) % 4 + self.kind = (self.kind + 1) % 3 + self.target_y, self.vy = 97, -1 + self.vy += ((-1 if self.freeze < 0 else 0) - self.vy) * 0.05 + self.target_y = min(97, max(10, self.target_y + self.vy)) + offset = 20 + self.lane * 20 - self.x + self.x += offset if offset < 1 else offset * 0.5 + self.y += (self.target_y - self.y) * 0.5 + reward = 0 + remaining = [] + for hand in self.hands: + if hand.lane == self.lane and abs(self.target_y - hand.y) < 5: + outcome = (self.kind - hand.kind) % 3 + if outcome == 0: + self.vy = 0 + hand.speed -= 4 + hand.y = self.target_y - 3 + elif outcome == 1: + reward += self.multiplier + self.multiplier += 1 + continue + else: + self.multiplier = 1 + self.vy = 5 + hand.speed -= 0.5 + self.target_y = hand.y + 3 + self.freeze = 60 + remaining.append(hand) + self.hands = remaining + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[min(9, int(self.y // 10)), int(self.x // 10), 0] = True + for hand in self.hands: + if 0 <= hand.y < 100: + state[int(hand.y // 10), 2 + 2 * hand.lane, 1 + hand.kind] = True + state[min(9, int(self.target_y // 10)), 2 + 2 * self.lane, 4] = True + values = (self.steps, self.kind, max(0, self.freeze), self.multiplier, self.held) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/s_lanes.py b/runtime/minatar_synth/games/s_lanes.py new file mode 100644 index 0000000000000000000000000000000000000000..c66f01f43a3fa4261a45cb8a4d62728743b7d201 --- /dev/null +++ b/runtime/minatar_synth/games/s_lanes.py @@ -0,0 +1,119 @@ +from dataclasses import dataclass + +import numpy as np + + +LANES = (22, 42, 62, 82) + + +@dataclass +class Target: + x: float + lane: int + + +class SLanesEnvironment: + score_cap = 150 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.y, self.target_y = 3.0, 22.0, 22.0 + self.lane = self.steps = self.lane_timer = self.shot_timer = self.spawn_timer = 0 + self.multiplier = 1 + self.held = self.terminal = False + self.enemies, self.coins, self.shots = [], [], [] + self.speeds = np.ones(4) + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap = held and not self.held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap): + self.spawn_timer -= 1 + if self.spawn_timer < 0: + self.enemies.append(Target(103, int(self.random.integers(4)))) + self.spawn_timer = self.random.uniform(60, 90) + if self.held: + self.x = 3 if tap else min(50, self.x + 0.3) + self.y = self.target_y = LANES[self.lane] + self.shot_timer -= 1 + if self.shot_timer < 0: + self.shots.append(Target(self.x, self.lane)) + self.shot_timer = self.lane_timer = 20 + else: + self.lane_timer -= 1 + if self.lane_timer < 0: + self.lane = (self.lane + 1) % 4 + self.target_y = LANES[self.lane] + (100 if self.lane == 0 else 0) + self.y %= 100 + self.lane_timer = 20 + self.x += (3 - self.x) * 0.3 + self.y += (self.target_y - self.y) * 0.3 + self.speeds += (0.9 - self.speeds) * 0.02 + reward = 0 + coins = [] + for coin in self.coins: + coin.x -= 0.2 + if abs(coin.x - self.x) < 5.5 and abs(LANES[coin.lane] - self.y % 100) < 4.5: + reward += self.multiplier + self.multiplier += 1 + elif coin.x < -3: + self.speeds[coin.lane] += 1 + self.multiplier = max(1, self.multiplier - 1) + else: + coins.append(coin) + for shot in self.shots: + shot.x += 2 + enemies = [] + for enemy in self.enemies: + enemy.x -= 0.2 * self.speeds[enemy.lane] + if any(shot.lane == enemy.lane and abs(shot.x - enemy.x) < 6 for shot in self.shots): + coins.append(enemy) + else: + self.terminal |= enemy.x < 9 + enemies.append(enemy) + self.coins, self.enemies = coins, enemies + self.shots = [ + shot for shot in self.shots if shot.x <= 103 and not any( + shot.lane == enemy.lane and abs(shot.x - enemy.x) < 6 for enemy in enemies + ) + ] + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[int(self.y % 100 // 10), int(self.x // 10), 0] = True + for channel, entities in ((1, self.enemies), (2, self.coins), (3, self.shots)): + for entity in entities: + if 0 <= entity.x < 100: + state[LANES[entity.lane] // 10, int(entity.x // 10), channel] = True + state[LANES[self.lane] // 10, :, 4] = True + gauges = (self.steps, self.multiplier, self.lane_timer, self.shot_timer, + self.held, *(round(speed * 100) for speed in self.speeds)) + for row, value in enumerate(gauges): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/s_shake.py b/runtime/minatar_synth/games/s_shake.py new file mode 100644 index 0000000000000000000000000000000000000000..a15aced818c185033e27638e814adc716f315470 --- /dev/null +++ b/runtime/minatar_synth/games/s_shake.py @@ -0,0 +1,123 @@ +from dataclasses import dataclass +from math import pi, sin + +import numpy as np + + +@dataclass +class Ground: + x: float + angle: float + height: float = 9 + + +@dataclass +class Enemy: + x: float = 203 + y: float = 50 + vy: float = 0 + grounded: bool = True + + +class SShakeEnvironment: + score_cap = 100 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.ground = [Ground(i * 10, (i + 1) * pi / 5) for i in range(22)] + self.terrain_x = np.arange(22) * 10 + self.terrain_y = np.full(22, 99.0) + self.ratio = 1.0 + self.steps = self.timer = 0 + self.multiplier = 1 + self.held = self.terminal = False + self.enemies = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap = held and not self.held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap): + if tap: + self.ratio = 3 + self.multiplier = 1 + self.ratio += (1 - self.ratio) * 0.05 + for index, ground in enumerate(self.ground): + ground.x += 0.3 + if ground.x > 210: + ground.x -= 220 + neighbor = self.ground[(index + 1) % 22] + ground.angle = neighbor.angle - pi / 5 * self.random.uniform(0.5, 1.5) + ground.height = 0.95 * (neighbor.height + self.random.uniform(-1, 1)) + 0.45 + ordered = sorted(self.ground, key=lambda ground: ground.x) + self.terrain_x = np.array([ground.x for ground in ordered]) + heights = np.array([sin(ground.angle) * ground.height for ground in ordered]) + self.terrain_y = 99 + (heights - max(0, heights.max())) * self.ratio + self.timer -= 1 + if self.timer < 0: + self.enemies.append(Enemy()) + self.timer = self.random.uniform(0, 120) + reward = 0 + remaining = [] + for enemy in self.enemies: + enemy.x -= 0.3 + enemy.y += enemy.vy + surface = float(np.interp(enemy.x, self.terrain_x, self.terrain_y)) + if enemy.grounded: + if tap and enemy.y > surface - 2.5: + launch = max(1, int(enemy.y - surface + 2.5)) + enemy.vy = -0.3 * launch + enemy.grounded = False + enemy.y = surface - 3.5 + else: + enemy.vy += 0.03 + if abs(enemy.y - surface) <= 3.5 or (enemy.vy > 0 and surface < enemy.y <= surface + 30): + enemy.y, enemy.vy, enemy.grounded = surface - 3.5, 0, True + if enemy.y < -3: + reward += self.multiplier + self.multiplier += 1 + else: + self.terminal |= enemy.x < 3 + if enemy.y <= 103: + remaining.append(enemy) + self.enemies = remaining + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + columns = np.arange(10) + surfaces = np.interp(columns * 20 + 10, self.terrain_x, self.terrain_y) + state[(surfaces // 10).astype(int), columns, 0] = True + for enemy in self.enemies: + if 0 <= enemy.x < 200 and 0 <= enemy.y < 100: + row, col = int(enemy.y // 10), int(enemy.x // 20) + channel = 1 if enemy.grounded else 2 if enemy.vy < 0 else 3 + state[row, col, channel] = True + state[:, 0, 4] = True + for row, value in enumerate((self.steps, self.multiplier, self.held, round(self.ratio * 100))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/scaffold.py b/runtime/minatar_synth/games/scaffold.py new file mode 100644 index 0000000000000000000000000000000000000000..e51ffa5897541f708bf802352a84ebc692cbf47a --- /dev/null +++ b/runtime/minatar_synth/games/scaffold.py @@ -0,0 +1,149 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Floor: + x: float + y: float + kind: int + + +@dataclass +class Item: + x: float + y: float + vy: float + remaining: float + travel: float + gold: bool + + +class ScaffoldEnvironment: + score_cap = 100 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.y = 5., 50. + self.next_x, self.next_y = 57., 52. + self.wall_x, self.wall_y = -9., 0. + self.kind = self.steps = self.charge = 0 + self.direction = self.multiplier = 1 + self.item_distance = 0. + self.held = self.terminal = False + self.floors = [Floor(i * 6 + 3, 52, 1) for i in range(9)] + self.items = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + if self.held and not held: + if self.kind + self.direction not in (0, 1, 2): + self.direction *= -1 + self.kind += self.direction + self.held = held + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self): + scroll = 0.05 + max(0, self.next_x - 40) * 0.1 + self.wall_x -= scroll + if self.wall_x < -6: + self.wall_y = 47 + for _ in range(9): + y = 47 + 4 * self.random.integers(-9, 9) + if abs(y - self.next_y) < 25: + self.wall_y = y + break + self.wall_x = 126 - self.next_x % 6 + self.items.append(Item(self.wall_x + 4, self.wall_y + 4, 0.1, 2, 4, True)) + self.item_distance += 30 + self.charge = self.charge + 1 if self.held else 0 + if self.charge == 16: + self.floors.append(Floor(self.next_x, self.next_y, self.kind)) + self.next_x += 6 + self.next_y += 4 * (self.kind - 1) + self.charge = 0 + for floor in self.floors: + floor.x -= scroll + self.floors = [floor for floor in self.floors if floor.x >= -3] + self.next_x -= scroll + self.x += max(0, 20 - self.x) * 0.2 - scroll + self.terminal = self.y < 5 or self.y > 95 or ( + abs(self.x - (self.wall_x + 4)) < 4 + and (self.y - 3 < self.wall_y - 12 or self.y + 3 > self.wall_y + 18) + ) + foot = self.x + 4 + surface = next((self._height(floor, foot) for floor in self.floors + if abs(foot - floor.x) <= 3), None) + self.y += 9 if surface is None else max(-9, min(9, surface - self.y)) + self.item_distance -= scroll + if self.item_distance < 0: + gold = self.random.random() < 0.5 + travel = self.random.uniform(20, 60) / (4 if gold else 1.5) + y = np.clip(self.next_y + self.random.uniform(-20, 20), 10, 90) + self.items.append(Item(120, y, self.random.choice((-0.3, 0.3)), travel / 2, travel, gold)) + self.item_distance = self.random.uniform(15, 25) + reward = 0 + remaining = [] + for item in self.items: + item.x -= scroll + item.y += item.vy + item.remaining -= abs(item.vy) + if item.remaining < 0: + item.remaining = item.travel + item.vy *= -1 + if abs(item.x - self.x) < 5 and abs(item.y - self.y) < 5: + if item.gold: + reward += self.multiplier + self.multiplier += 1 + continue + self.terminal = True + if item.x >= -3: + remaining.append(item) + elif item.gold: + self.multiplier = max(1, self.multiplier - 1) + self.items = remaining + return reward + + @staticmethod + def _height(floor, x): + return floor.y - 2 + (floor.kind - 1) * (x - floor.x + 3) * 2 / 3 + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + entities = [(self.x, self.y, 0), (self.next_x, self.next_y, 2)] + entities.extend((floor.x, floor.y, 1) for floor in self.floors) + entities.extend((item.x, item.y, 3 if item.gold else 4) for item in self.items) + for x, y, channel in entities: + if 0 <= x < 100 and 0 <= y < 100: + state[int(y // 10), int(x // 10), channel] = True + wall = self.wall_x + 4 + if 0 <= wall < 100: + rows = np.arange(5, 100, 10) + state[(rows < self.wall_y - 12) | (rows > self.wall_y + 18), int(wall // 10), 4] = True + values = (self.steps, self.kind, self.direction > 0, self.charge, self.multiplier, self.held) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/scrambird.py b/runtime/minatar_synth/games/scrambird.py new file mode 100644 index 0000000000000000000000000000000000000000..657c6df6169d9a5116478564dc7207e4435007b4 --- /dev/null +++ b/runtime/minatar_synth/games/scrambird.py @@ -0,0 +1,153 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Target: + x: float + y: float + timer: float = 0 + + +@dataclass +class Bomb: + x: float + y: float + vx: float = 2 + vy: float = 0 + + +class ScrambirdEnvironment: + score_cap = 100 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.y, self.vy, self.fuel = 50., 0., 50. + self.height, self.slope, self.tank_timer = 10, 0, 10 + self.steps = 0 + self.multiplier = 1 + self.held = self.terminal = False + self.terrain = [(i * 10., 10) for i in range(11)] + self.shots, self.bombs, self.missiles, self.tanks = [], [], [], [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap = held and not self.held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap): + for index, (x, height) in enumerate(self.terrain): + x -= 0.3 + if x < -10: + x += 110 + next_height = self.height + self.slope + if not 10 <= next_height <= 50: + self.slope *= -1 + else: + self.height = next_height + if self.random.random() < 0.2: + self.slope = 0 + elif self.random.random() < 0.3: + self.slope = self.random.choice((-10, 10)) + height = self.height + self.tank_timer -= 1 + if self.tank_timer < 0: + self.tanks.append(Target(x + 5, 87 - height)) + self.tank_timer = self.random.uniform(1, 16) + elif self.random.random() < 0.5: + timer = 9999 if self.random.random() < 0.5 else self.random.uniform(200, 300) + self.missiles.append(Target(x + 5, 87 - height, timer)) + self.terrain[index] = x, height + if tap: + self.vy -= 0.5 if self.fuel > 0 else 0.1 + self.shots.append(Target(10, self.y)) + self.bombs.append(Bomb(10, self.y)) + self.vy = (self.vy + 0.015) * 0.98 + self.y += self.vy + self.terminal = self._wall_hit(10, self.y, 3) + for shot in self.shots: + shot.x += 2 + self.shots = [shot for shot in self.shots if shot.x <= 103 and not self._wall_hit(shot.x, shot.y, 1)] + for bomb in self.bombs: + bomb.vx *= 0.9 + bomb.vy = (bomb.vy + 0.1) * 0.9 + bomb.x += bomb.vx + bomb.y += bomb.vy + self.bombs = [bomb for bomb in self.bombs if bomb.y <= 103 and not self._wall_hit(bomb.x, bomb.y, 1)] + reward = 0 + spent = set() + for targets, fuel_tanks in ((self.missiles, False), (self.tanks, True)): + survivors = [] + for target in targets: + target.x -= 0.3 + if not fuel_tanks: + target.timer -= 1 + if target.timer < 0: + target.y -= 0.5 + hits = [projectile for projectile in (*self.shots, *self.bombs) + if abs(projectile.x - target.x) < 4 and abs(projectile.y - target.y) < 4] + if hits: + spent.update(map(id, hits)) + if fuel_tanks: + self.fuel = min(50, self.fuel + 10) + else: + reward += self.multiplier + self.multiplier += 1 + continue + self.terminal |= abs(target.x - 10) < 5 and abs(target.y - self.y) < 5 + if target.x >= -3 and target.y >= -3: + survivors.append(target) + elif not fuel_tanks: + self.multiplier = max(1, self.multiplier - 1) + targets[:] = survivors + self.shots = [shot for shot in self.shots if id(shot) not in spent] + self.bombs = [bomb for bomb in self.bombs if id(bomb) not in spent] + self.fuel = max(0, self.fuel - 0.025) + return reward + + def _wall_hit(self, x, y, margin): + return y - margin < 5 or any( + left - margin < x < left + 9 + margin and y + margin > 90 - height + and y - margin < 90 for left, height in self.terrain + ) + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[int(np.clip(self.y // 10, 0, 9)), 1, 0] = True + state[0, :, 1] = True + for col in range(10): + for x, height in self.terrain: + if x < col * 10 + 10 and x + 9 > col * 10: + state[(90 - height) // 10:9, col, 1] = True + for channel, entities in ((2, self.missiles), (3, self.tanks), (4, (*self.shots, *self.bombs))): + for entity in entities: + if 0 <= entity.x < 100 and 0 <= entity.y < 100: + state[int(entity.y // 10), int(entity.x // 10), channel] = True + values = (self.steps, round(self.fuel * 10), self.multiplier, self.held, round((self.vy + 30) * 16)) + for row, value in enumerate(values): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/screen.py b/runtime/minatar_synth/games/screen.py new file mode 100644 index 0000000000000000000000000000000000000000..e45e1a0ebce2a080beec4dc41fa457fee0c61393 --- /dev/null +++ b/runtime/minatar_synth/games/screen.py @@ -0,0 +1,128 @@ +from dataclasses import dataclass +from math import cos, pi, sin + +import numpy as np + + +@dataclass +class Shot: + x: float + y: float + angle: float + + +@dataclass +class Enemy: + x: float + y: float = -3 + + +class ScreenEnvironment: + score_cap = 150 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x = self.target = 55.0 + self.angle = 0.0 + self.ammo = 3 + self.multiplier = 1 + self.steps = self.timer = 0 + self.held = self.terminal = False + self.shots = [] + self.enemies = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap = held and not self.held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _aim(self): + return -self.angle if self.x > 50 else pi + self.angle + + def _advance(self, tap): + self.angle = (self.angle + 0.01) % (pi / 2) + if tap and self.ammo and abs(self.x - self.target) < 1: + self.shots.append(Shot(self.x, 95, self._aim())) + self.ammo -= 1 + if self.ammo == 0 and self.x == self.target: + self.target = 100 - self.target + previous = self.x + self.x += (self.target - self.x) * 0.2 + if abs(self.target - self.x) < 1: + self.x = self.target + if (previous - 50) * (self.x - 50) <= 0: + self.ammo = 3 + shots = [] + for shot in self.shots: + shot.x += cos(shot.angle) + shot.y += sin(shot.angle) + if -5 <= shot.x <= 105 and -5 <= shot.y <= 105: + shots.append(shot) + else: + self.multiplier = max(1, self.multiplier - 1) + self.timer -= 1 + if self.timer < 0: + x = 50 + self.random.choice((-1, 1)) * self.random.uniform(15, 40) + self.enemies.append(Enemy(x)) + self.timer = self.random.uniform(60, 90) + spent = set() + remaining = [] + reward = 0 + for enemy in self.enemies: + enemy.y += 0.1 + hits = [index for index, shot in enumerate(shots) + if abs(shot.x - enemy.x) < 4 and abs(shot.y - enemy.y) < 4] + if hits: + spent.update(hits) + reward += self.multiplier + self.multiplier += 1 + else: + self.terminal |= enemy.y > 99 + remaining.append(enemy) + self.enemies = remaining + self.shots = [shot for index, shot in enumerate(shots) if index not in spent] + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[9, int(self.x // 10), 0] = True + for channel, entities in ((1, self.enemies), (2, self.shots)): + for entity in entities: + if 0 <= entity.x < 100 and 0 <= entity.y < 100: + state[int(entity.y // 10), int(entity.x // 10), channel] = True + distance = np.arange(100) + x = self.x + cos(self._aim()) * distance + y = 95 + sin(self._aim()) * distance + visible = (x >= 0) & (x < 100) & (y >= 0) & (y < 100) + state[(y[visible] // 10).astype(int), (x[visible] // 10).astype(int), 3] = True + if self.x > 50: + state[:, :5, 4] = True + else: + state[:, 5:, 4] = True + for row, value in enumerate((self.steps, self.ammo, self.multiplier, self.held, + round(self.angle * 100), self.target > 50)): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/shiny.py b/runtime/minatar_synth/games/shiny.py new file mode 100644 index 0000000000000000000000000000000000000000..0a88383b804dd7ac315f646f275390251ba08aaa --- /dev/null +++ b/runtime/minatar_synth/games/shiny.py @@ -0,0 +1,156 @@ +from dataclasses import dataclass +from math import floor + +import numpy as np + + +@dataclass +class Human: + speed: float + phase: int + x: float = -4 + y: float = 89 + running: bool = False + falling: bool = False + + +@dataclass +class Drop: + x: float + y: float + vx: float + strong: bool + + +class ShinyEnvironment: + score_cap = 300 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.ground = np.full(22, 8.0) + self.cloud_x = np.arange(1, 31) * 199 / 31 + self.random.uniform(-3, 3, 30) + self.cloud_y = self.random.uniform(5, 15, 30) + self.cloud_radius = self.random.uniform(5, 10, 30) + self.weak_timer = self.random.uniform(0, 99, 30) + self.strong_timer = self.random.uniform(100, 900, 30) + self.rain = self.steps = self.population = 0 + self.wind = 0. + self.held = self.terminal = False + self.humans, self.drops = [], [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap = held and not self.held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _cloud_positions(self): + clear = np.where(self.cloud_x < 99, -20, 220) + return clear + (self.cloud_x - clear) * self.rain / 10 + + def _advance(self, tap): + if not self.humans: + self.population = min(9, self.population + 1) + self.humans = [Human(self.random.uniform(0.1, 0.15), self.random.integers(999)) + for _ in range(self.population)] + self.ground[20] = 8 + if tap: + self.wind = self.random.uniform(-0.5, 0.5) + self.ground[20] -= 0.1 + self.rain = min(10, max(0, self.rain + (1 if self.held else -1))) + cloud_positions = self._cloud_positions() + for timer, strong, bounds in ((self.weak_timer, False, (100, 200)), + (self.strong_timer, True, (500, 999))): + timer -= 1 + for index in np.flatnonzero(timer < 0): + if self.held: + self.drops.append(Drop(cloud_positions[index], self.cloud_y[index] + self.cloud_radius[index], + self.wind + self.random.uniform(-0.2, 0.2), strong)) + timer[index] = self.random.uniform(*bounds) + support = self.ground >= 8 + support[20] = self.ground[20] >= 1 + self.ground[:20] = np.minimum(self.ground[:20] + 0.12, 8) + self.ground[21] = min(8, self.ground[21] + 0.12) + if support[20]: + self.ground[20] -= 0.005 + count = len(self.humans) + reward = 0 + survivors = [] + for human in self.humans: + if not human.falling: + human.x += human.speed * (5 if human.running else 1) + on_ground = human.y < 102 and any( + intact and abs(human.x - (index * 10 - 5)) < 7 + for index, intact in enumerate(support) + ) + human.falling = not on_ground + human.y = 89 if on_ground else human.y + 1 + if human.y > 103: + self.population -= 1 + self.terminal |= self.population <= 0 + continue + human.phase += 1 + if human.phase % 30 == 0: + human.running = self.held + if human.x > 203: + reward += max(0, floor(self.ground[20] * count)) + else: + survivors.append(human) + self.humans = survivors + drops = [] + for drop in self.drops: + drop.x += drop.vx + drop.y += 1 + if drop.strong and any(not h.falling and abs(h.x - drop.x) < 4 + and abs(h.y - drop.y - 2) < 5 for h in self.humans): + continue + if drop.y <= 90: + drops.append(drop) + elif drop.strong: + index = floor(drop.x / 10) + 1 + if 2 <= index < 20: + self.ground[index] = 0 + self.drops = drops[-128:] + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + for human in self.humans: + col = int(np.clip(human.x // 20, 0, 9)) + state[min(9, int(human.y // 10)), col, int(human.falling)] = True + for index in range(1, 21): + size = self.ground[index] + if (index == 20 and size < 1) or (index != 20 and size < 8): + state[9, (index - 1) // 2, 2] = True + for drop in self.drops: + if drop.strong and 0 <= drop.x < 200: + state[int(drop.y // 10), int(drop.x // 20), 3] = True + for x, y in zip(self._cloud_positions(), self.cloud_y): + if 0 <= x < 200: + state[int(y // 10), int(x // 20), 4] = True + values = (self.steps, self.population, self.rain, self.held, round(max(0, self.ground[20]) * 50)) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/sight_on.py b/runtime/minatar_synth/games/sight_on.py new file mode 100644 index 0000000000000000000000000000000000000000..778b975bdeedaa1f8c1c38c5a11e1cd0e1ab4621 --- /dev/null +++ b/runtime/minatar_synth/games/sight_on.py @@ -0,0 +1,142 @@ +from dataclasses import dataclass +from math import cos + +import numpy as np + + +@dataclass +class Motion: + pos: np.ndarray + vel: np.ndarray + + +@dataclass +class Enemy: + motion: Motion + sink: np.ndarray + target: Motion + + +class SightOnEnvironment: + score_cap = 150 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.sight = Motion(np.full(2, 50.), np.zeros(2)) + self.enemies, self.targets, self.blasts = [], [], [] + self.steps = self.count = self.wave_timer = self.enemy_timer = 0 + self.multiplier = 1 + self.penalty = 0. + self.held = self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap = held and not self.held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _wave(self): + target = Motion(np.array([self.random.uniform(20, 80), 0.]), + np.array([self.random.uniform(-0.1, 0.1), 0.1])) + self.targets.append(target) + self.template = Enemy( + Motion(np.array([self.random.uniform(10, 90), -5.]), + self.random.uniform(1, 2, 2) * self.random.choice((-1, 1), 2)), + self.random.uniform(0.02, 0.07, 2), target, + ) + self.count = self.random.integers(2, 5) + self.interval = self.random.uniform(3, 9) + self.enemy_timer = 0 + self.wave_timer = self.random.uniform(120, 150) + + def _advance(self, tap): + self.wave_timer -= 1 + if self.wave_timer < 0: + self._wave() + for target in self.targets: + target.pos += target.vel + target.pos[0] %= 99 + self.targets = [target for target in self.targets if target.pos[1] <= 150] + template = self.template + template.motion.pos += template.target.vel + self.enemy_timer -= 1 + if self.count and self.enemy_timer < 0: + self.enemies.append(Enemy(Motion(template.motion.pos.copy(), template.motion.vel.copy()), + template.sink, template.target)) + self.count -= 1 + self.enemy_timer = self.interval + if not self.enemies and not self.count: + self.wave_timer = 0 + reward = 0 + remaining = [] + for enemy in self.enemies: + motion = enemy.motion + delta = enemy.target.pos - motion.pos + delta[0] = (delta[0] + 50) % 100 - 50 + motion.vel = (motion.vel + delta * enemy.sink) * 0.997 + motion.pos += motion.vel * 0.2 + motion.pos[0] %= 99 + if any(np.all(abs(motion.pos - center) < 3 + 7.5 * cos(age * 0.05)) + for center, age in self.blasts): + reward += self.multiplier + self.multiplier += 1 + else: + self.terminal |= bool(motion.pos[1] > 90) + remaining.append(enemy) + self.enemies = remaining + self.blasts = [(center, age + 1) for center, age in self.blasts if age < 31] + leader = max(self.enemies, key=lambda enemy: enemy.motion.pos[1], default=None) + target = leader.motion.pos if leader is not None and leader.motion.pos[1] > 0 else np.full(2, 50.) + delta = target - self.sight.pos + delta[0] = (delta[0] + 50) % 100 - 50 + self.sight.vel = (self.sight.vel + delta * 0.01) * 0.97 + self.sight.pos += self.sight.vel * 0.2 + self.sight.pos[0] %= 99 + if tap: + self.multiplier = 1 + self.blasts.append((self.sight.pos.copy(), 0)) + for target in self.targets: + target.pos[1] += self.penalty + self.penalty += 1 + self.sight.vel *= 0.1 + self.penalty *= 0.99 + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + positions = [(self.sight.pos, 0)] + positions.extend((enemy.motion.pos, 1) for enemy in self.enemies) + positions.extend((target.pos, 2) for target in self.targets) + for (x, y), channel in positions: + if 0 <= x < 100 and 0 <= y < 100: + state[int(y // 10), int(x // 10), channel] = True + rows, cols = np.ogrid[5:100:10, 5:100:10] + for (x, y), age in self.blasts: + reach = 7.5 * cos(age * 0.05) + 5 + state[:, :, 3] |= (abs(cols - x) < reach) & (abs(rows - y) < reach) + state[9, :, 4] = True + for row, value in enumerate((self.steps, self.multiplier, self.held, round(self.penalty * 10))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/skiing.py b/runtime/minatar_synth/games/skiing.py new file mode 100644 index 0000000000000000000000000000000000000000..9dfd2c8d00e025c1b5fb38a2a5dcde23c47e1adc --- /dev/null +++ b/runtime/minatar_synth/games/skiing.py @@ -0,0 +1,133 @@ +import numpy as np + + +GATE_OFFSETS = tuple(2 + index * 2 for index in range(50)) +GATE_COLUMNS = tuple(1 + (index * 3 + 2) % 8 for index in range(50)) +OBSTACLES = tuple((3 + index * 4, (index * 5 + 1) % 10) for index in range(24)) + + +class SkiingEnvironment: + """Olympic slalom with ski-angle speed, gates, trees, and timed recovery.""" + + score_cap = 6_000.0 + + def __init__(self, sticky_action_prob: float = 0.1, horizon: int = 300): + self.sticky_action_prob = sticky_action_prob + self.horizon = horizon + self.random = np.random.RandomState() + self.seed(0) + self.reset() + + @classmethod + def normalize_score(cls, raw_score: float) -> float: + return min(max(raw_score, 0.0), cls.score_cap) / cls.score_cap + + def seed(self, seed: int) -> None: + self.random.seed(seed) + + def reset(self) -> None: + self.steps = 0 + self.last_action = 0 + self.terminal = False + self._restart_run() + + def _restart_run(self) -> None: + self.progress = 0 + self.column = 5 + self.previous_column = self.column + self.angle = 0 + self.previous_angle = self.angle + self.recovery = 0 + self.score = 0.0 + self.passed: set[int] = set() + self.missed: set[int] = set() + self.crashed: set[int] = set() + + def act(self, action: int) -> tuple[float, bool]: + if self.terminal: + return 0.0, True + if self.random.rand() < self.sticky_action_prob: + action = self.last_action + self.last_action = action + self.previous_column = self.column + self.previous_angle = self.angle + reward = 0.0 + if action == 5: + self._restart_run() + elif self.recovery > 0: + self.recovery -= 1 + else: + if action == 1: + self.angle = max(-3, self.angle - 1) + elif action == 3: + self.angle = min(3, self.angle + 1) + elif action == 2: + self.angle -= int(np.sign(self.angle)) + elif action == 4: + self.angle = -3 if self.angle <= 0 else 3 + progress_before = self.progress + speed = 2 if self.angle == 0 else 1 if abs(self.angle) <= 2 else 0 + self.progress = min(100, self.progress + speed) + self.column = min(9, max(0, self.column + int(np.sign(self.angle)))) + reward += self._resolve_gates(progress_before) + self._resolve_obstacles(progress_before) + if self.progress >= 100: + reward += 1_000.0 + self.terminal = True + self.score += reward + self.steps += 1 + if self.steps >= self.horizon: + self.terminal = True + return reward, self.terminal + + def _resolve_gates(self, previous_progress: int) -> float: + reward = 0.0 + for index, (offset, gate_column) in enumerate(zip(GATE_OFFSETS, GATE_COLUMNS, strict=True)): + if index in self.passed or index in self.missed or not previous_progress < offset <= self.progress: + continue + if abs(self.column - gate_column) <= 1: + self.passed.add(index) + reward += 100.0 + else: + self.missed.add(index) + return reward + + def _resolve_obstacles(self, previous_progress: int) -> None: + for index, (offset, column) in enumerate(OBSTACLES): + if index in self.crashed or not previous_progress < offset <= self.progress: + continue + if self.column == column: + self.crashed.add(index) + self.recovery = 3 + + def state(self) -> np.ndarray: + state = np.zeros((10, 10, 6), dtype=bool) + state[2, self.column, 0] = True + state[2, self.previous_column, 4] = True + for index, (offset, gate_column) in enumerate(zip(GATE_OFFSETS, GATE_COLUMNS, strict=True)): + row = 2 + offset - self.progress + if 0 <= row < 10 and index not in self.passed and index not in self.missed: + state[row, max(0, gate_column - 1), 2] = True + state[row, min(9, gate_column + 1), 2] = True + for index, (offset, column) in enumerate(OBSTACLES): + row = 2 + offset - self.progress + if 0 <= row < 10 and index not in self.crashed: + state[row, column, 1] = True + for index in range(50): + state[index // 10, index % 10, 5] = index in self.passed + state[5 + index // 10, index % 10, 5] = index in self.missed + values = ( + (self.progress, 7), + (self.column, 4), + (self.angle + 3, 3), + (self.previous_angle + 3, 3), + (self.recovery, 2), + (self.steps, 9), + ) + offset = 0 + for value, width in values: + for bit in range(width): + index = offset + bit + state[index // 10, index % 10, 4] = bool(value & (1 << bit)) + offset += width + return state diff --git a/runtime/minatar_synth/games/sky_floor.py b/runtime/minatar_synth/games/sky_floor.py new file mode 100644 index 0000000000000000000000000000000000000000..2839ae2c88998c581ff8b666cb59604138f53711 --- /dev/null +++ b/runtime/minatar_synth/games/sky_floor.py @@ -0,0 +1,155 @@ +from dataclasses import dataclass +from math import atan2, ceil, cos, hypot, pi, sin, sqrt + +import numpy as np + + +@dataclass +class Floor: + x: float + y: float + width: float + height: float + + +@dataclass +class Fan: + x: float + y: float + speed: float + angle: float + + +class SkyFloorEnvironment: + score_cap = 150 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.y = 50., 90. + self.vx = self.vy = self.distance = 0. + self.radius = 2. + self.steps = self.action = 0 + self.multiplier = 1 + self.outside = self.terminal = False + self.floors = [Floor(50, 50, 80, 150)] + self.fans, self.coins = [], [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.action = action + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _spawn(self): + last = self.floors[-1] + for _ in range(9): + x, width = self.random.uniform(0, 99), self.random.uniform(30, 80) + if abs(x - last.x) < (width + last.width) / 2: + break + else: + x, width = last.x, last.width + height = self.random.uniform(30, 99) + y = -height / 2 - 20 + self.floors.append(Floor(x, y, width, height)) + for _ in range(self.random.integers(ceil(height / 30))): + side = self.random.choice((-1, 1)) + self.fans.append(Fan(x + side * width * self.random.uniform(0.6, 0.7), + y + height * self.random.uniform(-0.4, 0.4), + self.random.uniform(1, 2), + (0 if side < 0 else pi) + self.random.uniform(-pi / 8, pi / 8))) + count = self.random.integers(ceil(height / 10)) + start = self.random.uniform(-0.5, 0.5) * height - count * 5 + coin_x = x + width * self.random.uniform(-0.2, 0.2) + for i in range(count): + offset = start + i * 10 + if abs(offset) < height * 0.3: + self.coins.append((coin_x, y + offset)) + self.distance = self.random.uniform(0.6, 0.8) * height + + def _advance(self): + sx = (min(55, max(45, self.x)) - self.x) * 0.1 + sy = max(0, 80 - self.y) * 0.1 + self.distance -= sy + if self.distance < 0: + self._spawn() + for floor in self.floors: + floor.x += sx + floor.y += sy + self.floors = [floor for floor in self.floors if floor.y - floor.height / 2 <= 99] + for fan in self.fans: + fan.x += sx + fan.y += sy + dx, dy = self.x - fan.x, self.y - fan.y + offset = abs((atan2(dy, dx) - fan.angle + pi) % (2 * pi) - pi) + force = 3 * fan.speed * max(0, pi / 4 - offset) / (hypot(dx, dy) + 1) + self.vx += force * cos(fan.angle) + self.vy += force * sin(fan.angle) + self.fans = [fan for fan in self.fans if fan.y <= 105] + offset = 35 * ((self.action == 3) - (self.action == 1)) + self.vx = (self.vx + offset * abs(offset) * 0.0001) * 0.95 + self.vy = (self.vy - 0.1) * 0.95 * (1 - 0.03 * sqrt(abs(offset))) + self.x += self.vx + sx + self.y += self.vy + sy - 0.1 + if any(abs(floor.x - self.x) < floor.width / 2 + self.radius and + abs(floor.y - self.y) < floor.height / 2 + self.radius for floor in self.floors): + self.outside = False + self.radius += (2 - self.radius) * 0.1 + else: + if not self.outside: + self.vx *= 0.5 + self.outside = True + self.radius *= 0.925 + self.terminal = self.radius < 0.1 + reward = 0 + remaining = [] + for x, y in self.coins: + x, y = x + sx, y + sy + if abs(x - self.x) < 4 + self.radius and abs(y - self.y) < 4 + self.radius: + reward += self.multiplier + self.multiplier += 1 + elif y > 105: + self.multiplier = max(1, self.multiplier - 1) + else: + remaining.append((x, y)) + self.coins = remaining + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + row, col = np.clip(np.array([self.y, self.x]) // 10, 0, 9).astype(int) + state[row, col, 0] = True + rows, cols = np.ogrid[5:100:10, 5:100:10] + for floor in self.floors: + state[:, :, 1] |= (abs(rows - floor.y) < floor.height / 2 + 5) & ( + abs(cols - floor.x) < floor.width / 2 + 5) + for channel, points in ((2, self.coins), (3, [(fan.x, fan.y) for fan in self.fans])): + for x, y in points: + if 0 <= x < 100 and 0 <= y < 100: + state[int(y // 10), int(x // 10), channel] = True + state[row, col, 4] = self.outside + values = (self.steps, self.action, self.multiplier, round(self.radius * 100), + round((self.vx + 20) * 20), round((self.vy + 20) * 20)) + for row, value in enumerate(values): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/sky_golf.py b/runtime/minatar_synth/games/sky_golf.py new file mode 100644 index 0000000000000000000000000000000000000000..6d3fe60e0e4040f342f8db8ac33fa85f8650953b --- /dev/null +++ b/runtime/minatar_synth/games/sky_golf.py @@ -0,0 +1,168 @@ +from math import cos, hypot, pi, sin + +import numpy as np + + +FAIRWAY, SAND, WATER, TREE, FLAG = range(5) + + +class SkyGolfEnvironment: + score_cap = 3 + hole_seeds = (71, 45, 9) + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.hole = self.ammo = self.steps = 0 + self.held = self.terminal = False + self._start_hole() + + def _start_hole(self): + course = np.random.default_rng(self.hole_seeds[self.hole]) + self.tiles = [] + + def platform(x, y, count, tee=False, flag=False): + kinds = np.full(count, FAIRWAY) + heights = np.zeros(count) + for kind, probability in ((TREE, 1), (FAIRWAY, 0.7), (SAND, 0.8), (WATER, 0.5)): + if course.random() < probability: + width = int(course.integers(3, count // 2)) + start = int(course.integers(0, count - width)) + kinds[start:start + width] = kind + if kind == TREE: + heights[start:start + width] = course.integers(10, 20) + course.integers(-5, 6, width) + if tee: + kinds[:5] = FAIRWAY + if flag: + width = int(course.integers(3, 6)) + start = count - width - int(course.integers(3)) + kinds[start:start + width] = FAIRWAY + kinds[start + width // 2] = FLAG + self.tiles.extend((x + i * 6, y, kind, heights[i]) for i, kind in enumerate(kinds)) + + width, y = 25, 90 + count = course.integers(1, 3) + if course.random() < 0.5: + width = course.integers(12, 20) + if course.random() < 0.5: + y = course.integers(30, 70) + platform(0, y, width, tee=True) + for index in range(count): + width = course.integers(9, 20) + platform(course.integers(150 - 6 * width), course.integers(30, 70), + width, flag=index == count - 1) + self.x, self.y = 5., y - 7. + self.vx = self.vy = self.angle = 0. + self.direction = -1 + self.base = 1. + self.previous = self.x, self.y, self.base + self.power = 0.1 + self.mode = "aim" + self.ammo += 5 + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap, release = held and not self.held, self.held and not held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0, release and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _surface(self, x, y): + for left, bottom, kind, height in self.tiles: + if left - 2 < x < left + 8 and bottom - 7 < y < bottom + 2: + return kind + if kind == TREE and left - 1 < x < left + 7 and bottom - 7 - height < y < bottom - 5: + return FAIRWAY + return None + + def _advance(self, tap, release): + if self.mode == "aim": + self.angle += self.direction * 0.05 + if not -pi <= self.angle <= 0: + self.direction *= -1 + self.angle += self.direction * 0.1 + if tap: + self.mode = "power" + elif self.mode == "power": + self.power += 0.2 + if self.power > 9 or release: + speed = self.power * 0.5 * self.base + self.vx, self.vy = speed * cos(self.angle), speed * sin(self.angle) + self.mode = "flight" + self.ammo -= 1 + else: + return self._fly() + return 0 + + def _fly(self): + if self._surface(self.x + self.vx, self.y) is not None or not 2 <= self.x + self.vx <= 148: + self.vx *= -0.8 + self.vy *= 0.8 + surface = self._surface(self.x, self.y + self.vy) + if surface is not None: + factor = {SAND: 0.5, WATER: 0.4}.get(surface, 0.8) if self.vy > 0 else 0.8 + self.vy *= -factor + self.vx *= factor + if self.vy < 0 and hypot(self.vx, self.vy) < 0.5: + if surface == FLAG: + self.hole += 1 + self.terminal = self.hole == len(self.hole_seeds) + if not self.terminal: + self._start_hole() + return 1 + if surface == WATER: + self.x, self.y, self.base = self.previous + else: + self.base = 0.5 if surface == SAND else 1 + self.previous = self.x, self.y, self.base + self._rest() + return 0 + self.x += self.vx + self.y += self.vy + self.vx *= 0.98 + self.vy = self.vy * 0.98 + 0.1 + if self.y > 110: + self.x, self.y, self.base = self.previous + self._rest() + return 0 + + def _rest(self): + self.mode = "aim" + self.power = 0.1 + self.terminal = self.ammo <= 0 + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[int(np.clip(self.y // 10, 0, 9)), int(np.clip(self.x // 15, 0, 9)), 0] = True + for x, y, kind, height in self.tiles: + col = int(x // 15) + channel = 2 if kind == SAND else 3 if kind == WATER else 4 if kind == FLAG else 1 + state[int((y - 3) // 10), col, channel] = True + if kind == TREE: + state[int((y - 5 - height) // 10):int((y - 5) // 10) + 1, col, 1] = True + gauges = (self.steps, self.hole, self.ammo, round(self.power * 50), + round(-self.angle * 100), self.direction > 0, self.held, + ("aim", "power", "flight").index(self.mode), self.base < 1) + for row, value in enumerate(gauges): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/sky_raftsman.py b/runtime/minatar_synth/games/sky_raftsman.py new file mode 100644 index 0000000000000000000000000000000000000000..670657221012535407facc4e016e1cbfc49c2a27 --- /dev/null +++ b/runtime/minatar_synth/games/sky_raftsman.py @@ -0,0 +1,129 @@ +from dataclasses import dataclass +from math import atan2, cos, floor, hypot, sin + +import numpy as np + + +@dataclass +class Log: + x: float + y: float + size: float + spin: float + angle: float = 0 + vx: float = 0 + vy: float = 0 + distance: float = 0 + + +class SkyRaftsmanEnvironment: + score_cap = 150 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x = self.y = self.vx = self.vy = self.distance = 0. + self.steps = 0 + self.jumping = self.held = self.terminal = False + self.current = Log(50, 75, 20, -0.05) + self.logs = [self.current, *(self._log(75 + i * 30) for i in range(1, 5))] + + def _log(self, y): + return Log(self.random.uniform(10, 90), y, self.random.uniform(15, 25), + self.random.uniform(0.04, 0.08) * self.random.choice((-1, 1))) + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap = held and not self.held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self, tap): + scroll = -0.05 + 0.1 * max(0, 20 - self.y) - 0.2 * max(0, self.y - 50) + log = self.current + if tap and not self.jumping: + self.jumping = True + self.vx, self.vy = 2 * cos(log.angle), 2 * sin(log.angle) + self.x += 2 * self.vx + self.y += 2 * self.vy + log.vx, log.vy = -self.vx, -self.vy + if self.jumping: + self.x += self.vx + self.y += self.vy + scroll + self.vx *= 0.99 + self.vy = self.vy * 0.99 + (0.05 if self.held else 0.1) + else: + self.x = log.x + log.size / 2 * cos(log.angle) + self.y = log.y + log.size / 2 * sin(log.angle) + if (self.x < 3 and self.vx < 0) or (self.x > 97 and self.vx > 0): + self.vx *= -1 + self.terminal = self.y > 100 + reward = 0 + for log in self.logs: + log.x += log.vx + log.y += log.vy + scroll + log.distance += log.vy + if log.distance > 20: + log.distance -= 20 + reward += max(0, floor(log.vy * 5)) + log.vx *= 0.99 + log.vy *= 0.99 + if (log.x < log.size / 2 and log.vx < 0) or (log.x > 100 - log.size / 2 and log.vx > 0): + log.vx *= -1 + log.angle += log.spin + self.logs = [log for log in self.logs if log.y >= -99 or log is self.current] + self.distance += scroll + if self.distance < 0 and not self.jumping: + self.logs.append(self._log(125)) + self.distance = 100 + if self.jumping: + for log in self.logs: + if log.y <= 100 + log.size / 2 and abs( + hypot(self.x - log.x, self.y - log.y) - log.size / 2 + ) < 5: + self.jumping = False + self.current = log + log.angle = atan2(self.y - log.y, self.x - log.x) + break + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + row, col = np.clip(np.array([self.y, self.x]) // 10, 0, 9).astype(int) + state[row, col, 0] = True + rows, cols = np.ogrid[5:100:10, 5:100:10] + for log in self.logs: + if log.y > 100 + log.size / 2: + state[9, :, 3] |= abs(cols[0] - log.x) < log.size / 2 + 5 + else: + channel = 2 if log is self.current and not self.jumping else 1 + state[:, :, channel] |= abs(np.hypot(cols - log.x, rows - log.y) - log.size / 2) < 6 + dx, dy = (self.vx, self.vy) if self.jumping else (cos(self.current.angle), sin(self.current.angle)) + row, col = np.clip(np.array([self.y + 10 * dy, self.x + 10 * dx]) // 10, 0, 9).astype(int) + state[row, col, 4] = True + values = (self.steps, self.held, self.jumping, + round((self.vx + 10) * 20), round((self.vy + 10) * 20)) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/slalom.py b/runtime/minatar_synth/games/slalom.py new file mode 100644 index 0000000000000000000000000000000000000000..cc958577585c62aa4c7fb531e986e6254f0ca920 --- /dev/null +++ b/runtime/minatar_synth/games/slalom.py @@ -0,0 +1,130 @@ +from dataclasses import dataclass +from math import cos, floor, hypot, pi, sin, sqrt + +import numpy as np + + +@dataclass +class Wall: + y: float + side: int + length: int + + @property + def tip(self): + return 99 - self.length if self.side > 0 else self.length + + +@dataclass +class Rock: + x: float + y: float + width: int + height: int + + +class SlalomEnvironment: + score_cap = 300 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x = self.y = 90.0 + self.angle = -3 * pi / 4 + self.vx, self.vy = cos(self.angle), sin(self.angle) + self.scroll = self.wall_distance = self.rock_distance = 0. + self.side = 1 + self.closest = 99. + self.steps = 0 + self.held = self.terminal = False + self.walls, self.rocks = [], [] + self.target = None + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0.0, True + if self.random.random() >= self.sticky_action_prob: + self.held = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self): + self.rock_distance -= self.scroll + if self.rock_distance < 0: + x = self.random.integers(-5, 5) + 100 * self.random.integers(2) + self.rocks.append(Rock(x, -9, self.random.integers(9, 19), 2 * self.random.integers(5, 9))) + self.rock_distance += 10 + for rock in self.rocks: + rock.y += self.scroll + self.rocks = [rock for rock in self.rocks if rock.y < 109] + self.wall_distance -= self.scroll + if self.wall_distance < 0: + self.walls.append(Wall(-5, self.side, self.random.integers(40, 60))) + self.side *= -1 + self.wall_distance += self.random.integers(80, 90) + for wall in self.walls: + wall.y += self.scroll + target = next((wall for wall in self.walls if wall.y < self.y + 9), None) + self.walls = [wall for wall in self.walls if wall.y < 105] + reward = 0 + if target is not self.target: + reward = max(0, floor(100 / (sqrt(self.closest) + 1)) - 15) + self.target = target + self.closest = 99 + if self.held and target is not None: + self.angle += target.side * 0.07 + self.vx = self.vx * 0.98 + 0.03 * cos(self.angle) + self.vy = self.vy * 0.98 + 0.03 * sin(self.angle) + self.x += self.vx + self.y += self.vy + self.scroll = max(0, 88 - self.y) * 0.5 + self.y += self.scroll + self.terminal = not (0 <= self.x <= 99 and 0 <= self.y <= 99) + self.terminal |= any( + abs(wall.y - self.y) < 4 and (self.x > wall.tip - 2 if wall.side > 0 else self.x < wall.tip + 2) + for wall in self.walls + ) + self.terminal |= any(abs(rock.x - self.x) < rock.width / 2 + 2 + and abs(rock.y - self.y) < rock.height / 2 + 2 for rock in self.rocks) + if target is not None: + self.closest = min(self.closest, hypot(target.tip - self.x, target.y - self.y)) + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + row, col = np.clip(np.array([self.y, self.x]) // 10, 0, 9).astype(int) + state[row, col, 0] = True + rows, cols = np.ogrid[5:100:10, 5:100:10] + for wall in self.walls: + state[:, :, 1] |= (abs(rows - wall.y) < 7) & ( + cols >= wall.tip - 5 if wall.side > 0 else cols <= wall.tip + 5) + for rock in self.rocks: + state[:, :, 2] |= (abs(rows - rock.y) < rock.height / 2 + 5) & ( + abs(cols - rock.x) < rock.width / 2 + 5) + if self.target is not None and 0 <= self.target.y < 100: + state[int(self.target.y // 10), self.target.tip // 10, 3] = True + x, y = self.x + 10 * cos(self.angle), self.y + 10 * sin(self.angle) + row, col = np.clip(np.array([y, x]) // 10, 0, 9).astype(int) + state[row, col, 4] = True + for row, value in enumerate((self.steps, self.held, round(self.closest * 5), + round((self.vx + 2) * 100), round((self.vy + 2) * 100))): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/slashes.py b/runtime/minatar_synth/games/slashes.py new file mode 100644 index 0000000000000000000000000000000000000000..1edb8b7e17707d1d2ca0f3dc10139f4a6748cd5d --- /dev/null +++ b/runtime/minatar_synth/games/slashes.py @@ -0,0 +1,101 @@ +from dataclasses import dataclass +from math import sqrt + +import numpy as np + + +@dataclass +class Slash: + x: float + y: float + slope: int + width: float + + def overlaps(self, x, y, width, thickness, margin=0): + dx, dy = x - self.x, y - self.y + return ((abs(dx + self.slope * dy) < (width / 2 + margin) * sqrt(2)) + & (abs(dy - self.slope * dx) < (thickness / 2 + margin) * sqrt(2))) + + +class SlashesEnvironment: + score_cap = 400 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.slashes = [Slash(22, 50, 1, 30)] + self.direction = 1 + self.speed = 1. + self.pending = self.timer = 0. + self.steps = 0 + self.held = self.terminal = False + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0., True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + if held and not self.held: + self.direction *= -1 + self.held = held + self.steps += 1 + reward = 0. + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return reward, self.terminal + + def _advance(self): + self.speed += (1 - self.speed) * 0.03 + self.timer -= 1 + if self.timer < 0: + width = self.random.integers(40, 70) + candidate = Slash(self.random.integers(-99, 199), -width, + self.random.choice((-1, 1)), width) + points = np.linspace(-width / 2, width / 2, width) / sqrt(2) + if not any(np.any(slash.overlaps(candidate.x + points, + candidate.y + candidate.slope * points, + slash.width, 4, 10)) for slash in self.slashes): + candidate.width -= 20 + self.slashes.append(candidate) + self.timer += self.random.uniform(10, 15) + self.terminal = any(slash.overlaps(50, 90, slash.width, 4, 2) for slash in self.slashes) + reward = 0. + if not self.terminal: + if any(slash.overlaps(50, 90, slash.width, 22, 2) for slash in self.slashes): + self.speed += 0.03 + self.pending += self.speed + else: + reward, self.pending = self.pending, 0. + for slash in self.slashes: + slash.x += self.direction * self.speed + slash.y += self.speed + self.slashes = [slash for slash in self.slashes if slash.y < 99 + slash.width] + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[9, 5, 0] = True + rows, cols = np.ogrid[5:100:10, 5:100:10] + for slash in self.slashes: + state[:, :, 1] |= slash.overlaps(cols, rows, slash.width, 4, 5) + state[:, :, 2] |= slash.overlaps(cols, rows, slash.width, 22, 5) + state[8, 4 if self.direction > 0 else 6, 3] = True + state[9, 5, 4] = self.pending > 0 + for row, value in enumerate((self.steps, self.held, round(self.speed * 100), + min(1023, round(self.pending * 4)))): + for bit in range(10): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/slime_stretcher.py b/runtime/minatar_synth/games/slime_stretcher.py new file mode 100644 index 0000000000000000000000000000000000000000..2e878e177ebb3e0caca757afb45c7427f4c2c87b --- /dev/null +++ b/runtime/minatar_synth/games/slime_stretcher.py @@ -0,0 +1,137 @@ +from dataclasses import dataclass + +import numpy as np + + +@dataclass +class Wall: + x: float + y: float + width: float + height: float + + def overlaps(self, x, y, width, height): + return (x < self.x + self.width and x + width > self.x + and y < self.y + self.height and y + height > self.y) + + +class SlimeStretcherEnvironment: + score_cap = 300 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x, self.y = 50., 90. + self.width = self.height = 20 + self.wall_distance, self.coin_distance = 50., 30. + self.steps = 0 + self.multiplier = 1 + self.held = self.terminal = False + self.walls, self.coins = [], [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0., True + if self.random.random() >= self.sticky_action_prob: + self.held = action == 5 + self.steps += 1 + reward = 0 + for _ in range(4): + reward += self._advance() + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _advance(self): + if self.held: + self.height = min(80, self.height + 2) + self.width = max(10, self.width - 0.5) + self.y = max(10, self.y - 2) + speed = 0.5 + else: + self.height = max(20, self.height - 4) + self.width = min(20, self.width + 1) + speed = 1.5 + self.x += speed + if self.x < 50: + self.x += 1 + self.terminal = self.x < -self.width + self.wall_distance -= speed + if self.wall_distance <= 0: + width = self.random.uniform(20, 60) + self.walls.append(Wall(200, self.random.uniform(0, 70), width, self.random.uniform(20, 40))) + self.wall_distance = width + self.random.integers(35, 55) + self.coin_distance -= speed + if self.coin_distance <= 0: + self.coins.append((203, self.random.uniform(20, 80))) + self.coin_distance = self.random.integers(30, 60) + grounded = False + for wall in self.walls: + if not wall.overlaps(self.x, self.y, self.width, self.height): + continue + if self.y + self.height < wall.y + 10: + self.height -= 1 + self.y = wall.y - self.height + grounded = True + elif self.y > wall.y + wall.height - 10: + self.y = wall.y + wall.height + self.height -= 2 + elif self.x + self.width < wall.x + 5: + self.x = wall.x - self.width + self.width -= 1 + else: + self.y = wall.y - self.height + grounded = True + if not grounded: + self.y = min(90, self.y + 1) + self.y = min(self.y, 90 - self.height) + self.x -= speed + for wall in self.walls: + wall.x -= speed + self.walls = [wall for wall in self.walls if wall.x + wall.width >= 0] + reward = 0 + remaining = [] + for x, y in self.coins: + if any(wall.overlaps(x - 3, y - 3, 6, 6) for wall in self.walls): + continue + if self.x - 3 < x < self.x + self.width + 3 and self.y - 3 < y < self.y + self.height + 3: + reward += self.multiplier + self.multiplier += 1 + elif x - speed < -3: + self.multiplier = max(1, self.multiplier - 1) + else: + remaining.append((x - speed, y)) + self.coins = remaining + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + rows, cols = np.ogrid[:100:10, :200:20] + state[:, :, 0] = (cols < self.x + self.width) & (cols + 20 > self.x) & ( + rows < self.y + self.height) & (rows + 10 > self.y) + for wall in self.walls: + state[:, :, 1] |= (cols < wall.x + wall.width) & (cols + 20 > wall.x) & ( + rows < wall.y + wall.height) & (rows + 10 > wall.y) + for x, y in self.coins: + if 0 <= x < 200: + state[int(y // 10), int(x // 20), 2] = True + state[9, :, 3] = True + state[:, :, 4] = state[:, :, 0] & self.held + values = (self.steps, self.multiplier, round(self.width * 10), + round(self.height * 4), self.held) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state diff --git a/runtime/minatar_synth/games/smily_angry.py b/runtime/minatar_synth/games/smily_angry.py new file mode 100644 index 0000000000000000000000000000000000000000..cd9a58f60de5d13ab38b3c8bc38f10dbc62ae36e --- /dev/null +++ b/runtime/minatar_synth/games/smily_angry.py @@ -0,0 +1,132 @@ +from dataclasses import dataclass +from math import atan2, cos, hypot, sin + +import numpy as np + + +@dataclass +class Face: + x: float + timer: float + smile: bool + lead: bool + target_x: float + y: float = 20 + target_y: float = 20 + interval: float = 30 + speed: float = 1 + + +@dataclass +class Projectile: + x: float + y: float + vx: float + vy: float + bonus: bool + + +class SmilyAngryEnvironment: + score_cap = 300 + + def __init__(self, sticky_action_prob=0.1, horizon=400): + self.sticky_action_prob = sticky_action_prob + self.horizon = min(horizon, 400) + self.seed(0) + self.reset() + + def seed(self, seed): + self.random = np.random.default_rng(seed) + + def reset(self): + self.x = 50. + self.direction = self.multiplier = 1 + self.steps = 0 + self.held = self.terminal = False + self.faces = [Face(30, 20, True, True, 30), Face(70, 50, False, False, 70)] + self.projectiles = [] + + @classmethod + def normalize_score(cls, score): + return min(max(score, 0), cls.score_cap) / cls.score_cap + + def act(self, action): + if self.terminal: + return 0., True + held = self.held if self.random.random() < self.sticky_action_prob else action == 5 + tap = held and not self.held + self.held = held + self.steps += 1 + reward = 0 + for frame in range(4): + reward += self._advance(tap and frame == 0) + if self.terminal: + break + self.terminal |= self.steps >= self.horizon + return float(reward), self.terminal + + def _fire(self, face): + dx, dy = self.x - face.x, 90 - face.y + if face.lead: + vx = self.direction * 0.5 + first = hypot(dx, dy) / face.speed + second = hypot(dx + vx * first, dy) / face.speed + dx += vx * second + angle = atan2(dy, dx) + self.projectiles.append(Projectile(face.x, face.y, cos(angle) * face.speed, + sin(angle) * face.speed, face.smile)) + + def _advance(self, tap): + for face in self.faces: + face.x += (face.target_x - face.x) * 0.1 + face.y += (face.target_y - face.y) * 0.1 + face.timer -= 1 + if face.timer < 0: + self._fire(face) + face.timer = face.interval + if self.random.random() < 0.002: + face.target_x = self.random.uniform(10, 90) + face.target_y = self.random.uniform(10, 40) + if self.random.random() < 0.002: + face.smile = not face.smile + if self.random.random() < 0.002: + face.lead = not face.lead + if self.random.random() < 0.002: + face.interval = self.random.uniform(30, 40) + face.speed = self.random.uniform(0.9, 1.2) + if tap: + self.direction *= -1 + self.x = (self.x + self.direction * 0.5 + 3) % 106 - 3 + reward = 0 + remaining = [] + for projectile in self.projectiles: + projectile.x = (projectile.x + projectile.vx + 3) % 106 - 3 + projectile.y += projectile.vy + reach = 5.5 if projectile.bonus else 4 + if abs(projectile.x - self.x) < reach and abs(projectile.y - 90) < reach: + if projectile.bonus: + reward += self.multiplier + self.multiplier += 1 + continue + self.terminal = True + if projectile.y < 93 - (3 if projectile.bonus else 1): + remaining.append(projectile) + elif projectile.bonus: + self.multiplier = max(1, self.multiplier - 1) + self.projectiles = remaining + return reward + + def state(self): + state = np.zeros((10, 10, 6), dtype=bool) + state[9, int(np.clip(self.x // 10, 0, 9)), 0] = True + for face in self.faces: + state[int(face.y // 10), int(face.x // 10), 1 if face.smile else 2] = True + for projectile in self.projectiles: + if 0 <= projectile.x < 100 and 0 <= projectile.y < 100: + state[int(projectile.y // 10), int(projectile.x // 10), 3 if projectile.bonus else 4] = True + values = (self.steps, self.multiplier, self.direction > 0, self.held, + *(face.lead for face in self.faces), *(round(face.timer) for face in self.faces)) + for row, value in enumerate(values): + for bit in range(9): + state[row, bit, 5] = bool(value & (1 << bit)) + return state