Skip to content

Playable implementation of Lights Out with a built-in solver based on concepts from linear algebra

Notifications You must be signed in to change notification settings

aydinschwa/Lights-Out-Solver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lights-Out-Solver

This is a fully playable implementation of the game Lights Out.

drawing

The objective of the game is to get all of the red "lights" on the board to disappear, so that only black empty squares are left. To turn any individual cell on the board on or off, simply click on the cell. The catch, however, is that clicking one cell switches the status of all cells adjacent to it. So if you click a cell surrounded by lights that are off, all the lights around it will turn on.

This game can get very frustrating, so I've also implemented a function that will solve any valid board configuration. It works by converting the board into a matrix-vector product of the form Ax = b. Then we run Gaussian elimination to derive a solution vector. To get the solution while playing Lights Out, just press the spacebar. This puts a green circle in front of all the cells that need to be clicked to solve the puzzle.

drawing

References

I originally got the idea for a Lights Out solver from the excellent computational linear algebra textbook Coding The Matrix by Philip N. Klein.

For the actual implementation, I found this video series by Mathapptician very useful.

About

Playable implementation of Lights Out with a built-in solver based on concepts from linear algebra

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages