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: INVALID_NAME
54 1.2.1. Listing available users
60 WHO <username1> <username2> ...
62 Lists connected users.
64 Possible errors: NO_NAME_SET
72 STATISTICS <username> "
76 Lists the statistics for the specified user.
78 Possible errors: NO_NAME_SET, NO_USER
88 Sends a message to all connected users. The text must be a
89 single token. Use a quoted-string to include spaces in the
92 Possible errors: NO_NAME_SET
101 <overview or detailed help>
104 Displays help. If <command> is provided, displays more
105 detailed help on a specific command, otherwise displays an
106 overview of all commands.
116 Disconnects the client from the server.
120 VERSION <client-version-number>
124 VERSION <server-version-number>
126 Negotiates version number between client and server. The server
127 will respond with a version no higher than the client version
128 number, but it may be lower. Version numbers are integers.
130 This document describes protocol version 1.
132 1.3. Game management commands
134 1.3.1. Inviting a player to play a game
142 Possible errors: NO_USER, BUSY, NO_NAME_SET
144 1.3.2. Accepting an invitation
152 Possible errors: NO_NAME_SET
154 1.4. In-game commands
156 1.4.1. Get the game contents
164 <game-board> is a quoted multi-line string containing an
165 diagram of the tic-tac-toe board, which is a 3x3 array of
172 c = '_' for empty or 'X' or 'O' for a played space
181 Possible errors: NOT_IN_GAME, NO_NAME_SET
191 Departs the current game
193 Possible errors: NOT_IN_GAME, NO_NAME_SET
203 <number> indicates a number in the tic-tac-toe grid as
210 Possible errors: NOT_IN_GAME, NOT_YOUR_MOVE, NOT_GRID, NO_NAME_SET
212 2. Asynchronous notification.
214 The server will send notices to each user in a game whenever
215 there is a move. It will also send notices to every connected
216 client when additional people join or new games are
217 started. These are of the form:
219 NOTICE <notice-code> <args>
221 Game-specific notices are sent to users involved in the related
222 game, other notices are sent to all users. Note that even the user
223 originating the notice receives a copy.
227 These notices are sent to all connected clients
231 NOTICE USER <username>
233 2.1.2. Disconnected user
235 NOTICE QUIT <username>
237 2.1.3. Game invitation
239 NOTICE INVITE <username>
241 2.1.4. Terminated games
243 NOTICE DISPOSE <game>
247 NOTICE MESSAGE <username> <text>
249 where <text> is a quoted-string. Quotes escaped with '\"'
253 These notices are sent to all players and watchers in
256 2.2.1. Global game notices
258 2.2.1.1. New game begins
260 NOTICE NEWGAME <username> <username>
262 The first username listed will go first
264 2.2.1.2. Game over, and winner
266 NOTICE GAMEOVER <outcome> <username>
268 <outcome> is either WON in which case <username> indicates
269 the winner or CATSGAME in which case <username> is "".
275 NOTICE MOVE <username> <number>
279 The following error codes may be returned.
281 3.1. Connection setup errors
283 These errors occur during connection setup.
289 'helo' must be sent before any command other than 'help',
292 Possibly returned by: WHO MESSAGE INVITE ACCEPT SHOW PART MOVE
298 All names must be of non-zero length and must be unique.
300 Possibly returned by: HELO
302 3.2. Command format errors
304 Errors caused by ill-formed commands
310 An invalid command was specified
316 A syntax error was detected
322 A non-numeric value was supplied where a number was required
324 3.2.4. Not a grid number
328 The number specified in the command was not a valid grid number
330 3.3. Global command errors.
332 There are no errors from any of the global commands
334 3.4. Game management errors.
336 Errors from game management commands
342 A game name was provided that does not exist.
344 3.5. User information errors
350 A user name was provided that does not exist.
354 3.6.1. Global game errors
360 A game playing command was made, but the user is not a
361 particpant of any game.
363 Possibly returned by: MOVE
369 A command was executed by a watching user that is
370 permitted only to players
374 3.6.2.1. Not your turn
378 A move was submitted during the other player's turn
380 Possibly returned by: MOVE