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

@@ -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());