introduce bitloops

This commit is contained in:
mike
2026-01-17 04:35:53 +01:00
parent 47b33af09d
commit 3bd7a0f958
6 changed files with 95 additions and 100 deletions

View File

@@ -67,7 +67,7 @@ public class ExportFormatTest {
assertTrue(placeWord(grid.grid(), grid.grid().g, key, lo, 0L, TEST));
var fillResult = new FillResult(true, new FillStats(0, 0, 0, 0));
var fillResult = new FillResult(true, 0, 0, new FillStats(0, 0));
var puzzleResult = new PuzzleResult(new Clued(clues), grid, new Slotinfo[]{
new Slotinfo(key, lo, 0L, 0, new Assign(TEST), null)
}, fillResult);
@@ -109,7 +109,7 @@ public class ExportFormatTest {
void testExportFormatEmpty() {
var grid = SwedishGeneratorTest.createEmpty();
val clues = Clues.createEmpty();
var fillResult = new FillResult(true, new FillStats(0, 0, 0, 0));
var fillResult = new FillResult(true, 0, 0, new FillStats(0, 0));
var puzzleResult = new PuzzleResult(new Clued(clues), new Gridded(grid), new Slotinfo[0], fillResult);
var exported = puzzleResult.exportFormatFromFilled(1, new Rewards(0, 0, 0));

View File

@@ -5,6 +5,7 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import puzzle.Export.ClueAt;
import puzzle.Export.Clued;
import puzzle.Export.Dicts;
import puzzle.Export.Gridded;
import puzzle.Export.LetterVisit.LetterAt;
import puzzle.Export.PuzzleResult;
@@ -42,7 +43,7 @@ public class MainTest {
this.tries = 1;
this.verbose = false;
}};
static final Dict dict = Dict.loadDict(opts.wordsPath);
static final Dict dict = Dicts.loadDict(opts.wordsPath);
@Test
void testExtractSlots() {

View File

@@ -4,6 +4,7 @@ import lombok.val;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import puzzle.Export.Clued;
import puzzle.Export.Dicts;
import puzzle.Export.Gridded;
import puzzle.Export.IntListDTO;
import puzzle.Export.LetterVisit.LetterAt;
@@ -219,7 +220,7 @@ public class SwedishGeneratorTest {
assertEquals(5, Lemma.length(l1));
assertEquals(LETTER_A, Lemma.byteAt(l1, 0));
var dict = new Dict(new long[]{ l1, l2, l2a, l4a, l6a, l7a, l8a });
var dict = Dicts.makeDict(new long[]{ l1, l2, l2a, l4a, l6a, l7a, l8a });
assertEquals(1, dict.index()[3].words().length);
assertEquals(1, dict.index()[5].words().length);
@@ -275,7 +276,7 @@ public class SwedishGeneratorTest {
@Test
void testCandidateInfoForPattern() {
var dict = new Dict(WORDS2);
var dict = Dicts.makeDict(WORDS2);
// Pattern "APP--" for length 5
var info = candidateInfoForPattern(Context.get().bitset(), packPattern("APP"), dict.index()[5].posBitsets(), dict.index()[5].numlong());
@@ -289,7 +290,7 @@ public class SwedishGeneratorTest {
// This should detect a slot starting at 0,1 with length 2 (0,1 and 0,2)
var clues = Masker.Clues.createEmpty();
clues.setClueLo(IDX_0_0.lo, CLUE_RIGHT);
var dict = new Dict(WORDS2);
var dict = Dicts.makeDict(WORDS2);
var slots = Masker.extractSlots(clues, dict.index());
assertEquals(1, slots.length);
var s = slots[0];
@@ -407,7 +408,7 @@ public class SwedishGeneratorTest {
val counts = new byte[SIZE];
counts[1] = 2;
counts[2] = 3;
var dict = new Dict(WORDS);
var dict = Dicts.makeDict(WORDS);
var entry5 = dict.index()[5];
// cross = (counts[1]-1) + (counts[2]-1) = 1 + 2 = 3
// score = 3 * 10 + len(2) = 32