Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Dalembert2()
- Dim player As Long
- Dim trial As Long
- Dim session As Long
- Dim winLoss As Long
- Dim bet As Integer
- Dim handle As Double
- Dim wins As Long
- Dim losses As Long
- Const PLAYERS = 1000000 'One million players
- Const TRIALS = 1000 'One thousand rounds per player
- Const MAX = 1000 'One thousand unit max bet
- Randomize 'Init RNG
- For player = 1 To PLAYERS
- 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
- If bet < MAX Then
- bet = bet + 1
- End If
- End If
- Next trial
- Next player
- 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