I’m really getting frustrated by the level “Peasant protection”. The code is correct (I checked the forum for similar issues), but I still end up with the farmer getting killed.
Here’s the code:
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: # Else, stay close to the peasant! Use else. hero.moveXY(40, 37)
The code works as expected. My hero kills two or three enemies, but then one of the attackers manages to kill the peasant, right before my hero kills the attacker.
I tried to fiddle with the distance (anything between 10 and 20) and also with the moveXY coordinates (forum mentions 40,38 regularly, but the in-game hints say it should be 40, 37).
Is there anyone else who has had this??? This is really frustrating, because it is blocking and has nothing to do with good programming (unless I missed something?)