View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
---|---|---|---|---|---|---|---|---|---|
0005423 | Spring engine | General | public | 2016-12-23 22:17 | 2016-12-24 19:59 | ||||
Reporter | silentwings | ||||||||
Assigned To | Kloot | ||||||||
Priority | normal | Severity | feature | Reproducibility | N/A | ||||
Status | resolved | Resolution | fixed | ||||||
Product Version | 103.0 +git | ||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0005423: random number generation in defs.lua (-> and _post.lua) | ||||||||
Description | Currently its not possible to produce "true" randomness inside defs.lua, and consequently in any of the _post files. The lua state that reads defs.lua has no access to anything that could be used to seed a random number generator. Obviously such randomness would need to be synced. Maybe the gameID can be passed in? | ||||||||
Additional Information | Use case is procedural generation of defs. I am making a frivolous (map) mutator that "randomly" mutates unit/weapondefs. Currently they only way I can find to seed its RNG is with a mapoption, which is clunky and poorly suited to autohosts. There are sensible use cases in the same mould! | ||||||||
Tags | No tags attached. | ||||||||
Checked infolog.txt for Errors | |||||||||
Attached Files |
|
![]() |
|
Kloot (developer) 2016-12-23 23:59 |
Unfortunately defs.lua is executed long before a client receives the game ID. Another complication is that Spring's synced RNG uses the game ID as a seed itself, so you would end up with the same sequence of mutations on every run if that one were accessible. Unless you are willing to add some kind of synced entropy source (like one client forwarding its /dev/random/ contents), this is just infeasible. |
silentwings (reporter) 2016-12-24 14:24 |
Sourcing entropy from the host seems natural to me. Sending a single random seed (e.g. a hashed os.time() from the host machine) would be enough, but I don't know if the network interface even exists early enough? |
Kloot (developer) 2016-12-24 15:26 |
Amusingly enough host-based "preseeding" already exists but isn't used anywhere. I'll be back. |
Anonymous (viewer) 2016-12-24 17:04 |
Fix 0df5fb566057eafe982db09740b50f910714b7c1 committed to develop branch: fix 0005423 math.random is now available during execution of defs.lua (math.randomseed also exists, but will always be a no-op), repo: spring changeset id: 7714 |
hokomoko (developer) 2016-12-24 19:59 |
compilation of dedicated server fails at the moment |
![]() |
|||
Date Modified | Username | Field | Change |
---|---|---|---|
2016-12-23 22:17 | silentwings | New Issue | |
2016-12-23 23:59 | Kloot | Note Added: 0016995 | |
2016-12-24 14:24 | silentwings | Note Added: 0016997 | |
2016-12-24 15:26 | Kloot | Note Added: 0016998 | |
2016-12-24 15:29 | Kloot | Assigned To | => Kloot |
2016-12-24 15:29 | Kloot | Status | new => assigned |
2016-12-24 17:04 | Changeset attached | => spring develop 0df5fb56 | |
2016-12-24 17:04 | Anonymous | Note Added: 0016999 | |
2016-12-24 17:04 | Anonymous | Status | assigned => resolved |
2016-12-24 17:04 | Anonymous | Resolution | open => fixed |
2016-12-24 19:59 | hokomoko | Note Added: 0017000 |