3 ms·
I don't know enough about SHA256 to say whether or not it's good enough, I'll assume it is. Performant enough strongly depends on the game. However looking at
by yoklov 11y ago
I don't know enough about SHA256 to say whether or not it's good enough, I'll assume it is.
Performant enough strongly depends on the game. However looking at the implementation of the algorithm on wikipedia[0], that looks extremely slow by RNG standards. Most RNGs finish in a handful of instructions, but building the 'message schedule array' takes 64 steps, and the 'main compression loop' also takes 64 steps. Consider that to reduce these to a range you'll have to throw out iterations (you need to do this with any RNG to avoid bias), you're looking at a lot of wasted time.
Maybe you can afford to waste that time, but given that there are much simpler and more efficient RNG algorithms, I'm not sure why you wouldn't use one of those.
[0]: https://en.wikipedia.org/wiki/SHA-2#Pseudocode https://en.wikipedia.org/wiki/SHA-2#Pseudocode