Skip to content

77 game-dev skills for AI coding agents — Godot, Unity, Unreal, Phaser, PixiJS, three.js, Bevy, pygame, LÖVE, Roblox. Portable SKILL.md Agent Skills (the format Anthropic launched as Claude Skills), with a router that loads the right skill for your engine and task. Runs in Claude Code, Cursor, Kiro, Codex, Copilot, Gemini CLI and more.

fix(puzzle): include RNG state in undo snapshots, add sliding-puzzle parity rule and match-free reshuffle

Kiro Crew6c50156558ed
diff --git a/skills/genres/puzzle/SKILL.md b/skills/genres/puzzle/SKILL.md
index 83c9235..034c395 100644
--- a/skills/genres/puzzle/SKILL.md
+++ b/skills/genres/puzzle/SKILL.md
@@ -96,14 +96,14 @@ def resolve(board):
### 3. Undo via state snapshot or command
```python
-# Pseudocode. Snapshot before each move; undo restores it exactly (board + score + counters).
+# Pseudocode. Snapshot before each move; undo restores it exactly (board + score + counters + RNG).
def make_move(move):
- history.append(snapshot(board, score, moves_left)) # push BEFORE applying
+ history.append(snapshot(board, score, moves_left, rng.state)) # push BEFORE applying
apply(move); resolve(board); moves_left -= 1
def undo():
if history:
- board, score, moves_left = history.pop() # exact revert, including resolution
+ board, score, moves_left, rng.state = history.pop() # exact revert, including refills
```
For large boards prefer the **command** pattern (store the move + enough to invert it) over full
@@ -116,10 +116,12 @@ snapshots to save memory; snapshots are simplest and fine for small boards.
- **Resolving only once** → cascades/chains are missed. Loop resolution until the board is stable
(Pattern 2).
- **Undo that doesn't restore everything** → score/move-count/random-state drift. Snapshot *all*
- state, or make the move fully invertible.
+ state, or make the move fully invertible. If undo skips the RNG state, redoing the same move
+ refills different pieces and players learn to "reroll" by undoing.
- **Unseeded refill RNG** → can't reproduce a level / no deterministic undo or daily puzzle. Seed it.
- **Generated boards that aren't solvable** → unfair dead ends. Generate-and-verify, or generate
- from a known solution backward (refs).
+ from a known solution backward (refs). A sliding-tile puzzle filled by a random shuffle is
+ unsolvable half the time; check the parity rule in refs §7.
- **No deadlock detection** (match-3) → board with no valid moves softlocks. Detect "no moves"
and shuffle or end the level (refs).
- **Difficulty spikes** → too many mechanics at once. Teach one mechanic per level before combining.
diff --git a/skills/genres/puzzle/references/board-and-resolution.md b/skills/genres/puzzle/references/board-and-resolution.md
index 8d0d9a8..b422ca5 100644
--- a/skills/genres/puzzle/references/board-and-resolution.md
+++ b/skills/genres/puzzle/references/board-and-resolution.md
@@ -47,8 +47,9 @@ def has_valid_move(board):
swap(board, (y, x), (y+dy, x+dx)) # swap back
if ok: return True
return False
-# If not has_valid_move(board): reshuffle existing pieces (keep counts) until a move exists,
-# or end the level, depending on your rules.
+# If not has_valid_move(board): reshuffle existing pieces (keep counts) until a move exists
+# AND find_matches(board) is empty (a reshuffle must not hand out free matches), or end the
+# level, depending on your rules. Cap the attempts and fall back to a fresh board.
```
## 3. Cascade scoring
@@ -110,7 +111,14 @@ Generated levels must be solvable, or players hit unfair dead ends:
push/slide puzzles; move-existence for match-3); keep it only if solvable within the move/time
budget. Use a seed so a level is reproducible.
- **Reverse generation:** start from a solved board and apply random *legal inverse* moves; the
- scrambled result is guaranteed solvable by reversing them. Great for sliding/sokoban puzzles.
+ scrambled result is guaranteed solvable by reversing them. Great for sliding/sokoban puzzles
+ (for sokoban the inverse move is a *pull*: the player steps back and drags the block).
+- **Sliding-tile parity:** placing the tiles of an N×M sliding puzzle in a random order gives an
+ unsolvable board exactly half the time. With the blank's goal in the bottom-right corner, count
+ *inversions* (pairs of numbered tiles in the wrong order, reading row by row, ignoring the
+ blank). Odd width: solvable iff inversions are even. Even width: solvable iff inversions plus
+ the blank's row counted from the bottom (1 = bottom row) is odd. If a shuffle fails, swap any
+ two numbered tiles to flip the parity.
- Tag each level with its seed and intended difficulty so progression curves are tunable and a
bad level can be reproduced and fixed.