Metadata-Version: 2.4
Name: cardsharp
Version: 0.6.0
Summary: Card Playing Simulator focused on Blackjack
Author-email: Matt Michie <mmichie@gmail.com>
License: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Games/Entertainment :: Board Games
Requires-Python: >=3.14
Requires-Dist: aiofiles>=24.0.0
Requires-Dist: asyncio<5.0.0,>=3.4.3
Requires-Dist: matplotlib<4.0.0,>=3.9.2
Requires-Dist: numpy<3.0.0,>=2.2.5
Requires-Dist: pandas>=2.0.0
Requires-Dist: pytest-xdist<4.0.0,>=3.6.1
Requires-Dist: scipy<2.0.0,>=1.15.3
Provides-Extra: dev
Requires-Dist: black<26.0,>=24.10; extra == 'dev'
Requires-Dist: flake8<8.0.0,>=7.1.1; extra == 'dev'
Requires-Dist: py-spy<0.5.0,>=0.3.14; extra == 'dev'
Requires-Dist: pylint<4.0.0,>=3.3.1; extra == 'dev'
Requires-Dist: pyrefly<1.0.0,>=0.25.1; extra == 'dev'
Requires-Dist: pytest-asyncio<2.0.0,>=0.25.1; extra == 'dev'
Requires-Dist: pytest-cov<8.0.0,>=6.0.0; extra == 'dev'
Requires-Dist: pytest-mock<4.0.0,>=3.12.0; extra == 'dev'
Requires-Dist: pytest<9.0.0,>=8.3.3; extra == 'dev'
Requires-Dist: ruff<0.15.0,>=0.9.1; extra == 'dev'
Provides-Extra: ui
Requires-Dist: streamlit<2.0.0,>=1.38.0; extra == 'ui'
Description-Content-Type: text/markdown

# CardSharp

A Python framework for simulating and analyzing card games. Currently supports
Blackjack, War, High Card, Baccarat, Dragon Tiger, and Durak.

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Installation

```bash
git clone https://github.com/mmichie/cardsharp.git
cd cardsharp
uv sync
```

## Usage

### Simulation

```bash
# 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

```bash
# 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

```bash
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

```bash
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
