Here is the Source Code for the recent update.
______________________________________
Public Class Pick3Pick4Tests
Public Class StatusUpdate
Public ProgressPercentage As Integer
Public ProgressIndex As Integer
Public ProgressInformation As String
End Class
'Holding structure for both Straight and reduced Box Selections
Private Structure ComboList
Dim Straight As String
Dim Box As String
End Structure
Public R, X As Integer 'R - 3 for Pick 3 and 4 for Pick 4, X Compare as 1 - Straight, 2 - Box, 3 - Both
Public Sub RunThePick3Pick4Test(ByVal worker As System.ComponentModel.BackgroundWorker, ByVal e As System.ComponentModel.DoWorkEventArgs)
Dim Draw As New List(Of Integer) 'Holding bin for sorting to a reduced box
Dim Draws As New ComboList 'Draw
Dim Combo As New List(Of Integer) 'Holding bin for sorting to a reduced box
Dim Play As New ComboList 'Play selection to be added to the plays list
Dim Plays As New List(Of ComboList) 'Plays where Plays.Item(0) is 1 Play and Plays.Item(1 to 10) are the 10 Plays
Dim UpdateStatus As New StatusUpdate
UpdateStatus.ProgressPercentage = 0
UpdateStatus.ProgressIndex = -1
UpdateStatus.ProgressInformation = "Testing."
worker.ReportProgress(0, UpdateStatus)
Randomize(Timer)
For TestIndex As Integer = 0 To 9
'Reset Count for each test
Dim Total_1P_10D_Wins As Integer = 0
Dim Total_10P_1D_Wins As Integer = 0
For DrawIndex As Integer = 1 To 15000000
'Cancel Thread
If worker.CancellationPending Then
e.Cancel = True
Exit Sub
End If
'Loads random combinations for 1 Play and 10 Plays once every 10 Draws
If Modulus(DrawIndex, 10) = 1 Then
Plays.Clear()
For a As Integer = 0 To 10
Combo.Clear()
Play.Straight = ""
Play.Box = ""
For b As Integer = 1 To R
Combo.Add(RandomLowerUpper(0, 9))
Play.Straight &= Combo.Item(b - 1).ToString
Next
Combo.Sort()
For b = 1 To R
Play.Box &= Combo.Item(b - 1).ToString
Next
Plays.Add(Play)
Next
End If
'Draws New Numbers
Draw.Clear()
Draws.Straight = ""
Draws.Box = ""
For a = 1 To R
Draw.Add(RandomLowerUpper(0, 9))
Draws.Straight &= Draw.Item(a - 1).ToString
Next
Draw.Sort()
For a = 1 To R
Draws.Box &= Draw.Item(a - 1).ToString
Next
'Individual Compare test of 1 - Staright only, 2 - Box only, 3 - Straight and Box
Select Case X
Case 1 'Run Straight tests
'Compare and Count 10 Plays to 1 Draw only once every 10 Draws
If Modulus(DrawIndex, 10) = 1 Then
For a = 1 To 10
If Plays.Item(a).Straight = Draws.Straight Then
Total_10P_1D_Wins += 1
End If
Next
End If
'Compare and Count 1 Play to 10 Draws
If Plays.Item(0).Straight = Draws.Straight Then
Total_1P_10D_Wins += 1
End If
Case 2 'Run Box tests
'Compare and Count 10 Plays to 1 Draw only once every 10 Draws
If Modulus(DrawIndex, 10) = 1 Then
For a = 1 To 10
If Plays.Item(a).Box = Draws.Box Then
Total_10P_1D_Wins += 1
End If
Next
End If
'Compare and Count 1 Play to 10 Draws
If Plays.Item(0).Box = Draws.Box Then
Total_1P_10D_Wins += 1
End If
Case 3 'Run both Straight and Box tests
'Compare and Count 10 Plays to 1 Draw only once every 10 Draws
If Modulus(DrawIndex, 10) = 1 Then
For a = 1 To 10
If Plays.Item(a).Straight = Draws.Straight Then
Total_10P_1D_Wins += 1
End If
If Plays.Item(a).Box = Draws.Box Then
Total_10P_1D_Wins += 1
End If
Next
End If
'Compare and Count 1 Play to 10 Draws
If Plays.Item(0).Straight = Draws.Straight Then
Total_1P_10D_Wins += 1
End If
If Plays.Item(0).Box = Draws.Box Then
Total_1P_10D_Wins += 1
End If
End Select
If Modulus(DrawIndex, 50000) = 0 Then
UpdateStatus.ProgressPercentage = Int(DrawIndex / 150000)
UpdateStatus.ProgressIndex = TestIndex
UpdateStatus.ProgressInformation = Total_1P_10D_Wins.ToString & " | " & Total_10P_1D_Wins.ToString & " | "
If Total_1P_10D_Wins = Total_10P_1D_Wins Then
UpdateStatus.ProgressInformation &= "None | 0"
End If
If Total_1P_10D_Wins > Total_10P_1D_Wins Then
UpdateStatus.ProgressInformation &= "1P 10D | " & Math.Abs(Total_1P_10D_Wins - Total_10P_1D_Wins).ToString
End If
If Total_1P_10D_Wins < Total_10P_1D_Wins Then
UpdateStatus.ProgressInformation &= "10P 1D | " & Math.Abs(Total_1P_10D_Wins - Total_10P_1D_Wins).ToString
End If
worker.ReportProgress(0, UpdateStatus)
End If
Next
Next
UpdateStatus.ProgressPercentage = 0
UpdateStatus.ProgressIndex = -1
UpdateStatus.ProgressInformation = "Complete."
worker.ReportProgress(0, UpdateStatus)
End Sub
Function Modulus(ByVal a As Double, ByVal b As Double) As Long
Modulus = a - b * Int(a / b)
End Function
Function RandomLowerUpper(ByVal L As Long, ByVal U As Long) As Long
RandomLowerUpper = Int(Rnd() * (U - (L - 1))) + L
End Function
End Class
__________________________________