Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

HELP stuck on volcano fighters

Hi! can you show us your code with formatting?

1 Like

I mean, can you copy and paste your code here?

paladins = hero.findByType(“paladin”)

This function finds the left-most unit.

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

This function finds the bottom-most unit:

def findMostBottom(units):
if len(units) == 0:
return None
mostBottom = units[0]
for unit in units:
if unit.pos.y < mostBottom.pos.y:
mostBottom = unit
return mostBottom

Find the top left paladin with findMostLeft function:

def findTopLeft(units):
if len(units) == 0:
return None
mostTop = units[0]
units = findMostLeft(units)
for unit in units:
if unit.pos.y > mostTop.pos.y:
mostTop = unit
topLeft = mostTop
return topLeft

Find the bottom right paladin with findMostBottom function:

def findBottomRight(units):
if len(units) == 0:
return None
mostRight = units[0]
findMostBottom(units)
for unit in units:
if unit.pos.x > mostRight.pos.x:
mostRight = unit
bottomRight = mostRight
return bottomRight

Please format your code.

at the beginning of your code, type ```

1 Like

And can you show a screenshot of your error?

1 Like

wrong one


hello you there?

Yea, i’m there. i don’t exactly know what the set thing is though…

Screenshot 2021-04-26 4.29.27 PM
here is my code.
tried that didn’t work for some reason i’ll try again
OH!! got it

I mean, can you paste it (not a picture, like your third post) except properly formatted by putting a ``` in front of your code. the screenshots are a bit blurry

no, not quotation marks: back quotation marks. they’re at the top left corner of the keyboard, above the tab button

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

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

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 = mostLeft.pos.x
y = mostBottom.pos.y
# Move to the {X, Y} point from the previous step:
hero.move({x, y})
# Continue to shield while the volcano is erupting:
while True:
    hero.shield()
1 Like

I think this should be

paladins = hero.findByType("paladin")[0]

it did noooooooooooooooooottttttttttttttttttt wwwwwwwwwwwwwwwwooooooorrrrrrrrrrrrrk!!!
in short: it did not work!!!

hello?

I can’t help for I have never even seen this level in my life, but good job getting the formatting right! that’s what they want around here to make it easier.

1 Like

this should be hero.moveXY(x,y)

ok

is any body there realy do want to compleat this level
oh hi ok

ok sorry

Please be patient. Some people are in school. and others have stuff to do

1 Like


Screenshot 2021-04-26 4.55.05 PM