Skip to content

AI ↔ Server

Once the handshake is complete, the drone drives its player with 12 commands. The server queues them and executes each after a delay expressed in time units (see Overview). Replies arrive in send order (FIFO). Reminder: at most 10 commands may be in flight at once, otherwise the server replies ko.

Sources: server/srcs/protocol/CommandParser.cpp, server/srcs/commands/Cmd*, ai/src/protocol/commands.py.

The 12 commands

Command Sent format Server reply Delay (t.u.) Example
Move forward Forward ok 7 Forwardok
Turn right Right ok 7 Rightok
Turn left Left ok 7 Leftok
Look Look [t0, t1, ...] 7 see below
Inventory Inventory [food n, linemate n, ...] 1 see below
Broadcast Broadcast <text> ok 7 Broadcast hellook
Free slots Connect_nbr <n> 0 Connect_nbr3
Lay an egg Fork ok 42 Forkok
Eject Eject ok / ko 7 Ejectok
Take Take <object> ok / ko 7 Take linemateok
Set Set <object> ok / ko 7 Set foodok
Incantation Incantation Elevation underway then Current level: N (or ko) 300 see below

(Delays from the getDelay() methods in server/srcs/commands/Cmd*.hpp.)

Details

  • Connect_nbr returns the number of eggs still available in the drone's team (free slots), with a zero delay (server/srcs/core/AICommandDispatcher.cpp).
  • Take <object> / Set <object> take a resource name: food, linemate, deraumere, sibur, mendiane, phiras, thystame.
  • An unrecognised command, or one with a wrong argument (present when it should not be, or vice versa), receives ko.

Look output

The reply is a bracketed list of tiles, comma-separated. A tile's content lists its objects space-separated:

  • the player token is repeated once per player present;
  • then each resource is repeated as many times as it occurs on the tile, in the order food, linemate, deraumere, sibur, mendiane, phiras, thystame.

An empty tile is represented by an empty string. Tile ordering follows the vision cone: tile 0 = the drone's tile, then rows of increasing depth (2 × depth + 1 tiles per row, left to right by orientation). Maximum depth equals the player's level. (server/srcs/algorithms/VisionAlgo.cpp.)

C -> S : Look
S -> C : [player, linemate, , food, , deraumere food, , , ]

Here tile 0 holds the drone, tile 1 a linemate, tile 2 is empty, tile 3 holds food, and so on.

Inventory output

A comma-separated name quantity list, bracketed.

Food is reported in time units

In Inventory, the food quantity is multiplied by 126 (food units × 126), which corresponds to the remaining life in time units (server/srcs/commands/CmdInventory.cpp). Other resources are returned as raw counts. Note: the GUI pin event, by contrast, returns the raw food count — a discrepancy documented in Known limitations.

C -> S : Inventory
S -> C : [food 1260, linemate 0, deraumere 0, sibur 0, mendiane 0, phiras 0, thystame 0]

food 1260 here corresponds to 10 units of food (10 × 126).

Broadcast example

C -> S : Broadcast hello world
S -> C : ok

The text may contain spaces; it is broadcast as-is to other players (see below) and to the GUI via pbc.

Unsolicited messages (Server → AI)

In addition to command replies, the server may send spontaneous messages at any time:

Message Format Meaning
Broadcast received message K, <text> Another player emitted a sound; K (0..8) is the incoming direction relative to the drone's orientation (0 = same tile).
Ejected eject: K The drone was pushed off a tile; K indicates the push direction.
Death dead The drone starved; the connection is about to close.

(server/srcs/algorithms/BroadcastAlgo.cpp, server/srcs/core/Server.cpp.)

Incantation sequence

When a drone issues Incantation, the server first replies Elevation underway, then — after the 300-time-unit delay and a re-validation of the conditions — sends each participant Current level: N (the new level) on success, or ko on failure (server/srcs/core/IncantationHandler.cpp).

C -> S : Incantation
S -> C : Elevation underway
... (300 time units later)
S -> C : Current level: 2

Broadcast parsing not implemented on the AI side

On the AI side, parse_broadcast raises NotImplementedError: the message K, <text> messages received are not used by the current strategy. Likewise, the encrypted team channel (ai/src/team/) is not wired in. See Known limitations and AI > Protocol layer. Reference: ai/src/protocol/parser.py.