introduce bitloops
This commit is contained in:
@@ -76,12 +76,45 @@ public record SwedishGenerator() {
|
||||
public int count;
|
||||
}
|
||||
|
||||
public static final long[] OFFSETS_D_IDX = Neighbors9x8.OFFSET_D_IDX_0_BASE;
|
||||
public static final long[] OFFSETS_D_IDX;
|
||||
public static final rci[] IT = Neighbors9x8.IT;
|
||||
public static final long[] NBR8_PACKED_LO = Neighbors9x8.NBR8_PACKED_LO;
|
||||
public static final long[] NBR8_PACKED_HI = Neighbors9x8.NBR8_PACKED_HI;
|
||||
public static final long[] PATH_LO = Neighbors9x8.PATH_LO;
|
||||
public static final long[] PATH_HI = Neighbors9x8.PATH_HI;
|
||||
public static final long[] PATH_LO;
|
||||
public static final long[] PATH_HI;
|
||||
|
||||
static {
|
||||
final int NEW_SIZE = SIZE << Masker.Slot.BIT_FOR_DIR;
|
||||
PATH_LO = new long[NEW_SIZE];
|
||||
PATH_HI = new long[NEW_SIZE];
|
||||
OFFSETS_D_IDX = new long[NEW_SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
for (int d = 0; d < 4; d++) {
|
||||
int oldKey = (i << 2) | d;
|
||||
int newKey = (i << Masker.Slot.BIT_FOR_DIR) | d;
|
||||
PATH_LO[newKey] = Neighbors9x8.PATH_LO[oldKey];
|
||||
PATH_HI[newKey] = Neighbors9x8.PATH_HI[oldKey];
|
||||
OFFSETS_D_IDX[newKey] = Neighbors9x8.OFFSET_D_IDX_0_BASE[oldKey];
|
||||
}
|
||||
// Richting 4: Corner Down (Clue op r,c -> Woord op r,c+1 naar beneden)
|
||||
int r = IT[i].r();
|
||||
int c = IT[i].c();
|
||||
int newKey4 = (i << Masker.Slot.BIT_FOR_DIR) | 4;
|
||||
if (c + 1 < C) {
|
||||
long mLo = 0, mHi = 0;
|
||||
for (int ri = r; ri < R; ri++) {
|
||||
int target = Grid.offset(ri, c + 1);
|
||||
if (isLo(target)) mLo |= (1L << target);
|
||||
else mHi |= (1L << (target & 63));
|
||||
}
|
||||
PATH_LO[newKey4] = mLo;
|
||||
PATH_HI[newKey4] = mHi;
|
||||
int first = Grid.offset(r, c + 1);
|
||||
int last = Grid.offset(R - 1, c + 1);
|
||||
OFFSETS_D_IDX[newKey4] = (long)first | ((long)last << 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static final Pick PICK_DONE = null;//new Pick(null, null, 0, true);
|
||||
public static final Pick PICK_NOT_DONE = new Pick(null, null, 0);
|
||||
|
||||
@@ -112,13 +145,10 @@ public record SwedishGenerator() {
|
||||
return y;
|
||||
}
|
||||
public byte randint2bitByte() {
|
||||
var b = (byte) (nextU32() & 3);
|
||||
if (b == 3) {
|
||||
return 1;
|
||||
}if (b == 4) {
|
||||
return 2;
|
||||
}
|
||||
return b;
|
||||
int r = nextU32() & 7;
|
||||
if (r < 4) return (byte) r;
|
||||
if (r == 4) return (byte) 4;
|
||||
return (byte) (r % 4);
|
||||
}
|
||||
public <T> T rand(T[] p) { return p[(int) (((nextU32() & 0xFFFFFFFFL) % ((long) p.length /*- 0L*/ /*+ 1L*/)))]; }
|
||||
public <T> T rand(List<T> p) { return p.get((int) (((nextU32() & 0xFFFFFFFFL) % ((long) p.size() /*- 0L*/ /*+ 1L*/)))); }
|
||||
|
||||
Reference in New Issue
Block a user