Beispiel #1
0
    def update(self):
        RaceGame.update(self)

        if self.is_broken:
            self.training_car()
            self.car.restart()
            self.training_group = []
            self.step = 0
        else:
            input = self.collision_sight + [self.car.angle]
            id_output = self.model.train(input)
            self.training_group.append((input, id_output))
            self.step += 1

            if self.step == 300:
                self.model.save('car_model.dat')

            self.car.update(delta_angle=self.delta_angle[id_output])
Beispiel #2
0
    def update(self):
        RaceGame.update(self)

        if self.is_broken:
            self.training_car()
            self.car.restart()
            self.training_group = []
            self.step = 0
        else:
            input = self.collision_sight + [self.car.angle]
            id_output = self.model.train(input)
            self.training_group.append((input, id_output))
            self.step += 1

            if self.step == 300:
                self.model.save('car_model.dat')

            self.car.update(delta_angle=self.delta_angle[id_output])
Beispiel #3
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]))
Beispiel #4
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]))