introduce bitloops

This commit is contained in:
mike
2026-01-14 23:26:54 +01:00
parent 04e3844732
commit e8711b30a1
4 changed files with 10 additions and 23 deletions

View File

@@ -122,10 +122,10 @@ public class MainTest {
@Test
public void testCluesDeepCopy() {
var grid = Clues.createEmpty();
grid.setClue(Grid.offset(0, 0), (byte) 1);
grid.setClue(Grid.offset(0, 1), (byte) 2);
grid.setClue(Grid.offset(1, 0), (byte) 3);
grid.setClue(Grid.offset(1, 1), (byte) 0);
grid.setClue(OFF_0_0, (byte) 1);
grid.setClue(OFF_0_1, (byte) 2);
grid.setClue(OFF_1_0, (byte) 3);
grid.setClue(OFF_1_1, (byte) 0);
var copy = grid.deepCopyGrid();
Assertions.assertEquals((byte) 1, copy.digitAt(0));

View File

@@ -100,11 +100,11 @@ public class SwedishGeneratorTest {
@Test
void testPatternForSlotMixed() {
var grid = createEmpty();
grid.setLetterLo(OFF_0_0, LETTER_A);
grid.setLetterLo(OFF_2_0, LETTER_C);
placeWord(grid, Slot.packSlotKey(0, CLUE_RIGHT), 1L << OFF_0_0, 0, Lemma.from(0, "A"));
placeWord(grid, Slot.packSlotKey(0, CLUE_RIGHT), 1L << OFF_2_0, 0, Lemma.from(0, "C"));
var key = Slot.packSlotKey(OFF_1_0, CLUE_RIGHT);
var pattern = patternForSlot(grid, key, 7L, 0L);
assertEquals(1L | (0L) | (55L << 16), pattern);
assertEquals(1L | (55L << 16), pattern);
}
@Test
@@ -118,7 +118,7 @@ public class SwedishGeneratorTest {
@Test
void testPatternForSlotSingleLetter() {
var grid = createEmpty();
grid.setLetterLo(OFF_0_0, LETTER_A);
placeWord(grid, Slot.packSlotKey(0, CLUE_RIGHT), 1L << OFF_0_0, 0, Lemma.from(0, "A"));
var key = Slot.packSlotKey(1, CLUE_RIGHT);
var pattern = patternForSlot(grid, key, 7L, 0L);
assertEquals(1L, pattern);
@@ -144,7 +144,7 @@ public class SwedishGeneratorTest {
@Test
void testGrid() {
var grid = new Gridded(createEmpty());
grid.grid().setLetterLo(OFF_0_0, LETTER_A);
placeWord(grid.grid(), Slot.packSlotKey(0, CLUE_RIGHT), 1L << OFF_0_0, 0, Lemma.from(0, "A"));
val arr = grid.stream(Clues.createEmpty()).collect(Collectors.toMap(LetterAt::index, LetterAt::letter));
assertEquals(1, arr.size());
assertEquals(LETTER_A, arr.get(OFF_0_0));
@@ -310,7 +310,7 @@ public class SwedishGeneratorTest {
// 4. Partial placement then conflict (rollback)
grid = new Gridded(createEmpty());
grid.grid().setLetterLo(OFF_0_2, LETTER_X); // Conflict at the end
placeWord(grid.grid(), Slot.packSlotKey(0, CLUE_RIGHT), 1L << OFF_0_2, 0, Lemma.from(0, "X")); // Conflict at the end
assertFalse(placeWord(grid.grid(), key, lo, hi, w1));
map = grid.stream(Clues.createEmpty()).collect(Collectors.toMap(LetterAt::index, LetterAt::letter));
assertEquals(1, map.size());