CardSharp is a powerful Python package for simulating, analyzing, and playing card games. While it currently focuses on Blackjack, its flexible architecture allows for easy extension to other card games.
- 🃏 Robust Blackjack simulation with multiple strategies
- 📊 Real-time visualization of game statistics
- ⚙️ Highly configurable game rules and parameters
- 🧪 Extensible framework for implementing new card games
- 🖥️ Support for both CLI and programmatic usage
- 🧮 Advanced statistical analysis of game outcomes
# Clone the repository
git clone https://github.com/yourusername/cardsharp.git
cd cardsharp
# Create a virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
# Install dependencies
pip install poetry
poetry install
CardSharp offers various modes of operation to suit different needs:
Run a batch simulation of Blackjack games:
python cardsharp/blackjack/blackjack.py --simulate --num_games 10000 --vis
This command simulates 10,000 games of Blackjack and displays a real-time visualization of the results.
Compare different Blackjack strategies:
python cardsharp/blackjack/blackjack.py --analysis --num_games 5000
This runs a comparative analysis of Basic, Counting, Aggressive, and Martingale strategies over 5,000 games.
Play Blackjack interactively in the console:
python cardsharp/blackjack/blackjack.py --console
cardsharp/
blackjack/
: Blackjack-specific implementationscommon/
: Shared utilities and base classeswar/
: War card game implementationhigh_card/
: High Card game implementationroulette/
: Roulette game implementation (in progress)
Run the test suite to ensure everything is working correctly:
pytest tests/
We welcome contributions! Here's how you can help:
- Fork the repository
- Create a new branch (
git checkout -b feature/amazing-feature
) - Make your changes
- Run tests to ensure no regressions
- Commit your changes (
git commit -am 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you find CardSharp useful, please consider giving it a star on GitHub. It helps us gain visibility and encourages further development!
For questions, suggestions, or discussions, please open an issue on GitHub or contact the maintainers directly.
Happy gaming and may the odds be ever in your favor! 🎰🃏