# Walkthrough? i m stuck

**URL:** <https://discourse.codecombat.com/t/walkthrough-i-m-stuck/1730>\
**Category:** Uncategorized\
**Created:** [December 11, 2014, 5:41am UTC](https://discourse.codecombat.com/t/walkthrough-i-m-stuck/1730 "2014-12-11T05:41:04Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![fedeps15](https://avatars.discourse-cdn.com/v4/letter/f/ee7513/32.png) [@fedeps15](https://discourse.codecombat.com/u/fedeps15)\
**Post date:** [December 11, 2014, 5:41am UTC](https://discourse.codecombat.com/t/walkthrough-i-m-stuck/1730/1 "2014-12-11T05:41:04Z")

</div>

> **[CodeCombat - Coding games to learn Python and JavaScript](https://codecombat.com/play/level/ogre-encampment)**
>
> Learn programming with a multiplayer live coding strategy game for beginners. Learn Python or JavaScript as you defeat ogres, solve mazes, and level up. Open source HTML5 game!

  
i cant pass this level…  
the game have no “help” or “walkthrough”… i m stuck on this lvl.

---

<div class="post-metadata">

**Author:** ![sotonin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/sotonin/32/24089_2.png) [@sotonin](https://discourse.codecombat.com/u/sotonin)\
**Post date:** [December 11, 2014, 5:49am UTC](https://discourse.codecombat.com/t/walkthrough-i-m-stuck/1730/2 "2014-12-11T05:49:31Z")

</div>

Try attacking if there is a nearby enemy if there is not then attack “Chest”… put it in a loop

---

<div class="post-metadata">

**Author:** ![fedeps15](https://avatars.discourse-cdn.com/v4/letter/f/ee7513/32.png) [@fedeps15](https://discourse.codecombat.com/u/fedeps15)\
**Post date:** [December 11, 2014, 6:21am UTC](https://discourse.codecombat.com/t/walkthrough-i-m-stuck/1730/3 "2014-12-11T06:21:49Z")

</div>

i just bought a better armor and sword.

---

<div class="post-metadata">

**Author:** ![tsepten](https://avatars.discourse-cdn.com/v4/letter/t/c57346/32.png) [@tsepten](https://discourse.codecombat.com/u/tsepten)\
**Post date:** [December 11, 2014, 11:53am UTC](https://discourse.codecombat.com/t/walkthrough-i-m-stuck/1730/4 "2014-12-11T11:53:07Z")

</div>

```
loop:
    self.attack("Chest")
    enemy = self.findNearestEnemy()
    if enemy:
        self.findNearestEnemy()
        self.attack(enemy)

```

This should work.

---

<div class="post-metadata">

**Author:** ![Liquidmantis](https://avatars.discourse-cdn.com/v4/letter/l/3da27b/32.png) [@Liquidmantis](https://discourse.codecombat.com/u/Liquidmantis)\
**Post date:** [December 11, 2014, 3:02pm UTC](https://discourse.codecombat.com/t/walkthrough-i-m-stuck/1730/5 "2014-12-11T15:02:03Z")

</div>

There’s a couple of issues with that code. First, on line 5 that second self.findNearestEnemy(), isn’t needed and it’s not actually doing anything. The main issue though is that you’re always going to alternate attacking the chest even if the enemy is alive, so it’s going to cause extra walking and ignoring the enemy attacking your backside. Try with an else clause so that you only attack the chest when there’s no enemy.

---

<div class="post-metadata">

**Author:** ![hollisgabe12](https://avatars.discourse-cdn.com/v4/letter/h/3da27b/32.png) [@hollisgabe12](https://discourse.codecombat.com/u/hollisgabe12)\
**Post date:** [December 18, 2014, 12:55am UTC](https://discourse.codecombat.com/t/walkthrough-i-m-stuck/1730/6 "2014-12-18T00:55:19Z")

</div>

I can’t beat thorn bush farm i think its rigged when i say put fire trap the over goes the other way i need help give me the code so i can understand what this is

---

<div class="post-metadata">

**Author:** ![sotonin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/sotonin/32/24089_2.png) [@sotonin](https://discourse.codecombat.com/u/sotonin)\
**Post date:** [December 18, 2014, 1:06am UTC](https://discourse.codecombat.com/t/walkthrough-i-m-stuck/1730/7 "2014-12-18T01:06:26Z")

</div>

This thread has nothing to do with thorn bush farm. its about ogre encampment. don’t bump an unrelated thread.

---

<div class="post-metadata">

**Author:** ![Vash\_Langford](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vash_langford/32/10996_2.png) [@Vash\_Langford](https://discourse.codecombat.com/u/Vash_Langford)\
**Post date:** [November 11, 2019, 2:32pm UTC](https://discourse.codecombat.com/t/walkthrough-i-m-stuck/1730/13 "2019-11-11T14:32:18Z")

</div>

how do I pass level 20 on computer science 2

---

<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:** [November 11, 2019, 4:21pm UTC](https://discourse.codecombat.com/t/walkthrough-i-m-stuck/1730/14 "2019-11-11T16:21:50Z")

</div>

Please could you make a new topic with the name of the level, you code (formatted, instructions here: [How to Post Your Code With Radiant, Harmonious Formatting](https://discourse.codecombat.com/t/how-to-post-your-code-with-radiant-harmonious-formatting/1484)), and any problems you’re having. Just asking how you do it without any context isn’t very helpful.  
Thanks  
Danny

---

<div class="post-metadata">

**Author:** ![abiiasf](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/abiiasf/32/10980_2.png) [@abiiasf](https://discourse.codecombat.com/u/abiiasf)\
**Post date:** [November 18, 2019, 10:19pm UTC](https://discourse.codecombat.com/t/walkthrough-i-m-stuck/1730/15 "2019-11-18T22:19:49Z")

</div>

> **[CodeCombat: Learn to Code by Playing a Game](https://codecombat.com/play/level/forest-fire-dancing?course=5632661322961295f9428638&course-instance=5dade57a9d2010002469bf57)**
>
> Learn programming with a multiplayer live coding strategy game for beginners. Learn Python or JavaScript as you defeat ogres, solve mazes, and level up. Open source HTML5 game!
