chess 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (501) hide show
  1. checksums.yaml +7 -0
  2. data/README.rdoc +6 -2
  3. data/Rakefile +1 -1
  4. data/ext/board.c +1 -4
  5. data/ext/chess.c +98 -15
  6. data/ext/chess.h +5 -3
  7. data/ext/common.c +3 -3
  8. data/ext/common.h +4 -4
  9. data/ext/game.c +22 -7
  10. data/lib/chess/game.rb +48 -19
  11. data/lib/chess/gnuchess.rb +39 -12
  12. data/lib/chess/pgn.rb +2 -1
  13. data/lib/chess/version.rb +1 -1
  14. data/test/pgn_collection/checkmate/{black_wins → black_won}/0001.pgn +0 -0
  15. data/test/pgn_collection/checkmate/{black_wins → black_won}/0002.pgn +0 -0
  16. data/test/pgn_collection/checkmate/{black_wins → black_won}/0003.pgn +0 -0
  17. data/test/pgn_collection/checkmate/{black_wins → black_won}/0004.pgn +0 -0
  18. data/test/pgn_collection/checkmate/{black_wins → black_won}/0005.pgn +0 -0
  19. data/test/pgn_collection/checkmate/{black_wins → black_won}/0006.pgn +0 -0
  20. data/test/pgn_collection/checkmate/{black_wins → black_won}/0007.pgn +0 -0
  21. data/test/pgn_collection/checkmate/{black_wins → black_won}/0008.pgn +0 -0
  22. data/test/pgn_collection/checkmate/{black_wins → black_won}/0009.pgn +0 -0
  23. data/test/pgn_collection/checkmate/{black_wins → black_won}/0010.pgn +0 -0
  24. data/test/pgn_collection/checkmate/{black_wins → black_won}/0011.pgn +0 -0
  25. data/test/pgn_collection/checkmate/{black_wins → black_won}/0012.pgn +0 -0
  26. data/test/pgn_collection/checkmate/{black_wins → black_won}/0013.pgn +0 -0
  27. data/test/pgn_collection/checkmate/{black_wins → black_won}/0014.pgn +0 -0
  28. data/test/pgn_collection/checkmate/{black_wins → black_won}/0015.pgn +0 -0
  29. data/test/pgn_collection/checkmate/{black_wins → black_won}/0016.pgn +0 -0
  30. data/test/pgn_collection/checkmate/{black_wins → black_won}/0017.pgn +0 -0
  31. data/test/pgn_collection/checkmate/{black_wins → black_won}/0018.pgn +0 -0
  32. data/test/pgn_collection/checkmate/{black_wins → black_won}/0019.pgn +0 -0
  33. data/test/pgn_collection/checkmate/{black_wins → black_won}/0020.pgn +0 -0
  34. data/test/pgn_collection/checkmate/{black_wins → black_won}/0021.pgn +0 -0
  35. data/test/pgn_collection/checkmate/{black_wins → black_won}/0022.pgn +0 -0
  36. data/test/pgn_collection/checkmate/{black_wins → black_won}/0023.pgn +0 -0
  37. data/test/pgn_collection/checkmate/{black_wins → black_won}/0024.pgn +0 -0
  38. data/test/pgn_collection/checkmate/{black_wins → black_won}/0025.pgn +0 -0
  39. data/test/pgn_collection/checkmate/{black_wins → black_won}/0026.pgn +0 -0
  40. data/test/pgn_collection/checkmate/{black_wins → black_won}/0027.pgn +0 -0
  41. data/test/pgn_collection/checkmate/{black_wins → black_won}/0028.pgn +0 -0
  42. data/test/pgn_collection/checkmate/{black_wins → black_won}/0029.pgn +0 -0
  43. data/test/pgn_collection/checkmate/{black_wins → black_won}/0030.pgn +0 -0
  44. data/test/pgn_collection/checkmate/{black_wins → black_won}/0031.pgn +0 -0
  45. data/test/pgn_collection/checkmate/{black_wins → black_won}/0032.pgn +0 -0
  46. data/test/pgn_collection/checkmate/{black_wins → black_won}/0033.pgn +0 -0
  47. data/test/pgn_collection/checkmate/{black_wins → black_won}/0034.pgn +0 -0
  48. data/test/pgn_collection/checkmate/{black_wins → black_won}/0035.pgn +0 -0
  49. data/test/pgn_collection/checkmate/{black_wins → black_won}/0036.pgn +0 -0
  50. data/test/pgn_collection/checkmate/{black_wins → black_won}/0037.pgn +0 -0
  51. data/test/pgn_collection/checkmate/{black_wins → black_won}/0038.pgn +0 -0
  52. data/test/pgn_collection/checkmate/{black_wins → black_won}/0039.pgn +0 -0
  53. data/test/pgn_collection/checkmate/{black_wins → black_won}/0040.pgn +0 -0
  54. data/test/pgn_collection/checkmate/{black_wins → black_won}/0041.pgn +0 -0
  55. data/test/pgn_collection/checkmate/{black_wins → black_won}/0042.pgn +0 -0
  56. data/test/pgn_collection/checkmate/{black_wins → black_won}/0043.pgn +0 -0
  57. data/test/pgn_collection/checkmate/{black_wins → black_won}/0044.pgn +0 -0
  58. data/test/pgn_collection/checkmate/{black_wins → black_won}/0045.pgn +0 -0
  59. data/test/pgn_collection/checkmate/{black_wins → black_won}/0046.pgn +0 -0
  60. data/test/pgn_collection/checkmate/{black_wins → black_won}/0047.pgn +0 -0
  61. data/test/pgn_collection/checkmate/{black_wins → black_won}/0048.pgn +0 -0
  62. data/test/pgn_collection/checkmate/{black_wins → black_won}/0049.pgn +0 -0
  63. data/test/pgn_collection/checkmate/{black_wins → black_won}/0050.pgn +0 -0
  64. data/test/pgn_collection/checkmate/{black_wins → black_won}/0051.pgn +0 -0
  65. data/test/pgn_collection/checkmate/{black_wins → black_won}/0052.pgn +0 -0
  66. data/test/pgn_collection/checkmate/{black_wins → black_won}/0053.pgn +0 -0
  67. data/test/pgn_collection/checkmate/{black_wins → black_won}/0054.pgn +0 -0
  68. data/test/pgn_collection/checkmate/{black_wins → black_won}/0055.pgn +0 -0
  69. data/test/pgn_collection/checkmate/{black_wins → black_won}/0056.pgn +0 -0
  70. data/test/pgn_collection/checkmate/{black_wins → black_won}/0057.pgn +0 -0
  71. data/test/pgn_collection/checkmate/{black_wins → black_won}/0058.pgn +0 -0
  72. data/test/pgn_collection/checkmate/{black_wins → black_won}/0059.pgn +0 -0
  73. data/test/pgn_collection/checkmate/{black_wins → black_won}/0060.pgn +0 -0
  74. data/test/pgn_collection/checkmate/{black_wins → black_won}/0061.pgn +0 -0
  75. data/test/pgn_collection/checkmate/{black_wins → black_won}/0062.pgn +0 -0
  76. data/test/pgn_collection/checkmate/{black_wins → black_won}/0063.pgn +0 -0
  77. data/test/pgn_collection/checkmate/{black_wins → black_won}/0064.pgn +0 -0
  78. data/test/pgn_collection/checkmate/{black_wins → black_won}/0065.pgn +0 -0
  79. data/test/pgn_collection/checkmate/{black_wins → black_won}/0066.pgn +0 -0
  80. data/test/pgn_collection/checkmate/{black_wins → black_won}/0067.pgn +0 -0
  81. data/test/pgn_collection/checkmate/{black_wins → black_won}/0068.pgn +0 -0
  82. data/test/pgn_collection/checkmate/{black_wins → black_won}/0069.pgn +0 -0
  83. data/test/pgn_collection/checkmate/{black_wins → black_won}/0070.pgn +0 -0
  84. data/test/pgn_collection/checkmate/{black_wins → black_won}/0071.pgn +0 -0
  85. data/test/pgn_collection/checkmate/{black_wins → black_won}/0072.pgn +0 -0
  86. data/test/pgn_collection/checkmate/{black_wins → black_won}/0073.pgn +0 -0
  87. data/test/pgn_collection/checkmate/{black_wins → black_won}/0074.pgn +0 -0
  88. data/test/pgn_collection/checkmate/{black_wins → black_won}/0075.pgn +0 -0
  89. data/test/pgn_collection/checkmate/{black_wins → black_won}/0076.pgn +0 -0
  90. data/test/pgn_collection/checkmate/{black_wins → black_won}/0077.pgn +0 -0
  91. data/test/pgn_collection/checkmate/{black_wins → black_won}/0078.pgn +0 -0
  92. data/test/pgn_collection/checkmate/{white_wins → white_won}/0001.pgn +0 -0
  93. data/test/pgn_collection/checkmate/{white_wins → white_won}/0002.pgn +0 -0
  94. data/test/pgn_collection/checkmate/{white_wins → white_won}/0003.pgn +0 -0
  95. data/test/pgn_collection/checkmate/{white_wins → white_won}/0004.pgn +0 -0
  96. data/test/pgn_collection/checkmate/{white_wins → white_won}/0005.pgn +0 -0
  97. data/test/pgn_collection/checkmate/{white_wins → white_won}/0006.pgn +0 -0
  98. data/test/pgn_collection/checkmate/{white_wins → white_won}/0007.pgn +0 -0
  99. data/test/pgn_collection/checkmate/{white_wins → white_won}/0008.pgn +0 -0
  100. data/test/pgn_collection/checkmate/{white_wins → white_won}/0009.pgn +0 -0
  101. data/test/pgn_collection/checkmate/{white_wins → white_won}/0010.pgn +0 -0
  102. data/test/pgn_collection/checkmate/{white_wins → white_won}/0011.pgn +0 -0
  103. data/test/pgn_collection/checkmate/{white_wins → white_won}/0012.pgn +0 -0
  104. data/test/pgn_collection/checkmate/{white_wins → white_won}/0013.pgn +0 -0
  105. data/test/pgn_collection/checkmate/{white_wins → white_won}/0014.pgn +0 -0
  106. data/test/pgn_collection/checkmate/{white_wins → white_won}/0015.pgn +0 -0
  107. data/test/pgn_collection/checkmate/{white_wins → white_won}/0016.pgn +0 -0
  108. data/test/pgn_collection/checkmate/{white_wins → white_won}/0017.pgn +0 -0
  109. data/test/pgn_collection/checkmate/{white_wins → white_won}/0018.pgn +0 -0
  110. data/test/pgn_collection/checkmate/{white_wins → white_won}/0019.pgn +0 -0
  111. data/test/pgn_collection/checkmate/{white_wins → white_won}/0020.pgn +0 -0
  112. data/test/pgn_collection/checkmate/{white_wins → white_won}/0021.pgn +0 -0
  113. data/test/pgn_collection/checkmate/{white_wins → white_won}/0022.pgn +0 -0
  114. data/test/pgn_collection/checkmate/{white_wins → white_won}/0023.pgn +0 -0
  115. data/test/pgn_collection/checkmate/{white_wins → white_won}/0024.pgn +0 -0
  116. data/test/pgn_collection/checkmate/{white_wins → white_won}/0025.pgn +0 -0
  117. data/test/pgn_collection/checkmate/{white_wins → white_won}/0026.pgn +0 -0
  118. data/test/pgn_collection/checkmate/{white_wins → white_won}/0027.pgn +0 -0
  119. data/test/pgn_collection/checkmate/{white_wins → white_won}/0028.pgn +0 -0
  120. data/test/pgn_collection/checkmate/{white_wins → white_won}/0029.pgn +0 -0
  121. data/test/pgn_collection/checkmate/{white_wins → white_won}/0030.pgn +0 -0
  122. data/test/pgn_collection/checkmate/{white_wins → white_won}/0031.pgn +0 -0
  123. data/test/pgn_collection/checkmate/{white_wins → white_won}/0032.pgn +0 -0
  124. data/test/pgn_collection/checkmate/{white_wins → white_won}/0033.pgn +0 -0
  125. data/test/pgn_collection/checkmate/{white_wins → white_won}/0034.pgn +0 -0
  126. data/test/pgn_collection/checkmate/{white_wins → white_won}/0035.pgn +0 -0
  127. data/test/pgn_collection/checkmate/{white_wins → white_won}/0036.pgn +0 -0
  128. data/test/pgn_collection/checkmate/{white_wins → white_won}/0037.pgn +0 -0
  129. data/test/pgn_collection/checkmate/{white_wins → white_won}/0038.pgn +0 -0
  130. data/test/pgn_collection/checkmate/{white_wins → white_won}/0039.pgn +0 -0
  131. data/test/pgn_collection/checkmate/{white_wins → white_won}/0040.pgn +0 -0
  132. data/test/pgn_collection/checkmate/{white_wins → white_won}/0041.pgn +0 -0
  133. data/test/pgn_collection/checkmate/{white_wins → white_won}/0042.pgn +0 -0
  134. data/test/pgn_collection/checkmate/{white_wins → white_won}/0043.pgn +0 -0
  135. data/test/pgn_collection/checkmate/{white_wins → white_won}/0044.pgn +0 -0
  136. data/test/pgn_collection/checkmate/{white_wins → white_won}/0045.pgn +0 -0
  137. data/test/pgn_collection/checkmate/{white_wins → white_won}/0046.pgn +0 -0
  138. data/test/pgn_collection/checkmate/{white_wins → white_won}/0047.pgn +0 -0
  139. data/test/pgn_collection/checkmate/{white_wins → white_won}/0048.pgn +0 -0
  140. data/test/pgn_collection/checkmate/{white_wins → white_won}/0049.pgn +0 -0
  141. data/test/pgn_collection/checkmate/{white_wins → white_won}/0050.pgn +0 -0
  142. data/test/pgn_collection/checkmate/{white_wins → white_won}/0051.pgn +0 -0
  143. data/test/pgn_collection/checkmate/{white_wins → white_won}/0052.pgn +0 -0
  144. data/test/pgn_collection/checkmate/{white_wins → white_won}/0053.pgn +0 -0
  145. data/test/pgn_collection/checkmate/{white_wins → white_won}/0054.pgn +0 -0
  146. data/test/pgn_collection/checkmate/{white_wins → white_won}/0055.pgn +0 -0
  147. data/test/pgn_collection/checkmate/{white_wins → white_won}/0056.pgn +0 -0
  148. data/test/pgn_collection/checkmate/{white_wins → white_won}/0057.pgn +0 -0
  149. data/test/pgn_collection/checkmate/{white_wins → white_won}/0058.pgn +0 -0
  150. data/test/pgn_collection/checkmate/{white_wins → white_won}/0059.pgn +0 -0
  151. data/test/pgn_collection/checkmate/{white_wins → white_won}/0060.pgn +0 -0
  152. data/test/pgn_collection/checkmate/{white_wins → white_won}/0061.pgn +0 -0
  153. data/test/pgn_collection/checkmate/{white_wins → white_won}/0062.pgn +0 -0
  154. data/test/pgn_collection/checkmate/{white_wins → white_won}/0063.pgn +0 -0
  155. data/test/pgn_collection/checkmate/{white_wins → white_won}/0064.pgn +0 -0
  156. data/test/pgn_collection/checkmate/{white_wins → white_won}/0065.pgn +0 -0
  157. data/test/pgn_collection/checkmate/{white_wins → white_won}/0066.pgn +0 -0
  158. data/test/pgn_collection/checkmate/{white_wins → white_won}/0067.pgn +0 -0
  159. data/test/pgn_collection/checkmate/{white_wins → white_won}/0068.pgn +0 -0
  160. data/test/pgn_collection/checkmate/{white_wins → white_won}/0069.pgn +0 -0
  161. data/test/pgn_collection/checkmate/{white_wins → white_won}/0070.pgn +0 -0
  162. data/test/pgn_collection/checkmate/{white_wins → white_won}/0071.pgn +0 -0
  163. data/test/pgn_collection/checkmate/{white_wins → white_won}/0072.pgn +0 -0
  164. data/test/pgn_collection/checkmate/{white_wins → white_won}/0073.pgn +0 -0
  165. data/test/pgn_collection/checkmate/{white_wins → white_won}/0074.pgn +0 -0
  166. data/test/pgn_collection/{valid/checkmate/ciccio.pgn → checkmate/white_won/0075.pgn} +0 -1
  167. data/test/pgn_collection/valid/0003.pgn +13 -19
  168. data/test/pgn_collection/valid/0004.pgn +15 -18
  169. data/test/pgn_collection/valid/0006.pgn +12 -13
  170. data/test/pgn_collection/valid/0007.pgn +16 -18
  171. data/test/pgn_collection/valid/0008.pgn +12 -14
  172. data/test/pgn_collection/valid/0017.pgn +13 -20
  173. data/test/pgn_collection/valid/0019.pgn +16 -18
  174. data/test/pgn_collection/valid/0022.pgn +14 -19
  175. data/test/pgn_collection/valid/0029.pgn +12 -20
  176. data/test/pgn_collection/valid/0031.pgn +13 -18
  177. data/test/pgn_collection/valid/0035.pgn +12 -16
  178. data/test/pgn_collection/valid/0040.pgn +12 -17
  179. data/test/pgn_collection/valid/0042.pgn +13 -17
  180. data/test/pgn_collection/valid/0043.pgn +11 -20
  181. data/test/pgn_collection/valid/0044.pgn +15 -22
  182. data/test/pgn_collection/valid/0048.pgn +12 -15
  183. data/test/pgn_collection/valid/0052.pgn +18 -26
  184. data/test/pgn_collection/valid/0058.pgn +10 -12
  185. data/test/pgn_collection/valid/0059.pgn +13 -15
  186. data/test/pgn_collection/valid/0064.pgn +13 -17
  187. data/test/pgn_collection/valid/0066.pgn +12 -14
  188. data/test/pgn_collection/valid/0067.pgn +14 -15
  189. data/test/pgn_collection/valid/0068.pgn +15 -18
  190. data/test/pgn_collection/valid/0071.pgn +11 -15
  191. data/test/pgn_collection/valid/0075.pgn +13 -14
  192. data/test/pgn_collection/valid/0076.pgn +14 -20
  193. data/test/pgn_collection/valid/0077.pgn +11 -14
  194. data/test/pgn_collection/valid/0078.pgn +14 -22
  195. data/test/pgn_collection/valid/0080.pgn +13 -17
  196. data/test/pgn_collection/valid/0083.pgn +17 -23
  197. data/test/pgn_collection/valid/0085.pgn +18 -21
  198. data/test/pgn_collection/valid/0088.pgn +14 -19
  199. data/test/pgn_collection/valid/0089.pgn +16 -18
  200. data/test/pgn_collection/valid/0090.pgn +11 -14
  201. data/test/pgn_collection/valid/0093.pgn +14 -19
  202. data/test/pgn_collection/valid/0099.pgn +14 -17
  203. data/test/pgn_collection/valid/0100.pgn +16 -21
  204. data/test/pgn_collection/valid/0102.pgn +17 -19
  205. data/test/pgn_collection/valid/0110.pgn +13 -18
  206. data/test/pgn_collection/valid/0113.pgn +15 -20
  207. data/test/pgn_collection/valid/0116.pgn +15 -17
  208. data/test/pgn_collection/valid/0118.pgn +14 -20
  209. data/test/pgn_collection/valid/0124.pgn +12 -20
  210. data/test/pgn_collection/valid/0132.pgn +12 -17
  211. data/test/pgn_collection/valid/0134.pgn +15 -17
  212. data/test/pgn_collection/valid/0135.pgn +17 -19
  213. data/test/pgn_collection/valid/0139.pgn +19 -21
  214. data/test/pgn_collection/valid/0144.pgn +16 -23
  215. data/test/pgn_collection/valid/0146.pgn +12 -14
  216. data/test/pgn_collection/valid/0148.pgn +15 -20
  217. data/test/pgn_collection/valid/0149.pgn +12 -16
  218. data/test/pgn_collection/valid/0152.pgn +7 -14
  219. data/test/pgn_collection/valid/0153.pgn +16 -22
  220. data/test/pgn_collection/valid/0154.pgn +13 -15
  221. data/test/pgn_collection/valid/0161.pgn +16 -22
  222. data/test/pgn_collection/valid/0163.pgn +11 -15
  223. data/test/pgn_collection/valid/0164.pgn +15 -17
  224. data/test/pgn_collection/valid/0169.pgn +15 -21
  225. data/test/pgn_collection/valid/0171.pgn +11 -15
  226. data/test/pgn_collection/valid/0173.pgn +11 -13
  227. data/test/pgn_collection/valid/0174.pgn +16 -24
  228. data/test/pgn_collection/valid/0177.pgn +15 -19
  229. data/test/pgn_collection/valid/0178.pgn +16 -21
  230. data/test/pgn_collection/valid/0185.pgn +11 -14
  231. data/test/pgn_collection/valid/0186.pgn +13 -15
  232. data/test/pgn_collection/valid/0187.pgn +17 -19
  233. data/test/pgn_collection/valid/0189.pgn +16 -20
  234. data/test/pgn_collection/valid/0191.pgn +18 -26
  235. data/test/pgn_collection/valid/0193.pgn +16 -18
  236. data/test/pgn_collection/valid/0196.pgn +16 -21
  237. data/test/pgn_collection/valid/0197.pgn +15 -21
  238. data/test/pgn_collection/valid/0198.pgn +15 -20
  239. data/test/pgn_collection/valid/0199.pgn +11 -13
  240. data/test/pgn_collection/valid/0202.pgn +10 -12
  241. data/test/pgn_collection/valid/0203.pgn +11 -13
  242. data/test/pgn_collection/valid/0204.pgn +12 -14
  243. data/test/pgn_collection/valid/0205.pgn +10 -13
  244. data/test/pgn_collection/valid/0209.pgn +14 -20
  245. data/test/pgn_collection/valid/0210.pgn +13 -15
  246. data/test/pgn_collection/valid/0216.pgn +13 -17
  247. data/test/pgn_collection/valid/0217.pgn +15 -21
  248. data/test/pgn_collection/valid/0221.pgn +18 -26
  249. data/test/pgn_collection/valid/0222.pgn +12 -21
  250. data/test/pgn_collection/valid/0225.pgn +16 -19
  251. data/test/pgn_collection/valid/0226.pgn +14 -19
  252. data/test/pgn_collection/valid/0228.pgn +12 -21
  253. data/test/pgn_collection/valid/0229.pgn +13 -16
  254. data/test/pgn_collection/valid/0231.pgn +14 -22
  255. data/test/pgn_collection/valid/0235.pgn +16 -23
  256. data/test/pgn_collection/valid/0238.pgn +12 -16
  257. data/test/pgn_collection/valid/0239.pgn +18 -21
  258. data/test/pgn_collection/valid/0240.pgn +13 -15
  259. data/test/pgn_collection/valid/0241.pgn +12 -21
  260. data/test/pgn_collection/valid/0242.pgn +18 -26
  261. data/test/pgn_collection/valid/0243.pgn +10 -13
  262. data/test/pgn_collection/valid/0246.pgn +11 -15
  263. data/test/pgn_collection/valid/0256.pgn +15 -18
  264. data/test/pgn_collection/valid/0257.pgn +16 -22
  265. data/test/pgn_collection/valid/0261.pgn +14 -16
  266. data/test/pgn_collection/valid/0263.pgn +10 -12
  267. data/test/pgn_collection/valid/0266.pgn +10 -13
  268. data/test/pgn_collection/valid/0267.pgn +12 -14
  269. data/test/pgn_collection/valid/0271.pgn +20 -22
  270. data/test/pgn_collection/valid/0276.pgn +16 -24
  271. data/test/pgn_collection/valid/0278.pgn +13 -17
  272. data/test/pgn_collection/valid/0284.pgn +9 -11
  273. data/test/pgn_collection/valid/0289.pgn +15 -23
  274. data/test/pgn_collection/valid/0290.pgn +22 -24
  275. data/test/pgn_collection/valid/0291.pgn +14 -20
  276. data/test/pgn_collection/valid/0292.pgn +11 -15
  277. data/test/pgn_collection/valid/0298.pgn +18 -25
  278. data/test/pgn_collection/valid/0300.pgn +13 -15
  279. data/test/pgn_collection/valid/0304.pgn +12 -18
  280. data/test/pgn_collection/valid/0309.pgn +17 -19
  281. data/test/pgn_collection/valid/0310.pgn +17 -24
  282. data/test/pgn_collection/valid/0313.pgn +13 -15
  283. data/test/pgn_collection/valid/0314.pgn +18 -21
  284. data/test/pgn_collection/valid/0318.pgn +10 -12
  285. data/test/pgn_collection/valid/0320.pgn +13 -18
  286. data/test/pgn_collection/valid/0325.pgn +15 -21
  287. data/test/pgn_collection/valid/0328.pgn +11 -15
  288. data/test/pgn_collection/valid/0333.pgn +14 -16
  289. data/test/pgn_collection/valid/0338.pgn +20 -24
  290. data/test/pgn_collection/valid/0339.pgn +18 -22
  291. data/test/pgn_collection/valid/0343.pgn +11 -14
  292. data/test/pgn_collection/valid/0349.pgn +21 -30
  293. data/test/pgn_collection/valid/0350.pgn +14 -20
  294. data/test/pgn_collection/valid/0356.pgn +14 -17
  295. data/test/pgn_collection/valid/0359.pgn +15 -17
  296. data/test/pgn_collection/valid/0369.pgn +17 -25
  297. data/test/pgn_collection/valid/0373.pgn +15 -19
  298. data/test/pgn_collection/valid/0374.pgn +13 -16
  299. data/test/pgn_collection/valid/0381.pgn +11 -17
  300. data/test/pgn_collection/valid/0386.pgn +14 -21
  301. data/test/pgn_collection/valid/0387.pgn +12 -17
  302. data/test/pgn_collection/valid/0388.pgn +16 -20
  303. data/test/pgn_collection/valid/0393.pgn +15 -18
  304. data/test/pgn_collection/valid/0395.pgn +10 -13
  305. data/test/pgn_collection/valid/0399.pgn +20 -24
  306. data/test/pgn_collection/valid/0402.pgn +14 -22
  307. data/test/pgn_collection/valid/0409.pgn +15 -23
  308. data/test/pgn_collection/valid/0417.pgn +15 -21
  309. data/test/pgn_collection/valid/0421.pgn +21 -24
  310. data/test/pgn_collection/valid/0422.pgn +15 -22
  311. data/test/pgn_collection/valid/0423.pgn +17 -23
  312. data/test/pgn_collection/valid/0427.pgn +11 -14
  313. data/test/pgn_collection/valid/0429.pgn +12 -16
  314. data/test/pgn_collection/valid/0433.pgn +15 -17
  315. data/test/pgn_collection/valid/0434.pgn +11 -20
  316. data/test/pgn_collection/valid/0438.pgn +12 -16
  317. data/test/pgn_collection/valid/0439.pgn +22 -26
  318. data/test/pgn_collection/valid/0440.pgn +21 -24
  319. data/test/pgn_collection/valid/0447.pgn +21 -25
  320. data/test/pgn_collection/valid/0450.pgn +15 -16
  321. data/test/pgn_collection/valid/0451.pgn +11 -14
  322. data/test/pgn_collection/valid/0453.pgn +13 -15
  323. data/test/pgn_collection/valid/0462.pgn +17 -25
  324. data/test/pgn_collection/valid/0463.pgn +12 -14
  325. data/test/pgn_collection/valid/0469.pgn +16 -18
  326. data/test/pgn_collection/valid/0471.pgn +11 -15
  327. data/test/pgn_collection/valid/0472.pgn +20 -29
  328. data/test/pgn_collection/valid/0473.pgn +12 -19
  329. data/test/pgn_collection/valid/0474.pgn +15 -20
  330. data/test/pgn_collection/valid/0476.pgn +11 -18
  331. data/test/pgn_collection/valid/0477.pgn +21 -30
  332. data/test/pgn_collection/valid/0480.pgn +13 -18
  333. data/test/pgn_collection/valid/0488.pgn +12 -18
  334. data/test/pgn_collection/valid/0490.pgn +15 -21
  335. data/test/pgn_collection/valid/0491.pgn +10 -15
  336. data/test/pgn_collection/valid/0503.pgn +15 -23
  337. data/test/pgn_collection/valid/0508.pgn +10 -13
  338. data/test/pgn_collection/valid/0509.pgn +20 -22
  339. data/test/pgn_collection/valid/0515.pgn +10 -12
  340. data/test/pgn_collection/valid/0518.pgn +17 -23
  341. data/test/pgn_collection/valid/0530.pgn +16 -19
  342. data/test/pgn_collection/valid/0531.pgn +13 -18
  343. data/test/pgn_collection/valid/0533.pgn +17 -19
  344. data/test/pgn_collection/valid/0534.pgn +17 -25
  345. data/test/pgn_collection/valid/0535.pgn +13 -17
  346. data/test/pgn_collection/valid/0536.pgn +13 -21
  347. data/test/pgn_collection/valid/0537.pgn +12 -17
  348. data/test/pgn_collection/valid/0540.pgn +14 -19
  349. data/test/pgn_collection/valid/0541.pgn +12 -17
  350. data/test/pgn_collection/valid/0542.pgn +15 -17
  351. data/test/pgn_collection/valid/0545.pgn +15 -19
  352. data/test/pgn_collection/valid/0546.pgn +12 -21
  353. data/test/pgn_collection/valid/0547.pgn +15 -17
  354. data/test/pgn_collection/valid/0548.pgn +14 -17
  355. data/test/pgn_collection/valid/0552.pgn +16 -22
  356. data/test/pgn_collection/valid/0557.pgn +12 -14
  357. data/test/pgn_collection/valid/0558.pgn +15 -21
  358. data/test/pgn_collection/valid/0561.pgn +13 -15
  359. data/test/pgn_collection/valid/0568.pgn +12 -20
  360. data/test/pgn_collection/valid/0569.pgn +15 -20
  361. data/test/pgn_collection/valid/0572.pgn +13 -17
  362. data/test/pgn_collection/valid/0573.pgn +13 -17
  363. data/test/pgn_collection/valid/0579.pgn +18 -25
  364. data/test/pgn_collection/valid/0580.pgn +14 -19
  365. data/test/pgn_collection/valid/0581.pgn +10 -13
  366. data/test/pgn_collection/valid/0586.pgn +15 -20
  367. data/test/pgn_collection/valid/0587.pgn +12 -16
  368. data/test/pgn_collection/valid/0589.pgn +12 -15
  369. data/test/pgn_collection/valid/0590.pgn +17 -23
  370. data/test/pgn_collection/valid/0592.pgn +15 -21
  371. data/test/pgn_collection/valid/0595.pgn +14 -16
  372. data/test/pgn_collection/valid/0597.pgn +14 -20
  373. data/test/pgn_collection/valid/0598.pgn +13 -18
  374. data/test/pgn_collection/valid/0603.pgn +12 -21
  375. data/test/pgn_collection/valid/0605.pgn +14 -20
  376. data/test/pgn_collection/valid/0607.pgn +12 -16
  377. data/test/pgn_collection/valid/0609.pgn +11 -15
  378. data/test/pgn_collection/valid/0611.pgn +13 -21
  379. data/test/pgn_collection/valid/0612.pgn +17 -18
  380. data/test/pgn_collection/valid/0613.pgn +9 -12
  381. data/test/pgn_collection/valid/0614.pgn +11 -15
  382. data/test/pgn_collection/valid/0615.pgn +16 -18
  383. data/test/pgn_collection/valid/0617.pgn +18 -26
  384. data/test/pgn_collection/valid/0618.pgn +13 -19
  385. data/test/pgn_collection/valid/0620.pgn +13 -22
  386. data/test/pgn_collection/valid/0630.pgn +13 -15
  387. data/test/pgn_collection/valid/0631.pgn +15 -21
  388. data/test/pgn_collection/valid/0634.pgn +12 -16
  389. data/test/pgn_collection/valid/0639.pgn +14 -19
  390. data/test/pgn_collection/valid/0640.pgn +19 -22
  391. data/test/pgn_collection/valid/0641.pgn +11 -14
  392. data/test/pgn_collection/valid/0646.pgn +15 -18
  393. data/test/pgn_collection/valid/0648.pgn +23 -28
  394. data/test/pgn_collection/valid/0650.pgn +13 -16
  395. data/test/pgn_collection/valid/0655.pgn +15 -20
  396. data/test/pgn_collection/valid/0656.pgn +14 -22
  397. data/test/pgn_collection/valid/0658.pgn +18 -26
  398. data/test/pgn_collection/valid/0659.pgn +13 -22
  399. data/test/pgn_collection/valid/0660.pgn +19 -27
  400. data/test/pgn_collection/valid/0665.pgn +10 -13
  401. data/test/pgn_collection/valid/0667.pgn +12 -20
  402. data/test/pgn_collection/valid/0669.pgn +15 -22
  403. data/test/pgn_collection/valid/0671.pgn +16 -19
  404. data/test/pgn_collection/valid/0673.pgn +13 -19
  405. data/test/pgn_collection/valid/0674.pgn +13 -15
  406. data/test/pgn_collection/valid/0679.pgn +14 -16
  407. data/test/pgn_collection/valid/0680.pgn +15 -21
  408. data/test/pgn_collection/valid/0689.pgn +16 -24
  409. data/test/pgn_collection/valid/0692.pgn +18 -26
  410. data/test/pgn_collection/valid/0702.pgn +12 -18
  411. data/test/pgn_collection/valid/0712.pgn +11 -12
  412. data/test/pgn_collection/valid/0714.pgn +15 -21
  413. data/test/pgn_collection/valid/0715.pgn +13 -17
  414. data/test/pgn_collection/valid/0717.pgn +15 -23
  415. data/test/pgn_collection/valid/0720.pgn +16 -21
  416. data/test/pgn_collection/valid/0721.pgn +14 -19
  417. data/test/pgn_collection/valid/0722.pgn +22 -32
  418. data/test/pgn_collection/valid/0728.pgn +14 -16
  419. data/test/pgn_collection/valid/0732.pgn +19 -21
  420. data/test/pgn_collection/valid/0734.pgn +14 -20
  421. data/test/pgn_collection/valid/0739.pgn +12 -20
  422. data/test/pgn_collection/valid/0740.pgn +12 -15
  423. data/test/pgn_collection/valid/0743.pgn +12 -18
  424. data/test/pgn_collection/valid/0752.pgn +14 -18
  425. data/test/pgn_collection/valid/0754.pgn +16 -24
  426. data/test/pgn_collection/valid/0758.pgn +12 -14
  427. data/test/pgn_collection/valid/0759.pgn +15 -19
  428. data/test/pgn_collection/valid/0762.pgn +12 -16
  429. data/test/pgn_collection/valid/0764.pgn +17 -21
  430. data/test/pgn_collection/valid/0765.pgn +15 -21
  431. data/test/pgn_collection/valid/0767.pgn +17 -25
  432. data/test/pgn_collection/valid/0768.pgn +13 -15
  433. data/test/pgn_collection/valid/0770.pgn +19 -21
  434. data/test/pgn_collection/valid/0773.pgn +18 -24
  435. data/test/pgn_collection/valid/0775.pgn +12 -14
  436. data/test/pgn_collection/valid/0783.pgn +15 -21
  437. data/test/pgn_collection/valid/0789.pgn +15 -21
  438. data/test/pgn_collection/valid/0794.pgn +12 -14
  439. data/test/pgn_collection/valid/0795.pgn +17 -23
  440. data/test/pgn_collection/valid/0797.pgn +17 -24
  441. data/test/pgn_collection/valid/0800.pgn +9 -12
  442. data/test/pgn_collection/valid/0812.pgn +14 -16
  443. data/test/pgn_collection/valid/0814.pgn +18 -21
  444. data/test/pgn_collection/valid/0815.pgn +11 -20
  445. data/test/pgn_collection/valid/0817.pgn +14 -19
  446. data/test/pgn_collection/valid/0818.pgn +10 -12
  447. data/test/pgn_collection/valid/0822.pgn +18 -25
  448. data/test/pgn_collection/valid/0828.pgn +11 -12
  449. data/test/pgn_collection/valid/0830.pgn +12 -16
  450. data/test/pgn_collection/valid/0837.pgn +11 -15
  451. data/test/pgn_collection/valid/0842.pgn +20 -29
  452. data/test/pgn_collection/valid/0843.pgn +15 -18
  453. data/test/pgn_collection/valid/0856.pgn +17 -23
  454. data/test/pgn_collection/valid/0861.pgn +12 -14
  455. data/test/pgn_collection/valid/0866.pgn +17 -24
  456. data/test/pgn_collection/valid/0867.pgn +13 -17
  457. data/test/pgn_collection/valid/0875.pgn +11 -13
  458. data/test/pgn_collection/valid/0882.pgn +14 -17
  459. data/test/pgn_collection/valid/0883.pgn +12 -14
  460. data/test/pgn_collection/valid/0888.pgn +19 -27
  461. data/test/pgn_collection/valid/0889.pgn +27 -39
  462. data/test/pgn_collection/valid/0891.pgn +12 -17
  463. data/test/pgn_collection/valid/0892.pgn +15 -18
  464. data/test/pgn_collection/valid/0903.pgn +14 -22
  465. data/test/pgn_collection/valid/0905.pgn +13 -18
  466. data/test/pgn_collection/valid/0906.pgn +10 -12
  467. data/test/pgn_collection/valid/0917.pgn +18 -21
  468. data/test/pgn_collection/valid/0918.pgn +11 -14
  469. data/test/pgn_collection/valid/0920.pgn +17 -23
  470. data/test/pgn_collection/valid/0921.pgn +13 -15
  471. data/test/pgn_collection/valid/0922.pgn +17 -25
  472. data/test/pgn_collection/valid/0926.pgn +14 -17
  473. data/test/pgn_collection/valid/0928.pgn +12 -14
  474. data/test/pgn_collection/valid/0929.pgn +16 -20
  475. data/test/pgn_collection/valid/0935.pgn +19 -27
  476. data/test/pgn_collection/valid/0936.pgn +11 -15
  477. data/test/pgn_collection/valid/0938.pgn +11 -14
  478. data/test/pgn_collection/valid/0940.pgn +13 -15
  479. data/test/pgn_collection/valid/0946.pgn +15 -18
  480. data/test/pgn_collection/valid/0952.pgn +19 -27
  481. data/test/pgn_collection/valid/0957.pgn +15 -19
  482. data/test/pgn_collection/valid/0959.pgn +15 -23
  483. data/test/pgn_collection/valid/0966.pgn +14 -16
  484. data/test/pgn_collection/valid/0972.pgn +14 -17
  485. data/test/pgn_collection/valid/0974.pgn +17 -24
  486. data/test/pgn_collection/valid/0975.pgn +12 -14
  487. data/test/pgn_collection/valid/0977.pgn +10 -14
  488. data/test/pgn_collection/valid/0979.pgn +17 -19
  489. data/test/pgn_collection/valid/0981.pgn +12 -21
  490. data/test/pgn_collection/valid/0982.pgn +13 -18
  491. data/test/pgn_collection/valid/0984.pgn +19 -27
  492. data/test/pgn_collection/valid/0987.pgn +13 -15
  493. data/test/pgn_collection/valid/0993.pgn +11 -15
  494. data/test/pgn_collection/valid/0997.pgn +16 -24
  495. data/test/test_checkmate.rb +4 -2
  496. data/test/test_insufficient_material.rb +3 -2
  497. data/test/test_pgn_collection.rb +5 -1
  498. data/test/test_stalemate.rb +1 -0
  499. metadata +313 -319
  500. data/test/pgn_collection/valid/checkmate/0925.pgn +0 -26
  501. data/test/pgn_collection/valid/checkmate/checkmate.pgn +0 -11
@@ -1,35 +1,54 @@
1
1
  module Chess
2
2
 
3
3
  # Use Gnuchess to I.A. <em>(Only a draft)</em>
4
- # To use this module, extend a game object with Chess::Gnuchess
4
+ # To use this module, extend a game object with Chess::Gnuchess.
5
+ # Gnuchess binary have to be installed.
5
6
  #
6
7
  # g = Chess::Game.new
7
8
  # g.extend Chess::Gnuchess
8
- # g.gnuchess_move
9
+ # g.gnuchess_move!
9
10
  # puts g
10
11
  module Gnuchess
11
12
 
12
- # Make a move using Gnuchess engine. This add a new Board in the Game.
13
13
  # Return the next move calculated by Gnuchess.
14
14
  # Gnuchess must be installed!
15
15
  def gnuchess_move
16
16
  pipe = IO.popen('gnuchess -x', 'r+')
17
17
  begin
18
- pipe.write("depth 1\n")
19
- pipe.write("force\n")
18
+ pipe.puts('depth 1')
19
+ pipe.puts('manual')
20
20
  self.full_moves.each do |m|
21
- pipe.write(m + "\n")
21
+ pipe.puts(m)
22
22
  end
23
- pipe.write("go\n")
23
+ pipe.puts('go')
24
24
  while line = pipe.gets
25
25
  raise IllegalMoveError if line.include?('Invalid move')
26
- match = line.match(/My move is : ([a-h][1-8][a-h][1-8])/)
27
- return self.move(match[1]) if match
26
+ match = line.match(/My move is : ([a-h][1-8][a-h][1-8][rkbq]?)/)
27
+ return match[1] if match
28
28
  end
29
29
  ensure
30
- pipe.write("quit\n")
30
+ pipe.puts('quit')
31
31
  pipe.close
32
32
  end
33
+ return moves
34
+ end
35
+
36
+ # Make a move using Gnuchess engine. This add a new Board in the Game.
37
+ # Return the next move calculated by Gnuchess.
38
+ # Gnuchess must be installed!
39
+ def gnuchess_move!
40
+ next_move = self.gnuchess_move
41
+ self.move(next_move) if next_move
42
+ end
43
+
44
+ # :nodoc:
45
+ def self.included(mod)
46
+ raise_if_gnuchess_is_not_installed
47
+ end
48
+
49
+ # :nodoc:
50
+ def self.extended(mod)
51
+ raise_if_gnuchess_is_not_installed
33
52
  end
34
53
 
35
54
  # :nodoc:
@@ -51,10 +70,10 @@ module Chess
51
70
  elsif line =~ / : resign/
52
71
  break
53
72
  elsif line =~ / : 1-0 {White mates}/
54
- done = :white_wins
73
+ done = :white_won
55
74
  break
56
75
  elsif line =~ / : 0-1 {Black mates}/
57
- done = :black_wins
76
+ done = :black_won
58
77
  break
59
78
  elsif m = line.match(/1\/2-1\/2 {(.*?)}/)
60
79
  case m[1]
@@ -87,6 +106,14 @@ module Chess
87
106
  system('which gnuchess >& /dev/null')
88
107
  $?.exitstatus == 0
89
108
  end
109
+
110
+ # Raise an exception if Gnuchess is not installed
111
+ def self.raise_if_gnuchess_is_not_installed
112
+ unless gnuchess_installed?
113
+ raise 'You need to install Gnuchess to use the module Chess::Gnuchess.'
114
+ end
115
+ end
116
+
90
117
  end
91
118
 
92
119
  end
data/lib/chess/pgn.rb CHANGED
@@ -22,11 +22,12 @@ module Chess
22
22
  TAGS.each do |t|
23
23
  instance_variable_set("@#{t}", data.match(/^\[#{t.capitalize} ".*"\]\s?$/).to_s.strip[t.size+3..-3])
24
24
  end
25
+ @result = '1/2-1/2' if @result == '1/2'
25
26
  game_index = data.index(/^1\./)
26
27
  raise Chess::InvalidPgnFormatError.new(filename) if game_index.nil?
27
28
  game = data[game_index..-1].strip
28
29
  @moves = game.gsub("\n", ' ').split(/\d+\./).collect{|t| t.strip}[1..-1].collect{|t| t.split(' ')}.flatten
29
- @moves.delete_at(@moves.size-1) if @moves.last =~ /(0\-1)|(1\-0)|(1\/2)|(1\/2\-1\/2)|(\*)/
30
+ @moves.delete_at(@moves.size-1) if @moves.last =~ /(0-1)|(1-0)|(1\/2)|(1\/2-1\/2)|(\*)/
30
31
  return self
31
32
  end
32
33
 
data/lib/chess/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # The Chess library module.
2
2
  module Chess
3
3
  # The library version.
4
- VERSION = '0.0.3'
4
+ VERSION = '0.0.4'
5
5
  end