chess 0.3.6 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2ea2f6690d7433bf5c037b3f62bfa5fa84e18900e2e98b52f08a7330c6b5a0d
4
- data.tar.gz: c79b608ef27aacce3d653cef25e7fa97e2661125e6ac99de3ddb13480b5124b3
3
+ metadata.gz: 70707b1702323bd7382d8b5c33f4215df8e4cc03456aca37f3c3007c0ca325c4
4
+ data.tar.gz: dce9ac8cd70a77c5f5ff615f468a58dff050e1ed0da806b1682dcfa407c80754
5
5
  SHA512:
6
- metadata.gz: c173bb5fcb5f5192c12a606fd8dd5224abf7aee1441dca39ee3cfd408a78b5d9072cb7730602f8369dabd0419ba69149990c0a20fc9a69881f329dfeeac41116
7
- data.tar.gz: 134fffef0ed8408c6e847fc3aef1a6fc65369d64671e4578460a1dfad706a509481dedeae1dbef7ae1a8bb5f4acfabb8b34e84bf6d04f5f1f609dd0f974a83bc
6
+ metadata.gz: c1cfbb10d79c883d5cdfacf01ca079075f7520053e323e6ff030e4882f1d9112aad465b2b47eb5995a9f48150ef332d6b9ee7e05f8218bf97636b965d0a4c463
7
+ data.tar.gz: 3a81d782a5e9bc63b611bbf6d1305bdd9c848233ee87f83e72e66738a69a5a8365aebbe5a22893cc41da51c4945fb997848aa9f972a61b1ee19f3198e6def9ab
@@ -21,12 +21,13 @@ jobs:
21
21
  ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3']
22
22
 
23
23
  steps:
24
- - uses: actions/checkout@v2
24
+ - name: Checkout repository
25
+ uses: actions/checkout@v4
25
26
  - name: Set up Ruby
26
27
  uses: ruby/setup-ruby@v1
27
28
  with:
28
29
  ruby-version: ${{ matrix.ruby-version }}
29
- bundler-cache: true # runs 'bundle install' and caches installed gems automatically
30
+ bundler-cache: true
30
31
  - name: Compile extension
31
32
  working-directory: ./ext/chess
32
33
  run: |
@@ -36,23 +37,17 @@ jobs:
36
37
  run: bundle exec rake test
37
38
  env:
38
39
  CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
39
- # - name: Upload coverage report to Codecov
40
- # uses: codecov/codecov-action@v1
41
- # with:
42
- # file: ./coverage/.resultset.json
43
40
 
44
41
  rubocop:
45
42
  runs-on: ubuntu-latest
46
- strategy:
47
- matrix:
48
- ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3']
49
43
 
50
44
  steps:
51
- - uses: actions/checkout@v2
45
+ - name: Checkout repository
46
+ uses: actions/checkout@v4
52
47
  - name: Set up Ruby
53
48
  uses: ruby/setup-ruby@v1
54
49
  with:
55
- ruby-version: ${{ matrix.ruby-version }}
56
- bundler-cache: true # runs 'bundle install' and caches installed gems automatically
50
+ ruby-version: '3.3'
51
+ bundler-cache: true
57
52
  - name: Run Rubocop
58
53
  run: bundle exec rubocop
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chess (0.3.6)
4
+ chess (0.4.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/README.md CHANGED
@@ -34,7 +34,7 @@ end
34
34
  puts g.status
35
35
  ```
36
36
 
37
- **Documentation** is available **[here](http://pioz.github.io/chess)**.
37
+ 📚 **Documentation** is available [here](https://pioz.github.io/chess).
38
38
 
39
39
  ## Questions or problems?
40
40
 
@@ -44,5 +44,5 @@ pull request.
44
44
 
45
45
  ## Copyright
46
46
 
47
- Copyright (c) 2021 [Enrico Pilotto (@pioz)](https://github.com/pioz). See
47
+ Copyright (c) 2024 [Enrico Pilotto (@pioz)](https://github.com/pioz). See
48
48
  [LICENSE](https://github.com/pioz/chess/blob/master/LICENSE) for details.
@@ -227,9 +227,9 @@
227
227
  </div>
228
228
 
229
229
  <div id="footer">
230
- Generated on Thu Jan 28 17:31:40 2021 by
231
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
232
- 0.9.26 (ruby-2.6.1).
230
+ Generated on Fri Aug 30 11:09:51 2024 by
231
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
232
+ 0.9.36 (ruby-3.3.2).
233
233
  </div>
234
234
 
235
235
  </div>
@@ -94,8 +94,8 @@
94
94
 
95
95
  <dl>
96
96
  <dt>Defined in:</dt>
97
- <dd>ext/chess.c<span class="defines">,<br />
98
- ext/chess.c</span>
97
+ <dd>ext/chess/chess.c<span class="defines">,<br />
98
+ ext/chess/chess.c</span>
99
99
  </dd>
100
100
  </dl>
101
101
 
@@ -268,6 +268,30 @@
268
268
  <p>Returns the fullmove number: the number of the full move.</p>
269
269
  </div></span>
270
270
 
271
+ </li>
272
+
273
+
274
+ <li class="public ">
275
+ <span class="summary_signature">
276
+
277
+ <a href="#generate_all_moves-instance_method" title="#generate_all_moves (instance method)">#<strong>generate_all_moves</strong> &#x21d2; Array&lt;String&gt; </a>
278
+
279
+
280
+
281
+ </span>
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+
291
+ <span class="summary_desc"><div class='inline'>
292
+ <p>Generate all legal moves for the current board position.</p>
293
+ </div></span>
294
+
271
295
  </li>
272
296
 
273
297
 
@@ -524,7 +548,7 @@
524
548
 
525
549
  &mdash;
526
550
  <div class='inline'>
527
- <p>The square of the <span class='object_link'><a href="" title="Chess::Board (class)">Chess::Board</a></span>. Can be an integer between 0 and 63 or a string like &#39;a2&#39;, &#39;c5&#39;…</p>
551
+ <p>The square of the <span class='object_link'><a href="" title="Chess::Board (class)">Chess::Board</a></span>. Can be an integer between 0 and 63 or a string like a2’, c5’…</p>
528
552
  </div>
529
553
 
530
554
  </li>
@@ -543,7 +567,7 @@
543
567
 
544
568
  &mdash;
545
569
  <div class='inline'>
546
- <p>The symbol that identify the piece <em>(&#39;P&#39;, &#39;R&#39;, &#39;N&#39;, &#39;B&#39;, &#39;Q&#39;, &#39;K&#39;)</em>. Upcase for a white piece, downcase for a black piece.</p>
570
+ <p>The symbol that identify the piece <em>(P’, R’, N’, B’, Q’, K)</em>. Upcase for a white piece, downcase for a black piece.</p>
547
571
  </div>
548
572
 
549
573
  </li>
@@ -577,7 +601,7 @@
577
601
  461</pre>
578
602
  </td>
579
603
  <td>
580
- <pre class="code"><span class="info file"># File 'ext/chess.c', line 446</span>
604
+ <pre class="code"><span class="info file"># File 'ext/chess/chess.c', line 446</span>
581
605
 
582
606
  VALUE
583
607
  board_get_piece (VALUE self, VALUE square)
@@ -662,7 +686,7 @@ board_get_piece (VALUE self, VALUE square)
662
686
  574</pre>
663
687
  </td>
664
688
  <td>
665
- <pre class="code"><span class="info file"># File 'ext/chess.c', line 565</span>
689
+ <pre class="code"><span class="info file"># File 'ext/chess/chess.c', line 565</span>
666
690
 
667
691
  VALUE
668
692
  board_active_color (VALUE self)
@@ -741,7 +765,7 @@ board_active_color (VALUE self)
741
765
  477</pre>
742
766
  </td>
743
767
  <td>
744
- <pre class="code"><span class="info file"># File 'ext/chess.c', line 468</span>
768
+ <pre class="code"><span class="info file"># File 'ext/chess/chess.c', line 468</span>
745
769
 
746
770
  VALUE
747
771
  board_king_in_check (VALUE self)
@@ -820,7 +844,7 @@ board_king_in_check (VALUE self)
820
844
  493</pre>
821
845
  </td>
822
846
  <td>
823
- <pre class="code"><span class="info file"># File 'ext/chess.c', line 484</span>
847
+ <pre class="code"><span class="info file"># File 'ext/chess/chess.c', line 484</span>
824
848
 
825
849
  VALUE
826
850
  board_king_in_checkmate (VALUE self)
@@ -899,7 +923,7 @@ board_king_in_checkmate (VALUE self)
899
923
  557</pre>
900
924
  </td>
901
925
  <td>
902
- <pre class="code"><span class="info file"># File 'ext/chess.c', line 548</span>
926
+ <pre class="code"><span class="info file"># File 'ext/chess/chess.c', line 548</span>
903
927
 
904
928
  VALUE
905
929
  board_fifty_move_rule (VALUE self)
@@ -936,7 +960,7 @@ board_fifty_move_rule (VALUE self)
936
960
  <div class="docstring">
937
961
  <div class="discussion">
938
962
 
939
- <p>Returns the fullmove number: the number of the full move. It starts at 1, and * is incremented after black&#39;s move.</p>
963
+ <p>Returns the fullmove number: the number of the full move. It starts at 1, and * is incremented after blacks move.</p>
940
964
 
941
965
 
942
966
  </div>
@@ -975,7 +999,7 @@ board_fifty_move_rule (VALUE self)
975
999
  603</pre>
976
1000
  </td>
977
1001
  <td>
978
- <pre class="code"><span class="info file"># File 'ext/chess.c', line 597</span>
1002
+ <pre class="code"><span class="info file"># File 'ext/chess/chess.c', line 597</span>
979
1003
 
980
1004
  VALUE
981
1005
  board_fullmove_number (VALUE self)
@@ -987,6 +1011,119 @@ board_fullmove_number (VALUE self)
987
1011
  </td>
988
1012
  </tr>
989
1013
  </table>
1014
+ </div>
1015
+
1016
+ <div class="method_details ">
1017
+ <h3 class="signature " id="generate_all_moves-instance_method">
1018
+
1019
+ #<strong>generate_all_moves</strong> &#x21d2; <tt>Array&lt;String&gt;</tt>
1020
+
1021
+
1022
+
1023
+
1024
+
1025
+ </h3><div class="docstring">
1026
+ <div class="discussion">
1027
+
1028
+
1029
+ </div>
1030
+ </div>
1031
+ <div class="tags">
1032
+
1033
+ <div class="docstring">
1034
+ <div class="discussion">
1035
+
1036
+ <p>Generate all legal moves for the current board position.</p>
1037
+
1038
+
1039
+ </div>
1040
+ </div>
1041
+ <div class="tags">
1042
+
1043
+ <div class="examples">
1044
+ <p class="tag_title">Examples:</p>
1045
+
1046
+
1047
+ <pre class="example code"><code>:001 &gt; g = Chess::Game.new
1048
+ =&gt; #&lt;Chess::Game:0x007f88a529fa88&gt;
1049
+ :002 &gt; g.board.generate_all_moves
1050
+ =&gt; [&quot;Na3&quot;, &quot;Nc3&quot;, &quot;Nf3&quot;, &quot;Nh3&quot;, &quot;a3&quot;, &quot;a4&quot;, &quot;b3&quot;, &quot;b4&quot;, &quot;c3&quot;, &quot;c4&quot;, &quot;d3&quot;, &quot;d4&quot;, &quot;e3&quot;, &quot;e4&quot;, &quot;f3&quot;, &quot;f4&quot;, &quot;g3&quot;, &quot;g4&quot;, &quot;h3&quot;, &quot;h4&quot;]</code></pre>
1051
+
1052
+ </div>
1053
+
1054
+ <p class="tag_title">Returns:</p>
1055
+ <ul class="return">
1056
+
1057
+ <li>
1058
+
1059
+
1060
+ <span class='type'>(<tt>Array&lt;String&gt;</tt>)</span>
1061
+
1062
+
1063
+
1064
+ &mdash;
1065
+ <div class='inline'>
1066
+ <p>Returns all legal moves that can be performed in the current board position. The moves are in short algebraic chess notation format.</p>
1067
+ </div>
1068
+
1069
+ </li>
1070
+
1071
+ </ul>
1072
+
1073
+ </div>
1074
+
1075
+
1076
+ </div><table class="source_code">
1077
+ <tr>
1078
+ <td>
1079
+ <pre class="lines">
1080
+
1081
+
1082
+ 655
1083
+ 656
1084
+ 657
1085
+ 658
1086
+ 659
1087
+ 660
1088
+ 661
1089
+ 662
1090
+ 663
1091
+ 664
1092
+ 665
1093
+ 666
1094
+ 667
1095
+ 668
1096
+ 669
1097
+ 670
1098
+ 671
1099
+ 672
1100
+ 673</pre>
1101
+ </td>
1102
+ <td>
1103
+ <pre class="code"><span class="info file"># File 'ext/chess/chess.c', line 655</span>
1104
+
1105
+ VALUE
1106
+ board_generate_all_moves (VALUE self)
1107
+ {
1108
+ Board *board;
1109
+ Data_Get_Struct (self, Board, board);
1110
+ VALUE moves = rb_ary_new ();
1111
+ Board new_board;
1112
+ char *move_done;
1113
+ char capture;
1114
+ for (int i = 0; i &lt; 64; i++)
1115
+ for (int j = 0; j &lt; 64; j++)
1116
+ if (pseudo_legal_move (board, i, j))
1117
+ {
1118
+ move_done = castling (board, castling_type (board, i, j), &amp;new_board);
1119
+ if (move_done || try_move (board, i, j, &#39;Q&#39;, &amp;new_board, &amp;move_done, &amp;capture))
1120
+ rb_ary_push (moves, rb_str_new2 (move_done));
1121
+ }
1122
+ return moves;
1123
+ }</pre>
1124
+ </td>
1125
+ </tr>
1126
+ </table>
990
1127
  </div>
991
1128
 
992
1129
  <div class="method_details ">
@@ -1040,7 +1177,7 @@ board_fullmove_number (VALUE self)
1040
1177
 
1041
1178
  &mdash;
1042
1179
  <div class='inline'>
1043
- <p>The square of the <span class='object_link'><a href="" title="Chess::Board (class)">Chess::Board</a></span>. Can be an integer between 0 and 63 or a string like &#39;a2&#39;, &#39;c5&#39;…</p>
1180
+ <p>The square of the <span class='object_link'><a href="" title="Chess::Board (class)">Chess::Board</a></span>. Can be an integer between 0 and 63 or a string like a2’, c5’…</p>
1044
1181
  </div>
1045
1182
 
1046
1183
  </li>
@@ -1100,7 +1237,7 @@ board_fullmove_number (VALUE self)
1100
1237
  641</pre>
1101
1238
  </td>
1102
1239
  <td>
1103
- <pre class="code"><span class="info file"># File 'ext/chess.c', line 619</span>
1240
+ <pre class="code"><span class="info file"># File 'ext/chess/chess.c', line 619</span>
1104
1241
 
1105
1242
  VALUE
1106
1243
  board_generate_moves (VALUE self, VALUE square)
@@ -1189,7 +1326,7 @@ board_generate_moves (VALUE self, VALUE square)
1189
1326
  589</pre>
1190
1327
  </td>
1191
1328
  <td>
1192
- <pre class="code"><span class="info file"># File 'ext/chess.c', line 583</span>
1329
+ <pre class="code"><span class="info file"># File 'ext/chess/chess.c', line 583</span>
1193
1330
 
1194
1331
  VALUE
1195
1332
  board_halfmove_clock (VALUE self)
@@ -1265,7 +1402,7 @@ board_halfmove_clock (VALUE self)
1265
1402
  525</pre>
1266
1403
  </td>
1267
1404
  <td>
1268
- <pre class="code"><span class="info file"># File 'ext/chess.c', line 516</span>
1405
+ <pre class="code"><span class="info file"># File 'ext/chess/chess.c', line 516</span>
1269
1406
 
1270
1407
  VALUE
1271
1408
  board_insufficient_material (VALUE self)
@@ -1344,7 +1481,7 @@ board_insufficient_material (VALUE self)
1344
1481
  541</pre>
1345
1482
  </td>
1346
1483
  <td>
1347
- <pre class="code"><span class="info file"># File 'ext/chess.c', line 532</span>
1484
+ <pre class="code"><span class="info file"># File 'ext/chess/chess.c', line 532</span>
1348
1485
 
1349
1486
  VALUE
1350
1487
  board_only_kings (VALUE self)
@@ -1475,7 +1612,7 @@ board_only_kings (VALUE self)
1475
1612
  421</pre>
1476
1613
  </td>
1477
1614
  <td>
1478
- <pre class="code"><span class="info file"># File 'ext/chess.c', line 397</span>
1615
+ <pre class="code"><span class="info file"># File 'ext/chess/chess.c', line 397</span>
1479
1616
 
1480
1617
  VALUE
1481
1618
  board_placement (VALUE self)
@@ -1569,7 +1706,7 @@ board_placement (VALUE self)
1569
1706
  509</pre>
1570
1707
  </td>
1571
1708
  <td>
1572
- <pre class="code"><span class="info file"># File 'ext/chess.c', line 500</span>
1709
+ <pre class="code"><span class="info file"># File 'ext/chess/chess.c', line 500</span>
1573
1710
 
1574
1711
  VALUE
1575
1712
  board_stalemate (VALUE self)
@@ -1636,19 +1773,19 @@ board_stalemate (VALUE self)
1636
1773
  <pre class="lines">
1637
1774
 
1638
1775
 
1639
- 648
1640
- 649
1641
- 650
1642
- 651
1643
- 652
1644
- 653
1645
- 654
1646
- 655
1647
- 656
1648
- 657</pre>
1776
+ 680
1777
+ 681
1778
+ 682
1779
+ 683
1780
+ 684
1781
+ 685
1782
+ 686
1783
+ 687
1784
+ 688
1785
+ 689</pre>
1649
1786
  </td>
1650
1787
  <td>
1651
- <pre class="code"><span class="info file"># File 'ext/chess.c', line 648</span>
1788
+ <pre class="code"><span class="info file"># File 'ext/chess/chess.c', line 680</span>
1652
1789
 
1653
1790
  VALUE
1654
1791
  board_to_fen (VALUE self)
@@ -1715,19 +1852,19 @@ board_to_fen (VALUE self)
1715
1852
  <pre class="lines">
1716
1853
 
1717
1854
 
1718
- 664
1719
- 665
1720
- 666
1721
- 667
1722
- 668
1723
- 669
1724
- 670
1725
- 671
1726
- 672
1727
- 673</pre>
1855
+ 696
1856
+ 697
1857
+ 698
1858
+ 699
1859
+ 700
1860
+ 701
1861
+ 702
1862
+ 703
1863
+ 704
1864
+ 705</pre>
1728
1865
  </td>
1729
1866
  <td>
1730
- <pre class="code"><span class="info file"># File 'ext/chess.c', line 664</span>
1867
+ <pre class="code"><span class="info file"># File 'ext/chess/chess.c', line 696</span>
1731
1868
 
1732
1869
  VALUE
1733
1870
  board_to_s (VALUE self)
@@ -1749,9 +1886,9 @@ board_to_s (VALUE self)
1749
1886
  </div>
1750
1887
 
1751
1888
  <div id="footer">
1752
- Generated on Thu Jan 28 17:31:41 2021 by
1753
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1754
- 0.9.26 (ruby-2.6.1).
1889
+ Generated on Fri Aug 30 11:09:51 2024 by
1890
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1891
+ 0.9.36 (ruby-3.3.2).
1755
1892
  </div>
1756
1893
 
1757
1894
  </div>