當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript seedrandom.alea函數代碼示例

本文整理匯總了TypeScript中seedrandom.alea函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript alea函數的具體用法?TypeScript alea怎麽用?TypeScript alea使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了alea函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: restoreRng

export function restoreRng(state: any): GeneratorInterface {
    return new SeedrandomGenerator(
        seedrandom.alea('', {
            state
        })
    );
}
開發者ID:mschroeder,項目名稱:6502.ts,代碼行數:7,代碼來源:factory.ts

示例2: generate

function generate() {
    const thisIterations = getControlInteger(iterationsInput, 0, MAX_ITERATIONS, DEFAULT_ITERATIONS);
    const thisSeed = seedInput.value;
    const thisVariation = getControlInteger(variationInput, 0, MAX_VARIATION, DEFAULT_VARIATION);
	if (mask) {
		if (iterations === thisIterations && seed === thisSeed && variation === thisVariation) {
			return;
		}
	}
    iterations = thisIterations;
    seed = thisSeed;
    variation = thisVariation;
    const path = BlockFractal.makeBlockFractal({
        random: seedrandom.alea(seed),
        iterations,
        variation: variation / 100
    });
	mask = path.rasterize();
    //const maxSize = (Math.pow(2, iterations + 2) - 1) * zoom;
	mult = Math.pow(2, 7 - iterations);
	document.getElementById('label').innerText = seed;
	document.title = `BlockFractal - ${seed}`;
	let newHash = `#${encodeURIComponent(seed)}`;
	if (variation != DEFAULT_VARIATION) {
		newHash += `/v=${variation}`;
	}
	if (hashSeed !== seed) {
		window.location.hash = newHash;
		hashSeed = seed;
	} else {
		window.location.replace(newHash);
	}
}
開發者ID:sbj42,項目名稱:sbj42.github.io,代碼行數:33,代碼來源:demo.ts

示例3: createRng

export function createRng(seed: number): GeneratorInterface {
    if (seed < 0) {
        seed = Math.random();
    }

    return new SeedrandomGenerator(
        seedrandom.alea(seed as any, {
            state: true
        })
    );
}
開發者ID:mschroeder,項目名稱:6502.ts,代碼行數:11,代碼來源:factory.ts

示例4: constructor

 constructor(
     mean: number, stdDeviation: number, dtype?: keyof RandNormalDataTypes,
     truncated?: boolean, seed?: number) {
   this.mean = mean;
   this.stdDev = stdDeviation;
   this.dtype = dtype;
   this.nextVal = NaN;
   this.truncated = truncated;
   if (this.truncated) {
     this.upper = this.mean + this.stdDev * 2;
     this.lower = this.mean - this.stdDev * 2;
   }
   const seedValue = seed ? seed : Math.random();
   this.random = seedrandom.alea(seedValue.toString());
 }
開發者ID:ScapeQin,項目名稱:deeplearnjs,代碼行數:15,代碼來源:rand.ts


注:本文中的seedrandom.alea函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。