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


Python Deck.calcProbability方法代码示例

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


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

示例1: Deck

# 需要导入模块: from Deck import Deck [as 别名]
# 或者: from Deck.Deck import calcProbability [as 别名]
if __name__ == '__main__':
    deck = Deck()
    # deck.displayDeck()
    # we are dealt 7 cards, lets try calculating
    # the probabilities of 1-7 cards being same suit
    for x in xrange(1, 8):
        # simple probab, assuming replacement,
        # no joker, and 52 card deck, forget this.
        y = x
        P = 1
        # complex probability, a la compound interest
        # no replacement, real life scenario
        while y > 0:
            y = y - 1
            # print 13 - y, 52.0 - y
            P = P * deck.calcProbability(deck.cardsInASuit - y, deck.totalCards - y)
        print "Getting", x, "cards of same suit", P

    # add a joker
    jokerDeck = Deck(("Hearts", "Clubs", "Diamonds", "Spades"),
                    [x for x in xrange(2, 11, 1)],
                    ("Ace", "King", "Queen", "Jack"),
                     53.0, True)
    # for ppt, value in vars(jokerDeck).iteritems():
    #     print ppt, value
    for x in xrange(1, 8):
        # simple probab, assuming replacement,
        # no joker, and 52 card deck, forget this.
        y = x
        P = 1
        # complex probability, a la compound interest
开发者ID:TDA,项目名称:CardGameProbabilities,代码行数:33,代码来源:HighFlush.py


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