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
def __init__(self, count) -> None: self.instructions = [ Vector2D.fromAngle(random.random() * 2 * math.pi) for _ in range(count) ] self.step = 0