Skip to content

Instantly share code, notes, and snippets.

@ahmedfgad
Created October 3, 2021 21:15
Show Gist options
  • Save ahmedfgad/2601f1d5ef8c274a391cbfee230e5f5d to your computer and use it in GitHub Desktop.
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
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