Dance-off help needed

Code posted below anyone know what I’m doing wrong

while True:
    Friends = hero.findFriends()
    friend = hero.findNearest(Friends)
    offset = hero.distanceTo(friend)
    heroPos = hero.pos
    friendPos = friend.pos
    if heroPos.x == friendPos.x - offset:
        hero.move({"x": friendPos.x - offset, "y": heroPos.y})
    elif heroPos.y == friendPos.y - offset:
        hero.move({"x": heroPos.x, "y": friendPos.y - offset})

Now I know the solution has something to do with distanceTo but havent really figured it out
Gonna try some other levels in the meantime. will mark this thread as watched by me.
see ya

PS sorry if this is in the wrong section.

I think you’ve really over complicated this. I often have a tendency to the same as well. All you need to do is find nearest out of an array of friends and then move in a loop to that friend’s position x, position y - 6.

I was able to pass this level with 4 lines of code without cheating.

1 Like