I need help on A Mayhem of Munchkins


#1

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!


#2

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


#3

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


#4

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


#5

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


#6

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.


#7

well i found these comments very helpful except yours


#8

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.


#9

your codes are more than four lines.


#10

i can’t kill all ogres


#11

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.


#12

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?


#13

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.


#14

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

Thank you for the tips! :slight_smile: