3 ms·
A while back there was a post about a randomness bug in Asheron's Call, the "Wi flag" [0]. I posted a comment there and was offered helpful answers about doing
by EarthLaunch 3y ago
A while back there was a post about a randomness bug in Asheron's Call, the "Wi flag" [0]. I posted a comment there and was offered helpful answers about doing weighted randomness [1].
This library seems to solve that problem and half a dozen others! Like: Reading code with functions named for their purpose is better than a string of arithmetic operations in most cases. Thank you for sharing this! Will use in my game! [2]
const weightedDiceRoll =
weighted(
[1,2,3,4,5,6],
[1,1,1,1,1,10]
)
// will return 6 much more often than the other options
0: https://news.ycombinator.com/item?id=34742505 https://news.ycombinator.com/item?id=34742505
1: https://news.ycombinator.com/item?id=34742985 https://news.ycombinator.com/item?id=34742985
2: https://github.com/Suncapped/babs https://github.com/Suncapped/babs
- chriscavs 3y agothanks for the comment, i'm happy you like it!