Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Game < GameOfLife
- def initialize
- make_grid_with 100, 100, %Q{rand(2)}
- rules :classic
- end
- end
- game = Game.new
- game.grid.shuffle
- time_values = []
- 100.times do
- t_init = Time.now
- game.evolve
- time_values << (Time.now - t_init)
- end
- p "Average: #{(time_values.inject { |x, y| x + y } / time_values.length)}"
- p "Sum: #{(time_values.inject { |x, y| x + y })}"
- #=> "Average: 0.2968543879299998"
- #=> "Sum: 29.68543879299998"
Add Comment
Please, Sign In to add comment