This commit is contained in:
33333-33333 2026-09-16 20:53:17 +09:00
commit 8f80997b0d
256 changed files with 4044 additions and 966 deletions

View file

@ -30,15 +30,9 @@ key,
clamp(get(traits) + rng.range(-amount * mutationScale, amount * mutationScale), min, max)
]));
}
function blendTraits(a, b, t) {
return Object.fromEntries(traitFields.map(([key, get]) => [key, lerp(get(a), get(b), t)]));
}
function emptyTraitSums() {
return Object.fromEntries(traitFields.map(([key]) => [key, 0]));
}
function addTraits(sum, traits) {
for (const [key, get, , , , sumScale] of traitFields) sum[key] += get(traits) * sumScale;
}
function averageTraits(sum, count) {
return Object.fromEntries(traitFields.map(([key, , , , , sumScale]) => [key, sum[key] / count / sumScale]));
}
@ -86,9 +80,6 @@ bestCount = count;
}
return bestId;
}
function traitDistance(a, b) {
return traitFields.reduce((sum, [, get, , , , distanceScale]) => sum + Math.abs(get(a) - get(b)) * distanceScale, 0);
}
function hslToRgb(h, s, l) {
const hue = (p, q, t) => {
if (t < 0) t += 1;