本文整理汇总了Python中hand.Hand.getSoftCount方法的典型用法代码示例。如果您正苦于以下问题:Python Hand.getSoftCount方法的具体用法?Python Hand.getSoftCount怎么用?Python Hand.getSoftCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hand.Hand
的用法示例。
在下文中一共展示了Hand.getSoftCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getReward
# 需要导入模块: from hand import Hand [as 别名]
# 或者: from hand.Hand import getSoftCount [as 别名]
def getReward(self, state, action, transitionState):
isDone, isFirst, isDoubleDown, hasAce, hardCount, dealerSoftCount = transitionState
multiplier = 2 if isDoubleDown else 1
if hardCount > 21:
return -2 * multiplier
softCount = hardCount + 10 if hasAce and hardCount <= 11 else hardCount
if isDone:
if isFirst and softCount == 21:
return multiplier
# Simulate the dealer's actions
dealerAgent = DealerAgent()
dealerCardValue = dealerSoftCount - 1 if dealerSoftCount != 11 else 0
card = Card(0, dealerCardValue)
dealerHand = Hand(1)
dealerHand.addCard(card)
deck = Deck(1, 4, 13)
dealerHand.addCard(deck.take())
while dealerAgent.getNextAction(None, dealerHand) == Actions.HIT:
dealerHand.addCard(deck.take())
return (
multiplier
if softCount > dealerHand.getSoftCount()
else (0 if softCount == dealerHand.getSoftCount() else -multiplier)
)
else:
return 0
示例2: test_emptyHandSoftCount
# 需要导入模块: from hand import Hand [as 别名]
# 或者: from hand.Hand import getSoftCount [as 别名]
def test_emptyHandSoftCount(self):
hand = Hand(1)
self.assertEqual(0, hand.getSoftCount(), "soft count wasn't 0 for empty deck")