introduce bitloops

This commit is contained in:
mike
2026-01-21 06:12:05 +01:00
parent 386777e576
commit ebcbc9b33c
13 changed files with 35 additions and 407 deletions

View File

@@ -1,5 +1,8 @@
package puzzle;
import gen.GenDict;
import gen.GenerateConst;
import gen.GenerateNeighbors;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.val;
@@ -25,18 +28,24 @@ import static java.nio.charset.StandardCharsets.US_ASCII;
* java SwedishGenerator [--seed N] [--pop N] [--gens N] [--tries N] [--words word-list.txt]
*/
@SuppressWarnings("ALL")
@GenerateNeighbors(C = 9, R = 8, packageName = "precomp", className = "Neighbors9x8", MIN_LEN = 2)
@GenerateConst(C = 9, R = 8, packageName = "precomp", className = "Const9x8")
@GenDict(
packageName = "puzzle.dict950",
className = "DictData950",
scv = "/home/mike/dev/puzzle-generator/nl_score_hints_v4.csv",
simpleMax = 950,
minLen = 2,
maxLen = 8
)
public record SwedishGenerator() {
public static final long X = 0L;
public static final int LOG_EVERY_MS = 200;
public static final int BAR_LEN = 22;
public static final int C = Neighbors9x8.C;
public static final int R = Neighbors9x8.R;
public static final int SIZE = Neighbors9x8.SIZE;// ~18
public static final int SIZE_MIN_1 = Neighbors9x8.SIZE_MIN_1;// ~18
public static final double SIZED = Neighbors9x8.SIZED;// ~18
public static final long MASK_LO = -1L;
public static final long MASK_HI = Neighbors9x8.MASK_HI;//(1L << (SIZE - 64)) - 1;
public static final int MAX_WORD_LENGTH = Neighbors9x8.R;
public static final int MAX_WORD_LENGTH_PLUS_ONE = MAX_WORD_LENGTH + 1;
public static final int MIN_LEN = Neighbors9x8.MIN_LEN;//Config.MIN_LEN;
@@ -65,9 +74,6 @@ public record SwedishGenerator() {
public static record FillResult(boolean ok, long nodes, long backtracks, int lastMRV, long elapsed, FillStats stats) { }
//@formatter:on
public static final long[] PATH_LO = Neighbors9x8.PATH_LO;
public static final long[] PATH_HI = Neighbors9x8.PATH_HI;
public static final class Rng {
private int x;
@@ -115,7 +121,6 @@ public record SwedishGenerator() {
return new String(bytes, 0, bi, US_ASCII);
}
static int unpackIndex(long w) { return (int) (w >>> 40); }
static int unpackShardIndex(long w) { return (int) (w >>> 43); }
static int unpackSize(long w) { return (int) (w >>> 40) & 7; }
static int unpackLetters(long w) { return (int) (w & LETTER_MASK); }
static long pack43(long w) {