Esempio n. 1
0
def start(cards_on_table, my_cards, enemy_num):
    global card_pool
    card_pool = _card_pool_manager.refresh_card_pool()
    table_cards = len(cards_on_table.split(","))
    if cards_on_table != "":
        card_pool = _card_pool_manager._change_card_pool(cards_on_table, "on_table", card_pool)
    else:
        table_cards = 0
    card_pool = _card_pool_manager._change_card_pool(my_cards, "for_me", card_pool)
    avalible_cards = _card_pool_manager._get_valid_cards(card_pool)
    pad_num = 5 - table_cards
    win_times = 0.0
    draw_game_times = 0.0
    for _ in range(100000):
        sub_card_pool = card_pool.copy()
        comming_card = sample(avalible_cards, pad_num)
        sub_card_pool = (_card_pool_manager._change_card_pool(",".join(comming_card), "on_the_table", sub_card_pool))
        sub_avalible_cards = _card_pool_manager._get_valid_cards(sub_card_pool)
        player_element_list = _tools.trim_cards_for_user(cards_on_table, my_cards, comming_card)
        for index in range(enemy_num):
            player_card = sample(sub_avalible_cards, 2)
            sub_card_pool = _card_pool_manager._change_card_pool(",".join(player_card), "for_p" + str(index + 1), sub_card_pool)
            sub_avalible_cards = _card_pool_manager._get_valid_cards(sub_card_pool)
            player_element_list += _tools.trim_cards_for_user(cards_on_table, ','.join(player_card), comming_card)
        max_combo, combo_name, rank, winner = who_is_daddy.dual(player_element_list)
        if len(winner) > 1:
            draw_game_times += 1.0
        elif 0 in winner:
            win_times += 1.0
        # else:
        #     print(player_element_list)
        #     print(combo_name + "\n")
    print("Your natural trump rate is " + str(win_times / 100000))
    print("draw game rate is " + str(draw_game_times / 100000))
def start():
    global card_pool
    card_pool = _card_pool_manager.refresh_card_pool()
    cards_on_table = input("input the cards on the table\t")
    enemy_number = input("input your enemy numbers\t")
    cal_enemy_hit_rate(cards_on_table, enemy_number)
    return
def start(cards_on_table, player_cards):
    global card_pool
    card_pool = _card_pool_manager.refresh_card_pool()
    table_cards = len(cards_on_table.split(","))
    if cards_on_table != "":
        card_pool = _card_pool_manager._change_card_pool(
            cards_on_table, "on_table", card_pool)
    else:
        table_cards = 0
    index = 1
    for player_card in player_cards:
        card_pool = _card_pool_manager._change_card_pool(
            player_card, "for_p" + str(index), card_pool)
        index += 1
    avalible_cards = _card_pool_manager._get_valid_cards(card_pool)
    pad_num = 5 - table_cards
    win_times_list = [0] * len(player_cards)
    draw_game_times = 0.0
    for _ in range(100000):
        comming_card = sample(avalible_cards, pad_num)
        player_element_list = []
        for player_card in player_cards:
            player_element_list += _tools.trim_cards_for_user(
                cards_on_table, player_card, comming_card)
        max_combo, combo_name, rank, winner = who_is_daddy.dual(
            player_element_list)
        if len(winner) > 1:
            draw_game_times += 1
        else:
            win_times_list[winner[0]] += 1
    winner = 0
    for win_times in win_times_list:
        print("player" + str(winner) + " win rate " + str(win_times / 100000))
        winner += 1
    print("draw game " + str(draw_game_times / 100000))
    return win_times_list, draw_game_times
def start(cards_on_table, enemy_number):
    global card_pool
    card_pool = _card_pool_manager.refresh_card_pool()
    cal_enemy_hit_rate(cards_on_table, enemy_number)
    return
            p_card = sample(avalible_cards, 2)
            card_pool = _card_pool_manager._change_card_pool(",".join(p_card), "for_p1", card_pool)
            the_combo = (cards_on_table).split(",") + p_card
            rank, combo_name = _combo_score.calculate_rank_power(the_combo)
            if rank > 2: #enemy hit level
                hit += 1
                #print(the_combo, combo_name)
                break
    print(hit / 100000, enemy_number)
    print(my_combo)
    return

def start():
    global card_pool
    card_pool = _card_pool_manager.refresh_card_pool()
    cards_on_table = input("input the cards on the table\t")
    enemy_number = input("input your enemy numbers\t")
    cal_enemy_hit_rate(cards_on_table, enemy_number)
    return

def start(cards_on_table, enemy_number):
    global card_pool
    card_pool = _card_pool_manager.refresh_card_pool()
    cal_enemy_hit_rate(cards_on_table, enemy_number)
    return

if __name__ == "__main__":
    enemy_number = 1
    card_pool = _card_pool_manager.refresh_card_pool()
    cards_on_table = "ht_2,cl_3,dm_5"
    start(cards_on_table, enemy_number)
Esempio n. 6
0
def start(cards_on_table, p1_cards, p2_cards):
    global card_pool
    card_pool = _card_pool_manager.refresh_card_pool()
    table_cards = len(cards_on_table.split(","))
    if cards_on_table != "":
        card_pool = _card_pool_manager._change_card_pool(
            cards_on_table, "on_table", card_pool)
    else:
        table_cards = 0
    card_pool = _card_pool_manager._change_card_pool(p1_cards, "for_p1",
                                                     card_pool)
    card_pool = _card_pool_manager._change_card_pool(p2_cards, "for_p2",
                                                     card_pool)
    avalible_cards = _card_pool_manager._get_valid_cards(card_pool)
    pad_num = 5 - table_cards
    p1_win = 0.0
    p2_win = 0.0
    draw_game_times = 0.0
    for _ in range(100000):
        p1_win_times = 0.0
        p2_win_times = 0.0
        sub_card_pool = card_pool.copy()
        comming_card = sample(avalible_cards, pad_num)
        sub_card_pool = (_card_pool_manager._change_card_pool(
            ",".join(comming_card), "on_the_table", sub_card_pool))
        sub_avalible_cards = _card_pool_manager._get_valid_cards(sub_card_pool)
        p1_element_list = _tools.trim_cards_for_user(cards_on_table, p1_cards,
                                                     comming_card)
        p2_element_list = _tools.trim_cards_for_user(cards_on_table, p2_cards,
                                                     comming_card)
        player_element_list_r1 = p1_element_list + p2_element_list
        max_combo, combo_name, rank, winner = who_is_daddy.dual(
            player_element_list_r1)
        if 0 in winner:
            p1_win_times += 1.0
        if 1 in winner:
            p2_win_times += 1.0
        comming_card = sample(sub_avalible_cards, pad_num)
        p1_element_list = _tools.trim_cards_for_user(cards_on_table, p1_cards,
                                                     comming_card)
        p2_element_list = _tools.trim_cards_for_user(cards_on_table, p2_cards,
                                                     comming_card)
        player_element_list_r2 = p1_element_list + p2_element_list
        max_combo, combo_name, rank, winner = who_is_daddy.dual(
            player_element_list_r2)
        if 0 in winner:
            p1_win_times += 1.0
        if 1 in winner:
            p2_win_times += 1.0
        if p1_win_times > p2_win_times:
            p1_win += 1
        elif p2_win_times > p1_win_times:
            p2_win += 1
        else:
            draw_game_times += 1
    print("p1 --> twice all in --> no return --> win rate " +
          str(p1_win / 100000))
    print("p2 --> twice all in --> no return --> win rate " +
          str(p2_win / 100000))
    print("draw game rate is " + str(draw_game_times / 100000))
    return p1_win / 100000, p2_win / 100000, draw_game_times / 100000