Skip to content

riordi80/java-multithreading-casino-simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java Multithreading Casino Simulation

A multi-threaded Java application that simulates different betting strategies in a French roulette casino game.

Description

This project simulates a casino environment where multiple players (threads) compete against the house using different betting strategies on a French roulette wheel. The simulation demonstrates concurrent programming concepts including thread synchronization, shared resource management, and race condition prevention.

Features

  • French Roulette: 37 numbers (0-36) with draws every 3000 milliseconds
  • Multiple Betting Strategies:
    • Direct number betting (4 players)
    • Even/Odd betting (4 players)
    • Martingale strategy (4 players)
  • Realistic Casino Rules:
    • Initial player balance: 1000€
    • Initial house balance: 50000€
    • House never pays more than available balance
    • Zero (0) results in house taking all bets

Game Rules

Betting Types

1. Direct Number Betting

  • Players select random numbers from 1-36 (not 0)
  • Bet amount: 10€
  • Payout: 360€ (36x bet) on win

2. Even/Odd Betting

  • Players randomly choose even or odd
  • Bet amount: 10€
  • Payout: 20€ (2x bet) on win

3. Martingale Strategy

  • Players select a random number
  • Initial bet: 10€
  • Payout on win: 360€
  • On loss: double previous bet (10€ → 20€ → 40€ → 80€...)
  • On win: reset to 10€ bet

Special Rules

  • When 0 is drawn, all players lose and the house collects all bets
  • The house accepts all bets but only pays winnings up to its available balance
  • New number drawn every 3 seconds

Technical Requirements

  • Java Version: Java 8 or higher
  • IDE: IntelliJ IDEA, Eclipse, or NetBeans (optional)
  • Build Tool: Not required (can be compiled with javac)

How to Run

Using Command Line

# Compile
javac src/*.java

# Run
java -cp src Main

Using IDE

  1. Open the project in your preferred Java IDE
  2. Locate the Main.java file in the src folder
  3. Run the Main class

Project Structure

Casino/
├── src/
│   └── Main.java
├── docs/                    # Excluded from git
├── .gitignore
├── .idea/                   # IntelliJ IDEA config
├── Casino.iml
└── README.md

Class Diagram

UML Class Diagram

Concepts Demonstrated

  • Multi-threading: Multiple concurrent players (threads)
  • Thread Synchronization: Coordinating players with the croupier
  • Shared Resources: Managing house balance across threads
  • Race Condition Prevention: Using synchronized blocks and methods
  • Thread Communication: wait(), notify(), and notifyAll()

Development Roadmap

  • Basic simulation structure
  • Roulette/Croupier implementation
  • Direct number betting players
  • Even/Odd betting players
  • Martingale strategy players
  • Thread synchronization
  • Balance management
  • Console output formatting
  • JavaDoc documentation
  • UML class diagram

License

This is an educational project. Feel free to use it for learning purposes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages