Created
October 3, 2021 21:15
-
-
Save ahmedfgad/2601f1d5ef8c274a391cbfee230e5f5d to your computer and use it in GitHub Desktop.
Thread to Run PyGAD in the Background // Play the Flappy Bird Game using PyGAD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygad | |
import threading | |
class PygadThread(threading.Thread): | |
def __init__(self): | |
super().__init__() | |
def run(self): | |
ga_instance = pygad.GA(num_generations=200000, | |
sol_per_pop=200, | |
num_parents_mating=100, | |
num_genes=1, | |
fitness_func=fitness_func, | |
init_range_low=100.0, | |
init_range_high=200.0, | |
random_mutation_min_val=40.0, | |
random_mutation_max_val=350.0, | |
mutation_by_replacement=True, | |
on_generation=on_generation, | |
suppress_warnings=True, | |
delay_after_gen=0.01) | |
ga_instance.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment