introduce bitloops

This commit is contained in:
mike
2026-01-14 18:42:13 +01:00
parent 29aceb2180
commit 75f599318a
4 changed files with 48 additions and 35 deletions

View File

@@ -44,7 +44,9 @@ public class Main {
public static class Opts {
public int seed = (int) (System.nanoTime() ^ System.currentTimeMillis());
public int pop = 24;
public int clueSize = 24;
public int pop = 40;
public int offspring = 60;
public int gens = 700;
public String wordsPath = "nl_score_hints_v3.csv";
public double minSimplicity = 0; // 0 means no limit
@@ -153,7 +155,9 @@ public class Main {
private static void printSettings(Opts o) {
System.out.printf(Locale.ROOT, " %-14s: %d%n", "seed", o.seed);
System.out.printf(Locale.ROOT, " %-14s: %d%n", "clues", o.clueSize);
System.out.printf(Locale.ROOT, " %-14s: %d%n", "population", o.pop);
System.out.printf(Locale.ROOT, " %-14s: %d%n", "offspring", o.offspring);
System.out.printf(Locale.ROOT, " %-14s: %d%n", "generations", o.gens);
System.out.printf(Locale.ROOT, " %-14s: %s%n", "wordsPath", o.wordsPath);
System.out.printf(Locale.ROOT, " %-14s: %.2f%n", "minSimplicity", o.minSimplicity);
@@ -196,11 +200,13 @@ public class Main {
static void usage() {
System.out.println("""
Usage:
java puzzle.Main [--seed N] [--pop N] [--gens N] [--tries N] [--words FILE] [--min-simplicity N.N] [--threads N] [--reindex]
java puzzle.Main [--seed N] [--clues N] [--pop N] [--offspring N] [--gens N] [--tries N] [--words FILE] [--min-simplicity N.N] [--threads N] [--reindex]
Defaults:
--pop 18
--gens 500
--clues 18
--pop 40
--offspring 60
--gens 700
--words nl_score_hints.csv
--min-simplicity 0 (no limit)
--threads %d
@@ -221,9 +227,15 @@ public class Main {
if (a.equals("--seed")) {
out.seed = Integer.parseInt(v);
i++;
} else if (a.equals("--clues")) {
out.clueSize = Integer.parseInt(v);
i++;
} else if (a.equals("--pop")) {
out.pop = Integer.parseInt(v);
i++;
} else if (a.equals("--offspring")) {
out.offspring = Integer.parseInt(v);
i++;
} else if (a.equals("--gens")) {
out.gens = Integer.parseInt(v);
i++;
@@ -359,7 +371,7 @@ public class Main {
static PuzzleResult _attempt(Rng rng, Dict dict, Opts opts) {
TOTAL_ATTEMPTS.incrementAndGet();
var swe = new SwedishGenerator(rng, new int[STACK_SIZE], Clues.createEmpty());
var mask = swe.generateMask(opts.pop, opts.gens, Math.max(opts.pop, (int) Math.floor(opts.pop * 1.5)));
var mask = swe.generateMask(opts.clueSize, opts.pop, opts.gens, opts.offspring);
var filled = fillMask(rng, extractSlots(mask, dict.index()), mask.toGrid());