introduce bitloops
This commit is contained in:
@@ -58,7 +58,7 @@ public class Main {
|
||||
|
||||
}
|
||||
|
||||
public void main(String[] args) {
|
||||
void main(String[] args) {
|
||||
var csv = Paths.get("nl_score_hints_v3.csv");
|
||||
var idx = Paths.get("nl_score_hints_v3.idx");
|
||||
try {
|
||||
@@ -97,7 +97,7 @@ public class Main {
|
||||
}
|
||||
|
||||
section("Result");
|
||||
res.filled().stats().simplicity = FillResult.calcSimpel(res.slots());
|
||||
res.filled().stats().simplicity = PuzzleResult.calcSimpel(res.slots());
|
||||
info(String.format(Locale.ROOT, "simplicity : %.2f", res.filled().stats().simplicity));
|
||||
|
||||
section("Mask");
|
||||
@@ -206,19 +206,19 @@ public class Main {
|
||||
}
|
||||
|
||||
static void usage() {
|
||||
System.out.println("""
|
||||
Usage:
|
||||
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:
|
||||
--clues 18
|
||||
--pop 40
|
||||
--offspring 60
|
||||
--gens 500
|
||||
--words nl_score_hints.csv
|
||||
--min-simplicity 0 (no limit)
|
||||
--threads %d
|
||||
""".formatted(Math.max(1, Runtime.getRuntime().availableProcessors())));
|
||||
System.out.printf("""
|
||||
Usage:
|
||||
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:
|
||||
--clues 18
|
||||
--pop 40
|
||||
--offspring 60
|
||||
--gens 500
|
||||
--words nl_score_hints.csv
|
||||
--min-simplicity 0 (no limit)
|
||||
--threads %d
|
||||
%n""", Math.max(1, Runtime.getRuntime().availableProcessors()));
|
||||
}
|
||||
|
||||
static Opts parseArgs(String[] argv) {
|
||||
@@ -392,7 +392,7 @@ public class Main {
|
||||
val slotInfo = Masker.scoreSlots(new int[slots.length], slots);
|
||||
var grid = mask.toGrid();
|
||||
var filled = fillMask(rng, slotInfo, grid, multiThreaded);
|
||||
|
||||
|
||||
if (!multiThreaded) {
|
||||
System.out.print("\r" + Strings.padRight("", 120) + "\r");
|
||||
System.out.flush();
|
||||
@@ -401,22 +401,22 @@ public class Main {
|
||||
if (Main.VERBOSE && !multiThreaded) {
|
||||
System.out.printf(Locale.ROOT,
|
||||
"[######################] %d/%d slots | nodes=%d | backtracks=%d | mrv=%d | %.1fs%n",
|
||||
Slotinfo.wordCount(0, slotInfo), slotInfo.length, filled.nodes(), filled.backtracks(), filled.stats().lastMRV(), filled.stats().seconds()
|
||||
);
|
||||
Slotinfo.wordCount(0, slotInfo), slotInfo.length, filled.nodes(), filled.backtracks(), filled.lastMRV(), filled.elapsed() * 0.001
|
||||
);
|
||||
}
|
||||
|
||||
TOTAL_NODES.addAndGet(filled.nodes());
|
||||
TOTAL_BACKTRACKS.addAndGet(filled.backtracks());
|
||||
if (filled.ok()) {
|
||||
val simpel = FillResult.calcSimpel(slotInfo);
|
||||
val simpel = PuzzleResult.calcSimpel(slotInfo);
|
||||
TOTAL_SUCCESS.incrementAndGet();
|
||||
TOTAL_SIMPLICITY.addAndGet((long) (simpel * 100));
|
||||
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.stats().seconds));
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user