Zoo Keeper 15chars

# Protect the cage.
# Put a soldier at each X.
points = [{"x": 33, "y": 42},
          {"x": 47, "y": 42},
          {"x": 33, "y": 26},
          {"x": 47, "y": 26}]

# 1. Collect 80 gold.
while True:
    if hero.gold < 80:
        item = hero.findNearestItem()
        if item:
            hero.move(item.pos)
# 2. Build 4 soldiers.
for i in range(4):
    hero.summon("soldier")
    
# 3. Send your soldiers into position.
while True:
    friends = hero.findFriends()
    for j in range(len(friends)):
        point = points[j]
        friend = friends[j]
        enemy = friend.findNearestEnemy()
        if enemy and enemy.team == "ogres" and friend.distanceTo(enemy) < 5:
            # Command friend to attack.
            hero.command(friend, "attack", enemy)
            pass
            
        else:
            # Command friend to move to point.
            hero.command(friend, "move", point)
            pass
            

please help me my hero just collects coins until it has 80

Since you put the while-true loop for collecting gold, the code will basically be stuck collecting gold when hero.gold is less than 80. Use a while loop for collecting gold with the condition being if gold is less than 80. Here’s what it looks like:

while hero.gold < 80:
    item = hero.findNearestItem()
    if item:
        hero.move(item.pos)