loop:
flag=self.findFlag(“green”)
if flag:
self.pickUpFlag(flag)
else:
enemy = self.findNearestEnemy()
If there is an enemy, then…
if enemy:
# If the enemy is less than 5 meters away, then attack()
distance = self.distanceTo(enemy)
if distance < 5:
if self.isReady("cleave"):
self.cleave(enemy)
else:
self.attack(enemy)
else:
# Otherwise (the enemy is far away), then shield()
pass
self.shield()
# Otherwise (there is no enemy...)
if enemy:
# then move back to the X
self.moveXY(40, 34)