SHARE
TWEET

Untitled

a guest Nov 22nd, 2014 117 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'TIC TAC TOE
  2. 'Made by Daniël Haazen
  3. '
  4. 'S for Start
  5. Lbl S
  6. ClrText
  7. 'The matrix for gamefield
  8. [[0,0,0][0,0,0][0,0,0]]→Mat A
  9. 'Create the board.
  10. 'Prog WRITE: List(x,y,Text in numbers,...)
  11. {9,2,40,0,40}→List 1
  12. Prog "WRITE"
  13. {8,3,40,40,40,40,40}→List 1
  14. Prog "WRITE"
  15. {9,4,40,0,40}→List 1
  16. Prog "WRITE"
  17. {8,5,40,40,40,40,40}→List 1
  18. Prog "WRITE"
  19. {9,6,40,0,40}→List 1
  20. Prog "WRITE"
  21. 'U for User/Player
  22. Lbl U
  23. 'Make C the character "X"
  24. 24→C
  25. 'Get Key loop
  26. Lbl K
  27. GetKey→K
  28. K=0Goto K
  29. 'If K is a valid key, and it's an empty cell, go fill that cell.
  30. K=54 And Mat A[3,3]=0Goto 9
  31. K=64 And Mat A[3,2]=0Goto 8
  32. K=74 And Mat A[3,1]=0Goto 7
  33. K=53 And Mat A[2,3]=0Goto 6
  34. K=63 And Mat A[2,2]=0Goto 5
  35. K=73 And Mat A[2,1]=0Goto 4
  36. K=52 And Mat A[1,3]=0Goto 3
  37. K=62 And Mat A[1,2]=0Goto 2
  38. K=72 And Mat A[1,1]=0Goto 1
  39. 'If not, go to K
  40. Goto K
  41. 'Set the x and y, and fill the matrix cell, go to P
  42. Lbl 1
  43. 8→A
  44. 6→B
  45. C→Mat[1,1]
  46. Goto P
  47. Lbl 2
  48. 10→A
  49. 6→B
  50. C→Mat A[1,2]
  51. Goto P
  52. Lbl 3
  53. 12→A
  54. 6→B
  55. C→Mat A[1,3]
  56. Goto P
  57. Lbl 4
  58. 8→A
  59. 4→B
  60. C→Mat A[2,1]
  61. Goto P
  62. Lbl 5
  63. 10→A
  64. 4→B
  65. C→Mat A[2,2]
  66. Goto P
  67. Lbl 6
  68. 12→A
  69. 4→B
  70. C→Mat A[2,3]
  71. Goto P
  72. Lbl 7
  73. 8→A
  74. 2→B
  75. C→Mat A[3,1]
  76. Goto P
  77. Lbl 8
  78. 10→A
  79. 2→B
  80. C→Mat A[3,2]
  81. Goto P
  82. Lbl 9
  83. 12→A
  84. 2→B
  85. C→Mat A[3,3]
  86. Goto P
  87. 'P for Put
  88. Lbl P
  89. 'Prog "PUT": Puts number C as character on position A,B
  90. PROG "PUT"
  91. Goto Q
  92. 'B for.. no idea actually
  93. Lbl B
  94. 'If the Player/Computer was previous turn, let the other go this turn
  95. C=24Goto C
  96. C=15Goto U
  97. Lbl C
  98. 15→C
  99. 'R for.. repeat?
  100. Lbl R
  101. 'Let K be an integer between 1 and 9
  102. Int (Ran#x9)+1→K
  103. 'If K is a cell that is not occupied..
  104. K=1 And Mat A[1,1]=0Goto 1
  105. K=2 And Mat A[1,2]=0Goto 2
  106. K=3 And Mat A[1,3]=0Goto 3
  107. K=4 And Mat A[2,1]=0Goto 4
  108. K=5 And Mat A[2,2]=0Goto 5
  109. K=6 And Mat A[2,3]=0Goto 6
  110. K=7 And Mat A[3,1]=0Goto 7
  111. K=8 And Mat A[3,2]=0Goto 8
  112. K=9 And Mat A[3,3]=0Goto 9
  113. 'If not, retry with a new random number
  114. Goto R
  115. 'Q for.. okay these are made up mostly.
  116. Lbl Q
  117. For 1→I To 3
  118. 'If cell 1 is equal to cell 2 and 3, and cell 1 is not empty, go to W
  119. Mat A[I,1]=Mat A[I,2] And Mat A[I,1]=Mat A[I,3] And Mat A[I,1]0Goto W
  120. Mat A[1,I]=Mat A[2,I] And Mat A[1,I]=Mat A[3,I] And Mat A[1,I]0Goto W
  121. Next
  122. 'Checking for diagonal lines.
  123. 'If the center is not filled, we already know there is no diagonal line.
  124. Mat A[2,2]=0Goto B
  125. 'If the diagonal cells are the same
  126. Mat A[1,1]=Mat A[2,2] And Mat A[1,1]=Mat A[3,3]Goto W
  127. Mat A[3,1]=Mat A[2,2] And Mat A[3,1]=Mat A[1,3]Goto W
  128. 'If these are all false, we need to check if it's not a tie
  129. For 1→I To 3
  130. for 1→J To 3
  131. 'If a cell is empty, there is no tie
  132. Mat A[I,J]=0Goto B
  133. Next
  134. Next
  135. 'All cells are filled, it's a tie
  136. {9,1,20,9,5}→List 1
  137. Goto E
  138. 'W for Win
  139. Lbl W
  140. 'Write "(X or O) WINS"!
  141. {8,1,C,0,23,9,1,4,19}→List 1
  142. 'E for End
  143. Lbl E
  144. Prog "WRITE"
  145. 'Big for-loop for pause
  146. For 1→I To 500
  147. Next
  148. Goto S
  149.  
  150.  
  151.  
  152. Libraries:
  153.  
  154. WRITE
  155.  
  156. 'WRITE
  157. 'By Daniël Haazen
  158. '
  159. List 1[1]→X
  160. List 1[2]→Y
  161. For 1→I To Dim List 1-2
  162. List 1[2+I]→C
  163. I-1→J
  164. If X+J>21
  165. Then 21→B
  166. J+X→A
  167. Prog "MOD"
  168. A+1→A
  169. Int ((X+J)/21)+Y→B
  170. If B<8
  171. Then Prog "PUT"
  172. IfEnd
  173. Else J+X→A
  174. Y→B
  175. Prog "PUT"
  176. IfEnd
  177. Next
  178. Return
  179.  
  180. MOD
  181.  
  182. 'MOD
  183. '
  184. A-Int (A/B)xB→A
  185. Return
  186.  
  187.  
  188. PUT
  189.  
  190. 'PUT
  191. 'By Daniël Haazen
  192. '
  193. If C≤20
  194. Then If C≤10
  195. Then If C≤5
  196. Then C=0Locate A,B," "
  197. C=1Locate A,B,"A"
  198. C=2Locate A,B,"B"
  199. C=3Locate A,B,"C"
  200. C=4Locate A,B,"D"
  201. C=5Locate A,B,"E"
  202. Else C=6Locate A,B,"F"
  203. C=7Locate A,B,"G"
  204. C=8Locate A,B,"H"
  205. C=9Locate A,B,"I"
  206. C=10Locate A,B,"J"
  207. IfEnd
  208. Else If C≤15
  209. Then C=11Locate A,B,"K"
  210. C=12Locate A,B,"L"
  211. C=13Locate A,B,"M"
  212. C=14Locate A,B,"N"
  213. C=15Locate A,B,"O"
  214. Else C=16Locate A,B,"P"
  215. C=17Locate A,B,"Q"
  216. C=18Locate A,B,"R"
  217. C=19Locate A,B,"S"
  218. C=20Locate A,B,"T"
  219. IfEnd
  220. IfEnd
  221. Else If C≤30
  222. Then if C≤25
  223. Then C=21Locate A,B,"U"
  224. C=22Locate A,B,"V"
  225. C=23Locate A,B,"W"
  226. C=24Locate A,B,"X"
  227. C=25Locate A,B,"Y"
  228. Else Then C=26Locate A,B,"Z"
  229. C=27Locate A,B,"0"
  230. C=28Locate A,B,"1"
  231. C=29Locate A,B,"2"
  232. C=30Locate A,B,"3"
  233. IfEnd
  234. Else If C≤35
  235. Then C=31Locate A,B,"4"
  236. C=32Locate A,B,"5"
  237. C=33Locate A,B,"6"
  238. C=34Locate A,B,"7"
  239. Else C=35Locate A,B,"8"
  240. C=36Locate A,B,"9"
  241. C=37Locate A,B,"."
  242. C=38Locate A,B,","
  243. C=39Locate A,B,"/"
  244. C=40Locate A,B,"+"
  245. IfEnd
  246. IfEnd
  247. Return
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top