[Timber Guard] Soldiers Too slow

Hi everyone,
I’m looking for some help on level Timber Guard.
My soldiers are not moving fast enough to defeat the first wave of enemies to protect the peasants.
I have changed my code for my hero to collect the most valuable coins to generate soldiers faster, but still not working.

def findBestCoin():
    worth = 0
    bestCoin = None
    coins = hero.findItems()
    for coin in coins:
        if coin.value / hero.distanceTo(coin) > worth:
            worth = coin.value / hero.distanceTo(coin)
            bestCoin = coin
    return bestCoin


while True:
    bestCoin = findBestCoin()
    
    if bestCoin:
        hero.moveXY(bestCoin.pos.x, bestCoin.pos.y)
    # If you have enough gold, summon a soldier.
    if hero.gold > hero.costOf("soldier"):
        hero.summon("soldier")
    # Use a for-loop to command each soldier.
    # For loops have two parts: "for X in Y"
    # Y is the array to loop over.
    # The loop will run once for each item in Y, with X set to the current item.
    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': 69, 'y': 42})

Try replacing the move command with this:

hero.command(friend, "move", {"x": 76, "y": 46})

sorry about necroposting

Ephemera is probably inactive now so you don’t have to reply past a week or so. Don’t wory you are still learning the ropes to the discourse. Hopefully you can stick around! The discourse is sorta dead. :skull:

1 Like