New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Put FastRand
into the core library
#167
Comments
further testing would be needed, I am short on time for that. |
That's a good point, although, I guess it doesn't really matter that much if it's hard to tell. It depends on what you're using it for I suppose. |
Hey guys! I chose FastRand for Mercury because it's one of the faster RNG algorithms out there. The speed comes at the price of true 'randomness' though, there are certainly noticeable patterns & it compares quite unfavourably to other RNG algorithms in that respect. It's a really great choice in situations where speed is more desirable than a good random distribution, and a really poor choice when random distribution is important. |
Thanks for the info @Matthew-Davey. I suspected as much. I think if we make it clear that FastRand is a faster alternative to normal Random and document the pros and cons as you've described here it makes sense to be part of the library. People can choose to use it if it makes sense for their situation. One question though @Matthew-Davey. Why did you make it a static class? I'm thinking if we pull it up into the core library, we should make it a normal class much like Something like:
The other benefit of this approach is that it might make sense to match the signature of the |
Hi @craftworkgames, I made it static purely for speed. I anticipated random numbers being generated tens or hundreds of thousands times a second - and a static method call is marginally faster than an instance method call, especially if it can be inlined. There's only about 0.7 nanoseconds in it, but it adds up. But then I was happy to trade away some fundamental OO principles in favour of speed - you might not want to make that same trade-off, especially for a general purpose library. |
Done. |
When we combined the Mercury Particle Engine with MonoGame.Extended it came with a class called
FastRand
for generating random numbers really fast.kosmonautgames noticed on the forums that this implementation is really good.
Unfortunately, at the moment the code is an internal static class in the
MonoGame.Extended.Particles
namespace. We should consider moving it up to the root namespace.The text was updated successfully, but these errors were encountered: