This commit is contained in:
mike
2026-01-23 05:23:11 +01:00
parent 4109c51cbe
commit 2c39e82b00
7 changed files with 37 additions and 31 deletions

View File

@@ -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();
}