redo
This commit is contained in:
@@ -195,16 +195,16 @@ public record Export() {
|
||||
|
||||
}
|
||||
|
||||
record Placed(long lemma, int slotKey, int[] cells) {
|
||||
record Placed(rci[] rcis, long lemma, int slotKey, int[] cells) {
|
||||
|
||||
public static final char HORIZONTAL = 'h';
|
||||
static final char VERTICAL = 'v';
|
||||
static final char[] DIRECTION = { Placed.VERTICAL, Placed.HORIZONTAL, Placed.VERTICAL, Placed.HORIZONTAL, Placed.VERTICAL, Placed.VERTICAL };
|
||||
|
||||
public int arrowCol() { return Masker.IT[Slot.clueIndex(slotKey)].c(); }
|
||||
public int arrowRow() { return Masker.IT[Slot.clueIndex(slotKey)].r(); }
|
||||
public int startRow() { return Masker.IT[cells[0]].r(); }
|
||||
public int startCol() { return Masker.IT[cells[0]].c(); }
|
||||
public int arrowCol() { return rcis[Slot.clueIndex(slotKey)].c(); }
|
||||
public int arrowRow() { return rcis[Slot.clueIndex(slotKey)].r(); }
|
||||
public int startRow() { return rcis[cells[0]].r(); }
|
||||
public int startCol() { return rcis[cells[0]].c(); }
|
||||
public boolean isReversed() { return !Slotinfo.increasing(slotKey); }
|
||||
public char direction() { return DIRECTION[Slot.dir(slotKey)]; }
|
||||
}
|
||||
@@ -247,13 +247,13 @@ public record Export() {
|
||||
|
||||
public record PuzzleResult(Signa clues, Puzzle grid, Slotinfo[] slots, FillResult filled) {
|
||||
|
||||
public ExportedPuzzle exportFormatFromFilled(Rewards rewards) {
|
||||
public ExportedPuzzle exportFormatFromFilled(Rewards rewards, rci[] rcis, int bits) {
|
||||
// If nothing placed: return full grid mapped to letters/# only
|
||||
if (slots.length == 0) {
|
||||
return new ExportedPuzzle(grid.exportGrid(_ -> '#', '#'), new WordOut[0], 1, rewards);
|
||||
}
|
||||
|
||||
var placed = Arrays.stream(slots).map(slot -> new Placed(slot.assign().w, slot.key(), Puzzle.cellWalk((byte) slot.key(), slot.lo(), slot.hi()).toArray())).toArray(
|
||||
var placed = Arrays.stream(slots).map(slot -> new Placed(rcis, slot.assign().w, slot.key(), Puzzle.cellWalk((byte) slot.key(), slot.lo(), slot.hi()).toArray())).toArray(
|
||||
Placed[]::new);
|
||||
|
||||
// 2) bounding box around all word cells + arrow cells, with 1-cell margin
|
||||
@@ -262,7 +262,7 @@ public record Export() {
|
||||
|
||||
for (var rc : placed) {
|
||||
for (var c : rc.cells) {
|
||||
val it = Masker.IT[c];
|
||||
val it = rcis[c];
|
||||
minR = Math.min(minR, it.r());
|
||||
minC = Math.min(minC, it.c());
|
||||
maxR = Math.max(maxR, it.r());
|
||||
@@ -280,7 +280,7 @@ public record Export() {
|
||||
var gridv2 = new String[Math.max(0, maxR - minR + 1)];
|
||||
for (int r = minR, i = 0; r <= maxR; r++, i++) {
|
||||
var row = new StringBuilder(Math.max(0, maxC - minC + 1));
|
||||
for (var c = minC; c <= maxC; c++) row.append(map.getOrDefault(Masker.offset(r, c), '#'));
|
||||
for (var c = minC; c <= maxC; c++) row.append(map.getOrDefault(r | (c << bits), '#'));
|
||||
gridv2[i] = row.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.val;
|
||||
import precomp.Neighbors9x8;
|
||||
import puzzle.SwedishGenerator.Rng;
|
||||
|
||||
import static puzzle.Export.*;
|
||||
@@ -25,7 +24,8 @@ import static puzzle.SwedishGenerator.*;
|
||||
@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)
|
||||
@GenerateNeighbor(C = 4, R = 3, packageName = "precomp", className = "Neighbors4x3", MIN_LEN = 2),
|
||||
@GenerateNeighbor(C = 3, R = 4, packageName = "precomp", className = "Neighbors3x4", MIN_LEN = 2)
|
||||
})
|
||||
public class Main {
|
||||
|
||||
@@ -101,7 +101,7 @@ public class Main {
|
||||
section("Grid (human)");
|
||||
System.out.print(indentLines(res.grid().renderHuman()));
|
||||
|
||||
var exported = res.exportFormatFromFilled(new Rewards(50, 2, 1));
|
||||
var exported = res.exportFormatFromFilled(new Rewards(50, 2, 1), Masker.IT, 3);
|
||||
|
||||
section("Clues");
|
||||
info("status : generating...");
|
||||
@@ -378,7 +378,7 @@ public class Main {
|
||||
if (mask == null) return null;
|
||||
|
||||
val slotInfo = Masker_Neighbors9x8.slots(mask, dict.index(), dict.reversed());
|
||||
var grid = Masker_Neighbors9x8.grid(slotInfo, Neighbors9x8.SIZE);// mask.toGrid();
|
||||
var grid = Masker_Neighbors9x8.grid(slotInfo);// mask.toGrid();
|
||||
var filled = fillMask(rng, slotInfo, grid.lo, grid.hi, grid.g);
|
||||
|
||||
if (!multiThreaded) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import static puzzle.SwedishGenerator.*;
|
||||
@GenerateShapedCopies(
|
||||
packageName = "puzzle",
|
||||
className = "Masker",
|
||||
shapes = { "precomp.Neighbors9x8", "precomp.Neighbors4x3" }
|
||||
shapes = { "precomp.Neighbors9x8", "precomp.Neighbors4x3" , "precomp.Neighbors3x4" }
|
||||
)
|
||||
public final class Masker {
|
||||
|
||||
@@ -52,13 +52,13 @@ public final class Masker {
|
||||
|
||||
return (bitCount(matchLo & MASK_LO) + bitCount(matchHi & MASK_HI)) / SIZED;
|
||||
}
|
||||
public static Grid grid(Slotinfo[] slots, int size) {
|
||||
public static Grid grid(Slotinfo[] slots) {
|
||||
long lo = X, hi = X;
|
||||
for (var slot : slots) {
|
||||
lo |= slot.lo();
|
||||
hi |= slot.hi();
|
||||
}
|
||||
return new Grid(new byte[size], ~lo & MASK_LO, ~hi & MASK_HI);
|
||||
return new Grid(new byte[SIZE], ~lo & MASK_LO, ~hi & MASK_HI);
|
||||
}
|
||||
|
||||
public boolean isValid(Clues c) {
|
||||
|
||||
Reference in New Issue
Block a user