本文整理汇总了Python中deuces.Card.get_rank_int方法的典型用法代码示例。如果您正苦于以下问题:Python Card.get_rank_int方法的具体用法?Python Card.get_rank_int怎么用?Python Card.get_rank_int使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类deuces.Card
的用法示例。
在下文中一共展示了Card.get_rank_int方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cards_to_ranks
# 需要导入模块: from deuces import Card [as 别名]
# 或者: from deuces.Card import get_rank_int [as 别名]
def cards_to_ranks(cards, pad):
rank_dummy = np.zeros(pad)
# Add one to distinguish deuce from missing
cards = sorted([Card.get_rank_int(x) for x in cards])
for i, card in enumerate(cards):
if i >= pad:
continue
rank_dummy[i] = card + 1
rank_dummy_std = (rank_dummy - 8) / 14 # Hacky "standardisation"
return rank_dummy_std
示例2: score_front_royalties
# 需要导入模块: from deuces import Card [as 别名]
# 或者: from deuces.Card import get_rank_int [as 别名]
def score_front_royalties(cards):
if len(cards) != 3:
raise ValueError("Incorrect number of cards!")
ranks = [Card.get_rank_int(x) for x in cards]
ctr = collections.Counter(ranks)
rank, count = ctr.most_common()[0]
if count < 2:
return 0
if count == 2:
return max(0, rank - 3)
if count == 3:
return 10 + rank
示例3: get_lowest_unpairing_card
# 需要导入模块: from deuces import Card [as 别名]
# 或者: from deuces.Card import get_rank_int [as 别名]
def get_lowest_unpairing_card(hand):
"""Add the worst possible card to an incomplete hand. Something
that cannot pair up or make a flush or make a straight."""
existing_ranks = set([Card.get_rank_int(x) for x in hand])
remaining_ranks = list(set(range(12)) - existing_ranks)
selected_rank = remaining_ranks[0]
would_be_hand = hand + [Card.new(Card.STR_RANKS[selected_rank] + 'h')]
if is_straight(would_be_hand):
selected_rank = remaining_ranks[1] # Don't make a straight
selected_rank_str = Card.STR_RANKS[selected_rank]
last_suit = Card.get_suit_int(hand[-1])
last_suit_index = [1, 2, 4, 8].index(last_suit)
selected_suit = [1, 2, 4, 8][(last_suit_index + 1) % 4]
selected_suit_str = Card.INT_SUIT_TO_CHAR_SUIT[selected_suit]
selected_card_str = selected_rank_str + str(selected_suit_str)
return Card.new(selected_card_str)
示例4: Evaluator
# 需要导入模块: from deuces import Card [as 别名]
# 或者: from deuces.Card import get_rank_int [as 别名]
evaluator = Evaluator()
cards = ['Ah', 'Kh', 'Qh', 'Jh', 'Th', '9h', '8h',
'7h', '6h', '5h', '4h', '3h', '2h']
perms = []
for i in xrange(len(cards)):
for j in xrange(i, len(cards)):
for k in xrange(j, len(cards)):
perms.append([Card.new(cards[i]),
Card.new(cards[j]),
Card.new(cards[k])])
front_lookup = {}
for perm in perms:
# Add the two lowest unpairing cards
hand = copy(perm)
hand.append(get_lowest_unpairing_card(hand))
hand.append(get_lowest_unpairing_card(hand))
prime_prod = Card.prime_product_from_hand(perm)
rank = evaluator.evaluate(hand, []) + 1
kicker = Card.get_rank_int(perm[0]) * 0.01 + \
Card.get_rank_int(perm[1]) * 0.0001 + \
Card.get_rank_int(perm[2]) * 0.000001
front_lookup[prime_prod] = rank - kicker
with open('res/front_lookup.p', 'wb') as f:
pickle.dump(front_lookup, f)
示例5: card_to_ranks_binary
# 需要导入模块: from deuces import Card [as 别名]
# 或者: from deuces.Card import get_rank_int [as 别名]
def card_to_ranks_binary(card):
out = np.zeros(13)
rank = Card.get_rank_int(card)
out[rank] = 1
return out