Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AppTitle "Tic Tac Toe - u can't win"
- Graphics 450,450,16,2
- SetBuffer BackBuffer()
- Dim feld(10)
- Cls
- Flip
- ChangeDir ("data/")
- leer1=LoadImage ("1.jpg")
- leer2=LoadImage ("2.jpg")
- leer3=LoadImage ("3.jpg")
- leer4=LoadImage ("4.jpg")
- leer5=LoadImage ("5.jpg")
- leer6=LoadImage ("6.jpg")
- leer7=LoadImage ("7.jpg")
- leer8=LoadImage ("8.jpg")
- leer9=LoadImage ("9.jpg")
- kreuz1=LoadImage ("1-1.jpg")
- kreuz2=LoadImage ("2-1.jpg")
- kreuz3=LoadImage ("3-1.jpg")
- kreuz4=LoadImage ("4-1.jpg")
- kreuz5=LoadImage ("5-1.jpg")
- kreuz6=LoadImage ("6-1.jpg")
- kreuz7=LoadImage ("7-1.jpg")
- kreuz8=LoadImage ("8-1.jpg")
- kreuz9=LoadImage ("9-1.jpg")
- kreis1=LoadImage ("1-2.jpg")
- kreis2=LoadImage ("2-2.jpg")
- kreis3=LoadImage ("3-2.jpg")
- kreis4=LoadImage ("4-2.jpg")
- kreis5=LoadImage ("5-2.jpg")
- kreis6=LoadImage ("6-2.jpg")
- kreis7=LoadImage ("7-2.jpg")
- kreis8=LoadImage ("8-2.jpg")
- kreis9=LoadImage ("9-2.jpg")
- .beginn
- zug=0
- comp=0
- gewinn=0
- For st=0 To 9
- feld(st)=0
- Next
- Cls:Flip
- FlushMouse()
- .start
- If feld(1) = 0 Then DrawImage leer1,0,0
- If feld(1) = 1 Then DrawImage kreuz1,0,0
- If feld(1) = 2 Then DrawImage kreis1,0,0
- If feld(2) = 0 Then DrawImage leer2,150,0
- If feld(2) = 1 Then DrawImage kreuz2,150,0
- If feld(2) = 2 Then DrawImage kreis2,150,0
- If feld(3) = 0 Then DrawImage leer3,300,0
- If feld(3) = 1 Then DrawImage kreuz3,300,0
- If feld(3) = 2 Then DrawImage kreis3,300,0
- If feld(4) = 0 Then DrawImage leer4,0,150
- If feld(4) = 1 Then DrawImage kreuz4,0,150
- If feld(4) = 2 Then DrawImage kreis4,0,150
- If feld(5) = 0 Then DrawImage leer5,150,150
- If feld(5) = 1 Then DrawImage kreuz5,150,150
- If feld(5) = 2 Then DrawImage kreis5,150,150
- If feld(6) = 0 Then DrawImage leer6,300,150
- If feld(6) = 1 Then DrawImage kreuz6,300,150
- If feld(6) = 2 Then DrawImage kreis6,300,150
- If feld(7) = 0 Then DrawImage leer7,0,300
- If feld(7) = 1 Then DrawImage kreuz7,0,300
- If feld(7) = 2 Then DrawImage kreis7,0,300
- If feld(8) = 0 Then DrawImage leer8,150,300
- If feld(8) = 1 Then DrawImage kreuz8,150,300
- If feld(8) = 2 Then DrawImage kreis8,150,300
- If feld(9) = 0 Then DrawImage leer9,300,300
- If feld(9) = 1 Then DrawImage kreuz9,300,300
- If feld(9) = 2 Then DrawImage kreis9,300,300
- Flip
- WaitMouse()
- mausx=MouseX()
- mausy=MouseY()
- If feld(1)=0 And mausx<150 And mausy<150 Then feld(1)=1 : zug=zug+1
- If feld(2)=0 And mausx>150 And mausx<300 And mausy<150 Then feld(2)=1 : zug=zug+1
- If feld(3)=0 And mausx>300 And mausy<150 Then feld(3)=1 : zug=zug+1
- If feld(4)=0 And mausx<150 And mausy>150 And mausy<300 Then feld(4)=1 : zug=zug+1
- If feld(5)=0 And mausx>150 And mausx<300 And mausy>150 And mausy<300 Then feld(5)=1 : zug=zug+1
- If feld(6)=0 And mausx>300 And mausy>150 And mausy<300 Then feld(6)=1 : zug=zug+1
- If feld(7)=0 And mausx<150 And mausy>300 Then feld(7)=1 : zug=zug+1
- If feld(8)=0 And mausx>150 And mausx<300 And mausy>300 Then feld(8)=1 : zug=zug+1
- If feld(9)=0 And mausx>300 And mausy>300 Then feld(9)=1 : zug=zug+1
- Cls
- For bla=1 To 9
- If zug=5 Then feld(bla)=0
- Next
- If feld(1) = 0 Then DrawImage leer1,0,0
- If feld(1) = 1 Then DrawImage kreuz1,0,0
- If feld(1) = 2 Then DrawImage kreis1,0,0
- If feld(2) = 0 Then DrawImage leer2,150,0
- If feld(2) = 1 Then DrawImage kreuz2,150,0
- If feld(2) = 2 Then DrawImage kreis2,150,0
- If feld(3) = 0 Then DrawImage leer3,300,0
- If feld(3) = 1 Then DrawImage kreuz3,300,0
- If feld(3) = 2 Then DrawImage kreis3,300,0
- If feld(4) = 0 Then DrawImage leer4,0,150
- If feld(4) = 1 Then DrawImage kreuz4,0,150
- If feld(4) = 2 Then DrawImage kreis4,0,150
- If feld(5) = 0 Then DrawImage leer5,150,150
- If feld(5) = 1 Then DrawImage kreuz5,150,150
- If feld(5) = 2 Then DrawImage kreis5,150,150
- If feld(6) = 0 Then DrawImage leer6,300,150
- If feld(6) = 1 Then DrawImage kreuz6,300,150
- If feld(6) = 2 Then DrawImage kreis6,300,150
- If feld(7) = 0 Then DrawImage leer7,0,300
- If feld(7) = 1 Then DrawImage kreuz7,0,300
- If feld(7) = 2 Then DrawImage kreis7,0,300
- If feld(8) = 0 Then DrawImage leer8,150,300
- If feld(8) = 1 Then DrawImage kreuz8,150,300
- If feld(8) = 2 Then DrawImage kreis8,150,300
- If feld(9) = 0 Then DrawImage leer9,300,300
- If feld(9) = 1 Then DrawImage kreuz9,300,300
- If feld(9) = 2 Then DrawImage kreis9,300,300
- Flip
- ; unter 150 / 150 150 / 300 150 450
- ;Analysiere Gewinn
- If feld(1)=1 And feld(1)=feld(2) And feld(1)=feld(3) Then gewinn=1
- If feld(4)=1 And feld(4)=feld(5) And feld(4)=feld(6) Then gewinn=1
- If feld(7)=1 And feld(7)=feld(8) And feld(7)=feld(9) Then gewinn=1
- If feld(1)=1 And feld(1)=feld(4) And feld(1)=feld(7) Then gewinn=1
- If feld(2)=1 And feld(2)=feld(5) And feld(2)=feld(8) Then gewinn=1
- If feld(3)=1 And feld(3)=feld(6) And feld(3)=feld(9) Then gewinn=1
- If feld(1)=1 And feld(1)=feld(5) And feld(1)=feld(9) Then gewinn=1
- If feld(3)=1 And feld(3)=feld(5) And feld(3)=feld(7) Then gewinn=1
- If feld(1)=2 And feld(1)=feld(2) And feld(1)=feld(3) Then gewinn=2
- If feld(4)=2 And feld(4)=feld(5) And feld(4)=feld(6) Then gewinn=2
- If feld(7)=2 And feld(7)=feld(8) And feld(7)=feld(9) Then gewinn=2
- If feld(1)=2 And feld(1)=feld(4) And feld(1)=feld(7) Then gewinn=2
- If feld(2)=2 And feld(2)=feld(5) And feld(2)=feld(8) Then gewinn=2
- If feld(3)=2 And feld(3)=feld(6) And feld(3)=feld(9) Then gewinn=2
- If feld(1)=2 And feld(1)=feld(5) And feld(1)=feld(9) Then gewinn=2
- If feld(3)=2 And feld(3)=feld(5) And feld(3)=feld(7) Then gewinn=2
- If gewinn=1 Then Print "Du hast Gewonnen" : WaitKey() : End
- If gewinn=2 Then Print "Ich habe Gewonnen" : WaitKey() : End
- ;Computer Zug - KI
- ;Erster Zug:
- If zug=1 And feld(5)=1 Then feld(1)=2 : comp=comp+1
- If zug=1 And feld(5)=0 Then feld(5)=2 : comp=comp+1
- ;Zweiter Zug
- 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
- ;prüfen ob 3er möglich
- If zug>comp And feld(1)=2 And feld(4)=2 And feld(7)=0 Then feld(7)=2 : comp=comp+1
- If zug>comp And feld(2)=2 And feld(5)=2 And feld(8)=0 Then feld(8)=2 : comp=comp+1
- If zug>comp And feld(3)=2 And feld(6)=2 And feld(9)=0 Then feld(9)=2 : comp=comp+1
- If zug>comp And feld(4)=2 And feld(7)=2 And feld(1)=0 Then feld(1)=2 : comp=comp+1
- If zug>comp And feld(5)=2 And feld(8)=2 And feld(2)=0 Then feld(2)=2 : comp=comp+1
- If zug>comp And feld(6)=2 And feld(9)=2 And feld(3)=0 Then feld(3)=2 : comp=comp+1
- If zug>comp And feld(1)=2 And feld(2)=2 And feld(3)=0 Then feld(3)=2 : comp=comp+1
- If zug>comp And feld(4)=2 And feld(5)=2 And feld(6)=0 Then feld(6)=2 : comp=comp+1
- If zug>comp And feld(7)=2 And feld(8)=2 And feld(9)=0 Then feld(9)=2 : comp=comp+1
- If zug>comp And feld(2)=2 And feld(3)=2 And feld(1)=0 Then feld(1)=2 : comp=comp+1
- If zug>comp And feld(5)=2 And feld(6)=2 And feld(1)=0 Then feld(1)=2 : comp=comp+1
- If zug>comp And feld(8)=2 And feld(9)=2 And feld(7)=0 Then feld(7)=2 : comp=comp+1
- If zug>comp And feld(1)=2 And feld(5)=2 And feld(9)=0 Then feld(9)=2 : comp=comp+1
- If zug>comp And feld(3)=2 And feld(5)=2 And feld(7)=0 Then feld(7)=2 : comp=comp+1
- If zug>comp And feld(7)=2 And feld(5)=2 And feld(3)=0 Then feld(3)=2 : comp=comp+1
- If zug>comp And feld(9)=2 And feld(5)=2 And feld(1)=0 Then feld(1)=2 : comp=comp+1
- If zug>comp And feld(1)=2 And feld(7)=2 And feld(4)=0 Then feld(4)=2 : comp=comp+1
- If zug>comp And feld(2)=2 And feld(8)=2 And feld(5)=0 Then feld(5)=2 : comp=comp+1
- If zug>comp And feld(3)=2 And feld(9)=2 And feld(6)=0 Then feld(6)=2 : comp=comp+1
- If zug>comp And feld(1)=2 And feld(3)=2 And feld(2)=0 Then feld(2)=2 : comp=comp+1
- If zug>comp And feld(4)=2 And feld(6)=2 And feld(5)=0 Then feld(5)=2 : comp=comp+1
- If zug>comp And feld(7)=2 And feld(9)=2 And feld(8)=0 Then feld(8)=2 : comp=comp+1
- If zug>comp And feld(1)=2 And feld(9)=2 And feld(5)=0 Then feld(5)=2 : comp=comp+1
- If zug>comp And feld(3)=2 And feld(7)=2 And feld(5)=0 Then feld(5)=2 : comp=comp+1
- ;prüfen ob 3er geblock werden muss
- If zug>comp And feld(1)=1 And feld(4)=1 And feld(7)=0 Then feld(7)=2 : comp=comp+1
- If zug>comp And feld(2)=1 And feld(5)=1 And feld(8)=0 Then feld(8)=2 : comp=comp+1
- If zug>comp And feld(3)=1 And feld(6)=1 And feld(9)=0 Then feld(9)=2 : comp=comp+1
- If zug>comp And feld(4)=1 And feld(7)=1 And feld(1)=0 Then feld(1)=2 : comp=comp+1
- If zug>comp And feld(5)=1 And feld(8)=1 And feld(2)=0 Then feld(2)=2 : comp=comp+1
- If zug>comp And feld(6)=1 And feld(9)=1 And feld(3)=0 Then feld(3)=2 : comp=comp+1
- If zug>comp And feld(1)=1 And feld(2)=1 And feld(3)=0 Then feld(3)=2 : comp=comp+1
- If zug>comp And feld(4)=1 And feld(5)=1 And feld(6)=0 Then feld(6)=2 : comp=comp+1
- If zug>comp And feld(7)=1 And feld(8)=1 And feld(9)=0 Then feld(9)=2 : comp=comp+1
- If zug>comp And feld(2)=1 And feld(3)=1 And feld(1)=0 Then feld(1)=2 : comp=comp+1
- If zug>comp And feld(5)=1 And feld(6)=1 And feld(1)=0 Then feld(1)=2 : comp=comp+1
- If zug>comp And feld(8)=1 And feld(9)=1 And feld(7)=0 Then feld(7)=2 : comp=comp+1
- If zug>comp And feld(1)=1 And feld(5)=1 And feld(9)=0 Then feld(9)=2 : comp=comp+1
- If zug>comp And feld(3)=1 And feld(5)=1 And feld(7)=0 Then feld(7)=2 : comp=comp+1
- If zug>comp And feld(7)=1 And feld(5)=1 And feld(3)=0 Then feld(3)=2 : comp=comp+1
- If zug>comp And feld(9)=1 And feld(5)=1 And feld(1)=0 Then feld(1)=2 : comp=comp+1
- If zug>comp And feld(1)=1 And feld(7)=1 And feld(4)=0 Then feld(4)=2 : comp=comp+1
- If zug>comp And feld(2)=1 And feld(8)=1 And feld(5)=0 Then feld(5)=2 : comp=comp+1
- If zug>comp And feld(3)=1 And feld(9)=1 And feld(6)=0 Then feld(6)=2 : comp=comp+1
- If zug>comp And feld(1)=1 And feld(3)=1 And feld(2)=0 Then feld(2)=2 : comp=comp+1
- If zug>comp And feld(4)=1 And feld(6)=1 And feld(5)=0 Then feld(5)=2 : comp=comp+1
- If zug>comp And feld(7)=1 And feld(9)=1 And feld(8)=0 Then feld(8)=2 : comp=comp+1
- If zug>comp And feld(1)=1 And feld(9)=1 And feld(5)=0 Then feld(5)=2 : comp=comp+1
- If zug>comp And feld(3)=1 And feld(7)=1 And feld(5)=0 Then feld(5)=2 : comp=comp+1
- ;prüfen Ecke - Ecke - Blocken
- 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
- 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
- ;prüfen 2 Seiten Trick
- 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
- 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
- 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
- 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
- ;Zufall setzen
- For x=1 To 9
- If zug>comp And feld(x)=0 Then feld(x)=2 : comp=comp+1
- Next
- ;Neu zeichnen
- If feld(1) = 0 Then DrawImage leer1,0,0
- If feld(1) = 1 Then DrawImage kreuz1,0,0
- If feld(1) = 2 Then DrawImage kreis1,0,0
- If feld(2) = 0 Then DrawImage leer2,150,0
- If feld(2) = 1 Then DrawImage kreuz2,150,0
- If feld(2) = 2 Then DrawImage kreis2,150,0
- If feld(3) = 0 Then DrawImage leer3,300,0
- If feld(3) = 1 Then DrawImage kreuz3,300,0
- If feld(3) = 2 Then DrawImage kreis3,300,0
- If feld(4) = 0 Then DrawImage leer4,0,150
- If feld(4) = 1 Then DrawImage kreuz4,0,150
- If feld(4) = 2 Then DrawImage kreis4,0,150
- If feld(5) = 0 Then DrawImage leer5,150,150
- If feld(5) = 1 Then DrawImage kreuz5,150,150
- If feld(5) = 2 Then DrawImage kreis5,150,150
- If feld(6) = 0 Then DrawImage leer6,300,150
- If feld(6) = 1 Then DrawImage kreuz6,300,150
- If feld(6) = 2 Then DrawImage kreis6,300,150
- If feld(7) = 0 Then DrawImage leer7,0,300
- If feld(7) = 1 Then DrawImage kreuz7,0,300
- If feld(7) = 2 Then DrawImage kreis7,0,300
- If feld(8) = 0 Then DrawImage leer8,150,300
- If feld(8) = 1 Then DrawImage kreuz8,150,300
- If feld(8) = 2 Then DrawImage kreis8,150,300
- If feld(9) = 0 Then DrawImage leer9,300,300
- If feld(9) = 1 Then DrawImage kreuz9,300,300
- If feld(9) = 2 Then DrawImage kreis9,300,300
- Flip
- ;Analysiere Gewinn
- If feld(1)=1 And feld(1)=feld(2) And feld(1)=feld(3) Then gewinn=1
- If feld(4)=1 And feld(4)=feld(5) And feld(4)=feld(6) Then gewinn=1
- If feld(7)=1 And feld(7)=feld(8) And feld(7)=feld(9) Then gewinn=1
- If feld(1)=1 And feld(1)=feld(4) And feld(1)=feld(7) Then gewinn=1
- If feld(2)=1 And feld(2)=feld(5) And feld(2)=feld(8) Then gewinn=1
- If feld(3)=1 And feld(3)=feld(6) And feld(3)=feld(9) Then gewinn=1
- If feld(1)=1 And feld(1)=feld(5) And feld(1)=feld(9) Then gewinn=1
- If feld(3)=1 And feld(3)=feld(5) And feld(3)=feld(7) Then gewinn=1
- If feld(1)=2 And feld(1)=feld(2) And feld(1)=feld(3) Then gewinn=2
- If feld(4)=2 And feld(4)=feld(5) And feld(4)=feld(6) Then gewinn=2
- If feld(7)=2 And feld(7)=feld(8) And feld(7)=feld(9) Then gewinn=2
- If feld(1)=2 And feld(1)=feld(4) And feld(1)=feld(7) Then gewinn=2
- If feld(2)=2 And feld(2)=feld(5) And feld(2)=feld(8) Then gewinn=2
- If feld(3)=2 And feld(3)=feld(6) And feld(3)=feld(9) Then gewinn=2
- If feld(1)=2 And feld(1)=feld(5) And feld(1)=feld(9) Then gewinn=2
- If feld(3)=2 And feld(3)=feld(5) And feld(3)=feld(7) Then gewinn=2
- If gewinn=1 Then Print "Du hast Gewonnen" : WaitKey() : End
- If gewinn=2 Then Print "Ich habe Gewonnen" : WaitKey() : End
- If zug=5 Then Goto beginn
- Goto start
- End
Add Comment
Please, Sign In to add comment