redo
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
package puzzle;
|
||||
|
||||
import module java.base;
|
||||
import anno.ConstGen;
|
||||
import anno.DictGen;
|
||||
import anno.GenerateNeighbor;
|
||||
import anno.GenerateNeighbors;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.val;
|
||||
import precomp.Neighbors9x8;
|
||||
import puzzle.SwedishGenerator.Rng;
|
||||
|
||||
import static puzzle.Export.*;
|
||||
@@ -18,8 +22,14 @@ import static puzzle.SwedishGenerator.*;
|
||||
minLen = 2,
|
||||
maxLen = 8
|
||||
)
|
||||
@ConstGen(C = 9, R = 8, packageName = "precomp", className = "Const9x8")
|
||||
@GenerateNeighbors({
|
||||
@GenerateNeighbor(C = 9, R = 8, packageName = "precomp", className = "Neighbors9x8", MIN_LEN = 2),
|
||||
@GenerateNeighbor(C = 4, R = 3, packageName = "precomp", className = "Neighbors4x3", MIN_LEN = 2)
|
||||
})
|
||||
public class Main {
|
||||
|
||||
final static rci RCI = Masker.IT[0];
|
||||
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");
|
||||
@@ -83,13 +93,13 @@ public class Main {
|
||||
}
|
||||
|
||||
section("Mask");
|
||||
System.out.print(indentLines(res.clues().gridToString(), " "));
|
||||
System.out.print(indentLines(res.clues().gridToString()));
|
||||
|
||||
section("Grid (raw)");
|
||||
System.out.print(indentLines(res.grid().gridToString(), " "));
|
||||
System.out.print(indentLines(res.grid().gridToString()));
|
||||
|
||||
section("Grid (human)");
|
||||
System.out.print(indentLines(res.grid().renderHuman(), " "));
|
||||
System.out.print(indentLines(res.grid().renderHuman()));
|
||||
|
||||
var exported = res.exportFormatFromFilled(new Rewards(50, 2, 1));
|
||||
|
||||
@@ -178,11 +188,11 @@ public class Main {
|
||||
return s.substring(0, Math.max(0, max - 1)) + "…";
|
||||
}
|
||||
|
||||
static String indentLines(String s, String indent) {
|
||||
static String indentLines(String s) {
|
||||
if (s == null || s.isEmpty()) return "";
|
||||
var lines = s.split("\\R", -1);
|
||||
var sb = new StringBuilder();
|
||||
for (var line : lines) sb.append(indent).append(line).append('\n');
|
||||
for (var line : lines) sb.append(" ").append(line).append('\n');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -356,7 +366,7 @@ public class Main {
|
||||
}
|
||||
}
|
||||
static Clues generateNewClues(Rng rng, Opts opts) {
|
||||
var masker = new Masker(rng, new int[Masker.STACK_SIZE], Clues.createEmpty());
|
||||
var masker = new Masker_Neighbors9x8(rng, new int[Masker_Neighbors9x8.STACK_SIZE], Clues.createEmpty());
|
||||
return masker.generateMask(opts.clueSize, opts.pop, opts.gens, opts.offspring);
|
||||
}
|
||||
static PuzzleResult _attempt(Rng rng, Dict dict, Opts opts) {
|
||||
@@ -367,8 +377,8 @@ public class Main {
|
||||
//val mask = generateClues();
|
||||
if (mask == null) return null;
|
||||
|
||||
val slotInfo = Masker.slots(mask, dict.index(), dict.reversed());
|
||||
var grid = Slotinfo.grid(slotInfo);// mask.toGrid();
|
||||
val slotInfo = Masker_Neighbors9x8.slots(mask, dict.index(), dict.reversed());
|
||||
var grid = Masker_Neighbors9x8.grid(slotInfo, Neighbors9x8.SIZE);// mask.toGrid();
|
||||
var filled = fillMask(rng, slotInfo, grid.lo, grid.hi, grid.g);
|
||||
|
||||
if (!multiThreaded) {
|
||||
|
||||
Reference in New Issue
Block a user