Issue with Peasant Protection

I recently tried to rebeat Peasant Protection, and even after following the instructions I had trouble.
Here is my code:

while True:
    enemy = hero.findNearestEnemy()
    distance = hero.distanceTo(enemy)
    if distance < 10:
        # Attack if they get too close to the peasant.
    # Else, stay close to the peasant! Use else.
        self.moveXY(40, 37)

as you can see, I did what the instructions said, but no matter what i did my code didn’t seem to work. the hints didn’t help either.

1 Like

Do you get some errors? Could you explain "doesn’t work?

1 Like

@Autri_Basu what kind of sword are you using? I used your code and won the level using the long sword so I am not sure what is happening on your end. Are you using a warrior class to play?

Make sure you can defeat each munchkin with 1 attack and try resubmitting.


I also used a long sword and these to:

Screenshot 2020-09-15 at 2.25.01 PM

Are you asking for help? Or are you just saying that you used the Long Sword for this level, because if you are, please do not revive dead topics.

I was asking for help but I gave up and just looked up a walk through for on YouTube so
not anymore no. :slightly_smiling_face:

20 characters

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.