Gather data

This commit is contained in:
mike
2026-01-06 19:32:32 +01:00
parent 73f06a2b13
commit 07b629c7a0
2 changed files with 24 additions and 33 deletions

View File

@@ -14,13 +14,9 @@ import static puzzle.SwedishGenerator.*;
*/
public final class ExportFormat {
private ExportFormat() { }
private static boolean isLetter(char ch) { return ch >= 'A' && ch <= 'Z'; }
private static boolean inBounds(int H, int W, int r, int c) {
return r >= 0 && r < H && c >= 0 && c < W;
}
private ExportFormat() { }
static final String HORIZONTAL = "h", VERTICAL = "v";
private static boolean inBounds(int H, int W, int r, int c) { return r >= 0 && r < H && c >= 0 && c < W; }
// ---------- Public API ----------
@@ -92,8 +88,7 @@ public final class ExportFormat {
for (var r = minR; r <= maxR; r++) {
var row = new StringBuilder(Math.max(0, maxC - minC + 1));
for (var c = minC; c <= maxC; c++) {
var ch = letterAt.get(pack(r, c));
row.append(ch != null ? ch : '#');
row.append(letterAt.getOrDefault(pack(r, c), '#'));
}
gridv2.add(row.toString());
}
@@ -118,7 +113,7 @@ public final class ExportFormat {
return new ExportedPuzzle(gridv2, wordsOut, difficulty, rewards);
}
static final String HORIZONTAL = "h", VERTICAL = "v";
/**
* Convert a generator Slot + assigned word into a Placed object for export.
*/
@@ -196,7 +191,8 @@ public final class ExportFormat {
public record Rewards(int coins, int stars, int hints) { }
/// @param direction "h" | "v"
public record WordOut(Lemma lemma,String word, String[] clue, int startRow, int startCol, String direction, String answer, int arrowRow, int arrowCol, boolean isReversed, int complex) { }
public record WordOut(Lemma lemma, String word, String[] clue, int startRow, int startCol, String direction, String answer, int arrowRow, int arrowCol, boolean isReversed,
int complex) { }
public record ExportedPuzzle(List<String> gridv2, List<WordOut> words, int difficulty, Rewards rewards) { }
}