introduce bitloops

This commit is contained in:
mike
2026-01-12 00:47:38 +01:00
parent 986c2f85a9
commit 84ba4c9c63
7 changed files with 164 additions and 143 deletions

View File

@@ -7,7 +7,6 @@ import puzzle.SwedishGenerator.Grid;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import static java.nio.charset.StandardCharsets.*;
import static puzzle.SwedishGenerator.R;
import static puzzle.SwedishGenerator.Lemma;
import static puzzle.SwedishGenerator.Slot;
@@ -82,10 +81,10 @@ public record Export() {
public void clear() { Arrays.fill(bits, 0L); }
}
record Placed(Lemma lemma, int startRow, int startCol, char direction, int arrowRow, int arrowCol, int[] cells, boolean isReversed) {
record Placed(Lemma lemma, int startRow, int startCol, char direction, int arrowRow, int arrowCol, int[] cells, boolean isReversed) {
public static final char HORIZONTAL = 'h';
static final char VERTICAL = 'v';
static final char VERTICAL = 'v';
}
public record Rewards(int coins, int stars, int hints) { }
@@ -109,9 +108,9 @@ public record Export() {
for (int i = 0, len = s.len(); i < len; i++) cells[i] = s.pos(i);
char direction;
var isReversed = false;
var startRow = Grid.r(cells[0]);
var startCol = Grid.c(cells[0]);
var isReversed = false;
var startRow = Grid.r(cells[0]);
var startCol = Grid.c(cells[0]);
if (d == 2) { // right -> horizontal
direction = Placed.HORIZONTAL;
} else if (d == 3 || d == 5) { // down or down-bent -> vertical
@@ -215,4 +214,25 @@ public record Export() {
return new ExportedPuzzle(gridv2, wordsOut, difficulty, rewards);
}
}
static record DictEntryDTO(ArrayList<Lemma> words, IntListDTO[][] pos) {
public DictEntryDTO(int L) {
this(new ArrayList<>(), new IntListDTO[L][26]);
for (var i = 0; i < L; i++) for (var j = 0; j < 26; j++) pos[i][j] = new IntListDTO();
}
}
static final class IntListDTO {
int[] a = new int[8];
int n = 0;
void add(int v) {
if (n >= a.length) a = Arrays.copyOf(a, a.length * 2);
a[n++] = v;
}
int size() { return n; }
int[] data() { return a; }
}
}