This commit is contained in:
mike
2026-01-23 03:37:54 +01:00
parent 4b61205bbb
commit ed7cade1c7
9 changed files with 150 additions and 155 deletions

View File

@@ -7,7 +7,6 @@ import puzzle.Export.Puzzle;
import puzzle.Export.Placed;
import puzzle.Export.PuzzleResult;
import puzzle.Export.Rewards;
import puzzle.Masker.Clues;
import puzzle.SwedishGenerator.Assign;
import puzzle.SwedishGenerator.FillResult;
import puzzle.SwedishGenerator.Lemma;
@@ -52,7 +51,7 @@ public class MarkerTest {
val orig = cache.from(clues);
simCount++;
masker.mutate(clues);
sim += orig.similarity(clues);
sim += Masker.similarity(orig, clues);
assertTrue(masker.isValid(clues), "Mask should be valid for length \n" + new Signa(clues).gridToString());
}
}
@@ -71,7 +70,7 @@ public class MarkerTest {
var clues2 = masker.randomMask(j);
simCount++;
var cross = masker.crossover(clues, clues2);
sim += Math.max(cross.similarity(clues), cross.similarity(clues2));
sim += Math.max(Masker.similarity(cross, clues), Masker.similarity(cross, clues2));
assertTrue(masker.isValid(cross), "Mask should be valid for length \n" + new Signa(cross).gridToString());
}
}
@@ -83,17 +82,17 @@ public class MarkerTest {
var b = Signa.of(r0c0d1, r2c1d0).c();
// Identity
assertEquals(1.0, a.similarity(b), 0.001);
assertEquals(1.0, Masker.similarity(a, b), 0.001);
// Different direction
var c = Signa.of(r0c0d0, r2c1d0);
assertTrue(a.similarity(c.c()) < 1.0);
assertTrue(Masker.similarity(a, c.c()) < 1.0);
// Completely different
var d = Clues.createEmpty();
// Matching empty cells count towards similarity.
// a has 2 clues, d has 0. They match on 70 empty cells.
assertEquals(70.0 / 72.0, a.similarity(d), 0.001);
assertEquals(70.0 / 72.0, Masker.similarity(a, d), 0.001);
}
@Test
@@ -113,22 +112,22 @@ public class MarkerTest {
var g = Clues.createEmpty();
// Room for Right clue at (0,0) (length 8)
assertTrue(g.hasRoomForClue(r0c0d1.slotKey));
assertTrue(Masker.hasRoomForClue(g,r0c0d1.slotKey));
// No room for Right clue at (0,8) (length 0 < MIN_LEN)
assertFalse(g.hasRoomForClue(r0c8d1.slotKey));
assertFalse(Masker.hasRoomForClue(g,r0c8d1.slotKey));
// Blocked room
// Let's place a clue that leaves only 1 cell for another clue.
g.setClue(r0c2d1);
// Now Right at (0,0) only has (0,1) available -> length 1 < MIN_LEN (which is 2)
assertFalse(g.hasRoomForClue(r0c0d1.slotKey));
assertFalse(Masker.hasRoomForClue(g,r0c0d1.slotKey));
// But enough room
g.clearClueLo(0L);
g.setClue(r0c3d1);
// Now Right at (0,0) has (0,1), (0,2) -> length 2 == MIN_LEN
assertTrue(g.hasRoomForClue(r0c0d1.slotKey));
assertTrue(Masker.hasRoomForClue(g,r0c0d1.slotKey));
}
@Test
@@ -239,7 +238,7 @@ public class MarkerTest {
// Controleer of forEachSlot het slot vindt
final var found = new boolean[]{ false };
clues.forEachSlot((key, lo, hi) -> {
Masker.forEachSlot(clues.c(), (key, lo, hi) -> {
if (key == r0c0d4.slotKey) {
found[0] = true;
// Woord zou moeten starten op (0,1)
@@ -269,7 +268,7 @@ public class MarkerTest {
// Controleer of forEachSlot het slot vindt
final var found = new boolean[]{ false };
clues.forEachSlot((key, lo, hi) -> {
Masker.forEachSlot(clues.c(), (key, lo, hi) -> {
if (key == r0c1d5.slotKey) {
found[0] = true;
// Woord zou moeten starten op (0,0)