Guest User

Untitled

a guest
Dec 11th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. class Game < GameOfLife
  2. def initialize
  3. make_grid_with 100, 100, %Q{rand(2)}
  4. rules :classic
  5. end
  6. end
  7. game = Game.new
  8. game.grid.shuffle
  9. time_values = []
  10. 100.times do
  11. t_init = Time.now
  12. game.evolve
  13. time_values << (Time.now - t_init)
  14. end
  15. p "Average: #{(time_values.inject { |x, y| x + y } / time_values.length)}"
  16. p "Sum: #{(time_values.inject { |x, y| x + y })}"
  17.  
  18.  
  19.  
  20. #=> "Average: 0.2968543879299998"
  21. #=> "Sum: 29.68543879299998"
Add Comment
Please, Sign In to add comment