Logic and physics puzzle games (Sokoban-likes, match-3, sliding and tile puzzles, nonograms, physics puzzles, programming puzzles). Rules as pure functions with undo and restart, level data and validation with a solver, difficulty curves built from mechanics introductions, hint systems, level select and star ratings, generating levels procedurally with guaranteed solutions, juicy feedback for m...
Download skill (.zip) Files on GitHubPuzzle game development
Core: clear rules, interesting consequences, the “aha!” moment.
Starter template
A playable starter for the game-scaffolding template is in assets/starter/. Box pushing with pure rules (move(state)), undo and restart, five levels in ASCII, star ratings against par, saved progress, smooth tweens, and an exported solve() (breadth-first) to prove levels are solvable and set par.
python3 <game-scaffolding>/scripts/scaffold.py my-game --title "My Game" --starter <this skill>/assets/starter
Controls: Arrows/WASD, Z undo, R restart, N next. Touch: swipe, or tap beside the player. Esc pauses. All numbers to tune are in src/config.js; the gameplay is in src/scenes/play.js.
Every level is solved in tests, with par set to the best solution; swipe, undo and saving were checked.
Architecture
- Rules are pure:
next = move(state, dir)returns a new state (or null if the move is invalid). Undo = a stack of states; restart = the initial state. This makes solvers, hints and tests easy. - Levels as data (ASCII is perfect: tilemap-development
fromAscii), loaded by index; progress saved. - Presentation animates the difference between states (tweens from game-feel-engineering).
// Sokoban-style move: # wall, . floor, $ box, @ player, * goal
function move(s, dx, dy) {
const nx = s.px + dx, ny = s.py + dy, bx = nx + dx, by = ny + dy;
if (s.wall(nx, ny)) return null;
const box = s.boxes.findIndex((b) => b.x === nx && b.y === ny);
if (box >= 0) { if (s.wall(bx, by) || s.boxes.some((b) => b.x === bx && b.y === by)) return null;
const boxes = s.boxes.map((b, i) => (i === box ? { x: bx, y: by } : b)); return { ...s, px: nx, py: ny, boxes, moves: s.moves + 1 }; }
return { ...s, px: nx, py: ny, moves: s.moves + 1 };
}
Level design
- Introduce one mechanic per few levels, alone, then combine (teach → test → twist).
- A solver (BFS / A* over states, fine for small puzzles) in tests: every level solvable, record the optimal move count for star ratings, and flag levels that are trivially easy.
- Early levels solvable in seconds; first “aha” level by level 3–5.
- Procedural puzzles: generate by working backwards from a solved state, or generate + solve + keep only solvable ones with a target difficulty (solution length, branching).
Player support
Unlimited undo and instant restart, optional hints (show the next move from the solver, or reveal a step), skip a level after a few attempts, and no time pressure unless that’s the point.
Controls
Grid puzzles: arrows/WASD, swipe (30 px threshold) or tap adjacent tiles; match-3: drag or tap-tap swap. Big tiles on phones.
Pitfalls
Unsolvable levels (solver in tests), unclear rules (show, don’t tell), punishing mistakes without undo, difficulty spikes, and input that misreads swipes as taps.