原文链接: seedrandom 支持设置种子的随机数
上一篇: regl Stencil [todo]
下一篇: vscode glsl shader lint 配置和自动格式化
主要用于在一定条件下获得可控的随机数序列
生成100内的随机数, 由于种子一样, 所以数值也是一样的
const seedRandom = require("seedrandom");
function f() {
const r = seedRandom("hello");
console.log(
Array(10)
.fill(0)
.map(() => (r() * 100) | 0)
.join(",")
);
}
for (let i = 0; i < 10; i++) {
f();
}