/**
 *
 * @param {number} [seed]
 * @returns {(function():number)|{setCurrentSeed:( function(v:number):void),getCurrentSeed:(function():number)}}
 */
export function seededRandom_Mulberry32(seed = 0) {
    let _seed = seed;

    function random() {
        _seed += 0x6D2B79F5;

        // Mulberry32 generator
        let t = _seed;

        t = Math.imul(t ^ t >>> 15, t | 1);

        t ^= t + Math.imul(t ^ t >>> 7, t | 61);

        return ((t ^ t >>> 14) >>> 0) / 4294967296;
    }

    random.setCurrentSeed = function (v) {
        _seed = v;
    };

    random.getCurrentSeed = function () {
        return _seed;
    };

    return random;
}
