Pender's Trial Python Help!

Wow… I can’t believe it…
My code works entirely, no bugs, I attack the shamans first (thank you SO much CryptiCrystal!! I figured it out!), but STILL… I run out of time!!!
Here is my code:

# Pender wants to test you on a series of trials. Use your boss star to clear off the ogres! Remember, you cannot move or attack in this level.
def summonTroops():
    # These are just an example. Feel free to use griffin riders and/or other units!
    if hero.gold >= 40:
        hero.summon("soldier")
        hero.summon("archer")
while True:
    summonTroops()
    friends = hero.findFriends()
    # Iterate over all troops using a for loop. Make peasants collect coins. Combat troops fight. 
    #item = hero.findNearestItem()
    enemy = hero.findNearestEnemy()
    flag = hero.findFlag("green")
    
    for friend in friends:
        peasants = hero.findByType("peasant")
        for peasant in peasants:
            item = peasant.findNearestItem()
            if friend.type == "peasant":
                if item:
                    hero.command(friend, "move", item.pos)
        if friend.type != "peasant":
            if enemy:
                hero.command(friend, "attack", enemy)
                shamans = friend.findByType("shaman")
                for shaman in shamans:
                    if shaman:
                        hero.command(friend, "attack", shaman)
                    #else:
                    #    hero.command(friend, "attack", enemy)
                
            else:
                hero.command(friend, "move", Vector(30, 36))
#        elif enemy and enemy.type == "shaman":
#            hero.command(friend, "attack", enemy)

Pretty sure that a soldier and archer cost combined is greater than forty. I believe a soldier’s cost is 25 gold, and an archer’s cost is 25 gold as well. So that would mean you need at least 50 gold to summon both an archer and a soldier at once.

That code came from the starting code, so I’m pretty sure that’s right.

I think 40 is the cost of a griffin-rider, which is what unit they gave as an example.

I only have stars I and II… is it possible to beat just with soldiers and archers?

I beat it by summoning a mass of soldiers and commanding them to attack, but I had boss star 3. You could try to get boss star three and then come back to this level or try to beat it with boss star 2. I attempted the level with boss star 2 just now, and I failed, I think you should go on and get boss star 3 before returning to this level. You would need the higher gold production rate.

I commanded them to move to a center position of Vector(30,36) that way they couldn’t be flanked from the sides.

Ok, I’ll wait until I get boss star III and see what happens. Thanks for the advice :smiley:

I got the boss star III!

1 Like

oh, dang, it didn’t work… I submitted 10 times to try to get a lucky seed but all of them failed
maybe i’ll save for boss star IV

never mind! I just discovered boss star III allows griffin riders! Thank you so much for your help, abc!! :smiley:

1 Like

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