-
Notifications
You must be signed in to change notification settings - Fork 10
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
Random number seed is always the same on the simulator #85
Comments
We need to implement this stub:
Despite the comment, it's only used for the seed in the port config. We dug into this a bit, and despite CODAL having a random number generator, MicroPython uses its own seeded from CODAL's one (potentially reseeded by the user). |
Looks like we had a case of: |
I looked into the other comments from the StackOverflow question: random.seed doesn't work in the simulatorThis seems to work for me, please raise a new issue with an example program if you can reproduce. For the moment, until we fix this issue, the default seed is zero to setting it to that won't affect anything. machine.reset seems to freeze on the emulator. Will be updating with solution after I test with microbitsThis doesn't reproduce straightforwardly, however trying variations on the program on stackoverflow, I raised #86 |
It's used in a non-crypto safe RNG in MicroPython so just seed it with a Math.random-derived value. Closes #85
It's used in a non-crypto safe RNG in MicroPython so just seed it with a Math.random-derived value. Closes #85
This change is now live in the V3 Python Editor as part of simulator 0.1.6. |
This does't match the device and is unhelpful when teaching random numbers.
https://stackoverflow.com/questions/74077710/microbit-python-random-library-only-generates-one-number
The text was updated successfully, but these errors were encountered: