News for hackers. Stuff that matters.
Re:A New Algorithm for Controlled Randomness by richard_todd on Sunday September 01, 2019 @12:11AM (#20850453)
By the time you are tracking misses on each class of event and adjusting the probabilities, you might as well just use random permutations of the desired distribution of outcomes. Like if the sword is supposed to hit 90%, just run through a 10-bit sequence with 9 ones and a zero, and shuffle it after every 10 attempts.
Re:A New Algorithm for Controlled Randomness by 1wd on Sunday September 01, 2019 @03:23AM (#20850963)
Famously Tetris typically uses this "grab bag randomizer" (or various other controlled forms of randomness). I was surprised Tetris was not mentioned at all in the article.

https://tetris.fandom.com/wiki/Random_Generator

https://katta.mere.st/different-tetris-algorithms/

Re:A New Algorithm for Controlled Randomness by XCSme on Sunday September 01, 2019 @07:15AM (#20851646)
Are you talking about randomly shuffling the bits or getting a new permutation? Any suggestions on how to quickly randomly shuffle the bits of a number?
Re:A New Algorithm for Controlled Randomness by richard_todd on Sunday September 01, 2019 @10:26AM (#20852449)
Randomly shuffling the bits _is_ a new permutation (of those bits). There may be a faster way to shuffle the bits of whole bytes/words on some architectures, but for the general case I suspect a normal shuffling algorithm (like Fisher-Yates) and shifts+and+xor swapping is best.
Re:A New Algorithm for Controlled Randomness by XCSme on Sunday September 01, 2019 @01:40PM (#20853514)
Oh, sorry for not making it clear, when I meant permutation I was referring to the the immediately next permutation. I guess after current set is over you could also take the Xth permutation of the current state, where X is a random integer. (so you randomly skip some permutations to not make it predictable).
Re:A New Algorithm for Controlled Randomness by richard_todd on Sunday September 01, 2019 @07:05PM (#20855584)
Yeah jumping ahead by X permutations would be good as well.
Re:A New Algorithm for Controlled Randomness by b0blee on Sunday September 01, 2019 @03:05AM (#20850918)
That sounds a lot easier to me.