如果你不做很多事情,那么用真实的卡片进行打真的就是这样。 很容易以不正确的方式加以扼杀,使包装的顶部或底部都 well得好。
利用RAND(RAND)(ORDER)sh,是一种合理的做法,但有一些事情需要了解:
- A slight bias is introduced if two exactly equal random numbers are generated by RAND() as it will not shuffle those two cards correctly with respect to each other.
- RAND() is not cryptographically secure. By seeing some of the first cards in the deck it might be possible for a skilled attacker to deduce the internal state of the PRNG used to shuffle the deck and therefore predict the remaining cards.
- ORDER BY RAND() requires O(n log(n)) operations. It will most likely have acceptable performance for shuffling 52 rows, but it is probably not something you want to use for shuffling millions of rows, for example.
For entertainment purposes your approach should be fine. If this is for serious money you might want to use a better shuffle algorithm such as the Fisher Yates shuffle and cryptographically secure random number generator.