考虑均匀的情况下
function limitAimToConstantNumber(aim, total=160) {
const l = aim instanceof Array ? aim.length : aim
const res = []
const left = Math.ceil(total % l)
for(let i=0; i < l; i++) {
res[i] = Math.floor(total / l)
}
for(let j=0; j < left; j++) {
const rL = Math.floor(Math.random() * l)
res[rL] = res[rL] + 1
}
return res
}
结果比较均匀...