introduce bitloops

This commit is contained in:
mike
2026-01-12 22:22:19 +01:00
parent 88a61e6f4d
commit a9b4dfb422
4 changed files with 148 additions and 119 deletions

View File

@@ -19,18 +19,23 @@ import static puzzle.SwedishGenerator.*;
public class ExportFormatTest {
static final byte CLUE_UP = 0;
static final byte CLUE_RIGHT = 1;
static final byte CLUE_DOWN = 2;
static final byte CLUE_LEFT = 3;
@Test
void testExportFormatFromFilled() {
var swe = new SwedishGenerator(new Rng(0));
var grid = Grid.createEmpty();
// Place a '2' (right) at (0,0)
grid.setClue(0, (byte) '2');
// Place a RIGHT clue at (0,0)
grid.setClue(0, CLUE_RIGHT);
// This creates a slot starting at (0,1)
var clueMap = new HashMap<Integer, Long>();
// key = (cellIndex << 4) | direction
var key = 2;
// key = (cellIndex << 3) | (direction + 1)
var key = (0 << 3) | (CLUE_RIGHT + 1);
clueMap.put(key, Lemma.from("TEST"));
// Manually fill the grid letters for "TEST" at (0,1), (0,2), (0,3), (0,4)
@@ -38,8 +43,8 @@ public class ExportFormatTest {
grid.setLetter(Grid.offset(0, 2), (byte) 'E');
grid.setLetter(Grid.offset(0, 3), (byte) 'S');
grid.setLetter(Grid.offset(0, 4), (byte) 'T');
// Terminate thGrid.offset(e slot at) (0,5) with another digit to avoid it extending to MAX_WORD_LENGTH
grid.setClue(Grid.offset(0, 5), (byte) '1');
// Terminate the slot at (0,5) with another digit to avoid it extending to MAX_WORD_LENGTH
grid.setClue(Grid.offset(0, 5), CLUE_UP);
var fillResult = new FillResult(true, new Gridded(grid), clueMap, new FillStats());
var puzzleResult = new PuzzleResult(swe, null, null, fillResult);