Card Playing Simulator focused on Blackjack
Project description
CardSharp
A Python framework for simulating and analyzing card games. Currently supports Blackjack, War, High Card, Baccarat, Dragon Tiger, and Durak.
Installation
git clone https://github.com/mmichie/cardsharp.git
cd cardsharp
uv sync
Usage
Simulation
# Run 10,000 blackjack games with visualization
uv run python cardsharp/blackjack/blackjack.py --simulate --num_games 10000 --vis
# Compare strategies (Basic, Counting, Aggressive, Martingale)
uv run python cardsharp/blackjack/blackjack.py --analysis --num_games 5000
# Performance profiling
uv run python cardsharp/blackjack/blackjack.py --simulate --profile --num_games 1000
Interactive Play
# Console blackjack
uv run python cardsharp/blackjack/blackjack.py --console
# Full CLI game with options
uv run python examples/cli_blackjack.py --players 3 --bankroll 500 --rounds 5
Examples
uv run python examples/async_api_demo.py # Async API with event-driven flow
uv run python examples/blackjack_engine_demo.py # Engine with immutable state
uv run python examples/adapter_demo.py # Platform adapter system
uv run python examples/modern_blackjack_ui.py # Streamlit web UI
See examples/ for the full set of demos.
Architecture
CardSharp uses an event-driven architecture with immutable state transitions:
- Events -- Components communicate through pub/sub (
cardsharp/events/) - Immutable State -- Game state transitions via pure functions (
cardsharp/state/) - Engines -- Game logic per game type (
cardsharp/engine/,cardsharp/blackjack/, etc.) - Adapters -- Platform-specific rendering and input (
cardsharp/adapters/) - APIs -- High-level sync/async interfaces (
cardsharp/api/)
Testing
uv run pytest # Run all tests
uv run pytest --cov=cardsharp # With coverage
uv run pytest tests/api/test_event_cleanup.py -v # Specific module
uv run pytest -n auto # Parallel
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cardsharp-0.6.0.tar.gz
(418.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
cardsharp-0.6.0-py3-none-any.whl
(241.6 kB
view details)
File details
Details for the file cardsharp-0.6.0.tar.gz.
File metadata
- Download URL: cardsharp-0.6.0.tar.gz
- Upload date:
- Size: 418.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
659c5300719b065c469b96b4201457c6fe8c94ae1a792ae63400b9affb5ea07b
|
|
| MD5 |
0a59cd83bb77e07738a88053e16a9359
|
|
| BLAKE2b-256 |
fea489bae8934a732710944fa433ce8d46d9a1d521a27ff55d476a893842fafc
|
File details
Details for the file cardsharp-0.6.0-py3-none-any.whl.
File metadata
- Download URL: cardsharp-0.6.0-py3-none-any.whl
- Upload date:
- Size: 241.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfe27ea8d382da072c5beb8d07627a03804cb8c0f3867b38b5c7e5ee834fb244
|
|
| MD5 |
a6a93ae7e5ee93903bc53a8adcbb3482
|
|
| BLAKE2b-256 |
087a3ff0f33bc6f2c87cd14109bad713ea160fd8d60db0f0820c6e6ff31c5bb7
|