-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rb
52 lines (43 loc) · 807 Bytes
/
main.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# frozen_string_literal: false
# '██' '░░'
require_relative './methods/cells'
# game of life
class Game < Cells
attr_accessor(:width, :height, :fig)
def initialize(width, height, fig)
super
@width = width
@height = height
@fig = fig
@matrix = start_matrix(@height, @width)
@flag = 0
end
def start_matrix(height, width)
matrix = Array.new(height) { Array.new(width) }
(0...width).each do |i|
(0...height).each do |j|
matrix[j][i] = ['░░', '░░']
end
end
matrix
end
def print_fig
@fig.each do |arr|
@matrix[arr[0]][arr[1]][@flag] = '██'
end
end
end
f = [
[5, 4],
[5, 3],
[3, 3],
[3, 4],
[4, 3],
[4, 5],
[3, 5],
[4, 5],
[5, 5]
]
a = Game.new(10, 10, f)
a.print_fig
a.display