What you have *shouldn't* repeat, except for one thing: You never seed the random number generator.
std::random_shuffle, if I recall correctly, uses rand() under the hood (unless you pass a different generator) - though I'm not sure if that changes for C++11, nor if it's standardized that rand() is default.
Since you never call srand(), rand() is seeded with 0 - thus the random shuffle repeats each time.
Instead, seed srand() with time(NULL) at the start of your program, and hopefully the result will be more suiting to your tastes.
[Edit:] Three posts within 60 seconds of each other. =)
Show differencesHistory of post edits
#2Servant of the Lord
Posted 15 November 2012 - 05:47 PM
What you have *shouldn't* repeat, except for one thing: You never seed the random number generator.
std::random_shuffle, if I recall correctly, uses rand() under the hood - though I'm not sure if that changes for C++11, nor if it's standardized.
Since you never call srand(), rand() is seeded with 0 - thus the random shuffle repeats each time.
Instead, seed srand() with time(NULL) at the start of your program, and hopefully the result will be more suiting to your tastes.
[Edit:] Three posts within 60 seconds of each other. =)
std::random_shuffle, if I recall correctly, uses rand() under the hood - though I'm not sure if that changes for C++11, nor if it's standardized.
Since you never call srand(), rand() is seeded with 0 - thus the random shuffle repeats each time.
Instead, seed srand() with time(NULL) at the start of your program, and hopefully the result will be more suiting to your tastes.
[Edit:] Three posts within 60 seconds of each other. =)
#1Servant of the Lord
Posted 15 November 2012 - 05:46 PM
What you have *shouldn't* repeat, except for one thing: You never seed the random number generator.
std::random_shuffle, if I recall correctly, uses rand() under the hood - though I'm not sure if that changes for C++11, nor if it's standardized.
Since you never call srand(), rand() is seeded with 0 - thus the random shuffle repeats each time.
Instead, seed srand() with time(NULL) at the start of your program, and hopefully the result will be more suiting to your tastes.
std::random_shuffle, if I recall correctly, uses rand() under the hood - though I'm not sure if that changes for C++11, nor if it's standardized.
Since you never call srand(), rand() is seeded with 0 - thus the random shuffle repeats each time.
Instead, seed srand() with time(NULL) at the start of your program, and hopefully the result will be more suiting to your tastes.