introduce bitloops

This commit is contained in:
mike
2026-01-20 10:21:38 +01:00
parent e8e0344212
commit 3cd17d170a
4 changed files with 14 additions and 25 deletions

View File

@@ -246,22 +246,10 @@ public record Export() {
public record PuzzleResult(Clued clues, Gridded grid, Slotinfo[] slots, FillResult filled) {
static public long calcSimpel(Slotinfo[] slots) {
int k = 0;
long simpel = 0L;
for (var n = 1; n < slots.length; n++) {
if (slots[n].assign().w != X) {
k++;
simpel += Meta.lookup(slots[n].assign().w).simpel();
}
}
simpel = k == 0 ? 0 : simpel / k;
return simpel;
}
public ExportedPuzzle exportFormatFromFilled(int difficulty, Rewards rewards) {
public ExportedPuzzle exportFormatFromFilled(Rewards rewards) {
// If nothing placed: return full grid mapped to letters/# only
if (slots.length == 0) {
return new ExportedPuzzle(grid.exportGrid(clues.c, _ -> '#', '#'), new WordOut[0], difficulty, rewards);
return new ExportedPuzzle(grid.exportGrid(clues.c, _ -> '#', '#'), new WordOut[0], 1, rewards);
}
var placed = Arrays.stream(slots).map(slot -> new Placed(slot.assign().w, slot.key(), Gridded.cellWalk((byte) slot.key(), slot.lo(), slot.hi()).toArray())).toArray(
@@ -307,7 +295,11 @@ public record Export() {
p.arrowCol() - MIN_C,
p.isReversed(), bytes
)).toArray(WordOut[]::new);
return new ExportedPuzzle(gridv2, wordsOut, difficulty, rewards);
var total = 0.0001d;
for (var word : wordsOut) {
total += word.complex();
}
return new ExportedPuzzle(gridv2, wordsOut, (int) (total / wordsOut.length), rewards);
}
}