better patterns
All checks were successful
Deploy to Pages / build (push) Successful in 26s

This commit is contained in:
Andras Schmelczer 2026-09-11 22:46:23 +01:00
commit 171fbf1927
9 changed files with 2589 additions and 37 deletions

View file

@ -524,8 +524,10 @@ function randomPatternPenalty(
// Half-board steps have equally near joints in both directions and tend to look brick-like.
let penalty = close(Math.abs(step), s.length / 2) ? 1 : 0;
for (let distance = 2; distance <= recent.length; distance++) {
if (Math.abs(jointStep(recent.at(-distance)!.offset, phase, s.length)) <= similar)
penalty += 5 - distance;
const separation = Math.abs(jointStep(recent.at(-distance)!.offset, phase, s.length));
// Two rows apart, joints within a board width still read as an H, even without exact alignment.
if (distance === 2 && separation < Math.min(s.width, s.length / 6) - EPSILON) penalty += 12;
if (separation <= similar) penalty += 5 - distance;
}
if (step * previousStep > 0) {
penalty += 1;
@ -644,6 +646,12 @@ function fraction(seed: string): number {
hash ^= seed.charCodeAt(i);
hash = Math.imul(hash, 16777619);
}
// Avalanche the final bits: adjacent candidate numbers must not yield almost identical offsets.
hash ^= hash >>> 16;
hash = Math.imul(hash, 0x85ebca6b);
hash ^= hash >>> 13;
hash = Math.imul(hash, 0xc2b2ae35);
hash ^= hash >>> 16;
return (hash >>> 0) / 4294967296;
}