A terminal-based slot machine game built in Go. Place your bet, spin the reels, and win based on symbol multipliers β or lose your balance trying.
Welcome to Show's Casino...
Enter your name: Show Manny
Welcome Show Manny, let's play!
Enter your bet, or 0 to quit (balance = $200): 50
C | A | B
C | C | C Won $250 (5x) on Line #2
D | A | B
Enter your bet, or 0 to quit (balance = $400): 0
You left with, $400.
- You start with a balance of $200.
- Each round you enter a bet amount.
- Three reels spin and display a 3x3 grid of symbols.
- If all three symbols on a row match, you win your bet multiplied by that symbol's multiplier.
- The game ends when your balance hits $0 or you choose to quit.
| Symbol | Multiplier | Rarity (weight) |
|---|---|---|
| A | 28x | 4 |
| B | 10x | 7 |
| C | 5x | 12 |
| D | 2x | 20 |
Rarer symbols pay out more. Common symbols appear more frequently but pay less.
slot-machine/
βββ main.go # Entry point, core game loop, and checkWin logic
βββ spin.go # GenerateSymbolArray, GetRandomNumber, GetSpin, PrintSpin
βββ utils.go # GetName, GetBet β handles all user input
All files share package main and compile together as one program.
- Maps β used as lookup tables for symbol weights and multipliers.
- 2D slices β
[][]stringrepresents the slot machine grid. - Unsigned integers (
uint) β balance and bets are always non-negative. - Game loop β
for balance > 0keeps the game running until the player runs out of funds or quits. - Multi-file structure β logic is split by responsibility across separate files.
- Functions with return values β
checkWinevaluates each row and returns a slice of winnings.
From inside the project folder:
go run .Use
go run .(notgo run main.go) since the project spans multiple files.
Ayomide Ajisegiri (Show Manny)