realbasic-games
[Top] [All Lists]

Re: Advice Wanted for Sudoku Analyzer

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: Advice Wanted for Sudoku Analyzer
From: Barry Traver <rb at ix dot netcom dot com>
Date: Mon, 21 Nov 2005 01:01:52 -0500
Delivered-to: realbasic-games at lists dot realsoftware dot com
References: <33cbfa100511201937y1d115e41i9970c12036cea6d1 at mail dot gmail dot com>
Lars Jensen wrote:

(BTW, I'm not sure what you mean by "basic" Sudoku analysis, but from
what little I've read, you might find that the UI is the easy part
after all...not that that should stop you!)

I'm accustomed to doing mathematical analysis of game positions. Examples: my "Giant and Dwarfs" game (published in 99'er Home Computer Magazine decades ago), my "Jump-a-Peg" puzzle program (published in MICROpendium also decades ago), my "NimRow" game (adapted from one of my - mostly mathematical - "Coney Games" collection I released decades ago), etc., etc. (I did port over to REALbasic "NimRow," "31 or Die!", and "Tic Tac Toe Philadelphia Style," which is now a magic trick in addition to being a card game.) Like the card trick program, many of these were inspired by Martin Gardner, especially by the "Mathematical Games" column he wrote for years for the magazine Scientific American.

Also, when I was working on my B.A. in mathematics, I was invited to become a member of Kappa Mu Epsilon, a national mathematics honorary society, and I have taught math on the college (well, on the junior college) level. I currently do tutoring in math, particularly preparing high school students for the PSAT and SAT exams. And any math involved in Sudoku is mostly just involved with expressing with numbers the locations of the various squares (figuring out what row, what column, and what block of nine, pretty simple stuff).

Fast description of Sudoku for those who may not yet have gotten caught up in the craze. Picture a grid that is 9 x 9 in dimensions, making up a total of 81 squares. In addition picture the 81 squares as being broken up into nine 3 x 3 squares. The object is to fill in numbers (a single digit in each square) so that these three things are true:

    (1) each row of 9 contains all of the numbers from 1 to 9.
    (2) each column of 9 contains all of the numbers from 1 to 9
    (3) each 3 x 3 block contains all of the numbers from 1 to 9

What makes it a fun puzzle is that someone else has already filled in some of the numbers, and you logically have to figure out what numbers to put into the empty boxes.

Specific (very easy) example: picture a particular empty square. Imagine that other squares in the same row already contain the numbers 2, 7, and 9. Imagine that other squares in the same column contain the numbers 3, 8, and 7. Finally, imagine that other squares in the same 3 x 3 block contain the numbers, 5, 1, and 6. From that information, it can be inferred that the only number that can be put in that square is 4 (since it can't be 1, 2, 3, 5, 6, 7, 8, or 9).

That's the sort of processing or "thinking" that a computer is very good at. Now, most of the time, of course, it will not be as simple as my example, but at least it should be easy to write a program that can figure out the easier Sudoku puzzles. (And, besides, I'm mainly writing it as an exercise, to make learning how to do graphics less painful <grin>.)

What if you can't reduce the possibilities for a particular empty square down to one? Well, then there are two possibilities: you have to hope that in the process of solving other empty squares, you'll get enough information to figure out this one, or you'll have to have the program figure out the outcomes if you try each of two or more possible options for that square.

The argument goes something like this: The number for such-and-such an empty square must be a 4 or a 5. Let's assume that it's a 5. But that leads to impossibilities elsewhere in the puzzle. Therefore the missing number must be a 4. Simple mathematical logic!

So I don't expect a problem with the math or the logic, but the graphics is a different story, since I've never done anything with a canvas before (at least while understanding what I was doing).

Warm regards,

Barry


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>