AC_PROG_CC
AM_PROG_CC_STDC
-AC_CONFIG_FILES([Makefile src/Makefile src/suexg/Makefile src/resources/Makefile src/classes/Makefile po/Makefile.in])
+AC_CONFIG_FILES([Makefile src/Makefile src/resources/Makefile src/classes/Makefile po/Makefile.in])
AC_CONFIG_COMMANDS([Version.java], [echo package: $pkgname version: $pkgversion], [pkgname=$PACKAGE_NAME, pkgversion=$PACKAGE_VERSION])
AC_OUTPUT
-SUBDIRS = suexg resources classes
+SUBDIRS = resources classes
bin_SCRIPTS = $(PACKAGE)
EXTRA_SCRIPTS = sudokuki
CLEANFILES = $(EXTRA_SCRIPTS)
-SUEXG_PROXY_JNI_DIR=$(top_builddir)/src/classes/net/jankenpoi/sudokuki/generator/suexg
-AM_CPPFLAGS = -I$(top_builddir)/tmpjar/net/jankenpoi/sudokuki/generator/suexg -Isuexg -DLOCALEDIR=\"$(localedir)\" -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -I$(JAVA_HOME)/include/win32
-
-lib_LTLIBRARIES = libsuexg_proxy.la
-
# gettext.h not needed in this project
-libsuexg_proxy_la_SOURCES = $(SUEXG_PROXY_JNI_DIR)/suexg_proxy.c suexg/gene_suexg_v12.c suexg/gene_suexg_v12.h gettext.h
-
# LIBINTL not needed in this project
-libsuexg_proxy_la_LDFLAGS = -shared -no-undefined $(LIBINTL)
net/jankenpoi/sudokuki/generator/SudokuGeneratorFactory.java \
net/jankenpoi/sudokuki/generator/SudokuGenerator.java \
net/jankenpoi/sudokuki/generator/suexg/SuexgGenerator.java \
-net/jankenpoi/sudokuki/generator/suexg/SuexgJava.java \
-net/jankenpoi/sudokuki/generator/suexg/SuexgProxy.java \
net/jankenpoi/sudokuki/model/GridChangedEvent.java \
net/jankenpoi/sudokuki/model/GridModel.java \
net/jankenpoi/sudokuki/model/Position.java \
JAVA_HOME=@JAVA_HOME@
JAVAC=@JAVAC@
-JAVAH=@JAVAH@
JAVA=@JAVA@
JAR=@JAR@
-$(jarfile): $(dist_noinst_JAVA) $(SUEXG_PROXY_JNI_INCLUDE) outputresources
+$(jarfile): $(dist_noinst_JAVA) outputresources
$(JAR) cmf $(MANIFEST) $(JARFLAGS) $@ -C $(top_builddir)/tmpjar .
include DIST_NOINST_JAVA.include
echo "" >> $(VERSION_FILE); \
echo "}" >> $(VERSION_FILE);
-CLEANFILES = $(jarfile) $(VERSION_FILE) $(MANIFEST) $(SUEXG_PROXY_JNI_INCLUDE) new_DIST_NOINST_JAVA.include
-
-SUEXG_PROXY_JNI_DIR=$(top_builddir)/src/classes/net/jankenpoi/sudokuki/suexg
-SUEXG_PROXY_JNI_CLASS=net.jankenpoi.sudokuki.generator.suexg.SuexgProxy
-SUEXG_PROXY_JNI_INCLUDE=$(top_builddir)/tmpjar/net/jankenpoi/sudokuki/generator/suexg/net_jankenpoi_sudokuki_generator_suexg_SuexgProxy.h
-$(SUEXG_PROXY_JNI_INCLUDE):
- $(JAVAH) -classpath $(JAVAROOT) -jni -o $(SUEXG_PROXY_JNI_INCLUDE) $(SUEXG_PROXY_JNI_CLASS)
-
+CLEANFILES = $(jarfile) $(VERSION_FILE) $(MANIFEST) new_DIST_NOINST_JAVA.include
package net.jankenpoi.sudokuki.generator;
-import net.jankenpoi.sudokuki.generator.suexg.SuexgGenerator;
import net.sourceforge.plantuml.sudoku.SuexgGenerator2;
public class SudokuGeneratorFactory {
public abstract class SuexgGenerator extends SudokuGenerator {
- private static final SudokuGenerator INSTANCE;
- static {
- if (SuexgProxy.getGenerator() != null) {
- INSTANCE = SuexgProxy.getGenerator();
- } else {
- INSTANCE = SuexgJava.getGenerator();
- }
- }
-
- public final static SudokuGenerator getInstance() {
- return INSTANCE;
+ public static SudokuGenerator getInstance() {
+ return null;
}
}
+++ /dev/null
-/*\r
- * Sudokuki - essential sudoku game\r
- * Copyright (C) 2007-2013 Sylvain Vedrenne\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package net.jankenpoi.sudokuki.generator.suexg;\r
-\r
-import java.util.Random;\r
-\r
-import net.jankenpoi.sudokuki.SudokuGrid;\r
-import net.jankenpoi.sudokuki.generator.SudokuGenerator;\r
-\r
-/*\r
- *****************************************************************************\r
- * This file results from Suexg's author initial work in the public domain *\r
- * and from Sudokuki's author. *\r
- * *\r
- * This is a GPLv3+ Java transposition of Suexg's original C source code. *\r
- * N.B: Instructions like 'goto label' are valid in C but not in Java, *\r
- * so I have transposed them using 'continue' inside a global while loop *\r
- * with boolean values and 'if' instructions to simulate the labels. *\r
- * And I replaced the B[] char table using the actual char values as int *\r
- *****************************************************************************\r
- * "Suexg version 12" is included in Sudokuki since version 0.0.12_gtkmm *\r
- * of Sudokuki. The two reasons why I chose Suexg in the first place are *\r
- * that it works and that it was public domain, so GPL compatible. *\r
- * **************************************************************************\r
- * The note below (between * ... *) is from Suexg's author: *\r
- * **************************************************************************\r
- * * suexg version 12, small randomized sudoku-generator in C. * *\r
- * * * *\r
- * * Generates about 24 sudokus per second with 1GHz CPU. * *\r
- * * Based on an exact cover solver, compiled with gcc3.2. Report bugs, * *\r
- * * improvement suggestions,feedback to sterten@aol.com. For some * *\r
- * * explanation of the solver see: http://magictour.free.fr/suexco.txt * *\r
- * * This generator starts from an empty grid and adds clues completely * *\r
- * * at random. There are faster pseudo-random methods which generate * *\r
- * * up to 1000 sudokus per second. [..] * *\r
- * * * *\r
- * * Send sudokus with rating more than 100000 to sterten@aol.com so they * *\r
- * * can be included in the list of hardest sudokus at * *\r
- * * http://magictour.free.fr/top94 [..] * *\r
- * * * *\r
- *****************************************************************************\r
- */\r
-class SuexgJava extends SuexgGenerator {\r
-\r
- private static long zr = 362436069;\r
- private static long wr = 521288629;\r
- private final static int[] A = new int[88];\r
- private final static int[] C = new int[88];\r
- private final static int[] I = new int[88];\r
- private final static int[] P = new int[88];\r
- private final static int[] V = new int[325];\r
- private final static int[] W = new int[325];\r
- private final static int[][] Col = new int[730][5];\r
- private final static int[][] Row = new int[325][10];\r
- private final static int[] Cols = new int[730];\r
- private final static int[] Rows = new int[325];\r
- private final static int[] Uc = new int[325];\r
- private final static int[] Ur = new int[730];\r
- private final static int[] Two = new int[888];\r
-\r
- private static int a;\r
- private static int c;\r
- private static int d;\r
- private static int f;\r
- private static int i;\r
- private static int j;\r
- private static int k;\r
- private static int l;\r
- private static int r;\r
- private static int n = 729;\r
- private static int m = 324;\r
- private static int s;\r
- private static int w;\r
- private static int x;\r
- private static int y;\r
-\r
- private static int c1;\r
- private static int c2;\r
- private static int i1;\r
- private static int m0;\r
- private static int m1;\r
- private static int m2;\r
- private static int r1;\r
- private static int s1;\r
-\r
- private static int clues;\r
- private static int min;\r
- private static int nodes;\r
- private static int nt;\r
- private static int rate;\r
- private static int sam1;\r
- private static int samples;\r
- // private static int seed;\r
- private static int solutions;\r
- private final static int[] B = new int[] { 48, 49, 49, 49, 50, 50, 50, 51,\r
- 51, 51, 49, 49, 49, 50, 50, 50, 51, 51, 51, 49, 49, 49, 50, 50, 50,\r
- 51, 51, 51, 52, 52, 52, 53, 53, 53, 54, 54, 54, 52, 52, 52, 53, 53,\r
- 53, 54, 54, 54, 52, 52, 52, 53, 53, 53, 54, 54, 54, 55, 55, 55, 56,\r
- 56, 56, 57, 57, 57, 55, 55, 55, 56, 56, 56, 57, 57, 57, 55, 55, 55,\r
- 56, 56, 56, 57, 57, 57 };\r
-\r
- private static int MWC() {\r
- final int result;\r
- zr = 36969 * (zr & 65535) + (zr >> 16);\r
- wr = 18000 * (wr & 65535) + (wr >> 16);\r
- result = (int) (zr ^ wr);\r
- return result;\r
- }\r
-\r
- @Override\r
- public synchronized SudokuGrid generateGrid(final int requestedRatingMin, final int requestedRatingMax) {\r
- Random rand = new Random(System.currentTimeMillis());\r
-\r
- int[] grid = new int[81];\r
- int[] gridAndClues = new int[81];\r
- int[] rating = new int[] { -1 };\r
- int seed = rand.nextInt();\r
- gridGenerate(seed, requestedRatingMin, requestedRatingMax, grid, rating, gridAndClues);\r
- //printGrid(grid);\r
- //printGrid(gridAndClues);\r
-\r
- SudokuGrid sudoku = new SudokuGrid(grid);\r
- return sudoku;\r
- }\r
-\r
-\r
- private int\r
- gridGenerate(final int seed, final int requestedRatingMin, final int requestedRatingMax, final int[] grid, final int[] rating,\r
- final int[] grid_with_clues) {\r
-\r
- /*\r
- * boolean values used to simulate the infamous goto used in the\r
- * original C suexg algorithm\r
- */\r
- boolean gotoM0S = true;\r
- boolean gotoMR1 = false, gotoMR3 = false, gotoM0 = false;\r
-\r
- zr ^= seed;\r
- wr += seed;\r
-\r
- samples = 1; // number of grids to generate (here only one grid is\r
- // generated)\r
- rate = 1; // if this value is not zero, the program will calculate the\r
- // rating (for each grid)\r
-\r
- for (i = 0; i < 888; i++) {\r
- j = 1;\r
- while (j <= i) {\r
- j += j;\r
- }\r
- Two[i] = j - 1;\r
- }\r
-\r
- r = 0;\r
- for (x = 1; x <= 9; x++) {\r
- for (y = 1; y <= 9; y++) {\r
- for (s = 1; s <= 9; s++) {\r
- r++;\r
- Cols[r] = 4;\r
- Col[r][1] = x * 9 - 9 + y;\r
- Col[r][2] = (B[x * 9 - 9 + y] - 48) * 9 - 9 + s + 81;\r
- Col[r][3] = x * 9 - 9 + s + 81 * 2;\r
- Col[r][4] = y * 9 - 9 + s + 81 * 3;\r
- }\r
- }\r
- }\r
- for (c = 1; c <= m; c++) {\r
- Rows[c] = 0;\r
- }\r
- for (r = 1; r <= n; r++) {\r
- for (c = 1; c <= Cols[r]; c++) {\r
- a = Col[r][c];\r
- Rows[a]++;\r
- Row[a][Rows[a]] = r;\r
- }\r
- }\r
-\r
- sam1 = 0;\r
-\r
- while (true) {\r
- // m0s:\r
- if (gotoM0S) {\r
- gotoM0S = false;\r
- sam1++;\r
- if (sam1 > samples) {\r
- return 0;\r
- } else {\r
- gotoM0 = true;\r
- }\r
- } // end of MOS if\r
-\r
- // m0:\r
- if (gotoM0) {\r
- gotoM0 = false;\r
- for (i = 1; i <= 81; i++) {\r
- A[i] = 0;\r
- }\r
- gotoMR1 = true;\r
- } // end of M0 if\r
-\r
- // mr1:\r
- if (gotoMR1) {\r
- gotoMR1 = false;\r
- i1 = (MWC() >> 8) & 127;\r
- if (i1 > 80) {\r
- gotoMR1 = true;\r
- continue; // these 2 instructions stand for: goto mr1;\r
- }\r
- i1++;\r
- if (A[i1] != 0) {\r
- gotoMR1 = true;\r
- continue; // these 2 instructions stand for: goto mr1;\r
- }\r
- gotoMR3 = true;\r
- }\r
-\r
- // mr3:\r
- if (gotoMR3) {\r
- gotoMR3 = false;\r
- s = (MWC() >> 9) & 15;\r
- if (s > 8) {\r
- gotoMR3 = true;\r
- continue; // these 2 instructions stand for: goto mr3;\r
- }\r
- s++;\r
- A[i1] = s;\r
- m2 = solve();\r
-\r
- // add a random clue and solve it. No solution ==> remove it\r
- // again.\r
- // Not yet a unique solution ==> continue adding clues\r
- if (m2 < 1) {\r
- A[i1] = 0;\r
- }\r
- if (m2 != 1) {\r
- gotoMR1 = true;\r
- continue; // these 2 instructions stand for: goto mr1;\r
- }\r
-\r
- if (solve() != 1) {\r
- gotoM0 = true;\r
- continue; // these 2 instructions stand for: goto m0;\r
- }\r
- // now we have a unique-solution sudoku. Now remove clues to\r
- // make it minimal\r
- {// EXPERIMENTAL: here is the grid with clues in it\r
- for (i = 1; i <= 81; i++) {\r
- grid_with_clues[i - 1] = A[i];\r
- }\r
- }\r
- for (i = 1; i <= 81; i++) {\r
-\r
- x = i;\r
- while (x >= i) {\r
- // mr4:\r
- x = (MWC() >> 8) & 127;\r
- }\r
- x++;\r
- P[i] = P[x];\r
- P[x] = i;\r
- }\r
- for (i1 = 1; i1 <= 81; i1++) {\r
- s1 = A[P[i1]];\r
- A[P[i1]] = 0;\r
- if (solve() > 1) {\r
- A[P[i1]] = s1;\r
- }\r
- }\r
-\r
- if (rate != 0) {\r
- nt = 0;\r
- for (f = 0; f < 100; f++) {\r
- solve();\r
- nt += nodes;\r
- }\r
- \r
- if (nt < requestedRatingMin|| requestedRatingMax < nt) {\r
- gotoM0 = true;\r
- continue;\r
- }\r
- rating[0] = nt;\r
- }\r
-\r
- {\r
-\r
- for (i = 1; i <= 81; i++) {\r
- grid[i - 1] = A[i];\r
- }\r
- }\r
- gotoM0S = true;\r
- continue; // these 2 instructions stand for: goto m0s;\r
- } // end of gotoMR3 if\r
-\r
- } // outer while loop\r
- }\r
-\r
- // -----------------------------------------------------------------------\r
- // -----------------------------------------------------------------------\r
-\r
- private static int solve() {// returns 0 (no solution), 1 (unique sol.), 2\r
- // (more\r
- // than one sol.)\r
-\r
- /*\r
- * boolean values used to simulate the infamous goto used in the\r
- * original C suexg algorithm\r
- */\r
- boolean gotoM2 = true, gotoM3 = false, gotoM4 = false, gotoMR = false;\r
-\r
- for (i = 0; i <= n; i++) {\r
- Ur[i] = 0;\r
- }\r
- for (i = 0; i <= m; i++) {\r
- Uc[i] = 0;\r
- }\r
- clues = 0;\r
- for (i = 1; i <= 81; i++) {\r
- if (A[i] != 0) {\r
- clues++;\r
- r = i * 9 - 9 + A[i];\r
- for (j = 1; j <= Cols[r]; j++) {\r
- d = Col[r][j];\r
- if (Uc[d] != 0) {\r
- return 0;\r
- }\r
- Uc[d]++;\r
- for (k = 1; k <= Rows[d]; k++) {\r
- Ur[Row[d][k]]++;\r
- }\r
- }\r
- }\r
- }\r
-\r
- for (c = 1; c <= m; c++) {\r
- V[c] = 0;\r
- for (r = 1; r <= Rows[c]; r++) {\r
- if (Ur[Row[c][r]] == 0) {\r
- V[c]++;\r
- }\r
- }\r
- }\r
-\r
- i = clues;\r
- m0 = 0;\r
- m1 = 0;\r
- solutions = 0;\r
- nodes = 0;\r
-\r
- whileloop: while (true) {\r
-\r
- // m2: //////////\r
- if (gotoM2) {\r
- gotoM2 = false;\r
-\r
- i++;\r
- I[i] = 0;\r
- min = n + 1;\r
-\r
- if (i > 81 || m0 != 0) {\r
- gotoM4 = true;\r
- continue; // simulates: goto m4;\r
- }\r
- if (m1 != 0) {\r
- C[i] = m1;\r
- gotoM3 = true;\r
- continue; // simulates: goto m3;\r
- }\r
-\r
- w = 0;\r
- for (c = 1; c <= m; c++) {\r
- if (Uc[c] == 0) {\r
- if (V[c] < 2) {\r
- C[i] = c;\r
- gotoM3 = true;\r
- continue whileloop; // simulates: goto m3;\r
- }\r
- if (V[c] <= min) {\r
- w++;\r
- W[w] = c;\r
- }\r
- \r
- if (V[c] < min) {\r
- w = 1;\r
- W[w] = c;\r
- min = V[c];\r
- }\r
- }\r
- }\r
- gotoMR = true;\r
- }\r
-\r
- // /mr:\r
- if (gotoMR) {\r
- gotoMR = false;\r
-\r
- c2 = (MWC() & Two[w]);\r
- if (c2 >= w) {\r
- gotoMR = true;\r
- continue; // simulates: goto mr;\r
- }\r
- C[i] = W[c2 + 1];\r
- gotoM3 = true;\r
- }\r
-\r
- // m3: //////\r
- if (gotoM3) {\r
- gotoM3 = false;\r
-\r
- c = C[i];\r
- I[i]++;\r
- if (I[i] > Rows[c]) {\r
- gotoM4 = true;\r
- continue; // simulates: goto m4;\r
- }\r
- r = Row[c][I[i]];\r
- if (Ur[r] != 0) {\r
- gotoM3 = true;\r
- continue; // simulates: goto m3;\r
- }\r
- m0 = 0;\r
- m1 = 0;\r
- nodes++;// if(nodes>9999 && part==0)return 0;\r
- for (j = 1; j <= Cols[r]; j++) {\r
- c1 = Col[r][j];\r
- Uc[c1]++;\r
- }\r
- for (j = 1; j <= Cols[r]; j++) {\r
- c1 = Col[r][j];\r
- for (k = 1; k <= Rows[c1]; k++) {\r
- r1 = Row[c1][k];\r
- Ur[r1]++;\r
- if (Ur[r1] == 1) {\r
- for (l = 1; l <= Cols[r1]; l++) {\r
- c2 = Col[r1][l];\r
- V[c2]--;\r
- if (Uc[c2] + V[c2] < 1) {\r
- m0 = c2;\r
- }\r
- if (Uc[c2] == 0 && V[c2] < 2) {\r
- m1 = c2;\r
- }\r
- }\r
- }\r
- }\r
- }\r
- if (i == 81) {\r
- solutions++;\r
- }\r
- if (solutions > 1) {\r
- break; // simulates: goto m9;\r
- }\r
- gotoM2 = true;\r
- continue; // simulates: goto m2;\r
- } // end of m3 if\r
-\r
- // m4: ////\r
- if (gotoM4) {\r
- gotoM4 = false;\r
-\r
- i--;\r
- c = C[i];\r
- r = Row[c][I[i]];\r
- if (i == clues) {\r
- break; // simulates: goto m9;\r
- }\r
- for (j = 1; j <= Cols[r]; j++) {\r
- c1 = Col[r][j];\r
- Uc[c1]--;\r
- for (k = 1; k <= Rows[c1]; k++) {\r
- r1 = Row[c1][k];\r
- Ur[r1]--;\r
- if (Ur[r1] == 0) {\r
- for (l = 1; l <= Cols[r1]; l++) {\r
- c2 = Col[r1][l];\r
- V[c2]++;\r
- }\r
- }\r
- }\r
- }\r
-\r
- if (i > clues) {\r
- gotoM3 = true;\r
- continue; // simulates: goto m3;\r
- }\r
- } // end of m4 if\r
-\r
- break;\r
- } // outer while loop\r
-\r
- // m9: /////\r
- return solutions;\r
- }\r
-\r
- private static final SuexgJava INSTANCE;\r
- static {\r
- INSTANCE = new SuexgJava();\r
- }\r
- \r
- public static SudokuGenerator getGenerator() {\r
- return INSTANCE;\r
- }\r
-\r
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Sudokuki - essential sudoku game
- * Copyright (C) 2007-2013 Sylvain Vedrenne
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package net.jankenpoi.sudokuki.generator.suexg;
-
-import java.util.Random;
-
-import net.jankenpoi.sudokuki.SudokuGrid;
-import net.jankenpoi.sudokuki.generator.SudokuGenerator;
-
-class SuexgProxy extends SuexgGenerator {
-
- private static final SuexgProxy INSTANCE;
- static {
- boolean exceptionCaught = false;
- try {
- System.loadLibrary("suexg_proxy");
- } catch (Throwable t) {
- exceptionCaught = true;
- } finally {
- if (exceptionCaught) {
- INSTANCE = null;
- } else {
- INSTANCE = new SuexgProxy();
- }
- }
- }
-
- public static SudokuGenerator getGenerator() {
- return INSTANCE;
- }
-
- private SuexgProxy() {
- }
-
- @Override
- public synchronized SudokuGrid generateGrid(int minRating, int maxRating) {
- Random rand = new Random(System.currentTimeMillis());
-
- int[] grid = new int[81];
- int[] gridAndClues = new int[81];
- int[] rating = new int[] { -1 };
- int seed = rand.nextInt();
- INSTANCE.generateSuexgGrid(seed, minRating, maxRating, grid, rating,
- gridAndClues);
- //printGrid(grid);
- //printGrid(gridAndClues);
-
- SudokuGrid sudoku = new SudokuGrid(grid);
- return sudoku;
- }
-
- private native int generateSuexgGrid(int inSeed, int minRating, int maxRating, int[] outGrid, int[] outRating,
- int[] outGridWithClues);
-
- private native int solveCustomGrid(int[] inGrid, int[] outGrid);
-
-}
+++ /dev/null
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class net_jankenpoi_sudokuki_generator_suexg_SuexgProxy */
-
-#ifndef _Included_net_jankenpoi_sudokuki_generator_suexg_SuexgProxy
-#define _Included_net_jankenpoi_sudokuki_generator_suexg_SuexgProxy
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * Class: net_jankenpoi_sudokuki_generator_suexg_SuexgProxy
- * Method: generateSuexgGrid
- * Signature: (III[I[I[I)I
- */
-JNIEXPORT jint JNICALL Java_net_jankenpoi_sudokuki_generator_suexg_SuexgProxy_generateSuexgGrid
- (JNIEnv *, jobject, jint, jint, jint, jintArray, jintArray, jintArray);
-
-/*
- * Class: net_jankenpoi_sudokuki_generator_suexg_SuexgProxy
- * Method: solveCustomGrid
- * Signature: ([I[I)I
- */
-JNIEXPORT jint JNICALL Java_net_jankenpoi_sudokuki_generator_suexg_SuexgProxy_solveCustomGrid
- (JNIEnv *, jobject, jintArray, jintArray);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
+++ /dev/null
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class net_jankenpoi_sudokuki_generator_suexg_SuexgProxy */
-
-#ifndef _Included_net_jankenpoi_sudokuki_generator_suexg_SuexgProxy
-#define _Included_net_jankenpoi_sudokuki_generator_suexg_SuexgProxy
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * Class: net_jankenpoi_sudokuki_generator_suexg_SuexgProxy
- * Method: generateSuexgGrid
- * Signature: (I[I[I[I)I
- */
-JNIEXPORT jint JNICALL Java_net_jankenpoi_sudokuki_generator_suexg_SuexgProxy_generateSuexgGrid
- (JNIEnv *, jobject, jint, jintArray, jintArray, jintArray);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
+++ /dev/null
-/*
- * Sudokuki - essential sudoku game
- * Copyright (C) 2007-2013 Sylvain Vedrenne
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-#include <stdlib.h>
-
-#include "suexg/gene_suexg_v12.h"
-
-#include "net_jankenpoi_sudokuki_generator_suexg_SuexgProxy.h"
-
-/*
- * Class: net_jankenpoi_sudokuki_generator_suexg_SuexgProxy
- * Method: generateSuexgGrid
- * Signature: (III[I[I[I)I
- */
-JNIEXPORT jint JNICALL Java_net_jankenpoi_sudokuki_generator_suexg_SuexgProxy_generateSuexgGrid
- (JNIEnv * env, jobject j_obj, jint seed, jint requestedRatingMin, jint requestedRatingMax, jintArray result_grid, jintArray result_rating, jintArray result_grid_and_clues)
-{
- //printf("\nBEGINNING OF PROXY NATIVE METHOD\n");
-
- jint* grid = malloc(81 * sizeof(int));
- jint* grid_and_clues = malloc(81 * sizeof(int));
-
- //printf("grid before call to suexg code:\n");
-
- //int i = 0;
- //for (i=0; i<81; i++) {
- // printf("%d", grid[i]);
- //}
-
- //printf("\n");
-
- jint rating = -2;
- grid_generate (seed, requestedRatingMin, requestedRatingMax, (int**)&grid, (int*)&rating, (int**)&grid_and_clues );
-
- //printf("after call to grid_generate - rating:%d\n", rating);
-
- //printf("grid:\n");
-
- //for (i=0; i<81; i++) {
- // printf("%d", grid[i]);
- //}
-
- //printf("\n");
-
- //printf("returning grid:0x%x\n", grid);
-
- (*env)->SetIntArrayRegion(env, result_grid, 0, 81, grid);
- (*env)->SetIntArrayRegion(env, result_rating, 0, 1, &rating);
- (*env)->SetIntArrayRegion(env, result_grid_and_clues, 0, 81, grid_and_clues);
-
- //printf("END OF PROXY NATIVE METHOD\n");
-
- return 0;
-}
+++ /dev/null
-noinst_lib_LIBRARIES = libto_ignore.a
-noinst_libdir = noinstlibdir
-libto_ignore_a_SOURCES = gene_suexg_v12.c gene_suexg_v12.h
+++ /dev/null
-////////////////////////////////////////////////////////////////////////////////
-// sudokuki - C++ graphical sudoku game //
-// Copyright (C) 2007-2009 Sylvain Vedrenne //
-// //
-// This program is free software; you can redistribute it and/or //
-// modify it under the terms of the GNU General Public License //
-// as published by the Free Software Foundation; either version 2 //
-// of the License, or (at your option) any later version. //
-// //
-// This program is distributed in the hope that it will be useful, //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
-// GNU General Public License for more details. //
-// //
-// You should have received a copy of the GNU General Public License along //
-// with this program; if not, write to the Free Software Foundation, Inc., //
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //
-////////////////////////////////////////////////////////////////////////////////
-// //
-// The source code below is the result of the initial work of Suexg's author //
-// -congratulations to him for making Suexg's source code public domain!- //
-// plus modifications by Sudokuki's author, for adaptation to Sudokuki. //
-// //
-// "Suexg" is a sudoku generator written in C. "Suexg version 12" is included //
-// in Sudokuki since version 0.0.12_gtkmm of Sudokuki. //
-// //
-////////////////////////////////////////////////////////////////////////////////
-// The note below (between /* ... */) is from Suexg's author: //
-/******************************************************************************/
-/* suexg version 12, small randomized sudoku-generator in C. */
-/* */
-/* Generates about 24 sudokus per second with 1GHz CPU. */
-/* Based on an exact cover solver, compiled with gcc3.2. Report bugs, */
-/* improvement suggestions,feedback to sterten@aol.com. For some */
-/* explanation of the solver see: http://magictour.free.fr/suexco.txt */
-/* This generator starts from an empty grid and adds clues completely */
-/* at random. There are faster pseudo-random methods which generate */
-/* up to 1000 sudokus per second. [..] */
-/* */
-/* Send sudokus with rating more than 100000 to sterten@aol.com so they */
-/* can be included in the list of hardest sudokus at */
-/* http://magictour.free.fr/top94 [..] */
-/* */
-/* This software is public domain. */
-/******************************************************************************/
-#include <stdlib.h>
-#include <stdio.h>
-
-#define MWC ((zr=36969*(zr&65535)+(zr>>16))^(wr=18000*(wr&65535)+(wr>>16)))
-
-unsigned zr = 362436069;
-unsigned wr = 521288629;
-int A[88];
-int C[88];
-int I[88];
-int P[88];
-int V[325];
-int W[325];
-int Col[730][5];
-int Row[325][10];
-int Cols[730];
-int Rows[325];
-int Uc[325];
-int Ur[730];
-int Two[888];
-
-int a;
-int c;
-int d;
-int f;
-int i;
-int j;
-int k;
-int l;
-int p;
-int r;
-int n = 729;
-int m = 324;
-int s;
-int w;
-int x;
-int y;
-
-int c1;
-int c2;
-int i1;
-int m0;
-int m1;
-int m2;
-int r1;
-int s1;
-
-int clues;
-int min;
-int nodes;
-int nt;
-int rate;
-int sam1;
-int samples;
-//int seed;
-int solutions;
-char B[83] = "0111222333111222333111222333444555666"
- "444555666444555666777888999777888999777888999";
-
-int solve();
-
-//------------------------------------------------------------
-#ifdef __cplusplus
-extern "C" {
-#endif
-int
-grid_generate ( int seed, int requestedRatingMin, int requestedRatingMax, int** grid, int* rating, int** grid_with_clues )
-{
-//printf("requestedRatingMin: %d\n", requestedRatingMin);
-//printf("requestedRatingMax: %d\n", requestedRatingMax);
-//int k=0;
-//for (k=0; k<1000; k++) {
-// //printf("MWC : %d\n", MWC);
-//}
-
-//int ii = 0;
-//for(ii = 0; ii<89; ii++) {
-// //printf("B[%d] = %d\n", ii, B[ii]);
-//}
-
- zr ^= seed;
- wr += seed;
-
- samples = 1; // number of grids to generate (here only one grid is generated)
- rate = 1; // if this value is not zero, the program will calculate the rating (for each grid)
-
- 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++;
-////printf("r : %d\n", r);
- Cols[r] = 4;
- Col[r][1] = x*9-9+y;
-////printf("Col[%d][1] : %d\n", r, Col[r][1]);
- Col[r][2] = (B[x*9-9+y]-48)*9-9+s+81;
-////printf("Col[%d][2] : %d\n", r, Col[r][2]);
- Col[r][3] = x*9-9+s+81*2;
-////printf("Col[%d][3] : %d\n", r, Col[r][4]);
- Col[r][4] = y*9-9+s+81*3;
-////printf("Col[%d][4] : %d\n", r, Col[r][4]);
- }
- }
- }
- for ( c=1; c<=m; c++ )
- {
- Rows[c] = 0;
- }
- for ( r=1; r<=n; r++ )
- {
-////printf("r : %d\n", r);
- for ( c=1; c<=Cols[r]; c++ )
- {
- a = Col[r][c];
-////printf("a : %d\n", a);
- Rows[a]++;
- Row[a][Rows[a]] = r;
- }
- }
-
- sam1 = 0;
-
- m0s:
-//printf("m0s\n");
- sam1++;
- if ( sam1 > samples )
- {
- ////printf(".\n");
- return 0;
- }
-
- m0:
-//printf("m0\n");
- for ( i=1; i<=81; i++ )
- {
- A[i] = 0;
- }
-
- mr1:
-//printf("mr1\n");
- i1 = (MWC>>8)&127;
- if ( i1 > 80 )
- {
- goto mr1;
- }
- i1++;
- if ( A[i1] )
- {
- goto mr1;
- }
-
- mr3:
-//printf("mr3\n");
- s = (MWC>>9)&15;
- if ( s>8 )
- {
- goto mr3;
- }
- s++;
- A[i1] = s;
- //printf("\nA[i1:%d] = s:%d\n", i1, s);
- m2 = solve();
-
- // add a random clue and solve it. No solution ==> remove it again.
- // Not yet a unique solution ==> continue adding clues
- if ( m2<1 )
- {
- A[i1] = 0;
- }
- if ( m2 != 1 )
- {
- goto mr1;
- }
-
- if ( solve() != 1 )
- {
- goto m0;
- }
- //now we have a unique-solution sudoku. Now remove clues to make it minimal
- {//EXPERIMENTAL: here is the grid with clues in it
-
- int* p_sol;
- p_sol = *grid_with_clues;
-
- for ( i=1; i<=81; i++ )
- {
- *p_sol = A[i];
- p_sol++;
- }
- }
- for ( i=1; i<=81; i++ )
- {
-
- mr4:
-//printf("mr4\n");
- 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]];
- A[P[i1]] = 0;
- if ( solve()>1 )
- {
- A[P[i1]] = s1;
- }
- }
-
- if ( rate )
- {
- nt=0;
- for ( f=0; f<100; f++ )
- {
- solve();
- nt += nodes;
- }
- ////printf ( "new grid, rating:%6i", nt );
- if (nt < requestedRatingMin || requestedRatingMax < nt) {
- goto m0;
- }
- *rating = nt;
- }
-
- {
-
- int* p_table;
- p_table = *grid;
-
- for ( i=1; i<=81; i++ )
- {
- *p_table = A[i];
- p_table++;
- }
- }
- goto m0s;
-}
-#ifdef __cplusplus
-}
-#endif
-
-//-----------------------------------------------------------------------
-//-----------------------------------------------------------------------
-int solve()
-{//returns 0 (no solution), 1 (unique sol.), 2 (more than one sol.)
-//printf("solve()...\n");
-
- 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] )
- {
- //printf("clues:%d", clues);
- clues++;
- r = i*9-9+A[i];
- for ( j=1; j<=Cols[r]; j++ )
- {
- d=Col[r][j];
- if ( Uc[d] )
- {
- 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;
-
- m2:
-//printf("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:
-//printf("MR ");
- c2 = MWC&Two[w];
- if ( c2 >= w )
- {
- goto mr;
- }
- C[i] = W[c2+1];
-
- m3:
-//printf("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;
- nodes++;//if(nodes>9999 && part==0)return 0;
- 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 )
- {
- goto m9;
- }
- goto m2;
-
- m4:
-//printf("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:
-//printf("\nsolve() => %d\n",solutions);
- return solutions;
-}
-//-----------------------------------------------------------------------
-// EOF
+++ /dev/null
-////////////////////////////////////////////////////////////////////////////////
-// sudokuki - C++ graphical sudoku game //
-// Copyright (C) 2007-2009 Sylvain Vedrenne //
-// //
-// This program is free software; you can redistribute it and/or //
-// modify it under the terms of the GNU General Public License //
-// as published by the Free Software Foundation; either version 2 //
-// of the License, or (at your option) any later version. //
-// //
-// This program is distributed in the hope that it will be useful, //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
-// GNU General Public License for more details. //
-// //
-// You should have received a copy of the GNU General Public License along //
-// with this program; if not, write to the Free Software Foundation, Inc., //
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //
-////////////////////////////////////////////////////////////////////////////////
-#ifndef GENERATOR_H_
-#define GENERATOR_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern int grid_generate ( int seed, int requestedRatingMin, int requestedRatingMax, int** grid, int* rating, int** grid_with_clues );
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*GENERATOR_H_*/