Skip to content

Commit

Permalink
minor stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
sverrejb committed Mar 23, 2017
1 parent b03bb06 commit 60b1859
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
11 changes: 1 addition & 10 deletions EA/fitness.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!
3 changes: 1 addition & 2 deletions EA/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
3 changes: 2 additions & 1 deletion EA/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 60b1859

Please sign in to comment.