Search for a tool
Lights Out Solver

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).

Results

Lights Out Solver -

Tag(s) : Mobile Games

Share
dCode and more

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!

Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!

Feedback and suggestions are welcome so that dCode offers the best 'Lights Out Solver' tool for free! Thank you!

Lights Out Solver

Lights Out Grid Solver

0 (or empty) = Off or 1st state/color, 1 = On or 2nd state/color, 2 = 3rd state/color etc.

What is the Lights Out game? (Definition)

Lights Out (or Flip Tiles game) is an electronic game composed of a grid of lighted (sometimes with bulbs) or numbered cells (originally 5x5) which consists of turning off all the lights in a grid.

At the start of the game, a pattern of cells is lit (different states). By pressing one of the boxes, it acts like a switch, it changes state (it goes from on to off, or flips 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.

How to play Lights Out?

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.

Are there different variants of Lights Out?

There are several variations and options in Lights Out:

— Grid size: different grid formats are possible, ranging from 3x3, 4x4, 5x5, 6x6 to larger or even rectangular sizes.

— Random or set start state: lights can start in various configurations.

— Limited actions: the number of state changes allowed can be restricted to increase the difficulty.

— Timed game: A countdown can add an extra challenge to complete the game within a time limit.

— Obstacles: some variants introduce black boxes that cannot be changed state.

What is the optimal strategy for Lights Out?

An effective strategy is to observe the patterns and symmetries in the grid, if there are any, then carry out symmetrical actions: bulb on the right then bulb on the left etc.

The optimal strategy, however, is to perform linear algebra mathematical calculations that allow all the grids to be mathematically resolved.

How to solve a Lights Outs grid?

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.

Source code

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, breaker, 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, mobile, tablet, iPhone or Android app!
Reminder : dCode is free to use.

Cite dCode

The copy-paste of the page "Lights Out Solver" or any of its results, is allowed (even for commercial purposes) as long as you credit dCode!
Exporting results as a .csv or .txt file is free by clicking on the export icon
Cite as source (bibliography):
Lights Out Solver on dCode.fr [online website], retrieved on 2024-07-15, https://www.dcode.fr/lights-out-solver

Need Help ?

Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!