Category Archives: software

development of the Sudoku software

Sue de Coq

I had a lot of fun implementing this ancient solving technique in SudoCue. Most players have already forgotten about it. However, it is a technique that provides a pattern-based alternative for otherwise difficult to spot ALS moves. Having studied the technical ins and outs, it proves to be a solving technique that could easily be expanded in several directions. Unfortunately, many players do not think in terms of constraint sets, and they have difficulty understanding the concepts or recognize its beauty. I wrote a good article about Sue De Coq in Sudopedia and on the Eureka forum. Maybe it needs time to sink in.

Other techniques I’ve implemented are Skyscraper and 2-String Kite. These are pattern-based alternatives for certain Turbot Fish moves, originally introduced by Havard. It took me less than a day to implement both these techniques, which tells enough about their simplicity.

In SumoCue, I implemented Law of Leftovers a while ago, but this technique is now finally out in an official release. I also added a Jigsaw pattern selector, so the players using SumoCue for the daily jigsaw competition at www.sudoku.org.uk can simply pick a pattern, rather than drawing it manually.

GattaiMaker

I spent the last week writing a new program which I called GattaiMaker. The name says it all. The program can generate overlapping Sudoku puzzles.

It is a major improvement over the CluelessMaker program which I used before for overlapping puzzles. CluelessMaker required me to generate a batch of puzzles with my regular Sudoku generator, which were glued together by CluelessMaker by relabeling the digits in the overlapping regions. Several configurations were tested and the best scoring combination was saved.

GattaiMaker can create any overlapping puzzle from scratch. It uses a DLX engine which is configured for the variant to be created. Diagonals are an option. The current version only supports global symmetry in every conceivable way, but the next version will also support local symmetry. A built-in solver can rate the puzzles. I’ve created it as a step-solver, so it does all occurrences of a specific type of move in a single step. Rating depends on the number of steps and the solving techniques used. This may obscure some advanced moves, but the overall difficulty of an overlapping puzzle is related to the number of alternative moves, which are measured by step counting. Finding the only possible single in a puzzle with 25 overlapping Sudokus is harder than spotting locked candidates when there are 20 present in the puzzle.

Internally, all solving techniques operate on the DLX data structures. I’ve never managed to do this before, but it works perfectly. No additional arrays, counters and masks are required. Every placement and elimination is implemented as a DLX operation.

The only format not supported yet is the Clueless Explosion, as the program cannot yet handle internally disjoint boxes. The regular Clueless format is supported, as well as the new Windmill format and two Clueless types merged with Sumo and Shaolin, respectively.

For advertising, I posted several different puzzles on my website and various forums.

Wasted a day on Almost Locked Digits

A weblog can be used to celebrate achievements or the write away frustrations. This post belongs to the latter category.

When I completed the ALS technique in SudoCue, I figured that there must be a counterpart, like hidden subsets are the counterpart for naked subsets. An ALS is defined as N cells having N+1 digits as candidates in a single house. Any digit that you can take away from the set will lock the remaining digits in these cells. It can act as a strong link in any chain, but the more basic application is a pairs of ALS’ with a shared digit, which is connected in such a way that it cannot appear in both sets at the same time. From here, we can eliminate any candidate that can see all instances of another digit in both sets. This sounds like a rate occasion, but ALS’ are abundant in any Sudoku.

So what about the counterpart?

Almost Locked Digits is the “hidden” counterpart. It has N digits confined to N+1 cells within a single house. The trigger mechanism is actually more flexible. Any move that would force one of the surplus candidates into any of the N+1 cells will lock the set. Now the easiest application would be a similar XZ rule. Find a conjugate pair with each end in an ALD. Either one of the ALD’s must be locked. Any shared peer for one of the digits can be eliminated. Simple, elegant, easy to implement.

Only, they do not exist. I tested this on numerous puzzles, even with ALS disabled, and although an average sudoku contains hundreds of ALD’s, they just won’t connect with an XZ rule. Pretty frustrating. I’m not even sure whether the code or the ALD logic has failed. The logic looks pretty solid and the code does find the ALD’s with the conjugate pairs that trigger them.

I’m going to run a couple of severe debug runs to check out the code, and if that doesn’t work, I’ll drop it in the trashcan.

The Incredible power of ALS

I cannot resist posting a few words about ALS (Almost Locked Sets), a very advanced solving technique with a lot of solving power. As I stated earlier, I just missed the deadline for 1.5.1 with these new solving techniques. They are now released in 1.5.1.1

One of them, long overdue, is Empty Rectanges. It does not solve anything new, but it is an easy to use alternative for multi-coloring and sometimes even for Nishio. Many other sudoku programs already supported ER, but having the most powerful techniques already implemented makes you lazy, I guess. The templates catch any single digit elimination, so I was not encouraged to implement lower-level single digit techniques. However, after the overwhelming success of my finned-fish implementation, it seemed the right time to do Empty Rectangles as well. Having restructured the solver in such a way that it is now very easy to add new techniques does also help.

The real thing I wanted to talk about is ALS. It is a bad acronym, but commonly known in the sudoku community. An Almost Locked Set is a situation where N cells have N+1 digits as their candidates. The simplest ALS is a single cell with only 2 candidates. Consider the following grid:

ALS-infested grid

How many Almost Locked Set does this grid contain? 10? 20?

No, there are almost 200 ALS’s in this grid, with only 96 candidates left. Most of them are harmless, but when you can pick the right combinations, they can become incredible solving tools. My list of 50,000 sudokus that require tabling steps is reduced to half its size, now ALS can be used. There is no single technique that had such a tremendous impact.

I will expand my solving guide to tell more about the power of ALS.

Size Matters

It has cost me a night sleep, but I have rewritten parts of SudokuGo, my batch generator. It now can generate any Sudoku with boxes of size 2×2, 2×3, 3×3 (duuh), 3×4 and 4×4, including the main variants, Jigsaw, X and DG.

If have also generalized the Windoku concept. A 4×4 sudoku can contain 1 extra 2×2 box in the center, with 3 implied extra groups. No Windows for the irregular formats, but 16×16 can have 9 extra 4×4 boxes, with 7 implied groups. I’m not sure this format will ever work, because the program chokes on generating a valid grid. Too bad if it turns out to be an impossible format, because it looks great. I’ve tested generation of the Windoku groups without box constraints, and that works. The combination may prove to be too much. Just to many conflicting constraints.

Also released SudoCue version 1.5.1. Redid the optimizer as many requested it should work, and also added a menu option to fetch the daily competition puzzle from www.sudoku.org.uk. Undo and redo work on candidates too.

I am now trying to implement Almost Locked Sets. Considering every possibility, the program now found 228 sets in a single grid. Needs some work to filter out the sets that are actually useful. I think I start sorting out the sets that do not overlap, but have a restricted common digit x. It must be possible to find ALS-xz patterns amongst these pairs of sets. I’ll write some more if I made some progress. Would be nice to be the first program that supports ALS, after being the first (and still the only) that supports finned fish.

First daily Sudoku-X on the WWW

Since I implemented Sudoku-X in SudoCue, I was wondering where people would be able to find these puzzles on a regular basis. To my surprise: nowhere! Only websudoku.com has a weekly feature of variants, and Inertia only pretends to have them, leading you to their desktop program.

So I decided to run my batch generator for a while, and it came up with a wonderful series of puzzles, with various symmetries and a wide range in difficulty levels. I decided to focus on 2 difficulty levels, one for the beginners and one for the advanced players, keeping them both happy on my site.

Since all my puzzles are themed, I needed one for this new feature. X-Rays, X-Wings, X-Men and X-Files were amongst the candidates. Combining the puzzles with an archive made me choose X-Files, which happened to be problems that needed to be solved. I’m still probing the theme, but there will be more wordplay in this arena. I’m full of ideas.

On a side note: The addition of regular puzzles and the rewriting of all the on-site documentation has resulted in a steady growth in visitors. This seems to have a snowball effect, because more and more people discover my site. It must have good pageranks in Google. Quality does pay off in the end.

The road to Perfection

I have brought 2 releases of SudoCue to the site in a very short period of time. The visible improvements can be seen on the release notes page of the www.sudocue.net website, but the internal restructuring is not seen by the outside world. Here are a few notes on how the architecture has changed.

First, a virtual class named Trick has been added. This class can save itself to the configuration file, has a name, a base score, a sequence number, an optional administration score, several classification flags, tries and usage counters, and a Performed method which reports a successful application of the trick.

A Tricks class contains a collection of Trick instances which can be enumerated.

The user can enable or disable any of these tricks through the options panel, and also change the order in which they are tried.

Several tricks that are basically different sizes of a single technique have a base class that performs the technique, with the size property of the derived class as a parameter. There are 2 tricks which are kept at the end of the collection, the DLX brute force solver and a Surrender class the does nothing, but declares the puzzle unsolvable. This trick cannot be disabled by the user for obvious reasons.

The only thing that I need to add a new technique is define a new class derived from the Trick class and add it initially to the Tricks collection. In earlier versions, I had to change the Log, the Options class, the Options dialog, the main solving method in the Grid class and the Analyzer dialog, even before I could start coding the nitty gritty stuff. This hassle disencouraged me from quickly adding new tricks.

There is also a strict separation between setup and play mode. The solver does nothing in setup mode, but validates and rates the puzzle when you switch to play mode. Earlier, the program had the habit of kicking in too soon, filling the log with complicated tabling chains when all it had to do it wait for all the clues to arrive. With uniqueness, this could even lead to a solving path going the wrong way.

With these changes, the program is ready to be expanded with all the lovely tricks that have been developed in the last months. Some have already been added to the program. More will follow.

HaniDoku

When you’re busy and have no time left, there is only one thing you can do: Start something new that even takes up more time!

When I was playing a game of Catan, I realized that the shape of the segments in this game could also be used for a new puzzle format.

A sudoku variant with hexagonal cells did exist, but it still had boxes and lines of equal length. So I decided to work out a concept with lines of different length, and drop the box constraint. This turned out to be a very good idea. With lines in 3 directions, the boxes would have so many intersections, that the puzzles would be too easy to solve.

The lines with different size open the way to new solving techniques. I found 3 already, and more are waiting to be discovered by me or others.

Killing Time

My focus has been shifting back and forth, lately. My log shows that SudoCue has been downloaded more than 9000 times, but still there are not many responses. This made me put SudoCue on hold for a while.

I turned my attention to Killer Sudokus. Amazing how little software is available for Killers, while the Net is swarming with Sudoku programs. This time I decided to do it the right way. Be the first, be the best, be the benchmark.

The new program is SumoCue. It specializes in sudoku variants with irregular shapes, such as Killers and Jigsaws. It has a DLX solver that can solve any variant. It has a designer mode with the right tools to help you create jigsaws and killers. When puzzle makers use the program, they will attract players. The program has a custom file format, but also handles PS format for Killers.

The tools are limited, but very useful for both killer and jigsaw puzzles. After a few quick releases, the program has stabilized. It is well received, better than SudoCue. Maybe it was a good idea to use the same colors as Simple Sudoku to give the users a comfortable feeling. It worked for me. The light 3D effects create a smooth User Interface.

Support as usual through the forum. I use the program to create (Jigsaw) Killers. I post a few on my website, but I also have managed to sell a few to a publisher, along with a couple of Clueless Specials.

There is also a new release of SudoCue. I wrote a trimmed DLX solver to be used for random puzzle generation and optimization. My experience in DLX is now paying off. This new code is flamingly fast. I could even include multiple symmetry types for the generator.

Â

The Clueless Days

Sometimes I feel clueless myself.

The first of these monster puzzles were meant as an experiment. People jumped on it and wanted more and more. Creating these puzzles manually involves some risk. You have a shot at it and when it can be solved by 10 instances of SudoCue, then it should be OK. Difficulty can only be determined by testing. Because that takes such a long time, I tend to approve anything that passes the test, no matter how difficult.

Now I have CluelessMaker. It accepts 9 template-generated puzzles and a solution as input, maps the 9 puzzles to the central solution, and solves the whole thing in a fraction of a second. It counts naked/hidden singles, line-box interactions and naked/hidden subsets. More techniques will be built into it, but I can manually assess an almost solved clueless to see what is needed to complete it. If it’s a fair technique, I’ll let it pass.

What worries me, is that players no longer fancy the ‘regular’ sudokus. They want more and more clueless specials. If have made 4 by hand, the rest will be machine made, and more reliable.

Also had some fun on the player’s forum with the superior and inferior threads.