introduce bitloops
This commit is contained in:
@@ -3,216 +3,216 @@ package puzzle;
|
||||
public final class DictDataL2W0 {
|
||||
private DictDataL2W0() {}
|
||||
public static final long[] DATA = new long[] {
|
||||
0x300000001c5L,
|
||||
0x40000000245L,
|
||||
0x500000000b4L,
|
||||
0x600000000a4L,
|
||||
0xa0000000169L,
|
||||
0xb00000000b7L,
|
||||
0xe00000000baL,
|
||||
0x12000000020fL,
|
||||
0x1600000000aaL,
|
||||
0xbb000000002eL,
|
||||
0xbc00000001c9L,
|
||||
0xc00000000181L,
|
||||
0xc20000000269L,
|
||||
0xc300000000adL,
|
||||
0xc500000000a8L,
|
||||
0xc700000002aeL,
|
||||
0xcc0000000027L,
|
||||
0xde00000001afL,
|
||||
0xdf00000000c1L,
|
||||
0xef00000000a9L,
|
||||
0x10600000000cfL,
|
||||
0x10a00000001faL,
|
||||
0x112000000002aL,
|
||||
0x11d00000002f5L,
|
||||
0xa7e0000000261L,
|
||||
0xa84000000002cL,
|
||||
0xa8d000000002dL,
|
||||
0xa960000000101L,
|
||||
0xaa00000000030L,
|
||||
0xab3000000016fL,
|
||||
0xae7000000010fL,
|
||||
0xafb0000000125L,
|
||||
0xb7e0000000115L,
|
||||
0xc690000000244L,
|
||||
0xd28000000026cL,
|
||||
0xd35000000024dL,
|
||||
0xf1600000002d4L,
|
||||
0x3f8d00000001c1L,
|
||||
0x3f9000000000b2L,
|
||||
0x3f910000000241L,
|
||||
0x3f920000000265L,
|
||||
0x3f930000000285L,
|
||||
0x3f940000000032L,
|
||||
0x3f9600000000b3L,
|
||||
0x3f970000000281L,
|
||||
0x3f980000000085L,
|
||||
0x3f990000000185L,
|
||||
0x3f9d00000001eeL,
|
||||
0x3f9e0000000033L,
|
||||
0x3f9f0000000081L,
|
||||
0x3fa400000001a5L,
|
||||
0x3fa70000000289L,
|
||||
0x3fad0000000133L,
|
||||
0x3fb200000001a1L,
|
||||
0x3fb50000000124L,
|
||||
0x3fb70000000105L,
|
||||
0x3fb900000000a7L,
|
||||
0x3fba0000000089L,
|
||||
0x3fbb000000002bL,
|
||||
0x3fbd000000012cL,
|
||||
0x3fc1000000026fL,
|
||||
0x3fd100000001e4L,
|
||||
0x3fd20000000045L,
|
||||
0x3fd60000000028L,
|
||||
0x3fdb00000001ecL,
|
||||
0x3fdc000000012dL,
|
||||
0x3ff20000000036L,
|
||||
0x3ff50000000041L,
|
||||
0x40070000000128L,
|
||||
0x400e00000001ebL,
|
||||
0x401b00000001edL,
|
||||
0x40220000000130L,
|
||||
0x40390000000122L,
|
||||
0x403a0000000023L,
|
||||
0x403f00000002a4L,
|
||||
0x40450000000026L,
|
||||
0x404900000001e7L,
|
||||
0x404c00000001e8L,
|
||||
0x406a00000001f0L,
|
||||
0x408e0000000021L,
|
||||
0x409f00000001e2L,
|
||||
0x40b30000000126L,
|
||||
0x410b00000001b5L,
|
||||
0x410f00000001f7L,
|
||||
0x41160000000121L,
|
||||
0x412600000001e3L,
|
||||
0x416700000000afL,
|
||||
0x419e0000000215L,
|
||||
0x41a300000002b6L,
|
||||
0x42ab0000000149L,
|
||||
0x434d00000002a1L,
|
||||
0x439f00000001eaL,
|
||||
0x43bd00000001cdL,
|
||||
0x44020000000293L,
|
||||
0x453e0000000135L,
|
||||
0x45bc0000000305L,
|
||||
0x46590000000250L,
|
||||
0x467e00000001b3L,
|
||||
0x48750000000276L,
|
||||
0x49bb00000001adL,
|
||||
0x4afa0000000283L,
|
||||
0x4b6f00000001a8L,
|
||||
0x4d620000000083L,
|
||||
0x4fff0000000102L,
|
||||
0x501800000001a3L,
|
||||
0x50ce000000024aL,
|
||||
0x534400000002c3L,
|
||||
0x593f0000000077L,
|
||||
0x60c30000000322L,
|
||||
0x96e80000000165L,
|
||||
0x96ea00000000e5L,
|
||||
0x96eb0000000205L,
|
||||
0x96ef000000028fL,
|
||||
0x96f000000000b0L,
|
||||
0x96f200000000b6L,
|
||||
0x96f400000002c1L,
|
||||
0x96f6000000012bL,
|
||||
0x96fa000000008fL,
|
||||
0x97040000000209L,
|
||||
0x970f0000000295L,
|
||||
0x97120000000061L,
|
||||
0x97150000000341L,
|
||||
0x971e00000002cfL,
|
||||
0x9724000000003aL,
|
||||
0x972f0000000069L,
|
||||
0x973500000002adL,
|
||||
0x973b0000000175L,
|
||||
0x973d000000013aL,
|
||||
0x974600000001e5L,
|
||||
0x974900000002a8L,
|
||||
0x974a0000000029L,
|
||||
0x9750000000024eL,
|
||||
0x975700000002d5L,
|
||||
0x9778000000002fL,
|
||||
0x977e0000000055L,
|
||||
0x978900000002a5L,
|
||||
0x979200000001e9L,
|
||||
0x979d000000018eL,
|
||||
0x979e000000012fL,
|
||||
0x97a50000000253L,
|
||||
0x97ab0000000075L,
|
||||
0x97ac00000000b5L,
|
||||
0x97e900000002ceL,
|
||||
0x97f20000000093L,
|
||||
0x97f50000000194L,
|
||||
0x980a0000000248L,
|
||||
0x980b00000002aaL,
|
||||
0x9812000000026dL,
|
||||
0x98180000000174L,
|
||||
0x981b0000000256L,
|
||||
0x982e00000001a4L,
|
||||
0x98490000000270L,
|
||||
0x984e0000000114L,
|
||||
0x9877000000020cL,
|
||||
0x98860000000131L,
|
||||
0x988b0000000054L,
|
||||
0x98920000000138L,
|
||||
0x989a0000000082L,
|
||||
0x989f0000000182L,
|
||||
0x98a20000000263L,
|
||||
0x98ad00000001a7L,
|
||||
0x98bc000000020dL,
|
||||
0x98c40000000170L,
|
||||
0x98ca0000000073L,
|
||||
0x98de0000000064L,
|
||||
0x98fa000000006cL,
|
||||
0x98fb00000000ccL,
|
||||
0x99060000000110L,
|
||||
0x99190000000216L,
|
||||
0x991a0000000177L,
|
||||
0x992800000002c2L,
|
||||
0x993600000001a6L,
|
||||
0x994500000002e7L,
|
||||
0x99730000000042L,
|
||||
0x999b0000000070L,
|
||||
0x99b200000002f7L,
|
||||
0x99bc0000000062L,
|
||||
0x99cc0000000144L,
|
||||
0x9a2100000002faL,
|
||||
0x9a300000000063L,
|
||||
0x9a9a0000000328L,
|
||||
0x9b6f0000000291L,
|
||||
0x9cb20000000223L,
|
||||
0x9eb800000002c9L,
|
||||
0x9ebc0000000025L,
|
||||
0x9ebd0000000049L,
|
||||
0x9f85000000028eL,
|
||||
0xa121000000016eL,
|
||||
0xa1f10000000264L,
|
||||
0xa3ad0000000084L,
|
||||
0xa3d80000000225L,
|
||||
0xa49b000000004eL,
|
||||
0xa4b100000002eeL,
|
||||
0xa89a00000001daL,
|
||||
0xa9c20000000088L,
|
||||
0xaa0a0000000229L,
|
||||
0xabfe0000000096L,
|
||||
0xafb500000000d3L,
|
||||
0xb0710000000176L,
|
||||
0xb16200000001a2L,
|
||||
0xb41b0000000210L,
|
||||
0xb53c0000000116L,
|
||||
0xb55800000002d6L,
|
||||
0xb58c000000019aL,
|
||||
0xb66100000000e2L,
|
||||
0xb71e0000000047L,
|
||||
0xc08300000000faL,
|
||||
0xc301000000018aL,
|
||||
0xc75900000000c3L,
|
||||
0xc7d90000000066L,
|
||||
0xd12c0000000156L
|
||||
0x100000001c5L,
|
||||
0x90000000245L,
|
||||
0x1100000000b4L,
|
||||
0x1900000000a4L,
|
||||
0x210000000169L,
|
||||
0x2900000000b7L,
|
||||
0x3100000000baL,
|
||||
0x39000000020fL,
|
||||
0x4100000000aaL,
|
||||
0x49000000002eL,
|
||||
0x5100000001c9L,
|
||||
0x590000000181L,
|
||||
0x610000000269L,
|
||||
0x6900000000adL,
|
||||
0x7100000000a8L,
|
||||
0x7900000002aeL,
|
||||
0x810000000027L,
|
||||
0x8900000001afL,
|
||||
0x9100000000c1L,
|
||||
0x9900000000a9L,
|
||||
0xa100000000cfL,
|
||||
0xa900000001faL,
|
||||
0xb1000000002aL,
|
||||
0xb900000002f5L,
|
||||
0xc10000000261L,
|
||||
0xc9000000002cL,
|
||||
0xd1000000002dL,
|
||||
0xd90000000101L,
|
||||
0xe10000000030L,
|
||||
0xe9000000016fL,
|
||||
0xf1000000010fL,
|
||||
0xf90000000125L,
|
||||
0x1010000000115L,
|
||||
0x1090000000244L,
|
||||
0x111000000026cL,
|
||||
0x119000000024dL,
|
||||
0x12100000002d4L,
|
||||
0x12900000001c1L,
|
||||
0x13100000000b2L,
|
||||
0x1390000000241L,
|
||||
0x1410000000265L,
|
||||
0x1490000000285L,
|
||||
0x1510000000032L,
|
||||
0x15900000000b3L,
|
||||
0x1610000000281L,
|
||||
0x1690000000085L,
|
||||
0x1710000000185L,
|
||||
0x17900000001eeL,
|
||||
0x1810000000033L,
|
||||
0x1890000000081L,
|
||||
0x19100000001a5L,
|
||||
0x1990000000289L,
|
||||
0x1a10000000133L,
|
||||
0x1a900000001a1L,
|
||||
0x1b10000000124L,
|
||||
0x1b90000000105L,
|
||||
0x1c100000000a7L,
|
||||
0x1c90000000089L,
|
||||
0x1d1000000002bL,
|
||||
0x1d9000000012cL,
|
||||
0x1e1000000026fL,
|
||||
0x1e900000001e4L,
|
||||
0x1f10000000045L,
|
||||
0x1f90000000028L,
|
||||
0x20100000001ecL,
|
||||
0x209000000012dL,
|
||||
0x2110000000036L,
|
||||
0x2190000000041L,
|
||||
0x2210000000128L,
|
||||
0x22900000001ebL,
|
||||
0x23100000001edL,
|
||||
0x2390000000130L,
|
||||
0x2410000000122L,
|
||||
0x2490000000023L,
|
||||
0x25100000002a4L,
|
||||
0x2590000000026L,
|
||||
0x26100000001e7L,
|
||||
0x26900000001e8L,
|
||||
0x27100000001f0L,
|
||||
0x2790000000021L,
|
||||
0x28100000001e2L,
|
||||
0x2890000000126L,
|
||||
0x29100000001b5L,
|
||||
0x29900000001f7L,
|
||||
0x2a10000000121L,
|
||||
0x2a900000001e3L,
|
||||
0x2b100000000afL,
|
||||
0x2b90000000215L,
|
||||
0x2c100000002b6L,
|
||||
0x2c90000000149L,
|
||||
0x2d100000002a1L,
|
||||
0x2d900000001eaL,
|
||||
0x2e100000001cdL,
|
||||
0x2e90000000293L,
|
||||
0x2f10000000135L,
|
||||
0x2f90000000305L,
|
||||
0x3010000000250L,
|
||||
0x30900000001b3L,
|
||||
0x3110000000276L,
|
||||
0x31900000001adL,
|
||||
0x3210000000283L,
|
||||
0x32900000001a8L,
|
||||
0x3310000000083L,
|
||||
0x3390000000102L,
|
||||
0x34100000001a3L,
|
||||
0x349000000024aL,
|
||||
0x35100000002c3L,
|
||||
0x3590000000077L,
|
||||
0x3610000000322L,
|
||||
0x3690000000165L,
|
||||
0x37100000000e5L,
|
||||
0x3790000000205L,
|
||||
0x381000000028fL,
|
||||
0x38900000000b0L,
|
||||
0x39100000000b6L,
|
||||
0x39900000002c1L,
|
||||
0x3a1000000012bL,
|
||||
0x3a9000000008fL,
|
||||
0x3b10000000209L,
|
||||
0x3b90000000295L,
|
||||
0x3c10000000061L,
|
||||
0x3c90000000341L,
|
||||
0x3d100000002cfL,
|
||||
0x3d9000000003aL,
|
||||
0x3e10000000069L,
|
||||
0x3e900000002adL,
|
||||
0x3f10000000175L,
|
||||
0x3f9000000013aL,
|
||||
0x40100000001e5L,
|
||||
0x40900000002a8L,
|
||||
0x4110000000029L,
|
||||
0x419000000024eL,
|
||||
0x42100000002d5L,
|
||||
0x429000000002fL,
|
||||
0x4310000000055L,
|
||||
0x43900000002a5L,
|
||||
0x44100000001e9L,
|
||||
0x449000000018eL,
|
||||
0x451000000012fL,
|
||||
0x4590000000253L,
|
||||
0x4610000000075L,
|
||||
0x46900000000b5L,
|
||||
0x47100000002ceL,
|
||||
0x4790000000093L,
|
||||
0x4810000000194L,
|
||||
0x4890000000248L,
|
||||
0x49100000002aaL,
|
||||
0x499000000026dL,
|
||||
0x4a10000000174L,
|
||||
0x4a90000000256L,
|
||||
0x4b100000001a4L,
|
||||
0x4b90000000270L,
|
||||
0x4c10000000114L,
|
||||
0x4c9000000020cL,
|
||||
0x4d10000000131L,
|
||||
0x4d90000000054L,
|
||||
0x4e10000000138L,
|
||||
0x4e90000000082L,
|
||||
0x4f10000000182L,
|
||||
0x4f90000000263L,
|
||||
0x50100000001a7L,
|
||||
0x509000000020dL,
|
||||
0x5110000000170L,
|
||||
0x5190000000073L,
|
||||
0x5210000000064L,
|
||||
0x529000000006cL,
|
||||
0x53100000000ccL,
|
||||
0x5390000000110L,
|
||||
0x5410000000216L,
|
||||
0x5490000000177L,
|
||||
0x55100000002c2L,
|
||||
0x55900000001a6L,
|
||||
0x56100000002e7L,
|
||||
0x5690000000042L,
|
||||
0x5710000000070L,
|
||||
0x57900000002f7L,
|
||||
0x5810000000062L,
|
||||
0x5890000000144L,
|
||||
0x59100000002faL,
|
||||
0x5990000000063L,
|
||||
0x5a10000000328L,
|
||||
0x5a90000000291L,
|
||||
0x5b10000000223L,
|
||||
0x5b900000002c9L,
|
||||
0x5c10000000025L,
|
||||
0x5c90000000049L,
|
||||
0x5d1000000028eL,
|
||||
0x5d9000000016eL,
|
||||
0x5e10000000264L,
|
||||
0x5e90000000084L,
|
||||
0x5f10000000225L,
|
||||
0x5f9000000004eL,
|
||||
0x60100000002eeL,
|
||||
0x60900000001daL,
|
||||
0x6110000000088L,
|
||||
0x6190000000229L,
|
||||
0x6210000000096L,
|
||||
0x62900000000d3L,
|
||||
0x6310000000176L,
|
||||
0x63900000001a2L,
|
||||
0x6410000000210L,
|
||||
0x6490000000116L,
|
||||
0x65100000002d6L,
|
||||
0x659000000019aL,
|
||||
0x66100000000e2L,
|
||||
0x6690000000047L,
|
||||
0x67100000000faL,
|
||||
0x679000000018aL,
|
||||
0x68100000000c3L,
|
||||
0x6890000000066L,
|
||||
0x6910000000156L
|
||||
};
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@ public final class HintScores {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
try (Connection conn = DriverManager.getConnection("jdbc:sqlite:/home/mike/dev/puzzle-generator/tools/hint/hint.sqlite")) {
|
||||
try (Connection conn = DriverManager.getConnection("jdbc:sqlite:tools/hint/hint.sqlite")) {
|
||||
updateCrossScores(conn, HintScores::crossabilityScore, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class Meta {
|
||||
return new ShardLem(Lemma.pack("XXX"), -1, new String[0]);
|
||||
}
|
||||
}
|
||||
static final Path[] SHARDS = IntStream.range(0, 10).mapToObj(sId -> Path.of("/home/mike/dev/puzzle-generator/src/main/generated-sources/puzzle").resolve(sId + ".idx")).toArray(
|
||||
static final Path[] SHARDS = IntStream.range(0, 10).mapToObj(sId -> Path.of("src/main/generated-sources/puzzle").resolve(sId + ".idx")).toArray(
|
||||
Path[]::new);
|
||||
static Path shardKey(long word) {
|
||||
int L = Lemma.length(word);
|
||||
|
||||
@@ -87,14 +87,12 @@ public class SwedishGenerator {
|
||||
public static final Pick PICK_NOT_DONE = new Pick(null, null, 0);
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
@Accessors(fluent = true)
|
||||
public static final class FillStats {
|
||||
|
||||
public double simplicity;
|
||||
}
|
||||
|
||||
public static record FillResult(boolean ok, long nodes, long backtracks, int lastMRV, long elapsed, @Delegate FillStats stats) {
|
||||
public static record FillResult(boolean ok, long nodes, long backtracks, int lastMRV, long elapsed, FillStats stats) {
|
||||
|
||||
}
|
||||
|
||||
@@ -144,16 +142,17 @@ public class SwedishGenerator {
|
||||
static final long LETTER_MASK = (1L << 40) - 1; // low 40 bits
|
||||
static final long INDEX_MASK = (1L << 24) - 1; // 24 bits
|
||||
|
||||
static long pack(String word) { return pack(word.getBytes(US_ASCII)); }
|
||||
static long pack(int index, byte[] b) { return pack(b) | ((long) index << 40); }
|
||||
static long pack(String word) { return pack(word.getBytes(US_ASCII)); }
|
||||
static long packW(byte[] b) { return pack(b) /*| ((long) index << 40)*/; }
|
||||
static long pack(byte[] b) {
|
||||
long w = 0;
|
||||
for (var i = 0; i < b.length; i++) w |= ((long) b[i] & 31) << (i * 5);
|
||||
return w;
|
||||
}
|
||||
static public long from(int index, String word) { return pack(index, word.getBytes(US_ASCII)); }
|
||||
static byte byteAt(long word, int idx) { return (byte) ((word >>> (idx * 5)) & 0b11111); }
|
||||
static int length(long word) { return ((63 - numberOfLeadingZeros(word & LETTER_MASK)) / 5) + 1; }
|
||||
static public long from(String word) { return packW(word.getBytes(US_ASCII)); }
|
||||
static byte byteAt(long word, int idx) { return (byte) ((word >>> (idx * 5)) & 0b11111); }
|
||||
static int length(long word) { return ((63 - numberOfLeadingZeros(word & LETTER_MASK)) / 5) + 1; }
|
||||
static int length0(long word) { return ((63 - numberOfLeadingZeros(word & LETTER_MASK)) / 5); }
|
||||
static ThreadLocal<byte[]> BYTES = ThreadLocal.withInitial(() -> new byte[MAX_WORD_LENGTH]);
|
||||
public static String asWord(long word) {
|
||||
val len = Lemma.length(word);
|
||||
@@ -413,10 +412,10 @@ public class SwedishGenerator {
|
||||
|
||||
var tries = Math.min(MAX_TRIES_PER_SLOT, N);
|
||||
for (var t = 0; t < tries; t++) {
|
||||
double r = rng.nextFloat();
|
||||
var shardIndx = (int) (r * r * r * (N - 1));
|
||||
var w = entry.words[shardIndx];
|
||||
var lemIdx = Lemma.unpackIndex(w);
|
||||
double r = rng.nextFloat();
|
||||
var shardIdx = (int) (r * r * r * (N - 1));
|
||||
var w = entry.words[shardIdx];
|
||||
var lemIdx = Lemma.unpackIndex(w);
|
||||
if (Bit1029.get(used, lemIdx)) continue;
|
||||
low = glo;
|
||||
top = ghi;
|
||||
@@ -424,7 +423,7 @@ public class SwedishGenerator {
|
||||
|
||||
Bit1029.set(used, lemIdx);
|
||||
s.assign.w = w;
|
||||
s.assign.shardIdx = shardIndx;
|
||||
s.assign.shardIdx = shardIdx;
|
||||
if (backtrack(depth + 1)) return true;
|
||||
s.assign.w = X;
|
||||
Bit1029.clear(used, lemIdx);
|
||||
|
||||
Reference in New Issue
Block a user