import sys from creatures import Dragon import mpi from math import * import traceback from util import * class Squatter(Dragon): # self.Actions # GetBreath # GetFlyingDirection # GetFlyingPosition # ScanHorizon [Range] # SetFlyingDirection [self.Direction.East, self.Direction.NorthEast, etc.] # self.Direction.ToString(), self.Direction.FromString() # BreatheFire [Power] # Fly [distance] def action(self): pos = doMpi(self,self.Actions.GetFlyingPosition,[]) x,y = (pos.x,pos.y) fdir = doMpi(self,self.Actions.GetFlyingDirection,[]) result = doMpi(self,self.Actions.ScanHorizon,[7]) for en in result: (ex,ey) = en['coords'] # returns list of actions to take in order to hit the target tl = fireAt(self,fdir,x,y,ex,ey) if len(tl) == 1: # one thing, it must be a turn doMpi(self,tl[0][0],tl[0][1]) if len(tl) <= 1: # zero or one thing, we can hit! doMpi(self,self.Actions.BreatheFire,[10])