Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/scoop' into scoop
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAlbion committed Mar 23, 2017
2 parents 24bffcd + 60b1859 commit db9c76e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 48 deletions.
4 changes: 2 additions & 2 deletions EA/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
CARD_DIRECTORY = config.CARD_DIR
FORGE_PATH = config.FORGE_DIR
DECKLIST_HEADER = '[metadata]\nName=candidate\n[Main]\n'
OPPONENTS = ["GB-sealed-opponent.dck", "UWg-sealed-opponent.dck", "RG-sealed-opponent1.dck"
OPPONENTS = ["GB-sealed-opponent.dck", "UWg-sealed-opponent.dck", "RG-sealed-opponent1.dck",
"BGw-sealed-opponent.dck", "UR-sealed-opponent.dck", "RW-sealed-opponent.dck"]
EXPERIMENT_TIMESTAMP = datetime.datetime.now().strftime("%d%m%H%M")
EXPERIMENT_FOLDER = "results/" + EXPERIMENT_TIMESTAMP
CARDS = read_cards_json()
# CARDS = read_cards_json()
10 changes: 1 addition & 9 deletions EA/fitness.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +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
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!
34 changes: 0 additions & 34 deletions EA/helloworld.py

This file was deleted.

3 changes: 1 addition & 2 deletions EA/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,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 db9c76e

Please sign in to comment.