From: Bob Showalter Date: 2005-10-18T00:44:28+09:00 Subject: Re: [QUIZ] Lost Cities (#51) 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. OK, one more minor glitch with the harness. The random number seeding doesn't work correctly. I get the exact same deck with every game. > seeds = Array.new(count) { rand } > > play_proc = lambda do |players| > p "Playing #{players.inspect}" > players.map! { |x| x.new } > seeds.each do |seed| > srand(seed) seeds is intialized with a list of nubers 0 <= n < 1. These are then later passed to Kernel.srand. However, srand's argument is converted using to_i, so all these calls are equivalent to srand(0). My fix is: seeds = Array.new(count) { rand(1 << (8 * 1.size))} I'm trying to generate random seeds over the range of a Fixnum. Is there a more appropriate way to do that?