introduce bitloops

This commit is contained in:
mike
2026-01-12 21:12:38 +01:00
parent b3b1921414
commit 4784fa7180
3 changed files with 52 additions and 55 deletions

View File

@@ -119,7 +119,7 @@ public record SwedishGenerator(Rng rng) {
final int[] stack = new int[SIZE];
final Bit seen = new Bit();
long pattern;
final long[] undo = new long[4096];
final long[] undo = new long[128];
final long[] bitset = new long[2500];
void setPattern(long p) { this.pattern = p; }
@@ -207,9 +207,6 @@ public record SwedishGenerator(Rng rng) {
return true;
}
static boolean isLetter(byte b) { return (b & B64) != B0; }
public boolean isLetterSet(int idx) { return isLetter(g[idx]); }
public double similarity(Grid b) {
var same = 0;
for (int i = 0; i < SIZE; i++) if (g[i] == b.g[i]) same++;
@@ -318,7 +315,8 @@ public record SwedishGenerator(Rng rng) {
public int len() { return Long.bitCount(lo) + Long.bitCount(hi); }
public int clueR() { return Grid.r((key >>> BIT_FOR_DIR)); }
public int clueIndex() { return key >>> BIT_FOR_DIR; }
public int clueIndex() { return clueIndex(key); }
public static int clueIndex(int key) { return key >>> BIT_FOR_DIR; }
public int clueC() { return Grid.c((key >>> BIT_FOR_DIR)); }
public int dir() { return key & 7; }
public boolean horiz() { return horiz(key); }