I recently uploaded Lights Out!” : a simple Android application that is inspired by the Lights Out!” game by Tiger Electronics.

I have another blog post (“The Mathematics of Lights Out”) that describes the mathematics behind the game logic as well as a simple interactive Javascript implementation of the game.

Here are a couple screen shots of the Android application. More information can be found on the Lights Out link for the Google PlayStore.

Lights Out main screen.
Title screen of application.

Here are a few screen shots showcasing the functionality of the app. The user can select a board size of 3x3, 4x4, 5x5, or 6x6.

Lights Out level select
Select level dimension.

Once a dimension is selected, the levels for the respective dimension may be selected. Here are examples for 3x3, 4x4, and 5x5.

Lights Out 3x3 level listing. Lights Out 4x4 level listing. Lights Out 5x5 level listing.

Selecting a level will open up the game board. Here is an example of a 6x6 level.

Lights Out 6x6 level.
Lights Out 6x6 level.

If stuck, the user may request a hint or to outright solve the configuration Pressing the “solve” button will solve the configuration and give the user a process to follow to solve the given board. This is shown below.

Lights Out 6x6 solved level.
Lights Out 6x6 level solved.

And to top it off, here’s a quick video showcasing the functionality of the app:

If you have an Android device, feel free to download the app and give it a try! If you have any improvements, suggestions, or crash reports, please let me know in the comments section! Again, you can download the app at the Google Play Store.

The most interesting part of this project was coding up the Lights Out solver. The Lights Out game board can be viewed as a matrix, where each entry is either “on” or “off”. This can be thought of as a binary matrix, or a matrix consisting of ones and zeros. Solving a Lights Out board really just boils down to solving a system of linear equations mod 2. Given an arbitrary configuration, you want to make sure that the given configuration is solvable. Furthermore, to provide hints to the user, the algorithm needs to solve the current configuration to give hints on where to move. It’s also possible to give the user a Lights Out game board that is impossible to solve (which wouldn’t be very fun for the player!).

I made use of the Efficient Java Matrix Library (EJML) in Java to perform some linear algebraic calculations, but I also had to code up a lot of routines by hand as they were not provided by the library. It turned out to be a fun and rewarding process!

I also want to acknowledge Ersin Ertan for working on an early version of this project with me. He has an excellent course on Android Studio that I definitely recommend if you’re looking to start developing Android apps. Furthermore, if you’re an Android developer and want to check out the project, I’ve open sourced the whole thing, and it can be cloned at the lights_out Github repository.