redo
This commit is contained in:
@@ -108,13 +108,6 @@ public record Export() {
|
||||
for (var h = grid.hi & MASK_HI & ~cl.hi; h != X; h &= h - 1) stream.accept(Lettrix.from(64 | Long.numberOfTrailingZeros(h), grid.g));
|
||||
return stream.build();
|
||||
}
|
||||
public char humanAt(int r, int c) {
|
||||
int idx = c * R + r;
|
||||
if (idx < 0 || idx >= 128) return '#';
|
||||
boolean hasLetter = (idx < 64) ? ((grid.lo & MASK_LO & ~cl.lo) & (1L << idx)) != 0
|
||||
: ((grid.hi & MASK_HI & ~cl.hi) & (1L << (idx - 64))) != 0;
|
||||
return hasLetter ? LETTER(grid.g[idx]) : '#';
|
||||
}
|
||||
public String[] exportGrid(Slotinfo[] slots, Replacar clueChar, char emptyFallback) {
|
||||
var sb = INIT_GRID_OUTPUT_ARR.clone();
|
||||
for (var slot : slots) {
|
||||
@@ -271,23 +264,31 @@ public record Export() {
|
||||
}
|
||||
|
||||
// 3) render gridv2 over cropped bounds (out-of-bounds become '#')
|
||||
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(grid.humanAt(r, c));
|
||||
gridv2[i] = row.toString();
|
||||
}
|
||||
final int MINR = minR, MINC = minC;
|
||||
int height = Math.max(0, maxR - minR + 1);
|
||||
int width = Math.max(0, maxC - minC + 1);
|
||||
byte[] template = new byte[height * (width + 1)];
|
||||
Arrays.fill(template, (byte) '#');
|
||||
for (int i = width; i < template.length; i += width + 1) template[i] = (byte) '\n';
|
||||
|
||||
grid.forEach(l -> {
|
||||
int rr = l.row() - MINR;
|
||||
int cc = l.col() - MINC;
|
||||
if (rr >= 0 && rr < height && cc >= 0 && cc < width) {
|
||||
template[rr * (width + 1) + cc] = (byte) l.human();
|
||||
}
|
||||
});
|
||||
var gridv2 = new String(template).split("\n");
|
||||
// 5) words output with cropped coordinates
|
||||
int MIN_R = minR, MIN_C = minC;
|
||||
|
||||
val bytes = BYTES.get();
|
||||
var wordsOut = Arrays.stream(placed).map(p -> new WordOut(
|
||||
p.lemma,
|
||||
p.startRow() - MIN_R,
|
||||
p.startCol() - MIN_C,
|
||||
p.startRow() - MINR,
|
||||
p.startCol() - MINC,
|
||||
p.direction(),
|
||||
p.arrowRow() - MIN_R,
|
||||
p.arrowCol() - MIN_C,
|
||||
p.arrowRow() - MINR,
|
||||
p.arrowCol() - MINC,
|
||||
p.isReversed(), bytes
|
||||
)).toArray(WordOut[]::new);
|
||||
var total = 0.0001d + Arrays.stream(wordsOut).mapToDouble(WordOut::complex).sum();
|
||||
|
||||
Reference in New Issue
Block a user