Darn I was looking through the manual for a mode function but didn't find one. I did think of one thing though. What if a row of the matrix is stored into a list, order the list from least to greatest, do [list][right][7] on it, and if any element of the list produced by the delta-list function is 0, then we know that number is illegal? Nah that probably won't work and if it did, it would take a long time.
i would like to see a sudoku maker and what if you made the puzzles ahaed of time with a program or by hand then randemly chose a puzzle to give them and include a puzzle maker to make more sets of lets say 5 puzzles
I'm pretty sure something like that has already been released on ticalc.org, but I'm not positive. Does that sound familiar to anyone?
KermMartian wrote:
There's actually a better way to do it if I remember correctly. I'd have to jfgi to find the algorithm though. I believe it works by placing a number, checking if it made the board illegal, then keep doing that until the board is full, and finally remove some of them and give it to the user. Then you have both the problem and the solution at the same time.


Lsat night (i saw a drive in moveie so i was dead tired) on the way home i made one, it almost works (and it uses that strategy, and eliminates having to do a loop to check horizontally because it uses a list) but i still have not gotten a full puzzle out of it... I left it on while i ate this morning and came back to an invalid ddim error... the y coordinate in the vertical check had somehow gotten to 10...

Oh well... i got about 6 rows out of it... and i am pretty sure it was ALL accurate, no repeats, even though it is REALLY SLOW (hey you have a pretty 'generating...' bar to inform you on the progress Wink ).

KermMartian wrote:

I'm pretty sure something like that has already been released on ticalc.org, but I'm not positive. Does that sound familiar to anyone?


It has been done, but it is either A. in ASM, or B. produces puzzles that are already messed up (multiple numbers in a row etc. see the earlier picture post to see what i mean)
Remember that the minimum number of clues needed to guarantee a unique puzzle is 17 but that puzzles with up to 79 clues can have more than one solution. Do you have a good method of guaranteeing uniqueness?
jpez wrote:
Remember that the minimum number of clues needed to guarantee a unique puzzle is 17 but that puzzles with up to 79 clues can have more than one solution. Do you have a good method of guaranteeing uniqueness?


lol... mine right now only generates a full puzzle...

I will upload the code as soon as i finish this...

Sigh... I just ran another test and i got another dim error... it was in the box check area... I think i fixed it though (i put another condition that B (used for the y variable during check) is less than 9 before it goes to the next line (and of course A (the temp x coordinate) has to = M (the end of the box coordinate)

and it did it one more time... this time A went over 9, i moved the A+1 (sto) A to the last part of the loop and i am trying again...

Once i get it to work i will post it...

(probably badly optimized... who can write good code at 11:50 p.m. ?
Run it through SC2 and post up the code - I'd like to see this.
KermMartian wrote:
Run it through SC2 and post up the code - I'd like to see this.


ok... *sigh* i am not sure it works anymore... it almost generated a full puzzle, but it had a few double numbers ofn the horizontal... I think i fixed that... but now it has been on for atlesat 10-15 minutes and is only about 60 percent done! It goes really fast at the beginning but like most programs that run checks for conditions, as the conditions become true more often (same number in square etc.) the program slows down to a crawl...

That is why i want to use VTI, i am pretty sure it has an option to run at the fastest speed the computer can handle

(i got the rom file and everything for tilem... but it still isn't working...)

OK! HERE IS THE SOURCE CODE! (and part of a puzzle that it made but i stopped because i got bored)

Code:

:1→Xmin
:95→Xmax
:1→XScl
:1→Ymin
:63→YMax
:1→YScl
:GridOff
:AxesOff
:ClrDraw
:1→F
:DelVar IDelVar T
:Line(17,38,79,38
:Line(17,27,79,27
:Line(17,38,17,27
:Line(79,38,79,27
:Text(17,15,"Generating puzzle...
:DelVar [A]DelVar IDelVar X
:9,9→dim([A]
:1→Y
:
:Lbl LO
:X+1→X
:If X=10
:Then
:1→X
:Y+1→Y
:End
:1,2,3,4,5,6,7,8,9→L1
:Lbl NU
:0→C
:randInt(1,9→N
:If N≠L1(N)
:Goto NU
:
:0→A
:Y→B
:While A<9 and not(C)
:A+1→A
:If [A](B,A)=N
:1→C
:End
:If C
:Goto NU
:
:
:X→A
:0→B
:While B≤8 and not(C)
:B+1→B
:If N=[A](B,A)
:1→C
:End
:If C
:Goto NU
:
:If X<4
:1→A
:If X>3 and X<7
:4→A
:If X>6
:7→A
:If Y<4
:1→B
:If Y>3 and Y<7
:4→B
:If Y>6
:7→B
:0→C
:0→D
:A+3→M
:While not(C) and D<9
:D+1→D
:If A=M and B<9
:Then
:B+1→B
:A-3→A
:End
:If [A](B,A)=N
:1→C
:A+1→A
:End
:If C
:Goto NU
:0→C
:N→[A](Y,X)
:0→L1(N)
:(X*Y)/81→I
:18+2F-2→W
:For(T,F,(I*100)/2
:Line(T+W,36,T+W,29
:If fPart(T/5)=0
:W+1→W
:End
:If Y*X<81
:Goto LO
:
:ClrDraw
:ClrHome
:Disp [A]



If you have any optimization tips (speed, not size) tell me (if it does nothing to speed but decreases size that works too)

i did not turn optimization on in source coder, either


OK the puzzle (about 6/10's done)

7 6 8 5 9 2 1 4 3

1 4 3 8 6 7 9 5 2

2 5 9 1 3 4 6 7 8

5 2 7 9 4 8 3 1 6

6 3 4 2 5 1 7 8 9

8 1 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0
did you download GTK+ and install it, and read the readme on where and how to name and place your ROM files
rivereye wrote:
did you download GTK+ and install it, and read the readme on where and how to name and place your ROM files


Oh... ok, also if you look now i uploaded a puzzle (that it was about 6/10's done creating) and the source code
Very nice. I see a ton of optimizations, but you've got the engine down fairly well!
Harq wrote:
That is why I want to use VTI, I am pretty sure it has an option to run at the fastest speed the computer can handle

(I got the rom file and everything for tilem... but it still isn't working...)

Both Tilem and PindurTI also have this feature to run as fast as the computer can handle.
KermMartian wrote:
Very nice. I see a ton of optimizations, but you've got the engine down fairly well!


*sigh* no.... i realized that it doesn't work...

You are lucky to get past the first 2 lines

(maybe i accidentally changed something but i am not sure)

it gets to the 9th number on the second line, but nothin works because (lets say line 2 needs the number 2) but the number 2 is also above it... so it goes on endlessly...

It could just be me though so could someone try it out?
Maybe remove the labels and see how it works without them?
something1990 wrote:
Maybe remove the labels and see how it works without them?


What exactly do you mean? i kinda have to have that otherwise it will come up with a totally random and unusable puzzle (of course it already does) I almost have to use the C variable to detect whether it is messed up or not...

The problem is i have no idea what is causing the issue...

actually i might have an idea but i am not sure how to phrase it...

Oh well here it is

the engine does not do any checks to see if it is inhibiting the correct formation of the next line (i could add and extra line onto the matrix so i do not get overloaded...)

I will try to get a system going after exams, but i am not sure i can


I have an example from the puzzle above too

OK the puzzle (about 6/10's done)

7 6 8 5 9 2 1 4 3

1 4 3 8 6 7 9 5 2

2 5 9 1 3 4 6 7 8

5 2 7 9 4 8 3 1 6 here

6 3 4 2 5 1 7 8 9

8 1 0 0 0 0 0 0 0 through here is a square of 9

0 0 0 0 0 0 0 0 0 the square needs a 9, but vertically, a nine is

0 0 0 0 0 0 0 0 0 already there... there has to be a way to run

0 0 0 0 0 0 0 0 0 checks on this...
Does anyone have an idea to make a working method of double checking to make sure?

I think there could be a way of checking so if it had failed more than 15 times, it goes through a list and if there are no possibilities 1-9, then it backtracks and tries regenerating the line (or maybe goes back about 3...

What i posted is a bare bones engine, and if it generates a full puzzle, its a miracle!

There has to be a method to check what has to be done on a line (on the 9th row in particular) since it has to have a specific line up based on the other lines)
I think this could be done quite easily...let me work on it a bit.
I think it can. I read an article about this in Scientific American recently. If I find a link I'll post it.
Basically all you need is:


Code:
Fill(0,[A]
For(A,1,9
For(B,1,9
0-->C  //C=correct
Repeat C
randInt(1,9-->[A](A,B
If [no repeats in column B except for zeros] and [no repeats in row A except for zeros]
1-->C
End  //repeat c
End  //for b
End  //for a
The problem is in guaranteed solvability, not just grid generation.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 3
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement