A modern implementation of the classic Spider Solitaire card game built with Python and Pygame.
PAUK (Russian: "Паук" - Spider) is a single-suit Spider Solitaire game featuring:
- Clean, intuitive drag-and-drop interface
- Automatic sequence completion
- Proper game rule validation
- Modular, well-documented codebase
- Comprehensive logging and error handling
- Complete Spider Solitaire gameplay with all traditional rules
- Drag-and-drop card movement for intuitive play
- Automatic sequence removal when King-to-Ace sequences are completed
- Visual feedback for valid moves and game state
- Keyboard shortcuts for common actions
- Game statistics tracking sequences completed
- Professional codebase with proper separation of concerns
- Python 3.9.6 or higher
- Pygame 2.6.1
- Clone or download the project
- Navigate to the project directory:
cd PAUK - Activate the virtual environment (if using the existing one):
# Windows Scripts\activate # Linux/Mac source Scripts/activate
- Install dependencies:
pip install -r requirements.txt
- Create a new virtual environment:
python -m venv pauk_env
- Activate the environment:
# Windows pauk_env\Scripts\activate # Linux/Mac source pauk_env/bin/activate
- Install dependencies:
pip install -r requirements.txt
Method 1: Using the launcher (Recommended)
# Make sure you're in the virtual environment
python pauk.pyMethod 2: Direct execution
# Make sure you're in the virtual environment first:
.venv\Scripts\activate # Windows
# source .venv/bin/activate # Linux/Mac
# Then run the game
python src/main.pyMethod 3: Using the setup script
python setup.pyOption 1: Using the test runner (Recommended)
python run_tests.pyOption 2: Using unittest directly
# Make sure you're in the virtual environment
python -m unittest discover tests -vOption 3: Individual test files
python -m unittest tests.test_card -v
python -m unittest tests.test_game_rules -vRemove all cards from the playing field by creating complete sequences from King to Ace of the same suit.
- Card Movement: Only face-up cards can be moved
- Sequence Building: Cards must be placed in descending order of the same suit
- Multi-Card Selection: You can move sequences of properly ordered cards together
- Empty Piles: Any card can be placed on an empty pile
- Stock: Click "Add Cards" to deal one card to each pile (when stock is available)
- Auto-Completion: Complete King-to-Ace sequences are automatically removed
- Mouse: Click and drag to move cards
- Escape: Cancel current selection
- F2: Start new game
- F1: Show help (future feature)
- Stock Counter: Shows remaining cards in stock
- Sequences Counter: Shows completed sequences
- Add Cards Button: Deals cards from stock to all piles
PAUK/
├── src/ # Main source code
│ ├── main.py # Entry point
│ ├── config/ # Configuration
│ │ ├── constants.py # Game constants
│ │ └── __init__.py
│ ├── models/ # Game models
│ │ ├── card.py # Card class
│ │ ├── pile.py # Pile class
│ │ └── __init__.py
│ ├── game/ # Game logic
│ │ ├── engine.py # Main game engine
│ │ ├── rules.py # Rule validation
│ │ └── __init__.py
│ ├── ui/ # User interface
│ │ ├── renderer.py # Graphics rendering
│ │ ├── events.py # Event handling
│ │ └── __init__.py
│ └── __init__.py
├── tests/ # Unit tests (future)
├── requirements.txt # Dependencies
├── README.md # This file
├── PAUK_PROJECT_SPECIFICATION.md # Detailed specification
└── .gitignore # Git ignore rules
The codebase follows clean architecture principles:
- Models (
src/models/): Core game entities (Card, Pile) - Game Logic (
src/game/): Business rules and game engine - UI (
src/ui/): Rendering and event handling - Configuration (
src/config/): Constants and settings
The game includes comprehensive logging:
- Console output for real-time feedback
- Log file (
pauk_game.log) for debugging - Different log levels for various components
- Graceful error recovery for invalid moves
- Comprehensive exception handling
- User-friendly error messages
- Language: Python 3.9.6
- Framework: Pygame 2.6.1
- Architecture: Modular object-oriented design
- Window Size: 1000×700 pixels
- Card Size: 70×100 pixels
- Performance: 60 FPS with efficient rendering
-
"No module named 'pygame'" Error:
- Problem: You're running tests/game outside the virtual environment
- Solution: Activate the virtual environment first:
# Windows .venv\Scripts\activate # Linux/Mac source .venv/bin/activate
- Alternative: Install pygame globally:
pip install pygame==2.6.1 - Check: Look for
(.venv)prefix in your command prompt
-
Import Errors:
- Ensure virtual environment is activated
- Check that pygame is installed:
pip list | grep pygame
-
Game Won't Start:
- Verify Python version:
python --version - Check log file for error details
- Verify Python version:
-
Performance Issues:
- Close other applications
- Check system resources
-
Tests Failing:
- Use
python run_tests.pyfor detailed diagnostics - Ensure all dependencies are installed:
pip install -r requirements.txt
- Use
Check the log file pauk_game.log for detailed error information. The game logs all major actions and errors with timestamps.
- Multiple difficulty levels (2-suit, 4-suit variations)
- Save/load game functionality
- Statistics tracking across sessions
- Sound effects and animations
- Online leaderboards
- Undo/redo functionality
This is a well-structured codebase suitable for learning and extension. Key areas for contribution:
- Unit tests implementation
- UI/UX improvements
- Additional game variations
- Performance optimizations
This project is created for educational and entertainment purposes.
- English Version (this file)
- Russian Version
Enjoy playing PAUK Spider Solitaire!