Esempio n. 1
0
def combat_power(hole, board, deal_num, max_time=1):
    t_start = time.time()
    count = 0
    rank_list = []
    rank_list_fake = []
    while True:
        board_ext = safe_draw(deal_num, hole + board)
        hole_fake = safe_draw(2, hole + board + board_ext)
        merge = board + board_ext

        rank = evaluator.evaluate(merge, hole)
        rank_fake = evaluator.evaluate(merge, hole_fake)

        rank_list.append(rank)
        rank_list_fake.append(rank_fake)

        count += 1
        t_end = time.time()
        if t_end - t_start > max_time:
            break

    sum_rank = 0
    sum_rank_fake = 0

    for i in rank_list:
        sum_rank += i
    for i in rank_list_fake:
        sum_rank_fake += i

    # print info
    my_pretty_cards = ''
    if len(hole) == 0:
        if len(board) != 0:
            my_pretty_cards += ' [ ? ? ]  [ ? ? ] '
    else:
        for i in hole:
            my_pretty_cards += Card.int_to_pretty_str(i)
    for i in board:
        my_pretty_cards += Card.int_to_pretty_str(i)
    for i in range(deal_num):
        if len(hole) == 0 and len(board) > 0 and i < 2:
            continue
        my_pretty_cards += ' [ ? ? ] '
    print my_pretty_cards + ', ' + str(sum_rank / count) + ', ' + str(
        int(numpy.std(numpy.array(rank_list), axis=0))) + ', ' + str(sum_rank_fake / count) + ', ' + str(
        int(numpy.std(numpy.array(rank_list_fake), axis=0)))  # +', '+str(count)
Esempio n. 2
0
 def query_state(self):
     ret = 'pies = %d, cards = ' % self.pies
     for c in self.cards:
         ret += Card.int_to_pretty_str(c)
     if self.game is None:
         ret += ', currently not in-game'
     else:
         ret += ', ' + self.game.query_state()
     return ret
Esempio n. 3
0
 def reveal(self):
     msg = "%s's cards are" % self.tag
     for c in self.cards:
         msg += ' ' + Card.int_to_pretty_str(c)
     self.cards = []
     if self.game is not None:
         self.game.message_players(msg)
     else:
         return 'Not in game'
     return 'Revealed and discarded hand'
Esempio n. 4
0
def hand_to_str(hand, mode):
    output = " "
    for i in range(len(hand)):
        c = hand[i]
        if c == -1:
            if i != len(hand) - 1:
                output += '[  ],'
            else:
                output += '[  ] '
            continue
        if i != len(hand) - 1:
            if mode == "machine":
                output += '[' + str(Card.int_to_str(c)) + '],'
            else:
                output += str(Card.int_to_pretty_str(c)) + ','
        else:
            if mode == "machine":
                output += '[' + str(Card.int_to_str(c)) + '] '
            else:
                output += str(Card.int_to_pretty_str(c)) + ' '
    return output
Esempio n. 5
0
 def get_card_pretty(self, card):
     return Card.int_to_pretty_str(card)
Esempio n. 6
0
def card_to_str(card):
    if card == -1:
        return ''
    return Card.int_to_pretty_str(card)
Esempio n. 7
0
 def query_state(self):
     info = '%s visible cards: ' % self.name
     for c in self.visible_cards:
         info += Card.int_to_pretty_str(c)
     info += ', potpies: %d' % self.potpies
     return info
Esempio n. 8
0
 def __str__(self):
     return Card.int_to_pretty_str(self.internal)