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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public final class Masker {
|
||||
@Shaped public static final long[] PATH_HI = Neighbors9x8.PATH_HI;
|
||||
@Shaped public static final long MASK_LO = Neighbors9x8.MASK_LO;
|
||||
@Shaped public static final long RANGE_0_SIZE = Neighbors9x8.RANGE_0_SIZE;
|
||||
@Shaped public static final long RANGE_0_624 = Neighbors9x8.RANGE_0_624;
|
||||
@Shaped public static final long RANGE_0_624 = Neighbors9x8.RANGE_0_624;
|
||||
@Shaped public static final long MASK_HI = Neighbors9x8.MASK_HI;//(1L << (SIZE - 64)) - 1;
|
||||
@Shaped public static final int MIN_LEN = Neighbors9x8.MIN_LEN;//Config.MIN_LEN;
|
||||
@Shaped public static final int C = Neighbors9x8.C;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user