Ejemplo n.º 1
0
 def __init__(self,parent_genes,initial_location,initial_energy,phenotype,parent_direction):
     self.location = initial_location
     self.genes=parent_genes  
     self.energy = initial_energy
     self.phenotype=phenotype
     self.direction=parent_direction 
     self.forwards=MIRROR_COORDS[tuple(map(operator.add, self.location , self.direction))]
     self.right=MIRROR_COORDS[tuple(map(operator.add, self.location , rotate(self.direction,1)))]
     self.left=MIRROR_COORDS[tuple(map(operator.add, self.location , rotate(self.direction,5)))]
Ejemplo n.º 2
0
 def turn(self,right=True):
     x,y,z=self.direction
     if right: # two wrongs don't make a right,
         self.direction=rotate(self.direction,1) 
         
     else:   # but five rights make a left!
         self.direction=rotate(self.direction,5) 
     self.forwards=MIRROR_COORDS[tuple(map(operator.add, self.location , self.direction))]
     self.right=MIRROR_COORDS[tuple(map(operator.add, self.location , rotate(self.direction,1)))]
     self.left=MIRROR_COORDS[tuple(map(operator.add, self.location , rotate(self.direction,5)))]    
     
     self.pay_energy(TURN_COST)#p0009