wesnoth/wesnoth — pull request #160 by cbeck88 (2014-04-30 03:45:18+00:00)
Title: Boost rng

*** WIP, Please don't merge ***

This is still experimental, I'm just posting as a PR to solicit feedback.

The idea is to use boost::mt19937 as our rng engine rather than the linear congruential generator implemented in simple_rng which we were using. This was discussed on IRC: http://www.wesnoth.org/irclogs/2014/04/%23wesnoth-dev.2014-04-29.log

Feel free to criticize, pull this branch and tweak it, merge yours instead of mine, ask me to pull your changes, or ignore this branch completely and do something completely different with the rng.

TODO:
- In cases when we don't have a seed, the boost random library seems to offer options like "random_device" to get a seed? Currently I'm using stdlib rand() to get the seed in that case, just like we were before...
- Do I *need* to use a boost distribution object, which seems to be an adapter to take raw RNG output and sample a nice distribution? It seems we only actually need raw RNG output. I'm currently simply returning that as a uint32_t.
- Should we put something like this on the server also?

Problems:
- I ran 3 AI vs AI test cases on this branch, they all had +25% damage dealt and taken throughout the game... so that certainly looks like a problem. Is it casting uint32_t to int? Is it the seeding?

Minor problems:
- Was I not supposed to use the rand_rng namespace for this?