introduce bitloops

This commit is contained in:
mike
2026-01-14 03:30:19 +01:00
parent b0b10d356a
commit 19f235ae59
6 changed files with 123 additions and 142 deletions

View File

@@ -3,7 +3,9 @@ package puzzle;
import lombok.Getter;
import lombok.experimental.Accessors;
import lombok.experimental.Delegate;
import lombok.val;
import puzzle.Export.Gridded.Replacar.Cell;
import puzzle.SwedishGenerator.Clues;
import puzzle.SwedishGenerator.Dict;
import puzzle.SwedishGenerator.FillResult;
import puzzle.SwedishGenerator.Grid;
@@ -36,6 +38,25 @@ public record Export() {
}
}
public record Clued(Clues mask) {
String gridToString() {
var sb = new StringBuilder();
for (var r = 0; r < R; r++) {
if (r > 0) sb.append('\n');
for (var c = 0; c < C; c++) {
val idx = Grid.offset(r, c);
if (mask.isClue(idx))
sb.append((char) mask.digitAt(idx));
else {
sb.append(' ');
}
}
}
return sb.toString();
}
}
record Gridded(@Delegate Grid grid) {
static boolean isLetter(byte b) { return (b & SwedishGenerator.B64) != SwedishGenerator.B0; }
@@ -161,7 +182,7 @@ public record Export() {
public record ExportedPuzzle(String[] grid, WordOut[] words, int difficulty, Rewards rewards) { }
public record PuzzleResult(SwedishGenerator swe, Dict dict, Gridded mask, FillResult filled) {
public record PuzzleResult(SwedishGenerator swe, Dict dict, Clued mask, FillResult filled) {
boolean inBounds(int idx) { return idx >= 0 && idx < SwedishGenerator.SIZE; }
Placed extractPlacedFromSlot(Slot s, long lemma) { return new Placed(lemma, s.key(), s.walk().toArray()); }