introduce bitloops

This commit is contained in:
mike
2026-01-14 12:01:13 +01:00
parent 8e049b3fa5
commit 6afe675a9d
3 changed files with 30 additions and 44 deletions

View File

@@ -27,8 +27,6 @@ import static java.nio.charset.StandardCharsets.*;
* A) generate randoms for and idx and direction (clue together)
* B) convert IDX_PATH_0_BASE into bit-pattern (i think) Length should not be checked, just left empty if not good.
* C) store more information in the byte[] even consider the long[] or try sqeeze the 288 options (clue) in a byte.
* D) separate clue into three long pairs of hi and lo, (v,h,r) so we do not store the clue anymore in the grid array at all
* E) store letter-set also in a long pair so we can use it in path determinations
* F) pre-determine random clue arrangements, so they do not involve impossible clue's such as bottom at last or the line before that and such to all sides
* G) Check 3wall, the current implementation may be faster, but the accuracy is lower, degrade performance on the filler
*/
@@ -391,11 +389,8 @@ public record SwedishGenerator(Rng rng, int[] stack, Clues cache) {
static Slot from(int key, long lo, long hi) { return new Slot(key, lo, hi); }
public int length() { return Long.bitCount(lo) + Long.bitCount(hi); }
public int clueIndex() { return clueIndex(key); }
public static int clueIndex(int key) { return key >>> BIT_FOR_DIR; }
public static int dir(int key) { return key & 3; }
public boolean horiz() { return horiz(key); }
public boolean increasing() { return (key & 2) == 0; }
public static boolean increasing(int dir) { return (dir & 2) == 0; }
public IntStream walk() { return Gridded.walk((byte) key, lo, hi); }
public static boolean horiz(int d) { return (d & 1) != 0; }