On Oct 17, 2005, at 10:15 AM, Bob Showalter wrote:

> I've found another glitch that affects the automation of players  
> with Daniel's harness.
>
> In James' dumb_player.rb, the following line captures the cards in  
> the players hand:
>
>  if @plays.nil? and @data =~ /Hand: (.+?)\s*$/
>
> The regex captures up to the end of the line containing "Hand:".  
> When you play this in the client-server mode, each line passed to  
> show() end with a newline (since :show is delegated to :puts), and  
> so the regex works.
>
> When you play this under Daniel's harness, the lines passed to show 
> () don't have newlines added, since each player directly calls the  
> opponent's show(). The last card is immediately followed by the  
> next line starting with "Score:", and so the regex captures  
> extraneous "cards" (and the eighth card is incorrectly parsed as  
> "8VScore:", for example).
>
> One way to resolve this is to change the dumb_player.rb line:
>
>   @data << game_data
>
> To:
>
>   @data << game_data.chomp << "\n"
>
> That way, you get the same data when you play through the client- 
> server mode or through the harness.
>
> I wonder how this would best be handled inside lost_cities.rb or  
> the harness itself?

Let's not go changing the protocol on people.  It's expected to be a  
line oriented network protocol, so each line should end in a "\n".

James Edward Gray II