introduce bitloops
This commit is contained in:
@@ -4,7 +4,6 @@ import lombok.Getter;
|
||||
import lombok.val;
|
||||
import precomp.Neighbors9x8;
|
||||
import precomp.Neighbors9x8.nbrs_16;
|
||||
import precomp.Neighbors9x8.nbrs_8;
|
||||
import precomp.Neighbors9x8.rci;
|
||||
import puzzle.Export.Bit;
|
||||
import puzzle.Export.Bit1029;
|
||||
@@ -172,27 +171,27 @@ public record SwedishGenerator(Rng rng) {
|
||||
this.lo = lo;
|
||||
this.hi = hi;
|
||||
}
|
||||
static Grid createEmpty() { return new Grid(new byte[SIZE], X, X); }
|
||||
int digitAt(int index) { return g[index] & 7; }
|
||||
public static int r(int offset) { return offset & 7; }
|
||||
public static int c(int offset) { return offset >>> 3; }
|
||||
static int offset(int r, int c) { return r | (c << 3); }
|
||||
Grid deepCopyGrid() { return new Grid(g.clone(), lo, hi); }
|
||||
public byte byteAt(int pos) { return g[pos]; }
|
||||
void setByteAt(int idx, byte ch) { g[idx] = ch; }
|
||||
static Grid createEmpty() { return new Grid(new byte[SIZE], X, X); }
|
||||
int digitAt(int index) { return g[index] & 7; }
|
||||
public static int r(int offset) { return offset & 7; }
|
||||
public static int c(int offset) { return offset >>> 3; }
|
||||
static int offset(int r, int c) { return r | (c << 3); }
|
||||
Grid deepCopyGrid() { return new Grid(g.clone(), lo, hi); }
|
||||
public byte byteAt(int pos) { return g[pos]; }
|
||||
|
||||
void setClue(int idx, byte ch) {
|
||||
g[idx] = ch;
|
||||
if ((idx & 64) == 0) lo |= (1L << idx);
|
||||
else hi |= (1L << (idx & 63));
|
||||
}
|
||||
void clearletter(int idx) { g[idx] = DASH; }
|
||||
void setLetter(int idx, byte ch) { g[idx] = ch; }
|
||||
void clearletter(int idx) { g[idx] = DASH; }
|
||||
void clearClue(int idx) {
|
||||
g[idx] = DASH;
|
||||
if ((idx & 64) == 0) lo &= ~(1L << idx);
|
||||
else hi &= ~(1L << (idx & 63));
|
||||
}
|
||||
static boolean isDigit(byte b) { return (b & B48) == B48; }
|
||||
boolean isDigitAt(int index) { return isDigit(g[index]); }
|
||||
boolean isClue(long index) {
|
||||
if ((index & 64) == 0) return ((lo >> index) & 1L) != X;
|
||||
return ((hi >> (index & 63)) & 1L) != X;
|
||||
@@ -655,7 +654,7 @@ public record SwedishGenerator(Rng rng) {
|
||||
ch = Lemma.byteAt(w, i);
|
||||
if (cur == DASH) {
|
||||
mask |= (1 << i);
|
||||
grid.setByteAt(idx, ch);
|
||||
grid.setLetter(idx, ch);
|
||||
} else if (cur != ch) {
|
||||
for (var j = 0; j < i; j++) {
|
||||
if ((mask & (1 << j)) != 0) {
|
||||
|
||||
Reference in New Issue
Block a user