Skip to content

Azertoxe/Zappy

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

757 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Zappy

Table of Contents

Description

Zappy is a complex multiplayer network game inspired by Douglas Adams' "The Hitchhiker's Guide to the Galaxy". Players control Trantorian inhabitants on the spherical world of Trantor, where teams compete to elevate their members through mystical rituals involving resource collection and cooperation.

Documentation:

The project consists of three main components:

  • Server (C): Manages the game world, resources, and player interactions
  • Graphical Client (C++): Provides real-time visualization of the game world
  • AI Client (Any language): Autonomous agents that control individual players

Features

Core Gameplay

  • Multiplayer Network Architecture: TCP socket-based communication with support for multiple concurrent clients
  • Resource Management: Six types of stones (linemate, deraumere, sibur, mendiane, phiras, thystame) plus food
  • Elevation System: Players advance through 8 levels using specific resource combinations and group rituals
  • Spherical World: Wrap-around map where players exit one side and enter the opposite
  • Vision System: Level-based sight range that expands with elevation
  • Sound Broadcasting: Directional audio messages between players
  • Player Reproduction: Fork command creates eggs for team expansion

Technical Features

  • Real-time Multiplexing: Server uses poll() for efficient socket handling
  • Time-based Actions: Configurable frequency system for action execution
  • Autonomous AI: Self-directing clients with no human intervention required
  • Live Visualization: GUI receives real-time updates from server
  • Resource Spawning: Dynamic resource generation every 20 time units

Objectives

This project aims to develop comprehensive skills in several key areas of computer science and software engineering:

Technical Learning Goals

  1. Network Programming: Master TCP socket communication, multiplexing with poll(), and real-time client-server architecture
  2. Concurrent Systems: Handle multiple simultaneous connections without blocking, implementing efficient resource management
  3. Protocol Design: Create robust communication protocols between different system components
  4. Cross-Language Integration: Coordinate C server, C++ GUI, and multi-language AI clients
  5. Real-Time Systems: Implement time-based action execution and event scheduling
  6. AI Development: Design autonomous agents capable of strategic decision-making and cooperation

Software Engineering Objectives

  • Modular Architecture: Build three distinct but interconnected applications
  • Code Quality: Write maintainable, efficient, and well-documented code
  • Testing & Debugging: Develop skills in network debugging and multi-client testing
  • Performance Optimization: Handle resource spawning, player actions, and GUI updates efficiently
  • Error Handling: Implement robust error recovery for network failures and invalid commands

Project Management Goals

  • Team Collaboration: Coordinate development across multiple components
  • Documentation: Create comprehensive technical documentation and user guides
  • Version Control: Manage complex multi-binary project structure
  • Deployment: Package and distribute networked applications

Understanding the Context

Zappy simulates a complex ecosystem on the planet Trantor where teams compete to achieve spiritual elevation. The game mechanics create a rich environment for AI development and strategic thinking:

Game Objective

The primary goal is for a team to have at least 6 players reach the maximum elevation level (level 8). This requires:

  1. Resource Collection: Gathering the correct combination of stones for each elevation
  2. Team Coordination: Multiple players of the same level must perform rituals together
  3. Survival Management: Maintaining food supplies to prevent starvation (126 time units per food)
  4. Strategic Planning: Balancing individual advancement with team cooperation

Elevation Requirements

Level Players Linemate Deraumere Sibur Mendiane Phiras Thystame
1β†’2 1 1 0 0 0 0 0
2β†’3 2 1 1 1 0 0 0
3β†’4 2 2 0 1 0 2 0
4β†’5 4 1 1 2 0 1 0
5β†’6 4 1 2 1 3 0 0
6β†’7 6 1 2 3 0 1 0
7β†’8 6 2 2 2 2 2 1

World Mechanics

  • Trantorians are peaceful, bodiless inhabitants who occupy entire tiles
  • Spherical World: Players wrap around map edges (exit right, enter left)
  • Resources are distributed according to density formulas based on map size
  • Time Management is crucial with configurable action speeds
  • Communication happens through directional broadcasts
  • Vision is limited and expands with player level advancement
  • Reproduction allows teams to create new players through the fork command

The game emphasizes artificial intelligence, network programming, and real-time systems design while providing an engaging competitive environment.

More details can be found in the Subject.


Build Instructions

Prerequisites

  • GCC compiler for C code
  • G++ compiler for C++
  • Standard C and C++ libraries
  • OGRE library
  • Make & CMake utility
  • Git

How to Install OGRE Library

The graphical client uses the OGRE (Object-Oriented Graphics Rendering Engine) library. To install OGRE on Ubuntu/Debian-based systems:

# Install dependencies
sudo apt-get update
sudo apt-get install -y \
    build-essential \
    cmake \
    git \
    libgl1-mesa-dev \
    libglu1-mesa-dev \
    libx11-dev \
    libxaw7-dev \
    libxrandr-dev \
    libxt-dev \
    libxxf86vm-dev \
    libfreetype6-dev \
    libfreeimage-dev \
    libzzip-dev \
    libois-dev \
    libboost-all-dev \
    libpugixml-dev \
    libsdl2-dev

# Go to home directory
cd ~

# Clone the repo
git clone https://github.com/OGRECave/ogre.git

# Go to the cloned repo
cd ogre

# Select the version v14.3.4
git checkout v14.3.4

# Create the build directory
mkdir build && cd build

# Compilation
cmake .. -DOGRE_BUILD_SAMPLES2=ON -DOGRE_BUILD_TESTS=OFF
make -j$(nproc)

# Installation
sudo make install

# Fix library linking
echo "/usr/local/lib" | sudo tee /etc/ld.so.conf.d/ogre.conf
sudo ldconfig

Tested on Ubuntu 24.04 For other distributions or more details, see the OGRE official installation guide.

Compilation

# Clone the repository
git clone <repository-url>
cd zappy

# Build all components
make

# Individual builds
make zappy_server    # Build server
make zappy_gui      # Build GUI client
make zappy_ai       # Build AI client

Makefile Targets

The Makefile should provide these targets:

  • zappy_server: Compiles the game server
  • zappy_gui: Compiles the graphical client
  • zappy_ai: Compiles the AI client

Usage

Server

./zappy_server -p port -x width -y height -n team1 team2 ... -c clientsNb -f freq

Options:

  • -p port: Port number for server
  • -x width: World width
  • -y height: World height
  • -n team1 team2 ...: Team names
  • -c clientsNb: Number of authorized clients per team
  • -f freq: Reciprocal of time unit for action execution

Graphical Client

./zappy_gui -p port -h machine

Options:

  • -p port: Server port number
  • -h machine: Server hostname

AI Client

./zappy_ai -p port -n name -h machine

Options:

  • -p port: Server port number
  • -n name: Team name
  • -h machine: Server hostname (localhost by default)

Example Session

# Start server with 10x10 world, 2 teams, 4 clients per team
./zappy_server -p 4242 -x 10 -y 10 -n team1 team2 -c 4 -f 100

# Start GUI client
./zappy_gui -p 4242 -h localhost

# Start AI clients
./zappy_ai -p 4242 -n team1 -h localhost
./zappy_ai -p 4242 -n team2 -h localhost

Contributors


Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is released under the GNU GPLv3 License. See LICENSE.

About

🌍 Zappy β€” A networked multiplayer game of resource management, AI strategy, and ritualistic elevation on the world of Trantor.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C 79.8%
  • C++ 13.5%
  • Python 4.9%
  • Makefile 1.8%