Sha256: b61a8f120e44701b53f7b9da8de2a4538b8dc5cf6173322db6159e69ef724dc1

Contents?: true

Size: 543 Bytes

Versions: 2

Compression:

Stored size: 543 Bytes

Contents

module GameOfLife
  # Cli will log the output
  class Cli
    def self.start(width, height, seed_probability, speed)
      if width.is_a?(Numeric) && height.is_a?(Numeric)
        puts '1 = alive', '0 = dead'
        game = GameOfLife::Earth.new(width, height, seed_probability)
        puts game.log
        while game.cells.flatten.map(&:bool_to_num).include? 1
          sleep speed || 1
          game.next!
          puts game.log
        end
      else
        puts 'please provide valid integers next time!'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
conways_game_of_life-1.0.3 lib/game_of_life/cli.rb
conways_game_of_life-1.0.2 lib/game_of_life/cli.rb