Press a square and its neighbours flip — can you turn them all off?
← Back to Fun TimeThis game is split into small library files inside funtime/lib/, and every function has a comment saying exactly what goes in, what comes out, and the algorithm in plain English. Empty any function out, read its comment, and write it yourself.
| File | What it does | Good functions to try re-writing |
|---|---|---|
| lib/lights-rules.js | The rules: the cross, the flips, the win | lightIndex, neighbours, pressLight, createPuzzle |
| lib/lights-draw.js | Painting the lights and the cursor | drawLight, squareAtPixel, renderGame |
| lib/lights-main.js | The glue: clicks, keyboard, the scoreboard | doAction, connectBoard, updateScoreboard |
💡 The big idea: the puzzle is built by pressing random squares on a solved board. Because every press undoes itself, a puzzle made that way can always be solved — a lovely example of making a problem impossible to get wrong.
🛠️ Want to be walked through it? Build Lights Out Yourself takes you through the key functions one step at a time and tests each one you write. There is a Python version too.