Ejemplo n.º 1
0
    def update(self):
        RaceGame.update(self)

        self.step_record[self.model_id] += 1
        if self.is_broken:
            self.model_id += 1
            if self.model_id == len(self.chromosome_weight):
                self.evaluation()
                self.selection()
                self.crossover()
                self.mutation()

                self.step_record = [0] * len(self.chromosome_weight)
                self.model_id = 0

            self.model = self.get_model(self.chromosome_weight[self.model_id])
            self.car.restart()
        else:
            self.car.update(delta_angle=self.get_angle(self.collision_sight + [self.car.angle]))
Ejemplo n.º 2
0
    def __init__(self):
        self.delta_angle = [-0.03, -0.02, -0.01, 0, 0.01, 0.02, 0.03]
        self.nn_nodes = [5, 8, 5, 7]
        self.start()

        RaceGame.__init__(self)