Skip to main content
Zappy logo

Zappy

Teams of AI compete to evolve and conquer the world

Epitech · G-YEP-400Rust / C++TCP ProtocolMulti-player
README.md

Zappy — A Tribute to Zaphod Beeblebrox

A networked multi-player strategy game where teams of autonomous AI agents compete on a tile-based world. The first team to have 6 players reach elevation 8 wins.

Architecture

Three independent programs communicate over TCP sockets. The server is the single source of truth; AI clients and the GUI client both connect to it.

zappy_ai

One process per player. Fully autonomous — navigates, forages, cooperates via broadcasts, triggers incantations.

zappy_server

Written in Rust (spec: C, C++ or Rust). Single-process, single-thread, uses poll(). The team name GRAPHIC is reserved for the GUI to authenticate.

zappy_gui

Written in C++ with SFML. Authenticates with GRAPHIC as team name. Passive observer rendering the world in real-time.

Game Rules

The world is Trantor — a zero-relief, toroidal tile map (edges wrap around). Trantorians are pacifists; they forage resources and incant. Each player starts with 10 food (1 260 time units of life). One food unit sustains a player for 126 time units. A player who runs out of food receives dead and is disconnected.

Vision increases with elevation: at level 1, a player sees 1 tile ahead; each elevation adds one line in front and one extra tile on each side. The Look command returns a flat list of tiles ordered front-to-back, left-to-right.

CommandDescriptionTimeResponse
ForwardMove one tile ahead7/fok
RightTurn 90° clockwise7/fok
LeftTurn 90° counter-clockwise7/fok
LookObserve surrounding tiles7/f[tile, ...]
InventoryList carried resources & food left1/f[linemate n, ...]
Broadcast textDirectional message to all players7/fok
Connect_nbrQuery available team slotsvalue
ForkLay an egg (new player slot)42/fok
EjectPush all players off this tile7/fok / ko
Take objectPick up an object from this tile7/fok / ko
Set objectDrop an object on this tile7/fok / ko
IncantationStart elevation ritual (group action)300/fElevation underway → level k

Resources

food×0.5
linemate×0.3
deraumere×0.15
sibur×0.1
mendiane×0.1
phiras×0.08
thystame×0.05

Resources spawn at startup and every 20 time units. Quantity per resource = map_width × map_height × density. On a 10×10 map: 50 food, 5 thystame.

Elevation Requirements

TransitionPlayerslinematederaumeresiburmendianephirasthystame
1211
232111
342212
4541121
5641213
6761231
786222221

Players do not need to be on the same team — only the same level. Incantation is verified at start and end: if conditions fail at either check, elevation fails. Players are frozen during the ritual; stones are consumed on success.

Connection Protocol

When a client connects, the following handshake occurs:

text
Server → Client : WELCOME
Client → Server : TEAM-NAME
Server → Client : CLIENT-NUM    (available slots for this team)
Server → Client : X Y           (world dimensions)

The AI client can pipeline up to 10 commands without waiting for responses. Commands beyond 10 are silently dropped. The GUI authenticates by sending GRAPHIC as team name.

Getting Started

bash
# 1. Build all binaries
make

# 2. Start the server (20×20 map, 2 teams, 5 slots each, 100 ticks/s)
./zappy_server -p 4242 -x 20 -y 20 -n team1 team2 -c 5 -f 100

# 3. Connect the graphical client
./zappy_gui -p 4242 -h localhost

# 4. Launch AI clients (one per player)
./zappy_ai -p 4242 -n team1 -h localhost
-p portTCP port to listen on
-x widthMap width (tiles)
-y heightMap height (tiles)
-n names…Team names (space-separated)
-c clientsMax clients per team
-f freqTime units per second

Victory Condition

The first team to have 6 players simultaneously reach elevation level 8 wins. Achieving this requires gathering the rarest resources across the map and perfectly coordinating a final group incantation ritual.