• Share this article:

Eclipse Sudoku!

Friday, June 2, 2006 - 14:41 by Wayne Beaton

I managed to speed up my puzzle generation algorithm by a few orders of magnitude. In the process, I got a free solver out of it. The Sudoku game is coming along quite nicely; not bad for about three days worth of actual effort.

We’ve also wrapped up the plug-in into an Eclipse RCP application, and added some fancy icons. Here’s what it looks like as an RCP application:

I’ve been playing with it a lot over the past day or so, and am quite happy with it. The one area where we really need to do a lot of work is in determining an appropriate set of given cells for a puzzle. Currently, we don’t do that very well.

The application itself is pretty function rich. You can click on a cell to set its value, or you can type the digit to put in the cell under the cursor. When you hover over a cell, it shows you the values that can legally be put into that cell based on the current state of the board (there’s no guarantee that any of those suggested values are actually in the final solution). We also added a feature (see below) where it marks the rows, columns, and boxes that are invalid.


“But,” I hear you say, “that’s cheating.” You’re right. We’re going to add some options to turn on or off the help.

The state of the current game is saved when the game is shut down, so that when you restart, it resumes with the previous state intact. It also has a cool “Solve” button that uses the fancy backtracking algorithm I developed to solve the puzzle (from its current state) in front of your eyes. If a solution is possible from the current state, it will find one (if you have invalid values in any of the cells, the solve will fail).

For kicks, I packaged up a Windows version of the RCP application. It weights in a 10MB. A little large, but not too large IMHO. I may put some effort into stripping it down.

If you want to take a look at the code, be my guest. Download and import this Team Project Set and it’ll set you up with all the code. Be advised that we’re still working on it and significant changes will likely be made. I intend to spend the next few days adding more comments and generally cleaning up the code. There’s a few spots in there that are a little inefficient in their implementation that I want to profile (with TPTP) and fix up.

I’d love to get any patches you deem valuable (I’m the only “wayne” at eclipse.org). There’s also some test projects, but they’re not included in the team project set.

There’s a few partially started bits in the code that you might find interesting. To start with, I have the puzzle generation functionality implemented as extensions. The plan is to make it possible to provide other sources of puzzles including pre-packaged ones or those generated by another algorithm or whatever. I also intend to make the solvers pluggable so that you can add other solvers and watch them in action.

At present, I don’t have a packaged up version of it for download, but do intend to shortly.