Gather data
This commit is contained in:
@@ -17,6 +17,14 @@ import java.util.function.Predicate;
|
||||
@SuppressWarnings("ALL")
|
||||
public record SwedishGenerator(int W, int H, int SIZE, int MAX_LEN) {
|
||||
|
||||
class Data {
|
||||
|
||||
static byte[] EXAMPLE = new byte[0];
|
||||
}
|
||||
public SwedishGenerator {
|
||||
Data.EXAMPLE = new byte[SIZE];
|
||||
Arrays.fill(Data.EXAMPLE, (byte) '#');
|
||||
}
|
||||
public SwedishGenerator(int W, int H) { this(W, H, W * H, Math.min(W, H)); }
|
||||
public SwedishGenerator() { this(9, 8); }
|
||||
|
||||
@@ -91,7 +99,7 @@ public record SwedishGenerator(int W, int H, int SIZE, int MAX_LEN) {
|
||||
int getOffset(int r, int c) { return r * W + c; }
|
||||
|
||||
boolean isLettercell(int r, int c) {
|
||||
return isLetterCell(getCharAt(r,c));
|
||||
return isLetterCell(getCharAt(r, c));
|
||||
}
|
||||
char getCharAt(int r, int c) {
|
||||
return (char) (g[getOffset(r, c)] & 0xFF);
|
||||
@@ -113,9 +121,7 @@ public record SwedishGenerator(int W, int H, int SIZE, int MAX_LEN) {
|
||||
}
|
||||
// ---------------- Grid helpers ----------------
|
||||
Grid makeEmptyGrid() {
|
||||
var g = new byte[H * W];
|
||||
Arrays.fill(g, (byte) '#');
|
||||
return new Grid(g, H, W);
|
||||
return new Grid(Data.EXAMPLE.clone(), H, W);
|
||||
}
|
||||
|
||||
String gridToString(Grid g) {
|
||||
@@ -670,9 +676,9 @@ public record SwedishGenerator(int W, int H, int SIZE, int MAX_LEN) {
|
||||
var n = 0;
|
||||
|
||||
for (var i = 0; i < s.len; i++) {
|
||||
int r = s.rs[i], c = s.cs[i];
|
||||
char cur = grid.getCharAt(r, c);
|
||||
var ch = w.charAt(i);
|
||||
int r = s.rs[i], c = s.cs[i];
|
||||
char cur = grid.getCharAt(r, c);
|
||||
var ch = w.charAt(i);
|
||||
if (cur == '#') {
|
||||
urs[n] = r;
|
||||
ucs[n] = c;
|
||||
|
||||
Reference in New Issue
Block a user