This is a command-line slot machine game built in Python. It simulates a simple 3x3 slot machine with symbols A, B, C, and D, each having different probabilities and payout values. The player can deposit money, place bets on up to 3 lines, and spin the machine to try their luck.
main()
β Entry point of the program.deposit()
β Asks the user how much money they want to deposit.get_number_of_lines()
β Asks the user how many lines they want to bet on (1β3).get_bet()
β Asks the user how much they want to bet per line.get_slot_machine_spin()
β Randomly generates slot symbols based on symbol weights.check_winnings()
β Checks if the user has won based on matching lines.print_slot_machine()
β Displays the slot machine outcome in a 3x3 format.spin()
β Coordinates the betting and spinning logic.
- Deposit: The user starts by depositing a certain amount of money.
- Bet: The user chooses how many lines to bet on (up to 3) and how much to bet per line.
- Spin: The slot machine generates random symbols based on predefined symbol frequencies.
- Payout: If all symbols in a selected line match, the player wins a payout based on the symbolβs value.
- Repeat: The user can continue playing until they run out of money or choose to quit.
Symbol | Count (Weight) | Value (Multiplier) |
---|---|---|
A | 2 | 5 |
B | 4 | 4 |
C | 6 | 3 |
D | 8 | 2 |
- Symbols with higher values are less likely to appear.
- Winning a line pays:
symbol value * bet amount
.
- Python 3.x
No external libraries are required. All functionality is built using Python's standard library (random
, input
, print
, etc.).
To play the game, simply run the following command in your terminal:
python slot_machine.py