我试图设计一个比赛,在用户注册后,网页显示了一个玩游戏的按钮。按下按钮,页面返回“你赢了”或“对不起,没有赢”。
问题是,如何给予积极的结果更少的机会被展示而不是50/50。比如说,在10场比赛中取得一场胜利将会很不错。
我为用户尝试设置了一个mysql表。每个用户都有一次机会只能玩。
我无法用数学的方式弄清楚随机性......
非常感谢任何帮助。
非常感谢
答案 0 :(得分:2)
您可以使用select (cast(rand() * 10 as unsigned)) = 1
,然后检查特定结果
select rand() returns a number between 0.0 and 1.0
select cast((rand() * 10) as unsigned) returns a number between 0 and 9
select cast((rand() * 10) as unsigned) = 1 checks if the result was 1 which is a win
but it is a loose for all random numbers != 1
一步一步:
{{1}}