chess 0.2.0 → 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 (70) hide show
  1. checksums.yaml +5 -5
  2. data/.github/FUNDING.yml +12 -0
  3. data/.github/workflows/ruby.yml +58 -0
  4. data/.gitignore +2 -2
  5. data/.rubocop.yml +51 -0
  6. data/Gemfile +1 -1
  7. data/Gemfile.lock +70 -0
  8. data/README.md +26 -22
  9. data/Rakefile +5 -4
  10. data/chess.gemspec +15 -11
  11. data/docs/Chess.html +157 -0
  12. data/docs/Chess/BadNotationError.html +237 -0
  13. data/docs/Chess/Board.html +1759 -0
  14. data/docs/Chess/CGame.html +2296 -0
  15. data/docs/Chess/Game.html +1277 -0
  16. data/docs/Chess/Gnuchess.html +366 -0
  17. data/docs/Chess/IllegalMoveError.html +137 -0
  18. data/docs/Chess/InvalidFenFormatError.html +237 -0
  19. data/docs/Chess/InvalidPgnFormatError.html +217 -0
  20. data/docs/Chess/Pgn.html +1477 -0
  21. data/docs/Chess/UTF8Notation.html +270 -0
  22. data/docs/_index.html +217 -0
  23. data/docs/class_list.html +51 -0
  24. data/docs/css/common.css +1 -0
  25. data/docs/css/full_list.css +58 -0
  26. data/docs/css/style.css +497 -0
  27. data/docs/file.README.html +116 -0
  28. data/docs/file_list.html +56 -0
  29. data/docs/frames.html +17 -0
  30. data/docs/index.html +116 -0
  31. data/docs/js/app.js +314 -0
  32. data/docs/js/full_list.js +216 -0
  33. data/docs/js/jquery.js +4 -0
  34. data/docs/method_list.html +531 -0
  35. data/docs/top-level-namespace.html +110 -0
  36. data/ext/bitboard.c +1 -1
  37. data/ext/bitboard.h +1 -1
  38. data/ext/board.c +1 -1
  39. data/ext/board.h +1 -1
  40. data/ext/chess.c +2 -2
  41. data/ext/chess.h +1 -1
  42. data/ext/common.c +1 -1
  43. data/ext/common.h +8 -4
  44. data/ext/extconf.rb +7 -6
  45. data/ext/game.c +2 -2
  46. data/ext/game.h +1 -1
  47. data/ext/special.c +10 -3
  48. data/ext/special.h +3 -2
  49. data/lib/chess/exceptions.rb +2 -5
  50. data/lib/chess/game.rb +55 -77
  51. data/lib/chess/gnuchess.rb +24 -27
  52. data/lib/chess/pgn.rb +32 -26
  53. data/lib/chess/utf8_notation.rb +3 -3
  54. data/lib/chess/version.rb +1 -1
  55. data/test/test_big_pgn_collection.rb +3 -4
  56. data/test/test_checkmate.rb +4 -6
  57. data/test/test_errors.rb +22 -0
  58. data/test/test_fifty_rule_move.rb +2 -4
  59. data/test/test_game.rb +82 -0
  60. data/test/test_helper.rb +16 -3
  61. data/test/test_illegal_moves.rb +1 -3
  62. data/test/test_insufficient_material.rb +6 -7
  63. data/test/test_load_fen.rb +11 -1
  64. data/test/test_move_generator.rb +13 -14
  65. data/test/test_particular_situations.rb +0 -2
  66. data/test/test_pgn.rb +82 -1
  67. data/test/test_pgn_collection.rb +2 -2
  68. data/test/test_stalemate.rb +1 -3
  69. data/test/test_threefold_repetition.rb +1 -3
  70. metadata +145 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 144e0056d416422439a212c961f1a20f97899732
4
- data.tar.gz: 8863ebc0662c3e8a9358df006302a41e2f4a1782
2
+ SHA256:
3
+ metadata.gz: 6c0769e70cd986cfb2f23d8f8eb2551cd72745e35dc5cde6832bbab0d35015d5
4
+ data.tar.gz: 9dd9e4fa0b620f8905e46d33ed6969a09a896e07018d3857dec3926e6da2571b
5
5
  SHA512:
6
- metadata.gz: 859d042dbca0d119161bd0361dc9940dadc0e9de3b60e863ec9609425f6b8487f70bbd5821de98d67096c96cf46d6ada82ce59dba7a8e3963aba47fb3c0d29f0
7
- data.tar.gz: 7466a2c6711067f3e90efb80ec5a7a64ca3c323cdd4d2ba087959ef93f04a54778fcd36d4cec537f962b9fc4d80aa726593febf857cf8588c791088ead57775c
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/*
@@ -0,0 +1,51 @@
1
+ require:
2
+ - rubocop-minitest
3
+ - rubocop-performance
4
+ - rubocop-rake
5
+
6
+ AllCops:
7
+ NewCops: enable
8
+ TargetRubyVersion: 2.5
9
+
10
+ Layout/LineLength:
11
+ Enabled: false
12
+ Max: 120
13
+
14
+ Metrics/AbcSize:
15
+ Enabled: false
16
+
17
+ Metrics/BlockNesting:
18
+ Max: 4
19
+
20
+ Metrics/ClassLength:
21
+ Max: 1000
22
+
23
+ Metrics/CyclomaticComplexity:
24
+ Max: 15
25
+
26
+ Metrics/MethodLength:
27
+ Max: 100
28
+
29
+ Metrics/PerceivedComplexity:
30
+ Max: 20
31
+
32
+ Minitest/MultipleAssertions:
33
+ Enabled: false
34
+
35
+ Style/FrozenStringLiteralComment:
36
+ Enabled: false
37
+
38
+ Style/GlobalVars:
39
+ Enabled: false
40
+
41
+ Style/RaiseArgs:
42
+ EnforcedStyle: compact
43
+
44
+ Style/RedundantReturn:
45
+ Enabled: false
46
+
47
+ Style/RedundantSelf:
48
+ Enabled: false
49
+
50
+ Style/RegexpLiteral:
51
+ AllowInnerSlashes: true
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in chess.gemspec
4
4
  gemspec
@@ -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 1.9 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
@@ -2,10 +2,11 @@ require 'bundler/gem_tasks'
2
2
 
3
3
  require 'yard'
4
4
  YARD::Rake::YardocTask.new do |t|
5
- t.files = ['lib/**/*.rb', 'ext/*.c']
6
- t.options << '-rREADME.md'
7
- t.options << '--title=Chess'
8
- t.options << '-mmarkdown'
5
+ t.files = ['lib/**/*.rb', 'ext/*.c']
6
+ t.options << '-rREADME.md'
7
+ t.options << '--title=Chess'
8
+ t.options << '-mmarkdown'
9
+ t.options << '--output-dir=docs'
9
10
  end
10
11
 
11
12
  require 'rake/testtask'
@@ -1,5 +1,4 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path('../lib', __FILE__)
1
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
3
2
  require 'chess/version'
4
3
 
5
4
  Gem::Specification.new do |s|
@@ -8,21 +7,26 @@ Gem::Specification.new do |s|
8
7
  s.authors = ['Enrico Pilotto']
9
8
  s.email = ['epilotto@gmx.com']
10
9
  s.homepage = 'https://github.com/pioz/chess'
11
- s.summary = %q{A fast chess library to play chess with Ruby.}
12
- s.description = %q{A fast chess library that use bitboards to play chess with Ruby.}
10
+ s.summary = 'A fast chess library to play chess with Ruby.'
11
+ s.description = 'A fast chess library that use bitboards to play chess with Ruby.'
13
12
  s.license = 'LGPLv3'
14
13
 
15
- s.rubyforge_project = 'chess'
16
-
17
14
  s.files = `git ls-files`.split("\n")
18
15
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
20
17
  s.extensions = ['ext/extconf.rb']
21
18
  s.require_paths = ['lib']
22
19
 
23
- s.required_ruby_version = '>= 1.9'
24
- s.add_development_dependency 'bundler', '~> 1.14'
25
- s.add_development_dependency 'rake', '~> 12.0'
26
- s.add_development_dependency 'minitest', '~> 5.10'
20
+ s.required_ruby_version = '>= 2.5'
21
+ s.add_development_dependency 'bundler', '~> 2'
22
+ s.add_development_dependency 'byebug', '~> 11'
23
+ s.add_development_dependency 'codecov', '~> 0.4'
24
+ s.add_development_dependency 'minitest', '~> 5'
25
+ s.add_development_dependency 'rake', '~> 13'
26
+ s.add_development_dependency 'rubocop', '~> 1'
27
+ s.add_development_dependency 'rubocop-minitest', '~> 0.10'
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'
27
31
  s.add_development_dependency 'yard', '~> 0.9'
28
32
  end
@@ -0,0 +1,157 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: Chess
8
+
9
+ &mdash; Chess
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "Chess";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index (C)</a> &raquo;
40
+
41
+
42
+ <span class="title">Chess</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: Chess
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ <dl>
80
+ <dt>Defined in:</dt>
81
+ <dd>lib/chess/version.rb<span class="defines">,<br />
82
+ lib/chess/pgn.rb,<br /> lib/chess/game.rb,<br /> lib/chess/gnuchess.rb,<br /> lib/chess/exceptions.rb,<br /> lib/chess/utf8_notation.rb,<br /> ext/chess.c</span>
83
+ </dd>
84
+ </dl>
85
+
86
+ </div>
87
+
88
+ <h2>Overview</h2><div class="docstring">
89
+ <div class="discussion">
90
+
91
+ <p>The Chess library module.</p>
92
+
93
+
94
+ </div>
95
+ </div>
96
+ <div class="tags">
97
+
98
+
99
+ </div><h2>Defined Under Namespace</h2>
100
+ <p class="children">
101
+
102
+
103
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Chess/Gnuchess.html" title="Chess::Gnuchess (module)">Gnuchess</a></span>, <span class='object_link'><a href="Chess/UTF8Notation.html" title="Chess::UTF8Notation (module)">UTF8Notation</a></span>
104
+
105
+
106
+
107
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Chess/BadNotationError.html" title="Chess::BadNotationError (class)">BadNotationError</a></span>, <span class='object_link'><a href="Chess/Board.html" title="Chess::Board (class)">Board</a></span>, <span class='object_link'><a href="Chess/CGame.html" title="Chess::CGame (class)">CGame</a></span>, <span class='object_link'><a href="Chess/Game.html" title="Chess::Game (class)">Game</a></span>, <span class='object_link'><a href="Chess/IllegalMoveError.html" title="Chess::IllegalMoveError (class)">IllegalMoveError</a></span>, <span class='object_link'><a href="Chess/InvalidFenFormatError.html" title="Chess::InvalidFenFormatError (class)">InvalidFenFormatError</a></span>, <span class='object_link'><a href="Chess/InvalidPgnFormatError.html" title="Chess::InvalidPgnFormatError (class)">InvalidPgnFormatError</a></span>, <span class='object_link'><a href="Chess/Pgn.html" title="Chess::Pgn (class)">Pgn</a></span>
108
+
109
+
110
+ </p>
111
+
112
+
113
+ <h2>
114
+ Constant Summary
115
+ <small><a href="#" class="constants_summary_toggle">collapse</a></small>
116
+ </h2>
117
+
118
+ <dl class="constants">
119
+
120
+ <dt id="VERSION-constant" class="">VERSION =
121
+ <div class="docstring">
122
+ <div class="discussion">
123
+
124
+ <p>The library version.</p>
125
+
126
+
127
+ </div>
128
+ </div>
129
+ <div class="tags">
130
+
131
+
132
+ </div>
133
+ </dt>
134
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>0.3.1</span><span class='tstring_end'>&#39;</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
135
+
136
+ </dl>
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+ </div>
148
+
149
+ <div id="footer">
150
+ Generated on Thu Jan 28 17:31:40 2021 by
151
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
152
+ 0.9.26 (ruby-2.6.1).
153
+ </div>
154
+
155
+ </div>
156
+ </body>
157
+ </html>