Ejemplo n.º 1
0
 def test_gin_rummy_dealer(self):
     dealer = GinRummyDealer(np.random.RandomState())
     current_deck = utils.get_deck()
     deck_card_ids = [utils.get_card_id(card) for card in current_deck]
     self.assertEqual(deck_card_ids, list(range(52)))
     # Deal 10 cards.
     player = GinRummyPlayer(player_id=0, np_random=np.random.RandomState())
     dealer.deal_cards(player=player, num=10)
     self.assertEqual(len(dealer.shuffled_deck), 52)
     self.assertEqual(len(dealer.stock_pile), 42)
     self.assertEqual(len(current_deck), 52)
     self.assertEqual(len(utils.get_deck()), 52)
     # Pop top_card from current_deck.
     top_card = current_deck.pop(-1)
     self.assertEqual(str(top_card), "KC")
     self.assertEqual(len(current_deck), 51)
     self.assertEqual(len(utils.get_deck()), 52)
Ejemplo n.º 2
0
 def test_decode_cards(self):
     deck = utils.get_deck()
     encoded_cards = utils.encode_cards(deck)
     decoded_cards = utils.decode_cards(encoded_cards)
     for i in range(52):
         card = deck[i]
         decoded_card = decoded_cards[i]
         self.assertEqual(card, decoded_card)