redo
This commit is contained in:
@@ -29,7 +29,7 @@ import static puzzle.SwedishGenerator.X;
|
||||
@GenerateShapedCopies(
|
||||
packageName = "puzzle",
|
||||
className = "ExportX",
|
||||
shapes = { "precomp.Const9x8", "precomp.Const3x4" }
|
||||
shapes = { "precomp.Const9x8", "precomp.Const3x4" }
|
||||
)
|
||||
public record Export() {
|
||||
|
||||
@@ -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); }
|
||||
@@ -262,15 +271,15 @@ public record Export() {
|
||||
maxC = Math.max(maxC, it.c());
|
||||
}
|
||||
}
|
||||
|
||||
// 3) render gridv2 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);
|
||||
byte[] template = new byte[height * (width + 1)];
|
||||
|
||||
// 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);
|
||||
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;
|
||||
@@ -278,9 +287,9 @@ 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();
|
||||
var wordsOut = Arrays.stream(placed).map(p -> new WordOut(
|
||||
p.lemma,
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user