Exemplo n.º 1
0
def test_card_count():
    deck = Deck()
    deck.set_cards([
        Cards.TEN,
        Cards.QUEEN,
        Cards.KING,
        Cards.TEN,
        Cards.KING,
        Cards.ACE,
        Cards.TEN,
        Cards.QUEEN,
        Cards.QUEEN,
        Cards.JACK,
        Cards.TEN,
    ])
    for i in range(11):
        deck.deal()
    assert deck.get_count() == -11

    cards = [
        Cards.FOUR,
        Cards.FIVE,
        Cards.SIX,
        Cards.SEVEN,
        Cards.EIGHT,
        Cards.TEN,
        Cards.ACE,
    ]
    deck = Deck()
    deck.set_cards(cards)
    for i in range(len(cards)):
        deck.deal()

    assert deck.get_count() == 1
Exemplo n.º 2
0
def test_overall_play():

    wager_amts = [1, 1, 1, 1, 1, 1, 4, 8, 16]
    ranges = [-3, -2, -1, 0, 0, 1, 2, 3]
    betting_policy = (wager_amts, ranges)

    player = Player(
        bankroll=100,
        hard_policy=hard_policy,
        soft_policy=soft_policy,
        split_policy=split_policy,
        betting_policy=betting_policy,
    )
    deck = Deck()
    # first hand player wins and wins 1 count is now 4
    cards_1 = [
        Cards.TEN,
        Cards.THREE,
        Cards.TEN,
        Cards.FOUR,
        Cards.THREE,
        Cards.FOUR,
        Cards.TWO,
        Cards.FOUR,
    ]
    cards_2 = [
        Cards.TEN,
        Cards.THREE,
        Cards.TEN,
        Cards.FOUR,
        Cards.JACK,
        Cards.ACE,
        Cards.TEN,
        Cards.TEN,
    ]
    # second hand player wagers 16 and wins 16*1.5 = 24
    deck.set_cards(cards_2 + cards_1)

    resolve_environment(player, deck, 8, 1, 0.001)
    assert player.get_bankroll() == 101
    assert deck.get_count() == 4
    assert player.calculate_wager(deck.get_true_count()) == 16
    resolve_environment(player, deck, 8, 1, 0.001)
    assert player.get_bankroll() == 125