Cannot complete "Misty Island Mine" even with solution from video


#1

Cannot completed “Misty Island Mine”.

Got error

My solution:

def findBestItem(friend, excludeItems):
    items = friend.findItems()
    bestItem = None
    bestItemValue = 0
    for item in items:
        if item in excludeItems:
            continue
        
        value = item.value / friend.distanceTo(item)
        if value > bestItemValue:
            bestItemValue = value
            bestItem = item
    return bestItem

while True:
    peasants = hero.findByType("peasant")
    claimedItems = []
    for peasant in peasants:
        nearest = peasant.findNearestEnemy()
        if nearest and peasant.distanceTo(nearest) < 15 and nearest.target == peasant:
            if peasant.gold >= peasant.costOf("decoy"):
                self.command(peasant, "buildXY", "decoy", peasant.pos.x - 2, peasant.pos.y)
        else:
            item = findBestItem(peasant, claimedItems)
            if item:
                claimedItems.append(item)
                hero.command(peasant, "move", item.pos)

#2

What kind of error did you receve, and what particularly not working about your code?


#3

Line 12: TypeError: Can’t read protected property: hasOwnProperty.

Error points on following line:

if item in excludeItems:

#4

Probably an Esper bug.
/cc @nick @rob


#5

I tried using the code and messing with it, but always get the same error, as well as an invoke bookmark function. I susspect you are running in to the same problme as I have recently.


-Cheers


#6

Should be fixed now with the latest interpreter version! Let me know if you are seeing any more problems.


#7

I still get Error: Attempt to invoke bookmark for [Funciton]. I dont know if that is what got fixed. Where hero.say(histList.join(', ')) works, but hero.say(histList) calls up the error.
-Cheers