introduce bitloops
This commit is contained in:
@@ -48,8 +48,8 @@ public record SwedishGenerator() {
|
||||
public static final long MASK_HI = (SIZE <= 64) ? 0L : (SIZE >= 128 ? -1L : (1L << (SIZE - 64)) - 1);
|
||||
public static final int MAX_WORD_LENGTH = C <= R ? C : R;
|
||||
public static final int MAX_WORD_LENGTH_PLUS_ONE = MAX_WORD_LENGTH + 1;
|
||||
public static final int MIN_LEN = Config.MIN_LEN;
|
||||
public static final int MAX_TRIES_PER_SLOT = Config.MAX_TRIES_PER_SLOT;
|
||||
public static final int MIN_LEN = 3;//Config.MIN_LEN;
|
||||
public static final int MAX_TRIES_PER_SLOT = 700;//Config.MAX_TRIES_PER_SLOT;
|
||||
public static final int STACK_SIZE = 64;
|
||||
public static final char C_DASH = '\0';
|
||||
public static final byte DASH = (byte) C_DASH;
|
||||
@@ -194,6 +194,14 @@ public record SwedishGenerator() {
|
||||
return k;
|
||||
}
|
||||
public static boolean increasing(int dir) { return (dir & 2) == 0; }
|
||||
public static Grid grid(Slotinfo[] slots) {
|
||||
long lo = X, hi = X;
|
||||
for (var slot : slots) {
|
||||
lo |= slot.lo;
|
||||
hi |= slot.hi;
|
||||
}
|
||||
return new Grid(new byte[SIZE], ~lo, ~hi /*& 0xFF*/);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isLo(int n) { return (n & 64) == 0; }
|
||||
@@ -318,8 +326,7 @@ public record SwedishGenerator() {
|
||||
int idx;
|
||||
for (long b = lo & glo; b != X; b &= b - 1) if (g[idx = numberOfTrailingZeros(b)] != Lemma.byteAt(w, bitCount(lo & ((1L << idx) - 1)))) return false;
|
||||
int bcLo = bitCount(lo);
|
||||
for (long b = hi & ghi; b != X; b &= b - 1)
|
||||
if (g[64 | (idx = numberOfTrailingZeros(b))] != Lemma.byteAt(w, bcLo + bitCount(hi & ((1L << idx) - 1)))) return false;
|
||||
for (long b = hi & ghi; b != X; b &= b - 1) if (g[64 | (idx = numberOfTrailingZeros(b))] != Lemma.byteAt(w, bcLo + bitCount(hi & ((1L << idx) - 1)))) return false;
|
||||
|
||||
long maskLo = lo & ~glo, maskHi = hi & ~ghi;
|
||||
if ((maskLo | maskHi) != X) {
|
||||
@@ -393,9 +400,9 @@ public record SwedishGenerator() {
|
||||
for (var t = 0; t < tries; t++) {
|
||||
//var r = rng.nextFloat();
|
||||
//var idxInArray = (int) (r * r * r * (L - 1));
|
||||
int idxInArray = rng.biasedIndexPow3(L - 1);
|
||||
var w = entry.words[idxs[idxInArray/*(int) (r * r * r * (L - 1))*/]];
|
||||
var lemIdx = Lemma.unpackIndex(w);
|
||||
int idxInArray = rng.biasedIndexPow3(L - 1);
|
||||
var w = entry.words[idxs[idxInArray/*(int) (r * r * r * (L - 1))*/]];
|
||||
var lemIdx = Lemma.unpackIndex(w);
|
||||
if (Bit1029.get(used, lemIdx)) continue;
|
||||
low = glo;
|
||||
top = ghi;
|
||||
|
||||
Reference in New Issue
Block a user