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
Metadata
Release files for cardsharp 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cardsharp-0.6.0.tar.gz | 418.7 kB | Without provenance | Details for cardsharp-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cardsharp-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for cardsharp-0.6.0-py3-none-any.whl |
Total release size: 660.3 kB
Release files / cardsharp-0.6.0.tar.gz
| Download URL | cardsharp-0.6.0.tar.gz |
|---|---|
| Size | 418.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
659c5300719b065c469b96b4201457c6fe8c94ae1a792ae63400b9affb5ea07b
|
|
BLAKE2b-256 checksum How to use checksums |
fea489bae8934a732710944fa433ce8d46d9a1d521a27ff55d476a893842fafc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / cardsharp-0.6.0-py3-none-any.whl
| Download URL | cardsharp-0.6.0-py3-none-any.whl |
|---|---|
| Size | 241.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cfe27ea8d382da072c5beb8d07627a03804cb8c0f3867b38b5c7e5ee834fb244
|
|
BLAKE2b-256 checksum How to use checksums |
087a3ff0f33bc6f2c87cd14109bad713ea160fd8d60db0f0820c6e6ff31c5bb7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Security for cardsharp 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.