Finally, i found that if i use the hero.moveXY(gemA.pos.x, gemA.pos.y) instead then i pass the level.
I think maybe the hero.move() couldn’t be used mixed with hero.moveXY(), then I tried hero.move({“x”:40, “y”:44}), so there is only hero.move() in the code, but the hero is spinning again.
Conclusion:in this level, hero.move() has some restrictions, so i report it as a bug.
This isn’t a bug. You are using two different move methods - move and moveXY. You have to pick one or the other. It’s no wonder your hero is spinning in circles. He’s being told to do exactly that.
The main difference between moveXY and move methods is that when executing the moveXY method, the hero will not do anything else until this is completed. The code doesn’t move to the next line and no other line of code is considered until the hero arrives at the x,y coordinate of the cited position. With the move method, the hero takes a single step toward the target coordinates and then the code iterates through to see if there’s anything else it should, or could, be doing. In some situations, one is better to use than the other. In other situations, it doesn’t make any significant difference, but you can’t use both.
It is not a bug, hero.move makes you only move one step towards the position of the gem, but moveXY moves you until you reach the pos. To fix this problem, you should put the move (and not the moveXY) inside this while statement
# while your X pos is far away from the gem A pos by more than 1
while Math.abs(hero.pos.x - gemA.pos.x) > 1:
hero.move(gemA.pos)
hero.moveXY(40, 44)
# while your X pos is far away from the gemB X pos by more than 1
while Math.abs(hero.pos.x - gemB.pos.x) > 1:
hero.move(gemB.pos)
hero.moveXY(40, 44)