A multi-platform blackjack basic strategy trainer to help memorize optimal play using progressive learning methods and reinforcement techniques. Available as a terminal-based Python program and a modern web application.
- Complete basic strategy chart implementation (hard totals, soft totals, pairs)
- Multiple practice modes:
- Quick Practice (random scenarios)
- Learn by Dealer Strength (weak/medium/strong dealers)
- Focus on Hand Types (hard/soft/pairs only)
- Absolutes Drill (never/always rules)
- Real-time feedback with explanations and mnemonics
- Session statistics tracking
- Progressive difficulty system
A modern, responsive web application built with Vue 3 and TypeScript that runs in your browser:
cd web/
npm install
npm run devThen open http://localhost:5173/ in your browser.
Web Version Features:
- Interactive playing card visuals
- Touch-friendly interface for mobile devices
- Real-time statistics with visual charts
- No installation required - runs in any modern browser
- Responsive design for desktop, tablet, and mobile
- All training modes with immediate feedback
The original Python implementation for command-line enthusiasts:
Requirements:
- Python 3.8 or higher
- macOS Terminal (or any compatible terminal)
- No external dependencies required
cd web/
npm install # One-time setup
npm run dev # Start development serverOpen http://localhost:5173/ in your browser to start training.
Start the interactive trainer with the main menu:
python3 bjstRun specific session types directly via command-line arguments:
# Quick practice (random scenarios)
python3 bjst --session random
# Learn by dealer strength groups
python3 bjst --session dealer
# Focus on specific hand types
python3 bjst --session hand
# Practice absolute rules
python3 bjst --session absolute
# Specify difficulty level
python3 bjst --session random --difficulty easy
python3 bjst -s absolute -d hard
# Show help and all options
python3 bjst --help-
--session, -s: Choose session typerandom: Mixed practice with all scenariosdealer: Practice by dealer strength (weak/medium/strong)hand: Focus on hand types (hard/soft/pairs)absolute: Practice absolute rules (always/never)
-
--difficulty, -d: Set difficulty leveleasy: Simpler scenariosnormal: Standard difficulty (default)hard: More challenging scenarios
- Quick Practice - Random hands vs random dealer cards
- Learn by Dealer Strength - Practice against specific dealer card groups:
- Weak dealers (4, 5, 6) - "bust cards"
- Medium dealers (2, 3, 7, 8)
- Strong dealers (9, 10, A)
- Focus on Hand Types - Practice specific categories:
- Hard totals only
- Soft totals only
- Pairs only
- Absolutes Drill - Practice never/always rules first
- View Statistics - See your session performance
- Quit - Exit the program
- Choose a practice mode from the main menu
- You'll be shown a dealer up-card and your hand
- Choose your action: (H)it, (S)tand, (D)ouble, s(P)lit
- Get immediate feedback with the correct answer and explanation
- Continue practicing to improve your accuracy
Dealer shows: 7
Your hand: 10, 6 (Hard 16)
What's your move?
(H)it, (S)tand, (D)ouble, s(P)lit: H
β Correct!
Press Enter to continue...
The project includes comprehensive unit tests to verify the strategy chart implementation.
python3 -m unittest tests.test_strategy -vpython3 -m unittest discover tests -vtests/test_strategy.py- Complete strategy chart validation- Tests all hard totals (5-21)
- Tests all soft totals (13-21)
- Tests all pairs (2-A)
- Validates edge cases and absolute rules
- Ensures 100% coverage of strategy combinations
All tests should pass, confirming that the strategy chart matches standard blackjack basic strategy.
blackjack_trainer/
βββ bjst/ # Python terminal implementation
β βββ __init__.py # Package initialization and exports
β βββ __main__.py # Entry point for `python3 bjst`
β βββ main.py # Main application logic
β βββ strategy.py # Strategy chart data and lookup
β βββ trainer.py # Training session classes
β βββ ui.py # Terminal interface utilities
β βββ stats.py # Statistics tracking
βββ web/ # Vue 3 web application
β βββ src/
β β βββ components/ # Vue components
β β βββ utils/ # Core strategy logic (TypeScript)
β β βββ types/ # TypeScript definitions
β β βββ App.vue # Main app component
β βββ package.json # Dependencies and scripts
β βββ README.md # Web-specific documentation
βββ swift/ # iOS/macOS SwiftUI app
βββ android/ # Android Kotlin app
βββ rust/ # Rust implementation
βββ cpp/ # C++ implementation
βββ go/ # Go implementation
βββ tests/ # Unit tests
βββ LICENSE # MIT license
βββ README.md # This file
βββ CLAUDE.md # Development workflow
βββ blackjack_basic_strategy.md # Official strategy reference
βββ blackjack_trainer_plan.md # Implementation plan
The trainer implements standard blackjack basic strategy with these rules:
- 4-8 decks
- Dealer stands on soft 17
- Double after split allowed
- Surrender not available
- "Aces and eights, don't hesitate" (always split)
- "Tens and fives, keep them alive" (never split)
- "Dealer bust cards (4,5,6) = player gets greedy"
- "Teens stay vs weak, flee from strong"
- Start with the Absolutes Drill to learn never/always rules
- Progress to Dealer Strength practice to understand patterns
- Use Hand Type Focus to master specific scenarios
- Practice regularly with Quick Practice for mixed scenarios
- Pay attention to the explanations and mnemonics provided
This project includes implementations in multiple programming languages for learning and comparison purposes:
- Python (
bjst/) - Original terminal-based implementation with complete feature set - Vue 3 Web App (
web/) - Modern browser-based version with interactive UI - SwiftUI (
swift/) - Native iOS/macOS app with modern SwiftUI interface - Rust (
rust/) - High-performance implementation - C++ (
cpp/) - Native implementation with CMake build system - Go (
go/) - Concurrent implementation - Android (
android/) - Native Android app
A comprehensive script is provided to run formatters, linters, and tests across all implementations:
./precommit.shThis script will:
- Format code using language-specific formatters (autopep8, cargo fmt, clang-format, go fmt)
- Run linters and static analysis (pylint, cargo clippy, go vet)
- Execute all test suites across all implementations
- Provide a summary of results with colored output
Individual implementation checks can also be run:
# Python only
pylint bjst/ && python3 -m unittest discover tests/
# Rust only
cd rust && cargo fmt && cargo clippy && cargo test
# C++ only
cd cpp && cmake --build build && cmake --build build --target test
# Go only
cd go && go fmt ./... && go vet ./... && go test ./...To run in development mode or make modifications:
- Clone or download the project
- All core functionality is in the main Python files
- Tests are in the
tests/directory - Run
./precommit.shbefore making changes to ensure code quality - Each implementation has comprehensive test coverage including hand generation validation
This project is for educational purposes to help learn blackjack basic strategy.