English 中文(简体)
MySQL s RAND()是否足以为卡片游戏打上“窒息”卡片?
原标题:Is MySQL s RAND() good enough for "shuffling" card decks for card games?

我在MySQL数据库中储存了一张底卡的掩体和黑色劫持游戏。 为了填充这些卡片,我随意使用RAND(RAER)的表格,并将卡片插入一个不同的表格。 使用RAND(RAND)是否会产生实事求是的难题,会发现这些困难与真实的卡片和身体上的缺陷,或者这一功能是否不够随意?

最佳回答

如果你不做很多事情,那么用真实的卡片进行打真的就是这样。 很容易以不正确的方式加以扼杀,使包装的顶部或底部都 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.

问题回答

供您使用:可原谅。

从赌博行业角度看: 页: 1

Nevada Gaming委员会负责监督这里核准的游戏的奇迹和随机性。 为此,消除循环器的可能性符合房屋的利益,因此,真正的赌博软件使用到期的“随机”种子,必须通过认证方法获得(通常使用一些自然混乱的输入)。 银行经常使用类似的工具。

供进一步阅读,见LavaRand

http://www.lavarand.com/。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签