initialize RNG only once

This commit is contained in:
Sami Samhuri 2011-12-23 21:52:27 -05:00
parent e9b0868974
commit 3bf39f90af
2 changed files with 3 additions and 2 deletions

View file

@ -36,6 +36,8 @@ class Roulette
@sets[:z].insert(2, 5) @sets[:z].insert(2, 5)
end end
@rng = @options[:seed] ? Random.new(@options[:seed]) : Random.new
# generated numbers are from 0 to max # generated numbers are from 0 to max
@max = @options[:american] ? 38 : 37 @max = @options[:american] ? 38 : 37
@ -63,7 +65,6 @@ class Roulette
@results = [] @results = []
@counts = Hash.new { 0 } @counts = Hash.new { 0 }
@rng = @options[:seed] ? Random.new(@options[:seed]) : Random.new
@options[:spins].times do @options[:spins].times do
result = spin result = spin

View file

@ -23,7 +23,7 @@ def main
roulette = Roulette.new(options.dup) roulette = Roulette.new(options.dup)
# puts ">>> Seed: #{roulette.seed}" puts ">>> Seed: #{roulette.seed}"
overall_status = { overall_status = {
:net => 0, :net => 0,