本文整理汇总了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;未经允许,请勿转载。 |
请发表评论