Advertisement
Guest User

Heres what i got

a guest
Nov 12th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.06 KB | None | 0 0
  1. Board = {
  2. a1 = {x=1, y=1,Piece= "Rw"},
  3. a2 = {x=2, y=1,Piece= "Hw"},
  4. a3 = {x=3, y=1,Piece= "Bw"},
  5. a4 = {x=4, y=1,Piece= "Qw"},
  6. a5 = {x=5, y=1,Piece= "Kw"},
  7. a6 = {x=6, y=1,Piece= "Bw"},
  8. a7 = {x=7, y=1,Piece= "Hw"},
  9. a8 = {x=8, y=1,Piece= "Rw"},
  10. b1 = {x=1, y=2,Piece= "Pw"},
  11. b2 = {x=2, y=2,Piece= "Pw"},
  12. b3 = {x=3, y=2,Piece= "Pw"},
  13. b4 = {x=4, y=2,Piece= "Pw"},
  14. b5 = {x=5, y=2,Piece= "Pw"},
  15. b6 = {x=6, y=2,Piece= "Pw"},
  16. b7 = {x=7, y=2,Piece= "Pw"},
  17. b8 = {x=8, y=2,Piece= "Pw"},
  18. c1 = {x=1, y=3,Piece= "Na"},
  19. c2 = {x=2, y=3,Piece= "Na"},
  20. c3 = {x=3, y=3,Piece= "Na"},
  21. c4 = {x=4, y=3,Piece= "Na"},
  22. c5 = {x=5, y=3,Piece= "Na"},
  23. c6 = {x=6, y=3,Piece= "Na"},
  24. c7 = {x=7, y=3,Piece= "Na"},
  25. c8 = {x=8, y=3,Piece= "Na"},
  26. d1 = {x=1, y=4,Piece= "Na"},
  27. d2 = {x=2, y=4,Piece= "Na"},
  28. d3 = {x=3, y=4,Piece= "Na"},
  29. d4 = {x=4, y=4,Piece= "Na"},
  30. d5 = {x=5, y=4,Piece= "Na"},
  31. d6 = {x=6, y=4,Piece= "Na"},
  32. d7 = {x=7, y=4,Piece= "Na"},
  33. d8 = {x=8, y=4,Piece= "Na"},
  34. e1 = {x=1, y=5,Piece= "Na"},
  35. e2 = {x=2, y=5,Piece= "Na"},
  36. e3 = {x=3, y=5,Piece= "Na"},
  37. e4 = {x=4, y=5,Piece= "Na"},
  38. e5 = {x=5, y=5,Piece= "Na"},
  39. e6 = {x=6, y=5,Piece= "Na"},
  40. e7 = {x=7, y=5,Piece= "Na"},
  41. e8 = {x=8, y=5,Piece= "Na"},
  42. f1 = {x=1, y=6,Piece= "Na"},
  43. f2 = {x=2, y=6,Piece= "Na"},
  44. f3 = {x=3, y=6,Piece= "Na"},
  45. f4 = {x=4, y=6,Piece= "Na"},
  46. f5 = {x=5, y=6,Piece= "Na"},
  47. f6 = {x=6, y=6,Piece= "Na"},
  48. f7 = {x=7, y=6,Piece= "Na"},
  49. f8 = {x=8, y=6,Piece= "Na"},
  50. g1 = {x=1, y=7,Piece= "Pb"},
  51. g2 = {x=2, y=7,Piece= "Pb"},
  52. g3 = {x=3, y=7,Piece= "Pb"},
  53. g4 = {x=4, y=7,Piece= "Pb"},
  54. g5 = {x=5, y=7,Piece= "Pb"},
  55. g6 = {x=6, y=7,Piece= "Pb"},
  56. g7 = {x=7, y=7,Piece= "Pb"},
  57. g8 = {x=8, y=7,Piece= "Pb"},
  58. h1 = {x=1, y=8,Piece= "Rb"},
  59. h2 = {x=2, y=8,Piece= "Hb"},
  60. h3 = {x=3, y=8,Piece= "Bb"},
  61. h4 = {x=4, y=8,Piece= "Kb"},
  62. h5 = {x=5, y=8,Piece= "Qb"},
  63. h6 = {x=6, y=8,Piece= "Bb"},
  64. h7 = {x=7, y=8,Piece= "Hb"},
  65. h8 = {x=8, y=8,Piece= "Rb"},
  66. }
  67. White = {"Pw","Rw","Bw","Hw","Qw","Kw"}
  68. Black = {"Pb","Rb","Bb","Hb","Qb","Kb"}
  69.  
  70. function coordstoclass(x, y)
  71. if x < 1 or x > 8 or y < 1 or y > 8 then
  72. return {x = nil,y = nil,Piece = "void"}
  73. end
  74. if x == 1 then
  75. if y == 1 then
  76. return Board.a1
  77. elseif y == 2 then
  78. return Board.a2
  79. elseif y == 3 then
  80. return Board.a3
  81. elseif y == 4 then
  82. return Board.a4
  83. elseif y == 5 then
  84. return Board.a5
  85. elseif y == 6 then
  86. return Board.a6
  87. elseif y == 7 then
  88. return Board.a7
  89. elseif y == 8 then
  90. return Board.a8
  91. end
  92. elseif x == 2 then
  93. if y == 1 then
  94. return Board.b1
  95. elseif y == 2 then
  96. return Board.b2
  97. elseif y == 3 then
  98. return Board.b3
  99. elseif y == 4 then
  100. return Board.b4
  101. elseif y == 5 then
  102. return Board.b5
  103. elseif y == 6 then
  104. return Board.b6
  105. elseif y == 7 then
  106. return Board.b7
  107. elseif y == 8 then
  108. return Board.b8
  109. end
  110. elseif x == 3 then
  111. if y == 1 then
  112. return Board.c1
  113. elseif y == 2 then
  114. return Board.c2
  115. elseif y == 3 then
  116. return Board.c3
  117. elseif y == 4 then
  118. return Board.c4
  119. elseif y == 5 then
  120. return Board.c5
  121. elseif y == 6 then
  122. return Board.c6
  123. elseif y == 7 then
  124. return Board.c7
  125. elseif y == 8 then
  126. return Board.c8
  127. end
  128. elseif x == 4 then
  129. if y == 1 then
  130. return Board.d1
  131. elseif y == 2 then
  132. return Board.d2
  133. elseif y == 3 then
  134. return Board.d3
  135. elseif y == 4 then
  136. return Board.d4
  137. elseif y == 5 then
  138. return Board.d5
  139. elseif y == 6 then
  140. return Board.d6
  141. elseif y == 7 then
  142. return Board.d7
  143. elseif y == 8 then
  144. return Board.d8
  145. end
  146. elseif x == 5 then
  147. if y == 1 then
  148. return Board.e1
  149. elseif y == 2 then
  150. return Board.e2
  151. elseif y == 3 then
  152. return Board.e3
  153. elseif y == 4 then
  154. return Board.e4
  155. elseif y == 5 then
  156. return Board.e5
  157. elseif y == 6 then
  158. return Board.e6
  159. elseif y == 7 then
  160. return Board.e7
  161. elseif y == 8 then
  162. return Board.e8
  163. end
  164. elseif x == 6 then
  165. if y == 1 then
  166. return Board.f1
  167. elseif y == 2 then
  168. return Board.f2
  169. elseif y == 3 then
  170. return Board.f3
  171. elseif y == 4 then
  172. return Board.f4
  173. elseif y == 5 then
  174. return Board.f5
  175. elseif y == 6 then
  176. return Board.f6
  177. elseif y == 7 then
  178. return Board.f7
  179. elseif y == 8 then
  180. return Board.f8
  181. end
  182. elseif x == 7 then
  183. if y == 1 then
  184. return Board.g1
  185. elseif y == 2 then
  186. return Board.g2
  187. elseif y == 3 then
  188. return Board.g3
  189. elseif y == 4 then
  190. return Board.g4
  191. elseif y == 5 then
  192. return Board.g5
  193. elseif y == 6 then
  194. return Board.g6
  195. elseif y == 7 then
  196. return Board.g7
  197. elseif y == 8 then
  198. return Board.g8
  199. end
  200. elseif x == 8 then
  201. if y == 1 then
  202. return Board.h1
  203. elseif y == 2 then
  204. return Board.h2
  205. elseif y == 3 then
  206. return Board.h3
  207. elseif y == 4 then
  208. return Board.h4
  209. elseif y == 5 then
  210. return Board.h5
  211. elseif y == 6 then
  212. return Board.h6
  213. elseif y == 7 then
  214. return Board.h7
  215. elseif y == 8 then
  216. return Board.h8
  217. end
  218. end
  219. end
  220. function getmoves(x,y)
  221. if Board.Piece == "Pw"
  222. and (coordstoclass(x,y+1).Piece) == Na then
  223. return Legal
  224. end
  225. if (coordstoclass(x-1,y+1).Piece) == Black then
  226. return Legal
  227. end
  228. if (coordstoclass(x+1,y+1).Piece) == Black then
  229. return Legal
  230. end
  231. if (coordstoclass(x-1,y+1).Piece) == White then
  232. return Illegal
  233. end
  234. if (coordstoclass(x+1,y+1).Piece) == White then
  235. return Illegal
  236. end
  237. if y == 2
  238. and (coordstoclass(x,y+1).Piece) == Na
  239. and (coordstoclass(x,y+2).Piece) == Na then
  240. return Legal
  241. end
  242. if Board.Piece == "Pb"
  243. and (coordstoclass(x,y-1).Piece) == Na then
  244. return Legal
  245. end
  246. if (coordstoclass(x-1,y-1).Piece) == White then
  247. return Legal
  248. end
  249. if (coordstoclass(x+1,y-1).Piece) == White then
  250. return Legal
  251. end
  252. if (coordstoclass(x-1,y+1).Piece) == Black then
  253. return Illegal
  254. end
  255. if (coordstoclass(x+1,y+1).Piece) == Black then
  256. return Illegal
  257. end
  258. if y == 2
  259. and (coordstoclass(x,y-1).Piece) == Na
  260. and (coordstoclass(x,y-2).Piece) == Na then
  261. return Legal
  262. end
  263. if Board.Piece == "Hw"
  264. and (coordstoclass(x+1,y+3).Piece) == Na then
  265. return Legal
  266. end
  267. if (coordstoclass(x-1,y+3).Piece) == Na then
  268. return Legal
  269. end
  270. if (coordstoclass(x-1,y-3).Piece) == Na then
  271. return Legal
  272. end
  273. if (coordstoclass(x+1,y-3).Piece) == Na then
  274. return Legal
  275. end
  276. if (coordstoclass(x+3,y+1).Piece) == Na then
  277. return Legal
  278. end
  279. if (coordstoclass(x+3,y-1).Piece) == Na then
  280. return Legal
  281. end
  282. if (coordstoclass(x-3,y+1).Piece) == Na then
  283. return Legal
  284. end
  285. if (coordstoclass(x-3,y-1).Piece) == Na then
  286. return Legal
  287. end
  288. if (coordstoclass(x+1,y+3).Piece) == Black then
  289. return Legal
  290. end
  291. if (coordstoclass(x-1,y+3).Piece) == Black then
  292. return Legal
  293. end
  294. if (coordstoclass(x-1,y-3).Piece) == Black then
  295. return Legal
  296. end
  297. if (coordstoclass(x+1,y-3).Piece) == Black then
  298. return Legal
  299. end
  300. if (coordstoclass(x+3,y+1).Piece) == Black then
  301. return Legal
  302. end
  303. if (coordstoclass(x+3,y-1).Piece) == Black then
  304. return Legal
  305. end
  306. if (coordstoclass(x-3,y+1).Piece) == Black then
  307. return Legal
  308. end
  309. if (coordstoclass(x-3,y-1).Piece) == Black then
  310. return Legal
  311. end
  312. if (coordstoclass(x+1,y+3).Piece) == White then
  313. return Illegal
  314. end
  315. if (coordstoclass(x-1,y+3).Piece) == White then
  316. return Illegal
  317. end
  318. if (coordstoclass(x-1,y-3).Piece) == White then
  319. return Illegal
  320. end
  321. if (coordstoclass(x+1,y-3).Piece) == White then
  322. return Illegal
  323. end
  324. if (coordstoclass(x+3,y+1).Piece) == White then
  325. return Illegal
  326. end
  327. if (coordstoclass(x+3,y-1).Piece) == White then
  328. return Illegal
  329. end
  330. if (coordstoclass(x-3,y+1).Piece) == White then
  331. return Illegal
  332. end
  333. if (coordstoclass(x-3,y-1).Piece) == White then
  334. return Illegal
  335. end
  336. if Board.Piece == "Hb"
  337. and (coordstoclass(x+1,y+3).Piece) == Na then
  338. return Legal
  339. end
  340. if (coordstoclass(x-1,y+3).Piece) == Na then
  341. return Legal
  342. end
  343. if (coordstoclass(x-1,y-3).Piece) == Na then
  344. return Legal
  345. end
  346. if (coordstoclass(x+1,y-3).Piece) == Na then
  347. return Legal
  348. end
  349. if (coordstoclass(x+3,y+1).Piece) == Na then
  350. return Legal
  351. end
  352. if (coordstoclass(x+3,y-1).Piece) == Na then
  353. return Legal
  354. end
  355. if (coordstoclass(x-3,y+1).Piece) == Na then
  356. return Legal
  357. end
  358. if (coordstoclass(x-3,y-1).Piece) == Na then
  359. return Legal
  360. end
  361. if (coordstoclass(x+1,y+3).Piece) == White then
  362. return Legal
  363. end
  364. if (coordstoclass(x-1,y+3).Piece) == White then
  365. return Legal
  366. end
  367. if (coordstoclass(x-1,y-3).Piece) == White then
  368. return Legal
  369. end
  370. if (coordstoclass(x+1,y-3).Piece) == White then
  371. return Legal
  372. end
  373. if (coordstoclass(x+3,y+1).Piece) == White then
  374. return Legal
  375. end
  376. if (coordstoclass(x+3,y-1).Piece) == White then
  377. return Legal
  378. end
  379. if (coordstoclass(x-3,y+1).Piece) == White then
  380. return Legal
  381. end
  382. if (coordstoclass(x-3,y-1).Piece) == White then
  383. return Legal
  384. end
  385. if (coordstoclass(x+1,y+3).Piece) == Black then
  386. return Illegal
  387. end
  388. if (coordstoclass(x-1,y+3).Piece) == Black then
  389. return Illegal
  390. end
  391. if (coordstoclass(x-1,y-3).Piece) == Black then
  392. return Illegal
  393. end
  394. if (coordstoclass(x+1,y-3).Piece) == Black then
  395. return Illegal
  396. end
  397. if (coordstoclass(x+3,y+1).Piece) == Black then
  398. return Illegal
  399. end
  400. if (coordstoclass(x+3,y-1).Piece) == Black then
  401. return Illegal
  402. end
  403. if (coordstoclass(x-3,y+1).Piece) == Black then
  404. return Illegal
  405. end
  406. if (coordstoclass(x-3,y-1).Piece) == Black then
  407. return Illegal
  408. end
  409. end
  410. print(getmoves(7,8))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement