Last active
October 3, 2019 06:54
-
-
Save fyr91/cabfb9b03b393e8b9f4346ba839dad92 to your computer and use it in GitHub Desktop.
dummpy ga
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if __name__ == "__main__": | |
lineups = [] | |
generation_size = 20 | |
# initialize 20 lineups with initial score 50 | |
for i in range(generation_size): | |
lineups.append(Lineup(50)) | |
# form battle pairs | |
pairs = np.random.choice(lineups, size=(int(generation_size/2),2), replace=False) | |
# fight | |
battles = [] | |
for pair in pairs: | |
battles.append(fight(pair)) | |
# evaluate | |
list(map(evaluate, battles)) | |
# check linup dictionaries sorted by key score | |
lineup_dict_list = list(map((lambda x: x.to_dict()), lineups)) | |
list(map(print, sorted(lineup_dict_list, key=lambda k: k['score'], reverse=True))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment