12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019 |
- #/!usr/bin/python
- #Chunyuyulong-MT2018
- import Tkinter as tk
- import sys,time,random #Module einsetzen
- from tkMessageBox import *
- Buttons1 = [] #global Variablen deffinieren
- ButtonS1 = []
- Buttons2 = [] #Buttens fur Gitter ButtenS fur Funktionschalter
- ButtonS2 = []
- ButtonP1 ={'1':0,'2':0,'3':0,'4':0,'5':0,'6':0,'7':0, #Daten speicher von einzene Stuck
- '8':0,'9':0,'10':0,'11':0,'12':0,'13':0,'14':0,
- '15':0,'16':0,'17':0,'18':0,'19':0,'20':0,'21':0,
- '22':0,'23':0,'24':0,'25':0,'26':0,'27':0,'28':0,
- '29':0,'30':0,'31':0,'32':0,'33':0,'34':0,'35':0,
- '36':0,'37':0,'38':0,'39':0,'40':0,'41':0,'42':0,
- '43':0,'44':0,'45':0,'46':0,'47':0,'48':0,'49':0}
- ButtonP2 ={'1':0,'2':0,'3':0,'4':0,'5':0,'6':0,'7':0,
- '8':0,'9':0,'10':0,'11':0,'12':0,'13':0,'14':0,
- '15':0,'16':0,'17':0,'18':0,'19':0,'20':0,'21':0,
- '22':0,'23':0,'24':0,'25':0,'26':0,'27':0,'28':0,
- '29':0,'30':0,'31':0,'32':0,'33':0,'34':0,'35':0,
- '36':0,'37':0,'38':0,'39':0,'40':0,'41':0,'42':0,
- '43':0,'44':0,'45':0,'46':0,'47':0,'48':0,'49':0}
- ai = 0 #Ob Singelplayer
- Scf = 0 #gewehlte Schiff Mark
- PW = 2 #Player switch
- Rot = 0 #Rotation Mark
- Wel = 0 #Spiele Mark
- z= [] #speicher von AI Darstellung
- SumS=[] #gesetzte Schiffe
- def p1(): #P1 start
- cv1 = tk.Canvas(root1,width = 1200,height = 600).pack() #Fenster darstellung
- zlh = 200
- for wl in range(7): #Gitter Massstab
- Zahlen = tk.Label(root1,text = str(wl+1),font = '30').place(x = zlh ,y = 50, width = 50, height = 50)
- zlh = zlh +50
- zlv = 100
- z = 'A','B','C','D','E','F','G'
- for wh in range(7):
- zahlen = tk.Label(root1,text = z[wh],font = '30' ).place(x = 150,y = zlv,width = 50, height = 50)
- zlv = zlv + 50
- #zeile 1 #Ganze Gitter von P1
- Button1 = tk.Button(root1,bg = 'lightblue',command = lambda:color(0,Buttons1,ButtonP1))
- Buttons1.append(Button1)
- Buttons1[0].place(x = 200 ,y = 100, width = 50, height = 50)
- Button2 = tk.Button(root1,bg = 'lightblue',command = lambda:color(1,Buttons1,ButtonP1))
- Buttons1.append(Button2)
- Buttons1[1].place(x = 250 ,y = 100, width = 50, height = 50)
- Button3 = tk.Button(root1,bg = 'lightblue',command = lambda:color(2,Buttons1,ButtonP1))
- Buttons1.append(Button3)
- Buttons1[2].place(x = 300 ,y = 100, width = 50, height = 50)
- Button4 = tk.Button(root1,bg = 'lightblue',command = lambda:color(3,Buttons1,ButtonP1))
- Buttons1.append(Button4)
- Buttons1[3].place(x = 350 ,y = 100, width = 50, height = 50)
- Button5 = tk.Button(root1,bg = 'lightblue',command = lambda:color(4,Buttons1,ButtonP1))
- Buttons1.append(Button5)
- Buttons1[4].place(x = 400 ,y = 100, width = 50, height = 50)
- Button6 = tk.Button(root1,bg = 'lightblue',command = lambda:color(5,Buttons1,ButtonP1))
- Buttons1.append(Button6)
- Buttons1[5].place(x = 450 ,y = 100, width = 50, height = 50)
- Button7 = tk.Button(root1,bg = 'lightblue',command = lambda:color(6,Buttons1,ButtonP1))
- Buttons1.append(Button7)
- Buttons1[6].place(x = 500 ,y = 100, width = 50, height = 50)
- #zeile 2
- Button8 = tk.Button(root1,bg = 'lightblue',command = lambda:color(7,Buttons1,ButtonP1))
- Buttons1.append(Button8)
- Buttons1[7].place(x = 200 ,y = 150, width = 50, height = 50)
- Button9 = tk.Button(root1,bg = 'lightblue',command = lambda:color(8,Buttons1,ButtonP1))
- Buttons1.append(Button9)
- Buttons1[8].place(x = 250 ,y = 150, width = 50, height = 50)
- Button10 = tk.Button(root1,bg = 'lightblue',command = lambda:color(9,Buttons1,ButtonP1))
- Buttons1.append(Button10)
- Buttons1[9].place(x = 300 ,y = 150, width = 50, height = 50)
- Button11 = tk.Button(root1,bg = 'lightblue',command = lambda:color(10,Buttons1,ButtonP1))
- Buttons1.append(Button11)
- Buttons1[10].place(x = 350 ,y = 150, width = 50, height = 50)
- Button12 = tk.Button(root1,bg = 'lightblue',command = lambda:color(11,Buttons1,ButtonP1))
- Buttons1.append(Button12)
- Buttons1[11].place(x = 400 ,y = 150, width = 50, height = 50)
- Button13 = tk.Button(root1,bg = 'lightblue',command = lambda:color(12,Buttons1,ButtonP1))
- Buttons1.append(Button13)
- Buttons1[12].place(x = 450 ,y = 150, width = 50, height = 50)
- Button14 = tk.Button(root1,bg = 'lightblue',command = lambda:color(13,Buttons1,ButtonP1))
- Buttons1.append(Button14)
- Buttons1[13].place(x = 500 ,y = 150, width = 50, height = 50)
- #zeile 3
- Button15 = tk.Button(root1,bg = 'lightblue',command = lambda:color(14,Buttons1,ButtonP1))
- Buttons1.append(Button15)
- Buttons1[14].place(x = 200 ,y = 200, width = 50, height = 50)
- Button16 = tk.Button(root1,bg = 'lightblue',command = lambda:color(15,Buttons1,ButtonP1))
- Buttons1.append(Button16)
- Buttons1[15].place(x = 250 ,y = 200, width = 50, height = 50)
- Button17 = tk.Button(root1,bg = 'lightblue',command = lambda:color(16,Buttons1,ButtonP1))
- Buttons1.append(Button17)
- Buttons1[16].place(x = 300 ,y = 200, width = 50, height = 50)
- Button18 = tk.Button(root1,bg = 'lightblue',command = lambda:color(17,Buttons1,ButtonP1))
- Buttons1.append(Button18)
- Buttons1[17].place(x = 350 ,y = 200, width = 50, height = 50)
- Button19 = tk.Button(root1,bg = 'lightblue',command = lambda:color(18,Buttons1,ButtonP1))
- Buttons1.append(Button19)
- Buttons1[18].place(x = 400 ,y = 200, width = 50, height = 50)
- Button20 = tk.Button(root1,bg = 'lightblue',command = lambda:color(19,Buttons1,ButtonP1))
- Buttons1.append(Button20)
- Buttons1[19].place(x = 450 ,y = 200, width = 50, height = 50)
- Button21 = tk.Button(root1,bg = 'lightblue',command = lambda:color(20,Buttons1,ButtonP1))
- Buttons1.append(Button21)
- Buttons1[20].place(x = 500 ,y = 200, width = 50, height = 50)
- #zeile 4
- Button22 = tk.Button(root1,bg = 'lightblue',command = lambda:color(21,Buttons1,ButtonP1))
- Buttons1.append(Button22)
- Buttons1[21].place(x = 200 ,y = 250, width = 50, height = 50)
- Button23 = tk.Button(root1,bg = 'lightblue',command = lambda:color(22,Buttons1,ButtonP1))
- Buttons1.append(Button23)
- Buttons1[22].place(x = 250 ,y = 250, width = 50, height = 50)
- Button24 = tk.Button(root1,bg = 'lightblue',command = lambda:color(23,Buttons1,ButtonP1))
- Buttons1.append(Button24)
- Buttons1[23].place(x = 300 ,y = 250, width = 50, height = 50)
- Button25 = tk.Button(root1,bg = 'lightblue',command = lambda:color(24,Buttons1,ButtonP1))
- Buttons1.append(Button25)
- Buttons1[24].place(x = 350 ,y = 250, width = 50, height = 50)
- Button26 = tk.Button(root1,bg = 'lightblue',command = lambda:color(25,Buttons1,ButtonP1))
- Buttons1.append(Button26)
- Buttons1[25].place(x = 400 ,y = 250, width = 50, height = 50)
- Button27 = tk.Button(root1,bg = 'lightblue',command = lambda:color(26,Buttons1,ButtonP1))
- Buttons1.append(Button27)
- Buttons1[26].place(x = 450 ,y = 250, width = 50, height = 50)
- Button28 = tk.Button(root1,bg = 'lightblue',command = lambda:color(27,Buttons1,ButtonP1))
- Buttons1.append(Button28)
- Buttons1[27].place(x = 500 ,y = 250, width = 50, height = 50)
- #zeile 5
- Button29 = tk.Button(root1,bg = 'lightblue',command = lambda:color(28,Buttons1,ButtonP1))
- Buttons1.append(Button29)
- Buttons1[28].place(x = 200 ,y = 300, width = 50, height = 50)
- Button30 = tk.Button(root1,bg = 'lightblue',command = lambda:color(29,Buttons1,ButtonP1))
- Buttons1.append(Button30)
- Buttons1[29].place(x = 250 ,y = 300, width = 50, height = 50)
- Button31 = tk.Button(root1,bg = 'lightblue',command = lambda:color(30,Buttons1,ButtonP1))
- Buttons1.append(Button31)
- Buttons1[30].place(x = 300 ,y = 300, width = 50, height = 50)
- Button32 = tk.Button(root1,bg = 'lightblue',command = lambda:color(31,Buttons1,ButtonP1))
- Buttons1.append(Button32)
- Buttons1[31].place(x = 350 ,y = 300, width = 50, height = 50)
- Button33 = tk.Button(root1,bg = 'lightblue',command = lambda:color(32,Buttons1,ButtonP1))
- Buttons1.append(Button33)
- Buttons1[32].place(x = 400 ,y = 300, width = 50, height = 50)
- Button34 = tk.Button(root1,bg = 'lightblue',command = lambda:color(33,Buttons1,ButtonP1))
- Buttons1.append(Button34)
- Buttons1[33].place(x = 450 ,y = 300, width = 50, height = 50)
- Button35 = tk.Button(root1,bg = 'lightblue',command = lambda:color(34,Buttons1,ButtonP1))
- Buttons1.append(Button35)
- Buttons1[34].place(x = 500 ,y = 300, width = 50, height = 50)
- #zeile 6
- Button36 = tk.Button(root1,bg = 'lightblue',command = lambda:color(35,Buttons1,ButtonP1))
- Buttons1.append(Button36)
- Buttons1[35].place(x = 200 ,y = 350, width = 50, height = 50)
- Button37 = tk.Button(root1,bg = 'lightblue',command = lambda:color(36,Buttons1,ButtonP1))
- Buttons1.append(Button37)
- Buttons1[36].place(x = 250 ,y = 350, width = 50, height = 50)
- Button38 = tk.Button(root1,bg = 'lightblue',command = lambda:color(37,Buttons1,ButtonP1))
- Buttons1.append(Button38)
- Buttons1[37].place(x = 300 ,y = 350, width = 50, height = 50)
- Button39 = tk.Button(root1,bg = 'lightblue',command = lambda:color(38,Buttons1,ButtonP1))
- Buttons1.append(Button39)
- Buttons1[38].place(x = 350 ,y = 350, width = 50, height = 50)
- Button40 = tk.Button(root1,bg = 'lightblue',command = lambda:color(39,Buttons1,ButtonP1))
- Buttons1.append(Button40)
- Buttons1[39].place(x = 400 ,y = 350, width = 50, height = 50)
- Button41 = tk.Button(root1,bg = 'lightblue',command = lambda:color(40,Buttons1,ButtonP1))
- Buttons1.append(Button41)
- Buttons1[40].place(x = 450 ,y = 350, width = 50, height = 50)
- Button42 = tk.Button(root1,bg = 'lightblue',command = lambda:color(41,Buttons1,ButtonP1))
- Buttons1.append(Button42)
- Buttons1[41].place(x = 500 ,y = 350, width = 50, height = 50)
- #zeile 7
- Button43 = tk.Button(root1,bg = 'lightblue',command = lambda:color(42,Buttons1,ButtonP1))
- Buttons1.append(Button43)
- Buttons1[42].place(x = 200 ,y = 400, width = 50, height = 50)
- Button44 = tk.Button(root1,bg = 'lightblue',command = lambda:color(43,Buttons1,ButtonP1))
- Buttons1.append(Button44)
- Buttons1[43].place(x = 250 ,y = 400, width = 50, height = 50)
- Button45 = tk.Button(root1,bg = 'lightblue',command = lambda:color(44,Buttons1,ButtonP1))
- Buttons1.append(Button45)
- Buttons1[44].place(x = 300 ,y = 400, width = 50, height = 50)
- Button46 = tk.Button(root1,bg = 'lightblue',command = lambda:color(45,Buttons1,ButtonP1))
- Buttons1.append(Button46)
- Buttons1[45].place(x = 350 ,y = 400, width = 50, height = 50)
- Button47 = tk.Button(root1,bg = 'lightblue',command = lambda:color(46,Buttons1,ButtonP1))
- Buttons1.append(Button47)
- Buttons1[46].place(x = 400 ,y = 400, width = 50, height = 50)
- Button48 = tk.Button(root1,bg = 'lightblue',command = lambda:color(47,Buttons1,ButtonP1))
- Buttons1.append(Button48)
- Buttons1[47].place(x = 450 ,y = 400, width = 50, height = 50)
- Button49 = tk.Button(root1,bg = 'lightblue',command = lambda:color(48,Buttons1,ButtonP1))
- Buttons1.append(Button49)
- Buttons1[48].place(x = 500 ,y = 400, width = 50, height = 50)
- #Funktion Buttens
- ButtonSS = tk.Button(root1,text = '1 Stuck',bg = 'yellow',command = lambda:schiffwehlen(1))
- ButtonS1.append(ButtonSS)
- ButtonS1[0].place(x = 50 ,y = 200, width = 50, height = 50)
- ButtonSM1 = tk.Button(root1,text = '2 Stuck',bg = 'yellow',command = lambda:schiffwehlen(2))
- ButtonS1.append(ButtonSM1)
- ButtonS1[1].place(x = 50 ,y = 300, width = 100, height = 50)
- ButtonSM2 = tk.Button(root1,text = '2 Stuck',bg = 'yellow',command = lambda:schiffwehlen(3))
- ButtonS1.append(ButtonSM2)
- ButtonS1[2].place(x = 50 ,y = 400, width = 100, height = 50)
- ButtonSL = tk.Button(root1,text = '5 Stuck',bg = 'yellow',command = lambda:schiffwehlen(4))
- ButtonS1.append(ButtonSL)
- ButtonS1[3].place(x = 50 ,y = 500, width = 250, height = 50)
- ButtonR = tk.Button(root1,text = 'Rotation',bg = 'green',command = Rot)
- ButtonS1.append(ButtonR)
- ButtonS1[4].place(x = 50 ,y = 100, width = 100, height = 50)
- ButtonEX = tk.Button(root1,text = 'Exit',bg = 'red',command = lambda:ex(root1))
- ButtonS1.append(ButtonEX)
- ButtonS1[5].place(x = 1150 ,y = 20, width = 50, height = 50)
- root1.mainloop()
- def p2(): #gleiche wir erst
- del SumS[:] #Speicher clear
- zlh = 800
- for wl in range(7):
- Zahlen = tk.Label(root1,text = str(wl+1),font = '30').place(x = zlh ,y = 50, width = 50, height = 50)
- zlh = zlh +50
- zlv = 100
- z = 'A','B','C','D','E','F','G'
- for wh in range(7):
- zahlen = tk.Label(root1,text = z[wh],font = '30' ).place(x = 750,y = zlv,width = 50, height = 50)
- zlv = zlv + 50
- #zeile 1
- Button1 = tk.Button(root1,bg = 'lightblue',command = lambda:color(0,Buttons2,ButtonP2))
- Buttons2.append(Button1)
- Buttons2[0].place(x = 800 ,y = 100, width = 50, height = 50)
- Button2 = tk.Button(root1,bg = 'lightblue',command = lambda:color(1,Buttons2,ButtonP2))
- Buttons2.append(Button2)
- Buttons2[1].place(x = 850 ,y = 100, width = 50, height = 50)
- Button3 = tk.Button(root1,bg = 'lightblue',command = lambda:color(2,Buttons2,ButtonP2))
- Buttons2.append(Button3)
- Buttons2[2].place(x = 900 ,y = 100, width = 50, height = 50)
- Button4 = tk.Button(root1,bg = 'lightblue',command = lambda:color(3,Buttons2,ButtonP2))
- Buttons2.append(Button4)
- Buttons2[3].place(x = 950 ,y = 100, width = 50, height = 50)
- Button5 = tk.Button(root1,bg = 'lightblue',command = lambda:color(4,Buttons2,ButtonP2))
- Buttons2.append(Button5)
- Buttons2[4].place(x = 1000 ,y = 100, width = 50, height = 50)
- Button6 = tk.Button(root1,bg = 'lightblue',command = lambda:color(5,Buttons2,ButtonP2))
- Buttons2.append(Button6)
- Buttons2[5].place(x = 1050 ,y = 100, width = 50, height = 50)
- Button7 = tk.Button(root1,bg = 'lightblue',command = lambda:color(6,Buttons2,ButtonP2))
- Buttons2.append(Button7)
- Buttons2[6].place(x = 1100 ,y = 100, width = 50, height = 50)
- #zeile 2
- Button8 = tk.Button(root1,bg = 'lightblue',command = lambda:color(7,Buttons2,ButtonP2))
- Buttons2.append(Button8)
- Buttons2[7].place(x = 800 ,y = 150, width = 50, height = 50)
- Button9 = tk.Button(root1,bg = 'lightblue',command = lambda:color(8,Buttons2,ButtonP2))
- Buttons2.append(Button9)
- Buttons2[8].place(x = 850 ,y = 150, width = 50, height = 50)
- Button10 = tk.Button(root1,bg = 'lightblue',command = lambda:color(9,Buttons2,ButtonP2))
- Buttons2.append(Button10)
- Buttons2[9].place(x = 900 ,y = 150, width = 50, height = 50)
- Button11 = tk.Button(root1,bg = 'lightblue',command = lambda:color(10,Buttons2,ButtonP2))
- Buttons2.append(Button11)
- Buttons2[10].place(x = 950 ,y = 150, width = 50, height = 50)
- Button12 = tk.Button(root1,bg = 'lightblue',command = lambda:color(11,Buttons2,ButtonP2))
- Buttons2.append(Button12)
- Buttons2[11].place(x = 1000 ,y = 150, width = 50, height = 50)
- Button13 = tk.Button(root1,bg = 'lightblue',command = lambda:color(12,Buttons2,ButtonP2))
- Buttons2.append(Button13)
- Buttons2[12].place(x = 1050 ,y = 150, width = 50, height = 50)
- Button14 = tk.Button(root1,bg = 'lightblue',command = lambda:color(13,Buttons2,ButtonP2))
- Buttons2.append(Button14)
- Buttons2[13].place(x = 1100 ,y = 150, width = 50, height = 50)
- #zeile 3
- Button15 = tk.Button(root1,bg = 'lightblue',command = lambda:color(14,Buttons2,ButtonP2))
- Buttons2.append(Button15)
- Buttons2[14].place(x = 800 ,y = 200, width = 50, height = 50)
- Button16 = tk.Button(root1,bg = 'lightblue',command = lambda:color(15,Buttons2,ButtonP2))
- Buttons2.append(Button16)
- Buttons2[15].place(x = 850 ,y = 200, width = 50, height = 50)
- Button17 = tk.Button(root1,bg = 'lightblue',command = lambda:color(16,Buttons2,ButtonP2))
- Buttons2.append(Button17)
- Buttons2[16].place(x = 900 ,y = 200, width = 50, height = 50)
- Button18 = tk.Button(root1,bg = 'lightblue',command = lambda:color(17,Buttons2,ButtonP2))
- Buttons2.append(Button18)
- Buttons2[17].place(x = 950 ,y = 200, width = 50, height = 50)
- Button19 = tk.Button(root1,bg = 'lightblue',command = lambda:color(18,Buttons2,ButtonP2))
- Buttons2.append(Button19)
- Buttons2[18].place(x = 1000 ,y = 200, width = 50, height = 50)
- Button20 = tk.Button(root1,bg = 'lightblue',command = lambda:color(19,Buttons2,ButtonP2))
- Buttons2.append(Button20)
- Buttons2[19].place(x = 1050 ,y = 200, width = 50, height = 50)
- Button21 = tk.Button(root1,bg = 'lightblue',command = lambda:color(20,Buttons2,ButtonP2))
- Buttons2.append(Button21)
- Buttons2[20].place(x = 1100 ,y = 200, width = 50, height = 50)
- #zeile 4
- Button22 = tk.Button(root1,bg = 'lightblue',command = lambda:color(21,Buttons2,ButtonP2))
- Buttons2.append(Button22)
- Buttons2[21].place(x = 800 ,y = 250, width = 50, height = 50)
- Button23 = tk.Button(root1,bg = 'lightblue',command = lambda:color(22,Buttons2,ButtonP2))
- Buttons2.append(Button23)
- Buttons2[22].place(x = 850 ,y = 250, width = 50, height = 50)
- Button24 = tk.Button(root1,bg = 'lightblue',command = lambda:color(23,Buttons2,ButtonP2))
- Buttons2.append(Button24)
- Buttons2[23].place(x = 900 ,y = 250, width = 50, height = 50)
- Button25 = tk.Button(root1,bg = 'lightblue',command = lambda:color(24,Buttons2,ButtonP2))
- Buttons2.append(Button25)
- Buttons2[24].place(x = 950 ,y = 250, width = 50, height = 50)
- Button26 = tk.Button(root1,bg = 'lightblue',command = lambda:color(25,Buttons2,ButtonP2))
- Buttons2.append(Button26)
- Buttons2[25].place(x = 1000 ,y = 250, width = 50, height = 50)
- Button27 = tk.Button(root1,bg = 'lightblue',command = lambda:color(26,Buttons2,ButtonP2))
- Buttons2.append(Button27)
- Buttons2[26].place(x = 1050 ,y = 250, width = 50, height = 50)
- Button28 = tk.Button(root1,bg = 'lightblue',command = lambda:color(27,Buttons2,ButtonP2))
- Buttons2.append(Button28)
- Buttons2[27].place(x = 1100 ,y = 250, width = 50, height = 50)
- #zeile 5
- Button29 = tk.Button(root1,bg = 'lightblue',command = lambda:color(28,Buttons2,ButtonP2))
- Buttons2.append(Button29)
- Buttons2[28].place(x = 800 ,y = 300, width = 50, height = 50)
- Button30 = tk.Button(root1,bg = 'lightblue',command = lambda:color(29,Buttons2,ButtonP2))
- Buttons2.append(Button30)
- Buttons2[29].place(x = 850 ,y = 300, width = 50, height = 50)
- Button31 = tk.Button(root1,bg = 'lightblue',command = lambda:color(30,Buttons2,ButtonP2))
- Buttons2.append(Button31)
- Buttons2[30].place(x = 900 ,y = 300, width = 50, height = 50)
- Button32 = tk.Button(root1,bg = 'lightblue',command = lambda:color(31,Buttons2,ButtonP2))
- Buttons2.append(Button32)
- Buttons2[31].place(x = 950 ,y = 300, width = 50, height = 50)
- Button33 = tk.Button(root1,bg = 'lightblue',command = lambda:color(32,Buttons2,ButtonP2))
- Buttons2.append(Button33)
- Buttons2[32].place(x = 1000 ,y = 300, width = 50, height = 50)
- Button34 = tk.Button(root1,bg = 'lightblue',command = lambda:color(33,Buttons2,ButtonP2))
- Buttons2.append(Button34)
- Buttons2[33].place(x = 1050 ,y = 300, width = 50, height = 50)
- Button35 = tk.Button(root1,bg = 'lightblue',command = lambda:color(34,Buttons2,ButtonP2))
- Buttons2.append(Button35)
- Buttons2[34].place(x = 1100 ,y = 300, width = 50, height = 50)
- #zeile 6
- Button36 = tk.Button(root1,bg = 'lightblue',command = lambda:color(35,Buttons2,ButtonP2))
- Buttons2.append(Button36)
- Buttons2[35].place(x = 800 ,y = 350, width = 50, height = 50)
- Button37 = tk.Button(root1,bg = 'lightblue',command = lambda:color(36,Buttons2,ButtonP2))
- Buttons2.append(Button37)
- Buttons2[36].place(x = 850 ,y = 350, width = 50, height = 50)
- Button38 = tk.Button(root1,bg = 'lightblue',command = lambda:color(37,Buttons2,ButtonP2))
- Buttons2.append(Button38)
- Buttons2[37].place(x = 900 ,y = 350, width = 50, height = 50)
- Button39 = tk.Button(root1,bg = 'lightblue',command = lambda:color(38,Buttons2,ButtonP2))
- Buttons2.append(Button39)
- Buttons2[38].place(x = 950 ,y = 350, width = 50, height = 50)
- Button40 = tk.Button(root1,bg = 'lightblue',command = lambda:color(39,Buttons2,ButtonP2))
- Buttons2.append(Button40)
- Buttons2[39].place(x = 1000 ,y = 350, width = 50, height = 50)
- Button41 = tk.Button(root1,bg = 'lightblue',command = lambda:color(40,Buttons2,ButtonP2))
- Buttons2.append(Button41)
- Buttons2[40].place(x = 1050 ,y = 350, width = 50, height = 50)
- Button42 = tk.Button(root1,bg = 'lightblue',command = lambda:color(41,Buttons2,ButtonP2))
- Buttons2.append(Button42)
- Buttons2[41].place(x = 1100 ,y = 350, width = 50, height = 50)
- #zeile 7
- Button43 = tk.Button(root1,bg = 'lightblue',command = lambda:color(42,Buttons2,ButtonP2))
- Buttons2.append(Button43)
- Buttons2[42].place(x = 800 ,y = 400, width = 50, height = 50)
- Button44 = tk.Button(root1,bg = 'lightblue',command = lambda:color(43,Buttons2,ButtonP2))
- Buttons2.append(Button44)
- Buttons2[43].place(x = 850 ,y = 400, width = 50, height = 50)
- Button45 = tk.Button(root1,bg = 'lightblue',command = lambda:color(44,Buttons2,ButtonP2))
- Buttons2.append(Button45)
- Buttons2[44].place(x = 900 ,y = 400, width = 50, height = 50)
- Button46 = tk.Button(root1,bg = 'lightblue',command = lambda:color(45,Buttons2,ButtonP2))
- Buttons2.append(Button46)
- Buttons2[45].place(x = 950 ,y = 400, width = 50, height = 50)
- Button47 = tk.Button(root1,bg = 'lightblue',command = lambda:color(46,Buttons2,ButtonP2))
- Buttons2.append(Button47)
- Buttons2[46].place(x = 1000 ,y = 400, width = 50, height = 50)
- Button48 = tk.Button(root1,bg = 'lightblue',command = lambda:color(47,Buttons2,ButtonP2))
- Buttons2.append(Button48)
- Buttons2[47].place(x = 1050 ,y = 400, width = 50, height = 50)
- Button49 = tk.Button(root1,bg = 'lightblue',command = lambda:color(48,Buttons2,ButtonP2))
- Buttons2.append(Button49)
- Buttons2[48].place(x = 1100 ,y = 400, width = 50, height = 50)
- ButtonSS = tk.Button(root1,text = '1 Stuck',bg = 'yellow',command = lambda:schiffwehlen(1))
- ButtonS2.append(ButtonSS)
- ButtonS2[0].place(x = 650 ,y = 200, width = 50, height = 50)
- ButtonSM1 = tk.Button(root1,text = '2 Stuck',bg = 'yellow',command = lambda:schiffwehlen(2))
- ButtonS2.append(ButtonSM1)
- ButtonS2[1].place(x = 650 ,y = 300, width = 100, height = 50)
- ButtonSM2 = tk.Button(root1,text = '2 Stuck',bg = 'yellow',command = lambda:schiffwehlen(3))
- ButtonS2.append(ButtonSM2)
- ButtonS2[2].place(x = 650 ,y = 400, width = 100, height = 50)
- ButtonSL = tk.Button(root1,text = '5 Stuck',bg = 'yellow',command = lambda:schiffwehlen(4))
- ButtonS2.append(ButtonSL)
- ButtonS2[3].place(x = 650 ,y = 500, width = 250, height = 50)
- ButtonR = tk.Button(root1,text = 'Rotation',bg = 'green',command = Rot)
- ButtonS2.append(ButtonR)
- ButtonS2[4].place(x = 650 ,y = 100, width = 100, height = 50)
- ButtonSw = tk.Button(root1,text = 'fertig',bg = 'green',command = wehlen)
- ButtonS2.append(ButtonSw)
- ButtonS2[5].place(x = 1000 ,y = 500, width = 120, height = 50)
- def wehlen(): #Funktion von Start Spiele
- global Wel
- for i in range(49):
- Buttons1[i].configure(bg = "lightblue")
- Buttons2[i].configure(bg = "lightblue")
- Wel = 1
- if ai == 1:
- ButtonSede = tk.Button(root1,text = 'AI Turn',command = lambda:Versuch_AI(Buttons1,ButtonP1))
- ButtonS2.append(ButtonSede)
- ButtonS2[6].place(x = 600 ,y = 30, width = 100, height = 50)
- Versuch_AI(Buttons1,ButtonP1)
- def Rot(): #Rotation darsrellung
- global Rot
- Rot = 1
- def Wintest(): #Siege Proben
- dic1 = (ButtonP1.values())
- dic2 = (ButtonP2.values())
- if 1 not in dic1 and ai == 1:
- WinAI= showinfo(title='Leide!',message='AI WINN!!!')
- root1.destroy()
- elif 1 not in dic1 and ai == 0:
- Win1= showinfo(title='Congratulate!',message='P2 WINN!!!')
- root1.destroy()
- elif 1 not in dic2:
- Win2= showinfo(title='Congratulate!',message='P1 WINN!!!')
- root1.destroy()
- def Versuch_AI(Buttons,Button): #AI versuch
- global PW,z
- if Wel == 1 and ai == 1:
- while True:
- i = random.randint(0,48)
- if i not in z:
- if Buttons == Buttons1 and PW == 2:
- if Button[str(i+1)] == 1:
- Button[str(i+1)] = 'X'
- Buttons[i].configure(bg = "red")
- z.append(i)
- elif Button[str(i+1)] == 0:
- Button[str(i+1)] = 'm'
- Buttons[i].configure(bg = "blue")
- z.append(i)
- Wintest()
- PW = 1
- break
- elif Buttons == Buttons1 and PW == 1:
- break
- else:
- continue
- def Schiffesetzen_AI(Buttons,Button): #AI Schiffe setzen
- global Scf
- Scfs = []
- while True:
- Scf = random.randint(1,4)
- if Scf not in Scfs:
- Rot = random.randint (0,1)
- i = random.randint (0,48)
- if Rot == 1:
- if Scf == 1:
- if Button[str(i+1)] == 0:
- Button[str(i+1)] = 1
- Scfs.append(Scf)
- Scf = 0
- else:
- continue
- elif Scf == 2:
- if i>41:
- if Button[str(i+1)] == 0 and Button[str(i+1-7)] == 0:
- Button[str(i+1)] = 1
- Button[str(i+1-7)] = 1
- Scfs.append(Scf)
- Scf = 0
- else:
- continue
- else:
- if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0:
- Button[str(i+1)] = 1
- Button[str(i+1+7)] = 1
- Scfs.append(Scf)
- Scf = 0
- else:
- continue
- elif Scf == 3:
- if i>41:
- if Button[str(i+1)] == 0 and Button[str(i+1-7)] == 0:
- Button[str(i+1)] = 1
- Button[str(i+1-7)] = 1
- Scfs.append(Scf)
- Scf = 0
- else:
- continue
- else:
- if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0:
- Button[str(i+1)] = 1
- Button[str(i+1+7)] = 1
- Scfs.append(Scf)
- Scf = 0
- else:
- continue
- elif Scf == 4:
- if i <21:
- if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0 and Button[str(i+1+14)] == 0 and Button[str(i+1+21)] == 0 and Button[str(i+1+28)] == 0:
- for m in range(5):
- Button[str(i+1)] = 1
- i = i + 7
- Scfs.append(Scf)
- Scf = 0
- else:
- continue
- elif i/7 == 3:
- if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0 and Button[str(i+1+14)] == 0 and Button[str(i+1+21)] == 0 and Button[str(i+1-7)] == 0:
- Button[str(i+1-7)] = 1
- Button[str(i+1)] = 1
- Button[str(i+1+7)] = 1
- Button[str(i+1+14)] = 1
- Button[str(i+21)] = 1
- Scfs.append(Scf)
- Scf = 0
- else:
- continue
- elif i/7 == 4:
- if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0 and Button[str(i+1+14)] == 0 and Button[str(i+1-14)] == 0 and Button[str(i+1-7)] == 0:
- Button[str(i+1-14)] = 1
- Button[str(i+1-7)] = 1
- Button[str(i+1)] = 1
- Button[str(i+1+7)] = 1
- Button[str(i+1+14)] = 1
- Scfs.append(Scf)
- Scf = 0
- else:
- continue
- elif i/7 == 5:
- if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0 and Button[str(i+1-21)] == 0 and Button[str(i+1-14)] == 0 and Button[str(i+1-7)] == 0:
- Button[str(i+1-21)] = 1
- Button[str(i+1-14)] = 1
- Button[str(i+1-7)] = 1
- Button[str(i+1)] = 1
- Button[str(i+1+7)] = 1
- Scfs.append(Scf)
- Scf = 0
- else:
- continue
- elif i/7 == 6:
- if Button[str(i+1)] == 0 and Button[str(i+1-28)] == 0 and Button[str(i+1-21)] == 0 and Button[str(i+1-14)] == 0 and Button[str(i+1-7)] == 0:
- Button[str(i+1-28)] = 1
- Button[str(i+1-21)] = 1
- Button[str(i+1-14)] = 1
- Button[str(i+1-7)] = 1
- Button[str(i+1)] = 1
- Scfs.append(Scf)
- Scf = 0
- else:
- continue
- Rot = 0
- else:
- if Scf == 1:
- if Button[str(i+1)] == 0:
- Button[str(i+1)] = 1
- Scfs.append(Scf)
- Scf = 0
- else:
- continue
- elif Scf == 2 :
- if i%7 == 6:
- if Button[str(i+1)] == 0 and Button[str(i)] == 0:
- Button[str(i+1)] = 1
- Button[str(i)] = 1
- Scfs.append(Scf)
- Scf = 0
- else:
- continue
- else:
- if Button[str(i+1)] == 0 and Button[str(i+2)] == 0:
- Button[str(i+1)] = 1
- Button[str(i+1+1)] = 1
- Scfs.append(Scf)
- Scf = 0
- else:
- continue
- elif Scf == 3 :
- if i%7 == 6:
- if Button[str(i+1)] == 0 and Button[str(i)] == 0:
- Button[str(i+1)] = 1
- Button[str(i)] = 1
- Scfs.append(Scf)
- Scf = 0
- else:
- continue
- else:
- if Button[str(i+1)] == 0 and Button[str(i+2)] == 0:
- Button[str(i+1)] = 1
- Button[str(i+1+1)] = 1
- Scfs.append(Scf)
- Scf = 0
- else:
- continue
- elif Scf == 4:
- if i%7<3:
- if Button[str(i+1)] == 0 and Button[str(i+2)] == 0 and Button[str(i+3)] == 0 and Button[str(i+4)] == 0 and Button[str(i+5)] == 0:
- for m in range(5):
- Button[str(i+1)] = 1
- i = i + 1
- Scfs.append(Scf)
- Scf = 0
- else:
- continue
- elif i%7 == 3:
- if Button[str(i-1)] == 0 and Button[str(i)] == 0 and Button[str(i+1)] == 0 and Button[str(i+2)] == 0 and Button[str(i+3)] == 0:
- Button[str(i)] = 1
- Button[str(i+1)] = 1
- Button[str(i+1+1)] = 1
- Button[str(i+1+2)] = 1
- Button[str(i+1+3)] = 1
- Scfs.append(Scf)
- Scf = 0
- else:
- continue
- elif i%7 == 4:
- if Button[str(i-2)] == 0 and Button[str(i-1)] == 0 and Button[str(i+1)] == 0 and Button[str(i+2)] == 0 and Button[str(i)] == 0:
- Button[str(i-1)] = 1
- Button[str(i)] = 1
- Button[str(i+1)] = 1
- Button[str(i+2)] = 1
- Button[str(i+3)] = 1
- Scfs.append(Scf)
- Scf = 0
- else:
- continue
- elif i%7 == 5:
- if Button[str(i-1)] == 0 and Button[str(i)] == 0 and Button[str(i+1)] == 0 and Button[str(i+2)] == 0 and Button[str(i-2)] == 0:
- Button[str(i-2)] = 1
- Button[str(i-1)] = 1
- Button[str(i)] = 1
- Button[str(i+1)] = 1
- Button[str(i+2)] = 1
- Scfs.append(Scf)
- Scf = 0
- else:
- continue
- elif i%7 == 6:
- if Button[str(i-1)] == 0 and Button[str(i)] == 0 and Button[str(i+1)] == 0 and Button[str(i-2)] == 0 and Button[str(i-3)] == 0:
- Button[str(i-3)] = 1
- Button[str(i-2)] = 1
- Button[str(i-1)] = 1
- Button[str(i)] = 1
- Button[str(i+1)] = 1
- Scfs.append(Scf)
- Scf = 0
- else:
- continue
- if len(Scfs) == 4:
- break
- def color(i,Buttons,Button): #Grundfunktion von einzele Button
- global Rot,Scf,PW
- if Wel == 1: #Schiffe auswehlen
- if Buttons == Buttons1 and PW == 2 and ai == 0:
- if Button[str(i+1)] == 1:
- Button[str(i+1)] = 'X'
- Buttons[i].configure(bg = "red")
- elif Button[str(i+1)] == 0:
- Button[str(i+1)] = 'm'
- Buttons[i].configure(bg = "blue")
- Wintest()
- PW = 1
- elif Buttons == Buttons2 and PW == 1:
- if Button[str(i+1)] == 1:
- Button[str(i+1)] = 'X'
- Buttons[i].configure(bg = "red")
- elif Button[str(i+1)] == 0:
- Button[str(i+1)] = 'm'
- Buttons[i].configure(bg = "blue")
- Wintest()
- PW = 2
- elif Buttons == Buttons1 and PW == 2 and ai == 1:
- achtung= showinfo(title='Achtung!!',message='das ist SingelPlayer!Bitten Sie das Button "AI Turn" klicken!')
- else:
- achtung= showinfo(title='Achtung!!',message='Sollen Aendere Player wehlen!')
- else:
- if Rot == 1: #Schiffe setzen
- if Scf == 1:
- if Button[str(i+1)] == 0:
- Buttons[i].configure(bg = "yellow")
- Button[str(i+1)] = 1
- Scf = 0
- else:
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
- elif Scf == 2:
- if i>41:
- if Button[str(i+1)] == 0 and Button[str(i+1-7)] == 0:
- Buttons[i].configure(bg = "yellow")
- Buttons[i-7].configure(bg = "yellow")
- Button[str(i+1)] = 1
- Button[str(i+1-7)] = 1
- Scf = 0
- else:
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
- else:
- if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0:
- Buttons[i].configure(bg = "yellow")
- Button[str(i+1)] = 1
- Buttons[i+7].configure(bg = "yellow")
- Button[str(i+1+7)] = 1
- Scf = 0
- else:
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
- elif Scf == 3:
- if i>41:
- if Button[str(i+1)] == 0 and Button[str(i+1-7)] == 0:
- Buttons[i].configure(bg = "yellow")
- Button[str(i+1)] = 1
- Buttons[i-7].configure(bg = "yellow")
- Button[str(i+1-7)] = 1
- Scf = 0
- else:
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
- else:
- if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0:
- Buttons[i].configure(bg = "yellow")
- Button[str(i+1)] = 1
- Buttons[i+7].configure(bg = "yellow")
- Button[str(i+1+7)] = 1
- Scf = 0
- else:
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
- elif Scf == 4:
- if i <21:
- if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0 and Button[str(i+1+14)] == 0 and Button[str(i+1+21)] == 0 and Button[str(i+1+28)] == 0:
- for m in range(5):
- Buttons[i].configure(bg = "yellow")
- Button[str(i+1)] = 1
- i = i + 7
- Scf = 0
- else:
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
- elif i/7 == 3:
- if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0 and Button[str(i+1+14)] == 0 and Button[str(i+1+21)] == 0 and Button[str(i+1-7)] == 0:
- Buttons[i-7].configure(bg = "yellow")
- Button[str(i+1-7)] = 1
- Buttons[i].configure(bg = "yellow")
- Button[str(i+1)] = 1
- Buttons[i+7].configure(bg = "yellow")
- Button[str(i+1+7)] = 1
- Buttons[i+14].configure(bg = "yellow")
- Button[str(i+1+14)] = 1
- Buttons[i+21].configure(bg = "yellow")
- Button[str(i+21)] = 1
- Scf = 0
- else:
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
- elif i/7 == 4:
- if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0 and Button[str(i+1+14)] == 0 and Button[str(i+1-14)] == 0 and Button[str(i+1-7)] == 0:
- Buttons[i-14].configure(bg = "yellow")
- Button[str(i+1-14)] = 1
- Buttons[i-7].configure(bg = "yellow")
- Button[str(i+1-7)] = 1
- Buttons[i].configure(bg = "yellow")
- Button[str(i+1)] = 1
- Buttons[i+7].configure(bg = "yellow")
- Button[str(i+1+7)] = 1
- Buttons[i+14].configure(bg = "yellow")
- Button[str(i+1+14)] = 1
- Scf = 0
- else:
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
- elif i/7 == 5:
- if Button[str(i+1)] == 0 and Button[str(i+1+7)] == 0 and Button[str(i+1-21)] == 0 and Button[str(i+1-14)] == 0 and Button[str(i+1-7)] == 0:
- Buttons[i-21].configure(bg = "yellow")
- Button[str(i+1-21)] = 1
- Buttons[i-14].configure(bg = "yellow")
- Button[str(i+1-14)] = 1
- Buttons[i-7].configure(bg = "yellow")
- Button[str(i+1-7)] = 1
- Buttons[i].configure(bg = "yellow")
- Button[str(i+1)] = 1
- Buttons[i+7].configure(bg = "yellow")
- Button[str(i+1+7)] = 1
- Scf = 0
- else:
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
- elif i/7 == 6:
- if Button[str(i+1)] == 0 and Button[str(i+1-28)] == 0 and Button[str(i+1-21)] == 0 and Button[str(i+1-14)] == 0 and Button[str(i+1-7)] == 0:
- Buttons[i-28].configure(bg = "yellow")
- Button[str(i+1-28)] = 1
- Buttons[i-21].configure(bg = "yellow")
- Button[str(i+1-21)] = 1
- Buttons[i-14].configure(bg = "yellow")
- Button[str(i+1-14)] = 1
- Buttons[i-7].configure(bg = "yellow")
- Button[str(i+1-7)] = 1
- Buttons[i].configure(bg = "yellow")
- Button[str(i+1)] = 1
- Scf = 0
- else:
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
- Rot = 0
- else:
- if Scf == 1:
- if Button[str(i+1)] == 0:
- Buttons[i].configure(bg = "yellow")
- Button[str(i+1)] = 1
- Scf = 0
- else:
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
- elif Scf == 2 :
- if i%7 == 6:
- if Button[str(i+1)] == 0 and Button[str(i)] == 0:
- Buttons[i].configure(bg = "yellow")
- Button[str(i+1)] = 1
- Buttons[i-1].configure(bg = "yellow")
- Button[str(i)] = 1
- Scf = 0
- else:
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
- else:
- if Button[str(i+1)] == 0 and Button[str(i+2)] == 0:
- Buttons[i].configure(bg = "yellow")
- Button[str(i+1)] = 1
- Buttons[i+1].configure(bg = "yellow")
- Button[str(i+1+1)] = 1
- Scf = 0
- else:
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
- elif Scf == 3 :
- if i%7 == 6:
- if Button[str(i+1)] == 0 and Button[str(i)] == 0:
- Buttons[i].configure(bg = "yellow")
- Button[str(i+1)] = 1
- Buttons[i-1].configure(bg = "yellow")
- Button[str(i)] = 1
- Scf = 0
- else:
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
- else:
- if Button[str(i+1)] == 0 and Button[str(i+2)] == 0:
- Buttons[i].configure(bg = "yellow")
- Button[str(i+1)] = 1
- Buttons[i+1].configure(bg = "yellow")
- Button[str(i+1+1)] = 1
- Scf = 0
- else:
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
- elif Scf == 4:
- if i%7<3:
- if Button[str(i+1)] == 0 and Button[str(i+2)] == 0 and Button[str(i+3)] == 0 and Button[str(i+4)] == 0 and Button[str(i+5)] == 0:
- for m in range(5):
- Buttons[i].configure(bg = "yellow")
- Button[str(i+1)] = 1
- i = i + 1
- Scf = 0
- else:
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
- elif i%7 == 3:
- if Button[str(i-1)] == 0 and Button[str(i)] == 0 and Button[str(i+1)] == 0 and Button[str(i+2)] == 0 and Button[str(i+3)] == 0:
- Buttons[i-1].configure(bg = "yellow")
- Button[str(i)] = 1
- Buttons[i].configure(bg = "yellow")
- Button[str(i+1)] = 1
- Buttons[i+1].configure(bg = "yellow")
- Button[str(i+1+1)] = 1
- Buttons[i+2].configure(bg = "yellow")
- Button[str(i+1+2)] = 1
- Buttons[i+3].configure(bg = "yellow")
- Button[str(i+1+3)] = 1
- Scf = 0
- else:
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
- elif i%7 == 4:
- if Button[str(i-2)] == 0 and Button[str(i-1)] == 0 and Button[str(i+1)] == 0 and Button[str(i+2)] == 0 and Button[str(i)] == 0:
- Buttons[i-2].configure(bg = "yellow")
- Button[str(i-1)] = 1
- Buttons[i-1].configure(bg = "yellow")
- Button[str(i)] = 1
- Buttons[i].configure(bg = "yellow")
- Button[str(i+1)] = 1
- Buttons[i+1].configure(bg = "yellow")
- Button[str(i+2)] = 1
- Buttons[i+2].configure(bg = "yellow")
- Button[str(i+3)] = 1
- Scf = 0
- else:
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
- elif i%7 == 5:
- if Button[str(i-1)] == 0 and Button[str(i)] == 0 and Button[str(i+1)] == 0 and Button[str(i+2)] == 0 and Button[str(i-2)] == 0:
- Buttons[i-3].configure(bg = "yellow")
- Button[str(i-2)] = 1
- Buttons[i-2].configure(bg = "yellow")
- Button[str(i-1)] = 1
- Buttons[i-1].configure(bg = "yellow")
- Button[str(i)] = 1
- Buttons[i].configure(bg = "yellow")
- Button[str(i+1)] = 1
- Buttons[i+1].configure(bg = "yellow")
- Button[str(i+2)] = 1
- Scf = 0
- else:
- achtung= showinfo(title='Achtung!',message='Diese Stuck schon gesetzt wird!')
- elif i%7 == 6:
- if Button[str(i-1)] == 0 and Button[str(i)] == 0 and Button[str(i+1)] == 0 and Button[str(i-2)] == 0 and Button[str(i-3)] == 0:
- Buttons[i-4].configure(bg = "yellow")
- Button[str(i-3)] = 1
- Buttons[i-3].configure(bg = "yellow")
- Button[str(i-2)] = 1
- Buttons[i-2].configure(bg = "yellow")
- Button[str(i-1)] = 1
- Buttons[i-1].configure(bg = "yellow")
- Button[str(i)] = 1
- Buttons[i].configure(bg = "yellow")
- Button[str(i+1)] = 1
- Scf = 0
- if len(SumS) == 4: #Ob alle Schiffe wird gesetzte
- ButtonSw = tk.Button(root1,text = 'Player waechseln',bg = 'green',command = was)
- ButtonS1.append(ButtonSw)
- ButtonS1[6].place(x = 450 ,y = 500, width = 120, height = 50)
- def schiffwehlen(W): #Spieler schiffe Wehlen
- global Scf
- if W in SumS:
- achtung= showinfo(title='Achtung!',message='Das Schiff schon gesetzt wird!')
- else:
- if W == 1:
- Scf = 1
- SumS.append(W)
- elif W == 2:
- SumS.append(W)
- Scf = 2
- elif W == 3:
- SumS.append(W)
- Scf = 3
- elif W == 4:
- SumS.append(W)
- Scf = 4
- else:
- print 'falsch eingeben'
- def was(): #AI moeglich fuer P2
- p2()
- if ai == 1:
- Schiffesetzen_AI(Buttons2,ButtonP2)
- def menu(): #Menu
- root = tk.Tk()
- root.title("Menu")
- fens = tk.Canvas(root,width = 800,height = 600,bg = 'lightblue')
- fens.pack()
- thema = tk.Label(root,text = "Schiffe Versenkung!",font = "Arial 30",fg = "White",padx = 50,pady = 10,background="blue",relief="ridge",borderwidth=10)
- thema.place(height=100, width=400 ,x = 200, y = 100)
- button1 = tk.Button(root,text = "Man vs AI",bg = 'black',activebackground = 'Green',font = '20',fg = 'White',command = lambda:sing())
- button1.place(x = 200, y = 250,height = 50,width = 120)
- button2 = tk.Button(root,text = "Man vs Man",bg = 'black',activebackground = 'Blue',font = '20',fg = 'White',command = lambda:muti())
- button2.place(x = 500, y = 250,height = 50,width = 120)
- button3 = tk.Button(root,text = "Hilfe",bg = 'black',activebackground = 'White',font = '20',fg = 'White',command = lambda:Hilfe())
- button3.place(x = 200, y = 400,height = 50,width = 120)
- button4 = tk.Button(root,text = "EXIT",bg = 'red',font = '20',fg = 'White',command = lambda:ex(root))
- button4.place(x = 500, y = 400,height = 50,width = 120)
- root.mainloop()
- def sing(): #Singl player
- global ai
- global root1
- root1 = tk.Tk()
- root1.title('Schiffe Versenkung')
- ai = 1
- p1()
- def muti(): #multi player
- global root1
- root1 = tk.Tk()
- root1.title('Schiffe Versenkung')
- p1()
- def Hilfe(): #Hilfe
- Hilfe = tk.Tk()
- Hilfe.title('Help')
- text = tk.Label(Hilfe,text = "Diese Programm wird entwicklert, um das Spiel Schiffe Versenkung durchzufuehren.",font = "Arial 15").pack()
- button1 = tk.Button(Hilfe,text = 'Zuruck',bg = "green",font = "20",command = lambda:ex(Hilfe)).pack()
- def ex(root):
- root.destroy()
- menu()
|