Senior Design Progress Blog 10

Code code code: This week I worked on finishing the Nonogram gameplay functionality for the Joan Clarke mini-game. I created a nonogram solution checker (as well as a constructor for 5x5 nonograms) so the game is now fully functional and playable.

In order to check if the player has successfully filled out the puzzle, I check if the solution is valid programmatically rather than having one hard-coded, as sometimes these puzzles can have multiple solutions. (I also don't want any older users clever enough to check the source code to be able to cheat) My game state contains two arrays that keep track of whether each row and column are valid. Every time the player selects or deselects a box, the game state updates that row and column in their respective arrays. Once both of these array are entirely true, then the game is won.

For checking the contents of each row and column I had to convert DOM elements into a string and then fiddle around with a few different array functions. I ended up using both the split function, to make sure that the boxes are parsed in groups based on whitespace, and my own filter method to remove blank values in the resulting array.

Video of gameplay