Пример #1
0
def spremi(vrijeme, situacija):
    dir = folder.get()
    im1 = Image.open(dir + 'slika.jpg')
    print(dir + 'primjeri\\slika')
    im1.save(
        dir + 'primjeri\\slika' + str(vrijeme) + '_' + str(situacija) + '.jpg',
        'JPEG')
Пример #2
0
def tko(dat):
    dir=folder.get()	
    im = Image.open(dir+"%d"%dat+'.jpg')
    im3 = Image.open(dir+"%d"%(dat+1)+'.jpg')
    im2=im.convert('P').convert('1')
    im4=im3.convert('P').convert('1')
    
    pix = im2.load()
    velicina=im2.getbbox()
    im2.save(dir+'cb_test.jpg')
    x=(velicina[2])
    y=(velicina[3])

    pix2 = im4.load()
    velicina2=im4.getbbox()
    im4.save(dir+'cb_test2.jpg')
    x1=(velicina2[2])
    y1=(velicina2[3])
    
    nula4=0
    nula1=0
    for j in range(y):  

        for i in range(x):
            #print(i+2,j+2,pix[i+2,j+2])
            if pix[i,j]==0:
                nula4+=1

    for j in range(y1):  

        for i in range(x1):
            #print(i+2,j+2,pix[i+2,j+2])
            if pix2[i,j]==0:
                nula1+=1
    #print(nula4)
    #print(nula1)
    #print(x,y,x1,y1)
    
    if nula4>2000:
        #print('na redu')
        if pix[26,24]==255 and pix[26,25]==255 and pix[26,26]==255:
            print('check')
            return 1
        else:
            print('call')
            return 2
    elif nula1>2000:
        if pix2[4,23]==255 and pix2[5,24]==255 and pix2[6,24]==255 and pix2[7,25]==255 and pix2[56,26]==255 and pix2[56,25]==255 and pix2[56,24]==255 and pix2[101,27]==255 and pix2[102,27]==255:
            #print('nije na redu')
            return 0
        else:
            print('call')
            return 3
    else:
        #print('nije na redu')
        return 0
Пример #3
0
def kamo():
    dir = folder.get()
    im = Image.open(dir + 'pomak2.jpg')
    im2 = im.convert('P').convert('1')

    pix = im2.load()
    im2.save(dir + 'pomak_cb2.jpg')
    pomoc = 0
    pomoc2 = 0
    for i in range(22):
        if pomoc > 0:
            break
        for j in range(5):
            if pix[i, j] == 0:
                pomoc = i  # stupac u kojem se prvi put pojavi crno ** kod mene,
                break

    #print(pomoc)
    pomoc2 = (pomoc - 9) * -1
    return pomoc2
Пример #4
0
def kamo():
    dir = folder.get()
    im = Image.open(dir + 'pomak.jpg')
    im2 = im.convert('P').convert('1')

    pix = im2.load()
    im2.save(dir + 'pomak_cb.jpg')
    pomoc = 0
    pomoc2 = 0
    for j in range(16):
        pomoc2 = 0
        if pomoc > 0:
            break
        for i in range(6):
            if pix[i, j] > 0:
                pomoc2 += 1
            if pomoc2 > 5:
                pomoc = j  # red u kojem se prvi put pojavi crno ** kod mene,
                break

    #print(pomoc)
    pomoc2 = pomoc - 10
    return pomoc2
Пример #5
0
def prekid():
    dir = folder.get()
    im = Image.open(dir + '10.jpg')
    im2 = im.convert('P').convert('1')

    pix = im2.load()
    velicina = im2.getbbox()
    im2.save(dir + 'screen1.jpg')

    nula = 0
    nula2 = 0
    for j in range(42):

        for i in range(20):
            if pix[i, j] == 0:
                nula += 1

    im = Image.open(dir + '11.jpg')
    im2 = im.convert('P').convert('1')

    pix = im2.load()
    velicina = im2.getbbox()
    im2.save(dir + 'screen2.jpg')

    for j in range(42):

        for i in range(20):
            if pix[i, j] == 0:
                nula2 += 1

    #print(nula,nula2)

    if nula > 20 and nula < 170 and nula2 > 20 and nula2 < 170:
        return 1
    else:
        return 0
Пример #6
0
def kakav(slika,pomak,pomak2):
    dir=folder.get()	
    b=[]
    #c=[]
    a=0
    
    im = Image.open(dir+'slika.jpg')

    if slika==1:
        size=(213-pomak2,470+pomak,268-pomak2,486+pomak) #povecat za 1 kad bude trebalo
        im2=im.crop(size) 
        im3=im2.convert('P').convert('1')
        pix1 = im3.load()
        im3.save(dir+'krug1.jpg') #krug1
    
    
    elif slika==2:
        size=(50-pomak2,324+pomak,105-pomak2,340+pomak) #povecat za 1 kad bude trebalo
        im2=im.crop(size) 
        im3=im2.convert('P').convert('1')
        pix1 = im3.load()
        im3.save(dir+'krug2.jpg') #krug2

    
    elif slika==3:
        size=(157-pomak2,159+pomak,212-pomak2,175+pomak) #povecat za 1 kad bude trebalo
        im2=im.crop(size) 
        im3=im2.convert('P').convert('1')
        pix1 = im3.load()
        im3.save(dir+'krug3.jpg') #krug3

   
    elif slika==4:
        size=(821-pomak2,160+pomak,876-pomak2,176+pomak) #povecat za 1 kad bude trebalo
        im2=im.crop(size) 
        im3=im2.convert('P').convert('1')
        pix1 = im3.load()
        im3.save(dir+'krug4.jpg') #krug4

    
    elif slika==5:
        size=(924-pomak2,324+pomak,979-pomak2,340+pomak) #povecat za 1 kad bude trebalo
        im2=im.crop(size) 
        im3=im2.convert('P').convert('1')
        pix1 = im3.load()
        im3.save(dir+'krug5.jpg') #krug5

    c=0
    for i in range(55):
        if pix1[i,0]==0:
            c+=1

    if c>4:
        #print('ne zanima me to')
        return 0
    #print(c)
    d=0
    a=0
    for i in range(55):
        for j in range(16):
            if pix1[i,j]==0:
                a+=1
                   
    
    if a<100:
        #print('ne zanima me to')
        return 0
    
    for i in range(55):
        a=0
        for j in range(16):
            if pix1[i,j]==0:
                a+=1
            else:
                a=0
            if a==7:
                d+=1
    #print(d)
    a=0

    pomoc2=[]
    b=0
    for i in range(55):
        for j in range(16):#novac
            if pix1[i,j]==0:
                b+=1
        pomoc2.append(b)
        b=0
        
    z=1
    broj13=0
    while z: #makni sve nule do prvog znaka
        if len(pomoc2)>0:
            if pomoc2[0]==0:
                pomoc2.remove(0)
                broj13+=1
            else:
                z=0


    
    check=[1, 8, 10, 12, 9, 4, 3, 5, 5, 7, 5, 2, 12, 12, 12, 6, 4, 8, 8, 6, 5, 7, 9, 8, 5, 8, 9, 6, 7, 8, 9, 7, 6, 8, 6, 4, 13, 12, 13, 9, 9, 10, 9, 8, 4, 6, 3, 8, 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    call=[1, 7, 10, 12, 10, 3, 5, 6, 5, 7, 4, 2, 5, 9, 8, 8, 8, 8, 5, 3, 12, 12, 12, 5, 6, 12, 13, 12, 8, 0, 3, 1, 4, 2, 4, 4, 3, 3, 6, 3, 7, 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    raisic=[1, 3, 11, 12, 13, 11, 9, 11, 12, 10, 5, 2, 1, 6, 8, 8, 8, 7, 7, 7, 3, 9, 12, 12, 7, 3, 8, 7, 9, 9, 8, 7, 7, 8, 9, 8, 10, 9, 6, 4, 4, 4, 4, 5, 4, 7, 4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]  
    fold=[1, 2, 12, 12, 12, 8, 4, 6, 8, 4, 3, 6, 8, 6, 4, 7, 8, 7, 6, 13, 12, 11, 7, 2, 6, 9, 8, 8, 12, 12, 14, 12, 6, 2, 1, 3, 3, 2, 6, 3, 5, 5, 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    
    potraga=-1
    oduz=[]
    vjerojatnost=[]
    #print(pomoc2)

    oduz=oduzmi.liste(pomoc2,check)
    vjerojatnost.append(sum(oduz))
    oduz=oduzmi.liste(pomoc2,call)
    vjerojatnost.append(sum(oduz))
    oduz=oduzmi.liste(pomoc2,raisic)
    vjerojatnost.append(sum(oduz))
    oduz=oduzmi.liste(pomoc2,fold)
    vjerojatnost.append(sum(oduz))
    
    potraga=(vjerojatnost.index(min(vjerojatnost))+1)
    
    #print ('prozor broj',slika,potraga)
    return potraga
Пример #7
0
def koji(pomak, pomak2):
    dir = folder.get()
    im = Image.open(dir + 'slika.jpg')

    size = (476 - pomak2, 52 + pomak, 556 - pomak2, 71 + pomak
            )  #povecat za 1 kad bude trebalo
    im2 = im.crop(size)
    im2.save(dir + 'pot.jpg', 'JPEG')

    #im3=im2.convert('P').convert('1')
    #im2 = Image.open('pot_cb7.jpg')
    im3 = im2.convert('P').convert('1')
    pix = im3.load()
    im3.save(dir + 'pot_cb.jpg')

    pomoc = 0
    pomoc2 = 0
    for i in range(80):
        if pomoc > 12 and pomoc < 17:
            break
        else:
            pomoc = 0

        for j in range(19):
            if pix[i, j] == 0:
                pomoc += 1
            if pomoc > 12:
                pomoc2 = i  # mjesto gdje je sredina od $
                #break
    #print(pomoc2)

    pomoc3 = []
    pomoc = -1
    for i in range(80 - pomoc2 - 5):
        if pomoc > 17:
            break
        if pomoc > -1:
            pomoc3.append(pomoc)
        pomoc = 0

        for j in range(19):
            if pix[i + pomoc2 + 5, j] == 0:
                pomoc += 1

    #pomoc3.append(pomoc)
    #print(pomoc3)
    pomoc4 = []
    pomoc5 = 0
    pomoc6 = 0
    flag = 0

    if len(pomoc3) > 0:
        if pomoc3[0] == 0:
            pomoc3.remove(0)

    novi = []
    novi = pomoc3[:]
    novi2 = []
    nule_gdje = []
    z = 1
    broj = 0
    broj2 = 0
    while (z):  #
        try:
            nule_gdje.append(novi.index(0) + broj + broj2)
        except ValueError:
            z = 0
            continue
        else:
            novi.remove(0)

        #if len(nule_gdje)>1:
        # if (nule_gdje[broj]-nule_gdje[broj-1])<4:
        #  broj-=1
        #  broj2+=1
        #  nule_gdje.pop()

        broj += 1

    #print(nule_gdje)
    broj3 = 0
    potraga = []
    oduz = []
    vjerojatnost = []
    zeroth = [
        5, 9, 4, 4, 4, 9, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0
    ]
    first = [
        2, 2, 2, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0
    ]
    second = [
        3, 6, 6, 6, 6, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0
    ]
    third = [
        1, 5, 4, 6, 6, 9, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0
    ]
    third2 = [
        5, 4, 6, 6, 9, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0
    ]
    fourth = [
        2, 4, 4, 4, 11, 11, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0
    ]
    fifth = [
        2, 9, 6, 6, 6, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0
    ]
    sixth = [
        5, 9, 4, 6, 6, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0
    ]
    seventh = [
        2, 4, 8, 5, 4, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0
    ]
    eigth = [
        5, 9, 6, 6, 6, 9, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0
    ]
    nineth = [
        4, 7, 6, 6, 4, 9, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0
    ]
    for i in nule_gdje:
        if len(pomoc3[broj3:i]) > 1:  # ako su nule jedna pored druge
            #print(pomoc3[broj3:i])

            if pomoc3[broj3:i] == [2, 2]:
                potraga.append(10)
            else:
                oduz = oduzmi.liste(pomoc3[broj3:i], zeroth)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(pomoc3[broj3:i], first)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(pomoc3[broj3:i], second)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(pomoc3[broj3:i], third)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(pomoc3[broj3:i], third2)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(pomoc3[broj3:i], fourth)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(pomoc3[broj3:i], fifth)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(pomoc3[broj3:i], sixth)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(pomoc3[broj3:i], seventh)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(pomoc3[broj3:i], eigth)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(pomoc3[broj3:i], nineth)
                vjerojatnost.append(sum(oduz))

                if vjerojatnost.index(min(vjerojatnost)) > 3:
                    potraga.append(vjerojatnost.index(min(vjerojatnost)) - 1)
                else:
                    potraga.append(vjerojatnost.index(min(vjerojatnost)))

        vjerojatnost = []
        broj3 = i + 1

    #print(potraga)
    jakost = 100
    if potraga.count(10) > 0:
        potraga.remove(10)
        jakost = 1

    dizati = 0

    for i in range(len(potraga)):
        dizati += potraga[i] * jakost * (10**(len(potraga) - 1 - i))

    #print('u potu ima %.2f$'%(float(dizati)/100))

    return dizati
Пример #8
0
def pamti(broj, pomak, pomak2):
    dir = folder.get()
    im = Image.open(dir + 'slika.jpg')

    if broj == 1:
        size = (298 - pomak2, 467 + pomak, 400 - pomak2, 482 + pomak
                )  #povecat za 1 kad bude trebalo
        im2 = im.crop(size)
        im3 = im2.convert('P').convert('1')
        pix2 = im3.load()
        im3.save(dir + 'ime1.jpg')  #ime1
    elif broj == 2:
        size = (26 - pomak2, 388 + pomak, 128 - pomak2, 403 + pomak
                )  #povecat za 1 kad bude trebalo
        im2 = im.crop(size)
        im3 = im2.convert('P').convert('1')
        pix2 = im3.load()
        im3.save(dir + 'ime2.jpg')  #ime2
    elif broj == 3:
        size = (21 - pomak2, 151 + pomak, 123 - pomak2, 166 + pomak
                )  #povecat za 1 kad bude trebalo
        im2 = im.crop(size)
        im3 = im2.convert('P').convert('1')
        pix2 = im3.load()
        im3.save(dir + 'ime3.jpg')  #ime3
    elif broj == 4:

        size = (905 - pomak2, 151 + pomak, 1007 - pomak2, 166 + pomak
                )  #povecat za 1 kad bude trebalo
        im2 = im.crop(size)
        im3 = im2.convert('P').convert('1')
        pix2 = im3.load()
        im3.save(dir + 'ime4.jpg')  #ime4
    elif broj == 5:

        size = (896 - pomak2, 387 + pomak, 998 - pomak2, 402 + pomak
                )  #povecat za 1 kad bude trebalo
        im2 = im.crop(size)
        im3 = im2.convert('P').convert('1')
        pix2 = im3.load()
        im3.save(dir + 'ime5.jpg')  #ime5

# size=(632-pomak2,467+pomak,734-pomak2,482+pomak) #povecat za 1 kad bude trebalo
# im2=im.crop(size)
# im3=im2.convert('P').convert('1')
# pix2 = im3.load()
# im3.save('ime6.jpg') #ime6

    pomoc4 = []
    pomoc3 = []
    pomoc2 = []
    b = 0
    for i in range(102):
        for j in range(15):  #ime
            if pix2[i, j] > 0:
                b += 1
        pomoc4.append(b)
        b = 0
    #print(pomoc) #ime
    #print(pomoc2) #novac
    for i in range(102):
        for j in range(15):
            if pix2[i, j] == 0:
                b += 1
        pomoc3.append(b)
        b = 0

    #print (sum(pomoc3),sum(pomoc4))
    if sum(pomoc3) > 1450 or sum(pomoc4) < 50:
        return 'xxxxxxxx'
    if sum(pomoc3) < sum(pomoc4):
        pomoc2 = pomoc3[:]
        situacija = 2  #svjetleca situacija
    else:
        pomoc2 = pomoc4[:]
        situacija = 1  # normalna situacija

    #print(pomoc2)
    z = 1
    broj13 = 0
    while z:
        if len(pomoc2) > 0:
            if pomoc2[0] == 0:
                pomoc2.remove(0)
                broj13 += 1
            else:
                pomoc2.insert(0, 0)
                broj13 -= 1
                z = 0
    #print (pomoc2)
    #print(sum(pomoc2))
    #print(broj13)
    novi = []
    novi = pomoc2[:]
    z = 1
    broj = 0
    broj2 = 0
    nule_gdje = []
    prevelik = 0
    while (z):  #
        try:
            nule_gdje.append(novi.index(0) + broj)
        except ValueError:
            z = 0
            continue
        else:
            broj2 += 1

        if len(nule_gdje) > 1:
            #print(len(nule_gdje))
            #print(broj)
            if (nule_gdje[broj] - nule_gdje[broj - 1]) > 12:
                #broj-=1
                #broj2+=1
                nule_gdje.pop()
                try:
                    novi[(nule_gdje[broj - 1] + 5 - broj2) +
                         novi[(nule_gdje[broj - 1] + 5 - broj2):].index(1)] = 0
                except ValueError:
                    try:
                        novi[(nule_gdje[broj - 1] + 5 - broj2) +
                             novi[(nule_gdje[broj - 1] + 5 -
                                   broj2):].index(2)] = 0
                    except ValueError:
                        try:
                            #print((nule_gdje[broj-1]+5-broj2))
                            #print( novi[(nule_gdje[broj-1]+5-broj2):])
                            novi[(nule_gdje[broj - 1] + 5 - broj2) +
                                 novi[(nule_gdje[broj - 1] + 5 -
                                       broj2):].index(3)] = 0
                        except ValueError:
                            try:
                                #print((nule_gdje[broj-1]+5-broj2))
                                #print( novi[(nule_gdje[broj-1]+5-broj2):])
                                novi[(nule_gdje[broj - 1] + 5 - broj2) +
                                     novi[(nule_gdje[broj - 1] + 5 -
                                           broj2):].index(3)] = 0
                            except ValueError:
                                try:
                                    #print((nule_gdje[broj-1]+5-broj2))
                                    #print( novi[(nule_gdje[broj-1]+5-broj2):])
                                    novi[(nule_gdje[broj - 1] + 5 - broj2) +
                                         novi[(nule_gdje[broj - 1] + 5 -
                                               broj2):].index(4)] = 0
                                except ValueError:
                                    try:
                                        #print((nule_gdje[broj-1]+5-broj2))
                                        #print( novi[(nule_gdje[broj-1]+5-broj2):])
                                        novi[(nule_gdje[broj - 1] + 5 - broj2)
                                             + novi[(nule_gdje[broj - 1] + 5 -
                                                     broj2):].index(5)] = 0
                                    except ValueError:
                                        try:
                                            #print((nule_gdje[broj-1]+5-broj2))
                                            #print( novi[(nule_gdje[broj-1]+5-broj2):])
                                            novi[(nule_gdje[broj - 1] + 5 -
                                                  broj2) +
                                                 novi[(nule_gdje[broj - 1] +
                                                       5 -
                                                       broj2):].index(6)] = 0
                                        except ValueError:
                                            try:
                                                #print((nule_gdje[broj-1]+5-broj2))
                                                #print( novi[(nule_gdje[broj-1]+5-broj2):])
                                                novi[(nule_gdje[broj - 1] + 5 -
                                                      broj2) +
                                                     novi[(
                                                         nule_gdje[broj - 1] +
                                                         5 -
                                                         broj2):].index(7)] = 0
                                            except ValueError:
                                                return 'xxxxxxxx'

                #print(novi[(nule_gdje[broj-1]+5-broj2):].index(1))
                #print(novi[(nule_gdje[broj-1]+5-broj2):])
                #print(novi)
                continue
                #prevelik=1
        novi.remove(0)
        broj += 1
    #print (nule_gdje)
    #print(broj2)
    broj = 0
    #while prevelik:
    #print(prevelik)

    #   prevelik=0

    if situacija == 1:
        zeroth = [
            9, 10, 6, 4, 7, 10, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        first = [
            2, 2, 3, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        second = [
            5, 7, 7, 7, 7, 8, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]

        third = [
            4, 7, 6, 6, 8, 11, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]

        fourth = [
            3, 5, 6, 6, 11, 11, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        fifth = [
            8, 10, 9, 6, 8, 10, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]

        sixth = [
            7, 10, 9, 6, 8, 10, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        seventh = [
            2, 6, 9, 8, 6, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        eigth = [
            6, 11, 10, 6, 8, 11, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0
        ]
        nineth = [
            7, 10, 8, 6, 9, 9, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        aa = [
            4, 6, 6, 7, 8, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0
        ]
        bb = [
            11, 11, 6, 4, 6, 8, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0
        ]
        cc = [
            5, 8, 5, 5, 6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0
        ]
        dd = [
            5, 8, 6, 4, 6, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        ee = [
            4, 8, 7, 6, 6, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        ff = [
            2, 11, 11, 4, 4, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        gg = [
            8, 10, 8, 5, 7, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        hh = [
            11, 11, 2, 2, 2, 8, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        ii = [
            10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        jj = [
            1, 1, 12, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0
        ]
        kk = [
            11, 11, 3, 5, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0
        ]
        ll = [
            11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        mm = [
            8, 8, 2, 2, 8, 8, 3, 2, 8, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0
        ]
        nn = [
            8, 8, 3, 2, 2, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0
        ]
        oo = [
            4, 8, 6, 4, 6, 8, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0
        ]
        pp = [
            10, 10, 6, 4, 7, 7, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        qq = [
            5, 8, 6, 4, 5, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0
        ]
        rr = [
            8, 8, 3, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0
        ]
        ss = [
            4, 7, 6, 6, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        tt = [
            2, 10, 10, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0
        ]
        uu = [
            7, 8, 3, 2, 3, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        vv = [
            1, 3, 6, 6, 3, 5, 6, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        ww = [
            2, 6, 8, 4, 8, 4, 8, 4, 7, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        xx = [
            4, 8, 6, 6, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        xx2 = [
            1, 4, 8, 5, 6, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        yy = [
            3, 7, 9, 6, 8, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        zz = [
            5, 6, 7, 7, 6, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0
        ]
        dot = [
            1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
    elif situacija == 2:
        zeroth = [
            5, 9, 4, 4, 4, 9, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        first = [
            2, 2, 3, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        second = [
            3, 6, 6, 6, 6, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        third = [
            1, 5, 4, 6, 6, 9, 5, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0
        ]
        fourth = [
            3, 5, 6, 6, 11, 11, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        fifth = [
            9, 6, 6, 6, 8, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0
        ]
        sixth = [
            5, 9, 4, 6, 6, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        seventh = [
            2, 6, 9, 8, 6, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        eigth = [
            4, 9, 6, 6, 6, 9, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        nineth = [
            4, 7, 6, 6, 5, 9, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        aa = [
            2, 6, 4, 4, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0
        ]
        bb = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        cc = [
            4, 6, 4, 4, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0
        ]
        dd = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        ee = [
            4, 6, 6, 6, 6, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        ff = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        gg = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        hh = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        ii = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        jj = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        kk = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        ll = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        mm = [
            8, 8, 1, 2, 8, 7, 1, 2, 8, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        nn = [
            8, 8, 1, 2, 2, 8, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0
        ]
        oo = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        pp = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        qq = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        rr = [
            8, 8, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        ss = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        tt = [
            2, 8, 9, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        uu = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        vv = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        ww = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        xx = [
            2, 6, 4, 3, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        xx2 = [
            2, 6, 4, 3, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]

        yy = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        zz = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        dot = [
            1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0
        ]

    broj3 = 0
    potraga = '-'
    oduz = []
    vjerojatnost = []
    broj3 = nule_gdje[0] + 1
    #print(nule_gdje)
    broj14 = []
    brojilo = 0
    for i in nule_gdje:

        if len(pomoc2[broj3:i]) > 1:
            broj14.append(broj3)
            broj14.append(i)
            #print(pomoc2[broj3:i])

            if pomoc2[broj3:i] == [2, 2]:
                potraga += '.'
                brojilo += 1
            else:
                za_oduzimane = []
                za_oduzimanje = pomoc2[broj3:i]
                za_oduzimanje.append(0)
                za_oduzimanje.append(0)
                oduz = oduzmi.liste(za_oduzimanje, zeroth)
                vjerojatnost.append(sum(oduz))

                oduz = oduzmi.liste(za_oduzimanje, first)
                vjerojatnost.append(sum(oduz))

                oduz = oduzmi.liste(za_oduzimanje, second)
                vjerojatnost.append(sum(oduz))

                oduz = oduzmi.liste(za_oduzimanje, third)
                vjerojatnost.append(sum(oduz))

                oduz = oduzmi.liste(za_oduzimanje, fourth)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, fifth)
                vjerojatnost.append(sum(oduz))

                oduz = oduzmi.liste(za_oduzimanje, sixth)
                vjerojatnost.append(sum(oduz))

                oduz = oduzmi.liste(za_oduzimanje, seventh)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, eigth)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, nineth)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, aa)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, bb)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, cc)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, dd)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, ee)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, ff)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, gg)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, hh)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, ii)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, jj)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, kk)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, ll)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, mm)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, nn)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, oo)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, pp)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, qq)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, rr)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, ss)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, tt)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, uu)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, vv)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, ww)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, xx)
                vjerojatnost.append(sum(oduz))

                oduz = oduzmi.liste(za_oduzimanje, yy)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, zz)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, xx2)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(za_oduzimanje, dot)
                vjerojatnost.append(sum(oduz))

                if vjerojatnost.index(min(vjerojatnost)) == 0:
                    potraga += '0'

                elif vjerojatnost.index(min(vjerojatnost)) == 1:
                    potraga += '1'
                elif vjerojatnost.index(min(vjerojatnost)) == 2:
                    potraga += '2'
                elif vjerojatnost.index(min(vjerojatnost)) == 3:
                    potraga += '3'
                elif vjerojatnost.index(min(vjerojatnost)) == 4:
                    potraga += '4'
                elif vjerojatnost.index(min(vjerojatnost)) == 5:
                    potraga += '5'
                elif vjerojatnost.index(min(vjerojatnost)) == 6:
                    potraga += '6'
                elif vjerojatnost.index(min(vjerojatnost)) == 7:
                    potraga += '7'
                elif vjerojatnost.index(min(vjerojatnost)) == 8:
                    potraga += '8'
                elif vjerojatnost.index(min(vjerojatnost)) == 9:
                    potraga += '9'

                elif vjerojatnost.index(min(vjerojatnost)) == 10:
                    potraga += 'a'
                elif vjerojatnost.index(min(vjerojatnost)) == 11:
                    potraga += 'b'
                elif vjerojatnost.index(min(vjerojatnost)) == 12:
                    potraga += 'c'
                elif vjerojatnost.index(min(vjerojatnost)) == 13:
                    potraga += 'd'
                elif vjerojatnost.index(min(vjerojatnost)) == 14:
                    potraga += 'e'
                elif vjerojatnost.index(min(vjerojatnost)) == 15:
                    potraga += 'f'
                elif vjerojatnost.index(min(vjerojatnost)) == 16:
                    potraga += 'g'
                elif vjerojatnost.index(min(vjerojatnost)) == 17:
                    potraga += 'h'
                elif vjerojatnost.index(min(vjerojatnost)) == 18:
                    potraga += 'i'
                elif vjerojatnost.index(min(vjerojatnost)) == 19:
                    potraga += 'j'
                elif vjerojatnost.index(min(vjerojatnost)) == 20:
                    potraga += 'k'
                elif vjerojatnost.index(min(vjerojatnost)) == 21:
                    potraga += 'l'
                elif vjerojatnost.index(min(vjerojatnost)) == 22:
                    potraga += 'm'
                elif vjerojatnost.index(min(vjerojatnost)) == 23:
                    potraga += 'r'
                elif vjerojatnost.index(min(vjerojatnost)) == 24:
                    potraga += 'o'
                elif vjerojatnost.index(min(vjerojatnost)) == 25:
                    potraga += 'b'
                elif vjerojatnost.index(min(vjerojatnost)) == 26:
                    potraga += 'q'
                elif vjerojatnost.index(min(vjerojatnost)) == 27:
                    potraga += 'r'
                elif vjerojatnost.index(min(vjerojatnost)) == 28:
                    potraga += 's'
                elif vjerojatnost.index(min(vjerojatnost)) == 29:
                    potraga += 't'
                elif vjerojatnost.index(min(vjerojatnost)) == 30:
                    potraga += 'u'
                elif vjerojatnost.index(min(vjerojatnost)) == 31:
                    potraga += 'v'
                elif vjerojatnost.index(min(vjerojatnost)) == 32:
                    potraga += 'w'
                elif vjerojatnost.index(min(vjerojatnost)) == 33:
                    potraga += 'x'
                elif vjerojatnost.index(min(vjerojatnost)) == 34:
                    potraga += 'y'
                elif vjerojatnost.index(min(vjerojatnost)) == 35:
                    potraga += 'z'
                elif vjerojatnost.index(min(vjerojatnost)) == 36:
                    potraga += 'x'
                elif vjerojatnost.index(min(vjerojatnost)) == 37:
                    potraga += '_'

                brojilo += 1

                #print(potraga)
                if potraga[brojilo] == '5' and situacija == 1:
                    if pix2[(broj13 + broj3), 9] == 0:
                        potraga = potraga[:brojilo] + '9'
                    elif pix2[(broj13 + broj3),
                              8] != 0 and pix2[(broj13 + broj3 + 6), 5] == 0:
                        potraga = potraga[:brojilo] + '6'
                    elif pix2[(broj13 + broj3), 8] != 0:
                        potraga = potraga[:brojilo] + '8'

                elif potraga[brojilo] == '6' and situacija == 1:
                    if pix2[(broj13 + broj3), 9] == 0:
                        potraga = potraga[:brojilo] + '9'
                    elif pix2[(broj13 + broj3), 8] == 0:
                        potraga = potraga[:brojilo] + '5'
                    elif pix2[(broj13 + broj3 + 6), 5] > 0:
                        potraga = potraga[:brojilo] + '8'

                elif potraga[brojilo] == '9' and situacija == 1:
                    if pix2[(broj13 + broj3), 9] != 0 and pix2[
                        (broj13 + broj3), 8] != 0 and pix2[(broj13 + broj3 +
                                                            6), 5] == 0:
                        potraga = potraga[:brojilo] + '6'
                    elif pix2[(broj13 + broj3),
                              8] == 0 and pix2[(broj13 + broj3), 9] != 0:
                        potraga = potraga[:brojilo] + '5'
                    elif pix2[(broj13 + broj3 + 6), 5] > 0 and pix2[
                        (broj13 + broj3), 9] != 0 and pix2[(broj13 + broj3),
                                                           8] != 0:
                        potraga = potraga[:brojilo] + '8'

                elif potraga[brojilo] == '8' and situacija == 1:
                    #print(broj13+broj3+6)
                    if pix2[(broj13 + broj3 + 6), 5] == 0:
                        potraga = potraga[:brojilo] + '6'

                #print(potraga[brojilo],(broj13+broj3))
                #if potraga[brojilo]==5 and situacija==2:
                # if pix1[(broj13+broj3),9]==0
                # elif pix1[(broj13+broj3),8]!=0:

                #   potraga.pop()
                #    potraga.append(6)
                #elif potraga[brojilo]==6 and situacija==2:
                # if pix1[(broj13+broj3),8]==0:
                #    potraga.pop()
                #    potraga.append(5)
                #print(potraga[brojilo])

        vjerojatnost = []
        broj3 = i + 1

    #print(potraga)

    #print(broj14)
    #print(pomoc2)

    return (potraga)
Пример #9
0
def grabi(pomak, pomak2):
    dir = folder.get()
    toplist, winlist = [], []

    def enum_cb(hwnd, results):
        winlist.append((hwnd, win32gui.GetWindowText(hwnd)))

    win32gui.EnumWindows(enum_cb, toplist)

    firefox = [(hwnd, title) for hwnd, title in winlist
               if 'notepad' in title.lower()]
    # just grab the hwnd for first window matching firefox
    firefox = firefox[0]
    hwnd = firefox[0]
    win32gui.SetForegroundWindow(hwnd)
    win32gui.MoveWindow(hwnd, 0, 0, 1028, 734, True)
    bbox = win32gui.GetWindowRect(hwnd)
    time.sleep(4)
    img = ImageGrab.grab(bbox)
    img.save(dir + 'slika.jpg', 'JPEG')

    #time.sleep(4)
    #img = ImageGrab.grab()

    #img.save(dir+'slika.jpg','JPEG')
    im1 = Image.open(dir + 'slika.jpg')

    size = (456, 594, 462, 610)
    im2 = im1.crop(size)
    im2.save(dir + 'pomak.jpg', 'JPEG')

    size = (326, 594, 348, 599)
    im2 = im1.crop(size)
    im2.save(dir + 'pomak2.jpg', 'JPEG')

    size = (741 - pomak2, 438 + pomak, 761 - pomak2, 480 + pomak)
    im2 = im1.crop(size)
    im2.save(dir + '1.jpg', 'JPEG')

    size1 = (801 - pomak2, 438 + pomak, 821 - pomak2, 480 + pomak)
    im2 = im1.crop(size1)
    im2.save(dir + '2.jpg', 'JPEG')

    size2 = (358 - pomak2, 233 + pomak, 378 - pomak2, 275 + pomak)
    im2 = im1.crop(size2)
    im2.save(dir + '3.jpg', 'JPEG')

    size3 = (423 - pomak2, 233 + pomak, 443 - pomak2, 275 + pomak)
    im2 = im1.crop(size3)
    im2.save(dir + '4.jpg', 'JPEG')

    size4 = (488 - pomak2, 233 + pomak, 508 - pomak2, 275 + pomak)
    im2 = im1.crop(size4)
    im2.save(dir + '5.jpg', 'JPEG')

    size5 = (553 - pomak2, 233 + pomak, 573 - pomak2, 275 + pomak)
    im2 = im1.crop(size5)
    im2.save(dir + '6.jpg', 'JPEG')

    size6 = (618 - pomak2, 233 + pomak, 638 - pomak2, 275 + pomak)
    im2 = im1.crop(size6)
    im2.save(dir + '7.jpg', 'JPEG')

    size7 = (713 - pomak2, 665 + pomak, 823 - pomak2, 721 + pomak)
    im2 = im1.crop(size7)
    im2.save(dir + '8.jpg', 'JPEG')

    size8 = (883 - pomak2, 665 + pomak, 993 - pomak2, 721 + pomak)
    im2 = im1.crop(size8)
    im2.save(dir + '9.jpg', 'JPEG')

    size9 = (253 - pomak2, 60 + pomak, 273 - pomak2, 102 + pomak)
    im2 = im1.crop(size9)
    im2.save(dir + '10.jpg', 'JPEG')

    size10 = (723 - pomak2, 60 + pomak, 743 - pomak2, 102 + pomak)
    im2 = im1.crop(size10)
    im2.save(dir + '11.jpg', 'JPEG')
Пример #10
0
def tko(pomak, pomak2):

    dir = folder.get()
    im = Image.open(dir + 'slika.jpg')

    size = (236 - pomak2, 395 + pomak, 248 - pomak2, 418 + pomak
            )  #povecat za 1 kad bude trebalo
    im2 = im.crop(size)
    im3 = im2.convert('P').convert('1')
    pix1 = im3.load()
    im3.save(dir + 'spil1.jpg')  #karte1
    b = []
    #c=[]
    a = 0
    for i in range(12):
        for j in range(23):
            if pix1[i, j] > 0:
                a += 1
    if a > 220:
        b.append(1)
    a = 0

    size = (146 - pomak2, 302 + pomak, 158 - pomak2, 325 + pomak
            )  #povecat za 1 kad bude trebalo
    im2 = im.crop(size)
    im3 = im2.convert('P').convert('1')
    pix1 = im3.load()
    im3.save(dir + 'spil2.jpg')  #karte2

    for i in range(12):
        for j in range(23):
            if pix1[i, j] > 0:
                a += 1
    if a > 220:
        b.append(2)
    a = 0

    size = (242 - pomak2, 185 + pomak, 254 - pomak2, 208 + pomak
            )  #povecat za 1 kad bude trebalo
    im2 = im.crop(size)
    im3 = im2.convert('P').convert('1')
    pix1 = im3.load()
    im3.save(dir + 'spil3.jpg')  #karte3

    for i in range(12):
        for j in range(23):
            if pix1[i, j] > 0:
                a += 1
    if a > 220:
        b.append(3)
    a = 0

    size = (782 - pomak2, 188 + pomak, 794 - pomak2, 211 + pomak
            )  #povecat za 1 kad bude trebalo
    im2 = im.crop(size)
    im3 = im2.convert('P').convert('1')
    pix1 = im3.load()
    im3.save(dir + 'spil4.jpg')  #karte4

    for i in range(12):
        for j in range(23):
            if pix1[i, j] > 0:
                a += 1
    if a > 220:
        b.append(4)
    a = 0

    size = (877 - pomak2, 303 + pomak, 889 - pomak2, 326 + pomak
            )  #povecat za 1 kad bude trebalo
    im2 = im.crop(size)
    im3 = im2.convert('P').convert('1')
    pix1 = im3.load()
    im3.save(dir + 'spil5.jpg')  #karte5

    for i in range(12):
        for j in range(23):
            if pix1[i, j] > 0:
                a += 1
    if a > 220:
        b.append(5)

    #print('u igri su =', b)
    return b
Пример #11
0
def podaci(slika, pomak, pomak2):  #koliko para igrac ima?
    dir = folder.get()
    im = Image.open(dir + 'slika.jpg')

    if slika == 1:
        size = (298 - pomak2, 485 + pomak, 400 - pomak2, 500 + pomak
                )  #povecat za 1 kad bude trebalo
        im2 = im.crop(size)
        im3 = im2.convert('P').convert('1')
        pix1 = im3.load()
        im3.save(dir + 'novac1.jpg')  #novac1

    elif slika == 2:
        size = (26 - pomak2, 406 + pomak, 128 - pomak2, 421 + pomak
                )  #povecat za 1 kad bude trebalo
        im2 = im.crop(size)
        im3 = im2.convert('P').convert('1')
        pix1 = im3.load()
        im3.save(dir + 'novac2.jpg')  #novac2

    elif slika == 3:
        size = (21 - pomak2, 169 + pomak, 123 - pomak2, 184 + pomak
                )  #povecat za 1 kad bude trebalo
        im2 = im.crop(size)
        im3 = im2.convert('P').convert('1')
        pix1 = im3.load()
        im3.save(dir + 'novac3.jpg')  #novac3

    elif slika == 4:
        size = (905 - pomak2, 169 + pomak, 1007 - pomak2, 184 + pomak
                )  #povecat za 1 kad bude trebalo
        im2 = im.crop(size)
        im3 = im2.convert('P').convert('1')
        pix1 = im3.load()
        im3.save(dir + 'novac4.jpg')  #novac4

    elif slika == 5:
        size = (896 - pomak2, 405 + pomak, 998 - pomak2, 420 + pomak
                )  #povecat za 1 kad bude trebalo
        im2 = im.crop(size)
        im3 = im2.convert('P').convert('1')
        pix1 = im3.load()
        im3.save(dir + 'novac5.jpg')  #novac5

    elif slika == 6:
        size = (632 - pomak2, 485 + pomak, 734 - pomak2, 500 + pomak
                )  #povecat za 1 kad bude trebalo
        im2 = im.crop(size)
        im3 = im2.convert('P').convert('1')
        pix1 = im3.load()
        im3.save(dir + 'novac6.jpg')  #novac6

    pomoc4 = []
    pomoc3 = []
    pomoc2 = []
    b = 0
    for i in range(102):
        for j in range(15):  #novac
            if pix1[i, j] > 0:
                b += 1
        pomoc4.append(b)
        b = 0
    #print(pomoc) #ime
    #print(pomoc2) #novac
    for i in range(102):
        for j in range(15):
            if pix1[i, j] == 0:
                b += 1
        pomoc3.append(b)
        b = 0

    #print (sum(pomoc3),sum(pomoc4))
    if sum(pomoc3) > 1450 or sum(pomoc4) < 50:
        return 0
    if sum(pomoc3) < sum(pomoc4):
        pomoc2 = pomoc3[:]
        situacija = 2  #svjetleca situacija
    else:
        pomoc2 = pomoc4[:]
        situacija = 1  # normalna situacija

    #print(pomoc2)
    z = 1
    broj13 = 0
    while z:  #makni sve nule do prvog znaka
        if len(pomoc2) > 0:
            if pomoc2[0] == 0:
                pomoc2.remove(0)
                broj13 += 1
            else:
                z = 0
    #print (pomoc2)
    #print(sum(pomoc2))
    #print(broj13)
    novi = []
    novi = pomoc2[:]
    z = 1
    broj = 0
    broj2 = 0
    nule_gdje = []
    prevelik = 0
    while (z):  #
        try:
            nule_gdje.append(novi.index(0) + broj)
        except ValueError:
            z = 0
            continue
        else:
            broj2 += 1

        if len(nule_gdje) > 1:
            #print(len(nule_gdje))
            #print(broj)
            if (nule_gdje[broj] - nule_gdje[broj - 1]) > 12:
                #broj-=1
                #broj2+=1
                nule_gdje.pop()
                try:
                    novi[(nule_gdje[broj - 1] + 5 - broj2) +
                         novi[(nule_gdje[broj - 1] + 5 - broj2):].index(1)] = 0
                except ValueError:
                    try:
                        novi[(nule_gdje[broj - 1] + 5 - broj2) +
                             novi[(nule_gdje[broj - 1] + 5 -
                                   broj2):].index(2)] = 0
                    except ValueError:
                        try:
                            novi[(nule_gdje[broj - 1] + 5 - broj2) +
                                 novi[(nule_gdje[broj - 1] + 5 -
                                       broj2):].index(3)] = 0
                        except ValueError:
                            return 99999999999

                #print(novi[(nule_gdje[broj-1]+5-broj2):].index(1))
                #print(novi[(nule_gdje[broj-1]+5-broj2):])
                #print(novi)
                continue
                #prevelik=1
        novi.remove(0)
        broj += 1
    #print (nule_gdje)
    #print(broj2)
    broj = 0
    #while prevelik:
    #print(prevelik)

    #   prevelik=0

    if situacija == 1:
        zeroth = [
            9, 10, 6, 4, 7, 10, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        first = [
            2, 2, 3, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        second = [
            5, 7, 7, 7, 7, 8, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]

        third = [
            4, 7, 6, 6, 8, 11, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        third2 = [
            4, 7, 6, 6, 8, 11, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]

        fourth = [
            3, 5, 6, 6, 11, 11, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        fifth = [
            8, 10, 9, 6, 8, 10, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        fifth2 = [
            8, 10, 9, 6, 8, 10, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]

        sixth = [
            7, 10, 9, 6, 8, 10, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        seventh = [
            2, 6, 9, 8, 6, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        eigth = [
            6, 11, 10, 6, 8, 11, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0
        ]
        nineth = [
            7, 10, 8, 6, 9, 9, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
    elif situacija == 2:
        zeroth = [
            5, 9, 4, 4, 4, 9, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        first = [
            2, 2, 3, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        second = [
            3, 6, 6, 6, 6, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        third = [
            1, 5, 4, 6, 6, 9, 5, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0
        ]
        third2 = [
            5, 5, 6, 6, 7, 10, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        fourth = [
            3, 5, 6, 6, 11, 11, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        fifth = [
            9, 6, 6, 6, 8, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0
        ]
        fifth2 = [
            2, 9, 6, 6, 6, 8, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        sixth = [
            5, 9, 4, 6, 6, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        seventh = [
            2, 6, 9, 8, 6, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        eigth = [
            4, 9, 6, 6, 6, 9, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]
        nineth = [
            4, 7, 6, 6, 5, 9, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0
        ]

    broj3 = 0
    potraga = []
    oduz = []
    vjerojatnost = []
    if len(nule_gdje) < 1:
        return 99999999999
    broj3 = nule_gdje[0] + 1
    #print(nule_gdje)
    broj14 = []
    brojilo = -1
    for i in nule_gdje:

        if len(pomoc2[broj3:i]) > 1:
            broj14.append(broj3)
            broj14.append(i)
            #print(pomoc2[broj3:i])

            if pomoc2[broj3:i] == [2, 2]:
                potraga.append(10)
                brojilo += 1
            else:
                oduz = oduzmi.liste(pomoc2[broj3:i], zeroth)
                vjerojatnost.append(sum(oduz))

                oduz = oduzmi.liste(pomoc2[broj3:i], first)
                vjerojatnost.append(sum(oduz))

                oduz = oduzmi.liste(pomoc2[broj3:i], second)
                vjerojatnost.append(sum(oduz))

                oduz = oduzmi.liste(pomoc2[broj3:i], third)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(pomoc2[broj3:i], third2)
                vjerojatnost.append(sum(oduz))

                oduz = oduzmi.liste(pomoc2[broj3:i], fourth)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(pomoc2[broj3:i], fifth)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(pomoc2[broj3:i], fifth2)
                vjerojatnost.append(sum(oduz))

                oduz = oduzmi.liste(pomoc2[broj3:i], sixth)
                vjerojatnost.append(sum(oduz))

                oduz = oduzmi.liste(pomoc2[broj3:i], seventh)
                vjerojatnost.append(sum(oduz))
                oduz = oduzmi.liste(pomoc2[broj3:i], eigth)
                vjerojatnost.append(sum(oduz))

                oduz = oduzmi.liste(pomoc2[broj3:i], nineth)
                vjerojatnost.append(sum(oduz))

                if vjerojatnost.index(min(vjerojatnost)) > 6:
                    potraga.append(vjerojatnost.index(min(vjerojatnost)) - 2)
                elif vjerojatnost.index(min(vjerojatnost)) > 3:
                    potraga.append(vjerojatnost.index(min(vjerojatnost)) - 1)

                else:
                    potraga.append(vjerojatnost.index(min(vjerojatnost)))
                brojilo += 1
                #print(potraga[brojilo],(broj13+broj3))
                #if potraga[brojilo]==5 and situacija==2:
                # if pix1[(broj13+broj3),9]==0
                # elif pix1[(broj13+broj3),8]!=0:

                #   potraga.pop()
                #    potraga.append(6)
                #elif potraga[brojilo]==6 and situacija==2:
                # if pix1[(broj13+broj3),8]==0:
                #    potraga.pop()
                #    potraga.append(5)
                #print(potraga[brojilo])
                if potraga[brojilo] == 5 and situacija == 1:
                    if pix1[(broj13 + broj3), 9] == 0:
                        potraga.pop()
                        potraga.append(9)
                    elif pix1[(broj13 + broj3),
                              8] != 0 and pix1[(broj13 + broj3 + 6), 5] == 0:
                        potraga.pop()
                        potraga.append(6)
                    elif pix1[(broj13 + broj3), 8] != 0:
                        potraga.pop()
                        potraga.append(8)
                elif potraga[brojilo] == 6 and situacija == 1:
                    if pix1[(broj13 + broj3), 9] == 0:
                        potraga.pop()
                        potraga.append(9)
                    elif pix1[(broj13 + broj3), 8] == 0:
                        potraga.pop()
                        potraga.append(5)
                    elif pix1[(broj13 + broj3 + 6), 5] > 0:
                        potraga.pop()
                        potraga.append(8)
                elif potraga[brojilo] == 9 and situacija == 1:
                    if pix1[(broj13 + broj3), 9] != 0 and pix1[
                        (broj13 + broj3), 8] != 0 and pix1[(broj13 + broj3 +
                                                            6), 5] == 0:
                        potraga.pop()
                        potraga.append(6)
                    elif pix1[(broj13 + broj3),
                              8] == 0 and pix1[(broj13 + broj3), 9] != 0:
                        potraga.pop()
                        potraga.append(5)
                    elif pix1[(broj13 + broj3 + 6), 5] > 0 and pix1[
                        (broj13 + broj3), 9] != 0 and pix1[(broj13 + broj3),
                                                           8] != 0:
                        potraga.pop()
                        potraga.append(8)
                elif potraga[brojilo] == 8 and situacija == 1:
                    if pix1[(broj13 + broj3 + 6), 5] == 0:
                        potraga.pop()
                        potraga.append(6)

        vjerojatnost = []
        broj3 = i + 1

    #print(potraga)
    jakost = 100
    if potraga.count(10) > 0:
        potraga.remove(10)
        jakost = 1

    dizati = 0

    for i in range(len(potraga)):
        dizati += potraga[i] * jakost * (10**(len(potraga) - 1 - i))

    #print 'igrac%(broj1)d ima %(broj2).2f $  ' %{"broj1": slika, "broj2": (float(dizati)/100)}

    #print(broj14)
    #print(pomoc2)

    if dizati > 1000000:
        return 0
    return (dizati)
Пример #12
0
def koliki(call):
    dir=folder.get()
    if call==2:
        im = Image.open(dir+'8.jpg')
    else:
        im = Image.open(dir+'9.jpg')
        
    
    #im3=im2.convert('P').convert('1')
    #im2 = Image.open('pot_cb7.jpg')
    im2=im.convert('P').convert('1')
    pix = im2.load()
    im2.save(dir+'raise_cb.jpg')

    pomoc=0
    pomoc2=[]
    for i in range(110-30):
        
        
        for j in range(56-36):
            if pix[i+16,j+24]>0:
              pomoc+=1  
        
        pomoc2.append(pomoc)
        pomoc=0
    z=1
    while z:
        if len(pomoc2)>0:
            if pomoc2[0]==0:
                pomoc2.remove(0)
            else:
                z=0
    #print (pomoc2)
    novi=[]
    novi=pomoc2[:]
    z=1
    broj=0
    broj2=0
    nule_gdje=[]
    prevelik=0
    while (z): #
        try:
            nule_gdje.append(novi.index(0)+broj)
        except ValueError:
            z=0
            continue
        else:
            broj2+=1
            
        
        if len(nule_gdje)>1:
            #print(len(nule_gdje))
            #print(broj)
            if (nule_gdje[broj]-nule_gdje[broj-1])>12:
                #broj-=1
                #broj2+=1
                nule_gdje.pop()
                #print(novi[(nule_gdje[broj-1]+5-broj2):].index(2))
                #print((nule_gdje[broj-1]+5-broj2))
                #print(novi)
                try:
                    novi[(nule_gdje[broj-1]+5-broj2)+novi[(nule_gdje[broj-1]+5-broj2):].index(1)]=0
                except ValueError:
                    try:
                        novi[(nule_gdje[broj-1]+5-broj2)+novi[(nule_gdje[broj-1]+5-broj2):].index(2)]=0
                    except ValueError:
                        try:    
                            novi[(nule_gdje[broj-1]+5-broj2)+novi[(nule_gdje[broj-1]+5-broj2):].index(3)]=0
                        except ValueError:
                            return 99999999999
                #print()
                #print(novi[(nule_gdje[broj-1]+5-broj2):].index(1))
                #print((nule_gdje[broj-1]+5-broj2))
                #print(novi)
                continue
                #prevelik=1
        novi.remove(0)
        broj+=1
    #print (nule_gdje)
    broj=0
    #while prevelik:
        #print(prevelik)
            
     #   prevelik=0
        
    zeroth=[1, 9, 12, 4, 3, 2, 9, 12, 7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    zeroth2=[9, 13, 4, 3, 2, 11, 12, 8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    first=[1, 2, 2, 10, 13, 13,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    first2=[1, 3, 10, 13, 14, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    second=[1, 4, 6, 6, 6, 5, 9, 8, 6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    second2=[1, 1, 4, 6, 6, 6, 5, 9, 8, 6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    second3=[ 4, 6, 6, 6, 5, 9, 8, 6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    third=[2, 3, 2, 5, 8, 11, 9, 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    third2=[1, 2, 5, 3, 4, 6, 12, 11, 4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    third3=[1, 1, 2, 4, 3, 5, 8, 10, 9, 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    fourth=[1, 4, 4, 4, 3, 10, 13, 14, 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    fifth=[3, 9, 5, 5, 5, 7, 9, 4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    sixth=[7, 10, 7, 4, 4, 6, 7, 6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    seventh=[4, 2, 3, 6, 6, 6, 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    eigth=[7, 12, 8, 5, 5, 8, 11, 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    nineth=[6, 8, 5, 5, 3, 10, 11, 7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    broj3=0
    potraga=[]
    oduz=[]
    vjerojatnost=[]
    broj3=nule_gdje[0]+1
    for i in nule_gdje:
            
        if len(pomoc2[broj3:i])>1:
            #print(pomoc2[broj3:i])

       
            if pomoc2[broj3:i]==[3,3] or pomoc2[broj3:i]==[1,3,3] or pomoc2[broj3:i]==[1,3,2] or pomoc2[broj3:i]==[3,2] or pomoc2[broj3:i]==[2,3] or pomoc2[broj3:i]==[1,2,3] :
                potraga.append(10)
            else:
                oduz=oduzmi.liste(pomoc2[broj3:i],zeroth)
                vjerojatnost.append(sum(oduz))
                oduz=oduzmi.liste(pomoc2[broj3:i],zeroth2)
                vjerojatnost.append(sum(oduz))
                oduz=oduzmi.liste(pomoc2[broj3:i],first)
                vjerojatnost.append(sum(oduz))
                oduz=oduzmi.liste(pomoc2[broj3:i],first2)
                vjerojatnost.append(sum(oduz))
                oduz=oduzmi.liste(pomoc2[broj3:i],second)
                vjerojatnost.append(sum(oduz))
                oduz=oduzmi.liste(pomoc2[broj3:i],second2)
                vjerojatnost.append(sum(oduz))
                oduz=oduzmi.liste(pomoc2[broj3:i],second3)
                vjerojatnost.append(sum(oduz))
                oduz=oduzmi.liste(pomoc2[broj3:i],third)
                vjerojatnost.append(sum(oduz))
                oduz=oduzmi.liste(pomoc2[broj3:i],third2)
                vjerojatnost.append(sum(oduz))
                oduz=oduzmi.liste(pomoc2[broj3:i],third3)
                vjerojatnost.append(sum(oduz))
                oduz=oduzmi.liste(pomoc2[broj3:i],fourth)
                vjerojatnost.append(sum(oduz))
                oduz=oduzmi.liste(pomoc2[broj3:i],fifth)
                vjerojatnost.append(sum(oduz))
                oduz=oduzmi.liste(pomoc2[broj3:i],sixth)
                vjerojatnost.append(sum(oduz))
                oduz=oduzmi.liste(pomoc2[broj3:i],seventh)
                vjerojatnost.append(sum(oduz))
                oduz=oduzmi.liste(pomoc2[broj3:i],eigth)
                vjerojatnost.append(sum(oduz))
                oduz=oduzmi.liste(pomoc2[broj3:i],nineth)
                vjerojatnost.append(sum(oduz))

                if vjerojatnost.index(min(vjerojatnost))>8:
                    potraga.append(vjerojatnost.index(min(vjerojatnost))-6)
                elif vjerojatnost.index(min(vjerojatnost))>7:
                    potraga.append(vjerojatnost.index(min(vjerojatnost))-5)
                elif vjerojatnost.index(min(vjerojatnost))>5:
                    potraga.append(vjerojatnost.index(min(vjerojatnost))-4)
                elif vjerojatnost.index(min(vjerojatnost))>4:
                    potraga.append(vjerojatnost.index(min(vjerojatnost))-3)
                elif vjerojatnost.index(min(vjerojatnost))>2:
                    potraga.append(vjerojatnost.index(min(vjerojatnost))-2)
                elif vjerojatnost.index(min(vjerojatnost))>0:
                    potraga.append(vjerojatnost.index(min(vjerojatnost))-1)
                else:
                    potraga.append(vjerojatnost.index(min(vjerojatnost)))

                            
        vjerojatnost=[]
        broj3=i+1

    #print(potraga)
    jakost=100
    if potraga.count(10)>0:
        potraga.remove(10)
        jakost=1

    dizati=0
    
    for i in range(len(potraga)):
        dizati+=potraga[i]*jakost*(10**(len(potraga)-1-i))

    #print('raise je bio %.2f$'%(float(dizati)/100))
        
    
    return (dizati)
Пример #13
0
def koja(dat):
    dir=folder.get()	
    im = Image.open(dir+"%d"%(dat+1)+'.jpg')

    im2=im.convert('P').convert('1')

    pix = im2.load()
    velicina=im2.getbbox()
    im2.save(dir+'karta3.jpg')
    x=(velicina[2])
    y=(velicina[3])

    nula=0
    nula1=0
    nula2=0
    nula3=0
    nula4=0

    for j in range(3):  

        for i in range(x):
            #print(i+2,j+2,pix[i+2,j+2])
            if pix[i,j+23]==0:
                nula4+=1
    #print(nula4)
    if nula4>20:
        #print('nije karta')
        return 0

    for j in range(y-33):  

        for i in range(x-12):
            #print(i+2,j+2,pix[i+2,j+2])
            if pix[i+2,j+2]==0:
                nula+=1

    for j in range(y-33):  

        for i in range(x-12):
            #print(i+10,j+2,pix[i+10,j+2])
            if pix[i+10,j+2]==0:
                nula1+=1


    for j in range(y-33):  

        for i in range(x-12):
            #print(i+10,j+11,pix[i+10,j+11])
            if pix[i+10,j+11]==0:
                nula2+=1


    for j in range(y-33):  

        for i in range(x-12):
            #print(i+2,j+11,pix[i+2,j+11])
            if pix[i+2,j+11]==0:
                nula3+=1

    #nula4=nula+nula1+nula2+nula3
    #print(nula)
    #print(jedan)
    #print(dva)
    #print(tri)
    #print(nula+jedan+dva+tri)

    dva=0

    #rjecnik={'dva':0,'tri':0, 'cetiri':0,'pet':0,'sest':0,'sedam':0,'osam':0,'devet':0, 'deset':0,'decko':0, 'dama':0,'kralj':0,'asic':0}

    tri=0
    cetiri=0
    pet=0
    sest=0
    sedam=0
    osam=0
    devet=0
    deset=0
    decko=0
    dama=0
    kralj=0
    asic=0



    if nula<5:
        decko+=5;
    
    elif nula<10:
        
        
        asic+=1
    elif nula<15:
        
        sedam+=1
        
        dama+=1
        
        
    elif nula<20:
       
        
        
        dama+=1
    
    
        
    
    
    
        
    
        
       
        
        
    if nula1<20:
       
       
        
       
        decko+=1
        dama+=1
        
        
    elif nula1<25: 
        
        
        sedam+=1
        
        decko+=1
        dama+=1
   
    else:
        
        sedam+=1

    if nula2<15:
        sedam+=2
        
    elif nula2<20:
        
        
        sedam+=1
        decko+=1
        
    elif nula2<25: 
        
       
        
        devet+=1
        decko+=1 
          
        
        
        
        
    elif nula2<35:
        
        
        dama+=1
        
        
    else:
        dama+=2

    if nula3<5:
        sedam+=2
        
    elif nula3<10:
       
        sedam+=1
        
    elif nula3<15:
       
        
        
        decko+=1
        
    elif nula3<20:
        
        
        
        decko+=1
        
    elif nula3<25:
        
        dama+=1
    
    elif nula3<30:
       
        dama+=1
        
        
        

    a1=0
    for i in range(11):
        if pix[6+i,17]==0 and pix[6+i,18]==0:
            a1+=1        
    
    if a1>9:
        dva+=12

    a2=0
    for i in range(5):
        if pix[8,5+i]==0 and pix[13,5+i]==0:
            a2+=1

    for i in range(5):
        if pix[7,12+i]==0 and pix[14,12+i]==0:
            a2+=1
        
    if a2>9:
        osam+=11


    a3=0
    for i in range(11):
        if pix[6,7+i]==0 and pix[7,7+i]==0:
            a3+=1

    for i in range(3):
        if pix[7+i,10]==0:
            a3+=1
        
    if a3>13:
        kralj+=11
        

    a4=0
    for i in range(13):
        if pix[6,i+5]==0 and pix[7,i+5]==0:
            a4+=1

    for i in range(7):
        if pix[9,i+8]==0 and pix[10,i+8]==0 and pix[15,i+8]==0:
            a4+=1

    if a4>19:
        deset+=11

    a5=0
    for i in range(9):
        if pix[6+i,13]==0 and pix[6+i,14]==0:
            a5+=1
    
    for i in range(8):
        if pix[12,5+i]==0 and pix[13,5+i]==0:
            a5+=1

    
    if a5>15:
        cetiri+=11

    a6=0
    for i in range(4):
        if pix[5+i,18]==0 and pix[13+i,18]==0:
            a6+=1
    for i in range(6):
        if pix[8+i,12]==0 and pix[8+i,13]==0:
            a6+=1

    if a6>8:
        asic+=11

    if pix[10,5]==0 and pix[7,8]==0 and pix[14,13]==0 and pix[7,13]==255 and pix[6,13]==255 and pix[5,13]==255  and pix[14,7]==255 and pix[13,7]==255:
        pet+=11

    if (pix[12,17]==0 or pix[12,17]==0) and (pix[13,8]==0 or pix[14,8]==0) and (pix[11,10]==0 or pix[10,10]==0) and (pix [11,5]==0 or pix[10,5]==0) and (pix[14,13]==0 or pix[14,12]==0) and pix[8,6]==0 and pix[7,12]==255 and pix[8,13]==255 and pix[7,9]==255 and pix[7,8]==255:
        tri+=11
        
    if pix[8,17]==0 and pix[6,11]==0 and pix[14,14]==0 and pix[8,5]==0 and pix[6,14]==0 and pix[13,8]==255 and pix[14,8]==255:
        sest+=11    

    if pix[9,17]==0 and pix[12,12]==0 and pix[7,11]==0 and pix[7,6]==0 and pix[13,6]==0 and pix[14,10]==0 and pix[6,14]==255 and pix[6,14]==255:
        devet+=11
    
    pitanje=max(dva,tri,cetiri,pet,sest,sedam,osam,devet,deset,decko,dama,kralj,asic)

    if pitanje==sest and pitanje==devet: 
            if (nula1+nula2)>(nula+nula3+1):
                devet+=2
            else:
                sest+=2

    pitanje=max(dva,tri,cetiri,pet,sest,sedam,osam,devet,deset,decko,dama,kralj,asic)

    provjer=0        
    if dva==pitanje:
        #print('dva')
        povrat=1
        provjer+=1
        
    if tri==pitanje:
        #print('tri')
        povrat=5
        provjer+=1
        
    if cetiri==pitanje:
        #print('cetiri')
        povrat=9
        provjer+=1
        
    if pet==pitanje:
        #print('pet')
        povrat=13
        provjer+=1
        
    if sest==pitanje:
        #print('sest')
        povrat=17
        provjer+=1

    if sedam==pitanje:
        #print('sedam')
        povrat=21
        provjer+=1

    if osam==pitanje:
        #print('osam')
        povrat=25
        provjer+=1

    if devet==pitanje:
        #print('devet')
        povrat=29
        provjer+=1
        
    if deset==pitanje:
        #print('deset')
        povrat=33
        provjer+=1
        
    if decko==pitanje:
        #print('decko')
        povrat=37
        provjer+=1
        
    if dama==pitanje:
        #print('dama')
        povrat=41
        provjer+=1
        
    if kralj==pitanje:
        #print('kralj')
        povrat=45
        provjer+=1
    if asic==pitanje:
        #print('asic')
        povrat=49
        provjer+=1

    if provjer>1:
        return 53
    
    if pix[5,25]==0 and pix[15,25]==0:
        #print('srce')
        povrat2=0

    elif pix[12,27]==255 and pix[8,27]==255:
        #print('tref')
        povrat2=1

    elif pix[3,30]==0 and pix[17,30]==0 and pix[10,37]==0:
        #print('karo')
        povrat2=2
    else:
        #print('pik')
        povrat2=3

    return (povrat+povrat2)
Пример #14
0
def gdje(pomak, pomak2):
    dir = folder.get()
    im = Image.open(dir + 'slika.jpg')

    size = (713 - pomak2, 441 + pomak, 730 - pomak2, 452 + pomak
            )  #povecat za 1 kad bude trebalo
    im2 = im.crop(size)
    im3 = im2.convert('P').convert('1')
    pix = im3.load()
    im3.save(dir + 'gumb6.jpg')  #button6

    a = 0
    for i in range(17):
        for j in range(11):
            if pix[i, j] > 0:
                a += 1

    if a > 50:
        #print('button na poziciji 6')
        return (6)
    a = 0
    size = (307 - pomak2, 441 + pomak, 324 - pomak2, 452 + pomak
            )  #povecat za 1 kad bude trebalo
    im2 = im.crop(size)
    im3 = im2.convert('P').convert('1')
    pix = im3.load()
    im3.save(dir + 'gumb1.jpg')  #button1

    for i in range(17):
        for j in range(11):
            if pix[i, j] > 0:
                a += 1

    if a > 50:
        #print('button na poziciji 1')
        return (1)
    a = 0

    size = (147 - pomak2, 352 + pomak, 164 - pomak2, 363 + pomak
            )  #povecat za 1 kad bude trebalo
    im2 = im.crop(size)
    im3 = im2.convert('P').convert('1')
    pix = im3.load()
    im3.save(dir + 'gumb2.jpg')  #button2

    for i in range(17):
        for j in range(11):
            if pix[i, j] > 0:
                a += 1

    if a > 50:
        #print('button na poziciji 2')
        return (2)
    a = 0

    size = (171 - pomak2, 222 + pomak, 188 - pomak2, 233 + pomak
            )  #povecat za 1 kad bude trebalo
    im2 = im.crop(size)
    im3 = im2.convert('P').convert('1')
    pix = im3.load()
    im3.save(dir + 'gumb3.jpg')  #button3

    for i in range(17):
        for j in range(11):
            if pix[i, j] > 0:
                a += 1

    if a > 50:
        #print('button na poziciji 3')
        return (3)
    a = 0

    size = (843 - pomak2, 223 + pomak, 860 - pomak2, 234 + pomak
            )  #povecat za 1 kad bude trebalo
    im2 = im.crop(size)
    im3 = im2.convert('P').convert('1')
    pix = im3.load()
    im3.save(dir + 'gumb4.jpg')  #button4

    for i in range(17):
        for j in range(11):
            if pix[i, j] > 0:
                a += 1

    if a > 50:
        #print('button na poziciji 4')
        return (4)
    a = 0

    size = (859 - pomak2, 349 + pomak, 876 - pomak2, 360 + pomak
            )  #povecat za 1 kad bude trebalo
    im2 = im.crop(size)
    im3 = im2.convert('P').convert('1')
    pix = im3.load()
    im3.save(dir + 'gumb5.jpg')  #button5

    for i in range(17):
        for j in range(11):
            if pix[i, j] > 0:
                a += 1

    if a > 50:
        #print('button na poziciji 5')
        return (5)
    a = 0