NetLogo banner

 Home
 Download
 Help
 Resources
 Extensions
 FAQ
 References
 Contact Us
 Donate

 Models:
 Library
 Community
 Modeling Commons

 User Manuals:
 Web
 Printable
 Chinese
 Czech
 Japanese

  Donate

NetLogo User Community Models

(back to the NetLogo User Community Models)

sudoku

by Matt Hellige (Submitted: 10/14/2005)

[screen shot]

Download sudoku
If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".

(You can also run this model in your browser, but we don't recommend it; details here.)

WHAT IS IT?

Those Sudoku puzzles are pretty popular these days [1]. This model provides some help in solving them. Instead of trying to solve the puzzle for you, the model acts as an assistant, keeping track of possibilities and constraints and, in some cases, making suggestions.

For simpler puzzles, very simple deduction and constraint propagation is enough to completely solve the puzzle, but let's be honest: those puzzles aren't really any fun to begin with. For harder puzzles, this model takes care of the trivial busy-work and bookkeeping, and allows you to focus on the deeper deductions that actually unlock the solution. (Of course, this model also makes it much easier to just guess-and-check with backtracking, but that's still a horribly inefficient strategy, and anyway you'll still have to face yourself in the mirror when you're done cheating.)

HOW IT WORKS

The model propagates the basic constraints along rows and columns and within regions, and it can identify certain moves as logically necessary and mark them. It allows you to mark the "givens" as well as your own deductions, and allows you to eliminate numbers that you believe are invalid in a particular location.

HOW TO USE IT

Hit SETUP. This resets the switches to their default positions and sets up the board.

Hit PLAY. You'll leave the model running while you solve the puzzle...

Use the mouse to select the givens. The givens will show up in BLACK. If you make a mistake, click elsewhere in the same box to undo your choice.

Switch EDIT-GIVENS off, and use the mouse to solve the puzzle. Your choices show up in RED. If you make a mistake, or want to reconsider a choice, clicking on a blank space in a square resets your choice.

You can't accidentally edit the givens while you're solving the puzzle. If you need to change one of the givens, you'll need to switch EDIT-GIVENS on, make your changes, and then switch it off again.

If the model can identify a particular number as the necessary choice in a location, it will make that number GREEN. These are just suggestions: you don't need to select them if you don't want to, but selecting a suggested number may allow the model to make more suggestions, and of course, the suggestions are never wrong.

If you want to narrow the choices in a particular location, switch MARK-INVALID on, and then click on the number you'd like to eliminate. The color of that number will change to GREY, and the model will assume that the number cannot be legally placed in that location. To change your mind, click on the number again.

CREDITS AND REFERENCES

[1] http://en.wikipedia.org/wiki/Sudoku

(back to the NetLogo User Community Models)