diff --git a/EA/fitness.py b/EA/fitness.py index e1558ae..31801c9 100644 --- a/EA/fitness.py +++ b/EA/fitness.py @@ -15,24 +15,15 @@ def evaluate_deck_by_wins(individual): decklist = genome_to_decklist(individual) filename = "candidate.dck" write_decklist(ct.CARD_DIRECTORY + filename, decklist) - total_damage = 0 wins = 0 - # colors,lands = colorsymbols_in_deck(CARDS, decklist) for opponent in ct.OPPONENTS: cmd = build_cmd(filename, opponent, ct.MATCHES_PER_OPPONENT) p = subprocess.Popen(cmd, cwd=ct.FORGE_PATH, stdout=subprocess.PIPE) for line in p.stdout: line = line.decode("utf-8").strip() - #print(line) - # if 'combat damage to Ai(2' in line: - # hit_event = line.split(' ') - # # print(hit_event) #For debugging - # damage_index = hit_event.index('deals') + 1 - # damage = int(hit_event[damage_index]) - # total_damage += damage if 'Match result' in line: result = line.split(' ') wins += int(result[3]) p.wait() - fitness = wins # (wins/float(MATCHES_PER_OPPONENT*len(opponents)))*damage + fitness = wins return fitness, # MUST BE TUPLE! diff --git a/EA/logger.py b/EA/logger.py index ef3c838..852752f 100644 --- a/EA/logger.py +++ b/EA/logger.py @@ -55,8 +55,7 @@ def write_log(top_list, median_list, worst_list, global_maximum, time_to_complet def write_graph(top_list, median_list, worst_list, filename): - - plt.plot((top_list), 'blue') + plt.plot(top_list, 'blue') plt.plot(median_list, 'green') plt.plot(worst_list, 'red') plt.xlabel('Generations') diff --git a/EA/main.py b/EA/main.py index a06b980..5b3e702 100644 --- a/EA/main.py +++ b/EA/main.py @@ -70,8 +70,9 @@ def mate_individuals(ind1, ind2): def main(): # TODO: VELG BREEDING OG MUTASJONSSTRATEGI - + number_of_matches = int(ct.MATCHES_PER_OPPONENT) * len(ct.OPPONENTS) * ct.NUMBER_OF_GENERATIONS * ct.POPSIZE print('Starting experiment {}'.format(ct.EXPERIMENT_TIMESTAMP)) + print('Doing {} matches'.format(number_of_matches)) start_time = time.time() first_gen_decks = generate_first_generation_decks(ct.CARD_POOL)