Lights Out!

Pusheen ad


I had a difficult time with this assignment. I began by creating one clickable box, then putting them in a 5 x 5 grid. Then I added a function to toggle the sides of the box on every click. I created a win condition that checks if there is are no "on" blocks with a happy little popup if none are found.

I wasn't sure how to generate a new map, so I found a method used for online games where you create a 2D-array and randomly generate a 1 or a 0 for each box. I used this method to toggle random boxes in my 2D-array. The only thing is, I'm not sure that this allows for a 100% solvable board. I don't know how to solve these.

Somehow in the process of this, I managed to mess up my grid to where it was no longer 5x5. I also didn't get the surrounding blocks to turn on correctly. However, this was solved by adjusting the size of the div which contains the game. I couldn't get the new game button to work, however.

But I'm a big believer in something is better than nothing, so I decided to at least make my work look pretty by formatting it with the rest of the website.

By the way, I have no idea how to solve these. So don't even ask me to try.