introduce bitloops

This commit is contained in:
mike
2026-01-20 10:17:47 +01:00
parent fde6f15b24
commit e8e0344212
2 changed files with 12 additions and 26 deletions

View File

@@ -28,7 +28,6 @@ public class Main {
static final AtomicLong TOTAL_BACKTRACKS = new AtomicLong(0);
static final AtomicLong TOTAL_ATTEMPTS = new AtomicLong(0);
static final AtomicLong TOTAL_SUCCESS = new AtomicLong(0);
static final AtomicLong TOTAL_SIMPLICITY = new AtomicLong(0); // Scaled by 100 for precision
@Data
@AllArgsConstructor
@@ -79,10 +78,6 @@ public class Main {
return;
}
section("Result");
res.filled().stats().simplicity = res.calcSimpel(res.slots());
info(String.format(Locale.ROOT, "simplicity : %.2f", res.filled().stats().simplicity));
section("Mask");
System.out.print(indentLines(res.clues().gridToString(), " "));
@@ -93,11 +88,15 @@ public class Main {
System.out.print(indentLines(res.grid().renderHuman(res.clues().c()), " "));
var exported = res.exportFormatFromFilled(1, new Rewards(50, 2, 1));
var total = 0.0001d;
for (var word : exported.words()) {
total += word.complex();
}
section("Clues");
info("status : generating...");
info("generatedFor : " + exported.words().length);
info("status : done");
info("simpel : " + (total / exported.words().length));
section("Words");
printWordsTable(exported.words());
@@ -347,9 +346,6 @@ public class Main {
section("Material");
info(String.format(Locale.ROOT, "attempts : %,d", TOTAL_ATTEMPTS.get()));
info(String.format(Locale.ROOT, "successRate : %.1f%%", TOTAL_ATTEMPTS.get() == 0 ? 0 : TOTAL_SUCCESS.get() * 100.0 / TOTAL_ATTEMPTS.get()));
if (TOTAL_SUCCESS.get() > 0) {
info(String.format(Locale.ROOT, "avgSimplic : %.2f", TOTAL_SIMPLICITY.get() / 100.0 / TOTAL_SUCCESS.get()));
}
info(String.format(Locale.ROOT, "dictWords : %,d", dict.length()));
return resFinal;
@@ -395,34 +391,25 @@ public class Main {
TOTAL_NODES.addAndGet(filled.nodes());
TOTAL_BACKTRACKS.addAndGet(filled.backtracks());
if (filled.ok()) {
val simpel = PuzzleResult.calcSimpel(slotInfo);
TOTAL_SUCCESS.incrementAndGet();
TOTAL_SIMPLICITY.addAndGet(simpel * 100);
}
var name = Thread.currentThread().getName();
var status = filled.ok() ? "SUCCESS" : "FAILED";
var simplicity = String.format(Locale.ROOT, "%.2f", filled.stats().simplicity);
var nps = (int) (filled.nodes() / Math.max(0.001, filled.elapsed() * 0.001));
var totalTime = (System.currentTimeMillis() - t0) / 1000.0;
var name = Thread.currentThread().getName();
var status = filled.ok() ? "SUCCESS" : "FAILED";
var nps = (int) (filled.nodes() / Math.max(0.001, filled.elapsed() * 0.001));
var totalTime = (System.currentTimeMillis() - t0) / 1000.0;
System.out.printf(Locale.ROOT,
"[ATTEMPT] thread=%s | status=%s | nodes=%d | backtracks=%d | nps=%d | simplicity=%s | time=%.1fs%n",
name, status, filled.nodes(), filled.backtracks(), nps, simplicity, totalTime
name, status, filled.nodes(), filled.backtracks(), nps, 1, totalTime
);
if (!filled.ok()) {
System.out.println(Arrays.stream(new Clued(mask).gridToString().split("\n")).map(s -> "\"" + s + "\\n\" +").collect(Collectors.joining("\n")));
//System.out.println(Arrays.stream(new Clued(mask).gridToString().split("\n")).map(s -> "\"" + s + "\\n\" +").collect(Collectors.joining("\n")));
}
if (filled.ok() && (opts.minSimplicity <= 0 || filled.stats().simplicity >= opts.minSimplicity)) {
if (filled.ok()) {
return new PuzzleResult(new Clued(mask), new Gridded(grid, mask), slotInfo, filled);
}
if (opts.verbose && filled.ok()) {
System.err.printf(Locale.ROOT,
"simplicity : %.2f (below min %.2f)%n",
filled.stats().simplicity, opts.minSimplicity
);
}
return null;
}

View File

@@ -236,7 +236,6 @@ public class MainTest {
if (res != null && res.filled().ok()) {
foundSeed = seed;
System.out.println("[DEBUG_LOG] Seed found: " + seed);
System.out.println("[DEBUG_LOG] Simplicity: " + res.filled().stats().simplicity);
System.out.println("[DEBUG_LOG] ClueMap Size: " + Slotinfo.wordCount(0, res.slots()));
System.out.println("[DEBUG_LOG] Grid:");
System.out.println(res.grid().renderHuman(res.clues().c()));