redo
This commit is contained in:
@@ -18,7 +18,6 @@ import puzzle.SwedishGenerator.Grid;
|
||||
import puzzle.SwedishGenerator.Slotinfo;
|
||||
import static puzzle.Masker.Slot;
|
||||
import static puzzle.SwedishGenerator.X;
|
||||
import puzzle.SwedishGenerator.Lemma;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -89,22 +88,23 @@ public record Export() {
|
||||
|
||||
public record PuzzleResult(Signa clues, Puzzle puzzle, Slotinfo[] slots, FillResult filled) {
|
||||
|
||||
public String exportGrid(ClueSign clueChar, byte[] template) {
|
||||
var sb = template.clone();
|
||||
for (var slot : slots) sb[INDEX(Slot.clueIndex(slot.key()), (C + 1))] = clueChar.replace(CLUE_CHAR(Slot.dir(slot.key())));
|
||||
puzzle.forEach((l) -> sb[INDEX(l.index(), C + 1)] = LETTER(l.d()));
|
||||
public String exportGrid(ClueSign clueChar, byte[] sb) {
|
||||
Arrays.stream(slots).map(s -> puzzle.cells[Slot.clueIndex(s.key())]).forEach(c -> sb[c.place()] = clueChar.replace(c.clueChar()));
|
||||
puzzle.forEach((l) -> sb[l.place()] = l.letter());
|
||||
return new String(sb);
|
||||
}
|
||||
public String cluesGridToString() { return gridToString(clues.c()); }
|
||||
public String gridRenderHuman() { return exportGrid(_ -> SPACE, INIT_GRID_OUTPUT_DASH_ARR); }
|
||||
public String gridGridToString() { return exportGrid(d1 -> d1, INIT_GRID_OUTPUT_ARR); }
|
||||
public String gridRenderHuman() { return exportGrid(_ -> SPACE, INIT_GRID_OUTPUT_DASH_ARR.clone()); }
|
||||
public String gridGridToString() { return exportGrid(d1 -> d1, INIT_GRID_OUTPUT_ARR.clone()); }
|
||||
public ExportedPuzzle exportFormatFromFilled(Rewards rewards) {
|
||||
if (slots.length == 0) {
|
||||
return new ExportedPuzzle(new String(INIT_GRID_OUTPUT_DASH_ARR).split("\n"), new WordOut[0], 1, rewards);
|
||||
}
|
||||
|
||||
var placed = Arrays.stream(slots)
|
||||
.map(slot -> new Placed(slot.assign().w, slot.key(), Riddle.cellWalk(slot.key(), slot.lo(), slot.hi()).mapToObj(idx-> puzzle.cells[idx]).toArray(Mask[]::new)))
|
||||
.map(slot -> new Placed(slot.assign().w, slot.key(), Riddle.cellWalk(slot.key(), slot.lo(), slot.hi())
|
||||
.mapToObj(idx -> puzzle.cells[idx])
|
||||
.toArray(Mask[]::new)))
|
||||
.toArray(Placed[]::new);
|
||||
|
||||
// 2) bounding box around all word cells + arrow cells, with 1-cell margin
|
||||
@@ -132,7 +132,7 @@ public record Export() {
|
||||
int rr = l.r() - MINR;
|
||||
int cc = l.c() - MINC;
|
||||
if (rr >= 0 && rr < height && cc >= 0 && cc < width) {
|
||||
template[rr * (width + 1) + cc] = LETTER(l.d());
|
||||
template[rr * (width + 1) + cc] = l.letter();
|
||||
}
|
||||
});
|
||||
var grid = new String(template).split("\n");
|
||||
|
||||
Reference in New Issue
Block a user