Gather data

This commit is contained in:
mike
2026-01-06 00:22:39 +01:00
parent 5bba12caf8
commit 7154ee757c
2 changed files with 41 additions and 31 deletions

View File

@@ -31,15 +31,15 @@ public final class ExportFormat {
var W = g[0].length;
// 1) extract "placed" list from all clue digits in the filled grid
List<Placed> placed = new ArrayList<>();
var allSlots = extractSlots(g);
var clueMap = puz.filled().clueMap;
var placed = new ArrayList<Placed>();
var allSlots = extractSlots(g);
var clueMap = puz.filled().clueMap;
for (var s : allSlots) {
var word = clueMap.get(s.key());
if (word == null) continue;
var p = extractPlacedFromSlot(puz.dict(),s, word);
var p = extractPlacedFromSlot(puz.dict(), s, word);
if (p == null) continue;
placed.add(p);
}
@@ -99,9 +99,10 @@ public final class ExportFormat {
}
// 5) words output with cropped coordinates
List<WordOut> wordsOut = new ArrayList<>(placed.size());
var wordsOut = new ArrayList<WordOut>(placed.size());
for (var p : placed) {
wordsOut.add(new WordOut(
p.lemma,
p.word,
p.clue, // placeholder = word (same as JS)
p.startRow - minR,
@@ -111,7 +112,7 @@ public final class ExportFormat {
p.arrowRow - minR,
p.arrowCol - minC,
p.isReversed,
puz.dict().words().get(p.word).simpel()
p.lemma.simpel()
));
}
@@ -121,7 +122,7 @@ public final class ExportFormat {
/**
* Convert a generator Slot + assigned word into a Placed object for export.
*/
private static Placed extractPlacedFromSlot(Dict dict,Slot s, String word) {
private static Placed extractPlacedFromSlot(Dict dict, Slot s, Lemma lemma) {
int r = s.clueR();
int c = s.clueC();
char d = s.dir();
@@ -167,12 +168,13 @@ public final class ExportFormat {
}
return new Placed(
word,
dict.words().get(word).clue().toArray( String[]::new), // clue placeholder
lemma,
lemma.word(),
dict.words().get(lemma.word()).clue().toArray(String[]::new), // clue placeholder
startRow,
startCol,
direction,
word, // answer
lemma.word(), // answer
arrowRow,
arrowCol,
cells,
@@ -187,13 +189,14 @@ public final class ExportFormat {
* @param direction "h" | "v"
* @param cells word cells
* @param arrow [arrowRow, arrowCol] */
private record Placed(String word, String[] clue, int startRow, int startCol, String direction, String answer, int arrowRow, int arrowCol, List<int[]> cells, int[] arrow,
private record Placed(Lemma lemma, String word, String[] clue, int startRow, int startCol, String direction, String answer, int arrowRow, int arrowCol, List<int[]> cells,
int[] arrow,
boolean isReversed) { }
public record Rewards(int coins, int stars, int hints) { }
/// @param direction "h" | "v"
public record WordOut(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) { }
}