๐ฎ UNO Card Game - Python Edition
๐ฏ Overview
This is a console-based implementation of the classic UNO card game developed in Python. Challenge yourself against an intelligent computer opponent in a beautifully formatted terminal interface powered by the Rich library. The game provides an interactive experience with real-time card management, game state tracking, and detailed end-game summaries.
Current Version: 1-on-1 gameplay (You vs Computer)
Future Roadmap: Multiplayer support, AI vs AI mode, and Online capabilities
โจ Features
โ
Player vs Computer Gameplay - Test your skills against an AI opponent
โ
Rich Terminal UI - Beautiful, colorful console interface with Rich library
โ
Card Management - Intuitive card selection and hand management
โ
Power Cards - Draw Two, Skip, Reverse, Wild, and Wild Draw Four
โ
Smart Computer AI - Computer makes strategic card plays
โ
Game Summary - Detailed end-game statistics and winner announcement
โ
Real-time Feedback - Instant notifications for game events (UNO!, card plays, etc.)
โ
Standard UNO Rules - Fully compliant with official UNO game rules
๐ฒ UNO Game Rules
Basic Rules
- Starting Hand: Each player receives 7 cards
- Deck: Standard UNO deck of 108 cards in 4 colors (Red, Yellow, Green, Blue)
- Objective: Be the first to get rid of all your cards
Card Types
Number Cards (0-9)
- Available in all 4 colors
- Must match either the color or number of the previous card
Action Cards
- Skip ๐ซ - Next player loses their turn
- Reverse โฉ๏ธ - Changes direction (acts as Skip in 2-player mode)
- Draw Two ๐ฅ - Next player draws 2 cards and loses their turn
Wild Cards
- Wild ๐ - Can be played anytime; choose any color to continue with
- Wild Draw Four ๐ช - Can be played only when no other card matches; opponent draws 4 cards and loses turn
Winning Condition
- โUNO!โ is announced when a player has only 1 card left
- First player to empty their hand wins the game
- Game ends with a detailed summary showing rounds played and final statistics
๐ Tech Stack
| Technology | Purpose |
|---|---|
| Python 3.7+ | Core game logic and implementation |
| Rich | Beautiful console UI with colors and formatting |
| NumPy | Optional numerical operations |
| Random | Card shuffling and AI decision-making |
Installation Requirements
pip install rich
๐ Project Structure
UNO/
โโโ app.py # Main application entry point
โโโ logic_rich.py # Enhanced game logic with Rich UI
โโโ deck.py # UNO deck generation and management
โโโ UNO_rules.py # Game rules and card validation
โโโ card_showing_logic.py # Card display and formatting
โโโ summary.py # Game summary and statistics
โโโ requirenment.txt # Project dependencies
โโโ README.md # This file
File Descriptions
๐ฎ app.py
- Purpose: Game UNO
- Usage: Run this file to start playing
๐ง logic_rich.py
- Contains: Player turns, computer AI, game flow control
- Features: Beautiful console output, real-time status updates
๐ฏ logic.py
- Purpose: Core game logic implementation
- Contains: Game mechanics, turn management, hand tracking
- Features: Rule checking, card validation, turn cycling
๐ deck.py
- Purpose: UNO deck generation and management
- Contains: Standard deck creation (108 cards)
- Features: Card shuffling, deck initialization, custom deck sizes (optional 112-card variant)
โ๏ธ UNO_rules.py
- Purpose: Game rules enforcement
- Contains: Card validation rules and power card effects
- Features:
check_rules_for_cards()- Validates if a card play is legalapply_power_card()- Handles special card effects
๐จ card_showing_logic.py
- Purpose: Card display and formatting
- Contains: Console output formatting for cards
- Features: Visual card representation, hand display
๐ summary.py
- Purpose: Game summary and statistics
- Contains: End-game results and player statistics
- Features: Winner announcement, game duration, round count
๐ Installation
Prerequisites
- Python 3.7 or higher
- pip (Python package manager)
Steps
- Clone the Repository
git clone https://github.com/mayank-gariya/crazy-python-projects-.git cd crazy-python-projects-/UNO - Install Dependencies
pip install -r requirenment.txt
Or install Rich directly:
pip install rich
- Run the Game
python app.py
๐ฎ How to Play
Game Start
- Run
python app.py - The game initializes with both players receiving 7 cards
- First card from the deck is placed as the initial discard pile card
Your Turn (Player)
- View Your Cards: Enter
showto display all your cards with numbers - Play a Card: Enter the card number corresponding to your card
- Valid cards must match the color OR number OR be a Wild card
- Draw a Card: If you canโt play, select โNโ to draw a card
- UNO: When you have 1 card left, โUNO!โ is automatically announced
Computerโs Turn
- The computer automatically plays valid cards from its hand
- Draws a card if no valid play is available
- Strategic decision-making for card selection
Game End
- The game ends when either player empties their hand
- Winner Announcement with detailed summary
- Game statistics including:
- Total rounds played
- Cards remaining for each player
- Game duration
๐ Future Enhancements
Phase 2: Multiplayer Mode
- Support for 2-10 players
- Network-based multiplayer
- Local multiplayer (hot-seat mode)
Phase 3: Advanced AI & Modes
- All Robots Mode - Watch AI players compete autonomously
- Difficulty Levels - Easy, Medium, Hard computer opponents
- Improved AI Strategy - Smarter card selection and blocking tactics
Phase 4: Online Capabilities
- WebSocket Implementation - Real-time multiplayer over internet
- Server Architecture - Central game server for matchmaking
- Player Authentication - User accounts and rankings
- Web Interface - Browser-based gameplay
- Mobile Support - Cross-platform compatibility
Phase 5: Additional Features
- Game replay functionality
- Leaderboards and statistics tracking
- Custom rule sets
- Game history and replays
- Sound effects and animations
๐ Game Summary Details
After each game, youโll receive a detailed summary including:
- Winner: Who won the game
- Rounds Played: Total number of complete rounds
- Game Duration: Time taken to complete the game
- Cards Played: Total cards used in the game
- Final Status: Remaining cards in each playerโs hand
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ก Tips & Tricks
- ๐ฐ Strategic Plays: Save your Wild cards for critical moments
- ๐ฏ Memory: Keep track of cards played to predict whatโs in the deck
- โก Speed: In competitive mode, think fast and play faster
- ๐ก๏ธ Defense: Use Skip and Reverse cards to block opponents
๐ง Contact & Support
Developer: Mayank Gariya
GitHub: mayank-gariya
Repository: crazy-python-projects-