chess 0.3.1 → 0.3.2

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 (55) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +12 -0
  3. data/.github/workflows/ruby.yml +58 -0
  4. data/.gitignore +2 -2
  5. data/.rubocop.yml +9 -144
  6. data/Gemfile.lock +70 -0
  7. data/README.md +26 -22
  8. data/Rakefile +1 -0
  9. data/chess.gemspec +8 -5
  10. data/docs/Chess.html +157 -0
  11. data/docs/Chess/BadNotationError.html +237 -0
  12. data/docs/Chess/Board.html +1759 -0
  13. data/docs/Chess/CGame.html +2296 -0
  14. data/docs/Chess/Game.html +1277 -0
  15. data/docs/Chess/Gnuchess.html +366 -0
  16. data/docs/Chess/IllegalMoveError.html +137 -0
  17. data/docs/Chess/InvalidFenFormatError.html +237 -0
  18. data/docs/Chess/InvalidPgnFormatError.html +217 -0
  19. data/docs/Chess/Pgn.html +1477 -0
  20. data/docs/Chess/UTF8Notation.html +270 -0
  21. data/docs/_index.html +217 -0
  22. data/docs/class_list.html +51 -0
  23. data/docs/css/common.css +1 -0
  24. data/docs/css/full_list.css +58 -0
  25. data/docs/css/style.css +497 -0
  26. data/docs/file.README.html +116 -0
  27. data/docs/file_list.html +56 -0
  28. data/docs/frames.html +17 -0
  29. data/docs/index.html +116 -0
  30. data/docs/js/app.js +314 -0
  31. data/docs/js/full_list.js +216 -0
  32. data/docs/js/jquery.js +4 -0
  33. data/docs/method_list.html +531 -0
  34. data/docs/top-level-namespace.html +110 -0
  35. data/ext/chess.c +1 -1
  36. data/ext/common.h +7 -3
  37. data/ext/extconf.rb +1 -1
  38. data/lib/chess/game.rb +53 -67
  39. data/lib/chess/gnuchess.rb +49 -53
  40. data/lib/chess/pgn.rb +10 -12
  41. data/lib/chess/utf8_notation.rb +3 -0
  42. data/lib/chess/version.rb +1 -1
  43. data/test/test_big_pgn_collection.rb +1 -1
  44. data/test/test_checkmate.rb +4 -4
  45. data/test/test_errors.rb +22 -0
  46. data/test/test_fifty_rule_move.rb +2 -2
  47. data/test/test_game.rb +82 -0
  48. data/test/test_helper.rb +15 -0
  49. data/test/test_insufficient_material.rb +4 -4
  50. data/test/test_move_generator.rb +3 -2
  51. data/test/test_pgn.rb +35 -0
  52. data/test/test_pgn_collection.rb +2 -2
  53. data/test/test_stalemate.rb +1 -1
  54. data/test/test_threefold_repetition.rb +1 -1
  55. metadata +112 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32451a4f1415327ad400f0330f12fd3682422d3c259e58151534f8170c816e1a
4
- data.tar.gz: 313e86f8308b218dfa5153aa35efd3495e2111368336c4152e5f76a57201b3e4
3
+ metadata.gz: 6c0769e70cd986cfb2f23d8f8eb2551cd72745e35dc5cde6832bbab0d35015d5
4
+ data.tar.gz: 9dd9e4fa0b620f8905e46d33ed6969a09a896e07018d3857dec3926e6da2571b
5
5
  SHA512:
6
- metadata.gz: 97ce070bb69a21f216e26799ccb996cb8369a89718787372975b2485303c569ff2cf88fd3d6d6b498cc91256471c79ca3c63bca132fe28e6a1eab0caab9f5f20
7
- data.tar.gz: 5818d183ce0e2617cf5a76e62f05fec7e9f3dfb0ea5c122c62c4fe0a4a278b2a2e20e5c2337cb3127d6f74816f32aada23bb3e6d6c1a8b01670df2ddcf37eabf
6
+ metadata.gz: d6bb94f4bc3a86cfb593c0e2c233bf75887c1c10be1f968d9dcc4e169e5add14dd18624c9d2932284e6f4fcacdf43fabb65457575fa29a7d308f7366d6f6d227
7
+ data.tar.gz: e68c4d62784204158e9829c85265fb354357b30af59cfdc790eeea498fb93e88c136712e6b61979017488a0a14836a2a07ac7c90dc091ad2bf5dcc739c9d5845
@@ -0,0 +1,12 @@
1
+ # These are supported funding model platforms
2
+
3
+ # github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4
+ # patreon: # Replace with a single Patreon username
5
+ # open_collective: # Replace with a single Open Collective username
6
+ # ko_fi: # Replace with a single Ko-fi username
7
+ # tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
+ # community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ # liberapay: # Replace with a single Liberapay username
10
+ # issuehunt: # Replace with a single IssueHunt username
11
+ # otechie: # Replace with a single Otechie username
12
+ custom: https://www.paypal.me/epilotto
@@ -0,0 +1,58 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [master]
13
+ pull_request:
14
+ branches: [master]
15
+
16
+ jobs:
17
+ test:
18
+ runs-on: ubuntu-latest
19
+ strategy:
20
+ matrix:
21
+ ruby-version: ['2.5', '2.6', '2.7', '3.0']
22
+
23
+ steps:
24
+ - uses: actions/checkout@v2
25
+ - name: Set up Ruby
26
+ uses: ruby/setup-ruby@v1
27
+ with:
28
+ ruby-version: ${{ matrix.ruby-version }}
29
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
30
+ - name: Compile extension
31
+ working-directory: ./ext
32
+ run: |
33
+ ruby extconf.rb
34
+ make
35
+ - name: Run tests
36
+ run: bundle exec rake test
37
+ env:
38
+ CODECOV: true
39
+ # - name: Upload coverage report to Codecov
40
+ # uses: codecov/codecov-action@v1
41
+ # with:
42
+ # file: ./coverage/.resultset.json
43
+
44
+ rubocop:
45
+ runs-on: ubuntu-latest
46
+ strategy:
47
+ matrix:
48
+ ruby-version: ['2.5', '2.6', '2.7', '3.0']
49
+
50
+ steps:
51
+ - uses: actions/checkout@v2
52
+ - name: Set up Ruby
53
+ uses: ruby/setup-ruby@v1
54
+ with:
55
+ ruby-version: ${{ matrix.ruby-version }}
56
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
57
+ - name: Run Rubocop
58
+ run: bundle exec rubocop
data/.gitignore CHANGED
@@ -1,11 +1,11 @@
1
1
  *.gem
2
2
  .bundle
3
+ .byebug_history
3
4
  .yardoc/
4
- doc/
5
+ coverage/
5
6
  ext/chess
6
7
  ext/Makefile
7
8
  ext/*.bundle
8
9
  ext/*.o
9
- Gemfile.lock
10
10
  main.rb
11
11
  pkg/*
@@ -1,55 +1,19 @@
1
- require: rubocop-performance
1
+ require:
2
+ - rubocop-minitest
3
+ - rubocop-performance
4
+ - rubocop-rake
2
5
 
3
6
  AllCops:
4
- Exclude:
5
- - bin/*
6
- - db/migrate/*
7
- - db/schema.rb
8
- - db/seeds.rb
9
- - lib/*/Gemfile
10
- - lib/*/Rakefile
11
- - lib/*/bin/*
12
- - lib/*/*.gemspec
13
- - node_modules/**/*
14
- - spec/**/*
15
- - tmp/**/*
7
+ NewCops: enable
8
+ TargetRubyVersion: 2.5
16
9
 
17
- Gemspec/RequiredRubyVersion:
10
+ Layout/LineLength:
18
11
  Enabled: false
19
-
20
- Layout/AlignHash:
21
- Enabled: false
22
-
23
- Layout/AlignParameters:
24
- EnforcedStyle: with_fixed_indentation
25
-
26
- Layout/EmptyLinesAroundBlockBody:
27
- EnforcedStyle: no_empty_lines
28
-
29
- Layout/EmptyLinesAroundClassBody:
30
- EnforcedStyle: no_empty_lines
31
-
32
- Layout/IndentationConsistency:
33
- EnforcedStyle: rails
34
-
35
- Layout/IndentFirstArrayElement:
36
- EnforcedStyle: consistent
37
-
38
- Layout/IndentFirstHashElement:
39
- EnforcedStyle: consistent
40
-
41
- Layout/MultilineMethodCallIndentation:
42
- EnforcedStyle: indented
43
-
44
- Layout/MultilineOperationIndentation:
45
- EnforcedStyle: indented
12
+ Max: 120
46
13
 
47
14
  Metrics/AbcSize:
48
15
  Enabled: false
49
16
 
50
- Metrics/BlockLength:
51
- Max: 100
52
-
53
17
  Metrics/BlockNesting:
54
18
  Max: 4
55
19
 
@@ -59,108 +23,21 @@ Metrics/ClassLength:
59
23
  Metrics/CyclomaticComplexity:
60
24
  Max: 15
61
25
 
62
- Metrics/LineLength:
63
- Enabled: false
64
- Max: 120
65
-
66
26
  Metrics/MethodLength:
67
27
  Max: 100
68
28
 
69
- Metrics/ModuleLength:
70
- Max: 1000
71
-
72
- Metrics/ParameterLists:
73
- Enabled: false
74
-
75
29
  Metrics/PerceivedComplexity:
76
30
  Max: 20
77
31
 
78
- Performance/Casecmp:
79
- Enabled: false
80
-
81
- Rails:
82
- Enabled: true
83
-
84
- Rails/HasAndBelongsToMany:
85
- Enabled: false
86
-
87
- Rails/HasManyOrHasOneDependent:
88
- Enabled: false
89
-
90
- Rails/InverseOf:
91
- Enabled: false
92
-
93
- Rails/OutputSafety:
94
- Enabled: false
95
-
96
- Rails/SafeNavigation:
97
- ConvertTry: true
98
-
99
- Rails/SkipsModelValidations:
100
- Enabled: false
101
-
102
- Rails/UnknownEnv:
103
- Environments:
104
- - development
105
- - test
106
- - simulation
107
- - staging
108
- - production
109
-
110
- Style/AsciiComments:
32
+ Minitest/MultipleAssertions:
111
33
  Enabled: false
112
34
 
113
- Style/BlockDelimiters:
114
- Enabled: false
115
-
116
- Style/BracesAroundHashParameters:
117
- Enabled: false
118
-
119
- Style/ClassAndModuleChildren:
120
- Enabled: false
121
-
122
- Style/ClassVars:
123
- Enabled: false
124
-
125
- Style/ConditionalAssignment:
126
- Enabled: false
127
-
128
- Style/Documentation:
129
- Enabled: false
130
-
131
- Style/EmptyMethod:
132
- EnforcedStyle: expanded
133
-
134
- Style/FormatStringToken:
135
- EnforcedStyle: template
136
-
137
35
  Style/FrozenStringLiteralComment:
138
36
  Enabled: false
139
37
 
140
38
  Style/GlobalVars:
141
39
  Enabled: false
142
40
 
143
- Style/GuardClause:
144
- Enabled: false
145
-
146
- Style/IfUnlessModifier:
147
- Enabled: false
148
-
149
- Style/Lambda:
150
- EnforcedStyle: literal
151
-
152
- Style/MethodDefParentheses:
153
- Enabled: false
154
-
155
- Style/NegatedIf:
156
- Enabled: false
157
-
158
- Style/Next:
159
- Enabled: false
160
-
161
- Style/NumericPredicate:
162
- Enabled: false
163
-
164
41
  Style/RaiseArgs:
165
42
  EnforcedStyle: compact
166
43
 
@@ -172,15 +49,3 @@ Style/RedundantSelf:
172
49
 
173
50
  Style/RegexpLiteral:
174
51
  AllowInnerSlashes: true
175
-
176
- Style/RescueModifier:
177
- Enabled: false
178
-
179
- Style/SafeNavigation:
180
- Enabled: true
181
-
182
- Style/SingleLineMethods:
183
- Enabled: false
184
-
185
- Style/SymbolArray:
186
- Enabled: false
@@ -0,0 +1,70 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ chess (0.3.2)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ byebug (11.1.3)
11
+ codecov (0.4.2)
12
+ simplecov (>= 0.15, < 0.22)
13
+ docile (1.3.5)
14
+ minitest (5.14.3)
15
+ parallel (1.20.1)
16
+ parser (3.0.0.0)
17
+ ast (~> 2.4.1)
18
+ rainbow (3.0.0)
19
+ rake (13.0.3)
20
+ regexp_parser (2.0.3)
21
+ rexml (3.2.4)
22
+ rubocop (1.8.1)
23
+ parallel (~> 1.10)
24
+ parser (>= 3.0.0.0)
25
+ rainbow (>= 2.2.2, < 4.0)
26
+ regexp_parser (>= 1.8, < 3.0)
27
+ rexml
28
+ rubocop-ast (>= 1.2.0, < 2.0)
29
+ ruby-progressbar (~> 1.7)
30
+ unicode-display_width (>= 1.4.0, < 3.0)
31
+ rubocop-ast (1.4.1)
32
+ parser (>= 2.7.1.5)
33
+ rubocop-minitest (0.10.3)
34
+ rubocop (>= 0.87, < 2.0)
35
+ rubocop-performance (1.9.2)
36
+ rubocop (>= 0.90.0, < 2.0)
37
+ rubocop-ast (>= 0.4.0)
38
+ rubocop-rake (0.5.1)
39
+ rubocop
40
+ ruby-progressbar (1.11.0)
41
+ simplecov (0.21.2)
42
+ docile (~> 1.1)
43
+ simplecov-html (~> 0.11)
44
+ simplecov_json_formatter (~> 0.1)
45
+ simplecov-html (0.12.3)
46
+ simplecov_json_formatter (0.1.2)
47
+ unicode-display_width (2.0.0)
48
+ yard (0.9.26)
49
+
50
+ PLATFORMS
51
+ ruby
52
+ x86_64-darwin-18
53
+ x86_64-darwin-19
54
+
55
+ DEPENDENCIES
56
+ bundler (~> 2)
57
+ byebug (~> 11)
58
+ chess!
59
+ codecov (~> 0.4)
60
+ minitest (~> 5)
61
+ rake (~> 13)
62
+ rubocop (~> 1)
63
+ rubocop-minitest (~> 0.10)
64
+ rubocop-performance (~> 1)
65
+ rubocop-rake (~> 0.5)
66
+ simplecov (~> 0.21)
67
+ yard (~> 0.9)
68
+
69
+ BUNDLED WITH
70
+ 2.2.7
data/README.md CHANGED
@@ -1,12 +1,13 @@
1
1
  # Chess
2
2
 
3
- A fast Ruby library to play chess with Ruby. This library is quite fast
4
- because rappresent the game situations with bitboards. In addition, the move
5
- generator is written in C as a Ruby extension.
3
+ ![build](https://github.com/pioz/chess/workflows/Ruby/badge.svg)
4
+ [![codecov](https://codecov.io/gh/pioz/chess/branch/master/graph/badge.svg?token=bsSUOW6wWa)](https://codecov.io/gh/pioz/chess)
5
+
6
+ A fast Ruby gem to play chess with Ruby. This library is quite fast because manage game situations with [bitboards](https://en.wikipedia.org/wiki/Bitboard). Also, the move generator is written in C as a Ruby extension.
6
7
 
7
8
  ## Requirements
8
9
 
9
- - Ruby 2.0 or higher
10
+ - Ruby 2.5 or higher
10
11
 
11
12
  ## Installation
12
13
 
@@ -14,23 +15,26 @@ generator is written in C as a Ruby extension.
14
15
 
15
16
  ## Usage
16
17
 
17
- require 'chess'
18
- g = Chess::Game.new
19
- until g.over?
20
- begin
21
- print "Give me a #{g.active_player} move: "
22
- input = gets.chop
23
- break if input == 'quit'
24
- g << input
25
- puts g
26
- puts g.moves.last
27
- rescue Chess::IllegalMoveError => e
28
- puts 'Illegal move!'
29
- end
30
- end
31
- puts g.status
32
-
33
- **Documentation** is available [here](http://pioz.github.com/chess).
18
+ ```ruby
19
+ require 'chess'
20
+
21
+ g = Chess::Game.new
22
+ until g.over?
23
+ begin
24
+ print "Give me a #{g.active_player} move: "
25
+ input = gets.chop
26
+ break if input == 'quit'
27
+ g << input
28
+ puts g
29
+ puts g.moves.last
30
+ rescue Chess::IllegalMoveError => e
31
+ puts 'Illegal move!'
32
+ end
33
+ end
34
+ puts g.status
35
+ ```
36
+
37
+ **Documentation** is available **[here](http://pioz.github.com/chess)**.
34
38
 
35
39
  ## Questions or problems?
36
40
 
@@ -40,5 +44,5 @@ pull request.
40
44
 
41
45
  ## Copyright
42
46
 
43
- Copyright (c) 2017 [Enrico Pilotto (@pioz)](https://github.com/pioz). See
47
+ Copyright (c) 2021 [Enrico Pilotto (@pioz)](https://github.com/pioz). See
44
48
  [LICENSE](https://github.com/pioz/chess/blob/master/LICENSE) for details.
data/Rakefile CHANGED
@@ -6,6 +6,7 @@ YARD::Rake::YardocTask.new do |t|
6
6
  t.options << '-rREADME.md'
7
7
  t.options << '--title=Chess'
8
8
  t.options << '-mmarkdown'
9
+ t.options << '--output-dir=docs'
9
10
  end
10
11
 
11
12
  require 'rake/testtask'
@@ -11,19 +11,22 @@ Gem::Specification.new do |s|
11
11
  s.description = 'A fast chess library that use bitboards to play chess with Ruby.'
12
12
  s.license = 'LGPLv3'
13
13
 
14
- s.rubyforge_project = 'chess'
15
-
16
14
  s.files = `git ls-files`.split("\n")
17
15
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
16
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
17
  s.extensions = ['ext/extconf.rb']
20
18
  s.require_paths = ['lib']
21
19
 
22
- s.required_ruby_version = '>= 2.0'
20
+ s.required_ruby_version = '>= 2.5'
23
21
  s.add_development_dependency 'bundler', '~> 2'
22
+ s.add_development_dependency 'byebug', '~> 11'
23
+ s.add_development_dependency 'codecov', '~> 0.4'
24
24
  s.add_development_dependency 'minitest', '~> 5'
25
- s.add_development_dependency 'rake', '~> 12'
26
- s.add_development_dependency 'rubocop', '~> 0.71'
25
+ s.add_development_dependency 'rake', '~> 13'
26
+ s.add_development_dependency 'rubocop', '~> 1'
27
+ s.add_development_dependency 'rubocop-minitest', '~> 0.10'
27
28
  s.add_development_dependency 'rubocop-performance', '~> 1'
29
+ s.add_development_dependency 'rubocop-rake', '~> 0.5'
30
+ s.add_development_dependency 'simplecov', '~> 0.21'
28
31
  s.add_development_dependency 'yard', '~> 0.9'
29
32
  end