I need help on A Mayhem of Munchkins

I’m stuck on this level.
I’m coding in Python and I am new to this game.
If any would help me that would be great!

1 Like

So far my code is this:
enemy1 = self.findNearestEnemy()
loop:
self.attack(enemy1)
self.moveUp()
self.attack(enemy1)

1 Like

Try putting your enemy1 = self.findNearestEnemy() inside your loop–otherwise it will never update.

1 Like

Thanks bro! :smile: I will try doing this when I get the time! But really, thanks very much!

1 Like

Also get rid of self.MoveUp() it is useless :smiley:

1 Like

This topic is dead. I’m pretty sure two months later he’s solved it, otherwise he would’ve asked for more help. Leave the dead topic(s) alone. It’s not Halloween anymore.

2 Likes

well i found these comments very helpful except yours

1 Like

Except that you should have. Emphasis added:

You may not have noticed, but you have just revived a 6 months old dead thread adding a completely unhelpful comment as well. And now we have this dead topic polluting the front page again, oh well.

2 Likes

your codes are more than four lines.

i can’t kill all ogres

my code is this:
while True:
enemy = hero.findNearestenemy()
hero.attack (enemy)

but these codes didn’t work perfectly
i can’t reach the third goad of defeating the ogres.

Hi!

I’ve got problem in the same part of the game and I’m stuck for the 2nd day in a row.
I’ve already tried writing the code just as you did in the above-mentioned section by TGKYT. However, mine still does not work. Either it does not accept the find.NearesEnemy-code or I get “There is too much identification” -message. (I also wrote that in loop format at the appropriate parts.)

Can you please give me advice or a possible solution for that?

Please post your code, and format it by surrounding it with 3x backticks ( ` ) on the top and bottom, so we can see your indentation.

If you want to look at previous levels for help, check our Fire Dancing for hints on while-loops, and Master of Names for help finding the nearest enemy and attacking it.

Also if you click the Hints button, there are a lot of docs for that particular level with lots of code snippets. The API docs also expand out when you click on them, and with a sword and book equipped should have enough sample code to get you going in the right direction.

1 Like

My code is the following:
while True:
in loop:
enemy1 = findNearestEnemy(enemy1)
self.attack(enemy1)
self.moveUp

Thank you for the tips! :slight_smile: