Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Dalembert()
- Dim trial As Long
- Dim trials As Long
- Dim winLoss As Long
- Dim bet As Integer
- Dim handle As Long
- Dim wins As Long
- Dim losses As Long
- trials = 1000000000 '1 Billion
- Randomize 'Init RNG
- bet = 1 'Start at a 1 unit
- For trial = 1 To trials
- handle = handle + bet 'Get the handle to be used for the average bet
- If Int(2 * Rnd) = 1 Then 'WINNER!
- wins = wins + 1 'Win counter
- winLoss = winLoss + bet 'Add the bet to the current win
- 'A round was won so drop the bet by 1 unit to a minimum of 1 unit
- If bet > 1 Then
- bet = bet - 1
- End If
- Else 'Loser
- losses = losses + 1 'Loss counter
- winLoss = winLoss - bet 'Subtract the bet from the current win
- 'A round was lost so add one to the bet
- bet = bet + 1
- End If
- Next trial
- Debug.Print "Trials: " & trials
- Debug.Print "Wins: " & wins & " (" & wins / trials * 100 & "%)"
- Debug.Print "Losses: " & losses & " (" & losses / trials * 100 & "%)"
- Debug.Print "Total Bet: " & handle
- Debug.Print "Average Bet: " & handle / trials
- Debug.Print "Win/Loss: " & winLoss
- Debug.Print "Edge: " & winLoss / handle
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment