Skip to content

Instantly share code, notes, and snippets.

@fyr91
Last active October 3, 2019 10:34
Show Gist options
  • Save fyr91/3bb536e1ed9de5aa2169d25ff626cfb4 to your computer and use it in GitHub Desktop.
Save fyr91/3bb536e1ed9de5aa2169d25ff626cfb4 to your computer and use it in GitHub Desktop.
import numpy as np
import namegenerator
from copy import deepcopy
# dummy lineup class
class Lineup:
def __init__(self, score, gene=''):
# name only used to differentiate the lineup
self.name = namegenerator.gen()
if len(gene):
self.gene = gene
else:
self.gene = np.random.randint(2, size=20)
self.combat_power = np.count_nonzero(self.gene == 1)
self.score = score
def to_dict(self):
return {"name": self.name,
"gene": ''.join(list(map(str, self.gene))),
"combat_power": self.combat_power,
"score": self.score}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment