chess 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +1 -1
  3. data/Rakefile +3 -4
  4. data/chess.gemspec +5 -0
  5. data/doc/Chess.html +112 -0
  6. data/doc/Chess/BadNotationError.html +107 -0
  7. data/doc/Chess/Board.html +703 -0
  8. data/doc/Chess/CGame.html +1005 -0
  9. data/doc/Chess/Game.html +684 -0
  10. data/doc/Chess/Gnuchess.html +215 -0
  11. data/doc/Chess/IllegalMoveError.html +105 -0
  12. data/doc/Chess/InvalidFenFormatError.html +105 -0
  13. data/doc/Chess/InvalidPgnFormatError.html +105 -0
  14. data/doc/Chess/Pgn.html +309 -0
  15. data/doc/Chess/UTF8Notation.html +174 -0
  16. data/doc/README_rdoc.html +143 -0
  17. data/doc/created.rid +15 -15
  18. data/doc/css/fonts.css +167 -0
  19. data/doc/css/rdoc.css +590 -0
  20. data/doc/fonts/Lato-Light.ttf +0 -0
  21. data/doc/fonts/Lato-LightItalic.ttf +0 -0
  22. data/doc/fonts/Lato-Regular.ttf +0 -0
  23. data/doc/fonts/Lato-RegularItalic.ttf +0 -0
  24. data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  25. data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  26. data/doc/images/add.png +0 -0
  27. data/doc/images/arrow_up.png +0 -0
  28. data/doc/images/brick.png +0 -0
  29. data/doc/images/brick_link.png +0 -0
  30. data/doc/images/bug.png +0 -0
  31. data/doc/images/bullet_black.png +0 -0
  32. data/doc/images/bullet_toggle_minus.png +0 -0
  33. data/doc/images/bullet_toggle_plus.png +0 -0
  34. data/doc/images/date.png +0 -0
  35. data/doc/images/delete.png +0 -0
  36. data/doc/images/find.png +0 -0
  37. data/doc/images/loadingAnimation.gif +0 -0
  38. data/doc/images/macFFBgHack.png +0 -0
  39. data/doc/images/package.png +0 -0
  40. data/doc/images/page_green.png +0 -0
  41. data/doc/images/page_white_text.png +0 -0
  42. data/doc/images/page_white_width.png +0 -0
  43. data/doc/images/plugin.png +0 -0
  44. data/doc/images/ruby.png +0 -0
  45. data/doc/images/tag_blue.png +0 -0
  46. data/doc/images/tag_green.png +0 -0
  47. data/doc/images/transparent.png +0 -0
  48. data/doc/images/wrench.png +0 -0
  49. data/doc/images/wrench_orange.png +0 -0
  50. data/doc/images/zoom.png +0 -0
  51. data/doc/index.html +159 -12
  52. data/doc/js/darkfish.js +161 -0
  53. data/doc/js/jquery.js +4 -0
  54. data/doc/js/navigation.js.gz +0 -0
  55. data/doc/js/search.js +109 -0
  56. data/doc/js/search_index.js +1 -1
  57. data/doc/js/search_index.js.gz +0 -0
  58. data/doc/js/searcher.js +1 -0
  59. data/doc/js/searcher.js.gz +0 -0
  60. data/doc/table_of_contents.html +331 -0
  61. data/ext/chess.c +5 -2
  62. data/ext/game.c +1 -1
  63. data/ext/game.h +1 -1
  64. data/lib/chess/game.rb +1 -1
  65. data/lib/chess/pgn.rb +5 -1
  66. data/lib/chess/version.rb +1 -1
  67. metadata +112 -46
  68. data/doc/apple-touch-icon.png +0 -0
  69. data/doc/classes/Chess.html +0 -162
  70. data/doc/classes/Chess/BadNotationError.html +0 -84
  71. data/doc/classes/Chess/Board.html +0 -795
  72. data/doc/classes/Chess/CGame.html +0 -1168
  73. data/doc/classes/Chess/Game.html +0 -775
  74. data/doc/classes/Chess/Gnuchess.html +0 -206
  75. data/doc/classes/Chess/IllegalMoveError.html +0 -82
  76. data/doc/classes/Chess/InvalidFenFormatError.html +0 -82
  77. data/doc/classes/Chess/InvalidPgnFormatError.html +0 -82
  78. data/doc/classes/Chess/Pgn.html +0 -332
  79. data/doc/classes/Chess/UTF8Notation.html +0 -175
  80. data/doc/css/github.css +0 -123
  81. data/doc/css/main.css +0 -323
  82. data/doc/css/panel.css +0 -384
  83. data/doc/css/reset.css +0 -48
  84. data/doc/favicon.ico +0 -0
  85. data/doc/files/README_rdoc.html +0 -122
  86. data/doc/files/ext/bitboard_c.html +0 -68
  87. data/doc/files/ext/board_c.html +0 -68
  88. data/doc/files/ext/chess_c.html +0 -68
  89. data/doc/files/ext/common_c.html +0 -68
  90. data/doc/files/ext/game_c.html +0 -68
  91. data/doc/files/ext/special_c.html +0 -68
  92. data/doc/files/lib/chess/exceptions_rb.html +0 -94
  93. data/doc/files/lib/chess/game_rb.html +0 -84
  94. data/doc/files/lib/chess/gnuchess_rb.html +0 -84
  95. data/doc/files/lib/chess/pgn_rb.html +0 -84
  96. data/doc/files/lib/chess/utf8_notation_rb.html +0 -84
  97. data/doc/files/lib/chess/version_rb.html +0 -85
  98. data/doc/files/lib/chess_rb.html +0 -84
  99. data/doc/i/arrows.png +0 -0
  100. data/doc/i/results_bg.png +0 -0
  101. data/doc/i/tree_bg.png +0 -0
  102. data/doc/js/highlight.pack.js +0 -1
  103. data/doc/js/jquery-1.3.2.min.js +0 -19
  104. data/doc/js/jquery-effect.js +0 -593
  105. data/doc/js/main.js +0 -24
  106. data/doc/js/searchdoc.js +0 -449
  107. data/doc/panel/index.html +0 -73
  108. data/doc/panel/links.html +0 -34
  109. data/doc/panel/tree.js +0 -1
@@ -1,775 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
- <head>
6
- <title>Chess::Game</title>
7
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
8
- <link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" />
9
- <link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" />
10
- <link rel="stylesheet" href="../../css/github.css" type="text/css" media="screen" />
11
- <script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
12
- <script src="../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
13
- <script src="../../js/main.js" type="text/javascript" charset="utf-8"></script>
14
- <script src="../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>
15
-
16
- </head>
17
-
18
- <body>
19
- <div class="banner">
20
-
21
- <h1>
22
- <span class="type">Class</span>
23
- Chess::Game
24
-
25
- <span class="parent">&lt;
26
-
27
- <a href="CGame.html">Chess::CGame</a>
28
-
29
- </span>
30
-
31
- </h1>
32
- <ul class="files">
33
-
34
- <li><a href="../../files/lib/chess/game_rb.html">lib/chess/game.rb</a></li>
35
-
36
- </ul>
37
- </div>
38
- <div id="bodyContent">
39
- <div id="content">
40
-
41
- <div class="description">
42
-
43
- <p>This class rappresents a chess game.</p>
44
-
45
- </div>
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
- <!-- Method ref -->
61
- <div class="sectiontitle">Methods</div>
62
- <dl class="methods">
63
-
64
- <dt>#</dt>
65
- <dd>
66
- <ul>
67
-
68
-
69
- <li>
70
- <a href="#method-i-3C-3C">&lt;&lt;</a>
71
- </li>
72
-
73
- </ul>
74
- </dd>
75
-
76
- <dt>A</dt>
77
- <dd>
78
- <ul>
79
-
80
-
81
- <li>
82
- <a href="#method-i-active_player">active_player</a>
83
- </li>
84
-
85
- </ul>
86
- </dd>
87
-
88
- <dt>I</dt>
89
- <dd>
90
- <ul>
91
-
92
-
93
- <li>
94
- <a href="#method-i-inactive_player">inactive_player</a>
95
- </li>
96
-
97
- </ul>
98
- </dd>
99
-
100
- <dt>L</dt>
101
- <dd>
102
- <ul>
103
-
104
-
105
- <li>
106
- <a href="#method-c-load_fen">load_fen</a>,
107
- </li>
108
-
109
-
110
- <li>
111
- <a href="#method-c-load_pgn">load_pgn</a>
112
- </li>
113
-
114
- </ul>
115
- </dd>
116
-
117
- <dt>M</dt>
118
- <dd>
119
- <ul>
120
-
121
-
122
- <li>
123
- <a href="#method-i-move">move</a>,
124
- </li>
125
-
126
-
127
- <li>
128
- <a href="#method-i-move-3D">move=</a>,
129
- </li>
130
-
131
-
132
- <li>
133
- <a href="#method-i-moves-3D">moves=</a>
134
- </li>
135
-
136
- </ul>
137
- </dd>
138
-
139
- <dt>N</dt>
140
- <dd>
141
- <ul>
142
-
143
-
144
- <li>
145
- <a href="#method-c-new">new</a>
146
- </li>
147
-
148
- </ul>
149
- </dd>
150
-
151
- <dt>O</dt>
152
- <dd>
153
- <ul>
154
-
155
-
156
- <li>
157
- <a href="#method-i-over-3F">over?</a>
158
- </li>
159
-
160
- </ul>
161
- </dd>
162
-
163
- <dt>P</dt>
164
- <dd>
165
- <ul>
166
-
167
-
168
- <li>
169
- <a href="#method-i-pgn">pgn</a>
170
- </li>
171
-
172
- </ul>
173
- </dd>
174
-
175
- <dt>S</dt>
176
- <dd>
177
- <ul>
178
-
179
-
180
- <li>
181
- <a href="#method-i-status">status</a>
182
- </li>
183
-
184
- </ul>
185
- </dd>
186
-
187
- </dl>
188
-
189
-
190
-
191
-
192
-
193
-
194
-
195
-
196
-
197
-
198
-
199
-
200
-
201
-
202
-
203
-
204
-
205
-
206
- <!-- Methods -->
207
-
208
- <div class="sectiontitle">Class Public methods</div>
209
-
210
- <div class="method">
211
- <div class="title method-title" id="method-c-load_fen">
212
-
213
- <b>load_fen</b>(fen)
214
-
215
- <a href="../../classes/Chess/Game.html#method-c-load_fen" name="method-c-load_fen" class="permalink">Link</a>
216
- </div>
217
-
218
-
219
- <div class="description">
220
- <p>Creates a new game from a FEN string.</p>
221
-
222
- <p>May be raise an <a
223
- href="InvalidFenFormatError.html">InvalidFenFormatError</a>.</p>
224
-
225
- <p><strong>Warning</strong>: this game do not have history before the FEN
226
- placement.</p>
227
- </div>
228
-
229
-
230
-
231
-
232
-
233
-
234
-
235
-
236
- <div class="sourcecode">
237
-
238
- <p class="source-link">
239
- Source:
240
- <a href="javascript:toggleSource('method-c-load_fen_source')" id="l_method-c-load_fen_source">show</a>
241
-
242
- </p>
243
- <div id="method-c-load_fen_source" class="dyn-source">
244
- <pre><span class="ruby-comment"># File lib/chess/game.rb, line 43</span>
245
- <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">self</span>.<span class="ruby-identifier">load_fen</span>(<span class="ruby-identifier">fen</span>)
246
- <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>
247
- <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>
248
- <span class="ruby-identifier">game</span>.<span class="ruby-identifier">set_fen!</span>(<span class="ruby-identifier">fen</span>)
249
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">game</span>
250
- <span class="ruby-keyword">else</span>
251
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidFenFormatError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">fen</span>)
252
- <span class="ruby-keyword">end</span>
253
- <span class="ruby-keyword">end</span></pre>
254
- </div>
255
- </div>
256
-
257
- </div>
258
-
259
- <div class="method">
260
- <div class="title method-title" id="method-c-load_pgn">
261
-
262
- <b>load_pgn</b>(file)
263
-
264
- <a href="../../classes/Chess/Game.html#method-c-load_pgn" name="method-c-load_pgn" class="permalink">Link</a>
265
- </div>
266
-
267
-
268
- <div class="description">
269
- <p>Creates a new game from a file in PGN format.</p>
270
-
271
- <p>May be raise an <a
272
- href="InvalidPgnFormatError.html">InvalidPgnFormatError</a> or <a
273
- href="IllegalMoveError.html">IllegalMoveError</a> or <a
274
- href="BadNotationError.html">BadNotationError</a>.</p>
275
- </div>
276
-
277
-
278
-
279
-
280
-
281
-
282
-
283
-
284
- <div class="sourcecode">
285
-
286
- <p class="source-link">
287
- Source:
288
- <a href="javascript:toggleSource('method-c-load_pgn_source')" id="l_method-c-load_pgn_source">show</a>
289
-
290
- </p>
291
- <div id="method-c-load_pgn_source" class="dyn-source">
292
- <pre><span class="ruby-comment"># File lib/chess/game.rb, line 18</span>
293
- <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">self</span>.<span class="ruby-identifier">load_pgn</span>(<span class="ruby-identifier">file</span>)
294
- <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>)
295
- <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>
296
- <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>) }
297
- <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">game</span>.<span class="ruby-identifier">over?</span>
298
- <span class="ruby-keyword">case</span> <span class="ruby-identifier">pgn</span>.<span class="ruby-identifier">result</span>
299
- <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;1-0&#39;</span>
300
- <span class="ruby-identifier">game</span>.<span class="ruby-identifier">resign</span>(<span class="ruby-value">:black</span>)
301
- <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;0-1&#39;</span>
302
- <span class="ruby-identifier">game</span>.<span class="ruby-identifier">resign</span>(<span class="ruby-value">:white</span>)
303
- <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;1/2-1/2&#39;</span>
304
- <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>
305
- <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>
306
- <span class="ruby-identifier">game</span>.<span class="ruby-identifier">draw</span>
307
- <span class="ruby-keyword">end</span>
308
- <span class="ruby-keyword">end</span>
309
- <span class="ruby-keyword">end</span>
310
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">game</span>
311
- <span class="ruby-keyword">end</span></pre>
312
- </div>
313
- </div>
314
-
315
- </div>
316
-
317
- <div class="method">
318
- <div class="title method-title" id="method-c-new">
319
-
320
- <b>new</b>(moves = [])
321
-
322
- <a href="../../classes/Chess/Game.html#method-c-new" name="method-c-new" class="permalink">Link</a>
323
- </div>
324
-
325
-
326
- <div class="description">
327
- <p>Create a new game. If an array of moves is provided, the moves will be
328
- performed.</p>
329
-
330
- <p>May be raise an <a href="IllegalMoveError.html">IllegalMoveError</a> or <a
331
- href="BadNotationError.html">BadNotationError</a>.</p>
332
- </div>
333
-
334
-
335
-
336
-
337
-
338
-
339
-
340
-
341
- <div class="sourcecode">
342
-
343
- <p class="source-link">
344
- Source:
345
- <a href="javascript:toggleSource('method-c-new_source')" id="l_method-c-new_source">show</a>
346
-
347
- </p>
348
- <div id="method-c-new_source" class="dyn-source">
349
- <pre><span class="ruby-comment"># File lib/chess/game.rb, line 11</span>
350
- <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">initialize</span>(<span class="ruby-identifier">moves</span> = [])
351
- <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>) }
352
- <span class="ruby-keyword">end</span></pre>
353
- </div>
354
- </div>
355
-
356
- </div>
357
-
358
- <div class="sectiontitle">Instance Public methods</div>
359
-
360
- <div class="method">
361
- <div class="title method-title" id="method-i-3C-3C">
362
-
363
- <b>&lt;&lt;</b>(m)
364
-
365
- <a href="../../classes/Chess/Game.html#method-i-3C-3C" name="method-i-3C-3C" class="permalink">Link</a>
366
- </div>
367
-
368
-
369
- <div class="description">
370
-
371
- </div>
372
-
373
-
374
-
375
-
376
-
377
- <div class="aka">
378
- Alias for: <a href="Game.html#method-i-move">move</a>
379
- </div>
380
-
381
-
382
-
383
- </div>
384
-
385
- <div class="method">
386
- <div class="title method-title" id="method-i-active_player">
387
-
388
- <b>active_player</b>()
389
-
390
- <a href="../../classes/Chess/Game.html#method-i-active_player" name="method-i-active_player" class="permalink">Link</a>
391
- </div>
392
-
393
-
394
- <div class="description">
395
- <p>Returns <code>:white</code> if the active player is the white player,
396
- <code>:black</code> otherwise.</p>
397
- </div>
398
-
399
-
400
-
401
-
402
-
403
-
404
-
405
-
406
- <div class="sourcecode">
407
-
408
- <p class="source-link">
409
- Source:
410
- <a href="javascript:toggleSource('method-i-active_player_source')" id="l_method-i-active_player_source">show</a>
411
-
412
- </p>
413
- <div id="method-i-active_player_source" class="dyn-source">
414
- <pre><span class="ruby-comment"># File lib/chess/game.rb, line 87</span>
415
- <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">active_player</span>
416
- <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>
417
- <span class="ruby-keyword">end</span></pre>
418
- </div>
419
- </div>
420
-
421
- </div>
422
-
423
- <div class="method">
424
- <div class="title method-title" id="method-i-inactive_player">
425
-
426
- <b>inactive_player</b>()
427
-
428
- <a href="../../classes/Chess/Game.html#method-i-inactive_player" name="method-i-inactive_player" class="permalink">Link</a>
429
- </div>
430
-
431
-
432
- <div class="description">
433
- <p>Returns <code>:white</code> if the inactive player is the white player,
434
- <code>:black</code> otherwise.</p>
435
- </div>
436
-
437
-
438
-
439
-
440
-
441
-
442
-
443
-
444
- <div class="sourcecode">
445
-
446
- <p class="source-link">
447
- Source:
448
- <a href="javascript:toggleSource('method-i-inactive_player_source')" id="l_method-i-inactive_player_source">show</a>
449
-
450
- </p>
451
- <div id="method-i-inactive_player_source" class="dyn-source">
452
- <pre><span class="ruby-comment"># File lib/chess/game.rb, line 92</span>
453
- <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">inactive_player</span>
454
- <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>
455
- <span class="ruby-keyword">end</span></pre>
456
- </div>
457
- </div>
458
-
459
- </div>
460
-
461
- <div class="method">
462
- <div class="title method-title" id="method-i-move">
463
-
464
- <b>move</b>(m)
465
-
466
- <a href="../../classes/Chess/Game.html#method-i-move" name="method-i-move" class="permalink">Link</a>
467
- </div>
468
-
469
-
470
- <div class="description">
471
- <p>Make a move. This add a new <a href="Board.html">Board</a> in the
472
- Storyboard.</p>
473
-
474
- <p>Parameters are:</p>
475
- <dl class="rdoc-list note-list"><dt>m
476
- <dd>
477
- <p>represents the short algebraic chess notation string of the move.
478
- <code>m</code> can be <em>from_square</em> plus <em>to_square</em>
479
- <em>(&#39;e2e4&#39;, …, &#39;b1c3&#39;)</em> (coordinate chess notation).</p>
480
- </dd></dl>
481
-
482
- <p>This method returns a string that represents the short algebraic chess
483
- notation of the move.</p>
484
-
485
- <p>Raise an <a href="IllegalMoveError.html">IllegalMoveError</a> if the move
486
- is illegal. Raise an <a href="BadNotationError.html">BadNotationError</a>
487
- if the short algebraic chess notation is malformed.</p>
488
- </div>
489
-
490
-
491
-
492
- <div class="aka">
493
- Also aliased as: <a href="Game.html#method-i-move-3D">move=</a>, <a href="Game.html#method-i-3C-3C">&lt;&lt;</a>
494
- </div>
495
-
496
-
497
-
498
-
499
-
500
-
501
- <div class="sourcecode">
502
-
503
- <p class="source-link">
504
- Source:
505
- <a href="javascript:toggleSource('method-i-move_source')" id="l_method-i-move_source">show</a>
506
-
507
- </p>
508
- <div id="method-i-move_source" class="dyn-source">
509
- <pre><span class="ruby-comment"># File lib/chess/game.rb, line 66</span>
510
- <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">move</span>(<span class="ruby-identifier">m</span>)
511
- <span class="ruby-keyword">begin</span>
512
- <span class="ruby-identifier">expand</span> = <span class="ruby-identifier">expand_move</span>(<span class="ruby-identifier">m</span>)
513
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">expand</span>[<span class="ruby-value">:from</span>]
514
- <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>])
515
- <span class="ruby-keyword">else</span>
516
- <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>])
517
- <span class="ruby-keyword">end</span>
518
- <span class="ruby-keyword">rescue</span> <span class="ruby-constant">IllegalMoveError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
519
- <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>)
520
- <span class="ruby-keyword">end</span>
521
- <span class="ruby-keyword">end</span></pre>
522
- </div>
523
- </div>
524
-
525
- </div>
526
-
527
- <div class="method">
528
- <div class="title method-title" id="method-i-move-3D">
529
-
530
- <b>move=</b>(m)
531
-
532
- <a href="../../classes/Chess/Game.html#method-i-move-3D" name="method-i-move-3D" class="permalink">Link</a>
533
- </div>
534
-
535
-
536
- <div class="description">
537
-
538
- </div>
539
-
540
-
541
-
542
-
543
-
544
- <div class="aka">
545
- Alias for: <a href="Game.html#method-i-move">move</a>
546
- </div>
547
-
548
-
549
-
550
- </div>
551
-
552
- <div class="method">
553
- <div class="title method-title" id="method-i-moves-3D">
554
-
555
- <b>moves=</b>(moves)
556
-
557
- <a href="../../classes/Chess/Game.html#method-i-moves-3D" name="method-i-moves-3D" class="permalink">Link</a>
558
- </div>
559
-
560
-
561
- <div class="description">
562
- <p>Make the array of moves.</p>
563
- </div>
564
-
565
-
566
-
567
-
568
-
569
-
570
-
571
-
572
- <div class="sourcecode">
573
-
574
- <p class="source-link">
575
- Source:
576
- <a href="javascript:toggleSource('method-i-moves-3D_source')" id="l_method-i-moves-3D_source">show</a>
577
-
578
- </p>
579
- <div id="method-i-moves-3D_source" class="dyn-source">
580
- <pre><span class="ruby-comment"># File lib/chess/game.rb, line 82</span>
581
- <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">moves=</span>(<span class="ruby-identifier">moves</span>)
582
- <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>) }
583
- <span class="ruby-keyword">end</span></pre>
584
- </div>
585
- </div>
586
-
587
- </div>
588
-
589
- <div class="method">
590
- <div class="title method-title" id="method-i-over-3F">
591
-
592
- <b>over?</b>()
593
-
594
- <a href="../../classes/Chess/Game.html#method-i-over-3F" name="method-i-over-3F" class="permalink">Link</a>
595
- </div>
596
-
597
-
598
- <div class="description">
599
- <p>Returns <code>true</code> if the game is over</p>
600
- </div>
601
-
602
-
603
-
604
-
605
-
606
-
607
-
608
-
609
- <div class="sourcecode">
610
-
611
- <p class="source-link">
612
- Source:
613
- <a href="javascript:toggleSource('method-i-over-3F_source')" id="l_method-i-over-3F_source">show</a>
614
-
615
- </p>
616
- <div id="method-i-over-3F_source" class="dyn-source">
617
- <pre><span class="ruby-comment"># File lib/chess/game.rb, line 140</span>
618
- <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">over?</span>
619
- <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>
620
- <span class="ruby-keyword">end</span></pre>
621
- </div>
622
- </div>
623
-
624
- </div>
625
-
626
- <div class="method">
627
- <div class="title method-title" id="method-i-pgn">
628
-
629
- <b>pgn</b>()
630
-
631
- <a href="../../classes/Chess/Game.html#method-i-pgn" name="method-i-pgn" class="permalink">Link</a>
632
- </div>
633
-
634
-
635
- <div class="description">
636
- <p>Returns the PGN rappresenting the game.</p>
637
- </div>
638
-
639
-
640
-
641
-
642
-
643
-
644
-
645
-
646
- <div class="sourcecode">
647
-
648
- <p class="source-link">
649
- Source:
650
- <a href="javascript:toggleSource('method-i-pgn_source')" id="l_method-i-pgn_source">show</a>
651
-
652
- </p>
653
- <div id="method-i-pgn_source" class="dyn-source">
654
- <pre><span class="ruby-comment"># File lib/chess/game.rb, line 145</span>
655
- <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">pgn</span>
656
- <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>
657
- <span class="ruby-identifier">pgn</span>.<span class="ruby-identifier">moves</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">moves</span>
658
- <span class="ruby-identifier">pgn</span>.<span class="ruby-identifier">result</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">result</span>
659
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">pgn</span>
660
- <span class="ruby-keyword">end</span></pre>
661
- </div>
662
- </div>
663
-
664
- </div>
665
-
666
- <div class="method">
667
- <div class="title method-title" id="method-i-status">
668
-
669
- <b>status</b>()
670
-
671
- <a href="../../classes/Chess/Game.html#method-i-status" name="method-i-status" class="permalink">Link</a>
672
- </div>
673
-
674
-
675
- <div class="description">
676
- <p>Returns the status of the game.</p>
677
-
678
- <p>Possible states are:</p>
679
- <ul><li><dl class="rdoc-list note-list"><dt>in_progress
680
- <dd>
681
- <p>the game is in progress.</p>
682
- </dd></dl>
683
- </li><li><dl class="rdoc-list note-list"><dt><code>white_won</code>
684
- <dd>
685
- <p>white player has won with a checkmate.</p>
686
- </dd></dl>
687
- </li><li><dl class="rdoc-list note-list"><dt><code>black_won</code>
688
- <dd>
689
- <p>black player has won with a checkmate.</p>
690
- </dd></dl>
691
- </li><li><dl class="rdoc-list note-list"><dt><code>white_won_resign</code>
692
- <dd>
693
- <p>white player has won for resign.</p>
694
- </dd></dl>
695
- </li><li><dl class="rdoc-list note-list"><dt><code>black_won_resign</code>
696
- <dd>
697
- <p>black player has won for resign.</p>
698
- </dd></dl>
699
- </li><li><dl class="rdoc-list note-list"><dt><code>stalemate</code>
700
- <dd>
701
- <p>draw for stalemate.</p>
702
- </dd></dl>
703
- </li><li><dl class="rdoc-list note-list"><dt><code>insufficient_material</code>
704
- <dd>
705
- <p>draw for insufficient material to checkmate.</p>
706
- </dd></dl>
707
- </li><li><dl class="rdoc-list note-list"><dt><code>fifty_rule_move</code>
708
- <dd>
709
- <p>draw for fifty rule move.</p>
710
- </dd></dl>
711
- </li><li><dl class="rdoc-list note-list"><dt><code>threefold_repetition</code>
712
- <dd>
713
- <p>draw for threefold_repetition.</p>
714
- </dd></dl>
715
- </li><li><dl class="rdoc-list note-list"><dt><code>unknown</code>
716
- <dd>
717
- <p>something went wrong.</p>
718
- </dd></dl>
719
- </li></ul>
720
- </div>
721
-
722
-
723
-
724
-
725
-
726
-
727
-
728
-
729
- <div class="sourcecode">
730
-
731
- <p class="source-link">
732
- Source:
733
- <a href="javascript:toggleSource('method-i-status_source')" id="l_method-i-status_source">show</a>
734
-
735
- </p>
736
- <div id="method-i-status_source" class="dyn-source">
737
- <pre><span class="ruby-comment"># File lib/chess/game.rb, line 109</span>
738
- <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">status</span>
739
- <span class="ruby-keyword">case</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">result</span>
740
- <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;*&#39;</span>
741
- <span class="ruby-keyword">return</span> <span class="ruby-value">:in_progress</span>
742
- <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;1-0&#39;</span>
743
- <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">board</span>.<span class="ruby-identifier">checkmate?</span>
744
- <span class="ruby-keyword">return</span> <span class="ruby-value">:white_won</span>
745
- <span class="ruby-keyword">else</span>
746
- <span class="ruby-keyword">return</span> <span class="ruby-value">:white_won_resign</span>
747
- <span class="ruby-keyword">end</span>
748
- <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;0-1&#39;</span>
749
- <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">board</span>.<span class="ruby-identifier">checkmate?</span>
750
- <span class="ruby-keyword">return</span> <span class="ruby-value">:black_won</span>
751
- <span class="ruby-keyword">else</span>
752
- <span class="ruby-keyword">return</span> <span class="ruby-value">:black_won_resign</span>
753
- <span class="ruby-keyword">end</span>
754
- <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;1/2-1/2&#39;</span>
755
- <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">board</span>.<span class="ruby-identifier">stalemate?</span>
756
- <span class="ruby-keyword">return</span> <span class="ruby-value">:stalemate</span>
757
- <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>
758
- <span class="ruby-keyword">return</span> <span class="ruby-value">:insufficient_material</span>
759
- <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>
760
- <span class="ruby-keyword">return</span> <span class="ruby-value">:fifty_rule_move</span>
761
- <span class="ruby-keyword">elsif</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">threefold_repetition?</span>
762
- <span class="ruby-keyword">return</span> <span class="ruby-value">:threefold_repetition</span>
763
- <span class="ruby-keyword">end</span>
764
- <span class="ruby-keyword">end</span>
765
- <span class="ruby-keyword">return</span> <span class="ruby-value">:unknown</span>
766
- <span class="ruby-keyword">end</span></pre>
767
- </div>
768
- </div>
769
-
770
- </div>
771
- </div>
772
-
773
- </div>
774
- </body>
775
- </html>