introduce bitloops

This commit is contained in:
mike
2026-01-16 22:46:04 +01:00
parent ecbc408cce
commit 91722ecc60
4 changed files with 202 additions and 124 deletions

View File

@@ -1,5 +1,6 @@
package puzzle;
import lombok.AllArgsConstructor;
import lombok.val;
import org.junit.jupiter.api.Test;
import puzzle.Export.Clued;
@@ -9,11 +10,13 @@ import puzzle.Export.PuzzleResult;
import puzzle.Export.Rewards;
import puzzle.SwedishGenerator.FillResult;
import puzzle.SwedishGenerator.Rng;
import puzzle.SwedishGeneratorTest.Idx;
import java.io.IOException;
import java.nio.file.Paths;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static puzzle.ExportFormatTest.Clue.RIGHT;
import static puzzle.SwedishGenerator.C;
import static puzzle.SwedishGenerator.Clues;
import static puzzle.SwedishGenerator.FillStats;
@@ -35,19 +38,33 @@ public class ExportFormatTest {
static final byte CLUE_UP = 2;
static final byte CLUE_LEFT = 3;
@AllArgsConstructor
enum Clue {
DOWN(CLUE_DOWN),
RIGHT(CLUE_RIGHT),
UP(CLUE_UP),
LEFT(CLUE_LEFT);
Clue(byte dir) {
this.dir = dir;
this.clueDir = dir;
}
final byte dir;
final int clueDir;
}
@Test
void testExportFormatFromFilled() {
var swe = new SwedishGenerator(new Rng(0), new int[STACK_SIZE], Clues.createEmpty());
val clues = Clues.createEmpty();
// Place a RIGHT clue at (0,0)
clues.setClue(0, CLUE_RIGHT);
clues.setClueLo(Idx.IDX_0_0.lo, RIGHT.dir);
// This creates a slot starting at (0,1)
// Terminate the slot at (0,5) with another digit to avoid it extending to MAX_WORD_LENGTH
clues.setClue(OFF_0_5, CLUE_LEFT);
clues.setClueLo(Idx.IDX_0_5.lo, CLUE_LEFT);
var grid = new Gridded(clues.toGrid());
var clueMap = new long[300];
var clueMap = new long[SwedishGenerator.CLUE_INDEX_MAX_SIZE];
// key = (cellIndex << 2) | (direction)
var key = Slot.packSlotKey(0, CLUE_RIGHT);
var lo = (1L << OFF_0_1) | (1L << OFF_0_2) | (1L << OFF_0_3) | (1L << OFF_0_4);