introduce bitloops

This commit is contained in:
mike
2026-01-17 04:18:35 +01:00
parent 81ea708345
commit 47b33af09d
8 changed files with 680 additions and 676 deletions

View File

@@ -104,10 +104,10 @@ public class Main {
System.out.print(indentLines(res.clues().gridToString(), " "));
section("Grid (raw)");
System.out.print(indentLines(res.filled().grid().gridToString(res.clues().c()), " "));
System.out.print(indentLines(res.grid().gridToString(res.clues().c()), " "));
section("Grid (human)");
System.out.print(indentLines(res.filled().grid().renderHuman(res.clues().c()), " "));
System.out.print(indentLines(res.grid().renderHuman(res.clues().c()), " "));
var exported = res.exportFormatFromFilled(1, new Rewards(50, 2, 1));
@@ -384,13 +384,14 @@ public class Main {
static PuzzleResult _attempt(Rng rng, Dict dict, Opts opts) {
long t0 = System.currentTimeMillis();
TOTAL_ATTEMPTS.incrementAndGet();
var swe = new SwedishGenerator(rng, new int[STACK_SIZE], Clues.createEmpty());
var mask = swe.generateMask(opts.clueSize, opts.pop, opts.gens, opts.offspring);
var masker = new Masker(rng, new int[STACK_SIZE], Masker.Clues.createEmpty());
var mask = masker.generateMask(opts.clueSize, opts.pop, opts.gens, opts.offspring);
if (mask == null) return null;
val multiThreaded = Thread.currentThread().getName().contains("pool");
var slots = extractSlots(mask, dict.index());
val slotInfo = scoreSlots(new int[slots.length], slots);
var filled = fillMask(rng, slotInfo, mask.toGrid(), multiThreaded);
var slots = Masker.extractSlots(mask, dict.index());
val slotInfo = Masker.scoreSlots(new int[slots.length], slots);
var grid = mask.toGrid();
var filled = fillMask(rng, slotInfo, grid, multiThreaded);
TOTAL_NODES.addAndGet(filled.stats().nodes);
TOTAL_BACKTRACKS.addAndGet(filled.stats().backtracks);
@@ -412,7 +413,7 @@ public class Main {
);
if (filled.ok() && (opts.minSimplicity <= 0 || filled.stats().simplicity >= opts.minSimplicity)) {
return new PuzzleResult(new Clued(mask), slotInfo, filled);
return new PuzzleResult(new Clued(mask), new Gridded(grid), slotInfo, filled);
}
if (opts.verbose && filled.ok()) {