The following is a snippet of the random shuffle I use in my BJ programs. I user the Mersenne Twister but obviously you can use any RNG with it.
Code:void shuffle(std::vector<short> & shoe) { short N = shoe.size(); // number of cards in shoe short i, j, max, temp; for (i = N; i > 1; --i) { max = i / 2; j = floor(max + myRNG(max)); // random index j temp = shoe[j]; shoe[j] = shoe[i - 1]; shoe[i - 1] = temp; } }
Bookmarks