by mjmogo » Mon Nov 29, 2010 5:45 pm
I am new here, but as I am curious about this discussion of writing a program in C, I am curious what the current status of this project is?
I wrote a program in C a few years back, but only got as far as one that creates randomly generated boards, but never got to the point of adding in any of the tests for "levels" or "ratings". I had written the program from discussions with another programmer friend of mine, we both enjoyed doing sudoku, and with him being a professional programmer, I was interested in picking his brain for those of how such a program might be written.
The basic logic of the program was pretty much a "brute force" method of randomly filling in squares, then testing to see if the results were valid, and then repeating until the whole board was filled. If it ran into a situation where it was "stumped", it would back track to the point where all the squares effecting the boards valid results were erased, and then pick up again from that point. If after a number of attempts at that particular board failed, it erased the whole board, and started over again. I also wrote some functions that would randomly mask squares, and then output the starting layout to a file for testing with other sudoku validating programs. The results I got were not all that interesting, as many of the boards produced very simplistic sudoku starting layouts.
The main point of why I wanted to write this program was that I am interested in extending the generator to handle not only the traditional 3x3 board, but ones of higher order. I was able to get my program to generate board of up to 6x6 dimensions, but the generated boards took quite a while to "discover". I tried to run it using a 7x7 matrix, but it ran for about an hour before I decided to shut it down.
One thing that interested me in this discussion was how these board might be stored, and one of the things that I had done with my program was to interface it with "sqlite" to store these board in an SQL database. Not really sure if anyone else here has thought of doing that, but it is a very simple interface and "sqlite" is a free database to use. The only real issue would be designing the SQL database structure to be used for storing these board.
Anyway, I am curious to see what the state of this project is. If anyone is interested, I would be willing to share my program with those interested. As I don't have access to anything to put it up online, you can send me a private message, and I can forward the files to you. Please do be kind in critiquing it, as I only do this as a hobby, and I might not be quite up to "snuff" with how other people think.
Mike
PS... I have looked at Sudoku Explainer, and have given some thoughts to "translating" it into Lua. It is a quite elegant program, and I think it would be quite interesting to try something like that. The only thing about Lua is that it interfaces with standard C very well, and once the program is up and running, any of the functions that require longer run times can be translated into C without much trouble.