level-generation-and-solvers
Generates and proves levels - level plans, BFS/IDA* solvers and par, star rules, packs and unlocking, daily level boards, pack tables, level metrics. Use when adding levels, a solver, par, stars, packs or the daily level. Not for rules (game-rules-engine) or dates and streaks (daily-and-statistics).
- License 许可
- MIT
- 最近更新
- 2026-11-05
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- level-generation-and-solvers
- description
- Generates and proves levels - level plans, BFS/IDA* solvers and par, star rules, packs and unlocking, daily level boards, pack tables, level metrics. Use when adding levels, a solver, par, stars, packs or the daily level. Not for rules (game-rules-engine) or dates and streaks (daily-and-statistics).
02 资源文件 127
- 资产文件assets/shared.json849 B
- 脚本examples/line-siege/levels/line-siege-describe.test.ts785 B
- 脚本examples/line-siege/levels/line-siege-describe.ts1.5 KB
- 脚本examples/line-siege/levels/line-siege-level-plan.test.ts4.0 KB
- 脚本examples/line-siege/levels/line-siege-level-plan.ts2.5 KB
- 脚本examples/line-siege/levels/line-siege-levels.golden.test.ts1.6 KB
- 其他examples/line-siege/levels/line-siege-levels.golden.test.ts.snap.ios3.4 KB
- 脚本examples/line-siege/levels/line-siege-levels.test.ts2.2 KB
- 脚本examples/line-siege/levels/line-siege-levels.ts1.6 KB
- 脚本examples/line-siege/levels/line-siege-solver.test.ts2.3 KB
- 脚本examples/line-siege/levels/line-siege-solver.ts1.8 KB
- 参考文档examples/line-siege/levels/pack-1.json4.4 KB
- 参考文档examples/line-siege/levels/pack-2.json4.4 KB
- 参考文档examples/line-siege/levels/pack-3.json4.4 KB
- 其他examples/tap-flip-levels.golden.test.ts.snap.ios1.5 KB
- 参考文档references/generators-and-plans.md12.1 KB
- 参考文档references/goldens-and-quality.md8.6 KB
- 参考文档references/levels-model.md10.3 KB
- 参考文档references/solvers.md9.6 KB
- 脚本scripts/check-levels.mjs5.5 KB
- 脚本scripts/check-lib.mjs44.4 KB
- 脚本scripts/lib/app-modules.mjs3.3 KB
- 脚本scripts/lib/assemble-fixtures.mjs4.1 KB
- 脚本scripts/lib/level-checks.mjs23.1 KB
- 脚本scripts/lib/level-run.mjs6.8 KB
- 脚本scripts/lib/pack-format.mjs5.4 KB
- 脚本scripts/lib/ts-scan.mjs3.0 KB
- 脚本scripts/selftest.mjs3.3 KB
- 脚本templates/apps/__GAME_ID__/src/levels/__GAME_ID__-describe.test.ts396 B
- 脚本templates/apps/__GAME_ID__/src/levels/__GAME_ID__-describe.ts663 B
- 脚本templates/apps/__GAME_ID__/src/levels/__GAME_ID__-level-plan.test.ts1.6 KB
- 脚本templates/apps/__GAME_ID__/src/levels/__GAME_ID__-level-plan.ts1.9 KB
- 脚本templates/apps/__GAME_ID__/src/levels/__GAME_ID__-levels.golden.test.ts1.7 KB
- 脚本templates/apps/__GAME_ID__/src/levels/__GAME_ID__-levels.test.ts1.6 KB
- 脚本templates/apps/__GAME_ID__/src/levels/__GAME_ID__-levels.ts1.7 KB
- 脚本templates/apps/__GAME_ID__/src/levels/__GAME_ID__-solver.test.ts2.6 KB
- 脚本templates/apps/__GAME_ID__/src/levels/__GAME_ID__-solver.ts2.8 KB
- 脚本templates/packages/game-kit/src/dates/daily-seed.ts592 B
- 脚本templates/packages/game-kit/src/dates/date-key.test.ts3.3 KB
- 脚本templates/packages/game-kit/src/dates/date-key.ts2.3 KB
- 脚本templates/packages/game-kit/src/levels/daily-start.test.ts654 B
- 脚本templates/packages/game-kit/src/levels/daily-start.ts856 B
- 脚本templates/packages/game-kit/src/levels/level-plan.ts2.2 KB
- 脚本templates/packages/game-kit/src/levels/level-table.test.ts1.0 KB
- 脚本templates/packages/game-kit/src/levels/level-table.ts2.1 KB
- 脚本templates/packages/game-kit/src/levels/levels-contract.test.ts5.6 KB
- 脚本templates/packages/game-kit/src/levels/levels-contract.ts5.6 KB
- 脚本templates/packages/game-kit/src/levels/pack-progress.test.ts2.2 KB
- 脚本templates/packages/game-kit/src/levels/pack-progress.ts2.2 KB
- 脚本templates/packages/game-kit/src/levels/plan-level-table.test.ts4.1 KB
- 脚本templates/packages/game-kit/src/levels/plan-level-table.ts3.1 KB
- 脚本templates/packages/game-kit/src/levels/star-rating.test.ts1.6 KB
- 脚本templates/packages/game-kit/src/levels/star-rating.ts1.4 KB
- 脚本templates/packages/game-kit/src/levels/witness-solver.test.ts3.6 KB
- 脚本templates/packages/game-kit/src/levels/witness-solver.ts2.5 KB
- 脚本templates/packages/game-kit/src/solver/bfs-solve.test.ts1.5 KB
- 脚本templates/packages/game-kit/src/solver/bfs-solve.ts2.5 KB
- 脚本templates/packages/game-kit/src/solver/engine-solver.ts1.4 KB
- 脚本templates/packages/game-kit/src/solver/ida-star-solve.test.ts3.2 KB
- 脚本templates/packages/game-kit/src/solver/ida-star-solve.ts3.7 KB
- 脚本templates/packages/game-kit/src/solver/search-problem.ts1.5 KB
- 脚本templates/packages/game-kit/src/solver/verify-line.test.ts2.4 KB
- 脚本templates/packages/game-kit/src/solver/verify-line.ts1.4 KB
- 脚本templates/packages/game-kit/src/testing/render-cells.test.ts407 B
- 脚本templates/packages/game-kit/src/testing/render-cells.ts448 B
- 脚本templates/packages/tooling/src/levels/generate-levels.ts3.3 KB
- 参考文档tests/fixtures/check-levels-score/bad-pack-hand-edited/EXPECT.txt50 B
- 参考文档tests/fixtures/check-levels-score/bad-pack-hand-edited/mutation.json146 B
- 参考文档tests/fixtures/check-levels-score/bad-pack-unformatted/EXPECT.txt118 B
- 参考文档tests/fixtures/check-levels-score/bad-pack-unformatted/mutation.json69 B
- 参考文档tests/fixtures/check-levels-score/README.md484 B
- 参考文档tests/fixtures/check-levels-score/score.json308 B
- 参考文档tests/fixtures/check-levels/bad-config-mismatch/EXPECT.txt53 B
- 参考文档tests/fixtures/check-levels/bad-config-mismatch/mutation.json118 B
- 参考文档tests/fixtures/check-levels/bad-daily-golden-dates/EXPECT.txt15 B
- 参考文档tests/fixtures/check-levels/bad-daily-golden-dates/mutation.json137 B
- 参考文档tests/fixtures/check-levels/bad-daily-off/EXPECT.txt34 B
- 参考文档tests/fixtures/check-levels/bad-daily-off/mutation.json107 B
- 参考文档tests/fixtures/check-levels/bad-daily-salt-shared/EXPECT.txt112 B
- 参考文档tests/fixtures/check-levels/bad-daily-salt-shared/mutation.json345 B
- 参考文档tests/fixtures/check-levels/bad-daily-seed/EXPECT.txt48 B
- 参考文档tests/fixtures/check-levels/bad-daily-seed/mutation.json117 B
- 参考文档tests/fixtures/check-levels/bad-difficulty-drop/EXPECT.txt42 B
- 参考文档tests/fixtures/check-levels/bad-difficulty-drop/mutation.json130 B
- 参考文档tests/fixtures/check-levels/bad-duplicate-level/EXPECT.txt42 B
- 参考文档tests/fixtures/check-levels/bad-duplicate-level/mutation.json133 B
- 参考文档tests/fixtures/check-levels/bad-fast-check-missing/EXPECT.txt105 B
- 参考文档tests/fixtures/check-levels/bad-fast-check-missing/mutation.json150 B
- 参考文档tests/fixtures/check-levels/bad-impure-import/EXPECT.txt35 B
- 参考文档tests/fixtures/check-levels/bad-impure-import/mutation.json189 B
- 参考文档tests/fixtures/check-levels/bad-kit-missing/EXPECT.txt63 B
- 参考文档tests/fixtures/check-levels/bad-kit-missing/mutation.json62 B
- 参考文档tests/fixtures/check-levels/bad-math-random/EXPECT.txt74 B
- 参考文档tests/fixtures/check-levels/bad-math-random/mutation.json197 B
- 参考文档tests/fixtures/check-levels/bad-no-contract-test/EXPECT.txt23 B
- 参考文档tests/fixtures/check-levels/bad-no-contract-test/mutation.json67 B
- 参考文档tests/fixtures/check-levels/bad-no-snapshot/EXPECT.txt82 B
- 参考文档tests/fixtures/check-levels/bad-no-snapshot/mutation.json83 B
- 参考文档tests/fixtures/check-levels/bad-null-solver/EXPECT.txt18 B
- 参考文档tests/fixtures/check-levels/bad-null-solver/mutation.json136 B
- 参考文档tests/fixtures/check-levels/bad-pack-edited/EXPECT.txt50 B
- 参考文档tests/fixtures/check-levels/bad-pack-edited/mutation.json130 B
- 参考文档tests/fixtures/check-levels/bad-pack-gap/EXPECT.txt44 B
- 参考文档tests/fixtures/check-levels/bad-pack-gap/mutation.json119 B
- 参考文档tests/fixtures/check-levels/bad-plan-failure/EXPECT.txt37 B
- 参考文档tests/fixtures/check-levels/bad-plan-failure/mutation.json128 B
- 参考文档tests/fixtures/check-levels/bad-relative-escape/EXPECT.txt105 B
- 参考文档tests/fixtures/check-levels/bad-relative-escape/mutation.json289 B
- 参考文档tests/fixtures/check-levels/bad-star-slack/EXPECT.txt73 B
- 参考文档tests/fixtures/check-levels/bad-star-slack/mutation.json181 B
- 参考文档tests/fixtures/check-levels/bad-testing-import/EXPECT.txt126 B
- 参考文档tests/fixtures/check-levels/bad-testing-import/mutation.json239 B
- 参考文档tests/fixtures/check-levels/bad-thresholds-descending/EXPECT.txt115 B
- 参考文档tests/fixtures/check-levels/bad-thresholds-descending/mutation.json233 B
- 参考文档tests/fixtures/check-levels/bad-trivial-level/EXPECT.txt42 B
- 参考文档tests/fixtures/check-levels/bad-trivial-level/mutation.json112 B
- 脚本tests/fixtures/check-levels/base/apps/tap-flip/game.config.ts229 B
- 脚本tests/fixtures/check-levels/base/apps/tap-flip/src/rules/apply-move.ts1.3 KB
- 脚本tests/fixtures/check-levels/base/apps/tap-flip/src/rules/create.ts1.6 KB
- 脚本tests/fixtures/check-levels/base/apps/tap-flip/src/rules/flip-cells.ts915 B
- 脚本tests/fixtures/check-levels/base/apps/tap-flip/src/rules/list-moves.ts567 B
- 脚本tests/fixtures/check-levels/base/apps/tap-flip/src/rules/outcome.ts711 B
- 脚本tests/fixtures/check-levels/base/apps/tap-flip/src/rules/tap-flip-tuning.ts2.6 KB
- 脚本tests/fixtures/check-levels/base/apps/tap-flip/src/rules/tap-flip-types.ts1.2 KB
- 脚本tests/fixtures/check-levels/base/packages/game-kit/src/contract/difficulty.ts1.6 KB
- 脚本tests/fixtures/check-levels/base/packages/game-kit/src/rng/sfc32.ts2.8 KB
- 参考文档tests/fixtures/check-levels/README.md880 B
03 SKILL.md 正文
Level generation and solvers
Gives every Pocket Arcade game a shipped level table that is generated from seeds, proven winnable (by an exact solver at a recorded par, or, for score games that draw their future at random, by a witness bot), laid out in packs that unlock by stars, pinned by data goldens, and a daily level that is the same on every phone. A script regenerates the table from the game's plan and fails on any difference in values or bytes, a bad curve, an import outside the levels zone or a missing golden.
Rules that must hold
- Levels are generated, never drawn: a level is
{ level, seed, difficulty, stars }and the board iscreate(seed, difficulty), with level and daily difficulties on 0..99 (100 is the endless run). Why: spec 8.1 (same seed, same level); tables stay tiny and saves replay exactly. pack-<n>.jsonfiles are written only bypackages/tooling/src/levels/generate-levels.tsfrom the game'sLevelPlan, formatted by the repo's Prettier, and the committed bytes equal what the plan generates. Never copy a pack from a template or an example: the pilot copies the Line Siege example'slevels/code without itspack-*.jsonfiles, then generates the packs withnode --disable-warning=MODULE_TYPELESS_PACKAGE_JSON packages/tooling/src/levels/generate-levels.ts --app line-siege(the output is byte-identical to the example's packs). Why: a hand-edited or copied table drifts from the generator; the checker regenerates and compares values and bytes.- Every shipped level is proven winnable and its proof line is replayed through the real engine (
verifyLine): par games by the exact solver at the recorded par; score games that draw during play (Line Siege) by the witness solver, the game's greedy bot from a fixed bot seed. Why: spec 8.1 and 15 item 7, "no level is impossible"; a solver is never trusted on its own. - Stars follow spec 8.1 through
starsFor: par games 3 at or under par, 2 up to par + 2, 1 for finishing; score games[win, two, three], wherethresholds[0]is the lowest score a win can have (0 when the win is not score-based) and a witness game's two stars sit at the witness score. Why: the result screen and the Levels grid show these stars to every player; one formula everywhere. - The difficulty curve never falls, later packs are never easier, and no level after the third is a one-mover (a witness game rejects levels its witness wins in fewer than its minimum, Line Siege 8). Why: players expect the game to rise; the owner approves the bands,
rate()enforces them. - The daily seed contract never changes:
dailySeed('2026-09-26', 17) = 2599028541,dailySeed('2026-09-27', 17) = 2582250922; each game's salt, daily difficulty and the daily boards of pinned dates stay fixed once shipped. Why: spec 8.3, every player gets the same daily level with no server. - Data goldens pin the level table and at least three daily dates, with committed snapshots; they change only with
-uon one file and aGate-Change:trailer. Why: a silent generator or tuning change would give players different boards under the same level numbers. - Packs match
game.config.ts(packCount,levelsPerPack), open with 0 stars and unlock by half the earlier stars (0, 45, 90 by default);levels.endlessis{ kind: 'endless', difficulty: ENDLESS_DIFFICULTY }exactly whenmodes.endlessis true. Why: spec S8, no player stuck on one level; the config and the table can never disagree. - Level code imports only
@e07/game-kit/**,@e07/<id>/rules/**and@e07/<id>/levels/**, and follows the rules' determinism policy (noMath.random, clocks,**or transcendentalMath). A witness's evaluation lives inrules/<id>-evaluate.ts, never intesting/. Why: tooling, tests and phones must generate bit-identical levels, and check-boundaries enforces the same zone.
Workflow
- Settle the tuning first, then read references/levels-model.md (types, the curve and the tuning rows, packs, stars, daily, endless). The game's balance sims (game-balance-and-bots) must pass before the packs are generated, because every level is
create(seed, difficulty)on the current tuning; a tuning change after the packs exist regenerates them (step 5) and their goldens, committed with aGate-Change:trailer. Get the owner's bands from the design notes: packs and levels per pack, minimum par per pack, star rule (par or score), daily difficulty; defaults are 3 x 30, minimum par 2/3/4, par stars, a daily difficulty of 40 to 50. - Install the level kit once per repo. First make sure fast-check is installed, because the kit's tests and the solver template import it and the bootstrap leaves it out (without it
tscandeslintfail with TS2307): when the rootdevDependenciesdo not pin it yet, runnpm install -D -E fast-check@4.10.2at the repo root, thennpm approve-scripts --allow-scripts-pendingand, if it listsfsevents(the macOS file watcher of jest-haste-map),npm approve-scripts fsevents. Then runnode ${CLAUDE_SKILL_DIR}/scripts/check-levels.mjs .; for eachkit-file-missingcopytemplates/packages/<path>topackages/<path>with its test (solver, levels withwitness-solver.ts,testing/render-cells.ts,tooling/src/levels/generate-levels.ts).dates/date-key.tsanddates/daily-seed.tsare shared with the daily-and-statistics skill: copy them only when missing. The game's rules (withcontract/difficulty.ts) must exist first (game-rules-engine). - Write the solver test-first. Read references/solvers.md. A game whose whole future is fixed by
creategets an exact search: copytemplates/apps/__GAME_ID__/src/levels/__GAME_ID__-solver.tsand its test toapps/<game-id>/src/levels/(replace__GAME_ID__,__GAME_PASCAL__,__GAME_CONST__), choose the search state, move order and key, BFS or IDA*, and prove it with examples, theverifyLineproperty and a budget test. A game that draws during play usescreateWitnessSolverwith its greedy bot onrules/<id>-evaluate.tsand a fixed bot seed: imitate examples/line-siege/levels/line-siege-solver.ts and its test. - Write the level plan test-first. Read references/generators-and-plans.md. Copy
__GAME_ID__-level-plan.tsand its test: packs, curve (difficultyForfrom 0 at level 1 to its cap, 99 unless the solver can only prove easier levels), budget, andrate({ start, par, line, final })with the owner's bands (a witness game: examples/line-siege/levels/line-siege-level-plan.ts, score thresholds fromfinal.score). - Generate the tables (copy the generator and the plan, never packs):
node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON packages/tooling/src/levels/generate-levels.ts --app <game-id>writespack-<n>.jsonthrough the repo's Prettier; fix anylevel N: no candidateby loosening the band or the curve there, then rerun until 0 failures. Thennode --disable-warning=MODULE_TYPELESS_PACKAGE_JSON packages/tooling/src/levels/generate-levels.ts --app <game-id> --checkandnpx prettier --check apps/<game-id>/src/levelsboth exit 0. Commit exactly what it wrote. - Assemble and prove the table. Copy
__GAME_ID__-levels.ts(theLevelsSpec: plan, packs,toLevelEntries, solver, daily salt and difficulty, endless; replace the template's salt0x5446with the game's own) and__GAME_ID__-levels.test.ts(runslevelsContractProblems); makegame.config.tslevelsandmodesagree, and setendless: { kind: 'endless', difficulty: ENDLESS_DIFFICULTY }only whenmodes.endlessis true. If the game has hints, wirehints: { kind: 'solver', suggest }in the rules (never for a witness); that makes the game facthasHintstrue, so the Game screen (S5) shows its Hint key (lead decision L8;hints: { kind: 'none' }, as in Line Siege, shows none). - Pin the goldens. Read references/goldens-and-quality.md. Copy
__GAME_ID__-describe.ts(with its test) and writedescribeLevel(state)for the game: the template's grid renderer suits a grid game; a game with lanes, pieces or a tray renders those too (examples/line-siege/levels/line-siege-describe.ts). Copy__GAME_ID__-levels.golden.test.ts, runnpx jest apps/<game-id>/src/levels/<game-id>-levels.golden.test.ts --selectProjects golden -uonce, open the.snap.iosand read the boards (compare with examples/tap-flip-levels.golden.test.ts.snap.ios), thennpx jest apps/<game-id>/src/levels --ci --selectProjects goldenpasses. - Format, lint, type-check, test:
npx eslint --fix apps/<game-id>/src/levels,npx prettier --write apps/<game-id>/src/levels/*.ts,npx tsc --noEmit -p apps/<game-id>,npx tsc --noEmit -p packages/tooling, thennpx jest apps/<game-id>/src/levels packages/game-kit/src/levels packages/game-kit/src/solver --ci --selectProjects unit --coverage --collectCoverageFrom='apps/<game-id>/src/levels/**/*.ts' --collectCoverageFrom='packages/game-kit/src/levels/**/*.ts' --collectCoverageFrom='packages/game-kit/src/solver/**/*.ts' --coverageThreshold='{}'and read the table (95/95/95/90 for game-kit; paths first,--selectProjectsreads every later word as a project name; onlynpm run test:coveragejudges the thresholds), thennpx jest apps/<game-id>/src/levels --ci --selectProjects golden. - Run the check
node ${CLAUDE_SKILL_DIR}/scripts/check-levels.mjs . --game <game-id> --report; fix everyFAILline (each names the file, the rule and the fix) and rerun until it printsRESULT: PASS. Put the--reportpack lines in the owner report and commit tables and goldens with aGate-Change:trailer.
Definition of done
- [ ] The game's balance sims passed before the packs were generated (or the packs were regenerated after the last tuning change).
- [ ] The root
package.jsonpinsfast-checkexactly indevDependencies(nokit-test-dependencyline);packages/game-kit/src/solver/,levels/(withwitness-solver.ts),testing/render-cells.tsanddates/are installed with their tests;packages/tooling/src/levels/generate-levels.tsexists. - [ ]
apps/<game-id>/src/levels/has the solver, the level plan,describeLevel, theLevelsSpec, one generatedpack-<n>.jsonper pack, and their tests;generate-levels.ts --app <game-id> --checkandnpx prettier --check apps/<game-id>/src/levelsexit 0. - [ ]
<game-id>-levels.test.tsrunslevelsContractProblemswith the solver and returns[](every level proven by a replayed line, at its par for par levels; packs matchinggame.config.ts; endless at difficulty 100 exactly whenmodes.endlessis on). - [ ] The golden test pins the pack boundary levels and three daily dates, and its
.snap.ioswas read and committed with aGate-Change:trailer. - [ ]
npx tsc --noEmit,npx eslint --max-warnings 0,npx prettier --checkandnpx jest <paths> --ci --selectProjects unitand--selectProjects goldenpass for the touched workspaces. - [ ]
node ${CLAUDE_SKILL_DIR}/scripts/check-levels.mjs . --game <game-id>printsRESULT: PASS
Anti-patterns
- Editing a pack file to "fix" one level. The next regeneration undoes it and the checker fails
pack-stale; change the plan orcreateand regenerate. - Raising a test's node budget until a level passes. A level the solver cannot prove within the plan's budget should never have been accepted; regenerate or improve the solver's key and move order.
- Treating
budget-exceededas unsolvable (or the reverse). Onlyunsolvablemeans the whole space was searched. - A heuristic that overestimates "to be faster". IDA* then returns a longer line than par and players can beat par; keep it admissible, or use 0.
- Changing a game's daily salt, the daily difficulty or
dailySeed. Every player's daily level changes between versions; ask the owner first. jest -uover a whole folder or in a script. Goldens change one file at a time, after reading the new boards.- Using
Math.randomor the clock to pick candidate seeds. Tables must regenerate identically everywhere; seeds come fromcandidateSeed(gameId, level, attempt). - Rating stars in the Shell with ad-hoc numbers. Stars come from the table's
StarRulethroughstarsFor. - Copying
pack-*.jsonfrom an example, or formatting packs by hand or adding them to.prettierignore. Their seeds belong to another plan, andprettier --checkandgenerate-levels --checkthen disagree; copy the plan and the generator and run it. solver: nullor bot sims instead of a proof for a score game. A game that draws at random proves each level withcreateWitnessSolver; a lost witness isbudget-exceeded, a retry with the next candidate seed, neverunsolvable.- Importing the bot from
testing/into a level file. It breaks the levels import zone (pure-import, and check-boundaries'rules-pure); keep the evaluation inrules/<id>-evaluate.ts. - Generating the packs before the tuning is settled. Every later tuning change regenerates the packs and their goldens; run the balance sims first.
Files in this skill
| File | What it is | Read/run when |
|---|---|---|
| references/levels-model.md | Spec rules for levels, the types, the difficulty scale (curve, tuning rows, daily, endless), packs and unlocking, stars, daily, endless, who uses what | Workflow step 1 |
| references/solvers.md | Search kit, custom problems and keys, BFS or IDA*, heuristics, budgets, the witness solver, verifyLine, hints, solver tests |
Step 3 |
| references/generators-and-plans.md | The pipeline, tuning first, generator strategies, curve, LevelPlan, candidate seeds, rate(), score games with a witness, running the generator (Prettier bytes), changing tables |
Steps 1, 4 and 5 |
| references/goldens-and-quality.md | Data goldens and describeLevel, -u policy, the daily contract, the levels contract test, every quality rule |
Steps 6, 7 and 9 |
templates/packages/game-kit/src/solver/ |
search-problem, bfs-solve, ida-star-solve, engine-solver, verify-line, with tests |
Step 2 |
templates/packages/game-kit/src/levels/ |
level-table, levels-contract (replays every proof line), pack-progress, star-rating, daily-start, level-plan (rate sees start, par, line, final), plan-level-table, witness-solver (createWitnessSolver), with tests |
Step 2 |
templates/packages/game-kit/src/testing/ |
render-cells.ts (ASCII boards for goldens) with its test |
Step 2 |
templates/packages/game-kit/src/dates/ |
date-key.ts (+ test) and daily-seed.ts: shared with daily-and-statistics, copy only when missing |
Step 2 |
templates/packages/tooling/src/levels/ |
generate-levels.ts: writes pack-<n>.json from the plan through the repo's Prettier, or with --check compares the bytes |
Steps 2 and 5 |
templates/apps/__GAME_ID__/src/levels/ |
The template game (Tap Flip): exact solver, level plan, describeLevel (grid renderer), LevelsSpec, unit, contract and golden tests. No packs: step 5 generates them |
Steps 3 to 7 |
examples/line-siege/levels/ |
Line Siege v1, a score game that draws at random: the witness solver (WITNESS_BOT_SEED, 60,000 nodes), the plan with score thresholds and the 8-placement minimum, describeLevel for lanes, board and tray, the LevelsSpec with the daily (salt 0xe8c0, difficulty 45) and endless (100), the 90 generated levels in Prettier's bytes, and the tests and golden snapshot |
Steps 3 to 7, for a game that draws during play |
| examples/tap-flip-levels.golden.test.ts.snap.ios | What a committed level golden snapshot looks like (the template game) | Step 7 |
scripts/check-levels.mjs |
Checker: kit (with the exact fast-check pin its tests need), daily seed goldens and the spec 8.1 star rule (run for real), pack tables, curve and quality metrics, modes, goldens, contract test, the levels import zone, regeneration from the plan compared by value (pack-stale) and by byte (pack-format) |
Steps 2 and 9, and at the end |
scripts/lib/ |
level-checks.mjs, level-run.mjs, pack-format.mjs (the repo's Prettier, or Prettier's JSON style when it is not installed), app-modules.mjs (loads the repo's TypeScript), ts-scan.mjs, assemble-fixtures.mjs |
When changing the checker |
scripts/selftest.mjs |
Proves the checker: the templates installed as a game (packs generated) must pass and 21 planted bugs must fail; the same game made score-rated must pass and 2 planted pack bugs must fail | After changing the checker or a template |
scripts/check-lib.mjs |
Shared script helper, synced from the library (do not edit here) | Never by hand |
assets/shared.json |
Declares the shared files this skill copies in | When adding a shared file |
tests/fixtures/ |
check-levels/base/ (rules, RNG, difficulty and config the good repo needs), check-levels/bad-*/ and check-levels-score/ (score.json, bad-*/), one mutation.json and EXPECT.txt each, READMEs |
When adding a rule to the checker |
Related skills
game-rules-engine-create,listMoves,applyMove,outcomeand the sfc32 RNG the levels are built on.game-host-integration- starting level, daily and endless runs, stars at run end and "Next level".daily-and-statistics- the daily model, streaks and the calendar on top ofdailySeed.game-balance-and-bots- the tuning and bot sims that must pass before the packs are generated, and the greedy bot a witness plays.golden-tests- the golden project,-upolicy and gated paths in general.toybox-screens- the S8 Levels grid and S7 Result screen that show packs and stars.new-game-scaffold-game.config.tslevelsandmodesfor a new app.
04 同仓库更多 Skills
unit-and-component-tests
Sets up Jest and writes Pocket Arcade test code - three projects, RNTL 14 async via renderWithShell, root SDK mocks, fakes, fast-check, coverage, Stryker. Use when a test needs the Shell wrapper, a mock or a fake, or Jest fails. Not for the red-green loop (tdd-workflow) or goldens (golden-tests).
typescript-and-lint-rules
Enforces Pocket Arcade's strict TypeScript 6 tsconfigs, ESLint 9 flat config, Prettier and size limits. Use when writing or splitting .ts/.tsx or fixing a tsc or lint error. Not for gate wiring (quality-gates), names (naming-conventions) or import zones (architecture-and-boundaries).
demo-skill
Builds a demo. Use when testing the pitfall checker.
demo-skill
Builds a demo. Use when testing the pitfall checker.
troubleshooting-playbook
Diagnoses and fixes Pocket Arcade failures with a catalogue of 300+ known ones (symptom, cause, fix). Use when something errors, crashes, hangs or renders wrong, or an error or log needs explaining. Not for gate setup (quality-gates) or running builds (ios-simulator-build, ios-release-testflight).
toybox-visual-parity
Proves a built Pocket Arcade screen matches its Toybox design screenshot (light/dark, en/fa) and drives the fixes: capture, element gates, sheets, sign-off. Use when any screen is built or changed, or for visual parity, design match, screenshot compare. Not for building screens (toybox-screens).