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
Controls
Main Menu:
↑↓: Navigate optionsEnter: Select optionQ: Quit application
Gameplay:
←→or↑↓: Move selectionEnter: Confirm action1-8: Direct card/bid selectionQ: Return to main menu during gameplay
Features
- Rich Terminal UI: Full-screen green felt table with detailed card graphics, face card art (Roi ♔, Dame ♕, Valet ⚔), and distinct color palettes.
- Main Menu: Configure Difficulty, Target Score, and Game Speed, and access Rules & History (EN/FR) without restarting the app.
- Live HUD: Real-time round scoring displays points won during the current round, with a smooth "rolling" numerical animation for total scores.
- Trick History: Visual "Last Trick" panel helps track the flow of the game.
- High Fidelity: Full implementation of French Belote rules including a two-round bidding system, "Dix de Der", and "Capot" (250 pts) announcements.
- Rules & History Viewer: A scrollable, bilingual (English/French) in-game reference for the game's heritage and mechanics.
- Robust Input: High-performance unbuffered key reading for responsive navigation and 'q' to quit functionality.
AI
Three difficulty levels:
- Easy: Random legal moves, bids on 2+ honors
- Medium: Heuristic suit scoring, strategic play (cover/duck/duck)
- Hard: Void inference, 1-ply lookahead, Monte-Carlo bidding
Project Structure
belote/
├── src/belote/
│ ├── main.py # Entry point, game loop, CLI args
│ ├── 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)
│ ├── ansi.py # ANSI escape helpers (colors, cursor)
│ ├── input.py # Platform-dispatched key reader
│ ├── ui.py # Render, prompts, full-screen layout
│ └── rules.py # Game rules content
├── tests/
│ └── test_belote.py # 36 pytest tests
├── pyproject.toml # Build system configuration
├── 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.1.tar.gz.
File metadata
- Download URL: belote_cli-0.9.1.tar.gz
- Upload date:
- Size: 38.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d10af63a383c095e61831b863edc2ac7f8bf835d9b0a8cfa2aaff63af901d58
|
|
| MD5 |
abf9538817dc6984f8a43b544f187dbd
|
|
| BLAKE2b-256 |
6d03f1f93b56267412699245480d644c05dadb530e8b1c57ddd2f5808079f7b2
|
File details
Details for the file belote_cli-0.9.1-py3-none-any.whl.
File metadata
- Download URL: belote_cli-0.9.1-py3-none-any.whl
- Upload date:
- Size: 36.4 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 |
5476059fcab5596e30d8bbcdc3823af034a751cee897114b26551dc99a1a2b17
|
|
| MD5 |
d32c6c0106111f8dd4fead7c66ac1ec9
|
|
| BLAKE2b-256 |
ab23a2b3d12e723943d2efdeab849b222e0337df2947601a29be63c11f58497f
|