Since you're using C++, there's an easier way to do it:
http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution
If you're curious, random_device is not necessary, but it does something way more fun than seeding with time:
- Windows/VS: http://stackoverflow.com/questions/9549357/the-implementation-of-random-device-in-vs2010
- Linux: http://en.cppreference.com/w/cpp/numeric/random/random_device/random_device
- Boost: http://www.boost.org/doc/html/boost/random/random_device.html
More:
http://en.cppreference.com/w/cpp/numeric/random/random_device
http://www.cplusplus.com/reference/random/random_device/
Show differencesHistory of post edits
#2Matt-D
Posted 17 January 2013 - 02:01 PM
Since you're using C++, there's an easier way to do it:
http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution
If you're curious, random_device does something way more fun than seeding with time:
- Windows/VS: http://stackoverflow.com/questions/9549357/the-implementation-of-random-device-in-vs2010
- Linux: http://en.cppreference.com/w/cpp/numeric/random/random_device/random_device
- Boost: http://www.boost.org/doc/html/boost/random/random_device.html
More:
http://en.cppreference.com/w/cpp/numeric/random/random_device
http://www.cplusplus.com/reference/random/random_device/
http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution
If you're curious, random_device does something way more fun than seeding with time:
- Windows/VS: http://stackoverflow.com/questions/9549357/the-implementation-of-random-device-in-vs2010
- Linux: http://en.cppreference.com/w/cpp/numeric/random/random_device/random_device
- Boost: http://www.boost.org/doc/html/boost/random/random_device.html
More:
http://en.cppreference.com/w/cpp/numeric/random/random_device
http://www.cplusplus.com/reference/random/random_device/
#1Matt-D
Posted 17 January 2013 - 01:50 PM
Since you're using C++, there's an easier way to do it:
http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution