How to use the rlcard.core.Card function in rlcard

To help you get started, we’ve selected a few rlcard examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github datamllab / rlcard / tests / utils / test_utils.py View on Github external
def test_is_single(self):
        self.assertTrue(is_single([Card('S', 'A')]))
        self.assertFalse(is_single([Card('S', 'A'), Card('BJ', '')]))
github datamllab / rlcard / tests / utils / test_utils.py View on Github external
def test_is_pair(self):
        self.assertTrue(is_pair([Card('S', 'A'), Card('D', 'A')]))
        self.assertFalse(is_pair([Card('BJ', ''), Card('S', 'A'), Card('D', 'A')]))
github datamllab / rlcard / tests / utils / test_utils.py View on Github external
def test_take_out_cards(self):
        cards = init_54_deck()
        remove_cards = [Card('S', 'A'), Card('BJ', '')]
        res = take_out_cards(cards, remove_cards)
        flag = False
        for card in res:
            if card.get_index() == 'SA' or card.get_index == 'BJ':
                flag = True
        self.assertFalse(flag)
        self.assertEqual(len(cards), len(init_54_deck()) - 2)
github datamllab / rlcard / tests / games / test_leducholdem_game.py View on Github external
def test_judge_game(self):
        players = [Player(0), Player(1)]
        players[0].in_chips = 10
        players[1].in_chips = 10

        # Test hand is equal
        players[0].hand = Card('S', 'J')
        players[1].hand = Card('H', 'J')
        public_card = Card('S', 'Q')
        payoffs = Judger.judge_game(players, public_card)
        self.assertEqual(payoffs[0], 0)
        self.assertEqual(payoffs[1], 0)

        # Test one player get a pair
        players[0].hand = Card('S', 'J')
        players[1].hand = Card('S', 'Q')
        public_card = Card('H', 'J')
        payoffs = Judger.judge_game(players, public_card)
        self.assertEqual(payoffs[0], 10.0)
        self.assertEqual(payoffs[1], -10.0)

        # Other cases
        # Test one player get a pair
        players[0].hand = Card('S', 'J')
        players[1].hand = Card('S', 'Q')
        public_card = Card('H', 'K')
        payoffs = Judger.judge_game(players, public_card)
        self.assertEqual(payoffs[0], -10.0)
        self.assertEqual(payoffs[1], 10.0)
github datamllab / rlcard / tests / utils / test_utils.py View on Github external
def test_is_pair(self):
        self.assertTrue(is_pair([Card('S', 'A'), Card('D', 'A')]))
        self.assertFalse(is_pair([Card('BJ', ''), Card('S', 'A'), Card('D', 'A')]))
github datamllab / rlcard / rlcard / utils / utils.py View on Github external
def init_54_deck():
    ''' Initialize a standard deck of 52 cards, BJ and RJ

    Returns:
        (list): Alist of Card object
    '''
    suit_list = ['S', 'H', 'D', 'C']
    rank_list = ['A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K']
    res = [Card(suit, rank) for suit in suit_list for rank in rank_list]
    res.append(Card('BJ', ''))
    res.append(Card('RJ', ''))
    return res
github datamllab / rlcard / rlcard / games / leducholdem / dealer.py View on Github external
def __init__(self):
        ''' Initialize a leducholdem dealer class
        '''
        self.deck = [Card('S', 'J'), Card('H', 'J'), Card('S', 'Q'), Card('H', 'Q'), Card('S', 'K'), Card('H', 'K')]
        self.shuffle()
        self.pot = 0
github datamllab / rlcard / rlcard / utils / utils.py View on Github external
def init_54_deck():
    ''' Initialize a standard deck of 52 cards, BJ and RJ

    Returns:
        (list): Alist of Card object
    '''
    suit_list = ['S', 'H', 'D', 'C']
    rank_list = ['A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K']
    res = [Card(suit, rank) for suit in suit_list for rank in rank_list]
    res.append(Card('BJ', ''))
    res.append(Card('RJ', ''))
    return res