mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Fix non-uniform distribution for freeplay shape color palette (#789)
* use nextIntRange instead of nextIntRangeInclusive * Remove nextIntRangeInclusive This function gave the minimum and maximum integer half as much weight, and it was not used anywhere except to generate a freeplay shape color palette, and that now uses nextIntRange.
This commit is contained in:
parent
da9f91aca4
commit
a79500d574
@ -108,17 +108,6 @@ export class RandomNumberGenerator {
|
|||||||
assert(max > min, "rng: max <= min");
|
assert(max > min, "rng: max <= min");
|
||||||
return Math.floor(this.next() * (max - min) + min);
|
return Math.floor(this.next() * (max - min) + min);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param {number} min
|
|
||||||
* @param {number} max
|
|
||||||
* @returns {number} Integer in range [min, max]
|
|
||||||
*/
|
|
||||||
nextIntRangeInclusive(min, max) {
|
|
||||||
assert(Number.isFinite(min), "Minimum is no integer");
|
|
||||||
assert(Number.isFinite(max), "Maximum is no integer");
|
|
||||||
assert(max > min, "rng: max <= min");
|
|
||||||
return Math.round(this.next() * (max - min) + min);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} min
|
* @param {number} min
|
||||||
|
@ -369,7 +369,7 @@ export class HubGoals extends BasicSerializableObject {
|
|||||||
if (allowUncolored) {
|
if (allowUncolored) {
|
||||||
universalColors.push(enumColors.uncolored);
|
universalColors.push(enumColors.uncolored);
|
||||||
}
|
}
|
||||||
const index = rng.nextIntRangeInclusive(0, colorWheel.length - 3);
|
const index = rng.nextIntRange(0, colorWheel.length - 2);
|
||||||
const pickedColors = colorWheel.slice(index, index + 3);
|
const pickedColors = colorWheel.slice(index, index + 3);
|
||||||
pickedColors.push(rng.choice(universalColors));
|
pickedColors.push(rng.choice(universalColors));
|
||||||
return pickedColors;
|
return pickedColors;
|
||||||
|
Loading…
Reference in New Issue
Block a user