introduce bitloops
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
package puzzle;
|
||||
|
||||
/**
|
||||
* Generated constants from pom.xml during build via templating-maven-plugin.
|
||||
*/
|
||||
public final class Config {
|
||||
public static final int CLUE_SIZE = ${CLUE_SIZE};
|
||||
public static final int MIN_LEN = ${MIN_LEN};
|
||||
public static final int MAX_TRIES_PER_SLOT = ${MAX_TRIES_PER_SLOT};
|
||||
public static final int MAX_LEN = ${MAX_LEN};
|
||||
public static final int PUZZLE_ROWS = ${PUZZLE_ROWS};
|
||||
public static final int PUZZLE_COLS = ${PUZZLE_COLS};
|
||||
public static final int PUZZLE_SIZE = PUZZLE_ROWS*PUZZLE_COLS;
|
||||
public static final int MAX_WORD_LENGTH = PUZZLE_ROWS;
|
||||
public static final int MAX_WORD_LENGTH_MIN_1 = PUZZLE_ROWS-1;
|
||||
}
|
||||
@@ -12,12 +12,14 @@ import puzzle.SwedishGenerator.FillResult;
|
||||
import puzzle.SwedishGenerator.Grid;
|
||||
import puzzle.SwedishGenerator.Slotinfo;
|
||||
import static precomp.Const9x8.INIT_GRID_OUTPUT;
|
||||
import static precomp.Const9x8.INIT_GRID_OUTPUT_ARR;
|
||||
import static puzzle.Export.Clue.DOWN0;
|
||||
import static puzzle.Export.Clue.RIGHT1;
|
||||
import static puzzle.Masker.Clues.createEmpty;
|
||||
import static puzzle.Masker.Slot;
|
||||
import static puzzle.Masker.C;
|
||||
import static puzzle.SwedishGenerator.Lemma;
|
||||
import static puzzle.SwedishGenerator.SIZE;
|
||||
import static puzzle.SwedishGenerator.X;
|
||||
|
||||
/**
|
||||
@@ -118,28 +120,28 @@ public record Export() {
|
||||
return stream.build();
|
||||
}
|
||||
String gridToString() {
|
||||
var sb = new StringBuilder(INIT_GRID_OUTPUT);
|
||||
var sb = INIT_GRID_OUTPUT_ARR.clone();
|
||||
cl.forEachSlot((s, _, _) -> {
|
||||
val idx = Slot.clueIndex(s);
|
||||
val r = idx & 7;
|
||||
val c = idx >>> 3;
|
||||
val dir = Slot.dir(s);
|
||||
sb.setCharAt(r * (C + 1) + c, (char) (dir | 48));
|
||||
sb[r * (C + 1) + c] = (byte) (dir | 48);
|
||||
});
|
||||
stream().forEach((l) -> sb.setCharAt(l.index(C + 1), l.human()));
|
||||
return sb.toString();
|
||||
stream().forEach((l) -> sb[l.index(C + 1)] = (byte) l.human());
|
||||
return new String(sb);
|
||||
}
|
||||
public String[] exportGrid(Replacar clueChar, char emptyFallback) {
|
||||
var sb = new StringBuilder(INIT_GRID_OUTPUT);
|
||||
var sb = INIT_GRID_OUTPUT_ARR.clone();
|
||||
cl.forEachSlot((s, l, a) -> {
|
||||
val idx = Slot.clueIndex(s);
|
||||
val r = idx & 7;
|
||||
val c = idx >>> 3;
|
||||
val dir = Slot.dir(s);
|
||||
sb.setCharAt(r * (C + 1) + c, clueChar.replace(new Rell(grid, cl, idx, (byte) (dir | 48))));
|
||||
sb[r * (C + 1) + c] = (byte) clueChar.replace(new Rell(grid, cl, idx, (byte) (dir | 48)));
|
||||
});
|
||||
stream().forEach((l) -> sb.setCharAt(l.index(C + 1), l.human()));
|
||||
return sb.toString().replaceAll(" ", "" + emptyFallback).split("\n");
|
||||
stream().forEach((l) -> sb[l.index(C + 1)] = (byte) l.human());
|
||||
return new String(sb).replaceAll(" ", "" + emptyFallback).split("\n");
|
||||
}
|
||||
public static IntStream cellWalk(byte base, long lo, long hi) {
|
||||
if (Slotinfo.increasing(base)) {
|
||||
|
||||
@@ -18,11 +18,13 @@ public final class Masker {
|
||||
public static final long[] PATH_HI = Neighbors9x8.PATH_HI;
|
||||
public static final long MASK_LO = -1L;
|
||||
public static final long MASK_HI = Neighbors9x8.MASK_HI;//(1L << (SIZE - 64)) - 1;
|
||||
public static final int MIN_LEN = Neighbors9x8.MIN_LEN;//Config.MIN_LEN;
|
||||
public static final int STACK_SIZE = 128;
|
||||
public static final int C = Neighbors9x8.C;
|
||||
public static final int R = Neighbors9x8.R;
|
||||
public static final double SIZED = Neighbors9x8.SIZED;// ~18
|
||||
public static final int MIN_LEN = Neighbors9x8.MIN_LEN;//Config.MIN_LEN;
|
||||
public static final int STACK_SIZE = 128;
|
||||
public static final int C = Neighbors9x8.C;
|
||||
public static final int R = Neighbors9x8.R;
|
||||
public static final double SIZED = Neighbors9x8.SIZED;// ~18
|
||||
private static final long[] NBR_LO = Neighbors9x8.NBR_LO;
|
||||
private static final long[] NBR_HI = Neighbors9x8.NBR_HI;
|
||||
private final Rng rng;
|
||||
private final int[] stack;
|
||||
private final Clues cache;
|
||||
@@ -31,10 +33,8 @@ public final class Masker {
|
||||
private final long[] activeSHi = new long[Neighbors9x8.SIZE];
|
||||
private final long[] adjLo = new long[Neighbors9x8.SIZE];
|
||||
private final long[] adjHi = new long[Neighbors9x8.SIZE];
|
||||
private final int[] rCount = new int[8];
|
||||
private final int[] cCount = new int[9];
|
||||
private static final long[] NBR_LO = Neighbors9x8.NBR_LO;
|
||||
private static final long[] NBR_HI = Neighbors9x8.NBR_HI;
|
||||
private final int[] rCount = new int[Neighbors9x8.R];
|
||||
private final int[] cCount = new int[Neighbors9x8.C];
|
||||
|
||||
public Masker(Rng rng, int[] stack, Clues cache) {
|
||||
this.rng = rng;
|
||||
@@ -94,10 +94,10 @@ public final class Masker {
|
||||
}
|
||||
}
|
||||
|
||||
public static final int[][] MUTATE_RI = new int[SwedishGenerator.SIZE][625];
|
||||
public static final int[][] MUTATE_RI = new int[Neighbors9x8.SIZE][625];
|
||||
|
||||
static {
|
||||
for (var i = 0; i < SwedishGenerator.SIZE; i++) {
|
||||
for (var i = 0; i < Neighbors9x8.SIZE; i++) {
|
||||
var k = 0;
|
||||
for (var dr1 = -2; dr1 <= 2; dr1++)
|
||||
for (var dr2 = -2; dr2 <= 2; dr2++)
|
||||
|
||||
@@ -41,10 +41,10 @@ import static java.nio.charset.StandardCharsets.US_ASCII;
|
||||
public record SwedishGenerator() {
|
||||
|
||||
public static final long X = 0L;
|
||||
public static final int SIZE = Neighbors9x8.SIZE;// ~18
|
||||
public static final int MAX_TRIES_PER_SLOT = 500;//Config.MAX_TRIES_PER_SLOT;
|
||||
public static final long RANGE_0_SIZE = Neighbors9x8.RANGE_0_SIZE;// (long) SIZE_MIN_1 - 0L + 1L
|
||||
public static final long RANGE_0_624 = Neighbors9x8.RANGE_0_624;//624L - 0L + 1L;
|
||||
public static final int SIZE = Neighbors9x8.SIZE;
|
||||
public static final int MAX_TRIES_PER_SLOT = 500;// MAX_TRIES_PER_SLOT;
|
||||
public static final long RANGE_0_SIZE = Neighbors9x8.RANGE_0_SIZE;
|
||||
public static final long RANGE_0_624 = Neighbors9x8.RANGE_0_624;
|
||||
|
||||
public static boolean isLo(int n) { return (n & 64) == 0; }
|
||||
interface Bit1029 {
|
||||
|
||||
Reference in New Issue
Block a user