Vladyslav Doloman 0703561446 Initial commit: Multiplayer Snake game with server discovery
Implemented a complete network multiplayer Snake game with the following features:

Core Game:
- Client-server architecture using asyncio for networking
- Pygame-based rendering at 60 FPS
- Server-authoritative game state with 10 TPS
- Collision detection (walls, self, other players)
- Food spawning and score tracking
- Support for multiple players with color-coded snakes

Server Discovery:
- UDP multicast-based automatic server discovery (239.255.0.1:9999)
- Server beacon broadcasts presence every 2 seconds
- Client discovery with 3-second timeout
- Server selection UI for multiple servers
- Auto-connect for single server
- Graceful fallback to manual connection

Project Structure:
- src/shared/ - Protocol, models, constants, discovery utilities
- src/server/ - Game server, game logic, server beacon
- src/client/ - Game client, renderer, discovery, server selector
- tests/ - Unit tests for game logic, models, and discovery

Command-line interface with argparse for both server and client.
Comprehensive documentation in README.md and CLAUDE.md.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-04 13:50:16 +03:00

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

# 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):

    python run_server.py
    # Optional: python run_server.py --name "My Server" --port 8888
    
  2. Start one or more clients (in separate terminals):

    python run_client.py --name Alice
    # Clients will automatically discover servers on the local network
    

Manual Connection

# 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

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

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

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
Description
No description provided
Readme 184 KiB
Languages
Python 77.9%
JavaScript 18.9%
CSS 2%
HTML 1.2%