Sunday, March 27, 2011

posted DDTe1 Hours 20 to 22 - Final Touches

This week we finish the series of posts on the creation of Dozen Days of Tiles Episode 1: Sudoku Player.


At this point, the Sudoku Player is in a pretty nice state with only three buttons left to implement and some additional cosmetic touches to add.

The Clear Notes button is the easiest to tackle. It simply sets all the notes in the notes section to the unchecked state. I probably don’t need to explain how this is implemented as all the method consists of is a loop through all the check boxes setting them all to false.

The Hint button is a handy feature in that it automatically sets up the notes for you. As this requires heavy use of the SudokuView classes valid tile methods the setTileHints method has been placed inside the SudokuView class. This is a bit more complex as it calls the checkRowForValue, checkColForValue, and checkGroupForValue methods for each of the 9 possible values for the tile. If all three of these methods return a 0 then we know it is possible for that number to be placed inside of the tile and therefore set the appropriate check box.

The final button to implement is the check button. It checks the value in the row using the checkRowForValue, checkColForValue, and checkGroupForValue methods to see that the value only appears one in the row, column and group. If it does, it is valid otherwise the tile gets set to blank and the hint function gets called.

Once all this was implemented, a backdrop piece of art was created and some fine tuning to the layout was completed. While I would have liked to add some keyboard support to the game, there simply was not enough time within the 24 hour limit this series imposes on episodes so the game was deemed finished. Depending on what happens on April 1st, I may re-visit this game and add additional features but I think the original version of the player will be retained to keep the spirit of the project.

No comments: