Skip to content

Instantly share code, notes, and snippets.

@fyr91
Last active October 3, 2019 06:54
Show Gist options
  • Save fyr91/cabfb9b03b393e8b9f4346ba839dad92 to your computer and use it in GitHub Desktop.
Save fyr91/cabfb9b03b393e8b9f4346ba839dad92 to your computer and use it in GitHub Desktop.
dummpy ga
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