Simulator Screen Shot
Simulator Use Notes:
-
The Drum is considerd the physical Drum the winning balls are drawn from. Some games have 2 drums with separate balls in them.
-
Cover Drum 2 plays all numbers in the "power ball -- the 2nd drum" thus at least one of those tickets will win something.
-
MegaMillions, PowerBall, and Cash 4 Life are all two drum specal 2nd ball games. Pick 6 and Cash 5 are not.
-
The "Don't Get Your Hopes Up!" button plays one game with your ticket -- or one game for every possible ball in drum two if Cover Drum 2 is checked.
-
Click "Get New Ticket" to generate a new random lottery ticket.
-
The "Try for Big" button will play games until you win the selected prize amount.
-
This app was a good learning experience. Some interisting aspects were:
-- Adding a 2nd thread to do the calulation so the UI doesn't hang up. See backgroundWorker code in Form1.cs
-- Learning from someone else's code base. Always good to see how someone thinks and codes.
-- Finding some bugs that were left in.
-- Adding some basic memory management. Updated UI "Games Played" every so often and cleard the variable holding the string or else memory would go out of control.
-- Left a Bug of my own.
-
Bug
-- For some reason the variable scoreValue resets to default 0 when trying to hit a jackpot. It happens reandomly and not sure why? See backgroundWorker1_ProgressChanged method in Form1.cs. The output is correct as I worked around the bug by passing the scoreValue directly into UserState.
-- Bug likely caused by worker thread. Look into lock statement
-- got a bit to learn there yet.
-
Plans/Ideas
-- Maybe generate a new ticket every so often when trying for a jackpot.
-- May have to exclude the "Games Played" output for jackpot calculations -- this may still take too much memory. Especially if you truly try to go for jackpot.
-- Try leaving this app running and see how long it takes to hit the big jackpot for PowerBall or MegaMillions. Calulated years and or maybe add a timer to see the hours it spent running. Does it crash because "Games Played" output takes too much RAM.
-- port idea to .NET MAUI
-- It was just fun the see how crummy your odds are. Good luck it may take 3 life times just to win $50,000!!