Skip to content
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

Replace the PRNG #31

Open
y-lohse opened this issue Sep 21, 2016 · 10 comments
Open

Replace the PRNG #31

y-lohse opened this issue Sep 21, 2016 · 10 comments

Comments

@y-lohse
Copy link
Owner

y-lohse commented Sep 21, 2016

Align the PRNG in inkjs with the C# version so the randomness is the same on all platforms.
The C# version can be found here.

If someone with an up and running C# env wants to tackle this one, feel free to grab it!

@joethephish
Copy link
Contributor

Note: I'd be very happy to use a simple-as-possible custom PRNG in C# to
make ports simpler. (But prob wouldn't have time to implement it myself,
but might be happy to back port if you started with a JS version?)

On 21 September 2016 at 21:03:38, Yannick Lohse (notifications@github.com)
wrote:

Align the PRNG in inkjs with the C# version so the randomness is the same
on all platforms.
The C# version can be found here.
http://referencesource.microsoft.com/#mscorlib/system/random.cs,bb77e610694e64ca

If someone with an up and running C# env wants to tackle this one, feel
free to grab it!


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#31, or mute the thread
https://github.com/notifications/unsubscribe-auth/AA0bVyCzrElU6UQXphkgpATGFUmDtqMdks5qsY2agaJpZM4KDODk
.

@y-lohse
Copy link
Owner Author

y-lohse commented Sep 21, 2016

Well, inkjs currently uses this one, if you want to have a look at it. They hardly come simpler than that :-)

@joethephish
Copy link
Contributor

Yup, looks ideal! Let's do that then.

On 21 September 2016 at 21:17:14, Yannick Lohse (notifications@github.com)
wrote:

Well, inkjs currently uses this one
https://gist.github.com/blixt/f17b47c62508be59987b, if you want to have
a look at it. They hardly come simpler than that :-)


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#31 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AA0bVwRZQLg5G-AstnAdFDXzHNkkgaWCks5qsZDKgaJpZM4KDODk
.

@curiousdannii
Copy link

If you want a super simple PRNG then I'd recommend Xorshift. It usually scores better on tests than LCGs.

@NQNStudios
Copy link
Contributor

@joethephish @y-lohse Is this feature still in any demand? It seems like something good I could tackle to learn more about RNG implementation.

@y-lohse
Copy link
Owner Author

y-lohse commented Jun 5, 2018

Not sure! I'm going to take a wild guess here and say that @joethephish would still like to switch the PRNG in ink, but is busy creating a game.
Switching inkjs to the C# implementation is still an option, but I'm not sure there's really a demand for it. But if you feel like working on it, the PR would be welcome :)

@joethephish
Copy link
Contributor

I'm in favour of both having a super simple/lightweight (but effective!) implementation that's the same for both. But yeah, it's not a huge priority for me, but having consistency between CS#/JS would be cool!

@curiousdannii
Copy link

I used this in an Inform project when I wanted reproducible cross platform random seeds. The third one is called xorshift* and is extremely reliable for the code size - only one word of state and 7 operations!

https://gist.github.com/Marc-B-Reynolds/0b5f1db5ad7a3e453596

I'd be happy to do up PRs for both implementations if you'd be interested.

@y-lohse
Copy link
Owner Author

y-lohse commented Jun 6, 2018

Sounds good to me :)

@curiousdannii
Copy link

curiousdannii commented Jun 7, 2018

It doesn't appear that nextFloat is ever used, do we need to keep it?

Hmm, could either of you help me by explaining briefly how NextSequenceShuffleIndex works?

Edit: I think I mostly understand. You're not storing the actually shuffled list, so you have to recreate it based on the hash of the container and the storyseed. That means the whole thing will change if SeedRandom is called, right?

@ephread ephread mentioned this issue Jun 11, 2020
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants