Global gfx = 1300, gfy = 1000 Graphics gfx,gfy,32,2 SetBuffer BackBuffer() SeedRnd MilliSecs() Dim zlog$(10000000) Global zlogz = 0 ClsColor 255,255,255 Global bool = False Global k208 = False, k200 = False, k203 = False, k205 = False Global k28 = False, k57 = False ;Menüs Global status = 0 Global hmstatus = 0 Global nsstatus = 0, nsspa = 0, nssm = 0 Global nsg = 0, nsv Global mbt = 0, mbf = 20 Global b = 10,h = 18,p If b >= h Then p = 1000/b Else p = 1000/h EndIf Global sstatus = 0, vs = 1000,v , t = MilliSecs() Global ao = Rand(0,6)*4, zs, rl = b/2-1 Global go, no = Rand(0,6)*4 Global klt, krt, kdmax = 9 Global vzs, vzt Global sa = 0, vzz = 0 Global spieler, modus, vorschau Global punkte = 0, linien Global od, ols, ors, of ;Befehle: Drehen, Linksschieben, Rechtsschieben, Fallen lassen Global highscorel Dim scores$(100) Dim vz(h-1) Dim f(b-1,h-1) Global objanz = 27 Dim objp(objanz) ;Objektpräferenz für KI objp(0) = 0 objp(1) = 1 objp(2) = 2 objp(3) = 3 objp(4) = 5 objp(5) = 7 objp(6) = 4 objp(7) = 6 objp(8) = 8 objp(9) = 10 objp(10) = 9 objp(11) = 11 objp(12) = 12 objp(13) = 14 objp(14) = 13 objp(15) = 15 objp(16) = 18 objp(17) = 16 objp(18) = 17 objp(19) = 19 objp(20) = 22 objp(21) = 21 objp(22) = 20 objp(23) = 23 objp(24) = 26 objp(25) = 27 objp(26) = 24 objp(27) = 25 Dim objx(objanz) objx(0) = 0 objx(4) = -1 objx(8) = -1 objx(12) = -1 objx(16) = -1 objx(20) = -1 objx(24) = -1 Dim objy(objanz) objy(0) = 0 objy(4) = -2 objy(8) = -1 objy(12) = 0 objy(16) = -1 objy(20) = -1 objy(24) = -1 Dim objf(objanz,3,3) objf(0,0,0) = 1 objf(0,0,1) = 1 objf(0,1,0) = 1 objf(0,1,1) = 1 objf(1,0,0) = 1 objf(1,0,1) = 1 objf(1,1,0) = 1 objf(1,1,1) = 1 objf(2,0,0) = 1 objf(2,0,1) = 1 objf(2,1,0) = 1 objf(2,1,1) = 1 objf(3,0,0) = 1 objf(3,0,1) = 1 objf(3,1,0) = 1 objf(3,1,1) = 1 objf(4,0,2) = 1 objf(4,1,2) = 1 objf(4,2,2) = 1 objf(4,3,2) = 1 objf(5,1,0) = 1 objf(5,1,1) = 1 objf(5,1,2) = 1 objf(5,1,3) = 1 objf(6,0,2) = 1 objf(6,1,2) = 1 objf(6,2,2) = 1 objf(6,3,2) = 1 objf(7,1,0) = 1 objf(7,1,1) = 1 objf(7,1,2) = 1 objf(7,1,3) = 1 objf(8,0,2) = 1 objf(8,1,1) = 1 objf(8,1,2) = 1 objf(8,2,1) = 1 objf(9,0,0) = 1 objf(9,0,1) = 1 objf(9,1,1) = 1 objf(9,1,2) = 1 objf(10,0,2) = 1 objf(10,1,1) = 1 objf(10,1,2) = 1 objf(10,2,1) = 1 objf(11,0,0) = 1 objf(11,0,1) = 1 objf(11,1,1) = 1 objf(11,1,2) = 1 objf(12,0,0) = 1 objf(12,1,0) = 1 objf(12,1,1) = 1 objf(12,2,1) = 1 objf(13,0,1) = 1 objf(13,1,1) = 1 objf(13,1,0) = 1 objf(13,0,2) = 1 objf(14,0,0) = 1 objf(14,1,0) = 1 objf(14,1,1) = 1 objf(14,2,1) = 1 objf(15,0,1) = 1 objf(15,1,1) = 1 objf(15,1,0) = 1 objf(15,0,2) = 1 objf(16,0,1) = 1 objf(16,1,1) = 1 objf(16,2,1) = 1 objf(16,1,2) = 1 objf(17,1,0) = 1 objf(17,0,1) = 1 objf(17,1,2) = 1 objf(17,1,1) = 1 objf(18,1,0) = 1 objf(18,0,1) = 1 objf(18,1,1) = 1 objf(18,2,1) = 1 objf(19,1,0) = 1 objf(19,2,1) = 1 objf(19,1,2) = 1 objf(19,1,1) = 1 objf(20,2,2) = 1 objf(20,0,1) = 1 objf(20,1,1) = 1 objf(20,2,1) = 1 objf(21,1,0) = 1 objf(21,1,1) = 1 objf(21,1,2) = 1 objf(21,0,2) = 1 objf(22,0,0) = 1 objf(22,0,1) = 1 objf(22,1,1) = 1 objf(22,2,1) = 1 objf(23,1,0) = 1 objf(23,2,0) = 1 objf(23,1,1) = 1 objf(23,1,2) = 1 objf(24,0,1) = 1 objf(24,0,2) = 1 objf(24,1,1) = 1 objf(24,2,1) = 1 objf(25,0,0) = 1 objf(25,1,0) = 1 objf(25,1,1) = 1 objf(25,1,2) = 1 objf(26,0,1) = 1 objf(26,1,1) = 1 objf(26,2,1) = 1 objf(26,2,0) = 1 objf(27,1,0) = 1 objf(27,1,1) = 1 objf(27,1,2) = 1 objf(27,2,2) = 1 Dim objt(objanz,3,3) Dim objd(objanz,2) For i = 0 To objanz For i2 = 0 To 3 For i3 = 0 To 3 objt(i,i2,i3) = 50 ;STANDARD (Wenn kein Stein in einer ganzen Reihe ist) Next Next Next For i = 0 To objanz ;Alle Objekte For i2 = 0 To 3 ;Von Links nach Rechts (Breite 4) For i3 = 0 To 3 ;Von Unten nach oben (3-i3) ersten Stein suchen If objf(i,i2,3-i3) = 1 Then objt(i,i2,0) = i3 ;Abstand des ersten Steins(i3) einer Reihe(i2) speichern i3 = 3 EndIf Next Next Next For i = 0 To objanz ;Alle Objekte For i2 = 0 To 3 ;Von Links nach Rechts For i3 = 1 To 3 ;Abschnitt mit Breite 2, 3 und 4 objt(i,i2,0) ist Ursprung If i2+i3 < 4 Then If objt(i,i2+i3,0) <> 50 Then objt(i,i2,i3) = objt(i,i2,0) - objt(i,i2+i3,0) Else objt(i,i2,i3) = 50 EndIf Else objt(i,i2,i3) = 100 EndIf Next Next Next For i = 0 To objanz For i2 = 0 To 2 objd(i,i2) = objt(i,i2,1) nlog(objd(i,i2) + ";" + objt(i,i2,0)) ;btext(100+i2*20,10+i*14,objd(i,i2),1,14,0) ;btext(10+i2*20,10+i*14,objt(i,i2,0),1,14,0) Next Next ;wl("steine") Global kimod = 1 Dim terra(b-1,3) ;Geländehöhe (Nummer(Links-Rechts)(Start),Index(Relativ zu Nummer)) ;AUTOPLAYER ;KI Dim terra2(b-1,3) ;Das Gelände, das entstehen würde, wenn der Stein da, und dort hingelegt wird ;Für kimod 0 Global schlucht, schluchtrl ;Für kimod 1 Dim f2(b-1,h-1) Dim prior(objanz,b) Global bop, boon, borl ;Auswahl des Besten Objekts (Prioritätswert, Nummer, Ort) Dim ah(objanz,b) Global fla, fre Global vr ;Volle Reihen (Anzahl bei einem Zug(temporär)) Dim vrrl(4) ;Koordinate Dim vrobj(4) ;Objektnummer Global geplh Global geplz, geplo For i = 0 To objanz For i2 = 1 To 3 ;objt(i,i2) = -5 For i3 = 0 To 3 If objf(i,i2,3-i3) = 1 Then ; If objt(i,0) <> -5 Then ; objt(i,i2) = objt(i,0)-i3 Else ; objt(i,i2) = i3 EndIf i3 = 3 ;EndIf Next Next Next Color 255,0,0 For o = 0 To 19 ;Text 10,o*50,o For i = 0 To 3 For i2 = 0 To 3 ; btext(60+i2*28,i*12+o*50,objt(o,i2,i),1,14,0) Next Next Next For o = 20 To objanz ;Text 210,(o-20)*50,o For i = 0 To 3 For i2 = 0 To 3 ;btext(260+i2*28,i*12+(o-20)*50,objt(o,i2,i),1,14,0) Next Next Next For i = 0 To 3 For i2 = 0 To 3 ;btext(0+i*28,100+i2*14,objt(16,i2,i),1,14,0) Next Next For i = 0 To objanz ;Text 10,10+i*20,i For i2 = 0 To 3 ;Text 30+i2*20,10+i*20,objt(i,i2,0) Next Next Flip ;WaitMouse() Flip Dim objr(objanz) Dim objg(objanz) Dim objbl(objanz) objr(0) = 255 objg(0) = 0 objbl(0) = 0 objr(4) = 255 objg(4) = 255 objbl(4) = 0 objr(8) = 100 objg(8) = 200 objbl(8) = 255 objr(12) = 0 objg(12) = 230 objbl(12) = 0 objr(16) = 0 objg(16) = 0 objbl(16) = 200 objr(20) = 190 objg(20) = 0 objbl(20) = 255 objr(24) = 244 objg(24) = 103 objbl(24) = 7 For i = 0 To objanz If i Mod 4 > 0 Then objr(i) = objr(i-i Mod 4) objg(i) = objg(i-i Mod 4) objbl(i) = objbl(i-i Mod 4) EndIf Next Dim objb(objanz) For i = 0 To objanz ti = -1 For i2 = 0 To 3 For i3 = 0 To 3 If objf(i,i2,i3) > 0 And ti < i2 Then ti = i2 EndIf Next Next objb(i) = ti + 1 Next Dim objh(objanz) For i = 0 To objanz ti = -1 For i2 = 0 To 3 For i3 = 0 To 3 If objf(i,i2,i3) > 0 And ti < i3 Then ti = i3 EndIf Next Next objh(i) = ti + 1 Next For i = 0 To objanz btextc(230,10+i*14,objb(i) + "x" + objh(i),1,14,0,255,0,0) Next Flip ;WaitMouse() Global maxtextheight = 110, mintextheight = 1, fonts = 2, tmp$, zeile, wanz, sbreite Dim w$(1000) Dim fnt(fonts-1,maxtextheight-1) Color 0,0,0 For i = mintextheight To maxtextheight-1 ;fnt(0,i) = LoadFont("Times New Roman",i,False,False,False) ;btextc(100,100,"Lädt Schriften..",0,i,0,0,0,0) Flip Cls Next For i = mintextheight To maxtextheight-1 fnt(1,i) = LoadFont("Courier New",i,True,False,False) Next HidePointer() FlushKeys() While Not KeyHit(1) Select status Case 0 k28 = KeyHit(28) k57 = KeyHit(57) mbt = (mbt+1) Mod mbf btextc(650,100,"TETRIS",1,100,1,0,0,0) If hmstatus <> 0 Or (hmstatus = 0 And mbt < mbf/2) Then btextc(650,300,"NEUES SPIEL",1,70,1,0,0,0) EndIf If hmstatus <> 1 Or (hmstatus = 1 And mbt < mbf/2) Then btextc(650,450,"SPIEL LADEN",1,70,1,0,0,0) EndIf If hmstatus <> 2 Or (hmstatus = 2 And mbt < mbf/2) Then btextc(650,600,"HIGHSCORE",1,70,1,0,0,0) EndIf If hmstatus <> 3 Or (hmstatus = 3 And mbt < mbf/2) Then btextc(650,900,"BEENDEN",1,70,1,0,0,0) EndIf If k28 Or k57 Then status = hmstatus + 2 EndIf If KeyHit(200) Then hmstatus = hmstatus - 1 mbt = 0 If hmstatus < 0 Then hmstatus = 0 EndIf EndIf If KeyHit(208) Then hmstatus = hmstatus + 1 mbt = 0 If hmstatus > 3 Then hmstatus = 3 EndIf EndIf Case 2 ;Neues Spiel mbt = (mbt+1) Mod mbf k28 = KeyHit(28) k57 = KeyHit(57) k200 = KeyHit(200) k208 = KeyHit(208) k203 = KeyHit(203) k205 = KeyHit(205) If k203 Or k205 Or k200 Or k208 Then mbt = 0 EndIf btextc(650,100,"NEUES SPIEL",1,100,1,0,0,0) If k208 Then If nsstatus < 99 And nsstatus <> 3 Then nsstatus = nsstatus + 1 k208 = False EndIf EndIf If k200 Then If nsstatus <> 3 And nsstatus < 99 Then nsstatus = nsstatus - 1 Else If nsstatus = 99 Then nsstatus = 3 k200 = False EndIf If nsstatus < 0 Then nsstatus = 0 EndIf EndIf If nsstatus <> 0 Then If nsspa > -1 Then btextc(120,170,"SPIELER: " + (1+nsspa) + " SPIELER",1,65,0,0,0,0) Else btextc(120,170,"SPIELER: COMPUTER",1,65,0,0,0,0) EndIf Else If k203 Then nsspa = nsspa - 1 If nsspa < -1 Then nsspa = nsspa+3 EndIf EndIf If k205 Then nsspa = nsspa + 1 If nsspa > 1 Then nsspa = nsspa-3 EndIf EndIf If (mbt < mbf/2) Then If nsspa > -1 Then btextc(120,170,"SPIELER: " + (1+nsspa) + " SPIELER",1,65,0,0,0,0) Else btextc(120,170,"SPIELER: COMPUTER",1,65,0,0,0,0) EndIf EndIf EndIf If nsstatus <> 1 Then Color 0,0,0 Select nssm Case 0 btext(120,250,"SPIELMODUS: TRADITIONELL",1,65,0) Case 1 btext(120,250,"SPIELMODUS: LINEBREAKER",1,65,0) End Select Else If k203 Then nssm = nssm - 1 If nssm < 0 Then nssm = 0 EndIf EndIf If k205 Then nssm = nssm + 1 If nssm > 1 Then nssm = 1 EndIf EndIf If (mbt < mbf/2) Then Color 0,0,0 Select nssm Case 0 btext(120,250,"SPIELMODUS: TRADITIONELL",1,65,0) Case 1 btext(120,250,"SPIELMODUS: LINEBREAKER",1,65,0) End Select EndIf EndIf If nsstatus <> 2 Or mbt >= mbf/2 Then If nsv = 0 Then btext(120,420,"VORSCHAU: JA",1,65,0) Else btext(120,420,"VORSCHAU: NEIN",1,65,0) EndIf EndIf If nsstatus = 2 Then If k203 Or k205 Then nsv = nsv Xor 1 EndIf EndIf brect(350,520,600,280,0,0,0,0) brect(351,521,598,278,0,0,0,0) For i = 0 To 4 bline(469+i*120,520,469+i*120,798,0,0,0) brect(351,640,598,40,1,255,0,0) If nsg <> i btextc(410+i*120,580,i,1,70,1,240,240,0) Else If (mbt < mbf/2) Or nsstatus <> 3 Then btextc(410+i*120,580,i,1,70,1,0,0,0) EndIf EndIf If nsg <> i+5 btextc(410+i*120,740,i+5,1,70,1,240,240,0) Else If (mbt < mbf/2) Or nsstatus <> 3 Then btextc(410+i*120,740,i+5,1,70,1,0,0,0) EndIf EndIf Next If nsstatus = 3 Then If k200 Then If nsg > 4 Then nsg = nsg - 5 Else nsstatus = 2 EndIf EndIf If k208 Then If nsg < 5 Then nsg = nsg + 5 Else nsstatus = 99 EndIf EndIf If k203 Then nsg = nsg - 1 If nsg < 0 Then nsg = 0 EndIf EndIf If k205 Then nsg = nsg + 1 If nsg > 9 Then nsg = 9 EndIf EndIf If k28 Or k57 Then nsstatus = 99 EndIf EndIf If nsstatus <> 99 Then btextc(650,920,"SPIEL STARTEN",1,75,1,0,0,0) Else If (mbt < mbf/2) Then btextc(650,920,"SPIEL STARTEN",1,75,1,0,0,0) EndIf If k28 Or k57 Then vs = 800-nsg*68 vorschau = nsv spieler = nsspa+1 modus = nssm nspiel() status = 1 EndIf EndIf Case 3 ;Spiel Laden Case 4 ;Highscore Case 5 ; Beenden End Case 1 If KeyHit(10) Then nspiel() EndIf Color 100,100,100 If spieler < 2 And modus = 0 Then Rect 0,0,300-p,1000 For i2 = 0 To h-1 For i = 0 To (1000-p*b)/p Rect 300+p*b+i*p+1,i2*p+1,p-2,p-2 Next Rect 300-p+1,i2*p+1,p-2,p-2 Next For i = 0 To 1000/p Rect 300-p+i*p+1,h*p+1,p-2,p-2 Next EndIf Color 255,255,255 ; btext(10,120,modus + " " + spieler + " " + vorschau,1,14,0) btext(10,100,"Punktzahl: " + punkte,1,24,0) btext(10,200,"Linien: " + linien,1,24,0) ; btext(10,10,no + " " + ao + " " + rl + " " + zs,1,14,0) ; btext(10,30,klt + " " + krt + " " + kdmax,1,14,0) ; btext(10,50,b + "x" + h,1,14,0) ; btext(10,70,vzt + " " + (MilliSecs()-vzt) + " " + (MilliSecs()-vzt) Mod 400,1,14,0) ; btext(10,85,geplo + " " + geplz,1,14,0) If KeyHit(2) Then spieler = spieler Xor 1 EndIf If KeyHit(28) Then nobj() EndIf For i = 0 To h-1 For i2 = 0 To b-1 If f(i2,i) > 0 Then Color objr(f(i2,i)-1),objg(f(i2,i)-1),objbl(f(i2,i)-1) Rect 300+i2*p,i*p,p,p Color 0,0,0 Rect 300+i2*p,i*p,p,p,0 EndIf Next Next Color 0,0,0 Line 300,0,300,h*p Line 300,h*p,300+b*p,h*p Line 300+b*p,0,300+b*p,h*p Color 200,0,0 For i = 0 To 3 For i2 = 0 To 3 If objf(ao,i,i2) > 0 Then Color objr(ao),objg(ao),objbl(ao) Rect 300+rl*p+i*p,i2*p+zs*p,p,p Color 0,0,0 Rect 300+rl*p+i*p,i2*p+zs*p,p,p,0 EndIf Next Next ;Bewegung zum Richtigen Ort / Zustand ;AUTOCOMPUTER ols = False ors = False od = False of = False If spieler = 0 Then If rl > geplo Then ols = True Else If rl < geplo Then ors = True Else of = True EndIf If geplz <> ao Then od = True EndIf EndIf If spieler > 0 Then If KeyDown(203) Then klt = (klt+2) EndIf Else If ols Then klt = (klt+2) EndIf EndIf klt = klt - 1 If klt < 0 Then klt = 0 EndIf If klt = kdmax-1 Or (KeyHit(203) And spieler > 0) Then bool = True For i = 0 To objb(ao)-1 For i2 = 0 To objh(ao)-1 If objf(ao,i,i2) > 0 Then If rl+i <= 0 Then bool = False Else If zs+i2 >= 0 Then If f(rl+i-1,zs+i2) > 0 Then bool = False EndIf EndIf EndIf Next Next If bool Then rl = rl - 1 EndIf klt = -1 EndIf If spieler > 0 Then If KeyDown(205) Then krt = (krt+2) EndIf Else If ors Then krt = (krt+2) EndIf EndIf krt = krt - 1 If krt < 0 Then krt = 0 EndIf If krt = kdmax-1 Or (KeyHit(205) And spieler > 0) Then bool = True For i = 0 To objb(ao)-1 For i2 = 0 To objh(ao)-1 If objf(ao,i,i2) > 0 Then If rl+i >= b-1 Then bool = False Else If zs+i2 >= 0 Then If f(rl+i+1,zs+i2) > 0 Then bool = False EndIf EndIf EndIf Next Next If bool Then rl = rl + 1 EndIf krt = -1 EndIf bool = True If od = True Or (KeyHit(57) And spieler > 0) Then bool = True For i = 0 To (objanz-3)/4 For i2 = 0 To 3 If i*4+i2 = ao Then go = i*4 + (i2+1) Mod 4 For i3 = 0 To objb(go)-1 For i4 = 0 To objh(go)-1 If objf(go,i3,i4) > 0 Then If rl+i3 < 0 Or rl+i3 >= b Then bool = False Else If zs+i4 >= 0 And zs+i4 < h Then If f(rl+i3,zs+i4) > 0 Then bool = False EndIf Else If zs+i4 >= h Then bool = False EndIf EndIf Next Next If bool Then ao = go i = (objanz-3)/4 i2 = 3 EndIf EndIf Next Next EndIf If KeyHit(208) Then k208 = True EndIf If Not KeyDown(208) Then k208 = False EndIf If (k208 And spieler > 0) Or of Then v = 40 Else v = vs sa = 0 EndIf If KeyHit(25) Or KeyHit(Asc("O")) Then If sstatus = 0 Then sstatus = 1 Else If sstatus = 1 Then sstatus = 0 EndIf EndIf If MilliSecs()-t > v And vzt = 0 And KeyDown(49) = False And sstatus = 0 Then aufp = False For i = 0 To objb(ao)-1 For i2 = 0 To objh(ao)-1 If objf(ao,i,i2) > 0 Then If zs+i2 >= h-1 Then aufp = True Else If f(rl+i,zs+i2+1) > 0 Then aufp = True EndIf EndIf Next Next If aufp Then For i = 0 To 3 For i2 = 0 To 3 If objf(ao,i,i2) > 0 Then f(rl+i,zs+i2) = ao+1 ; f2(rl+i,zs+i2) = ao+1 EndIf Next Next For i = 0 To h-1 bool = True For i2 = 0 To b-1 If f(i2,i) = 0 Then bool = False EndIf Next If bool Then vz(i) = True vzt = MilliSecs() If i < h Then For i3 = i+1 To kint(e,i+3) bool = True For i4 = 0 To b-1 If f(i4,i3) = 0 Then bool = False EndIf Next If bool Then vz(i3) = True EndIf Next EndIf EndIf Next If vzt = 0 Then nobj() EndIf Else If v = 40 Then sa = sa + 1 EndIf zs = zs + 1 EndIf t = MilliSecs() EndIf If vzt > 0 Then If ((MilliSecs()-vzt) Mod 333) > 333/2 Then For i = 0 To h-1 If vz(i) = 1 Then Color 255,255,255 Rect 301,i*p+1,p*b-2,p-1 EndIf Next EndIf If MilliSecs()-vzt >= 1334 Then vzt = 0 For i = 0 To h-1 If vz(i) = 1 Then vzz = vzz + 1 For i2 = 0 To i-1 For i3 = 0 To b-1 f(i3,i-i2) = f(i3,i-i2-1) ; f2(i3,i-i2) = f2(i3,i-i2-1) Next Next vz(i) = False EndIf Next linien = linien + vzz Select vzz Case 1 punkte = punkte + 320 Case 2 punkte = punkte + 800 Case 3 punkte = punkte + 2400 Case 4 punkte = punkte + 9600 End Select nobj() EndIf EndIf If sstatus = 1 Then btext(300+p*b/2,200,"PAUSE",1,80,1) EndIf If sstatus = 2 Then btext(300+p*b/2,200,"YOU LOOSE",1,80,1) nscore() nspiel() EndIf For i = 0 To b-1 For i2 = 0 To 3 ;btext(900+i*28,100+i2*14,terra(i,i2),1,14,0) Next Next End Select Flip Cls Wend End Function nobj() If sa > 0 Then punkte = punkte + sa sa = 0 EndIf vzz = 0 ao = no no = Rand(0,6)*4 zs = 1+objy(ao) rl = b/2-1+objx(ao) t = MilliSecs() k208 = False vzt = 0 wf = WriteFile("auto.log") WriteLine(wf,spieler) WriteLine(wf,ao + "," + no) CloseFile(wf) If spieler = 0 Then ;KI-ANALYSE For i = 0 To b-1 i2 = 0 terra(i,0) = h For i2 = 0 To h-1 If f(i,i2) > 0 Then terra(i,0) = i2 i2 = h-1 EndIf Next Next For i = 0 To b-1 For i2 = 1 To 3 If i+i2 < b Then terra(i,i2) = terra(i,0) - terra(i+i2,0) Else terra(i,i2) = terra(i,0) EndIf Next Next If kimod = 0 Then geplz = -2 geplo = -2 schlucht = 0 schluchtrl = -2 ;Angestrebter Zustand/Ort fexit = False ;WaitMouse() For i = ao To ao+3 If Not fexit Then For i2 = 0 To b-1 If Not fexit Then bool = True If objp(i) <> 5 And objp(i) <> 7 Then For i3 = 0 To 2 If i2+i3 >= 0 And i2+i3 < b Then If objd(objp(i),i3) < 5 And objd(objp(i),i3) > -5 Then If (objd(objp(i),i3) <> -1*terra(i2+i3,1)) Then nlog(ao + " " + i + " " + i2 + " " + i3 + " " + objp(i) + " " + objd(objp(i),i3) + " und " + terra(i2+i3,1) + " passen nicht") bool = False Else nlog(ao + " " + i + " " + i2 + " " + i3 + " " + objp(i) + " " + objd(objp(i),i3) + " und " + terra(i2+i3,1) + " passen") EndIf Else nlog(ao + " " + i + " " + i2 + " " + i3 + " " + objp(i) + " Eine Freikante (" + objd(objp(i),i3) + ")") EndIf Else nlog(ao + " " + i + " " + i2 + " " + i3 + " " + objp(i) + " Außerhalb der Betrachtung") EndIf Next If bool Then If ((objp(i) = 4 Or objp(i) = 6) And schlucht < 2) Then If i <> ao Then ;Beim Ersten Versuch gibt es noch keine Schluchtdaten (schlucht = -2 (< 2)) geplz = objp(i) geplo = i2-1 nlog("Dorthin Trotz Schlucht:" + geplz + " " + geplo + " " + schlucht) fexit = True EndIf Else geplz = objp(i) geplo = i2 nlog("Dorthin:" + geplz + " " + geplo) fexit = True EndIf EndIf Else If i2 < b-2 Then If i2 > 0 Then If schlucht < (terra(i2+1,1)-terra(i2,1)) Then schlucht = (terra(i2+1,1)-terra(i2,1)) schluchtrl = i2 EndIf Else schlucht = terra(i2,1)*2 schluchtrl = i2-1 EndIf Else If schlucht < -1*terra(i2,1)*2 Then schlucht = -1*terra(i2,1)*2 schluchtrl = i2 EndIf geplz = 5 geplo = schluchtrl fexit = True EndIf nlog(objp(i) + "," + i2 + ": Schlucht = " + schlucht + " bei " + schluchtrl) EndIf Else Exit EndIf Next Else Exit EndIf Next ;wl(ao + "auto" + Rand(0,100)) If geplo > -2 And geplz > -2 Then If geplo <= b-objb(geplz) Then If geplz <> -2 Then ;ao = geplz EndIf If geplo <> -2 Then ;rl = geplo EndIf EndIf Else geplz = ao EndIf Else If kimod = 1 geplz = -2 geplo = -2 For i = 0 To objanz For i2 = 0 To b-1 prior(i,i2) = 0 Next Next For i = 0 To 4 vrobj(i) = -2 vrrl(i) = -2 Next ;Prüfen, ob und wie wieviele Linien eliminiert werden könnten For i = ao To ao+3 fla = 0 fre = b-objb(i) If i = 5 Or i = 7 Then fla = -1 fre = 8 EndIf For i2 = fla To fre ;Jede Objekt-Platz-Variante bool = True For j = 0 To 2 If i2+j >= 0 And i2+j < b Then If objd(i,j) < 5 And objd(i,j) > -5 Then If (objd(i,j) <> -1*terra(i2+j,1)) Then nlog(ao + " " + i + " " + i2 + " " + j + " " + objd(i,j) + " und " + terra(i2+j,1) + " passen nicht") bool = False Else nlog(ao + " " + i + " " + i2 + " " + j + " " + i + " " + objd(i,j) + " und " + terra(i2+j,1) + " passen") EndIf Else nlog(ao + " " + i + " " + i2 + " " + j + " Eine Freikante (" + objd(i,j) + ")") EndIf Else nlog(ao + " " + i + " " + i2 + " " + j + " " + i + " Außerhalb der Betrachtung") EndIf Next If bool And i2 > -2 And i2 < b-2 Then If (i2+1) < 0 Then End EndIf prior(i,i2+1) = 1 EndIf aufp = False geplh = 0 For i3 = 0 To h-(objh(i)-1) If Not aufp Then For i4 = 0 To objb(i)-1 If Not aufp Then For i5 = 0 To objh(i)-1 If i2+i4 < b Then ;-1 If objf(i,i4,i5) > 0 Then If i3+i5 >= h-1 Then aufp = True geplh = i3 nlog("Aufprall auf den Boden von " + i + " bei " + i2 + "|" + i3) Else If f(i2+i4,i3+i5+1) > 0 Then ;Wie hoch prallt er auf(i3) aufp = True geplh = i3 nlog("Aufprall von " + i + " bei " + i2 + "|" + i3) EndIf EndIf EndIf Next EndIf Next EndIf Next If i2 > -2 And i2 < b-2 Then ah(i,i2+1) = geplh EndIf If aufp Then nlog("Einsetzen bei " + i2 + "|" + geplh + " (i3 wäre " + i3 + ")") For i6 = 0 To 3 For i7 = 0 To 3 If objf(i,i6,i7) > 0 And i2+i6 < b And geplh+i7 < h Then f(i2+i6,geplh+i7) = i+1 EndIf Next Next EndIf vr = 0 For i8 = 0 To h-1 bool = True For i9 = 0 To b-1 If f(i9,i8) = 0 Then bool = False EndIf nlog(i9+ " " + i8 + " -> "+ f(i9,i8)) Next If bool Then nlog("Volle Reihe bei " + geplh + "!") vr = vr + 1 prior(i,i2+1) = vr*25 vrrl(vr) = i2 vrobj(vr) = i EndIf Next If aufp Then nlog("Löschen bei " + i2 + "|" + geplh) For i6 = 0 To 3 For i7 = 0 To 3 If objf(i,i6,i7) > 0 And i2+i6 < b And geplh+i7 < h Then f(i2+i6,geplh+i7) = 0 EndIf Next Next EndIf Next Next ; For i = 1 To 4 ;If vrobj(5-i) <> -2 And vrrl(5-i) <> -2 Then ; geplz = vrobj(5-i) ; geplo = vrrl(5-i) ; Exit ;EndIf ; Next bop = 0 borl = 0 boon = 0 For i = ao To ao+3 For i2 = -1 To b-2 If bop < prior(i,i2+1) Then bop = prior(i,i2+1) boon = i borl = i2 Else If prior(i,i2+1) = bop And ah(boon,borl+1) < ah(i,i2+1) Then ;Wenn ein auch passendes Objekt tiefer gelegt werden kann -> Bevorzugung boon = i borl = i2 EndIf If bo = 100 Then Exit EndIf Next Next If bop > 0 Then geplz = boon geplo = borl Else geplz = ao geplo = 0 EndIf ; wl("1kimod" + ao + "_" + geplz + "_" + geplo + ".log") For i2 = 0 To objanz For i = 0 To b-1 ; btextc(1000+i*20,100+i2*14,prior(i2,i),1,14,0,255,0,0) Next Next ;btextc(1000,10,bop + " " + boon + " " + borl,1,14,0,255,0,0) ;btextc(1000,30,fla + " " + fre,1,14,0,255,0,0) Flip EndIf EndIf For i = b/2-1+objx(ao) To b/2-1+objx(ao)+objb(ao)-1 For i2 = 1 To objh(ao) If f(i,i2) > 0 And objf(ao,i-(b/2-1+objx(ao)),i2-1) = 1 Then sstatus = 2 EndIf Next Next End Function Function nspiel() For i = 0 To b-1 For i2 = 0 To h-1 f(i,i2) = 0 Next Next punkte = 0 linien = 0 sstatus = 0 nobj() nobj() End Function Function nscore() rf = ReadFile("highscore.hs") highscorel = 0 If rf Then Repeat scores$(highscorel) = ReadLine(rf) highscorel = highscorel + 1 Until Eof(rf) EndIf writef = WriteFile("highscore.hs") For i = 0 To highscorel-1 WriteLine(writef,scores$(i)) Next WriteLine(writef,punkte + "," + linien) CloseFile(writef) End Function Function kint(int1,int2) If int1 <= int2 Then Return int1 Else Return int2 EndIf End Function Function btext(x,y,t$,sa,sg,m) ; SetFont fnt(0,14) If sa >= 0 And sa <= 1 And sg >= mintextheight And sg < maxtextheight Then SetFont fnt(sa,sg) EndIf If m = 0 Then ;Linksoben Text x,y,t$ Else If m = 1 Then ;Zentriert Text x-StringWidth(t$)/2,y-StringHeight(t$)/2,t$ Else If m > 0 ;Block If StringWidth(t$) < m Then Text x,y,t$ Else tmp = t For i = 0 To wanz w(i) = "" Next wanz = 0 tmp = tmp + " " Repeat w(wanz) = Left(tmp,Instr(tmp," ")) tmp = Right(tmp,Len(tmp)-Len(w(wanz))) w(wanz) = Left(w(wanz),Len(w(wanz))-1) wanz = wanz + 1 Until tmp$ = "" zeile = 0 i = 0 Repeat tmpl = 0 tmps$ = "" wanzz = 0 While tmpl+wanzz*StringWidth(" ")+StringWidth(w(i)) < m And i < wanz And w(i) <> "\n" tmpl = tmpl + StringWidth(w(i)) tmps = tmps + w(i) + " " i = i + 1 wanzz = wanzz + 1 Wend If w(i) = "\n" Then i = i + 1 EndIf Text x,y+zeile*1.25*sg,tmps zeile = zeile + 1 Until i = wanz EndIf Else If m < 0 Then ;Ein-Wort-Block i = maxtextheight-1 Repeat SetFont fnt(sa,i) sbreite = StringWidth(t$) i = i-1 Until (sbreite <= -1*m And i <= sg) Or i <= 0 If i > 0 Then btext(x-StringWidth(t$)/2,y-i/2,t$,sa,i,0) Else btext(x-StringWidth("Fehler")/2,y-i/2,"Fehler",sa,i,0) EndIf EndIf End Function Function btextc(x,y,t$,sa,sg,m,colr,colg,colb) Color colr,colg,colb btext(x,y,t$,sa,sg,m) Color 255,255,255 End Function Function bline (posx1,posy1,posx2,posy2,colr,colg,colb) Color colr,colg,colb Line posx1,posy1,posx2,posy2 Color 255,255,255 End Function Function brect (posx,posy,width,height,hole,colr,colg,colb) Color colr,colg,colb If posx > camx - 500 And posx < camx + 1300 And posy > camy - 500 And posy < camy + 1050 Then Rect posx,posy,width,height,hole EndIf Color 255,255,255 End Function Function boval (posx,posy,width,height,hole,colr,colg,colb) Color colr,colg,colb If posx > camx - 500 And posx < camx + 1300 And posy > camy - 500 And posy < camy + 1050 Then Oval posx,posy,width,height,hole EndIf Color 255,255,255 End Function Function nlog(s$) zlog(zlogz) = s$ zlogz = zlogz + 1 End Function Function wl(dn$) wf = WriteFile(dn$ + ".log") For i = 0 To zlogz-1 WriteLine(wf,zlog(i)) zlog(i) = "" Next zlogz = 0 CloseFile(wf) End Function