# \[SOLVED\] Help! Restless Dead \[Python\]

**URL:** <https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161>\
**Category:** Level Help\
**Created:** [July 21, 2020, 12:36am UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161 "2020-07-21T00:36:07Z")\
**Posts on this page:** 20\
**Page:** 4

<div class="post-metadata">

**Author:** ![Anna](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/anna/32/8378_2.png) [@Anna](https://discourse.codecombat.com/u/Anna)\
**Post date:** [August 4, 2020, 12:57pm UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161/65 "2020-08-04T12:57:37Z")

</div>

I haven’t been here for most of the topic but I’m pretty sure you don’t need a defend line in your function. I would also define summon and command (for the soldiers) separately (as in two functions).

---

<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 5, 2020, 9:42am UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161/66 "2020-08-05T09:42:15Z")

</div>

Did you put black or green flags because you if it doesn’t move to that position its probably you placed the wrong flag.

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [August 6, 2020, 1:06am UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161/67 "2020-08-06T01:06:22Z")

</div>

Yes, I did use it. (2020202)

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [August 6, 2020, 1:07am UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161/68 "2020-08-06T01:07:00Z")

</div>

I put black flags as it said in the function.

---

<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 6, 2020, 12:35pm UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161/69 "2020-08-06T12:35:19Z")

</div>

I know you did but you might’ve placed green or pink flags, and did you change your code if you did can you repost it 🙂.

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [August 6, 2020, 8:52pm UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161/70 "2020-08-06T20:52:21Z")

</div>

I placed down black flags, I’m pretty sure.

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [August 7, 2020, 7:56pm UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161/71 "2020-08-07T19:56:33Z")

</div>

This is my current code, sorry for responding so late, school started and they gave us a lot of homework.

```python
def findFlags():
    flag = hero.findFlag("black")
    if flag:
        hero.moveXY(flag.pos.x, flag.pos.y)
        hero.pickUpFlag(flag)

def commandSoldiers():
    if hero.gold >= hero.costOf("soldier"):
        hero.summon("soldier")
    for friend in hero.findFriends():
        if friend.type == "soldier":
            enemy = friend.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)
            else:
                hero.command(friend, "defend", {'x':63, 'y':57})

def collectCoins(): 
    coin = hero.findNearestItem()
    if coin:
        hero.move(coin.pos)

enemyuser = hero.findNearestEnemy()
if enemyuser:
    
    if hero.isReady("throw"):
        hero.throw(enemyuser)
    else:
        hero.attack(enemyuser)

while True:
    collectCoins()
    commandSoldiers()
    enemyuser = hero.findNearestEnemy()
    if enemyuser:
        if hero.distanceTo(enemyuser) > 10:
            hero.move(enemyuser.pos)
        if hero.isReady("throw"):
            hero.throw(enemyuser)
        else:
            hero.attack(enemyuser)
    

```

---

<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 8, 2020, 4:52am UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161/72 "2020-08-08T04:52:42Z")

</div>

You didn’t call the `findFlags()` command in the while true loop so that explain why you can’t move the flag.  
Suggestion:  
I tried the code using Nalfar and I passed the level. It’s not a good idea to let the soldiers move into the Graveyard because thats where the skeleton king summon his minions, try deleting the else line in commandSoldiers().

---

<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 8, 2020, 5:16am UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161/73 "2020-08-08T05:16:06Z")

</div>

I also passed the level with Anya and this is the gear I used

 ![Screenshot 2020-08-08 at 1.06.29 PM](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/4/43e76f5b40c4b8781b9a64b95aec602dc0d71a3d.png)

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [August 8, 2020, 6:05pm UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161/74 "2020-08-08T18:05:00Z")

</div>

Ok, thank you guys for the support!  
Lydia

---

<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 8, 2020, 6:07pm UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161/75 "2020-08-08T18:07:38Z")

</div>

@Lydia_Song does that mean you’ve passed the level?

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [August 8, 2020, 6:18pm UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161/76 "2020-08-08T18:18:43Z")

</div>

NOpe! 🤣 🤣 🤣 🤣 🤣 🤣

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [August 8, 2020, 6:19pm UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161/77 "2020-08-08T18:19:39Z")

</div>

```python
`def findFlags():
    flag = hero.findFlag("black")
    if flag:
        hero.moveXY(flag.pos.x, flag.pos.y)
        hero.pickUpFlag(flag)

def commandSoldiers():
    if hero.gold >= hero.costOf("soldier"):
        hero.summon("soldier")
    for friend in hero.findFriends():
        if friend.type == "soldier":
            enemy = friend.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)
           

def collectCoins(): 
    coin = hero.findNearestItem()
    if coin:
        hero.move(coin.pos)

enemyuser = hero.findNearestEnemy()
if enemyuser:
    if hero.isReady("cleave"):
        hero.cleave(enemyuser)
    if hero.isReady("throw"):
        hero.bash(enemyuser)
    else:
        hero.attack(enemyuser)

while True:
    findFlags()
    collectCoins()
    commandSoldiers()
    enemyuser = hero.findNearestEnemy()
    if enemyuser:
        if hero.isReady("cleave"):
            hero.cleave(enemyuser)
        if hero.isReady("bash"):
            hero.bash(enemyuser)
        else:
            hero.attack(enemyuser)
    `

```

So… all you guys passed the level with this code? That means my armor is trash. 🤣 🤣 🤣

---

<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 8, 2020, 6:32pm UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161/78 "2020-08-08T18:32:02Z")

</div>

That is quite likely. Using your code, but with Anya at 3510 HP, I was also able to pass.

---

<div class="post-metadata">

**Author:** ![MidnightWolf39](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/midnightwolf39/32/13309_2.png) [@MidnightWolf39](https://discourse.codecombat.com/u/MidnightWolf39)\
**Post date:** [August 8, 2020, 6:43pm UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161/79 "2020-08-08T18:43:20Z")

</div>

> [@Lydia\_Song](#):
>
> ```python
> if hero.isReady("throw"):
> hero.bash(enemyuser)
> 
> ```

I think you know what is wrong…

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [August 8, 2020, 7:26pm UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161/80 "2020-08-08T19:26:35Z")

</div>

Lol, i forgot to switch back to bash. I keep switching from ranger and warrior, so…

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [August 8, 2020, 7:27pm UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161/81 "2020-08-08T19:27:11Z")

</div>

Can I see your equipment?

---

<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 8, 2020, 7:28pm UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161/82 "2020-08-08T19:28:55Z")

</div>

![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/5/52633933a0d30df86583818c755b671fe75b8823.jpeg)  
Keep in mind though, I came back to this level after some time so was much better equipped.

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [August 8, 2020, 7:29pm UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161/83 "2020-08-08T19:29:52Z")

</div>

Ok, thank you. I think I’ll come back to this one after I have enough gems to buy a better sword.

---

<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 8, 2020, 7:31pm UTC](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161/84 "2020-08-08T19:31:45Z")

</div>

I think that would be a good idea. Your code is certainly viable.

[Previous page](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161.md?page=3)

[Next page](https://discourse.codecombat.com/t/solved-help-restless-dead-python/23161.md?page=5)
