Interception HELP (SoLvEd)

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

Here’s a screenshot:

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.

I’m not sure what im supposed to fix next :sweat_smile:
can you help me please?

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.

1 Like

yayyyyyy i got it, thank youuu!!! :grin::stuck_out_tongue_closed_eyes:

I about pulled my hair out of my head trying to go back and forth from the internet and rummage for the solution…that really helped me a LOT