introduce bitloops

This commit is contained in:
mike
2026-01-14 23:15:52 +01:00
parent 5849f543c5
commit 04e3844732
6 changed files with 254 additions and 207 deletions

View File

@@ -5,20 +5,28 @@ import org.junit.jupiter.api.Test;
import puzzle.Export.Clued;
import puzzle.Export.Gridded;
import puzzle.Export.Placed;
import puzzle.Export.Rewards;
import puzzle.Export.PuzzleResult;
import puzzle.Export.Rewards;
import puzzle.SwedishGenerator.FillResult;
import puzzle.SwedishGenerator.Grid;
import puzzle.SwedishGenerator.Rng;
import java.io.IOException;
import java.nio.file.Paths;
import static org.junit.jupiter.api.Assertions.*;
import static puzzle.MainTest.*;
import static puzzle.MainTest.LETTER_E;
import static puzzle.MainTest.LETTER_T;
import static puzzle.SwedishGenerator.*;
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.SwedishGenerator.C;
import static puzzle.SwedishGenerator.Clues;
import static puzzle.SwedishGenerator.FillStats;
import static puzzle.SwedishGenerator.R;
import static puzzle.SwedishGenerator.STACK_SIZE;
import static puzzle.SwedishGenerator.Slot;
import static puzzle.SwedishGenerator.placeWord;
import static puzzle.SwedishGeneratorTest.OFF_0_1;
import static puzzle.SwedishGeneratorTest.OFF_0_2;
import static puzzle.SwedishGeneratorTest.OFF_0_3;
import static puzzle.SwedishGeneratorTest.OFF_0_4;
import static puzzle.SwedishGeneratorTest.OFF_0_5;
import static puzzle.SwedishGeneratorTest.TEST;
public class ExportFormatTest {
@@ -26,7 +34,7 @@ public class ExportFormatTest {
static final byte CLUE_RIGHT = 1;
static final byte CLUE_UP = 2;
static final byte CLUE_LEFT = 3;
@Test
void testExportFormatFromFilled() {
var swe = new SwedishGenerator(new Rng(0), new int[STACK_SIZE], Clues.createEmpty());
@@ -36,21 +44,17 @@ public class ExportFormatTest {
clues.setClue(0, CLUE_RIGHT);
// 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(Grid.offset(0, 5), CLUE_LEFT);
var grid = clues.toGrid();
clues.setClue(OFF_0_5, CLUE_LEFT);
var grid = new Gridded(clues.toGrid());
var clueMap = new long[300];
// key = (cellIndex << 2) | (direction)
var key = (0) | (CLUE_RIGHT);
clueMap[key] = SwedishGeneratorTest.TEST;
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);
clueMap[key] = TEST;
assertTrue(placeWord(grid.grid(), key, lo, 0L, TEST));
// Manually fill the grid letters for "TEST" at (0,1), (0,2), (0,3), (0,4)
grid.setLetterLo(OFF_0_1, LETTER_T);
grid.setLetterLo(OFF_0_2, LETTER_E);
grid.setLetterLo(OFF_0_3, LETTER_S);
grid.setLetterLo(OFF_0_4, LETTER_T);
var fillResult = new FillResult(true, new Gridded(grid), clueMap, new FillStats(0, 0, 0, 0));
var fillResult = new FillResult(true, grid, clueMap, new FillStats(0, 0, 0, 0));
var puzzleResult = new PuzzleResult(new Clued(clues), fillResult);
var rewards = new Rewards(10, 5, 1);