-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add FlxRandom seeded random generator #197
Comments
I like this idea. At first I thought it would just make things more complicated, but since The only problem I see is |
|
We could also change the |
I think that's an excellent solution! We'll go with that. |
I love GSkinner's seeded random generator (and I was hoping just to make this a frontend of that class); but, I will be using HaxeFlixel's However, I think HaxeFlixel's random class looks to cluttered and complicated, so even though this class will use the same seeded random generator under the hood and HaxeFlixel, I will be making this |
EDIT: This monologue can be safely ignored! See my next comment. Notice: In these examples, I'm using the One problem I am already noticing (which may or may not end up being any issue), Haxe doesn't "use" the The current random number generator used by HaxeFlixel returns a value between 1 and that ~2 billion value inclusively (and never results in You get a similar problem of only returning even (or perhaps it's odd) values if you return the max ranges of Is this going to be an issue? Will people in practice ever want values exactly between the minimum and maximum of a data type? |
Ignore my last monologue, after doing more research, according to the experts, HaxeFlixel uses a "better" multiplier. The only large difference is that Give me one more night to do a bit more research, and after that, I will have random number generation down. |
That's how it's done in Java (using algorithms described in "Art of Programming"): |
Temporarily on hold for this reason:
I would like to make sure the random number generator works the same in both AS3 and Haxe. However, I could theoretically just upload what I have of the generator now, and then tweak it if needed when the reason for the problem (whether it be in my code or Haxe) has been found. |
I think you could upload what you have and work on it later. The idea of an inter-operable RNG is awesome, but for now we need all classes in place so there will be no merge conflicts in the future. |
I feel as a monk walking down from his mountain, enlightened with new wisdom; Lehmer pseudo-randomness: I understand you, and we are one. I have created a pull request with the new
|
haha, best comment ever! 😄 |
Added in 8bad64f |
(I touched on this briefly, but I would like to present the idea completely)
Flixel already has a seeded random number generator, but right now the functions are strewn about a little everywhere: Google Docs: FlxMath (see the highlighted blue functions)
What I would like to do is use GSkinner's seeded random generator as a base for a new
FlxRandom
class.First of all you have all the static functions:
Or, you can instead create a new instance (which contains all those methods) that uses a specific seed:
And most importantly, the static random methods of
FlxG
are replaced with an instance ofFlxRandom
. So instead of accessingFlxG.shuffle(array)
, you useFlxG.random.shuffle(array)
, plus you get access to the entire collection of FlxRandom helper functions.The text was updated successfully, but these errors were encountered: