Create a Sudoku Puzzle Generator using VB.NET
(Page 1 of 6 )
Back in 1988, a game called Tetris became a worldwide phenomenon. At the time, I programmed my own PC version of it using Turbo Pascal. Recently, a friend of mine introduced me to Sudoku. Like Tetris, this puzzle game sparked a global fervor. I could download it for free from a number of sites, but what fun would that be? Instead, the learning experience and challenge would lie in coding it myself. Join me as I show you how to roll your own Sudoku puzzle generator.
For those of you that have never heard of it, Sudoku is a logic-based placement puzzle that garnered early popularity in Japan. The puzzle retained its current moniker from an abbreviation of the Japanese phrase, “the digits must remain single." The puzzle is comprised of a 9x9 cell grid sub-divided into 9 3x3 regions and several of these cells, called “clues," are pre-filled with the numbers 1 to 9. As its name implies, solving the puzzle entails filling the remaining empty cells with the numbers 1 to 9 so that they appear only once in each column, row, or region. Figure 1 shows a sample puzzle. For more in-depth information and links on Sudoku, I recommend going to the increasingly popular Wikipedia at http://en.wikipedia.org/wiki/Sudoku.

Figure 1. Screen Shot of Sudoku Generator
Puzzle Generator Features
I originally targeted the puzzle generator for mobile smart devices (as evident by the application’s small user interface footprint), due to the lure of playing it on my PDA or cell phone. Yet in writing this article, I decided to target the Window’s desktop so as not to convolute the review of the code with particulars about the Mobile Device API. In the near future, I’m looking forward to writing a second installment for the smart device platform. The application implements some pretty basic features. You can create new puzzles with varying degrees of difficulty, save and load them to and from disk for later enjoyment, or print them. The latter feature is especially useful if you prefer to leave your laptop at home and use a pencil to solve your puzzle the old-fashioned way. Check out the Enhancing the Puzzle Generatorsection below for some suggestions on how to further enhance the application.
Next: The User Interface >>
More Visual Basic.NET Articles
More By Pete Rodriguez