This commit is contained in:
mike
2026-01-23 20:04:02 +01:00
parent c21ad114dc
commit fa3e8ef1ed
2 changed files with 27 additions and 18 deletions

View File

@@ -68,9 +68,18 @@ public record Export() {
public static Signa of(Mask... cells) {
var c = createEmpty();
for (var cell : cells) c.setClue(cell);
for (var cell : cells) {
if ((cell.index() & 64) == 0) c.setClueLo(cell.lo(), cell.d());
else c.setClueHi(cell.hi(), cell.d());
}
return new Signa(c);
}
public Signa setClue(Mask cell) {
if ((cell.index() & 64) == 0) setClueLo(cell.lo(), cell.d());
else setClueHi(cell.hi(), cell.d());
return this;
}
public Signa deepCopyGrid() { return new Signa(new Clues(c.lo, c.hi, c.vlo, c.vhi, c.rlo, c.rhi, c.xlo, c.xhi)); }
String gridToString() {
var sb = new StringBuilder(INIT_GRID_OUTPUT);
@@ -176,8 +185,8 @@ public record Export() {
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 cells[0].c()/*rcis[Slot.clueIndex(slotKey)].c()*/; }
public int arrowRow() { return cells[0].r()/*rcis[Slot.clueIndex(slotKey)].r()*/; }
public int arrowCol() { return cells[0].c(); }
public int arrowRow() { return cells[0].r(); }
public int startRow() { return cells[1].r(); }
public int startCol() { return cells[1].c(); }
public boolean isReversed() { return !Slotinfo.increasing(slotKey); }
@@ -263,7 +272,7 @@ public record Export() {
}
}
// 3) render gridv2 over cropped bounds (out-of-bounds become '#')
// 3) render grid over cropped bounds (out-of-bounds become '#')
final int MINR = minR, MINC = minC;
int height = Math.max(0, maxR - minR + 1);
int width = Math.max(0, maxC - minC + 1);
@@ -278,7 +287,7 @@ public record Export() {
template[rr * (width + 1) + cc] = (byte) l.human();
}
});
var gridv2 = new String(template).split("\n");
var grid = new String(template).split("\n");
// 5) words output with cropped coordinates
val bytes = BYTES.get();
@@ -292,7 +301,7 @@ public record Export() {
p.isReversed(), bytes
)).toArray(WordOut[]::new);
var total = 0.0001d + Arrays.stream(wordsOut).mapToDouble(WordOut::complex).sum();
return new ExportedPuzzle(gridv2, wordsOut, (int) (total / wordsOut.length), rewards);
return new ExportedPuzzle(grid, wordsOut, (int) (total / wordsOut.length), rewards);
}
}

View File

@@ -68,8 +68,8 @@ public final class Masker {
}
public int findOffendingClue(Clues c) {
if (((c.xlo & c.rlo) & c.lo) != X) return numberOfTrailingZeros((c.xlo & c.rlo) & c.lo);
if (((c.xhi & c.rhi) & c.hi) != X) return 64 | numberOfTrailingZeros((c.xhi & c.rhi) & c.hi);
//if (((c.xlo & c.rlo) & c.lo) != X) return numberOfTrailingZeros((c.xlo & c.rlo) & c.lo);
// if (((c.xhi & c.rhi) & c.hi) != X) return 64 | numberOfTrailingZeros((c.xhi & c.rhi) & c.hi);
var num = 0;
for (var bits = c.lo; bits != X; bits &= bits - 1) activeCIdx[num++] = numberOfTrailingZeros(bits);
@@ -457,7 +457,7 @@ public final class Masker {
compHi |= expandedHi & hi_cl;
} while (compLo != lastLo || compHi != lastHi);
var s = bitCount(compLo) + bitCount(compHi);
if (s >= 2) penalty += (long) (s - 1) * 520;
if (s >= 2) penalty += (long) (s - 1) * 720;
remLo &= ~compLo;
remHi &= ~compHi;
}