|
本帖最后由 老陈 于 2012-7-16 22:39 编辑
treeqy001 发表于 2012-7-16 16:27
有个实际要算的题目,霍老能不能帮忙算下?有人拿100万百家乐,每次压1万,输光或者赢到20万就停,输光或 ...
我用蒙特卡洛算法算出近似值:
赢:77.20%
输:22.80%
玩100次的EV是:77.20x200000-22.8x1000000=-7360000
程序如下:
Dim Wins, Lose, Total As Integer
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Wins = 0
Lose = 0
Total = 1000000
Dim I As Integer
For I = 1 To Total
Bacc()
Next
Me.Label1.Text = Wins
Me.Label2.Text = Lose
Me.Label3.Text = Wins + Lose
Me.Label4.Text = Format(Wins / (Wins + Lose), "###.00%")
Me.Label5.Text = Format(Lose / (Wins + Lose), "###.00%")
End Sub
Sub Bacc()
Dim Chips As Double = 1000000
Dim Ws As Double
While True
Randomize()
Ws = Rnd()
If Ws < 0.5 Then
If Chips > 10000 Then
Chips = Chips - 10000
Else
Lose += 1
Exit Sub
End If
Else
If Chips > 10000 Then
Chips = Chips + 9750
Else
Chips = Chips * 1.975
End If
If Chips > 1200000 Then
Wins += 1
Exit Sub
End If
End If
End While
End Sub
|
|