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…