Gather data
This commit is contained in:
@@ -224,12 +224,16 @@ public record SwedishGenerator(Rng rng) {
|
||||
if (idx < 64) bo[0] &= ~(1L << idx);
|
||||
else bo[1] &= ~(1L << (idx & 63));
|
||||
}
|
||||
boolean isDigitAt(int r, int c) { return (g[offset(r, c)] & 48) == 48; }
|
||||
boolean isDigitAt(int index) { return (g[index] & 48) == 48; }
|
||||
static boolean isDigit(byte b) { return (b & 48) == 48; }
|
||||
boolean isLettercell(int r, int c) { return (g[offset(r, c)] & 48) != 48; }
|
||||
public boolean isLetterAt(int r, int c) { return ((g[offset(r, c)] & 64) != 0); }
|
||||
public boolean isLetterAt(int index) { return (g[index] & 48) != 48; }
|
||||
static boolean isDigit(byte b) { return (b & 48) == 48; }
|
||||
boolean isDigitAt(int r, int c) { return isDigit(g[offset(r, c)]); }
|
||||
boolean isDigitAt(int index) { return isDigit(g[index]); }
|
||||
static boolean isLetter(byte b) { return (b & 64) != 0; }
|
||||
public boolean isLetterSet(int r, int c) { return isLetter(g[offset(r, c)]); }
|
||||
public boolean isLetterSet(int idx) { return isLetter(g[idx]); }
|
||||
static boolean notDigit(byte b) { return (b & 48) != 48; }
|
||||
public boolean isLetterAt(int r, int c) { return notDigit(g[offset(r, c)]); }
|
||||
public boolean isLetterAt(int index) { return notDigit(g[index]); }
|
||||
|
||||
public double similarity(Grid b) {
|
||||
var same = 0;
|
||||
for (int i = 0; i < SIZE; i++) if (g[i] == b.g[i]) same++;
|
||||
@@ -392,7 +396,7 @@ public record SwedishGenerator(Rng rng) {
|
||||
long packedPos = 0;
|
||||
var n = 0;
|
||||
|
||||
while (rr >= 0 && rr < R && cc >= 0 && cc < C && grid.isLettercell(rr, cc) && n < MAX_WORD_LENGTH) {
|
||||
while (rr >= 0 && rr < R && cc >= 0 && cc < C && grid.isLetterAt(rr, cc) && n < MAX_WORD_LENGTH) {
|
||||
packedPos |= (long) Grid.offset(rr, cc) << (n * 7);
|
||||
n++;
|
||||
rr += nbrs16.dr;
|
||||
@@ -411,7 +415,7 @@ public record SwedishGenerator(Rng rng) {
|
||||
boolean hasRoomForClue(Grid grid, int idx, nbrs_16 nbrs16) {
|
||||
int rr = Grid.r(idx) + nbrs16.r, cc = Grid.c(idx) + nbrs16.c;
|
||||
var run = 0;
|
||||
while (rr >= 0 && rr < R && cc >= 0 && cc < C && (grid.isLettercell(rr, cc)) && run < MAX_WORD_LENGTH) {
|
||||
while (rr >= 0 && rr < R && cc >= 0 && cc < C && (grid.isLetterAt(rr, cc)) && run < MAX_WORD_LENGTH) {
|
||||
run++;
|
||||
rr += nbrs16.dr;
|
||||
cc += nbrs16.dc;
|
||||
|
||||
Reference in New Issue
Block a user