[SOLVED] Need Help With Timber Guard (Python)

I’ve been having an issue with the ‘Timber Guard’ level - I think my code itself is correct, but when my avatar summons soldiers and sends them to the right side of the map, the ogres at the beginning outnumber my soldiers and end up getting past them and getting to the loggers and I end up losing the level, and I’m wondering if maybe I need different equipment or something to complete the level (movement-wise I’m using boots of leaping and the ring of speed). Here’s my code:

while True:
    
    coin = hero.findNearest(hero.findItems())
    if coin:
        charged = hero.isReady("jump")
        if charged:
            hero.jumpTo(coin.pos)
        else:
            hero.move(coin.pos)
    
    if hero.gold > hero.costOf("soldier"):
        hero.summon("soldier")
    
    for friend in hero.findFriends():
        if friend.type == "soldier":
            enemy = friend.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)
            else:
                hero.command(friend, "move", {"x": 74, "y": 47})

Here’s a screenshot demonstrating how the ogres are getting past the soldiers:
Situation
Basically, the first soldier and ogre (green circle) engage normally, but the second ogre (red circle) manages to reach a logger (either the red logger or the blue one) before the next soldier (purple) can reach them, and I lose the level. I’ve also tried getting enough gold for one soldier, sending them in, then jumping to fight the ogres myself, and while my avatar can survive the ogre assassins, they always manage to kill at least one of the loggers before they can be stopped. I’ve tried sending the soldiers to different positions at the right side (lower and higher), but the ogres always manage to get to the loggers. I’ve been stuck on this for a while now… Something to add - I’ve had success before in beating the level using the ‘run’ button, but when I tried submitting it so I could actually pass the level, the ogres moved in different places and I ended up losing. If someone could also reply with if levels have random NPC spawns or not, that would be helpful, too.

Also, this is my first post, so if I made any mistakes, sorry in advance.

Welcome‌ ‌welcome‌ ‌to‌ ‌the‌ ‌forum!‌ ‌It‌ ‌is‌ ‌a‌ ‌lovely‌ ‌place‌ ‌where‌ ‌you‌ ‌can‌ ‌share‌ ‌all‌ ‌kinds‌ ‌of‌ stuff‌ ‌(appropriate‌ ‌of‌ ‌course),‌ ‌share‌ ‌bugs,‌ ‌and‌ ‌even‌ ‌get‌ ‌assistance‌ ‌for‌ ‌code!‌ ‌We‌ ‌suggest‌ ‌that‌ ‌you‌ ‌review‌ ‌this‌‌ topic ‌ ‌which‌ ‌shows‌ ‌all‌ ‌essentials‌ ‌of‌ ‌this‌ ‌board!‌ Thanks!!‌ ‌ :partying_face: :partying_face:
Just submit your code over and over, you’ll win eventually

1 Like

Oh thanks, that worked! For some reason even though I tried that many times before, after you said this, it worked! Perhaps a coincidence…

Thanks for the welcome, too!

1 Like

Everytime you submit, you get a different seed. :slight_smile: So each submission is slightly different.

2 Likes

yeah happens to me too (sometimes)

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.