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


Python hand.Hand类代码示例

本文整理汇总了Python中hand.Hand的典型用法代码示例。如果您正苦于以下问题:Python Hand类的具体用法?Python Hand怎么用?Python Hand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createFourCard20PointHand

 def createFourCard20PointHand(self):
     hand = Hand(1)
     hand.addCard(Card(1, 1))
     hand.addCard(Card(1, 2))
     hand.addCard(Card(1, 3))
     hand.addCard(Card(1, 4))
     return hand
开发者ID:melonhead901,项目名称:vegas,代码行数:7,代码来源:hand_test.py

示例2: __init__

 def __init__(self,name,tyyppi):
     self.__name=name
     self.__cottages=0
     self.__points=0
     self.__hand = Hand()
     self.__type = tyyppi
     self.__stack = Hand()
开发者ID:severi,项目名称:Casino,代码行数:7,代码来源:player.py

示例3: test_find_squarebomb

    def test_find_squarebomb(self):
        cards = 'Phoenix, 2_Pa, 3_Pa, 4_Pa, 5_Pa, 5_Sw, 5_Ja, 5_St'
        hand = Hand(cards_string=cards)

        combination = hand.find_lowest_combination(4, 'SQUAREBOMB')
        print(combination)
        self.assertIsNotNone(combination)
开发者ID:emmanuelameisen,项目名称:ticher,代码行数:7,代码来源:test_hand.py

示例4: test_find_low_pair_with_phoenix

    def test_find_low_pair_with_phoenix(self):
        cards = 'Phoenix, 2_Pa, 3_Pa, 4_Pa, 5_Pa'
        hand = Hand(cards_string=cards)

        combination = hand.find_lowest_combination(1, 'PAIR')
        print(combination)
        self.assertTrue(combination.phoenix_flag)
开发者ID:emmanuelameisen,项目名称:ticher,代码行数:7,代码来源:test_hand.py

示例5: Player

class Player():
    def __init__(self, name, bankroll):
        self.hand = Hand()
        self.bankroll = bankroll
        self.name = name
        self.bet = 0

    def play_hand(self, dealer_card):
        while True:
            recommend = basic_strategy(self.hand.value(), dealer_card.value(), self.hand.is_soft())

            if len(self.hand.cards) == 2:
                move = raw_input("%s: %s - hit/stand/double? (we recommend %s) " % (self.name, self.hand, recommend)).lower()
            else:
                # for simplicity. This is not true for soft 18.
                if recommend == 'double':
                    recommend = 'hit'

                move = raw_input("%s: %s - hit/stand? (we recommend %s) " % (self.name, self.hand, recommend)).lower()

            if move.startswith('h'):
                return 'hit'
            elif move.startswith('s'):
                return 'stand'
            elif move.startswith('d'):
                return 'double'

            print "Invalid move"

    def __str__(self):
        return '(%s, $%s)' % (self.name, self.bankroll)

    def is_bust(self):
        return self.hand.value() > 21
开发者ID:v,项目名称:blackjack,代码行数:34,代码来源:player.py

示例6: test_find_trio

    def test_find_trio(self):
        cards = 'Phoenix, 2_Pa, 3_Pa, 4_Pa, 5_Pa, 5_Sw, 5_Ja, 5_St'
        hand = Hand(cards_string=cards)

        combination = hand.find_lowest_combination(4, 'TRIO')
        print(combination)
        self.assertIsNotNone(combination)
开发者ID:emmanuelameisen,项目名称:ticher,代码行数:7,代码来源:test_hand.py

示例7: startMatch

 def startMatch(self,cards,withholecard=True):
     '''Deals initial cards to the dealer'''
     if withholecard:
         self._hand=Hand(cards[0])
         self._holecard=cards[1]
     else:
         self._hand=Hand(cards)
开发者ID:JeromeLefebvre,项目名称:CardsForTheWorkingMathematician,代码行数:7,代码来源:player.py

示例8: test_steps_with_phoenix_not_need

    def test_steps_with_phoenix_not_need(self):
        cards = '5_Sw, 5_Pa, 6_Sw, Phoenix, 7_Sw, 7_Pa, 8_Sw, 8_Pa'
        hand = Hand(cards_string=cards)

        combination = hand.find_lowest_combination(2, 'STEPS')
        print(combination)
        self.assertEqual(combination.type, 'STEPS')
开发者ID:emmanuelameisen,项目名称:ticher,代码行数:7,代码来源:test_hand.py

示例9: test_find_low_pair

    def test_find_low_pair(self):
        cards = 'Phoenix, 2_Pa, 3_Pa, 4_Pa, 5_Pa, 5_Sw, 5_Ja, 5_St'
        hand = Hand(cards_string=cards)

        combination = hand.find_lowest_combination(1, 'PAIR')
        print(combination)
        self.assertFalse(combination.phoenix_flag)
开发者ID:emmanuelameisen,项目名称:ticher,代码行数:7,代码来源:test_hand.py

示例10: test_find_straight_with_phoenix

    def test_find_straight_with_phoenix(self):
        cards = '2_Sw, 3_Pa, Phoenix, 5_Pa, 6_Pa'
        hand = Hand(cards_string=cards)

        combination = hand.find_lowest_combination(5, 'STRAIGHT')
        print(combination)
        self.assertIsNotNone(combination)
开发者ID:emmanuelameisen,项目名称:ticher,代码行数:7,代码来源:test_hand.py

示例11: test_find_long_steps_with_phoenix

    def test_find_long_steps_with_phoenix(self):
        cards = '5_Sw, 5_Pa, 6_Sw, 6_Pa, 7_Sw, Phoenix'
        hand = Hand(cards_string=cards)

        combination = hand.find_lowest_combination(2, 'STEPS', length=3)
        print(combination)
        self.assertEqual(combination.type, 'STEPS')
开发者ID:emmanuelameisen,项目名称:ticher,代码行数:7,代码来源:test_hand.py

示例12: test_find_steps

    def test_find_steps(self):
        cards = '2_Sw, 2_Pa, 3_Sw,3_Pa'
        hand = Hand(cards_string=cards)

        combination = hand.find_lowest_combination(2, 'STEPS')
        print(combination)
        self.assertEqual(combination.type, 'STEPS')
开发者ID:emmanuelameisen,项目名称:ticher,代码行数:7,代码来源:test_hand.py

示例13: test_find_straight

    def test_find_straight(self):
        cards = '2_Sw, 3_Pa, 4_Pa, 5_Pa, 6_Pa, 5_Ja, 5_St'
        hand = Hand(cards_string=cards)

        combination = hand.find_lowest_combination(5, 'STRAIGHT')
        print(combination)
        self.assertIsNotNone(combination)
开发者ID:emmanuelameisen,项目名称:ticher,代码行数:7,代码来源:test_hand.py

示例14: testIsCalling

 def testIsCalling(self):
     """test calling hands"""
     for idx, ruleset in enumerate(RULESETS):
         for content, completingTiles in [('s1s1s1s1 b5b6b7 RB8B8C2C2C6C7C8 mwe Lb5', ('b8c2', '')),
                     ('s1s1s1s1 b5b6b7 RB7B8C2C2C6C7C8 mwe Lb5', ('b6b9', '')),
                     ('RS2B2C2S4B4C4S6B6C6S7B7C7S8 mee LS8', ('', 'b8c8')),
                     ('RS2B2C2S4B4C4S6B6C6B7C7S8C8 mee LC7', ('', 'b8s7')),
                     ('RS2B2S3B3S4B4S5B5S6B6S7B7S9 Mwn LB7', ('s9', 'b9')),
                     ('RDbDgDrWeWsWwWnWnB1B9C1S1S9 mwe LWn', ('c9', 'c9')),
                     ('RDbDgDrWsWwWnWnB1B9C1S1S9C9 mwe LDg', ('we', 'we')),
                     ('RC4C4C5C6C5C7C8 dgdgdg s6s6s6 mnn', ('c4c5', 'c4c5')),
                     ('RS1S4C5C6C5C7C8 dgdgdg s6s6s6 mnn', ('', '')),
                     ('RB1B2B3B4B5B5B6B6B7B7B8B8B8 mwe LB1', ('b1b3b4b6b7b9', '')),
                     ('RDbDgDrWsWwWeWnB1B9C1S1S9C9 mwe LWe',
                         ('b1b9c1c9dbdgdrs1s9wewnwsww', 'b1b9c1c9dbdgdrs1s9wewnwsww'))]:
             hand = Hand(ruleset, content)
             completedHands = hand.callingHands(99)
             testSays = ''.join(sorted(set(x.lastTile for x in completedHands))).lower()
             if idx >= len(completingTiles):
                 idx %= len(RULESETS) / 2
             completingTiles = completingTiles[idx]
             self.assert_(testSays == completingTiles,
                 '%s: %s is completed by %s but test says %s' % (
                 ruleset.name, content, completingTiles, testSays))
         for content in ['s1s1s1s1 b5b6b7 B1B8C2C2C6C7C8 mwe Lb5',
                         'Dg Dg Dr We Ws Ww Wn Wn B1B9C1S1S9 mwe LWe',
                         'Db Dg Dr We Ws Ww Wn B7 B1B9C1S1S9 mwe LWe']:
             hand = Hand(ruleset, content)
             self.assert_(not hand.callingHands(), content)
开发者ID:jsj2008,项目名称:kdegames,代码行数:29,代码来源:scoringtest.py

示例15: test_find_straight_with_card_discard

    def test_find_straight_with_card_discard(self):
        cards = ' 4_Sw, 6_Pa, 7_Sw, 8_Pa, 9_Sw, 10_Pa'
        hand = Hand(cards_string=cards)

        combination = hand.find_lowest_combination(3, 'STRAIGHT')
        print(combination)
        self.assertIsNotNone(combination)
开发者ID:emmanuelameisen,项目名称:ticher,代码行数:7,代码来源:test_hand.py


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