Gather data
This commit is contained in:
@@ -21,14 +21,14 @@ import static puzzle.SwedishGenerator.loadWords;
|
||||
public class Main {
|
||||
|
||||
// ---------------- Top-level generatePuzzle ----------------
|
||||
public record PuzzleResult(SwedishGenerator swe, Dict dict, Grid mask, FillResult filled) { }
|
||||
public record PuzzleResult(SwedishGenerator swe, Dict dict, Gridded mask, FillResult filled) { }
|
||||
|
||||
final static String OUT_DIR = envOrDefault("OUT_DIR", "/data/puzzle");
|
||||
final static Path PUZZLE_DIR = Paths.get(OUT_DIR, "puzzles");
|
||||
static final Path INDEX_FILE = PUZZLE_DIR.resolve("index.json");
|
||||
static final OffsetDateTime now = OffsetDateTime.now(ZoneOffset.UTC);
|
||||
static final String CREATED_AT = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'"));
|
||||
static final String FILE_ID = CREATED_AT.replace(":", "-") + "_" + (System.currentTimeMillis() / 1000);
|
||||
static final String FILE_ID = CREATED_AT.replace(":", "-") + "_" + System.currentTimeMillis() / 1000;
|
||||
static final String FILE_NAME = FILE_ID + ".json";
|
||||
static final Path OUTPUT_PATH = PUZZLE_DIR.resolve(FILE_NAME);
|
||||
static final String DATE_STRING = now.toLocalDate().toString();
|
||||
@@ -84,13 +84,13 @@ public class Main {
|
||||
info(String.format(Locale.ROOT, "simplicity : %.2f", res.filled().simplicity()));
|
||||
|
||||
section("Mask");
|
||||
System.out.print(indentLines(res.swe().gridToString(res.mask()), " "));
|
||||
System.out.print(indentLines(res.mask().gridToString(), " "));
|
||||
|
||||
section("Grid (raw)");
|
||||
System.out.print(indentLines(res.swe().gridToString(res.filled().grid()), " "));
|
||||
System.out.print(indentLines(res.filled().grid().gridToString(), " "));
|
||||
|
||||
section("Grid (human)");
|
||||
System.out.print(indentLines(res.swe().renderHuman(res.filled().grid()), " "));
|
||||
System.out.print(indentLines(res.filled().grid().renderHuman(), " "));
|
||||
|
||||
var exported = exportFormatFromFilled(res, 1, new Rewards(50, 2, 1));
|
||||
|
||||
@@ -140,7 +140,7 @@ public class Main {
|
||||
|
||||
private static String envOrDefault(String key, String def) {
|
||||
var v = System.getenv(key);
|
||||
return (v == null || v.isBlank()) ? def : v;
|
||||
return v == null || v.isBlank() ? def : v;
|
||||
}
|
||||
|
||||
private static void printSettings(Opts o) {
|
||||
@@ -203,7 +203,7 @@ public class Main {
|
||||
var out = new Opts();
|
||||
for (var i = 0; i < argv.length; i++) {
|
||||
var a = argv[i];
|
||||
var v = (i + 1 < argv.length) ? argv[i + 1] : null;
|
||||
var v = i + 1 < argv.length ? argv[i + 1] : null;
|
||||
|
||||
if (a.equals("--help") || a.equals("-h")) {
|
||||
usage();
|
||||
@@ -332,9 +332,9 @@ 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())));
|
||||
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, "avgSimplic : %.2f", TOTAL_SIMPLICITY.get() / 100.0 / TOTAL_SUCCESS.get()));
|
||||
}
|
||||
info(String.format(Locale.ROOT, "dictWords : %,d", dict.wordz().length));
|
||||
|
||||
@@ -365,7 +365,7 @@ public class Main {
|
||||
);
|
||||
|
||||
if (filled.ok() && (opts.minSimplicity <= 0 || filled.simplicity() >= opts.minSimplicity)) {
|
||||
return new PuzzleResult(swe, dict, mask, filled);
|
||||
return new PuzzleResult(swe, dict, new Gridded(mask), filled);
|
||||
}
|
||||
|
||||
if (opts.verbose && filled.ok()) {
|
||||
|
||||
Reference in New Issue
Block a user