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.
64 Possible errors: NONAMESET
74 Sends a message to all connected users. The text must be a
75 single token. Use a quoted-string to include spaces in the
78 Possible errors: NONAMESET
84 Displays help. If <command> is provided, displays more
85 detailed help on a specific command, otherwise displays an
86 overview of all commands.
96 Disconnects the client from the server.
100 VERSION <client-version-number>
104 VERSION <server-version-number>
106 Negotiates version number between client and server. The server
107 will respond with a version no higher than the client version
108 number, but it may be lower. Version numbers are integers.
110 This document describes protocol version 1.
112 1.3. Game management commands
114 1.3.1. Inviting a player to play a game
122 Possible errors: NOUSER, BUSY, NONAMESET
124 1.3.2. Accepting an invitation
132 Possible errors: NONAMESET
134 1.4. In-game commands
136 1.4.1. Get the game contents
144 <game-board> is a quoted multi-line string containing an
145 diagram of the tic-tac-toe board, which is a 3x3 array of
152 c = '_' for empty or 'X' or 'O' for a played space
161 Possible errors: NOTINGAME, NONAMESET
171 Departs the current game
173 Possible errors: NOTINGAME, NONAMESET
183 <number> indicates a number in the tic-tac-toe grid as
190 Possible errors: NOTINGAME, NOTYOURMOVE, NOTGRID, NONAMESET
192 2. Asynchronous notification.
194 The server will send notices to each user in a game whenever
195 there is a move. It will also send notices to every connected
196 client when additional people join or new games are
197 started. These are of the form:
199 NOTICE <notice-code> <args>
201 Game-specific notices are sent to users involved in the related
202 game, other notices are sent to all users. Note that even the user
203 originating the notice receives a copy.
207 These notices are sent to all connected clients
211 NOTICE USER <username>
213 2.1.2. Disconnected user
215 NOTICE QUIT <username>
217 2.1.3. Game invitation
219 NOTICE INVITE <username>
221 2.1.4. Terminated games
223 NOTICE DISPOSE <game>
227 NOTICE MESSAGE <username> <text>
231 These notices are sent to all players and watchers in
234 2.2.1. Global game notices
236 2.2.1.1. New game begins
238 NOTICE NEWGAME <username> <username>
240 The first username listed will go first
242 2.2.1.2. Game over, and winner
244 NOTICE GAMEOVER <outcome> <username>
246 <outcame> is either WON in which case <username> indicates
247 the winner or CATSGAME in which case <username> is "".
253 NOTICE MOVE <username> <number>
257 The following error codes may be returned.
259 3.1. Connection setup errors
261 These errors occur during connection setup.
267 'helo' must be sent before any command other than 'help',
270 Possibly returned by: WHO MESSAGE INVITE ACCEPT SHOW PART MOVE
276 All names must be of non-zero length and must be unique.
278 Possibly returned by: HELO
280 3.2. Command format errors
282 Errors caused by ill-formed commands
288 An invalid command was specified
294 A syntax error was detected
300 A non-numeric value was supplied where a number was required
302 3.2.4. Not a grid number
306 The number specified in the command was not a valid grid number
308 3.3. Global command errors.
310 There are no errors from any of the global commands
312 3.4. Game management errors.
314 Errors from game management commands
320 A game name was provided that does not exist.
322 3.5. User information errors
328 A user name was provided that does not exist.
332 3.6.1. Global game errors
338 A game playing command was made, but the user is not a
339 particpant of any game.
341 Possibly returned by: MOVE
347 A command was executed by a watching user that is
348 permitted only to players
352 3.6.2.1. Not your turn
356 A move was submitted during the other player's turn
358 Possibly returned by: MOVE