class GameOfLifeGto::Board

Attributes

array[RW]
height[RW]
width[RW]

Public Class Methods

new(width, height) click to toggle source
# File lib/game_of_life_gto.rb, line 7
def initialize(width, height)
  @width = width
  @height = height
  @array = Array.new(@width) do
    Array.new(@height) { Cell.new(rand(0..1)) }
  end
end

Public Instance Methods

display() click to toggle source
# File lib/game_of_life_gto.rb, line 21
def display
  @array.each do |row|
    row.each { |cell| print cell.id }
    print "\n"
  end
end
reset() click to toggle source
# File lib/game_of_life_gto.rb, line 15
def reset
  @array.each do |row|
    row.each { |cell| cell.id = 0 }
  end
end