simple_gol_console 1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/gol.rb +26 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4d556f7d8f2bd8ea6d1650e660cec2beb7bb8c1b819307cfe0a5f1fd7c5080cd
4
+ data.tar.gz: 2be5ad71dfe0fddda32c946f4035264bf4712836935f46c3f540e82d1b01242b
5
+ SHA512:
6
+ metadata.gz: 64c073a955aea2155b46cb703eb7d8541c894222ce8935a72d147e81474f5eeb0b871dde65b15c481677864ab928dfb02d9e5f28dd44243089e9251130d063f6
7
+ data.tar.gz: 73b6617bfead717001b7b6b0c0228ee16c68530de318e64e81f0b1de5fa0fef1547634a0da199fca14a4fbcd3fa8077dba37afaf578eb30837adbb9c052faea4
data/lib/gol.rb ADDED
@@ -0,0 +1,26 @@
1
+ # Project: Simple Game of Life automaton in ruby
2
+ # Author: Hugo V. Elías (c0d34fn@gmail.com)
3
+
4
+ require "./lib/grid.rb"
5
+
6
+ class Gol
7
+ GRID_SIZE = 16
8
+ SPEED_LIMIT = 1
9
+
10
+ def initialize(grid_size: GRID_SIZE, speed_limit: SPEED_LIMIT)
11
+ grid = Grid.new(size: grid_size, speed: speed_limit)
12
+
13
+ while(true)
14
+ draw(grid)
15
+ grid.iterate()
16
+ end
17
+ end
18
+
19
+ def draw(grid)
20
+ puts "Generation: #{grid.generation}, Speed: #{grid.speed} (lower is faster), Stop with CTRL+C\n"
21
+ grid.cells.each do |row|
22
+ graph = row.map {|item| item.alive == true ? "X" : " "}
23
+ p graph
24
+ end
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple_gol_console
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - Hugo Elias
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-08-21 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Simple Game of Life in Console
14
+ email: c0d34fn@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/gol.rb
20
+ homepage: https://github.com/hugovelias/gameoflife
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubygems_version: 3.2.22
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: Simple Game of Life in Console
43
+ test_files: []