rsb-gol 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a6d3875f41a07f9d7dd562777398579a7703041
4
- data.tar.gz: 5b291f721c0b488572401f26fe387aeefa229226
3
+ metadata.gz: a3da5ccda1bc86c201ea34f365e97e54f96e3852
4
+ data.tar.gz: 227feae90ef9c9cab4c6cd437d2022892947229f
5
5
  SHA512:
6
- metadata.gz: 0826e79ad984c0bf88726454f09f6f1bbe63fe919ec9134ffb79d28c3d4cc904fed927a7227025e9c2d2a24a98725b8f2afbf6b04395fc535e99293e77ceecdf
7
- data.tar.gz: bb99b7fc717274a83aa02aec10ff4a126bf299f031bebfc6a12934c5f1cad4de3cdb03a7ebdc3cf964342a8cc73ba73a13a9128a40360fdac40c4f48a3d59933
6
+ metadata.gz: 426fda512a0efc72141d96d9039467891068522db30ac8b0ef840a143529cf7a0c581c91ddef9c10251516958db6f0f3d3aca79276cbda7d345e81a4b93f18e4
7
+ data.tar.gz: 0d2b80588b01f2ff3d77f851454557bf6e664ece729d998caff8cdeed2d5c409b972efe303ea2806a15c6ff3ad43919dee064b9ae1fa5eb7a0b064fd708c121f
@@ -3,15 +3,21 @@ module Rsb
3
3
  class Game
4
4
  CLEAR_SCREEN_CHAR = "\e[H\e[2J"
5
5
 
6
- attr_reader :universe
6
+ attr_reader :universe, :stop_running
7
7
  attr_accessor :seed
8
8
 
9
9
  def initialize(options = {})
10
- random_seed = options[:random_seed] == false ? false : true
11
- rows = options[:rows] || 40
12
- cols = options[:cols] || 40
13
- grid = Rsb::Gol::Grid.new(rows, cols, random_seed)
14
- @universe = options[:universe] || Rsb::Gol::Universe.new(grid: grid)
10
+ random_seed = options[:random_seed] == false ? false : true
11
+ rows = options[:rows] || 40
12
+ cols = options[:cols] || 80
13
+ grid = Rsb::Gol::Grid.new(rows, cols, random_seed)
14
+ @universe = options[:universe] || Rsb::Gol::Universe.new(grid: grid)
15
+ @stop_running = false
16
+
17
+ trap('INT') do
18
+ puts "\ngame of life will now stop running\n"
19
+ @stop_running = true
20
+ end
15
21
  end
16
22
 
17
23
  def clear_screen
@@ -26,6 +32,7 @@ module Rsb
26
32
  def start(iterations = 1000, alive='0', dead=' ', step=3)
27
33
  clear_screen
28
34
  iterations.times do
35
+ exit if stop_running
29
36
  data = universe.tick!
30
37
  abort('empty universe') if data[:empty_universe]
31
38
  status = status_line(data)
@@ -1,5 +1,5 @@
1
1
  module Rsb
2
2
  module Gol
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsb-gol
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Scott-Buccleuch