all
This commit is contained in:
@@ -19,11 +19,11 @@ import static puzzle.SwedishGenerator.*;
|
||||
|
||||
public class ExportFormatTest {
|
||||
|
||||
static final byte CLUE_DOWN = 0;
|
||||
static final byte CLUE_DOWN = 0;
|
||||
static final byte CLUE_RIGHT = 1;
|
||||
static final byte CLUE_UP = 2;
|
||||
static final byte CLUE_LEFT = 3;
|
||||
|
||||
static final byte CLUE_UP = 2;
|
||||
static final byte CLUE_LEFT = 3;
|
||||
|
||||
@Test
|
||||
void testExportFormatFromFilled() {
|
||||
var swe = new SwedishGenerator(new Rng(0));
|
||||
@@ -33,10 +33,10 @@ public class ExportFormatTest {
|
||||
grid.setClue(0, CLUE_RIGHT);
|
||||
// This creates a slot starting at (0,1)
|
||||
|
||||
var clueMap = new HashMap<Integer, Long>();
|
||||
var clueMap = new long[300];
|
||||
// key = (cellIndex << 2) | (direction)
|
||||
var key = (0 << 2) | (CLUE_RIGHT);
|
||||
clueMap.put(key, Lemma.from("TEST"));
|
||||
var key = (0 << 2) | (CLUE_RIGHT);
|
||||
clueMap[key] = Lemma.from("TEST");
|
||||
|
||||
// Manually fill the grid letters for "TEST" at (0,1), (0,2), (0,3), (0,4)
|
||||
grid.setLetter(Grid.offset(0, 1), (byte) 'T');
|
||||
@@ -86,7 +86,7 @@ public class ExportFormatTest {
|
||||
void testExportFormatEmpty() {
|
||||
var swe = new SwedishGenerator(new Rng(0));
|
||||
var grid = Grid.createEmpty();
|
||||
var fillResult = new FillResult(true, new Gridded(grid), new HashMap<>(), new FillStats());
|
||||
var fillResult = new FillResult(true, new Gridded(grid), new long[300], new FillStats());
|
||||
var puzzleResult = new PuzzleResult(swe, null, null, fillResult);
|
||||
|
||||
var exported = puzzleResult.exportFormatFromFilled(1, new Rewards(0, 0, 0));
|
||||
|
||||
@@ -16,21 +16,21 @@ import static puzzle.SwedishGenerator.DASH;
|
||||
|
||||
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_DOWN = 0;
|
||||
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_DOWN = 0;
|
||||
static final byte CLUE_RIGHT = 1;
|
||||
static final byte CLUE_UP = 2;
|
||||
static final byte CLUE_LEFT = 3;
|
||||
|
||||
static final byte CLUE_UP = 2;
|
||||
static final byte CLUE_LEFT = 3;
|
||||
|
||||
static final int OFF_0_0 = Grid.offset(0, 0);
|
||||
static final int OFF_0_1 = Grid.offset(0, 1);
|
||||
static final int OFF_0_2 = Grid.offset(0, 2);
|
||||
static final int OFF_1_1 = Grid.offset(1, 1);
|
||||
static final int OFF_1_2 = Grid.offset(1, 2);
|
||||
static final int OFF_2_3 = Grid.offset(2, 3);
|
||||
|
||||
|
||||
@Test
|
||||
void testExtractSlots() {
|
||||
var grid = Grid.createEmpty();
|
||||
@@ -163,7 +163,7 @@ public class MainTest {
|
||||
foundSeed = seed;
|
||||
System.out.println("[DEBUG_LOG] Seed found: " + seed);
|
||||
System.out.println("[DEBUG_LOG] Simplicity: " + res.filled().stats().simplicity);
|
||||
System.out.println("[DEBUG_LOG] ClueMap Size: " + res.filled().clueMap().size());
|
||||
System.out.println("[DEBUG_LOG] ClueMap Size: " + res.filled().wordCount());
|
||||
System.out.println("[DEBUG_LOG] Grid:");
|
||||
System.out.println(res.filled().grid().renderHuman());
|
||||
var aa = res.exportFormatFromFilled(1, new Rewards(1, 1, 1));
|
||||
@@ -177,8 +177,8 @@ 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("TROTS", Lemma.asWord(res.filled().clueMap().get(282)));
|
||||
Assertions.assertEquals(18, res.filled().wordCount(), "Number of assigned words changed");
|
||||
Assertions.assertEquals("SLEDE", Lemma.asWord(res.filled().clueMap()[282]));
|
||||
Assertions.assertEquals(74732156493031040L, res.filled().grid().grid().lo);
|
||||
Assertions.assertEquals(193L, res.filled().grid().grid().hi);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class SwedishGeneratorTest {
|
||||
var slot = Slot.from(18 << Slot.BIT_FOR_DIR | (CLUE_RIGHT), 7L, 0L);
|
||||
long pattern = patternForSlot(grid, slot);
|
||||
|
||||
assertEquals(1 | (2 << 5) | (3 << 10), pattern);
|
||||
assertEquals(1L | (28L << 8) | (55L << 16), pattern);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -48,7 +48,7 @@ public class SwedishGeneratorTest {
|
||||
var slot = Slot.from(1 << Slot.BIT_FOR_DIR | (CLUE_RIGHT), 7L, 0L);
|
||||
long pattern = patternForSlot(grid, slot);
|
||||
|
||||
assertEquals(1 | (0 << 5) | (3 << 10), pattern);
|
||||
assertEquals(1L | (0L << 8) | (55L << 16), pattern);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -57,7 +57,7 @@ public class SwedishGeneratorTest {
|
||||
var slot = Slot.from(1 << Slot.BIT_FOR_DIR | (CLUE_RIGHT), 7L, 0L);
|
||||
long pattern = patternForSlot(grid, slot);
|
||||
|
||||
assertEquals(0, pattern);
|
||||
assertEquals(0L, pattern);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -66,7 +66,7 @@ public class SwedishGeneratorTest {
|
||||
var slot = Slot.from(1 << Slot.BIT_FOR_DIR | (CLUE_RIGHT), 7L, 0L);
|
||||
long pattern = patternForSlot(grid, slot);
|
||||
|
||||
assertEquals(1, pattern);
|
||||
assertEquals(1L, pattern);
|
||||
}
|
||||
@Test
|
||||
void testRng() {
|
||||
@@ -232,6 +232,18 @@ public class SwedishGeneratorTest {
|
||||
assertEquals(0, count);
|
||||
}
|
||||
|
||||
static long packPattern(String s) {
|
||||
long p = 0;
|
||||
byte[] b = s.getBytes(StandardCharsets.US_ASCII);
|
||||
for (int i = 0; i < b.length; i++) {
|
||||
int val = b[i] & 31;
|
||||
if (val != 0) {
|
||||
p |= (long) (i * 26 + val) << (i << 3);
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCandidateInfoForPattern() {
|
||||
var l0 = Lemma.from("IN");
|
||||
@@ -247,7 +259,7 @@ public class SwedishGeneratorTest {
|
||||
|
||||
// Pattern "APP--" for length 5
|
||||
var context = new Context();
|
||||
context.setPattern(Lemma.pack(new byte[]{ 'A', 'P', 'P', DASH, DASH }));
|
||||
context.setPattern(packPattern("APP"));
|
||||
var info = candidateInfoForPattern(context, dict.index()[5], 5);
|
||||
|
||||
assertEquals(2, info.count());
|
||||
@@ -410,14 +422,14 @@ public class SwedishGeneratorTest {
|
||||
var entry5 = dict.index()[5];
|
||||
|
||||
var ctx = new Context();
|
||||
ctx.setPattern(Lemma.pack("APP".getBytes(StandardCharsets.US_ASCII)));
|
||||
assertEquals(2, candidateCountForPattern(ctx, entry5,3));
|
||||
ctx.setPattern(packPattern("APP"));
|
||||
assertEquals(2, candidateCountForPattern(ctx, entry5, 3));
|
||||
|
||||
ctx.setPattern(Lemma.pack("BAN".getBytes(StandardCharsets.US_ASCII)));
|
||||
assertEquals(1, candidateCountForPattern(ctx, entry5,3));
|
||||
ctx.setPattern(packPattern("BAN"));
|
||||
assertEquals(1, candidateCountForPattern(ctx, entry5, 3));
|
||||
|
||||
ctx.setPattern(Lemma.pack("CAT".getBytes(StandardCharsets.US_ASCII)));
|
||||
assertEquals(0, candidateCountForPattern(ctx, entry5,3));
|
||||
ctx.setPattern(packPattern("CAT"));
|
||||
assertEquals(0, candidateCountForPattern(ctx, entry5, 3));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user