1 Tic-tac-toe Protocol (TTTP)
5 Carl Worth Richard Worth Kevin Worth
6 carl@theworths.org richard@theworths.org kevin@theworths.org
10 TTTP is a network protocol for playing the game tic-tac-toe. It permits
11 a single server to host multiple games with named participants. The
12 protocol is designed so that people can play using only telnet, but it is
13 expected that graphical interfaces will be able to drive the protocol as
16 TTTP borrows heavily from RRGP (Ricochet Robot Game Protocol) by Keith
17 Packard and indirectly from other network protocols like SMTP using a
18 synchronous command interface.
22 All commands include a response (yeah, synchronous protocols are
40 The TTTP server has no well defined port; agreement on which port to
41 use must be done through some external mechanism. Once connected,
42 the client must identify itself:
48 HELO <username> <server-addr> <server-port>
50 Possible errors: INVALIDNAME
54 1.2.1 Listing available users
60 WHO <username1> <games1> <username2> <games2> ...
62 lists connected users and the number of games they've won.
76 Displays help. If <command> is provided, displays more
77 detailed help on a specific command, otherwise displays an
78 overview of all commands.
88 Disconnects the client from the server.
92 VERSION <client-version-number>
96 VERSION <server-version-number>
98 Negotiates version number between client and server. The server
99 will respond with a version no higher than the client version
100 number, but it may be lower. Version numbers are integers.
102 This document describes protocol version 1.
104 1.3. Game management commands
106 1.3.1. Inviting a player to play a game
114 Possible errors: NOUSER, BUSY
116 1.3.2. Accepting an invitation
124 1.4. In-game commands
126 1.4.1. Get the game contents
134 <game-board> is a quoted multi-line string containing an
135 diagram of the tic-tac-toe board, which is a 3x3 array of
142 c = '_' for empty or 'X' or 'O' for a played space
151 Possible errors: NOTINGAME
161 Departs the current game
163 Possible errors: NOTINGAME
173 <number> indicates a number in the tic-tac-toe grid as
180 Possible errors: NOTINGAME, NOTYOURMOVE, NOTGRID
182 2. Asynchronous notification.
184 The server will send notices to each user in a game whenever
185 there is a move. It will also send notices to every connected
186 client when additional people join or new games are
187 started. These are of the form:
189 NOTICE <notice-code> <args>
191 Game-specific notices are sent to users involved in the related
192 game, other notices are sent to all users. Note that even the user
193 originating the notice receives a copy.
197 These notices are sent to all connected clients
201 NOTICE USER <username>
203 2.1.2. Disconnected user
205 NOTICE QUIT <username>
207 2.1.3. Game invitation
209 NOTICE INVITE <username>
211 2.1.4. Terminated games
213 NOTICE DISPOSE <game>
217 NOTICE MESSAGE <username> <text>
221 These notices are sent to all players and watchers in
224 2.2.1. Global game notices
226 2.2.1.1. New game begins
228 NOTICE NEWGAME <username> <username>
230 The first username listed will go first
232 2.2.1.2. Game over, and winner
234 NOTICE GAMEOVER <outcome> <username>
236 <outcame> is either WON in which case <username> indicates
237 the winner or CATSGAME in which case <username> is "".
243 NOTICE MOVE <username> <number>
247 The following error codes may be returned.
249 3.1. Connection setup errors
251 These errors occur during connection setup.
257 'helo' must be sent before any command other than 'quit'.
263 All names must be of non-zero length and must be unique.
265 Possibly returned by: HELO
267 3.2. Command format errors
269 Errors caused by ill-formed commands
275 An invalid command was specified
281 A syntax error was detected
287 A non-numeric value was supplied where a number was required
289 3.2.4. Not a grid number
293 The number specified in the command was not a valid grid number
295 3.3. Global command errors.
297 There are no errors from any of the global commands
299 3.4. Game management errors.
301 Errors from game management commands
307 A game name was provided that does not exist.
309 3.5. User information errors
315 A user name was provided that does not exist.
319 3.6.1. Global game errors
325 A game playing command was made, but the user is not a
326 particpant of any game.
328 Possibly returned by: MOVE
334 A command was executed by a watching user that is
335 permitted only to players
339 3.6.2.1. Not your turn
343 A move was submitted during the other player's turn
345 Possibly returned by: MOVE