当前位置: 首页>>代码示例>>Python>>正文


Python Card.new方法代码示例

本文整理汇总了Python中card.Card.new方法的典型用法代码示例。如果您正苦于以下问题:Python Card.new方法的具体用法?Python Card.new怎么用?Python Card.new使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在card.Card的用法示例。


在下文中一共展示了Card.new方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _initiate_opening_hands

# 需要导入模块: from card import Card [as 别名]
# 或者: from card.Card import new [as 别名]
 def _initiate_opening_hands(self):
     for rank in Card.STR_RANKS:
         for suit,val in Card.CHAR_SUIT_TO_INT_SUIT.items():
             John._FULL_DECK.append(Card.new(rank + suit))
     for combo in itertools.combinations(John._FULL_DECK, 2):
         John._ALL_HOLE_CARDS.append(combo)
         cards = Card.int_to_str(combo[0]) + Card.int_to_str(combo[1])
         c1_rank, c1_suit, c2_rank, c2_suit = cards
         # Check for pairs
         if c1_rank == c2_rank:
             for rank in Card.STR_RANKS:
                 if c1_rank == rank:
                     if rank not in John._PAIRS:
                         John._PAIRS[rank] = set()
                     John._PAIRS[rank].add(combo)
         else:
             for rank_pair in itertools.combinations(Card.STR_RANKS[::-1], 2):
                 ranks = rank_pair[0] + rank_pair[1]
                 if rank_pair == (c2_rank, c1_rank) or rank_pair == (c1_rank, c2_rank):
                     if c1_suit == c2_suit:  # Suited!
                         if ranks not in John._SUITED:
                             John._SUITED[ranks] = set()
                         John._SUITED[ranks].add(combo)
                         if Card.STR_RANKS.index(rank_pair[0]) == 1 + Card.STR_RANKS.index(rank_pair[1]):
                             if ranks not in John._SUITED_CONNECTORS:
                                 John._SUITED_CONNECTORS[ranks] = set()
                             John._SUITED_CONNECTORS[ranks].add(combo)
                         # DEBUGGING
                         # print(ranks, Card.int_to_str(combo[0]), Card.int_to_str(combo[1]))
                     else:
                         if ranks not in John._UNSUITED:
                             John._UNSUITED[ranks] = set()
                         John._UNSUITED[ranks].add(combo)
开发者ID:simonbw,项目名称:poker-player,代码行数:35,代码来源:john.py

示例2: GetFullDeck

# 需要导入模块: from card import Card [as 别名]
# 或者: from card.Card import new [as 别名]
    def GetFullDeck():
        if Deck._FULL_DECK:
            return list(Deck._FULL_DECK)

        # create the standard 52 card deck
        for rank in Card.STR_RANKS:
            for suit,val in Card.CHAR_SUIT_TO_INT_SUIT.iteritems():
                Deck._FULL_DECK.append(Card.new(rank + suit))

        return list(Deck._FULL_DECK)
开发者ID:KitN,项目名称:deuces,代码行数:12,代码来源:deck.py

示例3: draw_specified

# 需要导入模块: from card import Card [as 别名]
# 或者: from card.Card import new [as 别名]
 def draw_specified(self, string):
     
     card = Card.new(string)
     for i, card_num in enumerate(self.cards):
         if card_num == card.real:
             return self.cards.pop(i)
开发者ID:fcullen,项目名称:deuces,代码行数:8,代码来源:deck.py


注:本文中的card.Card.new方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。