#include <random>#include <functional>#include <iostream>#include <iomanip>int main(){ std::uniform_int_distribution<int> distribution(1, 6); std::mt19937 rng; auto generator = std::bind(distribution, rng); // roll a set of six 3d6 stats, several times for(int set=1; set<=10; set++){ for (int stat=1; stat<=6; stat++){ int rnd_3d6 =0; for(int die=1; die<=3; die++){ rnd_3d6 += generator(); } std::cout << std::setw(3) << rnd_3d6; } std::cout << std::endl; }}
Output:
12 13 12 7 8 1813 17 10 12 5 1117 13 10 13 13 1310 6 11 10 3 16 8 14 8 6 11 6 9 12 16 12 10 10 7 15 13 8 12 1514 13 6 8 13 10 9 9 11 14 12 1014 13 13 13 12 10
But without a seeding function it produces the same set of numbers on every run. How do I seed this new beast? Also, I know that std::uniform_int_distribution isn't what I really want. Ideally I think it's a binomial_distribution over the range [3,18].
[Edited by - AngleWyrm on December 2, 2010 1:05:37 AM]