1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +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:
EmeraldBlock
2020-10-08 01:44:10 -05:00
committed by GitHub
parent da9f91aca4
commit a79500d574
2 changed files with 1 additions and 12 deletions

View File

@@ -108,17 +108,6 @@ export class RandomNumberGenerator {
assert(max > min, "rng: max <= 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