introduce bitloops

This commit is contained in:
mike
2026-01-13 00:03:39 +01:00
parent 61d246e551
commit 6119722867
5 changed files with 47 additions and 49 deletions

View File

@@ -19,9 +19,9 @@ public class MainTest {
static final byte LETTER_A = (byte) 'A';
static final byte LETTER_B = (byte) 'B';
static final byte LETTER_Z = (byte) 'Z';
static final byte CLUE_UP = 0;
static final byte CLUE_DOWN = 0;
static final byte CLUE_RIGHT = 1;
static final byte CLUE_DOWN = 2;
static final byte CLUE_UP = 2;
static final byte CLUE_LEFT = 3;
static final int OFF_0_0 = Grid.offset(0, 0);
@@ -55,10 +55,10 @@ public class MainTest {
@Test
void testStaticSlotMethods() {
// Test static horiz
// dir 2 (right) is horizontal
assertTrue(Slot.horizv2(1));
// dir 3 (down) is vertical
assertFalse(Slot.horizv2(2));
// dir 1 (right) is horizontal
assertTrue(Slot.horiz(1));
// dir 0 (down) is vertical
assertFalse(Slot.horiz(0));
}
@Test
@@ -77,10 +77,10 @@ public class MainTest {
}
@Test
public void testHoriz() {
assertTrue(Slot.from(2, 0L, 0L).horiz());
assertTrue(Slot.from(0, 0L, 0L).horiz());
assertFalse(Slot.from(1, 0L, 0L).horiz());
assertFalse(Slot.from(3, 0L, 0L).horiz());
assertTrue(Slot.from(1, 0L, 0L).horiz()); // Right
assertTrue(Slot.from(3, 0L, 0L).horiz()); // Left
assertFalse(Slot.from(0, 0L, 0L).horiz()); // Down
assertFalse(Slot.from(2, 0L, 0L).horiz()); // Up
}
@Test
public void testGridBasics() {
@@ -178,9 +178,9 @@ public class MainTest {
// Regression baseline for seed search starting at 12347, pop 4, gens 20
Assertions.assertEquals(12348, foundSeed, "Found seed changed");
Assertions.assertEquals(18, res.filled().clueMap().size(), "Number of assigned words changed");
Assertions.assertEquals("DISCO", Lemma.asWord(res.filled().clueMap().get(476)));
Assertions.assertEquals(3332734179516361088L, res.filled().grid().grid().lo);
Assertions.assertEquals(128L, res.filled().grid().grid().hi);
Assertions.assertEquals("TROTS", Lemma.asWord(res.filled().clueMap().get(282)));
Assertions.assertEquals(74732156493031040L, res.filled().grid().grid().lo);
Assertions.assertEquals(193L, res.filled().grid().grid().hi);
}
boolean isLetter(byte b) { return (b & 64) != 0; }
@Test