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,366 @@
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::Gnuchess
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::Gnuchess";
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 (G)</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">Gnuchess</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::Gnuchess
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/gnuchess.rb</dd>
82
+ </dl>
83
+
84
+ </div>
85
+
86
+ <h2>Overview</h2><div class="docstring">
87
+ <div class="discussion">
88
+
89
+ <div class="note notetag">
90
+ <strong>Note:</strong>
91
+ <div class='inline'>
92
+ <p>Gnuchess binary have to be installed.</p>
93
+ </div>
94
+ </div>
95
+
96
+
97
+ <p>Use Gnuchess to I.A. <em>(Only a draft)</em>.</p>
98
+
99
+ <p>To use this module, extend a game object with <span class='object_link'><a href="" title="Chess::Gnuchess (module)">Gnuchess</a></span>.</p>
100
+
101
+
102
+ </div>
103
+ </div>
104
+ <div class="tags">
105
+
106
+ <div class="examples">
107
+ <p class="tag_title">Examples:</p>
108
+
109
+
110
+ <pre class="example code"><code><span class='id identifier rubyid_g'>g</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Chess.html" title="Chess (module)">Chess</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Game.html" title="Chess::Game (class)">Game</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Game.html#initialize-instance_method" title="Chess::Game#initialize (method)">new</a></span></span>
111
+ <span class='id identifier rubyid_g'>g</span><span class='period'>.</span><span class='id identifier rubyid_extend'>extend</span> <span class='const'><span class='object_link'><a href="../Chess.html" title="Chess (module)">Chess</a></span></span><span class='op'>::</span><span class='const'>Gnuchess</span>
112
+ <span class='id identifier rubyid_g'>g</span><span class='period'>.</span><span class='id identifier rubyid_gnuchess_move!'>gnuchess_move!</span>
113
+ <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_g'>g</span></code></pre>
114
+
115
+ </div>
116
+
117
+
118
+ </div>
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+ <h2>
127
+ Instance Method Summary
128
+ <small><a href="#" class="summary_toggle">collapse</a></small>
129
+ </h2>
130
+
131
+ <ul class="summary">
132
+
133
+ <li class="public ">
134
+ <span class="summary_signature">
135
+
136
+ <a href="#gnuchess_move-instance_method" title="#gnuchess_move (instance method)">#<strong>gnuchess_move</strong> &#x21d2; String </a>
137
+
138
+
139
+
140
+ </span>
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+ <span class="summary_desc"><div class='inline'>
151
+ <p>Returns the next move calculated by Gnuchess.</p>
152
+ </div></span>
153
+
154
+ </li>
155
+
156
+
157
+ <li class="public ">
158
+ <span class="summary_signature">
159
+
160
+ <a href="#gnuchess_move!-instance_method" title="#gnuchess_move! (instance method)">#<strong>gnuchess_move!</strong> &#x21d2; String </a>
161
+
162
+
163
+
164
+ </span>
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+
174
+ <span class="summary_desc"><div class='inline'>
175
+ <p>Make a move using Gnuchess engine.</p>
176
+ </div></span>
177
+
178
+ </li>
179
+
180
+
181
+ </ul>
182
+
183
+
184
+
185
+
186
+ <div id="instance_method_details" class="method_details_list">
187
+ <h2>Instance Method Details</h2>
188
+
189
+
190
+ <div class="method_details first">
191
+ <h3 class="signature first" id="gnuchess_move-instance_method">
192
+
193
+ #<strong>gnuchess_move</strong> &#x21d2; <tt>String</tt>
194
+
195
+
196
+
197
+
198
+
199
+ </h3><div class="docstring">
200
+ <div class="discussion">
201
+
202
+ <p>Returns the next move calculated by Gnuchess.</p>
203
+
204
+
205
+ </div>
206
+ </div>
207
+ <div class="tags">
208
+
209
+ <p class="tag_title">Returns:</p>
210
+ <ul class="return">
211
+
212
+ <li>
213
+
214
+
215
+ <span class='type'>(<tt>String</tt>)</span>
216
+
217
+
218
+
219
+ &mdash;
220
+ <div class='inline'>
221
+ <p>Returns the short algebraic chess notation of the move.</p>
222
+ </div>
223
+
224
+ </li>
225
+
226
+ </ul>
227
+
228
+ </div><table class="source_code">
229
+ <tr>
230
+ <td>
231
+ <pre class="lines">
232
+
233
+
234
+ 16
235
+ 17
236
+ 18
237
+ 19
238
+ 20
239
+ 21
240
+ 22
241
+ 23
242
+ 24
243
+ 25
244
+ 26
245
+ 27
246
+ 28
247
+ 29
248
+ 30
249
+ 31
250
+ 32
251
+ 33
252
+ 34
253
+ 35
254
+ 36</pre>
255
+ </td>
256
+ <td>
257
+ <pre class="code"><span class="info file"># File 'lib/chess/gnuchess.rb', line 16</span>
258
+
259
+ <span class='kw'>def</span> <span class='id identifier rubyid_gnuchess_move'>gnuchess_move</span>
260
+ <span class='id identifier rubyid_pipe'>pipe</span> <span class='op'>=</span> <span class='const'>IO</span><span class='period'>.</span><span class='id identifier rubyid_popen'>popen</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>gnuchess -x</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>r+</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
261
+ <span class='kw'>begin</span>
262
+ <span class='id identifier rubyid_pipe'>pipe</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>depth 1</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
263
+ <span class='id identifier rubyid_pipe'>pipe</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>manual</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
264
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_coord_moves'>coord_moves</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_m'>m</span><span class='op'>|</span>
265
+ <span class='id identifier rubyid_pipe'>pipe</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span><span class='lparen'>(</span><span class='id identifier rubyid_m'>m</span><span class='rparen'>)</span>
266
+ <span class='kw'>end</span>
267
+ <span class='id identifier rubyid_pipe'>pipe</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>go</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
268
+ <span class='kw'>while</span> <span class='lparen'>(</span><span class='id identifier rubyid_line'>line</span> <span class='op'>=</span> <span class='id identifier rubyid_pipe'>pipe</span><span class='period'>.</span><span class='id identifier rubyid_gets'>gets</span><span class='rparen'>)</span>
269
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="IllegalMoveError.html" title="Chess::IllegalMoveError (class)">IllegalMoveError</a></span></span> <span class='kw'>if</span> <span class='id identifier rubyid_line'>line</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Invalid move</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
270
+
271
+ <span class='id identifier rubyid_match'>match</span> <span class='op'>=</span> <span class='id identifier rubyid_line'>line</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>My move is : ([a-h][1-8][a-h][1-8][rkbq]?)</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span>
272
+ <span class='kw'>return</span> <span class='id identifier rubyid_match'>match</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_match'>match</span>
273
+ <span class='kw'>end</span>
274
+ <span class='kw'>ensure</span>
275
+ <span class='id identifier rubyid_pipe'>pipe</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>quit</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
276
+ <span class='id identifier rubyid_pipe'>pipe</span><span class='period'>.</span><span class='id identifier rubyid_close'>close</span>
277
+ <span class='kw'>end</span>
278
+ <span class='kw'>return</span> <span class='id identifier rubyid_moves'>moves</span>
279
+ <span class='kw'>end</span></pre>
280
+ </td>
281
+ </tr>
282
+ </table>
283
+ </div>
284
+
285
+ <div class="method_details ">
286
+ <h3 class="signature " id="gnuchess_move!-instance_method">
287
+
288
+ #<strong>gnuchess_move!</strong> &#x21d2; <tt>String</tt>
289
+
290
+
291
+
292
+
293
+
294
+ </h3><div class="docstring">
295
+ <div class="discussion">
296
+
297
+ <div class="note notetag">
298
+ <strong>Note:</strong>
299
+ <div class='inline'>
300
+ <p>This add a new <span class='object_link'><a href="Board.html" title="Chess::Board (class)">Board</a></span> in the <span class='object_link'><a href="Game.html" title="Chess::Game (class)">Chess::Game</a></span>.</p>
301
+ </div>
302
+ </div>
303
+
304
+
305
+ <p>Make a move using Gnuchess engine.</p>
306
+
307
+
308
+ </div>
309
+ </div>
310
+ <div class="tags">
311
+
312
+ <p class="tag_title">Returns:</p>
313
+ <ul class="return">
314
+
315
+ <li>
316
+
317
+
318
+ <span class='type'>(<tt>String</tt>)</span>
319
+
320
+
321
+
322
+ &mdash;
323
+ <div class='inline'>
324
+ <p>Returns the short algebraic chess notation of the move.</p>
325
+ </div>
326
+
327
+ </li>
328
+
329
+ </ul>
330
+
331
+ </div><table class="source_code">
332
+ <tr>
333
+ <td>
334
+ <pre class="lines">
335
+
336
+
337
+ 41
338
+ 42
339
+ 43
340
+ 44</pre>
341
+ </td>
342
+ <td>
343
+ <pre class="code"><span class="info file"># File 'lib/chess/gnuchess.rb', line 41</span>
344
+
345
+ <span class='kw'>def</span> <span class='id identifier rubyid_gnuchess_move!'>gnuchess_move!</span>
346
+ <span class='id identifier rubyid_next_move'>next_move</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_gnuchess_move'>gnuchess_move</span>
347
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_move'>move</span><span class='lparen'>(</span><span class='id identifier rubyid_next_move'>next_move</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_next_move'>next_move</span>
348
+ <span class='kw'>end</span></pre>
349
+ </td>
350
+ </tr>
351
+ </table>
352
+ </div>
353
+
354
+ </div>
355
+
356
+ </div>
357
+
358
+ <div id="footer">
359
+ Generated on Thu Jan 28 17:31:40 2021 by
360
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
361
+ 0.9.26 (ruby-2.6.1).
362
+ </div>
363
+
364
+ </div>
365
+ </body>
366
+ </html>
@@ -0,0 +1,137 @@
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::IllegalMoveError
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::IllegalMoveError";
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 (I)</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">IllegalMoveError</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::IllegalMoveError
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::IllegalMoveError</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>ext/chess.c<span class="defines">,<br />
100
+ ext/chess.c</span>
101
+ </dd>
102
+ </dl>
103
+
104
+ </div>
105
+
106
+ <h2>Overview</h2><div class="docstring">
107
+ <div class="discussion">
108
+
109
+ <p>This exception will be raised when making an illegal move.</p>
110
+
111
+
112
+ </div>
113
+ </div>
114
+ <div class="tags">
115
+
116
+
117
+ </div>
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+ </div>
128
+
129
+ <div id="footer">
130
+ Generated on Thu Jan 28 17:31:41 2021 by
131
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
132
+ 0.9.26 (ruby-2.6.1).
133
+ </div>
134
+
135
+ </div>
136
+ </body>
137
+ </html>