#2931 closed defect (fixed)
[PATCH] random numbers for AI
Reported by: | mimo | Owned by: | |
---|---|---|---|
Priority: | Should Have | Milestone: | Alpha 18 |
Component: | UI & Simulation | Keywords: | patch |
Cc: | Patch: |
Description
Presently, javascript has no seeded random generator, so the sequence of random numbers is always the same. That's really problematic for the AI. Here is a patch to prevent this situation: it transfers to the AI the seed defined at initialization (mainly for random map generation), and adds some entropy when we initialize the shared AI component by doing n dummy calls to the generator (n being a function of the seed). In addition, it corrects a bug where the wrong seed was used when defined by autostart.
The next step will be to use a true seeded algorithm, instead of this hand-made initialization.
Attachments (2)
Change History (5)
by , 9 years ago
comment:1 by , 9 years ago
comment:2 by , 9 years ago
After discussion with leper and yves on IRC, it happens that we already have an implementation of a seeded random generator, but its seed initialisation was missing. So the previous patch is now modified accordingly.
by , 9 years ago
Attachment: | seed.2.diff added |
---|
comment:3 by , 9 years ago
Keywords: | review removed |
---|---|
Milestone: | Backlog → Alpha 18 |
Resolution: | → fixed |
Status: | new → closed |
fixed in r15973
Here is a good and fast implementation of the Mersenne Twister algorithm. Licence: LGPL
http://simjs.com/random.html#the-random-library