OT - Sudoku

ndzied1

Lifetime Supporting Member
Join Date
Aug 2002
Location
Chicago, Illinois
Posts
2,856
Peter Nachtwey said:
[font=&quot]Which PLC is best for solving Sudoku?
What approach is best?
How long do you think it would take to solve 1000 puzzles.
Simpler. How could the PLC generate the puzzles?









[/font]

Is this a challenge??
 
Peter Nachtwey said:
[font=&quot]
Simpler. How could the PLC generate the puzzles?
[/font]

Perhaps simpler to generate "any" puzzle but a much harder task to make puzzles people would want to play and even harder to "grade" the puzzle as to it's difficulty level (something that seems necessary for publication).
 
ndzied1 said:
Perhaps simpler to generate "any" puzzle but a much harder task to make puzzles people would want to play and even harder to "grade" the puzzle as to it's difficulty level (something that seems necessary for publication). Today 06:07 PM
The puzzles can be graded by the number amd depth of look ahead situations that arise. The simple Sudoku puzzles are simple deduction problems where one can simply elimanate options until the puzzle is complete. In some cases there are situation where none of the square have only one option so one must search ahead by 'trying' a number and then trying to find a solution. If it doesn't work then one must back track and try the other combination. A computer can make these tries very quickly. So quickly that I doubt it would take a tenth of a second. A PLC would take longer because of its scans.

Norm, you may be right. Generating the problem may mean generating the solution too and then evaluting it.

darrenj said:
Is this a challenge??
No, I don't have the time, just think about it.
 
Perhaps simpler to generate "any" puzzle but a much harder task to make puzzles people would want to play

Playability is the key. I started my computer interest as a hobby making computer games on Atari 400. It was always tough to make the computer AI stupid enough, or slow enough to make the player vs. cpu type games playable.

PLC ... Game ... same sentence? I wrote a sequencer demo that used six lighted pushbuttons to create a simple simon game. It had a data table I filled with a pseudo-random sequence for one light on per step. When you pressed the start button to start the game, a free-running timer acc was stored as the "random" index. (No two games start in the same place). To start, the computer would flash the sequence of four lights starting at that "random" index, then wait a limited time for the player to repeat it by pushing the buttons. If successful, the speed was increased and one more step added to the sequence which would repeat until you lost. When you lost, an industrial buzzer turned on and the lights all blinked for 1 second.

I did this at tech school, and don't have a copy. Some time when I get bored I'll write it again and post it here if anyone's curious.
 
OkiePC said:
Playability is the key. I started my computer interest as a hobby making computer games on Atari 400. It was always tough to make the computer AI stupid enough, or slow enough to make the player vs. cpu type games playable.
I believe slow enough. I don't believe stupid enough.
Most game players complain the computer's AI is too stupid. It took a long time before chess programs were good enough to beat decent players.
 
Sudoku is not hard compared to the new version: hexadoku. It uses the hexadecimal system and has 256 fields compared to the 81 ones with Sudoku. I have only seen hexadokus with the Dutch magazine Elektuur so far.

Oh, and by the way: it isn't very hard to solve both if you use some tools. I took on a challenge. It took me about 6 hours to write two Excel workbooks to solve these puzzles, one for sudokus and one for hexadokus. Now I can solve a hexadoku in under 20 minutes.

Kind regards,
 
Peter Nachtwey said:
In some cases there are situation where none of the square have only one option so one must search ahead by 'trying' a number and then trying to find a solution.

Trial and error is not always needed if there are more than one possibility to a square. In fact, many frown upon the need for "guessing" or as others more scientifically call it bifurcation.

That's what I meant when I compared Soduku to solving boolean logic at the outset of this thread. You can, based on the possibilities of surrounding squares, deduce and eliminate numbers from other squares. There is logic to it... some is very hard to grasp but in properly designed puzzles, it is there.

jvdcande said:
Now I can solve a hexadoku in under 20 minutes
Having a tool is great but being able to solve the puzzle without the tool is the whole challenge, at least for me.
 
OK, I will go first.

Since no one has taken the challenge to say how they would approach this problem I will go first. This approach would also work nicely for hex Sudoku.

1. The 'board' is represented by a three dimensional array with each dimension being 3 long. ( 4 for hex ) Each dimension of the array represents the row, colum and square of all the pieces.
2. Each element is a integer or word where each bit represents a number.
3. Initially the board is shuffled or genearated with a bit set in the cell that represents a number 1-9. Blank cells have all bits set.
4. Now the computer can scan each cell for which a number has not been found ( has a bit count > 1 ). All cells in a dimension, except for the cell in question, have their contents inverted and anded with the cell in question. This is a NAND function.
5 For each cell all three dimensions must be processed. It is possible that a only a few bits are cleared but this will help during the next scan through the board.

I have to go to work. Do you get the idea? Did I ruin the game for everyone? The procedure is simple and brute force. There are more sophisticated ways of solving instead of just scanning though all the board over and over again. I will answer questions later.

This involves array indexing and bit counting and bit manipulation. These topics come up on this forum often so I thought it was valid to ask how would you solve this on a PLC.

A Siemens S7 or Control Logix would make this simple. I would choose a S7 if I have to choose a PLC because it programs in assembly language ( STL ) or ST.

When solving by hand I use the same technique except I use dots in the blank squares to keep track of what has been elimated. Not much fun anymore. Back to chess and freecell.

More later.
 

Similar Topics

Hello. I want to share with you a program that can help you, and sometimes solve a sudoku puzzle. It was started on it in my last days of...
Replies
4
Views
2,641
Back
Top Bottom