# {UNSOLVED}Hunting party level help

**URL:** <https://discourse.codecombat.com/t/unsolved-hunting-party-level-help/21103>\
**Category:** Level Help\
**Created:** [April 20, 2020, 5:59pm UTC](https://discourse.codecombat.com/t/unsolved-hunting-party-level-help/21103 "2020-04-20T17:59:06Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZAX155](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/zax155/32/34141_2.png) [@ZAX155](https://discourse.codecombat.com/u/ZAX155)\
**Post date:** [April 20, 2020, 5:59pm UTC](https://discourse.codecombat.com/t/unsolved-hunting-party-level-help/21103/1 "2020-04-20T17:59:06Z")

</div>

@dedreous

```python

enemy = hero.findNearest(hero.findEnemies())
hero.moveXY(60, 72)
if enemy:
    hero.attack(enemy)
else:
    pass

hero.moveXY(64, 24)
if enemy:
    hero.attack(enemy)
else:
    pass

hero.moveXY(88, 60)
if enemy:
    hero.attack(enemy)
    ready = hero.isReady("cleave")
    hero.cleave(enemy)
else:
    pass
# here is my code

```

---

<div class="post-metadata">

**Author:** ![brotherofall](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/brotherofall/32/11594_2.png) [@brotherofall](https://discourse.codecombat.com/u/brotherofall)\
**Post date:** [April 21, 2020, 12:50pm UTC](https://discourse.codecombat.com/t/unsolved-hunting-party-level-help/21103/2 "2020-04-21T12:50:15Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![ZAX155](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/zax155/32/34141_2.png) [@ZAX155](https://discourse.codecombat.com/u/ZAX155)\
**Post date:** [April 21, 2020, 1:21pm UTC](https://discourse.codecombat.com/t/unsolved-hunting-party-level-help/21103/3 "2020-04-21T13:21:10Z")

</div>

thats javascript not python

---

<div class="post-metadata">

**Author:** ![ZAX155](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/zax155/32/34141_2.png) [@ZAX155](https://discourse.codecombat.com/u/ZAX155)\
**Post date:** [April 21, 2020, 5:52pm UTC](https://discourse.codecombat.com/t/unsolved-hunting-party-level-help/21103/4 "2020-04-21T17:52:54Z")

</div>

![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/5/5666f7eaa2aa8bb30f116386ee57e3e634313964.jpeg)  
i dont know what i am doing wrong @Chaboi_3000

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [April 21, 2020, 6:13pm UTC](https://discourse.codecombat.com/t/unsolved-hunting-party-level-help/21103/5 "2020-04-21T18:13:37Z")

</div>

You’re not quite following the instructions of the level. Ready the comments at the start of the level and in the hints. You’re supposed to be commanding your soldiers, not moving yourself.  
Danny

---

<div class="post-metadata">

**Author:** ![ZAX155](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/zax155/32/34141_2.png) [@ZAX155](https://discourse.codecombat.com/u/ZAX155)\
**Post date:** [April 21, 2020, 6:18pm UTC](https://discourse.codecombat.com/t/unsolved-hunting-party-level-help/21103/6 "2020-04-21T18:18:10Z")

</div>

i tried that and that wasn’t working

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [April 21, 2020, 6:19pm UTC](https://discourse.codecombat.com/t/unsolved-hunting-party-level-help/21103/7 "2020-04-21T18:19:25Z")

</div>

Well you may have to try again and post your code, you kind of need to know how to use a for loop.  
Danny

---

<div class="post-metadata">

**Author:** ![ZAX155](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/zax155/32/34141_2.png) [@ZAX155](https://discourse.codecombat.com/u/ZAX155)\
**Post date:** [April 21, 2020, 6:22pm UTC](https://discourse.codecombat.com/t/unsolved-hunting-party-level-help/21103/8 "2020-04-21T18:22:43Z")

</div>

```python
# You can use findNearestEnemy() on your soldiers to get their nearest enemy instead of yours.
while True:
    friends = hero.findFriends()
    # Use for-loop and for each friend:
    for
        # If they see an enemy then command to attack.
        if enemy:
            hero.command(friends, "attack", enemy)
        # Command to move east by small steps.
        

```

is this looking good so far

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [April 21, 2020, 6:28pm UTC](https://discourse.codecombat.com/t/unsolved-hunting-party-level-help/21103/9 "2020-04-21T18:28:45Z")

</div>

That’s not a bad start, you need to do the for loop properly, define enemy and use an else to command the friends to move eastwards when there isn’t an enemy.  
The For loop:

```python
# this is how you do a simple for loop (I think I can tell you this without giving too much away)
Option 1) Simple:
units = hero.findUnits()
for unit in units:
    #code follows

Option 2) More complicated, but sometimes necessary:
units = hero.findUnits()
for i in range(0, len(units)):
    unit = units[i]
    #code follows

```

I hope this helps,  
Danny

---

<div class="post-metadata">

**Author:** ![ZAX155](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/zax155/32/34141_2.png) [@ZAX155](https://discourse.codecombat.com/u/ZAX155)\
**Post date:** [April 21, 2020, 6:32pm UTC](https://discourse.codecombat.com/t/unsolved-hunting-party-level-help/21103/10 "2020-04-21T18:32:29Z")

</div>

```python
# You can use findNearestEnemy() on your soldiers to get their nearest enemy instead of yours.
while True:
    friends = hero.findFriends()
    # Use for-loop and for each friend:
    units = hero.findFriends
    for i in range(0, len(units)):
        unit = units[i]
        if enemy:
            hero.command(units, "attack", enemy)
        else:
            hero.command(units, "move", east)

```

hows this much better and is normal that when i summit it is laggy

```python
# You can use findNearestEnemy() on your soldiers to get their nearest enemy instead of yours.

```

how does this work

 ![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/a6f651abe17d9859ea17e4eeacb1d0a63e13ef7f.jpeg)  
i don’t get this error at all could you explain it @Deadpool198

- @ZAX155  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/4/4dc3282050b82171f1de6e414c330e9ae48ea422.jpeg)  
here is what i am wearing

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [April 21, 2020, 6:42pm UTC](https://discourse.codecombat.com/t/unsolved-hunting-party-level-help/21103/11 "2020-04-21T18:42:23Z")

</div>

You need to put the for loop inside the while true loop and I was giving unit as an example, you should use friend.  
Danny

---

<div class="post-metadata">

**Author:** ![ZAX155](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/zax155/32/34141_2.png) [@ZAX155](https://discourse.codecombat.com/u/ZAX155)\
**Post date:** [April 21, 2020, 6:49pm UTC](https://discourse.codecombat.com/t/unsolved-hunting-party-level-help/21103/12 "2020-04-21T18:49:46Z")

</div>

@everybody  
i need help on this so very bad please help me out soon please because i am about to rage if i cannot solve this level it is hunting party on the cloud rip mountain

---

<div class="post-metadata">

**Author:** ![brotherofall](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/brotherofall/32/11594_2.png) [@brotherofall](https://discourse.codecombat.com/u/brotherofall)\
**Post date:** [April 22, 2020, 12:09am UTC](https://discourse.codecombat.com/t/unsolved-hunting-party-level-help/21103/13 "2020-04-22T00:09:16Z")

</div>

@ZAX155

Change to python and it will be success.

---

<div class="post-metadata">

**Author:** ![ZAX155](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/zax155/32/34141_2.png) [@ZAX155](https://discourse.codecombat.com/u/ZAX155)\
**Post date:** [April 22, 2020, 1:55pm UTC](https://discourse.codecombat.com/t/unsolved-hunting-party-level-help/21103/14 "2020-04-22T13:55:09Z")

</div>

okay  
i will try that @brotherofall

[en\_US.composer.my\_button\_text]

---

<div class="post-metadata">

**Author:** ![CoolDude](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@CoolDude](https://discourse.codecombat.com/u/CoolDude)\
**Post date:** [April 22, 2020, 7:49pm UTC](https://discourse.codecombat.com/t/unsolved-hunting-party-level-help/21103/15 "2020-04-22T19:49:38Z")

</div>

Im not a Python kinda guy but I can give it to u in Javascript?

---

<div class="post-metadata">

**Author:** ![Hin\_Lee](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/hin_lee/32/20147_2.png) [@Hin\_Lee](https://discourse.codecombat.com/u/Hin_Lee)\
**Post date:** [March 22, 2021, 5:49pm UTC](https://discourse.codecombat.com/t/unsolved-hunting-party-level-help/21103/16 "2021-03-22T17:49:02Z")

</div>

define east as {‘x’:friend.pos.x+1, ‘y’:friend.pos.y}

---

<div class="post-metadata">

**Author:** ![milton.jinich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/milton.jinich/32/21419_2.png) [@milton.jinich](https://discourse.codecombat.com/u/milton.jinich)\
**Post date:** [March 22, 2021, 5:55pm UTC](https://discourse.codecombat.com/t/unsolved-hunting-party-level-help/21103/17 "2021-03-22T17:55:16Z")

</div>

Please don’t revive dead topics. This person is inactive.
