This commit is contained in:
mike
2026-01-24 00:46:10 +01:00
parent 2a5b70896e
commit 3cc6570cdc
11 changed files with 88 additions and 72 deletions

View File

@@ -9,7 +9,7 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import precomp.Neighbors9x8;
import puzzle.DictJavaGeneratorMulti.DictEntryDTO.IntListDTO;
import puzzle.Export.Lettrix;
import precomp.Mask;
import puzzle.Export.Puzzle;
import puzzle.Riddle.Signa;
import puzzle.Masker.Slot;
@@ -128,7 +128,7 @@ public class SwedishGeneratorTest {
void testPatternForSlotAllLetters() {
var grid = new Puzzle(Riddle.Signa.of(r0c0d1));
GridBuilder.placeWord(grid.grid(), grid.grid().g, r0c0d1.slotKey, r0c1.or(r0c2).or(r0c3).lo(), X, ABC);
val map = grid.collect(Collectors.toMap(Lettrix::index, Lettrix::letter));
val map = grid.sync().collect(Collectors.toMap(Mask::index, Mask::d));
assertEquals(LETTER_A, map.get(OFF_0_1));
assertEquals(LETTER_B, map.get(OFF_0_2));
assertEquals(LETTER_C, map.get(OFF_0_3));
@@ -160,9 +160,9 @@ public class SwedishGeneratorTest {
@Test
void testGrid() {
var grid = new Puzzle(Clues.createEmpty());
GridBuilder.placeWord(grid.grid(), grid.grid().g, r0c0d1.slotKey, r0c0d0.mask, X, WORD_A);
val arr = grid.collect(Collectors.toMap(Lettrix::index, Lettrix::letter));
var p = new Puzzle(Clues.createEmpty());
GridBuilder.placeWord(p.grid(), p.grid().g, r0c0d1.slotKey, r0c0d0.mask, X, WORD_A);
val arr = p.sync().collect(Collectors.toMap(Mask::index, Mask::d));
assertEquals(1, arr.size());
assertEquals(LETTER_A, arr.get(OFF_0_0));
}
@@ -286,7 +286,7 @@ public class SwedishGeneratorTest {
var grid = new Puzzle(Clues.createEmpty());
assertTrue(GridBuilder.placeWord(grid.grid(), grid.grid().g, r0c0d1.slotKey, r0c0.or(r0c1).or(r0c2).lo(), X, ABC));
var map = grid.collect(Collectors.toMap(Lettrix::index, Lettrix::letter));
var map = new Puzzle(grid.grid(), grid.cl()).collect(Collectors.toMap(Mask::index, Mask::d));
assertEquals(3, map.size());
assertEquals(LETTER_A, map.get(OFF_0_0));
assertEquals(LETTER_B, map.get(OFF_0_1));
@@ -297,7 +297,7 @@ public class SwedishGeneratorTest {
// 3. Conflict: place "ABD" where "ABC" is
assertFalse(GridBuilder.placeWord(grid.grid(), grid.grid().g, r0c0d1.slotKey, r0c0.or(r0c1).or(r0c2).lo(), X, ABD));
// Verify grid is unchanged (still "ABC")
map = grid.collect(Collectors.toMap(Lettrix::index, Lettrix::letter));
map = new Puzzle(grid.grid(), grid.cl()).collect(Collectors.toMap(Mask::index, Mask::d));
assertEquals(3, map.size());
assertEquals(LETTER_A, map.get(OFF_0_0));
assertEquals(LETTER_B, map.get(OFF_0_1));
@@ -307,7 +307,7 @@ public class SwedishGeneratorTest {
grid = new Puzzle(Clues.createEmpty());
GridBuilder.placeWord(grid.grid(), grid.grid().g, r0c0d1.slotKey, 1L << OFF_0_2, 0, WORD_X); // Conflict at the end
assertFalse(GridBuilder.placeWord(grid.grid(), grid.grid().g, r0c0d1.slotKey, r0c0.or(r0c1).or(r0c2).lo(), X, ABC));
map = grid.stream().collect(Collectors.toMap(Lettrix::index, Lettrix::letter));
map = new Puzzle(grid.grid(), grid.cl()).collect(Collectors.toMap(Mask::index, Mask::d));
assertEquals(1, map.size());
assertEquals(LETTER_X, map.get(OFF_0_2));
}
@@ -321,14 +321,14 @@ public class SwedishGeneratorTest {
var placed = GridBuilder.placeWord(grid.grid(), grid.grid().g, r0c0d1.slotKey, r0c1.or(r0c2).lo(), X, AZ);
assertTrue(placed);
var map = grid.collect(Collectors.toMap(Lettrix::index, Lettrix::letter));
var map = new Puzzle(grid.grid(), grid.cl()).collect(Collectors.toMap(Mask::index, Mask::d));
assertEquals(2, map.size());
assertEquals(LETTER_A, map.get(OFF_0_1));
assertEquals(LETTER_Z, map.get(OFF_0_2));
grid.grid().hi = top;
grid.grid().lo = low;
map = grid.collect(Collectors.toMap(Lettrix::index, Lettrix::letter));
map = grid.collect(Collectors.toMap(Mask::index, Mask::d));
assertEquals(0, map.size());
assertFalse(map.containsKey(OFF_0_1));
assertFalse(map.containsKey(OFF_0_2));