SuperSalad1

Genshin Impact odds simulation

Oct 13th, 2020 (edited)
2,966
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub Roll()
  2.  
  3. 'odds and probability values
  4. Dim total_rolls As Long: total_rolls = 100000000 'total rolls to simulate
  5. Dim perc4 As Single: perc4 = 0.051 'chance of 4 star
  6. Dim perc5 As Single: perc5 = 0.006 'chance of 5 star
  7. Dim pitynum4 As Integer: pitynum4 = 10 'pity threshold for 4 star
  8. Dim pitynum5 As Integer: pitynum5 = 90 'pity threshold for 5 star
  9.  
  10. Dim rand As Single
  11.  
  12. 'start counters at 0
  13. Dim count3 As Long: count3 = 0
  14. Dim count4 As Long: count4 = 0
  15. Dim count5 As Long: count5 = 0
  16. Dim streak4 As Integer: streak4 = 0
  17. Dim streak5 As Integer: streak5 = 0
  18. Dim nat4 As Long: nat4 = 0
  19. Dim nat5 As Long: nat5 = 0
  20. Dim pity4 As Long: pity4 = 0
  21. Dim pity5 As Long: pity5 = 0
  22.  
  23. 'start rolling
  24. For i = 1 To total_rolls
  25.  
  26.     'randomize roll
  27.    rand = Rnd()
  28.    
  29.     'if pity 5
  30.    If streak5 >= pitynum5 - 1 Then
  31.         pity5 = pity5 + 1
  32.         count5 = count5 + 1
  33.         streak5 = 0
  34.         streak4 = 0
  35.     'if natural 5
  36.    ElseIf rand <= perc5 Then
  37.         nat5 = nat5 + 1
  38.         count5 = count5 + 1
  39.         streak5 = 0
  40.         streak4 = 0
  41.     'if pity 4
  42.    ElseIf streak4 >= pitynum4 - 1 Then
  43.         pity4 = pity4 + 1
  44.         count4 = count4 + 1
  45.         streak5 = streak5 + 1
  46.         streak4 = 0
  47.     'if natural 4
  48.    ElseIf rand <= perc4 + perc5 Then
  49.         nat4 = nat4 + 1
  50.         count4 = count4 + 1
  51.         streak5 = streak5 + 1
  52.         streak4 = 0
  53.     'else 3 star
  54.    Else
  55.         count3 = count3 + 1
  56.         streak5 = streak5 + 1
  57.         streak4 = streak4 + 1
  58.     End If
  59.    
  60. 'next roll
  61. Next i
  62.  
  63. 'export results into spreadsheet
  64. Cells(2, 3).Value = count3 'total 3* pulls
  65. Cells(2, 4).Value = count4 'total 4* pulls
  66. Cells(2, 5).Value = count5 'total 5* pulls
  67.  
  68. Cells(3, 4).Value = nat4 'total natural 4* pulls
  69. Cells(3, 5).Value = nat5 'total natural 5* pulls
  70.  
  71. Cells(4, 4).Value = pity4 'total pity 4* pulls
  72. Cells(4, 5).Value = pity5 'total pity 5* pulls
  73.  
  74.  
  75. End Sub
  76.  
RAW Paste Data