Hello, I was going back to extra levels that i never passed and I was wondering if anyone can help me with my problem.

Here’s my code:

while True:
enemy = hero.findNearestEnemy()
friend = hero.findNearestFriend()
# Calculate x by adding friend.pos.x to enemy.pos.x
# Then divide by 2.
# Check the guide if you need more help!
x = (friend.pos.x + enemy.pos.x) / 2
# Now do the same for y
y = (friend.pos.y + enemy.pos.y) / 2
# Move to the x and y coordinates you calculated.
x = ("tower".pos.x + peasant.pos.x) / 2
y = ("tower".pos.y + peasant.pos.y) / 2

You’re pretty close. You define x and y twice. The first definitions are unnecessary, the second are close but tower is not a string and you shouldn’t be using peasant in the equation, you have defined friend above so use it there. Also, you never tell your hero to move to the x and y coordinates defined as x and y.

You’re adding the hero’s coordinates to your friend’s. You’re supposed to add the enemy’s coordinates to your friend’s. Then after defining x and y, you call moveXY() and move to the defined x and y coordinates.