A 4-player terminal card game
Project description
Belote – 4-Player Terminal Card Game
Complete implementation of the French card game Belote for the terminal, with a full-screen green felt table and full card graphics at compass positions (N/W/E/S).
Showcase
Main Menu
⢠⣴⣶⣶⣶⣄
⣿⣿⣿⣿⣿⣿⣦
⢰⣿⣿⣿⣿⡿⠟⠁⣠⣴⣶⣦⠄
⢸⣿⣿⠟⠉⣠⣴⣿⣿⣿⠟⠁⣠⣾⣿⣦⡀
⠉⣀⣴⣾⣿⣿⣿⠟⢁⣤⣾⣿⣿⣿⣿⣿⡆
⢀⣤⣾⣿⣿⣿⡿⠛⢁⣴⣿⣿⣿⣿⣿⣿⣿⠟⠁⡀
⢼⣿⣿⣿⡿⠋⣀⣴⣿⣿⣿⣿⣿⣿⣿⡿⠉⣠⣾⣿⡆
⠘⢿⡿⠋⣠⣾⣿⣿⣿⠟⠁⣿⣿⣿⣿⣿⠟⢁⣀
⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⠏⢀⣴⣿⣿⣿⠋⢠⣾⣿⣷⣦⡀
⢻⣿⣿⣿⣿⣿⣿⣿⠟⢁⣴⣿⣿⣿⡿⠁⣰⣿⣿⣿⣿⣿⣿
⠹⢿⣿⣿⣿⡿⠋⣠⣾⣿⣿⣿⠟⢀⣼⣿⣿⣿⣿⣿⣿⡟
⠉⠉⠉⠀⢾⣿⣿⣿⣿⠋⠀⠚⠛⠛⠛⠛⠛⠛⠁
(
) (
___...(-------)-....___
.-'' ) ( ''-.
.-'``'|-._ ) _.-|
/ .--.| `''---...........---''` |
/ / | > Start Game < |
| | | Difficulty: Medium |
\ \ | Target Score: 1000 |
`\ `\ | Speed: Normal |
`\ `| Rules & History |
_/ /\ Quit /
(__/ \ /
_..---''` \ /`''---.._
.-' \ / '-.
: `-.__ __.-' :
: ) ''---...---'' ( :
'._ `''...___...--''` _.'
jgs \''--..__ __..--''/
'._ '''----.....______.....----''' _.'
`''--..,,_____ _____,,..--''`
`'''----'''`
Card Graphics
┌────┐ ┌────┐ ┌────┐ ┌────┐
│J ♠ │ │Q ♦ │ │K ♥ │ │A ♣ │
│ ⚔ │ │ ♕ │ │ ♔ │ │ ★ │
│ J ♠│ │ Q ♦│ │ K ♥│ │ A ♣│
└────┘ └────┘ └────┘ └────┘
Requirements
- Python >= 3.10
- No third-party dependencies (stdlib only)
- Terminal with >= 100 columns x 40 rows
- UTF-8 support (for card symbols: ♠♥♦♣)
Quick Start
# Install in editable mode (recommended for development)
pip install -e .
# Or install from PyPI (once uploaded)
pip install belote-cli
# Play using the belote command
belote
# Custom settings
belote --difficulty hard --target 500 --seed 123 --speed fast
Controls
General:
?orH: Show keyboard shortcut helpM: Toggle sound effects on/offQ: Quit to main menu or exitT: View Game History (Round-by-round)
Main Menu:
↑↓: Navigate options←→: Quick-change settings (Difficulty, Target, Speed, Mode)Enter: Select option / Enter submenu
Gameplay:
←→or↑↓: Move selectionEnter: Confirm card/bid1-8: Direct card selection (or1-4for bids)O: Sort hand by suit and rankZ: Undo last moveSpaceorEsc: Skip animations
Features
- Rich Terminal UI: Full-screen green felt table with detailed card graphics, face card art, and distinct color palettes. Graceful fallback to text-only mode for non-UTF-8 terminals.
- Incremental Rendering: High-performance cursor-based updates for zero-flicker gameplay even at high speeds.
- Hand Sorting: One-touch organization of your hand by suit and rank for better strategic overview.
- Main Menu: Configure Mode, Difficulty, Target Score, and Game Speed, and access Rules & History (EN/FR) without restarting the app.
- Undo/Redo: Press
Zto undo your last move during bidding or play. - Statistics: Global tracking of games played/won, win rate (per difficulty), capots, best/worst rounds, and longest games. Includes a Session Stats dashboard.
- Sound Effects: Enhanced auditory feedback for trick wins, Belote, and Capot, with a built-in mute toggle.
- Declarations: Automatic detection and announcement of sequences (Tierce, Quarte, etc.) and Carrés after the first trick.
- Live HUD: Real-time round scoring displays points won during the current round, with a smooth "rolling" numerical animation for total scores.
- High Fidelity: Full implementation of French Belote rules including a two-round bidding system, "Dix de Der", and "Capot" (250 pts).
- Rules & History Viewer: A scrollable, bilingual (English/French) in-game reference for the game's heritage and mechanics.
AI
Three difficulty levels:
- Easy: Random legal moves, bids on 2+ honors.
- Medium: Heuristic suit scoring, strategic lead (longest suit), and smart covering/ducking.
- Hard: Void inference, 2-ply lookahead for critical tricks, and randomized "personality" bidding thresholds.
Project Structure
belote/
├── src/belote/
│ ├── main.py # Entry point, CLI parsing, terminal setup
│ ├── gameflow.py # Main game loop and phase transitions
│ ├── deck.py # Card, Suit, Rank, deck operations, points
│ ├── game.py # GameState, phases, pure transitions, legal moves
│ ├── bidding.py # Bidding phase state machine
│ ├── scoring.py # Declarations, round scoring, capot
│ ├── ai.py # Three-tier AI (easy/medium/hard)
│ ├── ui/ # Modular UI package
│ │ ├── render.py # ANSI table and card rendering
│ │ ├── prompts.py # Keyboard input and menu navigation
│ │ ├── menu.py # Main menu and settings
│ │ └── announce.py# Sound and score animations
│ ├── ansi.py # ANSI escape helpers (colors, cursor)
│ ├── input.py # Platform-dispatched key reader
│ ├── stats.py # Global and session statistics tracking
│ └── rules.py # Game rules content
├── tests/ # Comprehensive test suite (50+ tests)
├── pyproject.toml # Build system and dev dependencies (ruff/mypy)
├── LICENSE # MIT License
└── DEVELOPMENT.md # Detailed setup and dev guide
Running Tests
PYTHONPATH=src pytest
Terminal Hygiene
Signal handlers (SIGINT, SIGTERM) and atexit hooks ensure the terminal is always restored — cursor visible, colors reset, alt-screen off — even after Ctrl+C or crashes.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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
File details
Details for the file belote_cli-0.9.6.tar.gz.
File metadata
- Download URL: belote_cli-0.9.6.tar.gz
- Upload date:
- Size: 5.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e2105075ca4267140b80e823c81e6200862510d5b6addd2935ab72474ade440
|
|
| MD5 |
c933fcf59565c6d754949b91dd74aa8b
|
|
| BLAKE2b-256 |
587af2692f1a9274ef705226d45270611b9683cefc713e13c74307b05ef66b69
|
File details
Details for the file belote_cli-0.9.6-py3-none-any.whl.
File metadata
- Download URL: belote_cli-0.9.6-py3-none-any.whl
- Upload date:
- Size: 49.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a6fbca412baa2974e49cd4b83773793747e247d8b0182fab27085fbe4316c94
|
|
| MD5 |
465dcf4e4e207e661090f2c0943870b8
|
|
| BLAKE2b-256 |
592a1aa1255b25654007c293809d363db3b2cc75a53cb14d9f2465f01c0d510e
|