Gather data

This commit is contained in:
mike
2026-01-10 00:55:32 +01:00
parent 4f42c613a0
commit a444f943b9
4 changed files with 19 additions and 57 deletions

View File

@@ -7,7 +7,7 @@ import puzzle.SwedishGenerator.Grid;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import static java.nio.charset.StandardCharsets.*;
import static puzzle.SwedishGenerator.R;
import static puzzle.SwedishGenerator.Lemma;
import static puzzle.SwedishGenerator.Slot;
@@ -58,10 +58,6 @@ public record Export() {
static long pack(int r, int c) { return (((long) r) << 32) ^ (c & 0xFFFFFFFFL); }
long l1, l2;
public Bit() {
l1 = 0L;
l2 = 0L;
}
public boolean get(int bitIndex) {
if (bitIndex < 64) return (l1 & (1L << bitIndex)) != 0L;
return (l2 & (1L << (bitIndex & 63))) != 0L;
@@ -86,18 +82,19 @@ public record Export() {
public void clear() { Arrays.fill(bits, 0L); }
}
private record Placed(Lemma lemma, int startRow, int startCol, String direction, int arrowRow, int arrowCol, int[] cells, boolean isReversed) {
record Placed(Lemma lemma, int startRow, int startCol, char direction, int arrowRow, int arrowCol, int[] cells, boolean isReversed) {
static final String HORIZONTAL = "h";
static final String VERTICAL = "v";
public static final char HORIZONTAL = 'h';
static final char VERTICAL = 'v';
}
public record Rewards(int coins, int stars, int hints) { }
public record WordOut(Lemma lemma, int startRow, int startCol, String direction, int arrowRow, int arrowCol, boolean isReversed, int complex) {
public record WordOut(String word, int[] cell, int startRow, int startCol, char direction, int arrowRow, int arrowCol, boolean isReversed, int complex, String[] clue) {
public String word() { return new String(lemma().word(), java.nio.charset.StandardCharsets.US_ASCII); }
public String[] clue() { return lemma.clue(); }
public WordOut(Lemma l, int startRow, int startCol, char d, int arrowRow, int arrowCol, boolean isReversed) {
this(new String(l.word(), US_ASCII), new int[]{ arrowRow, arrowCol, startRow, startCol }, startRow, startCol, d, arrowRow, arrowCol, isReversed, l.simpel(), l.clue());
}
}
public record ExportedPuzzle(String[] gridv2, WordOut[] words, int difficulty, Rewards rewards) { }
@@ -111,7 +108,7 @@ public record Export() {
var cells = new int[s.len()];
for (int i = 0, len = s.len(); i < len; i++) cells[i] = s.pos(i);
String direction;
char direction;
var isReversed = false;
var startRow = Grid.r(cells[0]);
var startCol = Grid.c(cells[0]);
@@ -200,9 +197,7 @@ public record Export() {
var gridv2 = new String[Math.max(0, maxR - minR + 1)];
for (int r = minR, i = 0; r <= maxR; r++, i++) {
var row = new StringBuilder(Math.max(0, maxC - minC + 1));
for (var c = minC; c <= maxC; c++) {
row.append(letterAt.getOrDefault(Bit.pack(r, c), '#'));
}
for (var c = minC; c <= maxC; c++) row.append(letterAt.getOrDefault(Bit.pack(r, c), '#'));
gridv2[i] = row.toString();
}
@@ -215,8 +210,7 @@ public record Export() {
p.direction,
p.arrowRow - MIN_R,
p.arrowCol - MIN_C,
p.isReversed,
p.lemma.simpel()
p.isReversed
)).toArray(WordOut[]::new);
return new ExportedPuzzle(gridv2, wordsOut, difficulty, rewards);
}