Don’t you only want to break when you’ve got 20 gold?
Also I think you should move in the while true loop not in the function. Instead use return to get the variable “bestCoin” from the function to the while True loop.
Danny
No, only break if you do have 20 gold.
Also you might want to do something else to get the soldiers. Maybe check if you have 20 gold, then if you do just use moveXY inside the loop. If you break you’ll have to write your code over and over again.
Danny
Because the while loop has stopped.
I thnk break should be used sparingly. It means you exit out of the while True loop forever.
It would be better to have one while True loop, call the function at the start then check if you have enough gold and move using hero.moveXY() inside the loop. There’s no need to break out.
Danny