diff --git a/.gitignore b/.gitignore index 00983fe..ba0430d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -/__pycache__/ \ No newline at end of file +__pycache__/ \ No newline at end of file diff --git a/GenTunic/gen_tuning.py b/GenTunic/gen_tuning.py index 43036e8..b61ae0b 100644 --- a/GenTunic/gen_tuning.py +++ b/GenTunic/gen_tuning.py @@ -21,8 +21,10 @@ def gen_tuning_main(AMOUNT_TRIES, AMOUNT_RUNS, REWARD_ON_WIN, REWARD_ON_LOSE): best_fintess_values = [] best_fitness = 0 + counter = 0 while True: + print(f"Starting eveloution round {counter + 1}") #? Calc fitness population_propability, fintess_values = calc_population_fitness(population, AMOUNT_TRIES, AMOUNT_RUNS, REWARD_ON_WIN, REWARD_ON_LOSE) @@ -46,6 +48,8 @@ def gen_tuning_main(AMOUNT_TRIES, AMOUNT_RUNS, REWARD_ON_WIN, REWARD_ON_LOSE): #? Mutation population = mutation(new_population, MUTATION_RATE, GEN_SIZE) + counter += 1 + population_propability, fintess_values = calc_population_fitness(population, AMOUNT_TRIES, AMOUNT_RUNS, REWARD_ON_WIN, REWARD_ON_LOSE) best_fintess_index, best_fitness = fintess_values diff --git a/GenTunic/gen_util.py b/GenTunic/gen_util.py index 4704184..f6304a3 100644 --- a/GenTunic/gen_util.py +++ b/GenTunic/gen_util.py @@ -19,7 +19,7 @@ def create_population(size, GEN_SIZE): def calc_population_fitness(population_propability, AMOUNT_TRIES, AMOUNT_RUNS, REWARD_ON_WIN, REWARD_ON_LOSE): population_fitness_sum = 0 - for individual in population_propability: + for i, individual in enumerate(population_propability): gen = individual["population"] alpha, epsilon, gamma = [project_bit(x) for x in np.split(gen, 3)] _, multiple_tries_win_prob = multipleTries(alpha, epsilon, gamma, AMOUNT_TRIES, AMOUNT_RUNS, REWARD_ON_WIN, REWARD_ON_LOSE) @@ -28,6 +28,8 @@ def calc_population_fitness(population_propability, AMOUNT_TRIES, AMOUNT_RUNS, R individual["probability"] = fitness population_fitness_sum += fitness + print(f"{i}: {fitness}") + best_fitness_index = np.argmax(population_propability["probability"]) best_fitness = population_propability[best_fitness_index]["probability"] diff --git a/ReinforcmentLearning/learning.py b/ReinforcmentLearning/learning.py index 44f8d33..f5a94d4 100644 --- a/ReinforcmentLearning/learning.py +++ b/ReinforcmentLearning/learning.py @@ -7,7 +7,6 @@ from ReinforcmentLearning.util import initial_q_fill - def multipleTries(EPSILON, ALPHA, GAMMA, AMOUNT_TRIES, AMOUNT_RUNS, REWARD_ON_WIN, REWARD_ON_LOSE): cookies_per_try = [] wins_per_try = []