introduce bitloops
This commit is contained in:
@@ -10,8 +10,8 @@ import puzzle.Export.LetterVisit.LetterAt;
|
||||
import puzzle.Export.PuzzleResult;
|
||||
import puzzle.Export.Rewards;
|
||||
import puzzle.Main.Opts;
|
||||
import puzzle.Masker.Clues;
|
||||
import puzzle.SwedishGenerator.Rng;
|
||||
import puzzle.SwedishGenerator.Slot;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
@@ -46,17 +46,17 @@ public class MainTest {
|
||||
@Test
|
||||
void testExtractSlots() {
|
||||
|
||||
var clues = Clues.createEmpty();
|
||||
val key = Slot.packSlotKey(OFF_0_0, CLUE_RIGHT);
|
||||
var clues = Masker.Clues.createEmpty();
|
||||
val key = Masker.Slot.packSlotKey(OFF_0_0, CLUE_RIGHT);
|
||||
clues.setClueLo(IDX_0_0.lo, CLUE_RIGHT);
|
||||
var grid = new Gridded(clues.toGrid());
|
||||
val g = grid.grid().g;
|
||||
placeWord(grid.grid(), g, key, (1L << OFF_0_1) | (1L << OFF_0_2), 0, AB);
|
||||
|
||||
var slots = extractSlots(clues, dict.index());
|
||||
var slots = Masker.extractSlots(clues, dict.index());
|
||||
assertEquals(1, slots.length);
|
||||
var s = slots[0];
|
||||
assertEquals(8, Slot.length(s.lo(), s.hi()));
|
||||
assertEquals(8, Masker.Slot.length(s.lo(), s.hi()));
|
||||
var cells = s.walk().toArray();
|
||||
assertEquals(0, SwedishGenerator.IT[cells[0]].r());
|
||||
assertEquals(1, SwedishGenerator.IT[cells[0]].c());
|
||||
@@ -68,14 +68,14 @@ public class MainTest {
|
||||
void testStaticSlotMethods() {
|
||||
// Test static horiz
|
||||
// dir 1 (right) is horizontal
|
||||
assertTrue(Slot.horiz(1));
|
||||
assertTrue(Masker.Slot.horiz(1));
|
||||
// dir 0 (down) is vertical
|
||||
assertFalse(Slot.horiz(0));
|
||||
assertFalse(Masker.Slot.horiz(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForEachSlot() {
|
||||
var clues = Clues.createEmpty();
|
||||
var clues = Masker.Clues.createEmpty();
|
||||
clues.setClueLo(IDX_0_0.lo, CLUE_RIGHT);
|
||||
var count = new AtomicInteger(0);
|
||||
clues.forEachSlot((key, lo, hi) -> {
|
||||
@@ -88,15 +88,15 @@ public class MainTest {
|
||||
}
|
||||
@Test
|
||||
public void testHoriz() {
|
||||
assertTrue(Slot.horiz(1)); // Right
|
||||
assertTrue(Slot.horiz(3)); // Left
|
||||
assertFalse(Slot.horiz(0)); // Down
|
||||
assertFalse(Slot.horiz(2)); // Up
|
||||
assertTrue(Masker.Slot.horiz(1)); // Right
|
||||
assertTrue(Masker.Slot.horiz(3)); // Left
|
||||
assertFalse(Masker.Slot.horiz(0)); // Down
|
||||
assertFalse(Masker.Slot.horiz(2)); // Up
|
||||
}
|
||||
@Test
|
||||
public void testGridBasics() {
|
||||
var clues = new Clued(Clues.createEmpty());
|
||||
val key = Slot.packSlotKey(OFF_2_1, CLUE_UP);
|
||||
var clues = new Clued(Masker.Clues.createEmpty());
|
||||
val key = Masker.Slot.packSlotKey(OFF_2_1, CLUE_UP);
|
||||
clues.setClueLo(IDX_2_1.lo, CLUE_UP);
|
||||
var grid = new Gridded(clues.toGrid());
|
||||
|
||||
@@ -130,7 +130,7 @@ public class MainTest {
|
||||
}
|
||||
@Test
|
||||
public void testCluesDeepCopy() {
|
||||
var clues = new Clued(Clues.createEmpty());
|
||||
var clues = new Clued(Masker.Clues.createEmpty());
|
||||
clues.setClueLo(IDX_0_0.lo, RIGHT.dir);
|
||||
clues.setClueLo(IDX_0_1.lo, UP.dir);
|
||||
clues.setClueLo(IDX_1_0.lo, LEFT.dir);
|
||||
@@ -148,16 +148,16 @@ public class MainTest {
|
||||
@Test
|
||||
public void testMini() {
|
||||
val idx = IDX_1_1;
|
||||
var clues = Clues.createEmpty();
|
||||
var clues = Masker.Clues.createEmpty();
|
||||
clues.setClueLo(idx.lo, CLUE_LEFT);
|
||||
Assertions.assertTrue(clues.isClueLo(idx.index));
|
||||
}
|
||||
@Test
|
||||
void testMaskerCreation() {
|
||||
var swe = new SwedishGenerator(new Rng(12348), new int[STACK_SIZE], Clues.createEmpty());
|
||||
var mask = swe.generateMask(opts.clueSize, opts.pop, opts.gens, opts.offspring);
|
||||
val clued = new Clued(mask);
|
||||
val test = clued.gridToString();
|
||||
var masker = new Masker(new Rng(12348), new int[STACK_SIZE], Masker.Clues.createEmpty());
|
||||
var mask = masker.generateMask(opts.clueSize, opts.pop, opts.gens, opts.offspring);
|
||||
val clued = new Clued(mask);
|
||||
val test = clued.gridToString();
|
||||
val RESULT = "1 \n" +
|
||||
" \n" +
|
||||
" 3\n" +
|
||||
@@ -180,16 +180,18 @@ public class MainTest {
|
||||
128L,
|
||||
422762372923520L,
|
||||
192L);
|
||||
var slots = extractSlots(mask, dict.index());
|
||||
val slotInfo = scoreSlots(new int[slots.length], slots);
|
||||
var filled = fillMask(rng, slotInfo, mask.toGrid(), false);
|
||||
var slots = Masker.extractSlots(mask, dict.index());
|
||||
val slotInfo = Masker.scoreSlots(new int[slots.length], slots);
|
||||
var grid = mask.toGrid();
|
||||
var filled = fillMask(rng, slotInfo, grid, false);
|
||||
Assertions.assertTrue(filled.ok(), "Puzzle generation failed (not ok)");
|
||||
Assertions.assertEquals(17, Slotinfo.wordCount(0, slotInfo), "Number of assigned words changed");
|
||||
Assertions.assertEquals("POENIGE", Lemma.asWord(slotInfo[0].assign().w));
|
||||
Assertions.assertEquals(-1L, filled.grid().grid().lo);
|
||||
Assertions.assertEquals(255L, filled.grid().grid().hi);
|
||||
filled.grid().gridToString(mask);
|
||||
var aa = new PuzzleResult(new Clued(mask), slotInfo, filled).exportFormatFromFilled(1, new Rewards(1, 1, 1));
|
||||
Assertions.assertEquals(-1L, grid.lo);
|
||||
Assertions.assertEquals(255L, grid.hi);
|
||||
var g = new Gridded(grid);
|
||||
g.gridToString(mask);
|
||||
var aa = new PuzzleResult(new Clued(mask), g, slotInfo, filled).exportFormatFromFilled(1, new Rewards(1, 1, 1));
|
||||
|
||||
}
|
||||
@Test
|
||||
@@ -205,9 +207,9 @@ public class MainTest {
|
||||
System.out.println("[DEBUG_LOG] Simplicity: " + res.filled().stats().simplicity);
|
||||
System.out.println("[DEBUG_LOG] ClueMap Size: " + Slotinfo.wordCount(0, res.slots()));
|
||||
System.out.println("[DEBUG_LOG] Grid:");
|
||||
System.out.println(res.filled().grid().renderHuman(res.clues().c()));
|
||||
System.out.println(res.filled().grid().gridToString(res.clues().c()));
|
||||
System.out.println(res.filled().grid().renderHuman(res.clues().c()));
|
||||
System.out.println(res.grid().renderHuman(res.clues().c()));
|
||||
System.out.println(res.grid().gridToString(res.clues().c()));
|
||||
System.out.println(res.grid().renderHuman(res.clues().c()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user