def statistics(self, db): cards = [db.cards.find({'name':c}).limit(1)[0] for c in self.__count__] mana_curve = bag(lambda: 0) for c in cards: mana_curve[sum(c["cost"][a] for a in c["cost"])] += 1 types = bag(lambda: 0) for c in cards: types[c["types"][0]] += 1
def statistics(self, db): cards = [ db.cards.find({ 'name': c }).limit(1)[0] for c in self.__count__ ] mana_curve = bag(lambda: 0) for c in cards: mana_curve[sum(c["cost"][a] for a in c["cost"])] += 1 types = bag(lambda: 0) for c in cards: types[c["types"][0]] += 1
def main(): parser = SafeConfigParser() parser.read('settings.ini') connection = Connection(parser.get('mongodb', 'server')) db = None exec('db = connection.' + parser.get('mongodb', 'db')) ai = mc(db, "markov", exp=1.2) deck = [] for i in range(100): c = ai.get() if(isinstance(c, type(""))): deck.append(c) deck.sort() deck_clean = bag(lambda: 0) for c in deck: deck_clean[c] += 1 for c in set(deck): print ("%2i %s" % (deck_clean[c], c))
def main(): parser = SafeConfigParser() parser.read('settings.ini') connection = Connection(parser.get('mongodb', 'server')) db = None exec('db = connection.' + parser.get('mongodb', 'db')) ai = mc(db, "markov", exp=1.2) deck = [] for i in range(100): c = ai.get() if (isinstance(c, type(""))): deck.append(c) deck.sort() deck_clean = bag(lambda: 0) for c in deck: deck_clean[c] += 1 for c in set(deck): print("%2i %s" % (deck_clean[c], c))
def parse(self, s): b = bag(lambda: 0) s = re.sub(r'\r\n', '\n', s) lines = re.split(r'\n', s) for l in lines: m = re.match('//', l) if m is None: l = re.sub(r'SB: ', '', l) l = re.sub(r' +', ' ', l) l = re.sub(r'^ +', '', l) l = l.split(" ") card_name = ' '.join(l[1::]) count = l[0] if(verbose): print(l, card_name, count) if l and (not False in [bool(a) for a in l]): try: s = ' '.join(l[1::]).strip('.') b[s] += int(l[0]) except: raise ParseError("Unable to parse the deck") b['sum'] = sum(b[i] for i in b if isinstance(b[i], int)) self.__count__ = deck return deck
def parse(self, s): b = bag(lambda: 0) s = re.sub(r'\r\n', '\n', s) lines = re.split(r'\n', s) for l in lines: m = re.match('//', l) if m is None: l = re.sub(r'SB: ', '', l) l = re.sub(r' +', ' ', l) l = re.sub(r'^ +', '', l) l = l.split(" ") card_name = ' '.join(l[1::]) count = l[0] if (verbose): print(l, card_name, count) if l and (not False in [bool(a) for a in l]): try: s = ' '.join(l[1::]).strip('.') b[s] += int(l[0]) except: raise ParseError("Unable to parse the deck") b['sum'] = sum(b[i] for i in b if isinstance(b[i], int)) self.__count__ = deck return deck
def generate(self, count=60, exp=1.2, table='markov'): self.__deck__ = bag(lambda: 0) ai = mc(self.__db__, table, exp=exp) for i in range(count): a = ai.get() self.__deck__[a] += 1 if a.name not in self.__cards__: self.__cards__[name] = a return self.__deck__
def generate(self, count=60, table='markov', ): self.__deck__ = bag(lambda: 0) ai = mc(self.__db__, table, exp=exp) for i in range(int(count * (2/3))): while 1: c = ai.get() if c not in land_ai.__lands__: self.__deck__[c] += 1 break v = land_ai.input_vector(self.__deck__, self.__db__) net = pickle.load(open(parser.get('land_net', 'brain'))) ov = net.activate(v) for i in range(len(land_ai.__lands__)): self.__deck__[land_ai.__lands__[i]] = int(ov[i]*count*0.33333333334) return self.__deck__
def __init__(self, db, restrict=None, seed=None): self.__restrict__ = restric self.__seed__ = seed self.__db__ = db self.__deck__ = bag(lambda: 0)
def __init__(self, deck={}): self.__deck__ = deck self.__count__ = bag(lambda: 0)