Stillness in Motion Python

    enemy = self.findNearestEnemy()
    if enemy:
        self.distanceTo(enemy) < 5
    if enemy:
        self.distanceTo(enemy) > 5
        self.moveXY(40, 34)

This is my code for Stillness in motion. I have no clue what is wrong but it’s not working. Sorry if it’s not formatted right but I’m short on time and am in ICT class at school. If someone could lend a hand that’d be great.


The FAQ specifically says “Read Before Posting”. If you didn’t read the FAQ, then you shouldn’t be posting. I will do it for you this time, but don’t post again until you have read the FAQ.

I’ll go through your code line by line:

Line 4: self..distanceTo(enemy) < something returns a boolean that states whether it is true or not. This should be an if-statement.

Line 7: See line 4.


What do you mean by it should be an if-statement. I have if enemy: as my if, but I end up walking over to the head hunters instead.


@ChronistGilver means instead of:

if enemy:
self.distanceTo(enemy) < 5:

It would turn into:

if enemy and self.distanceTo(enemy) < 5:


I finally got it. Thank you so very much.