lights_out, a MATLAB code which analyzes the "Lights Out" game, in which lights on a 5x5 board are randomly lit up. Pushing a light reverses its status, as well as the status of the north, south, east and west neighbor lights. The user seeks to push buttons in such a way that all the lights are turned off.
Only some initial states are actually solvable.
A strategy to solve the game begins by driving all the lighted squares to the bottom row. This is done by starting in the second row, and clicking just below any light in the first row. This blacks out row 1. Repeating this process by working downwards results in turning off all the lights except in the last row.
For the 5x5 case, the strategy then depends on the pattern of lights in the bottom row. Depending on that pattern, click lights ON in the first row, and then repeat the process of driving all the lighted squares to the bottom row. This time, you should end with no lights on.
if bottom is start top as 00111 00010 01010 01001 01101 10000 10001 00011 10110 00001 11011 00100 11100 01000where, of course, "0" means a light is out, and "1" means a light is on.
The information on this web page is distributed under the MIT license.
lights_out is available in a MATLAB version.
lights_out_game, a MATLAB code which sets up the "Lights Out" game, lighting up a few squares on a grid. An interactive user must then try to press squares in such a way that all the lights are turned off.