introduce bitloops
This commit is contained in:
4
pom.xml
4
pom.xml
@@ -64,7 +64,7 @@
|
||||
<dependency>
|
||||
<groupId>mike.processor</groupId>
|
||||
<artifactId>puzzle-processor</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
<version>1.4-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -104,7 +104,7 @@
|
||||
<path>
|
||||
<groupId>mike.processor</groupId>
|
||||
<artifactId>puzzle-processor</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
<version>1.4-SNAPSHOT</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
<source>25</source>
|
||||
|
||||
@@ -62,10 +62,11 @@ public record SwedishGenerator(Rng rng) {
|
||||
record Pick(Slot slot, CandidateInfo info, boolean done) { }
|
||||
|
||||
// Directions for '1'..'6'
|
||||
static final nbrs_16[] OFFSETS = Neighbors9x8.OFFSETS;
|
||||
static final nbrs_8[] nbrs8 = Neighbors9x8.nbrs8;
|
||||
static final nbrs_8[] nbrs4 = Neighbors9x8.nbrs4;
|
||||
static final rci[] IT = Neighbors9x8.IT;
|
||||
static final nbrs_16[] OFFSETS = Neighbors9x8.OFFSETS;
|
||||
static final nbrs_8[] nbrs8 = Neighbors9x8.nbrs8;
|
||||
static final nbrs_8[] nbrs4 = Neighbors9x8.nbrs4;
|
||||
static final rci[] IT = Neighbors9x8.IT;
|
||||
static final long[] INBR8_PACKEDT = Neighbors9x8.NBR8_PACKED;
|
||||
|
||||
static final Pick PICK_DONE = new Pick(null, null, true);
|
||||
static final Pick PICK_NOT_DONE = new Pick(null, null, false);
|
||||
@@ -388,7 +389,7 @@ public record SwedishGenerator(Rng rng) {
|
||||
final long[] penalty = { 0 };
|
||||
|
||||
var clueCount = grid.clueCount();
|
||||
penalty[0] += 8L * Math.abs(clueCount - TARGET_CLUES);
|
||||
penalty[0] += ((long) Math.abs(clueCount - TARGET_CLUES)) << 3;
|
||||
|
||||
var ctx = CTX.get();
|
||||
var covH = ctx.covH;
|
||||
@@ -451,8 +452,16 @@ public record SwedishGenerator(Rng rng) {
|
||||
var p = stack[--sp];
|
||||
int rr = Grid.c(p), cc = Grid.r(p);
|
||||
size++;
|
||||
|
||||
for (var d : nbrs8) {
|
||||
long packed = Neighbors9x8.NBR8_PACKED[Grid.offset(rr, cc)];
|
||||
int n = (int) (packed >>> 56);
|
||||
for (int k = 0; k < n; k++) {
|
||||
int nidx = (int)((packed >>> (k * 7)) & 0x7F);
|
||||
|
||||
if (seen.get(nidx) || grid.isLetterAt(nidx)) continue;
|
||||
seen.set(nidx);
|
||||
stack[sp++] = nidx;
|
||||
}
|
||||
/* for (var d : nbrs8) {
|
||||
var nr = rr + d.r();
|
||||
var nc = cc + d.c();
|
||||
if (nr < 0 || nr >= R || nc < 0 || nc >= C) continue;
|
||||
@@ -460,7 +469,7 @@ public record SwedishGenerator(Rng rng) {
|
||||
if (seen.get(nidx) || grid.isLetterAt(nidx)) continue;
|
||||
seen.set(nidx);
|
||||
stack[sp++] = nidx;
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
if (size >= 2) penalty[0] += (size - 1L) * 120L;
|
||||
|
||||
@@ -166,9 +166,9 @@ public class MainTest {
|
||||
|
||||
// Regression baseline for seed search starting at 12347, pop 4, gens 20
|
||||
Assertions.assertEquals(12347, foundSeed, "Found seed changed");
|
||||
Assertions.assertEquals(20, res.filled().clueMap().size(), "Number of assigned words changed");
|
||||
Assertions.assertEquals(758.55, res.filled().stats().simplicity, 1e-9, "Simplicity value changed");
|
||||
Assertions.assertArrayEquals(new byte[]{ 'M', 'A', 'N', 'T', 'A' }, res.filled().clueMap().get(849).word());
|
||||
Assertions.assertEquals(24, res.filled().clueMap().size(), "Number of assigned words changed");
|
||||
Assertions.assertEquals(735.7083333333334, res.filled().stats().simplicity, 1e-9, "Simplicity value changed");
|
||||
Assertions.assertArrayEquals(new byte[]{ 'E', 'B', 'B', 'E', 'N' }, res.filled().clueMap().get(515).word());
|
||||
}
|
||||
@Test
|
||||
public void testIsLetterA() {
|
||||
|
||||
Reference in New Issue
Block a user