Need help on Timber guard


while True:
    # Collect gold.
    coin = hero.findNearestItem()
    hero.moveXY(coin.pos.x, coin.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 there's an enemy, command her to attack.
            # Otherwise, move her to the right side of the map.
            hero.command(friend, "attack", enemy)
        else:
            hero.command(friend, "move", 68,47)

42%20PM 18%20PM

You can only command the soldiers, but your current code is attempting to command the peasants too in the else statement. You will want to add an if statement to check for an enemy before commanding the attack and then the else statement on that same indentation for the move to ensure you are only commanding the soldiers.

Also, when you are using the move command, you need to give an object coordinate and not just the numbers.

{"x": 68, "y": 47}