Minh T. Nguyen’s Sudoku3D in XAML


I’ve already played with XAML almost a year ago when it was still in the early stages, but over my winter break, I spent some time getting my hands dirty with the 3D aspects of Microsoft’s XAML/Windows Presentation Framework. I decided to create a 3D version of the famous Japanese Sudoku game, and pretty much finished coding 90% of it already in December 2006, but it’s not until today that I finally found the time to wrap up the code, the user interface and fix all the pending bugs.


So, here it is: Minh T. Nguyen’s Sudoku3D


Minh T. Nguyen's Sudoku 3D


The Game


Just like in regular Sudoku, you need to fill in a row, column and “height column” of the cube with all natural numbers, so that each number appears once and only once. Unfortunately, the third rule of Sudoku (that a given 3x3 sub-square of a 9x9 Sudoku square contains all 9 numbers) does not translate into the third dimension. For instance, in a 4x4x4 Sudoku cube the 2x2x2 sub-cube has eight cells, not four. I therefore had to get rid of the third rule, which makes playing this game not as fun as I expected it to be. If anyone has any insightful suggestions on how to translate the third Sudoku rule into the third dimension, let me know.


Requirements


This game requires Internet Explorer as well as the Microsoft .NET 3.0 (which comes pre-installed with Windows Vista but is available as a separate download for other Windows systems). A fast and powerful computer running Windows Vista is preferred, as the Sudoku generation for large cubes can be very CPU-consuming (in fact, I don’t even allow you to generate cubes larger than 5x5x5 even though it’s theoretically possible). In addition, the graphics just looks much smoother on Vista since 3D anti-aliasing is only enabled there.


Development


Coding this game has been pretty fun. The hardest part of this all was actually not the 3D aspects of this, but the Sudoku generation algorithm itself. I never realized that creating a valid Sudoku is actually much harder than solving it. In the end, I’ve designed a backtracking algorithm using a stack of intermediate steps in conjunction with a 3D array of possible moves. Fun stuff.


Hope you all will enjoy playing this game as much as I enjoyed coding it!


Comments (5)
  1. Garry Trinder says:

    Way cool Minh! I completed the default puzzle in 4 minutes.  It took a bit to understand the instructions and to navigate the 3d space.  

    Here are some of my suggestions:

    1) The instruction panel auto-collapses.  Is there a way to leave it persistent once expanded.

    2) As a player I would also like the ability to change the opacity of the selection pane.  It was hard to see the middle sections.

    3) mouse-wheel to zoom in additional to right-click zooming.

    4) I picture a visualization and animation where you can flatten out the cube into the traditional sudoku layout or merge the panels back into a cube.  That would be awesome!

    5) The winning alert box was out of place.  I mean, you’re navigating a 3D space and all a sudden a generic window pops up that tell you that you’ve won.  It would’ve been better if the winning message was displayed with WPF controls.

    Btw, I would love to see your source to learn more about WPF’s 3D capabilities.  

    Keep up the great work and keep in touch.

  2. The smallest sudoku cube that you can consider for the third rule to hold is 8x8x8. The 2x2x2 sub-cube has 8 cells now. The next sudoku cube that you can consider is 27x27x27. The 3x3x3 sub-cube has 27 cells now. I hope is clear the idea. The number of cells along one dimension of the sudoku cube should be the third power of the number of cubes along one dimension of the sub-cube. Now, let us move to higher dimensions. The smallest n-dimensional sudoku hypercube is (2^n)x(2^n)x(2^n)x…x(2^n), where ^ denotes power and the product has n-terms. The next n-dimensional sudoku hypercube is (3^n)x(3^n)x(3^n)x…x(3^n), where the product has n-terms, and so on and so on…

  3. don baechtel says:

    Server Error in ‘/’ Application.

    ——————————————————————————–

    Runtime Error

    Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

    Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

    <!– Web.Config Configuration File –>

    <configuration>

       <system.web>

           <customErrors mode="Off"/>

       </system.web>

    </configuration>

    Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application’s <customErrors> configuration tag to point to a custom error page URL.

    <!– Web.Config Configuration File –>

    <configuration>

       <system.web>

           <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>

       </system.web>

    </configuration>

  4. don baechtel says:

    Server Error in ‘/’ Application.

    ——————————————————————————–

    Runtime Error

    Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

    Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

    <!– Web.Config Configuration File –>

    <configuration>

       <system.web>

           <customErrors mode="Off"/>

       </system.web>

    </configuration>

    Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application’s <customErrors> configuration tag to point to a custom error page URL.

    <!– Web.Config Configuration File –>

    <configuration>

       <system.web>

           <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>

       </system.web>

    </configuration>

  5. don Baechtel says:

    Can’t get your program to ru. Please fix.

    Server Error in ‘/’ Application.

    ——————————————————————————–

    Runtime Error

    Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

    Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

    <!– Web.Config Configuration File –>

    <configuration>

       <system.web>

           <customErrors mode="Off"/>

       </system.web>

    </configuration>

    Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application’s <customErrors> configuration tag to point to a custom error page URL.

    <!– Web.Config Configuration File –>

    <configuration>

       <system.web>

           <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>

       </system.web>

    </configuration>

Comments are closed.

Skip to main content