introduce bitloops

This commit is contained in:
mike
2026-01-20 09:47:55 +01:00
parent a764f45041
commit 8b7827cfc2
10 changed files with 252 additions and 94 deletions

View File

@@ -235,8 +235,8 @@ public record Export() {
public record WordOut(String word, int[] cell, int startRow, int startCol, char direction, int arrowRow, int arrowCol, boolean isReversed, int complex, String[] clue) {
public WordOut(Path shard,long l, int startRow, int startCol, char d, int arrowRow, int arrowCol, boolean isReversed, byte[] bytes) {
val meta = Meta.readRecord(shard, Lemma.unpackShardIndex(l));
public WordOut(long l, int startRow, int startCol, char d, int arrowRow, int arrowCol, boolean isReversed, byte[] bytes) {
val meta = Meta.lookup(l);
this(Lemma.asWord(l, bytes), new int[]{ arrowRow, arrowCol, startRow, startCol }, startRow, startCol, d, arrowRow, arrowCol, isReversed,
meta.simpel(), meta.clues());
}
@@ -244,27 +244,15 @@ public record Export() {
public record ExportedPuzzle(String[] grid, WordOut[] words, int difficulty, Rewards rewards) { }
public record PuzzleResult(Clued clues, Gridded grid, Slotinfo[] slots, FillResult filled, int thress) {
public record PuzzleResult(Clued clues, Gridded grid, Slotinfo[] slots, FillResult filled) {
public Path shardKey(long word) {
return shardKey(this.thress, word);
}
public static Path shardKey(int thress, long word) {
if (thress <= 0)
return Path.of("src/main/generated-sources/puzzle").resolve(Lemma.unpackSize(word) + 1 + ".idx");
else
return Path.of("src/main/generated-sources/puzzle/dict" + thress).resolve(Lemma.unpackSize(word) + 1 + ".idx");
}
public long calcSimpel( Slotinfo[] slots) {
return calcSimpel(thress, slots);
}
static public long calcSimpel(int thress, Slotinfo[] slots) {
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.readRecord(shardKey(thress,slots[n].assign().w), Lemma.unpackShardIndex(slots[n].assign().w)).simpel();
simpel += Meta.lookup(slots[n].assign().w).simpel();
}
}
simpel = k == 0 ? 0 : simpel / k;
@@ -311,7 +299,6 @@ public record Export() {
int MIN_R = minR, MIN_C = minC;
val bytes = BYTES.get();
var wordsOut = Arrays.stream(placed).map(p -> new WordOut(
shardKey( p.lemma),
p.lemma,
p.startRow() - MIN_R,
p.startCol() - MIN_C,