Scratchcard PHP脚本

Scratchcard PHP脚本,php,random,numbers,Php,Random,Numbers,我正在写一个scratchcard脚本,我想知道是否有人能帮我,如果你不明白这可能会融化你的大脑一点 因此,几率可能会有所不同:1/$x

我正在写一个scratchcard脚本,我想知道是否有人能帮我,如果你不明白这可能会融化你的大脑一点

因此,几率可能会有所不同:
1/$x$x=36

这就是我想要理解的

  • 我想在
    1和5之间生成
    9
    随机数
  • 我希望
    3
    数字匹配的几率等于
    1/36
  • 一次生成3个以上的重复数字必须是不可能的

我可以想象,某种数组循环可能是正确的通过方式?

有时——这是其中一种情况——作弊是做你想做的事情的最佳方式

a) Set up an array of your 9 numbers, and a 2nd frequency array (5 elements) that counts which number occurs how often.
b) Generate a random number 1-5. Set the 1st and 2nd card to this number, and mark this number with 2 in your freqency array.
c) If random(36) < 1 (1/36 probability), set your 3rd card to the same number and mark this number with 3 in your frequency array.
d) Generate the rest of the cards - find a random number, repeat while frequency of the found number >=2, set the next card to number, increase frequency of the found number.
e) When finished, shuffle the cards (generate 2 random numbers between 1 and 9, swap the 2 cards, repeat 20-30 times).
a)设置一个包含9个数字的数组,以及一个第二频率数组(5个元素),用于计算哪个数字出现的频率。
b) 生成一个随机数1-5。将第一张和第二张卡设置为该数字,并在频率数组中用2标记该数字。
c) 如果随机(36)<1(1/36概率),将您的第三张卡设置为相同的数字,并在频率阵列中用3标记此数字。
d) 生成其余的卡-找到一个随机数,当找到的数字的频率>=2时重复,将下一张卡设置为数字,增加找到的数字的频率。
e) 完成后,洗牌(在1和9之间生成2个随机数,交换2张牌,重复20-30次)。

d)部分是我所说的作弊——你把你的1/36概率放在了步骤c)中,在d)中,你只需确保你不会产生另一个匹配。e) 用于向用户隐藏该问题。

尝试在每篇文章中只问一个问题