Ok, ok, ok let’s back it up a bit here. How far are you? That code in VERY limited and will accomplish nothing. First you want a loop where you constantly define :“flag”
loop:
flag=self.findFlag()
Then you want to move to that flag.
if flag:
self.moveXY(flag.pos.x,flag.pos.y) or self.move(flag.pos)
But honestly I don’t see the use of flags for this level.
Do that same as above except with items to collect gold.
loop:
item= self.findNearest(self.findItems())
Then you can be creative and attack attack, projectile dodging etc…