What it does
game.screwRelocate.create(level) makes a game of a level. The player picks a screw that is movable, in a hole and
not covered by a higher plank, and moves it to a free hole. Any plank whose hole lies over that hole is fastened there,
so a single move can let one plank go and catch another. Planks held by one screw swing round it and planks held by
none fall, on the real rigid-body physics of a plate-stack stack that belongs to the level.
The level is won when every plank has fallen, or the ones the level names in clear. It is lost when the moves run
out, or as stuck once everything has settled with no uncovered screw or no free hole left. The board's spare holes are
its parking places: the fewer there are, the harder the level. Stars come from the level's par.
A generator lays planks across a grid of holes in layers, with as many spare holes as you ask for, and a search proves
each level can be cleared and sets its par from the shortest solution it found. solve finds a solution for any level,
so a hint is one call away. The game reports moves, pivots, falls, the win with its moves and stars, and the loss, and
view() gives the plates, the screws and every hole with whether it is free, for your game to draw.
Features
- Screw moves —
movable(screw)andmove(screw, hole), with the planks each move now fastens. - Planks on real physics — held, swinging on one screw and falling on none, through
plate-stack. - Win and lose rules — drop every plank or the named ones; lose on a move limit, or when stuck.
- Parking — the number of spare holes sets the difficulty.
- Generated levels — a grid of holes, a number of planks, spare holes and a minimum number of moves, from a seed, each with a solution and a par.
- A solver —
solve(level)finds moves that clear it, best first, within a budget of states. - Stars, saves and restarts —
stars(),snapshot(),restore()andrestart(). - Validation —
validatelists a level's problems before it is played.
Good for
- Screw-moving puzzles in the style of Nuts and Bolts, with layered planks.
- Daily or endless puzzle modes — seeded levels that are always clearable.
- Difficulty ladders — fewer spare holes, more planks and more required moves as the levels climb.
- Hand-made puzzle levels — any board, planks and screws as a
plate-stackspec, with your own move limit and par.
Make it yours
A level is a plate-stack spec with three more fields: clear (the planks that must fall, all of them by default),
moves (a limit) and par (moves for three stars). generate takes a seed, cols and rows of holes (5 by 7),
their spacing (90), the number of plates (5), the parking spare holes (2), the minimum moves (3) and the
colours.
Two different uses: a gentle opening level generated with five planks, three spare holes and a minimum of three moves;
and a tight late level with more planks, a single spare hole, a higher minimum and a move limit, where only the planks
named in clear must fall.
A quick look
A generated level played by lifting a screw and dropping it in a free hole:
const play = game.screwRelocate.create(game.screwRelocate.generate({ seed: 2, plates: 6, parking: 2 }));
let held: string | null = null;
game.step('bolts', dt => {
const p = game.input.pointer;
if (p?.pressed) {
const v = play.view();
const screw = v.screws.find(s => s.hole && Math.hypot(s.x - p.x, s.y - p.y) < 24);
const hole = v.holes.find(h => h.free && Math.hypot(h.x - p.x, h.y - p.y) < 24);
if (screw && play.movable(screw.id)) held = screw.id; // lift it
else if (held && hole) { play.move(held, hole.id); held = null; }
}
play.step(dt);
});
Works with
plate-stack— the plates, screws and physics under every level.screw-sort— the screw-sorting game on the same plates, where screws go into colour boxes.pull-pin— another casual physics puzzle, of pins pulled to free what they hold.
Good to know
- The search works from where the planks start; the real planks swing as they lose screws, which can free a hole early or cover one for a moment.
paris the shortest solution the search found, which may not be the shortest there is.generatethrows when no level of those options needs that many moves; give fewer planks or a smaller minimum.- It draws nothing: the view gives the plates, screws and holes to draw.






