# \[SOLVED\] Could someone help me on Noble Sacrifice? (Python)

**URL:** <https://discourse.codecombat.com/t/solved-could-someone-help-me-on-noble-sacrifice-python/15761>\
**Category:** Solved\
**Created:** [August 26, 2018, 1:36am UTC](https://discourse.codecombat.com/t/solved-could-someone-help-me-on-noble-sacrifice-python/15761 "2018-08-26T01:36:59Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![BookFanatic](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bookfanatic/32/8872_2.png) [@BookFanatic](https://discourse.codecombat.com/u/BookFanatic)\
**Post date:** [August 26, 2018, 1:36am UTC](https://discourse.codecombat.com/t/solved-could-someone-help-me-on-noble-sacrifice-python/15761/1 "2018-08-26T01:36:59Z")

</div>

I tried to loop so the soldiers would lure Mr. Yeti but it won’t work.

```python
# Collect 80 gold
while hero.gold <= 80:
    coin = hero.findNearestItem()
    if coin:
        hero.move(coin.pos)
soldiers = 0
while soldiers < 4:
    if hero.gold >= hero.costOf("soldier"):
        hero.summon("soldier")
        soldiers += 1
# Send your soldiers into position
points = []
points[0] = { "x": 13, "y": 73 }
points[1] = { "x": 51, "y": 73 }
points[2] = { "x": 51, "y": 53 }
points[3] = { "x": 90, "y": 52 }
friends = hero.findFriends()

# Use range to make an array to loop over.
while True:
    for j in range(len(friends)):
        point = points[j]
        friend = friends[j]
    if friend:
        hero.command(friend, "move", point)

```

---

<div class="post-metadata">

**Author:** ![BookFanatic](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bookfanatic/32/8872_2.png) [@BookFanatic](https://discourse.codecombat.com/u/BookFanatic)\
**Post date:** [August 26, 2018, 1:58am UTC](https://discourse.codecombat.com/t/solved-could-someone-help-me-on-noble-sacrifice-python/15761/2 "2018-08-26T01:58:36Z")

</div>

Never mind, I figured it out  
I did something

---

<div class="post-metadata">

**Author:** ![fredandgeorge](https://avatars.discourse-cdn.com/v4/letter/f/a3d4f5/32.png) [@fredandgeorge](https://discourse.codecombat.com/u/fredandgeorge)\
**Post date:** [June 25, 2020, 9:21pm UTC](https://discourse.codecombat.com/t/solved-could-someone-help-me-on-noble-sacrifice-python/15761/3 "2020-06-25T21:21:26Z")

</div>

My hero does nothing when I run this code.

```python
item = hero.findNearestItem()
while hero.gold < 80:
    hero.move(item.pos)
# Build 4 soldiers to use as bait
self.summon("soldier")
self.summon("soldier")
self.summon("soldier")
self.summon("soldier")
# Send your soldiers into position
soldier = hero.findFriends()

points = []
points[0] = { "x": 13, "y": 73 }
points[1] = { "x": 51, "y": 73 }
points[2] = { "x": 51, "y": 53 }
points[3] = { "x": 90, "y": 52 }
friends = hero.findFriends()
hero.command(soldier[0], "move", point[0])
hero.command(soldier[1], "move", point[1])
hero.command(soldier[2], "move", point[2])
hero.command(soldier[3], "move", point[3])
# Use range to make an array to loop over.
# Match the friends to the points and command them to move

```

help please.

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [June 25, 2020, 9:29pm UTC](https://discourse.codecombat.com/t/solved-could-someone-help-me-on-noble-sacrifice-python/15761/4 "2020-06-25T21:29:04Z")

</div>

That’s because ‘soldier’ is not defined. Instead, you should loop through your ‘friends’ array, assigning them to their specific points. That’s what the comments are telling you:

```python
# Use range to make an array to loop over.
# Match the friends to the points and command them to move

```

---

<div class="post-metadata">

**Author:** ![jka2706](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/jka2706/32/13636_2.png) [@jka2706](https://discourse.codecombat.com/u/jka2706)\
**Post date:** [June 26, 2020, 7:20am UTC](https://discourse.codecombat.com/t/solved-could-someone-help-me-on-noble-sacrifice-python/15761/5 "2020-06-26T07:20:44Z")

</div>

You’ve defined all the positions as point **s** and then tasked the soldiers to move to point.

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 26, 2020, 7:25am UTC](https://discourse.codecombat.com/t/solved-could-someone-help-me-on-noble-sacrifice-python/15761/6 "2020-06-26T07:25:08Z")

</div>

What @jka2706 is trying to say is that you are using point as an array, but the array you should use is points.

> [@fredandgeorge](#):
>
> `friends = hero.findFriends()`

Here try to put

```python
soldiers = hero.findFriends()

```

Andrei

---

<div class="post-metadata">

**Author:** ![fredandgeorge](https://avatars.discourse-cdn.com/v4/letter/f/a3d4f5/32.png) [@fredandgeorge](https://discourse.codecombat.com/u/fredandgeorge)\
**Post date:** [July 3, 2020, 1:48pm UTC](https://discourse.codecombat.com/t/solved-could-someone-help-me-on-noble-sacrifice-python/15761/7 "2020-07-03T13:48:48Z")

</div>

still not working can you explain more.

```python
item = hero.findNearestItem()
while hero.gold < 80:
    hero.move(item.pos)
# Build 4 soldiers to use as bait
self.summon("soldier")
self.summon("soldier")
self.summon("soldier")
self.summon("soldier")
# Send your soldiers into position
soldier = hero.findFriends()

points = []
points[0] = { "x": 13, "y": 73 }
points[1] = { "x": 51, "y": 73 }
points[2] = { "x": 51, "y": 53 }
points[3] = { "x": 90, "y": 52 }
soldiers = hero.findFriends()
hero.command(soldier[0], "move", point[0])
hero.command(soldier[1], "move", point[1])
hero.command(soldier[2], "move", point[2])
hero.command(soldier[3], "move", point[3])
# Use range to make an array to loop over.
# Match the friends to the points and command them to move

```

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [July 3, 2020, 1:50pm UTC](https://discourse.codecombat.com/t/solved-could-someone-help-me-on-noble-sacrifice-python/15761/8 "2020-07-03T13:50:48Z")

</div>

> [@fredandgeorge](#):
>
> ```python
> hero.command(soldier[0], "move", point[0])
> hero.command(soldier[1], "move", point[1])
> hero.command(soldier[2], "move", point[2])
> hero.command(soldier[3], "move", point[3])
> 
> ```

Here you have to use the array _points_ instead of  
using _point_.

Andrei

---

<div class="post-metadata">

**Author:** ![TEO](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/teo/32/23025_2.png) [@TEO](https://discourse.codecombat.com/u/TEO)\
**Post date:** [August 28, 2020, 2:38am UTC](https://discourse.codecombat.com/t/solved-could-someone-help-me-on-noble-sacrifice-python/15761/9 "2020-08-28T02:38:26Z")

</div>

Hi everyone i was just stuck on this lvl i build the soldiers start moving and then an error comes up look.

```python
# Collect 80 gold
while hero.gold< 80:
    item = hero.findNearestItem()
    hero.move(item.pos)
# Build 4 soldiers to use as bait
hero.summon("soldier")
hero.summon("soldier")
hero.summon("soldier")
hero.summon("soldier")
# Send your soldiers into position
points = []
points[0] = { "x": 13, "y": 73 }
points[1] = { "x": 51, "y": 73 }
points[2] = { "x": 51, "y": 53 }
points[3] = { "x": 90, "y": 52 }
friends = hero.findFriends()
# Use range to make an array to loop over.
# Match the friends to the points and command them to move
if friends:
    hero.command(friend, "move", points)

```

and this is the error  
 ![eg](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/a42fe84c8e56cd07f7b51f2d03ff07ee15d56d86.png)

---

<div class="post-metadata">

**Author:** ![weary](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/weary/32/15122_2.png) [@weary](https://discourse.codecombat.com/u/weary)\
**Post date:** [August 28, 2020, 3:28am UTC](https://discourse.codecombat.com/t/solved-could-someone-help-me-on-noble-sacrifice-python/15761/10 "2020-08-28T03:28:28Z")

</div>

You have to put for loop around the friends.

---

<div class="post-metadata">

**Author:** ![TEO](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/teo/32/23025_2.png) [@TEO](https://discourse.codecombat.com/u/TEO)\
**Post date:** [August 28, 2020, 3:28am UTC](https://discourse.codecombat.com/t/solved-could-someone-help-me-on-noble-sacrifice-python/15761/11 "2020-08-28T03:28:58Z")

</div>

i already solved it but thx anyway

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [August 28, 2020, 2:20pm UTC](https://discourse.codecombat.com/t/solved-could-someone-help-me-on-noble-sacrifice-python/15761/12 "2020-08-28T14:20:42Z")

</div>


