# Bug in kthgard brawl

**URL:** <https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628>\
**Category:** Bugs\
**Created:** [September 24, 2021, 10:30am UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628 "2021-09-24T10:30:47Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rabbit](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rabbit/32/25831_2.png) [@Rabbit](https://discourse.codecombat.com/u/Rabbit)\
**Post date:** [September 24, 2021, 10:30am UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628/1 "2021-09-24T10:30:47Z")

</div>

it says my code has an infinite loop. my code:  
while true:  
if hero.isReady(‘heart-shield’):  
hero.heartShield()  
else:  
hero.shield()  
if hero.gold \>= 25:  
hero.buildXY(“decoy”, hero.pos.x, hero.pos…y)  
and when I do comment out of my code, my hero does nothing

---

<div class="post-metadata">

**Author:** ![Alfa\_Jayden\_Iskandar](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/alfa_jayden_iskandar/32/23714_2.png) [@Alfa\_Jayden\_Iskandar](https://discourse.codecombat.com/u/Alfa_Jayden_Iskandar)\
**Post date:** [September 24, 2021, 10:50am UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628/2 "2021-09-24T10:50:29Z")

</div>

Welcome to the forum! This is a family-friendly place where coders can share bugs, ask for help on any CodeCombat level (don’t forget to post your [code correctly](https://discourse.codecombat.com/t/essentials-how-to-post-format-your-code-correctly/15521?u)), or just hang out with other coders. But before you proceed, please check out our guidelines: [this topic.](https://discourse.codecombat.com/t/this-topic/15601)  
Have a great time! 🥳

---

<div class="post-metadata">

**Author:** ![Alfa\_Jayden\_Iskandar](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/alfa_jayden_iskandar/32/23714_2.png) [@Alfa\_Jayden\_Iskandar](https://discourse.codecombat.com/u/Alfa_Jayden_Iskandar)\
**Post date:** [September 24, 2021, 10:51am UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628/3 "2021-09-24T10:51:27Z")

</div>

i think your if hero gold should be below if hero is ready

---

<div class="post-metadata">

**Author:** ![Aya](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/aya/32/42680_2.png) [@Aya](https://discourse.codecombat.com/u/Aya)\
**Post date:** [September 24, 2021, 6:50pm UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628/4 "2021-09-24T18:50:40Z")

</div>

Please don’t forget to format your code properly using this button:

 ![Screenshot 2021-08-24 12.35.14](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/e/5/e57840f813a3539688c224cba20b4880412c4590.png)

This time I formatted it for you:

```python
while true:
     if hero.isReady(‘heart-shield’):
          hero.heartShield()
     else:
          hero.shield()
     if hero.gold >= 25:
          hero.buildXY(“decoy”, hero.pos.x, hero.pos…y)

```

I can see several mistake here

1. in the while true loop, the “true” should be capitalized: `while True:`
2. In your build statement, the third argument - y - should be `hero.pos.y` instead of `hero.pos...y`
3. You might want to place the if statement of the building decoy at the beginning

---

<div class="post-metadata">

**Author:** ![Rabbit](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rabbit/32/25831_2.png) [@Rabbit](https://discourse.codecombat.com/u/Rabbit)\
**Post date:** [September 25, 2021, 6:38am UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628/5 "2021-09-25T06:38:35Z")

</div>

I did that but it still says infinte loop

---

<div class="post-metadata">

**Author:** ![Rabbit](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rabbit/32/25831_2.png) [@Rabbit](https://discourse.codecombat.com/u/Rabbit)\
**Post date:** [September 25, 2021, 7:27am UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628/6 "2021-09-25T07:27:15Z")

</div>

Hi @Aya , I did that but It still say my code has an infinite loop

---

<div class="post-metadata">

**Author:** ![Aya](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/aya/32/42680_2.png) [@Aya](https://discourse.codecombat.com/u/Aya)\
**Post date:** [September 25, 2021, 7:49am UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628/7 "2021-09-25T07:49:07Z")

</div>

Can you please post your newest code

---

<div class="post-metadata">

**Author:** ![Rabbit](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rabbit/32/25831_2.png) [@Rabbit](https://discourse.codecombat.com/u/Rabbit)\
**Post date:** [September 25, 2021, 7:54am UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628/8 "2021-09-25T07:54:37Z")

</div>

I CAN’T enter the level

---

<div class="post-metadata">

**Author:** ![Aya](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/aya/32/42680_2.png) [@Aya](https://discourse.codecombat.com/u/Aya)\
**Post date:** [September 25, 2021, 9:16am UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628/9 "2021-09-25T09:16:29Z")

</div>

Oops, how come?  
20chars

---

<div class="post-metadata">

**Author:** ![Rabbit](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rabbit/32/25831_2.png) [@Rabbit](https://discourse.codecombat.com/u/Rabbit)\
**Post date:** [September 25, 2021, 10:13am UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628/10 "2021-09-25T10:13:46Z")

</div>

It says Infinite loop detected @Aya

---

<div class="post-metadata">

**Author:** ![Aya](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/aya/32/42680_2.png) [@Aya](https://discourse.codecombat.com/u/Aya)\
**Post date:** [September 25, 2021, 5:17pm UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628/11 "2021-09-25T17:17:02Z")

</div>

You can press “comment out my code”, and sorry for the late reply

---

<div class="post-metadata">

**Author:** ![Rabbit](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rabbit/32/25831_2.png) [@Rabbit](https://discourse.codecombat.com/u/Rabbit)\
**Post date:** [September 25, 2021, 10:24pm UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628/12 "2021-09-25T22:24:10Z")

</div>

I still does not work @Aya

---

<div class="post-metadata">

**Author:** ![cheddarcheese](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/cheddarcheese/32/22417_2.png) [@cheddarcheese](https://discourse.codecombat.com/u/cheddarcheese)\
**Post date:** [September 25, 2021, 10:30pm UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628/13 "2021-09-25T22:30:24Z")

</div>

is this kithgard brawl 8 or smthn? cuz if its that then the problem might just be way too many units so It bugs out

---

<div class="post-metadata">

**Author:** ![Rabbit](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rabbit/32/25831_2.png) [@Rabbit](https://discourse.codecombat.com/u/Rabbit)\
**Post date:** [September 25, 2021, 10:32pm UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628/14 "2021-09-25T22:32:49Z")

</div>

I know it is the problem @cheddarcheese but I can’t fix it

---

<div class="post-metadata">

**Author:** ![cheddarcheese](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/cheddarcheese/32/22417_2.png) [@cheddarcheese](https://discourse.codecombat.com/u/cheddarcheese)\
**Post date:** [September 25, 2021, 10:47pm UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628/15 "2021-09-25T22:47:11Z")

</div>

no one can fix it not even me

---

<div class="post-metadata">

**Author:** ![Rabbit](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rabbit/32/25831_2.png) [@Rabbit](https://discourse.codecombat.com/u/Rabbit)\
**Post date:** [September 25, 2021, 10:49pm UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628/16 "2021-09-25T22:49:17Z")

</div>

I hope someone will remove some ogres

---

<div class="post-metadata">

**Author:** ![moonwatcher348](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/moonwatcher348/32/24126_2.png) [@moonwatcher348](https://discourse.codecombat.com/u/moonwatcher348)\
**Post date:** [September 27, 2021, 2:27am UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628/17 "2021-09-27T02:27:41Z")

</div>

No, it shouldn’t.

---

<div class="post-metadata">

**Author:** ![Rabbit](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rabbit/32/25831_2.png) [@Rabbit](https://discourse.codecombat.com/u/Rabbit)\
**Post date:** [September 27, 2021, 2:28am UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628/18 "2021-09-27T02:28:55Z")

</div>

Maybe someone should remove some ogres

---

<div class="post-metadata">

**Author:** ![moonwatcher348](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/moonwatcher348/32/24126_2.png) [@moonwatcher348](https://discourse.codecombat.com/u/moonwatcher348)\
**Post date:** [September 27, 2021, 2:29am UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628/19 "2021-09-27T02:29:37Z")

</div>

Create a function called whatever you want (e.x: do)  
So do something like:

```python
def do (b):
    while True:
        if hero.isReady(‘heart-shield’):
            hero.heartShield()
        else:
            hero.shield()
        if hero.gold >= 25:
            hero.buildXY(“decoy”, hero.pos.x, hero.pos.y)

```

---

<div class="post-metadata">

**Author:** ![moonwatcher348](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/moonwatcher348/32/24126_2.png) [@moonwatcher348](https://discourse.codecombat.com/u/moonwatcher348)\
**Post date:** [September 27, 2021, 2:31am UTC](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628/20 "2021-09-27T02:31:51Z")

</div>

Then add

```python
    if b: return

```

to the start of the function.  
And _then_ add

```python
        hero.wait(0)
        do(True)

```

to the end of the while loop. That should trick the ‘infinite-loop’ error. 😁

[Next page](https://discourse.codecombat.com/t/bug-in-kthgard-brawl/30628.md?page=2)
