0

目前我有这个:

$chance = 5;
    #Set the winning chances.
    function winningChance($percentage)
    {
        if ($percentage < 0 || $percentage > 100)
            throw new Exception('Invalid percentage');

        return rand(0, 100) <= $percentage ? 'won' : 'lost';
    }

    if(winningChance($chance) == "lost"){
        $won = false; //You lost.   
    }else{
        $won = true; //You won.
    }

这真的很简单。似乎即使 $chance 设置为 5,获胜的频率也比它应该的要高。谁能建议我如何改善这一点?

4

0 回答 0