I really need help in timber guard
here is my code:
while True:
while True:
# Collect gold.
coins = hero.findNearestItem()
hero.move(coins.pos,coins.pos)
# 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.
if enemy:
hero.command(friend, "attack", enemy)
else:
pos = {'x': 72, 'y': 42}
hero.command(friend, "move", pos)
what happens is I can spawn the soldiers but after like 4 of them go the the spot I chose the rest that spawns just stay on the left side instead of the right side so If I can get the soldiers to go the the right side then I would have finished the level