Reported in github here, but perhaps I’m doing something dumb.
When playing Sarven Shepherd and Bookkeeper with Python the game freezes and I get an “infinite loop” error.
In both cases the play freezes mid-animation until the loop detection error kicks in.
Video of the bug occurring: https://www.youtube.com/watch?v=aCC17gneaNY
Code for Sarven Shepherd:
while True: # Wrap this logic in a while loop to attack all enemies. # Find the array's length with: len(enemies) enemies = hero.findEnemies() enemyIndex = 0 while enemyIndex < len(enemies): enemy = enemies[enemyIndex] # "!=" means "not equal to." if enemy.type != "sand-yak": # While the enemy's health is greater than 0, attack it! while enemy.health > 0: hero.attack(enemy) enemyIndex =+ 1 # Between waves, move back to the center. hero.moveXY(40, 33)
Code for Bookkeeper (not complete for level goals, but shouldn’t freeze and fail):
# Fight enemies for 15 seconds. # Keep count whenever an enemy is defeated. death = 0 bob = hero.now() hero.moveXY(58, 33) while hero.now() - bob < 15: #hero.say(hero.now() - bob) enemy = hero.findNearest(hero.findEnemies()) if enemy: if enemy.health <= 0: death += 1 if enemy: hero.attack(enemy) # Tell Naria how many enemies you defeated. hero.say(bob) # I understand that this is the wrong variable to say, but I don't think this is my issue. # Collect coins until the clock reaches 30 seconds. # Tell Naria how much gold you collected. # Fight enemies until the clock reaches 45 seconds. # Remember to reset the count of defeated enemies! # Tell Naria how many enemies you defeated.