28 Oct
2012
28 Oct
'12
11:42 a.m.
I'm using boost to shuffle an array, but it's not looking as random as I would expect.
for(unsigned i=0;i<5;i++) { boost::random::uniform_int_distribution<> dist(min,max); const int j = dist(rng); ... code that shuffles stuff using j ... min++; cout<
You may of course be using the results of an uniform distribution in a way that causes the resulting shuffle have some configurations that are more likely than others...
Use std::shuffle from the algorithm header. This stuff is tricky to get right if you write it yourself. Google "Knuth shuffle" for some background. - Rhys