chess 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -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>
@@ -0,0 +1,237 @@
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
+ Exception: Chess::BadNotationError
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::BadNotationError";
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 (B)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Chess.html" title="Chess (module)">Chess</a></span></span>
41
+ &raquo;
42
+ <span class="title">BadNotationError</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>Exception: Chess::BadNotationError
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">StandardError</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">StandardError</li>
78
+
79
+ <li class="next">Chess::BadNotationError</li>
80
+
81
+ </ul>
82
+ <a href="#" class="inheritanceTree">show all</a>
83
+
84
+ </dd>
85
+ </dl>
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+ <dl>
98
+ <dt>Defined in:</dt>
99
+ <dd>lib/chess/exceptions.rb</dd>
100
+ </dl>
101
+
102
+ </div>
103
+
104
+ <h2>Overview</h2><div class="docstring">
105
+ <div class="discussion">
106
+
107
+ <p>This exception will be raised when an invalid short algebraic chess notation string is passed to the <span class='object_link'><a href="Game.html#move-instance_method" title="Chess::Game#move (method)">Game#move</a></span> function.</p>
108
+
109
+
110
+ </div>
111
+ </div>
112
+ <div class="tags">
113
+
114
+
115
+ </div>
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+ <h2>
124
+ Instance Method Summary
125
+ <small><a href="#" class="summary_toggle">collapse</a></small>
126
+ </h2>
127
+
128
+ <ul class="summary">
129
+
130
+ <li class="public ">
131
+ <span class="summary_signature">
132
+
133
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(notation) &#x21d2; BadNotationError </a>
134
+
135
+
136
+
137
+ </span>
138
+
139
+
140
+ <span class="note title constructor">constructor</span>
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+ <span class="summary_desc"><div class='inline'>
150
+ <p>A new instance of BadNotationError.</p>
151
+ </div></span>
152
+
153
+ </li>
154
+
155
+
156
+ </ul>
157
+
158
+
159
+
160
+ <div id="constructor_details" class="method_details_list">
161
+ <h2>Constructor Details</h2>
162
+
163
+ <div class="method_details first">
164
+ <h3 class="signature first" id="initialize-instance_method">
165
+
166
+ #<strong>initialize</strong>(notation) &#x21d2; <tt><span class='object_link'><a href="" title="Chess::BadNotationError (class)">BadNotationError</a></span></tt>
167
+
168
+
169
+
170
+
171
+
172
+ </h3><div class="docstring">
173
+ <div class="discussion">
174
+
175
+ <p>Returns a new instance of BadNotationError.</p>
176
+
177
+
178
+ </div>
179
+ </div>
180
+ <div class="tags">
181
+ <p class="tag_title">Parameters:</p>
182
+ <ul class="param">
183
+
184
+ <li>
185
+
186
+ <span class='name'>notation</span>
187
+
188
+
189
+ <span class='type'>(<tt>String</tt>)</span>
190
+
191
+
192
+
193
+ &mdash;
194
+ <div class='inline'>
195
+ <p>The invalid notation.</p>
196
+ </div>
197
+
198
+ </li>
199
+
200
+ </ul>
201
+
202
+
203
+ </div><table class="source_code">
204
+ <tr>
205
+ <td>
206
+ <pre class="lines">
207
+
208
+
209
+ 6
210
+ 7
211
+ 8</pre>
212
+ </td>
213
+ <td>
214
+ <pre class="code"><span class="info file"># File 'lib/chess/exceptions.rb', line 6</span>
215
+
216
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_notation'>notation</span><span class='rparen'>)</span>
217
+ <span class='kw'>super</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Invalid notation &#39;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_notation'>notation</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
218
+ <span class='kw'>end</span></pre>
219
+ </td>
220
+ </tr>
221
+ </table>
222
+ </div>
223
+
224
+ </div>
225
+
226
+
227
+ </div>
228
+
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).
233
+ </div>
234
+
235
+ </div>
236
+ </body>
237
+ </html>
@@ -0,0 +1,1759 @@
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
+ Class: Chess::Board
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::Board";
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 (B)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Chess.html" title="Chess (module)">Chess</a></span></span>
41
+ &raquo;
42
+ <span class="title">Board</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>Class: Chess::Board
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">Chess::Board</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dl>
96
+ <dt>Defined in:</dt>
97
+ <dd>ext/chess.c<span class="defines">,<br />
98
+ ext/chess.c</span>
99
+ </dd>
100
+ </dl>
101
+
102
+ </div>
103
+
104
+ <h2>Overview</h2><div class="docstring">
105
+ <div class="discussion">
106
+
107
+ <p>This class rappresents a chess board. The rappresentation of the board use <em>bitboards</em> where each bit represents a game position or state, designed for optimization of speed and/or memory or disk use in mass calculations. This ensures a fast library.</p>
108
+
109
+
110
+ </div>
111
+ </div>
112
+ <div class="tags">
113
+
114
+
115
+ </div>
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+ <h2>
124
+ Instance Method Summary
125
+ <small><a href="#" class="summary_toggle">collapse</a></small>
126
+ </h2>
127
+
128
+ <ul class="summary">
129
+
130
+ <li class="public ">
131
+ <span class="summary_signature">
132
+
133
+ <a href="#[]-instance_method" title="#[] (instance method)">#<strong>[]</strong>(square) &#x21d2; String </a>
134
+
135
+
136
+
137
+ </span>
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+ <span class="summary_desc"><div class='inline'>
148
+ <p>Returns the piece on the <code>square</code> of the chessboard.</p>
149
+ </div></span>
150
+
151
+ </li>
152
+
153
+
154
+ <li class="public ">
155
+ <span class="summary_signature">
156
+
157
+ <a href="#active_color-instance_method" title="#active_color (instance method)">#<strong>active_color</strong> &#x21d2; Boolean </a>
158
+
159
+
160
+
161
+ </span>
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+ <span class="summary_desc"><div class='inline'>
172
+ <p>Returns the active color: <code>false</code> means white turn, <code>true</code> means black turn.</p>
173
+ </div></span>
174
+
175
+ </li>
176
+
177
+
178
+ <li class="public ">
179
+ <span class="summary_signature">
180
+
181
+ <a href="#check%3F-instance_method" title="#check? (instance method)">#<strong>check?</strong> &#x21d2; Boolean </a>
182
+
183
+
184
+
185
+ </span>
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+ <span class="summary_desc"><div class='inline'>
196
+ <p>Returns <code>true</code> if the king of the color that has the turn is in check, <code>false</code> otherwise.</p>
197
+ </div></span>
198
+
199
+ </li>
200
+
201
+
202
+ <li class="public ">
203
+ <span class="summary_signature">
204
+
205
+ <a href="#checkmate%3F-instance_method" title="#checkmate? (instance method)">#<strong>checkmate?</strong> &#x21d2; Boolean </a>
206
+
207
+
208
+
209
+ </span>
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+ <span class="summary_desc"><div class='inline'>
220
+ <p>Returns <code>true</code> if the king of the color that has the turn is in checkmate, <code>false</code> otherwise.</p>
221
+ </div></span>
222
+
223
+ </li>
224
+
225
+
226
+ <li class="public ">
227
+ <span class="summary_signature">
228
+
229
+ <a href="#fifty_move_rule%3F-instance_method" title="#fifty_move_rule? (instance method)">#<strong>fifty_move_rule?</strong> &#x21d2; Boolean </a>
230
+
231
+
232
+
233
+ </span>
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+ <span class="summary_desc"><div class='inline'>
244
+ <p>Returns <code>true</code> if a player can claim draw by the fifty-move rule, <code>false</code> otherwise.</p>
245
+ </div></span>
246
+
247
+ </li>
248
+
249
+
250
+ <li class="public ">
251
+ <span class="summary_signature">
252
+
253
+ <a href="#fullmove_number-instance_method" title="#fullmove_number (instance method)">#<strong>fullmove_number</strong> &#x21d2; Integer </a>
254
+
255
+
256
+
257
+ </span>
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+ <span class="summary_desc"><div class='inline'>
268
+ <p>Returns the fullmove number: the number of the full move.</p>
269
+ </div></span>
270
+
271
+ </li>
272
+
273
+
274
+ <li class="public ">
275
+ <span class="summary_signature">
276
+
277
+ <a href="#generate_moves-instance_method" title="#generate_moves (instance method)">#<strong>generate_moves</strong>(square) &#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 piece in <code>square</code> position.</p>
293
+ </div></span>
294
+
295
+ </li>
296
+
297
+
298
+ <li class="public ">
299
+ <span class="summary_signature">
300
+
301
+ <a href="#halfmove_clock-instance_method" title="#halfmove_clock (instance method)">#<strong>halfmove_clock</strong> &#x21d2; Integer </a>
302
+
303
+
304
+
305
+ </span>
306
+
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+
315
+ <span class="summary_desc"><div class='inline'>
316
+ <p>Returns the halfmove clock that is the number of halfmoves since the last pawn advance or capture.</p>
317
+ </div></span>
318
+
319
+ </li>
320
+
321
+
322
+ <li class="public ">
323
+ <span class="summary_signature">
324
+
325
+ <a href="#insufficient_material%3F-instance_method" title="#insufficient_material? (instance method)">#<strong>insufficient_material?</strong> &#x21d2; Boolean </a>
326
+
327
+
328
+
329
+ </span>
330
+
331
+
332
+
333
+
334
+
335
+
336
+
337
+
338
+
339
+ <span class="summary_desc"><div class='inline'>
340
+ <p>Returns <code>true</code> if the board has insufficient material to checkmate, <code>false</code> otherwise.</p>
341
+ </div></span>
342
+
343
+ </li>
344
+
345
+
346
+ <li class="public ">
347
+ <span class="summary_signature">
348
+
349
+ <a href="#only_kings%3F-instance_method" title="#only_kings? (instance method)">#<strong>only_kings?</strong> &#x21d2; Boolean </a>
350
+
351
+
352
+
353
+ </span>
354
+
355
+
356
+
357
+
358
+
359
+
360
+
361
+
362
+
363
+ <span class="summary_desc"><div class='inline'>
364
+ <p>Returns <code>true</code> if on the board there are only the two kings, <code>false</code> otherwise.</p>
365
+ </div></span>
366
+
367
+ </li>
368
+
369
+
370
+ <li class="public ">
371
+ <span class="summary_signature">
372
+
373
+ <a href="#placement-instance_method" title="#placement (instance method)">#<strong>placement</strong> {|piece, index| ... } &#x21d2; Board, Array&lt;String&gt; </a>
374
+
375
+
376
+
377
+ </span>
378
+
379
+
380
+
381
+
382
+
383
+
384
+
385
+
386
+
387
+ <span class="summary_desc"><div class='inline'>
388
+ <p>Cycle the <span class='object_link'><a href="" title="Chess::Board (class)">Board</a></span> squares.</p>
389
+ </div></span>
390
+
391
+ </li>
392
+
393
+
394
+ <li class="public ">
395
+ <span class="summary_signature">
396
+
397
+ <a href="#stalemate%3F-instance_method" title="#stalemate? (instance method)">#<strong>stalemate?</strong> &#x21d2; Boolean </a>
398
+
399
+
400
+
401
+ </span>
402
+
403
+
404
+
405
+
406
+
407
+
408
+
409
+
410
+
411
+ <span class="summary_desc"><div class='inline'>
412
+ <p>Returns <code>true</code> if the pieces of the color that has the turn are in stalemate, <code>false</code> otherwise.</p>
413
+ </div></span>
414
+
415
+ </li>
416
+
417
+
418
+ <li class="public ">
419
+ <span class="summary_signature">
420
+
421
+ <a href="#to_fen-instance_method" title="#to_fen (instance method)">#<strong>to_fen</strong> &#x21d2; String </a>
422
+
423
+
424
+
425
+ </span>
426
+
427
+
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+ <span class="summary_desc"><div class='inline'>
436
+ <p>Returns the FEN string of the board.</p>
437
+ </div></span>
438
+
439
+ </li>
440
+
441
+
442
+ <li class="public ">
443
+ <span class="summary_signature">
444
+
445
+ <a href="#to_s-instance_method" title="#to_s (instance method)">#<strong>to_s</strong> &#x21d2; String </a>
446
+
447
+
448
+
449
+ </span>
450
+
451
+
452
+
453
+
454
+
455
+
456
+
457
+
458
+
459
+ <span class="summary_desc"><div class='inline'>
460
+ <p><span class='object_link'><a href="" title="Chess::Board (class)">Board</a></span> to string.</p>
461
+ </div></span>
462
+
463
+ </li>
464
+
465
+
466
+ </ul>
467
+
468
+
469
+
470
+
471
+ <div id="instance_method_details" class="method_details_list">
472
+ <h2>Instance Method Details</h2>
473
+
474
+
475
+ <div class="method_details first">
476
+ <h3 class="signature first" id="[]-instance_method">
477
+
478
+ #<strong>[]</strong>(square) &#x21d2; <tt>String</tt>
479
+
480
+
481
+
482
+
483
+
484
+ </h3><div class="docstring">
485
+ <div class="discussion">
486
+
487
+
488
+ </div>
489
+ </div>
490
+ <div class="tags">
491
+
492
+ <div class="docstring">
493
+ <div class="discussion">
494
+
495
+ <p>Returns the piece on the <code>square</code> of the chessboard. If there is no piece or the square is not valid return <code>nil</code>. Each square on the chessboard is represented by an integer according to the following scheme:</p>
496
+
497
+ <pre class="code"><code class="">8 | 56 57 58 59 60 61 62 63
498
+ 7 | 48 49 50 51 52 53 54 55
499
+ 6 | 40 41 42 43 44 45 46 47
500
+ 5 | 32 33 34 35 36 37 38 39
501
+ 4 | 24 25 26 27 28 29 30 31
502
+ 3 | 16 17 18 19 20 21 22 23
503
+ 2 | 8 9 10 11 12 13 14 15
504
+ 1 | 0 1 2 3 4 5 6 7
505
+ +-------------------------
506
+ a b c d e f g h
507
+ </code></pre>
508
+
509
+
510
+ </div>
511
+ </div>
512
+ <div class="tags">
513
+ <p class="tag_title">Parameters:</p>
514
+ <ul class="param">
515
+
516
+ <li>
517
+
518
+ <span class='name'>square</span>
519
+
520
+
521
+ <span class='type'>(<tt>Integer</tt>, <tt>String</tt>)</span>
522
+
523
+
524
+
525
+ &mdash;
526
+ <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>
528
+ </div>
529
+
530
+ </li>
531
+
532
+ </ul>
533
+
534
+ <p class="tag_title">Returns:</p>
535
+ <ul class="return">
536
+
537
+ <li>
538
+
539
+
540
+ <span class='type'>(<tt>String</tt>)</span>
541
+
542
+
543
+
544
+ &mdash;
545
+ <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>
547
+ </div>
548
+
549
+ </li>
550
+
551
+ </ul>
552
+
553
+ </div>
554
+
555
+
556
+ </div><table class="source_code">
557
+ <tr>
558
+ <td>
559
+ <pre class="lines">
560
+
561
+
562
+ 446
563
+ 447
564
+ 448
565
+ 449
566
+ 450
567
+ 451
568
+ 452
569
+ 453
570
+ 454
571
+ 455
572
+ 456
573
+ 457
574
+ 458
575
+ 459
576
+ 460
577
+ 461</pre>
578
+ </td>
579
+ <td>
580
+ <pre class="code"><span class="info file"># File 'ext/chess.c', line 446</span>
581
+
582
+ VALUE
583
+ board_get_piece (VALUE self, VALUE square)
584
+ {
585
+ Board *board;
586
+ Data_Get_Struct (self, Board, board);
587
+ int i;
588
+ if (TYPE (square) == T_STRING)
589
+ i = coord_to_square (StringValuePtr (square));
590
+ else
591
+ i = FIX2INT (square);
592
+ char piece = board-&gt;placement[i];
593
+ if (i &lt; 0 || i &gt; 63 || !piece)
594
+ return Qnil;
595
+ else
596
+ return rb_str_new (&amp;piece, 1);
597
+ }</pre>
598
+ </td>
599
+ </tr>
600
+ </table>
601
+ </div>
602
+
603
+ <div class="method_details ">
604
+ <h3 class="signature " id="active_color-instance_method">
605
+
606
+ #<strong>active_color</strong> &#x21d2; <tt>Boolean</tt>
607
+
608
+
609
+
610
+
611
+
612
+ </h3><div class="docstring">
613
+ <div class="discussion">
614
+
615
+
616
+ </div>
617
+ </div>
618
+ <div class="tags">
619
+
620
+ <div class="docstring">
621
+ <div class="discussion">
622
+
623
+ <p>Returns the active color: <code>false</code> means white turn, <code>true</code> means black turn.</p>
624
+
625
+
626
+ </div>
627
+ </div>
628
+ <div class="tags">
629
+
630
+ <p class="tag_title">Returns:</p>
631
+ <ul class="return">
632
+
633
+ <li>
634
+
635
+
636
+ <span class='type'>(<tt>Boolean</tt>)</span>
637
+
638
+
639
+
640
+ </li>
641
+
642
+ </ul>
643
+
644
+ </div>
645
+
646
+
647
+ </div><table class="source_code">
648
+ <tr>
649
+ <td>
650
+ <pre class="lines">
651
+
652
+
653
+ 565
654
+ 566
655
+ 567
656
+ 568
657
+ 569
658
+ 570
659
+ 571
660
+ 572
661
+ 573
662
+ 574</pre>
663
+ </td>
664
+ <td>
665
+ <pre class="code"><span class="info file"># File 'ext/chess.c', line 565</span>
666
+
667
+ VALUE
668
+ board_active_color (VALUE self)
669
+ {
670
+ Board *board;
671
+ Data_Get_Struct (self, Board, board);
672
+ if (board-&gt;active_color)
673
+ return Qtrue;
674
+ else
675
+ return Qfalse;
676
+ }</pre>
677
+ </td>
678
+ </tr>
679
+ </table>
680
+ </div>
681
+
682
+ <div class="method_details ">
683
+ <h3 class="signature " id="check?-instance_method">
684
+
685
+ #<strong>check?</strong> &#x21d2; <tt>Boolean</tt>
686
+
687
+
688
+
689
+
690
+
691
+ </h3><div class="docstring">
692
+ <div class="discussion">
693
+
694
+
695
+ </div>
696
+ </div>
697
+ <div class="tags">
698
+
699
+ <div class="docstring">
700
+ <div class="discussion">
701
+
702
+ <p>Returns <code>true</code> if the king of the color that has the turn is in check, <code>false</code> otherwise.</p>
703
+
704
+
705
+ </div>
706
+ </div>
707
+ <div class="tags">
708
+
709
+
710
+ </div>
711
+
712
+ <p class="tag_title">Returns:</p>
713
+ <ul class="return">
714
+
715
+ <li>
716
+
717
+
718
+ <span class='type'>(<tt>Boolean</tt>)</span>
719
+
720
+
721
+
722
+ </li>
723
+
724
+ </ul>
725
+
726
+ </div><table class="source_code">
727
+ <tr>
728
+ <td>
729
+ <pre class="lines">
730
+
731
+
732
+ 468
733
+ 469
734
+ 470
735
+ 471
736
+ 472
737
+ 473
738
+ 474
739
+ 475
740
+ 476
741
+ 477</pre>
742
+ </td>
743
+ <td>
744
+ <pre class="code"><span class="info file"># File 'ext/chess.c', line 468</span>
745
+
746
+ VALUE
747
+ board_king_in_check (VALUE self)
748
+ {
749
+ Board *board;
750
+ Data_Get_Struct (self, Board, board);
751
+ if (king_in_check (board, board-&gt;active_color))
752
+ return Qtrue;
753
+ else
754
+ return Qfalse;
755
+ }</pre>
756
+ </td>
757
+ </tr>
758
+ </table>
759
+ </div>
760
+
761
+ <div class="method_details ">
762
+ <h3 class="signature " id="checkmate?-instance_method">
763
+
764
+ #<strong>checkmate?</strong> &#x21d2; <tt>Boolean</tt>
765
+
766
+
767
+
768
+
769
+
770
+ </h3><div class="docstring">
771
+ <div class="discussion">
772
+
773
+
774
+ </div>
775
+ </div>
776
+ <div class="tags">
777
+
778
+ <div class="docstring">
779
+ <div class="discussion">
780
+
781
+ <p>Returns <code>true</code> if the king of the color that has the turn is in checkmate, <code>false</code> otherwise.</p>
782
+
783
+
784
+ </div>
785
+ </div>
786
+ <div class="tags">
787
+
788
+
789
+ </div>
790
+
791
+ <p class="tag_title">Returns:</p>
792
+ <ul class="return">
793
+
794
+ <li>
795
+
796
+
797
+ <span class='type'>(<tt>Boolean</tt>)</span>
798
+
799
+
800
+
801
+ </li>
802
+
803
+ </ul>
804
+
805
+ </div><table class="source_code">
806
+ <tr>
807
+ <td>
808
+ <pre class="lines">
809
+
810
+
811
+ 484
812
+ 485
813
+ 486
814
+ 487
815
+ 488
816
+ 489
817
+ 490
818
+ 491
819
+ 492
820
+ 493</pre>
821
+ </td>
822
+ <td>
823
+ <pre class="code"><span class="info file"># File 'ext/chess.c', line 484</span>
824
+
825
+ VALUE
826
+ board_king_in_checkmate (VALUE self)
827
+ {
828
+ Board *board;
829
+ Data_Get_Struct (self, Board, board);
830
+ if (king_in_checkmate (board, board-&gt;active_color))
831
+ return Qtrue;
832
+ else
833
+ return Qfalse;
834
+ }</pre>
835
+ </td>
836
+ </tr>
837
+ </table>
838
+ </div>
839
+
840
+ <div class="method_details ">
841
+ <h3 class="signature " id="fifty_move_rule?-instance_method">
842
+
843
+ #<strong>fifty_move_rule?</strong> &#x21d2; <tt>Boolean</tt>
844
+
845
+
846
+
847
+
848
+
849
+ </h3><div class="docstring">
850
+ <div class="discussion">
851
+
852
+
853
+ </div>
854
+ </div>
855
+ <div class="tags">
856
+
857
+ <div class="docstring">
858
+ <div class="discussion">
859
+
860
+ <p>Returns <code>true</code> if a player can claim draw by the fifty-move rule, <code>false</code> otherwise.</p>
861
+
862
+
863
+ </div>
864
+ </div>
865
+ <div class="tags">
866
+
867
+
868
+ </div>
869
+
870
+ <p class="tag_title">Returns:</p>
871
+ <ul class="return">
872
+
873
+ <li>
874
+
875
+
876
+ <span class='type'>(<tt>Boolean</tt>)</span>
877
+
878
+
879
+
880
+ </li>
881
+
882
+ </ul>
883
+
884
+ </div><table class="source_code">
885
+ <tr>
886
+ <td>
887
+ <pre class="lines">
888
+
889
+
890
+ 548
891
+ 549
892
+ 550
893
+ 551
894
+ 552
895
+ 553
896
+ 554
897
+ 555
898
+ 556
899
+ 557</pre>
900
+ </td>
901
+ <td>
902
+ <pre class="code"><span class="info file"># File 'ext/chess.c', line 548</span>
903
+
904
+ VALUE
905
+ board_fifty_move_rule (VALUE self)
906
+ {
907
+ Board *board;
908
+ Data_Get_Struct (self, Board, board);
909
+ if (fifty_move_rule (board))
910
+ return Qtrue;
911
+ else
912
+ return Qfalse;
913
+ }</pre>
914
+ </td>
915
+ </tr>
916
+ </table>
917
+ </div>
918
+
919
+ <div class="method_details ">
920
+ <h3 class="signature " id="fullmove_number-instance_method">
921
+
922
+ #<strong>fullmove_number</strong> &#x21d2; <tt>Integer</tt>
923
+
924
+
925
+
926
+
927
+
928
+ </h3><div class="docstring">
929
+ <div class="discussion">
930
+
931
+
932
+ </div>
933
+ </div>
934
+ <div class="tags">
935
+
936
+ <div class="docstring">
937
+ <div class="discussion">
938
+
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>
940
+
941
+
942
+ </div>
943
+ </div>
944
+ <div class="tags">
945
+
946
+ <p class="tag_title">Returns:</p>
947
+ <ul class="return">
948
+
949
+ <li>
950
+
951
+
952
+ <span class='type'>(<tt>Integer</tt>)</span>
953
+
954
+
955
+
956
+ </li>
957
+
958
+ </ul>
959
+
960
+ </div>
961
+
962
+
963
+ </div><table class="source_code">
964
+ <tr>
965
+ <td>
966
+ <pre class="lines">
967
+
968
+
969
+ 597
970
+ 598
971
+ 599
972
+ 600
973
+ 601
974
+ 602
975
+ 603</pre>
976
+ </td>
977
+ <td>
978
+ <pre class="code"><span class="info file"># File 'ext/chess.c', line 597</span>
979
+
980
+ VALUE
981
+ board_fullmove_number (VALUE self)
982
+ {
983
+ Board *board;
984
+ Data_Get_Struct (self, Board, board);
985
+ return INT2FIX (board-&gt;fullmove_number);
986
+ }</pre>
987
+ </td>
988
+ </tr>
989
+ </table>
990
+ </div>
991
+
992
+ <div class="method_details ">
993
+ <h3 class="signature " id="generate_moves-instance_method">
994
+
995
+ #<strong>generate_moves</strong>(square) &#x21d2; <tt>Array&lt;String&gt;</tt>
996
+
997
+
998
+
999
+
1000
+
1001
+ </h3><div class="docstring">
1002
+ <div class="discussion">
1003
+
1004
+
1005
+ </div>
1006
+ </div>
1007
+ <div class="tags">
1008
+
1009
+ <div class="docstring">
1010
+ <div class="discussion">
1011
+
1012
+ <p>Generate all legal moves for the piece in <code>square</code> position.</p>
1013
+
1014
+
1015
+ </div>
1016
+ </div>
1017
+ <div class="tags">
1018
+
1019
+ <div class="examples">
1020
+ <p class="tag_title">Examples:</p>
1021
+
1022
+
1023
+ <pre class="example code"><code>:001 &gt; g = Chess::Game.new
1024
+ =&gt; #&lt;Chess::Game:0x007f88a529fa88&gt;
1025
+ :002 &gt; g.board.generate_moves(&#39;b1&#39;)
1026
+ =&gt; [&quot;Na3&quot;, &quot;Nc3&quot;]</code></pre>
1027
+
1028
+ </div>
1029
+ <p class="tag_title">Parameters:</p>
1030
+ <ul class="param">
1031
+
1032
+ <li>
1033
+
1034
+ <span class='name'>square</span>
1035
+
1036
+
1037
+ <span class='type'>(<tt>Integer</tt>, <tt>String</tt>)</span>
1038
+
1039
+
1040
+
1041
+ &mdash;
1042
+ <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>
1044
+ </div>
1045
+
1046
+ </li>
1047
+
1048
+ </ul>
1049
+
1050
+ <p class="tag_title">Returns:</p>
1051
+ <ul class="return">
1052
+
1053
+ <li>
1054
+
1055
+
1056
+ <span class='type'>(<tt>Array&lt;String&gt;</tt>)</span>
1057
+
1058
+
1059
+
1060
+ &mdash;
1061
+ <div class='inline'>
1062
+ <p>Returns all legal moves that the piece in <code>square</code> position can perform. The moves are in short algebraic chess notation format.</p>
1063
+ </div>
1064
+
1065
+ </li>
1066
+
1067
+ </ul>
1068
+
1069
+ </div>
1070
+
1071
+
1072
+ </div><table class="source_code">
1073
+ <tr>
1074
+ <td>
1075
+ <pre class="lines">
1076
+
1077
+
1078
+ 619
1079
+ 620
1080
+ 621
1081
+ 622
1082
+ 623
1083
+ 624
1084
+ 625
1085
+ 626
1086
+ 627
1087
+ 628
1088
+ 629
1089
+ 630
1090
+ 631
1091
+ 632
1092
+ 633
1093
+ 634
1094
+ 635
1095
+ 636
1096
+ 637
1097
+ 638
1098
+ 639
1099
+ 640
1100
+ 641</pre>
1101
+ </td>
1102
+ <td>
1103
+ <pre class="code"><span class="info file"># File 'ext/chess.c', line 619</span>
1104
+
1105
+ VALUE
1106
+ board_generate_moves (VALUE self, VALUE square)
1107
+ {
1108
+ Board *board;
1109
+ Data_Get_Struct (self, Board, board);
1110
+ int from;
1111
+ if (TYPE (square) == T_STRING)
1112
+ from = coord_to_square (StringValuePtr (square));
1113
+ else
1114
+ from = FIX2INT (square);
1115
+ VALUE moves = rb_ary_new ();
1116
+ Board new_board;
1117
+ char *move_done;
1118
+ char capture;
1119
+ for (int i = 0; i &lt; 64; i++)
1120
+ if (pseudo_legal_move (board, from, i))
1121
+ {
1122
+ move_done = castling (board, castling_type (board, from, i), &amp;new_board);
1123
+ if (move_done || try_move (board, from, i, &#39;Q&#39;, &amp;new_board, &amp;move_done, &amp;capture))
1124
+ rb_ary_push (moves, rb_str_new2 (move_done));
1125
+ }
1126
+ return moves;
1127
+ }</pre>
1128
+ </td>
1129
+ </tr>
1130
+ </table>
1131
+ </div>
1132
+
1133
+ <div class="method_details ">
1134
+ <h3 class="signature " id="halfmove_clock-instance_method">
1135
+
1136
+ #<strong>halfmove_clock</strong> &#x21d2; <tt>Integer</tt>
1137
+
1138
+
1139
+
1140
+
1141
+
1142
+ </h3><div class="docstring">
1143
+ <div class="discussion">
1144
+
1145
+
1146
+ </div>
1147
+ </div>
1148
+ <div class="tags">
1149
+
1150
+ <div class="docstring">
1151
+ <div class="discussion">
1152
+
1153
+ <p>Returns the halfmove clock that is the number of halfmoves since the last pawn advance or capture. This is used to determine if a draw can be claimed under the fifty-move rule.</p>
1154
+
1155
+
1156
+ </div>
1157
+ </div>
1158
+ <div class="tags">
1159
+
1160
+ <p class="tag_title">Returns:</p>
1161
+ <ul class="return">
1162
+
1163
+ <li>
1164
+
1165
+
1166
+ <span class='type'>(<tt>Integer</tt>)</span>
1167
+
1168
+
1169
+
1170
+ </li>
1171
+
1172
+ </ul>
1173
+
1174
+ </div>
1175
+
1176
+
1177
+ </div><table class="source_code">
1178
+ <tr>
1179
+ <td>
1180
+ <pre class="lines">
1181
+
1182
+
1183
+ 583
1184
+ 584
1185
+ 585
1186
+ 586
1187
+ 587
1188
+ 588
1189
+ 589</pre>
1190
+ </td>
1191
+ <td>
1192
+ <pre class="code"><span class="info file"># File 'ext/chess.c', line 583</span>
1193
+
1194
+ VALUE
1195
+ board_halfmove_clock (VALUE self)
1196
+ {
1197
+ Board *board;
1198
+ Data_Get_Struct (self, Board, board);
1199
+ return INT2FIX (board-&gt;halfmove_clock);
1200
+ }</pre>
1201
+ </td>
1202
+ </tr>
1203
+ </table>
1204
+ </div>
1205
+
1206
+ <div class="method_details ">
1207
+ <h3 class="signature " id="insufficient_material?-instance_method">
1208
+
1209
+ #<strong>insufficient_material?</strong> &#x21d2; <tt>Boolean</tt>
1210
+
1211
+
1212
+
1213
+
1214
+
1215
+ </h3><div class="docstring">
1216
+ <div class="discussion">
1217
+
1218
+
1219
+ </div>
1220
+ </div>
1221
+ <div class="tags">
1222
+
1223
+ <div class="docstring">
1224
+ <div class="discussion">
1225
+
1226
+ <p>Returns <code>true</code> if the board has insufficient material to checkmate, <code>false</code> otherwise.</p>
1227
+
1228
+
1229
+ </div>
1230
+ </div>
1231
+ <div class="tags">
1232
+
1233
+
1234
+ </div>
1235
+
1236
+ <p class="tag_title">Returns:</p>
1237
+ <ul class="return">
1238
+
1239
+ <li>
1240
+
1241
+
1242
+ <span class='type'>(<tt>Boolean</tt>)</span>
1243
+
1244
+
1245
+
1246
+ </li>
1247
+
1248
+ </ul>
1249
+
1250
+ </div><table class="source_code">
1251
+ <tr>
1252
+ <td>
1253
+ <pre class="lines">
1254
+
1255
+
1256
+ 516
1257
+ 517
1258
+ 518
1259
+ 519
1260
+ 520
1261
+ 521
1262
+ 522
1263
+ 523
1264
+ 524
1265
+ 525</pre>
1266
+ </td>
1267
+ <td>
1268
+ <pre class="code"><span class="info file"># File 'ext/chess.c', line 516</span>
1269
+
1270
+ VALUE
1271
+ board_insufficient_material (VALUE self)
1272
+ {
1273
+ Board *board;
1274
+ Data_Get_Struct (self, Board, board);
1275
+ if (insufficient_material (board))
1276
+ return Qtrue;
1277
+ else
1278
+ return Qfalse;
1279
+ }</pre>
1280
+ </td>
1281
+ </tr>
1282
+ </table>
1283
+ </div>
1284
+
1285
+ <div class="method_details ">
1286
+ <h3 class="signature " id="only_kings?-instance_method">
1287
+
1288
+ #<strong>only_kings?</strong> &#x21d2; <tt>Boolean</tt>
1289
+
1290
+
1291
+
1292
+
1293
+
1294
+ </h3><div class="docstring">
1295
+ <div class="discussion">
1296
+
1297
+
1298
+ </div>
1299
+ </div>
1300
+ <div class="tags">
1301
+
1302
+ <div class="docstring">
1303
+ <div class="discussion">
1304
+
1305
+ <p>Returns <code>true</code> if on the board there are only the two kings, <code>false</code> otherwise.</p>
1306
+
1307
+
1308
+ </div>
1309
+ </div>
1310
+ <div class="tags">
1311
+
1312
+
1313
+ </div>
1314
+
1315
+ <p class="tag_title">Returns:</p>
1316
+ <ul class="return">
1317
+
1318
+ <li>
1319
+
1320
+
1321
+ <span class='type'>(<tt>Boolean</tt>)</span>
1322
+
1323
+
1324
+
1325
+ </li>
1326
+
1327
+ </ul>
1328
+
1329
+ </div><table class="source_code">
1330
+ <tr>
1331
+ <td>
1332
+ <pre class="lines">
1333
+
1334
+
1335
+ 532
1336
+ 533
1337
+ 534
1338
+ 535
1339
+ 536
1340
+ 537
1341
+ 538
1342
+ 539
1343
+ 540
1344
+ 541</pre>
1345
+ </td>
1346
+ <td>
1347
+ <pre class="code"><span class="info file"># File 'ext/chess.c', line 532</span>
1348
+
1349
+ VALUE
1350
+ board_only_kings (VALUE self)
1351
+ {
1352
+ Board *board;
1353
+ Data_Get_Struct (self, Board, board);
1354
+ if (only_kings (board))
1355
+ return Qtrue;
1356
+ else
1357
+ return Qfalse;
1358
+ }</pre>
1359
+ </td>
1360
+ </tr>
1361
+ </table>
1362
+ </div>
1363
+
1364
+ <div class="method_details ">
1365
+ <h3 class="signature " id="placement-instance_method">
1366
+
1367
+ #<strong>placement</strong> {|piece, index| ... } &#x21d2; <tt><span class='object_link'><a href="" title="Chess::Board (class)">Board</a></span></tt>, <tt>Array&lt;String&gt;</tt>
1368
+
1369
+
1370
+
1371
+
1372
+
1373
+ </h3><div class="docstring">
1374
+ <div class="discussion">
1375
+
1376
+
1377
+ </div>
1378
+ </div>
1379
+ <div class="tags">
1380
+
1381
+ <div class="docstring">
1382
+ <div class="discussion">
1383
+
1384
+ <p>Cycle the <span class='object_link'><a href="" title="Chess::Board (class)">Chess::Board</a></span> squares.</p>
1385
+
1386
+
1387
+ </div>
1388
+ </div>
1389
+ <div class="tags">
1390
+
1391
+ <p class="tag_title">Yields:</p>
1392
+ <ul class="yield">
1393
+
1394
+ <li>
1395
+
1396
+
1397
+ <span class='type'>(<tt>piece</tt>, <tt>index</tt>)</span>
1398
+
1399
+
1400
+
1401
+ &mdash;
1402
+ <div class='inline'>
1403
+ <p>Calls <code>block</code> once for each square in the <span class='object_link'><a href="" title="Chess::Board (class)">Chess::Board</a></span>, passing the <code>piece</code> in the square and the <code>index</code> as parameters.</p>
1404
+ </div>
1405
+
1406
+ </li>
1407
+
1408
+ </ul>
1409
+ <p class="tag_title">Returns:</p>
1410
+ <ul class="return">
1411
+
1412
+ <li>
1413
+
1414
+
1415
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Chess::Board (class)">Board</a></span></tt>)</span>
1416
+
1417
+
1418
+
1419
+ &mdash;
1420
+ <div class='inline'>
1421
+ <p>Returns <code>self</code> if a block is given.</p>
1422
+ </div>
1423
+
1424
+ </li>
1425
+
1426
+ <li>
1427
+
1428
+
1429
+ <span class='type'>(<tt>Array&lt;String&gt;</tt>)</span>
1430
+
1431
+
1432
+
1433
+ &mdash;
1434
+ <div class='inline'>
1435
+ <p>Returns the array of pieces if no block is given.</p>
1436
+ </div>
1437
+
1438
+ </li>
1439
+
1440
+ </ul>
1441
+
1442
+ </div>
1443
+
1444
+
1445
+ </div><table class="source_code">
1446
+ <tr>
1447
+ <td>
1448
+ <pre class="lines">
1449
+
1450
+
1451
+ 397
1452
+ 398
1453
+ 399
1454
+ 400
1455
+ 401
1456
+ 402
1457
+ 403
1458
+ 404
1459
+ 405
1460
+ 406
1461
+ 407
1462
+ 408
1463
+ 409
1464
+ 410
1465
+ 411
1466
+ 412
1467
+ 413
1468
+ 414
1469
+ 415
1470
+ 416
1471
+ 417
1472
+ 418
1473
+ 419
1474
+ 420
1475
+ 421</pre>
1476
+ </td>
1477
+ <td>
1478
+ <pre class="code"><span class="info file"># File 'ext/chess.c', line 397</span>
1479
+
1480
+ VALUE
1481
+ board_placement (VALUE self)
1482
+ {
1483
+ Board *board;
1484
+ Data_Get_Struct (self, Board, board);
1485
+ if (!rb_block_given_p ())
1486
+ {
1487
+ VALUE placement = rb_ary_new ();
1488
+ for (int i = 0; i &lt; 64; i++)
1489
+ {
1490
+ char piece = board-&gt;placement[i];
1491
+ rb_ary_push (placement, rb_str_new (&amp;piece, 1));
1492
+ }
1493
+ return placement;
1494
+ }
1495
+ else
1496
+ {
1497
+ for (int i = 0; i &lt; 64; i++)
1498
+ {
1499
+ char piece = board-&gt;placement[i];
1500
+ rb_yield_values (2, rb_str_new (&amp;piece, 1), INT2FIX (i));
1501
+ }
1502
+ return self;
1503
+ }
1504
+ }</pre>
1505
+ </td>
1506
+ </tr>
1507
+ </table>
1508
+ </div>
1509
+
1510
+ <div class="method_details ">
1511
+ <h3 class="signature " id="stalemate?-instance_method">
1512
+
1513
+ #<strong>stalemate?</strong> &#x21d2; <tt>Boolean</tt>
1514
+
1515
+
1516
+
1517
+
1518
+
1519
+ </h3><div class="docstring">
1520
+ <div class="discussion">
1521
+
1522
+
1523
+ </div>
1524
+ </div>
1525
+ <div class="tags">
1526
+
1527
+ <div class="docstring">
1528
+ <div class="discussion">
1529
+
1530
+ <p>Returns <code>true</code> if the pieces of the color that has the turn are in stalemate, <code>false</code> otherwise.</p>
1531
+
1532
+
1533
+ </div>
1534
+ </div>
1535
+ <div class="tags">
1536
+
1537
+
1538
+ </div>
1539
+
1540
+ <p class="tag_title">Returns:</p>
1541
+ <ul class="return">
1542
+
1543
+ <li>
1544
+
1545
+
1546
+ <span class='type'>(<tt>Boolean</tt>)</span>
1547
+
1548
+
1549
+
1550
+ </li>
1551
+
1552
+ </ul>
1553
+
1554
+ </div><table class="source_code">
1555
+ <tr>
1556
+ <td>
1557
+ <pre class="lines">
1558
+
1559
+
1560
+ 500
1561
+ 501
1562
+ 502
1563
+ 503
1564
+ 504
1565
+ 505
1566
+ 506
1567
+ 507
1568
+ 508
1569
+ 509</pre>
1570
+ </td>
1571
+ <td>
1572
+ <pre class="code"><span class="info file"># File 'ext/chess.c', line 500</span>
1573
+
1574
+ VALUE
1575
+ board_stalemate (VALUE self)
1576
+ {
1577
+ Board *board;
1578
+ Data_Get_Struct (self, Board, board);
1579
+ if (stalemate (board, board-&gt;active_color))
1580
+ return Qtrue;
1581
+ else
1582
+ return Qfalse;
1583
+ }</pre>
1584
+ </td>
1585
+ </tr>
1586
+ </table>
1587
+ </div>
1588
+
1589
+ <div class="method_details ">
1590
+ <h3 class="signature " id="to_fen-instance_method">
1591
+
1592
+ #<strong>to_fen</strong> &#x21d2; <tt>String</tt>
1593
+
1594
+
1595
+
1596
+
1597
+
1598
+ </h3><div class="docstring">
1599
+ <div class="discussion">
1600
+
1601
+
1602
+ </div>
1603
+ </div>
1604
+ <div class="tags">
1605
+
1606
+ <div class="docstring">
1607
+ <div class="discussion">
1608
+
1609
+ <p>Returns the FEN string of the board.</p>
1610
+
1611
+
1612
+ </div>
1613
+ </div>
1614
+ <div class="tags">
1615
+
1616
+ <p class="tag_title">Returns:</p>
1617
+ <ul class="return">
1618
+
1619
+ <li>
1620
+
1621
+
1622
+ <span class='type'>(<tt>String</tt>)</span>
1623
+
1624
+
1625
+
1626
+ </li>
1627
+
1628
+ </ul>
1629
+
1630
+ </div>
1631
+
1632
+
1633
+ </div><table class="source_code">
1634
+ <tr>
1635
+ <td>
1636
+ <pre class="lines">
1637
+
1638
+
1639
+ 648
1640
+ 649
1641
+ 650
1642
+ 651
1643
+ 652
1644
+ 653
1645
+ 654
1646
+ 655
1647
+ 656
1648
+ 657</pre>
1649
+ </td>
1650
+ <td>
1651
+ <pre class="code"><span class="info file"># File 'ext/chess.c', line 648</span>
1652
+
1653
+ VALUE
1654
+ board_to_fen (VALUE self)
1655
+ {
1656
+ Board *board;
1657
+ Data_Get_Struct (self, Board, board);
1658
+ char *fen = to_fen (board);
1659
+ VALUE rb_fen = rb_str_new2 (fen);
1660
+ free (fen);
1661
+ return rb_fen;
1662
+ }</pre>
1663
+ </td>
1664
+ </tr>
1665
+ </table>
1666
+ </div>
1667
+
1668
+ <div class="method_details ">
1669
+ <h3 class="signature " id="to_s-instance_method">
1670
+
1671
+ #<strong>to_s</strong> &#x21d2; <tt>String</tt>
1672
+
1673
+
1674
+
1675
+
1676
+
1677
+ </h3><div class="docstring">
1678
+ <div class="discussion">
1679
+
1680
+
1681
+ </div>
1682
+ </div>
1683
+ <div class="tags">
1684
+
1685
+ <div class="docstring">
1686
+ <div class="discussion">
1687
+
1688
+ <p><span class='object_link'><a href="" title="Chess::Board (class)">Chess::Board</a></span> to string.</p>
1689
+
1690
+
1691
+ </div>
1692
+ </div>
1693
+ <div class="tags">
1694
+
1695
+ <p class="tag_title">Returns:</p>
1696
+ <ul class="return">
1697
+
1698
+ <li>
1699
+
1700
+
1701
+ <span class='type'>(<tt>String</tt>)</span>
1702
+
1703
+
1704
+
1705
+ </li>
1706
+
1707
+ </ul>
1708
+
1709
+ </div>
1710
+
1711
+
1712
+ </div><table class="source_code">
1713
+ <tr>
1714
+ <td>
1715
+ <pre class="lines">
1716
+
1717
+
1718
+ 664
1719
+ 665
1720
+ 666
1721
+ 667
1722
+ 668
1723
+ 669
1724
+ 670
1725
+ 671
1726
+ 672
1727
+ 673</pre>
1728
+ </td>
1729
+ <td>
1730
+ <pre class="code"><span class="info file"># File 'ext/chess.c', line 664</span>
1731
+
1732
+ VALUE
1733
+ board_to_s (VALUE self)
1734
+ {
1735
+ Board *board;
1736
+ Data_Get_Struct (self, Board, board);
1737
+ char *s = print_board (board);
1738
+ VALUE rb_s = rb_str_new2 (s);
1739
+ free (s);
1740
+ return rb_s;
1741
+ }</pre>
1742
+ </td>
1743
+ </tr>
1744
+ </table>
1745
+ </div>
1746
+
1747
+ </div>
1748
+
1749
+ </div>
1750
+
1751
+ <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).
1755
+ </div>
1756
+
1757
+ </div>
1758
+ </body>
1759
+ </html>