HELP stuck on volcano fighters

The function you defined is called findMostLeft, but the function you called is mostLeft

1 Like

Screenshot 2021-04-26 4.58.38 PM
this is what it sais in my problem
thanks i thing i have it now i will message you if i have any problems bye

actually, try deleting the [0] after the paladin line. my bad i think

all you actually needed to do was delete the {} brackets i think

this is my code now and i have a few problems

def findMostLeft(units):
    if len(units) == 0:
        return None
    findMostLeft = units[0]
    for unit in units:
        if unit.pos.x < findMostLeft.pos.x:
            findMostLeft = unit
    return findMostLeft

# This function finds the bottom-most unit:
def findMostBottom(units):
    if len(units) == 0:
        return None
    findMostBottom = units[0]
    for unit in units:
        if unit.pos.y < findMostBottom.pos.y:
            findMostBottom = unit
    return findMostBottom

paladins = hero.findByType("paladin")
# Find the top left paladin with findMostLeft function:
mostLeft = findMostLeft(paladins)
# Find the bottom right paladin with findMostBottom function:
mostBottom = findMostBottom(paladins)

# Use X coordinate from the top left paladin:
# and Y coordinate from the bottom right paladin:
 x = findMostLeft.pos.x
 y = findMostBottom.pos.y
# Move to the {X, Y} point from the previous step:
hero.moveXY(x,y)        
# Continue to shield while the volcano is erupting:
while True:
    hero.shield()

this piece of code

x = findMostLeft.pos.x
y = findMostBottom.pos.y
oh

That should be:

x = mostLeft.pos.x
y = mostBottom.pos.y

You want to find the positions of the paladin to the top and the paladin to the bottom right. findMostLeft() and findMostBottom() are functions. You cannot find the position of a function, so you need to use that function to find the mostLeft paladin and the mostBottom paladin and store them as variables. Then create two more variables by finding then mostLeft paladin and the mostBottom paladin positions. Store those positions as variables. Then moveXY to the position.

1 Like

image

1 Like

Which area is this in?

Screenshot 2021-04-26 5.21.26 PM
HELLO?

SOZ gotta go. bye

Instead of labelling your variable mostLeft and mostBottom, label them bottomPaladin and leftPaladin. I think the reason you are getting this error is because mostLeft and mostBottom are already defined as variables in the findMostLeft() and findMostBottom() functions.

leftPaladin = findMostLeft(paladins)
bottomPaladin = findMostBottom(paladins)
x = leftPaladin.pos.x
y = bottomPaladin.pos.y

Then move to (x, y) with hero.moveXY().

I haven’t reached there yet, I’m only in the Sarven Desert.

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.