示例#1
0
 def mutate(self):
     mutationRate = 0.01  #Chance that vector gets changed
     for i in range(len(self.instructions)):
         rand = random.random()
         if (rand < mutationRate):
             self.instructions[i] = Vector2D.fromAngle(
                 random.random() * 2 *
                 math.pi)  #Set direction to random angle
示例#2
0
 def __init__(self, count) -> None:
     self.instructions = [
         Vector2D.fromAngle(random.random() * 2 * math.pi)
         for _ in range(count)
     ]
     self.step = 0