introduce bitloops

This commit is contained in:
mike
2026-01-21 05:13:39 +01:00
parent 92a736aa0a
commit f203f2106e
11 changed files with 97 additions and 108 deletions

View File

@@ -23,14 +23,13 @@ public class BuildClueAndSimpelIndex {
buildShard(records);
for (var qRaw : List.of("FIETS", "huis", "kiwi")) {
var q = Meta.normWord(qRaw);
var w = Lemma.from(q);
var i = Meta.findIndexInMapMmap(Meta.shardMap, w);
for (var qRaw : List.of("FIETS", "HUIS", "KIWI")) {
var w = Lemma.from(qRaw);
var i = Meta.findIndexInMapMmap(w);
System.out.println("\nQuery: " + qRaw + " (norm=" + q + ") w=" + w + " -> i=" + i);
System.out.println("\nQuery: " + qRaw + " (norm=" + qRaw + ") w=" + w + " -> i=" + i);
if (i >= 0) {
var rec = Meta.readRecord(Meta.shardData, w, i);
var rec = Meta.readRecord(w, i);
System.out.println(" simpel=" + rec.simpel());
System.out.println(" clues=" + Arrays.toString(rec.clues()));
} else {

View File

@@ -110,11 +110,7 @@ public final class DictJavaGeneratorMulti {
static final class ShardBuilder {
int c;
int addRecord() {
val currSize = c;
c++;
return currSize;
}
int addRecord() { return c++; }
}
private static void writeAggregator(Path outDir, String pkg, String cls, int totalLen, int thress) throws IOException {
@@ -262,9 +258,7 @@ public final class DictJavaGeneratorMulti {
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE);
}
private static String toLongLiteral(long v) {
return "0x" + Long.toUnsignedString(v, 16) + "L";
}
private static String toLongLiteral(long v) { return "0x" + Long.toUnsignedString(v, 16) + "L"; }
public static final class CsvIndexService {
static int SIMPEL_IDX = 2;

View File

@@ -13,6 +13,7 @@ import puzzle.Export.PuzzleResult;
import puzzle.Export.Rewards;
import puzzle.Main.Opts;
import puzzle.SwedishGenerator.Rng;
import puzzle.dict950.DictData950;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -140,15 +141,17 @@ public class MainTest {
}
@Test
void testFiller2() {
val mask = Clued.parse(
"1 000000\n" +
"1 \n" +
"1 \n" +
"3 3 \n" +
"3 0 3 \n" +
"3 \n" +
"3 \n" +
"222 3");
var mask = Clued.of(
r0c0d1,
r0c3d0, r0c4d0, r0c5d0, r0c6d0, r0c7d0, r0c8d0,
r1c0d1,
r2c0d1,
r3c0d3, r3c3d3,
r4c0d3, r4c3d0, r4c6d3,
r5c0d3,
r6c0d3,
r7c0d2, r7c1d2, r7c2d2, r7c8d3
);
Assertions.assertEquals(20, mask.clueCount());
val map = mask.stream().collect(Collectors.toMap(ClueAt::index, ClueAt::clue));
Assertions.assertEquals(20, map.size());
@@ -158,17 +161,19 @@ public class MainTest {
}
@Test
void testFiller() {
System.out.println(DictData950.DICT950.index().length);
val rng = new Rng(-343913721);
val mask = Clued.parse(
" 3 300\n" +
" 1 \n" +
" 1 \n" +
" 3 0 \n" +
" 31 \n" +
" 1 \n" +
" 1 2\n" +
"21 22 3");
var slotInfo = mask.slots();
var mask = Clued.of(
r0c3d3, r0c6d3, r0c7d0, r0c8d0,
r1c1d1,
r2c1d1,
r3c3d3, r3c6d0,
r4c2d3, r4c3d1,
r5c1d1,
r6c1d1, r6c8d2,
r7c0d2, r7c1d1, r7c4d2, r7c5d2, r7c8d3
);
var slotInfo = mask.slots(/*DictData950.DICT950*/);
var grid = Slotinfo.grid(slotInfo);
var filled = fillMask(rng, slotInfo, grid);
Assertions.assertTrue(filled.ok(), "Puzzle generation failed (not ok)");
@@ -177,7 +182,7 @@ public class MainTest {
Assertions.assertEquals(-1L, grid.lo);
Assertions.assertEquals(-1L, grid.hi);
var g = new Gridded(grid, mask.c());
g.gridToString(mask.c());
g.gridToString();
var aa = new PuzzleResult(mask, g, slotInfo, filled).exportFormatFromFilled(new Rewards(1, 1, 1));
System.out.println(String.join("\n", aa.grid()));
@@ -194,8 +199,8 @@ public class MainTest {
System.out.println("[DEBUG_LOG] Seed found: " + seed);
System.out.println("[DEBUG_LOG] ClueMap Size: " + Slotinfo.wordCount(0, res.slots()));
System.out.println("[DEBUG_LOG] Grid:");
System.out.println(res.grid().renderHuman(res.clues().c()));
System.out.println(res.grid().gridToString(res.clues().c()));
System.out.println(res.grid().renderHuman());
System.out.println(res.grid().gridToString());
break;
}
}

View File

@@ -12,6 +12,7 @@ import puzzle.SwedishGenerator.Rng;
import puzzle.SwedishGenerator.Slotinfo;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static precomp.Const9x8.Cell.*;
import static puzzle.SwedishGenerator.fillMask;
import static puzzle.dict800.DictData.DICT800;
import static puzzle.dict900.DictData.DICT900;
@@ -74,15 +75,16 @@ public class PerformanceTest {
void testIncrementalComplexity() {
// Use the complex mask from Main.java
var maskStr = "1 0000\n" +
"1 \n" +
"00 01 \n" +
" 1 \n" +
" 1 \n" +
" 2 1 \n" +
" 1 \n" +
"221 22\n";
val mask = Clued.parse(maskStr);
var mask = Clued.of(
r0c0d1, r0c5d0, r0c6d0, r0c7d0, r0c8d0,
r1c0d1,
r2c0d0, r2c1d0, r2c3d0, r2c4d1,
r3c4d1,
r4c4d1,
r5c2d2, r5c4d1,
r6c2d1,
r7c0d2, r7c1d2, r7c2d1, r7c7d2, r7c8d2
);
val allSlots = Masker.slots(mask.c(), DICT900.index());
//mask.toGrid()
System.out.println("[DEBUG_LOG] \n--- Incremental Complexity Test ---");
@@ -103,7 +105,7 @@ public class PerformanceTest {
val rng = new Rng(42);
// A single horizontal slot at (0,0)
val mask = Clued.parse("1 \n");
val mask = Clued.of(r0c0d1);
val slots = Masker.slots(mask.c(), EN);
System.out.println("[DEBUG_LOG] \n--- Single Slot Resolution ---");