Slot Machine Logic - A quick look
- elliotjlowis
- Sep 9, 2025
- 2 min read
Most modern slot-machines or VLTs (Video Lottery Terminals), use a random number generator to determine the outcome of a given spin. Any "wheels" of a slot machine that you may see on these digital displays are purely for aesthetic, and do not influence the outcome.
When designing the odds for a slot machine, a spreadsheet as such is common to visualise each "wheel".
Each "slot" or "wheel" shows the count of each symbol. This would be nothing but code for a VLT, but for a physical wheel? It would look something like this:


So why am I using physical wheels? Well, it can look more fun in a game, especially when perfect odds aren't essential (when not using real money). In my case I am going for a fantasy style game, where large stone wheels have painted symbols on each square. My main focus is the logic behind the slot machine, and calculating winnings.
private void CalculateWinnings()
{
var symbols = CheckSymbols();
if (symbols.All(s => s == symbols[0]))
{
if (MatchThreePayouts.TryGetValue(symbols[0], out int payout))
{
WinSlot(payout);
return;
}
return;
}
else
if (symbols[0] == symbols[1] || symbols[1] == symbols[2])
{
for (int i = 0; i < symbols.Length - 1; i++)
{
if (MatchTwoPayouts.TryGetValue(symbols[1], out int payout))
{
WinSlot(payout);
return;
}
for (int p = 0; p < symbols.Length - 1; p++)
{
if (MatchSinglePayouts.TryGetValue(symbols[p], out int payout1))
{
WinSlot(payout1);
}
}
}
}
else
{
for (int p = 0; p < symbols.Length; p++)
{
if (MatchSinglePayouts.TryGetValue(symbols[p], out int payout1))
{
WinSlot(payout1);
}
}
}
}
private string[] CheckSymbols()
{
var symbols = new[] { "null", "null", "null" };
var i = 0;
foreach (Node3D wheel in _wheels)
{
Debug.WriteLine("chek");
_wheelCheckRays[i].ForceRaycastUpdate();
if (_wheelCheckRays[i].IsColliding())
{
var col = _wheelCheckRays[i].GetCollider();
if (col is Node3D node)
{
var sqr = node.GetParent<Square>();
symbols[i] = sqr.ChosenSymbol.ToString().ToLower();
}
}
i++;
}
return symbols;
}
Here is my logic for calculating the winnings, I created a dictionary for each match type; single, double, triple matches. Each dictionary has a <string, int> structure and the name of the symbol gives the number in winnings, very easy to tweak. Whether or not you are interested in truly random results, I recommend employing strategies other than my own. I used 3 random floats to determine a speed at which each wheel spins, using the same deceleration value for each. This is just so I can test the part of the code that's more important to me, but note that after some research it seems like this does not create a perfectly random environment.
And here's the demo to my product! I succesfully accomplished my goal of using slot machine logic to calculate winnings. Please contact me if you would like a playable build for you to test. And that's what I got up to last week, thanks!




Comments