-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rb
64 lines (50 loc) · 1.04 KB
/
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
53
54
55
56
57
58
59
60
61
62
#puts "X X X"
#puts "O O O"
#uts "O X O"
#always_alive
#array = [
# [0,0,1],
# [1,0,1],
# [0,1,1]
#]
array = [
[0,0,1],
[1,1,1],
[0,1,1]
]
array = [
[1,1,1],
[1,1,0],
[0,0,0]
]
# only five generations
population = [
[1,0,0],
[1,1,0],
[1,1,0]
]
require_relative './game.rb'
#GC.disable
clear_output()
population = Universe::Creator.call
saver = Universe::Saver.new
printer = Universe::Printer.new
printer.configure do
puts (`ps -o rss= -p #{Process.pid}`.to_i / 1024).to_s << ' mb'
puts saver.generations_cnt.to_s << " generations"
end
g = Game.new(population: population, printer: printer, saver: saver)
g.loop
puts "generations cnt #{saver.generations_cnt}"
saver.store
cli_interface do |command|
if command == 'new'
printer = Universe::Printer.new
printer.configure do
puts (`ps -o rss= -p #{Process.pid}`.to_i / 1024).to_s << ' mb'
puts saver.generations_cnt.to_s << " generations"
end
g = Game.new(population: Universe::Creator.call, printer: printer, saver: saver)
g.loop
end
end