From: James Edward Gray II Date: 2005-10-18T04:04:58+09:00 Subject: Re: [QUIZ] Lost Cities (#51) On Oct 17, 2005, at 9:24 AM, Bob Showalter wrote: > Daniel Sheppard wrote: > >> Just had 10 minutes to look at this, and created a quick test >> harness to >> compare players before I go poking around trying to figure out >> what kind >> of logic to use. >> > > Daniel, this is awesome! I'm learning a ton just studying your code > and James'. > > There's a small bug in James' lost_cities.rb that affects your > program. Game.new does not clear the player's hand (it does clear > everything else). So if a player object is reused to play a second > game, he ends up with 16 cards in his hand, and the game is messed up. > > As a quick fix, I just added: > > players.map { |x| x.hand.clear } > > before the call to Game.new() in your code. Yes, Game.new() expects to be given fresh players. Good catch. James Edward Gray II