# Beating Roulette with Neural Networks, YoloV3, and PyTorch

Background:

I am in my last semester of electrical engineering, and I am working on my senior design project. The senior design project is a two-semester design project in which students outline, or are given a task and put all of our knowledge towards completing it.

There are four other people in my group. We came up with the idea that maybe we could use Machine Learning and Deep Neural networks to gain an advantage while playing the game, Roulette.

Roulette

Roulette is a statistically even game, and an ideal unbiased wheel has no pocket favored over the other. The casino gains its edge by having a 0 (European roulette -2.15%), or a '0' and '00' (American roulette -5.3% Expected Value).

ATTN: We are aware roulette is a CHAOTIC system and cannot be predicted in full, but we would like to gain an advantage. The game is inherently deterministic, but there are too many initial conditions and not enough precision to predict 100%.

So before we have anyone comments, "it can't be done," realize planetary motion in the solar system is also a chaotic system.

Project in a Nutshell

1. There is a short period where the ball is still spinning, and the players can still place bets.
2. If we can get position data, we can gain an advantage over the house by betting on most likely pockets.

What we have so far

We have successfully trained a network to located the position and the zero-pocket. The object detection needs some more fine-tuning, but we got a good base for positioning the ball and the zero pocket.

https://youtu.be/zNRTxbcqwRA

We are going to get our a dedicated wheel on a smaller scale and position the camera directly overhead and have a relatively constant position.

1. So now that we have this data, we can get unity normalized position data (as we are using YoloV3)

• $$x_{ball},y_{ball}$$
• $$x_{zero},y_{zero}$$
2. From these xy-coordinates, we can transform into polar coordinates like so.

• $$R_{ball}$$ = radial position of the ball

• $$\theta_{ball} =$$ angular position of the ball

• $$R_{zero} =$$ should be constant and can exclude

• $$\beta_{zero} =$$ angular position of the zero pocket, from which all other pocket positions can be extrapolated

• $$\omega_{ball} =$$ angular velocity of ball
• $$\alpha_{ball} =$$ angular acceleration of ball
• $$\omega_{zero} =$$ angular velocity of wheel
• $$\alpha_{zero} =$$ angular acceleration of wheel

What's the Problem?

1. So now that we have this data, what is the best way to go about building a network around it?

• CNN
• RNN - maybe but time series wouldn't be helpful because where the ball was doesn't necessarily determine its state now. But this could be useful in generating a probability distribution, at every set interval a prediction is made, but more recent predictions are weighted more heavily.
• Any other structures?
2. Define the outputs.

• We thought about making it a classification problem, but this would leave us open to unbalanced data sets. i.e., there is no guarantee we will get an even amount of results for each pocket, or that a specific pocket will hit.

• Predicting final angles

If $$\omega_{ball} - \omega_{zero} <= constant$$

one can assume the ball has come to its final p one could use

$$\theta{'}_{ball} =$$ final postion result of ball

$$\beta{'}_{zero} =$$ final position result of wheel

then $$\theta{'}_{ball}-\beta{'}_{zero}$$ would give us a number result

3. Training

• What would be the best way to train said network. Spins and data can be variable in length depending on a lot of factors.
• Automate training data and algorithms.
• A video per game/spin?
• A video with many spins? The network figures out where it has landed and trains accordingly?
4. Any other caveats not mentioned?

Any suggestions, insight, and experience with those mentioned above or not mentioned are welcomed and appreciated.