Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Continuous Alchemy Infinite Loop


I have tried this level for many days using javascript but my code still not running. the red box appears said infinite loop and code not working. i use mahogany glasses and programmaticon III but it stuck at the hero.findNearest() method and my hero can’t continue to say a word. Please someone can help to give opinions and tell the problems with my code thx.

while (true) {
    var enemy = hero.findNearest(hero.findEnemies());
    var item = hero.findNearest(hero.findItems());

    if(!enemy) {
    if(!item) {
        hero.say("I need water!");
    if(item.type == "poison") {
    } else {
        hero.moveXY(44, 36);

Help with countiniuos alchemy in java script
Continuous Alchemy (Python)

Not sure what is causing the infinite looping, but a (temporary) work around is to put hero.moveXY(hero.pos.x, hero.pos.y) before each continue statement.


Waoo you’re great trotod, i can solve the problem with your help thanks, but i dont understand why i need to use the hero.moveXY(hero.pos.x, hero.pos.y) method before the continue statement though


We’re working on a fix for this infinite loop problem, it’s a bug in the game, not your code :slight_smile:


I think because you are continuing if an enemy is seen, the program will constantly run the first 2 lines and the check condition continously without executing any command? That is a possible reason why the program thinks that it is stuck in an infinite loop. I also had that problem, and solved the level by not using continue statements


Well that was incredibly frustrating. Quit this game for like a week in frustration from not being able to figure this level out, then reading online people talking about “the level not being hard enough” “you don’t even need code to beat the level” hahaha I was borderline ripping my hair out before I found this post. Any other broken levels in JS I should know about??? …at least now I know to come here…