daily pastebin goal
51%
SHARE
TWEET

Untitled

a guest Mar 16th, 2018 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. AppTitle "Tic Tac Toe - u can't win"
  2. Graphics 450,450,16,2
  3. SetBuffer BackBuffer()
  4. Dim feld(10)
  5. Cls
  6.  
  7. Flip
  8.  
  9. ChangeDir ("data/")
  10. leer1=LoadImage ("1.jpg")
  11. leer2=LoadImage ("2.jpg")
  12. leer3=LoadImage ("3.jpg")
  13. leer4=LoadImage ("4.jpg")
  14. leer5=LoadImage ("5.jpg")
  15. leer6=LoadImage ("6.jpg")
  16. leer7=LoadImage ("7.jpg")
  17. leer8=LoadImage ("8.jpg")
  18. leer9=LoadImage ("9.jpg")
  19.  
  20. kreuz1=LoadImage ("1-1.jpg")
  21. kreuz2=LoadImage ("2-1.jpg")
  22. kreuz3=LoadImage ("3-1.jpg")
  23. kreuz4=LoadImage ("4-1.jpg")
  24. kreuz5=LoadImage ("5-1.jpg")
  25. kreuz6=LoadImage ("6-1.jpg")
  26. kreuz7=LoadImage ("7-1.jpg")
  27. kreuz8=LoadImage ("8-1.jpg")
  28. kreuz9=LoadImage ("9-1.jpg")
  29.  
  30. kreis1=LoadImage ("1-2.jpg")
  31. kreis2=LoadImage ("2-2.jpg")
  32. kreis3=LoadImage ("3-2.jpg")
  33. kreis4=LoadImage ("4-2.jpg")
  34. kreis5=LoadImage ("5-2.jpg")
  35. kreis6=LoadImage ("6-2.jpg")
  36. kreis7=LoadImage ("7-2.jpg")
  37. kreis8=LoadImage ("8-2.jpg")
  38. kreis9=LoadImage ("9-2.jpg")
  39.  
  40. .beginn
  41. zug=0
  42. comp=0
  43. gewinn=0
  44. For st=0 To 9
  45. feld(st)=0
  46. Next
  47. Cls:Flip
  48.  
  49.  
  50. FlushMouse()
  51.  
  52.  
  53. .start
  54.  
  55. If feld(1) = 0 Then DrawImage leer1,0,0
  56. If feld(1) = 1 Then DrawImage kreuz1,0,0
  57. If feld(1) = 2 Then DrawImage kreis1,0,0
  58.  
  59. If feld(2) = 0 Then DrawImage leer2,150,0
  60. If feld(2) = 1 Then DrawImage kreuz2,150,0
  61. If feld(2) = 2 Then DrawImage kreis2,150,0
  62.  
  63. If feld(3) = 0 Then DrawImage leer3,300,0
  64. If feld(3) = 1 Then DrawImage kreuz3,300,0
  65. If feld(3) = 2 Then DrawImage kreis3,300,0
  66.  
  67. If feld(4) = 0 Then DrawImage leer4,0,150
  68. If feld(4) = 1 Then DrawImage kreuz4,0,150
  69. If feld(4) = 2 Then DrawImage kreis4,0,150
  70.  
  71. If feld(5) = 0 Then DrawImage leer5,150,150
  72. If feld(5) = 1 Then DrawImage kreuz5,150,150
  73. If feld(5) = 2 Then DrawImage kreis5,150,150
  74.  
  75. If feld(6) = 0 Then DrawImage leer6,300,150
  76. If feld(6) = 1 Then DrawImage kreuz6,300,150
  77. If feld(6) = 2 Then DrawImage kreis6,300,150
  78.  
  79. If feld(7) = 0 Then DrawImage leer7,0,300
  80. If feld(7) = 1 Then DrawImage kreuz7,0,300
  81. If feld(7) = 2 Then DrawImage kreis7,0,300
  82.  
  83. If feld(8) = 0 Then DrawImage leer8,150,300
  84. If feld(8) = 1 Then DrawImage kreuz8,150,300
  85. If feld(8) = 2 Then DrawImage kreis8,150,300
  86.  
  87. If feld(9) = 0 Then DrawImage leer9,300,300
  88. If feld(9) = 1 Then DrawImage kreuz9,300,300
  89. If feld(9) = 2 Then DrawImage kreis9,300,300
  90. Flip
  91.  
  92.  
  93. WaitMouse()
  94. mausx=MouseX()
  95. mausy=MouseY()
  96.  
  97.  
  98.  
  99. If feld(1)=0 And mausx<150 And mausy<150 Then feld(1)=1 : zug=zug+1
  100. If feld(2)=0  And mausx>150 And mausx<300 And mausy<150 Then feld(2)=1 : zug=zug+1
  101. If feld(3)=0  And mausx>300 And mausy<150 Then  feld(3)=1 : zug=zug+1
  102.  
  103. If feld(4)=0  And mausx<150 And mausy>150 And mausy<300 Then feld(4)=1 : zug=zug+1
  104. If feld(5)=0  And mausx>150 And mausx<300 And mausy>150 And mausy<300 Then feld(5)=1 : zug=zug+1
  105. If feld(6)=0  And mausx>300 And mausy>150 And mausy<300 Then  feld(6)=1 : zug=zug+1
  106. If feld(7)=0  And mausx<150 And mausy>300 Then feld(7)=1 : zug=zug+1
  107. If feld(8)=0  And mausx>150 And mausx<300 And mausy>300 Then feld(8)=1 : zug=zug+1
  108. If feld(9)=0  And mausx>300 And mausy>300 Then  feld(9)=1 : zug=zug+1
  109.  
  110. Cls
  111.  
  112. For bla=1 To 9
  113.  
  114. If zug=5 Then feld(bla)=0
  115. Next
  116.  
  117. If feld(1) = 0 Then DrawImage leer1,0,0
  118. If feld(1) = 1 Then DrawImage kreuz1,0,0
  119. If feld(1) = 2 Then DrawImage kreis1,0,0
  120.  
  121. If feld(2) = 0 Then DrawImage leer2,150,0
  122. If feld(2) = 1 Then DrawImage kreuz2,150,0
  123. If feld(2) = 2 Then DrawImage kreis2,150,0
  124.  
  125. If feld(3) = 0 Then DrawImage leer3,300,0
  126. If feld(3) = 1 Then DrawImage kreuz3,300,0
  127. If feld(3) = 2 Then DrawImage kreis3,300,0
  128.  
  129. If feld(4) = 0 Then DrawImage leer4,0,150
  130. If feld(4) = 1 Then DrawImage kreuz4,0,150
  131. If feld(4) = 2 Then DrawImage kreis4,0,150
  132.  
  133. If feld(5) = 0 Then DrawImage leer5,150,150
  134. If feld(5) = 1 Then DrawImage kreuz5,150,150
  135. If feld(5) = 2 Then DrawImage kreis5,150,150
  136.  
  137. If feld(6) = 0 Then DrawImage leer6,300,150
  138. If feld(6) = 1 Then DrawImage kreuz6,300,150
  139. If feld(6) = 2 Then DrawImage kreis6,300,150
  140.  
  141. If feld(7) = 0 Then DrawImage leer7,0,300
  142. If feld(7) = 1 Then DrawImage kreuz7,0,300
  143. If feld(7) = 2 Then DrawImage kreis7,0,300
  144.  
  145. If feld(8) = 0 Then DrawImage leer8,150,300
  146. If feld(8) = 1 Then DrawImage kreuz8,150,300
  147. If feld(8) = 2 Then DrawImage kreis8,150,300
  148.  
  149. If feld(9) = 0 Then DrawImage leer9,300,300
  150. If feld(9) = 1 Then DrawImage kreuz9,300,300
  151. If feld(9) = 2 Then DrawImage kreis9,300,300
  152.  
  153. Flip
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160. ; unter 150 / 150    150 / 300   150 450
  161.  
  162.  
  163.  
  164.  
  165. ;Analysiere Gewinn
  166.  
  167. If feld(1)=1 And feld(1)=feld(2) And feld(1)=feld(3) Then gewinn=1
  168. If feld(4)=1 And feld(4)=feld(5) And feld(4)=feld(6) Then gewinn=1
  169. If feld(7)=1 And feld(7)=feld(8) And feld(7)=feld(9) Then gewinn=1
  170. If feld(1)=1 And feld(1)=feld(4) And feld(1)=feld(7) Then gewinn=1
  171. If feld(2)=1 And feld(2)=feld(5) And feld(2)=feld(8) Then gewinn=1
  172. If feld(3)=1 And feld(3)=feld(6) And feld(3)=feld(9) Then gewinn=1
  173. If feld(1)=1 And feld(1)=feld(5) And feld(1)=feld(9) Then gewinn=1
  174. If feld(3)=1 And feld(3)=feld(5) And feld(3)=feld(7) Then gewinn=1
  175.  
  176. If feld(1)=2 And feld(1)=feld(2) And feld(1)=feld(3) Then gewinn=2
  177. If feld(4)=2 And feld(4)=feld(5) And feld(4)=feld(6) Then gewinn=2
  178. If feld(7)=2 And feld(7)=feld(8) And feld(7)=feld(9) Then gewinn=2
  179. If feld(1)=2 And feld(1)=feld(4) And feld(1)=feld(7) Then gewinn=2
  180. If feld(2)=2 And feld(2)=feld(5) And feld(2)=feld(8) Then gewinn=2
  181. If feld(3)=2 And feld(3)=feld(6) And feld(3)=feld(9) Then gewinn=2
  182. If feld(1)=2 And feld(1)=feld(5) And feld(1)=feld(9) Then gewinn=2
  183. If feld(3)=2 And feld(3)=feld(5) And feld(3)=feld(7) Then gewinn=2
  184.  
  185. If gewinn=1 Then Print "Du hast Gewonnen" :  WaitKey() : End
  186. If gewinn=2 Then Print "Ich habe Gewonnen" : WaitKey() : End
  187.  
  188. ;Computer Zug - KI
  189.  
  190. ;Erster Zug:
  191. If zug=1 And feld(5)=1 Then feld(1)=2 : comp=comp+1
  192. If zug=1 And feld(5)=0 Then feld(5)=2 : comp=comp+1
  193. ;Zweiter Zug
  194. If zug=2 And (feld(1)=1 And feld(9)=1) Or zug=2 And feld(3)=1 And feld(7)=1 Then feld(8)=2 : comp=comp+1
  195.  
  196. ;prüfen ob 3er möglich
  197.  
  198. If zug>comp And feld(1)=2 And feld(4)=2 And feld(7)=0 Then feld(7)=2 : comp=comp+1
  199. If zug>comp And feld(2)=2 And feld(5)=2 And feld(8)=0 Then feld(8)=2 : comp=comp+1
  200. If zug>comp And feld(3)=2 And feld(6)=2 And feld(9)=0 Then feld(9)=2 : comp=comp+1
  201. If zug>comp And feld(4)=2 And feld(7)=2 And feld(1)=0 Then feld(1)=2 : comp=comp+1
  202. If zug>comp And feld(5)=2 And feld(8)=2 And feld(2)=0 Then feld(2)=2 : comp=comp+1
  203. If zug>comp And feld(6)=2 And feld(9)=2 And feld(3)=0 Then feld(3)=2 : comp=comp+1
  204. If zug>comp And feld(1)=2 And feld(2)=2 And feld(3)=0 Then feld(3)=2 : comp=comp+1
  205. If zug>comp And feld(4)=2 And feld(5)=2 And feld(6)=0 Then feld(6)=2 : comp=comp+1
  206. If zug>comp And feld(7)=2 And feld(8)=2 And feld(9)=0 Then feld(9)=2 : comp=comp+1
  207. If zug>comp And feld(2)=2 And feld(3)=2 And feld(1)=0 Then feld(1)=2 : comp=comp+1
  208. If zug>comp And feld(5)=2 And feld(6)=2 And feld(1)=0 Then feld(1)=2 : comp=comp+1
  209. If zug>comp And feld(8)=2 And feld(9)=2 And feld(7)=0 Then feld(7)=2 : comp=comp+1
  210. If zug>comp And feld(1)=2 And feld(5)=2 And feld(9)=0 Then feld(9)=2 : comp=comp+1
  211. If zug>comp And feld(3)=2 And feld(5)=2 And feld(7)=0 Then feld(7)=2 : comp=comp+1
  212. If zug>comp And feld(7)=2 And feld(5)=2 And feld(3)=0 Then feld(3)=2 : comp=comp+1
  213. If zug>comp And feld(9)=2 And feld(5)=2 And feld(1)=0 Then feld(1)=2 : comp=comp+1
  214.  
  215. If zug>comp And feld(1)=2 And feld(7)=2 And feld(4)=0 Then feld(4)=2 : comp=comp+1
  216. If zug>comp And feld(2)=2 And feld(8)=2 And feld(5)=0 Then feld(5)=2 : comp=comp+1
  217. If zug>comp And feld(3)=2 And feld(9)=2 And feld(6)=0 Then feld(6)=2 : comp=comp+1
  218. If zug>comp And feld(1)=2 And feld(3)=2 And feld(2)=0 Then feld(2)=2 : comp=comp+1
  219. If zug>comp And feld(4)=2 And feld(6)=2 And feld(5)=0 Then feld(5)=2 : comp=comp+1
  220. If zug>comp And feld(7)=2 And feld(9)=2 And feld(8)=0 Then feld(8)=2 : comp=comp+1
  221. If zug>comp And feld(1)=2 And feld(9)=2 And feld(5)=0 Then feld(5)=2 : comp=comp+1
  222. If zug>comp And feld(3)=2 And feld(7)=2 And feld(5)=0 Then feld(5)=2 : comp=comp+1
  223.  
  224.  
  225.  
  226. ;prüfen ob 3er geblock werden muss
  227. If zug>comp And feld(1)=1 And feld(4)=1 And feld(7)=0 Then feld(7)=2 : comp=comp+1
  228. If zug>comp And feld(2)=1 And feld(5)=1 And feld(8)=0 Then feld(8)=2 : comp=comp+1
  229. If zug>comp And feld(3)=1 And feld(6)=1 And feld(9)=0 Then feld(9)=2 : comp=comp+1
  230. If zug>comp And feld(4)=1 And feld(7)=1 And feld(1)=0 Then feld(1)=2 : comp=comp+1
  231. If zug>comp And feld(5)=1 And feld(8)=1 And feld(2)=0 Then feld(2)=2 : comp=comp+1
  232. If zug>comp And feld(6)=1 And feld(9)=1 And feld(3)=0 Then feld(3)=2 : comp=comp+1
  233. If zug>comp And feld(1)=1 And feld(2)=1 And feld(3)=0 Then feld(3)=2 : comp=comp+1
  234. If zug>comp And feld(4)=1 And feld(5)=1 And feld(6)=0 Then feld(6)=2 : comp=comp+1
  235. If zug>comp And feld(7)=1 And feld(8)=1 And feld(9)=0 Then feld(9)=2 : comp=comp+1
  236. If zug>comp And feld(2)=1 And feld(3)=1 And feld(1)=0 Then feld(1)=2 : comp=comp+1
  237. If zug>comp And feld(5)=1 And feld(6)=1 And feld(1)=0 Then feld(1)=2 : comp=comp+1
  238. If zug>comp And feld(8)=1 And feld(9)=1 And feld(7)=0 Then feld(7)=2 : comp=comp+1
  239. If zug>comp And feld(1)=1 And feld(5)=1 And feld(9)=0 Then feld(9)=2 : comp=comp+1
  240. If zug>comp And feld(3)=1 And feld(5)=1 And feld(7)=0 Then feld(7)=2 : comp=comp+1
  241. If zug>comp And feld(7)=1 And feld(5)=1 And feld(3)=0 Then feld(3)=2 : comp=comp+1
  242. If zug>comp And feld(9)=1 And feld(5)=1 And feld(1)=0 Then feld(1)=2 : comp=comp+1
  243.  
  244. If zug>comp And feld(1)=1 And feld(7)=1 And feld(4)=0 Then feld(4)=2 : comp=comp+1
  245. If zug>comp And feld(2)=1 And feld(8)=1 And feld(5)=0 Then feld(5)=2 : comp=comp+1
  246. If zug>comp And feld(3)=1 And feld(9)=1 And feld(6)=0 Then feld(6)=2 : comp=comp+1
  247. If zug>comp And feld(1)=1 And feld(3)=1 And feld(2)=0 Then feld(2)=2 : comp=comp+1
  248. If zug>comp And feld(4)=1 And feld(6)=1 And feld(5)=0 Then feld(5)=2 : comp=comp+1
  249. If zug>comp And feld(7)=1 And feld(9)=1 And feld(8)=0 Then feld(8)=2 : comp=comp+1
  250. If zug>comp And feld(1)=1 And feld(9)=1 And feld(5)=0 Then feld(5)=2 : comp=comp+1
  251. If zug>comp And feld(3)=1 And feld(7)=1 And feld(5)=0 Then feld(5)=2 : comp=comp+1
  252.  
  253. ;prüfen Ecke - Ecke - Blocken
  254. If zug>comp And zug=2 And feld(1)=1 And feld(9)=1 And feld(7)=0 Then feld(7)=2 : comp=comp+1
  255. If zug>comp And zug=2 And feld(3)=1 And feld(7)=1 And feld(7)=0 Then feld(7)=2 : comp=comp+1
  256.  
  257. ;prüfen 2 Seiten Trick
  258.  
  259.  
  260. If zug>comp And zug=2 And (feld(1)=1 Or feld(4)=1) And (feld(8)=1 Or feld(9)=1) And feld(7)=0 Then feld(7)=2: comp=comp+1
  261. If zug>comp And zug=2 And (feld(7)=1 Or feld(8)=1) And (feld(6)=1 Or feld(3)=1) And feld(9)=0 Then feld(9)=2: comp=comp+1
  262. If zug>comp And zug=2 And (feld(9)=1 Or feld(6)=1) And (feld(1)=1 Or feld(2)=1) And feld(3)=0 Then feld(3)=2: comp=comp+1
  263. If zug>comp And zug=2 And (feld(2)=1 Or feld(3)=1) And (feld(4)=1 Or feld(7)=1) And feld(1)=0 Then feld(1)=2: comp=comp+1
  264.  
  265. ;Zufall setzen
  266. For x=1 To 9
  267. If zug>comp  And feld(x)=0 Then feld(x)=2 : comp=comp+1
  268. Next
  269.  
  270.  
  271.  
  272. ;Neu zeichnen
  273. If feld(1) = 0 Then DrawImage leer1,0,0
  274. If feld(1) = 1 Then DrawImage kreuz1,0,0
  275. If feld(1) = 2 Then DrawImage kreis1,0,0
  276.  
  277. If feld(2) = 0 Then DrawImage leer2,150,0
  278. If feld(2) = 1 Then DrawImage kreuz2,150,0
  279. If feld(2) = 2 Then DrawImage kreis2,150,0
  280.  
  281. If feld(3) = 0 Then DrawImage leer3,300,0
  282. If feld(3) = 1 Then DrawImage kreuz3,300,0
  283. If feld(3) = 2 Then DrawImage kreis3,300,0
  284.  
  285. If feld(4) = 0 Then DrawImage leer4,0,150
  286. If feld(4) = 1 Then DrawImage kreuz4,0,150
  287. If feld(4) = 2 Then DrawImage kreis4,0,150
  288.  
  289. If feld(5) = 0 Then DrawImage leer5,150,150
  290. If feld(5) = 1 Then DrawImage kreuz5,150,150
  291. If feld(5) = 2 Then DrawImage kreis5,150,150
  292.  
  293. If feld(6) = 0 Then DrawImage leer6,300,150
  294. If feld(6) = 1 Then DrawImage kreuz6,300,150
  295. If feld(6) = 2 Then DrawImage kreis6,300,150
  296.  
  297. If feld(7) = 0 Then DrawImage leer7,0,300
  298. If feld(7) = 1 Then DrawImage kreuz7,0,300
  299. If feld(7) = 2 Then DrawImage kreis7,0,300
  300.  
  301. If feld(8) = 0 Then DrawImage leer8,150,300
  302. If feld(8) = 1 Then DrawImage kreuz8,150,300
  303. If feld(8) = 2 Then DrawImage kreis8,150,300
  304.  
  305. If feld(9) = 0 Then DrawImage leer9,300,300
  306. If feld(9) = 1 Then DrawImage kreuz9,300,300
  307. If feld(9) = 2 Then DrawImage kreis9,300,300
  308.  
  309. Flip
  310.  
  311. ;Analysiere Gewinn
  312.  
  313. If feld(1)=1 And feld(1)=feld(2) And feld(1)=feld(3) Then gewinn=1
  314. If feld(4)=1 And feld(4)=feld(5) And feld(4)=feld(6) Then gewinn=1
  315. If feld(7)=1 And feld(7)=feld(8) And feld(7)=feld(9) Then gewinn=1
  316. If feld(1)=1 And feld(1)=feld(4) And feld(1)=feld(7) Then gewinn=1
  317. If feld(2)=1 And feld(2)=feld(5) And feld(2)=feld(8) Then gewinn=1
  318. If feld(3)=1 And feld(3)=feld(6) And feld(3)=feld(9) Then gewinn=1
  319. If feld(1)=1 And feld(1)=feld(5) And feld(1)=feld(9) Then gewinn=1
  320. If feld(3)=1 And feld(3)=feld(5) And feld(3)=feld(7) Then gewinn=1
  321.  
  322. If feld(1)=2 And feld(1)=feld(2) And feld(1)=feld(3) Then gewinn=2
  323. If feld(4)=2 And feld(4)=feld(5) And feld(4)=feld(6) Then gewinn=2
  324. If feld(7)=2 And feld(7)=feld(8) And feld(7)=feld(9) Then gewinn=2
  325. If feld(1)=2 And feld(1)=feld(4) And feld(1)=feld(7) Then gewinn=2
  326. If feld(2)=2 And feld(2)=feld(5) And feld(2)=feld(8) Then gewinn=2
  327. If feld(3)=2 And feld(3)=feld(6) And feld(3)=feld(9) Then gewinn=2
  328. If feld(1)=2 And feld(1)=feld(5) And feld(1)=feld(9) Then gewinn=2
  329. If feld(3)=2 And feld(3)=feld(5) And feld(3)=feld(7) Then gewinn=2
  330.  
  331.  
  332. If gewinn=1 Then Print "Du hast Gewonnen" :  WaitKey() : End
  333. If gewinn=2 Then Print "Ich habe Gewonnen" : WaitKey() : End
  334. If zug=5 Then Goto beginn
  335. Goto start
  336.  
  337. End
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