Java implementation of the classic lights out game.
Screenshot Gallery...
Using two 2d arrays of boolean values, one representing the lights states, and the other where to click to solve the puzzle. The first array is reflected by the light grid, and is what the player is directly interacting with. The other is an underlying array, which implements the breadth-first algorithm to calculate the least amount of buttons t click to turn all the lights on.
Taking two integers as input, the game launces a UI composed of two parts. The Game Board, and the Button Holder. Initially, the game board is initialized to off, and the user can interact with it, attempting to turn all lights on by themselves. If the player finds this too difficult, they are able to turn on the Solution overlay, which directs them to a fully-on grid.
This randomly generates a board for the player to begin with, assuring that any board given is guaranteed have at least one solution to turn it on. Any generated boards which are insolvable are discarded.
Creating an overlay on the board, this button projects the quickest solution onto the board until the player disables it. Each time the player clicks, a new solution is generated so a mis-click does not interfere with a desired quick-solution.
Upon winning, a player is presented with a pop-up which reveals the number of clicks required for them to do so. They are presented with the option to begin again.