Skip to content

Freezing then Infinite loop in Sarven Shepherd and Bookkeeper #3709

Open

Description

@alexholman

When playing Sarven Shepherd and Bookkeeper 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.
# I understand the the var bob is the wrong one to say, but I don't think
# that's causing my freezing issue.
hero.say(bob)

# 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.

Activity

  1. alexholman commented on Jun 3, 2016

    @alexholman
    Author

    Figured out that my issue on Sarven Shepherd was trying to increment with
    enemyIndex =+ 1
    I'm going to open another issue as I feel that this should be caught as an error or warning instead of just causing a more obscure infinite loop error.

    Haven't yet been able to find my issue on Bookkeeper.

  2. alexholman commented on Jun 3, 2016

    @alexholman
    Author

    The Bookkeeper bug seems a little weirder.
    I rewrote the code to successfully complete the level, however, I have to add a say during the first attack phase to prevent the freezing bug.

    The code below freezes and gives an infinite loop error. However, if I uncomment the hero.say("stay down") in line 13 then it works. Somehow the delay from the hero.say is allowing the while loop to exit?

    # Fight enemies for 15 seconds.
    # Keep count whenever an enemy is defeated.
    death = 0
    bob = hero.now()
    hero.moveXY(58, 33)
    while hero.now() < 15:
        enemy = hero.findNearest(hero.findEnemies())
    
        if enemy:
            while enemy.health > 0:
                hero.attack(enemy)
            death += 1
        #hero.say("and stay down")
    # Tell Naria how many enemies you defeated.
    hero.say(death)
    # Collect coins until the clock reaches 30 seconds.
    while hero.now() < 30:
        coin = hero.findNearest(hero.findItems())
        coin_count=0
        if coin:
            hero.moveXY(coin.pos.x, coin.pos.y)
            coin_count += 1
    # Tell Naria how much gold you collected.
    hero.moveXY(58, 33)
    hero.say(hero.gold)
    
    # Fight enemies until the clock reaches 45 seconds.
    # Remember to reset the count of defeated enemies!
    death=0
    while hero.now() < 45:
        enemy = hero.findNearest(hero.findEnemies())
    
        if enemy:
            while enemy.health > 0:
                hero.attack(enemy)
            death += 1
        hero.say("and stay down")
    
    # Tell Naria how many enemies you defeated.
    hero.moveXY(58, 33)
    hero.say(death)
    
    
  3. UltCombo commented on Jun 25, 2016

    @UltCombo
    Contributor

    That's probably related to (duplicate of?) this issue reported in the forums.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions