Skip to content

Ayomide-codex/slot-machine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Slot Machine

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.

Demo

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.

How It Works

  1. You start with a balance of $200.
  2. Each round you enter a bet amount.
  3. Three reels spin and display a 3x3 grid of symbols.
  4. If all three symbols on a row match, you win your bet multiplied by that symbol's multiplier.
  5. The game ends when your balance hits $0 or you choose to quit.

Symbols and Multipliers

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.

Project Structure

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.

Concepts Demonstrated

  • Maps β€” used as lookup tables for symbol weights and multipliers.
  • 2D slices β€” [][]string represents the slot machine grid.
  • Unsigned integers (uint) β€” balance and bets are always non-negative.
  • Game loop β€” for balance > 0 keeps 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 β€” checkWin evaluates each row and returns a slice of winnings.

Running the Program

From inside the project folder:

go run .

Use go run . (not go run main.go) since the project spans multiple files.

Author

Ayomide Ajisegiri (Show Manny)

About

Terminal slot machine game written in Go. Spin to win 😁

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages