conway_deathmatch 0.5.0.3 → 0.6.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95413f3557aa8dcb568065213eb0e296c951aac2
4
- data.tar.gz: 7640ea076629eaab5134bed4f11288155916de58
3
+ metadata.gz: e231c26991bcf255abd1bf05004d79183d025dc8
4
+ data.tar.gz: 5d96b4380756b46bd477e4e0baadeae27a9a36d3
5
5
  SHA512:
6
- metadata.gz: 0ce56f027fdcf40ed302a65a928c22b9b7e3677c3c755505941a3546d1391bfb5af6810f9e092e19845d55d3d3cfd533954930e815d9f8d676305fc09b714e10
7
- data.tar.gz: abdedab43e2091b6a3f150e909685a90acaafe59022d73a6ce9003eb9d5b31a88fc2be44209238dd4a9339175c4043539ad85369a77106cc77bc489fa85ec33d
6
+ metadata.gz: e11495b48f8611b99287e3a77c14d2fe4fdd966c97833d1af41983694642e81729ac3740b9fcf3be1c3b60742f3f922b2562fed8276cef7ef9be367dc24edb84
7
+ data.tar.gz: f4fb473dc800d24f7f82bd03af235007dd2f00db3c122e861277b8065f053cafa8852177e0167e0bc4597b582c804a92f8b2ccaffe3e39afab08c38c43bdf634
data/Rakefile CHANGED
@@ -1,14 +1,3 @@
1
- require 'buildar'
2
-
3
- Buildar.new do |b|
4
- b.gemspec_file = 'conway_deathmatch.gemspec'
5
- b.version_file = 'VERSION'
6
- b.use_git = true
7
- end
8
-
9
- task default: %w[test bench]
10
- task travis: %w[test bench ruby-prof]
11
-
12
1
  require 'rake/testtask'
13
2
  desc "Run tests"
14
3
  Rake::TestTask.new do |t|
@@ -24,45 +13,100 @@ Rake::TestTask.new do |t|
24
13
  # t.warning = true
25
14
  end
26
15
 
27
- desc "Generate code metrics reports"
28
- task :code_metrics => [:flog, :flay, :roodi] do
29
- end
16
+ task default: %w[test bench]
17
+
18
+
19
+ #
20
+ # METRICS
21
+ #
30
22
 
31
- desc "Run flog on lib/"
32
- task :flog do
33
- puts
34
- sh "flog lib | tee metrics/flog"
23
+ metrics_tasks = []
24
+
25
+ begin
26
+ require 'flog_task'
27
+ FlogTask.new do |t|
28
+ t.threshold = 200
29
+ t.dirs = ['lib']
30
+ t.verbose = true
31
+ end
32
+ metrics_tasks << :flog
33
+ rescue LoadError
34
+ warn 'flog_task unavailable'
35
35
  end
36
36
 
37
- desc "Run flay on lib/"
38
- task :flay do
39
- puts
40
- sh "flay lib | tee metrics/flay"
37
+ begin
38
+ require 'flay_task'
39
+ FlayTask.new do |t|
40
+ t.verbose = true
41
+ t.dirs = ['lib']
42
+ end
43
+ metrics_tasks << :flay
44
+ rescue LoadError
45
+ warn 'flay_task unavailable'
41
46
  end
42
47
 
43
- desc "Run roodi on lib/"
44
- task :roodi do
45
- puts
46
- sh "roodi -config=.roodi.yml lib | tee metrics/roodi"
48
+ begin
49
+ require 'roodi_task'
50
+ RoodiTask.new config: '.roodi.yml', patterns: ['lib/**/*.rb']
51
+ metrics_tasks << :roodi
52
+ rescue LoadError
53
+ warn "roodi_task unavailable"
47
54
  end
48
55
 
56
+ desc "Generate code metrics reports"
57
+ task code_metrics: metrics_tasks
58
+
59
+
60
+ #
61
+ # PROFILING TASKS
62
+ #
63
+
49
64
  desc "Show current system load"
50
65
  task "loadavg" do
51
66
  puts File.read "/proc/loadavg"
52
67
  end
53
68
 
54
- # this runs against the installed gem lib, not git / filesystem
69
+ rubylib = "RUBYLIB=lib"
70
+ rubyprof = "ruby-prof -m1"
71
+ scriptname = "bin/conway_deathmatch"
72
+ scriptargs = "-n 100 -s 0 --renderfinal"
73
+
55
74
  desc "Run ruby-prof on bin/conway_deathmatch (100 ticks)"
56
75
  task "ruby-prof" => "loadavg" do
57
- sh ["ruby-prof -m1 bin/conway_deathmatch",
58
- "-- -n100 -s0 --renderfinal",
59
- "| tee metrics/ruby-prof"].join(' ')
76
+ sh [rubylib, rubyprof, scriptname, '--', scriptargs].join(' ')
60
77
  end
61
78
 
62
- # this runs against the installed gem lib, not git / filesystem
63
79
  desc "Run ruby-prof with --exclude-common-cycles"
64
80
  task "ruby-prof-exclude" => "ruby-prof" do
65
- sh ["ruby-prof -m1 --exclude-common-cycles bin/conway_deathmatch",
66
- "-- -n100 -s0 --renderfinal",
67
- "| tee metrics/ruby-prof-exclude"].join(' ')
81
+ sh [rubylib,
82
+ rubyprof, '--exclude-common-cycles', scriptname, '--',
83
+ scriptargs].join(' ')
84
+ end
85
+
86
+ task "no-prof" do
87
+ sh [rubylib, scriptname, scriptargs].join(' ')
88
+ end
89
+
90
+ #
91
+ # GEM BUILD / PUBLISH TASKS
92
+ #
93
+
94
+ begin
95
+ require 'buildar'
96
+
97
+ Buildar.new do |b|
98
+ b.gemspec_file = 'conway_deathmatch.gemspec'
99
+ b.version_file = 'VERSION'
100
+ b.use_git = true
101
+ end
102
+ rescue LoadError
103
+ # ok
68
104
  end
105
+
106
+
107
+ #
108
+ # TRAVIS CI
109
+ #
110
+
111
+ desc "Rake tasks for travis to run"
112
+ task travis: %w[test bench no-prof]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0.3
1
+ 0.6.0.1
@@ -1,31 +1,35 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- gem 'slop', '~> 3'
4
3
  require 'slop'
5
4
  require 'conway_deathmatch'
6
5
  require 'conway_deathmatch/shapes'
7
6
 
8
7
  # process cmdline options
9
8
  #
10
- opts = Slop.parse(help: true,
11
- banner: true,
12
- strict: true,
13
- optional_arguments: true) do
14
- banner 'Usage: conway_deathmatch [options]'
9
+ opts = Slop.parse do |o|
10
+ o.banner = "Usage: conway_deathmatch [options]"
11
+ o.int '-x', '--width', 'Grid width'
12
+ o.int '-y', '--height', 'Grid height'
13
+ o.int '-n', '--ticks', 'Max number of ticks to generate'
14
+ o.float '-s', '--sleep', 'Sleep duration'
15
+ o.string '-p', '--points', 'e.g. acorn 50 18 p 1 2 p 3 4'
16
+ o.bool '-g', '--step', 'Pause each tick for user input'
17
+ o.bool '-r', '--renderfinal', 'Only render the final state'
18
+ o.string '-d', '--deathmatch', 'single|aggressive|defensive|friendly'
19
+ o.string '--one', 'points for population "1"'
20
+ o.string '--two', 'points for population "2"'
21
+ o.string '--three', 'points for population "3"'
15
22
 
16
- on 'x', 'width=', '[int] Grid width', as: Integer
17
- on 'y', 'height=', '[int] Grid height', as: Integer
18
- # on 'D', 'dimensions=', '[str] width x height', as: String
19
- on 'n', 'ticks=', '[int] Max number of ticks to generate', as: Integer
20
- on 's', 'sleep=', '[flt] Sleep duration', as: Float
21
- on 'p', 'points=', '[str] e.g. "acorn 50 18 p 1 2 p 3 4"', as: String
22
- on 'g', 'step', 'Hold ticks for user input'
23
- on 'r', 'renderfinal', 'Only render the final state'
24
- on 'd', 'deathmatch',
25
- '[str] single|aggressive|defensive|friendly', as: String
26
- on 'one=', '[str] points for population "1"', as: String
27
- on 'two=', '[str] points for population "2"', as: String
28
- on 'three=', '[str] points for population "3"', as: String
23
+ o.on '-h', '--help' do
24
+ puts o
25
+ exit
26
+ end
27
+ end
28
+
29
+ def opts.error(msg = nil)
30
+ puts self
31
+ puts "ERROR: #{msg}" if msg
32
+ exit 1
29
33
  end
30
34
 
31
35
  width = opts[:width] || 70
@@ -40,7 +44,7 @@ deathmatch = case opts[:deathmatch].to_s.downcase
40
44
  when 'd', 'defensive' then :defensive
41
45
  when 'f', 'friendly' then :friendly
42
46
  else
43
- raise "unknown: #{opts[:deathmatch]}"
47
+ opts.error("unknown deathmatch option: #{opts[:deathmatch]}")
44
48
  end
45
49
 
46
50
  # create game
@@ -71,7 +75,7 @@ while n.nil? or count <= n
71
75
  b.tick
72
76
 
73
77
  if opts.step?
74
- gets
78
+ $stdin.gets
75
79
  else
76
80
  sleep slp if slp > 0.0
77
81
  end
@@ -1,24 +1,23 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'set'
4
- gem 'slop', '~> 3'
5
4
  require 'slop'
6
5
  require 'conway_deathmatch'
7
6
  require 'conway_deathmatch/shapes'
8
7
 
9
8
  # process cmdline options
10
9
  #
11
- opts = Slop.parse(help: true,
12
- banner: true,
13
- strict: true,
14
- optional_arguments: true) do
15
- banner 'Usage: proving_ground [options]'
16
-
17
- on 'w', 'width=', '[int] Grid width', as: Integer
18
- on 'height=', '[int] Grid height', as: Integer
19
- on 'n', 'num_ticks=', '[int] Max number of ticks to generate', as: Integer
20
- on 'p', 'num_points=', '[int] Number of points to generate', as: Integer
21
- on 'm', 'max_collisions=', '[int] Max number of collisions', as: Integer
10
+ opts = Slop.parse do |o|
11
+ o.banner = "Usage: proving_ground [options]"
12
+ o.int '-w', '--width', 'Grid width'
13
+ o.int '--height', 'Grid height'
14
+ o.int '-n', '--num_ticks', 'Max number of ticks to generate'
15
+ o.int '-p', '--num_points', 'Number of points to generate'
16
+ o.int '-m', '--max_collisions', 'Max number of generation collisions'
17
+ o.on '-h', '--help' do
18
+ puts o
19
+ exit
20
+ end
22
21
  end
23
22
 
24
23
  num_points = opts[:num_points] || 5
@@ -71,7 +70,7 @@ def conclude!(results, w, h)
71
70
  exit 0
72
71
  end
73
72
 
74
- results = { final: [0], peak: [0], score: [0], }
73
+ results = { final: [0, []], peak: [0, []], score: [0, []], }
75
74
  seen = Set.new
76
75
  collisions = 0
77
76
 
@@ -23,13 +23,13 @@ Gem::Specification.new do |s|
23
23
  'test/test_shapes.rb',
24
24
  ]
25
25
  s.executables = ['conway_deathmatch']
26
- s.add_runtime_dependency "slop", "~> 3.0"
27
- s.add_development_dependency "buildar", "~> 2"
26
+ s.add_runtime_dependency "slop", "~> 4.0"
27
+ s.add_development_dependency "buildar", "~> 3"
28
28
  s.add_development_dependency "minitest", "~> 5"
29
29
  s.add_development_dependency "ruby-prof", "~> 0"
30
30
  s.add_development_dependency "flog", "~> 4.0"
31
31
  s.add_development_dependency "flay", "~> 2.0"
32
- s.add_development_dependency "roodi", "~> 4.0"
32
+ s.add_development_dependency "roodi", ">= 4", "< 6"
33
33
 
34
34
  # uncomment and set ENV['CODE_COVERAGE']
35
35
  # s.add_development_dependency "simplecov", "~> 0.9.0"
@@ -3,8 +3,8 @@ require 'minitest/benchmark'
3
3
  require 'conway_deathmatch'
4
4
  require 'conway_deathmatch/shapes'
5
5
 
6
- BENCH_NEW_THRESH = (ENV['BENCH_NEW_THRESH'] || 0.9).to_f
7
- BENCH_TICK_THRESH = (ENV['BENCH_TICK_THRESH'] || 0.9995).to_f
6
+ bnew = (ENV['BENCH_NEW_THRESH'] || 0.9).to_f
7
+ btick = (ENV['BENCH_TICK_THRESH'] || 0.9995).to_f
8
8
  Shapes = ConwayDeathmatch::Shapes
9
9
 
10
10
  describe "ConwayDeathmatch.new Benchmark" do
@@ -12,7 +12,7 @@ describe "ConwayDeathmatch.new Benchmark" do
12
12
  bench_exp 9, 9999, 3
13
13
  end
14
14
 
15
- bench_performance_linear "width*height", BENCH_NEW_THRESH do |n|
15
+ bench_performance_linear "width*height", bnew do |n|
16
16
  ConwayDeathmatch.new(n, n)
17
17
  end
18
18
  end
@@ -22,14 +22,13 @@ describe "ConwayDeathmatch#tick Benchmark" do
22
22
  bench_exp 1, 100, 3
23
23
  end
24
24
 
25
- bench_performance_linear "acorn demo", BENCH_TICK_THRESH do |n|
25
+ bench_performance_linear "acorn demo", btick do |n|
26
26
  b = ConwayDeathmatch.new(70, 40)
27
27
  Shapes.add(b, "acorn 50 18")
28
28
  n.times { b.tick }
29
29
  end
30
30
 
31
- bench_performance_linear "aggressive deathmatch demo",
32
- BENCH_TICK_THRESH do |n|
31
+ bench_performance_linear "aggressive deathmatch demo", btick do |n|
33
32
  b = ConwayDeathmatch.new(70, 40)
34
33
  b.deathmatch = :aggressive
35
34
  Shapes.add(b, "acorn 30 30", "1")
@@ -37,8 +36,7 @@ describe "ConwayDeathmatch#tick Benchmark" do
37
36
  n.times { b.tick }
38
37
  end
39
38
 
40
- bench_performance_linear "defensive deathmatch demo",
41
- BENCH_TICK_THRESH do |n|
39
+ bench_performance_linear "defensive deathmatch demo", btick do |n|
42
40
  b = ConwayDeathmatch.new(70, 40)
43
41
  b.deathmatch = :defensive
44
42
  Shapes.add(b, "acorn 30 30", "1")
@@ -46,8 +44,7 @@ describe "ConwayDeathmatch#tick Benchmark" do
46
44
  n.times { b.tick }
47
45
  end
48
46
 
49
- bench_performance_linear "friendly deathmatch demo",
50
- BENCH_TICK_THRESH do |n|
47
+ bench_performance_linear "friendly deathmatch demo", btick do |n|
51
48
  b = ConwayDeathmatch.new(70, 40)
52
49
  b.deathmatch = :friendly
53
50
  Shapes.add(b, "acorn 30 30", "1")
@@ -3,7 +3,6 @@ if ENV['CODE_COVERAGE']
3
3
  SimpleCov.start
4
4
  end
5
5
 
6
- require 'minitest/spec'
7
6
  require 'minitest/autorun'
8
7
  require 'conway_deathmatch'
9
8
  require 'conway_deathmatch/shapes'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conway_deathmatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0.3
4
+ version: 0.6.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Hull
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-27 00:00:00.000000000 Z
11
+ date: 2017-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slop
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
19
+ version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.0'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: buildar
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2'
33
+ version: '3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2'
40
+ version: '3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -98,16 +98,22 @@ dependencies:
98
98
  name: roodi
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: '4.0'
103
+ version: '4'
104
+ - - "<"
105
+ - !ruby/object:Gem::Version
106
+ version: '6'
104
107
  type: :development
105
108
  prerelease: false
106
109
  version_requirements: !ruby/object:Gem::Requirement
107
110
  requirements:
108
- - - "~>"
111
+ - - ">="
109
112
  - !ruby/object:Gem::Version
110
- version: '4.0'
113
+ version: '4'
114
+ - - "<"
115
+ - !ruby/object:Gem::Version
116
+ version: '6'
111
117
  description: Deathmatch
112
118
  email:
113
119
  executables:
@@ -149,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
155
  version: '0'
150
156
  requirements: []
151
157
  rubyforge_project:
152
- rubygems_version: 2.5.2
158
+ rubygems_version: 2.6.8
153
159
  signing_key:
154
160
  specification_version: 4
155
161
  summary: Conway's Game of Life