# Hunting party, I am hunting for answers!

**URL:** <https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295>\
**Category:** Level Help\
**Created:** [September 1, 2021, 7:33pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295 "2021-09-01T19:33:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![hellodaddy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/hellodaddy/32/30448_2.png) [@hellodaddy](https://discourse.codecombat.com/u/hellodaddy)\
**Post date:** [September 1, 2021, 7:33pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295/1 "2021-09-01T19:33:49Z")

</div>

This is my code so far

```python
while True:
    friends = hero.findFriends()
    # Use for-loop and for each friend:
    for friend in friends:
        # If they see an enemy then command to attack.
        if friend.findNearestEnemy:
            hero.command(friend, "attack", enemy)
        # Command to move east by small steps.
        

```

I have no idea how to

```python
Command to move east by small steps.

```

---

<div class="post-metadata">

**Author:** ![hellodaddy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/hellodaddy/32/30448_2.png) [@hellodaddy](https://discourse.codecombat.com/u/hellodaddy)\
**Post date:** [September 1, 2021, 7:34pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295/2 "2021-09-01T19:34:41Z")

</div>

I have barely written any code, 'cause I am so confused!

---

<div class="post-metadata">

**Author:** ![enPointe77](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/enpointe77/32/43632_2.png) [@enPointe77](https://discourse.codecombat.com/u/enPointe77)\
**Post date:** [September 1, 2021, 7:35pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295/3 "2021-09-01T19:35:21Z")

</div>

Don’t summon me. You’ve passed me up by a tiny bit. I can no longer help you. Lol

---

<div class="post-metadata">

**Author:** ![hellodaddy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/hellodaddy/32/30448_2.png) [@hellodaddy](https://discourse.codecombat.com/u/hellodaddy)\
**Post date:** [September 1, 2021, 7:35pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295/4 "2021-09-01T19:35:39Z")

</div>

enpointe77, Did you solve cloudrip commander?

---

<div class="post-metadata">

**Author:** ![hellodaddy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/hellodaddy/32/30448_2.png) [@hellodaddy](https://discourse.codecombat.com/u/hellodaddy)\
**Post date:** [September 1, 2021, 7:36pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295/5 "2021-09-01T19:36:05Z")

</div>

I didn’t summon you, did I?

---

<div class="post-metadata">

**Author:** ![enPointe77](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/enpointe77/32/43632_2.png) [@enPointe77](https://discourse.codecombat.com/u/enPointe77)\
**Post date:** [September 1, 2021, 7:36pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295/6 "2021-09-01T19:36:16Z")

</div>

Nope. I’ve been doing school this entire day. Haven’t had a chance too. But that’s off topic.

---

<div class="post-metadata">

**Author:** ![enPointe77](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/enpointe77/32/43632_2.png) [@enPointe77](https://discourse.codecombat.com/u/enPointe77)\
**Post date:** [September 1, 2021, 7:37pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295/7 "2021-09-01T19:37:00Z")

</div>

No. But you summoned me on cloudrip commander, and I wasn’t quite there yet.

---

<div class="post-metadata">

**Author:** ![hellodaddy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/hellodaddy/32/30448_2.png) [@hellodaddy](https://discourse.codecombat.com/u/hellodaddy)\
**Post date:** [September 1, 2021, 7:37pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295/8 "2021-09-01T19:37:11Z")

</div>

Ok but I helped you in RE: I post to many topics, Weakest quickest help.

---

<div class="post-metadata">

**Author:** ![enPointe77](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/enpointe77/32/43632_2.png) [@enPointe77](https://discourse.codecombat.com/u/enPointe77)\
**Post date:** [September 1, 2021, 7:38pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295/9 "2021-09-01T19:38:00Z")

</div>

Yes. And I’ve been doing school. We’re still off topic. So let’s stop talking about this please.

---

<div class="post-metadata">

**Author:** ![Archion](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/archion/32/26234_2.png) [@Archion](https://discourse.codecombat.com/u/Archion)\
**Post date:** [September 1, 2021, 7:40pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295/10 "2021-09-01T19:40:17Z")

</div>

@hellodaddy what do you need help with? It seems that you arnt fully understanding arrays. Am i correct?

---

<div class="post-metadata">

**Author:** ![hellodaddy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/hellodaddy/32/30448_2.png) [@hellodaddy](https://discourse.codecombat.com/u/hellodaddy)\
**Post date:** [September 1, 2021, 7:40pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295/11 "2021-09-01T19:40:49Z")

</div>

Yah. I always have a little bit of trouble on arrays.

---

<div class="post-metadata">

**Author:** ![abc](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@abc](https://discourse.codecombat.com/u/abc)\
**Post date:** [September 1, 2021, 7:41pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295/12 "2021-09-01T19:41:03Z")

</div>

> [@hellodaddy](#):
>
> ```python
> if friend.findNearestEnemy:
> hero.command(friend, "attack", enemy)
> # Command to move east by small steps.
> 
> ```

You have to check if there is an enemy using `friend.findNearestEnemy()`. If that enemy exists, then command your friends to attack that enemy, else command them to move `friend.pos.x + 1, friend.pos.y`

---

<div class="post-metadata">

**Author:** ![hellodaddy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/hellodaddy/32/30448_2.png) [@hellodaddy](https://discourse.codecombat.com/u/hellodaddy)\
**Post date:** [September 1, 2021, 7:41pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295/13 "2021-09-01T19:41:54Z")

</div>

Oh, thanks. abc. I will try that.

---

<div class="post-metadata">

**Author:** ![Archion](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/archion/32/26234_2.png) [@Archion](https://discourse.codecombat.com/u/Archion)\
**Post date:** [September 1, 2021, 7:42pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295/14 "2021-09-01T19:42:24Z")

</div>

Yes abc is correct, i reccomend assigning a variable to friend.findNearestEnemy.

---

<div class="post-metadata">

**Author:** ![hellodaddy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/hellodaddy/32/30448_2.png) [@hellodaddy](https://discourse.codecombat.com/u/hellodaddy)\
**Post date:** [September 1, 2021, 7:45pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295/15 "2021-09-01T19:45:16Z")

</div>

It says that friend.findNearestEnemy() isn’t a thing?

---

<div class="post-metadata">

**Author:** ![abc](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@abc](https://discourse.codecombat.com/u/abc)\
**Post date:** [September 1, 2021, 7:46pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295/16 "2021-09-01T19:46:13Z")

</div>

You have to remember to include parenthesis at the end.

---

<div class="post-metadata">

**Author:** ![hellodaddy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/hellodaddy/32/30448_2.png) [@hellodaddy](https://discourse.codecombat.com/u/hellodaddy)\
**Post date:** [September 1, 2021, 7:46pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295/17 "2021-09-01T19:46:43Z")

</div>

haha, I just did that. It still dosn’t work though.

---

<div class="post-metadata">

**Author:** ![abc](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@abc](https://discourse.codecombat.com/u/abc)\
**Post date:** [September 1, 2021, 7:47pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295/18 "2021-09-01T19:47:47Z")

</div>

If it gives you an error, then you probably haven’t checked if a friend exists. If a friend exists, then they need to find the nearest enemy to them. If that enemy exists, they need to attack it, otherwise they need to move to the right.

---

<div class="post-metadata">

**Author:** ![hellodaddy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/hellodaddy/32/30448_2.png) [@hellodaddy](https://discourse.codecombat.com/u/hellodaddy)\
**Post date:** [September 1, 2021, 7:48pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295/19 "2021-09-01T19:48:17Z")

</div>

Oh, I didn’t check if friend exists. I will do that.

---

<div class="post-metadata">

**Author:** ![hellodaddy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/hellodaddy/32/30448_2.png) [@hellodaddy](https://discourse.codecombat.com/u/hellodaddy)\
**Post date:** [September 1, 2021, 7:50pm UTC](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295/20 "2021-09-01T19:50:19Z")

</div>

It still doesn’t work,

```python
while True:
    friends = hero.findFriends()
    enemy = hero.findNearestEnemy()
    # Use for-loop and for each friend:
    for friend in friends:
        friendAttackEnemy = friend.findNearestEnemy()
        # If they see an enemy then command to attack.
        if friendAttckEnemy:
            hero.command(friend, "attack", enemy)
        # Command to move east by small steps.
        else:
            hero.command(friend, "move", friend.pos.x, friend.pos.y + 1)

```

[Next page](https://discourse.codecombat.com/t/hunting-party-i-am-hunting-for-answers/30295.md?page=2)
