Overview
This project is a web-based implementation of the classic Lights Out puzzle game. The objective is to simply turn off all the lights on the grid.
Clicking a cell toggles:
- the cell itself
- its immediate neighbors (up, down, left, right)
The rules are simple, but solving it becomes harder as the grid size increases.
Why?
This project was forked from a version that had all the visuals and base logic working, I extended it with several new features to help me prove some things for my math classes in Uni. The original question was along the line of is a 3x3 grid always solvable given an inital random starting state?, the answer is yes. The obvious next question I had was about 4x4, 5x5, nxn etc.
Solver (Linear Algebra)
The main feature I added was an auto-solver using linear algebra.
Each button press is treated as a binary value (0 or 1), and the board becomes a system of equations. This lets represent the grid as a matrix and we can ofc solve a matrix.
Further I added...
- Building the matrix for any grid size
- Code for automating creating grids and trying to solve
- Code for extracting this, to make charts in excel
- Code to randomly fill these grids (may not always be solvable)
- Code to debug (like manual input)
- Nice Gui
This allows me to:
- Automatically solve the puzzle
- Work on larger grids
- Do it really alot (psudo proof by exhaustion "run until I find one I cant solve")
Know that Larger grids increase difficulty and computation cost..
Stack used
- HTML
- CSS
- JavaScript
- jQuery
See it here: