chess 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/README.md +44 -0
  4. data/Rakefile +6 -7
  5. data/chess.gemspec +1 -1
  6. data/ext/bitboard.c +24 -0
  7. data/ext/board.c +78 -24
  8. data/ext/board.h +4 -2
  9. data/ext/chess.c +216 -196
  10. data/ext/chess.h +1 -0
  11. data/ext/common.c +10 -0
  12. data/ext/game.c +33 -16
  13. data/ext/special.c +14 -11
  14. data/ext/special.h +1 -2
  15. data/lib/chess/exceptions.rb +7 -10
  16. data/lib/chess/game.rb +66 -50
  17. data/lib/chess/gnuchess.rb +19 -25
  18. data/lib/chess/pgn.rb +49 -9
  19. data/lib/chess/utf8_notation.rb +11 -9
  20. data/lib/chess/version.rb +1 -1
  21. data/test/pgn_collection/illegal/0001.pgn +18 -0
  22. data/test/pgn_collection/illegal/0002.pgn +17 -0
  23. data/test/pgn_collection/illegal/0003.pgn +13 -0
  24. data/test/pgn_collection/illegal/0004.pgn +15 -0
  25. data/test/pgn_collection/illegal/0005.pgn +16 -0
  26. data/test/pgn_collection/invalid/0001.pgn +20 -0
  27. data/test/pgn_collection/invalid/0002.pgn +16 -0
  28. data/test/pgn_collection/invalid/0003.pgn +13 -0
  29. data/test/pgn_collection/invalid/0004.pgn +15 -0
  30. data/test/pgn_collection/valid/0001.pgn +6 -7
  31. data/test/pgn_collection/valid/0002.pgn +8 -9
  32. data/test/pgn_collection/valid/0005.pgn +7 -8
  33. data/test/pgn_collection/valid/0009.pgn +14 -15
  34. data/test/pgn_collection/valid/0010.pgn +6 -7
  35. data/test/pgn_collection/valid/0011.pgn +5 -6
  36. data/test/pgn_collection/valid/0012.pgn +0 -1
  37. data/test/pgn_collection/valid/0013.pgn +5 -6
  38. data/test/pgn_collection/valid/0014.pgn +6 -7
  39. data/test/pgn_collection/valid/0020.pgn +6 -7
  40. data/test/pgn_collection/valid/0021.pgn +15 -16
  41. data/test/pgn_collection/valid/0971.pgn +22 -14
  42. data/test/test_big_pgn_collection.rb +12 -5
  43. data/test/test_helper.rb +1 -1
  44. data/test/test_illegal_moves.rb +14 -0
  45. data/test/test_insufficient_material.rb +13 -1
  46. data/test/test_particular_situations.rb +14 -0
  47. data/test/test_pgn.rb +24 -0
  48. data/test/test_pgn_collection.rb +1 -4
  49. metadata +30 -63
  50. data/README.rdoc +0 -44
  51. data/doc/Chess.html +0 -112
  52. data/doc/Chess/BadNotationError.html +0 -107
  53. data/doc/Chess/Board.html +0 -700
  54. data/doc/Chess/CGame.html +0 -1004
  55. data/doc/Chess/Game.html +0 -684
  56. data/doc/Chess/Gnuchess.html +0 -215
  57. data/doc/Chess/IllegalMoveError.html +0 -105
  58. data/doc/Chess/InvalidFenFormatError.html +0 -105
  59. data/doc/Chess/InvalidPgnFormatError.html +0 -105
  60. data/doc/Chess/Pgn.html +0 -309
  61. data/doc/Chess/UTF8Notation.html +0 -174
  62. data/doc/README_rdoc.html +0 -143
  63. data/doc/created.rid +0 -15
  64. data/doc/css/fonts.css +0 -167
  65. data/doc/css/rdoc.css +0 -590
  66. data/doc/fonts/Lato-Light.ttf +0 -0
  67. data/doc/fonts/Lato-LightItalic.ttf +0 -0
  68. data/doc/fonts/Lato-Regular.ttf +0 -0
  69. data/doc/fonts/Lato-RegularItalic.ttf +0 -0
  70. data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  71. data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  72. data/doc/images/add.png +0 -0
  73. data/doc/images/arrow_up.png +0 -0
  74. data/doc/images/brick.png +0 -0
  75. data/doc/images/brick_link.png +0 -0
  76. data/doc/images/bug.png +0 -0
  77. data/doc/images/bullet_black.png +0 -0
  78. data/doc/images/bullet_toggle_minus.png +0 -0
  79. data/doc/images/bullet_toggle_plus.png +0 -0
  80. data/doc/images/date.png +0 -0
  81. data/doc/images/delete.png +0 -0
  82. data/doc/images/find.png +0 -0
  83. data/doc/images/loadingAnimation.gif +0 -0
  84. data/doc/images/macFFBgHack.png +0 -0
  85. data/doc/images/package.png +0 -0
  86. data/doc/images/page_green.png +0 -0
  87. data/doc/images/page_white_text.png +0 -0
  88. data/doc/images/page_white_width.png +0 -0
  89. data/doc/images/plugin.png +0 -0
  90. data/doc/images/ruby.png +0 -0
  91. data/doc/images/tag_blue.png +0 -0
  92. data/doc/images/tag_green.png +0 -0
  93. data/doc/images/transparent.png +0 -0
  94. data/doc/images/wrench.png +0 -0
  95. data/doc/images/wrench_orange.png +0 -0
  96. data/doc/images/zoom.png +0 -0
  97. data/doc/index.html +0 -160
  98. data/doc/js/darkfish.js +0 -161
  99. data/doc/js/jquery.js +0 -4
  100. data/doc/js/navigation.js +0 -142
  101. data/doc/js/navigation.js.gz +0 -0
  102. data/doc/js/search.js +0 -109
  103. data/doc/js/search_index.js +0 -1
  104. data/doc/js/search_index.js.gz +0 -0
  105. data/doc/js/searcher.js +0 -229
  106. data/doc/js/searcher.js.gz +0 -0
  107. data/doc/table_of_contents.html +0 -331
data/doc/Chess/Game.html DELETED
@@ -1,684 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta charset="UTF-8">
6
-
7
- <title>class Chess::Game - Chess</title>
8
-
9
- <script type="text/javascript">
10
- var rdoc_rel_prefix = "../";
11
- var index_rel_prefix = "../";
12
- </script>
13
-
14
- <script src="../js/jquery.js"></script>
15
- <script src="../js/darkfish.js"></script>
16
-
17
- <link href="../css/fonts.css" rel="stylesheet">
18
- <link href="../css/rdoc.css" rel="stylesheet">
19
-
20
-
21
-
22
- <body id="top" role="document" class="class">
23
- <nav role="navigation">
24
- <div id="project-navigation">
25
- <div id="home-section" role="region" title="Quick navigation" class="nav-section">
26
- <h2>
27
- <a href="../index.html" rel="home">Home</a>
28
- </h2>
29
-
30
- <div id="table-of-contents-navigation">
31
- <a href="../table_of_contents.html#pages">Pages</a>
32
- <a href="../table_of_contents.html#classes">Classes</a>
33
- <a href="../table_of_contents.html#methods">Methods</a>
34
- </div>
35
- </div>
36
-
37
- <div id="search-section" role="search" class="project-section initially-hidden">
38
- <form action="#" method="get" accept-charset="utf-8">
39
- <div id="search-field-wrapper">
40
- <input id="search-field" role="combobox" aria-label="Search"
41
- aria-autocomplete="list" aria-controls="search-results"
42
- type="text" name="search" placeholder="Search" spellcheck="false"
43
- title="Type to search, Up and Down to navigate, Enter to load">
44
- </div>
45
-
46
- <ul id="search-results" aria-label="Search Results"
47
- aria-busy="false" aria-expanded="false"
48
- aria-atomic="false" class="initially-hidden"></ul>
49
- </form>
50
- </div>
51
-
52
- </div>
53
-
54
-
55
-
56
- <div id="class-metadata">
57
-
58
- <div id="parent-class-section" class="nav-section">
59
- <h3>Parent</h3>
60
-
61
-
62
- <p class="link"><a href="CGame.html">Chess::CGame</a>
63
-
64
- </div>
65
-
66
-
67
-
68
- <!-- Method Quickref -->
69
- <div id="method-list-section" class="nav-section">
70
- <h3>Methods</h3>
71
-
72
- <ul class="link-list" role="directory">
73
-
74
- <li ><a href="#method-c-load_fen">::load_fen</a>
75
-
76
- <li ><a href="#method-c-load_pgn">::load_pgn</a>
77
-
78
- <li ><a href="#method-c-new">::new</a>
79
-
80
- <li ><a href="#method-i-3C-3C">#&lt;&lt;</a>
81
-
82
- <li ><a href="#method-i-active_player">#active_player</a>
83
-
84
- <li ><a href="#method-i-inactive_player">#inactive_player</a>
85
-
86
- <li class="calls-super" ><a href="#method-i-move">#move</a>
87
-
88
- <li ><a href="#method-i-move-3D">#move=</a>
89
-
90
- <li ><a href="#method-i-moves-3D">#moves=</a>
91
-
92
- <li ><a href="#method-i-over-3F">#over?</a>
93
-
94
- <li ><a href="#method-i-pgn">#pgn</a>
95
-
96
- <li ><a href="#method-i-status">#status</a>
97
-
98
- </ul>
99
- </div>
100
-
101
- </div>
102
- </nav>
103
-
104
- <main role="main" aria-labelledby="class-Chess::Game">
105
- <h1 id="class-Chess::Game" class="class">
106
- class Chess::Game
107
- </h1>
108
-
109
- <section class="description">
110
-
111
- <p>This class rappresents a chess game.</p>
112
-
113
- </section>
114
-
115
-
116
-
117
-
118
- <section id="5Buntitled-5D" class="documentation-section">
119
-
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
- <section id="public-class-5Buntitled-5D-method-details" class="method-section">
129
- <header>
130
- <h3>Public Class Methods</h3>
131
- </header>
132
-
133
-
134
- <div id="method-c-load_fen" class="method-detail ">
135
-
136
- <div class="method-heading">
137
- <span class="method-name">load_fen</span><span
138
- class="method-args">(fen)</span>
139
-
140
- <span class="method-click-advice">click to toggle source</span>
141
-
142
- </div>
143
-
144
-
145
- <div class="method-description">
146
-
147
- <p>Creates a new game from a FEN string.</p>
148
-
149
- <p>May be raise an <a
150
- href="InvalidFenFormatError.html">InvalidFenFormatError</a>.</p>
151
-
152
- <p><strong>Warning</strong>: this game do not have history before the FEN
153
- placement.</p>
154
-
155
-
156
-
157
-
158
- <div class="method-source-code" id="load_fen-source">
159
- <pre><span class="ruby-comment"># File lib/chess/game.rb, line 43</span>
160
- <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">load_fen</span>(<span class="ruby-identifier">fen</span>)
161
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">fen</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^((?:[PRNBQKprnbqk1-8]{1,8}\/){7}[RNBQKPrnbqkp1-8]{1,8})\s(w|b)\s(K?Q?k?q?|-)\s([a-h][1-8]|-)\s(\d+)\s(\d+)$/</span>
162
- <span class="ruby-identifier">game</span> = <span class="ruby-constant">Chess</span><span class="ruby-operator">::</span><span class="ruby-constant">Game</span>.<span class="ruby-identifier">new</span>
163
- <span class="ruby-identifier">game</span>.<span class="ruby-identifier">set_fen!</span>(<span class="ruby-identifier">fen</span>)
164
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">game</span>
165
- <span class="ruby-keyword">else</span>
166
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidFenFormatError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">fen</span>)
167
- <span class="ruby-keyword">end</span>
168
- <span class="ruby-keyword">end</span></pre>
169
- </div>
170
-
171
- </div>
172
-
173
-
174
-
175
-
176
- </div>
177
-
178
-
179
- <div id="method-c-load_pgn" class="method-detail ">
180
-
181
- <div class="method-heading">
182
- <span class="method-name">load_pgn</span><span
183
- class="method-args">(file)</span>
184
-
185
- <span class="method-click-advice">click to toggle source</span>
186
-
187
- </div>
188
-
189
-
190
- <div class="method-description">
191
-
192
- <p>Creates a new game from a file in PGN format.</p>
193
-
194
- <p>May be raise an <a
195
- href="InvalidPgnFormatError.html">InvalidPgnFormatError</a> or <a
196
- href="IllegalMoveError.html">IllegalMoveError</a> or <a
197
- href="BadNotationError.html">BadNotationError</a>.</p>
198
-
199
-
200
-
201
-
202
- <div class="method-source-code" id="load_pgn-source">
203
- <pre><span class="ruby-comment"># File lib/chess/game.rb, line 18</span>
204
- <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">load_pgn</span>(<span class="ruby-identifier">file</span>)
205
- <span class="ruby-identifier">pgn</span> = <span class="ruby-constant">Chess</span><span class="ruby-operator">::</span><span class="ruby-constant">Pgn</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">file</span>)
206
- <span class="ruby-identifier">game</span> = <span class="ruby-constant">Chess</span><span class="ruby-operator">::</span><span class="ruby-constant">Game</span>.<span class="ruby-identifier">new</span>
207
- <span class="ruby-identifier">pgn</span>.<span class="ruby-identifier">moves</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">m</span><span class="ruby-operator">|</span> <span class="ruby-identifier">game</span>.<span class="ruby-identifier">move</span>(<span class="ruby-identifier">m</span>) }
208
- <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">game</span>.<span class="ruby-identifier">over?</span>
209
- <span class="ruby-keyword">case</span> <span class="ruby-identifier">pgn</span>.<span class="ruby-identifier">result</span>
210
- <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;1-0&#39;</span>
211
- <span class="ruby-identifier">game</span>.<span class="ruby-identifier">resign</span>(<span class="ruby-value">:black</span>)
212
- <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;0-1&#39;</span>
213
- <span class="ruby-identifier">game</span>.<span class="ruby-identifier">resign</span>(<span class="ruby-value">:white</span>)
214
- <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;1/2-1/2&#39;</span>
215
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">game</span>.<span class="ruby-identifier">board</span>.<span class="ruby-identifier">insufficient_material?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">game</span>.<span class="ruby-identifier">board</span>.<span class="ruby-identifier">stalemate?</span> <span class="ruby-operator">||</span>
216
- <span class="ruby-identifier">game</span>.<span class="ruby-identifier">threefold_repetition?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">game</span>.<span class="ruby-identifier">board</span>.<span class="ruby-identifier">fifty_rule_move?</span>
217
- <span class="ruby-identifier">game</span>.<span class="ruby-identifier">draw</span>
218
- <span class="ruby-keyword">end</span>
219
- <span class="ruby-keyword">end</span>
220
- <span class="ruby-keyword">end</span>
221
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">game</span>
222
- <span class="ruby-keyword">end</span></pre>
223
- </div>
224
-
225
- </div>
226
-
227
-
228
-
229
-
230
- </div>
231
-
232
-
233
- <div id="method-c-new" class="method-detail ">
234
-
235
- <div class="method-heading">
236
- <span class="method-name">new</span><span
237
- class="method-args">(moves = [])</span>
238
-
239
- <span class="method-click-advice">click to toggle source</span>
240
-
241
- </div>
242
-
243
-
244
- <div class="method-description">
245
-
246
- <p>Create a new game. If an array of moves is provided, the moves will be
247
- performed.</p>
248
-
249
- <p>May be raise an <a href="IllegalMoveError.html">IllegalMoveError</a> or <a
250
- href="BadNotationError.html">BadNotationError</a>.</p>
251
-
252
-
253
-
254
-
255
- <div class="method-source-code" id="new-source">
256
- <pre><span class="ruby-comment"># File lib/chess/game.rb, line 11</span>
257
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">moves</span> = [])
258
- <span class="ruby-identifier">moves</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">m</span><span class="ruby-operator">|</span> <span class="ruby-identifier">move</span>(<span class="ruby-identifier">m</span>) }
259
- <span class="ruby-keyword">end</span></pre>
260
- </div>
261
-
262
- </div>
263
-
264
-
265
-
266
-
267
- </div>
268
-
269
-
270
- </section>
271
-
272
- <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
273
- <header>
274
- <h3>Public Instance Methods</h3>
275
- </header>
276
-
277
-
278
- <div id="method-i-3C-3C" class="method-detail method-alias">
279
-
280
- <div class="method-heading">
281
- <span class="method-name">&lt;&lt;</span><span
282
- class="method-args">(m)</span>
283
-
284
- </div>
285
-
286
-
287
- <div class="method-description">
288
-
289
-
290
-
291
-
292
-
293
-
294
- </div>
295
-
296
-
297
-
298
-
299
- <div class="aliases">
300
- Alias for: <a href="Game.html#method-i-move">move</a>
301
- </div>
302
-
303
- </div>
304
-
305
-
306
- <div id="method-i-active_player" class="method-detail ">
307
-
308
- <div class="method-heading">
309
- <span class="method-name">active_player</span><span
310
- class="method-args">()</span>
311
-
312
- <span class="method-click-advice">click to toggle source</span>
313
-
314
- </div>
315
-
316
-
317
- <div class="method-description">
318
-
319
- <p>Returns <code>:white</code> if the active player is the white player,
320
- <code>:black</code> otherwise.</p>
321
-
322
-
323
-
324
-
325
- <div class="method-source-code" id="active_player-source">
326
- <pre><span class="ruby-comment"># File lib/chess/game.rb, line 87</span>
327
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">active_player</span>
328
- <span class="ruby-keyword">self</span>.<span class="ruby-identifier">board</span>.<span class="ruby-identifier">active_color</span> <span class="ruby-operator">?</span> <span class="ruby-value">:black</span> <span class="ruby-operator">:</span> <span class="ruby-value">:white</span>
329
- <span class="ruby-keyword">end</span></pre>
330
- </div>
331
-
332
- </div>
333
-
334
-
335
-
336
-
337
- </div>
338
-
339
-
340
- <div id="method-i-inactive_player" class="method-detail ">
341
-
342
- <div class="method-heading">
343
- <span class="method-name">inactive_player</span><span
344
- class="method-args">()</span>
345
-
346
- <span class="method-click-advice">click to toggle source</span>
347
-
348
- </div>
349
-
350
-
351
- <div class="method-description">
352
-
353
- <p>Returns <code>:white</code> if the inactive player is the white player,
354
- <code>:black</code> otherwise.</p>
355
-
356
-
357
-
358
-
359
- <div class="method-source-code" id="inactive_player-source">
360
- <pre><span class="ruby-comment"># File lib/chess/game.rb, line 92</span>
361
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">inactive_player</span>
362
- <span class="ruby-keyword">self</span>.<span class="ruby-identifier">board</span>.<span class="ruby-identifier">active_color</span> <span class="ruby-operator">?</span> <span class="ruby-value">:white</span> <span class="ruby-operator">:</span> <span class="ruby-value">:black</span>
363
- <span class="ruby-keyword">end</span></pre>
364
- </div>
365
-
366
- </div>
367
-
368
-
369
-
370
-
371
- </div>
372
-
373
-
374
- <div id="method-i-move" class="method-detail ">
375
-
376
- <div class="method-heading">
377
- <span class="method-name">move</span><span
378
- class="method-args">(m)</span>
379
-
380
- <span class="method-click-advice">click to toggle source</span>
381
-
382
- </div>
383
-
384
-
385
- <div class="method-description">
386
-
387
- <p>Make a move. This add a new <a href="Board.html">Board</a> in the
388
- Storyboard.</p>
389
-
390
- <p>Parameters are:</p>
391
- <dl class="rdoc-list note-list"><dt><code>m</code>
392
- <dd>
393
- <p>represents the short algebraic chess notation string of the move.
394
- <code>m</code> can be <em>from_square</em> plus <em>to_square</em>
395
- <em>(&#39;e2e4&#39;, …, &#39;b1c3&#39;)</em> (coordinate chess notation).</p>
396
- </dd></dl>
397
-
398
- <p>This method returns a string that represents the short algebraic chess
399
- notation of the move.</p>
400
-
401
- <p>Raise an <a href="IllegalMoveError.html">IllegalMoveError</a> if the move
402
- is illegal. Raise an <a href="BadNotationError.html">BadNotationError</a>
403
- if the short algebraic chess notation is malformed.</p>
404
-
405
-
406
- <div class="method-calls-super">
407
- Calls superclass method
408
- <a href="CGame.html#method-i-move">Chess::CGame#move</a>
409
- </div>
410
-
411
-
412
-
413
- <div class="method-source-code" id="move-source">
414
- <pre><span class="ruby-comment"># File lib/chess/game.rb, line 66</span>
415
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">move</span>(<span class="ruby-identifier">m</span>)
416
- <span class="ruby-keyword">begin</span>
417
- <span class="ruby-identifier">expand</span> = <span class="ruby-identifier">expand_move</span>(<span class="ruby-identifier">m</span>)
418
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">expand</span>[<span class="ruby-value">:from</span>]
419
- <span class="ruby-identifier">move2</span>(<span class="ruby-identifier">expand</span>[<span class="ruby-value">:from</span>], <span class="ruby-identifier">expand</span>[<span class="ruby-value">:to</span>], <span class="ruby-identifier">expand</span>[<span class="ruby-value">:promotion</span>])
420
- <span class="ruby-keyword">else</span>
421
- <span class="ruby-keyword">super</span>(<span class="ruby-identifier">expand</span>[<span class="ruby-value">:name</span>], <span class="ruby-identifier">expand</span>[<span class="ruby-value">:dis</span>], <span class="ruby-identifier">expand</span>[<span class="ruby-value">:to</span>], <span class="ruby-identifier">expand</span>[<span class="ruby-value">:promotion</span>])
422
- <span class="ruby-keyword">end</span>
423
- <span class="ruby-keyword">rescue</span> <span class="ruby-constant">IllegalMoveError</span>
424
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">IllegalMoveError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;Illegal move &#39;#{m}&#39;\n#{self.active_player} turn\n#{self.to_s}&quot;</span>)
425
- <span class="ruby-keyword">end</span>
426
- <span class="ruby-keyword">end</span></pre>
427
- </div>
428
-
429
- </div>
430
-
431
-
432
- <div class="aliases">
433
- Also aliased as: <a href="Game.html#method-i-move-3D">move=</a>, <a href="Game.html#method-i-3C-3C">&lt;&lt;</a>
434
- </div>
435
-
436
-
437
-
438
- </div>
439
-
440
-
441
- <div id="method-i-move-3D" class="method-detail method-alias">
442
-
443
- <div class="method-heading">
444
- <span class="method-name">move=</span><span
445
- class="method-args">(m)</span>
446
-
447
- </div>
448
-
449
-
450
- <div class="method-description">
451
-
452
-
453
-
454
-
455
-
456
-
457
- </div>
458
-
459
-
460
-
461
-
462
- <div class="aliases">
463
- Alias for: <a href="Game.html#method-i-move">move</a>
464
- </div>
465
-
466
- </div>
467
-
468
-
469
- <div id="method-i-moves-3D" class="method-detail ">
470
-
471
- <div class="method-heading">
472
- <span class="method-name">moves=</span><span
473
- class="method-args">(moves)</span>
474
-
475
- <span class="method-click-advice">click to toggle source</span>
476
-
477
- </div>
478
-
479
-
480
- <div class="method-description">
481
-
482
- <p>Make the array of moves.</p>
483
-
484
-
485
-
486
-
487
- <div class="method-source-code" id="moves-3D-source">
488
- <pre><span class="ruby-comment"># File lib/chess/game.rb, line 82</span>
489
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">moves=</span>(<span class="ruby-identifier">moves</span>)
490
- <span class="ruby-identifier">moves</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">m</span><span class="ruby-operator">|</span> <span class="ruby-identifier">move</span>(<span class="ruby-identifier">m</span>) }
491
- <span class="ruby-keyword">end</span></pre>
492
- </div>
493
-
494
- </div>
495
-
496
-
497
-
498
-
499
- </div>
500
-
501
-
502
- <div id="method-i-over-3F" class="method-detail ">
503
-
504
- <div class="method-heading">
505
- <span class="method-name">over?</span><span
506
- class="method-args">()</span>
507
-
508
- <span class="method-click-advice">click to toggle source</span>
509
-
510
- </div>
511
-
512
-
513
- <div class="method-description">
514
-
515
- <p>Returns <code>true</code> if the game is over</p>
516
-
517
-
518
-
519
-
520
- <div class="method-source-code" id="over-3F-source">
521
- <pre><span class="ruby-comment"># File lib/chess/game.rb, line 140</span>
522
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">over?</span>
523
- <span class="ruby-keyword">return</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">result</span> <span class="ruby-operator">!=</span> <span class="ruby-string">&#39;*&#39;</span>
524
- <span class="ruby-keyword">end</span></pre>
525
- </div>
526
-
527
- </div>
528
-
529
-
530
-
531
-
532
- </div>
533
-
534
-
535
- <div id="method-i-pgn" class="method-detail ">
536
-
537
- <div class="method-heading">
538
- <span class="method-name">pgn</span><span
539
- class="method-args">()</span>
540
-
541
- <span class="method-click-advice">click to toggle source</span>
542
-
543
- </div>
544
-
545
-
546
- <div class="method-description">
547
-
548
- <p>Returns the PGN rappresenting the game.</p>
549
-
550
-
551
-
552
-
553
- <div class="method-source-code" id="pgn-source">
554
- <pre><span class="ruby-comment"># File lib/chess/game.rb, line 145</span>
555
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">pgn</span>
556
- <span class="ruby-identifier">pgn</span> = <span class="ruby-constant">Chess</span><span class="ruby-operator">::</span><span class="ruby-constant">Pgn</span>.<span class="ruby-identifier">new</span>
557
- <span class="ruby-identifier">pgn</span>.<span class="ruby-identifier">moves</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">moves</span>
558
- <span class="ruby-identifier">pgn</span>.<span class="ruby-identifier">result</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">result</span>
559
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">pgn</span>
560
- <span class="ruby-keyword">end</span></pre>
561
- </div>
562
-
563
- </div>
564
-
565
-
566
-
567
-
568
- </div>
569
-
570
-
571
- <div id="method-i-status" class="method-detail ">
572
-
573
- <div class="method-heading">
574
- <span class="method-name">status</span><span
575
- class="method-args">()</span>
576
-
577
- <span class="method-click-advice">click to toggle source</span>
578
-
579
- </div>
580
-
581
-
582
- <div class="method-description">
583
-
584
- <p>Returns the status of the game.</p>
585
-
586
- <p>Possible states are:</p>
587
- <ul><li><dl class="rdoc-list note-list"><dt><code>in_progress</code>
588
- <dd>
589
- <p>the game is in progress.</p>
590
- </dd></dl>
591
- </li><li><dl class="rdoc-list note-list"><dt><code>white_won</code>
592
- <dd>
593
- <p>white player has won with a checkmate.</p>
594
- </dd></dl>
595
- </li><li><dl class="rdoc-list note-list"><dt><code>black_won</code>
596
- <dd>
597
- <p>black player has won with a checkmate.</p>
598
- </dd></dl>
599
- </li><li><dl class="rdoc-list note-list"><dt><code>white_won_resign</code>
600
- <dd>
601
- <p>white player has won for resign.</p>
602
- </dd></dl>
603
- </li><li><dl class="rdoc-list note-list"><dt><code>black_won_resign</code>
604
- <dd>
605
- <p>black player has won for resign.</p>
606
- </dd></dl>
607
- </li><li><dl class="rdoc-list note-list"><dt><code>stalemate</code>
608
- <dd>
609
- <p>draw for stalemate.</p>
610
- </dd></dl>
611
- </li><li><dl class="rdoc-list note-list"><dt><code>insufficient_material</code>
612
- <dd>
613
- <p>draw for insufficient material to checkmate.</p>
614
- </dd></dl>
615
- </li><li><dl class="rdoc-list note-list"><dt><code>fifty_rule_move</code>
616
- <dd>
617
- <p>draw for fifty rule move.</p>
618
- </dd></dl>
619
- </li><li><dl class="rdoc-list note-list"><dt><code>threefold_repetition</code>
620
- <dd>
621
- <p>draw for threefold_repetition.</p>
622
- </dd></dl>
623
- </li><li><dl class="rdoc-list note-list"><dt><code>unknown</code>
624
- <dd>
625
- <p>something went wrong.</p>
626
- </dd></dl>
627
- </li></ul>
628
-
629
-
630
-
631
-
632
- <div class="method-source-code" id="status-source">
633
- <pre><span class="ruby-comment"># File lib/chess/game.rb, line 109</span>
634
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">status</span>
635
- <span class="ruby-keyword">case</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">result</span>
636
- <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;*&#39;</span>
637
- <span class="ruby-keyword">return</span> <span class="ruby-value">:in_progress</span>
638
- <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;1-0&#39;</span>
639
- <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">board</span>.<span class="ruby-identifier">checkmate?</span>
640
- <span class="ruby-keyword">return</span> <span class="ruby-value">:white_won</span>
641
- <span class="ruby-keyword">else</span>
642
- <span class="ruby-keyword">return</span> <span class="ruby-value">:white_won_resign</span>
643
- <span class="ruby-keyword">end</span>
644
- <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;0-1&#39;</span>
645
- <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">board</span>.<span class="ruby-identifier">checkmate?</span>
646
- <span class="ruby-keyword">return</span> <span class="ruby-value">:black_won</span>
647
- <span class="ruby-keyword">else</span>
648
- <span class="ruby-keyword">return</span> <span class="ruby-value">:black_won_resign</span>
649
- <span class="ruby-keyword">end</span>
650
- <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;1/2-1/2&#39;</span>
651
- <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">board</span>.<span class="ruby-identifier">stalemate?</span>
652
- <span class="ruby-keyword">return</span> <span class="ruby-value">:stalemate</span>
653
- <span class="ruby-keyword">elsif</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">board</span>.<span class="ruby-identifier">insufficient_material?</span>
654
- <span class="ruby-keyword">return</span> <span class="ruby-value">:insufficient_material</span>
655
- <span class="ruby-keyword">elsif</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">board</span>.<span class="ruby-identifier">fifty_rule_move?</span>
656
- <span class="ruby-keyword">return</span> <span class="ruby-value">:fifty_rule_move</span>
657
- <span class="ruby-keyword">elsif</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">threefold_repetition?</span>
658
- <span class="ruby-keyword">return</span> <span class="ruby-value">:threefold_repetition</span>
659
- <span class="ruby-keyword">end</span>
660
- <span class="ruby-keyword">end</span>
661
- <span class="ruby-keyword">return</span> <span class="ruby-value">:unknown</span>
662
- <span class="ruby-keyword">end</span></pre>
663
- </div>
664
-
665
- </div>
666
-
667
-
668
-
669
-
670
- </div>
671
-
672
-
673
- </section>
674
-
675
- </section>
676
- </main>
677
-
678
-
679
- <footer id="validator-badges" role="contentinfo">
680
- <p><a href="http://validator.w3.org/check/referer">Validate</a>
681
- <p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
682
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
683
- </footer>
684
-