← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #466210]: 'findAll(): 'NoneType' object is not iterable' due to inconsistent image recognition?

 

Question #466210 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/466210

    Status: Answered => Open

Martin Roth is still having a problem:
Thank you kindly for the feedback. Being a very novice hobby programmer,
I still have trouble understanding parts of the code that you posted
(although now I picked up a few new useful commands!).

The old code looks as following:


Settings.MinSimilarity = 0.95

rollRegion = Region(Region(536,570,49,23))

numbPattern = [(0,"num0-1.png"),(1,"num1-1.png"),(2,"num2-1.png"),(3,"num3-1.png"),(4,"num4-1.png"),(5,"num5-1.png"),(6,"num6-1.png"),(7,"num7-1.png"),(8,"num8-1.png"),(9,"num9-1.png")]
bestRoll = 0
count = 0

while True:
    
    hover(Location(614, 626)) #Reroll
    mouseDown(Button.LEFT)
    wait(0.1)
    mouseUp(Button.LEFT)
    
    x = []
    for i in range(0, 9):
        if rollRegion.exists(numbPattern[i][1]):
            currentRollRaw = list(rollRegion.findAll(numbPattern[i][1]))    # naughty
            y = i
            for n in range(len(currentRollRaw)):
                coordRoll = currentRollRaw[n].getX()
                x.append((y,coordRoll))
        else:
            pass
    
    sortedRoll = sorted(x, key=lambda mlem: mlem[1])
    
    finalRoll = []
    for i in range(len(sortedRoll)):
        finalRoll.extend([sortedRoll[i][0]])
    
    stringRoll=[str(i) for i in finalRoll]
    endString = ''.join(stringRoll)
    
    endResult = int(endString)

    if endResult > 108:
        print('Omitting: ', endResult)
        endResult = 0
    else:
        pass
    
    if endResult > bestRoll:
        hover(Location(321, 624)) 
        mouseDown(Button.LEFT)
        wait(0.1)
        mouseUp(Button.LEFT)
        bestRoll = endResult
    else:
        pass
    
    count += 1
    print('Last roll: ', endResult)
    print('Best so far: ', bestRoll)
    print('Attempt number: ', count)

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.