introduce bitloops

This commit is contained in:
mike
2026-01-12 02:02:01 +01:00
parent 84ba4c9c63
commit dd28151d49
3 changed files with 69 additions and 44 deletions

View File

@@ -167,7 +167,7 @@ public class MainTest {
// Regression baseline for seed search starting at 12347, pop 4, gens 20
Assertions.assertEquals(12348, foundSeed, "Found seed changed");
Assertions.assertEquals(22, res.filled().clueMap().size(), "Number of assigned words changed");
Assertions.assertEquals(Lemma.pack(new byte[]{ 'I', 'E', 'M', 'A', 'N', 'D', 'S' }), res.filled().clueMap().get(515).word());
Assertions.assertEquals(Lemma.pack(new byte[]{ 'I', 'E', 'M', 'A', 'N', 'D', 'S' }), res.filled().clueMap().get(259).word());
Assertions.assertEquals(648985643903632391L, res.filled().grid().grid().lo);
Assertions.assertEquals(140L, res.filled().grid().grid().hi);
}

View File

@@ -135,8 +135,12 @@ public class SwedishGeneratorTest {
@Test
void testSlot() {
System.out.println("[DEBUG_LOG] Slot.BIT_FOR_DIR = " + Slot.BIT_FOR_DIR);
// key = (r << 8) | (c << 4) | d
var key = (Grid.offset(2, 3) << 4) | 5;
var offset = Grid.offset(2, 3);
System.out.println("[DEBUG_LOG] Grid.offset(2, 3) = " + offset);
var key = (offset << Slot.BIT_FOR_DIR) | 5;
System.out.println("[DEBUG_LOG] key = " + key);
long packedPos = 0;
// pos 0: (2, 5)
packedPos |= Grid.offset(2, 5);
@@ -146,6 +150,7 @@ public class SwedishGeneratorTest {
packedPos |= (long) Grid.offset(4, 5) << 14;
var s = Slot.from(key, packedPos, 3);
System.out.println("[DEBUG_LOG] s.dir() = " + s.dir());
assertEquals(2, s.clueR());
assertEquals(3, s.clueC());
assertEquals(5, s.dir());