/**
 * Returns a random number within a normal distribution (Bell/Gaussian curve)
 * @param {number} [quality=6] controls number of "die rolls" used to approximate curve, more rolls - better approximation but higher cost of computation
 * @param {function():number} random
 * @returns {number} value between 0 and 1 with normal weight at 0.5
 */
export function randomGaussian(random, quality = 6) {
    let s = 0;

    for (let i = 0; i < quality; i++) {
        s += random();
    }

    return s / quality;
}
