def test_award(self): """ can we award a single winner the entire pot? """ pot = analyze.setup(self.table) analyze.order(pot) analyze.flush(pot) analyze.convert_to_card_value(pot) analyze.matching(pot) analyze.compare(pot) analyze.award(pot, self.table.sb_amount) self.assertTrue(self.player1.stack == 200) self.assertTrue(len(pot.players) == 1)
def test_compare(self): """ Can we determine a single winner? """ pot = analyze.setup(self.table) analyze.order(pot) analyze.flush(pot) analyze.convert_to_card_value(pot) analyze.matching(pot) analyze.compare(pot) expected = self.player1 self.assertEqual(expected, pot.players[-1]) self.assertTrue(len(pot.players) == 1)
def test_compare_multiple(self): """ if there are multiple winners do we return all of them? """ pot = analyze.setup(self.table) pot.players[1].hole_cards[0].value = 14 pot.players[1].hole_cards[0].suit = 'h' pot.players[1].hole_cards[1].value = 13 pot.players[1].hole_cards[1].suit = 'h' analyze.order(pot) analyze.flush(pot) analyze.convert_to_card_value(pot) analyze.matching(pot) analyze.compare(pot) expected = [self.player1, self.player2] self.assertEqual(expected, pot.players)
def test_award_multiple(self): """ Can we pay out evenly to multiple winners """ pot = analyze.setup(self.table) pot.players[1].hole_cards[0].value = 14 pot.players[1].hole_cards[0].suit = 'h' pot.players[1].hole_cards[1].value = 13 pot.players[1].hole_cards[1].suit = 'h' analyze.order(pot) analyze.flush(pot) analyze.convert_to_card_value(pot) analyze.matching(pot) analyze.compare(pot) analyze.award(pot, self.table.sb_amount) expected = [self.player1, self.player2] self.assertEqual(expected, pot.players)
def test_award_indivisible(self): """Can we properly pay pots that don't divide evenly?""" pot = analyze.setup(self.table) pot.amount = 101 pot.players[1].hole_cards[0].value = 14 pot.players[1].hole_cards[0].suit = 'h' pot.players[1].hole_cards[1].value = 13 pot.players[1].hole_cards[1].suit = 'h' analyze.order(pot) analyze.flush(pot) analyze.convert_to_card_value(pot) analyze.matching(pot) analyze.compare(pot) analyze.award(pot, self.table.sb_amount) expected1 = 151 expected2 = 150 self.assertEqual(expected1, pot.players[0].stack) self.assertEqual(expected2, pot.players[1].stack)
def compare_against_ddb(): data_json = json.loads(request.data) decklist = data_json["decklist"] identity = data_json["identity"] clean_decklist = {} for card in decklist.split("\n"): if card: clean_card = " ".join(card.split()[1:]) clean_decklist[normalize(clean_card)] = clean_card if not clean_decklist: fetch_result = ("No decklist provided! Fetch via decklist " "URL or paste in above text box.") else: fetch_result = compare(clean_decklist, identity) time.sleep(1) return Response(fetch_result, status=200, mimetype="application/json")
y_train = np.array(y_train) y_test = np.array(y_test) X_train = sequence.pad_sequences(X_train, padding="post", maxlen=max_sample_length + pad) X_test = sequence.pad_sequences(X_test, padding="post", maxlen=max_sample_length + pad) y_train = sequence.pad_sequences(y_train, padding="post", maxlen=max_sample_length) y_test = sequence.pad_sequences(y_test, padding="post", maxlen=max_sample_length) # train for j in range(3): model.fit(X_train, y_train, epochs=10, batch_size=50) X_train, y_train = shuffle(X_train, y_train, random_state=1) # test after every epoch y_hat = model.predict(X_test) compare(y_hat, y_test) accuracy(y_hat, y_test) # serialize model to JSON at the end of training model_json = model.to_json() with open(models + "model_" + str(i) + ".json", "w") as json_file: json_file.write(model_json) # serialize weights to HDF5 model.save_weights(models + "model_" + str(i) + ".h5") print "Saved model to disk"