chess 0.3.0 → 0.3.3
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 +4 -4
- data/.github/FUNDING.yml +12 -0
- data/.github/workflows/ruby.yml +58 -0
- data/.gitignore +3 -2
- data/.rubocop.yml +10 -142
- data/Gemfile.lock +74 -0
- data/README.md +26 -22
- data/Rakefile +2 -1
- data/chess.gemspec +11 -7
- data/docs/Chess/BadNotationError.html +237 -0
- data/docs/Chess/Board.html +1759 -0
- data/docs/Chess/CGame.html +2296 -0
- data/docs/Chess/Game.html +1277 -0
- data/docs/Chess/Gnuchess.html +366 -0
- data/docs/Chess/IllegalMoveError.html +137 -0
- data/docs/Chess/InvalidFenFormatError.html +237 -0
- data/docs/Chess/InvalidPgnFormatError.html +217 -0
- data/docs/Chess/Pgn.html +1477 -0
- data/docs/Chess/UTF8Notation.html +270 -0
- data/docs/Chess.html +157 -0
- data/docs/_index.html +217 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +497 -0
- data/docs/file.README.html +116 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +116 -0
- data/docs/js/app.js +314 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +531 -0
- data/docs/top-level-namespace.html +110 -0
- data/ext/chess.c +1 -1
- data/ext/common.h +7 -3
- data/ext/extconf.rb +1 -1
- data/lib/chess/game.rb +68 -66
- data/lib/chess/gnuchess.rb +49 -53
- data/lib/chess/pgn.rb +13 -15
- data/lib/chess/version.rb +1 -1
- data/test/test_big_pgn_collection.rb +1 -1
- data/test/test_checkmate.rb +4 -4
- data/test/test_errors.rb +22 -0
- data/test/test_fifty_rule_move.rb +2 -2
- data/test/test_game.rb +82 -0
- data/test/test_helper.rb +15 -0
- data/test/test_insufficient_material.rb +4 -4
- data/test/test_move_generator.rb +3 -2
- data/test/test_pgn.rb +35 -0
- data/test/test_pgn_collection.rb +2 -2
- data/test/test_stalemate.rb +1 -1
- data/test/test_threefold_repetition.rb +1 -1
- data/test/test_uci_castling.rb +34 -0
- metadata +118 -1236
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00f424b92a6c4551574198f0f90be9b15a868ff51793e78c2d203b757ad7c735
|
4
|
+
data.tar.gz: 2fe26a9a27b7a2ab68745ed8469dd3a0fe4a0222a33662e0f1a669b7ecd8c9db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f595f0999604ca4599c178276e54dbd0394f3c637116958c89887b452ece5d8b43fa9e3930a08577d922b35edcbbf95a86a0314dc8a5ee5aee22e522a5e2069
|
7
|
+
data.tar.gz: 151b85e0ea1605ede20d1d8615903b6ccc2a51586ab5ab309405d70c4d3af1d9b64f3745859b0df5740101168f511288c64f1eed5b41ea131e1014409671523e
|
data/.github/FUNDING.yml
ADDED
@@ -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.6', '2.7', '3.0', '3.1']
|
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.6', '2.7', '3.0', '3.1']
|
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
data/.rubocop.yml
CHANGED
@@ -1,55 +1,19 @@
|
|
1
|
-
require:
|
1
|
+
require:
|
2
|
+
- rubocop-minitest
|
3
|
+
- rubocop-performance
|
4
|
+
- rubocop-rake
|
2
5
|
|
3
6
|
AllCops:
|
4
|
-
|
5
|
-
|
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/**/*
|
16
|
-
|
17
|
-
Gemspec/RequiredRubyVersion:
|
18
|
-
Enabled: false
|
7
|
+
NewCops: enable
|
8
|
+
TargetRubyVersion: 2.5
|
19
9
|
|
20
|
-
Layout/
|
10
|
+
Layout/LineLength:
|
21
11
|
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,24 @@ 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
|
-
|
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:
|
111
|
-
Enabled: false
|
112
|
-
|
113
|
-
Style/BlockDelimiters:
|
114
|
-
Enabled: false
|
115
|
-
|
116
|
-
Style/BracesAroundHashParameters:
|
117
|
-
Enabled: false
|
118
|
-
|
119
|
-
Style/ClassAndModuleChildren:
|
120
|
-
Enabled: false
|
121
|
-
|
122
|
-
Style/ClassVars:
|
32
|
+
Minitest/AssertPredicate:
|
123
33
|
Enabled: false
|
124
34
|
|
125
|
-
|
35
|
+
Minitest/MultipleAssertions:
|
126
36
|
Enabled: false
|
127
37
|
|
128
|
-
Style/Documentation:
|
129
|
-
Enabled: false
|
130
|
-
|
131
|
-
Style/EmptyMethod:
|
132
|
-
EnforcedStyle: expanded
|
133
|
-
|
134
|
-
Style/FormatStringToken:
|
135
|
-
EnforcedStyle: template
|
136
|
-
|
137
38
|
Style/FrozenStringLiteralComment:
|
138
39
|
Enabled: false
|
139
40
|
|
140
41
|
Style/GlobalVars:
|
141
42
|
Enabled: false
|
142
43
|
|
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
44
|
Style/RaiseArgs:
|
165
45
|
EnforcedStyle: compact
|
166
46
|
|
@@ -172,15 +52,3 @@ Style/RedundantSelf:
|
|
172
52
|
|
173
53
|
Style/RegexpLiteral:
|
174
54
|
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
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
chess (0.3.3)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.2)
|
10
|
+
byebug (11.1.3)
|
11
|
+
codecov (0.6.0)
|
12
|
+
simplecov (>= 0.15, < 0.22)
|
13
|
+
docile (1.4.0)
|
14
|
+
json (2.6.2)
|
15
|
+
minitest (5.16.2)
|
16
|
+
parallel (1.22.1)
|
17
|
+
parser (3.1.2.0)
|
18
|
+
ast (~> 2.4.1)
|
19
|
+
rainbow (3.1.1)
|
20
|
+
rake (13.0.6)
|
21
|
+
regexp_parser (2.5.0)
|
22
|
+
rexml (3.2.5)
|
23
|
+
rubocop (1.31.2)
|
24
|
+
json (~> 2.3)
|
25
|
+
parallel (~> 1.10)
|
26
|
+
parser (>= 3.1.0.0)
|
27
|
+
rainbow (>= 2.2.2, < 4.0)
|
28
|
+
regexp_parser (>= 1.8, < 3.0)
|
29
|
+
rexml (>= 3.2.5, < 4.0)
|
30
|
+
rubocop-ast (>= 1.18.0, < 2.0)
|
31
|
+
ruby-progressbar (~> 1.7)
|
32
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
33
|
+
rubocop-ast (1.19.1)
|
34
|
+
parser (>= 3.1.1.0)
|
35
|
+
rubocop-minitest (0.20.1)
|
36
|
+
rubocop (>= 0.90, < 2.0)
|
37
|
+
rubocop-performance (1.14.2)
|
38
|
+
rubocop (>= 1.7.0, < 2.0)
|
39
|
+
rubocop-ast (>= 0.4.0)
|
40
|
+
rubocop-rake (0.6.0)
|
41
|
+
rubocop (~> 1.0)
|
42
|
+
ruby-progressbar (1.11.0)
|
43
|
+
simplecov (0.21.2)
|
44
|
+
docile (~> 1.1)
|
45
|
+
simplecov-html (~> 0.11)
|
46
|
+
simplecov_json_formatter (~> 0.1)
|
47
|
+
simplecov-html (0.12.3)
|
48
|
+
simplecov_json_formatter (0.1.4)
|
49
|
+
unicode-display_width (2.2.0)
|
50
|
+
webrick (1.7.0)
|
51
|
+
yard (0.9.28)
|
52
|
+
webrick (~> 1.7.0)
|
53
|
+
|
54
|
+
PLATFORMS
|
55
|
+
ruby
|
56
|
+
x86_64-darwin-18
|
57
|
+
x86_64-darwin-19
|
58
|
+
|
59
|
+
DEPENDENCIES
|
60
|
+
bundler (~> 2)
|
61
|
+
byebug (~> 11)
|
62
|
+
chess!
|
63
|
+
codecov (~> 0)
|
64
|
+
minitest (~> 5)
|
65
|
+
rake (~> 13)
|
66
|
+
rubocop (~> 1)
|
67
|
+
rubocop-minitest (~> 0)
|
68
|
+
rubocop-performance (~> 1)
|
69
|
+
rubocop-rake (~> 0)
|
70
|
+
simplecov (~> 0)
|
71
|
+
yard (>= 0.9.20)
|
72
|
+
|
73
|
+
BUNDLED WITH
|
74
|
+
2.3.8
|
data/README.md
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# Chess
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+

|
4
|
+
[](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.
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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.io/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)
|
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'
|
@@ -13,5 +14,5 @@ task default: :test
|
|
13
14
|
Rake::TestTask.new do |test|
|
14
15
|
test.libs << 'test'
|
15
16
|
test.warning = true
|
16
|
-
test.test_files = FileList["test/test_#{ENV
|
17
|
+
test.test_files = FileList["test/test_#{ENV.fetch('T', '*')}.rb"]
|
17
18
|
end
|
data/chess.gemspec
CHANGED
@@ -11,19 +11,23 @@ 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
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
15
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
19
16
|
s.extensions = ['ext/extconf.rb']
|
20
17
|
s.require_paths = ['lib']
|
21
18
|
|
22
|
-
s.
|
19
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
20
|
+
|
21
|
+
s.required_ruby_version = '>= 2.5'
|
23
22
|
s.add_development_dependency 'bundler', '~> 2'
|
23
|
+
s.add_development_dependency 'byebug', '~> 11'
|
24
|
+
s.add_development_dependency 'codecov', '~> 0'
|
24
25
|
s.add_development_dependency 'minitest', '~> 5'
|
25
|
-
s.add_development_dependency 'rake', '~>
|
26
|
-
s.add_development_dependency 'rubocop', '~>
|
26
|
+
s.add_development_dependency 'rake', '~> 13'
|
27
|
+
s.add_development_dependency 'rubocop', '~> 1'
|
28
|
+
s.add_development_dependency 'rubocop-minitest', '~> 0'
|
27
29
|
s.add_development_dependency 'rubocop-performance', '~> 1'
|
28
|
-
s.add_development_dependency '
|
30
|
+
s.add_development_dependency 'rubocop-rake', '~> 0'
|
31
|
+
s.add_development_dependency 'simplecov', '~> 0'
|
32
|
+
s.add_development_dependency 'yard', '>= 0.9.20'
|
29
33
|
end
|