Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED] Summit's Gate - infinite loop

First few tries this loaded and ran fine. Then I maybe did something wrong and it froze. Reloading it gives this:
image

I’ve tried all three options, sometimes I get back in to the code and can change things, but I get the same problem. (I can’t see anything bad in my code…but it’s entirely possible…).

I’ve tried logging out & back in, and opening CoCo in a different browser.

For reference my code so far is:
(Edited to remove most of it)


while(hero.time < 30) {
    findAndAttack();
    if(hero.gold > hero.costOf("griffin-rider")) {
        hero.summon("griffin-rider");
    }
}

Any suggestions?

I think it may be this. Sometimes codecombat can be very annoying about while loops. You may want to put a while true loop then and if hero.time >= 30 then break.
Danny

Brilliant, thanks.

Any idea why (ie is writing code like that intrinsically wrong, or is it just a product of the background processes that convert my code to actions)?

That does possibly explain why actions in a time limited while loop sometimes happen after they’re supposed to have stopped!

Have a good day :smile:.

Jenny

1 Like