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

I made a compatible "Random" of the C# in TypeCrsipt #5

Open
x2nie opened this issue Nov 29, 2023 · 2 comments
Open

I made a compatible "Random" of the C# in TypeCrsipt #5

x2nie opened this issue Nov 29, 2023 · 2 comments

Comments

@x2nie
Copy link

x2nie commented Nov 29, 2023

Hi Yuu,
I wonder if we can generate an identical result with MarkovJunior C#.
So I translated the C# (or dotnet) random function into TypeScript.
After a week stabilizing, I got the perfect result.

That was a good news, right? I think so.
THe bad news is, I did it in very old commit of your MarkovJuniorWeb: while it has no webassembly at all.
So here I send you only file that declare the random function.
(if you want to try, here is my working branch)

Okay, here is the file: https://github.com/x2nie/MarkovJuniorWeb/blob/x2nie-nowasm2/src/random.ts

@x2nie
Copy link
Author

x2nie commented Nov 29, 2023

YOu might ask, why this guy didn't send a pool request?
Well, There is another argue (beside it written in old commit),
That is because my usage of this new random is dirty.
For example, it is still called as rng.NextDouble, like as the C# original code; which it might be better written as random.nextDouble as more convenient for JS users.
(as same as the .Next() shall be written as .next() )
(and I let it be your todo, perhaps, for fun?).
However, I guarantee that is will give a verbatim result in JS/TypeScript, compared to the one generated by C#.

@x2nie
Copy link
Author

x2nie commented Nov 29, 2023

Oh, I forgot to mention.. How I am sure that it will generates an identical result?
answer: by allow user to manually input the seed.

So, let say we give the MarkovJuniorC# : <model name="BasicKey" seed="1234567" />
then we input that same seed into the MarkovJunioWeb.
That is just that is that.

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

1 participant