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.
90 VERSION <client-version-number>
94 VERSION <server-version-number>
96 Negotiates version number between client and server. The server
97 will respond with a version no higher than the client version
98 number, but it may be lower. Version numbers are integers.
100 This document describes protocol version 1.
102 1.3. Game management commands
104 1.3.1. Inviting a player to play a game
112 Possible errors: NOUSER, BUSY
114 1.3.2. Accepting an invitation
122 1.4. In-game commands
124 1.4.1. Get the game contents
132 <game-board> is a quoted multi-line string containing an
133 diagram of the tic-tac-toe board, which is a 3x3 array of
140 c = '_' for empty or 'X' or 'O' for a played space
149 Possible errors: NOTINGAME
159 Departs the current game
161 Possible errors: NOTINGAME
171 <number> indicates a number in the tic-tac-toe grid as
178 Possible errors: NOTINGAME, NOTYOURMOVE, NOTGRID
180 2. Asynchronous notification.
182 The server will send notices to each user in a game whenever
183 there is a move. It will also send notices to every connected
184 client when additional people join or new games are
185 started. These are of the form:
187 NOTICE <notice-code> <args>
189 Game-specific notices are sent to users involved in the related
190 game, other notices are sent to all users. Note that even the user
191 originating the notice receives a copy.
195 These notices are sent to all connected clients
199 NOTICE USER <username>
201 2.1.2. Disconnected user
203 NOTICE QUIT <username>
205 2.1.3. Game invitation
207 NOTICE INVITE <username>
209 2.1.4. Terminated games
211 NOTICE DISPOSE <game>
215 NOTICE MESSAGE <username> <text>
219 These notices are sent to all players and watchers in
222 2.2.1. Global game notices
224 2.2.1.1. New game begins
226 NOTICE NEWGAME <username> <username>
228 The first username listed will go first
230 2.2.1.2. Game over, and winner
232 NOTICE GAMEOVER <outcome> <username>
234 <outcame> is either WON in which case <username> indicates
235 the winner or CATSGAME in which case <username> is "".
241 NOTICE MOVE <username> <number>
245 The following error codes may be returned.
247 3.1. Connection setup errors
249 These errors occur during connection setup.
255 'helo' must be sent before any command other than 'quit'.
261 All names must be of non-zero length and must be unique.
263 Possibly returned by: HELO
265 3.2. Command format errors
267 Errors caused by ill-formed commands
273 An invalid command was specified
279 A syntax error was detected
285 A non-numeric value was supplied where a number was required
287 3.2.4. Not a grid number
291 The number specified in the command was not a valid grid number
293 3.3. Global command errors.
295 There are no errors from any of the global commands
297 3.4. Game management errors.
299 Errors from game management commands
305 A game name was provided that does not exist.
307 3.5. User information errors
313 A user name was provided that does not exist.
317 3.6.1. Global game errors
323 A game playing command was made, but the user is not a
324 particpant of any game.
326 Possibly returned by: MOVE
332 A command was executed by a watching user that is
333 permitted only to players
337 3.6.2.1. Not your turn
341 A move was submitted during the other player's turn
343 Possibly returned by: MOVE