コード例 #1
0
    def setUp(self) -> None:
        self.brain_pop = [brains.NeuralBrain(None) for _ in range(10)]

        self.window = gui.GameWindow(width=config.width, height=config.height)
        self.t = gui.DrawingTrack(window=self.window,
                                  batch=self.window.fixed_batch,
                                  track_json=load.tracks[0])
コード例 #2
0
ファイル: main.py プロジェクト: MikeOfZen/GeneticCars
 def single_experiment_drawn(self):
     window = gui.GameWindow(width=config.width, height=config.height)
     t = gui.DrawingTrack(window=window,
                          batch=window.fixed_batch,
                          track=self.track_json)
     e = experiment.DrawnExperiment(window=window,
                                    batch=window.new_activity_batch(),
                                    track=t,
                                    brain_pop=self.population)
     window.activity = e.step
     window.start()
     del window
     results = e.experiment_results()
     print("Fitness results" + "\n".join([{x[0]} + "-" + {x[1]}
                                          for x in results]))
コード例 #3
0
ファイル: main.py プロジェクト: MikeOfZen/GeneticCars
    def evolution_drawn(self):
        generations_to_run = input_with_conditions(
            "Please input number of generations to evolve [1-500]", int,
            [lambda x: x > 0, lambda x: x < 500])
        window = gui.GameWindow(width=config.width,
                                height=config.height,
                                close_on_finish=False)
        t = gui.DrawingTrack(window=window,
                             batch=window.fixed_batch,
                             track=self.track_json)

        ev = evolution.DrawnEvolution(self.population,
                                      t,
                                      generations_to_run,
                                      window,
                                      genetics=self.genetics)
        temp_population = ev.run()

        save = input_with_conditions("Accept evolution results (y/n)", str,
                                     [lambda x: x in ["y", "n"]])
        save = True if save == "y" else False
        if save:
            self.population.clear()
            self.population.extend(temp_population)