Help on Zoo Keeper

Help! Can you please help for level zoo keeper

# 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.
while hero.gold < 80:
    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:
            hero.command(friend, "move", points)

welcome to the code combat discourse me.

2 Likes

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review this topic, which shows all essentials of this board! Thanks!

Try to do something like this for all your soldiers hero.command(friend, "move" points[0]) and keep doing that all the way to 3 then you should be good to go.

You have each point for each soldier defined, so now you need to command your soldiers to move to each point and it should work. Command them with hero.command(friend, "move", point)

Luke tried that. it just made all of his soldiers move to points0

1 Like

Yeah so you should to the array version that I did.

1 Like

I tried that? Huh im confused…

No, the other guy’s name. Friend of mine.

do

hero.command(friend, "move", points[])

he tried that, @Eric_Tang

What about without the

not yet. As far as I know, anyway.

Then make him try that.

I did

point = points[j]
hero.command(friend, "defend", point

You forgot a parenthesis.

Just looked at my code, he’s suposed to do points[j]

It is supposed to be hero.command(friend, "move", point).

yeah. @wishtalon. 20

1 Like