Gather data
This commit is contained in:
@@ -7,7 +7,9 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
@@ -122,11 +124,10 @@ public record SwedishGenerator(int W, int H, int SIZE, int MAX_LEN, int[] buff)
|
||||
Grid deepCopyGrid() { return new Grid(g.clone(), W); }
|
||||
private int offset(int r, int c) { return r * W + c; }
|
||||
boolean isLettercell(int r, int c) { return !isDigitAt(r, c); }
|
||||
char getCharAt(int r, int c) { return (char) (g[offset(r, c)] & 0xFF); }
|
||||
char getCharAt(int r, int c) { return (char) (g[offset(r, c)]); }
|
||||
int digitAt(int r, int c) { return g[offset(r, c)] - 48; }
|
||||
byte byteAt(int r, int c) { return g[offset(r, c)]; }
|
||||
void setCharAt(int r, int c, char ch) { g[offset(r, c)] = (byte) ch; }
|
||||
void setCharAt(UndoPlace pl) { g[offset(pl.ur, pl.uc)] = (byte) pl.up; }
|
||||
boolean isLetterAt(int r, int c) { return ((g[offset(r, c)] & 64) != 0); }
|
||||
boolean isDigitAt(int r, int c) { return (g[offset(r, c)] & 48) == 48; }
|
||||
public int H() {
|
||||
@@ -663,6 +664,7 @@ public record SwedishGenerator(int W, int H, int SIZE, int MAX_LEN, int[] buff)
|
||||
return pop.get(0);
|
||||
}
|
||||
record UndoPlace(int ur, int uc, char up) { }
|
||||
|
||||
// ---------------- Fill (CSP) ----------------
|
||||
record Undo(UndoPlace[] ur, int n) { }
|
||||
|
||||
@@ -730,32 +732,6 @@ public record SwedishGenerator(int W, int H, int SIZE, int MAX_LEN, int[] buff)
|
||||
}
|
||||
return n;
|
||||
}
|
||||
/*
|
||||
static Undo placeWord(Grid grid, Slot s, Lemma w) {
|
||||
var ur = new UndoPlace[s.len()];
|
||||
var n = 0;
|
||||
for (var i = 0; i < s.len(); i++) {
|
||||
int r = s.r(i), c = s.c(i);
|
||||
char cur = grid.getCharAt(r, c);
|
||||
var ch = w.charAt(i);
|
||||
if (cur == C_DASH) {
|
||||
ur[n] = new UndoPlace(r, c, C_DASH);
|
||||
n++;
|
||||
grid.setCharAt(r, c, ch);
|
||||
} else {
|
||||
if (cur != ch) {
|
||||
// rollback immediate changes
|
||||
for (var j = 0; j < n; j++) grid.setCharAt(ur[j]);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Undo(ur, n);
|
||||
}*/
|
||||
|
||||
static void undoPlace(Grid grid, Undo u) {
|
||||
for (var i = 0; i < u.n; i++) grid.setCharAt(u.ur[i]);
|
||||
}
|
||||
|
||||
public FillResult fillMask(Rng rng, Grid mask, DictEntry[] dictIndex,
|
||||
int logEveryMs, int timeLimitMs, boolean verbose) {
|
||||
@@ -772,7 +748,7 @@ public record SwedishGenerator(int W, int H, int SIZE, int MAX_LEN, int[] buff)
|
||||
for (var s : slots) for (var i = 0; i < s.len(); i++) cellCount[grid.offset(s.r(i), s.c(i))]++;
|
||||
|
||||
var t0 = System.currentTimeMillis();
|
||||
final var lastLog = new java.util.concurrent.atomic.AtomicLong(t0);
|
||||
final var lastLog = new AtomicLong(t0);
|
||||
|
||||
var stats = new FillStats();
|
||||
final var TOTAL = slots.size();
|
||||
@@ -799,7 +775,7 @@ public record SwedishGenerator(int W, int H, int SIZE, int MAX_LEN, int[] buff)
|
||||
System.out.flush();
|
||||
};
|
||||
|
||||
java.util.function.Supplier<Pick> chooseMRV = () -> {
|
||||
Supplier<Pick> chooseMRV = () -> {
|
||||
Slot best = null;
|
||||
CandidateInfo bestInfo = null;
|
||||
|
||||
@@ -853,7 +829,6 @@ public record SwedishGenerator(int W, int H, int SIZE, int MAX_LEN, int[] buff)
|
||||
stats.lastMRV = pick.info.count;
|
||||
renderProgress.run();
|
||||
|
||||
|
||||
var s = pick.slot;
|
||||
var k = s.key();
|
||||
var entry = dictIndex[s.len()];
|
||||
|
||||
Reference in New Issue
Block a user