# Stuck on Zoo Keeper

I’m stuck on Zoo Keeper. Apparently, my problem is that it cannot read ‘start’ of undefined. I don’t really understand. Here is my code:

for j in range(len(friends)):
point = points[j]
friend = friends[j]
enemy = friend.findNearestEnemy()
if friend and enemy and enemy.team == “ogres” and fr.distanceTo(enemy) < 5:
hero.command(friend, “attack”, enemy)
elif friend:
hero.command(friend, “move”, point

# 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.
pass
hero.command(friend, “attack”, enemy)
else:
# Command friend to move to point.
pass
hero.command(friend, “move”, 47, 42)

What is `points`? Did you define that?
Never heard of `fr.distanceTo(enemy)`. Try using `friend`.
Also, try getting your friend to move to `point` in the loop rather than a fixed (x, y) coordinate.

Ah. Thanks for helping me! Will go to check now.

1 Like

I don’t know how to move my soldier to different positions on the map here is my code so far.
can you help me?

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

# 1. Collect 80 gold.
item = hero.findNearestItem()
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.
#I DON'T KNOW WHAT TO PUT HERE!
pass

``````

You only move to an item once. Will you have 80 gold after that?

Command your friend to “move” to point using

``````hero.command(friend, "move", where you want your friend to move)
``````

You might want to add `while hero.gold > 80` so the hero don’t collect gold forever.

well how do i make sure that each soldier goes to a different cross?

Have to completed the nobel sacrifice level.

no i am on zoo keeper

I solved It ! thanks for helping me everyone

Don’t mention it

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