Skip to main content

AI Client

Language: No constraint — Python, Rust, C, Go, anything that can open a TCP socket.

The AI client drives one player (drone) on the Trantor map. Once launched, it is fully autonomous — the user has no further influence. Multiple instances connect as separate players for the same team.

Connection & Handshake

Server → Client : WELCOME
Client → Server : TEAM-NAME
Server → Client : CLIENT-NUM (available slots)
Server → Client : X Y (world width × height)

CLIENT-NUM indicates how many more clients can still connect for this team. If ≥ 1, a new client may connect. The newly connected player hatches from a randomly selected egg and starts facing a random direction.

Command Queue

The client can pipeline up to 10 commands without waiting for responses. The server processes them in order. Commands beyond 10 are silently dropped.

All commands end with \n. Bad/unknown commands receive ko.

Command Reference

CommandTimeResponse
Forward7/fok
Right7/fok
Left7/fok
Look7/f[tile1, tile2, ...]
Inventory1/f[food n, linemate n, ...]
Broadcast text7/fok
Connect_nbrvalue
Fork42/fok
Eject7/fok / ko
Take object7/fok / ko
Set object7/fok / ko
Incantation300/fElevation underwayCurrent level: k / ko

f is the frequency set at server launch (-f flag). Default: f = 100.

Survival

  • Players start with 10 food = 1 260 time units of life.
  • 1 food unit = 126 time units.
  • Running out of food → server sends dead\n → client is disconnected.
  • Food is found on tiles and picked up with Take food.

Vision (Look)

The Look command returns a flat, comma-separated list of tile contents. The first element of tile 0 always contains player (the current player).

[player, object1 object2, , object3, ...]

Vision range increases with elevation:

LevelTiles visible (lines in front)
11
22
33
88

Each new level adds one line in front and widens the cone by one tile on each side.

Broadcast

Broadcast text\n

The server relays it to all clients (including the sender):

message K, text\n

K is the tile number indicating the direction the sound comes from. K = 0 means the sender is on the same tile.

Ejection

When another player ejects you:

eject: K\n

K is the direction of the tile the push came from. Ejection also destroys any eggs on the tile.

Reproduction (Fork)

Fork lays an egg, adding one available slot to the team. When a new client connects, it hatches from a random egg.

Incantation (Elevation Ritual)

To level up, the initiating player calls Incantation. Requirements (stones + players of the same level) must be met on the tile at both the start and the end of the ritual (300/f seconds). Conditions checked:

  • Correct number of players of the same level (not necessarily same team)
  • Correct stones present

On success: all participating players level up, stones are consumed, server broadcasts the result. On failure: ko.

API Reference

Since the AI has no language constraint, the doc generator depends on the language chosen by the team. Add the appropriate tool call to scripts/gen-docs.sh once the language is decided.

Common options:

LanguageToolCommand
Pythonpdocpdoc ./ai -o ../static/api/ai
Gogodocgodoc -http :6060 then export
C/C++Doxygensame approach as the GUI
Rustcargo docsame approach as the server
TypeScripttypedoctypedoc --out ../static/api/ai

Once configured, the reference will be served at /api/ai/.


Elevation Table

TransitionPlayerslinematederaumeresiburmendianephirasthystame
1 → 21100000
2 → 32111000
3 → 42201020
4 → 54112010
5 → 64121300
6 → 76123010
7 → 86222221