Menu

Solving Lights-Out Over GF(2): Computing Exact Minimum Par Clicks Across 500 Glass Boards
📰

Solving Lights-Out Over GF(2): Computing Exact Minimum Par Clicks Across 500 Glass Boards

DEV Community: javascript·Jeon Pilgoo·about 2 hours ago
#5xoOTNA0
#devtojavascript#devto#dev#board#lights
Long article (468 words) — no AI summary yet.
Reading 0:00
15s threshold

Lights-Out looks deceptively simple: tap a tile, and it flips itself along with its orthogonal neighbors. Turn all the tiles on (or off) to clear the board.

But if you build a 500-stage Lights-Out game with custom board shapes, locked tiles , and diagonal toggle tiles — like Glass Lights on 2Day Games — two hard questions immediately show up:

How do you guarantee a board is actually solvable?

How do you show the player the exact mathematical minimum number of clicks ( Par ) ?

The answer is one of the cleanest applications of linear algebra in game development: Gaussian elimination over GF(2) .

Modeling the Board as a System of Linear Equations

Every tile press is its own inverse — pressing a tile twice is identical to not pressing it at all ( 1 + 1 = 0 mod 2 ), and the order of presses does not matter.

That means an N×N board with M active (unlocked) tiles is simply a linear system over the binary field GF(2) :

$$A \cdot x = b \pmod 2$$

A is an M×M binary toggle matrix where A[i][j] = 1 if pressing…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.