Gather data
This commit is contained in:
@@ -145,57 +145,47 @@ public class MainTest {
|
||||
Assertions.assertTrue(grid.isDigitAt(1, 1));
|
||||
}
|
||||
@Test
|
||||
@Disabled
|
||||
public void testAttempt() {
|
||||
// Arrange
|
||||
var opts = new Main.Opts();
|
||||
//seed=1811328180
|
||||
opts.seed = -1645461655;// (int) (System.nanoTime() ^ System.currentTimeMillis());
|
||||
opts.pop = 18; // Small for micro-scale
|
||||
opts.gens = 200;
|
||||
opts.seed = 12347;
|
||||
opts.pop = 4; // Tiny population
|
||||
opts.gens = 20; // Very few generations
|
||||
opts.minSimplicity = 0;
|
||||
opts.fillTimeout = 20_000;
|
||||
opts.fillTimeout = 10_000;
|
||||
opts.threads = 1;
|
||||
opts.tries = 1;
|
||||
opts.verbose = true;
|
||||
opts.verbose = false;
|
||||
|
||||
// We need a small dictionary for testing
|
||||
// Instead of loading from file, we might want a way to create a mock Dict
|
||||
// But SwedishGenerator.loadWords(path) is what we have.
|
||||
// Let's try to load a real one or a small subset if possible.
|
||||
var dict = new Dict(new Lemma[]{
|
||||
new Lemma(0, "NU", 1, "NU"),
|
||||
new Lemma(1, "ET", 2, "ET"),
|
||||
new Lemma(2, "NUT", 3, "NUT"),
|
||||
new Lemma(3, "ETE", 4, "ETE"),
|
||||
new Lemma(4, "IK", 5, "IK"),
|
||||
new Lemma(5, "IN", 6, "IN"),
|
||||
new Lemma(6, "AU", 7, "AU"),
|
||||
new Lemma(7, "JE", 8, "JE"),
|
||||
new Lemma(8, "AI", 9, "AI"),
|
||||
new Lemma(9, "NA", 10, "NA"),
|
||||
new Lemma(10, "AF", 11, "AF"),
|
||||
new Lemma(11, "AL", 14, "AL"),
|
||||
new Lemma(12, "EA", 15, "EA"),
|
||||
new Lemma(13, "AV", 18, "AV"),
|
||||
new Lemma(14, "IL", 19, "IL"),
|
||||
new Lemma(15, "EN", 22, "EN")
|
||||
});
|
||||
var dict = SwedishGenerator.loadWords(opts.wordsPath);
|
||||
|
||||
// Act
|
||||
for (int i = 0; i < 200; i++) {
|
||||
int seed = opts.seed + i;
|
||||
var rng = new Rng(seed);
|
||||
PuzzleResult res = Main.attempt(rng, dict, opts);
|
||||
// Assert
|
||||
PuzzleResult res = null;
|
||||
int foundSeed = -1;
|
||||
for (int i = 0; i < 50; i++) {
|
||||
int seed = opts.seed + i;
|
||||
var rng = new Rng(seed);
|
||||
res = Main.attempt(rng, dict, opts);
|
||||
if (res != null && res.filled().ok()) {
|
||||
System.out.println("Test Passed: Puzzle generated");
|
||||
System.out.println("Seed: " + seed);
|
||||
System.out.print(indentLines(res.swe().renderHuman(res.filled().grid()), " "));
|
||||
return;
|
||||
foundSeed = seed;
|
||||
System.out.println("[DEBUG_LOG] Seed found: " + seed);
|
||||
System.out.println("[DEBUG_LOG] Simplicity: " + res.filled().simplicity());
|
||||
System.out.println("[DEBUG_LOG] ClueMap Size: " + res.filled().clueMap().size());
|
||||
System.out.println("[DEBUG_LOG] Grid:");
|
||||
System.out.println(res.swe().renderHuman(res.filled().grid()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
System.out.println("Test Note: Puzzle not generated in 1 attempt (this is possible depending on RNG)");
|
||||
|
||||
// Assert
|
||||
Assertions.assertNotNull(res, "Puzzle generation failed (null result)");
|
||||
Assertions.assertTrue(res.filled().ok(), "Puzzle generation failed (not ok)");
|
||||
|
||||
// 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(763.8, res.filled().simplicity(), 1e-9, "Simplicity value changed");
|
||||
Assertions.assertArrayEquals(new char[]{ 'M', 'A', 'N', 'T', 'A' }, res.filled().clueMap().get(1377).word());
|
||||
}
|
||||
@Test
|
||||
public void testIsLetterA() {
|
||||
|
||||
Reference in New Issue
Block a user