예제 #1
0
def test_has_two_overcards():
    assert has_two_overcards(holecards('Kh Ts'), flop('4c 3h 2d'))
    assert has_two_overcards(holecards('Ac Kc'),
                             flop('Tc Th 5d'))  # Even though pair on board
    assert has_two_overcards(holecards('Qd Qc'),
                             flop('Tc 4h 5d'))  # Even though it's a pair
    assert not has_two_overcards(holecards('Ac 4h'), flop('5c 5h Qd'))
    assert not has_two_overcards(holecards('Kh Ts'), flop('Qd Qc Qs'))
예제 #2
0
def test_five_cards_decorator():
    with pytest.raises(ConflictingCards):
        is_onepair(holecards('Ac Ac'), flop('Tc Th 5d'))

    with pytest.raises(ConflictingCards):
        is_3straight(holecards('Ac Tc'), flop('Tc Th 5d'))

    with pytest.raises(ConflictingCards):
        is_3flush(holecards('Ac 5d'), flop('Tc Th 5d'))

    with pytest.raises(ValueError):
        is_onepair(holecards('Ac'), flop('Tc Th 5d'))
def test_has_2flush():
    assert has_2flush(flop('Ah Th 3c'))
    assert has_2flush(flop('Ah Td 3d'))
    assert has_2flush(flop('Ks Qd 2s'))
    assert not has_2flush(flop('Ah Th 3h'))
    assert not has_2flush(flop('Ah Td 3c'))
    assert not has_2flush(flop('Ks Td Th'))
def test_has_3straight():
    assert has_3straight(flop('Ah 2d 3c'))
    assert has_3straight(flop('Jh Td 9c'))
    assert has_3straight(flop('Ks Qd Js'))
    assert not has_3straight(flop('Ah Td 3c'))
    assert not has_3straight(flop('As Ts 3s'))
    assert not has_3straight(flop('Ts 9s 7c'))
def test_has_gutshot():
    assert has_gutshot(flop('Ts 9s 7c'))
    assert has_gutshot(flop('Ah 2d 4c'))
    assert has_gutshot(flop('Ah 3d 4c'))
    assert not has_gutshot(flop('Ah Td 3c'))
    assert not has_gutshot(flop('As Ts 3s'))
    assert not has_gutshot(flop('Ts 9s 8c'))
def test_has_pair():
    assert has_pair(flop('Ah Ad 3c'))
    assert has_pair(flop('Ah 3d 3c'))
    assert has_pair(flop('Th Td 3c'))
    assert not has_pair(flop('Ah Td 3c'))
    assert not has_pair(flop('As Ts 3s'))
    assert not has_pair(flop('Ks Qd 2s'))
def test_has_threeofakind():
    assert has_threeofakind(flop('Ah Ad Ac'))
    assert has_threeofakind(flop('Th Td Tc'))
    assert has_threeofakind(flop('3h 3d 3c'))
    assert not has_threeofakind(flop('Ah Td 3c'))
    assert not has_threeofakind(flop('As Ts 3s'))
    assert not has_threeofakind(flop('Ks Qd 2s'))
def test_is_monotone():
    assert is_monotone(flop('Ah Th 3h'))
    assert is_monotone(flop('Ac Tc 3c'))
    assert is_monotone(flop('Ks Qs 2s'))
    assert not is_monotone(flop('Ah Td 3c'))
    assert not is_monotone(flop('As Ts 3d'))
    assert not is_monotone(flop('Ks Qd 2s'))
def test_is_rainbow():
    assert is_rainbow(flop('Ah Td 3c'))
    assert is_rainbow(flop('Ah Ks 3c'))
    assert is_rainbow(flop('Ah Td 3s'))
    assert not is_rainbow(flop('Kd 5d 2d'))
    assert not is_rainbow(flop('Kd 8d 6s'))
    assert not is_rainbow(flop('Ks Qh 2s'))
예제 #10
0
def test_is_bluffcandidate():
    assert is_bluffcandidate(holecards('2c 3c'), flop('4c Jh Qd'))
    assert is_bluffcandidate(holecards('9h Th'), flop('3c Jh Qd'))
    assert is_bluffcandidate(holecards('Ac 3c'), flop('2c Jh Qd'))
    assert not is_bluffcandidate(holecards('2c 4h'), flop('Tc Jh Qd'))
    assert not is_bluffcandidate(holecards('2c Th'), flop('3c Jh Ad'))
    assert not is_bluffcandidate(holecards('Ac 3c'), flop('2c Jh Ad'))  # It's a pair
예제 #11
0
def test_isomorph():
    assert len(get_all_canonicals()) == 1755

    assert get_canonical(flop('6s 8d 7c')) == flop('6c 7d 8h')
    assert get_translation_dict(flop('6s 8d 7c')) == {'c': 'd', 'd': 'h', 'h': 's', 's': 'c'}

    assert get_canonical(flop('Qs Qd 4d')) == flop('4c Qc Qd')
    assert get_translation_dict(flop('Qs Qd 4d')) == {'c': 'h', 'd': 'c', 'h': 's', 's': 'd'}
예제 #12
0
def test_get_bluffcandidates():
    assert set(get_bluffcandidates(flop('2s 4s Ac'))) == {
        holecards('Kc Qc'),
        holecards('6c 5c'),
    }

    assert set(get_bluffcandidates(flop('6s 6d Kc'))) == {
        holecards('Qd Jd'),
        holecards('Qc Jc'),
        holecards('Qs Js'),
        holecards('8s 7s'),
        holecards('8c 7c'),
        holecards('8d 7d'),
        holecards('5d 4d'),
        holecards('5c 4c'),
        holecards('5s 4s'),
        holecards('Ad Qd'),
        holecards('Ac Qc'),
        holecards('As Qs'),
    }

    # TODO: This hand exists in the bluff candidate set, but actually
    # it's an open-ended straight draw which makes it a semi-bluff.
    assert holecards('6c 5c') in set(get_bluffcandidates(flop('4s 7s Ac')))
예제 #13
0
def test_is_onepair():
    assert is_onepair(holecards('2c 4h'),
                      flop('Tc Th 5d'),
                      exclude_board=False)
    assert is_onepair(holecards('2c Th'),
                      flop('Tc 4h 5d'),
                      exclude_board=False)
    assert is_onepair(holecards('2c 2h'), flop('Ac Kh Qd'), exclude_board=True)
    assert is_onepair(holecards('2c Qh'), flop('Ac Kh Qd'), exclude_board=True)
    assert not is_onepair(
        holecards('2c 4h'), flop('5c Jh Qd'), exclude_board=False)
    assert not is_onepair(
        holecards('4c Ah'), flop('5c 5h Qd'), exclude_board=True)
예제 #14
0
def test_is_3flush():
    assert is_3flush(holecards('2c 4h'),
                     flop('Td Jd Qd'),
                     required_holecards=0)
    assert is_3flush(holecards('2c Th'),
                     flop('3h Jh Qd'),
                     required_holecards=1)
    assert is_3flush(holecards('2d 4d'),
                     flop('5d Jh Qh'),
                     required_holecards=2)
    assert not is_3flush(
        holecards('2c 4c'), flop('Ts Jh Qd'), required_holecards=0)
    assert not is_3flush(
        holecards('2c Th'), flop('3c Jh Qd'), required_holecards=1)
    assert not is_3flush(
        holecards('2c 4c'), flop('5s Jh Qd'), required_holecards=2)
예제 #15
0
def test_is_3straight():
    assert is_3straight(holecards('2c 4h'),
                        flop('Tc Jh Qd'),
                        required_holecards=0)
    assert is_3straight(holecards('2c Th'),
                        flop('3c Jh Qd'),
                        required_holecards=1)
    assert is_3straight(holecards('2c 3h'),
                        flop('4c Jh Qd'),
                        required_holecards=2)
    assert not is_3straight(
        holecards('2c 4h'), flop('5c Jh Qd'), required_holecards=0)
    assert not is_3straight(
        holecards('2c 4h'), flop('5c Jh Qd'), required_holecards=1)
    assert not is_3straight(
        holecards('2c 4c'), flop('5c Jh Ad'), required_holecards=2)
예제 #16
0
def test_isomorph():
    assert len(get_all_canonicals()) == 1755

    assert get_canonical(flop('6s 8d 7c')) == flop('6c 7d 8h')
    assert get_translation_dict(flop('6s 8d 7c')) == {
        'c': 'd',
        'd': 'h',
        'h': 's',
        's': 'c'
    }

    assert get_canonical(flop('Qs Qd 4d')) == flop('4c Qc Qd')
    assert get_translation_dict(flop('Qs Qd 4d')) == {
        'c': 'h',
        'd': 'c',
        'h': 's',
        's': 'd'
    }