in Bash 'em all, the following code produces a timeout:
while True: enemy = hero.findNearestEnemy() if enemy: hero.bash(enemy) hero.moveXY(40, 33) hero.wait(5) else: continue hero.moveXY(18, 11) hero.moveXY(64, 13) hero.moveXY(65, 58) hero.moveXY(15, 55)
It gets stuck on line 7 after slaying the last enemy:
I realize that the common way of doing this is by getting an array of enemies and repeating the loop
len(enemies) -1 times, but I want to to understand why this above isn’t working.
They way I see it, if there is no enemy because they were all slain, the loop should be exited and code execution should shift to move commands. Right?