This is protocol version 0.22 for the Galax game. All commands consist of four letters and a space-separated list of arguments. Each command is terminated by the sequence \r\n (carriage return, newline). Most command arguments are integers. Planet id's are unsigned and start at 0. Player id's start at 1 (0 as a planet owner indicates an independent planet). Time, measured in years, is specified in floating-point numbers with at least one decimal (so, for example, the first turn starts with YEAR 0.0). X and Y coordinates are unsigned and start at 0. (0, 0) is the upper left corner of the playfield (this does not really matter, of course). y is the row and x is the column. Game id's start at 1. If a client JOINs with game id=0, the server starts a new game. Protocol version is an ASCII string, and protocol versions may be lexically compared (e.g. "1.0a" > "1.0" and "1.15" > "1.0"). and are strings which may contain spaces, because they are always the last arguments on a line. may not contain spaces. The strings are not delimited in any way. Initialization: The client makes a connection to TCP port 42529. The server identifies itself with the command --> GSRV The client answers with <-- GCLT --> CLOK Now the server lists the games you can join into. --> GAME (repeated...) --> SLCT The client must now choose a game. If id=0, a new game is created. <-- JOIN The server returns the game id (important if a new game was created). --> JNOK The server lists the players when a new player joins the game. Note that a player may be listed several times. --> GPLR (repeated...) The first player (id 1) starts the game <-- PLAY The server lists data about the playfield and the game --> GFLD Game: The game consists of two phases, Move phase and Battle phase. It starts with Move phase. Move phase: The server lists the state of all planets. Currently unknown values for and are shown as -1. is an index value starting from 0. The home planet for player x has the id (x-1). --> PLNT (repeat...) --> YEAR After this the client may issue commands. The possible commands are MOVE and DONE. <-- MOVE --> MVOK (repeat...) <-- DONE Now the battle phase starts. The server crunches through the events in order and issues the commands BATT, FORT and KILL. A BATT is followed by one or more ATTK commands, which show the stages of combat, and finally a BWIN declares the winner of the battle. There is some redundant data in the arguments - feel free to throw some away. It's just to avoid storing much data on the client side. In ATTK commands, who=1 means that the attacker is charging, and who=0 is the defender. Normally, the defender takes the first turn, but a surprise attack (issurprise=1) gives the attacker the first turn. gives the number of attacking ships, and as each attacking ship destroys one ship, it also shows how many ships were destroyed. Battle phase: --> BATT --> ATTK (repeated...) --> BWIN --> FORT Issued when a player is dead, i.e. has neither ships nor planets. --> KILL Declares the winner and ends the game. --> WINN The possible errors are: ERRP The player is not allowed to do that. E.g. the second player tries to start the game, or a player tries to send ships from someone else's planet. ERRC Command syntax error. ERRM Error (not syntax) in a MOVE command. E.g. not enough ships on planet or illegal planet id's. ERRJ Cannot join. The server is busy.