diff --git a/DATA_FORMAT.md b/DATA_FORMAT.md new file mode 100644 index 0000000000000000000000000000000000000000..fc7b86e27fa8bbe9bc0b1d6c5bcfaa57011fa341 --- /dev/null +++ b/DATA_FORMAT.md @@ -0,0 +1,131 @@ +# Canonical data + +The canonical package contains nine evaluation sets. Perception uses fixed +images and has no generation command. The canonical dataset is hosted at [mrble/MARBLE](https://huggingface.co/datasets/mrble/MARBLE). + +| Task | Planning easy | Planning hard | Perception | +| --- | ---: | ---: | ---: | +| CUBE | 200 | 200 | 50 | +| MAZE | 200 | 200 | 50 | +| BLOX | 200 | 200 | 50 | + +Each set lives at `//samples.jsonl`, with one JSON +object per line and an ID unique within that set. Every set includes +`manifest.json` with its count, preparation recipe, source hashes, and SHA-256 +hashes of its files. Perception images live under `images/`; `image_path` is +relative to the directory containing `samples.jsonl`. Keep these files together. + +The six canonical planning JSONL files preserve the original benchmark records. +`generate.py` samples new puzzles from the documented families; it does not +recreate the exact canonical files. Generated records add seeds and generation +metadata. See [Planning generation](DATA_GENERATION.md). + +## Load and evaluate + +`src/data_paths.py` pins the `mrble/MARBLE` repository and release commit. +Evaluation without `--data_root` uses `snapshot_download` to fetch only the selected set, including its images: + +```bash +python eval.py --task cube --mode planning --config easy --model MODEL +python eval.py --task blox --mode perception --model MODEL +``` + +Files are read directly from the +[Hugging Face cache](https://huggingface.co/docs/huggingface_hub/guides/download). +Rerun an interrupted download to complete it. Set `HF_HUB_OFFLINE=1` before starting +Python to use an already cached set without network access. No files are copied +into the code repository, and evaluation never generates data. + +For prepared or generated local data, pass `--data_root PATH` or set +`MARBLE_DATA_ROOT`. The CLI option takes precedence. A local root disables HF +loading, including when local files are missing: + +```bash +python eval.py --task blox --mode perception --model MODEL --data_root data +``` + +Evaluation summaries record the manifest and actual samples hash, plus the HF +repository and commit when loaded from HF. Keep the JSONL, images, and manifest +unchanged when comparing benchmark scores. Use a fresh output directory when +evaluating another dataset version; resume does not compare previous settings. + +## CUBE + +Planning requires `id`, `faces`, `solution`, and `locked_placements`. +`faces` is a list of six 5x5 binary arrays in piece order A–F. A 1 is solid and +a 0 is a gap. `solution` maps each piece to `[face_name, left_edge, top_edge]`; +face names are front/back/left/right/top/bottom, case insensitive. Edge numbers +refer to the original piece: 1 left, 2 top, 3 right, 4 bottom. Placements use the +same representation. Easy fixes four pieces (two missing); hard fixes two +(four missing). The full solution assembles a valid cube without conflicts. + +Perception requires `id`, `answer` (5x5 binary array), and `image_path`. +Rows run from Edge 2 to Edge 4; columns run from Edge 1 to Edge 3. All 50 canonical +answers are preserved. Images are rendered directly from the answers: +lavender cells, thickness 1, fixed elevation -135°, azimuth -120°, labeled edges, +6x6-inch figure at 100 DPI. This is one fixed isometric observation setting. +It changes the images from earlier releases; old scores are not directly comparable. + +## MAZE + +Planning requires `id`, `difficulty`, `target_piece`, `depth`, and `initial_state`. +`initial_manhattan` and `connected_path_len` are source metadata. Easy/hard have +source insertion depths 2/4. A state contains `players`, `targets`, `board_grid`, +`extra_tile`, and `objects`. Board arrays are row-major; player, target, object, +and movement coordinates are `(x, y)` = `(column, row)`, zero indexed. Object +coordinates in JSON are `{ "x": ..., "y": ... }`. + +Tiles use `shape` I/L/T and `rotation` 0–3 (clockwise quarter turns). I0/I2 are +vertical, I1/I3 horizontal. L0 opens up/right; T0 opens up/left/right. An insertion +uses `side` left/right/top/bottom, `index` 1/3/5, and an **absolute** extra-tile +`rotation`. Immediate reversal of the previous insertion is forbidden. Movement +follows connected corridors, with a one-position path denoting stay. + +The target is the object named by `target_piece`. The preserved canonical +`targets.P1` cache may be stale; evaluation resolves the named object. Canonical +records omit solutions. All 400 canonical puzzles were verified by replaying +reference trajectories. Generated records include valid `steps` and `final_state`. +Canonical depth labels are retained; shortest-depth searches were not repeated +during packaging. + +Perception requires `id`, `grid_tokens_str` (Python list-of-lists string), +`grid_size` (`7x7`), `gamestate`, `target_label`, and `image_path`. It contains +the original 50 board-parsing puzzles, renamed `board_0000`–`board_0049` in source +order. The renderer uses texture +opacity 0.2 and the frozen source state. Tile labels are checked against that +state, allowing I0=I2 and I1=I3. There are no subset, split, or render options. + +## BLOX + +Planning requires `id`, `difficulty`, `board`, `block`, `goal`, `target_depth`, +and `solution`. Easy/hard are 5x7 crumble boards with one elevator and source +solution lengths 10/16. `solution` is a list of actions: 0 up, 1 down, 2 left, +3 right. All 400 solutions replayed successfully during packaging. + +`board` contains `rows`, `cols`, a row-major integer `grid`, and `height_map`. +Tile codes are 0 void, 1 normal, 2 goal, 3 switch, 4 bridge, 5 fragile, 6 elevator, +7 crumble. Optional board fields describe switches, bridges, and elevators. +`block` has `r`, `c`, and `orientation`: 0 standing, 1 lying horizontally, +2 lying vertically. The anchor is the left/top occupied cell. `goal` has `r` +and `c`. Coordinates are zero-indexed `(row, column)`. Optional dynamic fields +are `active_bridges`, `current_height` (0 low / 1 high), and `collapsed_crumble`; +their defaults are empty, 0, and empty respectively. + +Perception contains 50 boards: 25 sampled without replacement from each of the +200-board easy and hard pools. Selection uses a separate `random.Random(42)` +stream: sample easy indices, then hard indices; retain source order within each +group and place easy before hard. Selected IDs, block states, and images are +preserved from the full source pool. +It shares board geometry with planning, so "held-out" here means a fixed +evaluation set, not disjoint board geometry. Each record contains a frozen state, +`id`, `source` (`difficulty`, `id`), `seed`, `rendering`, and `image_path`. +Planning solutions/depths are removed because blocks have been randomized. + +Block preparation uses one local `random.Random(42)` stream over the full source +pool (all easy, then all hard), including unselected boards. For each board, enumerate +row, column, then orientation 0/1/2; choose uniformly from placements whose cells +are in bounds, non-void, and at the block's height except elevator cells. This +matches the agreed placement rule and preserves the selected frozen blocks. Rendering +uses cell size 54, coordinates on, legend off, and the frozen bridges/height. +Void-cell heights in perception labels are normalized to zero. These placement +and legend changes intentionally differ from the old perception benchmark. diff --git a/DATA_GENERATION.md b/DATA_GENERATION.md new file mode 100644 index 0000000000000000000000000000000000000000..4a840f502375d04b3c90e9d4b48cf01e8e7fe289 --- /dev/null +++ b/DATA_GENERATION.md @@ -0,0 +1,77 @@ +# Planning data generation + +Run `generate.py` from the repository, or use its absolute path from another +working directory. It writes the same planning JSONL layout that the evaluators +read. Perception uses a fixed held-out dataset for each environment and has no +generation command. + +```bash +python generate.py --task cube --config easy --num_samples 10 --seed 42 --output_dir generated +python generate.py --task maze --config hard --num_samples 1 --seed 42 --output_dir generated +python generate.py --task blox --config easy --num_samples 10 --seed 500000 --output_dir generated +python generate.py --task blox --config hard --num_samples 10 --seed 600000 --output_dir generated +``` + +`--config` is required and selects `easy` or `hard`. `--seed` defaults to 42. +`--num_samples` defaults to 10 and must be positive. + +## Output + +Every command writes one split under the supplied output root: + +```text +generated/// + samples.jsonl + manifest.json +``` + +Planning records contain the environment state and a validated solution. +MAZE records include each insertion, the movement path, and states before and +after movement. Insertion rotations are absolute orientations 0–3, not turns +relative to the extra tile's previous orientation. + +The manifest records the recipe, requested count and seed, accepted sample seeds, +source-file hashes, and the JSONL checksum. + +The command refuses a nonempty output split. Other splits under the same root +can coexist. Interrupted or failed runs leave `.incomplete` and +`samples.jsonl.partial`; `samples.jsonl` appears only after generation succeeds. +Use a fresh output root to retry. There is no automatic append, overwrite, or +resume behavior. + +## Recipes + +| Task | Planning easy / hard | +| --- | --- | +| CUBE | Solved 5×5 faces; permuted, flipped, and rotated; 2 / 4 pieces left to place | +| MAZE | 7×7 strategic boards, one target, T/L/I anchor shapes, seeded starting position; shortest insertion depth 2 / 4 | +| BLOX | 5×7 connected boards, one required elevator, crumble mechanics; shortest solution length 10 / 16 | + +CUBE validates each constructed solution. MAZE searches forward with breadth-first +search and rejects boards with the wrong minimum depth; it replays every exported +solution. BLOX retains the benchmark's geometry, candidate ranking, crumble +selection, validation, and duplicate filtering. MAZE and BLOX examine seeds in +ascending order and skip rejected candidates. MAZE depth-four search can be +expensive; the command reports the candidate seed before searching it. + +These commands sample new puzzles from the documented recipes. They do not +recreate the exact previously released canonical records. In particular, the +current MAZE generator's one-target recipe differs from historical canonical +boards containing multiple objects. Retain the canonical files for benchmark +evaluation. + +The implementation lives in `src//generator/planning.py`. BLOX keeps its +level-construction helpers in `generator/levels.py`. Puzzle rules and validation +use the corresponding task's `env.py`. + +## Evaluate and test + +```bash +python eval.py --task cube --mode planning --config easy --data_root generated --model MODEL --max_samples 10 +python -m unittest discover -s tests -v +``` + +The tests run offline using generated temporary data. They check CLI errors, +output protection, interrupted exports, loader compatibility, and solution replay +through the environments. Install the dependencies in `requirements.txt`. +Generation makes no model calls. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..bef17df83b741f1bfa540f2e95c45b41fe0903ce --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 MARBLE Authors + +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/README.md b/README.md index 133e2a0d867d37eb0a7480e98325ec04f7165ade..a61ab7b0cbd54764c611596cce8522fb1decae28 100644 --- a/README.md +++ b/README.md @@ -1,198 +1,50 @@ ---- -language: -- en -license: cc-by-nc-4.0 -size_categories: -- 1K