MySQL 的 RAND() 是否足以进行“洗牌”?纸牌游戏的纸牌组?
我有一个扑克和二十一点游戏,它在 MySQL 数据库中存储一组基本牌。为了洗牌,我使用 ORDER BY RAND() 对表进行随机排序,并按该顺序将牌插入到另一个表中。使用 RAND() 是否会导致使用真实纸牌和物理洗牌时出现的实际赔率,或者该函数是否不够随机?
I've got a poker and blackjack game that store a base card deck in a MySQL database. In order to shuffle the cards, I order the table at random using ORDER BY RAND() and insert the cards in that order into a different table. Will using RAND() result in realistic odds that would be found playing with real cards and physically shuffling, or is this function not random enough?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除非你经常练习,否则用真牌洗牌并不是那么随机。很容易错误地洗牌,导致牌堆顶部或底部的洗牌效果不佳。
使用 ORDER BY RAND() 进行洗牌是一种合理的方法,但有一些事情需要注意:
出于娱乐目的,您的方法应该没问题。如果这是为了大笔资金,您可能需要使用更好的随机播放算法,例如 Fisher Yates shuffle 和加密安全随机数生成器。
Shuffling with real cards isn't really all that random unless you practise it a lot. It's easy to shuffle incorrectly so that either the top or the bottom of the pack isn't shuffled well.
Using ORDER BY RAND() to shuffle is a reasonable approach but there are some things to be aware of:
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.
供您使用:可能。
从博彩业的角度来看:不会。
内华达州博彩委员会负责监督这里批准的游戏的赔率和随机性。出于这样的目的,消除 RE 随机发生器的可能性符合赌场的利益,因此真正的游戏软件使用过期的“真正的随机”种子,这些种子必须通过经过认证的方法(通常使用一些自然混沌输入)获得。银行经常会使用类似的工具。
如需进一步阅读,请参阅 LavaRand
http://www.lavarand.com/
For your use: Probably.
From the gaming industry perspective: No.
The Nevada Gaming Commission oversees the odds and randomness of approved games here. For such a purpose, it is in the interest of the house to eliminate the possibility of RE the randomizer so the real gaming software uses expiring "true random" seeds which must be obtained by certified methods (usually using some naturally chaotic input). Banks will often employ similar tools.
For further reading, see LavaRand
http://www.lavarand.com/