{"id":47829500,"url":"https://github.com/mmichie/cardsharp","last_synced_at":"2026-04-03T20:07:56.227Z","repository":{"id":174294237,"uuid":"646599789","full_name":"mmichie/cardsharp","owner":"mmichie","description":"CardSharp is a Python package for simulating and testing card games. The package currently supports Blackjack but can be extended to support more card games.","archived":false,"fork":false,"pushed_at":"2026-02-14T04:00:29.000Z","size":1569,"stargazers_count":9,"open_issues_count":5,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-02-14T10:53:29.744Z","etag":null,"topics":["blackjack","blackjack-cli","blackjack-python","blackjack-simulator","blackjack-strategy","card-game","cards","gambling","python","simulation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mmichie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2023-05-28T22:40:39.000Z","updated_at":"2026-02-14T04:00:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"51d5fc62-be1a-4338-bf7c-19d701d06c7d","html_url":"https://github.com/mmichie/cardsharp","commit_stats":null,"previous_names":["mmichie/cardsharp"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/mmichie/cardsharp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmichie%2Fcardsharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmichie%2Fcardsharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmichie%2Fcardsharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmichie%2Fcardsharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmichie","download_url":"https://codeload.github.com/mmichie/cardsharp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmichie%2Fcardsharp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31374119,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T17:53:18.093Z","status":"ssl_error","status_checked_at":"2026-04-03T17:53:17.617Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blackjack","blackjack-cli","blackjack-python","blackjack-simulator","blackjack-strategy","card-game","cards","gambling","python","simulation"],"created_at":"2026-04-03T20:07:55.418Z","updated_at":"2026-04-03T20:07:56.214Z","avatar_url":"https://github.com/mmichie.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CardSharp: Advanced Card Game Simulation Framework\n\nCardSharp is a powerful Python package for simulating, analyzing, and playing\ncard games. While it currently focuses on Blackjack, its flexible architecture\nallows for easy extension to other card games.\n\n[![GitHub stars](https://img.shields.io/github/stars/mmichie/cardsharp.svg)](https://github.com/mmichie/cardsharp/stargazers)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Python Versions](https://img.shields.io/pypi/pyversions/cardsharp.svg)](https://pypi.org/project/cardsharp/)\n\n## 🚀 Key Features\n\n- 🃏 Robust Blackjack simulation with multiple strategies\n- 📊 Real-time visualization of game statistics\n- ⚙️ Highly configurable game rules and parameters\n- 🧪 Extensible framework for implementing new card games\n- 🖥️ Support for both CLI and programmatic usage\n- 🧮 Advanced statistical analysis of game outcomes\n- 🔄 Event-driven architecture for improved modularity\n- 🔌 Platform adapters for multi-platform support\n\n## 🛠️ Installation\n\n```bash\n# Clone the repository\ngit clone https://github.com/mmichie/cardsharp.git\ncd cardsharp\n\n# Create a virtual environment and install dependencies\nuv sync\n```\n\n## 🎮 Usage\n\nCardSharp offers various modes of operation to suit different needs:\n\n### Blackjack Simulation\n\nRun a batch simulation of Blackjack games:\n\n```bash\nuv run python cardsharp/blackjack/blackjack.py --simulate --num_games 10000 --vis\n```\n\nThis command simulates 10,000 games of Blackjack and displays a real-time visualization of the results.\n\n### Strategy Analysis\n\nCompare different Blackjack strategies:\n\n```bash\nuv run python cardsharp/blackjack/blackjack.py --analysis --num_games 5000\n```\n\nThis runs a comparative analysis of Basic, Counting, Aggressive, and Martingale strategies over 5,000 games.\n\n### Interactive Console Mode\n\nPlay Blackjack interactively in the console:\n\n```bash\nuv run python cardsharp/blackjack/blackjack.py --console\n```\n\n### Event System Demo\n\nTry the new event system:\n\n```bash\nuv run python examples/event_system_demo.py\n```\n\n### Platform Adapter Demo\n\nExperience the platform adapter system:\n\n```bash\nuv run python examples/adapter_demo.py\n```\n\n### Immutable State Demo\n\nSee how immutable state transitions work:\n\n```bash\nuv run python examples/immutable_state_demo.py\n```\n\n### BlackjackEngine Demo\n\nExperience the new engine with immutable state:\n\n```bash\nuv run python examples/blackjack_engine_demo.py\n```\n\n### Asynchronous API Demo\n\nSee the new Phase 3 asynchronous API in action:\n\n```bash\nuv run python examples/async_api_demo.py\n```\n\nThis demo showcases:\n- High-level BlackjackGame interface\n- Event-driven flow control\n- Synchronous and asynchronous operation modes\n- Auto-play capabilities\n\n### BlackjackGame Demo\n\nExperience the BlackjackGame API with event handling:\n\n```bash\nuv run python examples/blackjack_game_demo.py\n```\n\n### Card Handling Demo\n\nSee how different card representations work with the HandState class:\n\n```bash\nuv run python examples/card_handling_demo.py\n```\n\n### Event Cleanup Demo\n\nDemonstrate proper cleanup of event handlers when games are shut down:\n\n```bash\nuv run python examples/event_cleanup_demo.py\n```\n\n### Modern UI Demo\n\nExperience the Streamlit-based web UI for Blackjack:\n\n```bash\nuv run python examples/modern_blackjack_ui.py\n```\n\n### Verification System Demo\n\nSee the immutable state verification system in action:\n\n```bash\nuv run python examples/verification_demo.py\n```\n\n### Full CLI Blackjack Game\n\nPlay the complete blackjack game using the new architecture:\n\n```bash\nuv run python examples/cli_blackjack.py\n```\n\nYou can customize your game experience with these options:\n```bash\n# Play with 3 players\nuv run python examples/cli_blackjack.py --players 3\n\n# Start with a custom bankroll\nuv run python examples/cli_blackjack.py --bankroll 500\n\n# Play a fixed number of rounds\nuv run python examples/cli_blackjack.py --rounds 5\n```\n\n## 📁 Project Structure\n\n- `cardsharp/`\n  - `blackjack/`: Blackjack-specific implementations\n  - `common/`: Shared utilities and base classes\n  - `events/`: Event system for event-driven architecture\n  - `adapters/`: Platform adapters for different environments\n  - `state/`: Immutable state models and transition functions\n  - `engine/`: Core game engine implementation\n  - `war/`: War card game implementation\n  - `high_card/`: High Card game implementation\n  - `roulette/`: Roulette game implementation (in progress)\n  - `verification/`: Game verification and event recording\n\n## 🏗️ Architecture\n\nCardSharp has undergone a phased modernization to an event-driven, adapter-based architecture:\n\n- **Event System**: Core components communicate through a robust event system\n- **Adapters**: Platform-specific code is isolated in adapters\n- **Immutable State**: Game state transitions via pure functions\n- **Asynchronous API**: Clean, platform-agnostic API with rich event-driven flow control\n- **Dual Mode**: Support for both synchronous and asynchronous operation\n\nThe architecture modernization plan has been completed:\n1. ✅ Phase 1: Event System and Adapters\n2. ✅ Phase 2: Immutable State\n3. ✅ Phase 3: Asynchronous API\n4. ✅ Phase 4: Integration \u0026 Component Architecture\n\nCheck out the [architecture documentation](docs/architecture_modernization.md) for details.\n\n### 📊 Performance Optimization\n\nWhen optimizing CardSharp simulations, it's critical to maintain accuracy. See our [optimization principles](docs/optimization_principles.md) for guidelines on proper performance improvements without compromising simulation fidelity.\n\n## 🧪 Testing\n\nRun the test suite to ensure everything is working correctly:\n\n```bash\n# Run all tests\nuv run pytest tests/\n\n# Run tests with coverage report\nuv run pytest tests/ --cov=cardsharp\n\n# Run specific test modules\nuv run pytest tests/api/test_event_cleanup.py -v\n```\n\nThe project includes comprehensive test coverage for:\n- Core components (cards, decks, etc.)\n- Game engines (Blackjack, War, High Card)\n- API interfaces\n- Resource management (event cleanup)\n- Component integration\n\n## 🤝 Contributing\n\nWe welcome contributions! Here's how you can help:\n\n1. Fork the repository\n2. Create a new branch (`git checkout -b feature/amazing-feature`)\n3. Make your changes\n4. Run tests to ensure no regressions\n5. Commit your changes (`git commit -am 'Add some amazing feature'`)\n6. Push to the branch (`git push origin feature/amazing-feature`)\n7. Open a Pull Request\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🌟 Star Us!\n\nIf you find CardSharp useful, please consider giving it a star on GitHub. It helps us gain visibility and encourages further development!\n\n[![GitHub stars](https://img.shields.io/github/stars/mmichie/cardsharp.svg?style=social\u0026label=Star)](https://github.com/mmichie/cardsharp)\n\n## 📬 Contact\n\nFor questions, suggestions, or discussions, please open an issue on GitHub or\ncontact the maintainers directly.\n\nHappy gaming and may the odds be ever in your favor! 🎰🃏\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmichie%2Fcardsharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmichie%2Fcardsharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmichie%2Fcardsharp/lists"}