Esempio n. 1
0
    def test_should_fold_AQ_on_flop_after_calling_3bet_pre_when_having_high_card(
            self):

        hand = list()
        hand.append(Card(figure=Figure.Ace, color=Color.Spade))
        hand.append(Card(figure=Figure.Queen, color=Color.Spade))
        self.situation.set_hand(hand)

        self.situation.ButtonPosition = 1
        self.situation.add_action(2, 0.5)
        self.situation.add_action(3, 1)
        self.situation.add_action(6, 2.4)
        self.situation.add_action(3, 8)

        board = list()
        board.append(Card(figure=Figure.King, color=Color.Spade))
        board.append(Card(figure=Figure.Three, color=Color.Diamond))
        board.append(Card(figure=Figure.Seven, color=Color.Club))

        self.situation.set_board(board)

        self.situation.add_action(3, 7)

        decision = self.startegy.get_decision(situation=self.situation)

        self.assertEqual(decision.decision, Decision.FOLD)
Esempio n. 2
0
    def test_should_fold_turn_with_top_pair_with_4_to_color(self):
        hand = list()
        hand.append(Card(figure=Figure.Ace, color=Color.Spade))
        hand.append(Card(figure=Figure.Queen, color=Color.Spade))
        self.situation.set_hand(hand)

        self.situation.ButtonPosition = 1
        self.situation.add_action(2, 0.5)
        self.situation.add_action(3, 1)
        self.situation.add_action(6, 2.4)

        board = list()
        board.append(Card(figure=Figure.King, color=Color.Diamond))
        board.append(Card(figure=Figure.Three, color=Color.Diamond))
        board.append(Card(figure=Figure.Seven, color=Color.Diamond))

        self.situation.set_board(board)

        self.situation.add_action(6, 3)

        turn = list()
        turn.append(Card(figure=Figure.King, color=Color.Diamond))
        turn.append(Card(figure=Figure.Three, color=Color.Diamond))
        turn.append(Card(figure=Figure.Seven, color=Color.Diamond))
        turn.append(Card(figure=Figure.Ace, color=Color.Diamond))

        self.situation.set_board(turn)

        self.situation.add_action(3, 7)

        decision = self.startegy.get_decision(situation=self.situation)

        self.assertEqual(decision.decision, Decision.FOLD)
Esempio n. 3
0
    def test_should_recognize_top_pair(self):

        self.situation.Board.append(Card(figure=Figure.Queen,color=Color.Spade))
        self.situation.Board.append(Card(figure=Figure.Three,color=Color.Heart))
        self.situation.Board.append(Card(figure=Figure.Ten,color=Color.Club))

        self.situation.Hand.append(Card(figure=Figure.King,color=Color.Spade))
        self.situation.Hand.append(Card(figure=Figure.Queen,color=Color.Club))

        hand = self.evaluator.has_pair(situation=self.situation)
        self.assertEqual(hand, HandType.TopPair)
Esempio n. 4
0
    def test_should_open_AK_preflop_from_CO(self):

        hand = list()
        hand.append(Card(figure=Figure.Ace, color=Color.Spade))
        hand.append(Card(figure=Figure.King, color=Color.Spade))
        self.situation.set_hand(hand)

        self.situation.ButtonPosition = 1

        decision = self.startegy.get_decision(situation=self.situation)

        self.assertEqual(decision.decision, Decision.RAISE)
    def test_should_recognize_openended(self):

        self.situation.Board.append(
            Card(figure=Figure.Queen, color=Color.Spade))
        self.situation.Board.append(
            Card(figure=Figure.Three, color=Color.Heart))
        self.situation.Board.append(Card(figure=Figure.Ten, color=Color.Club))

        self.situation.Hand.append(Card(figure=Figure.King, color=Color.Spade))
        self.situation.Hand.append(Card(figure=Figure.Jack, color=Color.Spade))

        hand = self.evaluator.has_openended(situation=self.situation)
        self.assertEqual(hand, HandPotential.OpenEnded)
    def test_should_recognize_openended_with_ace_as_bottom(self):

        self.situation.Board.append(Card(figure=Figure.Five,
                                         color=Color.Spade))
        self.situation.Board.append(
            Card(figure=Figure.Three, color=Color.Heart))
        self.situation.Board.append(Card(figure=Figure.Four, color=Color.Club))

        self.situation.Hand.append(Card(figure=Figure.King, color=Color.Spade))
        self.situation.Hand.append(Card(figure=Figure.Two, color=Color.Spade))

        hand = self.evaluator.has_openended(situation=self.situation)
        self.assertEqual(hand, HandPotential.OpenEnded)
Esempio n. 7
0
    def test_should_call_open_99_preflop(self):
        hand = list()
        hand.append(Card(figure=Figure.Nine, color=Color.Spade))
        hand.append(Card(figure=Figure.Nine, color=Color.Club))
        self.situation.set_hand(hand)

        self.situation.ButtonPosition = 1
        self.situation.add_action(2, 0.5)
        self.situation.add_action(3, 1)
        self.situation.add_action(4, 2.4)

        decision = self.startegy.get_decision(situation=self.situation)

        self.assertEqual(decision.decision, Decision.CALL)
Esempio n. 8
0
    def test_should_fold_to_3bet_88_preflop(self):
        hand = list()
        hand.append(Card(figure=Figure.Eight, color=Color.Spade))
        hand.append(Card(figure=Figure.Eight, color=Color.Club))
        self.situation.set_hand(hand)

        self.situation.ButtonPosition = 1
        self.situation.add_action(2, 0.5)
        self.situation.add_action(3, 1)
        self.situation.add_action(6, 2.4)
        self.situation.add_action(3, 8)

        decision = self.startegy.get_decision(situation=self.situation)

        self.assertEqual(decision.decision, Decision.FOLD)
Esempio n. 9
0
    def test_should_recognize_straight_on_board(self):
        self.situation.Board.append(Card(figure=Figure.Queen,color=Color.Spade))
        self.situation.Board.append(Card(figure=Figure.Jack,color=Color.Heart))
        self.situation.Board.append(Card(figure=Figure.King,color=Color.Diamond))
        self.situation.Board.append(Card(figure=Figure.Ten,color=Color.Spade))
        self.situation.Board.append(Card(figure=Figure.Nine,color=Color.Heart))

        self.situation.Hand.append(Card(figure=Figure.Seven,color=Color.Spade))
        self.situation.Hand.append(Card(figure=Figure.Eight,color=Color.Spade))

        hand = self.evaluator.has_straight(situation=self.situation)
        self.assertEqual(hand, HandType.StraightOnBoard)
Esempio n. 10
0
    def test_should_recognize_straight_flush(self):
        self.situation.Board.append(Card(figure=Figure.Ace,color=Color.Diamond))
        self.situation.Board.append(Card(figure=Figure.King,color=Color.Diamond))
        self.situation.Board.append(Card(figure=Figure.Queen,color=Color.Diamond))
        self.situation.Board.append(Card(figure=Figure.Jack,color=Color.Diamond))
        self.situation.Board.append(Card(figure=Figure.Six,color=Color.Club))

        self.situation.Hand.append(Card(figure=Figure.Ten,color=Color.Diamond))
        self.situation.Hand.append(Card(figure=Figure.Queen,color=Color.Spade))

        hand = self.evaluator.has_straight_flush(situation=self.situation)
        self.assertEqual(hand, HandType.StraightFlush)
Esempio n. 11
0
    def test_should_recognize_quads_on_board(self):
        self.situation.Board.append(Card(figure=Figure.Six,color=Color.Diamond))
        self.situation.Board.append(Card(figure=Figure.Six,color=Color.Heart))
        self.situation.Board.append(Card(figure=Figure.Queen,color=Color.Diamond))
        self.situation.Board.append(Card(figure=Figure.Six,color=Color.Spade))
        self.situation.Board.append(Card(figure=Figure.Six,color=Color.Club))

        self.situation.Hand.append(Card(figure=Figure.Queen,color=Color.Heart))
        self.situation.Hand.append(Card(figure=Figure.Queen,color=Color.Spade))

        hand = self.evaluator.has_4_of_the_kind(situation=self.situation)
        self.assertEqual(hand, HandType.FourOfTheKindOnBoard)
Esempio n. 12
0
    def test_should_recognize_fullhouse_on_board(self):
        self.situation.Board.append(Card(figure=Figure.Queen,color=Color.Spade))
        self.situation.Board.append(Card(figure=Figure.Six,color=Color.Heart))
        self.situation.Board.append(Card(figure=Figure.Queen,color=Color.Diamond))
        self.situation.Board.append(Card(figure=Figure.Six,color=Color.Spade))
        self.situation.Board.append(Card(figure=Figure.Six,color=Color.Club))

        self.situation.Hand.append(Card(figure=Figure.Seven,color=Color.Heart))
        self.situation.Hand.append(Card(figure=Figure.Seven,color=Color.Spade))

        hand = self.evaluator.has_fullhouse(situation=self.situation)
        self.assertEqual(hand, HandType.FullHouseOnBoard)
Esempio n. 13
0
    def test_should_recognize_straight_with_ace_on_bottom(self):
        self.situation.Board.append(Card(figure=Figure.Two,color=Color.Spade))
        self.situation.Board.append(Card(figure=Figure.Three,color=Color.Heart))
        self.situation.Board.append(Card(figure=Figure.Four,color=Color.Diamond))
        self.situation.Board.append(Card(figure=Figure.Ten,color=Color.Spade))
        self.situation.Board.append(Card(figure=Figure.Nine,color=Color.Heart))

        self.situation.Hand.append(Card(figure=Figure.Five,color=Color.Spade))
        self.situation.Hand.append(Card(figure=Figure.Ace,color=Color.Spade))

        hand = self.evaluator.has_straight(situation=self.situation)
        self.assertEqual(hand, HandType.Straight_from_bottom)
Esempio n. 14
0
    def test_should_not_recognize_flush_when_cards_from_hand_not_used(self):
        self.situation.Board.append(Card(figure=Figure.Queen,color=Color.Spade))
        self.situation.Board.append(Card(figure=Figure.Nine,color=Color.Spade))
        self.situation.Board.append(Card(figure=Figure.Ten,color=Color.Spade))
        self.situation.Board.append(Card(figure=Figure.Ace,color=Color.Spade))
        self.situation.Board.append(Card(figure=Figure.Eight,color=Color.Spade))

        self.situation.Hand.append(Card(figure=Figure.Seven,color=Color.Spade))
        self.situation.Hand.append(Card(figure=Figure.Six,color=Color.Spade))

        hand = self.evaluator.has_flush(situation=self.situation)
        self.assertEqual(hand, None)
Esempio n. 15
0
def recognize_cards_in_picture(model, picture):

    import keras.backend.tensorflow_backend as tb
    tb._SYMBOLIC_SCOPE.value = True

    img_rows = 30
    img_cols = 30
    sample = rgb2gray(picture).reshape(1, img_rows, img_cols, 1)
    result = model.predict(sample)
    y_class = result.argmax()
    if y_class < 13 and result[0][y_class] > 0.98:  #   classes 0-12 are cards
        color = get_card_color(picture)
        return Card(color=color, figure=convert_numer_to_class(y_class))
    return None
Esempio n. 16
0
    def test_should_recognize_four_card_flush_not_nuts(self):
        self.situation.Board.append(Card(figure=Figure.Queen,color=Color.Spade))
        self.situation.Board.append(Card(figure=Figure.Three,color=Color.Spade))
        self.situation.Board.append(Card(figure=Figure.Six,color=Color.Spade))
        self.situation.Board.append(Card(figure=Figure.Ten,color=Color.Spade))

        self.situation.Hand.append(Card(figure=Figure.King,color=Color.Spade))
        self.situation.Hand.append(Card(figure=Figure.Two,color=Color.Spade))

        hand = self.evaluator.has_flush(situation=self.situation)
        self.assertEqual(hand, HandType.NotNutsFlushWithFourBoardCards)
Esempio n. 17
0
    def test_should_recognize_trips(self):
        self.situation.Board.append(Card(figure=Figure.Queen,color=Color.Spade))
        self.situation.Board.append(Card(figure=Figure.Queen,color=Color.Heart))
        self.situation.Board.append(Card(figure=Figure.King,color=Color.Diamond))
        self.situation.Board.append(Card(figure=Figure.Ten,color=Color.Club))

        self.situation.Hand.append(Card(figure=Figure.Queen,color=Color.Diamond))
        self.situation.Hand.append(Card(figure=Figure.Ten,color=Color.Heart))

        hand = self.evaluator.has_3_of_the_kind(situation=self.situation)
        self.assertEqual(hand, HandType.Trips)
Esempio n. 18
0
    def test_should_recognize_flush(self):
        self.situation.Board.append(Card(figure=Figure.Queen,color=Color.Spade))
        self.situation.Board.append(Card(figure=Figure.Three,color=Color.Spade))
        self.situation.Board.append(Card(figure=Figure.King,color=Color.Diamond))
        self.situation.Board.append(Card(figure=Figure.Ten,color=Color.Spade))

        self.situation.Hand.append(Card(figure=Figure.King,color=Color.Spade))
        self.situation.Hand.append(Card(figure=Figure.Two,color=Color.Spade))

        hand = self.evaluator.has_flush(situation=self.situation)
        self.assertEqual(hand, HandType.Flush)
Esempio n. 19
0
    def test_should_recognize_two_pairs_without_top(self):

        self.situation.Board.append(Card(figure=Figure.Queen,color=Color.Spade))
        self.situation.Board.append(Card(figure=Figure.Three,color=Color.Heart))
        self.situation.Board.append(Card(figure=Figure.King,color=Color.Diamond))
        self.situation.Board.append(Card(figure=Figure.Ten,color=Color.Club))

        self.situation.Hand.append(Card(figure=Figure.Ten,color=Color.Diamond))
        self.situation.Hand.append(Card(figure=Figure.Queen,color=Color.Club))

        hand = self.evaluator.has_two_pairs(situation=self.situation)
        self.assertEqual(hand, HandType.TwoPairsWithoutTop)
Esempio n. 20
0
    def test_should_call_river_with_tp_when_only_bet_on_river(self):

        hand = list()
        hand.append(Card(figure=Figure.Ace, color=Color.Spade))
        hand.append(Card(figure=Figure.Queen, color=Color.Spade))
        self.situation.set_hand(hand)

        self.situation.ButtonPosition = 1
        self.situation.add_action(2, 0.5)
        self.situation.add_action(3, 1)
        self.situation.add_action(6, 2.4)

        board = list()
        board.append(Card(figure=Figure.King, color=Color.Heart))
        board.append(Card(figure=Figure.Three, color=Color.Diamond))
        board.append(Card(figure=Figure.Seven, color=Color.Club))

        self.situation.set_board(board)

        # self.situation.add_action(3, 3)

        turn = list()
        turn.append(Card(figure=Figure.King, color=Color.Heart))
        turn.append(Card(figure=Figure.Three, color=Color.Diamond))
        turn.append(Card(figure=Figure.Seven, color=Color.Club))
        turn.append(Card(figure=Figure.Ace, color=Color.Spade))

        self.situation.set_board(turn)

        # self.situation.add_action(3, 7)

        river = list()
        river.append(Card(figure=Figure.King, color=Color.Heart))
        river.append(Card(figure=Figure.Three, color=Color.Diamond))
        river.append(Card(figure=Figure.Seven, color=Color.Club))
        river.append(Card(figure=Figure.Ace, color=Color.Heart))
        river.append(Card(figure=Figure.Four, color=Color.Heart))

        self.situation.set_board(river)

        self.situation.add_action(3, 7)

        decision = self.startegy.get_decision(situation=self.situation)

        self.assertEqual(decision.decision, Decision.CALL)