Multiplayer Treasure Grove (python)

Hey - just wondering… how do I beat the Multiplayer Treasure Grove using python… I am very confused. I have tried a couple of methods posted previously, however, could not get them to operate correctly

Here some functions

def pickUpNearestItem(items):
    nearestItem = self.findNearest(items)
    if nearestItem:
        moveTo(nearestItem.pos)
        
def moveTo(position, fast = True):    
    if(self.isReady("jump") and self.distanceTo(position)>10 and fast):
        self.jumpTo(position)
    else:
        self.move(position)
        
def attack(target):
    if target:
        if(self.distanceTo(target)>10):
            moveTo(target.pos)
        elif(self.isReady("bash")):
            self.bash(target)
        elif(self.canCast('chain-lightning', target)):
            self.cast('chain-lightning', target)
        elif(self.isReady("attack")):
            self.attack(target)
        else:
            self.shield()

why it doesn’t work
even the indentations weren’t right

while True:
    #  Find coins and/or attack the enemy.
    # Use flags and your special moves to win!
    flag = hero.findFlag()
    item = hero.findNearestItem()
    enemy = hero.findNearestEnemy()
    if flag:
        hero.pickUpFlag(flag)
        if enemy not flag:
            hero.attack(enemy)

Why isn’t this working? My hero won’t even go to a flag that I place down. Please help!

Add hero.move(flag.pos)
And

You’ll want to delete an indent here and remove the not flag
Lydia

I don’t think you need that.

The reason I have the “if enemy not flag” is because I only want to attack the enemy if there isn’t a flag on screen.

Then do

if enemy and not flag:

by the way flags are not good in this level.