Leave it to the cleaver - Last ogre stuck on edge of the map

This is the code i currently have:

This shows how to define a function called cleaveWhenClose

The function defines a parameter called target

def cleaveWhenClose(target):
if hero.distanceTo(target) < 5:
pass
# Put your attack code here
# If cleave is ready, then cleave target
ready = hero.isReady(“cleave”)
hero.cleave(target)
else:
hero.attack(target)

This code is not part of the function.

while True:
enemy = hero.findNearestEnemy()
if enemy:
# Note that inside cleaveWhenClose, we refer to the enemy as target.
cleaveWhenClose(enemy)

Could you post the screenshot of it?

you can see the last ogre alive at the top middle of the map/area above the hero on the hero’s left side. You can also see my code in the screen shot (I am using python)

Rafael, shouldn’t you use ready, because you assigned it to the value of hero.isReady("cleave") and you never actually use it. What I mean is, you should use if hero.distanceTo(target) < 5 and ready: instead of using hero.distanceTo(target) < 5. Also, define ready inside the while loop.