Hans Fugal wrote:
> Brian Schr?der wrote:
> 
>> On Sun, 12 Dec 2004 04:12:28 +0900
>> Hans Fugal <fugalh / xmission.com> wrote:
>>
>>
>>> It would be good to be able to play against eachother when this is 
>>> all over, so I propose the following 'protocol'. It's not complicated 
>>> and probably not ready for tournament tic-tac-toe ;-), but it should 
>>> do nicely.
>>>
>>> 3 entities - a game server and two players. The game waits for 
>>> players to connect. Upon connection the game sends an arbitrary hello 
>>> line, then the character representing this player, and the board size:
>>
>>
>>
>> This is a good idea. Let me propose one enhancement to the protocol. 
>> If we
>> would submit the active player each time together with the board it 
>> would make
>> the client actions simpler. (Though now I've got the Idea that the active
>> player is always Player |non-nil-positions| mod 2...
> 
> 
> Well, the idea is that if it's your turn to move you will receive 
> "move". If it's not, you won't. But if you prefer 'move X' to be sent to 
> both players when it's X's turn, we can apply this patch:

This will teach me to test a patch first!

diff -rN -u rubyquiz-old/tictactoe/server.rb
rubyquiz-new/tictactoe/server.rb
--- rubyquiz-old/tictactoe/server.rb    2004-12-11 17:02:52.000000000 -0700
+++ rubyquiz-new/tictactoe/server.rb    2004-12-11 17:10:51.000000000 -0700
@@ -100,7 +100,7 @@
         [@x,@o].each {|p| p.puts state}
         move = nil
         until move
-         cur.puts "move"
+         [@x,@o].each {|p| p.puts "move #{cur == @x ? 'X' : 'O'}"}
           move = cur.gets
           move = nil unless make_move(cur,move)
         end