Sudoku Programmers Forum Index

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log inLog in          Games  Calendar

Log in to check your private messagesLog in to check your private messages   

short and fast sudoku-generator in C
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Setting sudoku
View previous topic :: View next topic  
Author Message
King Wonka

Joined: 14 Dec 2005
Posts: 26
:

Items
PostPosted: Mon Dec 19, 2005 3:31 am    Post subject: Reply with quote

Hmm...this won't compile under Miracle C. Off to find a free C compiler for testing...
Back to top
View user's profile Send private message
dukuso

Joined: 14 Jul 2005
Posts: 424
:
Location: germany

Items
PostPosted: Tue Dec 20, 2005 12:35 am    Post subject: Reply with quote

King Wonka wrote:
Hmm...this won't compile under Miracle C. Off to find a free C compiler for testing...


what error messages do you get ?
you can remove the initial G[] string and the timings
and maybe some other nonessential stuff
Back to top
View user's profile Send private message Send e-mail Visit poster's website
King Wonka

Joined: 14 Dec 2005
Posts: 26
:

Items
PostPosted: Wed Dec 21, 2005 5:34 am    Post subject: Reply with quote

* Just found page 2! hehe

I just downloaded Bloodshed and it won't compile either. Gonna mess around and remove non-essentials like you suggest.
Back to top
View user's profile Send private message
King Wonka

Joined: 14 Dec 2005
Posts: 26
:

Items
PostPosted: Wed Dec 21, 2005 5:39 am    Post subject: Reply with quote

Ok first off it flags Exit with:
Code:
27 `exit' undeclared (first use this function)
Back to top
View user's profile Send private message
Bo

Joined: 02 Sep 2005
Posts: 27
:

Items
PostPosted: Wed Dec 21, 2005 6:59 am    Post subject: Reply with quote

King Wonka wrote:
Ok first off it flags Exit with:
Code:
27 `exit' undeclared (first use this function)


Add:
Code:
#include <stdlib.h>

Bo
Back to top
View user's profile Send private message
dukuso

Joined: 14 Jul 2005
Posts: 424
:
Location: germany

Items
PostPosted: Wed Dec 21, 2005 8:15 am    Post subject: Reply with quote

thanks ,Bo.
What compiler do you use ?
I use GCC3.2 , djgpp so all my programs should run under plain
DOS or in a DOS-window under Windows.
It should also work under Linux with some few modifications,
but I don't know much about Linux.
Have you tried to compile it with Miracle or Bloodshed ?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Bo

Joined: 02 Sep 2005
Posts: 27
:

Items
PostPosted: Wed Dec 21, 2005 9:51 am    Post subject: Reply with quote

I am using the mingw port to Windows of gcc 3.4.2.
After removing the G array (gcc complains about non-terminating ")
and adding #include <stdlib.h>, the program (your latest given in
this thread) compiles.
But it does not run (e.g after giving command suexg 123 100).
I have not tried any other compiler.

Bo
Back to top
View user's profile Send private message
dukuso

Joined: 14 Jul 2005
Posts: 424
:
Location: germany

Items
PostPosted: Wed Dec 21, 2005 11:27 am    Post subject: Reply with quote

yes, sorry. There was a bug in that version. I edited it now.
Here is a more simple version without rating:
(also edited once)

Code:


#include <stdio.h>
#include <stdlib.h>
#define MWC ((zr=36969*(zr&65535)+(zr>>16))^(wr=18000*(wr&65535)+(wr>>16)))
unsigned zr=362436069, wr=521288629;
int Rows[325],Cols[730],Row[325][10],Col[730][5],Ur[730],Uc[325],V[325],W[325];
int P[88],A[88],A0[88],C[88],I[88],Two[888];
int b,w,f,s1,m0,c1,c2,r1,l,i1,m1,m2,a,p,i,j,k,r,c,d,n=729,m=324,x,y,s;
int mi1,mi2,q7,part,nt,nodes,seed,solutions,min,samples,sam1,clues;
char L[11]=".123456789";
FILE *file;
int solve();



int main(int argc,char*argv[]){
  if(argc<3){printf("\nusage:suexg random-seed z [file] \n\n");
       printf("     generates z locally minimal sudokus\n");
       printf("     use different numbers for seed to get different streams of sudokus\n");
       printf("     if file is given then for each puzzle in file z random minimal sudokus \n");
       printf("       are generated by deleting clues from the given puzzle\n");
       printf("     to redirect the sudokus to a file use e.g. : suexg 0 100 r >file\n");
       exit(1);}

  sscanf(argv[1],"%i",&seed);zr^=seed;wr+=seed;
  sscanf(argv[2],"%i",&samples);
  if(argc>3)if((file=fopen(argv[3],"rb"))==NULL)
                        {printf("\ncan't find file %s\n",argv[3]);exit(1);}

for(i=0;i<888;i++){j=1;while(j<=i)j+=j;Two[i]=j-1;}
for(i=1;i<=81;i++)A0[i]=0;

r=0;for(x=1;x<=9;x++)for(y=1;y<=9;y++)for(s=1;s<=9;s++){
r++;Cols[r]=4;k=3;
   Col[r][1]=x*9-9+y;
   Col[r][2]=(k*((x-1)/k)+(y-1)/3)*9+s+81*1;
   Col[r][3]=x*9-9+s+81*2;
   Col[r][4]=y*9-9+s+81*3;}
for(c=1;c<=m;c++)Rows[c]=0;
for(r=1;r<=n;r++)for(c=1;c<=Cols[r];c++){
a=Col[r][c];Rows[a]++;Row[a][Rows[a]]=r;}


m6:if(argc>3)
   for(i=1;i<=81;i++){
   m6a:A0[i]=fgetc(file)-48;if(feof(file))exit(8);
      if(A0[i]==-2)A0[i]=0;if(A0[i]<0 || A0[i]>9)goto m6a;}

    sam1=0;
m0s:sam1++;if(sam1>samples){if(argc>3)goto m6;exit(0);}

m0:for(i=1;i<=81;i++)A[i]=A0[i];part=0;if(argc<4)solve();

part++;
for(i=1;i<=81;i++){mr4:x=(MWC>>8)&127;if(x>=i)goto mr4;x++;P[i]=P[x];P[x]=i;}
for(i1=1;i1<=81;i1++){s1=A[P[i1]];if(s1){A[P[i1]]=0;if(solve()>1)A[P[i1]]=s1;}}
for(i=1;i<=81;i++)printf("%c",L[A[i]]);printf("\n");
goto m0s;}



int solve(){
   for(i=0;i<=n;i++)Ur[i]=0;for(i=0;i<=m;i++)Uc[i]=0;
   clues=0;for(i=1;i<=81;i++)
     if(A[i]){clues++;r=i*9-9+A[i];
       for(j=1;j<=Cols[r];j++){d=Col[r][j];if(Uc[d])return -1;Uc[d]++;
         for(k=1;k<=Rows[d];k++){Ur[Row[d][k]]++;}}}
   for(c=1;c<=m;c++){V[c]=0;for(r=1;r<=Rows[c];r++)if(Ur[Row[c][r]]==0)V[c]++;}
   i=clues;m0=0;m1=0;solutions=0;if(i==81)return 1;
m2:i++;I[i]=0;min=n+1;if(i>81 || m0)goto m4;
   if(m1){C[i]=m1;goto m3;}
   w=0;for(c=1;c<=m;c++)if(!Uc[c]) {  if(V[c]<2){C[i]=c;goto m3;}
          if(V[c]<=min){w++;W[w]=c;};
          if(V[c]<min){w=1;W[w]=c;min=V[c];} }
mr:c2=MWC&Two[w];if(c2>=w)goto mr;C[i]=W[c2+1];
m3:c=C[i];I[i]++;if(I[i]>Rows[c])goto m4;
   r=Row[c][I[i]];if(Ur[r])goto m3;m0=0;m1=0;
   if(part==0){j=9;k=81;x=(r-1)/k+1;y=((r-1)%k)/j+1;s=(r-1)%j+1;A[x*9-9+y]=s;P[x*9-9+y]=i;}
   for(j=1;j<=Cols[r];j++){c1=Col[r][j];Uc[c1]++;}
   for(j=1;j<=Cols[r];j++){c1=Col[r][j];
      for(k=1;k<=Rows[c1];k++){r1=Row[c1][k];Ur[r1]++;if(Ur[r1]==1)
         for(l=1;l<=Cols[r1];l++){c2=Col[r1][l];V[c2]--;
            if(Uc[c2]+V[c2]<1)m0=c2;if(Uc[c2]==0 && V[c2]<2)m1=c2;}}}
    if(i==81){solutions++;if(solutions>1)return 2;if(part==0)return 1;}
    goto m2;
m4:i--;c=C[i];r=Row[c][I[i]];if(i==clues)goto m9;
   for(j=1;j<=Cols[r];j++){c1=Col[r][j];Uc[c1]--;
      for(k=1;k<=Rows[c1];k++){r1=Row[c1][k];Ur[r1]--;
         if(Ur[r1]==0)for(l=1;l<=Cols[r1];l++){c2=Col[r1][l];V[c2]++;}}}
   if(i>clues)goto m3;
m9:return solutions;}




Last edited by dukuso on Wed Dec 21, 2005 11:56 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Bo

Joined: 02 Sep 2005
Posts: 27
:

Items
PostPosted: Wed Dec 21, 2005 11:37 am    Post subject: Reply with quote

The new version compiles and runs fine
with mingw gcc 3.4.2.

Bo
Back to top
View user's profile Send private message
dukuso

Joined: 14 Jul 2005
Posts: 424
:
Location: germany

Items
PostPosted: Wed Dec 28, 2005 3:07 pm    Post subject: Reply with quote

here is a Java-version by Rolf Sandberg.
He wants me to mention, that it's not being supported.



Code:



/*
 * Main.java
 *
 * Created on 27 december 2005, 00:29
 *
 *  Class dlx_generator
 *
 *  Based on suexg v14. For terms and information, please see
 *  suexg at http://magictour.free.fr/
 *
 *  Rolf Sandberg, December 2005
 */

package dlx;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;
import javax.swing.JFileChooser;

class dlx_generator {
    long zr = 362436069, wr = 521288629;
    long MWC() {
        return ((zr = 36969 *(zr & 65535) + (zr >> 16)) ^ ( wr = 18000 * (wr & 65535) + (wr >> 16)));
    }
   
    int Rows[]      = new int[325],
            Cols[]  = new int[730],
            Row[][] = new int[325][10],
            Col[][] = new int[730][5],
            Ur[]    = new int[730],
            Uc[]    = new int[325],
            V[]     = new int[325],
            W[]     = new int[325];
    int P[]         = new int[88],
            A[]     = new int[88],
            C[]     = new int[88],
            I[]     = new int[88],
            Two[]   = new int[888];
    char B[]= {'0',
            '1','1','1','2','2','2','3','3','3',
            '1','1','1','2','2','2','3','3','3',
            '1','1','1','2','2','2','3','3','3',
            '4','4','4','5','5','5','6','6','6',
            '4','4','4','5','5','5','6','6','6',
            '4','4','4','5','5','5','6','6','6',
            '7','7','7','8','8','8','9','9','9',
            '7','7','7','8','8','8','9','9','9',
            '7','7','7','8','8','8','9','9','9'
    };
    char H[][] = new char[326][7];
    long c2, w;
    int b, f, s1, m0, c1,
            r1, l, i1, m1, m2, a, p,
            i, j, k, r, c, d, n = 729,
            m = 324, x, y, s;
    int mi1, mi2, q7, part, nt, rate, nodes, seed,
            solutions, min, samples, sam1, clues;
    char L[]= {'.','1','2','3','4','5','6','7','8','9'};
   
    static final int M0S = 10;
    static final int M0  = 11;
    static final int MR1 = 12;
    static final int MR3 = 13;
    static final int MR4 = 14;
    static final int M2 = 15;
    static final int M3 = 16;
    static final int M4 = 17;
    static final int M9 = 18;
    static final int MR = 19;
    static final int END = 20;
   
    // Set to true to generate debug output
    boolean DBG = false;
   
    void dbg(String s) {
        if(DBG)
            System.out.println(s);
    }
   
    public dlx_generator() {
        dbg("In constructor");
        Date t = new Date();
        long start = t.getTime();
        // First arg: rand seed
        // Second arg: #samples, ignored if <= 0
        // Third arg: rating and hints, ignored if <= 0
        String s = generate(start, 1, 0);
        saveSudokuToFile(s);
       
        t = new Date();
        long end = t.getTime();
        System.out.println("Time: " + String.valueOf(end - start) + " milliseconds");
    }
   
    void saveSudokuToFile(String s) {
        FileOutputStream FO = null;
        byte[] buffer = new byte[s.length()+1];
        int i = 0;
       
        while (i < s.length()){
            buffer[i] = (byte) s.charAt(i);
            i++;
        }
       
        try {
            FO = new FileOutputStream("generated_sudoku.sdk");
            FO.write(buffer);
            FO.close();
        } catch (IOException IOE) {
            // Well, well, well....
            return;
        }
    }
   
   
   
    String generate(long Seed, int Samples, int Rate){
        int STATE = M0S;
        String result = new String();
       
        dbg("Entering generate");
       
        seed = (int)Seed;
        zr = zr ^ seed;
        wr = wr + seed;
       
        samples = 1000000000;
        if (Samples > 0)
            samples = Samples;
       
        // Set to 1 for rating, set to 2 for rating and hint
        rate = 0;
        if(Rate > 0)
            rate = Rate;
        if(rate > 2)
            rate = 2;
       
        for(i = 0; i < 888; i++) {
            j = 1;
            while(j <= i)
                j += j;
            Two[i] = j - 1;
        }
       
        r = 0;
        for(x = 1; x <= 9; x++) for(y = 1; y <= 9; y++) for(s = 1;s <= 9; s++) {
            r++;
            Cols[r] = 4;
            Col[r][1] = x * 9 - 9 + y;
            Col[r][2] = (B[x * 9 - 9 + y] - 48) * 9 - 9 + s + 81;
            Col[r][3] = x * 9 - 9 + s + 81 * 2;
            Col[r][4] = y * 9 - 9 + s + 81 * 3;
        }
       
        for(c = 1; c <= m; c++) Rows[c] = 0;
       
        for(r = 1; r <= n; r++) for(c = 1; c <= Cols[r]; c++) {
            a = Col[r][c];
            Rows[a]++;
            Row[a][Rows[a]] = r;
        }
       
        c = 0;
        for(x = 1; x <= 9; x++) for(y = 1; y <= 9; y++) {
            c++;
            H[c][0] = 'r';
            H[c][1] = L[x];
            H[c][2] = 'c';
            H[c][3] = L[y];
            H[c][4] = 0;
        }
       
        c = 81;
        for(b = 1; b <= 9; b++) for(s = 1; s <= 9; s++) {
            c++;
            H[c][0] = 'b';
            H[c][1] = L[b];
            H[c][2] = 's';
            H[c][3] = L[s];
            H[c][4] = 0;
        }
       
        c = 81 * 2;
        for(x = 1; x <= 9; x++) for(s = 1; s <= 9; s++) {
            c++;
            H[c][0] = 'r';
            H[c][1] = L[x];
            H[c][2] = 's';
            H[c][3] = L[s];
            H[c][4] = 0;
        }
       
        c = 81 * 3;
        for(y = 1; y <= 9; y++) for(s = 1; s <= 9; s++) {
            c++;
            H[c][0] = 'c';
            H[c][1] = L[y];
            H[c][2] = 's';
            H[c][3] = L[s];
            H[c][4] = 0;
        }
       
        dbg("Entering state machine");
       
        sam1 = 0;
        while(STATE != END) {
            switch (STATE) {
                case M0S:
                    dbg("Entering state M0S");
                    sam1++;
                    if(sam1 > samples) {
                        dbg("*** Finishing. New state: END");
                        STATE = END;
                        break;
                    }
                   
                case M0:
                    dbg("Entering state M0");
                    for(i = 1; i <= 81; i++) A[i] = 0;
                    part = 0;
                    q7 = 0;
                   
                case MR1:
                    dbg("Entering state MR1");
                    i1 = (int)((MWC()>>8)&127);
                    if(i1 > 80) {
                        dbg("New state: MR1");
                        STATE = MR1;
                        break;
                    }
                   
                    i1++;
                    if(A[i1] > 0) {
                        dbg("New state: MR1");
                        STATE = MR1;
                        break;
                    }
                   
                case MR3:
                    dbg("Entering state MR3");
                    s = (int)((MWC()>>9)&15);
                    if(s > 8) {
                        dbg("New state: MR3");
                        STATE = MR3;
                        break;
                    }
                   
                    s++;
                    A[i1] = s;
                    m2 = solve();
                    q7++;
                   
                    if(m2 < 1)
                        A[i1] = 0;
                   
                    if(m2 != 1){
                        dbg("New state: MR1");
                        STATE = MR1;
                        break;
                    }
                   
                    part++;
                    dbg("####### Generated Sudoku in MR3!");
                    if(solve() != 1) {
                        dbg("Solve returned again, but no single solution");
                        dbg("New state: M0");
                        STATE = M0;
                        break;
                    }
                   
                case MR4:
                    dbg("Entering state MR4");
                    for(i = 1; i <= 81; i++){
                        x = (int)((MWC()>>8)&127);
                        while(x >= i) {
                            x = (int)((MWC()>>8)&127);
                            dbg("##### MR4, while x >= i x: " + x + ", i: " + i);
                        }
                        x++;
                        P[i] = P[x];
                        P[x]=i;
                    }
                   
                    for(i1 = 1; i1 <= 81; i1++){
                        s1 = A[P[i1]];
                        A[P[i1]] = 0;
                        if(solve() > 1) A[P[i1]] = s1;
                    }
                   
                    if(rate > 0){
                        nt = 0;
                        mi1 = 9999;
                        for(f = 0; f < 100; f++){
                            solve();
                            nt += nodes;
                            if(nodes < mi1) {
                                mi1 = nodes;
                                mi2 = C[clues];
                            }
                        }
                        result = result.concat("Rating: " + nt + " # ");
                        if(rate > 1) {
                            result = result.concat("hint: " + String.valueOf(H[mi2]).substring(0, 4) + " #\n");
                        } else
                            result = result.concat("\n");
                    }
                   
                    for(i = 1; i <= 81; i++) {
                        result = result.concat(String.valueOf(L[A[i]]));
                        if(i%9 == 0) {
                            result = result.concat("\n");
                        }
                    }
                    result = result.concat("\n");
                   
                default:
                    dbg("Default case. New state M0S");
                    STATE = M0S;
                    break;
            } // end of switch statement
        } // end of while loop
        return result;
    }
   
   
//-----------------------------------------------------------------------
    int solve(){//returns 0 (no solution), 1 (unique sol.), 2 (more than one sol.)
        int STATE = M2;
       
        for(i = 0; i <= n; i++) Ur[i] = 0;
        for(i = 0; i <= m; i++) Uc[i] = 0;
        clues = 0;
       
        for(i = 1; i <= 81; i++) if(A[i] > 0){
            clues++;
            r = i * 9 - 9 + A[i];
           
            for(j = 1; j <= Cols[r]; j++){
                d = Col[r][j];
                if(Uc[d] > 0) return 0;
                Uc[d]++;
               
                for(k = 1; k <= Rows[d]; k++){
                    Ur[Row[d][k]]++;
                }
            }
        }
       
        for(c = 1; c <= m; c++) {
            V[c] = 0;
            for(r = 1; r <= Rows[c]; r++) if(Ur[Row[c][r]] == 0)
                V[c]++;
        }
       
        i = clues;
        m0 = 0;
        m1 = 0;
        solutions = 0;
        nodes = 0;
       
        dbg("Solve: Entering state machine");
       
        while(STATE != END) {
            switch(STATE) {
                case M2:
                    dbg("Entering state M2");
                    i++;
                    I[i] = 0;
                    min = n+1;
                    if((i > 81) || (m0 > 0)){
                        dbg("New state: M4");
                        STATE = M4;
                        break;
                    }
                   
                    if(m1 > 0){
                        dbg("New state: M3");
                        C[i] = m1;
                        STATE = M3;
                        break;
                    }
                   
                    w = 0;
                    for(c = 1; c <= m; c++) if(Uc[c] <= 0){
                        if(V[c] < 2){
                            C[i] = c;
                            STATE = M3;
                            break;
                        }
                       
                        if(V[c] <= min){
                            w++;
                            W[(int)w] = c;
                        }
                        ;
                       
                        if(V[c] < min){
                            w = 1;
                            W[(int)w] = c;
                            min = V[c];
                        }
                    }
                   
                    if(STATE == M3) {
                        dbg("***** break in for loop detected");
                        break;
                    }
                   
                case MR:
                    dbg("Entering state MR");
                    c2 = (MWC()&Two[(int)w]);
                    while (c2 >= w){
                        dbg("In MR c2: " + c2 + ", w: " + w);
                        c2 = (MWC()&Two[(int)w]);
                    }
                    C[i] = W[(int)c2 + 1];
                   
                case M3:
                    dbg("Entering state M3");
                    c = C[i];
                    I[i]++;
                    if(I[i] > Rows[c]){
                        dbg("New state: M4");
                        STATE = M4;
                        break;
                    }
                   
                    r = Row[c][I[i]];
                    if(Ur[r] > 0){
                        dbg("New state: M3");
                        STATE = M3;
                        break;
                    }
                    m0 = 0;
                    m1 = 0;
                    nodes++;
                    for(j = 1; j <= Cols[r]; j++){
                        c1 = Col[r][j];
                        Uc[c1]++;
                    }
                   
                    for(j = 1; j <= Cols[r]; j++){
                        c1 = Col[r][j];
                        for(k = 1; k <= Rows[c1]; k++){
                            r1 = Row[c1][k];
                            Ur[r1]++;
                            if(Ur[r1] == 1) for(l = 1; l <= Cols[r1]; l++){
                                c2 = Col[r1][l];
                                V[(int)c2]--;
                                if(Uc[(int)c2] + V[(int)c2] < 1)
                                    m0 = (int)c2;
                                if(Uc[(int)c2] == 0 && V[(int)c2] < 2)
                                    m1 = (int)c2;
                            }
                        }
                    }
                   
                    if(i == 81)
                        solutions++;
                    if(solutions > 1) {
                        dbg("After solutions: New state: M9");
                        STATE = M9;
                        break;
                    }
                    dbg("New state: M2");
                    STATE = M2;
                    break;
                   
                case M4:
                    dbg("Entering state M4");
                    i--;
                    c = C[i];
                    r = Row[c][I[i]];
                    if(i == clues) {
                        dbg("After clues: New state: M9");
                        STATE = M9;
                        break;
                    }
                   
                    for(j = 1; j <= Cols[r]; j++){
                        c1 = Col[r][j];
                        Uc[c1]--;
                        for(k = 1; k <= Rows[c1]; k++){
                            r1 = Row[c1][k];
                            Ur[r1]--;
                            if(Ur[r1] == 0) for(l = 1; l <= Cols[r1]; l++){
                                c2 = Col[r1][l];
                                V[(int)c2]++;
                            }
                        }
                    }
                   
                    if(i > clues) {
                        dbg("New state: M3");
                        STATE = M3;
                        break;
                    }
                   
                case M9:
                    dbg("*** Entering state M9 solutions: " + solutions);
                    STATE = END;
                    break;
                default:
                    dbg("*** Fell into default clause, solutions: " + solutions);
                    STATE = END;
                    break;
            } // end of switch statement
        } // end of while statement
        dbg("****returning solutions: " + solutions);
        return solutions;
    }
}


/**
 *
 * @author Rolf Sandberg
 */
public class Main {
   
    /** Creates a new instance of Main */
    public Main() {
    }
   
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        dlx_generator d = new dlx_generator();
    }
   
}

Back to top
View user's profile Send private message Send e-mail Visit poster's website
eclark

Joined: 28 Dec 2005
Posts: 70
:

Items
PostPosted: Thu Dec 29, 2005 12:49 am    Post subject: Reply with quote

dukuso wrote:
here is a Java-version by Rolf Sandberg.
He wants me to mention, that it's not being supported.


Wow thanks for that I'll look at it as java is what I am using for my language right now.

Maybe I can look at putting a true random number generator in it rather then MWC.

One quick question Is this under the BSD too?
Back to top
View user's profile Send private message
dukuso

Joined: 14 Jul 2005
Posts: 424
:
Location: germany

Items
PostPosted: Thu Dec 29, 2005 3:40 am    Post subject: Reply with quote

yes, you can replace it with another random generator.
I'm not so happy with MWC either. I don't know about the
period, given the initialization, just that it seems to work in practice.
If you implement another one, I'd maybe like to replace MWC by it.

what's BSD ?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
eclark

Joined: 28 Dec 2005
Posts: 70
:

Items
PostPosted: Thu Dec 29, 2005 6:37 am    Post subject: Reply with quote

dukuso wrote:
yes, you can replace it with another random generator.
I'm not so happy with MWC either. I don't know about the
period, given the initialization, just that it seems to work in practice.
If you implement another one, I'd maybe like to replace MWC by it.

what's BSD ?


BSD is the license
Basically it puts it out there for people to use and change freely. For some reason I was under the impression that was what it was.
http://www.opensource.org/licenses/bsd-license.php
Doesn't really matter.

Anyway I am working on that and starting my gui tonight. Thanks
Back to top
View user's profile Send private message
eclark

Joined: 28 Dec 2005
Posts: 70
:

Items
PostPosted: Thu Dec 29, 2005 8:00 am    Post subject: Reply with quote

Can you explain to me why A is 88 rather than 81 ? and where the result is stored after a single solution is found.

I'm currently reading the wkikipedia article to see if I can get the idea of what the code is doing.

But on a good note I did find a supposedly very good psuedorandom number generator. http://www.honeylocust.com/RngPack/

It does solow things down since it has a multiply needed , but other than that it seems to work well.
Back to top
View user's profile Send private message
dukuso

Joined: 14 Jul 2005
Posts: 424
:
Location: germany

Items
PostPosted: Fri Dec 30, 2005 2:39 pm    Post subject: Reply with quote

eclark wrote:
Can you explain to me why A is 88 rather than 81 ? and where the result is stored after a single solution is found.

I'm currently reading the wkikipedia article to see if I can get the idea of what the code is doing.

But on a good note I did find a supposedly very good psuedorandom number generator. http://www.honeylocust.com/RngPack/

It does solow things down since it has a multiply needed , but other than that it seems to work well.



88 is quicker to type than 82 (81 is not enough, though), that's all
storing the result - Rolf Sandberg asked the same thing and sent his new version. I assume it should solve that problem.
The random generator - well, as soon as its fast and noone complains
I keep it. I 'll keep that link in mind.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Setting sudoku All times are GMT
Goto page Previous  1, 2, 3, 4  Next
Page 2 of 4

 
Jump to:  
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
Sudoku Programmers topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group

Igloo Theme Version 1.0 :: Created By: Andrew Charron