# Multiplayer Snake Game A network multiplayer Snake game built with Python, asyncio, and pygame. ## Features - Real-time multiplayer gameplay with client-server architecture - **Automatic server discovery** using multicast (zero-configuration LAN play) - Support for multiple players simultaneously - Classic Snake gameplay with collision detection - Color-coded snakes for each player - Score tracking and win conditions ## Setup ```bash # Create and activate virtual environment python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # Install dependencies pip install -r requirements.txt # For development pip install -r requirements-dev.txt ``` ## Running the Game ### Quick Start (Auto-Discovery) 1. **Start the server** (in one terminal): ```bash python run_server.py # Optional: python run_server.py --name "My Server" --port 8888 ``` 2. **Start one or more clients** (in separate terminals): ```bash python run_client.py --name Alice # Clients will automatically discover servers on the local network ``` ### Manual Connection ```bash # Server python run_server.py --host 0.0.0.0 --port 8888 --name "Game Room" # Client (specify host directly) python run_client.py 192.168.1.100 --port 8888 --name Bob ``` ### Server Options ```bash python run_server.py --help # --host HOST Host address to bind to (default: localhost) # --port PORT Port number (default: 8888) # --name NAME Server name for discovery (default: Snake Server) # --no-discovery Disable multicast beacon ``` ### Client Options ```bash python run_client.py --help # [host] Server host (omit to use auto-discovery) # --port PORT Server port (default: 8888) # --name NAME Your player name (default: Player) # --discover Force discovery mode ``` ### Playing the Game - Press **SPACE** to start the game (any player can start) - Use **arrow keys** or **WASD** to control your snake - Eat food to grow and score points - Avoid walls and other snakes ## Testing ```bash pytest pytest --cov=src --cov-report=html # With coverage ``` ## Project Structure - `src/server/` - Game server with authoritative game state - `src/client/` - Game client with pygame rendering - `src/shared/` - Shared code (models, protocol, constants) - `tests/` - Unit tests