Sarven Treasure Teleport

My hero moves towards where I believe the teleporter is, in this case it’s the bottom-right one and then he appears and keeps going towards it, over and over and over. The rest of my code may not be perfect but specifically I’m wondering what teleport locations work so that my hero will teleport and then stop and look for money instead of heading towards the same teleporter.

I’ve looked at this question and updated my locations to be as close to (5.27, 19.23), (4.71, 49.19), (76.67, 19.02), (75.95, 51.00) by rounding to (5, 19), (5, 49), (77, 19), (76, 51) but there is still a never ending loop to the bottom-right teleporter. Here is my code:

# Collect 150 gold while evading ogres with teleporters.
# If you win, it gets harder (and more rewarding).
# If you lose, you must wait a day before you can resubmit.
# Remember, each submission gets a new random seed.
def teleTL():
    hero.moveXY(5, 49)
def teleBL():
    hero.moveXY(5, 19)
def teleTR():
    hero.moveXY(76, 51)
def teleBR():
    hero.moveXY(77, 19)
def inBetween(ogre,coin):
    if (toLeft and oToLeft) or (below and oBelow) or (not toLeft and not oToLeft) or (not below and not oBelow):
        return True
    return False

while True:
    ogres = hero.findEnemies()
    while coinIndex<len(coins):
        if coin.value>=2 and hero.distanceTo(coin)<minDistance:
    if closest and not ogre:
        hero.moveXY(closest.pos.x, closest.pos.y)    
    elif closest and ogre:
        ogreDistance = hero.distanceTo(ogre)
        if ogreDistance >= 10 and closest and not inBetween(ogre,coin):
            hero.moveXY(closest.pos.x, closest.pos.y)
        elif closest:
            if top and left:
            elif top:
            elif not top and left:
            hero.say("I'm here") # right now he never says anything
        hero.moveXY(closest.pos.x, closest.pos.y)

@depperm the hero.moveXY() command will keep moving the hero to the location until it reaches it. If something interrupts this movement like a wall, the hero will eventually stop. Otherwise the hero will try to keep moving toward that location.

The teleporters do not stop the movement. So by using hero.moveXY() you are entering into an infinite loop as the teleporter always places the hero away from the teleporter and never allows the hero to reach the (x,y) coordinate specified.

There are two ways to get around this from what I understand.

  1. keep moving the (x,y) coordinate away from the teleporter until you stop.
  2. use hero.move() instead.

hero.move() advances you in increments towards a point and allows you to place an if statement in between movement to detect if you have teleported. I do not know if you can use moveXY() and teleport, for this to work you would have to stop right on the edge of the teleporter before it teleported you and not after.