Tool/solver to resolve the Lights Out levels, a puzzle game based on a change of state/color of the cells of a grid (and its neighbours).
Lights Out Solver - dCode
Tag(s) : Mobile Games
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
Lights Out is an electronic game composed of a grid of lighted (sometimes with bulbs) or numbered cells (originally 5 by 5).
At the start of the game, a pattern of cells is lit (different states). By pressing one of the boxes, it switches state (it goes from on to off, or from off to on or changes color), as well as the four adjacent boxes (neighboring top, right, bottom and left).
The goal of the game is to switch all the lights to the off (or on) position, preferably by pressing as few boxes as possible.
The player must think about which squares to press to turn off all the lights.
Example: A game board with 2 states: 0 or 1 is in the initial position:
0 | 0 | 0 |
0 | 0 | 0 |
0 | 0 | 0 |
A click on the middle box gives the following result:
0 | 1 | 0 |
1 | 1 | 1 |
0 | 1 | 0 |
(the box clicked as well as the 4 adjacent cells (top, bottom, right, left) have changed state)
For a game with $ n $ states, pressing a box $ n $ times returns it to its initial state.
The principle of resolution is mathematical, by modeling the grid by a matrix $ [a_i] $ of size $ n \times m $ and $ p \geq 2 $ possible states.
By pressing a box, some other cells have their state changed or reversed (if $ p = 2 $)
The next state is then determined, for each box $ i $, by the number of times the boxes are pressed (modulo $ p $)
This state can be represented with $ m $ calculations $ a_{i1} x_1 + ... + a_{in} x_n) \mod p = 0 $ for which the value of $ x_i $ is the solution sought.
dCode retains ownership of the "Lights Out Solver" source code. Except explicit open source licence (indicated Creative Commons / free), the "Lights Out Solver" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, translator), or the "Lights Out Solver" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, or API access for "Lights Out Solver" are not public, same for offline use on PC, tablet, iPhone or Android !
The copy-paste of the page "Lights Out Solver" or any of its results, is allowed as long as you cite the online source
Reminder : dCode is free to use.