The game consists of 25 lamps, arranged in a 5 x 5 grid. At the beginning of the game all the lights are turned on. The goal of the game is to switch off all the lights. If you switch a lamp on or off, the lamp itself and the four adjacent ones are inverted. |
![]() |
![]() |
![]() |
![]() |
As a template you can use the file LightsOut_0.java .
Download (LightsOut_0.zip)
Step 1: Create lamps in all cells of the grid
Step 2: Not only the lamp that was clicked on, but also the four adjacent lamps are supposed to change their sprites
The affected cells can be recorded in an array: |
![]() |
You don't have to start this game with "all lights on". You can start with an arbitrary pattern, with the task staying the same. The solution, if there exists one, can be calculated mathematically (see LightsOutGame).