![]() I'll share the Store links and some pictures now and leave the trying and testing part of the app to you! Sudoku app windows phone download# Windows 8.1 - Sudoku Solver- PWNING Sudokus Like A BOSS! B-) app for Windows in the Windows Store Windows Phone 8.I came across the Sudoku game a few months ago. I commute by train daily to my office this puzzle, in everyday newspaper, was one of my favorite ways to pass time in the train. I thought why not develop this game in C#? This article discusses the implementation of this game in C#. The game provides three complexity levels: simple, medium and complex. The user can view the answer for a few seconds to get a clue. NET Framework installed on your PC or laptop to run this program. The game presented in this article arranges numbers in 9X9 matrix, which is the most common form of this game. The number, in each row and column, should be between 1 and 9 and should appear only once.The 9X9 matrix is made of nine 3X3 matrices.So, the number in each of these subsets should also be between 1 and 9 and should appear only once. Now that we know the rules, let us see the implementation. The main class implementing this game is Sudoku and is implemented in Sudoku.cs file. The view is implemented using a DataGrid and the main form for implementing the view is in SudokuMainForm.cs file. The basic design idea is to first generate the solution and then unmask certain spots based on the complexity level. Initially, I spent some time to create a solution by populating sets which were independent using random numbers between 1 and 9. This was a bit complex and was taking time. Hence, I decided to take one unique solution as the base and then derive other unique solutions by swapping rows, columns, sets and reversing numbers. This way, I could generate 1000s of combinations. GenerateGame() method of the Sudoku class uses this technique. I have used DataGrid which is a very useful control to represent data in tabular form. I have used DataSet which is easier to bind to the grid. As I am using two dimensional array to keep the problem and answer sets, I have exposed two properties ProblemSet and AnswerSet which return the data in two dimensional array as a DataSet.Īnother important part of the game is to provide data validations. The ColumnChanging event of the DataTable is quite useful and I have used this event to handle data validations such as "valid number", "answer position not changed" and "number is not a duplicate". The event arguments of this event enable us to set the appropriate error message for the affected column. I have provided a button control to show the answer, which displays the answer for a few seconds and then brings back the problem. You can use this if the problem is complex and for getting some clues. I will only explain the important methods. ![]() You can see the full implementation by downloading the source code using the links given above. Sudoku class is the main class implementing the game. GenerateGame(GameLevel level) method generates the new game. The code for this is given below:Ĭopy Code // Method: GenerateGame // Purpose: Generates game based on complexity level. InitialiseSet // This first creates answer set by using Game combinations public void GenerateGame(GameLevel level) Sudoku app windows phone code# Now unmask positions and create problem set. In the above code, GameLevel is of type enum and it defines the complexity levels. The InitialiseSet() method generates the unique solution. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |