File: protocol

package info (click to toggle)
ricochet 0.10
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 520 kB
  • sloc: makefile: 147; sh: 12
file content (734 lines) | stat: -rw-r--r-- 13,847 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
		 Ricochet Robots Game Protocol (RRGP)
			   Version 0.1.2
			     2003-5-31
		
		  Keith Packard         Carl Worth
		keithp@keithp.com   carl@theworths.org

Introduction

RRGP is a network protocol for playing the Ricochet Robots game.  It permits
a single server to host multiple games with named participants.  The
protocol is designed so that people can play using only telnet, but it is
expected that graphical interfaces will be able to drive the protocol as
well.

RRGP borrows ideas from other network protocols like SMTP using a
synchronous command interface.

Document Conventions

	All commands include a response (yeah, synchronous protocols are
	bad.  tough)

	<command> <args> 

	->

	<response>

	<response> is one of:

	<command> <args>
	ERROR <message>

1. Requests

1.1 Connection setup

    The RRGP server has no well defined port; agreement on which port to
    use must be done through some external mechanism.  Once connected,
    the client must identify itself:
    
    HELO [<username>]
    
    ->
    
    HELO <servername> <username> <server-addr> <server-port>

    If the client doesn't supply <username>, the server will compute
    one and return it.

    Possible errors: INVALIDNAME

1.2. Global commands

    1.2.1 Listing available users

	WHO

	->

	WHO <username1> <games1> <username2> <games2> ...

	lists connected users and the number of games they've won.

    1.2.2. Listing available games

	GAMES

	->

	GAMES <game1> <game2> ...

    1.2.3. Message

	MESSAGE <text>

	->
	
	MESSAGE

    1.2.4. Help

	HELP { <command> }

	Displays help.  If <command> is provided, displays more
	detailed help on a specific command, otherwise displays an
	overview of all commands.

    1.2.5. Quit

	QUIT

	->

	QUIT

    1.2.6. Version

	VERSION <client-version-number>

	->

	VERSION <server-version-number>

	Negotiates version number between client and server.  The server
	will respond with a version no higher than the client version
	number, but it may be lower.  Version numbers are integers.

	This document describes protocol version 1.

1.3. Game management commands

    1.3.1. Listing players in a game

	PLAYERS <game>

	->

	PLAYERS <username1> <score1> <username2> <score2> ...

	Possible errors: NOGAME

    1.3.2. Listing watchers of a game

	WATCHERS <game>

	->

	WATCERS <username1> <username2> ...

	Possible errors: NOGAME

    1.3.3. Get game information

	GAMEINFO <game>

	->

	GAMEINFO <turn> <color> <shape> <state> <time> <bid> <active>

	<turn> is a number from 1 to 17 indicating the current turn
	<color> <shape> indicate the active piece
	<state> is one of:
		new	Turn just started, no bids yet
		bid	Bidding opened.  <time> indicates time remaining,
			<bid> indicates the minimum bid
		show	Bidding closed and solution being demonstrated
			<active> indicates the person demonstrating
		done 	Current turn is over.  Either a solution
                        was demonstrated or the players have all
			given up trying to find a solution.
	<time> is valid only in BID state, else it's 0
	<bid> is valid in all but NEW state where it's 0
	<active> is valid in SHOW state, else it's ""

	Possible errors: NOGAME

    1.3.4. Creating a new game

	NEW <game-suggestion>

	->

	NEW <game>

    1.3.5. Joining an existing game

	JOIN <game>

	->

	JOIN

	Possible errors: NOGAME

    1.3.6. Watching an existing game

	WATCH <game>

	->

	WATCH

	The client will monitor the game, but not be listed in the
	userlist nor be allowed to make moves.

	Possible errors: NOGAME

    1.3.7. Dispose an empty game

	DISPOSE <game>

	->

	DISPOSE

	Disposes <game> unless it still has players associated.

	Possible errors: NOGAME NOTEMPTY

1.4. User information commands

    1.4.1. Get user information
    
	USERINFO <username>
    
	->
    
	USERINFO <game> <playing> <games> <score> <bid>
    
	<game> is any currently associated game, else "".  If the user
	is not associated with any game, the remaining fields are
	false 0 0.
	
	<playing> is true if the user is playing and false if watching.
    
	<games> is the number of games won by this user

	<score> is a number from 0 to 17 indicating this players score
    
	<bid> is either "0" indicating no bid or a number indicating
	the users minimum bid.
	    
1.5. In-game commands

    1.5.1. Global game commands

	1.5.1.1 Get the game contents
    
	    SHOW
    
	    ->
    
	    SHOW <game-board>
    
	    <game-board> is a quoted multi-line string containing an
	    diagram of the game contents, (an array of cells). A single
	    cell and its surrounding are indicated as:
    
	     HHH 
	    VrcsV
	     HHH
    
	    H = ' ' or '='
	    V = ' ' or '|'
	    r = '.' or <robot-color>  (one of 'r', 'g', 'b', or 'y')
	    c = '.' or <target-color> (one of 'r', 'g', 'b', or 'y')
	    s = '.' or <target-shape> (one of 'c', 's', 'o', or 't')
    
	    The goal robot and target (color and shape) are indicated with
	    capital letters.
    
	    For example:
    
	    SHOW "
	     ===         
	    |R.. ... .gs 
	                 
	     byc|... .RT|
	     ===     === "
    
	    R.. = 	Red robot (goal robot)
	    .gs = 	Green square target
	    byc = 	Blue robot on yellow circle target
	    .RT =	Red triangle (goal target)
    
	    Possible errors: NOTINGAME
    
	1.5.1.2. Next turn
    
	    TURN
    
	    ->
    
	    TURN
    
	    Advance the game to the next turn, (which will have a new
	    target square).  TURN is valid only when the game is in
	    the DONE state
		    
	    Possible errors: NOTINGAME, NOTDONE
    
	1.5.1.3. Part
    
	    PART
    
	    ->
    
	    PART
    
	    Departs the current game
    
    1.5.2. Bidding commands 

	1.5.2.1 Bid
    
	    BID <number>
    
	    ->
    
	    BID
    
	    Possible errors: NOTINGAME, NOTBIDDING, NOTNUMBER, NOTLOWER
    
	1.5.2.2. Revoke
    
	    REVOKE
    
	    ->
    
	    REVOKE
    
	    Possible errors: NOTINGAME, NOTBIDDING, NOBID
    
	1.5.2.3. Abandon
    
	    ABANDON
    
	    ->
    
	    ABANDON
    
	    Possible errors: NOTINGAME, NOTBIDDING
    
	    Mark this user as having abandoned this turn.  If all users
	    abandon, then the game state is switched to DONE.

	1.5.2.4. No more bids

	    NOBID

	    ->

	    NOBID

	    Possible errors: NOTINGAME, NOTBIDDING
    
	    Mark this user as done bidding.  If all users NOBID, then
	    the game state is switched to SHOW.
    
    1.5.3. Solving commands

	1.5.3.1. Move
    
	    MOVE <color> <dir1> <dir2> ...
    
	    ->
    
	    MOVE <count>
    
	    <color> is one of 'R', 'Y', 'G' or 'B', <dir> is one of 'N',
	    'E', 'S' or 'W'.
    
	    Possible errors: NOTINGAME, NOTACTIVE, BLOCKED, TOOMANYMOVES
    
	1.5.3.2. Undo
    
	    UNDO
    
	    ->
    
	    UNDO
    
	    Undoes the last move
    
	    Possible errors: NOTINGAME, NOTACTIVE
    
	    XXX: Do we add another error code for no further undo?
    
	1.5.3.3. Reset
    
	    RESET
    
	    ->
    
	    RESET
    
	    Resets robot positions to that at the start of the turn.
    
	    Possible errors: NOTINGAME, NOTACTIVE
    
	1.5.3.4. Pass the demonstration to the next lowest bidder
    
	    PASS
    
	    ->
    
	    PASS
    
	    Possible errors: NOTINGAME
	
2. Asynchronous notification.  

    The server will send notices to each user in a game whenever
    there is a move. It will also send notices to every connected
    client when additional people join or new games are
    started. These are of the form:

	NOTICE <notice-code> <args>

    Game-specific notices are sent to users involved in the related
    game, other notices are sent to all users.  Note that even the user
    originating the notice receives a copy.

2.1. Global notices

    These notices are sent to all connected clients

    2.1.1. New users
    
	NOTICE USER <username>
    
    2.1.2. Disconnected user
    
	NOTICE QUIT <username>
    
    2.1.3. New games
    
	NOTICE GAME <game>
    
    2.1.4. Terminated games
    
	NOTICE DISPOSE <game>
    
    2.1.5. Message

	NOTICE MESSAGE <username> <text>

    2.1.6. Join game (game)
	
	    NOTICE JOIN <username> <game>
	
    2.1.7. Watch game (game)
	
	    NOTICE WATCH <username> <game>
	
    2.1.8. User departed game (game)
	
	    NOTICE PART <username> <game>

2.2. Game notices

    These notices are sent to all players and watchers in
    the affected game

    2.2.1. Global game notices

	2.2.1.1. Board layout change

	    NOTICE BOARD <game-board>

	    The layout of the game board has changed. <game-board> is
	    formatted as in the reply to the SHOW request.
	
	2.2.1.2. Game state change
	
	    NOTICE GAMESTATE <state>

	    Game state has changed to <state>.  <state> is one
	    of "NEW", "BID", "SHOW" or "DONE".

	2.2.1.3. Next turn (game)

	    NOTICE TURN <color> <shape>

	    Note that the game state is implicitly changed to New

	2.2.1.4. Next game (game)

	    NOTICE GAMEOVER

    2.2.2. Bid notices

	Notices sent duing the bidding phase of a turn
    
	2.2.2.1. Bids (game)
	
	    NOTICE BID <username> <number>
	
	2.2.2.2. Revoke (game)
	
	    NOTICE REVOKE <username>

	    The specific user has revoked their bid. If there
	    are no other bids outstanding, the game state is
	    returned to New.
	
	2.2.2.3. Timer (game)
	
	    NOTICE TIMER <seconds>
    
	    Timer ticks are sent every 10 seconds after the first
	    bid has been made

	2.2.2.4. Abandon request

	    NOTICE ABANDON <username>
    
	    <username> has requested that the current turn be abandoned
	    before bidding has closed.  If all players make such
	    a request, the TURN command may be used to move to the next
	    turn.

	2.2.2.5. Nobid request

	    NOTICE NOBID <username>

	    <username> has announced that they plan on making no more bids
	    in the current turn.  If all players make such a request,
	    the game moves to the SHOW state.

   2.2.3. Solving notices

	Notices sent during the solving phase of a turn
	    	
	2.2.3.1. Select active player (game)

	    NOTICE ACTIVE <username> <bid>

	    Only the active player may move the robots

	2.2.3.2. Move notice (game)

	    NOTICE MOVE <count> <color> <dir>

	2.2.3.3. Undo (game)

	    NOTICE UNDO

	2.2.3.4. Reset (game)

	    NOTICE RESET

	2.2.3.5. Position (after move/undo/reset)

	    NOTICE POSITION <color> <x> <y>

	    The indicated robot has moved to the indicated position.
	    The board is 0-based with the origin in the upper left
	    corner.

	2.2.3.6. Score (game)

	    NOTICE SCORE <username> <score>

	    The indicated user has demonstrated a solution and
	    received a point.

2.3. User notices

     These notices are sent to a single user

     2.3.1. Solving notices

	Notices sent during the solving phase of a turn
	    	
	2.3.1.1. Notify active player (user)

	    NOTICE ACTIVATE <bid>

	    Sent to the player which has just become active
	    
3. Errors

    The following error codes may be returned.

3.1. Connection setup errors

    These errors occur during connection setup.

    3.1.1. No name set
    
	ERROR NONAMESET
    
	'helo' must be sent before any command other than 'quit'.
    
    3.1.2. Invalid name
    
	ERROR INVALIDNAME
    
	All names must be unique.

	Possibly returned by: HELO

3.2. Command format errors

    Errors caused by ill-formed commands
    
    3.2.1. Command
    
	ERROR COMMAND
    
	An invalid command was specified
    
    3.2.2. Syntax
    
	ERROR SYNTAX
    
	A syntax error was detected
    
    3.2.3. Not number
    
	ERROR NOTNUMBER
    
	A non-numeric value was supplied where a number was required
	
    3.2.4. Not color
    
	ERROR NOTCOLOR
    
	The color name specified in the command was invalid
    
    3.2.5. Not shape
    
	ERROR NOTSHAPE
    
	The shape name specified in the command was invalid
    
    3.2.6. Not direction
    
	ERROR NOTDIRECTION
    
	The direction name specified in the command was invalid

3.3. Global command errors.

    There are no errors from any of the global commands

3.4. Game management errors.

    Errors from game management commands
    
    3.3.1. No such game
	
	ERROR NOGAME
	
	A game name was provided that does not exist.
	
    3.3.2. Not empty
	
	ERROR NOTEMPTY
	
	DISPOSE was requested for a game with active players
	
3.5. User information errors

    3.5.1. No such user
    
	ERROR NOUSER

	A user name was provided that does not exist.

3.6. In-game errors

    3.6.1. Global game errors
    
	3.6.1.1. Not in game
    
	    ERROR NOTINGAME
    
	    A game playing command was made, but the user is not a
	    particpant of any game.
    
	    Possibly returned by: SHOW, MOVE, RESET, UNDO, TURN, PASS,
	    MESSAGE.

	3.6.1.2. Not playing

	    ERROR NOTPLAYING

	    A command was executed by a watching user that is
	    permitted only to players

	3.6.1.3. Not done
    
	    ERROR NOTDONE
    
	    TURN was requested and the game is not in DONE state.
    
    3.6.2. Bidding errors 
    
	3.6.2.1. Not bidding

	    ERROR NOTBIDDING
    
	    A bid was submitted after the bidding closed
    
	    Possibly returned by: BID
    
	3.6.2.2. Not lower

	    ERROR NOTLOWER
    
	    A bid was submitted that was higher than previous bid.
    
	    Possibly returned by: BID
    
	3.6.2.3. No bid

	    ERROR NOBID
    
	    A revoke was requested when no bid had been entered
    
	    Possibly returned by: REVOKE
	    
    3.6.3. Solving mode errors
    
	3.6.3.1. Not active

	    ERROR NOTACTIVE
	
	    A move, undo or reset was submitted by other than the
	    active user.
	    
	    Possibly returned by: MOVE, RESET, UNDO
	
	3.6.3.2. Blocked
	
	    ERROR BLOCKED
	
	    The robot cannot move the requested direction.
	
	    Possibly returned by: MOVE
	
	3.6.3.3. TOOMANYMOVES
	
	    ERROR TOOMANYMOVES
	
	    An attempt was made to make more moves than the users bid
	
	    Possibly returned by: MOVE