예제 #1
0
 def __init__(self):
     self.num_of_vehs = 10
     self.vehicles = []
     for i in range(self.num_of_vehs):
         self.vehicles.append(
             Vehicle(random_uniform(width), random_uniform(height)))
     self.debug = False
예제 #2
0
파일: Evolver.py 프로젝트: asaph96/Evolver
 def clone(self, w, h):
     if random_uniform(1) < self.clone_rate and self.health > 0.9:
         x = random_uniform(w)
         y = random_uniform(h)
         print("Hey, cloned")
         return Evolver(x, y, self.dna)
     else:
         return False
예제 #3
0
 def populate(self):
     self.points = []
     self.points.append(self.first_point)
     for point in range(self.num_of_paths):
         self.points.append(
             Vector(((point + 1) * width / self.num_of_paths),
                    random_uniform(height, 0)))
예제 #4
0
def setup():
    size(640, 360)
    no_stroke()
    background(0)
    global perlx
    global perly
    perlx = random_uniform(1000)
    perly = 0
예제 #5
0
파일: Evolver.py 프로젝트: asaph96/Evolver
    def __init__(self, x, y, dna=False):

        self.pos = Vector(x, y)
        self.acc = Vector(0, 0)
        self.vel = Vector(0, -2)
        self.__health = 1

        if not dna:
            self.dna = []
            for _ in range(4):
                self.dna.append(random_uniform(-2, 2))
        else:
            self.dna = []
            for gene in dna:
                if random_uniform(1) < self.mutation_rate:
                    self.dna.append((gene + random_uniform(-1, 1)) / 2)
                else:
                    self.dna.append(gene)
예제 #6
0
파일: sentence.py 프로젝트: mahubu/poepy
 def disperse(self):
     """
     Move the letter randomly on the window.
     """
     self.x += random_uniform(-2, 2)
     self.y += random_uniform(-2, 2)
예제 #7
0
 def __init__(self, num_of_paths=4):
     self.num_of_paths = num_of_paths
     self.radius = 5
     self.first_point = Vector(0, random_uniform(height, 0))
     self.points = []
예제 #8
0
파일: evolver.py 프로젝트: asaph96/apm-test
 def generate_random_dna():
     alelos = [random_uniform(-1, 1) for _ in range(4)]
     dna = DNA(alelos)
     return dna
예제 #9
0
 def update_path(self):
     self.point_a = Vector(0, random_uniform(height))
     self.point_b = Vector(width, random_uniform(height))