introduce bitloops
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
package puzzle;
|
||||
|
||||
/**
|
||||
* Generated constants from pom.xml during build via templating-maven-plugin.
|
||||
*/
|
||||
public final class Config {
|
||||
public static final int CLUE_SIZE = 4;
|
||||
public static final int MIN_LEN = 2;
|
||||
public static final int MAX_TRIES_PER_SLOT = 1000;
|
||||
public static final int MAX_LEN = 8;
|
||||
public static final int PUZZLE_ROWS = 8;
|
||||
public static final int PUZZLE_COLS = 9;
|
||||
public static final int PUZZLE_SIZE = PUZZLE_ROWS*PUZZLE_COLS;
|
||||
public static final int MAX_WORD_LENGTH = PUZZLE_ROWS;
|
||||
public static final int MAX_WORD_LENGTH_MIN_1 = PUZZLE_ROWS-1;
|
||||
}
|
||||
@@ -32,18 +32,18 @@ public record SwedishGenerator() {
|
||||
public static final int BAR_LEN = 22;
|
||||
public static final int C = Config.PUZZLE_COLS;
|
||||
public static final int R = Config.PUZZLE_ROWS;
|
||||
public static final int SIZE = C * R;// ~18
|
||||
public static final int SIZE = Neighbors9x8.SIZE;// ~18
|
||||
public static final int SIZE_MIN_1 = SIZE - 1;// ~18
|
||||
public static final double SIZED = (double) SIZE;// ~18
|
||||
public static final long MASK_LO = -1L;
|
||||
public static final long MASK_HI = (1L << (SIZE - 64)) - 1;
|
||||
public static final long MASK_HI = Neighbors9x8.MASK_HI;//(1L << (SIZE - 64)) - 1;
|
||||
public static final int MAX_WORD_LENGTH = Config.PUZZLE_ROWS;
|
||||
public static final int MAX_WORD_LENGTH_PLUS_ONE = MAX_WORD_LENGTH + 1;
|
||||
public static final int MIN_LEN = 3;//Config.MIN_LEN;
|
||||
public static final int MIN_LEN = 2;//Neighbors9x8.MIN_LEN;//Config.MIN_LEN;
|
||||
public static final int MAX_TRIES_PER_SLOT = 700;//Config.MAX_TRIES_PER_SLOT;
|
||||
public static final int STACK_SIZE = 128;
|
||||
public static final long RANGE_0_SIZE = (long) SIZE_MIN_1 - 0L + 1L;
|
||||
public static final long RANGE_0_624 = 624L - 0L + 1L;
|
||||
public static final long RANGE_0_SIZE = Neighbors9x8.RANGE_0_SIZE;// (long) SIZE_MIN_1 - 0L + 1L
|
||||
public static final long RANGE_0_624 = Neighbors9x8.RANGE_0_624;//624L - 0L + 1L;
|
||||
static final int PICK_NOT_DONE = -1;
|
||||
static final int PICK_DONE = 0;
|
||||
public static boolean isLo(int n) { return (n & 64) == 0; }
|
||||
@@ -65,9 +65,8 @@ public record SwedishGenerator() {
|
||||
public static record DictEntry(long[] words, long[][] posBitsets, int length, int numlong) { }
|
||||
//@formatter:on
|
||||
|
||||
public static final long[] OFFSETS_D_IDX = Neighbors9x8.OFFSETS_D_IDX;
|
||||
public static final long[] PATH_LO = Neighbors9x8.PATH_LO;
|
||||
public static final long[] PATH_HI = Neighbors9x8.PATH_HI;
|
||||
public static final long[] PATH_LO = Neighbors9x8.PATH_LO;
|
||||
public static final long[] PATH_HI = Neighbors9x8.PATH_HI;
|
||||
|
||||
public static final class Rng {
|
||||
|
||||
@@ -85,13 +84,10 @@ public record SwedishGenerator() {
|
||||
x = y;
|
||||
return y;
|
||||
}
|
||||
public byte randint2bitByte() {
|
||||
int r = nextU32() & 7;
|
||||
if (r == 4) return (byte) 4;
|
||||
return (byte) (r & 3);
|
||||
}
|
||||
static final byte[] BYTE = new byte[]{ 0, 1, 2, 3/*,4, 5*/ };
|
||||
public byte randomClueDir() { return rand(BYTE); }
|
||||
public <T> T rand(T[] p) { return p[(int) (((nextU32() & 0xFFFFFFFFL) % ((long) p.length)))]; }
|
||||
public int randint(int max) { return (int) (((nextU32() & 0xFFFFFFFFL) % ((long) max))); }
|
||||
public byte rand(byte[] p) { return p[(int) (((nextU32() & 0xFFFFFFFFL) % ((long) p.length)))]; }
|
||||
public int randint0_SIZE() { return (int) (((nextU32() & 0xFFFFFFFFL) % RANGE_0_SIZE)); }
|
||||
public int randint0_624() { return (int) (((nextU32() & 0xFFFFFFFFL) % RANGE_0_624)); }
|
||||
public double nextFloat() { return (nextU32() & 0xFFFFFFFFL) / 4294967295.0; }
|
||||
@@ -124,7 +120,7 @@ public record SwedishGenerator() {
|
||||
static int unpackLetters(long w) { return (int) (w & LETTER_MASK); }
|
||||
}
|
||||
|
||||
public static record Slotinfo(int key, long lo, long hi, int score, Assign assign, DictEntry entry) {
|
||||
public static record Slotinfo(int key, long lo, long hi, int score, Assign assign, DictEntry entry, int minL) {
|
||||
|
||||
public static int wordCount(int k, Slotinfo[] arr) {
|
||||
for (var n = 1; n < arr.length; n++) if (arr[n].assign.w != X) k++;
|
||||
@@ -322,8 +318,7 @@ public record SwedishGenerator() {
|
||||
|
||||
var N = words.length;
|
||||
|
||||
var tries = Math.min(MAX_TRIES_PER_SLOT, N);
|
||||
for (var t = 0; t < tries; t++) {
|
||||
for (var t = 0; t < s.minL; t++) {
|
||||
var w = words[rng.biasedIndexPow3(N - 1)];
|
||||
var lemIdx = Lemma.unpackIndex(w);
|
||||
if (Bit1029.get(used, lemIdx)) continue;
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
package puzzle;
|
||||
|
||||
import gen.GenerateNeighbors;
|
||||
@GenerateNeighbors(C = 9, R = 8, packageName = "precomp", className = "Neighbors9x8")
|
||||
@GenerateNeighbors(C = 9, R = 8, packageName = "precomp", className = "Neighbors9x8", MIN_LEN = 3)
|
||||
public final class Trigger { }
|
||||
|
||||
Reference in New Issue
Block a user