Gather data

This commit is contained in:
mike
2026-01-07 23:28:14 +01:00
parent dad1fd69a1
commit efe70fb121
4 changed files with 100 additions and 69 deletions

View File

@@ -1,7 +1,8 @@
package puzzle;
import lombok.experimental.Accessors;
import lombok.*;
import javax.naming.Context;
import javax.xml.crypto.Data;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
@@ -25,7 +26,7 @@ public record SwedishGenerator(int W, int H, int SIZE, int MAX_LEN, int[] buff)
public static final char C_DASH = '\0';
static final byte _1 = 49, _9 = 57, A = 65, Z = 90, DASH = (byte) C_DASH;
record nbrs_8(int x, int y) { }
static record nbrs_8(int x, int y) { }
public SwedishGenerator(int W, int H) { this(W, H, W * H, Math.min(W, H), new int[10000]); }
public SwedishGenerator() { this(9, 8); }
@@ -94,7 +95,7 @@ public record SwedishGenerator(int W, int H, int SIZE, int MAX_LEN, int[] buff)
static final class Rng {
private int x;
@Getter private int x;
Rng(int seed) {
var s = seed;
if (s == 0) s = 1;
@@ -117,7 +118,7 @@ public record SwedishGenerator(int W, int H, int SIZE, int MAX_LEN, int[] buff)
}
static int clamp(int x, int a, int b) { return Math.max(a, Math.min(b, x)); }
static final record CandidateInfo(int[] indices, int count) { }
static record CandidateInfo(int[] indices, int count) { }
record Grid(byte[] g, int W) {
@@ -506,7 +507,6 @@ public record SwedishGenerator(int W, int H, int SIZE, int MAX_LEN, int[] buff)
}
// dead-end-ish letter cell (3+ walls)
for (var r = 0; r < H; r++)
for (var c = 0; c < W; c++) {
if (grid.isDigitAt(r, c)) continue;
@@ -663,13 +663,10 @@ public record SwedishGenerator(int W, int H, int SIZE, int MAX_LEN, int[] buff)
pop.sort(Comparator.comparingLong(g -> maskFitness(g, lenCounts)));
return pop.get(0);
}
record UndoPlace(int ur, int uc, char up) { }
// ---------------- Fill (CSP) ----------------
record Undo(UndoPlace[] ur, int n) { }
@Data
public static final class FillStats {
public long nodes;
public long backtracks;
public double seconds;
@@ -680,7 +677,7 @@ public record SwedishGenerator(int W, int H, int SIZE, int MAX_LEN, int[] buff)
CandidateInfo info,
boolean done) { }
public static final record FillResult(boolean ok,
public static record FillResult(boolean ok,
Grid grid,
HashMap<Integer, Lemma> clueMap,
FillStats stats,