When i run my code it says
here is my code:
# Complete the paladin rectangle to protect the village.
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
# Use X coordinate from the top left paladin:
# and Y coordinate from the bottom right paladin:
if paladins:
coordX = findTopLeft(paladins).pos.x
coordY = findBottomRight(paladins).pos.y
# Move to the {X, Y} point from the previous step:
hero.moveXY(coordX, coordY)
# Continue to shield while the volcano is erupting:
while true:
hero.shield()