Level: Peasant Protection


#112

@JIAN_WEN_CHIN You can see the forum staff in the About section.


#113

So he is not one of their staff


#114

Yeah, but I don’t think that’s very relevant. The forums are public, so anyone can help others and can even help moderating the forum by flagging posts that require staff intervention.


#117

Can someone help? We are trying to open this level and we can’t get it to load. The level before it, and the level after it seem to load fine.

I tried to post the log, but it says as a new user I can’t have more than 2 links!

Thanks!


#118

Hello,

I am new to this game and a bit frustrated. I read all of the above discussions, and the code I’m using is the same as code that is said to work many times above, namely:

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

The hints pretty much say to do this exactly (even though, as an experienced programmer, this logic doesn’t really make sense to me…it says if the distance to the nearest enemy is less than 10, then attack, whereas it would make much more sense if it was the distance from the enemy to the peasant - of course that would involve some more complicated maths…anyway).

Anyway, it seems to me that the problem is my hero has a wand, and it’s just too slow to kill anything. I don’t want to spend gems on the wrong weapon having discovered the hard way that gems can cost actual money…

Can someone tell me what weapon I need to buy, or otherwise, what the problem is?

Thanks,


#119

Ok, never mind. We didn’t realise we could still use the old “fighter” hero. When we switched the fighter with a sword, all the ogres died. Great!


#121

I absolutely can not beat this level. I have tried everything mentioned above and nothing works. I normally use Python. It has seemingly glitched out. Everything from past attempts is playing at once.

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

#122

I checked the level and its initial code is:

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

I think the first lines must be:

    enemy = hero.findNearestEnemy() 
    # delete  distance = hero.distanceTo(enemy)
    # you don't know if the enemy exists
    # you cannot measure  a distance to non existent enemy 
    if enemy and hero.distanceTo(enemy) < 10:

If you cannot pass the level with these corrections you maybe are using a very simple sword.
Try to be max closer to the peasant ( increase the y coordinate)


#123

What happens when you run your code? Your code works for me. As xython said, this may be an equipment problem.